From 8a462cfb793d0d99f5805abfe388543f4e18b17f Mon Sep 17 00:00:00 2001 From: harryob <55142896+harryob@users.noreply.github.com> Date: Thu, 7 Dec 2023 17:58:39 +0000 Subject: [PATCH 1/9] init --- code/game/verbs/records.dm | 31 ++++++++++++++ .../packages/tgui/interfaces/MedalsViewer.tsx | 40 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 tgui/packages/tgui/interfaces/MedalsViewer.tsx diff --git a/code/game/verbs/records.dm b/code/game/verbs/records.dm index db420a45bc76..c421b28fe581 100644 --- a/code/game/verbs/records.dm +++ b/code/game/verbs/records.dm @@ -181,3 +181,34 @@ 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] 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)) + .["medals"] += list( + "round_id" = medal.round_id, + "medal_type" = medal.medal_type, + "recipient_name" = medal.recipient_name, + "recipient_role" = medal.recipient_role, + "giver_name" = medal.giver_name, + "citation" = medal.citation + ) + +/datum/medals_view_tgui/ui_status(mob/user, datum/ui_state/state) + return GLOB.always_state + +/client/verb/view_own_medals() + set name = "View Own Medals" + set category = "OOC.Records" + + GLOB.medals_view_tgui.tgui_interact(src.mob) diff --git a/tgui/packages/tgui/interfaces/MedalsViewer.tsx b/tgui/packages/tgui/interfaces/MedalsViewer.tsx new file mode 100644 index 000000000000..6fd0914d0ffa --- /dev/null +++ b/tgui/packages/tgui/interfaces/MedalsViewer.tsx @@ -0,0 +1,40 @@ +import { useBackend } from '../backend'; +import { Flex } from '../components'; +import { Window } from '../layouts'; + +interface MedalProps { + medals: Medal[]; +} + +interface Medal { + round_id: string; + medal_type?: string; + 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) => { + return ( + + {medal.round_id}: {medal.medal_type} issued to{' '} + {medal.recipient_name} ({medal.recipient_role}) by{' '} + {medal.giver_name} for:
+ {medal.citation} +
+ ); + })} +
+
+
+ ); +}; From c68580f17d5d39197b12a287c09bd1763771acc3 Mon Sep 17 00:00:00 2001 From: harryob Date: Thu, 7 Dec 2023 18:50:10 +0000 Subject: [PATCH 2/9] adds a medal viewer --- code/game/verbs/records.dm | 14 ++++++- code/modules/asset_cache/assets/medals.dm | 10 +++++ colonialmarines.dme | 1 + .../packages/tgui/interfaces/MedalsViewer.tsx | 41 ++++++++++++------- .../tgui/styles/interfaces/MedalsViewer.scss | 3 ++ tgui/packages/tgui/styles/main.scss | 1 + 6 files changed, 54 insertions(+), 16 deletions(-) create mode 100644 code/modules/asset_cache/assets/medals.dm create mode 100644 tgui/packages/tgui/styles/interfaces/MedalsViewer.scss diff --git a/code/game/verbs/records.dm b/code/game/verbs/records.dm index c421b28fe581..1997e80eec1b 100644 --- a/code/game/verbs/records.dm +++ b/code/game/verbs/records.dm @@ -184,6 +184,8 @@ GLOBAL_DATUM_INIT(medals_view_tgui, /datum/medals_view_tgui, new) +GLOBAL_SUBTYPE_PATHS_LIST_INDEXED(all_medals, /obj/item/clothing/accessory/medal, name) + /datum/medals_view_tgui/tgui_interact(mob/user, datum/tgui/ui) ui = SStgui.try_update_ui(user, src, ui) if(!ui) @@ -195,18 +197,26 @@ GLOBAL_DATUM_INIT(medals_view_tgui, /datum/medals_view_tgui, new) .["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)) - .["medals"] += list( + var/list/current_medal = list( "round_id" = medal.round_id, "medal_type" = medal.medal_type, + "medal_icon" = replacetext(medal.medal_type, " ", "-"), "recipient_name" = medal.recipient_name, "recipient_role" = medal.recipient_role, "giver_name" = medal.giver_name, "citation" = medal.citation ) -/datum/medals_view_tgui/ui_status(mob/user, datum/ui_state/state) + .["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" 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 index 6fd0914d0ffa..cf84bcc77b79 100644 --- a/tgui/packages/tgui/interfaces/MedalsViewer.tsx +++ b/tgui/packages/tgui/interfaces/MedalsViewer.tsx @@ -1,5 +1,6 @@ +import { classes } from 'common/react'; import { useBackend } from '../backend'; -import { Flex } from '../components'; +import { Section } from '../components'; import { Window } from '../layouts'; interface MedalProps { @@ -9,6 +10,7 @@ interface MedalProps { interface Medal { round_id: string; medal_type?: string; + medal_icon?: string; recipient_name?: string; recipient_role?: string; giver_name?: string; @@ -20,20 +22,31 @@ export const MedalsViewer = (props, context) => { const { medals } = data; return ( - + - - {medals.map((medal) => { - return ( - - {medal.round_id}: {medal.medal_type} issued to{' '} - {medal.recipient_name} ({medal.recipient_role}) by{' '} - {medal.giver_name} for:
- {medal.citation} -
- ); - })} -
+ {medals.map((medal) => { + const medalType = medal.medal_type + ? medal.medal_type + : 'Unknown Medal'; + const sectionTitle = `Round ${medal.round_id} - ${medalType}`; + return ( +
+ Issued to{' '} + + {medal.recipient_name} ({medal.recipient_role}) + {' '} + by {medal.giver_name} for:
+ + {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..78a604ea6554 --- /dev/null +++ b/tgui/packages/tgui/styles/interfaces/MedalsViewer.scss @@ -0,0 +1,3 @@ +.medal-icon { + vertical-align: -50%; +} 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'); From 3586f610a08f8e956d0d4a1cda6b14c1d1ccbc3a Mon Sep 17 00:00:00 2001 From: harryob Date: Thu, 7 Dec 2023 19:26:27 +0000 Subject: [PATCH 3/9] distinguishes xeno medals a bit more --- code/datums/medal_awards.dm | 4 ++- code/game/verbs/records.dm | 7 +++++- .../packages/tgui/interfaces/MedalsViewer.tsx | 25 ++++++++++++------- .../tgui/styles/interfaces/MedalsViewer.scss | 8 ++++++ 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/code/datums/medal_awards.dm b/code/datums/medal_awards.dm index 54af48fd3345..19df1d054130 100644 --- a/code/datums/medal_awards.dm +++ b/code/datums/medal_awards.dm @@ -182,6 +182,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 +222,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 1997e80eec1b..29d78a71276d 100644 --- a/code/game/verbs/records.dm +++ b/code/game/verbs/records.dm @@ -189,7 +189,7 @@ GLOBAL_SUBTYPE_PATHS_LIST_INDEXED(all_medals, /obj/item/clothing/accessory/medal /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] Medals") + ui = new(user, src, "MedalsViewer", "[user.ckey]'s Medals") ui.open() /datum/medals_view_tgui/ui_static_data(mob/user) @@ -197,10 +197,15 @@ GLOBAL_SUBTYPE_PATHS_LIST_INDEXED(all_medals, /obj/item/clothing/accessory/medal .["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, diff --git a/tgui/packages/tgui/interfaces/MedalsViewer.tsx b/tgui/packages/tgui/interfaces/MedalsViewer.tsx index cf84bcc77b79..5d1488ab4d72 100644 --- a/tgui/packages/tgui/interfaces/MedalsViewer.tsx +++ b/tgui/packages/tgui/interfaces/MedalsViewer.tsx @@ -1,4 +1,4 @@ -import { classes } from 'common/react'; +import { BooleanLike, classes } from 'common/react'; import { useBackend } from '../backend'; import { Section } from '../components'; import { Window } from '../layouts'; @@ -11,6 +11,7 @@ interface Medal { round_id: string; medal_type?: string; medal_icon?: string; + xeno_medal?: BooleanLike; recipient_name?: string; recipient_role?: string; giver_name?: string; @@ -29,20 +30,26 @@ export const MedalsViewer = (props, context) => { ? 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.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 index 78a604ea6554..36e2f8d5aae0 100644 --- a/tgui/packages/tgui/styles/interfaces/MedalsViewer.scss +++ b/tgui/packages/tgui/styles/interfaces/MedalsViewer.scss @@ -1,3 +1,11 @@ .medal-icon { vertical-align: -50%; } + +.xeno-medal { + background-color: #52375c; + + .Section__title { + border-bottom: 0.1666666667em solid #6b3f7a; + } +} From 6c9862fa124a9bca7de08b2c2818e02c3bd39cde Mon Sep 17 00:00:00 2001 From: harryob Date: Thu, 7 Dec 2023 19:37:06 +0000 Subject: [PATCH 4/9] namespaces .scss correctly --- tgui/packages/tgui/interfaces/MedalsViewer.tsx | 2 +- .../tgui/styles/interfaces/MedalsViewer.scss | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tgui/packages/tgui/interfaces/MedalsViewer.tsx b/tgui/packages/tgui/interfaces/MedalsViewer.tsx index 5d1488ab4d72..5ef513b37865 100644 --- a/tgui/packages/tgui/interfaces/MedalsViewer.tsx +++ b/tgui/packages/tgui/interfaces/MedalsViewer.tsx @@ -24,7 +24,7 @@ export const MedalsViewer = (props, context) => { return ( - + {medals.map((medal) => { const medalType = medal.medal_type ? medal.medal_type diff --git a/tgui/packages/tgui/styles/interfaces/MedalsViewer.scss b/tgui/packages/tgui/styles/interfaces/MedalsViewer.scss index 36e2f8d5aae0..e3630a34e063 100644 --- a/tgui/packages/tgui/styles/interfaces/MedalsViewer.scss +++ b/tgui/packages/tgui/styles/interfaces/MedalsViewer.scss @@ -1,11 +1,13 @@ -.medal-icon { - vertical-align: -50%; -} +.MedalsViewer { + .medal-icon { + vertical-align: -50%; + } -.xeno-medal { - background-color: #52375c; + .xeno-medal { + background-color: #52375c; - .Section__title { - border-bottom: 0.1666666667em solid #6b3f7a; + .Section__title { + border-bottom: 0.1666666667em solid #6b3f7a; + } } } From b2174fd36ad200f438b4157791a3d66f5d54494b Mon Sep 17 00:00:00 2001 From: harryob <55142896+harryob@users.noreply.github.com> Date: Thu, 7 Dec 2023 20:11:37 +0000 Subject: [PATCH 5/9] removes redundant line --- code/game/verbs/records.dm | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/game/verbs/records.dm b/code/game/verbs/records.dm index 29d78a71276d..01daa5fdcc49 100644 --- a/code/game/verbs/records.dm +++ b/code/game/verbs/records.dm @@ -184,8 +184,6 @@ GLOBAL_DATUM_INIT(medals_view_tgui, /datum/medals_view_tgui, new) -GLOBAL_SUBTYPE_PATHS_LIST_INDEXED(all_medals, /obj/item/clothing/accessory/medal, name) - /datum/medals_view_tgui/tgui_interact(mob/user, datum/tgui/ui) ui = SStgui.try_update_ui(user, src, ui) if(!ui) From 53339d9c470d0de5b1058e61378ec78290863be1 Mon Sep 17 00:00:00 2001 From: harryob <55142896+harryob@users.noreply.github.com> Date: Thu, 7 Dec 2023 20:27:41 +0000 Subject: [PATCH 6/9] implicit src --- code/game/verbs/records.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/verbs/records.dm b/code/game/verbs/records.dm index 01daa5fdcc49..e58dff8b4bbf 100644 --- a/code/game/verbs/records.dm +++ b/code/game/verbs/records.dm @@ -224,4 +224,4 @@ GLOBAL_DATUM_INIT(medals_view_tgui, /datum/medals_view_tgui, new) set name = "View Own Medals" set category = "OOC.Records" - GLOB.medals_view_tgui.tgui_interact(src.mob) + GLOB.medals_view_tgui.tgui_interact(mob) From bbe206857f4515b0326e72e53f07503fdd8da018 Mon Sep 17 00:00:00 2001 From: harryob Date: Fri, 8 Dec 2023 08:19:36 +0000 Subject: [PATCH 7/9] Update code/game/verbs/records.dm Co-authored-by: Drathek <76988376+Drulikar@users.noreply.github.com> --- code/game/verbs/records.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/verbs/records.dm b/code/game/verbs/records.dm index e58dff8b4bbf..6b80d19bbabf 100644 --- a/code/game/verbs/records.dm +++ b/code/game/verbs/records.dm @@ -194,7 +194,7 @@ GLOBAL_DATUM_INIT(medals_view_tgui, /datum/medals_view_tgui, new) . = ..() .["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)) + 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 From ef6c5f801724a952b5e40e7f3c490117dd3634b0 Mon Sep 17 00:00:00 2001 From: harryob <55142896+harryob@users.noreply.github.com> Date: Fri, 8 Dec 2023 08:46:51 +0000 Subject: [PATCH 8/9] drathekview --- code/datums/medal_awards.dm | 3 ++- tgui/packages/tgui/interfaces/MedalsViewer.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/code/datums/medal_awards.dm b/code/datums/medal_awards.dm index 19df1d054130..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 diff --git a/tgui/packages/tgui/interfaces/MedalsViewer.tsx b/tgui/packages/tgui/interfaces/MedalsViewer.tsx index 5ef513b37865..5c96453352d0 100644 --- a/tgui/packages/tgui/interfaces/MedalsViewer.tsx +++ b/tgui/packages/tgui/interfaces/MedalsViewer.tsx @@ -38,7 +38,8 @@ export const MedalsViewer = (props, context) => { className={sectionType}> Issued to{' '} - {medal.recipient_name} ({medal.recipient_role}) + {medal.recipient_name}{' '} + {!medal.xeno_medal && medal.recipient_role} {' '} by {medal.giver_name} for:
{!medal.xeno_medal && ( From c7e273713a7a0851de270994c1cf3cb87a8220ea Mon Sep 17 00:00:00 2001 From: harryob <55142896+harryob@users.noreply.github.com> Date: Fri, 8 Dec 2023 18:31:43 +0000 Subject: [PATCH 9/9] i forgot the parenthesis --- tgui/packages/tgui/interfaces/MedalsViewer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgui/packages/tgui/interfaces/MedalsViewer.tsx b/tgui/packages/tgui/interfaces/MedalsViewer.tsx index 5c96453352d0..591a0b4b233f 100644 --- a/tgui/packages/tgui/interfaces/MedalsViewer.tsx +++ b/tgui/packages/tgui/interfaces/MedalsViewer.tsx @@ -39,7 +39,7 @@ export const MedalsViewer = (props, context) => { Issued to{' '} {medal.recipient_name}{' '} - {!medal.xeno_medal && medal.recipient_role} + {!medal.xeno_medal && `(${medal.recipient_role})`} {' '} by {medal.giver_name} for:
{!medal.xeno_medal && (