mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-20 11:35:19 +01:00
selective belly import (#18369)
* selective belly import * sanity check
This commit is contained in:
@@ -52,6 +52,8 @@
|
||||
data["show_station_news"] = GLOB.news_data.station_newspaper
|
||||
data["new_station_news"] = client.prefs.lastlorenews != GLOB.news_data.newsindex
|
||||
data["new_changelog"] = read_preference(/datum/preference/text/lastchangelog) == GLOB.changelog_hash
|
||||
data["can_start_now"] = client.is_localhost() && check_rights_for(client, R_SERVER)
|
||||
data["immediate_start"] = SSticker.start_immediately || (!isnull(SSticker.timeLeft) && SSticker.timeLeft < 0)
|
||||
|
||||
return data
|
||||
|
||||
@@ -165,3 +167,10 @@
|
||||
|
||||
playsound_local(ui.user, get_sfx("keyboard"), vol = 20)
|
||||
return TRUE
|
||||
if("start_immediately")
|
||||
if(!ui.user.client.is_localhost() || !check_rights_for(ui.user.client, R_SERVER))
|
||||
return FALSE
|
||||
|
||||
SSticker.start_immediately = TRUE
|
||||
if(SSticker.current_state == GAME_STATE_STARTUP)
|
||||
to_chat(usr, span_admin("The server is still setting up, but the round will be started as soon as possible."))
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
/datum/tgui_alert/Destroy(force, ...)
|
||||
SStgui.close_uis(src)
|
||||
state = null
|
||||
QDEL_NULL(buttons)
|
||||
buttons?.Cut()
|
||||
. = ..()
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
return null
|
||||
|
||||
if(!user.read_preference(/datum/preference/toggle/tgui_input_mode))
|
||||
return input(user, message, title) as null|anything in items
|
||||
var/our_input = input(user, message, title) as null|anything in items
|
||||
return our_input ? list(our_input) : null
|
||||
var/datum/tgui_checkbox_input/input = new(user, message, title, items, min_checked, max_checked, timeout, ui_state)
|
||||
input.tgui_interact(user)
|
||||
input.wait()
|
||||
@@ -73,7 +74,7 @@
|
||||
/datum/tgui_checkbox_input/Destroy(force)
|
||||
SStgui.close_uis(src)
|
||||
state = null
|
||||
QDEL_NULL(items)
|
||||
items?.Cut()
|
||||
|
||||
return ..()
|
||||
|
||||
@@ -115,7 +116,7 @@
|
||||
|
||||
return data
|
||||
|
||||
/datum/tgui_checkbox_input/tgui_act(action, list/params)
|
||||
/datum/tgui_checkbox_input/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
|
||||
. = ..()
|
||||
if (.)
|
||||
return
|
||||
@@ -124,7 +125,11 @@
|
||||
if("submit")
|
||||
var/list/selections = params["entry"]
|
||||
if(length(selections) >= min_checked && length(selections) <= max_checked)
|
||||
set_choices(selections)
|
||||
var/list/valid_selections = list()
|
||||
for(var/raw_entry in selections)
|
||||
if(raw_entry in items)
|
||||
valid_selections += raw_entry
|
||||
set_choices(valid_selections)
|
||||
closed = TRUE
|
||||
SStgui.close_uis(src)
|
||||
return TRUE
|
||||
|
||||
@@ -97,7 +97,8 @@
|
||||
/datum/tgui_list_input/Destroy(force)
|
||||
SStgui.close_uis(src)
|
||||
state = null
|
||||
QDEL_NULL(items)
|
||||
items?.Cut()
|
||||
items_map?.Cut()
|
||||
return ..()
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#define IMPORT_ALL_BELLIES "Import all bellies from VRDB"
|
||||
#define IMPORT_ONE_BELLY "Import one belly from VRDB"
|
||||
#define IMPORT_ONE_BELLY "Import some bellies from VRDB"
|
||||
#define IMPORT_SOULCATCHER "Import Soulcatcher from VRDB"
|
||||
|
||||
|
||||
/datum/vore_look/proc/import_belly(mob/host)
|
||||
var/panel_choice = tgui_input_list(host, "Belly Import", "Pick an option", list(IMPORT_ALL_BELLIES, IMPORT_ONE_BELLY, IMPORT_SOULCATCHER))
|
||||
if(!panel_choice) return
|
||||
var/pickOne = FALSE
|
||||
var/pickSome = FALSE
|
||||
if(panel_choice == IMPORT_ONE_BELLY)
|
||||
pickOne = TRUE
|
||||
pickSome = TRUE
|
||||
var/input_file = input(host,"Please choose a valid VRDB file to import from.","Belly Import") as file
|
||||
var/input_data
|
||||
try
|
||||
@@ -41,16 +41,22 @@
|
||||
var/list/updated = list()
|
||||
|
||||
for(var/list/raw_list in input_data)
|
||||
if(length(valid_names) >= BELLIES_MAX) break
|
||||
if(!islist(raw_list)) continue
|
||||
if(!istext(raw_list["name"])) continue
|
||||
if(length(raw_list["name"]) > BELLIES_NAME_MAX || length(raw_list["name"]) < BELLIES_NAME_MIN) continue
|
||||
if(raw_list["name"] in valid_names) continue
|
||||
if(length(valid_names) >= BELLIES_MAX)
|
||||
break
|
||||
if(!islist(raw_list))
|
||||
continue
|
||||
if(!istext(raw_list["name"]))
|
||||
continue
|
||||
if(length(raw_list["name"]) > BELLIES_NAME_MAX || length(raw_list["name"]) < BELLIES_NAME_MIN)
|
||||
continue
|
||||
if(raw_list["name"] in valid_names)
|
||||
continue
|
||||
for(var/obj/belly/B in host.vore_organs)
|
||||
if(lowertext(B.name) == lowertext(raw_list["name"]))
|
||||
updated += raw_list["name"]
|
||||
break
|
||||
if(!pickOne && length(host.vore_organs)+length(valid_names)-length(updated) >= BELLIES_MAX) continue
|
||||
if(!pickSome && length(host.vore_organs)+length(valid_names)-length(updated) >= BELLIES_MAX)
|
||||
continue
|
||||
valid_names += raw_list["name"]
|
||||
valid_lists += list(raw_list)
|
||||
|
||||
@@ -58,18 +64,29 @@
|
||||
tgui_alert_async(host, "The supplied VRDB file does not contain any valid bellies.", "Error!")
|
||||
return FALSE
|
||||
|
||||
if(pickOne)
|
||||
var/picked = tgui_input_list(host, "Belly Import", "Which belly?", valid_names)
|
||||
if(!picked) return
|
||||
if(pickSome)
|
||||
var/list/picked = tgui_input_checkboxes(host, "Belly Import", "Which bellies?", valid_names)
|
||||
if(!LAZYLEN(picked))
|
||||
return
|
||||
|
||||
var/list/trimmed_names = list()
|
||||
var/list/trimmed_lists = list()
|
||||
var/list/trimmed_update = list()
|
||||
for(var/B in valid_lists)
|
||||
if(lowertext(picked) == lowertext(B["name"]))
|
||||
valid_names = list(picked)
|
||||
valid_lists = list(B)
|
||||
break
|
||||
if(picked in updated)
|
||||
updated = list(picked)
|
||||
else
|
||||
updated = list()
|
||||
var/belly_to_check = B["name"]
|
||||
if(belly_to_check in picked)
|
||||
if(belly_to_check in updated)
|
||||
trimmed_update += belly_to_check
|
||||
if(length(host.vore_organs)+length(trimmed_names)-length(trimmed_update) >= BELLIES_MAX)
|
||||
break
|
||||
trimmed_names += belly_to_check
|
||||
trimmed_lists += list(B)
|
||||
valid_names = trimmed_names
|
||||
valid_lists = trimmed_lists
|
||||
updated = trimmed_update
|
||||
|
||||
if(length(valid_names) == 0)
|
||||
return FALSE
|
||||
|
||||
var/list/alert_msg = list()
|
||||
if(length(valid_names)-length(updated) > 0)
|
||||
|
||||
Reference in New Issue
Block a user