Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit c2fc857

Browse files
Makes the traffic control console less terrible to use (#22478)
* AHAHAHAHAHAHAHAHAHAHAHAHAHA * VESTIGIAL CODE THAT MUST BE DESTROYED * E * FIXES STUFF * Update NtslEditor.js * USELESS VARIABLE THAT DOES NOTHING BUT THE LINTER WANTS IT * IS THIS WHAT IT WANTS * MADE THE SCROLLING NOT TERRIBLY CODED * YES * NOT USED * Update traffic_control.dm * SCROLL BAR
1 parent 4358185 commit c2fc857

File tree

5 files changed

+361
-637
lines changed

5 files changed

+361
-637
lines changed

interface/skin.dmf

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -359,99 +359,3 @@ window "statwindow"
359359
background-color = none
360360
is-visible = false
361361
saved-params = ""
362-
363-
window "Telecomms IDE"
364-
elem "Telecomms IDE"
365-
type = MAIN
366-
pos = 281,0
367-
size = 569x582
368-
anchor1 = none
369-
anchor2 = none
370-
text-color = #eeeeee
371-
background-color = #222222
372-
is-visible = false
373-
saved-params = "pos;size;is-minimized;is-maximized"
374-
title = "TCS IDE"
375-
statusbar = false
376-
on-close = "exittcs"
377-
elem "button5"
378-
type = BUTTON
379-
pos = 209,464
380-
size = 70x20
381-
anchor1 = 37,80
382-
anchor2 = 49,83
383-
text-color = #eeeeee
384-
background-color = #555555
385-
saved-params = "is-checked"
386-
text = "Clear Memory"
387-
command = "tcsclearmem"
388-
elem "button4"
389-
type = BUTTON
390-
pos = 157,464
391-
size = 52x20
392-
anchor1 = 28,80
393-
anchor2 = 37,83
394-
text-color = #eeeeee
395-
background-color = #555555
396-
saved-params = "is-checked"
397-
text = "Revert"
398-
command = "tcsrevert"
399-
elem "button3"
400-
type = BUTTON
401-
pos = 105,464
402-
size = 52x20
403-
anchor1 = 18,80
404-
anchor2 = 28,83
405-
text-color = #eeeeee
406-
background-color = #555555
407-
saved-params = "is-checked"
408-
text = "Execute"
409-
command = "tcsrun"
410-
elem "tcserror"
411-
type = OUTPUT
412-
pos = 0,488
413-
size = 566x94
414-
anchor1 = 0,84
415-
anchor2 = 99,100
416-
font-family = "sans-serif"
417-
font-size = 9
418-
text-color = #eeeeee
419-
background-color = #333334
420-
saved-params = "max-lines"
421-
elem "button2"
422-
type = BUTTON
423-
pos = 53,464
424-
size = 52x20
425-
anchor1 = 9,80
426-
anchor2 = 18,83
427-
text-color = #eeeeee
428-
background-color = #555555
429-
saved-params = "is-checked"
430-
text = "Compile"
431-
command = "tcscompile"
432-
elem "button1"
433-
type = BUTTON
434-
pos = 0,464
435-
size = 53x20
436-
anchor1 = 0,80
437-
anchor2 = 9,83
438-
text-color = #eeeeee
439-
background-color = #555555
440-
saved-params = "is-checked"
441-
text = "Save"
442-
command = "tcssave"
443-
elem "tcscode"
444-
type = INPUT
445-
pos = 0,0
446-
size = 569x464
447-
anchor1 = 0,0
448-
anchor2 = 100,80
449-
font-family = "Courier"
450-
font-size = 10
451-
text-color = #eeeeee
452-
background-color = #333334
453-
saved-params = ""
454-
command = "cancel"
455-
multi-line = true
456-
no-command = true
457-
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
import { useBackend, useLocalState } from '../backend';
2+
import { Box, Button, Divider, Input, Tabs, TextArea, Section, Stack } from '../components';
3+
import { Window } from '../layouts';
4+
5+
6+
export const NtslEditor = (props, context) => {
7+
// Make sure we don't start larger than 50%/80% of screen width/height.
8+
const winWidth = Math.min(900, window.screen.availWidth * 0.5);
9+
const winHeight = Math.min(600, window.screen.availHeight * 0.8);
10+
11+
return (
12+
<Window
13+
title="Traffic Control Console"
14+
width={winWidth}
15+
height={winHeight}
16+
>
17+
<Window.Content>
18+
<Stack fill>
19+
<Stack.Item width={winWidth-240}>
20+
<ScriptEditor />
21+
</Stack.Item>
22+
<Stack.Item>
23+
<MainMenu />
24+
</Stack.Item>
25+
</Stack>
26+
</Window.Content>
27+
</Window>
28+
);
29+
};
30+
31+
const ScriptEditor = (props, context) => {
32+
const { act, data } = useBackend(context);
33+
const { stored_code, user_name } = data;
34+
return (
35+
<Box width="100%" height="100%">
36+
{user_name ?
37+
<TextArea
38+
noborder
39+
scrollbar
40+
value={stored_code}
41+
width="100%"
42+
height="100%"
43+
onChange={(e, value) => act('save_code', {
44+
saved_code: value,
45+
})}
46+
onEnter={(e, value) => act('save_code', {
47+
saved_code: value+"\n",
48+
})}
49+
/> :
50+
<Section width="100%" height="100%">
51+
{stored_code}
52+
</Section>
53+
}
54+
</Box>
55+
);
56+
};
57+
58+
const MainMenu = (props, context) => {
59+
const { act, data } = useBackend(context);
60+
const { emagged, user_name } = data;
61+
const [tabIndex, setTabIndex] = useLocalState(context, "tab-index", 1);
62+
return (
63+
<>
64+
<Section width="240px">
65+
{user_name ?
66+
<Stack>
67+
<Stack.Item>
68+
<Button
69+
icon="power-off"
70+
color="purple"
71+
content="Log Out"
72+
disabled={emagged}
73+
onClick={() => act('log_out')}
74+
/>
75+
</Stack.Item>
76+
<Stack.Item verticalAlign="middle">
77+
{user_name}
78+
</Stack.Item>
79+
</Stack> : <Button
80+
icon="power-off"
81+
color="green"
82+
content="Log In"
83+
onClick={() => act('log_in')}
84+
/>}
85+
</Section>
86+
{user_name &&
87+
<Section width="240px" height="90%" fill>
88+
<Tabs>
89+
<Tabs.Tab
90+
selected={tabIndex === 1}
91+
onClick={() => setTabIndex(1)}>
92+
Compile
93+
</Tabs.Tab>
94+
<Tabs.Tab
95+
selected={tabIndex === 2}
96+
onClick={() => setTabIndex(2)}>
97+
Network
98+
</Tabs.Tab>
99+
<Tabs.Tab
100+
selected={tabIndex === 3}
101+
onClick={() => setTabIndex(3)}>
102+
Logs
103+
</Tabs.Tab>
104+
</Tabs>
105+
{ tabIndex === 1 && <CompilerOutput /> }
106+
{ tabIndex === 2 && <ServerList /> }
107+
{ tabIndex === 3 && <LogViewer /> }
108+
</Section>
109+
}
110+
</>
111+
);
112+
};
113+
114+
const CompilerOutput = (props, context) => {
115+
const { act, data } = useBackend(context);
116+
const { compiler_output } = data;
117+
return (
118+
<>
119+
<Box>
120+
<Button
121+
mb={1}
122+
icon="save"
123+
content='Compile & Run'
124+
onClick={() => act('compile_code')}
125+
/>
126+
</Box>
127+
<Divider />
128+
<Section fill scrollable height="87.2%">
129+
{compiler_output ? compiler_output.map((error_message, index) => (
130+
<Box key={index}>
131+
{error_message}
132+
</Box>
133+
)) : "No compile errors."}
134+
</Section>
135+
</>
136+
);
137+
};
138+
139+
const ServerList = (props, context) => {
140+
const { act, data } = useBackend(context);
141+
const { network, server_data } = data;
142+
return (
143+
<>
144+
<Box>
145+
<Button
146+
mb={1}
147+
icon="sync"
148+
content='Reconnect to Network'
149+
onClick={() => act('refresh_servers')}
150+
/>
151+
</Box>
152+
<Box>
153+
<Input
154+
mb={1}
155+
value={network}
156+
onChange={(e, value) => act('set_network', {
157+
new_network: value,
158+
})}
159+
/>
160+
</Box>
161+
<Divider />
162+
<Section fill scrollable height="82%">
163+
{server_data.map((nt_server, index) => (
164+
<Box key={index}>
165+
<Button.Checkbox
166+
mb={0.5}
167+
checked={nt_server.run_code}
168+
content={nt_server.server_name}
169+
onClick={() => act('toggle_code_execution', {
170+
selected_server: nt_server.server,
171+
})}
172+
/>
173+
</Box>
174+
))}
175+
</Section>
176+
</>
177+
);
178+
};
179+
180+
const LogViewer = (props, context) => {
181+
const { act, data } = useBackend(context);
182+
const { access_log } = data;
183+
// This is terrible but nothing else will work
184+
return (
185+
<>
186+
<Box>
187+
<Button
188+
mb={1}
189+
icon='trash'
190+
content='Clear Logs'
191+
onClick={() => act('clear_logs')}
192+
/>
193+
</Box>
194+
<Divider />
195+
<Section fill scrollable height="87.2%">
196+
{access_log ? access_log.map((access_message, index) => (
197+
<Box key={index}>
198+
{access_message}
199+
</Box>
200+
)) : "Access log could not be found. Please contact an administrator."}
201+
</Section>
202+
</>
203+
);
204+
};

yogstation.dme

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4544,7 +4544,6 @@
45444544
#include "yogstation\code\modules\research\techweb\all_nodes.dm"
45454545
#include "yogstation\code\modules\ruins\ivymen_den.dm"
45464546
#include "yogstation\code\modules\ruins\lavaland_ruin_code.dm"
4547-
#include "yogstation\code\modules\scripting\client_verbs.dm"
45484547
#include "yogstation\code\modules\scripting\Errors.dm"
45494548
#include "yogstation\code\modules\scripting\Options.dm"
45504549
#include "yogstation\code\modules\scripting\stack.dm"

0 commit comments

Comments
 (0)