Show loadstate.cpp syntax highlighted
/***************************************************************************
loadstate.cpp
-------------------
begin : Thu Feb 3 2005
copyright : (C) 2005 by Brendon Lloyd Higgins
email : bh_doc@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <client.h>
#include <entityclientfactory.h>
#include <gamestate.h>
#include <loadstate.h>
#include <maptileclient.h>
#include <playerclient.h>
#include <rules.h>
#include <worldclient.h>
#include <ClanLib/core.h>
LoadState::LoadState(CL_NetSession* ns, const CL_NetComputer& s,
const CL_NetStream& i, PlayerList* p, PlayerClient* m):
netsession(ns),
server(s),
startInput(new CL_NetStream(i)),
players(p),
me(m) {
}
LoadState::~LoadState() {
}
ClientState* LoadState::go(Client* client) {
Rules* rules = new Rules(startInput->input);
loadSprites(rules);
WorldClient* world = new WorldClient(&startInput->input, netsession, rules,
players);
bool startPaused = startInput->input.read_bool8();
startInput->output.write_bool8(true);
delete startInput;
return new GameState(netsession, server, players, me, rules, world,
startPaused);
}
void LoadState::loadSprites(Rules* rules) {
CL_ProgressBar pb(CL_Rect(0, 40, 200, 60),
EntityClientFactory::getSpriteStages(),
app.getGuiManager(), app.getStyleManager());
CL_Signal_v1<int> sig;
CL_Slot slot = sig.connect(this, &LoadState::loadSpritesCallback, &pb);
MapTileClient::loadSprites(rules);
EntityClientFactory::loadSprites(sig, rules);
}
void LoadState::loadSpritesCallback(int stage, CL_ProgressBar* pb) {
pb->set_progress(stage);
CL_Display::clear(CL_Color(127, 0, 0));
CL_Surface("gui/main/loading", app.getResources()).draw(0, 0);
app.getGuiManager()->show();
CL_Display::flip();
CL_System::keep_alive();
}
See more files for this project here