|
1 | 1 | /datum/browser
|
2 |
| - var/mob/user |
| 2 | + var/client/user |
3 | 3 | var/title
|
4 | 4 | var/window_id // window_id is used as the window name for browse and onclose
|
5 | 5 | var/width = 0
|
|
18 | 18 | var/static/datum/asset/simple/common/common_asset = get_asset_datum(/datum/asset/simple/common)
|
19 | 19 | var/static/datum/asset/simple/other/other_asset = get_asset_datum(/datum/asset/simple/other)
|
20 | 20 |
|
| 21 | + var/existing_browser = FALSE |
| 22 | + |
21 | 23 |
|
22 | 24 | /datum/browser/New(nuser, nwindow_id, ntitle = 0, nstylesheet = "common.css", nwidth = 0, nheight = 0, atom/nref = null)
|
23 | 25 | user = nuser
|
|
70 | 72 | head_content += "<link rel='stylesheet' type='text/css' href='[common_asset.get_url_mappings()[stylesheet]]'>"
|
71 | 73 | head_content += "<link rel='stylesheet' type='text/css' href='[other_asset.get_url_mappings()["loading.gif"]]'>"
|
72 | 74 |
|
| 75 | + if(user.window_scaling && user.window_scaling != 1 && !user.prefs.window_scale && width && height) |
| 76 | + head_content += {" |
| 77 | + <style> |
| 78 | + body { |
| 79 | + zoom: [100 / user.window_scaling]%; |
| 80 | + } |
| 81 | + </style> |
| 82 | + "} |
| 83 | + |
73 | 84 | for (var/file in stylesheets)
|
74 | 85 | head_content += "<link rel='stylesheet' type='text/css' href='[SSassets.transport.get_asset_url(file)]'>"
|
75 | 86 |
|
|
114 | 125 | return
|
115 | 126 | var/window_size = ""
|
116 | 127 | if (width && height)
|
117 |
| - window_size = "size=[width]x[height];" |
| 128 | + if(user.window_scaling && user.prefs.window_scale) |
| 129 | + window_size = "size=[width * user?.window_scaling]x[height * user?.window_scaling];" |
| 130 | + else |
| 131 | + window_size = "size=[width]x[height];" |
118 | 132 | common_asset.send(user)
|
119 | 133 | other_asset.send(user)
|
120 | 134 | if (length(stylesheets))
|
|
124 | 138 |
|
125 | 139 | user << browse(get_content(), "window=[window_id];[window_size][window_options]")
|
126 | 140 |
|
| 141 | + if(existing_browser) |
| 142 | + winset(user, existing_browser, window_size) |
| 143 | + |
127 | 144 | if (use_onclose)
|
128 | 145 | setup_onclose()
|
129 | 146 |
|
|
226 | 243 | mob.unset_interaction()
|
227 | 244 | return
|
228 | 245 |
|
229 |
| -/proc/show_browser(target, browser_content, browser_name, id = null, window_options = null, closeref) |
| 246 | +/proc/show_browser(target, browser_content, browser_name, id = null, window_options = null, closeref, width, height, existing_container = FALSE) |
230 | 247 | var/client/C = target
|
231 | 248 |
|
232 | 249 | if (ismob(target))
|
|
241 | 258 | C.prefs.stylesheet = "Modern"
|
242 | 259 | stylesheet = "Modern"
|
243 | 260 |
|
244 |
| - var/datum/browser/popup = new(C, id ? id : browser_name, browser_name, GLOB.stylesheets[stylesheet], nref = closeref) |
| 261 | + var/datum/browser/popup = new(C, id ? id : browser_name, browser_name, GLOB.stylesheets[stylesheet], nwidth = width, nheight = height, nref = closeref) |
| 262 | + |
| 263 | + if(existing_container) |
| 264 | + popup.existing_browser = existing_container |
| 265 | + |
245 | 266 | popup.set_content(browser_content)
|
246 | 267 | if (window_options)
|
247 | 268 | popup.set_window_options(window_options)
|
|
324 | 345 | set_content(output)
|
325 | 346 |
|
326 | 347 | /datum/browser/modal/listpicker/Topic(href,href_list)
|
327 |
| - if (href_list["close"] || !user || !user.client) |
| 348 | + if (href_list["close"] || !user) |
328 | 349 | opentime = 0
|
329 | 350 | return
|
330 | 351 | if (href_list["button"])
|
|
0 commit comments