- try to fix mouse pointer for issue #94
This commit is contained in:
parent
03f5455eb2
commit
c25867b5d8
|
@ -1 +1 @@
|
|||
Subproject commit 0ebb6df9491841a83a872d2a95291e6ee6f17750
|
||||
Subproject commit f22554bcfa828545a8996e8f08a49c9f96848283
|
|
@ -60,7 +60,7 @@ namespace Glest{ namespace Game{
|
|||
// class Text
|
||||
// =====================================================
|
||||
|
||||
Text::Text(const string &text, const Vec2i &pos, int time, Font2D *font, Font3D *font3D) {
|
||||
IntroText::IntroText(const string &text, const Vec2i &pos, int time, Font2D *font, Font3D *font3D) {
|
||||
this->text= text;
|
||||
this->pos= pos;
|
||||
this->time= time;
|
||||
|
@ -69,7 +69,7 @@ Text::Text(const string &text, const Vec2i &pos, int time, Font2D *font, Font3D
|
|||
this->font3D = font3D;
|
||||
}
|
||||
|
||||
Text::Text(const Texture2D *texture, const Vec2i &pos, const Vec2i &size, int time) {
|
||||
IntroText::IntroText(const Texture2D *texture, const Vec2i &pos, const Vec2i &size, int time) {
|
||||
this->pos= pos;
|
||||
this->size= size;
|
||||
this->time= time;
|
||||
|
@ -322,7 +322,7 @@ Intro::Intro(Program *program):
|
|||
textureHeight = strToInt(lang.getString(introTagTextureHeightName,"",true));
|
||||
}
|
||||
|
||||
texts.push_back(new Text(logoTexture, Vec2i(w/2-(textureWidth/2), h/2-(textureHeight/2)), Vec2i(textureWidth, textureHeight), displayTime));
|
||||
texts.push_back(new IntroText(logoTexture, Vec2i(w/2-(textureWidth/2), h/2-(textureHeight/2)), Vec2i(textureWidth, textureHeight), displayTime));
|
||||
}
|
||||
// This is a line of text
|
||||
else {
|
||||
|
@ -385,7 +385,7 @@ Intro::Intro(Program *program):
|
|||
}
|
||||
|
||||
}
|
||||
texts.push_back(new Text(lineText, Vec2i(textX, textY), displayTime, font,font3d));
|
||||
texts.push_back(new IntroText(lineText, Vec2i(textX, textY), displayTime, font,font3d));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -496,7 +496,7 @@ Intro::Intro(Program *program):
|
|||
textureStartTime = strToInt(lang.getString("IntroTextureStartMilliseconds","",true));
|
||||
}
|
||||
|
||||
texts.push_back(new Text(tex, texPlacement, Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), textureStartTime +(showMiscTime*(i+1))));
|
||||
texts.push_back(new IntroText(tex, texPlacement, Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), textureStartTime +(showMiscTime*(i+1))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -682,7 +682,7 @@ void Intro::render() {
|
|||
renderer.reset2d();
|
||||
|
||||
for(int i = 0; i < (int)texts.size(); ++i) {
|
||||
Text *text= texts[i];
|
||||
IntroText *text= texts[i];
|
||||
|
||||
int difTime= 1000 * timer / GameConstants::updateFps - text->getTime();
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace Glest{ namespace Game{
|
|||
// class Text
|
||||
// =====================================================
|
||||
|
||||
class Text {
|
||||
class IntroText {
|
||||
private:
|
||||
string text;
|
||||
Vec2i pos;
|
||||
|
@ -59,8 +59,8 @@ private:
|
|||
const Texture2D *texture;
|
||||
|
||||
public:
|
||||
Text(const string &text, const Vec2i &pos, int time, Font2D *font, Font3D *font3D);
|
||||
Text(const Texture2D *texture, const Vec2i &pos, const Vec2i &size, int time);
|
||||
IntroText(const string &text, const Vec2i &pos, int time, Font2D *font, Font3D *font3D);
|
||||
IntroText(const Texture2D *texture, const Vec2i &pos, const Vec2i &size, int time);
|
||||
|
||||
const string &getText() const {return text;}
|
||||
Font2D *getFont() {return font;}
|
||||
|
@ -85,7 +85,7 @@ private:
|
|||
static int disapearTime;
|
||||
|
||||
private:
|
||||
vector<Text *> texts;
|
||||
vector<IntroText *> texts;
|
||||
int timer;
|
||||
int mouse2d;
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
#include "network_protocol.h"
|
||||
#include "conversion.h"
|
||||
#include "gen_uuid.h"
|
||||
//#include "intro.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
|
@ -1327,6 +1328,76 @@ void MainWindow::eventKeyPress(SDL_KeyboardEvent c) {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,c);
|
||||
}
|
||||
|
||||
void MainWindow::eventWindowEvent(SDL_WindowEvent event) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,event.event);
|
||||
if(program == NULL) {
|
||||
throw megaglest_runtime_error("In [MainWindow::eventKeyPress] ERROR, program == NULL!");
|
||||
}
|
||||
|
||||
// if(program->getState() != NULL && dynamic_cast<Intro *>(program->getState()) != NULL) {
|
||||
// printf("In eventWindowEvent skip\n");
|
||||
// return;
|
||||
// }
|
||||
//Renderer &renderer= Renderer::getInstance();
|
||||
switch(event.event) {
|
||||
case SDL_WINDOWEVENT_ENTER:
|
||||
{
|
||||
//printf("In SDL_WINDOWEVENT_ENTER\n");
|
||||
// bool showCursorState = Window::lastShowMouseState;
|
||||
// showCursor(showCursorState);
|
||||
// renderer.setNo2DMouseRendering(showCursorState);
|
||||
//
|
||||
// Window::lastShowMouseState = SDL_ShowCursor(SDL_QUERY);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::lastShowMouseState = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::lastShowMouseState);
|
||||
}
|
||||
break;
|
||||
case SDL_WINDOWEVENT_LEAVE:
|
||||
{
|
||||
//printf("In SDL_WINDOWEVENT_LEAVE\n");
|
||||
// bool showCursorState = false;
|
||||
// int state = SDL_ShowCursor(SDL_QUERY);
|
||||
// if(state == SDL_DISABLE) {
|
||||
// showCursorState = true;
|
||||
// }
|
||||
// showCursor(showCursorState);
|
||||
// renderer.setNo2DMouseRendering(showCursorState);
|
||||
//
|
||||
// Window::lastShowMouseState = SDL_ShowCursor(SDL_QUERY);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::lastShowMouseState = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::lastShowMouseState);
|
||||
}
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
{
|
||||
//printf("SDL_WINDOWEVENT_FOCUS_GAINED\n");
|
||||
// bool showCursorState = Window::lastShowMouseState;
|
||||
// showCursor(showCursorState);
|
||||
// renderer.setNo2DMouseRendering(showCursorState);
|
||||
//
|
||||
// Window::lastShowMouseState = SDL_ShowCursor(SDL_QUERY);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::lastShowMouseState = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::lastShowMouseState);
|
||||
}
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
{
|
||||
//printf("SDL_WINDOWEVENT_FOCUS_LOST\n");
|
||||
// bool showCursorState = false;
|
||||
// int state = SDL_ShowCursor(SDL_QUERY);
|
||||
// if(state == SDL_DISABLE) {
|
||||
// showCursorState = true;
|
||||
// }
|
||||
// showCursor(showCursorState);
|
||||
// renderer.setNo2DMouseRendering(showCursorState);
|
||||
//
|
||||
// Window::lastShowMouseState = SDL_ShowCursor(SDL_QUERY);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::lastShowMouseState = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::lastShowMouseState);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,event.event);
|
||||
}
|
||||
|
||||
void MainWindow::eventActivate(bool active) {
|
||||
if(!active){
|
||||
//minimize();
|
||||
|
@ -4786,6 +4857,7 @@ int glestMain(int argc, char** argv) {
|
|||
::Shared::Platform::PlatformContextGl::charSet = config.getInt("FONT_CHARSET",intToStr(::Shared::Platform::PlatformContextGl::charSet).c_str());
|
||||
if(config.getBool("No2DMouseRendering","false") == false) {
|
||||
showCursor(false);
|
||||
//showWindowCursorState = false;
|
||||
}
|
||||
if(config.getInt("DEFAULT_HTTP_TIMEOUT",intToStr(SystemFlags::DEFAULT_HTTP_TIMEOUT).c_str()) >= 0) {
|
||||
SystemFlags::DEFAULT_HTTP_TIMEOUT = config.getInt("DEFAULT_HTTP_TIMEOUT",intToStr(SystemFlags::DEFAULT_HTTP_TIMEOUT).c_str());
|
||||
|
@ -5645,6 +5717,7 @@ int glestMain(int argc, char** argv) {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
showCursor(true);
|
||||
//showWindowCursorState = true;
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
virtual void eventActivate(bool active);
|
||||
virtual void eventResize(SizeState sizeState);
|
||||
virtual void eventClose();
|
||||
virtual void eventWindowEvent(SDL_WindowEvent event);
|
||||
|
||||
virtual void render();
|
||||
void toggleLanguage(string language);
|
||||
|
|
|
@ -215,6 +215,7 @@ protected:
|
|||
virtual void eventClose() {};
|
||||
virtual void eventDestroy() {};
|
||||
virtual void eventToggleFullScreen(bool isFullscreen) {};
|
||||
virtual void eventWindowEvent(SDL_WindowEvent event) {}
|
||||
|
||||
private:
|
||||
/// needed to detect double clicks
|
||||
|
|
|
@ -1716,6 +1716,9 @@ bool isCursorShowing() {
|
|||
}
|
||||
|
||||
void showCursor(bool b) {
|
||||
//printf("In showCursor, b: %d, isCursorShowing(): %d\n",b,isCursorShowing());
|
||||
|
||||
|
||||
if(isCursorShowing() == b) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -462,7 +462,35 @@ bool Window::handleEvent() {
|
|||
// bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly());
|
||||
// showCursor(willShowCursor);
|
||||
// }
|
||||
showCursor(false);
|
||||
|
||||
//printf("In SDL_WINDOWEVENT, event.window.event: %d\n",event.window.event);
|
||||
|
||||
/*
|
||||
switch(event.window.event) {
|
||||
case SDL_WINDOWEVENT_ENTER:
|
||||
printf("In SDL_WINDOWEVENT_ENTER\n");
|
||||
showCursor(true);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_LEAVE:
|
||||
printf("In SDL_WINDOWEVENT_LEAVE\n");
|
||||
showCursor(false);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
printf("SDL_WINDOWEVENT_FOCUS_GAINED\n");
|
||||
showCursor(true);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
printf("SDL_WINDOWEVENT_FOCUS_LOST\n");
|
||||
showCursor(false);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
//showCursor(false);
|
||||
|
||||
if(global_window) {
|
||||
global_window->eventWindowEvent(event.window);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue