mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 13:10:02 +01:00
[MIRROR] Add admin panel for viewing circuits (#7389)
* Add admin panel for viewing circuits * Update admin_verbs.dm * Update admin_verbs.dm Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> Co-authored-by: Gandalf <jzo123@hotmail.com>
This commit is contained in:
co-authored by
Mothblocks
Gandalf
parent
19ef84aba6
commit
4e4647bd71
@@ -87,7 +87,8 @@ GLOBAL_PROTECT(admin_verbs_admin)
|
||||
/client/proc/admin_open_event_spawners_menu, //SKYRAT EDIT ADDITION - EVENTS
|
||||
/datum/admins/proc/toggleaooc, //SKYRAT EDIT ADDITION - ADMIN
|
||||
/datum/admins/proc/togglesooc, //SKYRAT EDIT ADDITION - ADMIN
|
||||
/datum/admins/proc/open_borgopanel
|
||||
/datum/admins/proc/open_borgopanel,
|
||||
/datum/admins/proc/view_all_circuits,
|
||||
)
|
||||
GLOBAL_LIST_INIT(admin_verbs_ban, list(/client/proc/unban_panel, /client/proc/ban_panel, /client/proc/stickybanpanel))
|
||||
GLOBAL_PROTECT(admin_verbs_ban)
|
||||
|
||||
@@ -902,18 +902,7 @@
|
||||
if(!isobserver(usr) && !check_rights(R_ADMIN))
|
||||
return
|
||||
|
||||
var/atom/movable/AM = locate(href_list["adminplayerobservefollow"])
|
||||
|
||||
var/client/C = usr.client
|
||||
var/can_ghost = TRUE
|
||||
if(!isobserver(usr))
|
||||
can_ghost = C.admin_ghost()
|
||||
|
||||
if(!can_ghost)
|
||||
return
|
||||
var/mob/dead/observer/A = C.mob
|
||||
A.ManualFollow(AM)
|
||||
|
||||
usr.client?.admin_follow(locate(href_list["adminplayerobservefollow"]))
|
||||
else if(href_list["admingetmovable"])
|
||||
if(!check_rights(R_ADMIN))
|
||||
return
|
||||
|
||||
@@ -1199,3 +1199,17 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
|
||||
return 0
|
||||
|
||||
return max(0, days_needed - player_age)
|
||||
|
||||
/// Attempts to make the client orbit the given object, for administrative purposes.
|
||||
/// If they are not an observer, will try to aghost them.
|
||||
/client/proc/admin_follow(atom/movable/target)
|
||||
var/can_ghost = TRUE
|
||||
|
||||
if (!isobserver(mob))
|
||||
can_ghost = admin_ghost()
|
||||
|
||||
if(!can_ghost)
|
||||
return FALSE
|
||||
|
||||
var/mob/dead/observer/observer = mob
|
||||
observer.ManualFollow(target)
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/// An admin verb to view all circuits, plus useful information
|
||||
/datum/admins/proc/view_all_circuits()
|
||||
set category = "Admin.Game"
|
||||
set name = "View All Circuits"
|
||||
|
||||
var/static/datum/circuit_admin_panel/circuit_admin_panel = new
|
||||
circuit_admin_panel.ui_interact(usr)
|
||||
|
||||
/datum/circuit_admin_panel
|
||||
|
||||
/datum/circuit_admin_panel/ui_static_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["circuits"] = list()
|
||||
|
||||
for (var/obj/item/integrated_circuit/circuit as anything in GLOB.integrated_circuits)
|
||||
var/datum/mind/inserter = circuit.inserter_mind?.resolve()
|
||||
|
||||
data["circuits"] += list(list(
|
||||
"ref" = REF(circuit),
|
||||
"name" = "[circuit.name] in [loc_name(circuit)]",
|
||||
"creator" = circuit.get_creator(),
|
||||
"has_inserter" = !isnull(inserter),
|
||||
))
|
||||
|
||||
return data
|
||||
|
||||
/datum/circuit_admin_panel/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
||||
. = ..()
|
||||
if (.)
|
||||
return .
|
||||
|
||||
if (!istext(params["circuit"]))
|
||||
return FALSE
|
||||
|
||||
var/obj/item/integrated_circuit/circuit = locate(params["circuit"])
|
||||
if (!istype(circuit))
|
||||
to_chat(usr, span_warning("That circuit no longer exists."))
|
||||
return FALSE
|
||||
|
||||
switch (action)
|
||||
if ("duplicate_circuit")
|
||||
if (alert(usr, "This will spawn the new circuit at where you are, are you sure?", "Confirm", "Yes", "No") != "Yes")
|
||||
return FALSE
|
||||
|
||||
var/list/errors = list()
|
||||
|
||||
var/obj/item/integrated_circuit/loaded/new_circuit = new(usr.drop_location())
|
||||
new_circuit.load_circuit_data(circuit.convert_to_json(), errors)
|
||||
|
||||
if (length(errors))
|
||||
to_chat(usr, span_warning("Somehow, duplicating the circuit failed:"))
|
||||
for (var/error in errors)
|
||||
to_chat(usr, span_warning(error))
|
||||
if ("follow_circuit")
|
||||
usr.client?.admin_follow(circuit)
|
||||
if ("save_circuit")
|
||||
circuit.attempt_save_to(usr.client)
|
||||
if ("vv_circuit")
|
||||
usr.client?.debug_variables(circuit)
|
||||
if ("open_circuit")
|
||||
circuit.ui_interact(usr)
|
||||
if ("open_player_panel")
|
||||
var/datum/mind/inserter = circuit.inserter_mind?.resolve()
|
||||
usr.client?.holder?.show_player_panel(inserter?.current)
|
||||
|
||||
return TRUE
|
||||
|
||||
/datum/circuit_admin_panel/ui_state(mob/user)
|
||||
return GLOB.admin_state
|
||||
|
||||
/datum/circuit_admin_panel/ui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
ui = new(user, src, "CircuitAdminPanel")
|
||||
ui.open()
|
||||
@@ -1,3 +1,6 @@
|
||||
/// A list of all integrated circuits
|
||||
GLOBAL_LIST_EMPTY_TYPED(integrated_circuits, /obj/item/integrated_circuit)
|
||||
|
||||
/**
|
||||
* # Integrated Circuitboard
|
||||
*
|
||||
@@ -53,6 +56,9 @@
|
||||
|
||||
/obj/item/integrated_circuit/Initialize()
|
||||
. = ..()
|
||||
|
||||
GLOB.integrated_circuits += src
|
||||
|
||||
RegisterSignal(src, COMSIG_ATOM_USB_CABLE_TRY_ATTACH, .proc/on_atom_usb_cable_try_attach)
|
||||
|
||||
/obj/item/integrated_circuit/loaded/Initialize()
|
||||
@@ -68,6 +74,7 @@
|
||||
examined_component = null
|
||||
owner_id = null
|
||||
QDEL_NULL(cell)
|
||||
GLOB.integrated_circuits -= src
|
||||
return ..()
|
||||
|
||||
/obj/item/integrated_circuit/examine(mob/user)
|
||||
@@ -468,14 +475,7 @@
|
||||
examined_component = null
|
||||
. = TRUE
|
||||
if("save_circuit")
|
||||
var/client/saver = usr.client
|
||||
if(!check_rights_for(saver, R_VAREDIT))
|
||||
return
|
||||
var/temp_file = file("data/CircuitDownloadTempFile")
|
||||
fdel(temp_file)
|
||||
WRITE_FILE(temp_file, convert_to_json())
|
||||
DIRECT_OUTPUT(saver, ftp(temp_file, "[display_name || "circuit"].json"))
|
||||
. = TRUE
|
||||
return attempt_save_to(usr.client)
|
||||
|
||||
/obj/item/integrated_circuit/proc/on_atom_usb_cable_try_attach(datum/source, obj/item/usb_cable/usb_cable, mob/user)
|
||||
SIGNAL_HANDLER
|
||||
@@ -507,3 +507,13 @@
|
||||
id_card = owner_id.resolve()
|
||||
|
||||
return "[src] (Shell: [shell || "*null*"], Inserter: [key_name(inserter, include_link)], Owner ID: [id_card?.name || "*null*"])"
|
||||
|
||||
/// Attempts to save a circuit to a given client
|
||||
/obj/item/integrated_circuit/proc/attempt_save_to(client/saver)
|
||||
if(!check_rights_for(saver, R_VAREDIT))
|
||||
return FALSE
|
||||
var/temp_file = file("data/CircuitDownloadTempFile")
|
||||
fdel(temp_file)
|
||||
WRITE_FILE(temp_file, convert_to_json())
|
||||
DIRECT_OUTPUT(saver, ftp(temp_file, "[display_name || "circuit"].json"))
|
||||
return TRUE
|
||||
|
||||
@@ -3718,6 +3718,7 @@
|
||||
#include "code\modules\vending\toys.dm"
|
||||
#include "code\modules\vending\wardrobes.dm"
|
||||
#include "code\modules\vending\youtool.dm"
|
||||
#include "code\modules\wiremod\admin_panel.dm"
|
||||
#include "code\modules\wiremod\component.dm"
|
||||
#include "code\modules\wiremod\component_printer.dm"
|
||||
#include "code\modules\wiremod\datatypes.dm"
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
import { BooleanLike } from "common/react";
|
||||
import { useBackend } from "../backend";
|
||||
import { Button, Table } from "../components";
|
||||
import { Window } from "../layouts";
|
||||
|
||||
type CircuitAdminPanelData = {
|
||||
circuits: {
|
||||
ref: string;
|
||||
name: string;
|
||||
creator: string;
|
||||
has_inserter: BooleanLike;
|
||||
}[]
|
||||
}
|
||||
|
||||
export const CircuitAdminPanel = (props, context) => {
|
||||
const { act, data } = useBackend<CircuitAdminPanelData>(context);
|
||||
|
||||
return (
|
||||
<Window title="Circuit Admin Panel" width={1200} height={500} resizable>
|
||||
<Window.Content>
|
||||
<Table>
|
||||
<Table.Row header>
|
||||
<Table.Cell>
|
||||
Circuit name
|
||||
</Table.Cell>
|
||||
|
||||
<Table.Cell>
|
||||
Creator
|
||||
</Table.Cell>
|
||||
|
||||
<Table.Cell>
|
||||
Actions
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
|
||||
{data.circuits.map(circuit => {
|
||||
const createAct = (action: string) => () => {
|
||||
act(action, { circuit: circuit.ref });
|
||||
};
|
||||
|
||||
return (
|
||||
<Table.Row key={circuit.ref}>
|
||||
<Table.Cell>
|
||||
{circuit.name}
|
||||
</Table.Cell>
|
||||
|
||||
<Table.Cell>
|
||||
{circuit.creator}
|
||||
</Table.Cell>
|
||||
|
||||
<Table.Cell>
|
||||
<Button onClick={createAct("follow_circuit")}>
|
||||
Follow
|
||||
</Button>
|
||||
|
||||
<Button onClick={createAct("open_circuit")}>
|
||||
Open
|
||||
</Button>
|
||||
|
||||
<Button onClick={createAct("vv_circuit")}>
|
||||
VV
|
||||
</Button>
|
||||
|
||||
<Button onClick={createAct("save_circuit")}>
|
||||
Save
|
||||
</Button>
|
||||
|
||||
<Button onClick={createAct("duplicate_circuit")}>
|
||||
Duplicate
|
||||
</Button>
|
||||
|
||||
{!!circuit.has_inserter && (
|
||||
<Button onClick={createAct("open_player_panel")}>
|
||||
Player Panel
|
||||
</Button>
|
||||
)}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
);
|
||||
})}
|
||||
</Table>
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user