Permalink
Browse files

fix renderer compile and make it create a "Save file invalid" sign wh…

…en it can't render the save, fixes #97
  • Loading branch information...
jacob1 committed Jan 10, 2015
1 parent b2954a7 commit 4f6094136e7f9ea56ae8a086b2aeabcb650c1737
Showing with 40 additions and 14 deletions.
  1. +32 −14 src/PowderToyRenderer.cpp
  2. +4 −0 src/gui/localbrowser/LocalBrowserView.cpp
  3. +4 −0 src/gui/search/SearchView.cpp
@@ -78,25 +78,43 @@ int main(int argc, char *argv[])
engine = &ui::Engine::Ref();
engine->Begin(WINDOWW, WINDOWH);
GameSave * gameSave = new GameSave(inputFile);
GameSave * gameSave = NULL;
try
{
gameSave = new GameSave(inputFile);
}
catch (ParseException e)
{
//Render the save again later or something? I don't know
if (e.what() == "Save from newer version")
throw e;
}
Simulation * sim = new Simulation();
Renderer * ren = new Renderer(ui::Engine::Ref().g, sim);
sim->Load(gameSave);
//Render save
ren->decorations_enable = true;
ren->blackDecorations = true;
int frame = 15;
while(frame)
if (gameSave)
{
sim->Load(gameSave);
//Render save
ren->decorations_enable = true;
ren->blackDecorations = true;
int frame = 15;
while(frame)
{
frame--;
ren->render_parts();
ren->render_fire();
ren->clearScreen(1.0f);
}
}
else
{
frame--;
ren->render_parts();
ren->render_fire();
ren->clearScreen(1.0f);
int w = Graphics::textwidth("Save file invalid")+16, x = (XRES-w)/2, y = (YRES-24)/2;
ren->drawrect(x, y, w, 24, 192, 192, 192, 255);
ren->drawtext(x+8, y+8, "Save file invalid", 192, 192, 240, 255);
}
ren->RenderBegin();
@@ -114,17 +114,21 @@ void LocalBrowserView::textChanged()
else if (num > pageCount)
pageTextbox->SetText(format::NumberToString(pageCount));
changed = true;
#ifdef USE_SDL
lastChanged = SDL_GetTicks()+600;
#endif
}
void LocalBrowserView::OnTick(float dt)
{
c->Update();
#ifdef USE_SDL
if (changed && lastChanged < SDL_GetTicks())
{
changed = false;
c->SetPage(std::max(format::StringToNumber<int>(pageTextbox->GetText()), 0));
}
#endif
}
void LocalBrowserView::NotifyPageChanged(LocalBrowserModel * sender)
@@ -277,7 +277,9 @@ void SearchView::textChanged()
else if (num > pageCount)
pageTextbox->SetText(format::NumberToString(pageCount));
changed = true;
#ifdef USE_SDL
lastChanged = SDL_GetTicks()+600;
#endif
}
void SearchView::OnTryOkay(OkayMethod method)
@@ -781,11 +783,13 @@ void SearchView::NotifySelectedChanged(SearchModel * sender)
void SearchView::OnTick(float dt)
{
c->Update();
#ifdef USE_SDL
if (changed && lastChanged < SDL_GetTicks())
{
changed = false;
c->SetPage(std::max(format::StringToNumber<int>(pageTextbox->GetText()), 0));
}
#endif
}
void SearchView::OnMouseWheel(int x, int y, int d)

0 comments on commit 4f60941

Please sign in to comment.