Commit d322c5e1 authored by Michael Long's avatar Michael Long
Browse files

Add favorites menu, fix bugs

parent 4249b01e
......@@ -29,7 +29,7 @@ singlecolumn_fmt: \1h\1c%3s \xb3 \1n\1c%s \1h
;underline: \1c\1h\xc4\xc4\xc4\xc4\xc5\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4
; used by the lightbar
multicolumn_fmt_inverse: \1n\1w[\1y\1h%2s\1n\1w] \1n\1w\1h\x015%-32.32s \1n\1h
singlecolumn_fmt_inverse: \1n\1w[\1y\1h%2s\1n\1w] \1n\1w\1h\x015%-32.32s \1n\1h
singlecolumn_fmt_inverse: \1n\1w[\1y\1h%2s\1n\1w] \1n\1w\1h\x015%s \1n\1h
; to enable cost display, use these instead
; Note: cost not supported in special menus
......@@ -78,9 +78,9 @@ return_singlecolumn_fmt: \1h\1c%3s \xb3 \1n\1c%s \1h
return_multicolumn_fmt_inverse: \1h\1c%3s \xb3 \1n\x016\1w\1h%-32.32s \1n\1h
return_singlecolumn_fmt_inverse: \1h\1c%3s \xb3 \1n\x016\1w\1h%s \1n\1h
return_multicolumn_special_fmt: \1h\1c%3s \xb3 \1m%-32.32s\1h
return_singlecolumn_special_fmt: \1h\1c%3s \xb3 \1m%-32.32s\1h
return_singlecolumn_special_fmt: \1h\1c%3s \xb3 \1m%s\1h
return_multicolumn_special_fmt_inverse: \1h\1c%3s \xb3 \x015\1w\1h%-32.32s\1n
return_singlecolumn_special_fmt_inverse: \1h\1c%3s \xb3 \x015\1w\1h%-32.32s\1n
return_singlecolumn_special_fmt_inverse: \1h\1c%3s \xb3 \x015\1w\1h%s\1n
; Change display of filearea command menu
;xfer_prompt: "\x01n\x01c\xfe \x01b\x01hFile \x01n\x01c\xfe \x01h"
......@@ -99,4 +99,11 @@ searchagainmsg: "\x01n\x01mPress S to Search Again."
; Feedback Module
;feedback_subject: "Game Server Feedback\r\n"
;feedback_msg: Thank you for your Feedback, @SYSOP@ will get back to you ASAP!\r\n\r\n
\ No newline at end of file
;feedback_msg: Thank you for your Feedback, @SYSOP@ will get back to you ASAP!\r\n\r\n
; Favorites Module
;favorite_add_item: "Add Item"
;favorte_remove_item: "Remove Item"
;add_favorites_msg: "\x01c\x01hAdd Favorite"
;remove_favorites_msg: "\x01c\x01hRemove Favorite"
;custom.favorites_inst: "\x01n\x01w\x01h\x012[Up/Down/Home/End] to Navigate, [Enter] to Select, [Q] to Quit"
......@@ -480,7 +480,7 @@ ExternalMenus.prototype.getSpecial = function(menutype, title, itemcount) {
var jsonClient = new JSONClient(this.options.json_host, this.options.json_port);
jsonClient.callback = processUpdate;
} catch (e) {
log(LOG_ERR, "xtrnmenulib: Could not initialize JSON database so door tracking is now disabled: " + e);
log(LOG_ERR, "xtrnmenulib: Could not initialize JSON database so special menu is now disabled: " + e);
return false;
}
......@@ -584,5 +584,68 @@ ExternalMenus.prototype.getSpecial = function(menutype, title, itemcount) {
};
}
return menu;
}
// return menu object for user's favorites
ExternalMenus.prototype.getFavorites = function(title, itemcount) {
var menu;
var menuitems = [];
if (itemcount === undefined) {
itemcount = 0;
}
if (!this.options.json_enabled) {
log(LOG_DEBUG, "xtrnmenulib: Skipping favorites because JSON is not enabled");
return false;
}
try {
load("json-client.js")
var jsonClient = new JSONClient(this.options.json_host, this.options.json_port);
jsonClient.callback = processUpdate;
} catch (e) {
log(LOG_ERR, "xtrnmenulib: Could not initialize JSON database so favorites is now disabled: " + e);
return false;
}
var sortedItems = [];
var jsonData = jsonClient.read("xtrnmenu", "favorites_" + user.alias, 1);
if (!jsonData) {
jsonData = {};
}
var i = 1;
for (var d=0; d<jsonData.length; d++) {
for (var e in xtrn_area.prog) {
if (xtrn_area.prog[e].code.toLowerCase() == jsonData[d].toLowerCase()) {
var stats;
menuitems.push({
'input': i,
'target': xtrn_area.prog[e].code,
'title': xtrn_area.prog[e].name,
'type': 'xtrnprog',
'access_string': xtrn_area.prog[e].ars,
'cost': xtrn_area.prog[e].cost,
});
i++;
break;
}
}
if ((itemcount > 0) && ((d + 1) >= itemcount)) {
break;
}
}
menu = {
'id': 'favorites',
'title': title,
'items': menuitems,
};
return menu;
}
\ No newline at end of file
This diff is collapsed.
......@@ -201,25 +201,13 @@ var editItems = function(menuid) {
itemids = [];
for(i in menu.items) {
items.push(format(
"%6s %10s %s",
"%6s %16s %s",
menu.items[i].input ? menu.items[i].input : '(auto)',
menu.items[i].type,
menu.items[i].title
));
itemids.push(i);
}
// WIN_ORG = original menu
// WIN_MID = centered mid
// WIN_ACT = menu remains active after a selection
// WIN_ESC = screen is active when escape is pressed
// WIN_XTR = blank line to insert
// WIN_INS = insert key
// WIN_DEL = delete
// WIN_CUT = cut ctrl-x
// WIN_COPY = copy ctrl-c
// WIN_PASTE = paste ctrl-v
// WIN_PASTEXTR = allow paste on new line
// WIN_SAV = use context/save position
selection = uifc.list(
WIN_ORG|WIN_MID|WIN_ACT|WIN_ESC|WIN_XTR|WIN_INS|WIN_DEL|WIN_CUT|WIN_COPY|WIN_PASTE|WIN_PASTEXTR|WIN_SAV,
menu.title + ": Items",
......@@ -307,14 +295,14 @@ var editItems = function(menuid) {
var menuitems2 = [];
var pushed = false;
for (i in menu.items) {
menuitems2.push(menu.items[i]);
// paste copied item after selected item
// paste copied item before selected item
if (i == itemids[selection]) {
menuitems2.push(copyitem);
ctxm.cur = i-1;
pushed = true;
}
}
menuitems2.push(menu.items[i]);
}
if (!pushed) {
// add to end
menuitems2.push(copyitem);
......@@ -398,6 +386,7 @@ var editItem = function(menuid, itemindex) {
case 'longestrunall':
case 'longestrunuser':
case 'search':
case 'favorites':
displayoptions.push(format("%23s: %s", "count",
("target" in item ? item.target : "")));
displayoptionids.push("target");
......@@ -423,6 +412,7 @@ var editItem = function(menuid, itemindex) {
case 'longestrunuser':
case 'longestrunall':
case 'search':
case 'favorites':
displayoptions.push(format("%23s: %s", "access_string",
("access_string" in item ? item.access_string : "(default)")));
displayoptionids.push("access_string");
......@@ -558,7 +548,8 @@ function present_select_targettype(item)
+ "mostlauncheduser is a special menu of most launched games, for current user"
+ "longestrunall is a special menu of games that users spent the most time in"
+ "longestrunuser is a special menu of games that current user spent the most time in"
+ "search is a special menu item to perform a search", 72);
+ "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);
var targetypectx = uifc.list.CTX(0, 0, 0, 0, 0);
if (typeof item.type !== "undefined") {
......@@ -607,12 +598,16 @@ function present_select_targettype(item)
targetypectx.cur = 10;
targetypectx.bar = 10;
break;
case 'favorites':
targetypectx.cur = 11;
targetypectx.bar = 11;
break;
}
}
switch (uifc.list(WIN_ORG | WIN_MID | WIN_SAV,
"Target Type", ["custommenu", "xtrnmenu", "xtrnprog", "command", "recentall",
"recentuser", "mostlaunchedall", "mostlauncheduser", "longestrunall",
"longestrunuser", "search"], targetypectx)) {
"longestrunuser", "search", "favorites"], targetypectx)) {
case 0:
item.type = "custommenu";
break;
......@@ -646,6 +641,9 @@ function present_select_targettype(item)
case 10:
item.type = "search";
break;
case 11:
item.type = "favorites";
break;
default:
// includes escape key
break;
......@@ -797,6 +795,7 @@ function present_select_target(item)
case "longestrunall":
case "longestrunuser":
case "search":
case "favorites":
selection2 = uifc.input(WIN_ORG | WIN_MID, "Number of Items to Display", item.target, 63, K_EDIT);
if ((selection2 < 0) || (selection2 == null)) {
// escape key
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment