Merge remote-tracking branch 'ParadiseSS13/master' into toml-config

This commit is contained in:
AffectedArc07
2021-07-09 11:42:23 +01:00
210 changed files with 1803 additions and 2434 deletions
+64
View File
@@ -247,6 +247,70 @@ GLOBAL_VAR_INIT(admin_ooc_colour, "#b82e00")
if(send)
to_chat(target, "<span class='ooc'><span class='looc'>LOOC<span class='prefix'>[prefix]: </span><EM>[display_name][admin_stuff]:</EM> <span class='message'>[msg]</span></span></span>")
// Ported from /tg/, full credit to SpaceManiac and Timberpoes.
/client/verb/fit_viewport()
set name = "Fit Viewport"
set desc = "Fit the size of the map window to match the viewport."
set category = "OOC"
// Fetch aspect ratio
var/list/view_size = getviewsize(view)
var/aspect_ratio = view_size[1] / view_size[2]
// Calculate desired pixel width using window size and aspect ratio
var/list/sizes = params2list(winget(src, "mainwindow.mainvsplit;mapwindow", "size"))
// Client closed the window? Some other error? This is unexpected behaviour, let's CRASH with some info.
if(!sizes["mapwindow.size"])
CRASH("sizes does not contain mapwindow.size key. This means a winget() failed to return what we wanted. --- sizes var: [sizes] --- sizes length: [length(sizes)]")
var/list/map_size = splittext(sizes["mapwindow.size"], "x")
// Looks like we didn't expect mapwindow.size to be "ixj" where i and j are numbers.
// If we don't get our expected 2 outputs, let's give some useful error info.
if(length(map_size) != 2)
CRASH("map_size of incorrect length --- map_size var: [map_size] --- map_size length: [length(map_size)]")
var/height = text2num(map_size[2])
var/desired_width = round(height * aspect_ratio)
if(text2num(map_size[1]) == desired_width)
// Nothing to do.
return
var/list/split_size = splittext(sizes["mainwindow.mainvsplit.size"], "x")
var/split_width = text2num(split_size[1])
// Avoid auto-resizing the statpanel and chat into nothing.
desired_width = min(desired_width, split_width - 300)
// Calculate and apply a best estimate
// +4 pixels are for the width of the splitter's handle
var/pct = 100 * (desired_width + 4) / split_width
winset(src, "mainwindow.mainvsplit", "splitter=[pct]")
// Apply an ever-lowering offset until we finish or fail
var/delta
for(var/safety in 1 to 10)
var/after_size = winget(src, "mapwindow", "size")
map_size = splittext(after_size, "x")
var/produced_width = text2num(map_size[1])
if(produced_width == desired_width)
// Success!
return
else if(isnull(delta))
// Calculate a probably delta based on the difference
delta = 100 * (desired_width - produced_width) / split_width
else if((delta > 0 && produced_width > desired_width) || (delta < 0 && produced_width < desired_width))
// If we overshot, halve the delta and reverse direction
delta = -delta / 2
pct += delta
winset(src, "mainwindow.mainvsplit", "splitter=[pct]")
/mob/proc/get_looc_source()
return src