Incremental fix on my Navigator work - switched out global to JGE vars actualWidth/Height to be real accessible members of the JRenderer instance, so that we can actually access what the real display width is from within the MTG project. This makes the fix for enchantment zone targetting work when the window is resized on Win32.

This commit is contained in:
wrenczes
2010-11-02 04:07:25 +00:00
parent f472c48a8a
commit 858950fb9d
6 changed files with 49 additions and 16 deletions
+25 -1
View File
@@ -73,7 +73,8 @@ protected:
void InitRenderer(); void InitRenderer();
void DestroyRenderer(); void DestroyRenderer();
float mActualWidth;
float mActualHeight;
public: public:
@@ -524,6 +525,29 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetImageFilter(JImageFilter* imageFilter); void SetImageFilter(JImageFilter* imageFilter);
/**
** Set/Get methods for the actual display screen size.
*/
inline void SetActualWidth(float inWidth)
{
mActualWidth = inWidth;
}
inline void SetActualHeight(float inHeight)
{
mActualHeight = inHeight;
}
inline float GetActualWidth()
{
return mActualWidth;
}
inline float GetActualHeight()
{
return mActualHeight;
}
private: private:
struct TextureInfo struct TextureInfo
+3 -5
View File
@@ -11,8 +11,6 @@
#ifdef WIN32 #ifdef WIN32
#pragma warning(disable : 4786) #pragma warning(disable : 4786)
extern int actualWidth;
extern int actualHeight;
#pragma comment( lib, "giflib.lib" ) #pragma comment( lib, "giflib.lib" )
#endif #endif
@@ -393,7 +391,7 @@ void JRenderer::Destroy()
} }
} }
JRenderer::JRenderer() JRenderer::JRenderer() : mActualWidth(SCREEN_WIDTH_F), mActualHeight(SCREEN_HEIGHT_F)
{ {
} }
@@ -814,8 +812,8 @@ void JRenderer::BeginScene()
esOrtho(&theMvpMatrix, 0.0f, SCREEN_WIDTH_F, 0.0f, SCREEN_HEIGHT_F-1.0f,-1.0f, 1.0f); esOrtho(&theMvpMatrix, 0.0f, SCREEN_WIDTH_F, 0.0f, SCREEN_HEIGHT_F-1.0f,-1.0f, 1.0f);
#endif //(!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0) #endif //(!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0)
#ifdef WIN32 #ifdef WIN32
float scaleH = (float)actualHeight/SCREEN_HEIGHT_F; float scaleH = mActualHeight/SCREEN_HEIGHT_F;
float scaleW = (float)actualWidth/SCREEN_WIDTH_F; float scaleW = mActualWidth/SCREEN_WIDTH_F;
glScalef(scaleW,scaleW,1.f); glScalef(scaleW,scaleW,1.f);
#endif #endif
checkGlError(); checkGlError();
+4 -7
View File
@@ -10,9 +10,6 @@
* Visit My Site At nehe.gamedev.net * Visit My Site At nehe.gamedev.net
*/ */
int actualWidth;
int actualHeight;
#ifdef WIN32 #ifdef WIN32
#include <windows.h> // Header File For Windows #include <windows.h> // Header File For Windows
#else #else
@@ -199,8 +196,8 @@ GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize Th
if (height==0) // Prevent A Divide By Zero By if (height==0) // Prevent A Divide By Zero By
height=1; // Making Height Equal One height=1; // Making Height Equal One
actualWidth = width; JRenderer::GetInstance()->SetActualWidth(static_cast<float>(width));
actualHeight = height; JRenderer::GetInstance()->SetActualHeight(static_cast<float>(height));
glScissor(0, 0, width, height); glScissor(0, 0, width, height);
glViewport (0, 0, width, height); // Reset The Current Viewport glViewport (0, 0, width, height); // Reset The Current Viewport
@@ -353,8 +350,8 @@ void KillGLWindow(void) // Properly Kill The Window
BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag) BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
{ {
actualWidth = width; JRenderer::GetInstance()->SetActualWidth(static_cast<float>(width));
actualHeight = height; JRenderer::GetInstance()->SetActualWidth(static_cast<float>(height));
GLuint pixelFormat; // Holds The Results After Searching For A Match GLuint pixelFormat; // Holds The Results After Searching For A Match
+8 -2
View File
@@ -56,11 +56,12 @@ class GuiHandOpponent : public GuiHand
class GuiHandSelf : public GuiHand class GuiHandSelf : public GuiHand
{ {
protected: protected:
enum typedef enum
{ {
Open, Open,
Closed Closed
} state; } HandState;
HandState state;
Pos backpos; Pos backpos;
public: public:
@@ -75,6 +76,11 @@ class GuiHandSelf : public GuiHand
void Update(float dt); void Update(float dt);
float LeftBoundary(); float LeftBoundary();
HandState GetState()
{
return state;
};
HandLimitor* limitor; HandLimitor* limitor;
}; };
+1 -1
View File
@@ -718,7 +718,7 @@ int Navigator::CardToCardZone(PlayGuiObject* inCard)
// isAI = card->getCard()->target->owner->isAI(); // isAI = card->getCard()->target->owner->isAI();
// nasty hack: the lines above don't always work, as when an enchantment comes into play, its ability hasn't been activated yet, // nasty hack: the lines above don't always work, as when an enchantment comes into play, its ability hasn't been activated yet,
// so it doesn't yet have a target. Instead, we now look at the card's position, if it's in the top half of the screen, it goes into an AI zone // so it doesn't yet have a target. Instead, we now look at the card's position, if it's in the top half of the screen, it goes into an AI zone
isAI = card->y < SCREEN_HEIGHT / 2; isAI = card->y < JRenderer::GetInstance()->GetActualHeight() / 2;
// enchantments that target creatures are treated as part of the creature zone // enchantments that target creatures are treated as part of the creature zone
if (card->getCard()->spellTargetType.find("creature") != string::npos) if (card->getCard()->spellTargetType.find("creature") != string::npos)
+8
View File
@@ -741,6 +741,10 @@
RelativePath=".\src\MTGRules.cpp" RelativePath=".\src\MTGRules.cpp"
> >
</File> </File>
<File
RelativePath=".\src\Navigator.cpp"
>
</File>
<File <File
RelativePath=".\src\OptionItem.cpp" RelativePath=".\src\OptionItem.cpp"
> >
@@ -1198,6 +1202,10 @@
RelativePath=".\include\MTGRules.h" RelativePath=".\include\MTGRules.h"
> >
</File> </File>
<File
RelativePath=".\include\Navigator.h"
>
</File>
<File <File
RelativePath=".\include\OptionItem.h" RelativePath=".\include\OptionItem.h"
> >