mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2026-08-22 12:16:40 +01:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -465,6 +465,22 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
|
||||
dat += "<HR>"
|
||||
|
||||
dat += "<center>"
|
||||
var/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
|
||||
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 += "</center>"
|
||||
|
||||
dat += "<HR>"
|
||||
|
||||
dat += "<center>"
|
||||
dat += "<a href='?_src_=prefs;preference=character_tab;tab=[GENERAL_CHAR_TAB]' [character_settings_tab == GENERAL_CHAR_TAB ? "class='linkOn'" : ""]>General</a>"
|
||||
dat += "<a href='?_src_=prefs;preference=character_tab;tab=[APPEARANCE_CHAR_TAB]' [character_settings_tab == APPEARANCE_CHAR_TAB ? "class='linkOn'" : ""]>Appearance</a>"
|
||||
@@ -3920,6 +3936,30 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
if("cumontopref")
|
||||
cit_toggles ^= CUM_ONTO
|
||||
//
|
||||
if("export_slot")
|
||||
var/savefile/S = save_character(export = TRUE)
|
||||
if(istype(S, /savefile))
|
||||
user.client.Export(S)
|
||||
tgui_alert_async(user, "Successfully saved character slot")
|
||||
else
|
||||
tgui_alert_async(user, "Failed saving character slot")
|
||||
return
|
||||
|
||||
if("import_slot")
|
||||
var/savefile/S = new(user.client.Import())
|
||||
if(istype(S, /savefile))
|
||||
if(load_character(provided = S) == TRUE)
|
||||
tgui_alert_async(user, "Successfully loaded character slot.")
|
||||
else
|
||||
tgui_alert_async(user, "Failed loading character slot")
|
||||
return
|
||||
else
|
||||
tgui_alert_async(user, "Failed loading character slot")
|
||||
return
|
||||
|
||||
if("delete_local_copy")
|
||||
user.client.clear_export()
|
||||
tgui_alert_async(user, "Local save data erased.")
|
||||
|
||||
if(href_list["preference"] == "gear")
|
||||
if(href_list["clear_loadout"])
|
||||
|
||||
@@ -723,9 +723,10 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
|
||||
|
||||
return 1
|
||||
|
||||
/datum/preferences/proc/load_character(slot, bypass_cooldown = FALSE)
|
||||
if(!path)
|
||||
return FALSE
|
||||
/datum/preferences/proc/load_character(slot, bypass_cooldown = FALSE, savefile/provided)
|
||||
if(!provided)
|
||||
if(!path)
|
||||
return FALSE
|
||||
if(!bypass_cooldown)
|
||||
if(world.time < loadcharcooldown) //This is before the check to see if the filepath exists to ensure that BYOND can't get hung up on read attempts when the hard drive is a little slow
|
||||
if(istype(parent))
|
||||
@@ -734,9 +735,30 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
|
||||
loadcharcooldown = world.time + PREF_SAVELOAD_COOLDOWN
|
||||
if(!fexists(path))
|
||||
return FALSE
|
||||
var/savefile/S = new /savefile(path)
|
||||
var/savefile/S
|
||||
if(provided)
|
||||
S = provided
|
||||
else
|
||||
S = new /savefile(path)
|
||||
if(!S)
|
||||
return FALSE
|
||||
|
||||
S.cd = "/"
|
||||
if(!slot)
|
||||
slot = default_slot
|
||||
slot = sanitize_integer(slot, 1, max_save_slots, initial(default_slot))
|
||||
if(slot != default_slot)
|
||||
default_slot = slot
|
||||
WRITE_FILE(S["default_slot"] , slot)
|
||||
|
||||
if(!provided)
|
||||
S.cd = "/character[slot]"
|
||||
var/needs_update = savefile_needs_update(S)
|
||||
if(needs_update == -2) //fatal, can't load any data
|
||||
return FALSE
|
||||
|
||||
. = TRUE
|
||||
|
||||
features = list(
|
||||
"mcolor" = "FFFFFF",
|
||||
"mcolor2" = "FFFFFF",
|
||||
@@ -829,22 +851,6 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
|
||||
"neckfire_color" = "ffffff"
|
||||
)
|
||||
|
||||
|
||||
S.cd = "/"
|
||||
if(!slot)
|
||||
slot = default_slot
|
||||
slot = sanitize_integer(slot, 1, max_save_slots, initial(default_slot))
|
||||
if(slot != default_slot)
|
||||
default_slot = slot
|
||||
WRITE_FILE(S["default_slot"] , slot)
|
||||
|
||||
S.cd = "/character[slot]"
|
||||
var/needs_update = savefile_needs_update(S)
|
||||
if(needs_update == -2) //fatal, can't load any data
|
||||
return FALSE
|
||||
|
||||
. = TRUE
|
||||
|
||||
//Species
|
||||
var/species_id
|
||||
S["species"] >> species_id
|
||||
@@ -1311,7 +1317,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
|
||||
|
||||
return 1
|
||||
|
||||
/datum/preferences/proc/save_character(bypass_cooldown = FALSE)
|
||||
/datum/preferences/proc/save_character(bypass_cooldown = FALSE, export = FALSE)
|
||||
if(!path)
|
||||
return 0
|
||||
if(!bypass_cooldown)
|
||||
@@ -1320,10 +1326,11 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
|
||||
to_chat(parent, "<span class='warning'>You're attempting to save your character a little too fast. Wait half a second, then try again.</span>")
|
||||
return 0
|
||||
savecharcooldown = world.time + PREF_SAVELOAD_COOLDOWN
|
||||
var/savefile/S = new /savefile(path)
|
||||
var/savefile/S = new /savefile(export ? null : path)
|
||||
if(!S)
|
||||
return 0
|
||||
S.cd = "/character[default_slot]"
|
||||
if(!export)
|
||||
S.cd = "/character[default_slot]"
|
||||
|
||||
WRITE_FILE(S["version"] , SAVEFILE_VERSION_MAX) //load_character will sanitize any bad data, so assume up-to-date.)
|
||||
|
||||
@@ -1556,7 +1563,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
|
||||
|
||||
splurt_character_pref_save(S)
|
||||
|
||||
return 1
|
||||
return S
|
||||
|
||||
|
||||
#undef SAVEFILE_VERSION_MAX
|
||||
|
||||
Reference in New Issue
Block a user