mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Implement unique IDs and card linking
This commit is contained in:
+50
-50
@@ -8,10 +8,10 @@
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <data/font.hpp>
|
||||
#include <wx/stdpaths.h>
|
||||
#include <wx/dir.h>
|
||||
#include <wx/font.h>
|
||||
|
||||
#include <wx/stdpaths.h>
|
||||
#include <wx/dir.h>
|
||||
#include <wx/font.h>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Font
|
||||
|
||||
Font::Font()
|
||||
@@ -27,59 +27,59 @@ Font::Font()
|
||||
, separator_color(Color(0,0,0,128))
|
||||
, flags(FONT_NORMAL)
|
||||
{}
|
||||
|
||||
bool Font::PreloadResourceFonts(bool recursive) {
|
||||
#if wxUSE_PRIVATE_FONTS
|
||||
String pathSeparator(wxFileName::GetPathSeparator());
|
||||
String appPath(wxFileName(wxStandardPaths::Get().GetExecutablePath()).GetPath());
|
||||
wxDir appDir(appPath);
|
||||
if (!appDir.IsOpened()) return true;
|
||||
|
||||
bool preloadHadErrors = false;
|
||||
bool Font::PreloadResourceFonts(bool recursive) {
|
||||
#if wxUSE_PRIVATE_FONTS
|
||||
String pathSeparator(wxFileName::GetPathSeparator());
|
||||
String appPath(wxFileName(wxStandardPaths::Get().GetExecutablePath()).GetPath());
|
||||
wxDir appDir(appPath);
|
||||
if (!appDir.IsOpened()) return true;
|
||||
|
||||
bool preloadHadErrors = false;
|
||||
wxString folder;
|
||||
bool cont = appDir.GetFirst(&folder, wxEmptyString, wxDIR_DIRS);
|
||||
while (cont)
|
||||
{
|
||||
{
|
||||
if (folder.Lower().Contains("fonts")) {
|
||||
String folderPath = appPath + pathSeparator + folder + pathSeparator;
|
||||
|
||||
// tally fonts
|
||||
vector<String> fontFilePaths;
|
||||
TallyResourceFonts(folderPath, fontFilePaths, recursive);
|
||||
|
||||
// load fonts
|
||||
for (const String& fontFilePath : fontFilePaths) {
|
||||
if (!wxFont::AddPrivateFont(fontFilePath)) {
|
||||
preloadHadErrors = true;
|
||||
}
|
||||
String folderPath = appPath + pathSeparator + folder + pathSeparator;
|
||||
|
||||
// tally fonts
|
||||
vector<String> fontFilePaths;
|
||||
TallyResourceFonts(folderPath, fontFilePaths, recursive);
|
||||
|
||||
// load fonts
|
||||
for (const String& fontFilePath : fontFilePaths) {
|
||||
if (!wxFont::AddPrivateFont(fontFilePath)) {
|
||||
preloadHadErrors = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cont = appDir.GetNext(&folder);
|
||||
}
|
||||
|
||||
return preloadHadErrors;
|
||||
|
||||
#endif // wxUSE_PRIVATE_FONTS
|
||||
return false;
|
||||
}
|
||||
|
||||
void Font::TallyResourceFonts(String fontsDirectoryPath, vector<String>& fontFilePaths, bool recursive) {
|
||||
wxDir fontsDirectory(fontsDirectoryPath);
|
||||
String fontFileName = wxEmptyString;
|
||||
bool hasNext = fontsDirectory.GetFirst(&fontFileName);
|
||||
while (hasNext) {
|
||||
String fontFilePath = fontsDirectoryPath + fontFileName;
|
||||
if (wxDirExists(fontFilePath)) {
|
||||
if (recursive) {
|
||||
TallyResourceFonts(fontFilePath + wxFileName::GetPathSeparator(), fontFilePaths, true);
|
||||
}
|
||||
}
|
||||
else if (fontFilePath.EndsWith(_(".ttf")) || fontFilePath.EndsWith(_(".otf"))) {
|
||||
fontFilePaths.push_back(fontFilePath);
|
||||
}
|
||||
hasNext = fontsDirectory.GetNext(&fontFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return preloadHadErrors;
|
||||
|
||||
#endif // wxUSE_PRIVATE_FONTS
|
||||
return false;
|
||||
}
|
||||
|
||||
void Font::TallyResourceFonts(String fontsDirectoryPath, vector<String>& fontFilePaths, bool recursive) {
|
||||
wxDir fontsDirectory(fontsDirectoryPath);
|
||||
String fontFileName = wxEmptyString;
|
||||
bool hasNext = fontsDirectory.GetFirst(&fontFileName);
|
||||
while (hasNext) {
|
||||
String fontFilePath = fontsDirectoryPath + fontFileName;
|
||||
if (wxDirExists(fontFilePath)) {
|
||||
if (recursive) {
|
||||
TallyResourceFonts(fontFilePath + wxFileName::GetPathSeparator(), fontFilePaths, true);
|
||||
}
|
||||
}
|
||||
else if (fontFilePath.EndsWith(_(".ttf")) || fontFilePath.EndsWith(_(".otf"))) {
|
||||
fontFilePaths.push_back(fontFilePath);
|
||||
}
|
||||
hasNext = fontsDirectory.GetNext(&fontFileName);
|
||||
}
|
||||
}
|
||||
|
||||
bool Font::update(Context& ctx) {
|
||||
bool changes = false;
|
||||
|
||||
Reference in New Issue
Block a user