diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index 67a5e7c4cde..2b0c164c597 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -285,7 +285,6 @@ CREATE TABLE `player` ( `discord_id` varchar(32) NULL DEFAULT NULL, `discord_name` varchar(32) NULL DEFAULT NULL, `keybindings` longtext COLLATE 'utf8mb4_unicode_ci' DEFAULT NULL, - `viewrange` VARCHAR(5) NOT NULL DEFAULT '19x15' COLLATE 'utf8mb4_general_ci', PRIMARY KEY (`id`), UNIQUE KEY `ckey` (`ckey`), KEY `lastseen` (`lastseen`), diff --git a/SQL/updates/29-30.sql b/SQL/updates/29-30.sql deleted file mode 100644 index 20b06a7cf88..00000000000 --- a/SQL/updates/29-30.sql +++ /dev/null @@ -1,4 +0,0 @@ -# Updating SQL from 29 to 30 -AffectedArc07 -# Add new viewrange toggle -ALTER TABLE `player` - ADD COLUMN `viewrange` VARCHAR(5) NOT NULL DEFAULT '19x15' AFTER `keybindings`; diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index 1062d6f2d80..b0c1c6ab230 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -117,13 +117,10 @@ #define in_range(source, user) (get_dist(source, user) <= 1) #define RANGE_TURFS(RADIUS, CENTER) \ - RECT_TURFS(RADIUS, RADIUS, CENTER) - -#define RECT_TURFS(H_RADIUS, V_RADIUS, CENTER) \ - block( \ - locate(max(CENTER.x-(H_RADIUS),1), max(CENTER.y-(V_RADIUS),1), CENTER.z), \ - locate(min(CENTER.x+(H_RADIUS),world.maxx), min(CENTER.y+(V_RADIUS),world.maxy), CENTER.z) \ - ) + block( \ + locate(max(CENTER.x-(RADIUS),1), max(CENTER.y-(RADIUS),1), CENTER.z), \ + locate(min(CENTER.x+(RADIUS),world.maxx), min(CENTER.y+(RADIUS),world.maxy), CENTER.z) \ + ) /// Returns the turfs on the edge of a square with CENTER in the middle and with the given RADIUS. If used near the edge of the map, will still work fine. // order of the additions: top edge + bottom edge + left edge + right edge @@ -385,7 +382,7 @@ #define EXPLOSION_BLOCK_PROC -1 // The SQL version required by this version of the code -#define SQL_VERSION 30 +#define SQL_VERSION 29 // Vending machine stuff #define CAT_NORMAL 1 @@ -519,6 +516,3 @@ #define TTS_SEED_DEFAULT_FEMALE "tyrande" #define TTS_SEED_DEFAULT_MALE "arthas" #define TTS_SEED_ANNOUNCER "anubarak" - -// This isnt in client_defines due to scoping issues -#define DEFAULT_CLIENT_VIEWSIZE "19x15" diff --git a/code/__DEFINES/preferences.dm b/code/__DEFINES/preferences.dm index 4e05225a1f5..adec427c6ac 100644 --- a/code/__DEFINES/preferences.dm +++ b/code/__DEFINES/preferences.dm @@ -55,11 +55,10 @@ #define PREFTOGGLE_2_SEE_ITEM_OUTLINES 512 // Yes I know this being an "enable to disable" is misleading, but it avoids having to tweak all existing pref entries #define PREFTOGGLE_2_REVERB_DISABLE 1024 -#define PREFTOGGLE_2_WIDESCREEN 2048 -#define TOGGLES_2_TOTAL 4095 // If you add or remove a preference toggle above, make sure you update this define with the total value of the toggles combined. +#define TOGGLES_2_TOTAL 2047 // If you add or remove a preference toggle above, make sure you update this define with the total value of the toggles combined. -#define TOGGLES_2_DEFAULT (PREFTOGGLE_2_FANCYUI|PREFTOGGLE_2_ITEMATTACK|PREFTOGGLE_2_WINDOWFLASHING|PREFTOGGLE_2_RUNECHAT|PREFTOGGLE_2_DEATHMESSAGE|PREFTOGGLE_2_SEE_ITEM_OUTLINES|PREFTOGGLE_2_WIDESCREEN) +#define TOGGLES_2_DEFAULT (PREFTOGGLE_2_FANCYUI|PREFTOGGLE_2_ITEMATTACK|PREFTOGGLE_2_WINDOWFLASHING|PREFTOGGLE_2_RUNECHAT|PREFTOGGLE_2_DEATHMESSAGE|PREFTOGGLE_2_SEE_ITEM_OUTLINES) // Sanity checks #if TOGGLES_TOTAL > 16777215 diff --git a/code/_onclick/hud/hud.dm b/code/_onclick/hud/hud.dm index d88d3d436db..481045f19e9 100644 --- a/code/_onclick/hud/hud.dm +++ b/code/_onclick/hud/hud.dm @@ -119,6 +119,15 @@ if(display_hud_version > HUD_VERSIONS) //If the requested version number is greater than the available versions, reset back to the first version display_hud_version = 1 + if(mymob.client.view < world.view) + if(mymob.client.view < ARBITRARY_VIEWRANGE_NOHUD) + to_chat(mymob, "HUD is unavailable with this view range.") + display_hud_version = HUD_STYLE_NOHUD + else + if(display_hud_version == HUD_STYLE_STANDARD) + to_chat(mymob, "Standard HUD mode is unavailable with a smaller-than-normal view range.") + display_hud_version = HUD_STYLE_REDUCED + switch(display_hud_version) if(HUD_STYLE_STANDARD) //Default HUD hud_shown = TRUE //Governs behavior of other procs diff --git a/code/_onclick/hud/parallax.dm b/code/_onclick/hud/parallax.dm index c521345d994..8c4566fa08a 100644 --- a/code/_onclick/hud/parallax.dm +++ b/code/_onclick/hud/parallax.dm @@ -240,24 +240,17 @@ /obj/screen/parallax_layer/proc/update_o(view) if(!view) view = world.view - - var/static/parallax_scaler = world.icon_size / 480 - - // Turn the view size into a grid of correctly scaled overlays - var/list/viewscales = getviewsize(view) - var/countx = CEILING((viewscales[1] / 2) * parallax_scaler, 1) + 1 - var/county = CEILING((viewscales[2] / 2) * parallax_scaler, 1) + 1 - var/list/new_overlays = new - for(var/x in -countx to countx) - for(var/y in -county to county) + var/list/new_overlays = list() + var/count = CEILING(view/(480/world.icon_size), 1)+1 + for(var/x in -count to count) + for(var/y in -count to count) if(x == 0 && y == 0) continue var/mutable_appearance/texture_overlay = mutable_appearance(icon, icon_state) - texture_overlay.transform = matrix(1, 0, x * 480, 0, 1, y * 480) + texture_overlay.transform = matrix(1, 0, x*480, 0, 1, y*480) new_overlays += texture_overlay - cut_overlays() - add_overlay(new_overlays) - // Cache this + + overlays = new_overlays view_sized = view /obj/screen/parallax_layer/proc/update_status(mob/M) diff --git a/code/game/gamemodes/miniantags/slaughter/slaughter.dm b/code/game/gamemodes/miniantags/slaughter/slaughter.dm index 6c867c97130..5fce4479d68 100644 --- a/code/game/gamemodes/miniantags/slaughter/slaughter.dm +++ b/code/game/gamemodes/miniantags/slaughter/slaughter.dm @@ -203,7 +203,7 @@ /datum/action/innate/demon/whisper/proc/choose_targets(mob/user = usr)//yes i am copying from telepathy..hush... var/list/validtargets = list() - for(var/mob/living/M in view(user.client.maxview(), get_turf(user))) + for(var/mob/living/M in view(user.client.view, get_turf(user))) if(M && M.mind && M.stat != DEAD) if(M == user) continue diff --git a/code/game/objects/items/blueprints.dm b/code/game/objects/items/blueprints.dm index 1c57af8016a..a7d9f0eb782 100644 --- a/code/game/objects/items/blueprints.dm +++ b/code/game/objects/items/blueprints.dm @@ -162,22 +162,19 @@ set_viewer(usr) attack_self(usr) - -/obj/item/areaeditor/blueprints/proc/get_images(turf/central_turf, viewsize) +/obj/item/areaeditor/blueprints/proc/get_images(turf/T, viewsize) . = list() - var/list/dimensions = getviewsize(viewsize) - var/horizontal_radius = dimensions[1] / 2 - var/vertical_radius = dimensions[2] / 2 - for(var/turf/nearby_turf as anything in RECT_TURFS(horizontal_radius, vertical_radius, central_turf)) - if(nearby_turf.blueprint_data) - . += nearby_turf.blueprint_data + for(var/tt in RANGE_TURFS(viewsize, T)) + var/turf/TT = tt + if(TT.blueprint_data) + . += TT.blueprint_data /obj/item/areaeditor/blueprints/proc/set_viewer(mob/user, message = "") if(user && user.client) if(viewing) clear_viewer() viewing = user.client - showing = get_images(get_turf(viewing.eye || user), viewing.view) + showing = get_images(get_turf(user), viewing.view) viewing.images |= showing if(message) to_chat(user, message) diff --git a/code/game/objects/items/devices/lightreplacer.dm b/code/game/objects/items/devices/lightreplacer.dm index 3715953eeec..2c34ec22d24 100644 --- a/code/game/objects/items/devices/lightreplacer.dm +++ b/code/game/objects/items/devices/lightreplacer.dm @@ -256,7 +256,7 @@ return if(!isturf(T)) return - if(get_dist(src, T) >= (U.client.maxview() + 2)) // To prevent people from using it over cameras + if(get_dist(src, T) >= (U.client.view + 2)) // To prevent people from using it over cameras return var/used = FALSE diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index fd1d5d46be3..6a7da89525c 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -482,8 +482,6 @@ /turf/proc/add_blueprints(atom/movable/AM) var/image/I = new - I.plane = GAME_PLANE - I.layer = OBJ_LAYER I.appearance = AM.appearance I.appearance_flags = RESET_COLOR|RESET_ALPHA|RESET_TRANSFORM I.loc = src diff --git a/code/modules/client/client_defines.dm b/code/modules/client/client_defines.dm index 3fe04a524d2..09e941cfd42 100644 --- a/code/modules/client/client_defines.dm +++ b/code/modules/client/client_defines.dm @@ -54,7 +54,7 @@ preload_rsc = 0 // This is 0 so we can set it to an URL once the player logs in and have them download the resources from a different server. - var/obj/screen/click_catcher/void + var/global/obj/screen/click_catcher/void var/karma = 0 var/karma_spent = 0 diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index 1c9f133673f..e54fe65ffec 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -312,10 +312,6 @@ GLOB.preferences_datums[ckey] = prefs else prefs.parent = src - - // Setup widescreen - view = prefs.viewrange - prefs.init_keybindings(prefs.keybindings_overrides) //The earliest sane place to do it where prefs are not null, if they are null you can't do crap at lobby prefs.last_ip = address //these are gonna be used for banning prefs.last_id = computer_id //these are gonna be used for banning @@ -354,10 +350,6 @@ winset(src, null, "command=\".configure graphics-hwmode off\"") winset(src, null, "command=\".configure graphics-hwmode on\"") - // Try doing this before mob login - generate_clickcatcher() - apply_clickcatcher() - connection_time = world.time connection_realtime = world.realtime connection_timeofday = world.timeofday @@ -389,6 +381,9 @@ else to_chat(src,"You have enabled karma gains.") + generate_clickcatcher() + apply_clickcatcher() + if(show_update_prompt) show_update_notice() @@ -431,7 +426,6 @@ GLOB.panic_bunker_enabled = FALSE message_admins("Panic bunker has been automatically disabled due to playercount dropping below [threshold]") - /client/proc/is_connecting_from_localhost() var/localhost_addresses = list("127.0.0.1", "::1") // Adresses if(!isnull(address) && (address in localhost_addresses)) @@ -1079,40 +1073,25 @@ /client/verb/fit_viewport() set name = "Fit Viewport" - set desc = "Fit the size of the map window to match the viewport." set category = "OOC" + set desc = "Fit the width of the map window to match the viewport" // Fetch aspect ratio - var/list/view_size = getviewsize(view) + 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/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/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. + if (text2num(map_size[1]) == desired_width) + // Nothing to do return - var/list/split_size = splittext(sizes["mainwindow.mainvsplit.size"], "x") + var/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 @@ -1123,20 +1102,20 @@ 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]) + var/got_width = text2num(map_size[1]) - if(produced_width == desired_width) - // Success! + if (got_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]") + 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]") /client/verb/fitviewport() // wrapper for mainwindow set hidden = 1 @@ -1375,11 +1354,6 @@ // If we are here, they have not accepted, and need to read it return FALSE -/// Returns the biggest number from client.view so we can do easier maths -/client/proc/maxview() - var/list/screensize = getviewsize(view) - return max(screensize[1], screensize[2]) - #undef LIMITER_SIZE #undef CURRENT_SECOND #undef SECOND_COUNT diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index f8aedca8ee0..f2fb15cd98f 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -237,8 +237,6 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts var/list/datum/keybindings = list() /// Keybinding overrides ("name" => ["key"...]) var/list/keybindings_overrides = null - /// View range preference for this client - var/viewrange = DEFAULT_CLIENT_VIEWSIZE /datum/preferences/New(client/C) parent = C @@ -542,7 +540,6 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts dat += "Play Lobby Music: [(sound & SOUND_LOBBY) ? "Yes" : "No"]
" dat += "Randomized Character Slot: [toggles2 & PREFTOGGLE_2_RANDOMSLOT ? "Yes" : "No"]
" dat += "Window Flashing: [(toggles2 & PREFTOGGLE_2_WINDOWFLASHING) ? "Yes" : "No"]
" - dat += "View Range: [viewrange]
" // RIGHT SIDE OF THE PAGE dat += "" dat += "

Special Role Settings

" @@ -692,7 +689,7 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts dat += "Reset Setup" dat += "" - var/datum/browser/popup = new(user, "preferences", "
Character Setup
", 820, 770) + var/datum/browser/popup = new(user, "preferences", "
Character Setup
", 820, 660) popup.set_content(dat.Join("")) popup.open(FALSE) @@ -2236,24 +2233,6 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts if("winflash") toggles2 ^= PREFTOGGLE_2_WINDOWFLASHING - if("setviewrange") - var/list/viewrange_options = list( - "15x15 (Classic)" = "15x15", - "17x15 (Wide)" = "17x15", - "19x15 (Ultrawide)" = "19x15" - ) - - var/new_range = input(user, "Select a view range") as anything in viewrange_options - var/actual_new_range = viewrange_options[new_range] - - viewrange = actual_new_range - - if(actual_new_range != parent.view) - parent.view = actual_new_range - // Update the size of the click catcher - var/list/actualview = getviewsize(parent.view) - parent.void.UpdateGreed(actualview[1],actualview[2]) - if("afk_watch") if(!(toggles2 & PREFTOGGLE_2_AFKWATCH)) to_chat(user, "You will now get put into cryo dorms after [config.auto_cryo_afk] minutes. \ diff --git a/code/modules/client/preference/preferences_mysql.dm b/code/modules/client/preference/preferences_mysql.dm index 2dc616c24d1..0e4bdd51cdc 100644 --- a/code/modules/client/preference/preferences_mysql.dm +++ b/code/modules/client/preference/preferences_mysql.dm @@ -19,8 +19,7 @@ parallax, discord_id, discord_name, - keybindings, - viewrange + keybindings FROM [format_table_name("player")] WHERE ckey=:ckey"}, list( "ckey" = C.ckey @@ -52,7 +51,6 @@ discord_id = query.item[17] discord_name = query.item[18] keybindings = init_keybindings(raw = query.item[19]) - viewrange = query.item[20] qdel(query) @@ -104,8 +102,7 @@ lastchangelog=:lastchangelog, clientfps=:clientfps, parallax=:parallax, - keybindings=:keybindings, - viewrange=:viewrange + keybindings=:keybindings WHERE ckey=:ckey"}, list( // OH GOD THE PARAMETERS "ooccolour" = ooccolor, @@ -124,7 +121,6 @@ "clientfps" = clientfps, "parallax" = parallax, "keybindings" = json_encode(keybindings_overrides), - "viewrange" = viewrange, "ckey" = C.ckey ) ) diff --git a/code/modules/client/view.dm b/code/modules/client/view.dm index 48b621c5e3b..ac862933afb 100644 --- a/code/modules/client/view.dm +++ b/code/modules/client/view.dm @@ -38,24 +38,22 @@ var/datum/viewmod/V = ViewMods[mod_id] highest_range = max(highest_range, V.size) - SetView(highest_range ? highest_range : prefs.viewrange) + SetView(highest_range ? highest_range : world.view) ViewModsActive = (highest_range > 0) /client/proc/SetView(view_range) - if(view_range == prefs.viewrange) + if(view_range == world.view) winset(src, "mapwindow.map", "icon-size=[ViewPreferedIconSize]") else winset(src, "mapwindow.map", "icon-size=0") view = view_range - var/view_range_calc = maxview() - - if(mob?.hud_used) + if(mob && mob.hud_used) // If view range is less than world.view, assume the HUD will not fit under normal mode and turn it to reduced - if(view_range_calc < world.view) + if(view_range < world.view) // If it's really tiny, turn their hud off completely - if(view_range_calc <= ARBITRARY_VIEWRANGE_NOHUD) + if(view_range <= ARBITRARY_VIEWRANGE_NOHUD) mob.hud_used.show_hud(HUD_STYLE_NOHUD) else mob.hud_used.show_hud(HUD_STYLE_REDUCED) diff --git a/code/modules/mining/lavaland/loot/ashdragon_loot.dm b/code/modules/mining/lavaland/loot/ashdragon_loot.dm index 77296f017d6..2eed75269a9 100644 --- a/code/modules/mining/lavaland/loot/ashdragon_loot.dm +++ b/code/modules/mining/lavaland/loot/ashdragon_loot.dm @@ -202,7 +202,7 @@ do_sparks(5, FALSE, user) return - if(target in view(user.client.maxview(), get_turf(user))) + if(target in view(user.client.view, get_turf(user))) var/turf/simulated/T = get_turf(target) if(!istype(T)) diff --git a/code/modules/mob/living/carbon/brain/MMI.dm b/code/modules/mob/living/carbon/brain/MMI.dm index 10404c596e1..6632014c2de 100644 --- a/code/modules/mob/living/carbon/brain/MMI.dm +++ b/code/modules/mob/living/carbon/brain/MMI.dm @@ -285,6 +285,6 @@ // As a synthetic, the only limit on visibility is view range /obj/item/mmi/contents_ui_distance(src_object, mob/living/user) . = ..() - if((src_object in view(src)) && get_dist(src_object, src) <= user.client.maxview()) + if((src_object in view(src)) && get_dist(src_object, src) <= user.client.view) return STATUS_INTERACTIVE // interactive (green visibility) return user.shared_living_ui_distance() diff --git a/code/modules/mob/living/life.dm b/code/modules/mob/living/life.dm index 14146c599be..0a3edd93a13 100644 --- a/code/modules/mob/living/life.dm +++ b/code/modules/mob/living/life.dm @@ -81,7 +81,7 @@ if(!isnum(forced_look)) var/atom/A = locateUID(forced_look) if(istype(A)) - var/view = client ? client.maxview() : world.view + var/view = client ? client.view : world.view if(get_dist(src, A) > view || !(src in viewers(view, A))) forced_look = null to_chat(src, "Your direction target has left your view, you are no longer facing anything.") diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 5bfd2196af8..5e87968de8b 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -312,7 +312,7 @@ /// possibly delayed verb that finishes the pointing process starting in [/mob/verb/pointed()]. /// either called immediately or in the tick after pointed() was called, as per the [DEFAULT_QUEUE_OR_CALL_VERB()] macro /mob/proc/run_pointed(atom/A) - if(client && !(A in view(client.maxview(), src))) + if(client && !(A in view(client.view, src))) return FALSE changeNext_move(CLICK_CD_POINT) diff --git a/code/modules/projectiles/firing.dm b/code/modules/projectiles/firing.dm index 5fe4b197424..5a3903f6581 100644 --- a/code/modules/projectiles/firing.dm +++ b/code/modules/projectiles/firing.dm @@ -89,14 +89,14 @@ //Split Y+Pixel_Y up into list(Y, Pixel_Y) var/list/screen_loc_Y = splittext(screen_loc_params[2],":") - var/x = (text2num(screen_loc_X[1]) - 1) * world.icon_size + text2num(screen_loc_X[2]) - var/y = (text2num(screen_loc_Y[1]) - 1) * world.icon_size + text2num(screen_loc_Y[2]) + var/x = text2num(screen_loc_X[1]) * world.icon_size + text2num(screen_loc_X[2]) - world.icon_size + (user.client ? user.client.pixel_x : 0) + var/y = text2num(screen_loc_Y[1]) * world.icon_size + text2num(screen_loc_Y[2]) - world.icon_size + (user.client ? user.client.pixel_y : 0) //Calculate the "resolution" of screen based on client's view and world's icon size. This will work if the user can view more tiles than average. - var/list/screenview = getviewsize(user.client.view) + var/screenview = (user.client.view * 2 + 1) * world.icon_size //Refer to http://www.byond.com/docs/ref/info.html#/client/var/view for mad maths - var/ox = round((screenview[1] * world.icon_size) / 2) - user.client.pixel_x //"origin" x - var/oy = round((screenview[2] * world.icon_size) / 2) - user.client.pixel_y //"origin" y + var/ox = round(screenview/2) //"origin" x + var/oy = round(screenview/2) //"origin" y var/angle = ATAN2(y - oy, x - ox) Angle = angle if(spread) diff --git a/code/modules/shuttle/navigation_computer.dm b/code/modules/shuttle/navigation_computer.dm index 970689a390d..53ca6edf392 100644 --- a/code/modules/shuttle/navigation_computer.dm +++ b/code/modules/shuttle/navigation_computer.dm @@ -135,7 +135,7 @@ to_remove += SSshuttle.hidden_shuttle_turf_images user.client.images -= to_remove - user.client.SetView(user.client.prefs.viewrange) + user.client.SetView(7) /obj/machinery/computer/camera_advanced/shuttle_docker/proc/placeLandingSpot() if(designating_target_loc || !current_user) diff --git a/code/modules/tgui/states/default.dm b/code/modules/tgui/states/default.dm index 1da3895ed5d..fe7385c33b7 100644 --- a/code/modules/tgui/states/default.dm +++ b/code/modules/tgui/states/default.dm @@ -31,7 +31,7 @@ GLOBAL_DATUM_INIT(default_state, /datum/ui_state/default, new) // Robots can interact with anything they can see. var/list/clientviewlist = getviewsize(client.view) - if((src_object in view(src)) && (get_dist(src, src_object) <= max(clientviewlist[1], clientviewlist[2]))) + if((src_object in view(src)) && (get_dist(src, src_object) <= min(clientviewlist[1],clientviewlist[2]))) return STATUS_INTERACTIVE return STATUS_DISABLED // Otherwise they can keep the UI open. diff --git a/code/modules/tooltip/tooltip.dm b/code/modules/tooltip/tooltip.dm index 4a510b71601..842d83c3883 100644 --- a/code/modules/tooltip/tooltip.dm +++ b/code/modules/tooltip/tooltip.dm @@ -70,8 +70,7 @@ Notes: params = {"{ "cursor": "[params]", "screenLoc": "[thing.screen_loc]" }"} //Send stuff to the tooltip - var/view_size = getviewsize(owner.view) - owner << output(list2params(list(params, view_size[1] , view_size[2], "[title][content]", theme, special)), "[control]:tooltip.update") + owner << output(list2params(list(params, owner.view, "[title][content]", theme, special)), "[control]:tooltip.update") //If a hide() was hit while we were showing, run hide() again to avoid stuck tooltips showing = 0 diff --git a/code/modules/tooltip/tooltip.html b/code/modules/tooltip/tooltip.html index 1fa8e72e54b..0be70b4229d 100644 --- a/code/modules/tooltip/tooltip.html +++ b/code/modules/tooltip/tooltip.html @@ -90,8 +90,7 @@ 'tileSize': 32, 'control': '', 'params': {}, - 'client_view_w': 0, - 'client_view_h': 0, + 'clientView': 0, 'text': '', 'theme': '', 'padding': 2, @@ -103,7 +102,7 @@ window.location = 'byond://winset?id='+tooltip.control+';is-visible=false'; }, updateCallback: function(map) { - if (typeof map === 'undefined' || !map) {return false;} + if(typeof map === 'undefined' || !map) {return false;} //alert(tooltip.params+' | '+tooltip.clientView+' | '+tooltip.text+' | '+tooltip.theme); //DEBUG @@ -111,49 +110,36 @@ window.location = 'byond://winset?id='+tooltip.control+';anchor1=0,0;size=999x999'; //Get the real icon size according to the client view - //FYI, this bit is even more borrowed from goon, our widescreen broke tooltips so I took a look at how they do it - //To improve our code. Thanks gooncoders, very cool var mapWidth = map['view-size'].x, mapHeight = map['view-size'].y, - tilesShownX = tooltip.client_view_w - tilesShownY = tooltip.client_view_h - realIconSizeX = mapWidth / tilesShownX, - realIconSizeY = mapHeight / tilesShownY, - resizeRatioX = realIconSizeX / tooltip.tileSize, - resizeRatioY = realIconSizeY / tooltip.tileSize, + tilesShown = (tooltip.clientView * 2) + 1, + realIconSize = mapWidth / tilesShown, + resizeRatio = realIconSize / tooltip.tileSize, //Calculate letterboxing offsets leftOffset = (map.size.x - mapWidth) / 2, topOffset = (map.size.y - mapHeight) / 2; //alert(realIconSize + ' | ' +tooltip.tileSize + ' | ' + resizeRatio); //DEBUG - const parameters = new Object(); - - //Parse out the contents of params (e.g. "icon-x=32;icon-y=29;screen-loc=3:10,15:29") - //It is worth noting that params is not always ordered in the same way. We therefore need to write the code - //To load their values in independantly of their order + //Parse out the tile and cursor locations from params (e.g. "icon-x=32;icon-y=29;screen-loc=3:10,15:29") var paramsA = tooltip.params.cursor.split(';'); - for (var i = 0; i < paramsA.length; i++) { - var entry = paramsA[i]; - var nameAndValue = entry.split("="); - parameters[nameAndValue[0]] = nameAndValue[1]; - } - - //Sometimes screen-loc is never sent ahaha fuck you byond - if (!parameters["icon-x"] || !parameters["icon-y"] || !parameters["screen-loc"]) { - return false; - } + if(paramsA.length < 3) {return false;} //Sometimes screen-loc is never sent ahaha fuck you byond //icon-x - var iconX = parseInt(parameters["icon-x"]); + var iconX = paramsA[0]; + iconX = iconX.split('='); + iconX = parseInt(iconX[1]); //icon-y - var iconY = parseInt(parameters["icon-y"]); + var iconY = paramsA[1]; + iconY = iconY.split('='); + iconY = parseInt(iconY[1]); //screen-loc - var screenLoc = parameters["screen-loc"]; - screenLoc = screenLoc.split(','); - if (screenLoc.length < 2) {return false;} + var screenLoc = paramsA[2]; + screenLoc = screenLoc.split('='); + screenLoc = screenLoc[1].split(','); + if(screenLoc.length < 2) {return false;} var left = screenLoc[0]; var top = screenLoc[1]; - if (!left || !top) {return false;} + if(!left || !top) {return false;} screenLoc = left.split(':'); left = parseInt(screenLoc[0]); var enteredX = parseInt(screenLoc[1]); @@ -166,30 +152,30 @@ var oScreenLoc = tooltip.params.screenLoc.split(','); //o for original ok var west = oScreenLoc[0].split(':'); - if (west.length > 1) { //Only if west has a pixel offset + if(west.length > 1) { //Only if west has a pixel offset var westOffset = parseInt(west[1]); - if (westOffset !== 0) { - if ((iconX + westOffset) !== enteredX) { //Cursor entered on the offset tile + if(westOffset !== 0) { + if((iconX + westOffset) !== enteredX) { //Cursor entered on the offset tile left = left + (westOffset < 0 ? 1 : -1); } - leftOffset = leftOffset + (westOffset * resizeRatioX); + leftOffset = leftOffset + (westOffset * resizeRatio); } } - if (oScreenLoc.length > 1) { //If north is given + if(oScreenLoc.length > 1) { //If north is given var north = oScreenLoc[1].split(':'); - if (north.length > 1) { //Only if north has a pixel offset + if(north.length > 1) { //Only if north has a pixel offset var northOffset = parseInt(north[1]); - if (northOffset !== 0) { - if ((iconY + northOffset) === enteredY) { //Cursor entered on the original tile + if(northOffset !== 0) { + if((iconY + northOffset) === enteredY) { //Cursor entered on the original tile top--; - topOffset = topOffset - ((tooltip.tileSize + northOffset) * resizeRatioY); + topOffset = topOffset - ((tooltip.tileSize + northOffset) * resizeRatio); } else { //Cursor entered on the offset tile - if (northOffset < 0) { //Offset southwards - topOffset = topOffset - ((tooltip.tileSize + northOffset) * resizeRatioY); + if(northOffset < 0) { //Offset southwards + topOffset = topOffset - ((tooltip.tileSize + northOffset) * resizeRatio); } else { //Offset northwards top--; - topOffset = topOffset - (northOffset * resizeRatioY); + topOffset = topOffset - (northOffset * resizeRatio); } } } @@ -197,17 +183,17 @@ } //Handle special cases (for fuck sake) - if (tooltip.special !== 'none') { + if(tooltip.special !== 'none') { //Put yo special cases here } //Clamp values - left = (left < 0 ? 0 : (left > tilesShownX ? tilesShownX : left)); - top = (top < 0 ? 0 : (top > tilesShownY ? tilesShownY : top)); + left = (left < 0 ? 0 : (left > tilesShown ? tilesShown : left)); + top = (top < 0 ? 0 : (top > tilesShown ? tilesShown : top)); //Calculate where on the screen the popup should appear (below the hovered tile) - var posX = Math.round(((left - 1) * realIconSizeX) + leftOffset + tooltip.padding); //-1 to position at the left of the target tile - var posY = Math.round(((tilesShownY - top + 1) * realIconSizeY) + topOffset + tooltip.padding); //+1 to position at the bottom of the target tile + var posX = Math.round(((left - 1) * realIconSize) + leftOffset + tooltip.padding); //-1 to position at the left of the target tile + var posY = Math.round(((tilesShown - top + 1) * realIconSize) + topOffset + tooltip.padding); //+1 to position at the bottom of the target tile //alert(mapWidth+' | '+mapHeight+' | '+tilesShown+' | '+realIconSize+' | '+leftOffset+' | '+topOffset+' | '+left+' | '+top+' | '+posX+' | '+posY); //DEBUG @@ -221,16 +207,11 @@ $wrap.width($wrap.width() + 2); //Dumb hack to fix a bizarre sizing bug - var pixelRatio = 1; - if (window.devicePixelRatio) { - pixelRatio = window.devicePixelRatio; - } - - var docWidth = Math.floor($wrap.outerWidth() * pixelRatio), - docHeight = Math.floor($wrap.outerHeight() * pixelRatio); + var docWidth = $wrap.outerWidth(), + docHeight = $wrap.outerHeight(); - if (posY + docHeight > map.size.y) { //Is the bottom edge below the window? Snap it up if so - posY = (posY - docHeight) - realIconSizeY - tooltip.padding; + if(posY + docHeight > map.size.y) { //Is the bottom edge below the window? Snap it up if so + posY = (posY - docHeight) - realIconSize - tooltip.padding; } //Actually size, move and show the tooltip box @@ -240,11 +221,10 @@ tooltip.hide(); }); }, - update: function(params, client_vw , clien_vh , text, theme, special) { + update: function(params, clientView, text, theme, special) { //Assign our global object tooltip.params = $.parseJSON(params); - tooltip.client_view_w = parseInt(client_vw); - tooltip.client_view_h = parseInt(clien_vh); + tooltip.clientView = parseInt(clientView); tooltip.text = text; tooltip.theme = theme; tooltip.special = special; diff --git a/code/world.dm b/code/world.dm index 50069768444..40f4268ef5a 100644 --- a/code/world.dm +++ b/code/world.dm @@ -5,6 +5,6 @@ mob = /mob/new_player turf = /turf/space area = /area/space - view = "15x15" // If you ever set this to a non-square value you will need to update a lot of the code! + view = "15x15" cache_lifespan = 0 //stops player uploaded stuff from being kept in the rsc past the current session fps = 20 // If this isnt hard-defined, anything relying on this variable before world load will cry a lot