mirror of
https://github.com/Sandstorm-Station/Sandstorm-Station-13.git
synced 2026-07-17 11:15:35 +01:00
push
This commit is contained in:
@@ -357,17 +357,25 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
dat += "<HR>"
|
||||
|
||||
dat += "<center>"
|
||||
var/client_file = user.client.Import()
|
||||
var/savefile/client_file = user.client.Import()
|
||||
var/savefile_name
|
||||
if(client_file)
|
||||
var/savefile/cache_savefile = new(user.client.Import())
|
||||
if(!cache_savefile["deleted"] || savefile_needs_update(cache_savefile) != -2)
|
||||
cache_savefile["real_name"] >> savefile_name
|
||||
if(istype(client_file, /savefile))
|
||||
if(!client_file["deleted"] || savefile_needs_update(client_file) != -2)
|
||||
client_file["real_name"] >> savefile_name
|
||||
dat += "Local storage: [savefile_name ? savefile_name : "Empty"]"
|
||||
dat += "<br />"
|
||||
dat += "<a href='?_src_=prefs;preference=export_slot'>Export current slot</a>"
|
||||
dat += "<a [savefile_name ? "href='?_src_=prefs;preference=import_slot' style='white-space:normal;'" : "class='linkOff'"]>Import into current slot</a>"
|
||||
dat += "<a href='?_src_=prefs;preference=delete_local_copy' style='white-space:normal;background:#eb2e2e;'>Delete locally saved character</a>"
|
||||
dat += "<br />"
|
||||
dat += "<a href='?_src_=prefs;preference=give_slot' [offer ? "style='white-space:normal;background:#eb2e2e;'" : ""]>[offer ? "Cancel offer" : "Offer slot"]</a>"
|
||||
dat += "<a href='?_src_=prefs;preference=retrieve_slot'>Retrieve offered character</a>"
|
||||
if(offer)
|
||||
dat += "<br />"
|
||||
dat += "The redemption code is <b>[offer.redemption_code]</b>"
|
||||
dat += "<br />"
|
||||
dat += "The offer will automatically be cancelled if there is an error, or if someone takes it"
|
||||
|
||||
dat += "</center>"
|
||||
|
||||
dat += "<HR>"
|
||||
@@ -3469,6 +3477,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
if(istype(S, /savefile))
|
||||
if(istype(load_character(provided = S), /savefile))
|
||||
tgui_alert_async(user, "Successfully loaded character slot.")
|
||||
save_character(TRUE)
|
||||
else
|
||||
tgui_alert_async(user, "Failed loading character slot")
|
||||
return
|
||||
@@ -3480,6 +3489,63 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
user.client.clear_export()
|
||||
tgui_alert_async(user, "Local save data erased.")
|
||||
|
||||
if("give_slot")
|
||||
if(!QDELETED(offer))
|
||||
var/datum/character_offer_instance/offer_datum = LAZYACCESS(GLOB.character_offers, offer.redemption_code)
|
||||
if(!offer_datum)
|
||||
return
|
||||
qdel(offer_datum)
|
||||
else
|
||||
var/savefile/S = save_character(export = TRUE)
|
||||
if(istype(S, /savefile))
|
||||
var/datum/character_offer_instance/offer_datum = new(usr.ckey, S)
|
||||
if(QDELETED(offer_datum))
|
||||
tgui_alert_async(usr, "Could not set up offer, try again later")
|
||||
return
|
||||
offer_datum.RegisterSignal(usr, COMSIG_MOB_CLIENT_LOGOUT, TYPE_PROC_REF(/datum/character_offer_instance, on_quit))
|
||||
offer = offer_datum
|
||||
tgui_alert_async(usr, "The redemption code is [offer_datum.redemption_code], give it to the receiver")
|
||||
|
||||
if("retrieve_slot")
|
||||
if(!LAZYLEN(GLOB.character_offers))
|
||||
tgui_alert_async(usr, "There are no active offers")
|
||||
return
|
||||
var/retrieve_code = input(usr, "Input the 5 digit redemption code") as text|null
|
||||
if(!retrieve_code)
|
||||
return
|
||||
if(!text2num(retrieve_code))
|
||||
tgui_alert_async(usr, "Only numbers allowed")
|
||||
return
|
||||
if(length(retrieve_code) != 5)
|
||||
tgui_alert_async(usr, "Exactly 5 digits, no less, no more, try again")
|
||||
return
|
||||
var/datum/character_offer_instance/offer_datum = LAZYACCESS(GLOB.character_offers, retrieve_code)
|
||||
if(!offer_datum)
|
||||
tgui_alert_async(usr, "This is an invalid code!")
|
||||
return
|
||||
var/savefile/savefile = offer_datum.character_savefile
|
||||
var/mob/living/the_owner = get_mob_by_ckey(offer_datum.owner_ckey)
|
||||
if(savefile_needs_update(savefile) == -2)
|
||||
tgui_alert_async(usr, "Something's wrong, this savefile is corrupted.")
|
||||
to_chat(the_owner, span_boldwarning("Something went wrong with the trade, it's been canceled."))
|
||||
qdel(offer_datum)
|
||||
return
|
||||
var/character_name = savefile["real_name"]
|
||||
if(tgui_alert(usr, "You are overwriting the currently selected slot with the character [character_name]", "Are you sure?", buttons = list("Yes, load this character deleting the currently selected slot", "No")) == "No")
|
||||
return
|
||||
if(QDELETED(offer_datum))
|
||||
tgui_alert_async(usr, "This character is no longer available, such a shame!")
|
||||
return
|
||||
to_chat(the_owner, span_boldwarning("[usr.key] has retrieved your character, [character_name]!"))
|
||||
if(!load_character(provided = savefile))
|
||||
tgui_alert_async(usr, "Something went wrong loading the savefile, even though it has already been checked, please report this issue!")
|
||||
to_chat(the_owner, span_boldwarning("Something went wrong at the final step of the trade, report this."))
|
||||
qdel(offer_datum)
|
||||
return
|
||||
tgui_alert_async(usr, "Successfully received [character_name]!")
|
||||
save_character(TRUE)
|
||||
qdel(offer_datum)
|
||||
|
||||
if(href_list["preference"] == "gear")
|
||||
if(href_list["clear_loadout"])
|
||||
loadout_data["SAVE_[loadout_slot]"] = list()
|
||||
|
||||
Reference in New Issue
Block a user