Add start screen section to select keymap

This commit is contained in:
JannisX11 2021-06-23 21:20:15 +02:00
parent e2381f0749
commit 73f904d557
6 changed files with 111 additions and 36 deletions

View File

@ -557,6 +557,7 @@
position: absolute; position: absolute;
top: 8px; top: 8px;
right: 8px; right: 8px;
cursor: pointer;
} }
#start_screen i.start_screen_close_button:not(:hover) { #start_screen i.start_screen_close_button:not(:hover) {
opacity: 0.8; opacity: 0.8;
@ -630,6 +631,38 @@
display: inline-block; display: inline-block;
} }
section#keymap_preference {
display: block !important;
}
section#keymap_preference > ul {
display: grid;
grid-template-columns: auto auto auto;
grid-gap: 6px;
padding: 12px;
}
section#keymap_preference > h2 {
padding: 12px 20px;
}
section#keymap_preference > p {
padding: 0 20px;
}
section#keymap_preference .keymap_select_box {
display: inline-block;
padding: 12px;
min-height: 132px;
background-color: var(--color-back);
cursor: pointer;
border: 2px solid transparent;
}
section#keymap_preference .keymap_select_box:hover {
color: var(--color-light);
border-color: var(--color-accent);
background-color: var(--color-ui);
}
section#keymap_preference .keymap_select_box p {
color: var(--color-subtle_text);
}
/*Status Bar*/ /*Status Bar*/
#status_bar { #status_bar {
position: relative; position: relative;

View File

@ -713,18 +713,6 @@ function addStartScreenSection(id, data) {
updateStreamerModeNotification() updateStreamerModeNotification()
} }
//Electron
if (isApp && !compareVersions(process.versions.electron, '6.0.0')) {
addStartScreenSection({
graphic: {type: 'icon', icon: 'fas.fa-atom'},
text: [
{type: 'h1', text: 'Electron Update Recommended'},
{text: 'Your Blockbench is using an old version of Electron. Install the latest version to get the best performance and newest features. Just run the latest Blockbench installer. This only takes a minute and will not affect your custom settings.'},
{text: '[Blockbench Downloads](https://blockbench.net/downloads/)'}
]
})
}
//Twitter //Twitter
let twitter_ad; let twitter_ad;
if (Blockbench.startup_count < 20 && Blockbench.startup_count % 5 === 4) { if (Blockbench.startup_count < 20 && Blockbench.startup_count % 5 === 4) {
@ -753,6 +741,46 @@ function addStartScreenSection(id, data) {
last: true last: true
}) })
} }
// Keymap Preference
if (!Blockbench.isMobile && !localStorage.getItem('selected_keymap_preference')) {
var obj = $(`<section id="keymap_preference">
<h2>${tl('mode.start.keymap_preference')}</h2>
<p>${tl('mode.start.keymap_preference.desc')}</p>
<ul></ul>
</section>`)
var keymap_list = $(obj).find('ul');
obj.prepend(`<i class="material-icons start_screen_close_button">clear</i>`);
obj.find('i.start_screen_close_button').on('click', (e) => {
obj.detach();
localStorage.setItem('selected_keymap_preference', true);
});
[
['default', 'action.load_keymap.default'],
['mouse', 'action.load_keymap.mouse'],
['blender', 'Blender'],
['cinema4d', 'Cinema 4D'],
['maya', 'Maya'],
].forEach(([id, name], index) => {
let node = $(`<li class="keymap_select_box">
<h4>${tl(name)}</h4>
<p>${tl(`action.load_keymap.${id}.desc`)}</p>
</li>`)
node.on('click', e => {
Keybinds.loadKeymap(id, true);
localStorage.setItem('selected_keymap_preference', true);
})
keymap_list.append(node);
})
$('#start_screen content').prepend(obj);
}
}) })
})() })()

View File

