Skip to content

Commit 7d3707a

Browse files
committed
Merge branch 'master' of github.com:Monkestation/Monkestation2.0 into modlinks-except-i-didnt-fuck-it-up-this-time
2 parents 2c510bc + a59ef8e commit 7d3707a

File tree

49 files changed

+1033
-886
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1033
-886
lines changed

code/__DEFINES/computers.dm

+3
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313
#define CATEGORY_BITRUNNING_TECH "Tech"
1414
#define CATEGORY_BITRUNNING_COMBAT_GEAR "Combat gear" // monkeystation addition: bitrunning tech split up
1515
#define CATEGORY_BITRUNNING_ABILITIES "Abilities" // monkeystation addition: bitrunning tech split up
16+
17+
///Helper macro for record computers' preview views, used to ensure consistency in all use cases.
18+
#define USER_PREVIEW_ASSIGNED_VIEW(user_ckey) "preview_[user_ckey]_[REF(src)]_records"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// Window is fully visible and we can make fragile calls
2+
#define COMSIG_TGUI_WINDOW_VISIBLE "tgui_window_visible"

code/_onclick/hud/map_popups.dm

-11
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,6 @@
1919
/atom/movable/screen/proc/set_position(x, y, px = 0, py = 0)
2020
if(assigned_map)
2121
screen_loc = "[assigned_map]:[x]:[px],[y]:[py]"
22-
ASYNC
23-
// HACK: This fixes the character creator in 516 being small and relying on other byondui things (like cameras) to open in order to update and refresh.
24-
// This also will fix the camera console screen being offset, Gateway, and admin pod panel.
25-
// Adding 100 then setting it back seemed to do the trick!
26-
// Why the fuck does this work? This is some byond bug and I honestly have no fucking clue why this works.
27-
// I don't think plane master will be affected, I hope.
28-
// We're stuck in the belly of this awful machine.
29-
sleep(0.5 SECONDS) // If it's too fast, it has a chance to fail? Idk. This seems like a good number.
30-
screen_loc = "[assigned_map]:[x+100]:[px],[y+100]:[py]"
31-
sleep(0.5 SECONDS)
32-
screen_loc = "[assigned_map]:[x]:[px],[y]:[py]"
3322
else
3423
screen_loc = "[x]:[px],[y]:[py]"
3524

code/_onclick/hud/map_view.dm

+37-16
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/map_view)
1616

1717
/atom/movable/screen/map_view/Destroy()
1818
for(var/datum/weakref/client_ref in viewers_to_huds)
19-
var/client/our_client = client_ref.resolve()
20-
if(!istype(our_client) || QDELING(our_client))
21-
continue
22-
hide_from(our_client.mob)
19+
hide_from_client(client_ref.resolve())
2320

2421
return ..()
2522

@@ -31,42 +28,66 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/map_view)
3128
assigned_map = map_key
3229
set_position(1, 1)
3330

34-
/atom/movable/screen/map_view/proc/display_to(mob/show_to)
35-
if(QDELETED(show_to) || QDELETED(show_to.client))
36-
return
37-
show_to.client?.register_map_obj(src)
31+
/**
32+
* Generates and displays the map view to a client
33+
* Make sure you at least try to pass tgui_window if map view needed on UI,
34+
* so it will wait a signal from TGUI, which tells windows is fully visible.
35+
*
36+
* If you use map view not in TGUI, just call it as usualy.
37+
* If UI needs planes, call display_to_client.
38+
*
39+
* * show_to - Mob which needs map view
40+
* * window - Optional. TGUI window which needs map view
41+
*/
42+
/atom/movable/screen/map_view/proc/display_to(mob/show_to, datum/tgui_window/window)
43+
if(window && !window.visible)
44+
RegisterSignal(window, COMSIG_TGUI_WINDOW_VISIBLE, PROC_REF(display_on_ui_visible))
45+
else
46+
display_to_client(show_to.client)
47+
48+
/atom/movable/screen/map_view/proc/display_on_ui_visible(datum/tgui_window/window, client/show_to)
49+
SIGNAL_HANDLER
50+
display_to_client(show_to)
51+
UnregisterSignal(window, COMSIG_TGUI_WINDOW_VISIBLE)
52+
53+
/atom/movable/screen/map_view/proc/display_to_client(client/show_to)
54+
show_to.register_map_obj(src)
3855
// We need to add planesmasters to the popup, otherwise
3956
// blending fucks up massively. Any planesmaster on the main screen does
4057
// NOT apply to map popups. If there's ever a way to make planesmasters
4158
// omnipresent, then this wouldn't be needed.
4259
// We lazy load this because there's no point creating all these if none's gonna see em
4360

