+
-
+
-
@@ -243,6 +276,7 @@ const CustomTheme = {
chooseText: tl('dialog.confirm'),
move(c) {
CustomTheme.data.colors[scope_key] = c.toHexString();
+ CustomTheme.customizeTheme();
},
change(c) {
last_color = c.toHexString();
@@ -260,6 +294,20 @@ const CustomTheme = {
}
CustomTheme.dialog_is_setup = true;
},
+ customizeTheme() {
+ if (!CustomTheme.data.customized) {
+ CustomTheme.data.customized = true;
+ CustomTheme.data.name = CustomTheme.data.name ? ('Copy of ' + CustomTheme.data.name) : 'Custom Theme';
+ CustomTheme.data.author = settings.username.value;
+ CustomTheme.data.id = 'custom_theme';
+ let i = 0;
+ while (CustomTheme.themes.find(theme => theme.id == CustomTheme.data.id)) {
+ i++;
+ CustomTheme.data.id = 'custom_theme_'+i;
+ }
+ localStorage.setItem('theme', JSON.stringify(CustomTheme.data));
+ }
+ },
updateColors() {
for (var key in CustomTheme.data.colors) {
@@ -314,6 +362,7 @@ const CustomTheme = {
}
}
Merge.string(app, theme, 'css');
+ app.customized = false;
this.updateColors();
this.updateSettings();
},
@@ -334,9 +383,16 @@ const CustomTheme = {
app.colors.accent_text = data.text_acc
}
- } else {
- if (data && data.colors) {
- CustomTheme.loadTheme(data);
+ } else if (data && data.colors) {
+ data.id = file.name.replace(/\.\w+$/, '');
+ if (!data.name) data.name = data.id;
+
+ CustomTheme.loadTheme(data);
+ CustomTheme.themes.push(data);
+
+ if (isApp) {
+ CustomTheme.sideloaded_themes.push(file.path);
+ localStorage.setItem('themes_sideloaded', JSON.stringify(CustomTheme.sideloaded_themes));
}
}
}
@@ -356,6 +412,7 @@ const CustomTheme = {
}
if (stored_theme) {
CustomTheme.loadTheme(stored_theme);
+ if (stored_theme.customized) CustomTheme.data.customized = true;
}
})()
@@ -386,28 +443,19 @@ BARS.defineActions(function() {
icon: 'style',
category: 'blockbench',
click: function () {
+ let theme = {};
+ Object.assign(theme, CustomTheme.data);
+ delete theme.customized;
+ delete theme.id;
Blockbench.export({
resource_id: 'config',
type: 'Blockbench Theme',
extensions: ['bbtheme'],
+ name: theme.id,
content: compileJSON(CustomTheme.data)
})
}
})
- new Action('reset_theme', {
- icon: 'replay',
- category: 'blockbench',
- click() {
- var app = CustomTheme.data;
- app.main_font = '';
- app.headline_font = '';
- app.code_font = '';
- app.css = '';
- for (var key in app.colors) {
- Merge.string(app.colors, CustomTheme.defaultColors, key);
- }
- }
- })
//Only interface
new Action('reset_layout', {
icon: 'replay',
@@ -425,7 +473,6 @@ BARS.defineActions(function() {
})
BarItems.import_theme.toElement('#layout_title_bar')
BarItems.export_theme.toElement('#layout_title_bar')
- BarItems.reset_theme.toElement('#layout_title_bar')
})
diff --git a/keymaps/blender.bbkeymap b/keymaps/blender.bbkeymap
index c6b32dcb..daeb5441 100644
--- a/keymaps/blender.bbkeymap
+++ b/keymaps/blender.bbkeymap
@@ -32,7 +32,6 @@
"action_control": {"key": 70},
"import_theme": null,
"export_theme": null,
- "reset_theme": null,
"reset_layout": null,
"start": null,
"edit": {"key": 49},
diff --git a/keymaps/cinema4d.bbkeymap b/keymaps/cinema4d.bbkeymap
index 66c9a1a6..493bc7ac 100644
--- a/keymaps/cinema4d.bbkeymap
+++ b/keymaps/cinema4d.bbkeymap
@@ -32,7 +32,6 @@
"action_control": {"key": 112},
"import_theme": null,
"export_theme": null,
- "reset_theme": null,
"reset_layout": null,
"start": null,
"edit": null,
diff --git a/keymaps/maya.bbkeymap b/keymaps/maya.bbkeymap
index 19edb197..4bb30380 100644
--- a/keymaps/maya.bbkeymap
+++ b/keymaps/maya.bbkeymap
@@ -32,7 +32,6 @@
"action_control": {"key": 112},
"import_theme": null,
"export_theme": null,
- "reset_theme": null,
"reset_layout": null,
"start": null,
"edit": null,
diff --git a/lang/en.json b/lang/en.json
index 622c9fe4..1589dc42 100644
--- a/lang/en.json
+++ b/lang/en.json
@@ -862,8 +862,6 @@
"action.import_theme": "Import Theme",
"action.export_theme": "Export Theme",
"action.export_theme.desc": "Create a theme file based on the current settings",
- "action.reset_theme": "Reset Theme",
- "action.reset_theme.desc": "Reset to the default Blockbench theme",
"action.uv_dialog": "UV Window...",
"action.uv_dialog.desc": "Open the UV dialog to see all faces next to each other",
diff --git a/themes/contrast.bbtheme b/themes/contrast.bbtheme
index 4bd81145..55a2187e 100644
--- a/themes/contrast.bbtheme
+++ b/themes/contrast.bbtheme
@@ -1,7 +1,7 @@
{
"id": "contrast",
"name": "Contrast",
- "author": "",
+ "author": "Default",
"borders": true,
"main_font": "",
"headline_font": "",
diff --git a/themes/dark.bbtheme b/themes/dark.bbtheme
index a8cc28b6..c759f906 100644
--- a/themes/dark.bbtheme
+++ b/themes/dark.bbtheme
@@ -1,7 +1,7 @@
{
"id": "dark",
"name": "Default (Dark)",
- "author": "",
+ "author": "Default",
"main_font": "",
"headline_font": "",
"code_font": "",
diff --git a/themes/light.bbtheme b/themes/light.bbtheme
index 150aa430..b531a5f7 100644
--- a/themes/light.bbtheme
+++ b/themes/light.bbtheme
@@ -1,7 +1,7 @@
{
"id": "light",
"name": "Default (Light)",
- "author": "",
+ "author": "Default",
"main_font": "",
"headline_font": "",
"code_font": "",