Skip to content

Commit

Permalink
fix mouse coords at startup being 0,0, fix glitch that could make bac…
Browse files Browse the repository at this point in the history
…kground windows fade completely to black
  • Loading branch information
jacob1 committed Jan 31, 2015
1 parent 94e635b commit b7fe998
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
8 changes: 6 additions & 2 deletions src/PowderToySDL.cpp
Expand Up @@ -987,11 +987,15 @@ int main(int argc, char * argv[])
}
}

//initial mouse coords
int sdl_x, sdl_y;
SDL_GetMouseState(&sdl_x, &sdl_y);
engine->onMouseMove(sdl_x*inputScale, sdl_y*inputScale);
EngineProcess();

#ifdef WIN
#ifdef WIN
SaveWindowPosition();
#endif
#endif

#if !defined(DEBUG) && !defined(_DEBUG)
}
Expand Down
22 changes: 5 additions & 17 deletions src/gui/interface/Engine.cpp
@@ -1,6 +1,7 @@
#include <iostream>
#include <stack>
#include <cstdio>
#include <cmath>

#include "Config.h"
#include "Misc.h"
Expand Down Expand Up @@ -76,7 +77,7 @@ void Engine::Exit()

void Engine::ShowWindow(Window * window)
{
windowOpenState = 0.0f;
windowOpenState = 0;
if(window->Position.X==-1)
{
window->Position.X = (width_-window->Size.X)/2;
Expand Down Expand Up @@ -182,22 +183,6 @@ void Engine::Tick()


lastTick = gettime();
if(windowOpenState<1.0f)
{
if(lastBuffer)
{
pixel * vid = g->vid;
g->vid = lastBuffer;
g->fillrect(0, 0, width_, height_, 0, 0, 0, 5);
g->vid = vid;

}
/*if(windowTargetPosition.Y < state_->Position.Y)
{
state_->Position.Y += windowTargetPosition.Y/20;
}*/
windowOpenState += 0.05f;//*dt;
}

/*if(statequeued_ != NULL)
{
Expand All @@ -223,6 +208,9 @@ void Engine::Draw()
g->Clear();
#ifndef OGLI
memcpy(g->vid, lastBuffer, (width_ * height_) * PIXELSIZE);
if(windowOpenState < 20)
windowOpenState++;
g->fillrect(0, 0, width_, height_, 0, 0, 0, 255-std::pow(.98, windowOpenState)*255);
#endif
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/gui/interface/Engine.h
Expand Up @@ -87,7 +87,7 @@ namespace ui
//Window* statequeued_;
Window* state_;
Point windowTargetPosition;
float windowOpenState;
int windowOpenState;

bool running_;
bool break_;
Expand Down

0 comments on commit b7fe998

Please sign in to comment.