From 3c318814a45215323a96a4a82c5d5d7113f2dae3 Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 20 Feb 2021 16:04:50 -0800 Subject: [PATCH] Remove EditorData and put its attributes on customlevelclass This object basically had no reason to exist... it was just more verbose to use, which really reminded me of Java. Anyway, this is the last thing named after the editor for no reason when it should be a part of the customlevelclass, so I moved its attributes to customlevelclass. --- desktop_version/src/CustomLevels.cpp | 14 +++++++------- desktop_version/src/CustomLevels.h | 22 ++++------------------ desktop_version/src/Editor.cpp | 16 ++++++++-------- 3 files changed, 19 insertions(+), 33 deletions(-) diff --git a/desktop_version/src/CustomLevels.cpp b/desktop_version/src/CustomLevels.cpp index f9c02bc2..1da79475 100644 --- a/desktop_version/src/CustomLevels.cpp +++ b/desktop_version/src/CustomLevels.cpp @@ -285,8 +285,8 @@ void customlevelclass::reset(void) mapwidth=5; mapheight=5; - EditorData::GetInstance().title="Untitled Level"; - EditorData::GetInstance().creator="Unknown"; + title="Untitled Level"; + creator="Unknown"; levmusic=0; @@ -992,12 +992,12 @@ bool customlevelclass::load(std::string& _path) if(SDL_strcmp(pKey_, "Creator") == 0) { - EditorData::GetInstance().creator = pText_; + creator = pText_; } if(SDL_strcmp(pKey_, "Title") == 0) { - EditorData::GetInstance().title = pText_; + title = pText_; } if(SDL_strcmp(pKey_, "Desc1") == 0) @@ -1294,13 +1294,13 @@ bool customlevelclass::save(std::string& _path) msg = xml::update_element(data, "MetaData"); //getUser - xml::update_tag(msg, "Creator", EditorData::GetInstance().creator.c_str()); + xml::update_tag(msg, "Creator", creator.c_str()); - xml::update_tag(msg, "Title", EditorData::GetInstance().title.c_str()); + xml::update_tag(msg, "Title", title.c_str()); xml::update_tag(msg, "Created", version); - xml::update_tag(msg, "Modified", EditorData::GetInstance().modifier.c_str()); + xml::update_tag(msg, "Modified", modifier.c_str()); xml::update_tag(msg, "Modifiers", version); diff --git a/desktop_version/src/CustomLevels.h b/desktop_version/src/CustomLevels.h index c3b9ea8d..9e0871ce 100644 --- a/desktop_version/src/CustomLevels.h +++ b/desktop_version/src/CustomLevels.h @@ -63,28 +63,14 @@ struct LevelMetaData extern std::vector customentities; -class EditorData -{ - public: - - static EditorData& GetInstance(void) - { - static EditorData instance; // Guaranteed to be destroyed. - // Instantiated on first use. - return instance; - } - - - std::string title; - std::string creator; - - std::string modifier; -}; - class customlevelclass { public: customlevelclass(void); + + std::string title; + std::string creator; + std::string modifier; std::string Desc1; std::string Desc2; std::string Desc3; diff --git a/desktop_version/src/Editor.cpp b/desktop_version/src/Editor.cpp index 32f6cfaf..8aa8e99b 100644 --- a/desktop_version/src/Editor.cpp +++ b/desktop_version/src/Editor.cpp @@ -321,7 +321,7 @@ static void editormenurender(int tr, int tg, int tb) } else { - graphics.bigprint( -1, 35, EditorData::GetInstance().title, tr, tg, tb, true); + graphics.bigprint( -1, 35, cl.title, tr, tg, tb, true); } if(ed.creatormod) { @@ -336,7 +336,7 @@ static void editormenurender(int tr, int tg, int tb) } else { - graphics.Print( -1, 60, "by " + EditorData::GetInstance().creator, tr, tg, tb, true); + graphics.Print( -1, 60, "by " + cl.creator, tr, tg, tb, true); } if(ed.websitemod) { @@ -1749,12 +1749,12 @@ static void editormenuactionpress(void) case 0: ed.titlemod=true; key.enabletextentry(); - key.keybuffer=EditorData::GetInstance().title; + key.keybuffer=cl.title; break; case 1: ed.creatormod=true; key.enabletextentry(); - key.keybuffer=EditorData::GetInstance().creator; + key.keybuffer=cl.creator; break; case 2: ed.desc1mod=true; @@ -2369,11 +2369,11 @@ void editorinput(void) { if(ed.titlemod) { - EditorData::GetInstance().title=key.keybuffer; + cl.title=key.keybuffer; } else if(ed.creatormod) { - EditorData::GetInstance().creator=key.keybuffer; + cl.creator=key.keybuffer; } else if(ed.websitemod) { @@ -2400,12 +2400,12 @@ void editorinput(void) game.mapheld=true; if(ed.titlemod) { - EditorData::GetInstance().title=key.keybuffer; + cl.title=key.keybuffer; ed.titlemod=false; } else if(ed.creatormod) { - EditorData::GetInstance().creator=key.keybuffer; + cl.creator=key.keybuffer; ed.creatormod=false; } else if(ed.websitemod)