Skip to content

Commit

Permalink
Rappel Menu For GM (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndroBetel authored Jan 15, 2024
1 parent ca214b9 commit 51beb83
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 0 deletions.
2 changes: 2 additions & 0 deletions code/datums/skills/uscm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ United States Colonial Marines
SKILL_ENDURANCE = SKILL_ENDURANCE_TRAINED,
SKILL_JTAC = SKILL_JTAC_TRAINED,
SKILL_INTEL = SKILL_INTEL_TRAINED,
SKILL_PILOT = SKILL_PILOT_EXPERT,
)

/datum/skills/intel
Expand Down Expand Up @@ -290,6 +291,7 @@ COMMAND STAFF
SKILL_JTAC = SKILL_JTAC_EXPERT,
SKILL_INTEL = SKILL_INTEL_TRAINED,
SKILL_SURGERY = SKILL_SURGERY_NOVICE,
SKILL_PILOT = SKILL_PILOT_EXPERT,
)

/datum/skills/SEA
Expand Down
21 changes: 21 additions & 0 deletions code/game/objects/items/devices/flashlight.dm
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,27 @@
qdel(signal)
..()

/obj/effect/landmark/rappel
name = "Rappel Point"
var/datum/cas_signal/signal
invisibility_value = SEE_INVISIBLE_OBSERVER
icon_state = "o_green"

/obj/effect/landmark/rappel/New()
. = ..()
signal = new(src)
signal.target_id = ++cas_tracking_id_increment
name = "Rappel Point #[signal.target_id]"
signal.name = name
cas_groups[FACTION_MARINE].add_signal(signal)

/obj/effect/landmark/rappel/Destroy()
if(signal)
cas_groups[FACTION_MARINE].remove_signal(signal)
QDEL_NULL(signal)
return ..()


