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

View File

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

View File

@ -1,5 +1,6 @@
// * 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
@ -17,36 +18,21 @@
// mainshort.cpp
#include <windows.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"
#include <ui/mainshort.h>
namespace Ui {
// 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_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT);
m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
m_event = static_cast<CEvent*>(m_iMan->SearchInstance(CLASS_EVENT));
m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
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_SHORTCUT01,
@ -113,13 +99,13 @@ bool CMainShort::CreateShortcuts()
int i, rank, icon;
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_EDITLOCK);
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_shortcuts[i] = 0;
@ -130,15 +116,15 @@ bool CMainShort::CreateShortcuts()
pos.x = 4.0f/640.0f;
pos.y = (480.0f-32.0f)/480.0f;
if ( m_main->RetMovieLock() &&
!m_main->RetEditLock() ) // hangs during film?
if ( m_main->GetMovieLock() &&
!m_main->GetEditLock() ) // hangs during film?
{
m_interface->CreateShortcut(pos, dim, 7, EVENT_OBJECT_MOVIELOCK);
return true;
}
if ( !m_main->RetFreePhoto() &&
(m_main->RetEditLock() ||
m_engine->RetPause()) ) // hangs during edition?
if ( !m_main->GetFreePhoto() &&
(m_main->GetEditLock() ||
m_engine->GetPause()) ) // hangs during edition?
{
m_interface->CreateShortcut(pos, dim, 6, EVENT_OBJECT_EDITLOCK);
return true;
@ -154,13 +140,13 @@ bool CMainShort::CreateShortcuts()
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
if ( pObj == 0 ) break;
if ( pObj == nullptr ) break;
if ( !pObj->RetActif() ) continue;
if ( !pObj->RetSelectable() ) continue;
if ( pObj->RetProxyActivate() ) continue;
if ( !pObj->GetActif() ) continue;
if ( !pObj->GetSelectable() ) continue;
if ( pObj->GetProxyActivate() ) continue;
type = pObj->RetType();
type = pObj->GetType();
icon = -1;
if ( m_bBuilding )
{
@ -243,12 +229,12 @@ bool CMainShort::UpdateShortcuts()
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]);
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());
}
}
@ -257,7 +243,7 @@ bool CMainShort::UpdateShortcuts()
// Selects an object through a shortcut.
void CMainShort::SelectShortcut(EventMsg event)
void CMainShort::SelectShortcut(EventType event)
{
int i;
@ -265,7 +251,7 @@ void CMainShort::SelectShortcut(EventMsg event)
{
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?
{
@ -289,9 +275,9 @@ void CMainShort::SelectNext()
CObject* pPrev;
int i;
if ( m_main->RetMovieLock() ||
m_main->RetEditLock() ||
m_engine->RetPause() ) return;
if ( m_main->GetMovieLock() ||
m_main->GetEditLock() ||
m_engine->GetPause() ) return;
pPrev = m_main->DeselectAll();
@ -299,12 +285,12 @@ void CMainShort::SelectNext()
{
if ( m_shortcuts[i] == pPrev )
{
if ( m_shortcuts[++i] == 0 ) i = 1;
if ( m_shortcuts[++i] == nullptr ) i = 1;
break;
}
}
if ( i == 20 || m_shortcuts[i] == 0 )
if ( i == 20 || m_shortcuts[i] == nullptr )
{
m_main->SelectHuman();
}
@ -325,13 +311,13 @@ CObject* CMainShort::DetectShort(Math::Point pos)
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]);
if ( pc != 0 )
{
cpos = pc->RetPos();
cdim = pc->RetDim();
cpos = pc->GetPos();
cdim = pc->GetDim();
if ( pos.x >= cpos.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.
void CMainShort::SetHilite(CObject* pObj)
void CMainShort::SetHighlight(CObject* pObj)
{
CControl* pc;
int 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]);
if ( pc == 0 ) continue;
if ( pc == nullptr ) continue;
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
// * 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
@ -18,45 +19,45 @@
#pragma once
#include <ui/interface.h>
#include "common/event.h"
#include "math/point.h"
#include <common/event.h>
#include <math/point.h>
class CInstanceManager;
class CD3DEngine;
class CInterface;
class CRobotMain;
class CObject;
#include <object/object.h>
#include <graphics/engine/engine.h>
namespace Ui {
class CMainShort
{
public:
CMainShort(CInstanceManager* iMan);
~CMainShort();
public:
CMainShort();
~CMainShort();
void SetMode(bool bBuilding);
void FlushShortcuts();
bool CreateShortcuts();
bool UpdateShortcuts();
void SelectShortcut(EventMsg event);
void SelectNext();
CObject* DetectShort(Math::Point pos);
void SetHilite(CObject* pObj);
void SetMode(bool bBuilding);
void FlushShortcuts();
bool CreateShortcuts();
bool UpdateShortcuts();
void SelectShortcut(EventType event);
void SelectNext();
CObject* DetectShort(Math::Point pos);
void SetHighlight(CObject* pObj);
protected:
protected:
protected:
CInstanceManager* m_iMan;
CEvent* m_event;
CD3DEngine* m_engine;
CInterface* m_interface;
CRobotMain* m_main;
protected:
CInstanceManager* m_iMan;
CEvent* m_event;
Gfx::CEngine* m_engine;
CInterface* m_interface;
CRobotMain* m_main;
CObject* m_shortcuts[20];
bool m_bBuilding;
CObject* m_shortcuts[20];
bool m_bBuilding;
};
}

View File

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