* added nullptr

* changed Ret to Get function names
* minor changes
dev-ui
erihel 2012-08-21 21:38:13 +02:00
parent 4faa1b9c44
commit 5408fe9252
6 changed files with 498 additions and 508 deletions

File diff suppressed because it is too large Load Diff

View File

@ -156,25 +156,25 @@ public:
void ScenePerso(); void ScenePerso();
void SetMovieLock(bool bLock); void SetMovieLock(bool bLock);
bool RetMovieLock(); bool GetMovieLock();
bool RetInfoLock(); bool GetInfoLock();
void SetSatComLock(bool bLock); void SetSatComLock(bool bLock);
bool RetSatComLock(); bool GetSatComLock();
void SetEditLock(bool bLock, bool bEdit); void SetEditLock(bool bLock, bool bEdit);
bool RetEditLock(); bool GetEditLock();
void SetEditFull(bool bFull); void SetEditFull(bool bFull);
bool RetEditFull(); bool GetEditFull();
bool RetFreePhoto(); bool GetFreePhoto();
void SetFriendAim(bool bFriend); void SetFriendAim(bool bFriend);
bool RetFriendAim(); bool GetFriendAim();
void SetTracePrecision(float factor); void SetTracePrecision(float factor);
float RetTracePrecision(); float GetTracePrecision();
void ChangePause(bool bPause); void ChangePause(bool bPause);
void SetSpeed(float speed); void SetSpeed(float speed);
float RetSpeed(); float GetSpeed();
void UpdateShortcuts(); void UpdateShortcuts();
void SelectHuman(); void SelectHuman();
@ -182,7 +182,7 @@ public:
CObject* SearchToto(); CObject* SearchToto();
CObject* SearchNearest(Math::Vector pos, CObject* pExclu); CObject* SearchNearest(Math::Vector pos, CObject* pExclu);
bool SelectObject(CObject* pObj, bool bDisplayError=true); bool SelectObject(CObject* pObj, bool bDisplayError=true);
CObject* RetSelectObject(); CObject* GetSelectObject();
CObject* DeselectAll(); CObject* DeselectAll();
bool DeleteObject(); bool DeleteObject();
@ -190,67 +190,67 @@ public:
void ResetCreate(); void ResetCreate();
Error CheckEndMission(bool bFrame); Error CheckEndMission(bool bFrame);
void CheckEndMessage(char *message); void CheckEndMessage(char *message);
int RetObligatoryToken(); int GetObligatoryToken();
char* RetObligatoryToken(int i); char* GetObligatoryToken(int i);
int IsObligatoryToken(char *token); int IsObligatoryToken(char *token);
bool IsProhibitedToken(char *token); bool IsProhibitedToken(char *token);
void UpdateMap(); void UpdateMap();
bool RetShowMap(); bool GetShowMap();
MainMovieType RetMainMovie(); MainMovieType GetMainMovie();
void FlushDisplayInfo(); void FlushDisplayInfo();
void StartDisplayInfo(int index, bool bMovie); void StartDisplayInfo(int index, bool bMovie);
void StartDisplayInfo(char *filename, int index); void StartDisplayInfo(char *filename, int index);
void StopDisplayInfo(); void StopDisplayInfo();
char* RetDisplayInfoName(int index); char* GetDisplayInfoName(int index);
int RetDisplayInfoPosition(int index); int GetDisplayInfoPosition(int index);
void SetDisplayInfoPosition(int index, int pos); void SetDisplayInfoPosition(int index, int pos);
void StartSuspend(); void StartSuspend();
void StopSuspend(); void StopSuspend();
float RetGameTime(); float GetGameTime();
void SetFontSize(float size); void SetFontSize(float size);
float RetFontSize(); float GetFontSize();
void SetWindowPos(Math::Point pos); void SetWindowPos(Math::Point pos);
Math::Point RetWindowPos(); Math::Point GetWindowPos();
void SetWindowDim(Math::Point dim); void SetWindowDim(Math::Point dim);
Math::Point RetWindowDim(); Math::Point GetWindowDim();
void SetIOPublic(bool bMode); void SetIOPublic(bool bMode);
bool RetIOPublic(); bool GetIOPublic();
void SetIOPos(Math::Point pos); void SetIOPos(Math::Point pos);
Math::Point RetIOPos(); Math::Point GetIOPos();
void SetIODim(Math::Point dim); void SetIODim(Math::Point dim);
Math::Point RetIODim(); Math::Point GetIODim();
char* RetTitle(); char* GetTitle();
char* RetResume(); char* GetResume();
char* RetScriptName(); char* GetScriptName();
char* RetScriptFile(); char* GetScriptFile();
bool RetTrainerPilot(); bool GetTrainerPilot();
bool RetFixScene(); bool GetFixScene();
bool RetGlint(); bool GetGlint();
bool RetSoluce4(); bool GetSoluce4();
bool RetMovies(); bool GetMovies();
bool RetNiceReset(); bool GetNiceReset();
bool RetHimselfDamage(); bool GetHimselfDamage();
bool RetShowSoluce(); bool GetShowSoluce();
bool RetSceneSoluce(); bool GetSceneSoluce();
bool RetShowAll(); bool GetShowAll();
bool RetCheatRadar(); bool GetCheatRadar();
char* RetSavegameDir(); char* GetSavegameDir();
char* RetPublicDir(); char* GetPublicDir();
char* RetFilesDir(); char* GetFilesDir();
void SetGamerName(char *name); void SetGamerName(char *name);
char* RetGamerName(); char* GetGamerName();
int RetGamerFace(); int GetGamerFace();
int RetGamerGlasses(); int GetGamerGlasses();
bool RetGamerOnlyHead(); bool GetGamerOnlyHead();
float RetPersoAngle(); float GetPersoAngle();
void StartMusic(); void StartMusic();
void ClearInterface(); void ClearInterface();
@ -258,7 +258,7 @@ public:
float SearchNearestObject(Math::Vector center, CObject *exclu); float SearchNearestObject(Math::Vector center, CObject *exclu);
bool FreeSpace(Math::Vector &center, float minRadius, float maxRadius, float space, CObject *exclu); bool FreeSpace(Math::Vector &center, float minRadius, float maxRadius, float space, CObject *exclu);
float RetFlatZoneRadius(Math::Vector center, float maxRadius, CObject *exclu); float GetFlatZoneRadius(Math::Vector center, float maxRadius, CObject *exclu);
void HideDropZone(CObject* metal); void HideDropZone(CObject* metal);
void ShowDropZone(CObject* metal, CObject* truck); void ShowDropZone(CObject* metal, CObject* truck);
void FlushShowLimit(int i); void FlushShowLimit(int i);
@ -278,7 +278,7 @@ public:
bool FlushNewScriptName(); bool FlushNewScriptName();
bool AddNewScriptName(ObjectType type, char *name); bool AddNewScriptName(ObjectType type, char *name);
char* RetNewScriptName(ObjectType type, int rank); char* GetNewScriptName(ObjectType type, int rank);
void WriteFreeParam(); void WriteFreeParam();
void ReadFreeParam(); void ReadFreeParam();
@ -303,9 +303,9 @@ protected:
Math::Vector LookatPoint( Math::Vector eye, float angleH, float angleV, float length ); Math::Vector LookatPoint( Math::Vector eye, float angleH, float angleV, float length );
CObject* CreateObject(Math::Vector pos, float angle, float zoom, float height, ObjectType type, float power=1.0f, bool bTrainer=false, bool bToy=false, int option=0); CObject* CreateObject(Math::Vector pos, float angle, float zoom, float height, ObjectType type, float power=1.0f, bool bTrainer=false, bool bToy=false, int option=0);
int CreateLight(Math::Vector direction, Gfx::Color color); int CreateLight(Math::Vector direction, Gfx::Color color);
void HiliteClear(); void HighlightClear();
void HiliteObject(Math::Point pos); void HighlightObject(Math::Point pos);
void HiliteFrame(float rTime); void HighlightFrame(float rTime);
void CreateTooltip(Math::Point pos, char* text); void CreateTooltip(Math::Point pos, char* text);
void ClearTooltip(); void ClearTooltip();
CObject* DetectObject(Math::Point pos); CObject* DetectObject(Math::Point pos);
@ -320,7 +320,7 @@ protected:
void DeleteAllObjects(); void DeleteAllObjects();
void UpdateInfoText(); void UpdateInfoText();
CObject* SearchObject(ObjectType type); CObject* SearchObject(ObjectType type);
CObject* RetSelect(); CObject* GetSelect();
void StartDisplayVisit(EventType event); void StartDisplayVisit(EventType event);
void FrameVisit(float rTime); void FrameVisit(float rTime);
void StopDisplayVisit(); void StopDisplayVisit();
@ -382,7 +382,7 @@ protected:
bool m_bEditLock; // edition in progress? bool m_bEditLock; // edition in progress?
bool m_bEditFull; // edition in full screen? bool m_bEditFull; // edition in full screen?
bool m_bPause; // simulation paused bool m_bPause; // simulation paused
bool m_bHilite; bool m_bHighlight;
bool m_bTrainerPilot; // remote trainer? bool m_bTrainerPilot; // remote trainer?
bool m_bSuspend; bool m_bSuspend;
bool m_bFriendAim; bool m_bFriendAim;

