summaryrefslogtreecommitdiffstats
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/app.cpp602
-rw-r--r--src/app/app.h174
-rw-r--r--src/app/main.cpp18
-rw-r--r--src/app/system.cpp340
-rw-r--r--src/app/system.h28
5 files changed, 581 insertions, 581 deletions
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 726d32d..466d757 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -34,492 +34,492 @@
*/
struct ApplicationPrivate
{
- //! Display surface
- SDL_Surface *surface;
- //! Currently handled event
- SDL_Event currentEvent;
- //! Joystick
- SDL_Joystick *joystick;
- //! Index of joystick device
- int joystickDevice;
-
- ApplicationPrivate()
- {
- memset(&currentEvent, 0, sizeof(SDL_Event));
- surface = NULL;
- joystick = NULL;
- joystickDevice = 0;
- }
+ //! Display surface
+ SDL_Surface *surface;
+ //! Currently handled event
+ SDL_Event currentEvent;
+ //! Joystick
+ SDL_Joystick *joystick;
+ //! Index of joystick device
+ int joystickDevice;
+
+ ApplicationPrivate()
+ {
+ memset(&currentEvent, 0, sizeof(SDL_Event));
+ surface = NULL;
+ joystick = NULL;
+ joystickDevice = 0;
+ }
};
CApplication::CApplication()
{
- m_private = new ApplicationPrivate();
- m_exitCode = 0;
+ m_private = new ApplicationPrivate();
+ m_exitCode = 0;
- m_iMan = new CInstanceManager();
- m_event = new CEvent(m_iMan);
+ m_iMan = new CInstanceManager();
+ m_event = new CEvent(m_iMan);
- m_engine = 0;
- m_robotMain = 0;
- m_sound = 0;
+ m_engine = 0;
+ m_robotMain = 0;
+ m_sound = 0;
- m_keyState = 0;
- m_axeKey = Math::Vector(0.0f, 0.0f, 0.0f);
- m_axeJoy = Math::Vector(0.0f, 0.0f, 0.0f);
+ m_keyState = 0;
+ m_axeKey = Math::Vector(0.0f, 0.0f, 0.0f);
+ m_axeJoy = Math::Vector(0.0f, 0.0f, 0.0f);
- m_vidMemTotal = 0;
- m_active = false;
- m_activateApp = false;
- m_ready = false;
- m_joystick = false;
- m_time = 0.0f;
+ m_vidMemTotal = 0;
+ m_active = false;
+ m_activateApp = false;
+ m_ready = false;
+ m_joystick = false;
+ m_time = 0.0f;
- for (int i = 0; i < 32; i++)
- {
- m_joyButton[i] = false;
- }
+ for (int i = 0; i < 32; i++)
+ {
+ m_joyButton[i] = false;
+ }
- m_windowTitle = "COLOBOT";
+ m_windowTitle = "COLOBOT";
- m_appUseZBuffer = true;
- m_appUseStereo = true;
- m_showStats = false;
- m_debugMode = false;
- m_audioState = true;
- m_audioTrack = true;
- m_niceMouse = false;
- m_setupMode = true;
+ m_appUseZBuffer = true;
+ m_appUseStereo = true;
+ m_showStats = false;
+ m_debugMode = false;
+ m_audioState = true;
+ m_audioTrack = true;
+ m_niceMouse = false;
+ m_setupMode = true;
- ResetKey();
+ ResetKey();
}
CApplication::~CApplication()
{
- delete m_private;
- m_private = NULL;
+ delete m_private;
+ m_private = NULL;
- delete m_iMan;
- m_iMan = NULL;
+ delete m_iMan;
+ m_iMan = NULL;
}
Error CApplication::ParseArguments(int argc, char *argv[])
{
- for (int i = 1; i < argc; ++i)
- {
- std::string arg = argv[i];
-
- if (arg == "-debug")
- {
- m_showStats = true;
- SetDebugMode(true);
- }
- else if (arg == "-audiostate")
- {
- m_audioState = false;
- }
- else if (arg == "-audiotrack")
- {
- m_audioTrack = false;
- }
- // TODO else {} report invalid argument
- }
-
- return ERR_OK;
+ for (int i = 1; i < argc; ++i)
+ {
+ std::string arg = argv[i];
+
+ if (arg == "-debug")
+ {
+ m_showStats = true;
+ SetDebugMode(true);
+ }
+ else if (arg == "-audiostate")
+ {
+ m_audioState = false;
+ }
+ else if (arg == "-audiotrack")
+ {
+ m_audioTrack = false;
+ }
+ // TODO else {} report invalid argument
+ }
+
+ return ERR_OK;
}
bool CApplication::Create()
{
/*
TODO
- Full screen by default unless in debug mode
- if (! m_debugMode)
- m_deviceConfig.fullScreen = true;
+ Full screen by default unless in debug mode
+ if (! m_debugMode)
+ m_deviceConfig.fullScreen = true;
- int full = 0;
- if (GetProfileInt("Device", "FullScreen", full))
- m_deviceConfig.fullScreen = full == 1;
+ int full = 0;
+ if (GetProfileInt("Device", "FullScreen", full))
+ m_deviceConfig.fullScreen = full == 1;
*/
- // Temporarily -- only in windowed mode
- m_deviceConfig.fullScreen = false;
+ // Temporarily -- only in windowed mode
+ m_deviceConfig.fullScreen = false;
/*
TODO
- // Create the 3D engine.
- m_engine = new CEngine(m_iMan, this);
+ // Create the 3D engine.
+ m_engine = new CEngine(m_iMan, this);
- // Initialize the app's custom scene stuff
- if (! m_engine->OneTimeSceneInit())
- {
- SystemDialog(SDT_ERROR, "COLOBOT - Error", m_engine->RetError());
- return false;
- }
+ // Initialize the app's custom scene stuff
+ if (! m_engine->OneTimeSceneInit())
+ {
+ SystemDialog(SDT_ERROR, "COLOBOT - Error", m_engine->RetError());
+ return false;
+ }
- // Create the sound instance.
- m_sound = new CSound(m_iMan);
+ // Create the sound instance.
+ m_sound = new CSound(m_iMan);
- // Create the robot application.
- m_robotMain = new CRobotMain(m_iMan);
+ // Create the robot application.
+ m_robotMain = new CRobotMain(m_iMan);
*/
- Uint32 initFlags = SDL_INIT_VIDEO;
- if (m_joystick)
- initFlags |= SDL_INIT_JOYSTICK;
+ Uint32 initFlags = SDL_INIT_VIDEO;
+ if (m_joystick)
+ initFlags |= SDL_INIT_JOYSTICK;
- if (SDL_Init(initFlags) < 0)
- {
- SystemDialog( SDT_ERROR, "COLOBOT - Error", "SDL initialization error:\n" + std::string(SDL_GetError()) );
- return false;
- }
+ if (SDL_Init(initFlags) < 0)
+ {
+ SystemDialog( SDT_ERROR, "COLOBOT - Error", "SDL initialization error:\n" + std::string(SDL_GetError()) );
+ return false;
+ }
- const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
- if (! videoInfo)
- {
- SystemDialog( SDT_ERROR, "COLOBOT - Error", "SDL error while getting video info:\n " + std::string(SDL_GetError()) );
- return false;
- }
+ const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
+ if (! videoInfo)
+ {
+ SystemDialog( SDT_ERROR, "COLOBOT - Error", "SDL error while getting video info:\n " + std::string(SDL_GetError()) );
+ return false;
+ }
- Uint32 videoFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;
+ Uint32 videoFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;
- if (m_deviceConfig.resizeable)
- videoFlags |= SDL_RESIZABLE;
+ if (m_deviceConfig.resizeable)
+ videoFlags |= SDL_RESIZABLE;
- // Use hardware surface if available
- if (videoInfo->hw_available)
- videoFlags |= SDL_HWSURFACE;
- else
- videoFlags |= SDL_SWSURFACE;
+ // Use hardware surface if available
+ if (videoInfo->hw_available)
+ videoFlags |= SDL_HWSURFACE;
+ else
+ videoFlags |= SDL_SWSURFACE;
- // Enable hardware blit if available
- if (videoInfo->blit_hw)
- videoFlags |= SDL_HWACCEL;
+ // Enable hardware blit if available
+ if (videoInfo->blit_hw)
+ videoFlags |= SDL_HWACCEL;
- if (m_deviceConfig.fullScreen)
- videoFlags |= SDL_FULLSCREEN;
+ if (m_deviceConfig.fullScreen)
+ videoFlags |= SDL_FULLSCREEN;
- SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+ SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
+ SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- if ((IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG) == 0)
- {
- SystemDialog( SDT_ERROR, "COLOBOT - Error", std::string("SDL_Image initialization error:\n") +
- std::string(IMG_GetError()) );
- return false;
- }
+ if ((IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG) == 0)
+ {
+ SystemDialog( SDT_ERROR, "COLOBOT - Error", std::string("SDL_Image initialization error:\n") +
+ std::string(IMG_GetError()) );
+ return false;
+ }
- m_private->surface = SDL_SetVideoMode(m_deviceConfig.width, m_deviceConfig.height,
- m_deviceConfig.bpp, videoFlags);
+ m_private->surface = SDL_SetVideoMode(m_deviceConfig.width, m_deviceConfig.height,
+ m_deviceConfig.bpp, videoFlags);
- if (! m_private->surface)
- {
- SystemDialog( SDT_ERROR, "COLOBT - Error", std::string("SDL error while setting video mode:\n") +
- std::string(SDL_GetError()) );
- return false;
- }
+ if (! m_private->surface)
+ {
+ SystemDialog( SDT_ERROR, "COLOBT - Error", std::string("SDL error while setting video mode:\n") +
+ std::string(SDL_GetError()) );
+ return false;
+ }
- SDL_WM_SetCaption(m_windowTitle.c_str(), m_windowTitle.c_str());
+ SDL_WM_SetCaption(m_windowTitle.c_str(), m_windowTitle.c_str());
- SDL_EnableUNICODE(1);
+ SDL_EnableUNICODE(1);
/*
TODO
- InitJoystick();
+ InitJoystick();
- if ( !GetProfileInt("Setup", "Sound3D", b3D) )
- {
- b3D = true;
- }
- m_pSound->SetDebugMode(m_bDebugMode);
- m_pSound->Create(m_hWnd, b3D);
- m_pSound->CacheAll();
- m_pSound->SetState(m_bAudioState);
- m_pSound->SetAudioTrack(m_bAudioTrack);
- m_pSound->SetCDpath(m_CDpath);
+ if ( !GetProfileInt("Setup", "Sound3D", b3D) )
+ {
+ b3D = true;
+ }
+ m_pSound->SetDebugMode(m_bDebugMode);
+ m_pSound->Create(m_hWnd, b3D);
+ m_pSound->CacheAll();
+ m_pSound->SetState(m_bAudioState);
+ m_pSound->SetAudioTrack(m_bAudioTrack);
+ m_pSound->SetCDpath(m_CDpath);
- // First execution?
- if ( !GetProfileInt("Setup", "ObjectDirty", iValue) )
- {
- m_pD3DEngine->FirstExecuteAdapt(true);
- }
+ // First execution?
+ if ( !GetProfileInt("Setup", "ObjectDirty", iValue) )
+ {
+ m_pD3DEngine->FirstExecuteAdapt(true);
+ }
- // Creates the file colobot.ini at the first execution.
- m_pRobotMain->CreateIni();
+ // Creates the file colobot.ini at the first execution.
+ m_pRobotMain->CreateIni();
- m_pRobotMain->ChangePhase(PHASE_WELCOME2);
+ m_pRobotMain->ChangePhase(PHASE_WELCOME2);
- m_engine->TimeInit();
+ m_engine->TimeInit();
*/
- // The app is ready to go
- m_ready = true;
+ // The app is ready to go
+ m_ready = true;
- return true;
+ return true;
}
void CApplication::Destroy()
{
- if (m_private->joystick != NULL)
- {
- SDL_JoystickClose(m_private->joystick);
- m_private->joystick = NULL;
- }
+ if (m_private->joystick != NULL)
+ {
+ SDL_JoystickClose(m_private->joystick);
+ m_private->joystick = NULL;
+ }
- SDL_FreeSurface(m_private->surface);
- m_private->surface = NULL;
+ SDL_FreeSurface(m_private->surface);
+ m_private->surface = NULL;
- IMG_Quit();
+ IMG_Quit();
- SDL_Quit();
+ SDL_Quit();
}
int CApplication::Run()
{
- m_active = true;
-
- while (m_private->currentEvent.type != SDL_QUIT)
- {
- // Use SDL_PeepEvents() if the app is active, so we can use idle time to
- // render the scene. Else, use SDL_PollEvent() to avoid eating CPU time.
- int count = 0;
- if (m_active)
- {
- SDL_PumpEvents();
- count = SDL_PeepEvents(&m_private->currentEvent, 1, SDL_GETEVENT, SDL_ALLEVENTS);
- }
- else
- {
- SDL_PollEvent(&m_private->currentEvent);
- }
-
- // If received an event
- if ((m_active && count > 0) || (!m_active))
- {
- ParseEvent();
- }
-
- // Render a frame during idle time (no messages are waiting)
- if (m_active && m_ready)
- {
- Event event;
- while (m_event->GetEvent(event))
- {
- if (event.event == EVENT_QUIT)
- {
- goto end; // exit both loops
- }
-
- //m_robotMain->EventProcess(event);
- }
-
- //if ( !RetNiceMouse())
- //{
- // SetMouseType(m_engine->RetMouseType());
- //}
-
- // If an error occurs, push quit event to the queue
- if (! Render())
- {
- SDL_Event quitEvent;
- memset(&quitEvent, 0, sizeof(SDL_Event));
- quitEvent.type = SDL_QUIT;
- SDL_PushEvent(&quitEvent);
- }
- }
- }
+ m_active = true;
+
+ while (m_private->currentEvent.type != SDL_QUIT)
+ {
+ // Use SDL_PeepEvents() if the app is active, so we can use idle time to
+ // render the scene. Else, use SDL_PollEvent() to avoid eating CPU time.
+ int count = 0;
+ if (m_active)
+ {
+ SDL_PumpEvents();
+ count = SDL_PeepEvents(&m_private->currentEvent, 1, SDL_GETEVENT, SDL_ALLEVENTS);
+ }
+ else
+ {
+ SDL_PollEvent(&m_private->currentEvent);
+ }
+
+ // If received an event
+ if ((m_active && count > 0) || (!m_active))
+ {
+ ParseEvent();
+ }
+
+ // Render a frame during idle time (no messages are waiting)
+ if (m_active && m_ready)
+ {
+ Event event;
+ while (m_event->GetEvent(event))
+ {
+ if (event.event == EVENT_QUIT)
+ {
+ goto end; // exit both loops
+ }
+
+ //m_robotMain->EventProcess(event);
+ }
+
+ //if ( !RetNiceMouse())
+ //{
+ // SetMouseType(m_engine->RetMouseType());
+ //}
+
+ // If an error occurs, push quit event to the queue
+ if (! Render())
+ {
+ SDL_Event quitEvent;
+ memset(&quitEvent, 0, sizeof(SDL_Event));
+ quitEvent.type = SDL_QUIT;
+ SDL_PushEvent(&quitEvent);
+ }
+ }
+ }
end:
- //m_sound->StopMusic();
- Destroy();
+ //m_sound->StopMusic();
+ Destroy();
- return m_exitCode;
+ return m_exitCode;
}
void CApplication::ParseEvent()
{
-/* Event event;
-
- if (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN)
- {
- if (m_private->currentEvent.button.button == SDL_BUTTON_LEFT)
- event.event = EVENT_LBUTTONDOWN;
- else if (m_private->currentEvent.button.button == SDL_BUTTON_RIGHT)
- event.event = EVENT_RBUTTONDOWN;
- }
- else if (m_private->currentEvent.type == SDL_MOUSEBUTTONUP)
- {
- if (m_private->currentEvent.button.button == SDL_BUTTON_LEFT)
- event.event = EVENT_LBUTTONUP;
- else if (m_private->currentEvent.button.button == SDL_BUTTON_RIGHT)
- event.event = EVENT_RBUTTONUP;
- }
- else if (m_private->currentEvent.type == SDL_MOUSEMOTION)
- {
- event.event = EVENT_MOUSEMOVE;
- }
- else if (m_private->currentEvent.type == SDL_KEYDOWN)
- {
- event.event = EVENT_KEYDOWN;
- }
- else if (m_private->currentEvent.type == SDL_KEYUP)
- {
- event.event = EVENT_KEYUP;
- }
-
- if (m_robotMain != NULL && event.event != EVENT_NULL)
- {
- m_robotMain->EventProcess(event);
- }
- if (m_engine != NULL)
- {
- m_engine->MsgProc( hWnd, uMsg, wParam, lParam );
- }
-
- ProcessEvent(event);*/
+/* Event event;
+
+ if (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN)
+ {
+ if (m_private->currentEvent.button.button == SDL_BUTTON_LEFT)
+ event.event = EVENT_LBUTTONDOWN;
+ else if (m_private->currentEvent.button.button == SDL_BUTTON_RIGHT)
+ event.event = EVENT_RBUTTONDOWN;
+ }
+ else if (m_private->currentEvent.type == SDL_MOUSEBUTTONUP)
+ {
+ if (m_private->currentEvent.button.button == SDL_BUTTON_LEFT)
+ event.event = EVENT_LBUTTONUP;
+ else if (m_private->currentEvent.button.button == SDL_BUTTON_RIGHT)
+ event.event = EVENT_RBUTTONUP;
+ }
+ else if (m_private->currentEvent.type == SDL_MOUSEMOTION)
+ {
+ event.event = EVENT_MOUSEMOVE;
+ }
+ else if (m_private->currentEvent.type == SDL_KEYDOWN)
+ {
+ event.event = EVENT_KEYDOWN;
+ }
+ else if (m_private->currentEvent.type == SDL_KEYUP)
+ {
+ event.event = EVENT_KEYUP;
+ }
+
+ if (m_robotMain != NULL && event.event != EVENT_NULL)
+ {
+ m_robotMain->EventProcess(event);
+ }
+ if (m_engine != NULL)
+ {
+ m_engine->MsgProc( hWnd, uMsg, wParam, lParam );
+ }
+
+ ProcessEvent(event);*/
}
void CApplication::ProcessEvent(Event event)
{
-
+
}
bool CApplication::Render()
{
- bool result = m_engine->Render();
- if (! result)
- return false;
+ bool result = m_engine->Render();
+ if (! result)
+ return false;
- if (m_deviceConfig.doubleBuf)
- SDL_GL_SwapBuffers();
+ if (m_deviceConfig.doubleBuf)
+ SDL_GL_SwapBuffers();
- return true;
+ return true;
}
void CApplication::Pause(bool pause)
{
- // TODO
+ // TODO
}
void CApplication::SetMousePos(Math::Point pos)
{
- // TODO
+ // TODO
}
void CApplication::StepSimulation(float rTime)
{
- // TODO
+ // TODO
}
void SetShowStat(bool show)
{
- // TODO
+ // TODO
}
bool CApplication::RetShowStat()
{
- // TODO
- return false;
+ // TODO
+ return false;
}
void CApplication::SetDebugMode(bool mode)
{
- // TODO
+ // TODO
}
bool CApplication::RetDebugMode()
{
- // TODO
- return false;
+ // TODO
+ return false;
}
bool CApplication::RetSetupMode()
{
- // TODO
- return false;
+ // TODO
+ return false;
}
void CApplication::FlushPressKey()
{
- // TODO
+ // TODO
}
void CApplication::ResetKey()
{
- // TODO
+ // TODO
}
void CApplication::SetKey(int keyRank, int option, int key)
{
- // TODO
+ // TODO
}
int CApplication::RetKey(int keyRank, int option)
{
- // TODO
- return 0;
+ // TODO
+ return 0;
}
void CApplication::SetJoystick(bool enable)
{
- // TODO
+ // TODO
}
bool CApplication::RetJoystick()
{
- // TODO
- return false;
+ // TODO
+ return false;
}
void SetMouseType(Gfx::MouseType type)
{
- // TODO
+ // TODO
}
void SetNiceMouse(bool nice)
{
- // TODO
+ // TODO
}
bool CApplication::RetNiceMouse()
{
- return false;
+ return false;
}
bool CApplication::RetNiceMouseCap()
{
- return false;
+ return false;
}
bool CApplication::WriteScreenShot(char *filename, int width, int height)
{
- // TODO
+ // TODO
}
void CApplication::InitText()
{
- // TODO
+ // TODO
}
void CApplication::DrawSuppl()
{
- // TODO
+ // TODO
}
void CApplication::ShowStats()
{
- // TODO
+ // TODO
}
void CApplication::OutputText(long x, long y, char* str)
{
- // TODO
+ // TODO
}
diff --git a/src/app/app.h b/src/app/app.h
index ee6184f..a58ea98 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -46,108 +46,108 @@ struct ApplicationPrivate;
class CApplication
{
public:
- //! Constructor (can only be called once!)
- CApplication();
- //! Destructor
- ~CApplication();
+ //! Constructor (can only be called once!)
+ CApplication();
+ //! Destructor
+ ~CApplication();
public:
- //! Parses commandline arguments
- Error ParseArguments(int argc, char *argv[]);
- //! Initializes the application
- bool Create();
- //! Main event loop
- int Run();
+ //! Parses commandline arguments
+ Error ParseArguments(int argc, char *argv[]);
+ //! Initializes the application
+ bool Create();
+ //! Main event loop
+ int Run();
protected:
- //! Cleans up before exit
- void Destroy();
- //! Processes an SDL event to Event struct
- void ParseEvent();
- //! Handles some incoming events
- void ProcessEvent(Event event);
- //! Renders the image in window
- bool Render();
+ //! Cleans up before exit
+ void Destroy();
+ //! Processes an SDL event to Event struct
+ void ParseEvent();
+ //! Handles some incoming events
+ void ProcessEvent(Event event);
+ //! Renders the image in window
+ bool Render();
public:
- void Pause(bool pause);
- void StepSimulation(float rTime);
+ void Pause(bool pause);
+ void StepSimulation(float rTime);
- void SetMousePos(Math::Point pos);
+ void SetMousePos(Math::Point pos);
- void SetShowStat(bool show);
- bool RetShowStat();
- void SetDebugMode(bool mode);
- bool RetDebugMode();
- bool RetSetupMode();
+ void SetShowStat(bool show);
+ bool RetShowStat();
+ void SetDebugMode(bool mode);
+ bool RetDebugMode();
+ bool RetSetupMode();
- void FlushPressKey();
- void ResetKey();
- void SetKey(int keyRank, int option, int key);
- int RetKey(int keyRank, int option);
+ void FlushPressKey();
+ void ResetKey();
+ void SetKey(int keyRank, int option, int key);
+ int RetKey(int keyRank, int option);
- void SetJoystick(bool enable);
- bool RetJoystick();
+ void SetJoystick(bool enable);
+ bool RetJoystick();
- void SetMouseType(Gfx::MouseType type);
- void SetNiceMouse(bool nice);
- bool RetNiceMouse();
- bool RetNiceMouseCap();
+ void SetMouseType(Gfx::MouseType type);
+ void SetNiceMouse(bool nice);
+ bool RetNiceMouse();
+ bool RetNiceMouseCap();
- bool WriteScreenShot(char *filename, int width, int height);
+ bool WriteScreenShot(char *filename, int width, int height);
protected:
- //HRESULT ConfirmDevice( DDCAPS* pddDriverCaps, D3DDEVICEDESC7* pd3dDeviceDesc );
- //HRESULT Initialize3DEnvironment();
- //HRESULT Change3DEnvironment();
- //HRESULT CreateZBuffer(GUID* pDeviceGUID);
- //HRESULT Render3DEnvironment();
- //VOID Cleanup3DEnvironment();
- //VOID DeleteDeviceObjects();
- //VOID DisplayFrameworkError( HRESULT, DWORD );
-
- void InitText();
- void DrawSuppl();
- void ShowStats();
- void OutputText(long x, long y, char* str);
+ //HRESULT ConfirmDevice( DDCAPS* pddDriverCaps, D3DDEVICEDESC7* pd3dDeviceDesc );
+ //HRESULT Initialize3DEnvironment();
+ //HRESULT Change3DEnvironment();
+ //HRESULT CreateZBuffer(GUID* pDeviceGUID);
+ //HRESULT Render3DEnvironment();
+ //VOID Cleanup3DEnvironment();
+ //VOID DeleteDeviceObjects();
+ //VOID DisplayFrameworkError( HRESULT, DWORD );
+
+ void InitText();
+ void DrawSuppl();
+ void ShowStats();
+ void OutputText(long x, long y, char* str);
protected:
- //! Private (SDL-dependent data)
- ApplicationPrivate* m_private;
- CInstanceManager* m_iMan;
- Gfx::DeviceConfig m_deviceConfig;
- Gfx::CEngine* m_engine;
- CEvent* m_event;
- CRobotMain* m_robotMain;
- CSound* m_sound;
-
- //! Code to return at exit
- int m_exitCode;
-
- bool m_active;
- bool m_activateApp;
- bool m_ready;
- bool m_joystick;
-
- std::string m_windowTitle;
- long m_vidMemTotal;
- bool m_appUseZBuffer;
- bool m_appUseStereo;
- bool m_showStats;
- bool m_debugMode;
- bool m_audioState;
- bool m_audioTrack;
- bool m_niceMouse;
- bool m_setupMode;
-
- int m_keyState;
- Math::Vector m_axeKey;
- Math::Vector m_axeJoy;
- bool m_joyButton[32];
- Math::Point m_mousePos;
- long m_mouseWheel;
-
- float m_time;
- long m_key[50][2];
+ //! Private (SDL-dependent data)
+ ApplicationPrivate* m_private;
+ CInstanceManager* m_iMan;
+ Gfx::DeviceConfig m_deviceConfig;
+ Gfx::CEngine* m_engine;
+ CEvent* m_event;
+ CRobotMain* m_robotMain;
+ CSound* m_sound;
+
+ //! Code to return at exit
+ int m_exitCode;
+
+ bool m_active;
+ bool m_activateApp;
+ bool m_ready;
+ bool m_joystick;
+
+ std::string m_windowTitle;
+ long m_vidMemTotal;
+ bool m_appUseZBuffer;
+ bool m_appUseStereo;
+ bool m_showStats;
+ bool m_debugMode;
+ bool m_audioState;
+ bool m_audioTrack;
+ bool m_niceMouse;
+ bool m_setupMode;
+
+ int m_keyState;
+ Math::Vector m_axeKey;
+ Math::Vector m_axeJoy;
+ bool m_joyButton[32];
+ Math::Point m_mousePos;
+ long m_mouseWheel;
+
+ float m_time;
+ long m_key[50][2];
};
diff --git a/src/app/main.cpp b/src/app/main.cpp
index 28d21ee..54d305e 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -26,16 +26,16 @@
//! Entry point to the program
int main(int argc, char *argv[])
{
- CApplication app; // single instance of the application
+ CApplication app; // single instance of the application
- Error err = app.ParseArguments(argc, argv);
- if (err != ERR_OK)
- {
- SystemDialog(SDT_ERROR, "COLOBOT", "Invalid commandline arguments!\n");
- }
+ Error err = app.ParseArguments(argc, argv);
+ if (err != ERR_OK)
+ {
+ SystemDialog(SDT_ERROR, "COLOBOT", "Invalid commandline arguments!\n");
+ }
- if (! app.Create())
- return 0;
+ if (! app.Create())
+ return 0;
- return app.Run();
+ return app.Run();
}
diff --git a/src/app/system.cpp b/src/app/system.cpp
index 4f7cd26..a765e11 100644
--- a/src/app/system.cpp
+++ b/src/app/system.cpp
@@ -45,13 +45,13 @@ SystemDialogResult SystemDialog_Other(SystemDialogType type, const std::string&
*/
SystemDialogResult SystemDialog(SystemDialogType type, const std::string& title, const std::string& message)
{
- #if defined(PLATFORM_WINDOWS)
- return SystemDialog_Windows(type, title, message);
- #elif defined(PLATFORM_LINUX)
- return SystemDialog_Linux(type, title, message);
- #else
- return SystemDialog_Other(type, title, message);
- #endif
+ #if defined(PLATFORM_WINDOWS)
+ return SystemDialog_Windows(type, title, message);
+ #elif defined(PLATFORM_LINUX)
+ return SystemDialog_Linux(type, title, message);
+ #else
+ return SystemDialog_Other(type, title, message);
+ #endif
}
@@ -61,193 +61,193 @@ SystemDialogResult SystemDialog(SystemDialogType type, const std::string& title,
// Convert a wide Unicode string to an UTF8 string
std::string UTF8_Encode_Windows(const std::wstring &wstr)
{
- int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
- std::string strTo(size_needed, 0);
- WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
- return strTo;
+ int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
+ std::string strTo(size_needed, 0);
+ WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
+ return strTo;
}
// Convert an UTF8 string to a wide Unicode String
std::wstring UTF8_Decode_Windows(const std::string &str)
{
- int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
- std::wstring wstrTo(size_needed, 0);
- MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed);
- return wstrTo;
+ int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
+ std::wstring wstrTo(size_needed, 0);
+ MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed);
+ return wstrTo;
}
SystemDialogResult SystemDialog_Windows(SystemDialogType type, const std::string& title, const std::string& message)
{
- unsigned int windowsType = 0;
- std::wstring windowsMessage = UTF8_Decode_Windows(message);
- std::wstring windowsTitle = UTF8_Decode_Windows(title);
-
- switch (type)
- {
- case SDT_INFO:
- default:
- windowsType = MB_ICONINFORMATION|MB_OK;
- break;
- case SDT_WARNING:
- windowsType = MB_ICONWARNING|MB_OK;
- break;
- case SDT_ERROR:
- windowsType = MB_ICONERROR|MB_OK;
- break;
- case SDT_YES_NO:
- windowsType = MB_ICONQUESTION|MB_YESNO;
- break;
- case SDT_OK_CANCEL:
- windowsType = MB_ICONWARNING|MB_OKCANCEL;
- break;
- }
-
- switch (MessageBoxW(NULL, windowsMessage.c_str(), windowsTitle.c_str(), windowsType))
- {
- case IDOK:
- return SDR_OK;
- case IDCANCEL:
- return SDR_CANCEL;
- case IDYES:
- return SDR_YES;
- case IDNO:
- return SDR_NO;
- default:
- break;
- }
-
- return SDR_OK;
+ unsigned int windowsType = 0;
+ std::wstring windowsMessage = UTF8_Decode_Windows(message);
+ std::wstring windowsTitle = UTF8_Decode_Windows(title);
+
+ switch (type)
+ {
+ case SDT_INFO:
+ default:
+ windowsType = MB_ICONINFORMATION|MB_OK;
+ break;
+ case SDT_WARNING:
+ windowsType = MB_ICONWARNING|MB_OK;
+ break;
+ case SDT_ERROR:
+ windowsType = MB_ICONERROR|MB_OK;
+ break;
+ case SDT_YES_NO:
+ windowsType = MB_ICONQUESTION|MB_YESNO;
+ break;
+ case SDT_OK_CANCEL:
+ windowsType = MB_ICONWARNING|MB_OKCANCEL;
+ break;
+ }
+
+ switch (MessageBoxW(NULL, windowsMessage.c_str(), windowsTitle.c_str(), windowsType))
+ {
+ case IDOK:
+ return SDR_OK;
+ case IDCANCEL:
+ return SDR_CANCEL;
+ case IDYES:
+ return SDR_YES;
+ case IDNO:
+ return SDR_NO;
+ default:
+ break;
+ }
+
+ return SDR_OK;
}
#elif defined(PLATFORM_LINUX)
SystemDialogResult SystemDialog_Linux(SystemDialogType type, const std::string& title, const std::string& message)
{
- std::string options = "";
- switch (type)
- {
- case SDT_INFO:
- default:
- options = "--info";
- break;
+ std::string options = "";
+ switch (type)
+ {
+ case SDT_INFO:
+ default:
+ options = "--info";
+ break;
case SDT_WARNING:
- options = "--warning";
- break;
+ options = "--warning";
+ break;
case SDT_ERROR:
- options = "--error";
- break;
+ options = "--error";
+ break;
case SDT_YES_NO:
- options = "--question --ok-label=\"Yes\" --cancel-label=\"No\"";
- break;
+ options = "--question --ok-label=\"Yes\" --cancel-label=\"No\"";
+ break;
case SDT_OK_CANCEL:
- options = "--question --ok-label=\"OK\" --cancel-label=\"Cancel\"";
- break;
- }
-
- std::string command = "zenity " + options + " --text=\"" + message + "\" --title=\"" + title + "\"";
- int code = system(command.c_str());
-
- SystemDialogResult result = SDR_OK;
- switch (type)
- {
- case SDT_YES_NO:
- result = code ? SDR_NO : SDR_YES;
- break;
- case SDT_OK_CANCEL:
- result = code ? SDR_CANCEL : SDR_OK;
- break;
- default:
- break;
- }
-
- return result;
+ options = "--question --ok-label=\"OK\" --cancel-label=\"Cancel\"";
+ break;
+ }
+
+ std::string command = "zenity " + options + " --text=\"" + message + "\" --title=\"" + title + "\"";
+ int code = system(command.c_str());
+
+ SystemDialogResult result = SDR_OK;
+ switch (type)
+ {
+ case SDT_YES_NO:
+ result = code ? SDR_NO : SDR_YES;
+ break;
+ case SDT_OK_CANCEL:
+ result = code ? SDR_CANCEL : SDR_OK;
+ break;
+ default:
+ break;
+ }
+
+ return result;
}
#else
SystemDialogResult SystemDialog_Other(SystemDialogType type, const std::string& title, const std::string& message)
{
- switch (type)
- {
- case SDT_INFO:
- std::cout << "INFO: ";
- break;
- case SDT_WARNING:
- std::cout << "WARNING:";
- break;
- case SDT_ERROR:
- std::cout << "ERROR: ";
- break;
- case SDT_YES_NO:
- case SDT_OK_CANCEL:
- std::cout << "QUESTION: ";
- break;
- }
-
- std::cout << message << std::endl;
-
- std::string line;
-
- SystemDialogResult result = SDR_OK;
-
- bool done = false;
- while (!done)
- {
- switch (type)
- {
- case SDT_INFO:
- case SDT_WARNING:
- case SDT_ERROR:
- std::cout << "Press ENTER to continue";
- break;
-
- case SDT_YES_NO:
- std::cout << "Type 'Y' for Yes or 'N' for No";
- break;
-
- case SDT_OK_CANCEL:
- std::cout << "Type 'O' for OK or 'C' for Cancel";
- break;
- }
-
- std::getline(std::cin, line);
-
- switch (type)
- {
- case SDT_INFO:
- case SDT_WARNING:
- case SDT_ERROR:
- done = true;
- break;
-
- case SDT_YES_NO:
- if (line == "Y" || line == "y")
- {
- result = SDR_YES;
- done = true;
- }
- else if (line == "N" || line == "n")
- {
- result = SDR_NO;
- done = true;
- }
- break;
-
- case SDT_OK_CANCEL:
- if (line == "O" || line == "o")
- {
- done = true;
- result = SDR_OK;
- }
- else if (line == "C" || line == "c")
- {
- done = true;
- result = SDR_CANCEL;
- }
- break;
- }
- }
-
- return result;
+ switch (type)
+ {
+ case SDT_INFO:
+ std::cout << "INFO: ";
+ break;
+ case SDT_WARNING:
+ std::cout << "WARNING:";
+ break;
+ case SDT_ERROR:
+ std::cout << "ERROR: ";
+ break;
+ case SDT_YES_NO:
+ case SDT_OK_CANCEL:
+ std::cout << "QUESTION: ";
+ break;
+ }
+
+ std::cout << message << std::endl;
+
+ std::string line;
+
+ SystemDialogResult result = SDR_OK;
+
+ bool done = false;
+ while (!done)
+ {
+ switch (type)
+ {
+ case SDT_INFO:
+ case SDT_WARNING:
+ case SDT_ERROR:
+ std::cout << "Press ENTER to continue";
+ break;
+
+ case SDT_YES_NO:
+ std::cout << "Type 'Y' for Yes or 'N' for No";
+ break;
+
+ case SDT_OK_CANCEL:
+ std::cout << "Type 'O' for OK or 'C' for Cancel";
+ break;
+ }
+
+ std::getline(std::cin, line);
+
+ switch (type)
+ {
+ case SDT_INFO:
+ case SDT_WARNING:
+ case SDT_ERROR:
+ done = true;
+ break;
+
+ case SDT_YES_NO:
+ if (line == "Y" || line == "y")
+ {
+ result = SDR_YES;
+ done = true;
+ }
+ else if (line == "N" || line == "n")
+ {
+ result = SDR_NO;
+ done = true;
+ }
+ break;
+
+ case SDT_OK_CANCEL:
+ if (line == "O" || line == "o")
+ {
+ done = true;
+ result = SDR_OK;
+ }
+ else if (line == "C" || line == "c")
+ {
+ done = true;
+ result = SDR_CANCEL;
+ }
+ break;
+ }
+ }
+
+ return result;
}
#endif // if defined(PLATFORM_WINDOWS)
diff --git a/src/app/system.h b/src/app/system.h
index fd1c051..95571a2 100644
--- a/src/app/system.h
+++ b/src/app/system.h
@@ -28,16 +28,16 @@
*/
enum SystemDialogType
{
- //! Information message
- SDT_INFO,
- //! Warning message
- SDT_WARNING,
- //! Error message
- SDT_ERROR,
- //! Yes/No question
- SDT_YES_NO,
- //! Ok/Cancel question
- SDT_OK_CANCEL
+ //! Information message
+ SDT_INFO,
+ //! Warning message
+ SDT_WARNING,
+ //! Error message
+ SDT_ERROR,
+ //! Yes/No question
+ SDT_YES_NO,
+ //! Ok/Cancel question
+ SDT_OK_CANCEL
};
/**
@@ -47,10 +47,10 @@ enum SystemDialogType
*/
enum SystemDialogResult
{
- SDR_OK,
- SDR_CANCEL,
- SDR_YES,
- SDR_NO
+ SDR_OK,
+ SDR_CANCEL,
+ SDR_YES,
+ SDR_NO
};
//! Displays a system dialog