From 41fa8458c2e28f05a610bfc3119f86b8dc85542a Mon Sep 17 00:00:00 2001 From: erihel Date: Mon, 24 Jun 2013 22:09:39 +0200 Subject: Some Ui refactoring --- src/graphics/engine/pyro.cpp | 7 ++----- src/graphics/engine/pyro.h | 5 ----- src/object/auto/auto.cpp | 2 -- src/object/auto/auto.h | 2 -- src/object/auto/autobase.cpp | 5 ++--- src/object/auto/autoconvert.cpp | 5 ++--- src/object/auto/autoderrick.cpp | 3 +-- src/object/auto/autodestroyer.cpp | 3 +-- src/object/auto/autoenergy.cpp | 5 ++--- src/object/auto/autofactory.cpp | 7 +++---- src/object/auto/autolabo.cpp | 5 ++--- src/object/auto/autonuclear.cpp | 5 ++--- src/object/auto/autoresearch.cpp | 7 +++---- src/object/auto/autotower.cpp | 3 +-- src/object/brain.cpp | 6 ++---- src/object/brain.h | 2 -- src/object/object.cpp | 7 ++----- src/object/object.h | 5 ----- src/object/robotmain.cpp | 9 +++++++++ src/object/robotmain.h | 3 +++ src/object/task/task.cpp | 1 - src/object/task/task.h | 4 ---- src/object/task/taskbuild.cpp | 6 ++---- src/object/task/taskrecover.cpp | 4 ++-- src/object/task/tasksearch.cpp | 8 +++----- src/object/task/taskshield.cpp | 1 + src/object/task/taskterraform.cpp | 1 + src/object/task/taskturn.cpp | 2 +- src/script/script.cpp | 9 ++++----- src/script/script.h | 2 -- 30 files changed, 51 insertions(+), 83 deletions(-) (limited to 'src') diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp index 7c51829..231bf51 100644 --- a/src/graphics/engine/pyro.cpp +++ b/src/graphics/engine/pyro.cpp @@ -32,8 +32,6 @@ #include "object/robotmain.h" #include "object/motion/motionhuman.h" -#include "ui/displaytext.h" - // Graphics module namespace namespace Gfx { @@ -49,7 +47,6 @@ CPyro::CPyro() m_camera = m_main->GetCamera(); m_particle = m_engine->GetParticle(); m_lightMan = m_engine->GetLightManager(); - m_displayText = m_main->GetDisplayText(); m_sound = CApplication::GetInstancePointer()->GetSound(); m_object = nullptr; @@ -1301,13 +1298,13 @@ void CPyro::DisplayError(PyroType type, CObject* obj) oType == OBJECT_END ) { err = ERR_DELETEBUILDING; - m_displayText->DisplayError(err, obj->GetPosition(0), 5.0f); + m_main->DisplayError(err, obj->GetPosition(0), 5.0f); return; } if ( err != ERR_OK ) { - m_displayText->DisplayError(err, obj); + m_main->DisplayError(err, obj); } } } diff --git a/src/graphics/engine/pyro.h b/src/graphics/engine/pyro.h index 98b9a1b..60724b4 100644 --- a/src/graphics/engine/pyro.h +++ b/src/graphics/engine/pyro.h @@ -35,10 +35,6 @@ class CObject; class CRobotMain; class CSoundInterface; -namespace Ui { -class CDisplayText; -} - // Graphics module namespace namespace Gfx { @@ -179,7 +175,6 @@ protected: CParticle* m_particle; CLightManager* m_lightMan; CObject* m_object; - Ui::CDisplayText* m_displayText; CRobotMain* m_main; CSoundInterface* m_sound; diff --git a/src/object/auto/auto.cpp b/src/object/auto/auto.cpp index 8dc1d94..0aeaa0a 100644 --- a/src/object/auto/auto.cpp +++ b/src/object/auto/auto.cpp @@ -52,7 +52,6 @@ CAuto::CAuto(CObject* object) m_lightning = m_engine->GetLightning(); m_camera = m_main->GetCamera(); m_interface = m_main->GetInterface(); - m_displayText = m_main->GetDisplayText(); m_type = m_object->GetType(); m_time = 0.0f; @@ -83,7 +82,6 @@ CAuto::~CAuto() m_lightning = nullptr; m_camera = nullptr; m_interface = nullptr; - m_displayText = nullptr; } diff --git a/src/object/auto/auto.h b/src/object/auto/auto.h index 4a430ce..fd25e70 100644 --- a/src/object/auto/auto.h +++ b/src/object/auto/auto.h @@ -28,7 +28,6 @@ class CRobotMain; class CSoundInterface; namespace Ui { -class CDisplayText; class CInterface; class CWindow; } /* Ui */ @@ -101,7 +100,6 @@ protected: Gfx::CLightning* m_lightning; Gfx::CCamera* m_camera; Ui::CInterface* m_interface; - Ui::CDisplayText* m_displayText; CRobotMain* m_main; CObject* m_object; CSoundInterface* m_sound; diff --git a/src/object/auto/autobase.cpp b/src/object/auto/autobase.cpp index d0bd87b..6d61bc2 100644 --- a/src/object/auto/autobase.cpp +++ b/src/object/auto/autobase.cpp @@ -34,7 +34,6 @@ #include "ui/interface.h" #include "ui/window.h" -#include "ui/displaytext.h" @@ -317,14 +316,14 @@ begin: err = CheckCloseDoor(); if ( err != ERR_OK ) { - m_displayText->DisplayError(err, m_object); + m_main->DisplayError(err, m_object); return false; } err = m_main->CheckEndMission(false); if ( err != ERR_OK ) { - m_displayText->DisplayError(err, m_object); + m_main->DisplayError(err, m_object); return false; } diff --git a/src/object/auto/autoconvert.cpp b/src/object/auto/autoconvert.cpp index 7281ed7..ee1e83b 100644 --- a/src/object/auto/autoconvert.cpp +++ b/src/object/auto/autoconvert.cpp @@ -26,7 +26,6 @@ #include "ui/interface.h" #include "ui/window.h" -#include "ui/displaytext.h" #include #include @@ -515,7 +514,7 @@ void CAutoConvert::CreateMetal() if ( !fret->CreateResource(pos, angle, OBJECT_METAL) ) { delete fret; - m_displayText->DisplayError(ERR_TOOMANY, m_object); + m_main->DisplayError(ERR_TOOMANY, m_object); return; } @@ -524,6 +523,6 @@ void CAutoConvert::CreateMetal() fret->SetResetCap(RESET_DELETE); } - m_displayText->DisplayError(INFO_CONVERT, m_object); + m_main->DisplayError(INFO_CONVERT, m_object); } diff --git a/src/object/auto/autoderrick.cpp b/src/object/auto/autoderrick.cpp index b613406..5b6cea4 100644 --- a/src/object/auto/autoderrick.cpp +++ b/src/object/auto/autoderrick.cpp @@ -28,7 +28,6 @@ #include "ui/interface.h" #include "ui/window.h" -#include "ui/displaytext.h" #include #include @@ -535,7 +534,7 @@ void CAutoDerrick::CreateFret(Math::Vector pos, float angle, ObjectType type, if ( !fret->CreateResource(pos, angle, type) ) { delete fret; - m_displayText->DisplayError(ERR_TOOMANY, m_object); + m_main->DisplayError(ERR_TOOMANY, m_object); return; } fret->SetLock(true); // object not yet usable diff --git a/src/object/auto/autodestroyer.cpp b/src/object/auto/autodestroyer.cpp index fdaebc0..dfe8e78 100644 --- a/src/object/auto/autodestroyer.cpp +++ b/src/object/auto/autodestroyer.cpp @@ -24,7 +24,6 @@ #include "ui/interface.h" #include "ui/window.h" -#include "ui/displaytext.h" #include #include @@ -122,7 +121,7 @@ bool CAutoDestroyer::EventProcess(const Event &event) { Error err = StartAction(0); if ( err != ERR_OK ) - m_displayText->DisplayError(err, m_object); + m_main->DisplayError(err, m_object); return false; } diff --git a/src/object/auto/autoenergy.cpp b/src/object/auto/autoenergy.cpp index 6a8672b..a38caf2 100644 --- a/src/object/auto/autoenergy.cpp +++ b/src/object/auto/autoenergy.cpp @@ -29,7 +29,6 @@ #include "ui/interface.h" #include "ui/gauge.h" #include "ui/window.h" -#include "ui/displaytext.h" #include #include @@ -325,7 +324,7 @@ bool CAutoEnergy::EventProcess(const Event &event) fret->SetPosition(0, Math::Vector(0.0f, 3.0f, 0.0f)); m_object->SetPower(fret); - m_displayText->DisplayError(INFO_ENERGY, m_object); + m_main->DisplayError(INFO_ENERGY, m_object); } SetBusy(false); @@ -468,7 +467,7 @@ void CAutoEnergy::CreatePower() if ( !power->CreateResource(pos, angle, OBJECT_POWER) ) { delete power; - m_displayText->DisplayError(ERR_TOOMANY, m_object); + m_main->DisplayError(ERR_TOOMANY, m_object); return; } power->SetLock(true); // battery not yet usable diff --git a/src/object/auto/autofactory.cpp b/src/object/auto/autofactory.cpp index a648656..49abad4 100644 --- a/src/object/auto/autofactory.cpp +++ b/src/object/auto/autofactory.cpp @@ -32,7 +32,6 @@ #include "ui/interface.h" #include "ui/window.h" -#include "ui/displaytext.h" #include #include @@ -211,7 +210,7 @@ bool CAutoFactory::EventProcess(const Event &event) Error err = StartAction(type); if( err != ERR_OK && err != ERR_GENERIC ) - m_displayText->DisplayError(err, m_object); + m_main->DisplayError(err, m_object); if( err != ERR_GENERIC ) return false; @@ -379,7 +378,7 @@ bool CAutoFactory::EventProcess(const Event &event) } else { - m_displayText->DisplayError(INFO_FACTORY, m_object); + m_main->DisplayError(INFO_FACTORY, m_object); SoundManip(2.0f, 1.0f, 1.2f); fret = SearchFret(); // transform metal? @@ -678,7 +677,7 @@ bool CAutoFactory::CreateVehicle() if ( !vehicle->CreateVehicle(pos, angle, m_type, -1.0f, false, false) ) { delete vehicle; - m_displayText->DisplayError(ERR_TOOMANY, m_object); + m_main->DisplayError(ERR_TOOMANY, m_object); return false; } vehicle->UpdateMapping(); diff --git a/src/object/auto/autolabo.cpp b/src/object/auto/autolabo.cpp index 172a618..07112b7 100644 --- a/src/object/auto/autolabo.cpp +++ b/src/object/auto/autolabo.cpp @@ -29,7 +29,6 @@ #include "ui/interface.h" #include "ui/window.h" -#include "ui/displaytext.h" #include #include @@ -179,7 +178,7 @@ bool CAutoLabo::EventProcess(const Event &event) if ( event.type == EVENT_OBJECT_RiGUN ) err = StartAction(RESEARCH_iGUN); if( err != ERR_OK && err != ERR_GENERIC ) - m_displayText->DisplayError(err, m_object); + m_main->DisplayError(err, m_object); if( err != ERR_GENERIC ) return false; @@ -370,7 +369,7 @@ bool CAutoLabo::EventProcess(const Event &event) delete power; } - m_displayText->DisplayError(INFO_LABO, m_object); + m_main->DisplayError(INFO_LABO, m_object); SoundManip(1.5f, 1.0f, 0.5f); m_phase = ALAP_CLOSE1; diff --git a/src/object/auto/autonuclear.cpp b/src/object/auto/autonuclear.cpp index 224776d..edab5eb 100644 --- a/src/object/auto/autonuclear.cpp +++ b/src/object/auto/autonuclear.cpp @@ -26,7 +26,6 @@ #include "ui/interface.h" #include "ui/window.h" -#include "ui/displaytext.h" #include #include @@ -274,7 +273,7 @@ bool CAutoNuclear::EventProcess(const Event &event) SetBusy(false); UpdateInterface(); - m_displayText->DisplayError(INFO_NUCLEAR, m_object); + m_main->DisplayError(INFO_NUCLEAR, m_object); m_phase = ANUP_WAIT; m_progress = 0.0f; @@ -402,7 +401,7 @@ void CAutoNuclear::CreatePower() if ( !power->CreateResource(pos, angle, OBJECT_ATOMIC) ) { delete power; - m_displayText->DisplayError(ERR_TOOMANY, m_object); + m_main->DisplayError(ERR_TOOMANY, m_object); return; } diff --git a/src/object/auto/autoresearch.cpp b/src/object/auto/autoresearch.cpp index 8308ebe..834a48c 100644 --- a/src/object/auto/autoresearch.cpp +++ b/src/object/auto/autoresearch.cpp @@ -29,7 +29,6 @@ #include "ui/interface.h" #include "ui/gauge.h" #include "ui/window.h" -#include "ui/displaytext.h" #include #include @@ -178,7 +177,7 @@ bool CAutoResearch::EventProcess(const Event &event) if ( event.type == EVENT_OBJECT_RATOMIC ) err = StartAction(RESEARCH_ATOMIC); if( err != ERR_OK && err != ERR_GENERIC ) - m_displayText->DisplayError(err, m_object); + m_main->DisplayError(err, m_object); if( err != ERR_GENERIC ) return false; @@ -257,7 +256,7 @@ bool CAutoResearch::EventProcess(const Event &event) m_eventQueue->AddEvent(newEvent); UpdateInterface(); - m_displayText->DisplayError(INFO_RESEARCH, m_object); + m_main->DisplayError(INFO_RESEARCH, m_object); message = ERR_OK; if ( m_research == RESEARCH_TANK ) message = INFO_RESEARCHTANK; @@ -270,7 +269,7 @@ bool CAutoResearch::EventProcess(const Event &event) if ( m_research == RESEARCH_ATOMIC ) message = INFO_RESEARCHATOMIC; if ( message != ERR_OK ) { - m_displayText->DisplayError(message, m_object); + m_main->DisplayError(message, m_object); } SetBusy(false); diff --git a/src/object/auto/autotower.cpp b/src/object/auto/autotower.cpp index 17a41f4..329cab0 100644 --- a/src/object/auto/autotower.cpp +++ b/src/object/auto/autotower.cpp @@ -27,7 +27,6 @@ #include "script/cmdtoken.h" #include "ui/interface.h" -#include "ui/displaytext.h" #include "ui/window.h" #include "ui/gauge.h" @@ -179,7 +178,7 @@ bool CAutoTower::EventProcess(const Event &event) target = SearchTarget(m_targetPos); if ( energy < ENERGY_FIRE ) { - m_displayText->DisplayError(ERR_TOWER_ENERGY, m_object); + m_main->DisplayError(ERR_TOWER_ENERGY, m_object); } if ( target == 0 || energy < ENERGY_FIRE ) { diff --git a/src/object/brain.cpp b/src/object/brain.cpp index 9e5149e..1b1565a 100644 --- a/src/object/brain.cpp +++ b/src/object/brain.cpp @@ -35,7 +35,6 @@ #include "sound/sound.h" -#include "ui/displaytext.h" #include "ui/interface.h" #include "ui/slider.h" #include "ui/studio.h" @@ -61,7 +60,6 @@ CBrain::CBrain(CObject* object) m_terrain = m_main->GetTerrain(); m_camera = m_main->GetCamera(); m_interface = m_main->GetInterface(); - m_displayText = m_main->GetDisplayText(); m_sound = CApplication::GetInstancePointer()->GetSound(); m_physics = nullptr; m_motion = nullptr; @@ -733,7 +731,7 @@ bool CBrain::EventProcess(const Event &event) if ( err != ERR_OK ) { - m_displayText->DisplayError(err, m_object); + m_main->DisplayError(err, m_object); } return true; @@ -1201,7 +1199,7 @@ void CBrain::GroundFlat() err = ERR_FLAG_FLY; pos = m_object->GetPosition(0); if ( pos.y < m_water->GetLevel() ) err = ERR_FLAG_WATER; - m_displayText->DisplayError(err, m_object); + m_main->DisplayError(err, m_object); return; } diff --git a/src/object/brain.h b/src/object/brain.h index dcf07a4..a1f5da7 100644 --- a/src/object/brain.h +++ b/src/object/brain.h @@ -43,7 +43,6 @@ namespace Ui { class CStudio; class CInterface; class CWindow; -class CDisplayText; } namespace Gfx { @@ -177,7 +176,6 @@ protected: CPhysics* m_physics; CMotion* m_motion; Ui::CInterface* m_interface; - Ui::CDisplayText* m_displayText; CRobotMain* m_main; Ui::CStudio* m_studio; CSoundInterface* m_sound; diff --git a/src/object/object.cpp b/src/object/object.cpp index 4cf0688..5a709e6 100644 --- a/src/object/object.cpp +++ b/src/object/object.cpp @@ -79,8 +79,6 @@ #include "script/cbottoken.h" #include "script/cmdtoken.h" -#include "ui/displaytext.h" - #define ADJUST_ONBOARD false // true -> adjusts the camera ONBOARD @@ -228,7 +226,6 @@ CObject::CObject() m_main = CRobotMain::GetInstancePointer(); m_terrain = m_main->GetTerrain(); m_camera = m_main->GetCamera(); - m_displayText = m_main->GetDisplayText(); m_physics = nullptr; m_brain = nullptr; m_motion = nullptr; @@ -5988,7 +5985,7 @@ bool CObject::EventFrame(const Event &event) m_sound->Play(SOUND_FINDING); pyro = new Gfx::CPyro(); pyro->Create(Gfx::PT_FINDING, this, 0.0f); - m_displayText->DisplayError(INFO_FINDING, this); + m_main->DisplayError(INFO_FINDING, this); } } @@ -6639,7 +6636,7 @@ void CObject::SetSelect(bool bMode, bool bDisplayError) } if ( err != ERR_OK && bDisplayError ) { - m_displayText->DisplayError(err, this); + m_main->DisplayError(err, this); } } diff --git a/src/object/object.h b/src/object/object.h index 25ea708..e8b83d9 100644 --- a/src/object/object.h +++ b/src/object/object.h @@ -38,10 +38,6 @@ class CRobotMain; class CBotVar; class CScript; -namespace Ui { -class CDisplayText; -} - /** * \enum ObjectType @@ -689,7 +685,6 @@ protected: CBrain* m_brain; CMotion* m_motion; CAuto* m_auto; - Ui::CDisplayText* m_displayText; CRobotMain* m_main; CSoundInterface* m_sound; CBotVar* m_botVar; diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index b58e5f8..ddee0ff 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -7520,3 +7520,12 @@ void CRobotMain::RestoreNumericLocale() setlocale(LC_NUMERIC, m_oldLocale.c_str()); } +void CRobotMain::DisplayError(Error err, CObject* pObj, float time) +{ + m_displayText->DisplayError(err, pObj, time); +} + +void CRobotMain::DisplayError(Error err, Math::Vector goal, float height, float dist, float time) +{ + m_displayText->DisplayError(err, goal, height, dist, time); +} diff --git a/src/object/robotmain.h b/src/object/robotmain.h index 525e5df..035698c 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -379,6 +379,9 @@ public: CObject* GetSelect(); + void DisplayError(Error err, CObject* pObj, float time=10.0f); + void DisplayError(Error err, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f); + protected: bool EventFrame(const Event &event); bool EventObject(const Event &event); diff --git a/src/object/task/task.cpp b/src/object/task/task.cpp index 5ec6f8a..3624816 100644 --- a/src/object/task/task.cpp +++ b/src/object/task/task.cpp @@ -35,7 +35,6 @@ CTask::CTask(CObject* object) m_main = CRobotMain::GetInstancePointer(); m_terrain = m_main->GetTerrain(); m_camera = m_main->GetCamera(); - m_displayText = m_main->GetDisplayText(); m_object = object; m_physics = m_object->GetPhysics(); diff --git a/src/object/task/task.h b/src/object/task/task.h index 41b3d3b..800b880 100644 --- a/src/object/task/task.h +++ b/src/object/task/task.h @@ -32,9 +32,6 @@ class CObject; class CRobotMain; class CSoundInterface; -namespace Ui { -class CDisplayText; -} /* Ui */ namespace Gfx { class CEngine; @@ -84,7 +81,6 @@ protected: CPhysics* m_physics; CObject* m_object; CRobotMain* m_main; - Ui::CDisplayText* m_displayText; CSoundInterface* m_sound; }; diff --git a/src/object/task/taskbuild.cpp b/src/object/task/taskbuild.cpp index 39479a6..4a62a4a 100644 --- a/src/object/task/taskbuild.cpp +++ b/src/object/task/taskbuild.cpp @@ -33,8 +33,6 @@ #include "physics/physics.h" -#include "ui/displaytext.h" - #include // Object's constructor. @@ -264,7 +262,7 @@ bool CTaskBuild::EventProcess(const Event &event) m_camera->FlushEffect(); Abort(); m_bError = true; - m_displayText->DisplayError(ERR_TOOMANY, m_object->GetPosition(0)); + m_main->DisplayError(ERR_TOOMANY, m_object->GetPosition(0)); return false; } CreateLight(); @@ -486,7 +484,7 @@ Error CTaskBuild::IsEnded() m_building->SetCirVibration(Math::Vector(0.0f, 0.0f, 0.0f)); m_building->SetLock(false); // building usable m_main->CreateShortcuts(); - m_displayText->DisplayError(INFO_BUILD, m_buildingPos, 10.0f, 50.0f); + m_main->DisplayError(INFO_BUILD, m_buildingPos, 10.0f, 50.0f); automat = m_building->GetAuto(); if ( automat != 0 ) diff --git a/src/object/task/taskrecover.cpp b/src/object/task/taskrecover.cpp index b86e9a5..af84099 100644 --- a/src/object/task/taskrecover.cpp +++ b/src/object/task/taskrecover.cpp @@ -27,7 +27,7 @@ #include "physics/physics.h" -#include "ui/displaytext.h" +#include "object/robotmain.h" const float ENERGY_RECOVER = 0.25f; // energy consumed by recovery @@ -305,7 +305,7 @@ Error CTaskRecover::IsEnded() m_metal = 0; Abort(); m_bError = true; - m_displayText->DisplayError(ERR_TOOMANY, m_object); + m_main->DisplayError(ERR_TOOMANY, m_object); return ERR_STOP; } m_metal->SetLock(true); // metal not yet usable diff --git a/src/object/task/tasksearch.cpp b/src/object/task/tasksearch.cpp index 974a53d..aa731a0 100644 --- a/src/object/task/tasksearch.cpp +++ b/src/object/task/tasksearch.cpp @@ -26,9 +26,7 @@ #include "physics/physics.h" -#include "ui/displaytext.h" - - +#include "object/robotmain.h" // Object's constructor. @@ -293,11 +291,11 @@ bool CTaskSearch::CreateMark() if ( !fret->CreateResource(pos, 0.0f, type) ) { delete fret; - m_displayText->DisplayError(ERR_TOOMANY, m_object); + m_main->DisplayError(ERR_TOOMANY, m_object); return false; } - m_displayText->DisplayError(info, pos, 5.0f, 50.0f); // displays the message + m_main->DisplayError(info, pos, 5.0f, 50.0f); // displays the message return true; } diff --git a/src/object/task/taskshield.cpp b/src/object/task/taskshield.cpp index fe6eaeb..e9ab157 100644 --- a/src/object/task/taskshield.cpp +++ b/src/object/task/taskshield.cpp @@ -26,6 +26,7 @@ #include "math/geometry.h" #include "object/brain.h" +#include "object/robotmain.h" #include "physics/physics.h" diff --git a/src/object/task/taskterraform.cpp b/src/object/task/taskterraform.cpp index 1f5ef7b..096e5de 100644 --- a/src/object/task/taskterraform.cpp +++ b/src/object/task/taskterraform.cpp @@ -28,6 +28,7 @@ #include "math/geometry.h" #include "object/brain.h" +#include "object/robotmain.h" #include "object/motion/motionant.h" #include "object/motion/motionspider.h" diff --git a/src/object/task/taskturn.cpp b/src/object/task/taskturn.cpp index bf9d593..9c099d2 100644 --- a/src/object/task/taskturn.cpp +++ b/src/object/task/taskturn.cpp @@ -20,7 +20,7 @@ #include "graphics/engine/terrain.h" #include "physics/physics.h" - +#include "object/robotmain.h" // Object's constructor. diff --git a/src/script/script.cpp b/src/script/script.cpp index b03702c..8736f01 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -3174,7 +3174,7 @@ bool CScript::rMessage(CBotVar* var, CBotVar* result, int& exception, void* user type = static_cast(var->GetValInt()); } - script->m_displayText->DisplayText(p, script->m_object, 10.0f, type); + script->m_main->GetDisplayText()->DisplayText(p, script->m_object, 10.0f, type); script->m_main->CheckEndMessage(p); return true; @@ -3504,7 +3504,6 @@ CScript::CScript(CObject* object, CTaskManager** secondaryTask) m_secondaryTask = secondaryTask; m_interface = m_main->GetInterface(); - m_displayText = m_main->GetDisplayText(); m_ipf = CBOT_IPF; m_errMode = ERM_STOP; @@ -3899,7 +3898,7 @@ bool CScript::Continue(const Event &event) { char s[100]; GetError(s); - m_displayText->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR); + m_main->GetDisplayText()->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR); } m_engine->SetPause(true); // gives pause return true; @@ -3932,7 +3931,7 @@ bool CScript::Continue(const Event &event) { char s[100]; GetError(s); - m_displayText->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR); + m_main->GetDisplayText()->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR); } return true; } @@ -3974,7 +3973,7 @@ bool CScript::Step(const Event &event) { char s[100]; GetError(s); - m_displayText->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR); + m_main->GetDisplayText()->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR); } return true; } diff --git a/src/script/script.h b/src/script/script.h index 7a5d075..7fd5555 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -34,7 +34,6 @@ class CTaskManager; class CRobotMain; namespace Ui{ -class CDisplayText; class CEdit; class CInterface; class CList; @@ -210,7 +209,6 @@ private: protected: Gfx::CEngine* m_engine; Ui::CInterface* m_interface; - Ui::CDisplayText* m_displayText; CBotProgram* m_botProg; CRobotMain* m_main; Gfx::CTerrain* m_terrain; -- cgit v1.2.3-1-g7c22 From f8a6c6750a2a0196d204c02b98082df1d1b56473 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Wed, 26 Jun 2013 20:40:48 +0200 Subject: Fix for #228 * "empty" objects were wrongly handled in CPyro --- src/graphics/engine/pyro.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp index 231bf51..d3e0405 100644 --- a/src/graphics/engine/pyro.cpp +++ b/src/graphics/engine/pyro.cpp @@ -1553,15 +1553,18 @@ void CPyro::ExploStart() for (int i = 0; i < OBJECTMAXPART; i++) { int objRank = m_object->GetObjectRank(i); - if (objRank == -1) continue; + if (objRank == -1) continue; // TODO: refactor later to material change int oldBaseObjRank = m_engine->GetObjectBaseRank(objRank); - int newBaseObjRank = m_engine->CreateBaseObject(); - m_engine->CopyBaseObject(oldBaseObjRank, newBaseObjRank); - m_engine->SetObjectBaseRank(objRank, newBaseObjRank); + if (oldBaseObjRank != -1) + { + int newBaseObjRank = m_engine->CreateBaseObject(); + m_engine->CopyBaseObject(oldBaseObjRank, newBaseObjRank); + m_engine->SetObjectBaseRank(objRank, newBaseObjRank); - m_engine->ChangeSecondTexture(objRank, "dirty04.png"); + m_engine->ChangeSecondTexture(objRank, "dirty04.png"); + } Math::Vector pos = m_object->GetPosition(i); @@ -1625,11 +1628,14 @@ void CPyro::BurnStart() // TODO: refactor later to material change int oldBaseObjRank = m_engine->GetObjectBaseRank(objRank); - int newBaseObjRank = m_engine->CreateBaseObject(); - m_engine->CopyBaseObject(oldBaseObjRank, newBaseObjRank); - m_engine->SetObjectBaseRank(objRank, newBaseObjRank); + if (oldBaseObjRank != -1) + { + int newBaseObjRank = m_engine->CreateBaseObject(); + m_engine->CopyBaseObject(oldBaseObjRank, newBaseObjRank); + m_engine->SetObjectBaseRank(objRank, newBaseObjRank); - m_engine->ChangeSecondTexture(objRank, "dirty04.png"); + m_engine->ChangeSecondTexture(objRank, "dirty04.png"); + } } m_engine->LoadTexture("dirty04.png"); -- cgit v1.2.3-1-g7c22 From b5e87aa91fc0ebafc0e00d17c19663dff7d1ac0d Mon Sep 17 00:00:00 2001 From: erihel Date: Tue, 16 Jul 2013 16:00:06 +0200 Subject: Datadir in command line didn't work with config. Values from config file overwrote datadir --- src/app/app.cpp | 8 +++++--- src/app/app.h | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index f98e0fc..f6fe19e 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -110,6 +110,7 @@ CApplication::CApplication() m_exitCode = 0; m_active = false; m_debugModes = 0; + m_customDataPath = false; m_windowTitle = "COLOBOT"; @@ -344,6 +345,7 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) case OPT_DATADIR: { m_dataPath = optarg; + m_customDataPath = true; GetLogger()->Info("Using custom data dir: '%s'\n", m_dataPath.c_str()); break; } @@ -404,7 +406,7 @@ bool CApplication::Create() } else { - if (GetProfile().GetLocalProfileString("Resources", "Data", path)) + if (!m_customDataPath && GetProfile().GetLocalProfileString("Resources", "Data", path)) m_dataPath = path; } @@ -440,7 +442,7 @@ bool CApplication::Create() GetProfile().SetLocalProfileString("Resources", "Music", GetDataSubdirPath(DIR_MUSIC)); } - if (GetProfile().GetLocalProfileString("Resources", "Sound", path)) + if (!m_customDataPath && GetProfile().GetLocalProfileString("Resources", "Sound", path)) { m_sound->CacheAll(path); } @@ -449,7 +451,7 @@ bool CApplication::Create() m_sound->CacheAll(GetDataSubdirPath(DIR_SOUND)); } - if (GetProfile().GetLocalProfileString("Resources", "Music", path)) + if (!m_customDataPath && GetProfile().GetLocalProfileString("Resources", "Music", path)) { m_sound->AddMusicFiles(path); } diff --git a/src/app/app.h b/src/app/app.h index 269fa9b..6b02f67 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -480,6 +480,9 @@ protected: //! Path to directory with data files std::string m_dataPath; + //! True if datadir was passed in command line + bool m_customDataPath; + //! Path to directory with language files std::string m_langPath; -- cgit v1.2.3-1-g7c22 From d70d31acc1753a6edda69727448834e6e1a07886 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 28 Sep 2013 11:13:45 +0200 Subject: Fix for #232 - Images in SatCom Only images, icons still don't work --- src/ui/edit.cpp | 8 ++++---- src/ui/edit.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp index 6fd1735..a187688 100644 --- a/src/ui/edit.cpp +++ b/src/ui/edit.cpp @@ -1144,7 +1144,7 @@ void CEdit::DrawImage(Math::Point pos, std::string name, float width, float dp; std::string filename; - filename = GetProfile().GetUserBasedPath(name, "diagram") + ".png"; + filename = GetProfile().GetUserBasedPath(name, "../icons") + ".png"; m_engine->SetTexture(filename); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); @@ -1426,7 +1426,7 @@ void CEdit::FreeImage() for (int i = 0 ; i < m_imageTotal; i++ ) { - filename = GetProfile().GetUserBasedPath(m_image[i].name, "diagram") + ".png"; + filename = GetProfile().GetUserBasedPath(m_image[i].name, "../icons") + ".png"; m_engine->DeleteTexture(filename); } } @@ -1436,7 +1436,7 @@ void CEdit::FreeImage() void CEdit::LoadImage(std::string name) { std::string filename; - filename = GetProfile().GetUserBasedPath(name, "diagram") + ".png"; + filename = GetProfile().GetUserBasedPath(name, "../icons") + ".png"; m_engine->LoadTexture(filename); } @@ -1653,7 +1653,7 @@ bool CEdit::ReadText(std::string filename, int addSize) m_image[iIndex].width = iWidth*0.75f; m_text[j] = static_cast(iIndex++); // as an index into m_image - m_format[j] = static_cast(Gfx::FONT_MASK_IMAGE); + m_format[j] = Gfx::FONT_MASK_IMAGE; j ++; } } diff --git a/src/ui/edit.h b/src/ui/edit.h index acdf72c..9484fc8 100644 --- a/src/ui/edit.h +++ b/src/ui/edit.h @@ -89,7 +89,7 @@ enum OperUndo struct ImageLine { - //! name of the image (without diagram \) + //! name of the image (without icons/) std::string name; //! vertical offset (v texture) float offset; @@ -101,7 +101,7 @@ struct ImageLine struct HyperLink { - //! text file name (without help \) + //! text file name (without help/) std::string name; //! name of the marker std::string marker; -- cgit v1.2.3-1-g7c22 From 5d0d9b5aa5cf19aff9edb42701d38b5096fce3aa Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 12 Oct 2013 18:48:28 +0200 Subject: Fixed some CBot-related memory leaks * fixed leaks in CScript::CheckToken() * fixed leaks in CInterface * commented out unused function in robotmain.cpp --- src/graphics/engine/lightman.cpp | 10 ---------- src/graphics/engine/lightman.h | 18 ++++++++++++++---- src/object/robotmain.cpp | 10 +++++----- src/script/script.cpp | 10 ++++++---- src/ui/interface.cpp | 26 ++++++++++++-------------- 5 files changed, 37 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/graphics/engine/lightman.cpp b/src/graphics/engine/lightman.cpp index 8694c7a..564cced 100644 --- a/src/graphics/engine/lightman.cpp +++ b/src/graphics/engine/lightman.cpp @@ -69,16 +69,6 @@ void LightProgression::SetTarget(float value) } -DynamicLight::DynamicLight() -{ - rank = 0; - used = enabled = false; - priority = LIGHT_PRI_LOW; - includeType = excludeType = ENG_OBJTYPE_NULL; -} - - - CLightManager::CLightManager(CEngine* engine) { m_device = nullptr; diff --git a/src/graphics/engine/lightman.h b/src/graphics/engine/lightman.h index a2f6044..5df466d 100644 --- a/src/graphics/engine/lightman.h +++ b/src/graphics/engine/lightman.h @@ -51,9 +51,12 @@ struct LightProgression float speed; LightProgression() - { - starting = ending = current = progress = speed = 0.0f; - } + : starting(0.0f) + , ending(0.0f) + , current(0.0f) + , progress(0.0f) + , speed(0.0f) + {} //! Initializes the progression void Init(float value); @@ -113,7 +116,14 @@ struct DynamicLight //! Type of objects excluded from lighting with this light; if ENG_OBJTYPE_NULL is used, it is ignored EngineObjectType excludeType; - DynamicLight(); + DynamicLight() + : rank(0) + , used(false) + , enabled(false) + , priority(LIGHT_PRI_LOW) + , includeType(ENG_OBJTYPE_NULL) + , excludeType(ENG_OBJTYPE_NULL) + {} }; /** diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index ddee0ff..1748c57 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -107,7 +107,7 @@ float g_unit; // conversion factor // Static variables static CBotClass* m_pClassFILE; -static CBotProgram* m_pFuncFile; +//static CBotProgram* m_pFuncFile; static int m_CompteurFileOpen = 0; static std::string m_filesDir; @@ -503,10 +503,10 @@ void InitClassFILE() m_pClassFILE->AddFunction("readln", rfread, cfread ); m_pClassFILE->AddFunction("eof", rfeof, cfeof ); - m_pFuncFile = new CBotProgram( ); - CBotStringArray ListFonctions; - m_pFuncFile->Compile( "public file openfile(string name, string mode) {return new file(name, mode);}", ListFonctions); - m_pFuncFile->SetIdent(-2); // restoreState in special identifier for this function + //m_pFuncFile = new CBotProgram( ); + //CBotStringArray ListFonctions; + //m_pFuncFile->Compile( "public file openfile(string name, string mode) {return new file(name, mode);}", ListFonctions); + //m_pFuncFile->SetIdent(-2); // restoreState in special identifier for this function } diff --git a/src/script/script.cpp b/src/script/script.cpp index 8736f01..ca6ce25 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -3689,6 +3689,7 @@ bool CScript::IsEmpty() bool CScript::CheckToken() { CBotToken* bt; + CBotToken* allBt; CBotString bs; const char* token; int error, cursor1, cursor2, i; @@ -3706,7 +3707,8 @@ bool CScript::CheckToken() used[i] = 0; // token not used } - bt = CBotToken::CompileTokens(m_script, error); + allBt = CBotToken::CompileTokens(m_script, error); + bt = allBt; while ( bt != 0 ) { bs = bt->GetString(); @@ -3727,7 +3729,7 @@ bool CScript::CheckToken() m_cursor1 = cursor1; m_cursor2 = cursor2; strcpy(m_title, ""); - CBotToken::Delete(bt); + CBotToken::Delete(allBt); return false; } @@ -3742,12 +3744,12 @@ bool CScript::CheckToken() strcpy(m_token, m_main->GetObligatoryToken(i)); m_error = ERR_OBLIGATORYTOKEN; strcpy(m_title, ""); - CBotToken::Delete(bt); + CBotToken::Delete(allBt); return false; } } - CBotToken::Delete(bt); + CBotToken::Delete(allBt); return true; } diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 845579e..ab2c01b 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -29,7 +29,7 @@ CInterface::CInterface() m_engine = Gfx::CEngine::GetInstancePointer(); m_camera = nullptr; - for (int i = 0; i < MAXCONTROL; i++ ) + for (int i = 0; i < MAXCONTROL; i++) { m_table[i] = nullptr; } @@ -47,9 +47,9 @@ CInterface::~CInterface() void CInterface::Flush() { - for (int i = 0; i < MAXCONTROL; i++ ) + for (int i = 0; i < MAXCONTROL; i++) { - if ( m_table[i] != nullptr ) + if (m_table[i] != nullptr) { delete m_table[i]; m_table[i] = nullptr; @@ -71,16 +71,15 @@ int CInterface::GetNextFreeControl() template inline T* CInterface::CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - T* pc; - int index; if (eventMsg == EVENT_NULL) eventMsg = GetUniqueEventType(); - if ((index = GetNextFreeControl()) < 0) + int index = GetNextFreeControl(); + if (index < 0) return nullptr; m_table[index] = new T(); - pc = static_cast(m_table[index]); + T* pc = static_cast(m_table[index]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -90,11 +89,10 @@ template inline T* CInterface::CreateControl(Math::Point pos, Math: CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - CWindow* pc; - int index; if (eventMsg == EVENT_NULL) eventMsg = GetUniqueEventType(); + int index = -1; switch (eventMsg) { case EVENT_WINDOW0: index = 0; break; @@ -114,8 +112,9 @@ CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, E if (index < 0) return nullptr; + delete m_table[index]; m_table[index] = new CWindow(); - pc = static_cast(m_table[index]); + CWindow* pc = static_cast(m_table[index]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -207,16 +206,15 @@ CSlider* CInterface::CreateSlider(Math::Point pos, Math::Point dim, int icon, Ev CList* CInterface::CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand) { - CList* pc; - int index; if (eventMsg == EVENT_NULL) eventMsg = GetUniqueEventType(); - if ((index = GetNextFreeControl()) < 0) + int index = GetNextFreeControl(); + if (index < 0) return nullptr; m_table[index] = new CList(); - pc = static_cast(m_table[index]); + CList* pc = static_cast(m_table[index]); pc->Create(pos, dim, icon, eventMsg, expand); return pc; } -- cgit v1.2.3-1-g7c22 From ccb63bd29e0cc7957be53cb40889496d04527d7a Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 12 Oct 2013 21:12:54 +0200 Subject: Fixed memory leaks in CText --- src/graphics/engine/text.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp index 610bfcf..ffd2eb2 100644 --- a/src/graphics/engine/text.cpp +++ b/src/graphics/engine/text.cpp @@ -140,6 +140,12 @@ void CText::FlushCache() for (auto jt = mf->fonts.begin(); jt != mf->fonts.end(); ++jt) { CachedFont *f = (*jt).second; + for (auto ct = f->cache.begin(); ct != f->cache.end(); ++ct) + { + Texture tex; + tex.id = (*ct).second.id; + m_device->DestroyTexture(tex); + } f->cache.clear(); } } @@ -358,14 +364,22 @@ float CText::GetCharWidth(UTF8Char ch, FontType font, float size, float offset) CachedFont* cf = GetOrOpenFont(font, size); assert(cf != nullptr); - CharTexture tex; + Math::Point charSize; auto it = cf->cache.find(ch); if (it != cf->cache.end()) - tex = (*it).second; + { + charSize = (*it).second.charSize; + } else - tex = CreateCharTexture(ch, cf); + { + Math::IntPoint wndSize; + std::string text; + text.append({ch.c1, ch.c2, ch.c3}); + TTF_SizeUTF8(cf->font, text.c_str(), &wndSize.x, &wndSize.y); + charSize = m_engine->WindowToInterfaceSize(wndSize); + } - return tex.charSize.x * width; + return charSize.x * width; } @@ -896,7 +910,6 @@ CharTexture CText::CreateCharTexture(UTF8Char ch, CachedFont* font) if (! tex.Valid()) { m_error = "Texture create error"; - return texture; } else { -- cgit v1.2.3-1-g7c22 From 9017dbbbdb1f59971b17976d7cf95fe39469d82a Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 13 Oct 2013 14:44:12 +0200 Subject: Fixed CTerrain-related memory leaks --- src/graphics/engine/engine.cpp | 26 ++++++++++++++++++++++++++ src/graphics/engine/terrain.cpp | 19 ++++++++++++++++++- src/graphics/engine/terrain.h | 2 +- src/object/robotmain.cpp | 3 ++- 4 files changed, 47 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 669ea42..e973eec 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -600,6 +600,31 @@ void CEngine::DeleteBaseObject(int baseObjRank) void CEngine::DeleteAllBaseObjects() { + for (int baseObjRank = 0; baseObjRank < static_cast( m_baseObjects.size() ); baseObjRank++) + { + EngineBaseObject& p1 = m_baseObjects[baseObjRank]; + if (! p1.used) + continue; + + for (int l2 = 0; l2 < static_cast( p1.next.size() ); l2++) + { + EngineBaseObjTexTier& p2 = p1.next[l2]; + + for (int l3 = 0; l3 < static_cast( p2.next.size() ); l3++) + { + EngineBaseObjLODTier& p3 = p2.next[l3]; + + for (int l4 = 0; l4 < static_cast( p3.next.size() ); l4++) + { + EngineBaseObjDataTier& p4 = p3.next[l4]; + + m_device->DestroyStaticBuffer(p4.staticBufferId); + p4.staticBufferId = 0; + } + } + } + } + m_baseObjects.clear(); } @@ -817,6 +842,7 @@ int CEngine::CreateObject() m_objects[objRank].drawWorld = true; m_objects[objRank].distance = 0.0f; + m_objects[objRank].baseObjRank = -1; m_objects[objRank].shadowRank = -1; return objRank; diff --git a/src/graphics/engine/terrain.cpp b/src/graphics/engine/terrain.cpp index 4fe3057..4b5384e 100644 --- a/src/graphics/engine/terrain.cpp +++ b/src/graphics/engine/terrain.cpp @@ -90,7 +90,7 @@ bool CTerrain::Generate(int mosaicCount, int brickCountPow2, float brickSize, std::vector(dim).swap(m_textures); dim = m_mosaicCount*m_mosaicCount; - std::vector(dim).swap(m_objRanks); + std::vector(dim, -1).swap(m_objRanks); return true; } @@ -258,6 +258,23 @@ TerrainRes CTerrain::GetResource(const Math::Vector &p) void CTerrain::FlushRelief() { m_relief.clear(); + m_resources.clear(); + m_textures.clear(); + + for (int objRank : m_objRanks) + { + if (objRank == -1) + continue; + + int baseObjRank = m_engine->GetObjectBaseRank(objRank); + + if (baseObjRank != -1) + m_engine->DeleteBaseObject(baseObjRank); + + m_engine->DeleteObject(objRank); + } + + m_objRanks.clear(); } /** diff --git a/src/graphics/engine/terrain.h b/src/graphics/engine/terrain.h index e2317c4..e618691 100644 --- a/src/graphics/engine/terrain.h +++ b/src/graphics/engine/terrain.h @@ -239,7 +239,7 @@ public: //! Generates a level in the terrain bool GenerateMaterials(int *id, float min, float max, float slope, float freq, Math::Vector center, float radius); - //! Clears the relief data to zero + //! Clears the relief, resources and all other associated data void FlushRelief(); //! Load relief from image bool LoadRelief(const std::string& fileName, float scaleRelief, bool adjustBorder); diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 1748c57..6fe85d3 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -1104,6 +1104,7 @@ void CRobotMain::ChangePhase(Phase phase) ChangePause(false); FlushDisplayInfo(); m_engine->SetRankView(0); + m_terrain->FlushRelief(); m_engine->DeleteAllObjects(); Gfx::CModelManager::GetInstancePointer()->DeleteAllModelCopies(); m_engine->SetWaterAddColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)); @@ -3842,9 +3843,9 @@ void CRobotMain::Convert() void CRobotMain::ScenePerso() { DeleteAllObjects(); // removes all the current 3D Scene + m_terrain->FlushRelief(); m_engine->DeleteAllObjects(); Gfx::CModelManager::GetInstancePointer()->DeleteAllModelCopies(); - m_terrain->FlushRelief(); // all flat m_terrain->FlushBuildingLevel(); m_terrain->FlushFlyingLimit(); m_lightMan->FlushLights(); -- cgit v1.2.3-1-g7c22 From b3b6a40d9ebe0ceeb1ce34f4de8acf57dc07fca0 Mon Sep 17 00:00:00 2001 From: Didier 'OdyX' Raboud Date: Wed, 23 Oct 2013 14:22:20 +0200 Subject: MacOSX: Add initial support in CMake build infra --- src/CMakeLists.txt | 3 +++ src/common/config.h.cmake | 1 + 2 files changed, 4 insertions(+) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 40373a3..c01fe0f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,6 +31,9 @@ elseif(PLATFORM_WINDOWS) elseif(PLATFORM_LINUX) # for clock_gettime set(PLATFORM_LIBS "-lrt -lX11") +elseif(PLATFORM_MACOSX) + find_library(LIBINTL_LIBRARY NAMES intl libintl ) + set(PLATFORM_LIBS ${LIBINTL_LIBRARY} ${X11_X11_LIB}) endif() diff --git a/src/common/config.h.cmake b/src/common/config.h.cmake index 76b37b5..2f403fa 100644 --- a/src/common/config.h.cmake +++ b/src/common/config.h.cmake @@ -3,6 +3,7 @@ // Macros set by CMake #cmakedefine PLATFORM_WINDOWS @PLATFORM_WINDOWS@ #cmakedefine PLATFORM_LINUX @PLATFORM_LINUX@ +#cmakedefine PLATFORM_MACOSX @PLATFORM_MACOSX@ #cmakedefine PLATFORM_OTHER @PLATFORM_OTHER@ #cmakedefine GLEW_STATIC -- cgit v1.2.3-1-g7c22 From 591ba30a0051c856c8b877b8687f071e0212e28c Mon Sep 17 00:00:00 2001 From: Didier 'OdyX' Raboud Date: Wed, 23 Oct 2013 10:02:41 +0200 Subject: Include the OpenAL headers using the "al.h" form, as recommended by its CMake finder script --- src/sound/oalsound/alsound.h | 2 +- src/sound/oalsound/buffer.h | 2 +- src/sound/oalsound/channel.h | 4 ++-- src/sound/oalsound/check.h | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/sound/oalsound/alsound.h b/src/sound/oalsound/alsound.h index ad32204..cd44ae9 100644 --- a/src/sound/oalsound/alsound.h +++ b/src/sound/oalsound/alsound.h @@ -32,7 +32,7 @@ #include #include -#include +#include class ALSound : public CSoundInterface diff --git a/src/sound/oalsound/buffer.h b/src/sound/oalsound/buffer.h index d847426..e693d75 100644 --- a/src/sound/oalsound/buffer.h +++ b/src/sound/oalsound/buffer.h @@ -30,7 +30,7 @@ #include #include -#include +#include #include class Buffer diff --git a/src/sound/oalsound/channel.h b/src/sound/oalsound/channel.h index a04b509..2930f26 100644 --- a/src/sound/oalsound/channel.h +++ b/src/sound/oalsound/channel.h @@ -30,8 +30,8 @@ #include #include -#include -#include +#include +#include struct SoundOper { diff --git a/src/sound/oalsound/check.h b/src/sound/oalsound/check.h index f677e17..b8f67c0 100644 --- a/src/sound/oalsound/check.h +++ b/src/sound/oalsound/check.h @@ -18,11 +18,11 @@ #pragma once -#include -#include - #include "common/logger.h" +#include +#include + static ALenum CODE = AL_NO_ERROR; inline bool alCheck() -- cgit v1.2.3-1-g7c22 From 97baf7242e49dd09d67b5c94441f983d61eaaeb3 Mon Sep 17 00:00:00 2001 From: Didier 'OdyX' Raboud Date: Wed, 23 Oct 2013 14:22:20 +0200 Subject: Fix system_other implementation by adding an Init() and fixing the wrong const --- src/app/system_other.cpp | 2 +- src/app/system_other.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/app/system_other.cpp b/src/app/system_other.cpp index da81a6d..9d9f76a 100644 --- a/src/app/system_other.cpp +++ b/src/app/system_other.cpp @@ -33,7 +33,7 @@ long long int CSystemUtilsOther::GetTimeStampExactResolution() return 1000000ll; } -long long int CSystemUtilsOther::TimeStampExactDiff(SystemTimeStamp* before, SystemTimeStamp* after) const +long long int CSystemUtilsOther::TimeStampExactDiff(SystemTimeStamp* before, SystemTimeStamp* after) { return (after->sdlTicks - before->sdlTicks) * 1000000ll; } diff --git a/src/app/system_other.h b/src/app/system_other.h index b10a326..7eccf3f 100644 --- a/src/app/system_other.h +++ b/src/app/system_other.h @@ -40,10 +40,11 @@ struct SystemTimeStamp class CSystemUtilsOther : public CSystemUtils { public: + virtual void Init() {}; virtual SystemDialogResult SystemDialog(SystemDialogType type, const std::string& title, const std::string& message) override; virtual void GetCurrentTimeStamp(SystemTimeStamp *stamp) override; - virtual long long GetTimeStampExactResolution() override; + virtual long long int GetTimeStampExactResolution() override; virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override; }; -- cgit v1.2.3-1-g7c22 From f31a570d96e1a0ee28baecefa18b7e8c586c201c Mon Sep 17 00:00:00 2001 From: Didier 'OdyX' Raboud Date: Wed, 23 Oct 2013 14:49:36 +0200 Subject: Include SDL.h in main.cpp to make sure the main loop is SDL's main loop This allows the MacOSX program to start. --- src/app/main.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/app/main.cpp b/src/app/main.cpp index 5c0afd3..1e70beb 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -28,6 +28,7 @@ #include "common/misc.h" #include "common/restext.h" +#include /* Doxygen main page */ -- cgit v1.2.3-1-g7c22 From 9e439d88bf81372ed38838dd406825ca24e7a183 Mon Sep 17 00:00:00 2001 From: Didier 'OdyX' Raboud Date: Mon, 28 Oct 2013 15:18:45 +0100 Subject: Fix the detection of alpha-channel in textures as created by IMG_Load This fixes the textures loading under Mac OS X --- src/graphics/opengl/gldevice.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index bbabdd6..9f64fab 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -606,7 +606,7 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par } else if (params.format == TEX_IMG_AUTO) { - if (data->surface->format->Amask != 0) + if (data->surface->format->BytesPerPixel == 4) { if ((data->surface->format->Amask == 0xFF000000) && (data->surface->format->Rmask == 0x00FF0000) && @@ -630,7 +630,7 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par convert = true; } } - else + else if (data->surface->format->BytesPerPixel == 3) { if ((data->surface->format->Rmask == 0xFF0000) && (data->surface->format->Gmask == 0x00FF00) && @@ -652,6 +652,10 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par convert = true; } } + else { + GetLogger()->Error("Unknown data surface format"); + assert(false); + } } else assert(false); -- cgit v1.2.3-1-g7c22 From c2a717d5c9adc3fb01fb42ca17ba14e65b955236 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Mon, 28 Oct 2013 15:25:14 +0100 Subject: Let mouse.png's format be detected Fixes the mouse cursor on Mac OS X --- src/graphics/engine/engine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index e973eec..5cf7b23 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -276,7 +276,7 @@ bool CEngine::Create() Math::LoadOrthoProjectionMatrix(m_matProjInterface, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f); TextureCreateParams params; - params.format = TEX_IMG_RGB; + params.format = TEX_IMG_AUTO; params.minFilter = TEX_MIN_FILTER_NEAREST; params.magFilter = TEX_MAG_FILTER_NEAREST; params.mipmap = false; -- cgit v1.2.3-1-g7c22 From 70af33e45d286bc6f62a392d0b967aafdc7548e4 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 28 Oct 2013 19:36:43 +0100 Subject: Revert "Merge pull request #243 from OdyX/dev-fix-textures-loading" Looks like it doesn't work on all platforms --- src/graphics/engine/engine.cpp | 2 +- src/graphics/opengl/gldevice.cpp | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 5cf7b23..e973eec 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -276,7 +276,7 @@ bool CEngine::Create() Math::LoadOrthoProjectionMatrix(m_matProjInterface, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f); TextureCreateParams params; - params.format = TEX_IMG_AUTO; + params.format = TEX_IMG_RGB; params.minFilter = TEX_MIN_FILTER_NEAREST; params.magFilter = TEX_MAG_FILTER_NEAREST; params.mipmap = false; diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index 9f64fab..bbabdd6 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -606,7 +606,7 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par } else if (params.format == TEX_IMG_AUTO) { - if (data->surface->format->BytesPerPixel == 4) + if (data->surface->format->Amask != 0) { if ((data->surface->format->Amask == 0xFF000000) && (data->surface->format->Rmask == 0x00FF0000) && @@ -630,7 +630,7 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par convert = true; } } - else if (data->surface->format->BytesPerPixel == 3) + else { if ((data->surface->format->Rmask == 0xFF0000) && (data->surface->format->Gmask == 0x00FF00) && @@ -652,10 +652,6 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par convert = true; } } - else { - GetLogger()->Error("Unknown data surface format"); - assert(false); - } } else assert(false); -- cgit v1.2.3-1-g7c22 From ee90f02bc4f45ff0b68099e47245869236bcbbfd Mon Sep 17 00:00:00 2001 From: Didier 'OdyX' Raboud Date: Tue, 29 Oct 2013 14:30:58 +0100 Subject: Add an icon and executable information to the colobot.exe when build in MXE --- src/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c01fe0f..2fab853 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,6 +50,12 @@ if(OPENAL_SOUND) ) endif() +set(RES_FILES "") + +if(PLATFORM_WINDOWS) + set(RES_FILES "../desktop/colobot.rc") +endif() + # Platform-dependent implementation of system.h if(PLATFORM_WINDOWS) set(SYSTEM_CPP_MODULE "system_windows.cpp") @@ -182,6 +188,7 @@ ui/studio.cpp ui/target.cpp ui/window.cpp ${OPENAL_SRC} +${RES_FILES} ) -- cgit v1.2.3-1-g7c22 From 9e9a9937ba94a3d800fce33c7f74cc32e2fef14c Mon Sep 17 00:00:00 2001 From: Didier 'OdyX' Raboud Date: Tue, 29 Oct 2013 14:43:24 +0100 Subject: Revert "Include SDL.h in main.cpp to make sure the main loop is SDL's main loop" This was the wrong fix for the problem. This reverts commit f31a570d96e1a0ee28baecefa18b7e8c586c201c. --- src/app/main.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/app/main.cpp b/src/app/main.cpp index 1e70beb..5c0afd3 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -28,7 +28,6 @@ #include "common/misc.h" #include "common/restext.h" -#include /* Doxygen main page */ -- cgit v1.2.3-1-g7c22 From cd97feabb0d3cf808f0332f8d9467f198e8d5d29 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Tue, 29 Oct 2013 21:59:23 +0100 Subject: Revert back "Merge pull request #243 from OdyX/dev-fix-textures-loading" False alarm, was caused probably by faulty build bot. This definately should work on all platforms. --- src/graphics/engine/engine.cpp | 2 +- src/graphics/opengl/gldevice.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index e973eec..5cf7b23 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -276,7 +276,7 @@ bool CEngine::Create() Math::LoadOrthoProjectionMatrix(m_matProjInterface, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f); TextureCreateParams params; - params.format = TEX_IMG_RGB; + params.format = TEX_IMG_AUTO; params.minFilter = TEX_MIN_FILTER_NEAREST; params.magFilter = TEX_MAG_FILTER_NEAREST; params.mipmap = false; diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index bbabdd6..9f64fab 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -606,7 +606,7 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par } else if (params.format == TEX_IMG_AUTO) { - if (data->surface->format->Amask != 0) + if (data->surface->format->BytesPerPixel == 4) { if ((data->surface->format->Amask == 0xFF000000) && (data->surface->format->Rmask == 0x00FF0000) && @@ -630,7 +630,7 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par convert = true; } } - else + else if (data->surface->format->BytesPerPixel == 3) { if ((data->surface->format->Rmask == 0xFF0000) && (data->surface->format->Gmask == 0x00FF00) && @@ -652,6 +652,10 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par convert = true; } } + else { + GetLogger()->Error("Unknown data surface format"); + assert(false); + } } else assert(false); -- cgit v1.2.3-1-g7c22 From 2acc338c3aeab684b9be4f67c28c7aaa47c18f5a Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Wed, 30 Oct 2013 21:51:03 +0100 Subject: Drop now-useless display of licenses.txt in PHASE_GENERIC The content of licenses.txt in data has gotten useless as the restrictions got waived, displaying it is useless. --- src/ui/maindialog.cpp | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index defff84..407f8da 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -1841,17 +1841,6 @@ pos.y -= 0.048f; pe->SetFontSize(Gfx::FONT_SIZE_SMALL); pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/authors.txt")); - pos.x = 80.0f/640.0f; - pos.y = 140.0f/480.0f; - ddim.x = 490.0f/640.0f; - ddim.y = 100.0f/480.0f; - pe = pw->CreateEdit(pos, ddim, 0, EVENT_EDIT2); - pe->SetGenericMode(true); - pe->SetEditCap(false); - pe->SetHighlightCap(false); - pe->SetFontType(Gfx::FONT_COURIER); - pe->SetFontSize(Gfx::FONT_SIZE_SMALL); - pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/licences.txt")); // #endif /* TODO: #if _SCHOOL #if _CEEBOTDEMO -- cgit v1.2.3-1-g7c22