View File

@ -177,7 +177,7 @@ void CMainMap::DimMap()
ps->SetPos(pos); ps->SetPos(pos);
ps->SetDim(dim); ps->SetDim(dim);
value = pm->RetZoom(); value = pm->GetZoom();
value = (value-ZOOM_MIN) / (ZOOM_MAX-ZOOM_MIN); value = (value-ZOOM_MIN) / (ZOOM_MAX-ZOOM_MIN);
value = powf(value, 0.5f); value = powf(value, 0.5f);
ps->SetVisibleValue(value); ps->SetVisibleValue(value);
@ -256,7 +256,8 @@ void CMainMap::ZoomMap()
if (ps == nullptr) if (ps == nullptr)
return; return;
zoom = ps->SetVisibleValue();
zoom = ps->GetVisibleValue();
zoom = powf(zoom, 2.0f); zoom = powf(zoom, 2.0f);
zoom = ZOOM_MIN+zoom*(ZOOM_MAX - ZOOM_MIN); zoom = ZOOM_MIN+zoom*(ZOOM_MAX - ZOOM_MIN);
pm->SetZoom(zoom); pm->SetZoom(zoom);

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * 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 // * 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 // * it under the terms of the GNU General Public License as published by
@ -17,36 +18,21 @@
// mainshort.cpp // mainshort.cpp
#include <windows.h> #include <ui/mainshort.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
#include "old/d3dengine.h"
#include "common/global.h"
#include "common/event.h"
#include "common/iman.h"
#include "object/object.h"
#include "ui/interface.h"
#include "ui/map.h"
#include "ui/button.h"
#include "object/robotmain.h"
#include "ui/mainshort.h"
namespace Ui {
// Constructor of the application card. // Constructor of the application card.
CMainShort::CMainShort(CInstanceManager* iMan) CMainShort::CMainShort()
{ {
m_iMan = iMan; m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_SHORT, this); m_iMan->AddInstance(CLASS_SHORT, this);
m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE); m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT); m_event = static_cast<CEvent*>(m_iMan->SearchInstance(CLASS_EVENT));
m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN); m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
FlushShortcuts(); FlushShortcuts();
} }
@ -78,7 +64,7 @@ void CMainShort::FlushShortcuts()
} }
} }
static EventMsg table_sc_em[20] = static EventType table_sc_em[20] =
{ {
EVENT_OBJECT_SHORTCUT00, EVENT_OBJECT_SHORTCUT00,
EVENT_OBJECT_SHORTCUT01, EVENT_OBJECT_SHORTCUT01,
@ -113,13 +99,13 @@ bool CMainShort::CreateShortcuts()
int i, rank, icon; int i, rank, icon;
char name[100]; char name[100];
if ( m_main->RetFixScene() ) return false; if ( m_main->GetFixScene() ) return false;
m_interface->DeleteControl(EVENT_OBJECT_MOVIELOCK); m_interface->DeleteControl(EVENT_OBJECT_MOVIELOCK);
m_interface->DeleteControl(EVENT_OBJECT_EDITLOCK); m_interface->DeleteControl(EVENT_OBJECT_EDITLOCK);
for ( i=0 ; i<20 ; i++ ) for ( i=0 ; i<20 ; i++ )
{ {
if ( i != 0 && m_shortcuts[i] == 0 ) continue; if ( i != 0 && m_shortcuts[i] == nullptr ) continue;
m_interface->DeleteControl(table_sc_em[i]); m_interface->DeleteControl(table_sc_em[i]);
m_shortcuts[i] = 0; m_shortcuts[i] = 0;
@ -130,15 +116,15 @@ bool CMainShort::CreateShortcuts()
pos.x = 4.0f/640.0f; pos.x = 4.0f/640.0f;
pos.y = (480.0f-32.0f)/480.0f; pos.y = (480.0f-32.0f)/480.0f;
if ( m_main->RetMovieLock() && if ( m_main->GetMovieLock() &&
!m_main->RetEditLock() ) // hangs during film? !m_main->GetEditLock() ) // hangs during film?
{ {
m_interface->CreateShortcut(pos, dim, 7, EVENT_OBJECT_MOVIELOCK); m_interface->CreateShortcut(pos, dim, 7, EVENT_OBJECT_MOVIELOCK);
return true; return true;
} }
if ( !m_main->RetFreePhoto() && if ( !m_main->GetFreePhoto() &&
(m_main->RetEditLock() || (m_main->GetEditLock() ||
m_engine->RetPause()) ) // hangs during edition? m_engine->GetPause()) ) // hangs during edition?
{ {
m_interface->CreateShortcut(pos, dim, 6, EVENT_OBJECT_EDITLOCK); m_interface->CreateShortcut(pos, dim, 6, EVENT_OBJECT_EDITLOCK);
return true; return true;
@ -154,13 +140,13 @@ bool CMainShort::CreateShortcuts()
for ( i=0 ; i<1000000 ; i++ ) for ( i=0 ; i<1000000 ; i++ )
{ {
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
if ( pObj == 0 ) break; if ( pObj == nullptr ) break;
if ( !pObj->RetActif() ) continue; if ( !pObj->GetActif() ) continue;
if ( !pObj->RetSelectable() ) continue; if ( !pObj->GetSelectable() ) continue;
if ( pObj->RetProxyActivate() ) continue; if ( pObj->GetProxyActivate() ) continue;
type = pObj->RetType(); type = pObj->GetType();
icon = -1; icon = -1;
if ( m_bBuilding ) if ( m_bBuilding )
{ {
@ -243,12 +229,12 @@ bool CMainShort::UpdateShortcuts()
for ( i=0 ; i<20 ; i++ ) for ( i=0 ; i<20 ; i++ )
{ {
if ( m_shortcuts[i] == 0 ) continue; if ( m_shortcuts[i] == nullptr ) continue;
pc = m_interface->SearchControl(table_sc_em[i]); pc = m_interface->SearchControl(table_sc_em[i]);
if ( pc != 0 ) if ( pc != nullptr )
{ {
pc->SetState(STATE_CHECK, m_shortcuts[i]->RetSelect()); pc->SetState(STATE_CHECK, m_shortcuts[i]->GetSelect());
pc->SetState(STATE_RUN, m_shortcuts[i]->IsProgram()); pc->SetState(STATE_RUN, m_shortcuts[i]->IsProgram());
} }
} }
@ -257,7 +243,7 @@ bool CMainShort::UpdateShortcuts()
// Selects an object through a shortcut. // Selects an object through a shortcut.
void CMainShort::SelectShortcut(EventMsg event) void CMainShort::SelectShortcut(EventType event)
{ {
int i; int i;
@ -265,7 +251,7 @@ void CMainShort::SelectShortcut(EventMsg event)
{ {
if ( event == table_sc_em[i] ) if ( event == table_sc_em[i] )
{ {
if ( i != 0 && m_shortcuts[i] == 0 ) continue; if ( i != 0 && m_shortcuts[i] == nullptr ) continue;
if ( i == 0 ) // buildings <-> vehicles? if ( i == 0 ) // buildings <-> vehicles?
{ {
@ -289,9 +275,9 @@ void CMainShort::SelectNext()
CObject* pPrev; CObject* pPrev;
int i; int i;
if ( m_main->RetMovieLock() || if ( m_main->GetMovieLock() ||
m_main->RetEditLock() || m_main->GetEditLock() ||
m_engine->RetPause() ) return; m_engine->GetPause() ) return;
pPrev = m_main->DeselectAll(); pPrev = m_main->DeselectAll();
@ -299,12 +285,12 @@ void CMainShort::SelectNext()
{ {
if ( m_shortcuts[i] == pPrev ) if ( m_shortcuts[i] == pPrev )
{ {
if ( m_shortcuts[++i] == 0 ) i = 1; if ( m_shortcuts[++i] == nullptr ) i = 1;
break; break;
} }
} }
if ( i == 20 || m_shortcuts[i] == 0 ) if ( i == 20 || m_shortcuts[i] == nullptr )
{ {
m_main->SelectHuman(); m_main->SelectHuman();
} }
@ -325,13 +311,13 @@ CObject* CMainShort::DetectShort(Math::Point pos)
for ( i=0 ; i<20 ; i++ ) for ( i=0 ; i<20 ; i++ )
{ {
if ( m_shortcuts[i] == 0 ) continue; if ( m_shortcuts[i] == nullptr ) continue;
pc = m_interface->SearchControl(table_sc_em[i]); pc = m_interface->SearchControl(table_sc_em[i]);
if ( pc != 0 ) if ( pc != 0 )
{ {
cpos = pc->RetPos(); cpos = pc->GetPos();
cdim = pc->RetDim(); cdim = pc->GetDim();
if ( pos.x >= cpos.x && if ( pos.x >= cpos.x &&
pos.x <= cpos.x+cdim.x && pos.x <= cpos.x+cdim.x &&
@ -347,17 +333,17 @@ CObject* CMainShort::DetectShort(Math::Point pos)
// Reports the object with the mouse hovers over. // Reports the object with the mouse hovers over.
void CMainShort::SetHilite(CObject* pObj) void CMainShort::SetHighlight(CObject* pObj)
{ {
CControl* pc; CControl* pc;
int i; int i;
for ( i=0 ; i<20 ; i++ ) for ( i=0 ; i<20 ; i++ )
{ {
if ( m_shortcuts[i] == 0 ) continue; if ( m_shortcuts[i] == nullptr ) continue;
pc = m_interface->SearchControl(table_sc_em[i]); pc = m_interface->SearchControl(table_sc_em[i]);
if ( pc == 0 ) continue; if ( pc == nullptr ) continue;
if ( m_shortcuts[i] == pObj ) if ( m_shortcuts[i] == pObj )
{ {
@ -372,3 +358,5 @@ void CMainShort::SetHilite(CObject* pObj)
} }
} }
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * 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 // * 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 // * it under the terms of the GNU General Public License as published by
@ -18,45 +19,45 @@
#pragma once #pragma once
#include <ui/interface.h>
#include "common/event.h" #include <common/event.h>
#include "math/point.h"
#include <math/point.h>
class CInstanceManager; #include <object/object.h>
class CD3DEngine;
class CInterface;
class CRobotMain;
class CObject;
#include <graphics/engine/engine.h>
namespace Ui {
class CMainShort class CMainShort
{ {
public: public:
CMainShort(CInstanceManager* iMan); CMainShort();
~CMainShort(); ~CMainShort();
void SetMode(bool bBuilding); void SetMode(bool bBuilding);
void FlushShortcuts(); void FlushShortcuts();
bool CreateShortcuts(); bool CreateShortcuts();
bool UpdateShortcuts(); bool UpdateShortcuts();
void SelectShortcut(EventMsg event); void SelectShortcut(EventType event);
void SelectNext(); void SelectNext();
CObject* DetectShort(Math::Point pos); CObject* DetectShort(Math::Point pos);
void SetHilite(CObject* pObj); void SetHighlight(CObject* pObj);
protected: protected:
protected: protected:
CInstanceManager* m_iMan; CInstanceManager* m_iMan;
CEvent* m_event; CEvent* m_event;
CD3DEngine* m_engine; Gfx::CEngine* m_engine;
CInterface* m_interface; CInterface* m_interface;
CRobotMain* m_main; CRobotMain* m_main;
CObject* m_shortcuts[20]; CObject* m_shortcuts[20];
bool m_bBuilding; bool m_bBuilding;
}; };
}

View File

@ -223,7 +223,7 @@ void CMap::SetHighlight(CObject* pObj)
m_highlightRank = -1; m_highlightRank = -1;
if ( m_bToy || m_fixImage[0] != 0 ) if ( m_bToy || m_fixImage[0] != 0 )
return; // card with still image? return; // card with still image?
if ( pObj == 0 ) if ( pObj == nullptr )
return; return;
for (int i = 0; i < MAPMAXOBJECT; i++) { for (int i = 0; i < MAPMAXOBJECT; i++) {