2012-03-21 20:00:22 -05:00
|
|
|
/*
|
2012-05-21 23:27:44 -05:00
|
|
|
Niotso - The New Implementation of The Sims Online
|
|
|
|
Scene/Scene.hpp
|
|
|
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
|
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
2012-03-21 20:00:22 -05:00
|
|
|
|
|
|
|
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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2012-04-08 12:20:25 -05:00
|
|
|
#define EXIT_SCENE() do { System::SceneFailed = true; delete this; return; } while(0)
|
|
|
|
#define SCENE_EXIT 0
|
|
|
|
#define SCENE_NEED_REDRAW 1
|
|
|
|
#define SCENE_NO_REDRAW -1
|
|
|
|
|
2012-03-21 20:00:22 -05:00
|
|
|
class Scene {
|
|
|
|
const float TickPeriod;
|
2012-04-09 23:58:16 -05:00
|
|
|
float RealTimeDelta;
|
2012-03-21 20:00:22 -05:00
|
|
|
virtual int Run(float TimeDelta) = 0;
|
|
|
|
|
|
|
|
protected:
|
2012-04-09 23:58:16 -05:00
|
|
|
float TimeDelta;
|
|
|
|
Scene(float c) : TickPeriod(c), RealTimeDelta(0) {}
|
2012-03-21 20:00:22 -05:00
|
|
|
|
|
|
|
public:
|
|
|
|
int RunFor(float TimeDelta) {
|
|
|
|
if(TickPeriod == 0){
|
|
|
|
return Run(TimeDelta);
|
|
|
|
}
|
2012-05-21 23:27:44 -05:00
|
|
|
|
2012-03-21 20:00:22 -05:00
|
|
|
bool Redraw = false;
|
2012-04-09 23:58:16 -05:00
|
|
|
RealTimeDelta += TimeDelta;
|
|
|
|
while(RealTimeDelta >= 0){
|
2012-03-21 20:00:22 -05:00
|
|
|
int result = Run(TickPeriod);
|
|
|
|
if(result == System::SHUTDOWN)
|
|
|
|
return System::SHUTDOWN;
|
|
|
|
if(result > 0) Redraw = true;
|
2012-04-09 23:58:16 -05:00
|
|
|
RealTimeDelta -= TickPeriod;
|
2012-03-21 20:00:22 -05:00
|
|
|
}
|
|
|
|
return (Redraw) ? 1 : -1;
|
|
|
|
}
|
2012-05-21 23:27:44 -05:00
|
|
|
|
2012-03-21 20:00:22 -05:00
|
|
|
virtual void Render() = 0;
|
2012-04-09 23:58:16 -05:00
|
|
|
virtual ~Scene() {};
|
|
|
|
};
|
|
|
|
|
2012-04-22 03:52:39 -05:00
|
|
|
/****
|
|
|
|
** Scenes
|
|
|
|
*/
|
2012-04-20 19:37:08 -05:00
|
|
|
|
2012-04-22 03:52:39 -05:00
|
|
|
#include "LoginScreen/LoginScreen.hpp"
|