CMainDialog rewrite

- rewritten CMainDialog and updated CRobotMain
dev-ui
Piotr Dziwinski 2012-09-15 21:47:19 +02:00
parent ad6bc13dc2
commit 8ad15c0ef7
7 changed files with 801 additions and 749 deletions

View File

@ -125,7 +125,7 @@ object/motion/motiontoto.cpp
object/motion/motionvehicle.cpp
object/motion/motionworm.cpp
object/object.cpp
# object/robotmain.cpp
object/robotmain.cpp
object/task/task.cpp
object/task/taskadvance.cpp
object/task/taskbuild.cpp
@ -167,7 +167,7 @@ ui/interface.cpp
ui/key.cpp
ui/label.cpp
ui/list.cpp
# ui/maindialog.cpp
ui/maindialog.cpp
ui/mainmap.cpp
ui/mainshort.cpp
ui/map.cpp

View File

@ -189,7 +189,7 @@ char GetToLower(char letter)
// Converting time to string.
void GimeToAscii(time_t time, char *buffer)
void TimeToAscii(time_t time, char *buffer)
{
struct tm when;
int year;

View File

@ -1175,10 +1175,10 @@ bool CRobotMain::EventProcess(const Event &event)
if (event.type == EVENT_KEY_DOWN)
{
if (event.key.key == m_app->GetKey(KEYRANK_HELP, 0) ||
event.key.key == m_app->GetKey(KEYRANK_HELP, 1) ||
event.key.key == m_app->GetKey(KEYRANK_PROG, 0) ||
event.key.key == m_app->GetKey(KEYRANK_PROG, 1) ||
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_HELP).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_HELP).joy */ ||
event.key.key == m_app->GetInputBinding(INPUT_SLOT_PROG).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_PROG).joy */ ||
event.key.key == KEY(ESCAPE))
{
StopDisplayInfo();
@ -1213,14 +1213,14 @@ bool CRobotMain::EventProcess(const Event &event)
}
if (m_editLock) // current edition?
{
if (event.key.key == m_app->GetKey(KEYRANK_HELP, 0) ||
event.key.key == m_app->GetKey(KEYRANK_HELP, 1))
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_HELP).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_HELP).joy*/ )
{
StartDisplayInfo(SATCOM_HUSTON, false);
return false;
}
if (event.key.key == m_app->GetKey(KEYRANK_PROG, 0) ||
event.key.key == m_app->GetKey(KEYRANK_PROG, 1))
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_PROG).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_PROG).joy*/)
{
StartDisplayInfo(SATCOM_PROG, false);
return false;
@ -1229,8 +1229,8 @@ bool CRobotMain::EventProcess(const Event &event)
}
if (m_movieLock) // current movie?
{
if (event.key.key == m_app->GetKey(KEYRANK_QUIT, 0) ||
event.key.key == m_app->GetKey(KEYRANK_QUIT, 1) ||
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_QUIT).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_QUIT).joy */ ||
event.key.key == KEY(ESCAPE))
{
AbortMovie();
@ -1239,21 +1239,21 @@ bool CRobotMain::EventProcess(const Event &event)
}
if (m_camera->GetType() == Gfx::CAM_TYPE_VISIT)
{
if (event.key.key == m_app->GetKey(KEYRANK_VISIT, 0) ||
event.key.key == m_app->GetKey(KEYRANK_VISIT, 1))
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_VISIT).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_VISIT).joy*/)
{
StartDisplayVisit(EVENT_NULL);
}
if (event.key.key == m_app->GetKey(KEYRANK_QUIT, 0) ||
event.key.key == m_app->GetKey(KEYRANK_QUIT, 1) ||
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_QUIT).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_QUIT).joy */ ||
event.key.key == KEY(ESCAPE))
{
StopDisplayVisit();
}
return false;
}
if (event.key.key == m_app->GetKey(KEYRANK_QUIT, 0) ||
event.key.key == m_app->GetKey(KEYRANK_QUIT, 1))
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_QUIT).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_QUIT).joy*/)
{
if (m_movie->IsExist())
StartDisplayInfo(SATCOM_HUSTON, false);
@ -1273,55 +1273,55 @@ bool CRobotMain::EventProcess(const Event &event)
ChangePause(!m_engine->GetPause());
}
}
if (event.key.key == m_app->GetKey(KEYRANK_CAMERA, 0) ||
event.key.key == m_app->GetKey(KEYRANK_CAMERA, 1))
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_CAMERA).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_CAMERA).joy*/)
{
ChangeCamera();
}
if (event.key.key == m_app->GetKey(KEYRANK_DESEL, 0) ||
event.key.key == m_app->GetKey(KEYRANK_DESEL, 1))
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_DESEL).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_DESEL).joy*/)
{
if (m_shortCut)
DeselectObject();
}
if (event.key.key == m_app->GetKey(KEYRANK_HUMAN, 0) ||
event.key.key == m_app->GetKey(KEYRANK_HUMAN, 1))
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_HUMAN).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_HUMAN).joy*/)
{
SelectHuman();
}
if (event.key.key == m_app->GetKey(KEYRANK_NEXT, 0) ||
event.key.key == m_app->GetKey(KEYRANK_NEXT, 1))
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_NEXT).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_NEXT).joy*/)
{
if (m_shortCut)
m_short->SelectNext();
}
if (event.key.key == m_app->GetKey(KEYRANK_HELP, 0) ||
event.key.key == m_app->GetKey(KEYRANK_HELP, 1))
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_HELP).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_HELP).joy*/)
{
StartDisplayInfo(SATCOM_HUSTON, true);
}
if (event.key.key == m_app->GetKey(KEYRANK_PROG, 0) ||
event.key.key == m_app->GetKey(KEYRANK_PROG, 1))
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_PROG).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_PROG).joy*/)
{
StartDisplayInfo(SATCOM_PROG, true);
}
if (event.key.key == m_app->GetKey(KEYRANK_VISIT, 0) ||
event.key.key == m_app->GetKey(KEYRANK_VISIT, 1))
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_VISIT).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_VISIT).joy*/)
{
StartDisplayVisit(EVENT_NULL);
}
if (event.key.key == m_app->GetKey(KEYRANK_SPEED10, 0) ||
event.key.key == m_app->GetKey(KEYRANK_SPEED10, 1))
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_SPEED10).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_SPEED10).joy*/)
{
SetSpeed(1.0f);
}
if (event.key.key == m_app->GetKey(KEYRANK_SPEED15, 0) ||
event.key.key == m_app->GetKey(KEYRANK_SPEED15, 1))
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_SPEED15).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_SPEED15).joy*/)
{
SetSpeed(1.5f);
}
if (event.key.key == m_app->GetKey(KEYRANK_SPEED20, 0) ||
event.key.key == m_app->GetKey(KEYRANK_SPEED20, 1))
if (event.key.key == m_app->GetInputBinding(INPUT_SLOT_SPEED20).key /* TODO: joystick
|| event.key.key == m_app->GetInputBinding(INPUT_SLOT_SPEED20).joy*/)
{
SetSpeed(2.0f);
}
@ -2694,12 +2694,11 @@ void CRobotMain::HiliteObject(Math::Point pos)
CObject* obj = m_short->DetectShort(pos);
char name[100];
if (m_dialog->GetTooltip() && m_interface->GetTooltip(pos, name))
std::string nameStr;
if (m_dialog->GetTooltip() && m_interface->GetTooltip(pos, nameStr))
{
m_tooltipPos = pos;
strcpy(m_tooltipName, name);
strcpy(m_tooltipName, nameStr.c_str());
m_tooltipTime = 0.0f;
if (obj == nullptr) return;
}
@ -2722,6 +2721,7 @@ void CRobotMain::HiliteObject(Math::Point pos)
}
}
char name[100];
if (obj != nullptr)
{
if (m_dialog->GetTooltip() && obj->GetTooltipName(name))
@ -2734,8 +2734,8 @@ void CRobotMain::HiliteObject(Math::Point pos)
if (IsSelectable(obj))
{
obj->SetHilite(true);
m_map->SetHilite(obj);
m_short->SetHilite(obj);
m_map->SetHighlight(obj);
m_short->SetHighlight(obj);
m_hilite = true;
}
}
@ -2903,26 +2903,26 @@ void CRobotMain::KeyCamera(EventType type, long key)
if (type == EVENT_KEY_UP)
{
if (key == m_app->GetKey(KEYRANK_LEFT, 0) ||
key == m_app->GetKey(KEYRANK_LEFT, 1))
if (key == m_app->GetInputBinding(INPUT_SLOT_LEFT).key /* TODO: joystick
|| key == m_app->GetInputBinding(INPUT_SLOT_LEFT).joy*/)
{
m_cameraPan = 0.0f;
}
if (key == m_app->GetKey(KEYRANK_RIGHT, 0) ||
key == m_app->GetKey(KEYRANK_RIGHT, 1))
if (key == m_app->GetInputBinding(INPUT_SLOT_RIGHT).key /* TODO: joystick
|| key == m_app->GetInputBinding(INPUT_SLOT_RIGHT).joy*/)
{
m_cameraPan = 0.0f;
}
if (key == m_app->GetKey(KEYRANK_UP, 0) ||
key == m_app->GetKey(KEYRANK_UP, 1))
if (key == m_app->GetInputBinding(INPUT_SLOT_UP).key /* TODO: joystick
|| key == m_app->GetInputBinding(INPUT_SLOT_UP).joy*/ )
{
m_cameraZoom = 0.0f;
}
if (key == m_app->GetKey(KEYRANK_DOWN, 0) ||
key == m_app->GetKey(KEYRANK_DOWN, 1))
if (key == m_app->GetInputBinding(INPUT_SLOT_DOWN).key /* TODO: joystick
|| key == m_app->GetInputBinding(INPUT_SLOT_DOWN).joy*/ )
{
m_cameraZoom = 0.0f;
}
@ -2938,26 +2938,26 @@ void CRobotMain::KeyCamera(EventType type, long key)
if (type == EVENT_KEY_DOWN)
{
if (key == m_app->GetKey(KEYRANK_LEFT, 0) ||
key == m_app->GetKey(KEYRANK_LEFT, 1))
if (key == m_app->GetInputBinding(INPUT_SLOT_LEFT).key /* TODO: joystick
|| key == m_app->GetInputBinding(INPUT_SLOT_LEFT).joy*/)
{
m_cameraPan = -1.0f;
}
if (key == m_app->GetKey(KEYRANK_RIGHT, 0) ||
key == m_app->GetKey(KEYRANK_RIGHT, 1))
if (key == m_app->GetInputBinding(INPUT_SLOT_RIGHT).key /* TODO: joystick
|| key == m_app->GetInputBinding(INPUT_SLOT_RIGHT).joy*/)
{
m_cameraPan = 1.0f;
}
if (key == m_app->GetKey(KEYRANK_UP, 0) ||
key == m_app->GetKey(KEYRANK_UP, 1))
if (key == m_app->GetInputBinding(INPUT_SLOT_UP).key /* TODO: joystick
|| key == m_app->GetInputBinding(INPUT_SLOT_UP).joy*/)
{
m_cameraZoom = -1.0f;
}
if (key == m_app->GetKey(KEYRANK_DOWN, 0) ||
key == m_app->GetKey(KEYRANK_DOWN, 1))
if (key == m_app->GetInputBinding(INPUT_SLOT_DOWN).key /* TODO: joystick
|| key == m_app->GetInputBinding(INPUT_SLOT_DOWN).joy*/)
{
m_cameraZoom = 1.0f;
}
@ -3588,15 +3588,16 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
}
}
sprintf(op, "Title.%c", GetLanguageLetter());
// TODO: language letters
sprintf(op, "Title.%c", 'E' /*GetLanguageLetter()*/);
if (Cmd(line, op) && !resetObject)
OpString(line, "text", m_title);
sprintf(op, "Resume.%c", GetLanguageLetter());
sprintf(op, "Resume.%c", 'E' /*GetLanguageLetter()*/);
if (Cmd(line, op) && !resetObject)
OpString(line, "text", m_resume);
sprintf(op, "ScriptName.%c", GetLanguageLetter());
sprintf(op, "ScriptName.%c", 'E' /*GetLanguageLetter()*/);
if (Cmd(line, op) && !resetObject)
OpString(line, "text", m_scriptName);
@ -4266,7 +4267,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
CreateShortcuts();
m_map->UpdateMap();
// TODO: m_engine->TimeInit(); ??
m_app->FlushPressKey();
m_app->ResetKeyStates();
m_time = 0.0f;
m_gameTime = 0.0f;
m_checkEndTime = 0.0f;
@ -6416,7 +6417,7 @@ void CRobotMain::SetSpeed(float speed)
float CRobotMain::GetSpeed()
{
return m_engine->GetSpeed();
return m_app->GetSimulationSpeed();
}
@ -6486,7 +6487,7 @@ void CRobotMain::SetEditLock(bool lock, bool edit)
m_map->ShowMap(!m_editLock && m_mapShow);
m_displayText->HideText(lock);
m_app->FlushPressKey();
m_app->ResetKeyStates();
if (m_editLock)
HiliteClear();

