Skip to content

Commit

Permalink
pushing half complete refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
harryob committed Jan 17, 2025
1 parent 725be3e commit 64946dd
Show file tree
Hide file tree
Showing 9 changed files with 271 additions and 139 deletions.
2 changes: 1 addition & 1 deletion code/__HELPERS/sanitize_values.dm
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
continue

var/datum/gear/gear_datum = GLOB.gear_datums_by_type[gear_type]
var/new_total = running_cost + gear_datum.cost
var/new_total = running_cost + gear_datum.fluff_cost

if(new_total > MAX_GEAR_COST)
to_chat(user, SPAN_WARNING("Your [gear_datum.display_name] was removed from your loadout as it exceeded the point limit."))
Expand Down
1 change: 1 addition & 0 deletions code/game/jobs/job/civilians/support/synthetic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
flags_startup_parameters = ROLE_ADD_TO_DEFAULT|ROLE_ADMIN_NOTIFY|ROLE_WHITELISTED|ROLE_CUSTOM_SPAWN
flags_whitelist = WHITELIST_SYNTHETIC
gear_preset = /datum/equipment_preset/synth/uscm
loadout_points = 120
entry_message_body = "You are a <a href='"+WIKI_PLACEHOLDER+"'>Synthetic!</a> You are held to a higher standard and are required to obey not only the Server Rules but Marine Law and Synthetic Rules. Failure to do so may result in your White-list Removal. Your primary job is to support and assist all USCM Departments and Personnel on-board. In addition, being a Synthetic gives you knowledge in every field and specialization possible on-board the ship. As a Synthetic you answer to the acting commanding officer. Special circumstances may change this!"

/datum/job/civilian/synthetic/New()
Expand Down
3 changes: 3 additions & 0 deletions code/game/jobs/job/job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
/// Under what faction menu the job gets displayed in lobby
var/faction_menu = FACTION_NEUTRAL //neutral to cover uscm jobs for now as loads of them are under civil and stuff mainly ment for other faction

/// How many points people with this role selected get to pick from
var/loadout_points = 0

/datum/job/New()
. = ..()

Expand Down
4 changes: 2 additions & 2 deletions code/game/jobs/role_authority.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ GLOBAL_VAR_INIT(players_preassigned, 0)
/datum/authority/branch/role
var/name = "Role Authority"