4461
// Store this info in a client -> hud pattern, so ghosts closing the window nukes the right group
45-
var/datum/weakref/client_ref = WEAKREF(show_to.client)
62+
var/datum/weakref/client_ref = WEAKREF(show_to)
4663

4764
var/datum/weakref/hud_ref = viewers_to_huds[client_ref]
4865
var/datum/hud/our_hud = hud_ref?.resolve()
49-
if(!QDELETED(our_hud))
66+
if(our_hud)
5067
return our_hud.get_plane_group(PLANE_GROUP_POPUP_WINDOW(src))
5168

5269
// Generate a new plane group for this case
5370
var/datum/plane_master_group/popup/pop_planes = new(PLANE_GROUP_POPUP_WINDOW(src), assigned_map)
54-
viewers_to_huds[client_ref] = WEAKREF(show_to.hud_used)
55-
pop_planes.attach_to(show_to.hud_used)
71+
viewers_to_huds[client_ref] = WEAKREF(show_to.mob.hud_used)
72+
pop_planes.attach_to(show_to.mob.hud_used)
5673

5774
return pop_planes
5875

5976
/atom/movable/screen/map_view/proc/hide_from(mob/hide_from)
60-
if(QDELETED(hide_from) || QDELETED(hide_from.canon_client))
77+
hide_from_client(hide_from?.canon_client)
78+
79+
/atom/movable/screen/map_view/proc/hide_from_client(client/hide_from)
80+
if(!hide_from)
6181
return
62-
hide_from?.canon_client.clear_map(assigned_map)
63-
var/client_ref = WEAKREF(hide_from?.canon_client)
82+
hide_from.clear_map(assigned_map)
6483

84+
var/datum/weakref/client_ref = WEAKREF(hide_from)
6585
// Make sure we clear the *right* hud
6686
var/datum/weakref/hud_ref = viewers_to_huds[client_ref]
6787
viewers_to_huds -= client_ref
88+
6889
var/datum/hud/clear_from = hud_ref?.resolve()
69-
if(QDELETED(clear_from))
90+
if(!clear_from)
7091
return
7192

7293
var/datum/plane_master_group/popup/pop_planes = clear_from.get_plane_group(PLANE_GROUP_POPUP_WINDOW(src))

code/controllers/subsystem/tgui.dm

+13-1
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,24 @@ SUBSYSTEM_DEF(tgui)
2626

2727
/datum/controller/subsystem/tgui/PreInit()
2828
basehtml = file2text('tgui/public/tgui.html')
29+
30+
// Inject inline helper functions
31+
var/helpers = file2text('tgui/public/helpers.min.js')
32+
helpers = "<script type='text/javascript'>\n[helpers]\n</script>"
33+
basehtml = replacetextEx(basehtml, "<!-- tgui:helpers -->", helpers)
34+
35+
// Inject inline ntos-error styles
36+
var/ntos_error = file2text('tgui/public/ntos-error.min.css')
37+
ntos_error = "<style type='text/css'>\n[ntos_error]\n</style>"
38+
basehtml = replacetextEx(basehtml, "<!-- tgui:ntos-error -->", ntos_error)
39+
2940
// Inject inline polyfills
3041
var/polyfill = file2text('tgui/public/tgui-polyfill.min.js')
31-
polyfill = "<script>\n[polyfill]\n</script>"
42+
polyfill = "<script type='text/javascript'>\n[polyfill]\n</script>"
3243
basehtml = replacetextEx(basehtml, "<!-- tgui:inline-polyfill -->", polyfill)
3344
basehtml = replacetextEx(basehtml, "<!-- tgui:nt-copyright -->", "Nanotrasen (c) 2525-[CURRENT_STATION_YEAR]")
3445