View File

@ -309,7 +309,7 @@ protected:
void HiliteClear();
void HiliteObject(Math::Point pos);
void HiliteFrame(float rTime);
void CreateTooltip(Math::Point pos, char* text);
void CreateTooltip(Math::Point pos, const char* text);
void ClearTooltip();
CObject* DetectObject(Math::Point pos);
void ChangeCamera();

View File

@ -175,45 +175,45 @@ class CSoundInterface : public CPluginInterface
*/
virtual bool Cache(Sound bSound, std::string bFile) = 0;
/** Return if plugin is enabled
/** Geturn if plugin is enabled
* @return return true if plugin is enabled
*/
virtual bool RetEnable() = 0;
virtual bool GetEnable() = 0;
/** Change sound mode to 2D/3D
* @param bool bMode - true to enable 3D sound
*/
virtual void SetSound3D(bool bMode) = 0;
/** Return if we use 3D sound
/** Geturn if we use 3D sound
* @return true if we have 3D sound enabled
*/
virtual bool RetSound3D() = 0;
virtual bool GetSound3D() = 0;
/** Return if we have 3D sound capable card
/** Geturn if we have 3D sound capable card
* @return true for 3D sound support
*/
virtual bool RetSound3DCap() = 0;
virtual bool GetSound3DCap() = 0;
/** Change global sound volume
* @param int volume - range from 0 to MAXVOLUME
*/
virtual void SetAudioVolume(int volume) = 0;
/** Return global sound volume
/** Geturn global sound volume
* @return global volume as int in range from 0 to MAXVOLUME
*/
virtual int RetAudioVolume() = 0;
virtual int GetAudioVolume() = 0;
/** Set music volume
* @param int volume - range from 0 to MAXVOLUME
*/
virtual void SetMusicVolume(int volume) = 0;
/** Return music volume
/** Geturn music volume
* @return music volume as int in range from 0 to MAXVOLUME
*/
virtual int RetMusicVolume() = 0;
virtual int GetMusicVolume() = 0;
/** Set listener position
* @param Math::Vector eye - position of listener

File diff suppressed because it is too large Load Diff

View File

@ -19,22 +19,32 @@
#pragma once
#include "graphics/core/color.h"
#include "object/robotmain.h"
class CInstanceManager;
class CEvent;
class CD3DEngine;
class CEventQueue;
class CSoundInterface;
namespace Gfx
{
class CEngine;
class CParticle;
};
namespace Ui
{
class CInterface;
class CWindow;
class CControl;
class CParticule;
class CSound;
const int USERLISTMAX = 100;
const int MAXSCENE = 1000;
const int MAX_FNAME = 255; // TODO: remove after rewrite to std::string
struct SceneInfo
{
char numTry;
@ -45,9 +55,9 @@ struct GamerPerso
{
int face; // face
int glasses; // glasses
D3DCOLORVALUE colorHair; // hair color
D3DCOLORVALUE colorCombi; // spacesuit volor
D3DCOLORVALUE colorBand; // strips color
Gfx::Color colorHair; // hair color
Gfx::Color colorCombi; // spacesuit volor
Gfx::Color colorBand; // strips color
};
@ -65,26 +75,26 @@ public:
void SetStackRead(char* name);
void SetSceneName(char* name);
void SetSceneRank(int rank);
char* RetSceneRead();
char* RetStackRead();
char* RetSceneName();
int RetSceneRank();
char* RetSceneDir();
bool RetSceneSoluce();
char* RetSavegameDir();
char* RetPublicDir();
char* GetSceneRead();
char* GetStackRead();
char* GetSceneName();
int GetSceneRank();
char* GetSceneDir();
bool GetSceneSoluce();
char* GetSavegameDir();
char* GetPublicDir();
bool RetTooltip();
bool RetGlint();
bool RetSoluce4();
bool RetMovies();
bool RetNiceReset();
bool RetHimselfDamage();
bool GetTooltip();
bool GetGlint();
bool GetSoluce4();
bool GetMovies();
bool GetNiceReset();
bool GetHimselfDamage();
void SetUserDir(char *base, int rank);
void BuildSceneName(char *filename, char *base, int rank);
void BuildResumeName(char *filename, char *base, int rank);
char* RetFilesDir();
char* GetFilesDir();
void StartAbort();
void StartDeleteObject();
@ -104,30 +114,30 @@ public:
bool ReadGamerInfo();
bool WriteGamerInfo();
void SetGamerInfoTry(int rank, int numTry);
int RetGamerInfoTry(int rank);
int GetGamerInfoTry(int rank);
void SetGamerInfoPassed(int rank, bool bPassed);
bool RetGamerInfoPassed(int rank);
bool GetGamerInfoPassed(int rank);
bool NextMission();
void WriteGamerPerso(char *gamer);
void ReadGamerPerso(char *gamer);
void SetGamerFace(char *gamer, int face);
int RetGamerFace(char *gamer);
int RetGamerFace();
int RetGamerGlasses();
bool RetGamerOnlyHead();
float RetPersoAngle();
D3DCOLORVALUE RetGamerColorHair();
D3DCOLORVALUE RetGamerColorCombi();
D3DCOLORVALUE RetGamerColorBand();
int GetGamerFace(char *gamer);
int GetGamerFace();
int GetGamerGlasses();
bool GetGamerOnlyHead();
float GetPersoAngle();
Gfx::Color GetGamerColorHair();
Gfx::Color GetGamerColorCombi();
Gfx::Color GetGamerColorBand();
void AllMissionUpdate();
void ShowSoluceUpdate();
protected:
void GlintMove();
void FrameParticule(float rTime);
void NiceParticule(Math::Point mouse, bool bPress);
void FrameParticle(float rTime);
void NiceParticle(Math::Point mouse, bool bPress);
void ReadNameList();
void UpdateNameList();
void UpdateNameEdit();
@ -148,7 +158,7 @@ protected:
void IODeleteScene();
bool IOWriteScene();
bool IOReadScene();
int RetChapPassed();
int GetChapPassed();
void UpdateSceneChap(int &chap);
void UpdateSceneList(int chap, int &sel);
void UpdateSceneResume(int rank);
@ -160,17 +170,18 @@ protected:
void ChangeSetupButtons();
void ChangeSetupQuality(int quality);
void UpdateKey();
void ChangeKey(EventMsg event);
void ChangeKey(EventType event);
protected:
CInstanceManager* m_iMan;
CRobotMain* m_main;
CEvent* m_event;
CD3DEngine* m_engine;
CInterface* m_interface;
CParticule* m_particule;
CCamera* m_camera;
CSound* m_sound;
CApplication* m_app;
CRobotMain* m_main;
CEventQueue* m_eventQueue;
Gfx::CEngine* m_engine;
CInterface* m_interface;
Gfx::CParticle* m_particle;
Gfx::CCamera* m_camera;
CSoundInterface* m_sound;
Phase m_phase; // copy of CRobotMain
Phase m_phaseSetup; // tab selected
@ -182,11 +193,11 @@ protected:
int m_persoTab; // perso: tab selected
float m_persoAngle; // perso: angle of presentation
char m_sceneDir[_MAX_FNAME]; // scene folder
char m_savegameDir[_MAX_FNAME]; // savegame folder
char m_publicDir[_MAX_FNAME]; // program folder
char m_userDir[_MAX_FNAME]; // user folder
char m_filesDir[_MAX_FNAME]; // case files
char m_sceneDir[MAX_FNAME]; // scene folder
char m_savegameDir[MAX_FNAME]; // savegame folder
char m_publicDir[MAX_FNAME]; // program folder
char m_userDir[MAX_FNAME]; // user folder
char m_filesDir[MAX_FNAME]; // case files
int m_index; // 0..4
int m_chap[10]; // selected chapter (0..8)
@ -239,7 +250,7 @@ protected:
float m_dialogParti;
float m_dialogTime;
bool m_bInitPause;
CameraType m_initCamera;
Gfx::CameraType m_initCamera;
int m_partiPhase[10];
float m_partiTime[10];
@ -248,4 +259,4 @@ protected:
SceneInfo m_sceneInfo[MAXSCENE];
};
} // namespace Ui