commit 51c4029b
Refactor naming to signal where the functions are defined
Changed files
| M | source/code/main.cpp before |
| M | source/code/menudef.cpp before |
| M | source/code/themes.cpp before |
| M | source/code/themes.hpp before |
diff --git a/source/code/main.cpp b/source/code/main.cpp
index afb9947..ee7736d 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -1185,7 +1185,7 @@ int main(int argc, char* argv[]) {
std::cout << "Renderer: " << info.name << "\n";
}
globalData.screen = renderer;
- globalData.theme = getTheme(0);
+ globalData.theme = ThemesGet(0);
ResetFullscreen();
SetSDLIcon(sdlWindow);
@@ -1567,7 +1567,7 @@ int runGame(Gametype gametype, int level) {
if ( event.key.keysym.sym == SDLK_F5 ) {
}
if ( event.key.keysym.sym == SDLK_F11 ) {
- globalData.theme = getNextTheme();
+ globalData.theme = ThemesGetNext();
} //F11
}
if ( event.key.keysym.sym == SDLK_F12 ) {
diff --git a/source/code/menudef.cpp b/source/code/menudef.cpp
index ed898c6..4609261 100644
--- a/source/code/menudef.cpp
+++ b/source/code/menudef.cpp
@@ -434,7 +434,7 @@ static void PlayerConfigMenu() {
}
static void switchTheme() {
- globalData.theme = getNextTheme();
+ globalData.theme = ThemesGetNext();
}
diff --git a/source/code/themes.cpp b/source/code/themes.cpp
index 89eac92..be82c95 100644
--- a/source/code/themes.cpp
+++ b/source/code/themes.cpp
@@ -132,7 +132,7 @@ static bool initialized = false;
static size_t current_theme = 0;
-static void FillMissingFields(Theme& theme) {
+static void ThemesFillMissingFields(Theme& theme) {
if (theme.background.name.empty()) {
//If the theme does not define a background then use the standard.
theme.background.name = "standard";
@@ -140,7 +140,7 @@ static void FillMissingFields(Theme& theme) {
theme.background = background_data[theme.background.name];
}
-static void ReadThemeDataFromFile(const std::string& filename) {
+static void ThemesReadDataFromFile(const std::string& filename) {
if (globalData.verboseLevel) {
std::cout << "Reading theme data from " << filename << "\n";
}
@@ -162,12 +162,12 @@ static void ReadThemeDataFromFile(const std::string& filename) {
std::cout << "Adding theme " << theme.theme_name << "\n";
}
themes.push_back(theme);
- FillMissingFields(themes.back());
+ ThemesFillMissingFields(themes.back());
}
}
-static void InitBackGroundData() {
+static void ThemesInitBackGroundData() {
BackGroundData standard;
standard.name = "standard";
standard.background_sprite = "background";
@@ -182,7 +182,7 @@ static bool str_startswith(const std::string& s, const char* prefix) {
return (s.rfind(prefix, 0) == 0);
}
-void DumpThemeData() {
+static void ThemesDumpData() {
ThemeFileData tfd;
tfd.themes = themes;
for (auto& pair : background_data) {
@@ -219,38 +219,38 @@ static void ThemesAddCustomSlot(std::vector<Theme>& themes, int slot_number) {
Theme new_theme;
new_theme.theme_name = slot_name;
themes.push_back(new_theme);
- FillMissingFields(themes.back());
+ ThemesFillMissingFields(themes.back());
}
-void InitThemes() {
+void ThemesInit() {
if (initialized) {
return;
}
initialized = true;
- InitBackGroundData();
+ ThemesInitBackGroundData();
themes.resize(1); //Add the default theme
- FillMissingFields(themes[0]);
+ ThemesFillMissingFields(themes[0]);
const std::vector<std::string>& theme_files = sago::GetFileList("themes");
for (const std::string& filename : theme_files) {
if (boost::algorithm::ends_with(filename,".json")) {
- ReadThemeDataFromFile("themes/"+filename);
+ ThemesReadDataFromFile("themes/"+filename);
}
}
- ReadThemeDataFromFile("custom_themes.json");
+ ThemesReadDataFromFile("custom_themes.json");
for (int i=1; i <= 4; ++i) {
ThemesAddCustomSlot(themes, i);
}
- DumpThemeData();
+ ThemesDumpData();
}
-Theme getNextTheme() {
- InitThemes();
+Theme ThemesGetNext() {
+ ThemesInit();
current_theme++;
current_theme = current_theme % themes.size();
return themes.at(current_theme);
}
-Theme getTheme(size_t theme_number) {
- InitThemes();
+Theme ThemesGet(size_t theme_number) {
+ ThemesInit();
return themes.at(theme_number % themes.size());
}
diff --git a/source/code/themes.hpp b/source/code/themes.hpp
index 3da3f2d..0c471f4 100644
--- a/source/code/themes.hpp
+++ b/source/code/themes.hpp
@@ -65,14 +65,14 @@ struct ThemeFileData {
* @brief returns a theme from a list
* @return A copy of a theme
*/
-Theme getNextTheme();
+Theme ThemesGetNext();
/**
* @brief getTheme returns a specific theme
* @param theme_number
* @return
*/
-Theme getTheme(size_t theme_number);
+Theme ThemesGet(size_t theme_number);
/**
* @brief Saves the themes starting with "custom_slot_" to "custom_themes.json"