mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-12 00:27:31 +01:00
21b4095dfd
Upstream 04/17/2026 fixes https://github.com/Bubberstation/Bubberstation/issues/5549 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com> Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com> Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com> Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com> Co-authored-by: loganuk <fakeemail123@aol.com> Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com> Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com> Co-authored-by: Lucy <lucy@absolucy.moe> Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com> Co-authored-by: Isratosh <Isratosh@hotmail.com> Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com> Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com> Co-authored-by: Alexander V. <volas@ya.ru> Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com> Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com> Co-authored-by: Tim <timothymtorres@gmail.com> Co-authored-by: Iamgoofball <iamgoofball@gmail.com> Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com> Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com> Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com> Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com> Co-authored-by: Josh <josh.adam.powell@gmail.com> Co-authored-by: Josh Powell <josh.powell@softwire.com> Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com> Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com> Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com> Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
135 lines
3.8 KiB
Plaintext
135 lines
3.8 KiB
Plaintext
/**
|
|
* A generic background object.
|
|
* It is also implicitly used to allocate a rectangle on the map, which will
|
|
* be used for auto-scaling the map.
|
|
*/
|
|
/atom/movable/screen/background
|
|
name = "background"
|
|
icon = 'icons/hud/map_backgrounds.dmi'
|
|
icon_state = "clear"
|
|
layer = GAME_PLANE
|
|
plane = GAME_PLANE
|
|
|
|
/**
|
|
* Sets screen_loc of this screen object, in form of point coordinates,
|
|
* with optional pixel offset (px, py).
|
|
*
|
|
* If applicable, "assigned_map" has to be assigned before this proc call.
|
|
*/
|
|
/atom/movable/screen/proc/set_position(x, y, px = 0, py = 0)
|
|
if(assigned_map)
|
|
screen_loc = "[assigned_map]:[x]:[px],[y]:[py]"
|
|
else
|
|
screen_loc = "[x]:[px],[y]:[py]"
|
|
|
|
/**
|
|
* Sets screen_loc to fill a rectangular area of the map.
|
|
*
|
|
* If applicable, "assigned_map" has to be assigned before this proc call.
|
|
*/
|
|
/atom/movable/screen/proc/fill_rect(x1, y1, x2, y2)
|
|
if(assigned_map)
|
|
screen_loc = "[assigned_map]:[x1],[y1] to [x2],[y2]"
|
|
else
|
|
screen_loc = "[x1],[y1] to [x2],[y2]"
|
|
|
|
/**
|
|
* Registers screen obj with the client, which makes it visible on the
|
|
* assigned map, and becomes a part of the assigned map's lifecycle.
|
|
*/
|
|
/client/proc/register_map_obj(atom/movable/screen/screen_obj)
|
|
if(!screen_obj.assigned_map)
|
|
CRASH("Can't register [screen_obj] without 'assigned_map' property.")
|
|
if(!screen_maps[screen_obj.assigned_map])
|
|
screen_maps[screen_obj.assigned_map] = list()
|
|
// NOTE: Possibly an expensive operation
|
|
var/list/screen_map = screen_maps[screen_obj.assigned_map]
|
|
screen_map |= screen_obj
|
|
screen |= screen_obj
|
|
|
|
/**
|
|
* Clears the map of registered screen objects.
|
|
*/
|
|
/client/proc/clear_map(map_name)
|
|
if(!map_name || !screen_maps[map_name])
|
|
return FALSE
|
|
for(var/atom/movable/screen/screen_obj in screen_maps[map_name])
|
|
screen_maps[map_name] -= screen_obj
|
|
screen -= screen_obj
|
|
if(screen_obj.del_on_map_removal)
|
|
qdel(screen_obj)
|
|
screen_maps -= map_name
|
|
|
|
/**
|
|
* Clears all the maps of registered screen objects.
|
|
*/
|
|
/client/proc/clear_all_maps()
|
|
for(var/map_name in screen_maps)
|
|
clear_map(map_name)
|
|
|
|
/**
|
|
* Creates a popup window with a basic map element in it, without any
|
|
* further initialization.
|
|
*
|
|
* Ratio is how many pixels by how many pixels (keep it simple).
|
|
*
|
|
* Returns a map name.
|
|
*/
|
|
/client/proc/create_popup(name, title, ratiox = 100, ratioy = 100)
|
|
winclone(src, "popupwindow", name)
|
|
var/list/winparams = list()
|
|
winparams["title"] = title
|
|
winparams["size"] = "[ratiox]x[ratioy]"
|
|
winparams["on-close"] = "handle-popup-close [name]"
|
|
winset(src, "[name]", list2params(winparams))
|
|
winshow(src, "[name]", 1)
|
|
|
|
var/list/params = list()
|
|
params["parent"] = "[name]"
|
|
params["type"] = "map"
|
|
params["size"] = "[ratiox]x[ratioy]"
|
|
params["anchor1"] = "0,0"
|
|
params["anchor2"] = "[ratiox],[ratioy]"
|
|
winset(src, "[name]_map", list2params(params))
|
|
|
|
return "[name]_map"
|
|
|
|
/**
|
|
* Create the popup, and get it ready for generic use by giving
|
|
* it a background.
|
|
*
|
|
* Width and height are multiplied by 64 by default.
|
|
*/
|
|
/client/proc/setup_popup(popup_name, width = 9, height = 9, \
|
|
tilesize = 2, title, bg_icon)
|
|
if(!popup_name)
|
|
return
|
|
clear_map("[popup_name]_map")
|
|
var/x_value = ICON_SIZE_X * tilesize * width
|
|
var/y_value = ICON_SIZE_Y * tilesize * height
|
|
var/map_name = create_popup(popup_name, title, x_value, y_value)
|
|
|
|
var/atom/movable/screen/background/background = new
|
|
background.assigned_map = map_name
|
|
background.fill_rect(1, 1, width, height)
|
|
if(bg_icon)
|
|
background.icon_state = bg_icon
|
|
register_map_obj(background)
|
|
|
|
return map_name
|
|
|
|
/**
|
|
* Closes a popup.
|
|
*/
|
|
/client/proc/close_popup(popup)
|
|
winshow(src, popup, 0)
|
|
handle_popup_close(popup)
|
|
|
|
/**
|
|
* When the popup closes in any way (player or proc call) it calls this.
|
|
*/
|
|
/client/verb/handle_popup_close(window_id as text)
|
|
set hidden = TRUE
|
|
clear_map("[window_id]_map")
|
|
SEND_SIGNAL(src, COMSIG_POPUP_CLEARED, window_id)
|