Skip to content

Commit

Permalink
Merge pull request #4700 from MistakeNot4892/feature/standardjobs
Browse files Browse the repository at this point in the history
Reworking HUD icons to support modpacked jobs and roles.
  • Loading branch information
out-of-phaze authored Jan 15, 2025
2 parents 10a6662 + c26f8c6 commit ebafbc6
Show file tree
Hide file tree
Showing 64 changed files with 352 additions and 278 deletions.
12 changes: 12 additions & 0 deletions code/game/antagonist/antagonist.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// Visual references.
var/antaghud_indicator = "hudsyndicate" // Used by the ghost antagHUD.
var/antag_indicator // icon_state for icons/mob/mob.dm visual indicator.
var/antag_hud_icon = 'icons/screen/hud_antag.dmi'
var/faction_indicator // See antag_indicator, but for factionalized people only.
var/faction_invisible // Can members of the faction identify other antagonists?

Expand Down Expand Up @@ -104,6 +105,17 @@

/decl/special_role/validate()
. = ..()

// Check for our antaghud icons.
if(faction_indicator || antag_indicator)
if(antag_hud_icon)
if(faction_indicator && !check_state_in_icon(faction_indicator, antag_hud_icon))
. += "missing faction_indicator '[faction_indicator]' from icon 'antag_hud_icon]'"
if(antag_indicator && !check_state_in_icon(antag_indicator, antag_hud_icon))
. += "missing antag_indicator '[antag_indicator]' from icon 'antag_hud_icon]'"
else
. += "missing antag_hud_icon"

// Grab initial in case it was already successfully loaded.
var/initial_base_to_load = initial(base_to_load)
if(isnull(initial_base_to_load))
Expand Down
6 changes: 4 additions & 2 deletions code/game/antagonist/antagonist_update.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
qdel(I)

/decl/special_role/proc/get_indicator(var/datum/mind/recipient, var/datum/mind/other)
if(!antag_indicator || !other.current || !recipient.current)
if(!other.current || !recipient.current)
return
var/indicator = (faction_indicator && (other in faction_members)) ? faction_indicator : antag_indicator
var/image/I = image('icons/mob/hud.dmi', loc = other.current, icon_state = indicator, layer = ABOVE_HUMAN_LAYER)
if(!indicator)
return
var/image/I = image(antag_hud_icon, loc = other.current, icon_state = indicator, layer = ABOVE_HUMAN_LAYER)
var/decl/bodytype/root_bodytype = other.current.get_bodytype()
if(istype(root_bodytype))
I.pixel_x = root_bodytype.antaghud_offset_x
Expand Down
9 changes: 6 additions & 3 deletions code/game/jobs/job/_job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
var/announced = TRUE // If their arrival is announced on radio
var/latejoin_at_spawnpoints // If this job should use roundstart spawnpoints for latejoin (offstation jobs etc)
var/forced_spawnpoint // If set to a spawnpoint name, will use that spawn point for joining as this job.
var/hud_icon // icon used for Sec HUD overlay
var/hud_icon // icon used for secHUD overlay
var/hud_icon_state // icon state used for secHUD overlay

// A list of string IDs for keys to grant on join.
var/list/lock_keys = list()
Expand Down Expand Up @@ -69,7 +70,7 @@

if(type == /datum/job && global.using_map.default_job_type == type)
title = "Debug Job"
hud_icon = "hudblank"
hud_icon_state = "hudblank"
outfit_type = /decl/outfit/job/generic/scientist
autoset_department = TRUE

Expand All @@ -83,7 +84,9 @@
spawn_positions = 0

if(!hud_icon)
hud_icon = "hud[ckey(title)]"
hud_icon = global.using_map.hud_icons
if(!hud_icon_state)
hud_icon_state = "hud[ckey(title)]"

..()

Expand Down
16 changes: 1 addition & 15 deletions code/modules/mob/living/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
icon_state = "body_m_s"
mob_sort_value = 6
max_health = 150

var/list/hud_list[10]
var/embedded_flag //To check if we've need to roll for damage on movement while an item is imbedded in us.

/mob/living/human/Initialize(mapload, species_name, datum/mob_snapshot/supplied_appearance)

current_health = max_health
setup_hud_overlays()
reset_hud_overlays()
var/list/newargs = args.Copy(2)
setup_human(arglist(newargs))
global.human_mob_list |= src
Expand All @@ -32,18 +30,6 @@
if(. != INITIALIZE_HINT_QDEL)
post_setup(arglist(newargs))

