mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-05 07:07:50 +02:00
v0.51.0 (#826)
* 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:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user