things and things. paperwork gone??

This commit is contained in:
Letter N
2020-07-21 14:08:26 +08:00
parent cf51c5aa2a
commit 3df765f5c7
65 changed files with 404 additions and 14 deletions
+4
View File
@@ -5,6 +5,10 @@
* Sometimes backend can response without a "data" field, but our final
* state will still contain previous "data" because we are merging
* the response with already existing state.
*
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import { UI_DISABLED, UI_INTERACTIVE } from './constants';
+6
View File
@@ -1,3 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
// Reference a global Byond object
const { Byond } = window;
-4
View File
@@ -83,10 +83,6 @@ export class Input extends Component {
if (input) {
input.value = toInputValue(nextValue);
}
if (this.props.autoFocus) {
setTimeout(() => input.focus(), 1);
}
}
componentDidUpdate(prevProps, prevState) {
@@ -0,0 +1,69 @@
import { toFixed } from 'common/math';
import { Component } from 'inferno';
// AnimatedNumber Copypaste
const isSafeNumber = value => {
return typeof value === 'number'
&& Number.isFinite(value)
&& !Number.isNaN(value);
};
export class TimeDisplay extends Component {
constructor(props) {
super(props);
this.timer = null;
this.last_seen_value = undefined;
this.state = {
value: 0,
};
// Set initial state with value provided in props
if (isSafeNumber(props.value)) {
this.state.value = Number(props.value);
this.last_seen_value = Number(props.value);
}
}
componentDidUpdate() {
if (this.props.auto !== undefined) {
clearInterval(this.timer);
this.timer = setInterval(() => this.tick(), 1000); // every 1 s
}
}
tick() {
let current = Number(this.state.value);
if (this.props.value !== this.last_seen_value) {
this.last_seen_value = this.props.value;
current = this.props.value;
}
const mod = this.props.auto === "up" ? 10 : -10; // Time down by default.
const value = Math.max(0, current + mod); // one sec tick
this.setState({ value });
}
componentDidMount() {
if (this.props.auto !== undefined) {
this.timer = setInterval(() => this.tick(), 1000); // every 1 s
}
}
componentWillUnmount() {
clearInterval(this.timer);
}
render() {
const val = this.state.value;
// Directly display weird stuff
if (!isSafeNumber(val)) {
return this.state.value || null;
}
// THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
// HH:MM:SS
// 00:02:13
const seconds = toFixed(Math.floor((val/10) % 60)).padStart(2, "0");
const minutes = toFixed(Math.floor((val/(10*60)) % 60)).padStart(2, "0");
const hours = toFixed(Math.floor((val/(10*60*60)) % 24)).padStart(2, "0");
const formattedValue = `${hours}:${minutes}:${seconds}`;
return formattedValue;
}
}
+6
View File
@@ -1,3 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
// UI states, which are mirrored from the BYOND code.
export const UI_INTERACTIVE = 2;
export const UI_UPDATE = 1;
+6
View File
@@ -1,3 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import { vecAdd, vecInverse, vecMultiply } from 'common/vector';
import { winget, winset } from './byond';
import { createLogger } from './logging';
+11 -1
View File
@@ -1,3 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import { clamp, round, toFixed } from 'common/math';
const SI_SYMBOLS = [
@@ -28,7 +34,11 @@ const SI_BASE_INDEX = SI_SYMBOLS.indexOf(' ');
* Formats a number to a human readable form, by reducing it to SI units.
* TODO: This is quite a shit code and shit math, needs optimization.
*/
const formatSiUnit = (value, minBase1000 = -SI_BASE_INDEX, unit = '') => {
export const formatSiUnit = (
value,
minBase1000 = -SI_BASE_INDEX,
unit = ''
) => {
const realBase10 = Math.floor(Math.log10(value));
const base10 = Math.floor(Math.max(minBase1000 * 3, realBase10));
const realBase1000 = Math.floor(realBase10 / 3);
+6
View File
@@ -1,3 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import { callByond, IS_IE8 } from './byond';
import { createLogger } from './logging';
+6
View File
@@ -1,3 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import { classes } from 'common/react';
import { IS_IE8 } from '../byond';
+6
View File
@@ -1,3 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import { useBackend } from '../backend';
import { Box, Button } from '../components';
import { refocusLayout } from './Layout';
+6
View File
@@ -1,3 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import { classes } from 'common/react';
import { decodeHtmlEntities, toTitleCase } from 'common/string';
import { Component, Fragment } from 'inferno';
+6
View File
@@ -1,3 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
export { Layout, refocusLayout } from './Layout';
export { NtosWindow } from './NtosWindow';
export { Window } from './Window';
+6
View File
@@ -1,3 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import { sendLogEntry } from 'tgui-dev-server/link/client';
import { callByond } from './byond';
+5
View File
@@ -1,6 +1,11 @@
/**
* CSS Object Model patches
*
* Adapted from: https://github.com/shawnbot/aight
*
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
/* eslint-disable */
+3 -2
View File
@@ -1,6 +1,7 @@
/**
* Copyright (c) 2013 Andrea Giammarchi @WebReflection
* SPDX-License-Identifier: MIT
* @file
* @copyright 2013 Andrea Giammarchi, WebReflection
* @license MIT
*/
/* eslint-disable */
+3 -2
View File
@@ -1,6 +1,7 @@
/**
* Copyright (c) 2014 Alexander Farkas
* SPDX-License-Identifier: MIT
* @file
* @copyright 2014 Alexander Farkas
* @license MIT
*/
/* eslint-disable */
+3 -2
View File
@@ -1,6 +1,7 @@
/**
* Copyright (c) 2013 Andrea Giammarchi @WebReflection
* SPDX-License-Identifier: MIT
* @file
* @copyright 2013 Andrea Giammarchi, WebReflection
* @license MIT
*/
/* eslint-disable */
+6
View File
@@ -1,3 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
// Inferno needs Int32Array, and it is not covered by core-js.
if (!window.Int32Array) {
window.Int32Array = Array;
+6
View File
@@ -1,3 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import { Window } from './layouts';
const requireInterface = require.context('./interfaces', false, /\.js$/);
+6
View File
@@ -1,3 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import { flow } from 'common/fp';
import { applyMiddleware, createStore as createReduxStore } from 'common/redux';
import { Component } from 'inferno';
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
.candystripe:nth-child(odd) {
background-color: rgba(0, 0, 0, 0.25);
}
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use '../colors.scss';
$fg-map: colors.$fg-map !default;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
.debug-layout,
.debug-layout *:not(g):not(path) {
color: rgba(255, 255, 255, 0.9) !important;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
.display-none {
display: none;
}
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@for $i from 0 through 2 {
.m-#{$i} {
margin: 6px * $i;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use '../colors.scss';
.outline-dotted {
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
.position-relative {
position: relative;
}
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
.text-left {
text-align: left;
}
+5
View File
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:color';
$color-fg: #ffffff !default;
+5
View File
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:color';
@use 'sass:map';
@use 'sass:meta';
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use '../base.scss';
@use '../colors.scss';
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use '../base.scss';
@use '../colors.scss';
@use '../functions.scss' as *;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
.ColorBox {
display: inline-block;
width: 12px;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
.Dimmer {
// Align everything in the middle.
// A fat middle finger for anything less than IE11.
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
$color: rgba(255, 255, 255, 0.1) !default;
$thickness: 2px !default;
$spacing: 6px;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
.Dropdown {
position: relative;
}
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
.FatalError {
display: block !important;
position: absolute;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
.Flex {
display: -ms-flexbox;
display: flex;
@@ -11,6 +16,16 @@
display: table !important;
}
.Flex--ie8--column {
display: block !important;
& > .Flex__item {
display: block !important;
margin-left: 6px;
margin-right: 6px;
}
}
.Flex__item--ie8 {
display: table-cell !important;
}
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use '../base.scss';
@use '../functions.scss' as *;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use '../base.scss';
@use '../colors.scss';
@use '../functions.scss' as *;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
.LabeledList {
display: table;
// IE8: Does not support calc
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use '../base.scss';
$color-background: base.$color-bg !default;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:color';
@use '../colors.scss';
@use '../functions.scss' as *;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:color';
@use '../functions.scss' as *;
@use './Input.scss';
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use '../base.scss';
@use '../colors.scss';
@use '../functions.scss' as *;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:color';
@use '../colors.scss';
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
.Slider {
cursor: e-resize;
}
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
.Table {
display: table;
width: 100%;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use '../base.scss';
$border-radius: base.$border-radius !default;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use '../base.scss';
@use '../functions.scss' as *;
+2 -2
View File
@@ -1,6 +1,6 @@
/**
* Copyright (c) 2018 Aleksej Komarov
* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:color';
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:color';
@use '../base.scss';
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
.NtosHeader__left {
position: absolute;
left: 12px;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
.NtosWindow__header {
position: absolute;
top: 0;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:color';
$color-text: rgba(255, 255, 255, 0.75) !default;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:color';
@use '../base.scss';
@use '../functions.scss' as *;
+5 -1
View File
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:meta';
@use './base.scss';
@@ -34,7 +39,6 @@
@include meta.load-css('./components/Slider.scss');
@include meta.load-css('./components/Table.scss');
@include meta.load-css('./components/Tabs.scss');
@include meta.load-css('./components/TextArea.scss');
@include meta.load-css('./components/Tooltip.scss');
// Interfaces
+5
View File
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
html, body {
box-sizing: border-box;
height: 100%;
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:color';
@use 'sass:meta';
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:color';
@use 'sass:meta';
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:color';
@use 'sass:meta';
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:color';
@use 'sass:meta';
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:color';
@use 'sass:meta';
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:color';
@use 'sass:meta';
+7
View File
@@ -1,3 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
const webpack = require('webpack');
const path = require('path');
const BuildNotifierPlugin = require('webpack-build-notifier');
@@ -138,6 +144,7 @@ module.exports = (env = {}, argv) => {
ie8: true,
output: {
ascii_only: true,
comments: false,
},
},
}),