From 39fff7826c51201d20215e7290abd108823df55a Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Tue, 28 Apr 2015 21:15:36 -0600 Subject: [PATCH] + Spin & Toggle menu demo start --- core/toggle_menu_view.js | 13 ++++++----- mods/art/demo_spin_and_toggle.ans | Bin 0 -> 640 bytes mods/menu.json | 37 ++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 mods/art/demo_spin_and_toggle.ans diff --git a/core/toggle_menu_view.js b/core/toggle_menu_view.js index a5e7d21a..c3e92b30 100644 --- a/core/toggle_menu_view.js +++ b/core/toggle_menu_view.js @@ -42,7 +42,8 @@ ToggleMenuView.prototype.redraw = function() { assert(this.items.length === 2); for(var i = 0; i < 2; i++) { var item = this.items[i]; - var text = strUtil.stylizeString(item.text, i === this.focusedItemIndex ? this.focusTextStyle : this.textStyle); + var text = strUtil.stylizeString( + item.text, i === this.focusedItemIndex && this.hasFocus ? this.focusTextStyle : this.textStyle); if(1 === i) { this.client.term.write(this.getANSIColor(this.getColor()) + ' / '); // :TODO: We need a color for this!!! @@ -51,7 +52,7 @@ ToggleMenuView.prototype.redraw = function() { this.client.term.write(this.getANSIColor(i === this.focusedItemIndex ? this.getFocusColor() : this.getColor())); this.client.term.write(text); } -} +}; ToggleMenuView.prototype.setFocus = function(focused) { ToggleMenuView.super_.prototype.setFocus.call(this, focused); @@ -73,7 +74,7 @@ ToggleMenuView.prototype.onKeyPress = function(key, isSpecial) { } ToggleMenuView.super_.prototype.onKeyPress.call(this, key, isSpecial); -} +}; ToggleMenuView.prototype.onSpecialKeyPress = function(keyName) { @@ -94,7 +95,7 @@ ToggleMenuView.prototype.onSpecialKeyPress = function(keyName) { this.updateSelection(); ToggleMenuView.super_.prototype.onSpecialKeyPress.call(this, keyName); -} +}; ToggleMenuView.prototype.getData = function() { return this.focusedItemIndex; @@ -105,5 +106,5 @@ ToggleMenuView.prototype.setItems = function(items) { this.items = this.items.splice(0, 2); // switch/toggle only works with two elements - this.dimens.width = this.items.join(' / ').length; // :TODO: allow configurable seperator -} + this.dimens.width = this.items.join(' / ').length; // :TODO: allow configurable seperator... string & color, e.g. styleColor1 (same as fillChar color) +}; diff --git a/mods/art/demo_spin_and_toggle.ans b/mods/art/demo_spin_and_toggle.ans new file mode 100644 index 0000000000000000000000000000000000000000..52d1be29cad76930d595c444053cdc9d26623c5f GIT binary patch literal 640 zcmb`EJ#T|B5QbqTV(L~eUZ~n3lKF6p%9PMF>VOmplEunURc;h1hKdih|GvGmfzYU9 zJpgyUd*1gBB3Kf!Bz#b=Ln#ry5=1bCUrESS{&6fzS!c5Bc1QWyU%|x<5zsS~71iNz zk{49~U}}DD+0?RWw8Sb;&*`?JwQRe(9Eoc0IBKFRmj?$kmfI5tXV z22g>FamN%9_eO8b%;9Rnd9L2Nh8FS*P_PT$&js$a4a^Y1Q!mea+)Ko9UnW9&40Js# z7NN3vPf})8fM&`AWsc3kFH~^5y~9?V9REab)mLV<7rq{c*ekMd!hz@y4(ct7cv7b$ p6uZtB+jPYk3jWgxn9o@h#NW1M+4jboS^8YPEHk=WFHAH(e*grrk)Hqn literal 0 HcmV?d00001 diff --git a/mods/menu.json b/mods/menu.json index 18149f1e..7c12d13d 100644 --- a/mods/menu.json +++ b/mods/menu.json @@ -197,6 +197,10 @@ { "value" : { "1" : 0 }, "action" : "@menu:demoEditTextView" + }, + { + "value" : { "1" : 1 }, + "action" : "@menu:demoSpinAndToggleView" } ] } @@ -247,6 +251,39 @@ } } } + }, + "demoSpinAndToggleView" : { + "art" : "demo_spin_and_toggle.ans", + "options" : { "cls" : true }, + "form" : { + "0" : { + "BT8SM1SM2TM3" : { + "mci" : { + "SM1" : { + "items" : [ "Henry Morgan", "François l'Ollonais", "Roche Braziliano", "Black Bart", "Blackbeard" ] + }, + "SM2" : { + "items" : [ "Razor 1911", "DrinkOrDie", "TRSI" ] + }, + "TM3" : { + "items" : [ "Yarly", "Nowaii" ] + }, + "BT8" : { + "text" : "< Back", + "submit" : [ "esc" ] + } + }, + "submit" : { + "*" : [ + { + "value" : 8, + "action" : "@menu:demoMain" + } + ] + } + } + } + } } /* :TODO: conceptual simplified menus -- actions/etc. without forms