Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zoom fixes #741

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions code/__DEFINES/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,12 @@
"End of Round Deathmatch" = BE_DEATHMATCH,\
"Prefer Squad over Role" = BE_SQUAD_STRICT\
)

#define WIDESCREEN_RESOLUTIONS list(\
CONFIG_GET(string/default_view1),\
CONFIG_GET(string/default_view2)\
)

#define WIDESCREEN1 "17x15"
#define WIDESCREEN2 "19x15"
#define SQUARESCREEN "15x15"
9 changes: 6 additions & 3 deletions code/controllers/configuration/entries/general.dm
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,14 @@ The default value assumes yt-dlp is in your system PATH

/datum/config_entry/flag/check_randomizer

/datum/config_entry/string/default_view
config_entry_value = "15x15"
/datum/config_entry/string/default_view1
config_entry_value = WIDESCREEN1

/datum/config_entry/string/default_view2
config_entry_value = WIDESCREEN2

/datum/config_entry/string/default_view_square
config_entry_value = "15x15"
config_entry_value = SQUARESCREEN

/*
This maintains a list of ip addresses that are able to bypass topic filtering.
Expand Down
15 changes: 13 additions & 2 deletions code/datums/view.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,29 @@
/datum/view_data/proc/add(num_to_add)
width += num_to_add
height += num_to_add
if(chief.prefs.widescreenpref) // if widescreen enabled
var/list/wide_size = getviewsize(default) // pickup current resolution
width = round(width * (wide_size[1] / wide_size[2])) // trying to save aspect ratio, cant be float/double number
apply()

///adds the size, which can also be a string, to the default and applies it
/datum/view_data/proc/add_size(toAdd)
var/list/new_size = getviewsize(toAdd)
width += new_size[1]
height += new_size[2]
if(chief.prefs.widescreenpref) // if widescreen enabled
var/list/wide_size = getviewsize(default) // pickup current resolution
width = round(width * (wide_size[1] / wide_size[2])) // trying to save aspect ratio, cant be float/double number
apply()

///INCREASES the view radius by this.
/datum/view_data/proc/set_view_radius_to(toAdd)
var/list/new_size = getviewsize(toAdd) //Backward compatability to account
width = new_size[1] //for a change in how sizes get calculated. we used to include world.view in
height = new_size[2] //this, but it was jank, so I had to move it
if(chief.prefs.widescreenpref) // if widescreen enabled
var/list/wide_size = getviewsize(default) // pickup current resolution
width = round(width * (wide_size[1] / wide_size[2])) // trying to save aspect ratio, cant be float/double number
apply()

///sets width and height as numbers
Expand Down Expand Up @@ -144,7 +153,9 @@
set_view_radius_to(radius)

///gets the current screen size as defined in config
/proc/get_screen_size(widescreen)
/proc/get_screen_size(widescreen, resolution = WIDESCREEN1)
if(widescreen)
return CONFIG_GET(string/default_view)
if(resolution == WIDESCREEN2)
return CONFIG_GET(string/default_view2)
return CONFIG_GET(string/default_view1)
return CONFIG_GET(string/default_view_square)
2 changes: 1 addition & 1 deletion code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ GLOBAL_DATUM_INIT(welding_sparks_prepdoor, /mutable_appearance, mutable_appearan
///how much tiles the zoom offsets to the direction it zooms to.
var/zoom_tile_offset = 6
///how much tiles the zoom zooms out, 5 is the default view.
var/zoom_viewsize = 7
var/zoom_viewsize = 5
///if you can move with the zoom on, only works if zoom_view_size is 7 otherwise CRASH() is called due to maptick performance reasons.
var/zoom_allow_movement = FALSE
var/datum/embedding_behavior/embedding
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/binoculars.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
throw_range = 15
throw_speed = 3
zoom_tile_offset = 11
zoom_viewsize = 12
zoom_viewsize = 15

/obj/item/binoculars/attack_self(mob/user)
if(user.interactee && istype(user.interactee, /obj/machinery/deployable))
Expand Down
6 changes: 2 additions & 4 deletions code/modules/client/client_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
if(!tooltips && prefs.tooltips)
tooltips = new /datum/tooltip(src)

view_size = new(src, get_screen_size(prefs.widescreenpref))
view_size = new(src, get_screen_size(prefs.widescreenpref, prefs.screen_resolution))
view_size.update_pixel_format()
view_size.update_zoom_mode()

Expand Down Expand Up @@ -870,14 +870,12 @@
CRASH("change_view called without argument.")
if(isnum(new_size))
CRASH("change_view called with a number argument. Use the string format instead.")
if(prefs && !prefs.widescreenpref && new_size == CONFIG_GET(string/default_view))
new_size = CONFIG_GET(string/default_view_square)

view = new_size
apply_clickcatcher()
mob.reload_fullscreens()

if(prefs.auto_fit_viewport)
if(prefs.auto_fit_viewport && (isnull(view_size) || !view_size.is_zooming()))
INVOKE_NEXT_TICK(src, VERB_REF(fit_viewport), 1 SECONDS) //Delayed to avoid wingets from Login calls.

///Change the fullscreen setting of the client
Expand Down
2 changes: 2 additions & 0 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ GLOBAL_LIST_EMPTY(preferences_datums)
var/datum/loadout_manager/loadout_manager
///Should we be in the widescreen mode set by the config?
var/widescreenpref = TRUE
///widescreen resolution
var/screen_resolution = "17x15"
///What size should pixels be displayed as? 0 is strech to fit
var/pixel_size = 0
///What scaling method should we use? Distort means nearest neighbor
Expand Down
4 changes: 4 additions & 0 deletions code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
READ_FILE(S["windowflashing"], windowflashing)
READ_FILE(S["auto_fit_viewport"], auto_fit_viewport)
READ_FILE(S["widescreenpref"], widescreenpref)
READ_FILE(S["screen_resolution"], screen_resolution)
READ_FILE(S["pixel_size"], pixel_size)
READ_FILE(S["scaling_method"], scaling_method)
READ_FILE(S["menuoptions"], menuoptions)
Expand Down Expand Up @@ -194,6 +195,7 @@
windowflashing = sanitize_integer(windowflashing, FALSE, TRUE, initial(windowflashing))
auto_fit_viewport = sanitize_integer(auto_fit_viewport, FALSE, TRUE, initial(auto_fit_viewport))
widescreenpref = sanitize_integer(widescreenpref, FALSE, TRUE, initial(widescreenpref))
screen_resolution = sanitize_inlist(screen_resolution, WIDESCREEN_RESOLUTIONS, initial(screen_resolution))
pixel_size = sanitize_float(pixel_size, PIXEL_SCALING_AUTO, PIXEL_SCALING_3X, 0.5, initial(pixel_size))
scaling_method = sanitize_text(scaling_method, initial(scaling_method))
ghost_vision = sanitize_integer(ghost_vision, FALSE, TRUE, initial(ghost_vision))
Expand Down Expand Up @@ -266,6 +268,7 @@
windowflashing = sanitize_integer(windowflashing, FALSE, TRUE, initial(windowflashing))
auto_fit_viewport = sanitize_integer(auto_fit_viewport, FALSE, TRUE, initial(auto_fit_viewport))
widescreenpref = sanitize_integer(widescreenpref, FALSE, TRUE, initial(widescreenpref))
screen_resolution = sanitize_inlist(screen_resolution, WIDESCREEN_RESOLUTIONS, initial(screen_resolution))
pixel_size = sanitize_float(pixel_size, PIXEL_SCALING_AUTO, PIXEL_SCALING_3X, 0.5, initial(pixel_size))
scaling_method = sanitize_text(scaling_method, initial(scaling_method))
chem_macros = sanitize_islist(chem_macros, list())
Expand Down Expand Up @@ -314,6 +317,7 @@
WRITE_FILE(S["windowflashing"], windowflashing)
WRITE_FILE(S["auto_fit_viewport"], auto_fit_viewport)
WRITE_FILE(S["widescreenpref"], widescreenpref)
WRITE_FILE(S["screen_resolution"], screen_resolution)
WRITE_FILE(S["pixel_size"], pixel_size)
WRITE_FILE(S["scaling_method"], scaling_method)
WRITE_FILE(S["menuoptions"], menuoptions)
Expand Down
10 changes: 9 additions & 1 deletion code/modules/client/preferences_ui.dm
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
data["show_typing"] = show_typing
data["tooltips"] = tooltips
data["widescreenpref"] = widescreenpref
data["screen_resolution"] = screen_resolution
data["radialmedicalpref"] = !!(toggles_gameplay & RADIAL_MEDICAL)
data["radialstackspref"] = !!(toggles_gameplay & RADIAL_STACKS)
data["radiallasersgunpref"] = !!(toggles_gameplay & RADIAL_LASERGUNS)
Expand Down Expand Up @@ -906,7 +907,14 @@

if("widescreenpref")
widescreenpref = !widescreenpref
user.client.view_size.set_default(get_screen_size(widescreenpref))
user.client.view_size.set_default(get_screen_size(widescreenpref, screen_resolution))

if("screen_resolution")
var/choice = tgui_input_list(ui.user, "Choose widescreen resolution", "Resolutions", WIDESCREEN_RESOLUTIONS)
if(choice)
screen_resolution = choice
if(widescreenpref)
user.client.view_size.set_default(get_screen_size(widescreenpref, screen_resolution))

if("radialmedicalpref")
toggles_gameplay ^= RADIAL_MEDICAL
Expand Down
2 changes: 1 addition & 1 deletion code/modules/clothing/modular_armor/attachments/modules.dm
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@
active = FALSE
flags_item = DOES_NOT_NEED_HANDS
zoom_tile_offset = 11
zoom_viewsize = 12
zoom_viewsize = 15
flags_attach_features = ATTACH_REMOVABLE|ATTACH_ACTIVATION|ATTACH_APPLY_ON_MOB
slot = ATTACHMENT_SLOT_HEAD_MODULE
prefered_slot = SLOT_HEAD
Expand Down
6 changes: 3 additions & 3 deletions code/modules/mob/dead/observer/observer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
to_chat(src, span_warning("Another consciousness is in your body...It is resisting you."))
return FALSE

client.view_size.set_default(get_screen_size(client.prefs.widescreenpref))//Let's reset so people can't become allseeing gods
client.view_size.set_default(get_screen_size(client.prefs.widescreenpref, client.prefs.screen_resolution))//Let's reset so people can't become allseeing gods
mind.transfer_to(old_mob, TRUE)
return TRUE

Expand Down Expand Up @@ -691,10 +691,10 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
if(!client)
return

if(client.view != CONFIG_GET(string/default_view))
if(client.view_size.is_zooming())
client.view_size.reset_to_default()
else
client.view_size.set_view_radius_to(12.5)
client.view_size.set_view_radius_to(12)

/mob/dead/observer/verb/add_view_range(input as num)
set name = "Add View Range"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ GLOBAL_LIST_INIT(boiler_glob_image_list, list(
span_notice("We start focusing your sight to look off into the distance."), null, 5)
if(!do_after(X, 1 SECONDS, IGNORE_HELD_ITEM, null, BUSY_ICON_GENERIC) || X.is_zoomed)
return
X.zoom_in(11)
X.zoom_in(10, 10)
return ..()

// ***************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@
if(message)
xeno.visible_message(span_notice("[xeno] emits a broad and weak psychic aura."),
span_notice("We start focusing our psychic energy to expand the reach of our senses."), null, 5)
xeno.zoom_in(0, 12)
xeno.zoom_in(0, 10)

/datum/action/ability/xeno_action/toggle_queen_zoom/proc/zoom_xeno_out(message = TRUE)
var/mob/living/carbon/xenomorph/xeno = owner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,5 +621,5 @@
else
if(!do_after(X, 0 SECONDS, IGNORE_HELD_ITEM, null, BUSY_ICON_GENERIC) || X.is_zoomed)
return
X.zoom_in(0, 9)
X.zoom_in(0, 10)
..()
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/xenomorph/xenoprocs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@

update_sight()

/mob/living/carbon/xenomorph/proc/zoom_in(tileoffset = 5, viewsize = 12)
/mob/living/carbon/xenomorph/proc/zoom_in(tileoffset = 5, viewsize = 4.5)
if(stat || resting)
if(is_zoomed)
is_zoomed = FALSE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/login.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
if(client.view_size)
client.view_size.reset_to_default() // Resets the client.view in case it was changed.
else
client.change_view(get_screen_size(client.prefs.widescreenpref))
client.change_view(get_screen_size(client.prefs.widescreenpref, client.prefs.screen_resolution))

if(client.player_details)
for(var/foo in client.player_details.post_login_callbacks)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/projectiles/attachables/scope.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
aim_speed_mod = 0.3
wield_delay_mod = 0.2 SECONDS
zoom_tile_offset = 7
zoom_viewsize = 2
zoom_viewsize = 5
add_aim_mode = TRUE

/obj/item/attachable/scope/mosin
Expand Down Expand Up @@ -115,7 +115,7 @@
/obj/item/attachable/scope/unremovable/hsg102/nest
scope_delay = 2 SECONDS
zoom_tile_offset = 7
zoom_viewsize = 2
zoom_viewsize = 5
deployed_scope_rezoom = FALSE

/obj/item/attachable/scope/activate(mob/living/carbon/user, turn_off)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/projectiles/guns/specialist.dm
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Note that this means that snipers will have a slowdown of 3, due to the scope
to_chat(user, span_danger("You lose sight of your target!"))
playsound(user,'sound/machines/click.ogg', 25, 1)

/obj/item/weapon/gun/rifle/sniper/antimaterial/zoom(mob/living/user, tileoffset = 11, viewsize = 12) //tileoffset is client view offset in the direction the user is facing. viewsize is how far out this thing zooms. 7 is normal view
/obj/item/weapon/gun/rifle/sniper/antimaterial/zoom(mob/living/user, tileoffset = 11, viewsize = 10) //tileoffset is client view offset in the direction the user is facing. viewsize is how far out this thing zooms. 5 is normal view
. = ..()
var/obj/item/attachable/scope = LAZYACCESS(attachments_by_slot, ATTACHMENT_SLOT_RAIL)
if(!scope.zoom && (targetmarker_on || targetmarker_primed) )
Expand Down
2 changes: 1 addition & 1 deletion code/modules/shuttle/mini_dropship.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
shuttleId = SHUTTLE_TADPOLE
lock_override = CAMERA_LOCK_GROUND
shuttlePortId = "minidropship_custom"
view_range = "26x26"
view_range = "25x25"
x_offset = 0
y_offset = 0
open_prompt = FALSE
Expand Down
3 changes: 2 additions & 1 deletion config/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ IS_AUTOMATIC_BALANCE_ON
## 15x15 would be the standard square view. 21x15 is what goonstation uses for widescreen.
## Setting this to something different from DEFAULT_VIEW_SQUARE will enable widescreen toggles
## Do note that changing this value will affect the title screen. The title screen will have to be updated manually if this is changed.
DEFAULT_VIEW 19x15
DEFAULT_VIEW1 17x15
DEFAULT_VIEW2 19x15

##Default view size, in tiles. Should *always* be square.
## The alternative square viewport size if you're using a widescreen view size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ export const GameSettings = (props) => {
leftLabel={'Enabled'}
rightLabel={'Disabled'}
/>
<SelectFieldPreference
label={'Widescreen resolution'}
value={'screen_resolution'}
action={'screen_resolution'}
/>
<ToggleFieldPreference
label="Radial medical wheel"
value="radialmedicalpref"
Expand Down
Loading