@ -242,32 +242,34 @@ class Keybind {
return this.label return this.label
} }
} }
Keybinds.loadKeymap = function(id) { Keybinds.loadKeymap = function(id, from_start_screen = false) {
let answer = confirm(tl('message.load_keymap')); let controls_only = from_start_screen && (id == 'default' || id == 'mouse');
let answer = controls_only || confirm(tl('message.load_keymap'));
if (!answer) return; if (!answer) return;
let preset = KeymapPresets[id]; let preset = KeymapPresets[id];
Keybinds.actions.forEach(item => { if (!controls_only)
if (!item.keybind) return; Keybinds.actions.forEach(item => {
if (!item.keybind) return;
if (preset && preset.keys[item.id] !== undefined) { if (preset && preset.keys[item.id] !== undefined) {
if (preset.keys[item.id] == null) { if (preset.keys[item.id] == null) {
item.keybind.clear(); item.keybind.clear();
} else {
item.keybind.set(preset.keys[item.id]).save(false);
}
} else { } else {
item.keybind.set(preset.keys[item.id]).save(false); if (item.default_keybind) {
item.keybind.set(item.default_keybind);
} else {
item.keybind.clear();
}
} }
} else {
if (item.default_keybind) {
item.keybind.set(item.default_keybind);
} else {
item.keybind.clear();
}
}
item.keybind.save(false); item.keybind.save(false);
}) })
if (id == 'mouse') { if (id == 'mouse') {
Keybinds.extra.preview_rotate.keybind.set({key: 2}).save(false); Keybinds.extra.preview_rotate.keybind.set({key: 2}).save(false);
@ -277,6 +279,7 @@ Keybinds.loadKeymap = function(id) {
Keybinds.save(); Keybinds.save();
TickUpdates.keybind_conflicts = true; TickUpdates.keybind_conflicts = true;
Blockbench.showQuickMessage('message.keymap_loaded', 1600);
} }
Keybinds.no_overlap = function(k1, k2) { Keybinds.no_overlap = function(k1, k2) {
if (typeof k1.condition !== 'object' || typeof k2.condition !== 'object') return false; if (typeof k1.condition !== 'object' || typeof k2.condition !== 'object') return false;
@ -406,11 +409,11 @@ BARS.defineActions(() => {
children: [ children: [
'import_keymap', 'import_keymap',
'_', '_',
{icon: 'keyboard', id: 'default', name: 'Default (Trackpad)', click() {Keybinds.loadKeymap('default')}}, {icon: 'keyboard', id: 'default', description: 'action.load_keymap.default.desc', name: 'action.load_keymap.default', click() {Keybinds.loadKeymap('default')}},
{icon: 'keyboard', id: 'mouse', name: 'Default (Mouse)', click() {Keybinds.loadKeymap('mouse')}}, {icon: 'keyboard', id: 'mouse', description: 'action.load_keymap.mouse.desc', name: 'action.load_keymap.mouse', click() {Keybinds.loadKeymap('mouse')}},
{icon: 'keyboard', id: 'blender', name: 'Blender', click() {Keybinds.loadKeymap('blender')}}, {icon: 'keyboard', id: 'blender', description: 'action.load_keymap.blender.desc', name: 'Blender', click() {Keybinds.loadKeymap('blender')}},
{icon: 'keyboard', id: 'cinema4d', name: 'Cinema 4D', click() {Keybinds.loadKeymap('cinema4d')}}, {icon: 'keyboard', id: 'cinema4d', description: 'action.load_keymap.cinema4d.desc', name: 'Cinema 4D', click() {Keybinds.loadKeymap('cinema4d')}},
{icon: 'keyboard', id: 'maya', name: 'Maya', click() {Keybinds.loadKeymap('maya')}} {icon: 'keyboard', id: 'maya', description: 'action.load_keymap.maya.desc', name: 'Maya', click() {Keybinds.loadKeymap('maya')}}
] ]
}) })
new Action('import_keymap', { new Action('import_keymap', {

File diff suppressed because one or more lines are too long

View File

@ -220,7 +220,7 @@
"reverse_keyframes": null, "reverse_keyframes": null,
"previous_keyframe": {"key": 188}, "previous_keyframe": {"key": 188},
"next_keyframe": {"key": 190}, "next_keyframe": {"key": 190},
"add_keyframe": {"key": 73}, "add_keyframe": {"key": 83},
"add_marker": {"key": 77, "ctrl": true}, "add_marker": {"key": 77, "ctrl": true},
"bring_up_all_animations": null, "bring_up_all_animations": null,
"fold_all_animations": null, "fold_all_animations": null,

View File

@ -73,6 +73,9 @@
"mode.start.new": "New", "mode.start.new": "New",
"mode.start.recent": "Recent", "mode.start.recent": "Recent",
"mode.start.no_recents": "No recently opened models", "mode.start.no_recents": "No recently opened models",
"mode.start.keymap_preference": "Keybinding Preference",
"mode.start.keymap_preference.desc": "If you are new to Blockbench and you are coming from another 3D program, you can select a keymap to make your transition easier. You can change the keymap or individual keybindigns later in the settings.",
"mode.start.select_keymap": "Select Keymap",
"format.free": "Generic Model", "format.free": "Generic Model",
"format.free.desc": "Model without restrictions. For game engines, rendering etc.", "format.free.desc": "Model without restrictions. For game engines, rendering etc.",
@ -228,6 +231,7 @@
"message.add_to_palette": "Added to palette", "message.add_to_palette": "Added to palette",
"message.size_modifiers": "Hold down Ctrl or Shift to transform in smaller increments.", "message.size_modifiers": "Hold down Ctrl or Shift to transform in smaller increments.",
"message.load_keymap": "Are you sure you want to load this keymap? This will overwrite your current keybindings.", "message.load_keymap": "Are you sure you want to load this keymap? This will overwrite your current keybindings.",
"message.keymap_loaded": "Keymap loaded",
"message.no_animation_to_import": "No animations to import", "message.no_animation_to_import": "No animations to import",
"message.wireframe.enabled": "Wireframe view enabled", "message.wireframe.enabled": "Wireframe view enabled",
@ -814,6 +818,13 @@
"action.export_settings.desc": "Export the Blockbench settings as a .bbsettings file", "action.export_settings.desc": "Export the Blockbench settings as a .bbsettings file",
"action.load_keymap": "Load Keymap", "action.load_keymap": "Load Keymap",
"action.load_keymap.default": "Default (Trackpad)",
"action.load_keymap.mouse": "Default (Mouse)",
"action.load_keymap.default.desc": "Default Blockbench keybindings, with viewport navigation controls optimized for use on laptop trackpads",
"action.load_keymap.mouse.desc": "Default Blockbench keybindings, with viewport navigation bound to the middle mouse button",
"action.load_keymap.blender.desc": "Keymap for users who are familiar with the controls of Blender",
"action.load_keymap.cinema4d.desc": "Keymap for users who are familiar with the controls of Cinema 4D",
"action.load_keymap.maya.desc": "Keymap for users who are familiar with the controls of Autodesk Maya",
"action.import_keymap": "Import Keymap", "action.import_keymap": "Import Keymap",
"action.import_keymap.desc": "Import keybindings a .bbkeymap file", "action.import_keymap.desc": "Import keybindings a .bbkeymap file",
"action.export_keymap": "Export Keymap", "action.export_keymap": "Export Keymap",