diff --git a/code/modules/client/preference_setup/loadout/loadout.dm b/code/modules/client/preference_setup/loadout/loadout.dm index 3205e9218fe..19252e6c85f 100644 --- a/code/modules/client/preference_setup/loadout/loadout.dm +++ b/code/modules/client/preference_setup/loadout/loadout.dm @@ -189,7 +189,10 @@ GLOBAL_LIST_INIT(gear_datums, list()) . += "" if (gear_reset) . += "" - . += "" + . += "" . += "
Your loadout failed to load and will be reset if you save this slot.
\<\<\[[pref.gear_slot]\] \>\>[total_cost]/[GLOB.config.loadout_cost] loadout points spent. \[Clear Loadout\]
\<\<\[[pref.gear_slot]\] \>\>[total_cost]/[GLOB.config.loadout_cost] loadout points spent. \[Clear Loadout\]" + if(GLOB.config.loadout_slots > 1) + . += " \[Duplicate Loadout\]" + . += "
" var/firstcat = 1 @@ -419,6 +422,36 @@ GLOBAL_LIST_INIT(gear_datums, list()) pref.gear.Cut() return TOPIC_REFRESH_UPDATE_PREVIEW + else if(href_list["duplicate_loadout"]) + if(pref.gear_modified) + tgui_alert(user, "Gear has been Modified - Save First or Reload", "Gear Modified", list("OK")) + return TOPIC_NOACTION + + var/source_slot = pref.gear_slot + var/list/available_slots = list() + for(var/slot = 1 to GLOB.config.loadout_slots) + if(slot != source_slot) + available_slots += "Slot [slot]" + + var/selected_slot = tgui_input_list(user, "Choose the loadout slot to replace with a copy of Slot [source_slot].", "Duplicate Loadout", available_slots) + if(!selected_slot || !CanUseTopic(user)) + return TOPIC_NOACTION + + var/target_slot = text2num(copytext(selected_slot, 6)) + if(target_slot < 1 || target_slot > GLOB.config.loadout_slots || target_slot == source_slot) + return TOPIC_NOACTION + + var/confirmation = tgui_alert(user, "Are you sure you want to replace everything in Slot [target_slot] with a copy of Slot [source_slot]?", "Duplicate Loadout", list("Yes", "No")) + if(confirmation != "Yes" || !CanUseTopic(user) || pref.gear_slot != source_slot || pref.gear_modified) + return TOPIC_NOACTION + + var/list/duplicated_gear = deep_copy_list(pref.gear) + pref.gear_list["[target_slot]"] = duplicated_gear + pref.gear_slot = target_slot + pref.gear = duplicated_gear + pref.gear_modified = TRUE + return TOPIC_REFRESH_UPDATE_PREVIEW + else if(href_list["search_input_refresh"] != null) // empty str is false search_input_value = sanitize(href_list["search_input_refresh"], 100) return TOPIC_REFRESH_UPDATE_PREVIEW diff --git a/html/changelogs/geeves-loadout_duplication.yml b/html/changelogs/geeves-loadout_duplication.yml new file mode 100644 index 00000000000..45a14528124 --- /dev/null +++ b/html/changelogs/geeves-loadout_duplication.yml @@ -0,0 +1,6 @@ +author: Geeves + +delete-after: True + +changes: + - qol: "Added the ability to duplicate a loadout into another loadout slot."