From ab49a0c6e159550196e3221d6e36631161499fd8 Mon Sep 17 00:00:00 2001 From: "wrenczes@gmail.com" Date: Thu, 4 Nov 2010 04:33:04 +0000 Subject: [PATCH] Added new files to the VS2010 sln; Fixed a bunch of int to float warnings. Minor note to others: if you're writing drawing code, the coordinate system in JGE uses floats, so don't bother with ints for x/y coords & the like. You're forcing the processor to do float to long conversions for nothing. --- projects/mtg/include/DeckMenu.h | 10 +++++----- projects/mtg/include/DeckMenuItem.h | 12 ++++++------ projects/mtg/src/DeckMenu.cpp | 20 ++++++++++---------- projects/mtg/src/DeckMenuItem.cpp | 6 +++--- projects/mtg/template.vcxproj | 3 +++ 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/projects/mtg/include/DeckMenu.h b/projects/mtg/include/DeckMenu.h index b71d2eba8..39eac3ea0 100644 --- a/projects/mtg/include/DeckMenu.h +++ b/projects/mtg/include/DeckMenu.h @@ -13,11 +13,11 @@ class DeckMenu:public JGuiController{ protected: - int mHeight, mWidth, mX, mY; - int titleX, titleY, titleWidth; - int descX, descY, descHeight, descWidth; - int statsX, statsY, statsHeight, statsWidth; - int avatarX, avatarY; + float mHeight, mWidth, mX, mY; + float titleX, titleY, titleWidth; + float descX, descY, descHeight, descWidth; + float statsX, statsY, statsHeight, statsWidth; + float avatarX, avatarY; string backgroundName; int fontId; diff --git a/projects/mtg/include/DeckMenuItem.h b/projects/mtg/include/DeckMenuItem.h index 3c91685b4..c4d2ab2df 100644 --- a/projects/mtg/include/DeckMenuItem.h +++ b/projects/mtg/include/DeckMenuItem.h @@ -27,13 +27,13 @@ class DeckMenuItem: public JGuiObject string desc; DeckMetaData *meta; - DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, int x, int y, bool hasFocus = false, bool autoTranslate = false, DeckMetaData *meta = NULL); + DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus = false, bool autoTranslate = false, DeckMetaData *meta = NULL); ~DeckMenuItem(); - int mX; - int mY; + float mX; + float mY; - void Relocate(int x, int y); - int GetWidth(); + void Relocate(float x, float y); + float GetWidth(); bool hasFocus(); void RenderWithOffset(float yOffset); @@ -44,7 +44,7 @@ class DeckMenuItem: public JGuiObject virtual bool Leaving(JButton key); virtual bool ButtonPressed(); virtual ostream& toString(ostream& out) const; - virtual bool getTopLeft(int& top, int& left) {top = mY; left = mX; return true;}; + virtual bool getTopLeft(float& top, float& left) {top = mY; left = mX; return true;}; }; #endif diff --git a/projects/mtg/src/DeckMenu.cpp b/projects/mtg/src/DeckMenu.cpp index fc58e6d9c..b63a80060 100644 --- a/projects/mtg/src/DeckMenu.cpp +++ b/projects/mtg/src/DeckMenu.cpp @@ -11,11 +11,11 @@ #include namespace { - const unsigned int kVerticalMargin = 16; - const unsigned int kHorizontalMargin = 30; - const signed int kLineHeight = 20; - const signed int kDescriptionVerticalBoxPadding = 5; - const signed int kDescriptionHorizontalBoxPadding = 5; + const float kVerticalMargin = 16; + const float kHorizontalMargin = 30; + const float kLineHeight = 20; + const float kDescriptionVerticalBoxPadding = 5; + const float kDescriptionHorizontalBoxPadding = 5; } hgeParticleSystem* DeckMenu::stars = NULL; @@ -60,7 +60,7 @@ fontId(fontId) { avatarX = 230; avatarY = 8; - int scrollerWidth = 80; + float scrollerWidth = 80; scroller = NEW TextScroller(Fonts::MAIN_FONT, 40 , 230, scrollerWidth, 100, 1, 1); @@ -103,7 +103,7 @@ void DeckMenu::initMenuItems() float sY = mY + kVerticalMargin; for (int i = startId; i < startId + mCount; ++i) { DeckMenuItem *menuItem = static_cast (mObjects[i]); - int width = menuItem->GetWidth(); + float width = menuItem->GetWidth(); if (mWidth < width) mWidth = width; } titleWidth = titleFont->GetStringWidth(title.c_str()); @@ -150,8 +150,8 @@ void DeckMenu::Render() // display the avatar image if ( currentMenuItem->imageFilename.size() > 0 ) { - JQuad * quad = resources.RetrieveTempQuad( currentMenuItem->imageFilename, TEXTURE_SUB_AVATAR ); - if (quad) + JQuad * quad = resources.RetrieveTempQuad( currentMenuItem->imageFilename, TEXTURE_SUB_AVATAR ); + if (quad) renderer->RenderQuad(quad, avatarX, avatarY); } // fill in the description part of the screen @@ -194,7 +194,7 @@ void DeckMenu::Update(float dt){ stars->Update(dt); selectionT += 3*dt; selectionY += (selectionTargetY - selectionY) * 8 * dt; - stars->MoveTo( 40 + ((mWidth-2*kHorizontalMargin)*(1+cos(selectionT))/2), selectionY + 5 * cos(selectionT*2.35) + kLineHeight / 2 - kLineHeight * startId); + stars->MoveTo( 40 + ((mWidth-2*kHorizontalMargin)*(1+cos(selectionT))/2), selectionY + 5 * cos(selectionT*2.35f) + kLineHeight / 2 - kLineHeight * startId); if (timeOpen < 0) { timeOpen += dt * 10; if (timeOpen >= 0) { timeOpen = 0; closed = true; stars->FireAt(mX, mY); } diff --git a/projects/mtg/src/DeckMenuItem.cpp b/projects/mtg/src/DeckMenuItem.cpp index 420d5ef35..675c88287 100644 --- a/projects/mtg/src/DeckMenuItem.cpp +++ b/projects/mtg/src/DeckMenuItem.cpp @@ -4,7 +4,7 @@ #include "Translate.h" #include "WResourceManager.h" -DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, int x, int y, bool hasFocus, bool autoTranslate, DeckMetaData *deckMetaData): JGuiObject(id), parent(_parent), fontId(fontId), mX(x), mY(y) +DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus, bool autoTranslate, DeckMetaData *deckMetaData): JGuiObject(id), parent(_parent), fontId(fontId), mX(x), mY(y) { if (autoTranslate) mText = _(text); @@ -74,13 +74,13 @@ bool DeckMenuItem::ButtonPressed() return true; } -void DeckMenuItem::Relocate(int x, int y) +void DeckMenuItem::Relocate(float x, float y) { mX = x; mY = y; } -int DeckMenuItem::GetWidth() +float DeckMenuItem::GetWidth() { WFont * mFont = resources.GetWFont(fontId); mFont->SetScale(1.0); diff --git a/projects/mtg/template.vcxproj b/projects/mtg/template.vcxproj index 5ad2366b3..906c2efcf 100644 --- a/projects/mtg/template.vcxproj +++ b/projects/mtg/template.vcxproj @@ -317,6 +317,7 @@ + @@ -448,7 +449,9 @@ + +