mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 17:43:48 +01:00
more panels!
This commit is contained in:
parent
69dfbb6673
commit
26401fbb93
106
src/Gang.jsx
106
src/Gang.jsx
@ -51,6 +51,7 @@ import { GangMemberTask } from "./Gang/GangMemberTask";
|
|||||||
|
|
||||||
import { Panel1 } from "./Gang/ui/Panel1";
|
import { Panel1 } from "./Gang/ui/Panel1";
|
||||||
import { Panel2 } from "./Gang/ui/Panel2";
|
import { Panel2 } from "./Gang/ui/Panel2";
|
||||||
|
import { Panel3 } from "./Gang/ui/Panel3";
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import ReactDOM from "react-dom";
|
import ReactDOM from "react-dom";
|
||||||
@ -1140,6 +1141,9 @@ export function unmount() {
|
|||||||
if(UIElems.gangMemberPanels[name]["taskDiv"]) {
|
if(UIElems.gangMemberPanels[name]["taskDiv"]) {
|
||||||
ReactDOM.unmountComponentAtNode(UIElems.gangMemberPanels[name]["taskDiv"]);
|
ReactDOM.unmountComponentAtNode(UIElems.gangMemberPanels[name]["taskDiv"]);
|
||||||
}
|
}
|
||||||
|
if(UIElems.gangMemberPanels[name]["taskDescDiv"]) {
|
||||||
|
ReactDOM.unmountComponentAtNode(UIElems.gangMemberPanels[name]["taskDescDiv"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1619,16 +1623,12 @@ Gang.prototype.updateGangContent = function() {
|
|||||||
UIElems.gangRecruitRequirementText.style.display = "inline-block";
|
UIElems.gangRecruitRequirementText.style.display = "inline-block";
|
||||||
UIElems.gangRecruitRequirementText.innerHTML = `${formatNumber(respectCost, 2)} respect needed to recruit next member`;
|
UIElems.gangRecruitRequirementText.innerHTML = `${formatNumber(respectCost, 2)} respect needed to recruit next member`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update information for each gang member
|
|
||||||
for (let i = 0; i < this.members.length; ++i) {
|
|
||||||
this.updateGangMemberDisplayElement(this.members[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Takes in a GangMember object
|
// Takes in a GangMember object
|
||||||
Gang.prototype.createGangMemberDisplayElement = function(memberObj) {
|
Gang.prototype.createGangMemberDisplayElement = function(memberObj) {
|
||||||
|
// TODO(hydroflame): you're working on this.
|
||||||
if (!UIElems.gangContentCreated) { return; }
|
if (!UIElems.gangContentCreated) { return; }
|
||||||
const name = memberObj.name;
|
const name = memberObj.name;
|
||||||
|
|
||||||
@ -1667,101 +1667,23 @@ Gang.prototype.createGangMemberDisplayElement = function(memberObj) {
|
|||||||
UIElems.gangMemberPanels[name]["taskDiv"] = taskDiv;
|
UIElems.gangMemberPanels[name]["taskDiv"] = taskDiv;
|
||||||
ReactDOM.render(<Panel2 gang={this} member={memberObj} />, taskDiv);
|
ReactDOM.render(<Panel2 gang={this} member={memberObj} />, taskDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// const taskSelector = createElement("select", {
|
|
||||||
// class: "dropdown",
|
|
||||||
// id: name + "gang-member-task-selector",
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // Get an array of the name of all tasks that are applicable for this Gang
|
|
||||||
// let tasks = this.getAllTaskNames();
|
|
||||||
// tasks.unshift("---");
|
|
||||||
|
|
||||||
// // Create selector for Gang member task
|
|
||||||
// for (var i = 0; i < tasks.length; ++i) {
|
|
||||||
// var option = document.createElement("option");
|
|
||||||
// option.text = tasks[i];
|
|
||||||
// taskSelector.add(option);
|
|
||||||
// }
|
|
||||||
// taskSelector.addEventListener("change", () => {
|
|
||||||
// var task = taskSelector.options[taskSelector.selectedIndex].text;
|
|
||||||
// memberObj.assignToTask(task);
|
|
||||||
// this.setGangMemberTaskDescription(memberObj, task);
|
|
||||||
// this.updateGangContent();
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // Set initial task in selector
|
|
||||||
|
|
||||||
// var gainInfo = createElement("div", {id:name + "gang-member-gain-info"});
|
|
||||||
// taskDiv.appendChild(taskSelector);
|
|
||||||
// taskDiv.appendChild(gainInfo);
|
|
||||||
|
|
||||||
// Panel 3 - for Description of task
|
// Panel 3 - for Description of task
|
||||||
var taskDescDiv = createElement("div", {
|
let taskDescDiv = document.getElementById(name + "-gang-member-task-description");
|
||||||
class:"gang-member-info-div",
|
if(!taskDescDiv) {
|
||||||
id: name + "gang-member-task-desc",
|
taskDescDiv = createElement("div", {
|
||||||
});
|
class:"gang-member-info-div",
|
||||||
|
id: name + "gang-member-task-desc",
|
||||||
var taskDescP = createElement("p", {
|
});
|
||||||
display:"inline",
|
UIElems.gangMemberPanels[name]["taskDescDiv"] = taskDescDiv;
|
||||||
id: name + "gang-member-task-description",
|
ReactDOM.render(<Panel3 member={memberObj} />, taskDescDiv);
|
||||||
});
|
}
|
||||||
taskDescDiv.appendChild(taskDescP);
|
|
||||||
|
|
||||||
gangMemberDiv.appendChild(statsDiv);
|
gangMemberDiv.appendChild(statsDiv);
|
||||||
gangMemberDiv.appendChild(taskDiv);
|
gangMemberDiv.appendChild(taskDiv);
|
||||||
gangMemberDiv.appendChild(taskDescDiv);
|
gangMemberDiv.appendChild(taskDescDiv);
|
||||||
|
|
||||||
UIElems.gangMemberList.appendChild(li);
|
UIElems.gangMemberList.appendChild(li);
|
||||||
this.setGangMemberTaskDescription(memberObj, memberObj.task); //Initialize description, TODO doesnt work rn
|
|
||||||
this.updateGangMemberDisplayElement(memberObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
Gang.prototype.updateGangMemberDisplayElement = function(memberObj) {
|
|
||||||
if (!UIElems.gangContentCreated) { return; }
|
|
||||||
var name = memberObj.name;
|
|
||||||
|
|
||||||
// Update info about gang member's earnings/gains
|
|
||||||
var gainInfo = document.getElementById(name + "gang-member-gain-info");
|
|
||||||
if (gainInfo) {
|
|
||||||
const data = [
|
|
||||||
[`Money:`, MoneyRate(5*memberObj.calculateMoneyGain(this))],
|
|
||||||
[`Respect:`, `${numeralWrapper.formatRespect(5*memberObj.calculateRespectGain(this))} / sec`],
|
|
||||||
[`Wanted Level:`, `${numeralWrapper.formatWanted(5*memberObj.calculateWantedLevelGain(this))} / sec`],
|
|
||||||
[`Total Respect:`, `${numeralWrapper.formatRespect(memberObj.earnedRespect)}`],
|
|
||||||
];
|
|
||||||
ReactDOM.render(StatsTable(data), gainInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update selector to have the correct task
|
|
||||||
const taskSelector = document.getElementById(name + "gang-member-task-selector");
|
|
||||||
if (taskSelector) {
|
|
||||||
let tasks = this.getAllTaskNames();
|
|
||||||
tasks.unshift("---");
|
|
||||||
|
|
||||||
if (GangMemberTasks.hasOwnProperty(memberObj.task)) {
|
|
||||||
const taskName = memberObj.task;
|
|
||||||
let taskIndex = 0;
|
|
||||||
for (let i = 0; i < tasks.length; ++i) {
|
|
||||||
if (taskName === tasks[i]) {
|
|
||||||
taskIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
taskSelector.selectedIndex = taskIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Gang.prototype.setGangMemberTaskDescription = function(memberObj, taskName) {
|
|
||||||
const name = memberObj.name;
|
|
||||||
const taskDesc = document.getElementById(name + "gang-member-task-description");
|
|
||||||
if (taskDesc) {
|
|
||||||
var task = GangMemberTasks[taskName];
|
|
||||||
if (task == null) { task = GangMemberTasks["Unassigned"]; }
|
|
||||||
var desc = task.desc;
|
|
||||||
taskDesc.innerHTML = desc;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Gang.prototype.clearUI = function() {
|
Gang.prototype.clearUI = function() {
|
||||||
|
@ -13,14 +13,13 @@ export function Panel2(props: IProps): React.ReactElement {
|
|||||||
const [currentTask, setCurrentTask] = useState(props.member.task);
|
const [currentTask, setCurrentTask] = useState(props.member.task);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const id = setInterval(() => {setRerender(old => !old); console.log('rendering');}, 1000);
|
const id = setInterval(() => setRerender(old => !old), 1000);
|
||||||
return () => clearInterval(id);
|
return () => clearInterval(id);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
function onChange(event: React.ChangeEvent<HTMLSelectElement>): void {
|
function onChange(event: React.ChangeEvent<HTMLSelectElement>): void {
|
||||||
const task = event.target.value;
|
const task = event.target.value;
|
||||||
props.member.assignToTask(task);
|
props.member.assignToTask(task);
|
||||||
props.gang.setGangMemberTaskDescription(props.member, task);
|
|
||||||
props.gang.updateGangContent();
|
props.gang.updateGangContent();
|
||||||
setCurrentTask(task);
|
setCurrentTask(task);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { GangMemberTasks } from "../GangMemberTasks";
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
member: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Panel3(props: IProps): React.ReactElement {
|
||||||
|
const [rerender, setRerender] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const id = setInterval(() => setRerender(old => !old), 1000);
|
||||||
|
return () => clearInterval(id);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const task = GangMemberTasks[props.member.task];
|
||||||
|
const desc = task ? task.desc: GangMemberTasks["Unassigned"].desc;
|
||||||
|
|
||||||
|
return (<>
|
||||||
|
<p className="inline"
|
||||||
|
id={`${props.member.name}-gang-member-task-description`}
|
||||||
|
dangerouslySetInnerHTML={{__html: desc}}>
|
||||||
|
</p>
|
||||||
|
</>);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user