diff options
author | Piotr Dziwinski <piotrdz@gmail.com> | 2013-12-03 00:11:26 +0100 |
---|---|---|
committer | Piotr Dziwinski <piotrdz@gmail.com> | 2013-12-04 00:15:39 +0100 |
commit | 8deb1305726966b3b583865dec1ba7ba1327d8cb (patch) | |
tree | 291627fbe0123dc35c015b1f398585f204afe8ea /src/object | |
parent | dae8d8738908a65a4ee4ef14d88681e196825126 (diff) | |
download | colobot-8deb1305726966b3b583865dec1ba7ba1327d8cb.tar.gz colobot-8deb1305726966b3b583865dec1ba7ba1327d8cb.tar.bz2 colobot-8deb1305726966b3b583865dec1ba7ba1327d8cb.zip |
Changed char[] to std::string in restext
Experimental changes
Diffstat (limited to 'src/object')
-rw-r--r-- | src/object/auto/auto.cpp | 2 | ||||
-rw-r--r-- | src/object/brain.cpp | 12 | ||||
-rw-r--r-- | src/object/object.cpp | 4 | ||||
-rw-r--r-- | src/object/object.h | 2 | ||||
-rw-r--r-- | src/object/robotmain.cpp | 27 | ||||
-rw-r--r-- | src/object/robotmain.h | 4 |
6 files changed, 27 insertions, 24 deletions
diff --git a/src/object/auto/auto.cpp b/src/object/auto/auto.cpp index 0aeaa0a..9e593a9 100644 --- a/src/object/auto/auto.cpp +++ b/src/object/auto/auto.cpp @@ -175,7 +175,6 @@ bool CAuto::CreateInterface(bool bSelect) Ui::CWindow* pw; Math::Point pos, dim, ddim; float ox, oy, sx, sy; - char name[100]; pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW0)); if ( pw != nullptr ) @@ -195,6 +194,7 @@ bool CAuto::CreateInterface(bool bSelect) pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW0)); if ( pw == 0 ) return false; + std::string name; m_object->GetTooltipName(name); pos.x = 0.0f; pos.y = 64.0f/480.0f; diff --git a/src/object/brain.cpp b/src/object/brain.cpp index 1b1565a..b27acd1 100644 --- a/src/object/brain.cpp +++ b/src/object/brain.cpp @@ -1238,7 +1238,6 @@ bool CBrain::CreateInterface(bool bSelect) Ui::CLabel* pl; Math::Point pos, dim, ddim; float ox, oy, sx, sy; - char name[100]; pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); if ( pw != 0 ) @@ -1259,13 +1258,14 @@ bool CBrain::CreateInterface(bool bSelect) pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); if ( pw == 0 ) return false; - m_object->GetTooltipName(name); + std::string tooltipLabel; + m_object->GetTooltipName(tooltipLabel); pos.x = 0.0f; pos.y = 64.0f/480.0f; ddim.x = 540.0f/640.0f; if ( !m_main->GetShowMap() ) ddim.x = 640.0f/640.0f; ddim.y = 16.0f/480.0f; - pw->CreateLabel(pos, ddim, 0, EVENT_LABEL0, name); + pw->CreateLabel(pos, ddim, 0, EVENT_LABEL0, tooltipLabel); dim.x = 33.0f/640.0f; dim.y = 33.0f/480.0f; @@ -1674,8 +1674,10 @@ bool CBrain::CreateInterface(bool bSelect) pos.y = oy+sy*1.2f; ddim.x = dim.x*2.2f; ddim.y = dim.y*0.4f; - GetResource(RES_TEXT, RT_INTERFACE_REC, name); - pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name); + + std::string recordLabel; + GetResource(RES_TEXT, RT_INTERFACE_REC, recordLabel); + pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, recordLabel); pl->SetFontSize(9.0f); pos.x = ox+sx*7.0f; diff --git a/src/object/object.cpp b/src/object/object.cpp index 5a709e6..f1de424 100644 --- a/src/object/object.cpp +++ b/src/object/object.cpp @@ -7263,10 +7263,10 @@ int CObject::GetDefRank() // Getes the object name for the tooltip. -bool CObject::GetTooltipName(char* name) +bool CObject::GetTooltipName(std::string& name) { GetResource(RES_OBJECT, m_type, name); - return ( name[0] != 0 ); + return !name.empty(); } diff --git a/src/object/object.h b/src/object/object.h index e8b83d9..b5c0385 100644 --- a/src/object/object.h +++ b/src/object/object.h @@ -639,7 +639,7 @@ public: void SetDefRank(int rank); int GetDefRank(); - bool GetTooltipName(char* name); + bool GetTooltipName(std::string& name); void AddDeselList(CObject* pObj); CObject* SubDeselList(); diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 26fa827..35ffe97 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -690,7 +690,7 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) m_movieInfoIndex = -1; m_tooltipPos = Math::Point(0.0f, 0.0f); - m_tooltipName[0] = 0; + m_tooltipName.clear(); m_tooltipTime = 0.0f; m_endingWinRank = 0; @@ -3025,7 +3025,7 @@ bool CRobotMain::DeleteObject() void CRobotMain::HiliteClear() { ClearTooltip(); - m_tooltipName[0] = 0; // really removes the tooltip + m_tooltipName.clear(); // really removes the tooltip if (!m_hilite) return; @@ -3059,11 +3059,11 @@ void CRobotMain::HiliteObject(Math::Point pos) CObject* obj = m_short->DetectShort(pos); - std::string nameStr; - if (m_dialog->GetTooltip() && m_interface->GetTooltip(pos, nameStr)) + std::string interfaceTooltipName; + if (m_dialog->GetTooltip() && m_interface->GetTooltip(pos, interfaceTooltipName)) { m_tooltipPos = pos; - strcpy(m_tooltipName, nameStr.c_str()); + m_tooltipName = interfaceTooltipName; m_tooltipTime = 0.0f; if (obj == nullptr) return; } @@ -3086,13 +3086,13 @@ void CRobotMain::HiliteObject(Math::Point pos) } } - char name[100]; if (obj != nullptr) { - if (m_dialog->GetTooltip() && obj->GetTooltipName(name)) + std::string objectTooltipName; + if (m_dialog->GetTooltip() && obj->GetTooltipName(objectTooltipName)) { m_tooltipPos = pos; - strcpy(m_tooltipName, name); + m_tooltipName = objectTooltipName; m_tooltipTime = 0.0f; } @@ -3117,15 +3117,14 @@ void CRobotMain::HiliteFrame(float rTime) ClearTooltip(); - if (m_tooltipTime >= 0.2f && - m_tooltipName[0] != 0) + if (m_tooltipTime >= 0.2f && !m_tooltipName.empty()) { CreateTooltip(m_tooltipPos, m_tooltipName); } } //! Creates a tooltip -void CRobotMain::CreateTooltip(Math::Point pos, const char* text) +void CRobotMain::CreateTooltip(Math::Point pos, const std::string& text) { Math::Point corner; corner.x = pos.x+0.022f; @@ -3949,7 +3948,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_dialog->BuildResumeName(m_title, base, rank); m_dialog->BuildResumeName(m_resume, base, rank); - GetResource(RES_TEXT, RT_SCRIPT_NEW, m_scriptName); + std::string scriptNameStr; + GetResource(RES_TEXT, RT_SCRIPT_NEW, scriptNameStr); + strcpy(m_scriptName, scriptNameStr.c_str()); m_scriptFile[0] = 0; m_beginObject = false; @@ -7504,7 +7505,7 @@ void CRobotMain::StartMusic() void CRobotMain::ClearInterface() { HiliteClear(); // removes setting evidence - m_tooltipName[0] = 0; // really removes the tooltip + m_tooltipName.clear(); // really removes the tooltip } void CRobotMain::SetNumericLocale() diff --git a/src/object/robotmain.h b/src/object/robotmain.h index 035698c..76535de 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -398,7 +398,7 @@ protected: void HiliteClear(); void HiliteObject(Math::Point pos); void HiliteFrame(float rTime); - void CreateTooltip(Math::Point pos, const char* text); + void CreateTooltip(Math::Point pos, const std::string& text); void ClearTooltip(); CObject* DetectObject(Math::Point pos); void ChangeCamera(); @@ -506,7 +506,7 @@ protected: char m_mapFilename[100]; Math::Point m_tooltipPos; - char m_tooltipName[100]; + std::string m_tooltipName; float m_tooltipTime; char m_infoFilename[SATCOM_MAX][100]; // names of text files |