From adfe6b0c36f48ad5a96e6ca791916649fb81c517 Mon Sep 17 00:00:00 2001 From: Ralph Sennhauser Date: Sun, 19 Jul 2026 19:06:49 +0200 Subject: [PATCH] Convert wxString using ToStdWstring Avoid using c-style cast to convert wxString to std::wstring. Signed-off-by: Ralph Sennhauser --- .../atlas/AtlasUI/ScenarioEditor/Sections/Cinema/Cinema.cpp | 4 ++-- .../tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp | 2 +- .../AtlasUI/ScenarioEditor/Sections/Terrain/Terrain.cpp | 6 +++--- .../AtlasUI/ScenarioEditor/Tools/Common/ObjectSettings.cpp | 2 +- .../atlas/AtlasUI/ScenarioEditor/Tools/FillTerrain.cpp | 2 +- .../atlas/AtlasUI/ScenarioEditor/Tools/PaintTerrain.cpp | 2 +- .../atlas/AtlasUI/ScenarioEditor/Tools/PlaceObject.cpp | 4 ++-- .../atlas/AtlasUI/ScenarioEditor/Tools/ReplaceTerrain.cpp | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinema/Cinema.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinema/Cinema.cpp index 90bc905a90..098dd8e13c 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinema/Cinema.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinema/Cinema.cpp @@ -114,7 +114,7 @@ void CinemaSidebar::OnAddPath(wxCommandEvent&) if (m_NewPathName->GetValue().empty()) return; - POST_COMMAND(AddCinemaPath, ((std::wstring)m_NewPathName->GetValue().wc_str())); + POST_COMMAND(AddCinemaPath, (m_NewPathName->GetValue().ToStdWstring())); m_NewPathName->Clear(); ReloadPathList(); } @@ -129,7 +129,7 @@ void CinemaSidebar::OnDeletePath(wxCommandEvent&) if (pathName.empty()) return; - POST_COMMAND(DeleteCinemaPath, ((std::wstring)pathName.wc_str())); + POST_COMMAND(DeleteCinemaPath, (pathName.ToStdWstring())); ReloadPathList(); } diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp index 63e5a1a691..a75a0f88b5 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp @@ -807,7 +807,7 @@ void MapSidebar::OnRandomGenerate(wxCommandEvent& WXUNUSED(evt)) m_ScenarioEditor.GetToolManager().SetCurrentTool(_T("")); // TODO: clear the undo buffer, etc - AtlasMessage::qGenerateMap qry((std::wstring)scriptName.wc_str(), json); + AtlasMessage::qGenerateMap qry(scriptName.ToStdWstring(), json); qry.Post(); if (qry.status < 0) diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Terrain/Terrain.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Terrain/Terrain.cpp index 31070b0f44..18cbb93280 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Terrain/Terrain.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Terrain/Terrain.cpp @@ -145,7 +145,7 @@ public: m_Sizer->Clear(true); - AtlasMessage::qGetTerrainTexturePreview qry((std::wstring)m_TextureName.wc_str(), imageWidth, imageHeight); + AtlasMessage::qGetTerrainTexturePreview qry(m_TextureName.ToStdWstring(), imageWidth, imageHeight); qry.Post(); AtlasMessage::sTerrainTexturePreview preview = qry.preview; @@ -316,7 +316,7 @@ void TerrainSidebar::OnPassabilityChoice(wxCommandEvent& evt) if (evt.GetSelection() == 0) POST_MESSAGE(SetViewParamS, (AtlasMessage::eRenderView::GAME, L"passability", L"")); else - POST_MESSAGE(SetViewParamS, (AtlasMessage::eRenderView::GAME, L"passability", (std::wstring)evt.GetString().wc_str())); + POST_MESSAGE(SetViewParamS, (AtlasMessage::eRenderView::GAME, L"passability", evt.GetString().ToStdWstring())); } void TerrainSidebar::OnShowPriorities(wxCommandEvent& evt) @@ -365,7 +365,7 @@ public: wxBusyInfo busy (_("Loading terrain previews")); - AtlasMessage::qGetTerrainGroupTextures query((std::wstring)m_Name.wc_str()); + AtlasMessage::qGetTerrainGroupTextures query(m_Name.ToStdWstring()); query.Post(); m_Textures = *query.names; diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/ObjectSettings.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/ObjectSettings.cpp index 6f9c6612d8..b749aeb0fb 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/ObjectSettings.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/ObjectSettings.cpp @@ -105,7 +105,7 @@ AtlasMessage::sObjectSettings ObjectSettings::GetSettings() const it != m_ActorSelections.end(); ++it) { - selections.push_back((std::wstring)it->wc_str()); + selections.push_back(it->ToStdWstring()); } settings.selections = selections; diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/FillTerrain.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/FillTerrain.cpp index 85c3987617..dc8b555dd2 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/FillTerrain.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/FillTerrain.cpp @@ -66,7 +66,7 @@ public: { Position pos(evt.GetPosition()); POST_MESSAGE(BrushPreview, (true, pos)); - POST_COMMAND(FillTerrain, (pos, (std::wstring)g_SelectedTexture.wc_str())); + POST_COMMAND(FillTerrain, (pos, g_SelectedTexture.ToStdWstring())); return true; } else if (evt.Moving()) diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PaintTerrain.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PaintTerrain.cpp index c3c8d607fc..356d8c29e4 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PaintTerrain.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PaintTerrain.cpp @@ -147,7 +147,7 @@ public: void Paint(PaintTerrain* obj) { POST_MESSAGE(BrushPreview, (true, obj->m_Pos)); - POST_COMMAND(PaintTerrain, (obj->m_Pos, (std::wstring)g_SelectedTexture.wc_str(), GetPriority())); + POST_COMMAND(PaintTerrain, (obj->m_Pos, g_SelectedTexture.ToStdWstring(), GetPriority())); } virtual bool IsMouseUp(wxMouseEvent& evt) = 0; diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PlaceObject.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PlaceObject.cpp index cd7fe05d59..fceb970a95 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PlaceObject.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PlaceObject.cpp @@ -61,10 +61,10 @@ public: + (m_ScreenPos.type1.y-m_Target.type1.y)*(m_ScreenPos.type1.y-m_Target.type1.y); bool useTarget = (dragDistSq >= 16*16); if (preview) - POST_MESSAGE(ObjectPreview, ((std::wstring)m_ObjectID.wc_str(), GetScenarioEditor().GetObjectSettings().GetSettings(), m_ObjPos, useTarget, m_Target, g_DefaultAngle, m_ActorSeed, true)); + POST_MESSAGE(ObjectPreview, (m_ObjectID.ToStdWstring(), GetScenarioEditor().GetObjectSettings().GetSettings(), m_ObjPos, useTarget, m_Target, g_DefaultAngle, m_ActorSeed, true)); else { - POST_COMMAND(CreateObject, ((std::wstring)m_ObjectID.wc_str(), GetScenarioEditor().GetObjectSettings().GetSettings(), m_ObjPos, useTarget, m_Target, g_DefaultAngle, m_ActorSeed)); + POST_COMMAND(CreateObject, (m_ObjectID.ToStdWstring(), GetScenarioEditor().GetObjectSettings().GetSettings(), m_ObjPos, useTarget, m_Target, g_DefaultAngle, m_ActorSeed)); RandomizeActorSeed(); } } diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/ReplaceTerrain.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/ReplaceTerrain.cpp index 5ee60c47e3..7a1777cd23 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/ReplaceTerrain.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/ReplaceTerrain.cpp @@ -66,7 +66,7 @@ public: { Position pos(evt.GetPosition()); POST_MESSAGE(BrushPreview, (true, pos)); - POST_COMMAND(ReplaceTerrain, (pos, (std::wstring)g_SelectedTexture.wc_str())); + POST_COMMAND(ReplaceTerrain, (pos, g_SelectedTexture.ToStdWstring())); return true; } else if (evt.Moving())