Skip to content

Commit

Permalink
Merge pull request #89 from OutpostUniverse/RefactorStringTable
Browse files Browse the repository at this point in the history
Prefer initialization in c'tor vs calling a load() function after obj…
  • Loading branch information
ldicker83 authored Jun 28, 2023
2 parents 8043243 + b4ae5a3 commit f94af52
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion OP2-Landlord/StringTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace
}


void StringTable::load(const std::string& filepath)
StringTable::StringTable(const std::string& filepath)
{
loadStringTable(filepath);
}
Expand Down
5 changes: 2 additions & 3 deletions OP2-Landlord/StringTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ class StringTable
};

public:
StringTable() = default;

void load(const std::string& filepath);
StringTable() = delete;
StringTable(const std::string& filepath);

const std::string& operator[](const StringName name) const;
};
5 changes: 2 additions & 3 deletions OP2-Landlord/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,14 @@ int main(int argc, char* argv[])
{
try
{
StringTable MessageStrings;
MessageStrings.load("data/en.json");
StringTable strings{ "data/en.json" };

Graphics graphics({ 800, 600 });
graphics.drawColor(ClearColor);

EditorConfig config(getUserPrefPath("OP2-Landlord", "OutpostUniverse"));

Gui gui(MessageStrings, config, graphics, config["UserSavePath"] + "gui.ini");
Gui gui(strings, config, graphics, config["UserSavePath"] + "gui.ini");

checkConfig(config);

Expand Down

0 comments on commit f94af52

Please sign in to comment.