From 0d42df1537113e2358a5736a816f178cadd472d4 Mon Sep 17 00:00:00 2001 From: Twan van Laarhoven Date: Sat, 25 Apr 2020 22:02:37 +0200 Subject: [PATCH] Fix type conversion errors in GCC/wxGTK --- src/gui/set/console_panel.cpp | 18 +++++++++--------- src/script/functions/basic.cpp | 6 +++--- src/script/functions/construction.cpp | 2 +- src/util/string.cpp | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/gui/set/console_panel.cpp b/src/gui/set/console_panel.cpp index 0ffe75fe..d56bc12c 100644 --- a/src/gui/set/console_panel.cpp +++ b/src/gui/set/console_panel.cpp @@ -277,14 +277,14 @@ class MessageCtrl : public wxScrolledWindow { // --------------------------------------------------- : Layout - static const int LIST_SPACING = 1; - static const int ICON_PADDING = 3; - static const int TEXT_PADDING_LEFT = ICON_PADDING + 16 + 4; - static const int TEXT_PADDING_RIGHT = 4; - static const int TEXT_PADDING_TOP = 4; - static const int TEXT_PADDING_BOTTOM = 2; - static const int TEXT_LINE_SPACING = 1; - static const int MIN_ITEM_HEIGHT = 16 + 2*ICON_PADDING; + static constexpr int LIST_SPACING = 1; + static constexpr int ICON_PADDING = 3; + static constexpr int TEXT_PADDING_LEFT = ICON_PADDING + 16 + 4; + static constexpr int TEXT_PADDING_RIGHT = 4; + static constexpr int TEXT_PADDING_TOP = 4; + static constexpr int TEXT_PADDING_BOTTOM = 2; + static constexpr int TEXT_LINE_SPACING = 1; + static constexpr int MIN_ITEM_HEIGHT = 16 + 2*ICON_PADDING; /// Layout all messages, starting from number start /// layout = determine their height @@ -510,7 +510,7 @@ void ConsolePanel::exec(String const& command) { message->bitmap = wxBitmap(image); } else if (type == SCRIPT_COLOR) { message->text = result->toCode(); - Color color = (Color)*result; + Color color = result->operator Color(); wxImage image(30,20); fill_image(image,color); set_alpha(image, color.Alpha() / 255.0); diff --git a/src/script/functions/basic.cpp b/src/script/functions/basic.cpp index 7c4617c3..d3d457d3 100644 --- a/src/script/functions/basic.cpp +++ b/src/script/functions/basic.cpp @@ -112,7 +112,7 @@ SCRIPT_FUNCTION(to_int) { if (t == SCRIPT_BOOL) { result = (bool)*input ? 1 : 0; } else if (t == SCRIPT_COLOR) { - Color c = (Color)*input; + Color c = input->operator Color(); result = (c.Red() + c.Blue() + c.Green()) / 3; } else if (t == SCRIPT_STRING) { long l; @@ -141,7 +141,7 @@ SCRIPT_FUNCTION(to_real) { if (t == SCRIPT_BOOL) { result = (bool)*input ? 1.0 : 0.0; } else if (t == SCRIPT_COLOR) { - Color c = (Color)*input; + Color c = input->operator Color(); result = (c.Red() + c.Blue() + c.Green()) / 3.0; } else if (t == SCRIPT_STRING) { String str = input->toString(); @@ -166,7 +166,7 @@ SCRIPT_FUNCTION(to_number) { if (t == SCRIPT_BOOL) { SCRIPT_RETURN((bool)*input ? 1 : 0); } else if (t == SCRIPT_COLOR) { - Color c = (Color)*input; + Color c = input->operator Color(); SCRIPT_RETURN( (c.Red() + c.Blue() + c.Green()) / 3 ); } else if (t == SCRIPT_DOUBLE) { SCRIPT_RETURN((double)*input); diff --git a/src/script/functions/construction.cpp b/src/script/functions/construction.cpp index 41aaf759..d572215b 100644 --- a/src/script/functions/construction.cpp +++ b/src/script/functions/construction.cpp @@ -44,7 +44,7 @@ SCRIPT_FUNCTION(new_card) { } else if (PackageChoiceValue* pvalue = dynamic_cast(value)) { pvalue->package_name = v->toString(); } else if (ColorValue* cvalue = dynamic_cast(value)) { - cvalue->value = (Color)*v; + cvalue->value = v->operator Color(); } else { throw ScriptError(format_string(_("Can not set value '%s', it is not of the right type"),name)); } diff --git a/src/util/string.cpp b/src/util/string.cpp index 3c675325..9ac8be01 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -198,9 +198,9 @@ String name_to_caption(const String& str) { String ret; ret.reserve(str.size()); bool leading = true, first = true; - FOR_EACH_CONST(c, str) { + for (wxUniChar c : str) { if ((c == _('_') || c == _(' '))) { - ret += leading ? c : _(' '); + ret += leading ? c : wxUniChar(_(' ')); } else if (first) { // capitalize_sentence ret += toUpper(c);