Augmentation Order (for both purchasing & viewing owned) is now saved as a persistent setting

This commit is contained in:
danielyxie 2018-10-26 11:42:23 -05:00
parent 5ad4dabe6c
commit f30602ce5d
5 changed files with 59 additions and 17 deletions

@ -9,6 +9,9 @@ import {prestigeAugmentation} from "./Prestige";
import {saveObject} from "./SaveObject";
import {Script, RunningScript} from "./Script";
import {Server} from "./Server";
import {OwnedAugmentationsOrderSetting} from "./SettingEnums";
import {Settings} from "./Settings";
import {SourceFiles} from "./SourceFile";
import {dialogBoxCreate} from "../utils/DialogBox";
import {createAccordionElement} from "../utils/uiHelpers/createAccordionElement";
@ -2570,7 +2573,7 @@ function displayAugmentationsContent() {
}));
//Sort Buttons
Engine.Display.augmentationsContent.appendChild(createElement("a", {
const sortInOrderButton = createElement("a", {
class:"a-link-button", fontSize:"14px", innerText:"Sort in Order",
tooltip:"Sorts the Augmentations alphabetically and Source Files in numerical order (1, 2, 3,...)",
clickListener:()=>{
@ -2587,22 +2590,31 @@ function displayAugmentationsContent() {
});
displaySourceFiles(augmentationsList, sourceFiles);
displayAugmentations(augmentationsList, augs);
}
}));
Engine.Display.augmentationsContent.appendChild(createElement("a", {
Settings.OwnedAugmentationsOrder = OwnedAugmentationsOrderSetting.Alphabetically;
}
});
Engine.Display.augmentationsContent.appendChild(sortInOrderButton);
const sortByAcquirementTimeButton = createElement("a", {
class:"a-link-button", fontSize:"14px", innerText:"Sort by Acquirement Time",
tooltip:"Sorts the Augmentations and Source Files based on when you acquired them (same as default)",
clickListener:()=>{
removeChildrenFromElement(augmentationsList);
displaySourceFiles(augmentationsList, Player.sourceFiles);
displayAugmentations(augmentationsList, Player.augmentations);
Settings.OwnedAugmentationsOrder = OwnedAugmentationsOrderSetting.AcquirementTime;
}
}));
});
Engine.Display.augmentationsContent.appendChild(sortByAcquirementTimeButton);
//Source Files - Temporary...Will probably put in a separate pane Later
displaySourceFiles(augmentationsList, Player.sourceFiles);
displayAugmentations(augmentationsList, Player.augmentations);
if (Settings.OwnedAugmentationsOrder === OwnedAugmentationsOrderSetting.Alphabetically) {
sortInOrderButton.click();
} else {
sortByAcquirementTimeButton.click();
}
Engine.Display.augmentationsContent.appendChild(augmentationsList);
}

