overhauls rendering + redoes some of widescreen/dynamic sizing + misc fixes (#4668)

Co-authored-by: VM_USER <VM_USER>
This commit is contained in:
silicons
2022-11-17 17:31:54 -06:00
committed by GitHub
co-authored by VM_USER <VM_USER>
parent 798902257c
commit bc5e0940a2
50 changed files with 1475 additions and 754 deletions
-46
View File
@@ -235,49 +235,3 @@
if(eyeobj)
return eyeobj
return src
/client/verb/fit_viewport()
set name = "Fit Viewport"
set category = "OOC"
set desc = "Fit the width of the map window to match the viewport"
// Fetch the client's aspect ratio
var/view_size = getviewsize(view)
var/aspect_ratio = view_size[1] / view_size[2]
// Calculate desired pixel width using window size and aspect ratio
var/sizes = params2list(winget(src, "mainwindow.split;mapwindow", "size"))
var/map_size = splittext(sizes["mapwindow.size"], "x")
var/height = text2num(map_size[2])
var/desired_width = round(height * aspect_ratio)
if (text2num(map_size[1]) == desired_width)
return // You're already good fam.
var/split_size = splittext(sizes["mainwindow.split.size"], "x")
var/split_width = text2num(split_size[1])
// Calculate and apply our best estimate
// +4 pixels are for the eidth of the splitter's handle
var/pct = 100 * (desired_width + 4) / split_width
winset(src, "mainwindow.split", "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/got_width = text2num(map_size[1])
if (got_width == desired_width)
return // Success!
// Calculate a probable delta value based on the diff
else if (isnull(delta))
delta = 100 * (desired_width - got_width) / split_width
// If we overshot, halve the delta and reverse direction
else if ((delta > 0 && got_width > desired_width) || (delta < 0 && got_width < desired_width))
delta = -delta/2
pct += delta
winset(src, "mainwindow.split", "splitter=[pct]")