mirror of
https://github.com/glest/glest-source.git
synced 2025-08-30 19:29:47 +02:00
- fixed mouse cursor position problrm at game startup
This commit is contained in:
@@ -551,10 +551,21 @@ void Game::render() {
|
||||
// Ensure the camera starts in the right position
|
||||
if(isFirstRender == true) {
|
||||
isFirstRender = false;
|
||||
|
||||
/*
|
||||
Map *map= world.getMap();
|
||||
const Vec2i &v= map->getStartLocation(world.getThisFaction()->getStartLocationIndex());
|
||||
gameCamera.init(map->getW(), map->getH());
|
||||
gameCamera.setPos(Vec2f(v.x, v.y));
|
||||
|
||||
//const Vec2i &mapPos = Map::toSurfCoords(v);
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
Vec3f screenPos = renderer.computeScreenPosition(gameCamera.getPos());
|
||||
SDL_WarpMouse(v.x, v.y);
|
||||
*/
|
||||
|
||||
gameCamera.resetPosition();
|
||||
this->restoreToStartXY();
|
||||
}
|
||||
|
||||
renderFps++;
|
||||
|
@@ -269,6 +269,11 @@ void Program::setState(ProgramState *programState, bool cleanupOldState)
|
||||
try {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
int X = 0;
|
||||
int Y = 0;
|
||||
SDL_GetMouseState(&X,&Y);
|
||||
programState->setStartXY(X,Y);
|
||||
|
||||
showCursor(true);
|
||||
sleep(0);
|
||||
|
||||
|
@@ -45,6 +45,9 @@ class ProgramState{
|
||||
protected:
|
||||
Program *program;
|
||||
|
||||
int startX;
|
||||
int startY;
|
||||
|
||||
public:
|
||||
ProgramState(Program *program) {this->program= program;}
|
||||
virtual ~ProgramState(){};
|
||||
@@ -70,6 +73,8 @@ public:
|
||||
virtual void keyDown(char key){};
|
||||
virtual void keyUp(char key){};
|
||||
virtual void keyPress(char c){};
|
||||
virtual void setStartXY(int X,int Y) { startX=X; startY=Y; }
|
||||
virtual void restoreToStartXY() { SDL_WarpMouse(startX, startY); }
|
||||
};
|
||||
|
||||
// ===============================
|
||||
|
Reference in New Issue
Block a user