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:
@@ -73,7 +73,8 @@ protected:
|
||||
void InitRenderer();
|
||||
void DestroyRenderer();
|
||||
|
||||
|
||||
float mActualWidth;
|
||||
float mActualHeight;
|
||||
|
||||
public:
|
||||
|
||||
@@ -524,6 +525,29 @@ public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
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:
|
||||
|
||||
struct TextureInfo
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning(disable : 4786)
|
||||
extern int actualWidth;
|
||||
extern int actualHeight;
|
||||
#pragma comment( lib, "giflib.lib" )
|
||||
#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);
|
||||
#endif //(!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0)
|
||||
#ifdef WIN32
|
||||
float scaleH = (float)actualHeight/SCREEN_HEIGHT_F;
|
||||
float scaleW = (float)actualWidth/SCREEN_WIDTH_F;
|
||||
float scaleH = mActualHeight/SCREEN_HEIGHT_F;
|
||||
float scaleW = mActualWidth/SCREEN_WIDTH_F;
|
||||
glScalef(scaleW,scaleW,1.f);
|
||||
#endif
|
||||
checkGlError();
|
||||
|
||||
@@ -10,9 +10,6 @@
|
||||
* Visit My Site At nehe.gamedev.net
|
||||
*/
|
||||
|
||||
int actualWidth;
|
||||
int actualHeight;
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h> // Header File For Windows
|
||||
#else
|
||||
@@ -199,8 +196,8 @@ GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize Th
|
||||
if (height==0) // Prevent A Divide By Zero By
|
||||
height=1; // Making Height Equal One
|
||||
|
||||
actualWidth = width;
|
||||
actualHeight = height;
|
||||
JRenderer::GetInstance()->SetActualWidth(static_cast<float>(width));
|
||||
JRenderer::GetInstance()->SetActualHeight(static_cast<float>(height));
|
||||
|
||||
glScissor(0, 0, width, height);
|
||||
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)
|
||||
{
|
||||
|
||||
actualWidth = width;
|
||||
actualHeight = height;
|
||||
JRenderer::GetInstance()->SetActualWidth(static_cast<float>(width));
|
||||
JRenderer::GetInstance()->SetActualWidth(static_cast<float>(height));
|
||||
|
||||
|
||||
GLuint pixelFormat; // Holds The Results After Searching For A Match
|
||||
|
||||
@@ -56,11 +56,12 @@ class GuiHandOpponent : public GuiHand
|
||||
class GuiHandSelf : public GuiHand
|
||||
{
|
||||
protected:
|
||||
enum
|
||||
typedef enum
|
||||
{
|
||||
Open,
|
||||
Closed
|
||||
} state;
|
||||
} HandState;
|
||||
HandState state;
|
||||
Pos backpos;
|
||||
|
||||
public:
|
||||
@@ -75,6 +76,11 @@ class GuiHandSelf : public GuiHand
|
||||
void Update(float dt);
|
||||
float LeftBoundary();
|
||||
|
||||
HandState GetState()
|
||||
{
|
||||
return state;
|
||||
};
|
||||
|
||||
HandLimitor* limitor;
|
||||
};
|
||||
|
||||
|
||||
@@ -718,7 +718,7 @@ int Navigator::CardToCardZone(PlayGuiObject* inCard)
|
||||
// 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,
|
||||
// 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
|
||||
if (card->getCard()->spellTargetType.find("creature") != string::npos)
|
||||
|
||||
@@ -741,6 +741,10 @@
|
||||
RelativePath=".\src\MTGRules.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Navigator.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\OptionItem.cpp"
|
||||
>
|
||||
@@ -1198,6 +1202,10 @@
|
||||
RelativePath=".\include\MTGRules.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Navigator.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\OptionItem.h"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user