diff --git a/code/datums/medal_awards.dm b/code/datums/medal_awards.dm index 54af48fd3345..78fec7569582 100644 --- a/code/datums/medal_awards.dm +++ b/code/datums/medal_awards.dm @@ -35,6 +35,7 @@ GLOBAL_LIST_EMPTY(jelly_awards) giver_mob = list() giver_ckey = list() +GLOBAL_LIST_INIT(human_medals, list(MARINE_CONDUCT_MEDAL, MARINE_BRONZE_HEART_MEDAL, MARINE_VALOR_MEDAL, MARINE_HEROISM_MEDAL)) /proc/give_medal_award(medal_location, as_admin = FALSE) if(as_admin && !check_rights(R_ADMIN)) @@ -52,7 +53,7 @@ GLOBAL_LIST_EMPTY(jelly_awards) return FALSE // Pick a medal - var/medal_type = tgui_input_list(usr, "What type of medal do you want to award?", "Medal Type", list(MARINE_CONDUCT_MEDAL, MARINE_BRONZE_HEART_MEDAL, MARINE_VALOR_MEDAL, MARINE_HEROISM_MEDAL)) + var/medal_type = tgui_input_list(usr, "What type of medal do you want to award?", "Medal Type", GLOB.human_medals) if(!medal_type) return FALSE @@ -182,6 +183,8 @@ GLOBAL_LIST_EMPTY(jelly_awards) if(give_medal_award(get_turf(printer))) user.visible_message(SPAN_NOTICE("[printer] prints a medal.")) +GLOBAL_LIST_INIT(xeno_medals, list(XENO_SLAUGHTER_MEDAL, XENO_RESILIENCE_MEDAL, XENO_SABOTAGE_MEDAL, XENO_PROLIFERATION_MEDAL, XENO_REJUVENATION_MEDAL)) + /proc/give_jelly_award(datum/hive_status/hive, as_admin = FALSE) if(!hive) return FALSE @@ -220,7 +223,7 @@ GLOBAL_LIST_EMPTY(jelly_awards) return FALSE // Pick a jelly - var/medal_type = tgui_input_list(usr, "What type of jelly do you want to award?", "Jelly Type", list(XENO_SLAUGHTER_MEDAL, XENO_RESILIENCE_MEDAL, XENO_SABOTAGE_MEDAL, XENO_PROLIFERATION_MEDAL, XENO_REJUVENATION_MEDAL), theme="hive_status") + var/medal_type = tgui_input_list(usr, "What type of jelly do you want to award?", "Jelly Type", GLOB.xeno_medals, theme="hive_status") if(!medal_type) return FALSE diff --git a/code/game/verbs/records.dm b/code/game/verbs/records.dm index db420a45bc76..6b80d19bbabf 100644 --- a/code/game/verbs/records.dm +++ b/code/game/verbs/records.dm @@ -181,3 +181,47 @@ dat += "" show_browser(src, dat, "[target]'s [category_text] Notes", "otherplayersinfo", "size=480x480") + +GLOBAL_DATUM_INIT(medals_view_tgui, /datum/medals_view_tgui, new) + +/datum/medals_view_tgui/tgui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "MedalsViewer", "[user.ckey]'s Medals") + ui.open() + +/datum/medals_view_tgui/ui_static_data(mob/user) + . = ..() + .["medals"] = list() + + for(var/datum/view_record/medal_view/medal as anything in DB_VIEW(/datum/view_record/medal_view, DB_COMP("player_id", DB_EQUALS, user.client.player_data.id))) + var/xeno_medal = FALSE + if(medal.medal_type in GLOB.xeno_medals) + xeno_medal = TRUE + + var/list/current_medal = list( + "round_id" = medal.round_id, + "medal_type" = medal.medal_type, + "medal_icon" = replacetext(medal.medal_type, " ", "-"), + "xeno_medal" = xeno_medal, + "recipient_name" = medal.recipient_name, + "recipient_role" = medal.recipient_role, + "giver_name" = medal.giver_name, + "citation" = medal.citation + ) + + .["medals"] += list(current_medal) + +/datum/medals_view_tgui/ui_state(mob/user) + return GLOB.always_state + +/datum/medals_view_tgui/ui_assets(mob/user) + return list( + get_asset_datum(/datum/asset/spritesheet/medal) + ) + +/client/verb/view_own_medals() + set name = "View Own Medals" + set category = "OOC.Records" + + GLOB.medals_view_tgui.tgui_interact(mob) diff --git a/code/modules/asset_cache/assets/medals.dm b/code/modules/asset_cache/assets/medals.dm new file mode 100644 index 000000000000..1d7214331e65 --- /dev/null +++ b/code/modules/asset_cache/assets/medals.dm @@ -0,0 +1,10 @@ +/datum/asset/spritesheet/medal + name = "medal" + +/datum/asset/spritesheet/medal/register() + for(var/obj/item/clothing/accessory/medal/medal as anything in subtypesof(/obj/item/clothing/accessory/medal)) + var/icon/current_icon = icon(initial(medal.icon), initial(medal.icon_state), SOUTH) + var/imgid = replacetext("[initial(medal.name)]", " ", "-") + + Insert(imgid, current_icon) + return ..() diff --git a/colonialmarines.dme b/colonialmarines.dme index a2c032428adf..b24f5afe14c4 100644 --- a/colonialmarines.dme +++ b/colonialmarines.dme @@ -1458,6 +1458,7 @@ #include "code\modules\asset_cache\asset_list.dm" #include "code\modules\asset_cache\asset_list_items.dm" #include "code\modules\asset_cache\assets\fontawesome.dm" +#include "code\modules\asset_cache\assets\medals.dm" #include "code\modules\asset_cache\assets\tgfont.dm" #include "code\modules\asset_cache\assets\tgui.dm" #include "code\modules\asset_cache\assets\vending.dm" diff --git a/tgui/packages/tgui/interfaces/MedalsViewer.tsx b/tgui/packages/tgui/interfaces/MedalsViewer.tsx new file mode 100644 index 000000000000..591a0b4b233f --- /dev/null +++ b/tgui/packages/tgui/interfaces/MedalsViewer.tsx @@ -0,0 +1,61 @@ +import { BooleanLike, classes } from 'common/react'; +import { useBackend } from '../backend'; +import { Section } from '../components'; +import { Window } from '../layouts'; + +interface MedalProps { + medals: Medal[]; +} + +interface Medal { + round_id: string; + medal_type?: string; + medal_icon?: string; + xeno_medal?: BooleanLike; + recipient_name?: string; + recipient_role?: string; + giver_name?: string; + citation?: string; +} + +export const MedalsViewer = (props, context) => { + const { data, act } = useBackend(context); + const { medals } = data; + + return ( + + + {medals.map((medal) => { + const medalType = medal.medal_type + ? medal.medal_type + : 'Unknown Medal'; + const sectionTitle = `Round ${medal.round_id} - ${medalType}`; + const sectionType = medal.xeno_medal ? 'xeno-medal' : 'human-medal'; + return ( +
+ Issued to{' '} + + {medal.recipient_name}{' '} + {!medal.xeno_medal && `(${medal.recipient_role})`} + {' '} + by {medal.giver_name} for:
+ {!medal.xeno_medal && ( + + )} + {medal.citation} +
+ ); + })} +
+
+ ); +}; diff --git a/tgui/packages/tgui/styles/interfaces/MedalsViewer.scss b/tgui/packages/tgui/styles/interfaces/MedalsViewer.scss new file mode 100644 index 000000000000..e3630a34e063 --- /dev/null +++ b/tgui/packages/tgui/styles/interfaces/MedalsViewer.scss @@ -0,0 +1,13 @@ +.MedalsViewer { + .medal-icon { + vertical-align: -50%; + } + + .xeno-medal { + background-color: #52375c; + + .Section__title { + border-bottom: 0.1666666667em solid #6b3f7a; + } + } +} diff --git a/tgui/packages/tgui/styles/main.scss b/tgui/packages/tgui/styles/main.scss index 1614d2129f35..bf1e77eb9f9a 100644 --- a/tgui/packages/tgui/styles/main.scss +++ b/tgui/packages/tgui/styles/main.scss @@ -54,6 +54,7 @@ @include meta.load-css('./interfaces/ElevatorControl.scss'); @include meta.load-css('./interfaces/ExperimentConfigure.scss'); @include meta.load-css('./interfaces/MarkMenu.scss'); +@include meta.load-css('./interfaces/MedalsViewer.scss'); @include meta.load-css('./interfaces/NavigationShuttle.scss'); @include meta.load-css('./interfaces/NuclearBomb.scss'); @include meta.load-css('./interfaces/Paper.scss');