Refactors the Preferences window to use appearances (#41978)

Instead of using expensive getFlatIcon() calls, character previews are now shown using appearance clones in a second map window.

Its creating a secondary map and adding mut_appearances as screen objs on that map.

There are 1 set of dummy objects per client, it also only creates them while the preview window is open and garbage collects them when it's closed.

Because it creates the MA from the main preview dummy mob, the dummy mob's appearance remains a seperate object and they don't affect each other
This commit is contained in:
kevinz000
2018-12-29 03:11:26 -08:00
committed by yogstation13-bot
parent 93637388aa
commit f2a3b06c13
6 changed files with 68 additions and 42 deletions

View File

@@ -461,4 +461,3 @@
// so just reset the user mob's machine var // so just reset the user mob's machine var
if(src && src.mob) if(src && src.mob)
src.mob.unset_machine() src.mob.unset_machine()
return

View File

@@ -74,4 +74,8 @@
var/datum/player_details/player_details //these persist between logins/logouts during the same round. var/datum/player_details/player_details //these persist between logins/logouts during the same round.
<<<<<<< HEAD
var/encoding = "1252" // yogs - LibVG var/encoding = "1252" // yogs - LibVG
=======
var/list/char_render_holders //Should only be a key-value list of north/south/east/west = obj/screen.
>>>>>>> 620db42963... Refactors the Preferences window to use appearances (#41978)

View File

@@ -453,6 +453,7 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
GLOB.ahelp_tickets.ClientLogout(src) GLOB.ahelp_tickets.ClientLogout(src)
GLOB.directory -= ckey GLOB.directory -= ckey
GLOB.clients -= src GLOB.clients -= src
QDEL_LIST_ASSOC_VAL(char_render_holders)
if(movingmob != null) if(movingmob != null)
movingmob.client_mobs_in_contents -= mob movingmob.client_mobs_in_contents -= mob
UNSETEMPTY(movingmob.client_mobs_in_contents) UNSETEMPTY(movingmob.client_mobs_in_contents)
@@ -881,3 +882,23 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
/client/proc/AnnouncePR(announcement) /client/proc/AnnouncePR(announcement)
if(prefs && prefs.chat_toggles & CHAT_PULLR) if(prefs && prefs.chat_toggles & CHAT_PULLR)
to_chat(src, announcement) to_chat(src, announcement)
/client/proc/show_character_previews(mutable_appearance/MA)
var/pos = 0
for(var/D in GLOB.cardinals)
pos++
var/obj/screen/O = LAZYACCESS(char_render_holders, "[D]")
if(!O)
O = new
LAZYSET(char_render_holders, "[D]", O)
screen |= O
O.appearance = MA
O.dir = D
O.screen_loc = "character_preview_map:0,[pos]"
/client/proc/clear_character_previews()
for(var/index in char_render_holders)
var/obj/screen/S = char_render_holders[index]
screen -= S
qdel(S)
char_render_holders = null

View File

@@ -25,7 +25,6 @@ GLOBAL_LIST_EMPTY(preferences_datums)
//If it's 0, that's good, if it's anything but 0, the owner of this prefs file's antag choices were, //If it's 0, that's good, if it's anything but 0, the owner of this prefs file's antag choices were,
//autocorrected this round, not that you'd need to check that. //autocorrected this round, not that you'd need to check that.
var/UI_style = null var/UI_style = null
var/buttons_locked = FALSE var/buttons_locked = FALSE
var/hotkeys = TRUE // yogs - Rebindable Keybindings var/hotkeys = TRUE // yogs - Rebindable Keybindings
@@ -71,9 +70,6 @@ GLOBAL_LIST_EMPTY(preferences_datums)
var/preferred_ai_core_display = "Blue" var/preferred_ai_core_display = "Blue"
var/prefered_security_department = SEC_DEPT_RANDOM var/prefered_security_department = SEC_DEPT_RANDOM
//Mob preview
var/icon/preview_icon = null
//Quirk list //Quirk list
var/list/positive_quirks = list() var/list/positive_quirks = list()
var/list/negative_quirks = list() var/list/negative_quirks = list()
@@ -155,7 +151,6 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if(!user || !user.client) if(!user || !user.client)
return return
update_preview_icon() update_preview_icon()
user << browse_rsc(preview_icon, "previewicon.png")
var/list/dat = list("<center>") var/list/dat = list("<center>")
dat += "<a href='?_src_=prefs;preference=tab;tab=0' [current_tab == 0 ? "class='linkOn'" : ""]>Character Settings</a>" dat += "<a href='?_src_=prefs;preference=tab;tab=0' [current_tab == 0 ? "class='linkOn'" : ""]>Character Settings</a>"
@@ -227,11 +222,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
dat += "<a href='?_src_=prefs;preference=ai_core_icon;task=input'><b>Preferred AI Core Display:</b> [preferred_ai_core_display]</a><br>" dat += "<a href='?_src_=prefs;preference=ai_core_icon;task=input'><b>Preferred AI Core Display:</b> [preferred_ai_core_display]</a><br>"
dat += "<a href='?_src_=prefs;preference=sec_dept;task=input'><b>Preferred Security Department:</b> [prefered_security_department]</a><BR></td>" dat += "<a href='?_src_=prefs;preference=sec_dept;task=input'><b>Preferred Security Department:</b> [prefered_security_department]</a><BR></td>"
dat += "<td valign='center'>" dat += "</tr></table>"
dat += "<div class='statusDisplay'><center><img src=previewicon.png width=[preview_icon.Width()] height=[preview_icon.Height()]></center></div>"
dat += "</td></tr></table>"
dat += "<h2>Body</h2>" dat += "<h2>Body</h2>"
dat += "<a href='?_src_=prefs;preference=all;task=random'>Random Body</A> " dat += "<a href='?_src_=prefs;preference=all;task=random'>Random Body</A> "
@@ -724,9 +715,11 @@ GLOBAL_LIST_EMPTY(preferences_datums)
dat += "<a href='?_src_=prefs;preference=reset_all'>Reset Setup</a>" dat += "<a href='?_src_=prefs;preference=reset_all'>Reset Setup</a>"
dat += "</center>" dat += "</center>"
var/datum/browser/popup = new(user, "preferences", "<div align='center'>Character Setup</div>", 640, 770) winshow(user, "preferences_window", TRUE)
var/datum/browser/popup = new(user, "preferences_browser", "<div align='center'>Character Setup</div>", 640, 770)
popup.set_content(dat.Join()) popup.set_content(dat.Join())
popup.open(FALSE) popup.open(FALSE)
onclose(user, "preferences_window", src)
#undef APPEARANCE_CATEGORY_COLUMN #undef APPEARANCE_CATEGORY_COLUMN
#undef MAX_MUTANT_ROWS #undef MAX_MUTANT_ROWS
@@ -857,12 +850,10 @@ GLOBAL_LIST_EMPTY(preferences_datums)
HTML += "<center><br><a href='?_src_=prefs;preference=job;task=random'>[message]</a></center>" HTML += "<center><br><a href='?_src_=prefs;preference=job;task=random'>[message]</a></center>"
HTML += "<center><a href='?_src_=prefs;preference=job;task=reset'>Reset Preferences</a></center>" HTML += "<center><a href='?_src_=prefs;preference=job;task=reset'>Reset Preferences</a></center>"
user << browse(null, "window=preferences")
var/datum/browser/popup = new(user, "mob_occupation", "<div align='center'>Occupation Preferences</div>", width, height) var/datum/browser/popup = new(user, "mob_occupation", "<div align='center'>Occupation Preferences</div>", width, height)
popup.set_window_options("can_close=0") popup.set_window_options("can_close=0")
popup.set_content(HTML) popup.set_content(HTML)
popup.open(FALSE) popup.open(FALSE)
return
/datum/preferences/proc/SetJobPreferenceLevel(datum/job/job, level) /datum/preferences/proc/SetJobPreferenceLevel(datum/job/job, level)
if (!job) if (!job)
@@ -1051,12 +1042,10 @@ GLOBAL_LIST_EMPTY(preferences_datums)
<font color='[font_color]'>[quirk_name]</font> - [initial(T.desc)]<br>" <font color='[font_color]'>[quirk_name]</font> - [initial(T.desc)]<br>"
dat += "<br><center><a href='?_src_=prefs;preference=trait;task=reset'>Reset Quirks</a></center>" dat += "<br><center><a href='?_src_=prefs;preference=trait;task=reset'>Reset Quirks</a></center>"
user << browse(null, "window=preferences")
var/datum/browser/popup = new(user, "mob_occupation", "<div align='center'>Quirk Preferences</div>", 900, 600) //no reason not to reuse the occupation window, as it's cleaner that way var/datum/browser/popup = new(user, "mob_occupation", "<div align='center'>Quirk Preferences</div>", 900, 600) //no reason not to reuse the occupation window, as it's cleaner that way
popup.set_window_options("can_close=0") popup.set_window_options("can_close=0")
popup.set_content(dat.Join()) popup.set_content(dat.Join())
popup.open(FALSE) popup.open(FALSE)
return
/datum/preferences/proc/GetQuirkBalance() /datum/preferences/proc/GetQuirkBalance()
var/bal = 0 var/bal = 0
@@ -1065,6 +1054,13 @@ GLOBAL_LIST_EMPTY(preferences_datums)
bal -= initial(T.value) bal -= initial(T.value)
return bal return bal
/datum/preferences/Topic(href, href_list, hsrc) //yeah, gotta do this I guess..
. = ..()
if(href_list["close"])
var/client/C = usr.client
if(C)
C.clear_character_previews()
/datum/preferences/proc/process_link(mob/user, list/href_list) /datum/preferences/proc/process_link(mob/user, list/href_list)
// yogs start - Donor features // yogs start - Donor features
if(href_list["preference"] == "donor") if(href_list["preference"] == "donor")

View File

@@ -25,12 +25,10 @@
if(job_engsec_high) if(job_engsec_high)
switch(job_engsec_high) switch(job_engsec_high)
if(AI_JF) if(AI_JF)
preview_icon = icon('icons/mob/ai.dmi', resolve_ai_icon(preferred_ai_core_display), SOUTH) parent.show_character_previews(image('icons/mob/ai.dmi', icon_state = resolve_ai_icon(preferred_ai_core_display), dir = SOUTH))
preview_icon.Scale(64, 64)
return return
if(CYBORG) if(CYBORG)
preview_icon = icon('icons/mob/robots.dmi', "robot", SOUTH) parent.show_character_previews(image('icons/mob/robots.dmi', icon_state = "robot", dir = SOUTH))
preview_icon.Scale(64, 64)
return return
// Set up the dummy for its photoshoot // Set up the dummy for its photoshoot
@@ -61,26 +59,5 @@
mannequin.job = previewJob.title mannequin.job = previewJob.title
previewJob.equip(mannequin, TRUE) previewJob.equip(mannequin, TRUE)
COMPILE_OVERLAYS(mannequin) COMPILE_OVERLAYS(mannequin)
CHECK_TICK parent.show_character_previews(new /mutable_appearance(mannequin))
preview_icon = icon('icons/effects/effects.dmi', "nothing")
preview_icon.Scale(48+32, 16+32)
CHECK_TICK
mannequin.setDir(NORTH)
var/icon/stamp = getFlatIcon(mannequin)
CHECK_TICK
preview_icon.Blend(stamp, ICON_OVERLAY, 25, 17)
CHECK_TICK
mannequin.setDir(WEST)
stamp = getFlatIcon(mannequin)
CHECK_TICK
preview_icon.Blend(stamp, ICON_OVERLAY, 1, 9)
CHECK_TICK
mannequin.setDir(SOUTH)
stamp = getFlatIcon(mannequin)
CHECK_TICK
preview_icon.Blend(stamp, ICON_OVERLAY, 49, 1)
CHECK_TICK
preview_icon.Scale(preview_icon.Width() * 2, preview_icon.Height() * 2) // Scaling here to prevent blurring in the browser.
CHECK_TICK
unset_busy_human_dummy(DUMMY_HUMAN_SLOT_PREFERENCES) unset_busy_human_dummy(DUMMY_HUMAN_SLOT_PREFERENCES)

View File

@@ -1,5 +1,6 @@
macro "default" macro "default"
menu "menu" menu "menu"
elem elem
name = "&File" name = "&File"
@@ -277,6 +278,34 @@ window "outputwindow"
is-default = true is-default = true
saved-params = "" saved-params = ""
window "preferences_window"
elem "preferences_window"
type = MAIN
pos = 372,0
size = 1120x1000
anchor1 = none
anchor2 = none
background-color = none
is-visible = false
saved-params = "pos;size;is-minimized;is-maximized"
statusbar = false
elem "preferences_browser"
type = BROWSER
pos = -8,-8
size = 896x1008
anchor1 = 0,0
anchor2 = 90,100
background-color = none
saved-params = ""
elem "character_preview_map"
type = MAP
pos = 887,0
size = 313x1000
anchor1 = 90,0
anchor2 = 100,100
right-click = true
saved-params = "zoom;letterbox;zoom-mode"
window "statwindow" window "statwindow"
elem "statwindow" elem "statwindow"
type = MAIN type = MAIN