Adds support for dirs and config changing in GAGS debug menu (#58794)

Previously, the menu wouldn't show you the generation steps for icons other than the south dir icons. You can now specify which you want to see. In addition the config type itself can be changed so as to allow previewing of icons that normally are not displayed directly on the map.

Co-authored-by: Aleksej Komarov <stylemistake@gmail.com>
This commit is contained in:
Emmett Gaines
2021-05-01 00:31:25 -04:00
committed by GitHub
parent 4c7bc58da9
commit 8c6d67ed3b
3 changed files with 141 additions and 7 deletions

View File

@@ -2,14 +2,17 @@
var/atom/target
var/client/user
var/datum/greyscale_config/config
var/list/split_colors
var/list/sprite_data
var/sprite_dir = SOUTH
/datum/greyscale_modify_menu/New(atom/target, client/user)
src.target = target
src.user = user
config = SSgreyscale.configurations["[target.greyscale_config]"]
ReadColorsFromString(target.greyscale_colors)
refresh_preview()
@@ -35,14 +38,17 @@
/datum/greyscale_modify_menu/ui_data(mob/user)
var/list/data = list()
data["greyscale_config"] = "[config.type]"
var/list/color_data = list()
data["colors"] = color_data
for(var/i in 1 to length(split_colors))
for(var/i in 1 to config.expected_colors)
color_data += list(list(
"index" = i,
"value" = split_colors[i]
))
data["sprites_dir"] = dir2text(sprite_dir)
data["sprites"] = sprite_data
return data
@@ -51,13 +57,33 @@
if(.)
return
switch(action)
if("select_config")
var/datum/greyscale_config/new_config = input(
usr,
"Choose a new greyscale configuration to use",
"Greyscale Modification Menu",
"[config.type]"
) as anything in SSgreyscale.configurations
new_config = SSgreyscale.configurations[new_config]
if(!isnull(new_config) && config != new_config)
config = new_config
refresh_preview()
if("load_config_from_string")
var/datum/greyscale_config/new_config = SSgreyscale.configurations[params["config_string"]]
if(!isnull(new_config) && config != new_config)
config = new_config
refresh_preview()
if("recolor")
var/index = text2num(params["color_index"])
split_colors[index] = lowertext(params["new_color"])
refresh_preview()
if("recolor_from_string")
ReadColorsFromString(lowertext(params["color_string"]))
refresh_preview()
if("pick_color")
var/group = params["color_index"]
var/new_color = input(
@@ -69,13 +95,20 @@
if(new_color)
split_colors[group] = new_color
refresh_preview()
if("apply")
target.set_greyscale_config(config.type, update=FALSE)
target.greyscale_colors = "" // We do this to force an update, in some cases it will think nothing changed when it should be refreshing
target.set_greyscale_colors(split_colors)
if("refresh_file")
SSgreyscale.RefreshConfigsFromFile()
refresh_preview()
if("change_dir")
sprite_dir = text2dir(params["new_sprite_dir"])
refresh_preview()
/datum/greyscale_modify_menu/proc/ReadColorsFromString(colorString)
var/list/raw_colors = splittext(colorString, "#")
split_colors = list()
@@ -83,11 +116,21 @@
split_colors += "#[raw_colors[i]]"
/datum/greyscale_modify_menu/proc/refresh_preview()
var/list/data = SSgreyscale.configurations["[target.greyscale_config]"].GenerateDebug(split_colors.Join())
for(var/i in length(split_colors) + 1 to config.expected_colors)
split_colors += rgb(100, 100, 100)
var/list/used_colors = split_colors.Copy(1, config.expected_colors+1)
var/list/data = config.GenerateDebug(used_colors.Join())
sprite_data = list()
var/list/steps = list()
sprite_data["steps"] = steps
for(var/step in data["steps"])
CHECK_TICK
steps += list(list("layer"=icon2html(data["steps"][step], user, sourceonly=TRUE), "result"=icon2html(step, user, sourceonly=TRUE)))
var/image/layer = image(data["steps"][step])
var/image/result = image(step)
steps += list(
list(
"layer"=icon2html(layer, user, dir=sprite_dir, sourceonly=TRUE),
"result"=icon2html(result, user, dir=sprite_dir, sourceonly=TRUE)
)
)