* Hash upgrades and Bladeburner skills can now be clicked to copy to clipboard

* Aug purchase confirmation popup displays money in 0.000a format

* Character now displays hacknet server info properly

* Character,Info now displays hacknet server info correctly.

* Formulas (#825)

Formulas API v0.1

* Make all money the same color, same for reputation, format all numbers consistently.

* rename a lot of the formulas function to no longer contain calculate

* added hacking related formulas

* removed unused variable

* v0.51.0
This commit is contained in:
hydroflame
2021-03-31 00:45:21 -04:00
committed by GitHub
parent ff097db1e2
commit e572c6dad8
127 changed files with 2772 additions and 1125 deletions
+55
View File
@@ -0,0 +1,55 @@
import * as React from "react";
import { renderToStaticMarkup } from "react-dom/server"
import { getElementById } from "../../utils/uiHelpers/getElementById";
/**
* Adds some output to the terminal.
* @param input Text or HTML to output to the terminal
*/
export function post(input: string) {
postContent(input);
}
export function postError(input: string) {
postContent(`ERROR: ${input}`, { color: "#ff2929" });
}
/**
* Adds some output to the terminal with an identifier of "hack-progress-bar"
* @param input Text or HTML to output to the terminal
*/
export function hackProgressBarPost(input: string) {
postContent(input, { id: "hack-progress-bar" });
}
/**
* Adds some output to the terminal with an identifier of "hack-progress"
* @param input Text or HTML to output to the terminal
*/
export function hackProgressPost(input: string) {
postContent(input, { id: "hack-progress" });
}
interface IPostContentConfig {
id?: string; // Replaces class, if specified
color?: string; // Additional class for terminal-line. Does NOT replace
}
export function postElement(element: JSX.Element) {
postContent(renderToStaticMarkup(element));
}
export function postContent(input: string, config: IPostContentConfig = {}) {
// tslint:disable-next-line:max-line-length
const style: string = `color: ${config.color != null ? config.color : "var(--my-font-color)"}; background-color:var(--my-background-color);${config.id === undefined ? " white-space:pre-wrap;" : ""}`;
// tslint:disable-next-line:max-line-length
const content: string = `<tr class="posted"><td ${config.id === undefined ? `class="terminal-line"` : `id="${config.id}"`} style="${style}">${input}</td></tr>`;
const inputElement: HTMLElement = getElementById("terminal-input");
inputElement.insertAdjacentHTML("beforebegin", content);
scrollTerminalToBottom();
}
function scrollTerminalToBottom() {
const container: HTMLElement = getElementById("terminal-container");
container.scrollTop = container.scrollHeight;
}