mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 14:36:13 +01:00
- Fix theme color overriding not being loaded.
This commit is contained in:
parent
2e314c343f
commit
81fbf91e20
2 changed files with 12 additions and 15 deletions
|
@ -584,9 +584,10 @@ event_inherited();
|
||||||
dialog.setDefault(val);
|
dialog.setDefault(val);
|
||||||
self.key = key;
|
self.key = key;
|
||||||
dialog.onApply = function(color) {
|
dialog.onApply = function(color) {
|
||||||
variable_struct_set(COLORS, key, color);
|
COLORS[$ key] = color;
|
||||||
overrideColor();
|
overrideColor(key);
|
||||||
};
|
};
|
||||||
|
|
||||||
dialog.selector.onApply = dialog.onApply;
|
dialog.selector.onApply = dialog.onApply;
|
||||||
|
|
||||||
addChildren(dialog);
|
addChildren(dialog);
|
||||||
|
@ -602,9 +603,12 @@ event_inherited();
|
||||||
return hh;
|
return hh;
|
||||||
});
|
});
|
||||||
|
|
||||||
function overrideColor() {
|
function overrideColor(key) {
|
||||||
var path = $"{DIRECTORY}Themes/{PREFERENCES.theme}/override.json";
|
var path = $"{DIRECTORY}Themes/{PREFERENCES.theme}/override.json";
|
||||||
json_save_struct(path, COLORS, true);
|
var json = file_exists_empty(path)? json_load_struct(path) : {};
|
||||||
|
|
||||||
|
json[$ key] = COLORS[$ key];
|
||||||
|
json_save_struct(path, json, true);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -21,21 +21,13 @@ function _loadColor(theme = "default", replace = false) {
|
||||||
var path = dirr + "/values.json";
|
var path = dirr + "/values.json";
|
||||||
var pathO = dirr + "/override.json";
|
var pathO = dirr + "/override.json";
|
||||||
|
|
||||||
if(theme == "default" && !file_exists_empty(pathO)) {
|
COLOR_KEYS = variable_struct_get_names(COLORS);
|
||||||
COLOR_KEYS = variable_struct_get_names(COLORS);
|
array_sort(COLOR_KEYS, true);
|
||||||
array_sort(COLOR_KEYS, true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(theme == "default" && !file_exists_empty(pathO)) return;
|
||||||
if(!file_exists_empty(path)) { noti_status($"Colors not defined at {path}, rollback to default color."); return; }
|
if(!file_exists_empty(path)) { noti_status($"Colors not defined at {path}, rollback to default color."); return; }
|
||||||
|
|
||||||
var clrs = json_load_struct(path);
|
var clrs = json_load_struct(path);
|
||||||
|
|
||||||
if(file_exists_empty(pathO)) {
|
|
||||||
var oclr = json_load_struct(pathO);
|
|
||||||
struct_override(clrs, oclr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!struct_has(clrs, "values")) { print("Load color error"); return; }
|
if(!struct_has(clrs, "values")) { print("Load color error"); return; }
|
||||||
|
|
||||||
var valkeys = variable_struct_get_names(clrs.values);
|
var valkeys = variable_struct_get_names(clrs.values);
|
||||||
|
@ -78,4 +70,5 @@ function _loadColor(theme = "default", replace = false) {
|
||||||
COLORS[$ key] = c;
|
COLORS[$ key] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(file_exists_empty(pathO)) struct_override(COLORS, json_load_struct(pathO));
|
||||||
}
|
}
|
Loading…
Reference in a new issue