mirror of
https://github.com/glest/glest-source.git
synced 2025-09-25 15:09:03 +02:00
glest_game/main:reformat/restyle source code [skip ci]
* used 'indent -nut -i2 -bli0 -ppi 3 *`
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -10,32 +10,40 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
|
|
||||||
#ifndef _GLEST_GAME_BATTLEEND_H_
|
#ifndef _GLEST_GAME_BATTLEEND_H_
|
||||||
#define _GLEST_GAME_BATTLEEND_H_
|
# define _GLEST_GAME_BATTLEEND_H_
|
||||||
|
|
||||||
#ifdef WIN32
|
# ifdef WIN32
|
||||||
#include <winsock2.h>
|
# include <winsock2.h>
|
||||||
#include <winsock.h>
|
# include <winsock.h>
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
#include "program.h"
|
# include "program.h"
|
||||||
#include "stats.h"
|
# include "stats.h"
|
||||||
#include "leak_dumper.h"
|
# include "leak_dumper.h"
|
||||||
|
|
||||||
namespace Shared { namespace Graphics {
|
namespace Shared
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
class VideoPlayer;
|
class VideoPlayer;
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest
|
||||||
|
{
|
||||||
|
namespace Game
|
||||||
|
{
|
||||||
|
|
||||||
class GameSettings;
|
class GameSettings;
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class BattleEnd
|
// class BattleEnd
|
||||||
//
|
//
|
||||||
/// ProgramState representing the end of the game
|
/// ProgramState representing the end of the game
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
class BattleEnd: public ProgramState{
|
class BattleEnd:public ProgramState
|
||||||
private:
|
{
|
||||||
|
private:
|
||||||
Stats stats;
|
Stats stats;
|
||||||
|
|
||||||
GraphicButton buttonExit;
|
GraphicButton buttonExit;
|
||||||
@@ -46,32 +54,34 @@ private:
|
|||||||
ProgramState *originState;
|
ProgramState *originState;
|
||||||
const char *containerName;
|
const char *containerName;
|
||||||
|
|
||||||
::Shared::Graphics::VideoPlayer *menuBackgroundVideo;
|
::Shared::Graphics::VideoPlayer * menuBackgroundVideo;
|
||||||
GameSettings *gameSettings;
|
GameSettings *gameSettings;
|
||||||
StrSound battleEndMusic;
|
StrSound battleEndMusic;
|
||||||
|
|
||||||
void showMessageBox(const string &text, const string &header, bool toggle);
|
void showMessageBox (const string & text, const string & header,
|
||||||
|
bool toggle);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BattleEnd(Program *program, const Stats *stats, ProgramState *originState);
|
BattleEnd (Program * program, const Stats * stats,
|
||||||
~BattleEnd();
|
ProgramState * originState);
|
||||||
|
~BattleEnd ();
|
||||||
|
|
||||||
virtual void update();
|
virtual void update ();
|
||||||
virtual void render();
|
virtual void render ();
|
||||||
virtual void keyDown(SDL_KeyboardEvent key);
|
virtual void keyDown (SDL_KeyboardEvent key);
|
||||||
virtual void mouseDownLeft(int x, int y);
|
virtual void mouseDownLeft (int x, int y);
|
||||||
virtual void mouseMove(int x, int y, const MouseState *ms);
|
virtual void mouseMove (int x, int y, const MouseState * ms);
|
||||||
//virtual void tick();
|
//virtual void tick();
|
||||||
virtual void reloadUI();
|
virtual void reloadUI ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void initBackgroundVideo();
|
void initBackgroundVideo ();
|
||||||
std::pair<string,string> getBattleEndVideo(bool won);
|
std::pair < string, string > getBattleEndVideo (bool won);
|
||||||
string getBattleEndMusic(bool won);
|
string getBattleEndMusic (bool won);
|
||||||
void initBackgroundMusic();
|
void initBackgroundMusic ();
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}} //end namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -10,19 +10,19 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
|
|
||||||
#ifndef _GLEST_GAME_INTRO_H_
|
#ifndef _GLEST_GAME_INTRO_H_
|
||||||
#define _GLEST_GAME_INTRO_H_
|
# define _GLEST_GAME_INTRO_H_
|
||||||
|
|
||||||
#include <vector>
|
# include <vector>
|
||||||
|
|
||||||
#include "program.h"
|
# include "program.h"
|
||||||
#include "font.h"
|
# include "font.h"
|
||||||
#include "vec.h"
|
# include "vec.h"
|
||||||
#include "texture.h"
|
# include "texture.h"
|
||||||
#include "camera.h"
|
# include "camera.h"
|
||||||
#include "model.h"
|
# include "model.h"
|
||||||
#include "randomgen.h"
|
# include "randomgen.h"
|
||||||
|
|
||||||
#include "leak_dumper.h"
|
# include "leak_dumper.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
@@ -42,34 +42,80 @@ using Shared::Util::RandomGen;
|
|||||||
//class Md5Object;
|
//class Md5Object;
|
||||||
//}}}
|
//}}}
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest
|
||||||
|
{
|
||||||
|
namespace Game
|
||||||
|
{
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class Text
|
// class Text
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
class IntroText {
|
class IntroText
|
||||||
private:
|
{
|
||||||
|
private:
|
||||||
string text;
|
string text;
|
||||||
Vec2i pos;
|
Vec2i pos;
|
||||||
Vec2i size;
|
Vec2i size;
|
||||||
int time;
|
int
|
||||||
Font2D *font;
|
time;
|
||||||
Font3D *font3D;
|
Font2D *
|
||||||
const Texture2D *texture;
|
font;
|
||||||
|
Font3D *
|
||||||
|
font3D;
|
||||||
|
const Texture2D *
|
||||||
|
texture;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IntroText(const string &text, const Vec2i &pos, int time, Font2D *font, Font3D *font3D);
|
IntroText (const string & text, const Vec2i & pos, int time,
|
||||||
IntroText(const Texture2D *texture, const Vec2i &pos, const Vec2i &size, int time);
|
Font2D * font, Font3D * font3D);
|
||||||
|
IntroText (const Texture2D * texture, const Vec2i & pos,
|
||||||
|
const Vec2i & size, int time);
|
||||||
|
|
||||||
const string &getText() const {return text;}
|
const
|
||||||
Font2D *getFont() {return font;}
|
string &
|
||||||
Font3D *getFont3D() {return font3D;}
|
getText () const
|
||||||
const Vec2i &getPos() const {return pos;}
|
{
|
||||||
const Vec2i &getSize() const {return size;}
|
return
|
||||||
int getTime() const {return time;}
|
text;
|
||||||
const Texture2D *getTexture() const {return texture;}
|
}
|
||||||
};
|
Font2D *
|
||||||
|
getFont ()
|
||||||
|
{
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
Font3D *
|
||||||
|
getFont3D ()
|
||||||
|
{
|
||||||
|
return font3D;
|
||||||
|
}
|
||||||
|
const
|
||||||
|
Vec2i &
|
||||||
|
getPos () const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
pos;
|
||||||
|
}
|
||||||
|
const
|
||||||
|
Vec2i &
|
||||||
|
getSize () const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
size;
|
||||||
|
}
|
||||||
|
int
|
||||||
|
getTime () const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
time;
|
||||||
|
}
|
||||||
|
const Texture2D *
|
||||||
|
getTexture () const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
texture;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class Intro
|
// class Intro
|
||||||
@@ -77,52 +123,75 @@ public:
|
|||||||
/// ProgramState representing the intro
|
/// ProgramState representing the intro
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
class Intro: public ProgramState {
|
class Intro:
|
||||||
private:
|
public ProgramState
|
||||||
static int introTime;
|
{
|
||||||
static int appearTime;
|
private:
|
||||||
static int showTime;
|
static int
|
||||||
static int disapearTime;
|
introTime;
|
||||||
|
static int
|
||||||
|
appearTime;
|
||||||
|
static int
|
||||||
|
showTime;
|
||||||
|
static int
|
||||||
|
disapearTime;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector<IntroText *> texts;
|
vector < IntroText * >texts;
|
||||||
int timer;
|
int
|
||||||
int mouse2d;
|
timer;
|
||||||
|
int
|
||||||
|
mouse2d;
|
||||||
|
|
||||||
//Model *mainModel;
|
//Model *mainModel;
|
||||||
int modelIndex;
|
int
|
||||||
float modelMinAnimSpeed;
|
modelIndex;
|
||||||
float modelMaxAnimSpeed;
|
float
|
||||||
vector<Model *> models;
|
modelMinAnimSpeed;
|
||||||
|
float
|
||||||
|
modelMaxAnimSpeed;
|
||||||
|
vector < Model * >models;
|
||||||
Camera nextCamera;
|
Camera nextCamera;
|
||||||
Camera camera;
|
Camera camera;
|
||||||
Camera lastCamera;
|
Camera lastCamera;
|
||||||
const Camera *targetCamera;
|
const Camera *
|
||||||
float t;
|
targetCamera;
|
||||||
|
float
|
||||||
|
t;
|
||||||
RandomGen random;
|
RandomGen random;
|
||||||
float anim;
|
float
|
||||||
float fade;
|
anim;
|
||||||
|
float
|
||||||
|
fade;
|
||||||
Vec3f startPosition;
|
Vec3f startPosition;
|
||||||
int modelShowTime;
|
int
|
||||||
|
modelShowTime;
|
||||||
|
|
||||||
//GLMmodel* test;
|
//GLMmodel* test;
|
||||||
//Shared::Graphics::md5::Md5Object *md5Test;
|
//Shared::Graphics::md5::Md5Object *md5Test;
|
||||||
|
|
||||||
bool exitAfterIntroVideo;
|
bool exitAfterIntroVideo;
|
||||||
void cleanup();
|
void
|
||||||
void renderModelBackground();
|
cleanup ();
|
||||||
|
void
|
||||||
|
renderModelBackground ();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Intro(Program *program);
|
explicit Intro (Program * program);
|
||||||
virtual ~Intro();
|
virtual ~ Intro ();
|
||||||
|
|
||||||
virtual void update();
|
virtual void
|
||||||
virtual void render();
|
update ();
|
||||||
virtual void keyDown(SDL_KeyboardEvent key);
|
virtual void
|
||||||
virtual void mouseUpLeft(int x, int y);
|
render ();
|
||||||
void mouseMove(int x, int y, const MouseState *ms);
|
virtual void
|
||||||
};
|
keyDown (SDL_KeyboardEvent key);
|
||||||
|
virtual void
|
||||||
|
mouseUpLeft (int x, int y);
|
||||||
|
void
|
||||||
|
mouseMove (int x, int y, const MouseState * ms);
|
||||||
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}} //end namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -10,17 +10,20 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
|
|
||||||
#ifndef _GLEST_GAME_MAIN_H_
|
#ifndef _GLEST_GAME_MAIN_H_
|
||||||
#define _GLEST_GAME_MAIN_H_
|
# define _GLEST_GAME_MAIN_H_
|
||||||
|
|
||||||
#include <ctime>
|
# include <ctime>
|
||||||
#include "program.h"
|
# include "program.h"
|
||||||
#include "window_gl.h"
|
# include "window_gl.h"
|
||||||
#include "leak_dumper.h"
|
# include "leak_dumper.h"
|
||||||
|
|
||||||
using Shared::Platform::MouseButton;
|
using Shared::Platform::MouseButton;
|
||||||
using Shared::Platform::MouseState;
|
using Shared::Platform::MouseState;
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest
|
||||||
|
{
|
||||||
|
namespace Game
|
||||||
|
{
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class MainWindow
|
// class MainWindow
|
||||||
@@ -28,49 +31,84 @@ namespace Glest{ namespace Game{
|
|||||||
/// Main program window
|
/// Main program window
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
class MainWindow: public WindowGl {
|
class MainWindow:
|
||||||
private:
|
public WindowGl
|
||||||
Program* program;
|
{
|
||||||
|
private:
|
||||||
|
Program * program;
|
||||||
PopupMenu popupMenu;
|
PopupMenu popupMenu;
|
||||||
int cancelLanguageSelection;
|
int
|
||||||
|
cancelLanguageSelection;
|
||||||
bool triggerLanguageToggle;
|
bool triggerLanguageToggle;
|
||||||
string triggerLanguage;
|
string triggerLanguage;
|
||||||
|
|
||||||
void showLanguages();
|
void
|
||||||
|
showLanguages ();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(Program *program);
|
explicit MainWindow (Program * program);
|
||||||
~MainWindow();
|
~MainWindow ();
|
||||||
|
|
||||||
void setProgram(Program *program);
|
void
|
||||||
|
setProgram (Program * program);
|
||||||
|
|
||||||
virtual void eventMouseDown(int x, int y, MouseButton mouseButton);
|
virtual void
|
||||||
virtual void eventMouseUp(int x, int y, MouseButton mouseButton);
|
eventMouseDown (int x, int y, MouseButton mouseButton);
|
||||||
virtual void eventMouseDoubleClick(int x, int y, MouseButton mouseButton);
|
virtual void
|
||||||
virtual void eventMouseMove(int x, int y, const MouseState *mouseState);
|
eventMouseUp (int x, int y, MouseButton mouseButton);
|
||||||
virtual bool eventTextInput(std::string text);
|
virtual void
|
||||||
virtual bool eventSdlKeyDown(SDL_KeyboardEvent key);
|
eventMouseDoubleClick (int x, int y, MouseButton mouseButton);
|
||||||
virtual void eventKeyDown(SDL_KeyboardEvent key);
|
virtual void
|
||||||
virtual void eventMouseWheel(int x, int y, int zDelta);
|
eventMouseMove (int x, int y, const MouseState * mouseState);
|
||||||
virtual void eventKeyUp(SDL_KeyboardEvent key);
|
virtual
|
||||||
virtual void eventKeyPress(SDL_KeyboardEvent c);
|
bool
|
||||||
virtual void eventActivate(bool active);
|
eventTextInput (std::string text);
|
||||||
virtual void eventResize(SizeState sizeState);
|
virtual
|
||||||
virtual void eventClose();
|
bool
|
||||||
virtual void eventWindowEvent(SDL_WindowEvent event);
|
eventSdlKeyDown (SDL_KeyboardEvent key);
|
||||||
|
virtual void
|
||||||
|
eventKeyDown (SDL_KeyboardEvent key);
|
||||||
|
virtual void
|
||||||
|
eventMouseWheel (int x, int y, int zDelta);
|
||||||
|
virtual void
|
||||||
|
eventKeyUp (SDL_KeyboardEvent key);
|
||||||
|
virtual void
|
||||||
|
eventKeyPress (SDL_KeyboardEvent c);
|
||||||
|
virtual void
|
||||||
|
eventActivate (bool active);
|
||||||
|
virtual void
|
||||||
|
eventResize (SizeState sizeState);
|
||||||
|
virtual void
|
||||||
|
eventClose ();
|
||||||
|
virtual void
|
||||||
|
eventWindowEvent (SDL_WindowEvent event);
|
||||||
|
|
||||||
virtual void render();
|
virtual void
|
||||||
void toggleLanguage(string language);
|
render ();
|
||||||
bool getTriggerLanguageToggle() const { return triggerLanguageToggle; }
|
void
|
||||||
string getTriggerLanguage() const { return triggerLanguage; }
|
toggleLanguage (string language);
|
||||||
|
bool getTriggerLanguageToggle ()const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
triggerLanguageToggle;
|
||||||
|
}
|
||||||
|
string
|
||||||
|
getTriggerLanguage () const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
triggerLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
virtual int getDesiredScreenWidth();
|
virtual int
|
||||||
virtual int getDesiredScreenHeight();
|
getDesiredScreenWidth ();
|
||||||
|
virtual int
|
||||||
|
getDesiredScreenHeight ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void eventToggleFullScreen(bool isFullscreen);
|
virtual void
|
||||||
};
|
eventToggleFullScreen (bool isFullscreen);
|
||||||
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}} //end namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -10,26 +10,26 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
|
|
||||||
#ifndef _GLEST_GAME_PROGRAM_H_
|
#ifndef _GLEST_GAME_PROGRAM_H_
|
||||||
#define _GLEST_GAME_PROGRAM_H_
|
# define _GLEST_GAME_PROGRAM_H_
|
||||||
|
|
||||||
#ifdef WIN32
|
# ifdef WIN32
|
||||||
#include <winsock2.h>
|
# include <winsock2.h>
|
||||||
#include <winsock.h>
|
# include <winsock.h>
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
#include "context.h"
|
# include "context.h"
|
||||||
#include "platform_util.h"
|
# include "platform_util.h"
|
||||||
#include "window_gl.h"
|
# include "window_gl.h"
|
||||||
#include "socket.h"
|
# include "socket.h"
|
||||||
#include "components.h"
|
# include "components.h"
|
||||||
#include "window.h"
|
# include "window.h"
|
||||||
#include "simple_threads.h"
|
# include "simple_threads.h"
|
||||||
#include "stats.h"
|
# include "stats.h"
|
||||||
#include "leak_dumper.h"
|
# include "leak_dumper.h"
|
||||||
|
|
||||||
#ifndef PRINT_DEBUG
|
# ifndef PRINT_DEBUG
|
||||||
# define PRINT_DEBUG printf("[DEBUG] "); printf
|
# define PRINT_DEBUG printf("[DEBUG] "); printf
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
using Shared::Platform::MouseButton;
|
using Shared::Platform::MouseButton;
|
||||||
using Shared::Graphics::Context;
|
using Shared::Graphics::Context;
|
||||||
@@ -38,13 +38,18 @@ using Shared::Platform::SizeState;
|
|||||||
using Shared::Platform::MouseState;
|
using Shared::Platform::MouseState;
|
||||||
using Shared::PlatformCommon::PerformanceTimer;
|
using Shared::PlatformCommon::PerformanceTimer;
|
||||||
using Shared::Platform::Ip;
|
using Shared::Platform::Ip;
|
||||||
using namespace Shared::PlatformCommon;
|
using
|
||||||
|
namespace
|
||||||
|
Shared::PlatformCommon;
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest
|
||||||
|
{
|
||||||
|
namespace Game
|
||||||
|
{
|
||||||
|
|
||||||
class Program;
|
class Program;
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
class GameSettings;
|
class GameSettings;
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class ProgramState
|
// class ProgramState
|
||||||
@@ -53,196 +58,441 @@ class GameSettings;
|
|||||||
/// Intro, MainMenu, Game, BattleEnd (State Design pattern)
|
/// Intro, MainMenu, Game, BattleEnd (State Design pattern)
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
class ProgramState {
|
class ProgramState
|
||||||
protected:
|
{
|
||||||
Program *program;
|
protected:
|
||||||
|
Program * program;
|
||||||
|
|
||||||
int mouseX;
|
int
|
||||||
int mouseY;
|
mouseX;
|
||||||
int mouse2dAnim;
|
int
|
||||||
|
mouseY;
|
||||||
|
int
|
||||||
|
mouse2dAnim;
|
||||||
|
|
||||||
int startX;
|
int
|
||||||
int startY;
|
startX;
|
||||||
|
int
|
||||||
|
startY;
|
||||||
bool forceMouseRender;
|
bool forceMouseRender;
|
||||||
|
|
||||||
int fps;
|
int
|
||||||
int lastFps;
|
fps;
|
||||||
|
int
|
||||||
|
lastFps;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static const char *MAIN_PROGRAM_RENDER_KEY;
|
static const char *
|
||||||
|
MAIN_PROGRAM_RENDER_KEY;
|
||||||
|
|
||||||
explicit ProgramState(Program *program);
|
explicit ProgramState (Program * program);
|
||||||
virtual ~ProgramState(){};
|
virtual ~ ProgramState ()
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int getFps() const { return fps; }
|
int
|
||||||
int getLastFps() const { return lastFps; }
|
getFps () const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
fps;
|
||||||
|
}
|
||||||
|
int
|
||||||
|
getLastFps () const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
lastFps;
|
||||||
|
}
|
||||||
|
|
||||||
//virtual void render()=0;
|
//virtual void render()=0;
|
||||||
virtual bool canRender(bool sleepIfCannotRender=true);
|
virtual
|
||||||
virtual void render();
|
bool
|
||||||
virtual void update();
|
canRender (bool sleepIfCannotRender = true);
|
||||||
virtual void updateCamera(){};
|
virtual void
|
||||||
virtual void tick();
|
render ();
|
||||||
virtual void init(){};
|
virtual void
|
||||||
virtual void load(){};
|
update ();
|
||||||
virtual void end(){};
|
virtual void
|
||||||
virtual void mouseDownLeft(int x, int y){};
|
updateCamera ()
|
||||||
virtual void mouseUpLeft(int x, int y){};
|
{
|
||||||
virtual void mouseUpRight(int x, int y){}
|
};
|
||||||
virtual void mouseUpCenter(int x, int y){}
|
virtual void
|
||||||
virtual void mouseDownRight(int x, int y){};
|
tick ();
|
||||||
virtual void mouseDownCenter(int x, int y){}
|
virtual void
|
||||||
virtual void mouseDoubleClickLeft(int x, int y){};
|
init ()
|
||||||
virtual void mouseDoubleClickRight(int x, int y){}
|
{
|
||||||
virtual void mouseDoubleClickCenter(int x, int y){}
|
};
|
||||||
virtual void eventMouseWheel(int x, int y, int zDelta){}
|
virtual void
|
||||||
virtual void mouseMove(int x, int y, const MouseState *mouseState);
|
load ()
|
||||||
virtual bool textInput(std::string text){ return false; };
|
{
|
||||||
virtual void keyDown(SDL_KeyboardEvent key){};
|
};
|
||||||
virtual bool sdlKeyDown(SDL_KeyboardEvent key){ return false; };
|
virtual void
|
||||||
virtual void keyUp(SDL_KeyboardEvent key){};
|
end ()
|
||||||
virtual void keyPress(SDL_KeyboardEvent c){};
|
{
|
||||||
virtual void setStartXY(int X,int Y) { startX=X; startY=Y; }
|
};
|
||||||
virtual void restoreToStartXY();
|
virtual void
|
||||||
virtual bool isInSpecialKeyCaptureEvent() { return false; }
|
mouseDownLeft (int x, int y)
|
||||||
virtual bool quitTriggered() { return false; }
|
{
|
||||||
virtual Stats quitAndToggleState() { return Stats(); };
|
};
|
||||||
virtual Program * getProgram() { return program; }
|
virtual void
|
||||||
virtual const Program * getProgramConstPtr() { return program; }
|
mouseUpLeft (int x, int y)
|
||||||
virtual void setForceMouseRender(bool value) { forceMouseRender=value;}
|
{
|
||||||
virtual void consoleAddLine(string line) { };
|
};
|
||||||
|
virtual void
|
||||||
|
mouseUpRight (int x, int y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual void
|
||||||
|
mouseUpCenter (int x, int y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual void
|
||||||
|
mouseDownRight (int x, int y)
|
||||||
|
{
|
||||||
|
};
|
||||||
|
virtual void
|
||||||
|
mouseDownCenter (int x, int y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual void
|
||||||
|
mouseDoubleClickLeft (int x, int y)
|
||||||
|
{
|
||||||
|
};
|
||||||
|
virtual void
|
||||||
|
mouseDoubleClickRight (int x, int y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual void
|
||||||
|
mouseDoubleClickCenter (int x, int y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual void
|
||||||
|
eventMouseWheel (int x, int y, int zDelta)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual void
|
||||||
|
mouseMove (int x, int y, const MouseState * mouseState);
|
||||||
|
virtual
|
||||||
|
bool
|
||||||
|
textInput (std::string text)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
virtual void
|
||||||
|
keyDown (SDL_KeyboardEvent key)
|
||||||
|
{
|
||||||
|
};
|
||||||
|
virtual
|
||||||
|
bool
|
||||||
|
sdlKeyDown (SDL_KeyboardEvent key)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
virtual void
|
||||||
|
keyUp (SDL_KeyboardEvent key)
|
||||||
|
{
|
||||||
|
};
|
||||||
|
virtual void
|
||||||
|
keyPress (SDL_KeyboardEvent c)
|
||||||
|
{
|
||||||
|
};
|
||||||
|
virtual void
|
||||||
|
setStartXY (int X, int Y)
|
||||||
|
{
|
||||||
|
startX = X;
|
||||||
|
startY = Y;
|
||||||
|
}
|
||||||
|
virtual void
|
||||||
|
restoreToStartXY ();
|
||||||
|
virtual
|
||||||
|
bool
|
||||||
|
isInSpecialKeyCaptureEvent ()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
virtual
|
||||||
|
bool
|
||||||
|
quitTriggered ()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
virtual
|
||||||
|
Stats
|
||||||
|
quitAndToggleState ()
|
||||||
|
{
|
||||||
|
return Stats ();
|
||||||
|
};
|
||||||
|
virtual Program *
|
||||||
|
getProgram ()
|
||||||
|
{
|
||||||
|
return program;
|
||||||
|
}
|
||||||
|
virtual const Program *
|
||||||
|
getProgramConstPtr ()
|
||||||
|
{
|
||||||
|
return program;
|
||||||
|
}
|
||||||
|
virtual void
|
||||||
|
setForceMouseRender (bool value)
|
||||||
|
{
|
||||||
|
forceMouseRender = value;
|
||||||
|
}
|
||||||
|
virtual void
|
||||||
|
consoleAddLine (string line)
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
virtual void reloadUI() {};
|
virtual void
|
||||||
virtual void addPerformanceCount(string key,int64 value) {};
|
reloadUI ()
|
||||||
|
{
|
||||||
|
};
|
||||||
|
virtual void
|
||||||
|
addPerformanceCount (string key, int64 value)
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void incrementFps();
|
virtual void
|
||||||
};
|
incrementFps ();
|
||||||
|
};
|
||||||
|
|
||||||
// ===============================
|
// ===============================
|
||||||
// class Program
|
// class Program
|
||||||
// ===============================
|
// ===============================
|
||||||
|
|
||||||
class Program {
|
class Program
|
||||||
private:
|
{
|
||||||
static const int maxTimes;
|
private:
|
||||||
SimpleTaskThread *soundThreadManager;
|
static const int
|
||||||
|
maxTimes;
|
||||||
|
SimpleTaskThread *
|
||||||
|
soundThreadManager;
|
||||||
|
|
||||||
class ShowMessageProgramState : public ProgramState {
|
class ShowMessageProgramState:
|
||||||
|
public ProgramState
|
||||||
|
{
|
||||||
GraphicMessageBox msgBox;
|
GraphicMessageBox msgBox;
|
||||||
int mouseX;
|
int
|
||||||
int mouseY;
|
mouseX;
|
||||||
int mouse2dAnim;
|
int
|
||||||
|
mouseY;
|
||||||
|
int
|
||||||
|
mouse2dAnim;
|
||||||
string msg;
|
string msg;
|
||||||
bool userWantsExit;
|
bool userWantsExit;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ShowMessageProgramState(Program *program, const char *msg);
|
ShowMessageProgramState (Program * program, const char *msg);
|
||||||
|
|
||||||
virtual void render();
|
virtual void
|
||||||
virtual void mouseDownLeft(int x, int y);
|
render ();
|
||||||
virtual void mouseMove(int x, int y, const MouseState &mouseState);
|
virtual void
|
||||||
virtual void keyPress(SDL_KeyboardEvent c);
|
mouseDownLeft (int x, int y);
|
||||||
virtual void update();
|
virtual void
|
||||||
virtual bool wantExit() { return userWantsExit; }
|
mouseMove (int x, int y, const MouseState & mouseState);
|
||||||
|
virtual void
|
||||||
|
keyPress (SDL_KeyboardEvent c);
|
||||||
|
virtual void
|
||||||
|
update ();
|
||||||
|
virtual
|
||||||
|
bool
|
||||||
|
wantExit ()
|
||||||
|
{
|
||||||
|
return userWantsExit;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProgramState *programState;
|
ProgramState * programState;
|
||||||
|
|
||||||
PerformanceTimer fpsTimer;
|
PerformanceTimer fpsTimer;
|
||||||
PerformanceTimer updateTimer;
|
PerformanceTimer updateTimer;
|
||||||
PerformanceTimer updateCameraTimer;
|
PerformanceTimer updateCameraTimer;
|
||||||
|
|
||||||
WindowGl *window;
|
WindowGl *
|
||||||
static Program *singleton;
|
window;
|
||||||
|
static Program *
|
||||||
|
singleton;
|
||||||
|
|
||||||
GraphicMessageBox msgBox;
|
GraphicMessageBox msgBox;
|
||||||
int skipRenderFrameCount;
|
int
|
||||||
|
skipRenderFrameCount;
|
||||||
|
|
||||||
bool messageBoxIsSystemError;
|
bool messageBoxIsSystemError;
|
||||||
ProgramState *programStateOldSystemError;
|
ProgramState *
|
||||||
|
programStateOldSystemError;
|
||||||
|
|
||||||
//bool masterserverMode;
|
//bool masterserverMode;
|
||||||
bool shutdownApplicationEnabled;
|
bool shutdownApplicationEnabled;
|
||||||
static bool wantShutdownApplicationAfterGame;
|
static
|
||||||
|
bool
|
||||||
|
wantShutdownApplicationAfterGame;
|
||||||
|
|
||||||
static bool tryingRendererInit;
|
static
|
||||||
static bool rendererInitOk;
|
bool
|
||||||
|
tryingRendererInit;
|
||||||
|
static
|
||||||
|
bool
|
||||||
|
rendererInitOk;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Program();
|
Program ();
|
||||||
virtual ~Program();
|
virtual ~ Program ();
|
||||||
|
|
||||||
static bool getTryingRendererInit() { return tryingRendererInit; }
|
static
|
||||||
static bool getRendererInitOk() { return rendererInitOk; }
|
bool
|
||||||
|
getTryingRendererInit ()
|
||||||
|
{
|
||||||
|
return tryingRendererInit;
|
||||||
|
}
|
||||||
|
static
|
||||||
|
bool
|
||||||
|
getRendererInitOk ()
|
||||||
|
{
|
||||||
|
return rendererInitOk;
|
||||||
|
}
|
||||||
|
|
||||||
static Program *getInstance() { return singleton; }
|
static Program *
|
||||||
|
getInstance ()
|
||||||
|
{
|
||||||
|
return singleton;
|
||||||
|
}
|
||||||
|
|
||||||
static void setWantShutdownApplicationAfterGame(bool value) { wantShutdownApplicationAfterGame = value; }
|
static void
|
||||||
static bool getWantShutdownApplicationAfterGame() { return wantShutdownApplicationAfterGame; }
|
setWantShutdownApplicationAfterGame (bool value)
|
||||||
|
{
|
||||||
|
wantShutdownApplicationAfterGame = value;
|
||||||
|
}
|
||||||
|
static
|
||||||
|
bool
|
||||||
|
getWantShutdownApplicationAfterGame ()
|
||||||
|
{
|
||||||
|
return wantShutdownApplicationAfterGame;
|
||||||
|
}
|
||||||
|
|
||||||
//bool isMasterserverMode() const;
|
//bool isMasterserverMode() const;
|
||||||
bool isShutdownApplicationEnabled() const { return shutdownApplicationEnabled; }
|
bool isShutdownApplicationEnabled ()const
|
||||||
void setShutdownApplicationEnabled(bool value) { shutdownApplicationEnabled = value; }
|
{
|
||||||
|
return
|
||||||
|
shutdownApplicationEnabled;
|
||||||
|
}
|
||||||
|
void
|
||||||
|
setShutdownApplicationEnabled (bool value)
|
||||||
|
{
|
||||||
|
shutdownApplicationEnabled = value;
|
||||||
|
}
|
||||||
|
|
||||||
GraphicMessageBox * getMsgBox() { return &msgBox; }
|
GraphicMessageBox *
|
||||||
void initNormal(WindowGl *window);
|
getMsgBox ()
|
||||||
void initServer(WindowGl *window,bool autostart=false,bool openNetworkSlots=false,bool masterserverMode=false);
|
{
|
||||||
void initServer(WindowGl *window, GameSettings *settings);
|
return &msgBox;
|
||||||
void initSavedGame(WindowGl *window,bool masterserverMode=false,string saveGameFile="");
|
}
|
||||||
void initClient(WindowGl *window, const Ip &serverIp,int portNumber=-1);
|
void
|
||||||
void initClientAutoFindHost(WindowGl *window);
|
initNormal (WindowGl * window);
|
||||||
void initScenario(WindowGl *window, string autoloadScenarioName);
|
void
|
||||||
|
initServer (WindowGl * window, bool autostart =
|
||||||
|
false, bool openNetworkSlots =
|
||||||
|
false, bool masterserverMode = false);
|
||||||
|
void
|
||||||
|
initServer (WindowGl * window, GameSettings * settings);
|
||||||
|
void
|
||||||
|
initSavedGame (WindowGl * window, bool masterserverMode =
|
||||||
|
false, string saveGameFile = "");
|
||||||
|
void
|
||||||
|
initClient (WindowGl * window, const Ip & serverIp, int portNumber =
|
||||||
|
-1);
|
||||||
|
void
|
||||||
|
initClientAutoFindHost (WindowGl * window);
|
||||||
|
void
|
||||||
|
initScenario (WindowGl * window, string autoloadScenarioName);
|
||||||
|
|
||||||
//main
|
//main
|
||||||
bool textInput(std::string text);
|
bool textInput (std::string text);
|
||||||
void keyDown(SDL_KeyboardEvent key);
|
void
|
||||||
bool sdlKeyDown(SDL_KeyboardEvent key);
|
keyDown (SDL_KeyboardEvent key);
|
||||||
void keyUp(SDL_KeyboardEvent key);
|
bool sdlKeyDown (SDL_KeyboardEvent key);
|
||||||
void keyPress(SDL_KeyboardEvent c);
|
void
|
||||||
|
keyUp (SDL_KeyboardEvent key);
|
||||||
|
void
|
||||||
|
keyPress (SDL_KeyboardEvent c);
|
||||||
|
|
||||||
void loop();
|
void
|
||||||
void loopWorker();
|
loop ();
|
||||||
void resize(SizeState sizeState);
|
void
|
||||||
void showMessage(const char *msg);
|
loopWorker ();
|
||||||
bool isMessageShowing();
|
void
|
||||||
|
resize (SizeState sizeState);
|
||||||
|
void
|
||||||
|
showMessage (const char *msg);
|
||||||
|
bool isMessageShowing ();
|
||||||
|
|
||||||
//misc
|
//misc
|
||||||
void setState(ProgramState *programStateNew,bool cleanupOldState=true);
|
void
|
||||||
ProgramState * getState() { return programState;}
|
setState (ProgramState * programStateNew, bool cleanupOldState = true);
|
||||||
WindowGl * getWindow() { return window; }
|
ProgramState *
|
||||||
const WindowGl * getWindowConstPtr() const { return window; }
|
getState ()
|
||||||
void init(WindowGl *window, bool initSound=true, bool toggleFullScreen=false);
|
{
|
||||||
void exit();
|
return programState;
|
||||||
|
}
|
||||||
|
WindowGl *
|
||||||
|
getWindow ()
|
||||||
|
{
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
const WindowGl *
|
||||||
|
getWindowConstPtr () const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
window;
|
||||||
|
}
|
||||||
|
void
|
||||||
|
init (WindowGl * window, bool initSound = true, bool toggleFullScreen =
|
||||||
|
false);
|
||||||
|
void
|
||||||
|
exit ();
|
||||||
|
|
||||||
virtual void simpleTask(BaseThread *callingThread,void *userdata);
|
virtual void
|
||||||
|
simpleTask (BaseThread * callingThread, void *userdata);
|
||||||
|
|
||||||
void mouseDownLeft(int x, int y);
|
void
|
||||||
void eventMouseMove(int x, int y, const MouseState *ms);
|
mouseDownLeft (int x, int y);
|
||||||
|
void
|
||||||
|
eventMouseMove (int x, int y, const MouseState * ms);
|
||||||
|
|
||||||
void renderProgramMsgBox();
|
void
|
||||||
bool isInSpecialKeyCaptureEvent() { return programState->isInSpecialKeyCaptureEvent(); }
|
renderProgramMsgBox ();
|
||||||
|
bool isInSpecialKeyCaptureEvent ()
|
||||||
|
{
|
||||||
|
return programState->isInSpecialKeyCaptureEvent ();
|
||||||
|
}
|
||||||
|
|
||||||
//void reInitGl();
|
//void reInitGl();
|
||||||
//void resetSoundSystem();
|
//void resetSoundSystem();
|
||||||
void stopSoundSystem();
|
void
|
||||||
void startSoundSystem();
|
stopSoundSystem ();
|
||||||
|
void
|
||||||
|
startSoundSystem ();
|
||||||
|
|
||||||
virtual void consoleAddLine(string line);
|
virtual void
|
||||||
|
consoleAddLine (string line);
|
||||||
|
|
||||||
virtual SimpleTaskThread * getSoundThreadManager(bool takeOwnership);
|
virtual SimpleTaskThread *
|
||||||
virtual void reloadUI();
|
getSoundThreadManager (bool takeOwnership);
|
||||||
|
virtual void
|
||||||
|
reloadUI ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void setDisplaySettings();
|
void
|
||||||
void restoreDisplaySettings();
|
setDisplaySettings ();
|
||||||
void restoreStateFromSystemError();
|
void
|
||||||
void initResolution();
|
restoreDisplaySettings ();
|
||||||
};
|
void
|
||||||
|
restoreStateFromSystemError ();
|
||||||
|
void
|
||||||
|
initResolution ();
|
||||||
|
};
|
||||||
|
|
||||||
}} //end namespace
|
}} //end namespace
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user