Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds a medal viewer #5157

Merged
merged 10 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions code/datums/medal_awards.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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

Expand Down Expand Up @@ -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))
harryob marked this conversation as resolved.
Show resolved Hide resolved

/proc/give_jelly_award(datum/hive_status/hive, as_admin = FALSE)
if(!hive)
return FALSE
Expand Down Expand Up @@ -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

Expand Down
44 changes: 44 additions & 0 deletions code/game/verbs/records.dm
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,47 @@

dat += "</body></html>"
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)
10 changes: 10 additions & 0 deletions code/modules/asset_cache/assets/medals.dm
Original file line number Diff line number Diff line change
@@ -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 ..()
1 change: 1 addition & 0 deletions colonialmarines.dme
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
61 changes: 61 additions & 0 deletions tgui/packages/tgui/interfaces/MedalsViewer.tsx
Original file line number Diff line number Diff line change
@@ -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<MedalProps>(context);
const { medals } = data;

return (
<Window width={700} height={350}>
<Window.Content scrollable className={'MedalsViewer'}>
{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 (
<Section
key={medal.citation}
title={sectionTitle}
className={sectionType}>
Issued to{' '}
<b>
{medal.recipient_name}{' '}
{!medal.xeno_medal && medal.recipient_role}
</b>{' '}
by <b>{medal.giver_name}</b> for: <br />
{!medal.xeno_medal && (
<span
className={classes([
'medal32x32',
medal.medal_icon,
'medal-icon',
])}
/>
)}
{medal.citation}
</Section>
);
})}
</Window.Content>
</Window>
);
};
13 changes: 13 additions & 0 deletions tgui/packages/tgui/styles/interfaces/MedalsViewer.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.MedalsViewer {
.medal-icon {
vertical-align: -50%;
}

.xeno-medal {
background-color: #52375c;

.Section__title {
border-bottom: 0.1666666667em solid #6b3f7a;
}
}
}
1 change: 1 addition & 0 deletions tgui/packages/tgui/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down