From 782cae6ba3de5801400cf28dcc4cdbaeea4304cd Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sun, 3 Sep 2017 20:45:00 -0600 Subject: [PATCH] File Base: Browse by area --- core/client_term.js | 1 + mods/file_base_area_select.js | 84 +++++++++++++++ mods/menu.hjson | 198 +++++++++++++++++++++++++++++++++- 3 files changed, 282 insertions(+), 1 deletion(-) create mode 100644 mods/file_base_area_select.js diff --git a/core/client_term.js b/core/client_term.js index 75831a96..9992f9f3 100644 --- a/core/client_term.js +++ b/core/client_term.js @@ -185,3 +185,4 @@ ClientTerminal.prototype.encode = function(s, convertLineFeeds) { return iconv.encode(s, this.outputEncoding); }; + diff --git a/mods/file_base_area_select.js b/mods/file_base_area_select.js new file mode 100644 index 00000000..5eef583b --- /dev/null +++ b/mods/file_base_area_select.js @@ -0,0 +1,84 @@ +/* jslint node: true */ +'use strict'; + +// enigma-bbs +const MenuModule = require('../core/menu_module.js').MenuModule; +const Config = require('../core/config.js').config; +const stringFormat = require('../core/string_format.js'); +const ViewController = require('../core/view_controller.js').ViewController; +const getSortedAvailableFileAreas = require('../core/file_base_area.js').getSortedAvailableFileAreas; + +// deps +const async = require('async'); +const _ = require('lodash'); + +exports.moduleInfo = { + name : 'File Area Selector', + desc : 'Select from available file areas', + author : 'NuSkooler', +}; + +const MciViewIds = { + areaList : 1, +}; + +exports.getModule = class FileAreaSelectModule extends MenuModule { + constructor(options) { + super(options); + + this.config = this.menuConfig.config || {}; + + this.loadAvailAreas(); + + this.menuMethods = { + selectArea : (formData, extraArgs, cb) => { + const area = this.availAreas[formData.value.areaSelect] || 0; + + const filterCriteria = { + areaTag : area.areaTag, + }; + + const menuOpts = { + extraArgs : { + filterCriteria : filterCriteria, + }, + menuFlags : [ 'noHistory' ], + }; + + return this.gotoMenu(this.menuConfig.config.fileBaseListEntriesMenu || 'fileBaseListEntries', menuOpts, cb); + } + }; + } + + loadAvailAreas() { + this.availAreas = getSortedAvailableFileAreas(this.client); + } + + mciReady(mciData, cb) { + super.mciReady(mciData, err => { + if(err) { + return cb(err); + } + + this.prepViewController('allViews', 0, { mciMap : mciData.menu }, (err, vc) => { + if(err) { + return cb(err); + } + + const areaListView = vc.getView(MciViewIds.areaList); + + const areaListFormat = this.config.areaListFormat || '{name}'; + + areaListView.setItems(this.availAreas.map(a => stringFormat(areaListFormat, a) ) ); + + if(this.config.areaListFocusFormat) { + areaListView.setFocusItems(this.availAreas.map(a => stringFormat(this.config.areaListFocusFormat, a) ) ); + } + + areaListView.redraw(); + + return cb(null); + }); + }); + } +}; diff --git a/mods/menu.hjson b/mods/menu.hjson index 803970d4..d1822cfc 100644 --- a/mods/menu.hjson +++ b/mods/menu.hjson @@ -761,6 +761,166 @@ } } + newScanFileBaseList: { + module: file_area_list + desc: New Files + config: { + art: { + browse: FNEWBRWSE + details: FDETAIL + detailsGeneral: FDETGEN + detailsNfo: FDETNFO + detailsFileList: FDETLST + help: FBHELP + } + } + form: { + 0: { + mci: { + MT1: { + mode: preview + ansiView: true + } + + HM2: { + focus: true + submit: true + argName: navSelect + items: [ + "prev", "next", "details", "toggle queue", "rate", "help", "quit" + ] + focusItemIndex: 1 + } + + // :TODO: these can be removed once the hack is not required: + TL10: {} + TL11: {} + TL12: {} + TL13: {} + TL14: {} + TL15: {} + TL16: {} + TL17: {} + TL18: {} + } + + submit: { + *: [ + { + value: { navSelect: 0 } + action: @method:prevFile + } + { + value: { navSelect: 1 } + action: @method:nextFile + } + { + value: { navSelect: 2 } + action: @method:viewDetails + } + { + value: { navSelect: 3 } + action: @method:toggleQueue + } + { + value: { navSelect: 4 } + action: @menu:fileBaseGetRatingForSelectedEntry + } + { + value: { navSelect: 5 } + action: @method:displayHelp + } + { + value: { navSelect: 6 } + action: @systemMethod:prevMenu + } + ] + } + + actionKeys: [ + { + keys: [ "w", "shift + w" ] + action: @method:showWebDownloadLink + } + { + keys: [ "escape", "q", "shift + q" ] + action: @systemMethod:prevMenu + } + { + keys: [ "t", "shift + t" ] + action: @method:toggleQueue + } + { + keys: [ "v", "shift + v" ] + action: @method:viewDetails + } + { + keys: [ "r", "shift + r" ] + action: @menu:fileBaseGetRatingForSelectedEntry + } + { + keys: [ "?" ] + action: @method:displayHelp + } + ] + } + + 1: { + mci: { + HM1: { + focus: true + submit: true + argName: navSelect + items: [ + "general", "nfo/readme", "file listing" + ] + } + + // :TODO: these can be removed once the hack is not required: + TL10: {} + TL11: {} + TL12: {} + TL13: {} + TL14: {} + TL15: {} + TL16: {} + TL17: {} + TL18: {} + } + + actionKeys: [ + { + keys: [ "escape", "q", "shift + q" ] + action: @method:detailsQuit + } + ] + } + + 2: { + // details - general + mci: {} + } + + 3: { + // details - nfo/readme + mci: { + MT1: { + mode: preview + } + } + } + + 4: { + // details - file listing + mci: { + VM1: { + + } + } + } + } + } + /////////////////////////////////////////////////////////////////////// // Main Menu /////////////////////////////////////////////////////////////////////// @@ -2312,9 +2472,13 @@ prompt: fileMenuCommand submit: [ { - value: { menuOption: "B" } + value: { menuOption: "L" } action: @menu:fileBaseListEntries } + { + value: { menuOption: "B" } + action: @menu:fileBaseBrowseByAreaSelect + } { value: { menuOption: "F" } action: @menu:fileAreaFilterEditor @@ -2509,6 +2673,38 @@ } } + fileBaseBrowseByAreaSelect: { + desc: Browsing File Areas + module: file_base_area_select + art: FAREASEL + form: { + 0: { + mci: { + VM1: { + focus: true + argName: areaSelect + } + } + + submit: { + *: [ + { + value: { areaSelect: null } + action: @method:selectArea + } + ] + } + + actionKeys: [ + { + keys: [ "escape" ] + action: @systemMethod:prevMenu + } + ] + } + } + } + fileBaseGetRatingForSelectedEntry: { desc: Rating a File prompt: fileBaseRateEntryPrompt