mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
[admin] Adds a system to assign roles to players in the lobby (#20778)
* [admin] [events] Adds a system to assign roles to players in the lobby * Fucking linter
This commit is contained in:
@@ -354,6 +354,7 @@ SUBSYSTEM_DEF(job)
|
||||
initial_players_to_assign = unassigned.len
|
||||
|
||||
JobDebug("DO, Len: [unassigned.len]")
|
||||
GLOB.event_role_manager.setup_event_positions()
|
||||
if(unassigned.len == 0)
|
||||
return validate_required_jobs(required_jobs)
|
||||
|
||||
|
||||
105
code/modules/admin/admin_events/event_role_manager.dm
Normal file
105
code/modules/admin/admin_events/event_role_manager.dm
Normal file
@@ -0,0 +1,105 @@
|
||||
GLOBAL_DATUM_INIT(event_role_manager, /datum/event_role_manager, new)
|
||||
|
||||
/client/proc/event_role_manager()
|
||||
set name = "Event Role Manager"
|
||||
set category = "Event"
|
||||
GLOB.event_role_manager.ui_interact(mob)
|
||||
|
||||
/datum/event_role_manager
|
||||
var/role_assignments = list()
|
||||
|
||||
/datum/event_role_manager/ui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
ui = new(user, src, "EventRoleManager")
|
||||
ui.open()
|
||||
|
||||
/datum/event_role_manager/ui_state(mob/user)
|
||||
return GLOB.fun_state
|
||||
|
||||
/datum/event_role_manager/ui_data(mob/user)
|
||||
. = ..()
|
||||
|
||||
var/list/assignments = list()
|
||||
for(var/ckey in role_assignments)
|
||||
var/ckey_data = list()
|
||||
var/datum/event_role_assignment/assignment = role_assignments[ckey]
|
||||
ckey_data["ckey"] = ckey
|
||||
ckey_data["title"] = assignment.title
|
||||
ckey_data["role_alt_title"] = assignment.role_alt_title
|
||||
assignments.Add(list(ckey_data))
|
||||
.["assignments"] = assignments
|
||||
|
||||
var/jobs = list()
|
||||
for(var/job in SSjob.name_occupations_all)
|
||||
jobs += job
|
||||
.["jobs"] = jobs
|
||||
|
||||
/datum/event_role_manager/ui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
var/ckey = ckey(params["ckey"])
|
||||
switch(action)
|
||||
if("addCkey")
|
||||
LAZYSET(role_assignments, ckey, new /datum/event_role_assignment)
|
||||
return TRUE
|
||||
if("setTitle")
|
||||
var/datum/event_role_assignment/assignment = LAZYACCESS(role_assignments, ckey)
|
||||
if(assignment)
|
||||
assignment.title = params["title"]
|
||||
return TRUE
|
||||
if("setAltTitle")
|
||||
var/datum/event_role_assignment/assignment = LAZYACCESS(role_assignments, ckey)
|
||||
if(assignment)
|
||||
assignment.role_alt_title = params["alt_title"]
|
||||
return TRUE
|
||||
if("removeCkey")
|
||||
LAZYREMOVE(role_assignments, ckey)
|
||||
return TRUE
|
||||
|
||||
/datum/event_role_manager/proc/admin_status_panel(var/list/items)
|
||||
if(!LAZYLEN(role_assignments))
|
||||
return
|
||||
|
||||
items += "Assigned player status:"
|
||||
|
||||
for(var/ckey in role_assignments)
|
||||
var/client/client = GLOB.directory[ckey]
|
||||
if(!client)
|
||||
items += "<font color='red'>[ckey] is not connected</font>"
|
||||
continue
|
||||
var/mob/player = client.mob
|
||||
if(!istype(player, /mob/dead/new_player))
|
||||
items += "<font color='red'>[ckey] is type [player.type]</font>"
|
||||
else
|
||||
var/mob/dead/new_player/new_player = player
|
||||
if(new_player.ready == PLAYER_READY_TO_PLAY)
|
||||
items += "<font color='green'>[ckey] - Ready</font>"
|
||||
else
|
||||
items += "<font color='red'>[ckey] - Not Ready</font>"
|
||||
|
||||
/datum/event_role_manager/proc/setup_event_positions()
|
||||
for(var/ckey in role_assignments)
|
||||
var/client/client = GLOB.directory[ckey]
|
||||
if(!client)
|
||||
message_admins("[ckey] is not connected")
|
||||
continue
|
||||
var/mob/player = client.mob
|
||||
var/datum/event_role_assignment/assignment = role_assignments[ckey]
|
||||
if(!istype(player, /mob/dead/new_player))
|
||||
message_admins("[ckey] is not in the lobby!")
|
||||
continue
|
||||
if(assignment.title)
|
||||
player.mind.assigned_role = assignment.title
|
||||
if(assignment.role_alt_title)
|
||||
player.mind.role_alt_title = assignment.role_alt_title
|
||||
SSjob.unassigned -= player
|
||||
|
||||
var/mob/dead/new_player/new_player = player
|
||||
if(new_player.ready != PLAYER_READY_TO_PLAY)
|
||||
message_admins("[ckey] is not ready, forcing ready")
|
||||
new_player.ready = PLAYER_READY_TO_PLAY
|
||||
|
||||
/datum/event_role_assignment
|
||||
var/title
|
||||
var/role_alt_title
|
||||
@@ -130,7 +130,8 @@ GLOBAL_LIST_INIT(admin_verbs_fun, list(
|
||||
/client/proc/admin_vox, // yogs - Admin AI Vox
|
||||
/client/proc/admin_away,
|
||||
/client/proc/centcom_podlauncher,/*Open a window to launch a Supplypod and configure it or it's contents*/
|
||||
/client/proc/load_json_admin_event
|
||||
/client/proc/load_json_admin_event,
|
||||
/client/proc/event_role_manager
|
||||
))
|
||||
GLOBAL_PROTECT(admin_verbs_fun)
|
||||
GLOBAL_LIST_INIT(admin_verbs_spawn, list(/datum/admins/proc/spawn_atom, /datum/admins/proc/podspawn_atom, /datum/admins/proc/spawn_cargo, /datum/admins/proc/spawn_objasmob, /client/proc/respawn_character, /datum/admins/proc/beaker_panel))
|
||||
|
||||
@@ -53,6 +53,7 @@ INITIALIZE_IMMEDIATE(/mob/dead)
|
||||
. += "Players: [SSticker.totalPlayers]"
|
||||
if(client.holder)
|
||||
. += "Players Ready: [SSticker.totalPlayersReady]"
|
||||
GLOB.event_role_manager.admin_status_panel(.)
|
||||
|
||||
/mob/dead/proc/server_hop()
|
||||
set category = "OOC"
|
||||
|
||||
6
code/modules/tgui/states/fun.dm
Normal file
6
code/modules/tgui/states/fun.dm
Normal file
@@ -0,0 +1,6 @@
|
||||
GLOBAL_DATUM_INIT(fun_state, /datum/ui_state/fun_state, new)
|
||||
|
||||
/datum/ui_state/fun_state/can_use_topic(src_object, mob/user)
|
||||
if(check_rights_for(user.client, R_FUN))
|
||||
return UI_INTERACTIVE
|
||||
return UI_CLOSE
|
||||
84
tgui/packages/tgui/interfaces/EventRoleManager.tsx
Normal file
84
tgui/packages/tgui/interfaces/EventRoleManager.tsx
Normal file
@@ -0,0 +1,84 @@
|
||||
import { KEY_ENTER } from '../../common/keycodes';
|
||||
import { useBackend, useLocalState } from '../backend';
|
||||
import { Button, Flex, NoticeBox, Section, ProgressBar, Table, Box, Input, Dropdown } from '../components';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
type RoleManagerContext = {
|
||||
assignments: Assignment[];
|
||||
jobs: string[];
|
||||
};
|
||||
|
||||
type Assignment = {
|
||||
ckey: string;
|
||||
title: string;
|
||||
role_alt_title: string
|
||||
}
|
||||
|
||||
export const EventRoleManager = (props, context) => {
|
||||
const { data, act } = useBackend<RoleManagerContext>(context);
|
||||
const { assignments, jobs } = data;
|
||||
|
||||
const [
|
||||
message,
|
||||
setMessage,
|
||||
] = useLocalState(context, 'text', '');
|
||||
|
||||
return (
|
||||
<Window width={700}
|
||||
height={700}
|
||||
title="Event Role Manager"
|
||||
resizable>
|
||||
<Window.Content>
|
||||
<Section fill title="Role Assignments" buttons={(
|
||||
<Box>
|
||||
<Input value={message} onChange={(e, value) => {
|
||||
if (e.keyCode === KEY_ENTER) {
|
||||
act('addCkey', { 'ckey': value });
|
||||
e.target.value = '';
|
||||
setMessage('');
|
||||
} else {
|
||||
setMessage(value);
|
||||
}
|
||||
}} />
|
||||
<Button icon="plus" color="good" onClick={(e, value) => {
|
||||
act('addCkey', { 'ckey': message });
|
||||
setMessage('');
|
||||
}} />
|
||||
</Box>
|
||||
)}>
|
||||
<Table>
|
||||
<Table.Row>
|
||||
<Table.Cell>
|
||||
Ckey
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
Job
|
||||
</Table.Cell>
|
||||
<Table.Cell pl="10px">
|
||||
Title
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
{assignments.map(assignment => (
|
||||
<Table.Row key={assignment.ckey}>
|
||||
<Table.Cell width="150px">
|
||||
{assignment.ckey}
|
||||
</Table.Cell>
|
||||
<Table.Cell collapsing py="3px">
|
||||
<Dropdown width="200px" selected={assignment.title} options={jobs} onSelected={value => act("setTitle", { ckey: assignment.ckey, title: value })} />
|
||||
</Table.Cell>
|
||||
<Table.Cell px="10px">
|
||||
<Input value={assignment.role_alt_title} width="100%" onChange={(e, value) => {
|
||||
act("setAltTitle", { ckey: assignment.ckey, alt_title: value });
|
||||
}} />
|
||||
</Table.Cell>
|
||||
<Table.Cell collapsing>
|
||||
<Button icon="trash" color="bad" onClick={() => act('removeCkey', { ckey: assignment.ckey })} />
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</Section>
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
};
|
||||
@@ -1543,6 +1543,7 @@
|
||||
#include "code\modules\admin\topic.dm"
|
||||
#include "code\modules\admin\whitelist.dm"
|
||||
#include "code\modules\admin\admin_events\admin_events.dm"
|
||||
#include "code\modules\admin\admin_events\event_role_manager.dm"
|
||||
#include "code\modules\admin\permissions\database.dm"
|
||||
#include "code\modules\admin\permissions\forums.dm"
|
||||
#include "code\modules\admin\permissions\permissions.dm"
|
||||
@@ -3689,6 +3690,7 @@
|
||||
#include "code\modules\tgui\states\contained.dm"
|
||||
#include "code\modules\tgui\states\deep_inventory.dm"
|
||||
#include "code\modules\tgui\states\default.dm"
|
||||
#include "code\modules\tgui\states\fun.dm"
|
||||
#include "code\modules\tgui\states\hands.dm"
|
||||
#include "code\modules\tgui\states\holder.dm"
|
||||
#include "code\modules\tgui\states\human_adjacent.dm"
|
||||
|
||||
Reference in New Issue
Block a user