@ -523,6 +523,7 @@ let CONSTANTS = {
* b1t_flum3.exe now takes significantly less time to create
* Crimes commited through Singularity function no longer give half money/exp
* Improved number formatting for Player 'work' actions (including crimes, etc.). These numbers should also adhere to locale settings now (by Kline-)
* The order that Augmentations are listed in (when purchasing from Faction and viewing your Augmentations) is now saved and persists when choosing different orders
* Bug Fix: Calling print() in NetscriptJS no longer brings up the print dialog
* Bug Fix: Fixed a bug that sometimes caused a blank black screen when destroying/resetting/switching BitNodes
* Bug Fix: Netscript calls that throw errors will now no longer cause the 'concurrent calls' error if they are caught in the script. i.e. try/catch should now work properly in scripts

@ -7,6 +7,7 @@ import {FactionInfos} from "./FactionInfo";
import {Locations} from "./Location";
import {HackingMission, setInMission} from "./Missions";
import {Player} from "./Player";
import {PurchaseAugmentationsOrderSetting} from "./SettingEnums";
import {Settings} from "./Settings";
import {Page, routing} from "./ui/navigationTracking";
@ -446,7 +447,6 @@ function displayFactionContent(factionName) {
}
}
var sortOption = null;
function displayFactionAugmentations(factionName) {
var faction = Factions[factionName];
if (faction == null) {
@ -481,10 +481,10 @@ function displayFactionAugmentations(factionName) {
var augmentationsList = createElement("ul");
//Sort buttons
var sortByCostBtn = createElement("a", {
const sortByCostBtn = createElement("a", {
innerText:"Sort by Cost", class:"a-link-button",
clickListener:()=>{
sortOption = "cost";
Settings.PurchaseAugmentationsOrder = PurchaseAugmentationsOrderSetting.Cost;
var augs = faction.augmentations.slice();
augs.sort((augName1, augName2)=>{
var aug1 = Augmentations[augName1], aug2 = Augmentations[augName2];
@ -497,10 +497,10 @@ function displayFactionAugmentations(factionName) {
createFactionAugmentationDisplayElements(augmentationsList, augs, faction);
}
});
var sortByRepBtn = createElement("a", {
const sortByRepBtn = createElement("a", {
innerText:"Sort by Reputation", class:"a-link-button",
clickListener:()=>{
sortOption = "reputation";
Settings.PurchaseAugmentationsOrder = PurchaseAugmentationsOrderSetting.Reputation;
var augs = faction.augmentations.slice();
augs.sort((augName1, augName2)=>{
var aug1 = Augmentations[augName1], aug2 = Augmentations[augName2];
@ -513,10 +513,10 @@ function displayFactionAugmentations(factionName) {
createFactionAugmentationDisplayElements(augmentationsList, augs, faction);
}
});
var defaultSortBtn = createElement("a", {
const defaultSortBtn = createElement("a", {
innerText:"Sort by Default Order", class:"a-link-button",
clickListener:()=>{
sortOption = "default";
Settings.PurchaseAugmentationsOrder = PurchaseAugmentationsOrderSetting.Default;
removeChildrenFromElement(augmentationsList);
createFactionAugmentationDisplayElements(augmentationsList, faction.augmentations, faction);
}
@ -524,11 +524,11 @@ function displayFactionAugmentations(factionName) {
elements.push(sortByCostBtn);
elements.push(sortByRepBtn);
elements.push(defaultSortBtn);
switch(sortOption) {
case "cost":
switch(Settings.PurchaseAugmentationsOrder) {
case PurchaseAugmentationsOrderSetting.Cost:
sortByCostBtn.click();
break;
case "reputation":
case PurchaseAugmentationsOrderSetting.Reputation:
sortByRepBtn.click();
break;
default:

16
src/SettingEnums.ts Normal file

@ -0,0 +1,16 @@
/**
* Enum Of allowed values for the 'OwnedAugmentationsOrder' setting
*/
export enum OwnedAugmentationsOrderSetting {
Alphabetically,
AcquirementTime,
}
/**
* Enum Of allowed values for the 'OwnedAugmentationsOrder' setting
*/
export enum PurchaseAugmentationsOrderSetting {
Cost,
Default,
Reputation,
}

@ -1,4 +1,5 @@
import { ISelfInitializer, ISelfLoading } from "./types";
import { OwnedAugmentationsOrderSetting, PurchaseAugmentationsOrderSetting } from "./SettingEnums";
/**
* Represents the default settings the player could customize.
@ -75,6 +76,16 @@ interface ISettings extends IDefaultSettings {
* TODO: This should really be an enum of allowed values.
*/
EditorTheme: string;
/**
* What order the player's owned Augmentations/Source Files should be displayed in
*/
OwnedAugmentationsOrder: OwnedAugmentationsOrderSetting;
/**
* What order the Augmentations should be displayed in when purchasing from a Faction
*/
PurchaseAugmentationsOrder: PurchaseAugmentationsOrderSetting;
}
const defaultSettings: IDefaultSettings = {
@ -104,6 +115,8 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = {
Locale: "en",
MaxLogCapacity: defaultSettings.MaxLogCapacity,
MaxPortCapacity: defaultSettings.MaxPortCapacity,
OwnedAugmentationsOrder: OwnedAugmentationsOrderSetting.AcquirementTime,
PurchaseAugmentationsOrder: PurchaseAugmentationsOrderSetting.Default,
SuppressBuyAugmentationConfirmation: defaultSettings.SuppressBuyAugmentationConfirmation,
SuppressFactionInvites: defaultSettings.SuppressFactionInvites,
SuppressHospitalizationPopup: defaultSettings.SuppressHospitalizationPopup,