Skip to content

Commit

Permalink
Portable Turret Fixes (#19056)
Browse files Browse the repository at this point in the history
Portable Turret can now access it's panel to control it's settings, as
intended

---------

Co-authored-by: Ben10083 <[email protected]>
  • Loading branch information
Ben10083 and Ben10083 authored Apr 30, 2024
1 parent 282b8ea commit 202e634
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 5 deletions.
2 changes: 1 addition & 1 deletion code/game/machinery/portable_turret.dm
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
/obj/machinery/porta_turret/ui_interact(mob/user, var/datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "TurretControl", "Defense Systems Control Panel", 375, 725)
ui = new(user, src, "TurretControlPorta", "Defense Systems Control Panel", 375, 425)
ui.open()

/obj/machinery/porta_turret/proc/HasController()
Expand Down
58 changes: 58 additions & 0 deletions html/changelogs/Ben10083 - PortaTurret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
################################
# Example Changelog File
#
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
#
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
# When it is, any changes listed below will disappear.
#
# Valid Prefixes:
# bugfix
# - (fixes bugs)
# wip
# - (work in progress)
# qol
# - (quality of life)
# soundadd
# - (adds a sound)
# sounddel
# - (removes a sound)
# rscadd
# - (adds a feature)
# rscdel
# - (removes a feature)
# imageadd
# - (adds an image or sprite)
# imagedel
# - (removes an image or sprite)
# spellcheck
# - (fixes spelling or grammar)
# experiment
# - (experimental change)
# balance
# - (balance changes)
# code_imp
# - (misc internal code change)
# refactor
# - (refactors code)
# config
# - (makes a change to the config files)
# admin
# - (makes changes to administrator tools)
# server
# - (miscellaneous changes to server)
#################################

# Your name.
author: Ben10083

# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
delete-after: True

# Any changes you've made. See valid prefix list above.
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
# SCREW THIS UP AND IT WON'T WORK.
# Also, this gets changed to [] after reading. Just remove the brackets when you add new shit.
# Please surround your changes in double quotes ("). It works without them, but if you use certain characters it screws up compiling. The quotes will not show up in the changelog.
changes:
- bugfix: "Portable Turrets now work outside of areas with a turret controller, spawning a panel for itself as intended."
8 changes: 4 additions & 4 deletions tgui/packages/tgui/interfaces/TurretControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ export const TurretControl = (props, context) => {
? 'Behaviour controls are locked.'
: 'Behaviour controls are unlocked.'}
</NoticeBox>
<ControlWindow />
<ControlSection />
</Section>
<Section title="Individual Controls">
<TurretsWindow />
<TurretsSection />
</Section>
</Window.Content>
</Window>
);
};

export const ControlWindow = (props, context) => {
export const ControlSection = (props, context) => {
const { act, data } = useBackend<TurretData>(context);

return (
Expand Down Expand Up @@ -102,7 +102,7 @@ export const ControlWindow = (props, context) => {
);
};

export const TurretsWindow = (props, context) => {
export const TurretsSection = (props, context) => {
const { act, data } = useBackend<TurretData>(context);

return (
Expand Down
88 changes: 88 additions & 0 deletions tgui/packages/tgui/interfaces/TurretControlPorta.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { BooleanLike } from '../../common/react';
import { useBackend } from '../backend';
import { Button, LabeledList, NoticeBox, Section } from '../components';
import { Window } from '../layouts';

export type TurretData = {
settings: Setting[];
locked: BooleanLike;
enabled: BooleanLike;
is_lethal: BooleanLike;
lethal: BooleanLike;
can_switch: BooleanLike;
};

type Setting = {
category: string;
variable_name: string;
value: BooleanLike;
};

export const TurretControlPorta = (props, context) => {
const { act, data } = useBackend<TurretData>(context);

return (
<Window resizable>
<Window.Content scrollable>
<Section title="Control Panel">
<NoticeBox>
{data.locked
? 'Behaviour controls are locked.'
: 'Behaviour controls are unlocked.'}
</NoticeBox>
<ControlSection />
</Section>
</Window.Content>
</Window>
);
};

export const ControlSection = (props, context) => {
const { act, data } = useBackend<TurretData>(context);

return (
<LabeledList>
<LabeledList.Item label="Turret Status">
<Button
content={data.enabled ? 'Enabled' : 'Disabled'}
color={data.enabled ? 'bad' : ''}
disabled={data.locked}
onClick={() =>
act('command', {
value: !data.enabled,
command: 'enable',
})
}
/>
</LabeledList.Item>
<LabeledList.Item label="Lethal Mode">
<Button
content={data.lethal ? 'On' : 'Off'}
color={data.lethal ? 'bad' : 'average'}
disabled={data.locked}
onClick={() =>
act('command', {
value: !data.lethal,
command: 'lethal',
})
}
/>
</LabeledList.Item>
{data.settings.map((setting) => (
<LabeledList.Item label={setting.category} key={setting.category}>
<Button
content={setting.value ? 'On' : 'Off'}
selected={setting.value}
disabled={data.locked}
onClick={() =>
act('command', {
value: !setting.value,
command: setting.variable_name,
})
}
/>
</LabeledList.Item>
))}
</LabeledList>
);
};

0 comments on commit 202e634

Please sign in to comment.