46+
3547
/datum/controller/subsystem/tgui/Shutdown()
3648
close_all_uis()
3749

code/game/machinery/computer/camera.dm

+30-17
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
var/list/concurrent_users = list()
1616

1717
// Stuff needed to render the map
18-
var/atom/movable/screen/map_view/cam_screen
19-
/// All the plane masters that need to be applied.
20-
var/atom/movable/screen/background/cam_background
18+
var/atom/movable/screen/map_view/camera/cam_screen
2119

2220
interaction_flags_machine = INTERACT_MACHINE_ALLOW_SILICON|INTERACT_MACHINE_SET_MACHINE|INTERACT_MACHINE_REQUIRES_SIGHT
2321

@@ -34,13 +32,9 @@
3432
// Initialize map objects
3533
cam_screen = new
3634
cam_screen.generate_view(map_name)
37-
cam_background = new
38-
cam_background.assigned_map = map_name
39-
cam_background.del_on_map_removal = FALSE
4035

4136
/obj/machinery/computer/security/Destroy()
4237
QDEL_NULL(cam_screen)
43-
QDEL_NULL(cam_background)
4438
return ..()
4539

4640
/obj/machinery/computer/security/connect_to_shuttle(mapload, obj/docking_port/mobile/port, obj/docking_port/stationary/dock)
@@ -67,12 +61,11 @@
6761
if(length(concurrent_users) == 1 && is_living)
6862
playsound(src, 'sound/machines/terminal_on.ogg', 25, FALSE)
6963
use_power(active_power_usage)
70-
// Register map objects
71-
cam_screen.display_to(user)
72-
user.client.register_map_obj(cam_background)
7364
// Open UI
7465
ui = new(user, src, "CameraConsole", name)
7566
ui.open()
67+
// Register map objects
68+
cam_screen.display_to(user, ui.window)
7669

7770
/obj/machinery/computer/security/ui_status(mob/user)
7871
. = ..()
@@ -126,7 +119,7 @@
126119
/obj/machinery/computer/security/proc/update_active_camera_screen()
127120
// Show static if can't use the camera
128121
if(!active_camera?.can_use())
129-
show_camera_static()
122+
cam_screen.show_camera_static()
130123
return
131124

132125
var/list/visible_turfs = list()
@@ -154,9 +147,7 @@
154147
var/size_x = bbox[3] - bbox[1] + 1
155148
var/size_y = bbox[4] - bbox[2] + 1
156149

157-
cam_screen.vis_contents = visible_turfs
158-
cam_background.icon_state = "clear"
159-
cam_background.fill_rect(1, 1, size_x, size_y)
150+
cam_screen.show_camera(visible_turfs, size_x, size_y)
160151

161152
/obj/machinery/computer/security/ui_close(mob/user)
162153
. = ..()
@@ -173,13 +164,35 @@
173164
playsound(src, 'sound/machines/terminal_off.ogg', 25, FALSE)
174165
use_power(0)
175166

