app:/, romfs:/ and sdmc:/ font loading

This commit is contained in:
zetaPRIME 2017-05-11 15:45:14 -04:00
parent 7928e56475
commit 15dbabd917
2 changed files with 47 additions and 22 deletions

View File

@ -286,9 +286,6 @@ void ThemeManager::LoadProc() {
} }
string ThemeManager::ResolveAssetPath(const string& id) { string ThemeManager::ResolveAssetPath(const string& id) {
//struct stat buf;
//string path(id.length() + 64, ' '); // preallocate buffer space
string pfx = ""; string pfx = "";
size_t cpos = id.find(":/"); size_t cpos = id.find(":/");
@ -339,23 +336,50 @@ string ThemeManager::ResolveAssetPath(const string& id) {
} }
} }
/*path.clear(); path.append("romfs:/"); path.append(id); path.append(".json");
printf("attempt: %s\n", path.c_str());
if (stat(path.c_str(), &buf) == 0) return path;
path.erase(path.end()-5, path.end()); path.append(".png");
printf("attempt: %s\n", path.c_str());
if (stat(path.c_str(), &buf) == 0) return path;//*/
return string(); return string();
} }
string ThemeManager::ResolveFontPath(const string& id) { // there we go, nice and simple string ThemeManager::ResolveFontPath(const string& id) { // there we go, nice and simple
string pfx = "";
size_t cpos = id.find(":/");
if (cpos != string::npos) {
pfx = id.substr(0, cpos);
cpos += 2;
} else cpos = 0;
if (pfx == "app") {
string sid = id.substr(cpos); // strip off the "app:/"
// app-local asset
// check if present in theme/app/[appname]/fonts/, else check in romfs
for (auto thm : themeData) {
Path bp = thm.basePath.Combine("app").Combine(Application::AppName()).Combine("fonts");
Path p = bp.Combine(sid+".json");
if (p.IsFile()) return p;
}
// TBD - directly in romfs, or in an assets folder?
Path bp = Path("romfs:/fonts/");
Path p = bp.Combine(sid+".json");
if (p.IsFile()) return p;
}
else if (pfx == "sdmc" || pfx == "romfs") {
// no forced "fonts" here, of course; this is an actual path
Path p = Path(id + ".json");
if (p.IsFile()) return p;
}
else {
// theme asset; check in each theme from selected to most-fallback
for (auto thm : themeData) { for (auto thm : themeData) {
Path p = thm.basePath.Combine("fonts").Combine(id+".json"); Path p = thm.basePath.Combine("fonts").Combine(id+".json");
if (p.IsFile()) return p; if (p.IsFile()) return p;
} }
}
return string(); // I guess fall back to 12px monospace if it's just nowhere to be found
const string fallback = "mono.12";
if (id != fallback) return ResolveFontPath(fallback);
return string(); // fallback not found; no themes on sdmc or romfs, probably
} }
json& ThemeManager::GetMetric(const string& path) { json& ThemeManager::GetMetric(const string& path) {

View File

@ -2,14 +2,10 @@
roadmap to v0.5.1 { roadmap to v0.5.1 {
- clear bug workaround implemented make font-not-found not outright crash the app
^ maybe replace clearing with the workaround entirely? make asset gc actually sweep every 5sec
- try to figure out why the workaround doesn't work in citra (it was a difference between openGL and PICA blend operations!) maybe entirely replace clearing with transparent knockout on bind?
https://github.com/citra-emu/citra/issues/2684 implement more blend modes??
implement more blend modes {
- flat replace
- masking
}
- libctru console as ui element - libctru console as ui element
@ -37,9 +33,11 @@ roadmap to v0.5.1 {
lambda task thread lambda task thread
} }
} then by v0.5.5 { } then by v0.5.5 {
refactor ResolveAsset/FontPath to use Path objects for cleaner code
event propagation system of some sort; threadsafe to whatever extent is needed on 3DS event propagation system of some sort; threadsafe to whatever extent is needed on 3DS
figure out how to *actually* fix the clear bug...? figure out how to *actually* fix the clear bug...?
some sort of tagging for longer retention for large drawables such as backgrounds (particularly for the OSK) some sort of tagging for longer retention for large drawables such as backgrounds (particularly for the OSK)
convert the profiler from "single static thing" to "here, have an instance on the stack"
} then consider these before 1.0 "gold" { } then consider these before 1.0 "gold" {
replace some of the OptRef stuffs on invalidatable types with invalid checks; add implicit conversions from nullptr to invalid replace some of the OptRef stuffs on invalidatable types with invalid checks; add implicit conversions from nullptr to invalid
make closing forms a bit less finicky (add them to a separate list and let the Application remove them from the list) make closing forms a bit less finicky (add them to a separate list and let the Application remove them from the list)
@ -68,7 +66,10 @@ roadmap to v0.5.1 {
quick includes for all UI elements, etc. quick includes for all UI elements, etc.
cross-app integrations { cross-app integrations {
app icon and manifest.json in romfs, copied into .starlight on launch app icon and manifest.json in romfs, copied into .starlight on launch {
app name, description etc.
themeLevel: 0 (default) as fallback only, 1 or 2 to override user theme unless opted out, 1 for "just by default", 2 for "this doesn't look so good otherwise"
}
settings pane data for each app, contained in manifest.json and used by Starlight Settings to provide centralized configuration, iOS-style settings pane data for each app, contained in manifest.json and used by Starlight Settings to provide centralized configuration, iOS-style
some standard means of passing parameters into another application, which works on a cia (probably a json file) some standard means of passing parameters into another application, which works on a cia (probably a json file)
} }