mirror of
https://github.com/CHOMPstation/CHOMPstation.git
synced 2026-08-22 03:26:21 +01:00
Multiple loadout slots (#4530)
* Multiple loadout slots Ported from Bay. Each character can have 3 (number can be overridden by config) loadout slots. This way, you can have different outfits for different situations without needing to have a separate character slot or edit your loadout every time. Tested here, works as intended. The current loadout is set as slot 1, so you don't need to worry about remaking it. This also ports the to_file and from_file macros to make it work, I'm assuming they could later be used elsewhere as well. * Log of Changing
This commit is contained in:
@@ -47,10 +47,18 @@ var/list/gear_datums = list()
|
||||
var/current_tab = "General"
|
||||
|
||||
/datum/category_item/player_setup_item/loadout/load_character(var/savefile/S)
|
||||
S["gear"] >> pref.gear
|
||||
from_file(S["gear_list"], pref.gear_list)
|
||||
from_file(S["gear_slot"], pref.gear_slot)
|
||||
if(pref.gear_list!=null && pref.gear_slot!=null)
|
||||
pref.gear = pref.gear_list["[pref.gear_slot]"]
|
||||
else
|
||||
from_file(S["gear"], pref.gear)
|
||||
pref.gear_slot = 1
|
||||
|
||||
/datum/category_item/player_setup_item/loadout/save_character(var/savefile/S)
|
||||
S["gear"] << pref.gear
|
||||
pref.gear_list["[pref.gear_slot]"] = pref.gear
|
||||
to_file(S["gear_list"], pref.gear_list)
|
||||
to_file(S["gear_slot"], pref.gear_slot)
|
||||
|
||||
/datum/category_item/player_setup_item/loadout/proc/valid_gear_choices(var/max_cost)
|
||||
. = list()
|
||||
@@ -68,6 +76,8 @@ var/list/gear_datums = list()
|
||||
var/mob/preference_mob = preference_mob()
|
||||
if(!islist(pref.gear))
|
||||
pref.gear = list()
|
||||
if(!islist(pref.gear_list))
|
||||
pref.gear_list = list()
|
||||
|
||||
for(var/gear_name in pref.gear)
|
||||
if(!(gear_name in gear_datums))
|
||||
@@ -102,7 +112,7 @@ var/list/gear_datums = list()
|
||||
fcolor = "#E67300"
|
||||
|
||||
. += "<table align = 'center' width = 100%>"
|
||||
. += "<tr><td colspan=3><center><b><font color = '[fcolor]'>[total_cost]/[MAX_GEAR_COST]</font> loadout points spent.</b> \[<a href='?src=\ref[src];clear_loadout=1'>Clear Loadout</a>\]</center></td></tr>"
|
||||
. += "<tr><td colspan=3><center><a href='?src=\ref[src];prev_slot=1'>\<\<</a><b><font color = '[fcolor]'>\[[pref.gear_slot]\]</font> </b><a href='?src=\ref[src];next_slot=1'>\>\></a><b><font color = '[fcolor]'>[total_cost]/[MAX_GEAR_COST]</font> loadout points spent.</b> \[<a href='?src=\ref[src];clear_loadout=1'>Clear Loadout</a>\]</center></td></tr>"
|
||||
|
||||
. += "<tr><td colspan=3><center><b>"
|
||||
var/firstcat = 1
|
||||
@@ -187,6 +197,29 @@ var/list/gear_datums = list()
|
||||
return TOPIC_NOACTION
|
||||
set_tweak_metadata(gear, tweak, metadata)
|
||||
return TOPIC_REFRESH_UPDATE_PREVIEW
|
||||
if(href_list["next_slot"] || href_list["prev_slot"])
|
||||
//Set the current slot in the gear list to the currently selected gear
|
||||
pref.gear_list["[pref.gear_slot]"] = pref.gear
|
||||
//If we're moving up a slot..
|
||||
if(href_list["next_slot"])
|
||||
//change the current slot number
|
||||
pref.gear_slot = pref.gear_slot+1
|
||||
if(pref.gear_slot>config.loadout_slots)
|
||||
pref.gear_slot = 1
|
||||
//If we're moving down a slot..
|
||||
else if(href_list["prev_slot"])
|
||||
//change current slot one down
|
||||
pref.gear_slot = pref.gear_slot-1
|
||||
if(pref.gear_slot<1)
|
||||
pref.gear_slot = config.loadout_slots
|
||||
// Set the currently selected gear to whatever's in the new slot
|
||||
if(pref.gear_list["[pref.gear_slot]"])
|
||||
pref.gear = pref.gear_list["[pref.gear_slot]"]
|
||||
else
|
||||
pref.gear = list()
|
||||
pref.gear_list["[pref.gear_slot]"] = list()
|
||||
// Refresh?
|
||||
return TOPIC_REFRESH_UPDATE_PREVIEW
|
||||
else if(href_list["select_category"])
|
||||
current_tab = href_list["select_category"]
|
||||
return TOPIC_REFRESH
|
||||
|
||||
@@ -50,7 +50,9 @@ datum/preferences
|
||||
var/species_preview //Used for the species selection window.
|
||||
var/list/alternate_languages = list() //Secondary language(s)
|
||||
var/list/language_prefixes = list() //Kanguage prefix keys
|
||||
var/list/gear //Custom/fluff item loadout.
|
||||
var/list/gear //Left in for Legacy reasons, will no longer save.
|
||||
var/list/gear_list = list() //Custom/fluff item loadouts.
|
||||
var/gear_slot = 1 //The current gear save slot
|
||||
var/list/traits //Traits which modifier characters for better or worse (mostly worse).
|
||||
var/synth_color = 0 //Lets normally uncolorable synth parts be colorable.
|
||||
var/r_synth //Used with synth_color to color synth parts that normaly can't be colored.
|
||||
@@ -131,6 +133,8 @@ datum/preferences
|
||||
b_type = RANDOM_BLOOD_TYPE
|
||||
|
||||
gear = list()
|
||||
gear_list = list()
|
||||
gear_slot = 1
|
||||
|
||||
if(istype(C))
|
||||
client = C
|
||||
|
||||
Reference in New Issue
Block a user