176-
/obj/machinery/computer/security/proc/show_camera_static()
177-
cam_screen.vis_contents.Cut()
167+
/atom/movable/screen/map_view/camera
168+
/// All the plane masters that need to be applied.
169+
var/atom/movable/screen/background/cam_background
170+
171+
/atom/movable/screen/map_view/camera/Destroy()
172+
QDEL_NULL(cam_background)
173+
return ..()
174+
175+
/atom/movable/screen/map_view/camera/generate_view(map_key)
176+
. = ..()
177+
cam_background = new
178+
cam_background.del_on_map_removal = FALSE
179+
cam_background.assigned_map = assigned_map
180+
181+
/atom/movable/screen/map_view/camera/display_to_client(client/show_to)
182+
show_to.register_map_obj(cam_background)
183+
. = ..()
184+
185+
/atom/movable/screen/map_view/camera/proc/show_camera(list/visible_turfs, size_x, size_y)
186+
vis_contents = visible_turfs
187+
cam_background.icon_state = "clear"
188+
cam_background.fill_rect(1, 1, size_x, size_y)
189+
190+
/atom/movable/screen/map_view/camera/proc/show_camera_static()
191+
vis_contents.Cut()
178192
cam_background.icon_state = "scanline2"
179193
cam_background.fill_rect(1, 1, DEFAULT_MAP_SIZE, DEFAULT_MAP_SIZE)
180194

181195
// SECURITY MONITORS
182-
183196
/obj/machinery/computer/security/wooden_tv
184197
name = "security camera monitor"
185198
desc = "An old TV hooked into the station's camera network."

code/game/machinery/computer/records/medical.dm

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
return
3333
ui = SStgui.try_update_ui(user, src, ui)
3434
if (!ui)
35-
create_character_preview_view(user)
3635
ui = new(user, src, "MedicalRecords")
3736
ui.set_autoupdate(FALSE)
3837
ui.open()

code/game/machinery/computer/records/records.dm

+14-6
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@
1313
if(!has_access)
1414
return data
1515

16-
data["assigned_view"] = "preview_[user.ckey]_[REF(src)]_records"
16+
data["assigned_view"] = USER_PREVIEW_ASSIGNED_VIEW(user.ckey)
1717
data["station_z"] = !!(z && is_station_level(z))
1818

1919
return data
2020

21+
/obj/machinery/computer/records/ui_close(mob/user)
22+
. = ..()
23+
user.client?.screen_maps -= USER_PREVIEW_ASSIGNED_VIEW(user.ckey)
24+
if((LAZYLEN(open_uis) <= 1) && character_preview_view) //only delete the preview if we're the last one to close the console.
25+
QDEL_NULL(character_preview_view)
26+
2127
/obj/machinery/computer/records/ui_act(action, list/params, datum/tgui/ui)
2228
. = ..()
2329
if(.)
@@ -95,29 +101,31 @@
95101
return FALSE
96102

97103
playsound(src, "sound/machines/terminal_button0[rand(1, 8)].ogg", 50, TRUE)
98-
update_preview(user, params["assigned_view"], target)
104+
update_preview(user, params["assigned_view"], target, ui.window)
99105
return TRUE
100106

101107
return FALSE
102108

103109
/// Creates a character preview view for the UI.
104-
/obj/machinery/computer/records/proc/create_character_preview_view(mob/user)
105-
var/assigned_view = "preview_[user.ckey]_[REF(src)]_records"
110+
/obj/machinery/computer/records/proc/create_character_preview_view(mob/user, datum/tgui_window/window)
111+
var/assigned_view = USER_PREVIEW_ASSIGNED_VIEW(user.ckey)
106112
if(user.client?.screen_maps[assigned_view])
107113
return
108114

109115
var/atom/movable/screen/map_view/char_preview/new_view = new(null, src)
110116
new_view.generate_view(assigned_view)
111-
new_view.display_to(user)
117+
new_view.display_to(user, window)
118+
return new_view
112119

113120
/// Takes a record and updates the character preview view to match it.
114-
/obj/machinery/computer/records/proc/update_preview(mob/user, assigned_view, datum/record/crew/target)
121+
/obj/machinery/computer/records/proc/update_preview(mob/user, assigned_view, datum/record/crew/target, datum/tgui_window/window)
115122
var/mutable_appearance/preview = new(target.character_appearance)
116123
preview.underlays += mutable_appearance('icons/effects/effects.dmi', "static_base", alpha = 20)
117124
preview.add_overlay(mutable_appearance(generate_icon_alpha_mask('icons/effects/effects.dmi', "scanline"), alpha = 20))
118125

119126
var/atom/movable/screen/map_view/char_preview/old_view = user.client?.screen_maps[assigned_view]?[1]
120127
if(!old_view)
128+
character_preview_view = create_character_preview_view(user, window)
121129
return
122130

123131
old_view.appearance = preview.appearance

code/game/machinery/computer/records/security.dm

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
return
8181
ui = SStgui.try_update_ui(user, src, ui)
8282
if(!ui)
83-
character_preview_view = create_character_preview_view(user)
8483
ui = new(user, src, "SecurityRecords")
8584
ui.set_autoupdate(FALSE)
8685
ui.open()

code/game/objects/items.dm

+2-26
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
///How large is the object, used for stuff like whether it can fit in backpacks or not
9797
var/w_class = WEIGHT_CLASS_NORMAL
9898
///This is used to determine on which slots an item can fit.
99-
var/slot_flags = 0
99+
var/slot_flags = NONE
100100
pass_flags = PASSTABLE
101101
pressure_resistance = 4
102102
/// This var exists as a weird proxy "owner" ref
@@ -897,31 +897,7 @@
897897
if(!ismob(loc))
898898
return
899899
var/mob/owner = loc
900-
var/flags = slot_flags
901-
if(flags & ITEM_SLOT_OCLOTHING)
902-
owner.update_worn_oversuit()
903-
if(flags & ITEM_SLOT_ICLOTHING)
904-
owner.update_worn_undersuit()
905-
if(flags & ITEM_SLOT_GLOVES)
906-
owner.update_worn_gloves()
907-
if(flags & ITEM_SLOT_EYES)
908-
owner.update_worn_glasses()
909-
if(flags & ITEM_SLOT_EARS)
910-
owner.update_inv_ears()
911-
if(flags & ITEM_SLOT_MASK)
912-
owner.update_worn_mask()
913-
if(flags & ITEM_SLOT_HEAD)
914-
owner.update_worn_head()
915-
if(flags & ITEM_SLOT_FEET)
916-
owner.update_worn_shoes()
917-
if(flags & ITEM_SLOT_ID)
918-
owner.update_worn_id()
919-
if(flags & ITEM_SLOT_BELT)
920-
owner.update_worn_belt()
921-
if(flags & ITEM_SLOT_BACK)
922-
owner.update_worn_back()
923-
if(flags & ITEM_SLOT_NECK)
924-
owner.update_worn_neck()
900+
owner.update_clothing(slot_flags | owner.get_slot_by_item(src))
925901

926902
///Returns the temperature of src. If you want to know if an item is hot use this proc.
927903
/obj/item/proc/get_temperature()

code/game/objects/items/devices/spyglasses.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
/obj/item/clothing/glasses/hud/security/sunglasses/normal/spy/proc/on_screen_clear(client/source, window)
2222
SIGNAL_HANDLER
23-
linked_bug.cam_screen.hide_from(source.mob)
23+
linked_bug.cam_screen.hide_from_client(source)
2424

2525
/obj/item/clothing/glasses/hud/security/sunglasses/normal/spy/equipped(mob/user, slot)
2626
. = ..()

code/modules/admin/view_variables/color_matrix_editor.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
proxy_view.appearance = view
2727
proxy_view.color = current_color
28-
proxy_view.display_to(owner.mob)
2928

3029
/datum/color_matrix_editor/Destroy(force)
3130
QDEL_NULL(proxy_view)
@@ -51,6 +50,7 @@
5150
if(!ui)
5251
ui = new(user, src, "ColorMatrixEditor")
5352
ui.open()
53+
proxy_view.display_to(owner.mob, ui.window)
5454

5555
/datum/color_matrix_editor/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
5656
. = ..()

0 commit comments

Comments
 (0)