Skip to content
Snippets Groups Projects
Commit 11ef78a4 authored by Kayz's avatar Kayz Committed by Rob Swindell
Browse files

xtrnmenu v3.1 = fix issue with singlecolumn_margin not working very well,...

xtrnmenu v3.1 = fix issue with singlecolumn_margin not working very well, streamline menuconfig when bulk-adding items
parent 02c7c379
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -20,7 +20,10 @@ clear_screen = true ...@@ -20,7 +20,10 @@ clear_screen = true
; uncomment and modify any of the below to change the look of the external programs menu ; uncomment and modify any of the below to change the look of the external programs menu
; to remove titles or underline, set to the text ' ' ; to remove titles or underline, set to the text ' '
;multicolumn_separator: " " ;multicolumn_separator: " "
;singlecolumn_margin=7
; set the singlecolumn margin to the number of lines of your footer, if you have one
;singlecolumn_margin=2
;header_fmt: \1n\1c\1h%s \1n\1cExternal Programs:\r\n\r\n ;header_fmt: \1n\1c\1h%s \1n\1cExternal Programs:\r\n\r\n
;titles: \1n\1cKey \1h\xb3\1n\1c Name \1n\1c ;titles: \1n\1cKey \1h\xb3\1n\1c Name \1n\1c
multicolumn_fmt: \1h\1c%3s \xb3 \1n\1c%-32.32s \1h multicolumn_fmt: \1h\1c%3s \xb3 \1n\1c%-32.32s \1h
......
...@@ -168,12 +168,6 @@ ExternalMenus.prototype.getOptions = function(menutype, menuid) { ...@@ -168,12 +168,6 @@ ExternalMenus.prototype.getOptions = function(menutype, menuid) {
? this.xtrn_custommenu_options.singlecolumn_margin : this.options.singlecolumn_margin; ? this.xtrn_custommenu_options.singlecolumn_margin : this.options.singlecolumn_margin;
if (typeof bbs !== "undefined") { if (typeof bbs !== "undefined") {
this.options.singlecolumn_height = (typeof this.xtrn_custommenu_options.singlecolumn_height !== "undefined")
? this.xtrn_custommenu_options.singlecolumn_height : this.options.singlecolumn_height;
if (this.options.singlecolumn_height === undefined)
this.options.singlecolumn_height = console.screen_rows - this.options.singlecolumn_margin;
// override and turn off multicolumn if terminal width is less than 80 // override and turn off multicolumn if terminal width is less than 80
if (console.screen_columns < 80) if (console.screen_columns < 80)
options.multicolumn = false; options.multicolumn = false;
......
...@@ -637,8 +637,18 @@ function external_menu_custom(menuid) ...@@ -637,8 +637,18 @@ function external_menu_custom(menuid)
// then display that, otherwise dynamiic // then display that, otherwise dynamiic
if (!bbs.menu("xtrnmenu_" + menuid, P_NOERROR)) { if (!bbs.menu("xtrnmenu_" + menuid, P_NOERROR)) {
// determine lines left. we can't know the size of the footer so
// let the sysop use singlecolumn_margin to specify that. Below
// calcution will always leave room for titles and underline even
// if they aren't rendered
var linesleft = console.screen_rows - console.line_counter - options.singlecolumn_margin
- 2 - 2; // -2 for header_fmt/crlf and -2 for crlf and footer
if(options.titles.trimRight() != '') linesleft = linesleft - 1;
if(options.underline.trimRight() != '') linesleft = linesleft - 2;
multicolumn = menuitemsfiltered.length > linesleft;
// if no custom menu file in text/menu, create a dynamic one // if no custom menu file in text/menu, create a dynamic one
multicolumn = options.multicolumn && menuitemsfiltered.length > options.singlecolumn_height;
printf(options.header_fmt, menuobj.title); printf(options.header_fmt, menuobj.title);
if(options.titles.trimRight() != '') if(options.titles.trimRight() != '')
write(options.titles); write(options.titles);
...@@ -760,8 +770,8 @@ function external_menu_custom(menuid) ...@@ -760,8 +770,8 @@ function external_menu_custom(menuid)
if (selected_index == j) { if (selected_index == j) {
if (menuitemsfiltered[j].type == 'quit') { if (menuitemsfiltered[j].type == 'quit') {
printf(multicolumn ? return_multicolumn_fmt_inverse : return_singlecolumn_fmt_inverse, printf(multicolumn ? return_multicolumn_fmt_inverse : return_singlecolumn_fmt_inverse,
menuitemsfiltered[i].input.toString().toUpperCase(), menuitemsfiltered[j].input.toString().toUpperCase(),
menuitemsfiltered[i].title, menuitemsfiltered[j].title,
'' ''
); );
} else { } else {
...@@ -1066,8 +1076,18 @@ function special_menu(menutype, title, itemcount) { ...@@ -1066,8 +1076,18 @@ function special_menu(menutype, title, itemcount) {
type: 'quit', type: 'quit',
}); });
// determine lines left. we can't know the size of the footer so
// let the sysop use singlecolumn_margin to specify that. Below
// calcution will always leave room for titles and underline even
// if they aren't rendered
var linesleft = console.screen_rows - console.line_counter - options.singlecolumn_margin
- 2 - 2; // -2 for header_fmt/crlf and -2 for crlf and footer
if(options.titles.trimRight() != '') linesleft = linesleft - 1;
if(options.underline.trimRight() != '') linesleft = linesleft - 2;
multicolumn = menuitemsfiltered.length > linesleft;
// if no custom menu file in text/menu, create a dynamic one // if no custom menu file in text/menu, create a dynamic one
multicolumn = options.multicolumn && menuitemsfiltered.length > options.singlecolumn_height;
printf(options.header_fmt, title); printf(options.header_fmt, title);
if(options.titles.trimRight() != '') if(options.titles.trimRight() != '')
write(options.titles); write(options.titles);
...@@ -1462,8 +1482,16 @@ function search_menu(title, itemcount) { ...@@ -1462,8 +1482,16 @@ function search_menu(title, itemcount) {
type: 'quit', type: 'quit',
}); });
// if no custom menu file in text/menu, create a dynamic one // determine lines left. we can't know the size of the footer so
multicolumn = options.multicolumn && menuitemsfiltered.length > options.singlecolumn_height; // let the sysop use singlecolumn_margin to specify that. Below
// calcution will always leave room for titles and underline even
// if they aren't rendered
var linesleft = console.screen_rows - console.line_counter - options.singlecolumn_margin
- 2 - 2; // -2 for header_fmt/crlf and -2 for crlf and footer
if(options.titles.trimRight() != '') linesleft = linesleft - 1;
if(options.underline.trimRight() != '') linesleft = linesleft - 2;
multicolumn = menuitemsfiltered.length > linesleft;
if(options.titles.trimRight() != '') if(options.titles.trimRight() != '')
write(options.titles); write(options.titles);
...@@ -1826,8 +1854,17 @@ function favorites_menu(title, itemcount) { ...@@ -1826,8 +1854,17 @@ function favorites_menu(title, itemcount) {
type: 'remove' type: 'remove'
}); });
// if no custom menu file in text/menu, create a dynamic one // determine lines left. we can't know the size of the footer so
multicolumn = options.multicolumn && menuitemsfiltered.length > options.singlecolumn_height; // let the sysop use singlecolumn_margin to specify that. Below
// calcution will always leave room for titles and underline even
// if they aren't rendered
var linesleft = console.screen_rows - console.line_counter - options.singlecolumn_margin
- 2 - 2; // -2 for header_fmt/crlf and -2 for crlf and footer
if(options.titles.trimRight() != '') linesleft = linesleft - 1;
if(options.underline.trimRight() != '') linesleft = linesleft - 2;
multicolumn = menuitemsfiltered.length > linesleft;
printf(options.header_fmt, title); printf(options.header_fmt, title);
if(options.titles.trimRight() != '') if(options.titles.trimRight() != '')
write(options.titles); write(options.titles);
......
...@@ -349,11 +349,11 @@ var editItem = function(menuid, itemindex) { ...@@ -349,11 +349,11 @@ var editItem = function(menuid, itemindex) {
// new item // new item
// //
menu.items.push({ menu.items.push({
"input": null, input: null,
"title": "New Item " + time(), title: null,
"type": null, type: null,
"target": null, target: null,
"access_string": null, access_string: null,
}); });
itemindex = menu.items.length - 1; itemindex = menu.items.length - 1;
present_select_targettype(menu.items[itemindex]); present_select_targettype(menu.items[itemindex]);
...@@ -551,7 +551,7 @@ function present_select_targettype(item) ...@@ -551,7 +551,7 @@ function present_select_targettype(item)
+ "search is a special menu item to perform a search" + "search is a special menu item to perform a search"
+ "favorites is a special menu to let the user pick favorite games to play", 72); + "favorites is a special menu to let the user pick favorite games to play", 72);
var targetypectx = uifc.list.CTX(0, 0, 0, 0, 0); // for existing items, set the popup to the correct value
if (typeof item.type !== "undefined") { if (typeof item.type !== "undefined") {
switch (item.type) { switch (item.type) {
case 'custommenu': case 'custommenu':
...@@ -658,8 +658,6 @@ function present_select_target(item) ...@@ -658,8 +658,6 @@ function present_select_target(item)
uifc.help_text = word_wrap("This is the ID of the custom menu, external program section, or external program to link to. " uifc.help_text = word_wrap("This is the ID of the custom menu, external program section, or external program to link to. "
+ "For special menus (recentall, etc.), it is the number of items to display.", 72); + "For special menus (recentall, etc.), it is the number of items to display.", 72);
var targetctx = uifc.list.CTX(0, 0, 0, 0, 0);
var custommenuitems = []; var custommenuitems = [];
var custommenuitemsids = []; var custommenuitemsids = [];
var custommenunames = []; var custommenunames = [];
...@@ -678,23 +676,31 @@ function present_select_target(item) ...@@ -678,23 +676,31 @@ function present_select_target(item)
if ((typeof item.target !== "undefined") && item.target) { if ((typeof item.target !== "undefined") && item.target) {
for (var p in custommenuitemsids) { for (var p in custommenuitemsids) {
if (custommenuitemsids[p] == item.target) { if (custommenuitemsids[p] == item.target) {
targetctx.cur = p; targetctxmenu.cur = p;
targetctx.bar = p; targetctxmenu.bar = p;
} }
} }
} }
selection2 = uifc.list(WIN_ORG | WIN_MID | WIN_SAV, "Target", custommenuitems, targetctx); selection2 = uifc.list(WIN_ORG | WIN_MID | WIN_SAV, "Target", custommenuitems, targetctxmenu);
if ((selection2 < 0) || (selection2 == null)) { if ((selection2 < 0) || (selection2 == null)) {
// escape key // escape key
break; break;
} }
// increment counter for rapid bulk adding
if (targetctxmenu.cur < custommenuitemsids.length) {
++targetctxmenu.cur;
++targetctxmenu.bar;
}
item.target = custommenuitemsids[selection2]; item.target = custommenuitemsids[selection2];
while(1) { while(1) {
if (uifc.list(WIN_ORG | WIN_MID, "Replace item title with sections's name?", ["Yes", "No"]) == 0) { if ((item.title !== null) && uifc.list(WIN_ORG | WIN_MID, "Replace item title with menus's name?", ["Yes", "No"]) == 0) {
item.title = custommenunames[selection2]; // for external program, change title to program name item.title = custommenunames[selection2]; // for external program, change title to program name
} else if (item.title === null) {
item.title = custommenunames[selection2];
} }
break; break;
} }
...@@ -717,23 +723,31 @@ function present_select_target(item) ...@@ -717,23 +723,31 @@ function present_select_target(item)
if ((typeof item.target !== "undefined") && item.target) { if ((typeof item.target !== "undefined") && item.target) {
for (var p in custommenuitemsids) { for (var p in custommenuitemsids) {
if (custommenuitemsids[p].toLowerCase() == item.target.toLowerCase()) { if (custommenuitemsids[p].toLowerCase() == item.target.toLowerCase()) {
targetctx.cur = p; targetctxsection.cur = p;
targetctx.bar = p; targetctxsection.bar = p;
} }
} }
} }
selection2 = uifc.list(WIN_ORG | WIN_MID | WIN_SAV, "Target", custommenuitems, targetctx); selection2 = uifc.list(WIN_ORG | WIN_MID | WIN_SAV, "Target", custommenuitems, targetctxsection);
if ((selection2 < 0) || (selection2 == null)) { if ((selection2 < 0) || (selection2 == null)) {
// escape key // escape key
break; break;
} }
// increment counter for rapid bulk adding
if (targetctxsection.cur < custommenuitemsids.length) {
++targetctxsection.cur;
++targetctxsection.bar;
}
item.target = custommenuitemsids[selection2]; item.target = custommenuitemsids[selection2];
while(1) { while(1) {
if (uifc.list(WIN_ORG | WIN_MID, "Replace item title with sections's name?", ["Yes", "No"]) == 0) { if ((item.title !== null) && uifc.list(WIN_ORG | WIN_MID, "Replace item title with sections's name?", ["Yes", "No"]) == 0) {
item.title = custommenunames[selection2]; // for external program, change title to program name item.title = custommenunames[selection2]; // for external program, change title to program name
} else if (item.title === null) {
item.title = custommenunames[selection2];
} }
break; break;
} }
...@@ -757,22 +771,31 @@ function present_select_target(item) ...@@ -757,22 +771,31 @@ function present_select_target(item)
if ((typeof item.target !== "undefined") && item.target) { if ((typeof item.target !== "undefined") && item.target) {
for (var p in custommenuitemsids) { for (var p in custommenuitemsids) {
if (custommenuitemsids[p].toLowerCase() == item.target.toLowerCase()) { if (custommenuitemsids[p].toLowerCase() == item.target.toLowerCase()) {
targetctx.cur = p; targetctxprog.cur = p;
targetctx.bar = p; targetctxprog.bar = p;
} }
} }
} }
selection2 = uifc.list(WIN_ORG | WIN_MID | WIN_SAV, "Target", custommenuitems, targetctx); selection2 = uifc.list(WIN_ORG | WIN_MID | WIN_SAV, "Target", custommenuitems, targetctxprog);
if ((selection2 < 0) || (selection2 == null)) { if ((selection2 < 0) || (selection2 == null)) {
// escape key // escape key
break; break;
} }
// increment counter for rapid bulk adding
if (targetctxprog.cur < custommenuitemsids.length) {
++targetctxprog.cur;
++targetctxprog.bar;
}
if (selection2 || selection2 === 0) { if (selection2 || selection2 === 0) {
item.target = custommenuitemsids[selection2]; item.target = custommenuitemsids[selection2];
while(1) { while(1) {
if (uifc.list(WIN_ORG | WIN_MID, "Replace item title with sections's name?", ["Yes", "No"]) == 0) { if ((item.title !== null) && uifc.list(WIN_ORG | WIN_MID, "Replace item title with programs's name?", ["Yes", "No"]) == 0) {
item.title = custommenunames[selection2]; // for external program, change title to program name item.title = custommenunames[selection2]; // for external program, change title to program name
} else if (item.title === null) {
item.title = custommenunames[selection2];
} }
break; break;
} }
...@@ -843,6 +866,13 @@ try { ...@@ -843,6 +866,13 @@ try {
var menuconfig = {}; var menuconfig = {};
var copyitem = {}; // for menu item copy/paste var copyitem = {}; // for menu item copy/paste
var config_file = new File(file_cfgname(system.ctrl_dir, "xtrnmenu.cfg")); var config_file = new File(file_cfgname(system.ctrl_dir, "xtrnmenu.cfg"));
// this is made to persist so that if adding multiple items, it will
// remember the position of the target type (good for bulk adds)
var targetypectx = uifc.list.CTX(0, 0, 0, 0, 0);
var targetctxmenu = uifc.list.CTX(0, 0, 0, 0, 0);
var targetctxsection = uifc.list.CTX(0, 0, 0, 0, 0);
var targetctxprog = uifc.list.CTX(0, 0, 0, 0, 0);
if (config_file.open('r+')) { if (config_file.open('r+')) {
var config_src = config_file.read(); var config_src = config_file.read();
try { try {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment