mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
simplify code
This commit is contained in:
+5
-7
@@ -37,7 +37,8 @@ bool Font::PreloadResourceFonts(String fontsDirectoryPath, bool recursive) {
|
||||
|
||||
// tally fonts
|
||||
vector<String> fontFilePaths;
|
||||
if (!TallyResourceFonts(fontsDirectoryPath, fontFilePaths, recursive)) return false;
|
||||
TallyResourceFonts(fontsDirectoryPath, fontFilePaths, recursive);
|
||||
if (fontFilePaths.size() == 0) return false;
|
||||
|
||||
// load fonts
|
||||
bool preloadHadErrors = false;
|
||||
@@ -53,25 +54,22 @@ bool Font::PreloadResourceFonts(String fontsDirectoryPath, bool recursive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Font::TallyResourceFonts(String fontsDirectoryPath, vector<String>& fontFilePaths, bool recursive) {
|
||||
void Font::TallyResourceFonts(String fontsDirectoryPath, vector<String>& fontFilePaths, bool recursive) {
|
||||
wxDir fontsDirectory(fontsDirectoryPath);
|
||||
String fontFileName = "";
|
||||
bool foundFonts = false;
|
||||
String fontFileName = wxEmptyString;
|
||||
bool hasNext = fontsDirectory.GetFirst(&fontFileName);
|
||||
while (hasNext) {
|
||||
String fontFilePath = fontsDirectoryPath + fontFileName;
|
||||
if (wxDirExists(fontFilePath)) {
|
||||
if (recursive) {
|
||||
foundFonts = foundFonts || TallyResourceFonts(fontFilePath + wxFileName::GetPathSeparator(), fontFilePaths, true);
|
||||
TallyResourceFonts(fontFilePath + wxFileName::GetPathSeparator(), fontFilePaths, true);
|
||||
}
|
||||
}
|
||||
else if (fontFilePath.EndsWith(_(".ttf")) || fontFilePath.EndsWith(_(".otf"))) {
|
||||
foundFonts = true;
|
||||
fontFilePaths.push_back(fontFilePath);
|
||||
}
|
||||
hasNext = fontsDirectory.GetNext(&fontFileName);
|
||||
}
|
||||
return foundFonts;
|
||||
}
|
||||
|
||||
bool Font::update(Context& ctx) {
|
||||
|
||||
+2
-2
@@ -51,8 +51,8 @@ public:
|
||||
|
||||
/// Load fonts (.ttf or .otf) from the given directory and its subdirectories, returns true if there were errors
|
||||
static bool PreloadResourceFonts(String fontsDirectoryPath, bool recursive);
|
||||
/// Adds font file paths from the given directory into fontFilePaths, returns true if fonts were found
|
||||
static bool TallyResourceFonts(String fontsDirectoryPath, vector<String>& fontFilePaths, bool recursive);
|
||||
/// Adds font file paths from the given directory into fontFilePaths
|
||||
static void TallyResourceFonts(String fontsDirectoryPath, vector<String>& fontFilePaths, bool recursive);
|
||||
/// Update the scritables, returns true if there is a change
|
||||
bool update(Context& ctx);
|
||||
/// Add the given dependency to the dependent_scripts list for the variables this font depends on
|
||||
|
||||
Reference in New Issue
Block a user