mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-26 18:12:40 +00:00
@@ -59,7 +59,11 @@
|
||||
|
||||
// Returns true if val is from min to max, inclusive.
|
||||
/proc/IsInRange(val, min, max)
|
||||
return (val >= min) && (val <= max)
|
||||
return (min <= val && val <= max)
|
||||
|
||||
// Same as above, exclusive.
|
||||
/proc/IsInRange_Ex(val, min, max)
|
||||
return (min < val && val < max)
|
||||
|
||||
/proc/IsInteger(x)
|
||||
return Floor(x) == x
|
||||
|
||||
@@ -10,3 +10,9 @@
|
||||
viewX = text2num(viewrangelist[1])
|
||||
viewY = text2num(viewrangelist[2])
|
||||
return list(viewX, viewY)
|
||||
|
||||
/proc/in_view_range(mob/user, atom/A)
|
||||
var/list/view_range = getviewsize(user.client.view)
|
||||
var/turf/source = get_turf(user)
|
||||
var/turf/target = get_turf(A)
|
||||
return IsInRange(target.x, source.x - view_range[1], source.x + view_range[1]) && IsInRange(target.y, source.y - view_range[1], source.y + view_range[1])
|
||||
|
||||
@@ -170,4 +170,50 @@
|
||||
var/list/choice = list(2, 4, 6, 8, 10, 12, 20, 50, 100)
|
||||
var/input = input("Select the Dice you want!", "Dice", null, null) in choice
|
||||
|
||||
to_chat(usr, "<span class='notice'>You roll [rand(1,input)] out of [input]!</span>")
|
||||
to_chat(usr, "<span class='notice'>You roll [rand(1,input)] out of [input]!</span>")
|
||||
|
||||
/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 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.mainvsplit;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)
|
||||
// Nothing to do
|
||||
return
|
||||
|
||||
var/split_size = splittext(sizes["mainwindow.mainvsplit.size"], "x")
|
||||
var/split_width = text2num(split_size[1])
|
||||
|
||||
// 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/got_width = text2num(map_size[1])
|
||||
|
||||
if (got_width == desired_width)
|
||||
// success
|
||||
return
|
||||
else if (isnull(delta))
|
||||
// calculate a probable delta value based on the difference
|
||||
delta = 100 * (desired_width - got_width) / split_width
|
||||
else if ((delta > 0 && got_width > desired_width) || (delta < 0 && got_width < desired_width))
|
||||
// if we overshot, halve the delta and reverse direction
|
||||
delta = -delta/2
|
||||
|
||||
pct += delta
|
||||
winset(src, "mainwindow.mainvsplit", "splitter=[pct]")
|
||||
|
||||
Reference in New Issue
Block a user