mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 05:00:55 +01:00
Fit Viewport cleanup (#65225)
* Fit Viewport cleanup Changes how Fit Viewport works slightly. From what I understand, the verb was created with the goal of eliminating the pixel hunting required to get rid of letterboxing. This works fine for stretch to fit, but ever since the command bar got nuked it's ended up creating a lot of blackspace for targeted zoom modes. I've changed how it decides on its optimal width slightly, if the client has a non stretch to fit zoom mode, we use it, the world icon size and the clients view size to figure out the exact width we want. The bars on the left and right have been bugging me forever. Want them gone. In light of this, I'm also making changing your zoom amount attempt to fit the viewport, if you have the pref enabled. Oh and I'm trying something with auto fit viewport stuff. It currently waits a second between view change and fitting. The comment implies this is to avoid winget strangeness from Login calls. When I blamed it, I found a commit from antruk talking about client dropping, and this being a potential fix. Unfortunately none wrote down what dropping means, and anturk's forgotten. I'm making the assumption that it's related to attempting the related winsets before an inital login is over. I might be wrong about this, if I am we'll know what went wrong I suppose. * Whoops, this needs to be invoke async * Ensures client safety, autodocs code, adds proper cleanup
This commit is contained in:
@@ -251,3 +251,6 @@
|
||||
|
||||
/// Whether or not this client has the combo HUD enabled
|
||||
var/combo_hud_enabled = FALSE
|
||||
|
||||
/// If this client has been fully initialized or not
|
||||
var/fully_created = FALSE
|
||||
|
||||
@@ -488,6 +488,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
|
||||
view_size.setZoomMode()
|
||||
Master.UpdateTickRate()
|
||||
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_CLIENT_CONNECT, src)
|
||||
fully_created = TRUE
|
||||
|
||||
//////////////
|
||||
//DISCONNECT//
|
||||
@@ -1039,8 +1040,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
|
||||
if (isliving(mob))
|
||||
var/mob/living/M = mob
|
||||
M.update_damage_hud()
|
||||
if (prefs.read_preference(/datum/preference/toggle/auto_fit_viewport))
|
||||
addtimer(CALLBACK(src,.verb/fit_viewport,10)) //Delayed to avoid wingets from Login calls.
|
||||
attempt_auto_fit_viewport()
|
||||
|
||||
/client/proc/generate_clickcatcher()
|
||||
if(!void)
|
||||
|
||||
@@ -359,13 +359,23 @@ GLOBAL_VAR_INIT(normal_ooc_colour, "#002eb8")
|
||||
|
||||
var/list/map_size = splittext(sizes["mapwindow.size"], "x")
|
||||
|
||||
// Looks like we 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)]")
|
||||
// Gets the type of zoom we're currently using from our view datum
|
||||
// If it's 0 we do our pixel calculations based off the size of the mapwindow
|
||||
// If it's not, we already know how big we want our window to be, since zoom is the exact pixel ratio of the map
|
||||
var/zoom_value = src.view_size?.zoom || 0
|
||||
|
||||
var/desired_width = 0
|
||||
if(zoom_value)
|
||||
desired_width = round(view_size[1] * zoom_value * world.icon_size)
|
||||
else
|
||||
|
||||
// Looks like we 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])
|
||||
desired_width = round(height * aspect_ratio)
|
||||
|
||||
var/height = text2num(map_size[2])
|
||||
var/desired_width = round(height * aspect_ratio)
|
||||
if (text2num(map_size[1]) == desired_width)
|
||||
// Nothing to do
|
||||
return
|
||||
@@ -401,6 +411,14 @@ GLOBAL_VAR_INIT(normal_ooc_colour, "#002eb8")
|
||||
pct += delta
|
||||
winset(src, "mainwindow.split", "splitter=[pct]")
|
||||
|
||||
/// Attempt to automatically fit the viewport, assuming the user wants it
|
||||
/client/proc/attempt_auto_fit_viewport()
|
||||
if (!prefs.read_preference(/datum/preference/toggle/auto_fit_viewport))
|
||||
return
|
||||
if(fully_created)
|
||||
INVOKE_ASYNC(src, .verb/fit_viewport)
|
||||
else //Delayed to avoid wingets from Login calls.
|
||||
addtimer(CALLBACK(src, .verb/fit_viewport, 1 SECONDS))
|
||||
|
||||
/client/verb/policy()
|
||||
set name = "Show Policy"
|
||||
|
||||
Reference in New Issue
Block a user