tgui-core 1.1.8 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. package/lib/common/assets.ts +38 -0
  2. package/lib/common/collections.ts +27 -0
  3. package/lib/common/color.ts +88 -0
  4. package/lib/common/constants.ts +349 -0
  5. package/lib/common/events.ts +262 -0
  6. package/{dist/common/exhaustive.d.ts → lib/common/exhaustive.ts} +3 -1
  7. package/lib/common/format.ts +167 -0
  8. package/{dist/common/fp.d.ts → lib/common/fp.ts} +16 -2
  9. package/lib/common/hotkeys.ts +207 -0
  10. package/lib/common/http.ts +16 -0
  11. package/lib/common/keycodes.ts +86 -0
  12. package/{dist/common/keys.d.ts → lib/common/keys.ts} +24 -21
  13. package/lib/common/math.ts +76 -0
  14. package/lib/common/perf.ts +72 -0
  15. package/lib/common/random.ts +32 -0
  16. package/lib/common/react.ts +59 -0
  17. package/lib/common/redux.ts +187 -0
  18. package/lib/common/storage.ts +207 -0
  19. package/lib/common/string.ts +169 -0
  20. package/lib/common/timer.ts +63 -0
  21. package/lib/common/type-utils.ts +41 -0
  22. package/lib/common/types.d.ts +12 -0
  23. package/lib/common/uuid.ts +18 -0
  24. package/lib/components/AnimatedNumber.tsx +180 -0
  25. package/lib/components/Autofocus.tsx +23 -0
  26. package/lib/components/Blink.tsx +91 -0
  27. package/lib/components/BlockQuote.tsx +9 -0
  28. package/lib/components/BodyZoneSelector.tsx +149 -0
  29. package/lib/components/Box.tsx +252 -0
  30. package/lib/components/Button.tsx +425 -0
  31. package/lib/components/ByondUi.jsx +110 -0
  32. package/lib/components/Chart.tsx +155 -0
  33. package/lib/components/Collapsible.tsx +43 -0
  34. package/lib/components/ColorBox.tsx +29 -0
  35. package/lib/components/Dialog.tsx +81 -0
  36. package/lib/components/Dimmer.tsx +13 -0
  37. package/lib/components/Divider.tsx +20 -0
  38. package/lib/components/DmIcon.tsx +86 -0
  39. package/lib/components/DraggableControl.jsx +276 -0
  40. package/lib/components/Dropdown.tsx +246 -0
  41. package/lib/components/FakeTerminal.jsx +52 -0
  42. package/lib/components/FitText.tsx +99 -0
  43. package/lib/components/Flex.tsx +159 -0
  44. package/lib/components/Icon.tsx +95 -0
  45. package/lib/components/Image.tsx +54 -0
  46. package/lib/components/InfinitePlane.jsx +192 -0
  47. package/lib/components/Input.tsx +176 -0
  48. package/lib/components/KeyListener.tsx +40 -0
  49. package/lib/components/Knob.tsx +178 -0
  50. package/lib/components/LabeledControls.tsx +44 -0
  51. package/lib/components/LabeledList.tsx +154 -0
  52. package/lib/components/MenuBar.tsx +228 -0
  53. package/lib/components/Modal.tsx +23 -0
  54. package/lib/components/NoticeBox.tsx +45 -0
  55. package/lib/components/NumberInput.tsx +328 -0
  56. package/lib/components/Popper.tsx +100 -0
  57. package/lib/components/ProgressBar.tsx +105 -0
  58. package/lib/components/RestrictedInput.jsx +301 -0
  59. package/lib/components/RoundGauge.tsx +180 -0
  60. package/lib/components/Section.tsx +120 -0
  61. package/lib/components/Slider.tsx +169 -0
  62. package/lib/components/Stack.tsx +96 -0
  63. package/lib/components/StyleableSection.tsx +33 -0
  64. package/lib/components/Table.tsx +84 -0
  65. package/lib/components/Tabs.tsx +89 -0
  66. package/lib/components/TextArea.tsx +182 -0
  67. package/lib/components/TimeDisplay.jsx +64 -0
  68. package/lib/components/Tooltip.tsx +152 -0
  69. package/lib/components/TrackOutsideClicks.tsx +35 -0
  70. package/lib/components/VirtualList.tsx +69 -0
  71. package/lib/styles/atomic/candystripe.scss +8 -0
  72. package/lib/styles/atomic/centered-image.scss +7 -0
  73. package/lib/styles/atomic/color.scss +21 -0
  74. package/lib/styles/atomic/debug-layout.scss +17 -0
  75. package/lib/styles/atomic/fit-text.scss +14 -0
  76. package/lib/styles/atomic/links.scss +12 -0
  77. package/lib/styles/atomic/outline.scss +47 -0
  78. package/lib/styles/atomic/text.scss +44 -0
  79. package/lib/styles/base.scss +32 -0
  80. package/lib/styles/colors.scss +92 -0
  81. package/lib/styles/components/BlockQuote.module.scss +20 -0
  82. package/lib/styles/components/BlockQuote.module.scss.d.ts +4 -0
  83. package/lib/styles/components/Button.module.scss +157 -0
  84. package/lib/styles/components/Button.module.scss.d.ts +46 -0
  85. package/lib/styles/components/ColorBox.module.scss +12 -0
  86. package/lib/styles/components/ColorBox.module.scss.d.ts +4 -0
  87. package/lib/styles/components/Dialog.module.scss +60 -0
  88. package/lib/styles/components/Dialog.module.scss.d.ts +10 -0
  89. package/lib/styles/components/Dimmer.module.scss +22 -0
  90. package/lib/styles/components/Dimmer.module.scss.d.ts +4 -0
  91. package/lib/styles/components/Divider.module.scss +27 -0
  92. package/lib/styles/components/Divider.module.scss.d.ts +6 -0
  93. package/lib/styles/components/Dropdown.scss +72 -0
  94. package/lib/styles/components/Flex.module.scss +13 -0
  95. package/lib/styles/components/Flex.module.scss.d.ts +5 -0
  96. package/lib/styles/components/Icon.module.scss +25 -0
  97. package/lib/styles/components/Icon.module.scss.d.ts +5 -0
  98. package/lib/styles/components/Input.module.scss +64 -0
  99. package/lib/styles/components/Input.module.scss.d.ts +8 -0
  100. package/lib/styles/components/Knob.module.scss +131 -0
  101. package/lib/styles/components/Knob.module.scss.d.ts +33 -0
  102. package/lib/styles/components/LabeledList.module.scss +49 -0
  103. package/lib/styles/components/LabeledList.module.scss.d.ts +8 -0
  104. package/lib/styles/components/MenuBar.module.scss +75 -0
  105. package/lib/styles/components/MenuBar.module.scss.d.ts +14 -0
  106. package/lib/styles/components/Modal.module.scss +14 -0
  107. package/lib/styles/components/Modal.module.scss.d.ts +4 -0
  108. package/lib/styles/components/NoticeBox.module.scss +65 -0
  109. package/lib/styles/components/NoticeBox.module.scss.d.ts +27 -0
  110. package/lib/styles/components/NumberInput.module.scss +71 -0
  111. package/lib/styles/components/NumberInput.module.scss.d.ts +9 -0
  112. package/lib/styles/components/ProgressBar.module.scss +63 -0
  113. package/lib/styles/components/ProgressBar.module.scss.d.ts +27 -0
  114. package/lib/styles/components/RoundGauge.module.scss +85 -0
  115. package/lib/styles/components/RoundGauge.module.scss.d.ts +49 -0
  116. package/lib/styles/components/Section.module.scss +130 -0
  117. package/lib/styles/components/Section.module.scss.d.ts +13 -0
  118. package/lib/styles/components/Slider.module.scss +54 -0
  119. package/lib/styles/components/Slider.module.scss.d.ts +8 -0
  120. package/lib/styles/components/Stack.module.scss +60 -0
  121. package/lib/styles/components/Stack.module.scss.d.ts +12 -0
  122. package/lib/styles/components/Table.module.scss +44 -0
  123. package/lib/styles/components/Table.module.scss.d.ts +10 -0
  124. package/lib/styles/components/Tabs.module.scss +144 -0
  125. package/lib/styles/components/Tabs.module.scss.d.ts +35 -0
  126. package/lib/styles/components/TextArea.module.scss +86 -0
  127. package/lib/styles/components/TextArea.module.scss.d.ts +11 -0
  128. package/lib/styles/components/Tooltip.module.scss +24 -0
  129. package/lib/styles/components/Tooltip.module.scss.d.ts +4 -0
  130. package/lib/styles/functions.scss +79 -0
  131. package/lib/styles/input.scss +9 -0
  132. package/lib/styles/main.scss +20 -0
  133. package/lib/styles/reset.scss +68 -0
  134. package/package.json +6 -6
  135. package/dist/ProgressBar.module-BkAFfFy0.js +0 -29
  136. package/dist/Section.module-CLVHJ4yA.js +0 -15
  137. package/dist/assets/BlockQuote.css +0 -1
  138. package/dist/assets/Button.css +0 -1
  139. package/dist/assets/ColorBox.css +0 -1
  140. package/dist/assets/Dialog.css +0 -1
  141. package/dist/assets/Dimmer.css +0 -1
  142. package/dist/assets/Divider.css +0 -1
  143. package/dist/assets/Flex.css +0 -1
  144. package/dist/assets/Icon.css +0 -6
  145. package/dist/assets/Input.css +0 -1
  146. package/dist/assets/Knob.css +0 -1
  147. package/dist/assets/LabeledList.css +0 -1
  148. package/dist/assets/MenuBar.css +0 -1
  149. package/dist/assets/Modal.css +0 -1
  150. package/dist/assets/NoticeBox.css +0 -1
  151. package/dist/assets/NumberInput.css +0 -1
  152. package/dist/assets/ProgressBar.css +0 -1
  153. package/dist/assets/RoundGauge.css +0 -1
  154. package/dist/assets/Section.css +0 -1
  155. package/dist/assets/Slider.css +0 -1
  156. package/dist/assets/Stack.css +0 -1
  157. package/dist/assets/Table.css +0 -1
  158. package/dist/assets/Tabs.css +0 -1
  159. package/dist/assets/TextArea.css +0 -1
  160. package/dist/assets/Tooltip.css +0 -1
  161. package/dist/common/assets.d.ts +0 -4
  162. package/dist/common/assets.js +0 -25
  163. package/dist/common/collections.d.ts +0 -10
  164. package/dist/common/collections.js +0 -15
  165. package/dist/common/color.d.ts +0 -25
  166. package/dist/common/color.js +0 -69
  167. package/dist/common/constants.d.ts +0 -102
  168. package/dist/common/constants.js +0 -312
  169. package/dist/common/events.d.ts +0 -33
  170. package/dist/common/events.js +0 -147
  171. package/dist/common/exhaustive.js +0 -6
  172. package/dist/common/format.d.ts +0 -11
  173. package/dist/common/format.js +0 -114
  174. package/dist/common/fp.js +0 -9
  175. package/dist/common/hotkeys.d.ts +0 -25
  176. package/dist/common/hotkeys.js +0 -112
  177. package/dist/common/http.d.ts +0 -4
  178. package/dist/common/http.js +0 -10
  179. package/dist/common/keycodes.d.ts +0 -85
  180. package/dist/common/keycodes.js +0 -88
  181. package/dist/common/keys.js +0 -8
  182. package/dist/common/math.d.ts +0 -39
  183. package/dist/common/math.js +0 -41
  184. package/dist/common/perf.d.ts +0 -24
  185. package/dist/common/perf.js +0 -33
  186. package/dist/common/random.d.ts +0 -16
  187. package/dist/common/random.js +0 -18
  188. package/dist/common/react.d.ts +0 -23
  189. package/dist/common/react.js +0 -30
  190. package/dist/common/redux.d.ts +0 -64
  191. package/dist/common/redux.js +0 -72
  192. package/dist/common/storage.js +0 -124
  193. package/dist/common/string.d.ts +0 -65
  194. package/dist/common/string.js +0 -83
  195. package/dist/common/timer.d.ts +0 -18
  196. package/dist/common/timer.js +0 -28
  197. package/dist/common/type-utils.d.ts +0 -9
  198. package/dist/common/type-utils.js +0 -25
  199. package/dist/common/uuid.d.ts +0 -9
  200. package/dist/common/uuid.js +0 -10
  201. package/dist/components/AnimatedNumber.d.ts +0 -60
  202. package/dist/components/AnimatedNumber.js +0 -76
  203. package/dist/components/Autofocus.d.ts +0 -4
  204. package/dist/components/Autofocus.js +0 -17
  205. package/dist/components/Blink.d.ts +0 -26
  206. package/dist/components/Blink.js +0 -56
  207. package/dist/components/BlockQuote.d.ts +0 -3
  208. package/dist/components/BlockQuote.js +0 -13
  209. package/dist/components/BodyZoneSelector.d.ts +0 -28
  210. package/dist/components/BodyZoneSelector.js +0 -115
  211. package/dist/components/Box.d.ts +0 -91
  212. package/dist/components/Box.js +0 -133
  213. package/dist/components/Button.d.ts +0 -93
  214. package/dist/components/Button.js +0 -298
  215. package/dist/components/ByondUi.js +0 -73
  216. package/dist/components/Chart.d.ts +0 -28
  217. package/dist/components/Chart.js +0 -95
  218. package/dist/components/Collapsible.d.ts +0 -15
  219. package/dist/components/Collapsible.js +0 -27
  220. package/dist/components/ColorBox.d.ts +0 -8
  221. package/dist/components/ColorBox.js +0 -24
  222. package/dist/components/Dialog.d.ts +0 -24
  223. package/dist/components/Dialog.js +0 -67
  224. package/dist/components/Dimmer.d.ts +0 -3
  225. package/dist/components/Dimmer.js +0 -13
  226. package/dist/components/Divider.d.ts +0 -6
  227. package/dist/components/Divider.js +0 -22
  228. package/dist/components/DmIcon.d.ts +0 -31
  229. package/dist/components/DmIcon.js +0 -34
  230. package/dist/components/DraggableControl.js +0 -176
  231. package/dist/components/Dropdown.d.ts +0 -48
  232. package/dist/components/Dropdown.js +0 -152
  233. package/dist/components/FakeTerminal.js +0 -38
  234. package/dist/components/FitText.d.ts +0 -22
  235. package/dist/components/FitText.js +0 -63
  236. package/dist/components/Flex.d.ts +0 -93
  237. package/dist/components/Flex.js +0 -72
  238. package/dist/components/Icon.d.ts +0 -30
  239. package/dist/components/Icon.js +0 -51
  240. package/dist/components/Image.d.ts +0 -14
  241. package/dist/components/Image.js +0 -35
  242. package/dist/components/InfinitePlane.js +0 -139
  243. package/dist/components/Input.d.ts +0 -61
  244. package/dist/components/Input.js +0 -89
  245. package/dist/components/KeyListener.d.ts +0 -15
  246. package/dist/components/KeyListener.js +0 -23
  247. package/dist/components/Knob.d.ts +0 -49
  248. package/dist/components/Knob.js +0 -162
  249. package/dist/components/LabeledControls.d.ts +0 -11
  250. package/dist/components/LabeledControls.js +0 -39
  251. package/dist/components/LabeledList.d.ts +0 -57
  252. package/dist/components/LabeledList.js +0 -94
  253. package/dist/components/MenuBar.d.ts +0 -28
  254. package/dist/components/MenuBar.js +0 -174
  255. package/dist/components/Modal.d.ts +0 -3
  256. package/dist/components/Modal.js +0 -25
  257. package/dist/components/NoticeBox.d.ts +0 -20
  258. package/dist/components/NoticeBox.js +0 -49
  259. package/dist/components/NumberInput.d.ts +0 -45
  260. package/dist/components/NumberInput.js +0 -221
  261. package/dist/components/Popper.d.ts +0 -27
  262. package/dist/components/Popper.js +0 -177
  263. package/dist/components/ProgressBar.d.ts +0 -46
  264. package/dist/components/ProgressBar.js +0 -37
  265. package/dist/components/RestrictedInput.js +0 -155
  266. package/dist/components/RoundGauge.d.ts +0 -53
  267. package/dist/components/RoundGauge.js +0 -147
  268. package/dist/components/Section.d.ts +0 -63
  269. package/dist/components/Section.js +0 -62
  270. package/dist/components/Slider.d.ts +0 -46
  271. package/dist/components/Slider.js +0 -124
  272. package/dist/components/Stack.d.ts +0 -27
  273. package/dist/components/Stack.js +0 -67
  274. package/dist/components/StyleableSection.d.ts +0 -11
  275. package/dist/components/StyleableSection.js +0 -16
  276. package/dist/components/Table.d.ts +0 -29
  277. package/dist/components/Table.js +0 -67
  278. package/dist/components/Tabs.d.ts +0 -23
  279. package/dist/components/Tabs.js +0 -89
  280. package/dist/components/TextArea.d.ts +0 -39
  281. package/dist/components/TextArea.js +0 -118
  282. package/dist/components/TimeDisplay.js +0 -34
  283. package/dist/components/Tooltip.d.ts +0 -29
  284. package/dist/components/Tooltip.js +0 -83
  285. package/dist/components/TrackOutsideClicks.d.ts +0 -13
  286. package/dist/components/TrackOutsideClicks.js +0 -24
  287. package/dist/components/VirtualList.d.ts +0 -8
  288. package/dist/components/VirtualList.js +0 -34
  289. package/dist/components/index.js +0 -92
  290. package/dist/popper-CiqSDJTE.js +0 -906
  291. /package/{dist/components/index.d.ts → lib/components/index.ts} +0 -0