/mob/living/human/proc/setup_hud_overlays()
hud_list[HEALTH_HUD] = new /image/hud_overlay('icons/mob/hud_med.dmi', src, "100")
hud_list[STATUS_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudhealthy")
hud_list[LIFE_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudhealthy")
hud_list[ID_HUD] = new /image/hud_overlay(global.using_map.id_hud_icons, src, "hudunknown")
hud_list[WANTED_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[IMPLOYAL_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[IMPCHEM_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[IMPTRACK_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[SPECIALROLE_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[STATUS_HUD_OOC] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudhealthy")

/mob/living/human/Destroy()
global.human_mob_list -= src
regenerate_body_icon = FALSE // don't bother regenerating if we happen to be queued to update icon
Expand Down
14 changes: 7 additions & 7 deletions code/modules/mob/living/human/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,8 @@
if(I)
var/datum/job/J = SSjobs.get_by_title(I.GetJobName())
if(J)
holder.icon_state = J.hud_icon
holder.icon = J.hud_icon
holder.icon_state = J.hud_icon_state

hud_list[ID_HUD] = holder

Expand Down Expand Up @@ -781,17 +782,16 @@
var/image/holder2 = hud_list[IMPLOYAL_HUD]
var/image/holder3 = hud_list[IMPCHEM_HUD]

holder1.icon_state = "hudblank"
holder2.icon_state = "hudblank"
holder3.icon_state = "hudblank"

holder1.icon_state = "hud_imp_blank"
holder2.icon_state = "hud_imp_blank"
holder3.icon_state = "hud_imp_blank"
for(var/obj/item/implant/I in src)
if(I.implanted)
if(istype(I,/obj/item/implant/tracking))
holder1.icon_state = "hud_imp_tracking"
if(istype(I,/obj/item/implant/loyalty))
else if(istype(I,/obj/item/implant/loyalty))
holder2.icon_state = "hud_imp_loyal"
if(istype(I,/obj/item/implant/chem))
else if(istype(I,/obj/item/implant/chem))
holder3.icon_state = "hud_imp_chem"

hud_list[IMPTRACK_HUD] = holder1
Expand Down
17 changes: 17 additions & 0 deletions code/modules/mob/living/living_hud.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/mob/living
var/list/hud_list = new(10)

/mob/living/proc/reset_hud_overlays()
hud_list = new(10)
hud_list[HEALTH_HUD] = new /image/hud_overlay(global.using_map.med_hud_icons, src, "blank")
hud_list[STATUS_HUD] = new /image/hud_overlay(global.using_map.hud_icons, src, "hudhealthy")
hud_list[LIFE_HUD] = new /image/hud_overlay(global.using_map.hud_icons, src, "hudhealthy")
hud_list[ID_HUD] = new /image/hud_overlay(global.using_map.hud_icons, src, "hudunknown")
hud_list[WANTED_HUD] = new /image/hud_overlay(global.using_map.hud_icons, src, "hudblank")
hud_list[IMPLOYAL_HUD] = new /image/hud_overlay(global.using_map.implant_hud_icons, src, "hud_imp_blank")
hud_list[IMPCHEM_HUD] = new /image/hud_overlay(global.using_map.implant_hud_icons, src, "hud_imp_blank")
hud_list[IMPTRACK_HUD] = new /image/hud_overlay(global.using_map.implant_hud_icons, src, "hud_imp_blank")
hud_list[SPECIALROLE_HUD] = new /image/hud_overlay(global.using_map.hud_icons, src, "hudblank")
hud_list[STATUS_HUD_OOC] = new /image/hud_overlay(global.using_map.hud_icons, src, "hudhealthy")

/datum/map
10 changes: 1 addition & 9 deletions code/modules/mob/living/silicon/ai/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,7 @@ var/global/list/ai_verbs_default = list(
. = INITIALIZE_HINT_QDEL
else if(brainmob.mind)
brainmob.mind.transfer_to(src)
hud_list[HEALTH_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[STATUS_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[LIFE_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[ID_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[WANTED_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[IMPLOYAL_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[IMPCHEM_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[IMPTRACK_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[SPECIALROLE_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
reset_hud_overlays()
ai_list += src

create_powersupply()
Expand Down
13 changes: 3 additions & 10 deletions code/modules/mob/living/silicon/robot/robot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
)

/mob/living/silicon/robot/Initialize()

reset_hud_overlays()

. = ..()

add_language(/decl/language/binary, 1)
Expand Down Expand Up @@ -126,16 +129,6 @@
// Disables lay down verb for robots due they're can't lay down and it cause some movement, vision issues.
verbs -= /mob/living/verb/lay_down

hud_list[HEALTH_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[STATUS_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudhealth100")
hud_list[LIFE_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudhealth100")
hud_list[ID_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[WANTED_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[IMPLOYAL_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[IMPCHEM_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[IMPTRACK_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")
hud_list[SPECIALROLE_HUD] = new /image/hud_overlay('icons/mob/hud.dmi', src, "hudblank")

AddMovementHandler(/datum/movement_handler/robot/use_power, /datum/movement_handler/mob/space)

/mob/living/silicon/robot/proc/recalculate_synth_capacities()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/silicon/silicon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
var/list/stating_laws = list()// Channels laws are currently being stated on
var/obj/item/radio/silicon_radio

var/list/hud_list[10]
var/list/speech_synthesizer_langs = list() //which languages can be vocalized by the speech synthesizer

//Used in say.dm.
Expand Down Expand Up @@ -40,6 +39,7 @@
#define MED_HUD 2 //Medical HUD mode

/mob/living/silicon/Initialize()
reset_hud_overlays()
global.silicon_mob_list += src
. = ..()

Expand Down
10 changes: 8 additions & 2 deletions code/modules/submaps/submap_job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
create_record = FALSE
total_positions = 4
outfit_type = /decl/outfit/job/survivor
hud_icon = "hudblank"
hud_icon_state = "hudblank"
hud_icon = null
available_by_default = FALSE
allowed_ranks = null
allowed_branches = null
Expand Down Expand Up @@ -55,7 +56,12 @@
if(islist(blacklisted_species) && !length(blacklisted_species))
blacklisted_species |= SSmodpacks.default_submap_blacklisted_species

if(!abstract_job)
if(abstract_job)
if(!hud_icon)
hud_icon = global.using_map.hud_icons
if(!hud_icon_state)
hud_icon_state = "hud[ckey(title)]"
else
spawnpoints = list()
owner = _owner
..()
Expand Down
61 changes: 61 additions & 0 deletions code/unit_tests/icon_tests.dm
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,64 @@
else
pass("All vendors have all icons and icon states.")
return 1


/datum/unit_test/HUDS_shall_have_icon_states
name = "ICON STATE: HUD overlays shall have appropriate icon_states"

/datum/unit_test/HUDS_shall_have_icon_states/start_test()
var/failed_jobs = 0
var/failed_sanity_checks = 0

// Throwing implants and health HUDs in here.
// Antag HUDs are tested by special role validation.

var/static/list/implant_hud_states = list(
"hud_imp_blank" = "Blank",
"hud_imp_loyal" = "Loyalty",
"hud_imp_unknown" = "Unknown",
"hud_imp_tracking" = "Tracking",
"hud_imp_chem" = "Chemical",
)
for(var/implant_hud_state in implant_hud_states)
if(!check_state_in_icon(implant_hud_state, global.using_map.implant_hud_icons))
log_bad("Sanity Check - Missing map [implant_hud_states[implant_hud_state]] implant HUD icon_state '[implant_hud_state]' from icon [global.using_map.implant_hud_icons]")
failed_sanity_checks++

var/static/list/med_hud_states = list(
"blank" = "Blank",
"flatline" = "Flatline",
"0" = "Dead",
"1" = "Healthy",
"2" = "Lightly injured",
"3" = "Moderately injured",
"4" = "Severely injured",
"5" = "Dying",
)
for(var/med_hud_state in med_hud_states)
if(!check_state_in_icon(med_hud_state, global.using_map.med_hud_icons))
log_bad("Sanity Check - Missing map [med_hud_states[med_hud_state]] medical HUD icon_state '[med_hud_state]' from icon [global.using_map.med_hud_icons]")
failed_sanity_checks++
var/static/list/global_states = list(
"" = "Default/unnamed",
"hudunknown" = "Unknown role",
"hudhealthy" = "Healthy mob",
"hudill" = "Diseased mob",
"huddead" = "Dead mob"
)
for(var/global_state in global_states)
if(!check_state_in_icon(global_state, global.using_map.hud_icons))
log_bad("Sanity Check - Missing map [global_states[global_state]] HUD icon_state '[global_state]' from icon [global.using_map.hud_icons]")
failed_sanity_checks++

for(var/job_name in SSjobs.titles_to_datums)
var/datum/job/job = SSjobs.titles_to_datums[job_name]
if(!check_state_in_icon(job.hud_icon_state, job.hud_icon))
log_bad("[job.title] - Missing HUD icon: [job.hud_icon_state] in icon [job.hud_icon]")
failed_jobs++

if(failed_sanity_checks || failed_jobs)
fail("[global.using_map.type] - [failed_sanity_checks] failed sanity check\s, [failed_jobs] job\s with missing HUD icon.")
else
pass("All jobs have a HUD icon.")
return 1
30 changes: 0 additions & 30 deletions code/unit_tests/job_tests.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,6 @@
pass("All jobs had outfit types.")
return 1

/datum/unit_test/jobs_shall_have_a_HUD_icon
name = "JOB: Shall have a HUD icon"

/datum/unit_test/jobs_shall_have_a_HUD_icon/start_test()
var/failed_jobs = 0
var/failed_sanity_checks = 0

var/list/job_huds = get_states_in_icon_cached(global.using_map.id_hud_icons)

if(!job_huds[""])
log_bad("Sanity Check - Missing default/unnamed HUD icon")
failed_sanity_checks++

if(!job_huds["hudunknown"])
log_bad("Sanity Check - Missing HUD icon: hudunknown")
failed_sanity_checks++

for(var/job_name in SSjobs.titles_to_datums)
var/datum/job/J = SSjobs.titles_to_datums[job_name]
var/hud_icon_state = J.hud_icon
if(!job_huds[hud_icon_state])
log_bad("[J.title] - Missing HUD icon: [hud_icon_state]")
failed_jobs++

if(failed_sanity_checks || failed_jobs)
fail("[global.using_map.id_hud_icons] - [failed_sanity_checks] failed sanity check\s, [failed_jobs] job\s with missing HUD icon.")
else
pass("All jobs have a HUD icon.")
return 1

/datum/unit_test/jobs_shall_have_a_unique_title
name = "JOBS: All Job Datums Shall Have A Unique Title"

Expand Down
Binary file removed icons/mob/hud.dmi
Binary file not shown.
Binary file removed icons/mob/hud_med.dmi
Binary file not shown.
Binary file added icons/screen/hud.dmi
Binary file not shown.
Binary file added icons/screen/hud_antag.dmi
Binary file not shown.
Binary file added icons/screen/hud_implants.dmi
Binary file not shown.
Binary file added icons/screen/hud_med.dmi
Binary file not shown.
Binary file added maps/away/liberia/hud.dmi
Binary file not shown.
3 changes: 2 additions & 1 deletion maps/away/liberia/liberia_jobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
info = "You are free traders who have drifted into unknown distances in search of profit. Travel, trade, make profit!"
supervisors = "the invisible hand of the market"
selection_color = "#515151"

hud_icon = 'maps/away/liberia/hud.dmi'
hud_icon_state = "hudmerchant"
ideal_character_age = 20
minimal_player_age = 7

Expand Down
4 changes: 2 additions & 2 deletions maps/example/example_jobs.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/datum/map/example
default_job_type = /datum/job/example
default_department_type = /decl/department/example
id_hud_icons = 'maps/example/hud.dmi'

/datum/job/example
title = "Tourist"
Expand All @@ -13,9 +12,10 @@
access = list()
minimal_access = list()
outfit_type = /decl/outfit/job/tourist
hud_icon = 'maps/example/hud.dmi'
department_types = list(
/decl/department/example
)
)

/decl/outfit/job/tourist
name = "Job - Testing Site Tourist"
Binary file modified maps/example/hud.dmi
Binary file not shown.
8 changes: 4 additions & 4 deletions maps/exodus/exodus_antagonism.dm
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/decl/special_role/traitor/Initialize()
. = ..()
LAZYINITLIST(protected_jobs)
protected_jobs |= list(/datum/job/officer, /datum/job/warden, /datum/job/detective, /datum/job/captain, /datum/job/lawyer, /datum/job/hos)
protected_jobs |= list(/datum/job/standard/officer, /datum/job/standard/warden, /datum/job/standard/detective, /datum/job/standard/captain, /datum/job/standard/lawyer, /datum/job/standard/hos)

/decl/special_role/cultist/Initialize()
. = ..()
LAZYINITLIST(restricted_jobs)
restricted_jobs |= list(/datum/job/lawyer, /datum/job/captain, /datum/job/hos)
restricted_jobs |= list(/datum/job/standard/lawyer, /datum/job/standard/captain, /datum/job/standard/hos)
LAZYINITLIST(protected_jobs)
protected_jobs |= list(/datum/job/officer, /datum/job/warden, /datum/job/detective)
protected_jobs |= list(/datum/job/standard/officer, /datum/job/standard/warden, /datum/job/standard/detective)
LAZYINITLIST(blacklisted_jobs)
blacklisted_jobs |= list(/datum/job/chaplain, /datum/job/counselor)
blacklisted_jobs |= list(/datum/job/standard/chaplain, /datum/job/standard/counselor)

/decl/special_role/loyalist
command_department_id = /decl/department/command
Expand Down
Loading

0 comments on commit ebafbc6

Please sign in to comment.