2012-06-22 14:31:55 +00:00
|
|
|
// * This file is part of the COLOBOT source code
|
|
|
|
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
|
|
|
|
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
|
|
|
|
// *
|
|
|
|
// * 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/.
|
|
|
|
|
|
|
|
// app.h
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
2012-06-24 13:41:56 +00:00
|
|
|
#include "common/misc.h"
|
2012-06-25 17:59:17 +00:00
|
|
|
#include "graphics/common/device.h"
|
2012-06-24 13:41:56 +00:00
|
|
|
#include "graphics/common/engine.h"
|
|
|
|
|
2012-06-25 17:59:17 +00:00
|
|
|
#include <string>
|
|
|
|
|
2012-06-24 13:41:56 +00:00
|
|
|
|
|
|
|
class CInstanceManager;
|
|
|
|
class CEvent;
|
|
|
|
class CRobotMain;
|
|
|
|
class CSound;
|
|
|
|
|
2012-06-25 17:59:17 +00:00
|
|
|
struct ApplicationPrivate;
|
|
|
|
|
2012-06-24 13:41:56 +00:00
|
|
|
|
2012-06-25 17:59:17 +00:00
|
|
|
/**
|
|
|
|
* \class CApplication Main application
|
|
|
|
*
|
|
|
|
* This class is responsible for creating and handling main application window,
|
|
|
|
* receiving events, etc.
|
|
|
|
*
|
|
|
|
* ...
|
|
|
|
*/
|
2012-06-22 14:31:55 +00:00
|
|
|
class CApplication
|
|
|
|
{
|
2012-06-24 13:41:56 +00:00
|
|
|
public:
|
2012-06-26 20:23:05 +00:00
|
|
|
//! Constructor (can only be called once!)
|
|
|
|
CApplication();
|
|
|
|
//! Destructor
|
|
|
|
~CApplication();
|
2012-06-24 13:41:56 +00:00
|
|
|
|
2012-06-25 17:59:17 +00:00
|
|
|
public:
|
2012-06-26 20:23:05 +00:00
|
|
|
//! Parses commandline arguments
|
|
|
|
Error ParseArguments(int argc, char *argv[]);
|
|
|
|
//! Initializes the application
|
|
|
|
bool Create();
|
|
|
|
//! Main event loop
|
|
|
|
int Run();
|
2012-06-25 17:59:17 +00:00
|
|
|
|
2012-06-24 13:41:56 +00:00
|
|
|
protected:
|
2012-06-26 20:23:05 +00:00
|
|
|
//! 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();
|
2012-06-24 13:41:56 +00:00
|
|
|
|
|
|
|
public:
|
2012-06-26 20:23:05 +00:00
|
|
|
void Pause(bool pause);
|
|
|
|
void StepSimulation(float rTime);
|
2012-06-25 17:59:17 +00:00
|
|
|
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetMousePos(Math::Point pos);
|
2012-06-24 13:41:56 +00:00
|
|
|
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetShowStat(bool show);
|
|
|
|
bool RetShowStat();
|
|
|
|
void SetDebugMode(bool mode);
|
|
|
|
bool RetDebugMode();
|
|
|
|
bool RetSetupMode();
|
2012-06-24 13:41:56 +00:00
|
|
|
|
2012-06-26 20:23:05 +00:00
|
|
|
void FlushPressKey();
|
|
|
|
void ResetKey();
|
|
|
|
void SetKey(int keyRank, int option, int key);
|
|
|
|
int RetKey(int keyRank, int option);
|
2012-06-24 13:41:56 +00:00
|
|
|
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetJoystick(bool enable);
|
|
|
|
bool RetJoystick();
|
2012-06-24 13:41:56 +00:00
|
|
|
|
2012-06-26 20:23:05 +00:00
|
|
|
void SetMouseType(Gfx::MouseType type);
|
|
|
|
void SetNiceMouse(bool nice);
|
|
|
|
bool RetNiceMouse();
|
|
|
|
bool RetNiceMouseCap();
|
2012-06-24 13:41:56 +00:00
|
|
|
|
2012-06-26 20:23:05 +00:00
|
|
|
bool WriteScreenShot(char *filename, int width, int height);
|
2012-06-24 13:41:56 +00:00
|
|
|
|
|
|
|
protected:
|
2012-06-26 20:23:05 +00:00
|
|
|
//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);
|
2012-06-24 13:41:56 +00:00
|
|
|
|
|
|
|
protected:
|
2012-06-26 20:23:05 +00:00
|
|
|
//! 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];
|
2012-06-22 14:31:55 +00:00
|
|
|
};
|
|
|
|
|