Fix GH Issue #632: 'Create Program' link visibility should now be properly dynamically evaluated

This commit is contained in:
danielyxie 2019-07-01 21:15:11 -07:00
parent 44bf3cb101
commit 658df9fb01
3 changed files with 4 additions and 2 deletions

@ -30,6 +30,7 @@ export interface IPlayer {
corporation: any; corporation: any;
currentServer: string; currentServer: string;
factions: string[]; factions: string[];
firstProgramAvailable: boolean;
firstTimeTraveled: boolean; firstTimeTraveled: boolean;
hacknetNodes: (HacknetNode | string)[]; // HacknetNode object or IP of Hacknet Server hacknetNodes: (HacknetNode | string)[]; // HacknetNode object or IP of Hacknet Server
has4SData: boolean; has4SData: boolean;

@ -41,7 +41,6 @@ function getNumAvailableCreateProgram() {
if (Player.firstProgramAvailable === false && count > 0) { if (Player.firstProgramAvailable === false && count > 0) {
Player.firstProgramAvailable = true; Player.firstProgramAvailable = true;
document.getElementById("create-program-tab").style.display = "list-item";
document.getElementById("hacking-menu-header").click(); document.getElementById("hacking-menu-header").click();
document.getElementById("hacking-menu-header").click(); document.getElementById("hacking-menu-header").click();
} }

@ -66,6 +66,8 @@ export function initializeMainMenuHeaders(p: IPlayer, dev: boolean=false): boole
const createProgram: HTMLElement = safeGetElement("create-program-tab"); const createProgram: HTMLElement = safeGetElement("create-program-tab");
const createProgramNot: HTMLElement = safeGetElement("create-program-notification"); const createProgramNot: HTMLElement = safeGetElement("create-program-notification");
createProgram.style.display = p.firstProgramAvailable ? "list-item" : "none";
this.classList.toggle("opened"); this.classList.toggle("opened");
const elems: HTMLElement[] = [terminal, createScript, activeScripts, createProgram]; const elems: HTMLElement[] = [terminal, createScript, activeScripts, createProgram];