From: Ian Jackson Date: Wed, 13 Jan 2021 23:16:08 +0000 (+0000) Subject: infopane: Pane switching machinery X-Git-Tag: otter-0.3.0~18 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=e91b81396b4ee95bfd6381a8985e9771e4844bf3;p=otter.git infopane: Pane switching machinery Signed-off-by: Ian Jackson --- diff --git a/templates/macros.tera b/templates/macros.tera index 71659c3f..099c7696 100644 --- a/templates/macros.tera +++ b/templates/macros.tera @@ -86,15 +86,25 @@ Hi {{nick | escape}} {% macro infopane() %}
-
+ +
Mouse select/deselect/drag
shift multiple selection
+
Show + H this help + U players +
-
+
+ + +
{% endmacro infopane %} diff --git a/templates/script.ts b/templates/script.ts index e5497ae7..75612cf4 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -124,6 +124,12 @@ var zoom_btn : HTMLInputElement; var links_elem : HTMLElement; var wresting: boolean; +type PaneName = string; +const pane_keys : { [key: string]: PaneName } = { + "H" : "help", + "U" : "players", +}; + const uo_kind_prec : { [kind: string]: number } = { 'GlobalExtra' : 50, 'Client' : 70, @@ -357,6 +363,11 @@ function some_keydown(e: KeyboardEvent) { // my tsc says this isComposing thing doesn't exist. wat. if ((e as any).isComposing /* || e.keyCode === 229 */) return; + let pane = pane_keys[e.key]; + if (pane) { + return pane_switch(pane); + } + let uo = uo_map[e.key]; if (uo === undefined || uo === null) return; @@ -381,6 +392,22 @@ function some_keydown(e: KeyboardEvent) { } } +function pane_switch(newpane: PaneName) { + let new_e; + for (;;) { + new_e = document.getElementById('pane_' + newpane)!; + let style = new_e.getAttribute('style'); + if (style || newpane == 'help') break; + newpane = 'help'; + } + for (let old_e = new_e.parentElement!.firstElementChild; + old_e; + old_e = old_e.nextElementSibling) { + old_e.setAttribute('style','display: none;'); + } + new_e.removeAttribute('style'); +} + keyops_local['left' ] = function (uo: UoRecord) { rotate_targets(uo, +1); } keyops_local['right'] = function (uo: UoRecord) { rotate_targets(uo, -1); }