/// Signal flares deployed by a flare gun
/obj/item/device/flashlight/flare/signal/gun
activate_message = FALSE
Expand Down
2 changes: 2 additions & 0 deletions code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ var/list/roundstart_mod_verbs = list(
add_verb(src, /client/proc/toggle_join_xeno)
add_verb(src, /client/proc/game_master_rename_platoon)
add_verb(src, /client/proc/toggle_vehicle_blockers)
add_verb(src, /client/proc/toggle_rappel_menu)
if(CLIENT_HAS_RIGHTS(src, R_SERVER))
add_verb(src, admin_verbs_server)
if(CLIENT_HAS_RIGHTS(src, R_DEBUG))
Expand Down Expand Up @@ -363,6 +364,7 @@ var/list/roundstart_mod_verbs = list(
/client/proc/toggle_join_xeno,
/client/proc/game_master_rename_platoon,
/client/proc/toggle_vehicle_blockers,
/client/proc/toggle_rappel_menu,
admin_verbs_admin,
admin_verbs_ban,
admin_verbs_minor_event,
Expand Down
108 changes: 108 additions & 0 deletions code/modules/admin/game_master/extra_buttons/rappel_menu.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
GLOBAL_LIST_EMPTY(game_master_rappels)
GLOBAL_DATUM_INIT(rappel_panel, /datum/rappel_menu, new)
#define RAPPEL_CLICK_INTERCEPT_ACTION "rappel_click_intercept_action"

/client/proc/toggle_rappel_menu()
set name = "Rappel Menu"
set category = "Game Master.Extras"
if(!check_rights(R_ADMIN))
return

GLOB.rappel_panel.tgui_interact(mob)

/datum/rappel_menu
var/rappel_click_intercept = FALSE

/datum/rappel_menu/ui_data(mob/user)
. = ..()

var/list/data = list()

data["game_master_rappels"] = length(GLOB.game_master_rappels) ? GLOB.game_master_rappels : ""
data["rappel_click_intercept"] = rappel_click_intercept
return data

/datum/rappel_menu/proc/InterceptClickOn(mob/user, params, atom/object)
var/list/modifiers = params2list(params)
if(rappel_click_intercept)
var/turf/object_turf = get_turf(object)
if(LAZYACCESS(modifiers, MIDDLE_CLICK))
for(var/obj/effect/landmark/rappel/R in object_turf)
GLOB.game_master_rappels -= R
QDEL_NULL(R)
return TRUE

var/obj/effect/landmark/rappel/rappel = new(object_turf)
var/rappel_ref = REF(rappel)
GLOB.game_master_rappels += list(list(
"rappel" = rappel,
"rappel_name" = rappel.name,
"rappel_ref" = rappel_ref,
))
return TRUE

/datum/rappel_menu/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "GameMasterRappelMenu", "Rappel Menu")
ui.open()
user.client?.click_intercept = src
/datum/rappel_menu/ui_status(mob/user, datum/ui_state/state)
return UI_INTERACTIVE


/datum/rappel_menu/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()

switch(action)
if("remove_rappel")
if(!params["val"])
return

var/list/rappel = params["val"]

var/atom/rappel_atom = locate(rappel["rappel_ref"])

if(!rappel_atom)
return TRUE

if(tgui_alert(ui.user, "Do you want to remove [rappel_atom] ?", "Confirmation", list("Yes", "No")) != "Yes")
return TRUE

remove_rappel(rappel_atom)

if("jump_to_rappel")
if(!params["val"])
return

var/list/rappel = params["val"]

var/atom/rappel_atom = locate(rappel["rappel_ref"])

var/turf/rappel_turf = get_turf(rappel_atom)

if(!rappel_turf)
return TRUE

var/client/jumping_client = ui.user.client
jumping_client.jump_to_turf(rappel_turf)
return TRUE

if("toggle_click_rappel")
rappel_click_intercept = !rappel_click_intercept
return

/datum/rappel_menu/ui_close(mob/user)
var/client/user_client = user.client
if(user_client?.click_intercept == src)
user_client.click_intercept = null

rappel_click_intercept = FALSE

/datum/rappel_menu/proc/remove_rappel(obj/removing_datum)
SIGNAL_HANDLER

for(var/list/cycled_rappel in GLOB.game_master_rappels)
if(cycled_rappel["rappel"] == removing_datum)
GLOB.game_master_rappels.Remove(list(cycled_rappel))
QDEL_NULL(removing_datum)
1 change: 1 addition & 0 deletions colonialmarines.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,7 @@
#include "code\modules\admin\ToRban.dm"
#include "code\modules\admin\game_master\game_master.dm"
#include "code\modules\admin\game_master\game_master_submenu.dm"
#include "code\modules\admin\game_master\extra_buttons\rappel_menu.dm"
#include "code\modules\admin\game_master\extra_buttons\rename_platoon.dm"
#include "code\modules\admin\game_master\extra_buttons\toggle_join_xeno.dm"
#include "code\modules\admin\game_master\extra_buttons\toggle_vehicle_blockers.dm"
Expand Down
75 changes: 75 additions & 0 deletions tgui/packages/tgui/interfaces/GameMasterRappelMenu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { useBackend } from '../backend';
import { Button, Section, Collapsible, Stack, Divider } from '../components';
import { Window } from '../layouts';

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

return (
<Window width={400} height={250}>
<Window.Content scrollable>
<Stack direction="column" grow>
<GameMasterRappelPanel />
</Stack>
</Window.Content>
</Window>
);
};

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

return (
<Section title="Rappel" mb={1}>
<Stack direction="column">
<Stack.Item>
<Button
ml={1}
selected={data.rappel_click_intercept}
content="Click Rappel"
onClick={() => {
act('toggle_click_rappel');
}}
/>
</Stack.Item>
{data.game_master_rappels && (
<Stack.Item>
<Collapsible title="Rappel Points">
<Stack vertical>
{data.game_master_rappels.map((val) => {
if (val) {
return (
<Stack.Item>
<Divider />
<Stack>
<Stack.Item align="center">
<Button
content={val.rappel_name}
onClick={() => {
act('jump_to_rappel', { val });
}}
/>
</Stack.Item>
<Stack.Item>
<Button
content="X"
color="bad"
onClick={() => {
act('remove_rappel', { val });
}}
/>
</Stack.Item>
</Stack>
</Stack.Item>
);
}
})}
<Divider />
</Stack>
</Collapsible>
</Stack.Item>
)}
</Stack>
</Section>
);
};

0 comments on commit 51beb83

Please sign in to comment.