Skip to content

Commit

Permalink
remove is_type + js refactor+ console in pda mute tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
dageavtobusnick committed Dec 13, 2024
1 parent e30bdc5 commit d08d33d
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 117 deletions.
6 changes: 2 additions & 4 deletions code/game/machinery/requests_console.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ GLOBAL_LIST_EMPTY(allRequestConsoles)
GLOB.req_console_information -= department
QDEL_NULL(Radio)
for(var/datum/data/pda/app/request_console/app as anything in connected_apps)
if(istype(app))
app.on_rc_destroyed(src)
app.on_rc_destroyed(src)
return ..()

/obj/machinery/requests_console/attack_ghost(user as mob)
Expand Down Expand Up @@ -350,8 +349,7 @@ GLOBAL_LIST_EMPTY(allRequestConsoles)

/obj/machinery/requests_console/proc/write_to_message_log(message, ore_message = FALSE)
for(var/datum/data/pda/app/request_console/app as anything in connected_apps)
if(istype(app))
app.on_rc_message_recieved(src, message, ore_message)
app.on_rc_message_recieved(src, message, ore_message)
message_log = list(message) + message_log

/obj/machinery/requests_console/proc/print_label(tag_name, tag_index)
Expand Down
25 changes: 17 additions & 8 deletions code/modules/pda/request_consoles_app.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
update = PDA_APP_UPDATE
var/list/department_list
var/list/possible_consoles = list()
var/list/consoles_mute = list()
var/ore_message_reciver_dep
var/obj/machinery/requests_console/selected_console

Expand Down Expand Up @@ -36,7 +37,7 @@
if(isoremessage && source.department != ore_message_reciver_dep)
return
var/rendered_message = "Recieved on [source.name] : [message]"
if(!QDELETED(pda))
if(!QDELETED(pda) && !consoles_mute[source])
notify(rendered_message)


Expand All @@ -48,19 +49,27 @@
data["selected_console"] = null
var/list/possible_consoles_data= list()
for(var/obj/machinery/requests_console/console as anything in possible_consoles)
possible_consoles_data += list(list("name" = console.name, "priority" = console.newmessagepriority))
possible_consoles_data += list(list("name" = console.name, "priority" = console.newmessagepriority, "muted" = consoles_mute[console]))
data["consoles_data"] = possible_consoles_data

/datum/data/pda/app/request_console/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
var/name = params["name"]
var/obj/machinery/requests_console/clicked_console
for(var/atom/console as anything in possible_consoles)
if(console.name == name)
clicked_console = console
break
switch(action)
if("select")
var/name = params["name"]
for(var/atom/console as anything in possible_consoles)
if(console.name == name)
selected_console = console
title = console.name
break
if(!clicked_console)
return
selected_console = clicked_console
title = clicked_console.name
unnotify()
if("mute")
if(!clicked_console)
return
consoles_mute[clicked_console] = !consoles_mute[clicked_console]
if("back")
selected_console = null
title = initial(title)
Expand Down
44 changes: 16 additions & 28 deletions tgui/packages/tgui/interfaces/RequestConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,30 @@ import { useBackend } from '../backend';
import { Button, LabeledList, Box, Section } from '../components';
import { Window } from '../layouts';

export const pickPage = (index) => {
switch (index) {
case 0:
return <MainMenu />;
case 1:
return <DepartmentList purpose="ASSISTANCE" />;
case 2:
return <DepartmentList purpose="SUPPLIES" />;
case 3:
return <DepartmentList purpose="INFO" />;
case 4:
return <MessageResponse type="SUCCESS" />;
case 5:
return <MessageResponse type="FAIL" />;
case 6:
return <MessageLog type="MESSAGES" />;
case 7:
return <MessageAuth />;
case 8:
return <StationAnnouncement />;
case 9:
return <PrintShippingLabel />;
case 10:
return <MessageLog type="SHIPPING" />;
default:
return "WE SHOULDN'T BE HERE!";
}
export const pages = {
0: () => <MainMenu />,
1: () => <DepartmentList purpose="ASSISTANCE" />,
2: () => <DepartmentList purpose="SUPPLIES" />,
3: () => <DepartmentList purpose="INFO" />,
4: () => <MessageResponse type="SUCCESS" />,
5: () => <MessageResponse type="FAIL" />,
6: () => <MessageLog type="MESSAGES" />,
7: () => <MessageAuth />,
8: () => <StationAnnouncement />,
9: () => <PrintShippingLabel />,
10: () => <MessageLog type="SHIPPING" />,
default: () => "WE SHOULDN'T BE HERE!",
};

export const RequestConsole = (props, context) => {
const { act, data } = useBackend(context);
const { screen } = data;

const renderPage = pages[screen] || pages.default;

return (
<Window width={520} height={410}>
<Window.Content scrollable>{pickPage(screen)}</Window.Content>
<Window.Content scrollable>{renderPage()}</Window.Content>
</Window>
);
};
Expand Down
34 changes: 21 additions & 13 deletions tgui/packages/tgui/interfaces/pda/pda_request_console.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useBackend } from '../../backend';
import { Box, Button, Section, NoticeBox, Stack } from '../../components';
import { pickPage } from '../../interfaces/RequestConsole';
import { pages } from '../../interfaces/RequestConsole';

export const pda_request_console = (props, context) => {
const { act, data } = useBackend(context);
Expand All @@ -14,17 +14,25 @@ export const pda_request_console = (props, context) => {
{consoles_data.map((console) => {
return (
<Stack.Item key={console['name']}>
<Button
content={console['name']}
color={
console['priority'] === 1
? 'green'
: console['priority'] === 2
? 'red'
: 'default'
}
onClick={() => act('select', { name: console['name'] })}
/>
<Stack>
<Stack.Item>
<Button
color={
console['priority'] === 1
? 'green'
: console['priority'] === 2
? 'red'
: 'default'
}
content={console['name']}
onClick={() => act('select', { name: console['name'] })}
/>
<Button
icon={console['muted'] ? 'volume-mute' : 'volume-up'}
onClick={() => act('mute', { name: console['name'] })}
/>
</Stack.Item>
</Stack>
</Stack.Item>
);
})}
Expand All @@ -34,7 +42,7 @@ export const pda_request_console = (props, context) => {
}
return (
<Box>
{pickPage(screen)}
{(pages[screen] || pages.default)()}
{screen === 0 ? (
<Button
content="Back to console selection"
Expand Down
128 changes: 64 additions & 64 deletions tgui/public/tgui.bundle.js

Large diffs are not rendered by default.

0 comments on commit d08d33d

Please sign in to comment.