From dddaa67abd146fb669485e60a43670680aa09d75 Mon Sep 17 00:00:00 2001 From: Stan Date: Tue, 29 Jun 2021 12:41:31 +0000 Subject: [PATCH] Fix unicode build for Atlas on OpenSuse. Based on a patch by: @MatSharrow Reviewed by: @wraitii Differential Revision: https://code.wildfiregames.com/D4178 This was SVN commit r25815. --- .../public/gui/credits/texts/programming.json | 1 + .../atlas/AtlasUI/ActorEditor/ActorEditor.cpp | 8 ++++---- .../EditableListCtrl/EditableListCtrl.cpp | 4 ++-- .../AtlasUI/ScenarioEditor/Sections/Map/Map.cpp | 4 ++-- .../ScenarioEditor/Sections/Player/Player.cpp | 17 +++++++---------- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/binaries/data/mods/public/gui/credits/texts/programming.json b/binaries/data/mods/public/gui/credits/texts/programming.json index bc3c236530..75937213b5 100644 --- a/binaries/data/mods/public/gui/credits/texts/programming.json +++ b/binaries/data/mods/public/gui/credits/texts/programming.json @@ -167,6 +167,7 @@ { "nick": "Markus" }, { "nick": "Mate-86", "name": "Mate Kovacs" }, { "nick": "Matei", "name": "Matei Zaharia" }, + { "nick": "MatSharrow" }, { "nick": "MattDoerksen", "name": "Matt Doerksen" }, { "nick": "mattlott", "name": "Matt Lott" }, { "nick": "maveric", "name": "Anton Protko" }, diff --git a/source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.cpp b/source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.cpp index 7d2a2821cd..96c57c7330 100644 --- a/source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.cpp +++ b/source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.cpp @@ -131,7 +131,7 @@ AtObj ActorEditor::FreezeData() actor.set("float", ""); if (m_Material->GetValue().length()) - actor.set("material", m_Material->GetValue()); + actor.set("material", m_Material->GetValue().utf8_str()); AtObj out; out.set("actor", actor); @@ -185,10 +185,10 @@ static AtObj ConvertToLatestFormat(AtObj in) // new format doesn't store the entire path) #define THING1(out,outname, in,inname, prefix) \ wxASSERT( wxString::FromUTF8(in["Object"][inname]).StartsWith(_T(prefix)) ); \ - out.add(outname, wxString::FromUTF8(in["Object"][inname]).Mid(wxString(_T(prefix)).Length())) + out.add(outname, wxString::FromUTF8(in["Object"][inname]).Mid(wxString(_T(prefix)).Length()).utf8_str()) #define THING2(out,outname, in,inname, prefix) \ wxASSERT( wxString::FromUTF8(in[inname]).StartsWith(_T(prefix)) ); \ - out.add(outname, wxString::FromUTF8(in[inname]).Mid(wxString(_T(prefix)).Length())) + out.add(outname, wxString::FromUTF8(in[inname]).Mid(wxString(_T(prefix)).Length()).utf8_str()) if (wxString::FromUTF8(in["Object"]["Material"]).Len()) { @@ -350,7 +350,7 @@ AtObj ActorEditor::ExportData() AtObj material = *m_Actor["material"]; actor.set("material", material); if (m_Material->GetValue().length()) - actor.set("material", m_Material->GetValue()); + actor.set("material", m_Material->GetValue().utf8_str()); AtObj out; out.set("actor", actor); diff --git a/source/tools/atlas/AtlasUI/CustomControls/EditableListCtrl/EditableListCtrl.cpp b/source/tools/atlas/AtlasUI/CustomControls/EditableListCtrl/EditableListCtrl.cpp index 1f5953d83b..199350b9b3 100644 --- a/source/tools/atlas/AtlasUI/CustomControls/EditableListCtrl/EditableListCtrl.cpp +++ b/source/tools/atlas/AtlasUI/CustomControls/EditableListCtrl/EditableListCtrl.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -257,7 +257,7 @@ void EditableListCtrl::SetCellString(long item, long column, wxString& str) { wxCHECK(item >= 0 && column >= 0 && column < (int)m_ColumnTypes.size(), ); MakeSizeAtLeast(item+1); - m_ListData[item].set(m_ColumnTypes[column].key, str); + m_ListData[item].set(m_ColumnTypes[column].key, str.utf8_str()); } void EditableListCtrl::SetCellObject(long item, long column, AtObj& obj) diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp index 6fce77f2bf..8e88b8356c 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -187,7 +187,7 @@ void MapSettingsControl::CreateWidgets() AtObj victoryCondition = AtlasObject::LoadFromJSON(victoryConditionJson); long index = wxWindow::NewControlId(); wxString title = wxString::FromUTF8(victoryCondition["Data"]["Title"]); - std::string escapedTitle = wxString::FromUTF8(title).Lower().ToStdString(); + std::string escapedTitle = title.Lower().ToStdString(); std::replace(escapedTitle.begin(), escapedTitle.end(), ' ', '_'); AtObj updateCondition = *(victoryCondition["Data"]["Title"]); updateCondition.setString(escapedTitle.c_str()); diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp index 3ca69bf052..1891d589d3 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp @@ -858,7 +858,7 @@ AtObj PlayerSettingsControl::UpdateSettingsObject() if (choice->IsEnabled() && choice->GetSelection() >= 0) { wxStringClientData* str = dynamic_cast(choice->GetClientObject(choice->GetSelection())); - player.set("Civ", str->GetData()); + player.set("Civ", str->GetData().utf8_str()); } else player.unset("Civ"); @@ -876,17 +876,14 @@ AtObj PlayerSettingsControl::UpdateSettingsObject() // player type choice = controls.ai; - if (choice->IsEnabled()) + if (choice->IsEnabled() && choice->GetSelection() > 0) { - if (choice->GetSelection() > 0) - { - // ai - get id - wxStringClientData* str = dynamic_cast(choice->GetClientObject(choice->GetSelection())); - player.set("AI", str->GetData()); - } - else // human - player.set("AI", _("")); + // ai - get id + wxStringClientData* str = dynamic_cast(choice->GetClientObject(choice->GetSelection())); + player.set("AI", str->GetData().utf8_str()); } + else // human + player.unset("AI"); // resources AtObj resObj;