ViewMods - Allows custom view ranges.

The primary function of this is a new button in the "Preferences" tab -
Set View Range. This functions similarly to the admin verb "Change View
Range", but it only allows you to set view ranges lower than the normal
world.view.

Full changelog:
 - Added ViewMods system to clients.
   - Everything that wants to change client.view should do it through
   this system.
   - Currently used by the Set View Range button and Marauders.
   - Stretch mode is set to stretch when active, but the original
   setting is preserved, as long as you set it with no ViewMods enabled.
   - The basic way this works is that it keeps track of /datum/viewmods
   on /clients, and whenever one is added or removed, it picks the
   highest view range out of all of them and sets the client's vision to
   that. This effectively means that, if you, say, set your view range
   to 5x5, and get into a Marauder and use the "zoom" button, it will
   always go to the marauder's zoom level.
   - The HUD is set to minimal mode for any view ranges below
   world.view, which means you only get absolutely critical buttons.
   	- It's set to invisible if you go down to view range 1 or 2,
	because the buttons can't fit on the screen at those view
	ranges.
 - Removed canvas examine option. Just zoom in yourself!
This commit is contained in:
tigercat2000
2017-06-07 19:39:33 -07:00
parent 4645b9e34d
commit 3652c3001a
9 changed files with 107 additions and 38 deletions
+1 -3
View File
@@ -76,8 +76,6 @@
"off" = "borgmacro")
)
var/reset_stretch = 0 //Used by things that fiddle with client's stretch-to-fit.
var/topic_debugging = 0 //if set to true, allows client to see nanoUI errors -- yes i realize this is messy but it'll make live testing infinitely easier
control_freak = CONTROL_FREAK_ALL | CONTROL_FREAK_SKIN | CONTROL_FREAK_MACROS
@@ -93,7 +91,7 @@
// Donator stuff.
var/donator_level = DONATOR_LEVEL_NONE
// If set to true, this client can interact with atoms such as buttons and doors on top of regular machinery interaction
var/advanced_admin_interaction = FALSE
+90
View File
@@ -0,0 +1,90 @@
/*
* ViewMods Client module
* This should be used by anything that wants to change a client's view range.
* Also includes
*/
/* Defines */
#define CUSTOM_VIEWRANGES list(1, 2, 3, 4, 5, 6, "RESET")
/* Viewmods */
/client
var/list/ViewMods = list()
var/ViewModsActive = FALSE
var/ViewPreferedIconSize = 0
/client/proc/AddViewMod(id, size)
var/datum/viewmod/V = new /datum/viewmod(id, size)
ViewMods[V.id] = V
UpdateView()
/client/proc/CheckViewMod(id)
. = 0
if(ViewMods[id])
. = 1
/client/proc/RemoveViewMod(id)
if(CheckViewMod(id))
qdel(ViewMods[id])
ViewMods.Remove(id)
UpdateView()
/client/proc/UpdateView()
if(!ViewModsActive)
ViewPreferedIconSize = winget(src, "mapwindow.map", "icon-size")
var/highest_range = 0
for(var/mod_id in ViewMods)
var/datum/viewmod/V = ViewMods[mod_id]
highest_range = max(highest_range, V.size)
SetView(highest_range ? highest_range : world.view)
ViewModsActive = (highest_range > 0)
/client/proc/SetView(view_range)
if(view_range == world.view)
winset(src, "mapwindow.map", "icon-size=[ViewPreferedIconSize]")
else
winset(src, "mapwindow.map", "icon-size=0")
view = view_range
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 < world.view)
// If it's really tiny, turn their hud off completely
if(view_range <= ARBITRARY_VIEWRANGE_NOHUD)
mob.hud_used.show_hud(HUD_STYLE_NOHUD)
else
mob.hud_used.show_hud(HUD_STYLE_REDUCED)
else
mob.hud_used.show_hud(HUD_STYLE_STANDARD)
/* Viewmod datums */
/datum/viewmod
var/id = ""
var/size = -1
/datum/viewmod/New(new_id, new_size = world.view)
. = ..()
id = new_id
size = new_size
/* Client verbs */
/proc/viewNum_to_text(view)
return "[(view * 2) + 1]x[(view * 2) + 1]"
/client/verb/set_view_range(view_range as null|anything in CUSTOM_VIEWRANGES)
set name = "Set View Range"
set category = "Preferences"
if(!view_range)
return
RemoveViewMod("custom")
if(view_range == "RESET")
to_chat(src, "<span class='notice'>View range reset.</span>")
return
to_chat(src, "<span class='notice'>View range set to [viewNum_to_text(view_range)]</span>")
AddViewMod("custom", view_range)
-8
View File
@@ -149,14 +149,6 @@
/client/Move(n, direct)
if(viewingCanvas)
view = world.view //Reset the view
winset(src, "mapwindow.map", "icon-size=[src.reset_stretch]")
viewingCanvas = 0
mob.reset_perspective()
if(mob.hud_used)
mob.hud_used.show_hud(HUD_STYLE_STANDARD)
if(world.time < move_delay)
return