|
| 1 | +//This is intended to be a full wrapper. DO NOT directly modify its values |
| 2 | +///Container for client viewsize |
| 3 | +/datum/viewData |
| 4 | + var/width = 0 |
| 5 | + var/height = 0 |
| 6 | + var/default = "" |
| 7 | + var/is_suppressed = FALSE |
| 8 | + var/client/chief = null |
| 9 | + |
| 10 | +/datum/viewData/New(client/owner, view_string) |
| 11 | + default = view_string |
| 12 | + chief = owner |
| 13 | + apply() |
| 14 | + |
| 15 | +/datum/viewData/proc/setDefault(string) |
| 16 | + default = string |
| 17 | + apply() |
| 18 | + |
| 19 | +/datum/viewData/proc/safeApplyFormat() |
| 20 | + if(isZooming()) |
| 21 | + assertFormat() |
| 22 | + return |
| 23 | + resetFormat() |
| 24 | + |
| 25 | +/datum/viewData/proc/assertFormat()//T-Pose |
| 26 | + winset(chief, "mapwindow.map", "zoom=0") |
| 27 | + |
| 28 | +/datum/viewData/proc/resetFormat()//Cuck |
| 29 | + winset(chief, "mapwindow.map", "zoom=[chief.prefs.pixel_size]") |
| 30 | + |
| 31 | +/datum/viewData/proc/setZoomMode() |
| 32 | + winset(chief, "mapwindow.map", "zoom-mode=[chief.prefs.scaling_method]") |
| 33 | + |
| 34 | +/datum/viewData/proc/isZooming() |
| 35 | + return (width || height) |
| 36 | + |
| 37 | +/datum/viewData/proc/resetToDefault() |
| 38 | + width = 0 |
| 39 | + height = 0 |
| 40 | + apply() |
| 41 | + |
| 42 | +/datum/viewData/proc/add(toAdd) |
| 43 | + width += toAdd |
| 44 | + height += toAdd |
| 45 | + apply() |
| 46 | + |
| 47 | +/datum/viewData/proc/addTo(toAdd) |
| 48 | + var/list/shitcode = getviewsize(toAdd) |
| 49 | + width += shitcode[1] |
| 50 | + height += shitcode[2] |
| 51 | + apply() |
| 52 | + |
| 53 | +/datum/viewData/proc/setTo(toAdd) |
| 54 | + var/list/shitcode = getviewsize(toAdd) //Backward compatability to account |
| 55 | + width = shitcode[1] //for a change in how sizes get calculated. we used to include world.view in |
| 56 | + height = shitcode[2] //this, but it was jank, so I had to move it |
| 57 | + apply() |
| 58 | + |
| 59 | +/datum/viewData/proc/setBoth(wid, hei) |
| 60 | + width = wid |
| 61 | + height = hei |
| 62 | + apply() |
| 63 | + |
| 64 | +/datum/viewData/proc/setWidth(wid) |
| 65 | + width = wid |
| 66 | + apply() |
| 67 | + |
| 68 | +/datum/viewData/proc/setHeight(hei) |
| 69 | + width = hei |
| 70 | + apply() |
| 71 | + |
| 72 | +/datum/viewData/proc/addToWidth(toAdd) |
| 73 | + width += toAdd |
| 74 | + apply() |
| 75 | + |
| 76 | +/datum/viewData/proc/addToHeight(screen, toAdd) |
| 77 | + height += toAdd |
| 78 | + apply() |
| 79 | + |
| 80 | +/datum/viewData/proc/apply() |
| 81 | + chief.change_view(getView()) |
| 82 | + safeApplyFormat() |
| 83 | + if(chief.prefs.auto_fit_viewport) |
| 84 | + chief.fit_viewport() |
| 85 | + |
| 86 | +/datum/viewData/proc/supress() |
| 87 | + is_suppressed = TRUE |
| 88 | + apply() |
| 89 | + |
| 90 | +/datum/viewData/proc/unsupress() |
| 91 | + is_suppressed = FALSE |
| 92 | + apply() |
| 93 | + |
| 94 | +/datum/viewData/proc/getView() |
| 95 | + var/list/temp = getviewsize(default) |
| 96 | + if(is_suppressed) |
| 97 | + return "[temp[1]]x[temp[2]]" |
| 98 | + return "[width + temp[1]]x[height + temp[2]]" |
| 99 | + |
| 100 | +/datum/viewData/proc/zoomIn() |
| 101 | + resetToDefault() |
| 102 | + animate(chief, pixel_x = 0, pixel_y = 0, 0, FALSE, LINEAR_EASING, ANIMATION_END_NOW) |
| 103 | + |
| 104 | +/datum/viewData/proc/zoomOut(radius = 0, offset = 0, direction = FALSE) |
| 105 | + if(direction) |
| 106 | + var/_x = 0 |
| 107 | + var/_y = 0 |
| 108 | + switch(direction) |
| 109 | + if(NORTH) |
| 110 | + _y = offset |
| 111 | + if(EAST) |
| 112 | + _x = offset |
| 113 | + if(SOUTH) |
| 114 | + _y = -offset |
| 115 | + if(WEST) |
| 116 | + _x = -offset |
| 117 | + animate(chief, pixel_x = world.icon_size*_x, pixel_y = world.icon_size*_y, 0, FALSE, LINEAR_EASING, ANIMATION_END_NOW) |
| 118 | + //Ready for this one? |
| 119 | + setTo(radius) |
| 120 | + |
| 121 | +/proc/getScreenSize(widescreen) |
| 122 | + if(widescreen) |
| 123 | + return CONFIG_GET(string/default_view) |
| 124 | + return CONFIG_GET(string/default_view_square) |
0 commit comments