var/list/roles_by_path //Master list generated when role aithority is created, listing every role by path, including variable roles. Great for manually equipping with.
var/list/roles_by_name //Master list generated when role authority is created, listing every default role by name, including those that may not be regularly selected.
var/list/datum/job/roles_by_path //Master list generated when role aithority is created, listing every role by path, including variable roles. Great for manually equipping with.
var/list/datum/job/roles_by_name //Master list generated when role authority is created, listing every default role by name, including those that may not be regularly selected.
var/list/roles_for_mode //Derived list of roles only for the game mode, generated when the round starts.
var/list/castes_by_path //Master list generated when role aithority is created, listing every caste by path.
var/list/castes_by_name //Master list generated when role authority is created, listing every default caste by name.
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/vending/vendor_types/crew/synthetic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ GLOBAL_LIST_INIT(cm_vending_clothing_synth, list(
/datum/gear/synthetic
category = "Synthetic"
allowed_roles = list(JOB_SYNTH, JOB_SHIP_SYNTH)
cost = 0
fluff_cost = 0

/datum/gear/synthetic/uscm
category = "Synthetic - USCM Uniforms"
Expand Down
100 changes: 72 additions & 28 deletions code/modules/client/loadout_picker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,44 @@

var/job = user.client?.prefs.get_high_priority_job()

.["categories"] = list()
.["fluff_categories"] = list()
.["loadout_categories"] = list()
for(var/category in GLOB.gear_datums_by_category)
var/list/datum/gear/gears = GLOB.gear_datums_by_category[category]

var/items = list()
var/fluff_items = list()
var/loadout_items = list()

for(var/gear_key as anything in gears)
var/datum/gear/gear = gears[gear_key]

if(length(gear.allowed_roles) && !(job in gear.allowed_roles))
continue

items += list(
list("name" = gear.display_name, "type" = gear.type, "cost" = gear.cost, "icon" = gear.path::icon, "icon_state" = gear.path::icon_state)
)
if(gear.loadout_cost)
loadout_items += list(
gear.get_list_representation()
)
continue

if(!length(items))
continue
if(gear.fluff_cost)
fluff_items += list(
gear.get_list_representation()
)

.["categories"] += list(
list("name" = category, "items" = items)
)
if(length(fluff_items))
.["fluff_categories"] += list(
list("name" = category, "items" = fluff_items)
)

if(length(loadout_items))
.["loadout_categories"] += list(
list("name" = category, "items" = loadout_items)
)

.["max_points"] = MAX_GEAR_COST
.["selected_job"] = job
.["max_job_points"] = GLOB.RoleAuthority.roles_by_name[job].loadout_points
.["max_fluff_points"] = MAX_GEAR_COST

/datum/loadout_picker/ui_data(mob/user)
. = ..()
Expand All @@ -35,19 +49,27 @@
if(!prefs)
return

var/points = 0

.["loadout"] = list()

.["fluff_gear"] = list()
var/fluff_points = 0
for(var/item in prefs.gear)
var/datum/gear/gear = GLOB.gear_datums_by_type[item]
points += gear.cost
fluff_points += gear.fluff_cost

.["loadout"] += list(
list("name" = gear.display_name, "type" = gear.type, "cost" = gear.cost, "icon" = gear.path::icon, "icon_state" = gear.path::icon_state)
.["fluff_gear"] += list(
gear.get_list_representation()
)
.["fluff_points"] = fluff_points

.["points"] = points
.["loadout"] = list()
var/loadout_points = 0
for(var/item in prefs.loadout)
var/datum/gear/gear = GLOB.gear_datums_by_type[item]
loadout_points += gear.loadout_cost

.["fluff_gear"] += list(
gear.get_list_representation()
)
.["loadout_points"] = loadout_points

/datum/loadout_picker/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
Expand All @@ -56,6 +78,8 @@
if(!prefs)
return

var/job = prefs.get_high_priority_job()

switch(action)
if("add")
var/picked_type = text2path(params["type"])
Expand All @@ -66,26 +90,46 @@
if(!istype(gear))
return

if(gear.fluff_cost)
var/total_cost = 0
for(var/gear_type in prefs.gear)
total_cost += GLOB.gear_datums_by_type[gear_type].fluff_cost

total_cost += gear.fluff_cost
if(total_cost > MAX_GEAR_COST)
return FALSE

prefs.gear += gear.type

return TRUE

var/total_cost = 0
for(var/gear_name in prefs.gear)
total_cost += GLOB.gear_datums_by_type[gear_name].cost
for(var/gear_type in prefs.loadout)
total_cost += GLOB.gear_datums_by_type[gear_type].loadout_cost

total_cost += gear.cost
if(total_cost > MAX_GEAR_COST)
return
total_cost += gear.loadout_cost
if(total_cost > GLOB.RoleAuthority.roles_by_name[job].loadout_points)
return FALSE

prefs.gear += gear.type
prefs.loadout += gear.type
return TRUE

if("remove")
var/picked_type = text2path(params["type"])
if(!picked_type)
return
return FALSE

var/datum/gear/gear = GLOB.gear_datums_by_type[picked_type]
if(!istype(gear))
return
return FALSE

if(gear.fluff_cost)
prefs.gear -= gear.type

if(gear.loadout_cost)
prefs.loadout -= gear.type

prefs.gear -= gear.type
return TRUE

prefs.ShowChoices(ui.user)
return TRUE
Expand Down
14 changes: 11 additions & 3 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ GLOBAL_LIST_INIT(bgstate_options, list(
var/body_size = "Average" // Body Size
var/body_type = "Lean" // Body Type
var/language = "None" //Secondary language
var/list/gear //Custom/fluff item loadout.
var/preferred_squad = "None"

//Some faction information.
Expand Down Expand Up @@ -272,6 +271,13 @@ GLOBAL_LIST_INIT(bgstate_options, list(
/// If this client has auto observe enabled, used by /datum/orbit_menu
var/auto_observe = TRUE

/// Fluff items that the user is equipped with on spawn.
var/list/gear

/// Loadout items that the user is equipped with on spawn.
var/list/loadout


/datum/preferences/New(client/C)
key_bindings = deep_copy_list(GLOB.hotkey_keybinding_list_by_key) // give them default keybinds and update their movement keys
macros = new(C, src)
Expand Down Expand Up @@ -427,8 +433,10 @@ GLOBAL_LIST_INIT(bgstate_options, list(
for(var/i = 1; i <= length(gear); i++)
var/datum/gear/G = GLOB.gear_datums_by_type[gear[i]]
if(G)
total_cost += G.cost
dat += "[G.display_name] ([G.cost] points)<br>"
total_cost += G.fluff_cost
var/fluff_cost = G.fluff_cost ? " ([G.fluff_cost] fluff point\s)" : ""
var/loadout_cost = G.loadout_cost ? " ([G.loadout_cost]) loadout point\s" : ""
dat += "[G.display_name][fluff_cost][loadout_cost]<br>"

dat += "<b>Used:</b> [total_cost] points"
else
Expand Down
Loading

0 comments on commit 64946dd

Please sign in to comment.