From d404f4a53813c7db7569777502365f292d2dba9f Mon Sep 17 00:00:00 2001 From: mniip Date: Tue, 8 May 2018 05:48:32 +0300 Subject: [PATCH] Fix some C++14-isms. Apparently C++11 is more strict regarding default argument and return value conversions. Also return brace-initializer construction has had little support. --- src/Format.h | 2 +- src/PowderToySDL.cpp | 2 - src/gui/dialogues/ConfirmPrompt.h | 2 +- src/gui/game/GameController.cpp | 2 +- src/gui/game/ToolButton.h | 2 +- src/gui/interface/Button.h | 2 +- src/gui/interface/ProgressBar.h | 2 +- src/gui/interface/RichLabel.cpp | 2 +- src/gui/interface/Textbox.h | 2 +- src/simulation/SimulationData.cpp | 134 +++++++++++++++--------------- 10 files changed, 75 insertions(+), 77 deletions(-) diff --git a/src/Format.h b/src/Format.h index 85b63c7f1..33d7ffa75 100644 --- a/src/Format.h +++ b/src/Format.h @@ -10,7 +10,7 @@ namespace format const static char hex[] = "0123456789ABCDEF"; ByteString URLEncode(ByteString value); - ByteString UnixtimeToDate(time_t unixtime, ByteString dateFomat = "%d %b %Y"); + ByteString UnixtimeToDate(time_t unixtime, ByteString dateFomat = ByteString("%d %b %Y")); ByteString UnixtimeToDateMini(time_t unixtime); String CleanString(String dirtyString, bool ascii, bool color, bool newlines, bool numeric = false); std::vector VideoBufferToPNG(const VideoBuffer & vidBuf); diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index a9d86f678..304ef287a 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -18,9 +18,7 @@ #endif #include -#include "common/String.h" #include "Config.h" -#include "common/String.h" #include "graphics/Graphics.h" #if defined(LIN) #include "icon.h" diff --git a/src/gui/dialogues/ConfirmPrompt.h b/src/gui/dialogues/ConfirmPrompt.h index 0e39f3450..a1fcd33b4 100644 --- a/src/gui/dialogues/ConfirmPrompt.h +++ b/src/gui/dialogues/ConfirmPrompt.h @@ -10,7 +10,7 @@ public: enum DialogueResult { ResultCancel, ResultOkay }; ConfirmPrompt(String title, String message, ConfirmDialogueCallback * callback_ = NULL); ConfirmPrompt(String title, String message, String buttonText, ConfirmDialogueCallback * callback_ = NULL); - static bool Blocking(String title, String message, String buttonText = "Confirm"); + static bool Blocking(String title, String message, String buttonText = String("Confirm")); virtual void OnDraw(); virtual ~ConfirmPrompt(); ConfirmDialogueCallback * callback; diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index cdc60911d..39376c5b6 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -1580,7 +1580,7 @@ String GameController::WallName(int type) if(gameModel && gameModel->GetSimulation() && type >= 0 && type < UI_WALLCOUNT) return gameModel->GetSimulation()->wtypes[type].name; else - return ""; + return String(); } int GameController::Record(bool record) diff --git a/src/gui/game/ToolButton.h b/src/gui/game/ToolButton.h index 8953e1dd4..8a5cd7820 100644 --- a/src/gui/game/ToolButton.h +++ b/src/gui/game/ToolButton.h @@ -8,7 +8,7 @@ class ToolButton: public ui::Button int currentSelection; ByteString toolIdentifier; public: - ToolButton(ui::Point position, ui::Point size, ByteString text_, ByteString toolIdentifier, String toolTip = ""); + ToolButton(ui::Point position, ui::Point size, ByteString text_, ByteString toolIdentifier, String toolTip = String()); virtual void OnMouseUnclick(int x, int y, unsigned int button); virtual void OnMouseUp(int x, int y, unsigned int button); virtual void OnMouseClick(int x, int y, unsigned int button); diff --git a/src/gui/interface/Button.h b/src/gui/interface/Button.h index 681d43517..ec0ce4c66 100644 --- a/src/gui/interface/Button.h +++ b/src/gui/interface/Button.h @@ -21,7 +21,7 @@ public: class Button : public Component { public: - Button(Point position = Point(0, 0), Point size = Point(0, 0), String buttonText = "", String toolTip = ""); + Button(Point position = Point(0, 0), Point size = Point(0, 0), String buttonText = String(), String toolTip = String()); virtual ~Button(); virtual void OnMouseClick(int x, int y, unsigned int button); diff --git a/src/gui/interface/ProgressBar.h b/src/gui/interface/ProgressBar.h index 855504d77..17de85a4c 100644 --- a/src/gui/interface/ProgressBar.h +++ b/src/gui/interface/ProgressBar.h @@ -10,7 +10,7 @@ namespace ui float intermediatePos; String progressStatus; public: - ProgressBar(Point position, Point size, int startProgress = 0, String startStatus = ""); + ProgressBar(Point position, Point size, int startProgress = 0, String startStatus = String()); virtual void SetProgress(int progress); virtual int GetProgress(); virtual void SetStatus(String status); diff --git a/src/gui/interface/RichLabel.cpp b/src/gui/interface/RichLabel.cpp index 5f9261700..3177af241 100644 --- a/src/gui/interface/RichLabel.cpp +++ b/src/gui/interface/RichLabel.cpp @@ -12,7 +12,7 @@ using namespace ui; struct RichTextParseException: public std::exception { String message; public: - RichTextParseException(String message_ = "Parse error"): message(message_) {} + RichTextParseException(String message_ = String("Parse error")): message(message_) {} const char * what() const throw() { return message.ToUtf8().c_str(); diff --git a/src/gui/interface/Textbox.h b/src/gui/interface/Textbox.h index f20b8c831..79c3b9461 100644 --- a/src/gui/interface/Textbox.h +++ b/src/gui/interface/Textbox.h @@ -22,7 +22,7 @@ class Textbox : public Label public: bool ReadOnly; enum ValidInput { All, Multiline, Numeric, Number }; // Numeric doesn't delete trailing 0's - Textbox(Point position, Point size, String textboxText = "", String textboxPlaceholder = ""); + Textbox(Point position, Point size, String textboxText = String(), String textboxPlaceholder = String()); virtual ~Textbox(); virtual void SetText(String text); diff --git a/src/simulation/SimulationData.cpp b/src/simulation/SimulationData.cpp index b92069c31..ec338f54e 100644 --- a/src/simulation/SimulationData.cpp +++ b/src/simulation/SimulationData.cpp @@ -6,38 +6,38 @@ std::vector LoadGOLMenu() { return - { - {"GOL", PIXPACK(0x0CAC00), 0, "Game Of Life: Begin 3/Stay 23"}, - {"HLIF", PIXPACK(0xFF0000), 1, "High Life: B36/S23"}, - {"ASIM", PIXPACK(0x0000FF), 2, "Assimilation: B345/S4567"}, - {"2x2", PIXPACK(0xFFFF00), 3, "2x2: B36/S125"}, - {"DANI", PIXPACK(0x00FFFF), 4, "Day and Night: B3678/S34678"}, - {"AMOE", PIXPACK(0xFF00FF), 5, "Amoeba: B357/S1358"}, - {"MOVE", PIXPACK(0xFFFFFF), 6, "'Move' particles. Does not move things.. it is a life type: B368/S245"}, - {"PGOL", PIXPACK(0xE05010), 7, "Pseudo Life: B357/S238"}, - {"DMOE", PIXPACK(0x500000), 8, "Diamoeba: B35678/S5678"}, - {"34", PIXPACK(0x500050), 9, "34: B34/S34"}, - {"LLIF", PIXPACK(0x505050), 10, "Long Life: B345/S5"}, - {"STAN", PIXPACK(0x5000FF), 11, "Stains: B3678/S235678"}, - {"SEED", PIXPACK(0xFBEC7D), 12, "Seeds: B2/S"}, - {"MAZE", PIXPACK(0xA8E4A0), 13, "Maze: B3/S12345"}, - {"COAG", PIXPACK(0x9ACD32), 14, "Coagulations: B378/S235678"}, - {"WALL", PIXPACK(0x0047AB), 15, "Walled cities: B45678/S2345"}, - {"GNAR", PIXPACK(0xE5B73B), 16, "Gnarl: B1/S1"}, - {"REPL", PIXPACK(0x259588), 17, "Replicator: B1357/S1357"}, - {"MYST", PIXPACK(0x0C3C00), 18, "Mystery: B3458/S05678"}, - {"LOTE", PIXPACK(0xFF0000), 19, "Living on the Edge: B37/S3458/4"}, - {"FRG2", PIXPACK(0x00FF00), 20, "Like Frogs rule: B3/S124/3"}, - {"STAR", PIXPACK(0x0000FF), 21, "Like Star Wars rule: B278/S3456/6"}, - {"FROG", PIXPACK(0x00AA00), 22, "Frogs: B34/S12/3"}, - {"BRAN", PIXPACK(0xCCCC00), 23, "Brian 6: B246/S6/3"} + std::vector{ + {"GOL", PIXPACK(0x0CAC00), 0, String("Game Of Life: Begin 3/Stay 23")}, + {"HLIF", PIXPACK(0xFF0000), 1, String("High Life: B36/S23")}, + {"ASIM", PIXPACK(0x0000FF), 2, String("Assimilation: B345/S4567")}, + {"2x2", PIXPACK(0xFFFF00), 3, String("2x2: B36/S125")}, + {"DANI", PIXPACK(0x00FFFF), 4, String("Day and Night: B3678/S34678")}, + {"AMOE", PIXPACK(0xFF00FF), 5, String("Amoeba: B357/S1358")}, + {"MOVE", PIXPACK(0xFFFFFF), 6, String("'Move' particles. Does not move things.. it is a life type: B368/S245")}, + {"PGOL", PIXPACK(0xE05010), 7, String("Pseudo Life: B357/S238")}, + {"DMOE", PIXPACK(0x500000), 8, String("Diamoeba: B35678/S5678")}, + {"34", PIXPACK(0x500050), 9, String("34: B34/S34")}, + {"LLIF", PIXPACK(0x505050), 10, String("Long Life: B345/S5")}, + {"STAN", PIXPACK(0x5000FF), 11, String("Stains: B3678/S235678")}, + {"SEED", PIXPACK(0xFBEC7D), 12, String("Seeds: B2/S")}, + {"MAZE", PIXPACK(0xA8E4A0), 13, String("Maze: B3/S12345")}, + {"COAG", PIXPACK(0x9ACD32), 14, String("Coagulations: B378/S235678")}, + {"WALL", PIXPACK(0x0047AB), 15, String("Walled cities: B45678/S2345")}, + {"GNAR", PIXPACK(0xE5B73B), 16, String("Gnarl: B1/S1")}, + {"REPL", PIXPACK(0x259588), 17, String("Replicator: B1357/S1357")}, + {"MYST", PIXPACK(0x0C3C00), 18, String("Mystery: B3458/S05678")}, + {"LOTE", PIXPACK(0xFF0000), 19, String("Living on the Edge: B37/S3458/4")}, + {"FRG2", PIXPACK(0x00FF00), 20, String("Like Frogs rule: B3/S124/3")}, + {"STAR", PIXPACK(0x0000FF), 21, String("Like Star Wars rule: B278/S3456/6")}, + {"FROG", PIXPACK(0x00AA00), 22, String("Frogs: B34/S12/3")}, + {"BRAN", PIXPACK(0xCCCC00), 23, String("Brian 6: B246/S6/3")} }; } std::vector > LoadGOLRules() { return - { + std::vector >{ // 0,1,2,3,4,5,6,7,8,STATES live=1 spawn=2 spawn&live=3 States are kind of how long until it dies, normal ones use two states(living,dead) for others the intermediate states live but do nothing {0,0,0,0,0,0,0,0,0,2},//blank {0,0,1,3,0,0,0,0,0,2},//GOL @@ -70,7 +70,7 @@ std::vector > LoadGOLRules() std::vector LoadGOLTypes() { return - { + std::vector{ GT_GOL, GT_HLIF, GT_ASIM, @@ -101,58 +101,58 @@ std::vector LoadGOLTypes() std::vector LoadWalls() { return - { - {PIXPACK(0x808080), PIXPACK(0x000000), 0, Renderer::WallIcon, "ERASE", "DEFAULT_WL_ERASE", "Erases walls."}, - {PIXPACK(0xC0C0C0), PIXPACK(0x101010), 0, Renderer::WallIcon, "CONDUCTIVE WALL", "DEFAULT_WL_CNDTW", "Blocks everything. Conductive."}, - {PIXPACK(0x808080), PIXPACK(0x808080), 0, Renderer::WallIcon, "EWALL", "DEFAULT_WL_EWALL", "E-Wall. Becomes transparent when electricity is connected."}, - {PIXPACK(0xFF8080), PIXPACK(0xFF2008), 1, Renderer::WallIcon, "DETECTOR", "DEFAULT_WL_DTECT", "Detector. Generates electricity when a particle is inside."}, - {PIXPACK(0x808080), PIXPACK(0x000000), 0, Renderer::WallIcon, "STREAMLINE", "DEFAULT_WL_STRM", "Streamline. Set start point of a streamline."}, - {PIXPACK(0x8080FF), PIXPACK(0x000000), 1, Renderer::WallIcon, "FAN", "DEFAULT_WL_FAN", "Fan. Accelerates air. Use the line tool to set direction and strength."}, - {PIXPACK(0xC0C0C0), PIXPACK(0x101010), 2, Renderer::WallIcon, "LIQUID WALL", "DEFAULT_WL_LIQD", "Allows liquids, blocks all other particles. Conductive."}, - {PIXPACK(0x808080), PIXPACK(0x000000), 1, Renderer::WallIcon, "ABSORB WALL", "DEFAULT_WL_ABSRB", "Absorbs particles but lets air currents through."}, - {PIXPACK(0x808080), PIXPACK(0x000000), 3, Renderer::WallIcon, "WALL", "DEFAULT_WL_WALL", "Basic wall, blocks everything."}, - {PIXPACK(0x3C3C3C), PIXPACK(0x000000), 1, Renderer::WallIcon, "AIRONLY WALL", "DEFAULT_WL_AIR", "Allows air, but blocks all particles."}, - {PIXPACK(0x575757), PIXPACK(0x000000), 1, Renderer::WallIcon, "POWDER WALL", "DEFAULT_WL_POWDR", "Allows powders, blocks all other particles."}, - {PIXPACK(0xFFFF22), PIXPACK(0x101010), 2, Renderer::WallIcon, "CONDUCTOR", "DEFAULT_WL_CNDTR", "Conductor. Allows all particles to pass through and conducts electricity."}, - {PIXPACK(0x242424), PIXPACK(0x101010), 0, Renderer::WallIcon, "EHOLE", "DEFAULT_WL_EHOLE", "E-Hole. absorbs particles, releases them when powered."}, - {PIXPACK(0x579777), PIXPACK(0x000000), 1, Renderer::WallIcon, "GAS WALL", "DEFAULT_WL_GAS", "Allows gases, blocks all other particles."}, - {PIXPACK(0xFFEE00), PIXPACK(0xAA9900), 4, Renderer::WallIcon, "GRAVITY WALL", "DEFAULT_WL_GRVTY", "Gravity wall. Newtonian Gravity has no effect inside a box drawn with this."}, - {PIXPACK(0xFFAA00), PIXPACK(0xAA5500), 4, Renderer::WallIcon, "ENERGY WALL", "DEFAULT_WL_ENRGY", "Allows energy particles, blocks all other particles."}, - {PIXPACK(0xDCDCDC), PIXPACK(0x000000), 1, Renderer::WallIcon, "AIRBLOCK WALL", "DEFAULT_WL_NOAIR", "Allows all particles, but blocks air."}, - {PIXPACK(0x808080), PIXPACK(0x000000), 0, Renderer::WallIcon, "ERASEALL", "DEFAULT_WL_ERASEA", "Erases walls, particles, and signs."}, - {PIXPACK(0x800080), PIXPACK(0x000000), 0, Renderer::WallIcon, "STASIS WALL", "DEFAULT_WL_STASIS", "Freezes particles inside the wall in place until powered."}, + std::vector{ + {PIXPACK(0x808080), PIXPACK(0x000000), 0, Renderer::WallIcon, String("ERASE"), "DEFAULT_WL_ERASE", String("Erases walls.")}, + {PIXPACK(0xC0C0C0), PIXPACK(0x101010), 0, Renderer::WallIcon, String("CONDUCTIVE WALL"), "DEFAULT_WL_CNDTW", String("Blocks everything. Conductive.")}, + {PIXPACK(0x808080), PIXPACK(0x808080), 0, Renderer::WallIcon, String("EWALL"), "DEFAULT_WL_EWALL", String("E-Wall. Becomes transparent when electricity is connected.")}, + {PIXPACK(0xFF8080), PIXPACK(0xFF2008), 1, Renderer::WallIcon, String("DETECTOR"), "DEFAULT_WL_DTECT", String("Detector. Generates electricity when a particle is inside.")}, + {PIXPACK(0x808080), PIXPACK(0x000000), 0, Renderer::WallIcon, String("STREAMLINE"), "DEFAULT_WL_STRM", String("Streamline. Set start point of a streamline.")}, + {PIXPACK(0x8080FF), PIXPACK(0x000000), 1, Renderer::WallIcon, String("FAN"), "DEFAULT_WL_FAN", String("Fan. Accelerates air. Use the line tool to set direction and strength.")}, + {PIXPACK(0xC0C0C0), PIXPACK(0x101010), 2, Renderer::WallIcon, String("LIQUID WALL"), "DEFAULT_WL_LIQD", String("Allows liquids, blocks all other particles. Conductive.")}, + {PIXPACK(0x808080), PIXPACK(0x000000), 1, Renderer::WallIcon, String("ABSORB WALL"), "DEFAULT_WL_ABSRB", String("Absorbs particles but lets air currents through.")}, + {PIXPACK(0x808080), PIXPACK(0x000000), 3, Renderer::WallIcon, String("WALL"), "DEFAULT_WL_WALL", String("Basic wall, blocks everything.")}, + {PIXPACK(0x3C3C3C), PIXPACK(0x000000), 1, Renderer::WallIcon, String("AIRONLY WALL"), "DEFAULT_WL_AIR", String("Allows air, but blocks all particles.")}, + {PIXPACK(0x575757), PIXPACK(0x000000), 1, Renderer::WallIcon, String("POWDER WALL"), "DEFAULT_WL_POWDR", String("Allows powders, blocks all other particles.")}, + {PIXPACK(0xFFFF22), PIXPACK(0x101010), 2, Renderer::WallIcon, String("CONDUCTOR"), "DEFAULT_WL_CNDTR", String("Conductor. Allows all particles to pass through and conducts electricity.")}, + {PIXPACK(0x242424), PIXPACK(0x101010), 0, Renderer::WallIcon, String("EHOLE"), "DEFAULT_WL_EHOLE", String("E-Hole. absorbs particles, releases them when powered.")}, + {PIXPACK(0x579777), PIXPACK(0x000000), 1, Renderer::WallIcon, String("GAS WALL"), "DEFAULT_WL_GAS", String("Allows gases, blocks all other particles.")}, + {PIXPACK(0xFFEE00), PIXPACK(0xAA9900), 4, Renderer::WallIcon, String("GRAVITY WALL"), "DEFAULT_WL_GRVTY", String("Gravity wall. Newtonian Gravity has no effect inside a box drawn with this.")}, + {PIXPACK(0xFFAA00), PIXPACK(0xAA5500), 4, Renderer::WallIcon, String("ENERGY WALL"), "DEFAULT_WL_ENRGY", String("Allows energy particles, blocks all other particles.")}, + {PIXPACK(0xDCDCDC), PIXPACK(0x000000), 1, Renderer::WallIcon, String("AIRBLOCK WALL"), "DEFAULT_WL_NOAIR", String("Allows all particles, but blocks air.")}, + {PIXPACK(0x808080), PIXPACK(0x000000), 0, Renderer::WallIcon, String("ERASEALL"), "DEFAULT_WL_ERASEA", String("Erases walls, particles, and signs.")}, + {PIXPACK(0x800080), PIXPACK(0x000000), 0, Renderer::WallIcon, String("STASIS WALL"), "DEFAULT_WL_STASIS", String("Freezes particles inside the wall in place until powered.")}, }; } std::vector LoadMenus() { return - { - {0xE041, "Walls", 0, 1}, - {0xE042, "Electronics", 0, 1}, - {0xE056, "Powered Materials", 0, 1}, - {0xE019, "Sensors", 0, 1}, - {0xE062, "Force", 0, 1}, - {0xE043, "Explosives", 0, 1}, - {0xE045, "Gases", 0, 1}, - {0xE044, "Liquids", 0, 1}, - {0xE050, "Powders", 0, 1}, - {0xE051, "Solids", 0, 1}, - {0xE046, "Radioactive", 0, 1}, - {0xE04C, "Special", 0, 1}, - {0xE052, "Game Of Life", 0, 1}, - {0xE057, "Tools", 0, 1}, - {0xE067, "Favorites", 0, 1}, - {0xE064, "Decoration tools", 0, 1}, - {0xE048, "Cracker", 0, 0}, - {0xE048, "Cracker!", 0, 0}, + std::vector{ + {0xE041, String("Walls"), 0, 1}, + {0xE042, String("Electronics"), 0, 1}, + {0xE056, String("Powered Materials"), 0, 1}, + {0xE019, String("Sensors"), 0, 1}, + {0xE062, String("Force"), 0, 1}, + {0xE043, String("Explosives"), 0, 1}, + {0xE045, String("Gases"), 0, 1}, + {0xE044, String("Liquids"), 0, 1}, + {0xE050, String("Powders"), 0, 1}, + {0xE051, String("Solids"), 0, 1}, + {0xE046, String("Radioactive"), 0, 1}, + {0xE04C, String("Special"), 0, 1}, + {0xE052, String("Game Of Life"), 0, 1}, + {0xE057, String("Tools"), 0, 1}, + {0xE067, String("Favorites"), 0, 1}, + {0xE064, String("Decoration tools"), 0, 1}, + {0xE048, String("Cracker"), 0, 0}, + {0xE048, String("Cracker!"), 0, 0}, }; } std::vector LoadLatent() { return - { + std::vector{ /* NONE */ 0, /* DUST */ 0, /* WATR */ 7500,