mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-24 14:06:23 +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);
|
||||
self.key = key;
|
||||
dialog.onApply = function(color) {
|
||||
variable_struct_set(COLORS, key, color);
|
||||
overrideColor();
|
||||
COLORS[$ key] = color;
|
||||
overrideColor(key);
|
||||
};
|
||||
|
||||
dialog.selector.onApply = dialog.onApply;
|
||||
|
||||
addChildren(dialog);
|
||||
|
@ -602,9 +603,12 @@ event_inherited();
|
|||
return hh;
|
||||
});
|
||||
|
||||
function overrideColor() {
|
||||
function overrideColor(key) {
|
||||
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
|
||||
|
||||
|
|
|
@ -21,21 +21,13 @@ function _loadColor(theme = "default", replace = false) {
|
|||
var path = dirr + "/values.json";
|
||||
var pathO = dirr + "/override.json";
|
||||
|
||||
if(theme == "default" && !file_exists_empty(pathO)) {
|
||||
COLOR_KEYS = variable_struct_get_names(COLORS);
|
||||
array_sort(COLOR_KEYS, true);
|
||||
return;
|
||||
}
|
||||
COLOR_KEYS = variable_struct_get_names(COLORS);
|
||||
array_sort(COLOR_KEYS, true);
|
||||
|
||||
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; }
|
||||
|
||||
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; }
|
||||
|
||||
var valkeys = variable_struct_get_names(clrs.values);
|
||||
|
@ -78,4 +70,5 @@ function _loadColor(theme = "default", replace = false) {
|
|||
COLORS[$ key] = c;
|
||||
}
|
||||
|
||||
if(file_exists_empty(pathO)) struct_override(COLORS, json_load_struct(pathO));
|
||||
}
|
Loading…
Reference in a new issue