Remove usage of List from Theme.cpp

This commit is contained in:
Ted John 2016-09-13 18:26:44 +01:00
parent c0957efb37
commit 97f231d945
1 changed files with 24 additions and 24 deletions

View File

@ -14,6 +14,7 @@
*****************************************************************************/
#pragma endregion
#include <vector>
#include <jansson.h>
extern "C"
@ -25,7 +26,6 @@ extern "C"
}
#include "../core/Json.hpp"
#include "../core/List.hpp"
#include "../core/Math.hpp"
#include "../core/Memory.hpp"
#include "../core/Path.hpp"
@ -65,9 +65,9 @@ struct UIThemeWindowEntry
class UITheme
{
public:
utf8 * Name;
List<UIThemeWindowEntry> Entries;
uint8 Flags;
utf8 * Name;
std::vector<UIThemeWindowEntry> Entries;
uint8 Flags;
UITheme(const utf8 * name);
UITheme(const UITheme & copy);
@ -323,7 +323,7 @@ void UITheme::SetName(const utf8 * name)
const UIThemeWindowEntry * UITheme::GetEntry(rct_windowclass windowClass) const
{
for (size_t i = 0; i < Entries.GetCount(); i++)
for (size_t i = 0; i < Entries.size(); i++)
{
const UIThemeWindowEntry * entry = &Entries[i];
if (entry->WindowClass == windowClass)
@ -337,7 +337,7 @@ const UIThemeWindowEntry * UITheme::GetEntry(rct_windowclass windowClass) const
void UITheme::SetEntry(const UIThemeWindowEntry * newEntry)
{
// Try to replace existing entry
for (size_t i = 0; i < Entries.GetCount(); i++)
for (size_t i = 0; i < Entries.size(); i++)
{
UIThemeWindowEntry * entry = &Entries[i];
if (entry->WindowClass == newEntry->WindowClass)
@ -347,18 +347,18 @@ void UITheme::SetEntry(const UIThemeWindowEntry * newEntry)
}
}
Entries.Add(*newEntry);
Entries.push_back(*newEntry);
}
void UITheme::RemoveEntry(rct_windowclass windowClass)
{
// Remove existing entry
for (size_t i = 0; i < Entries.GetCount(); i++)
for (size_t i = 0; i < Entries.size(); i++)
{
UIThemeWindowEntry * entry = &Entries[i];
if (entry->WindowClass == windowClass)
{
Entries.RemoveAt(i);
Entries.erase(Entries.begin() + i);
break;
}
}
@ -485,7 +485,7 @@ UITheme UITheme::CreatePredefined(const utf8 * name, const UIThemeWindowEntry *
numEntries++;
}
theme.Entries = List<UIThemeWindowEntry>(entries, numEntries);
theme.Entries = std::vector<UIThemeWindowEntry>(entries, entries + numEntries);
return theme;
}
@ -499,21 +499,21 @@ namespace ThemeManager
utf8 Name[96];
};
utf8 * CurrentThemePath;
UITheme * CurrentTheme;
List<AvailableTheme> AvailableThemes;
size_t ActiveAvailableThemeIndex = SIZE_MAX;
size_t NumPredefinedThemes = 0;
utf8 * CurrentThemePath;
UITheme * CurrentTheme;
std::vector<AvailableTheme> AvailableThemes;
size_t ActiveAvailableThemeIndex = SIZE_MAX;
size_t NumPredefinedThemes = 0;
void GetThemeFileName(utf8 * buffer, size_t bufferSize, const utf8 * name);
bool EnsureThemeDirectoryExists();
void GetThemePath(utf8 * buffer, size_t bufferSize);
static void GetAvailableThemes(List<AvailableTheme> * outThemes)
static void GetAvailableThemes(std::vector<AvailableTheme> * outThemes)
{
Guard::ArgumentNotNull(outThemes, GUARD_LINE);
outThemes->Clear();
outThemes->clear();
NumPredefinedThemes = 0;
for (const UITheme * * predefinedTheme = PredefinedThemes; *predefinedTheme != nullptr; predefinedTheme++)
@ -521,7 +521,7 @@ namespace ThemeManager
AvailableTheme theme;
String::Set(theme.Path, sizeof(theme.Path), String::Empty);
String::Set(theme.Name, sizeof(theme.Name), (*predefinedTheme)->Name);
outThemes->Add(theme);
outThemes->push_back(theme);
NumPredefinedThemes++;
}
@ -540,11 +540,11 @@ namespace ThemeManager
Path::GetFileNameWithoutExtension(theme.Name, sizeof(theme.Name), fileInfo.path);
GetThemeFileName(theme.Path, sizeof(theme.Path), theme.Name);
outThemes->Add(theme);
outThemes->push_back(theme);
if (Path::Equals(CurrentThemePath, fileInfo.path))
{
ActiveAvailableThemeIndex = outThemes->GetCount() - 1;
ActiveAvailableThemeIndex = outThemes->size() - 1;
}
}
platform_enumerate_files_end(handle);
@ -590,7 +590,7 @@ namespace ThemeManager
static bool LoadThemeByName(const utf8 * name)
{
for (size_t i = 0; i < ThemeManager::AvailableThemes.GetCount(); i++)
for (size_t i = 0; i < ThemeManager::AvailableThemes.size(); i++)
{
if (String::Equals(name, ThemeManager::AvailableThemes[i].Name))
{
@ -660,7 +660,7 @@ extern "C"
size_t theme_manager_get_num_available_themes()
{
return ThemeManager::AvailableThemes.GetCount();
return ThemeManager::AvailableThemes.size();
}
const utf8 * theme_manager_get_available_theme_path(size_t index)
@ -766,7 +766,7 @@ extern "C"
ThemeManager::CurrentTheme->WriteToFile(ThemeManager::CurrentThemePath);
theme_manager_load_available_themes();
for (size_t i = 0; i < ThemeManager::AvailableThemes.GetCount(); i++)
for (size_t i = 0; i < ThemeManager::AvailableThemes.size(); i++)
{
if (Path::Equals(newPath, ThemeManager::AvailableThemes[i].Path))
{
@ -794,7 +794,7 @@ extern "C"
ThemeManager::LoadTheme(newPath);
theme_manager_load_available_themes();
for (size_t i = 0; i < ThemeManager::AvailableThemes.GetCount(); i++)
for (size_t i = 0; i < ThemeManager::AvailableThemes.size(); i++)
{
if (Path::Equals(newPath, ThemeManager::AvailableThemes[i].Path))
{