mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-15 12:54:07 +02:00
Nice graphics for Showing windows
This commit is contained in:
@@ -67,7 +67,7 @@ int main(int argc, char * argv[])
|
|||||||
ui::Engine::Ref().g->AttachSDLSurface(SDLOpen());
|
ui::Engine::Ref().g->AttachSDLSurface(SDLOpen());
|
||||||
|
|
||||||
ui::Engine * engine = &ui::Engine::Ref();
|
ui::Engine * engine = &ui::Engine::Ref();
|
||||||
engine->Begin(XRES, YRES);
|
engine->Begin(XRES+BARSIZE, YRES+MENUSIZE);
|
||||||
|
|
||||||
GameController * gameController = new GameController();
|
GameController * gameController = new GameController();
|
||||||
engine->ShowWindow(gameController->GetView());
|
engine->ShowWindow(gameController->GetView());
|
||||||
|
@@ -19,7 +19,9 @@ Engine::Engine():
|
|||||||
mousexp_(0),
|
mousexp_(0),
|
||||||
mouseyp_(0),
|
mouseyp_(0),
|
||||||
FpsLimit(60.0f),
|
FpsLimit(60.0f),
|
||||||
windows(stack<Window*>())
|
windows(stack<Window*>()),
|
||||||
|
lastBuffer(NULL),
|
||||||
|
prevBuffers(stack<pixel*>())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,15 +63,34 @@ void Engine::ShowWindow(Window * window)
|
|||||||
}
|
}
|
||||||
if(state_)
|
if(state_)
|
||||||
{
|
{
|
||||||
|
if(lastBuffer)
|
||||||
|
{
|
||||||
|
prevBuffers.push(lastBuffer);
|
||||||
|
}
|
||||||
|
lastBuffer = (pixel*)malloc((width_ * height_) * PIXELSIZE);
|
||||||
|
g->fillrect(0, 0, width_, height_, 0, 0, 0, 100);
|
||||||
|
memcpy(lastBuffer, g->vid, (width_ * height_) * PIXELSIZE);
|
||||||
|
|
||||||
windows.push(state_);
|
windows.push(state_);
|
||||||
}
|
}
|
||||||
state_ = window;
|
state_ = window;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::CloseWindow()
|
void Engine::CloseWindow()
|
||||||
{
|
{
|
||||||
if(!windows.empty())
|
if(!windows.empty())
|
||||||
{
|
{
|
||||||
|
if(!prevBuffers.empty())
|
||||||
|
{
|
||||||
|
lastBuffer = prevBuffers.top();
|
||||||
|
prevBuffers.pop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
free(lastBuffer);
|
||||||
|
lastBuffer = NULL;
|
||||||
|
}
|
||||||
state_ = windows.top();
|
state_ = windows.top();
|
||||||
windows.pop();
|
windows.pop();
|
||||||
}
|
}
|
||||||
@@ -120,10 +141,17 @@ void Engine::Tick(float dt)
|
|||||||
|
|
||||||
void Engine::Draw()
|
void Engine::Draw()
|
||||||
{
|
{
|
||||||
|
if(lastBuffer && !(state_->Position.X == 0 && state_->Position.Y == 0 && state_->Size.X == width_ && state_->Size.Y == height_))
|
||||||
|
{
|
||||||
|
memcpy(g->vid, lastBuffer, (width_ * height_) * PIXELSIZE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g->Clear();
|
||||||
|
}
|
||||||
if(state_)
|
if(state_)
|
||||||
state_->DoDraw();
|
state_->DoDraw();
|
||||||
g->Blit();
|
g->Blit();
|
||||||
g->Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::onKeyPress(int key, bool shift, bool ctrl, bool alt)
|
void Engine::onKeyPress(int key, bool shift, bool ctrl, bool alt)
|
||||||
|
@@ -54,6 +54,8 @@ namespace ui
|
|||||||
float FpsLimit;
|
float FpsLimit;
|
||||||
Graphics * g;
|
Graphics * g;
|
||||||
private:
|
private:
|
||||||
|
pixel * lastBuffer;
|
||||||
|
std::stack<pixel*> prevBuffers;
|
||||||
std::stack<Window*> windows;
|
std::stack<Window*> windows;
|
||||||
//Window* statequeued_;
|
//Window* statequeued_;
|
||||||
Window* state_;
|
Window* state_;
|
||||||
|
@@ -19,6 +19,7 @@ PreviewView::PreviewView():
|
|||||||
void PreviewView::OnDraw()
|
void PreviewView::OnDraw()
|
||||||
{
|
{
|
||||||
Graphics * g = ui::Engine::Ref().g;
|
Graphics * g = ui::Engine::Ref().g;
|
||||||
|
g->clearrect(Position.X-2, Position.Y-2, Size.X+4, Size.Y+4);
|
||||||
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);
|
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user