@@ -0,0 +1,38 @@
1
+ import { Action, AnyAction, Dispatch, Middleware } from './redux';
2
+
3
+ const EXCLUDED_PATTERNS = [/v4shim/i];
4
+ const loadedMappings: Record<string, string> = {};
5
+
6
+ export function resolveAsset(name: string): string {
7
+ return loadedMappings[name] || name;
8
+ }
9
+
10
+ export const assetMiddleware: Middleware =
11
+ (_storeApi) =>
12
+ <ActionType extends Action = AnyAction>(next: Dispatch<ActionType>) =>
13
+ (action: ActionType) => {
14
+ const { type, payload } = action as AnyAction;
15
+ if (type === 'asset/stylesheet') {
16
+ Byond.loadCss(payload);
17
+ return;
18
+ }
19
+ if (type === 'asset/mappings') {
20
+ for (const name of Object.keys(payload)) {
21
+ // Skip anything that matches excluded patterns
22
+ if (EXCLUDED_PATTERNS.some((regex) => regex.test(name))) {
23
+ continue;
24
+ }
25
+ const url = payload[name];
26
+ const ext = name.split('.').pop();
27
+ loadedMappings[name] = url;
28
+ if (ext === 'css') {
29
+ Byond.loadCss(url);
30
+ }
31
+ if (ext === 'js') {
32
+ Byond.loadJs(url);
33
+ }
34
+ }
35
+ return;
36
+ }
37
+ next(action);
38
+ };
@@ -0,0 +1,27 @@
1
+ type Zip<T extends unknown[][]> = {
2
+ [I in keyof T]: T[I] extends (infer U)[] ? U : never;
3
+ }[];
4
+
5
+ /**
6
+ * Creates an array of grouped elements, the first of which contains
7
+ * the first elements of the given arrays, the second of which contains
8
+ * the second elements of the given arrays, and so on.
9
+ */
10
+ export function zip<T extends unknown[][]>(...arrays: T): Zip<T> {
11
+ if (arrays.length === 0) {
12
+ return [];
13
+ }
14
+ const numArrays = arrays.length;
15
+ const numValues = arrays[0].length;
16
+ const result: Zip<T> = [];
17
+ for (let valueIndex = 0; valueIndex < numValues; valueIndex++) {
18
+ const entry: unknown[] = [];
19
+ for (let arrayIndex = 0; arrayIndex < numArrays; arrayIndex++) {
20
+ entry.push(arrays[arrayIndex][valueIndex]);
21
+ }
22
+
23
+ // I tried everything to remove this any, and have no idea how to do it.
24
+ result.push(entry as any);
25
+ }
26
+ return result;
27
+ }
@@ -0,0 +1,88 @@
1
+ const EPSILON = 0.0001;
2
+
3
+ export class Color {
4
+ r: number;
5
+ g: number;
6
+ b: number;
7
+ a: number;
8
+
9
+ constructor(r = 0, g = 0, b = 0, a = 1) {
10
+ this.r = r;
11
+ this.g = g;
12
+ this.b = b;
13
+ this.a = a;
14
+ }
15
+
16
+ toString(): string {
17
+ // Alpha component needs to permit fractional values, so cannot use |
18
+ let alpha = this.a;
19
+ if (typeof alpha === 'string') {
20
+ alpha = parseFloat(this.a as any);
21
+ }
22
+ if (isNaN(alpha)) {
23
+ alpha = 1;
24
+ }
25
+ return `rgba(${this.r | 0}, ${this.g | 0}, ${this.b | 0}, ${alpha})`;
26
+ }
27
+
28
+ /** Darkens a color by a given percent. Returns a color, which can have toString called to get it's rgba() css value. */
29
+ darken(percent: number): Color {
30
+ percent /= 100;
31
+ return new Color(
32
+ this.r - this.r * percent,
33
+ this.g - this.g * percent,
34
+ this.b - this.b * percent,
35
+ this.a,
36
+ );
37
+ }
38
+
39
+ /** Brightens a color by a given percent. Returns a color, which can have toString called to get it's rgba() css value. */
40
+ lighten(percent: number): Color {
41
+ // No point in rewriting code we already have.
42
+ return this.darken(-percent);
43
+ }
44
+
45
+ /**
46
+ * Creates a color from the CSS hex color notation.
47
+ */
48
+ static fromHex(hex: string): Color {
49
+ return new Color(
50
+ parseInt(hex.slice(1, 3), 16),
51
+ parseInt(hex.slice(3, 5), 16),
52
+ parseInt(hex.slice(5, 7), 16),
53
+ );
54
+ }
55
+
56
+ /**
57
+ * Linear interpolation of two colors.
58
+ */
59
+ static lerp(c1: Color, c2: Color, n: number): Color {
60
+ return new Color(
61
+ (c2.r - c1.r) * n + c1.r,
62
+ (c2.g - c1.g) * n + c1.g,
63
+ (c2.b - c1.b) * n + c1.b,
64
+ (c2.a - c1.a) * n + c1.a,
65
+ );
66
+ }
67
+
68
+ /**
69
+ * Loops up the color in the provided list of colors
70
+ * with linear interpolation.
71
+ */
72
+ static lookup(value: number, colors: Color[]): Color {
73
+ const len = colors.length;
74
+ if (len < 2) {
75
+ throw new Error('Needs at least two colors!');
76
+ }
77
+ const scaled = value * (len - 1);
78
+ if (value < EPSILON) {
79
+ return colors[0];
80
+ }
81
+ if (value >= 1 - EPSILON) {
82
+ return colors[len - 1];
83
+ }
84
+ const ratio = scaled % 1;
85
+ const index = scaled | 0;
86
+ return this.lerp(colors[index], colors[index + 1], ratio);
87
+ }
88
+ }
@@ -0,0 +1,349 @@
1
+ type Gas = {
2
+ color: string;
3
+ id: string;
4
+ label: string;
5
+ name: string;
6
+ path: string;
7
+ };
8
+
9
+ // UI states, which are mirrored from the BYOND code.
10
+ export const UI_INTERACTIVE = 2;
11
+ export const UI_UPDATE = 1;
12
+ export const UI_DISABLED = 0;
13
+ export const UI_CLOSE = -1;
14
+
15
+ // All game related colors are stored here
16
+ export const COLORS = {
17
+ // Department colors
18
+ department: {
19
+ captain: '#c06616',
20
+ security: '#e74c3c',
21
+ medbay: '#3498db',
22
+ science: '#9b59b6',
23
+ engineering: '#f1c40f',
24
+ cargo: '#f39c12',
25
+ service: '#7cc46a',
26
+ centcom: '#00c100',
27
+ other: '#c38312',
28
+ },
29
+ // Damage type colors
30
+ damageType: {
31
+ oxy: '#3498db',
32
+ toxin: '#2ecc71',
33
+ burn: '#e67e22',
34
+ brute: '#e74c3c',
35
+ },
36
+ // reagent / chemistry related colours
37
+ reagent: {
38
+ acidicbuffer: '#fbc314',
39
+ basicbuffer: '#3853a4',
40
+ },
41
+ } as const;
42
+
43
+ // Colors defined in CSS
44
+ export const CSS_COLORS = [
45
+ 'average',
46
+ 'bad',
47
+ 'black',
48
+ 'blue',
49
+ 'brown',
50
+ 'good',
51
+ 'green',
52
+ 'grey',
53
+ 'label',
54
+ 'olive',
55
+ 'orange',
56
+ 'pink',
57
+ 'purple',
58
+ 'red',
59
+ 'teal',
60
+ 'transparent',
61
+ 'violet',
62
+ 'white',
63
+ 'yellow',
64
+ ] as const;
65
+
66
+ export type CssColor = (typeof CSS_COLORS)[number];
67
+
68
+ /* IF YOU CHANGE THIS KEEP IT IN SYNC WITH CHAT CSS */
69
+ export const RADIO_CHANNELS = [
70
+ {
71
+ name: 'Syndicate',
72
+ freq: 1213,
73
+ color: '#8f4a4b',
74
+ },
75
+ {
76
+ name: 'Red Team',
77
+ freq: 1215,
78
+ color: '#ff4444',
79
+ },
80
+ {
81
+ name: 'Blue Team',
82
+ freq: 1217,
83
+ color: '#3434fd',
84
+ },
85
+ {
86
+ name: 'Green Team',
87
+ freq: 1219,
88
+ color: '#34fd34',
89
+ },
90
+ {
91
+ name: 'Yellow Team',
92
+ freq: 1221,
93
+ color: '#fdfd34',
94
+ },
95
+ {
96
+ name: 'CentCom',
97
+ freq: 1337,
98
+ color: '#2681a5',
99
+ },
100
+ {
101
+ name: 'Supply',
102
+ freq: 1347,
103
+ color: '#b88646',
104
+ },
105
+ {
106
+ name: 'Service',
107
+ freq: 1349,
108
+ color: '#6ca729',
109
+ },
110
+ {
111
+ name: 'Science',
112
+ freq: 1351,
113
+ color: '#c68cfa',
114
+ },
115
+ {
116
+ name: 'Command',
117
+ freq: 1353,
118
+ color: '#fcdf03',
119
+ },
120
+ {
121
+ name: 'Medical',
122
+ freq: 1355,
123
+ color: '#57b8f0',
124
+ },
125
+ {
126
+ name: 'Engineering',
127
+ freq: 1357,
128
+ color: '#f37746',
129
+ },
130
+ {
131
+ name: 'Security',
132
+ freq: 1359,
133
+ color: '#dd3535',
134
+ },
135
+ {
136
+ name: 'AI Private',
137
+ freq: 1447,
138
+ color: '#d65d95',
139
+ },
140
+ {
141
+ name: 'Common',
142
+ freq: 1459,
143
+ color: '#1ecc43',
144
+ },
145
+ ] as const;
146
+
147
+ const GASES = [
148
+ {
149
+ id: 'o2',
150
+ path: '/datum/gas/oxygen',
151
+ name: 'Oxygen',
152
+ label: 'O₂',
153
+ color: 'blue',
154
+ },
155
+ {
156
+ id: 'n2',
157
+ path: '/datum/gas/nitrogen',
158
+ name: 'Nitrogen',
159
+ label: 'N₂',
160
+ color: 'yellow',
161
+ },
162
+ {
163
+ id: 'co2',
164
+ path: '/datum/gas/carbon_dioxide',
165
+ name: 'Carbon Dioxide',
166
+ label: 'CO₂',
167
+ color: 'grey',
168
+ },
169
+ {
170
+ id: 'plasma',
171
+ path: '/datum/gas/plasma',
172
+ name: 'Plasma',
173
+ label: 'Plasma',
174
+ color: 'pink',
175
+ },
176
+ {
177
+ id: 'water_vapor',
178
+ path: '/datum/gas/water_vapor',
179
+ name: 'Water Vapor',
180
+ label: 'H₂O',
181
+ color: 'lightsteelblue',
182
+ },
183
+ {
184
+ id: 'hypernoblium',
185
+ path: '/datum/gas/hypernoblium',
186
+ name: 'Hyper-noblium',
187
+ label: 'Hyper-nob',
188
+ color: 'teal',
189
+ },
190
+ {
191
+ id: 'n2o',
192
+ path: '/datum/gas/nitrous_oxide',
193
+ name: 'Nitrous Oxide',
194
+ label: 'N₂O',
195
+ color: 'bisque',
196
+ },
197
+ {
198
+ id: 'no2',
199
+ path: '/datum/gas/nitrium',
200
+ name: 'Nitrium',
201
+ label: 'Nitrium',
202
+ color: 'brown',
203
+ },
204
+ {
205
+ id: 'tritium',
206
+ path: '/datum/gas/tritium',
207
+ name: 'Tritium',
208
+ label: 'Tritium',
209
+ color: 'limegreen',
210
+ },
211
+ {
212
+ id: 'bz',
213
+ path: '/datum/gas/bz',
214
+ name: 'BZ',
215
+ label: 'BZ',
216
+ color: 'mediumpurple',
217
+ },
218
+ {
219
+ id: 'pluoxium',
220
+ path: '/datum/gas/pluoxium',
221
+ name: 'Pluoxium',
222
+ label: 'Pluoxium',
223
+ color: 'mediumslateblue',
224
+ },
225
+ {
226
+ id: 'miasma',
227
+ path: '/datum/gas/miasma',
228
+ name: 'Miasma',
229
+ label: 'Miasma',
230
+ color: 'olive',
231
+ },
232
+ {
233
+ id: 'freon',
234
+ path: '/datum/gas/freon',
235
+ name: 'Freon',
236
+ label: 'Freon',
237
+ color: 'paleturquoise',
238
+ },
239
+ {
240
+ id: 'hydrogen',
241
+ path: '/datum/gas/hydrogen',
242
+ name: 'Hydrogen',
243
+ label: 'H₂',
244
+ color: 'white',
245
+ },
246
+ {
247
+ id: 'healium',
248
+ path: '/datum/gas/healium',
249
+ name: 'Healium',
250
+ label: 'Healium',
251
+ color: 'salmon',
252
+ },
253
+ {
254
+ id: 'proto_nitrate',
255
+ path: '/datum/gas/proto_nitrate',
256
+ name: 'Proto Nitrate',
257
+ label: 'Proto-Nitrate',
258
+ color: 'greenyellow',
259
+ },
260
+ {
261
+ id: 'zauker',
262
+ path: '/datum/gas/zauker',
263
+ name: 'Zauker',
264
+ label: 'Zauker',
265
+ color: 'darkgreen',
266
+ },
267
+ {
268
+ id: 'halon',
269
+ path: '/datum/gas/halon',
270
+ name: 'Halon',
271
+ label: 'Halon',
272
+ color: 'purple',
273
+ },
274
+ {
275
+ id: 'helium',
276
+ path: '/datum/gas/helium',
277
+ name: 'Helium',
278
+ label: 'He',
279
+ color: 'aliceblue',
280
+ },
281
+ {
282
+ id: 'antinoblium',
283
+ path: '/datum/gas/antinoblium',
284
+ name: 'Antinoblium',
285
+ label: 'Anti-Noblium',
286
+ color: 'maroon',
287
+ },
288
+ {
289
+ id: 'nitrium',
290
+ path: '/datum/gas/nitrium',
291
+ name: 'Nitrium',
292
+ label: 'Nitrium',
293
+ color: 'brown',
294
+ },
295
+ ] as const;
296
+
297
+ // Returns gas label based on gasId
298
+ export function getGasLabel(gasId: string, fallbackValue?: string) {
299
+ if (!gasId) return fallbackValue || 'None';
300
+
301
+ const gasSearchString = gasId.toLowerCase();
302
+
303
+ for (let idx = 0; idx < GASES.length; idx++) {
304
+ if (GASES[idx].id === gasSearchString) {
305
+ return GASES[idx].label;
306
+ }
307
+ }
308
+
309
+ return fallbackValue || 'None';
310
+ }
311
+
312
+ // Returns gas color based on gasId
313
+ export function getGasColor(gasId: string) {
314
+ if (!gasId) return 'black';
315
+
316
+ const gasSearchString = gasId.toLowerCase();
317
+
318
+ for (let idx = 0; idx < GASES.length; idx++) {
319
+ if (GASES[idx].id === gasSearchString) {
320
+ return GASES[idx].color;
321
+ }
322
+ }
323
+
324
+ return 'black';
325
+ }
326
+
327
+ // Returns gas object based on gasId
328
+ export const getGasFromId = (gasId: string): Gas | undefined => {
329
+ if (!gasId) return;
330
+
331
+ const gasSearchString = gasId.toLowerCase();
332
+
333
+ for (let idx = 0; idx < GASES.length; idx++) {
334
+ if (GASES[idx].id === gasSearchString) {
335
+ return GASES[idx];
336
+ }
337
+ }
338
+ };
339
+
340
+ // Returns gas object based on gasPath
341
+ export const getGasFromPath = (gasPath: string): Gas | undefined => {
342
+ if (!gasPath) return;
343
+
344
+ for (let idx = 0; idx < GASES.length; idx++) {
345
+ if (GASES[idx].path === gasPath) {
346
+ return GASES[idx];
347
+ }
348
+ }
349
+ };