From 09dd38bb2d80cee7e488f2aca58e6333025d27af Mon Sep 17 00:00:00 2001 From: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com> Date: Fri, 8 Oct 2021 18:18:10 -0400 Subject: [PATCH] =?UTF-8?q?[MODULAR]=C2=A0Prefs=20Menu=20Refactor:=20Fine,?= =?UTF-8?q?=20I'll=20Do=20It=20Myself=20Edition=20(#8695)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * We're getting there. * It's ugly but it works * Ladies and gentlemen, we got 'em. * Marking my Skyrat Edits and removing debug shit * A fix for the Other gender button * Augmented folks rejoice! * Update tgui/packages/tgui/interfaces/PreferencesMenu/MainPage.tsx Co-authored-by: Gandalf --- code/modules/client/preferences.dm | 7 + .../middleware/limbs_and_markings.dm | 35 +++- .../modules/client/preferences_savefile.dm | 2 +- .../CharacterPreferenceWindow.tsx | 2 +- .../interfaces/PreferencesMenu/LimbsPage.tsx | 161 +++++++++++------- .../interfaces/PreferencesMenu/MainPage.tsx | 5 +- .../interfaces/PreferencesMenu/QuirksPage.tsx | 28 +-- .../tgui/interfaces/PreferencesMenu/data.ts | 7 +- .../PreferencesMenu/preferences/gender.ts | 2 +- 9 files changed, 156 insertions(+), 93 deletions(-) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index cd622de6110..0031b7a2d49 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -166,6 +166,9 @@ GLOBAL_LIST_EMPTY(preferences_datums) //SKYRAT EDIT BEGIN data["preview_options"] = list(PREVIEW_PREF_JOB, PREVIEW_PREF_LOADOUT, PREVIEW_PREF_UNDERWEAR, PREVIEW_PREF_NAKED, PREVIEW_PREF_NAKED_AROUSED) data["preview_selection"] = preview_pref + + data["quirks_balance"] = GetQuirkBalance() + data["positive_quirk_count"] = GetPositiveQuirkCount() //SKYRAT EDIT END data["character_preferences"] = compile_character_preferences(user) @@ -332,6 +335,10 @@ GLOBAL_LIST_EMPTY(preferences_datums) return FALSE return TRUE + + // For the quirks in the prefs menu. + if ("get_quirks_balance") + return TRUE //SKYRAT EDIT END diff --git a/modular_skyrat/master_files/code/modules/client/preferences/middleware/limbs_and_markings.dm b/modular_skyrat/master_files/code/modules/client/preferences/middleware/limbs_and_markings.dm index 7dfdaea84b0..f476ca53026 100644 --- a/modular_skyrat/master_files/code/modules/client/preferences/middleware/limbs_and_markings.dm +++ b/modular_skyrat/master_files/code/modules/client/preferences/middleware/limbs_and_markings.dm @@ -30,7 +30,8 @@ "liver" = "Liver", "stomach" = "Stomach", "eyes" = "Eyes", - "tongue" = "Tongue" + "tongue" = "Tongue", + "Mouth implant" = "Mouth implant" ) var/list/aug_support = list( @@ -41,10 +42,14 @@ "chest" = FALSE, // TODO: figure out why head/chest augs dont render, needed for IPC head on non IPC body "head" = FALSE, "l_hand" = FALSE, - "r_hand" = FALSE + "r_hand" = FALSE, ) var/list/nice_aug_names = list() var/list/augment_to_path = list() + var/list/costs = list( + AUGMENT_CATEGORY_LIMBS = list(), + AUGMENT_CATEGORY_ORGANS = list(), + ) var/list/robotic_styles /datum/preference_middleware/limbs_and_markings/proc/set_limb_aug(list/params, mob/user) @@ -179,8 +184,15 @@ nice_aug_names[limb] = list() for(var/augments in GLOB.augment_slot_to_items[limbs_to_process[limb]]) var/obj/item/aug = augments - nice_aug_names[limb][augments] = initial(aug.name) - augment_to_path[initial(aug.name)] = augments + var/cost = 0 + if(GLOB.augment_items[augments]) + var/datum/augment_item/expensive_augment = GLOB.augment_items[augments] + cost = expensive_augment.cost + // To display the cost of the limb, if it's anything aside from 0. + var/aug_name = cost != 0 ? initial(aug.name) + " ([cost])" : initial(aug.name) + costs[AUGMENT_CATEGORY_LIMBS][aug_name] = cost + nice_aug_names[limb][augments] = aug_name + augment_to_path[aug_name] = augments nice_aug_names[limb]["none"] = "None" var/chosen_augment if(preferences.augments[limbs_to_process[limb]] && !isnull(nice_aug_names[limb][preferences.augments[limbs_to_process[limb]]])) @@ -194,6 +206,7 @@ "chosen_aug" = chosen_augment, "chosen_style" = preferences.augment_limb_styles[limbs_to_process[limb]] ? preferences.augment_limb_styles[limbs_to_process[limb]] : "None", "aug_choices" = nice_aug_names[limb], + "costs" = costs[AUGMENT_CATEGORY_LIMBS], "markings" = list( "marking_choices" = GLOB.body_markings_per_limb[limb], "markings_list" = fix_colors_on_markings_to_tgui(preferences.body_markings[limb], limb) @@ -208,8 +221,15 @@ nice_aug_names[organ] = list() for(var/augments in GLOB.augment_slot_to_items[organs_to_process[organ]]) var/obj/item/aug = augments - nice_aug_names[organ][augments] = initial(aug.name) - augment_to_path[initial(aug.name)] = augments + var/cost = 0 + if(GLOB.augment_items[augments]) + var/datum/augment_item/expensive_augment = GLOB.augment_items[augments] + cost = expensive_augment.cost + // To display the cost of the limb, if it's anything aside from 0. + var/aug_name = cost != 0 ? initial(aug.name) + " ([cost])" : initial(aug.name) + costs[AUGMENT_CATEGORY_ORGANS][aug_name] = cost + nice_aug_names[organ][augments] = aug_name + augment_to_path[aug_name] = augments nice_aug_names[organ]["organic"] = "Organic" var/chosen_organ if(preferences.augments[organs_to_process[organ]] && !isnull(nice_aug_names[organ][preferences.augments[organs_to_process[organ]]])) @@ -220,7 +240,8 @@ "slot" = organ, "name" = organs_to_process[organ], "chosen_organ" = chosen_organ, - "organ_choices" = nice_aug_names[organ] + "organ_choices" = nice_aug_names[organ], + "costs" = costs[AUGMENT_CATEGORY_ORGANS] )) data["organs_data"] = organs_data diff --git a/modular_skyrat/master_files/code/modules/client/preferences_savefile.dm b/modular_skyrat/master_files/code/modules/client/preferences_savefile.dm index de81f962434..5be077643a8 100644 --- a/modular_skyrat/master_files/code/modules/client/preferences_savefile.dm +++ b/modular_skyrat/master_files/code/modules/client/preferences_savefile.dm @@ -13,7 +13,7 @@ augment_limb_styles = SANITIZE_LIST(augment_limb_styles) //validating limb styles for(var/key in augment_limb_styles) - if(!GLOB.robotic_styles_list[key]) + if(!GLOB.robotic_styles_list[augment_limb_styles[key]]) augment_limb_styles -= key diff --git a/tgui/packages/tgui/interfaces/PreferencesMenu/CharacterPreferenceWindow.tsx b/tgui/packages/tgui/interfaces/PreferencesMenu/CharacterPreferenceWindow.tsx index 7e77f290f86..50163c6ac98 100644 --- a/tgui/packages/tgui/interfaces/PreferencesMenu/CharacterPreferenceWindow.tsx +++ b/tgui/packages/tgui/interfaces/PreferencesMenu/CharacterPreferenceWindow.tsx @@ -157,7 +157,7 @@ export const CharacterPreferenceWindow = (props, context) => { page={Page.Limbs} setPage={setCurrentPage} > - Limb Augumentation/Marking + Augments+ diff --git a/tgui/packages/tgui/interfaces/PreferencesMenu/LimbsPage.tsx b/tgui/packages/tgui/interfaces/PreferencesMenu/LimbsPage.tsx index b2114c2672f..01ec79e64b1 100644 --- a/tgui/packages/tgui/interfaces/PreferencesMenu/LimbsPage.tsx +++ b/tgui/packages/tgui/interfaces/PreferencesMenu/LimbsPage.tsx @@ -1,4 +1,4 @@ -import { Stack, Section, Dropdown, Button, ColorBox } from "../../components"; +import { Box, Stack, Section, Dropdown, Button, ColorBox } from "../../components"; import { useBackend } from "../../backend"; import { PreferencesMenuData } from "./data"; import { CharacterPreview } from "./CharacterPreview"; @@ -6,13 +6,13 @@ import { CharacterPreview } from "./CharacterPreview"; export const Markings = (props, context) => { const { act } = useBackend(context); return ( - + Markings: {props.limb.markings.markings_list.map((marking, index) => ( - + { export const LimbPage = (props, context) => { const { act } = useBackend(context); return ( -
- - - - - -
+
+
+ + + + + +
+
); }; export const AugmentationPage = (props, context) => { const { act } = useBackend(context); + const { data } = useBackend(context); + let balance = -data.quirks_balance; if (props.limb.can_augment) { return ( -
- - - - - - - Augumentation: - - - act("set_limb_aug", { limb_slot: props.limb.slot, augment_name: value })} - /> - - - - - - - Style: - - - act("set_limb_aug_style", { limb_slot: props.limb.slot, style_name: value })} - /> - - - - - - -
+
+
+ + + + + Augumentation: + + + + { + // Since the costs are positive, + // it's added and not substracted + if (balance + props.limb.costs[value] > 0) { + return; + } + act("set_limb_aug", { limb_slot: props.limb.slot, augment_name: value }); + }} + /> + + + + + + + Style: + + + act("set_limb_aug_style", { limb_slot: props.limb.slot, style_name: value })} + /> + + + + +
+
); } return null; @@ -116,6 +126,8 @@ export const AugmentationPage = (props, context) => { export const OrganPage = (props, context) => { const { act } = useBackend(context); + const { data } = useBackend(context); + let balance = -data.quirks_balance; return ( @@ -127,7 +139,14 @@ export const OrganPage = (props, context) => { width="100%" options={Object.values(props.organ.organ_choices)} displayText={props.organ.chosen_organ} - onSelected={(value) => act("set_organ_aug", { organ_slot: props.organ.slot, augment_name: value })} + onSelected={(value) => + { + // Since the costs are positive, it's added and not substracted + if (balance + props.organ.costs[value] > 0) { + return; + } + act("set_organ_aug", { organ_slot: props.organ.slot, augment_name: value }); + }} />
@@ -139,19 +158,20 @@ export const LimbsPage = (props, context) => { const { data } = useBackend(context); const { act } = useBackend(context); const markings = data.marking_presets ? data.marking_presets : []; + let balance = -data.quirks_balance; return ( - - -
- + + +
+
act("set_preset", { preset: value })} /> - - +
+
{data.limbs_data.map(val => ( { data={data} /> ))} - +
-
+
+ +
+ + + + {balance} +
-
+
{data.organs_data.map(val => ( { ))}
-
+
{data.limbs_data.map(val => ( act('update_preview', { diff --git a/tgui/packages/tgui/interfaces/PreferencesMenu/QuirksPage.tsx b/tgui/packages/tgui/interfaces/PreferencesMenu/QuirksPage.tsx index e1f8d58bc76..d26b19bd1ae 100644 --- a/tgui/packages/tgui/interfaces/PreferencesMenu/QuirksPage.tsx +++ b/tgui/packages/tgui/interfaces/PreferencesMenu/QuirksPage.tsx @@ -109,7 +109,7 @@ const QuirkList = (props: { ); }; -const StatDisplay: StatelessComponent<{}> = (props) => { +export const StatDisplay: StatelessComponent<{}> = (props) => { // SKYRAT EDIT return ( { return ( { - if (!data) { + // SKYRAT EDIT START - Quirks balance refactor + render={quirks_data => { + if (!quirks_data) { // SKYRAT EDIT END return Loading quirks...; } @@ -144,7 +145,7 @@ export const QuirksPage = (props, context) => { max_positive_quirks: maxPositiveQuirks, quirk_blacklist: quirkBlacklist, quirk_info: quirkInfo, - } = data.quirks; + } = quirks_data.quirks; // SKYRAT EDIT - Quirks balance refactor const quirks = Object.entries(quirkInfo); quirks.sort(([_, quirkA], [__, quirkB]) => { @@ -155,21 +156,10 @@ export const QuirksPage = (props, context) => { } }); - let balance = 0; - let positiveQuirks = 0; - - for (const selectedQuirkName of selectedQuirks) { - const selectedQuirk = quirkInfo[selectedQuirkName]; - if (!selectedQuirk) { - continue; - } - - if (selectedQuirk.value > 0) { - positiveQuirks += 1; - } - - balance += selectedQuirk.value; - } + // SKYRAT EDIT START - Better Quirk Count Code + let balance = -data.quirks_balance; + let positiveQuirks = data.positive_quirk_count; + // SKYRAT EDIT END const getReasonToNotAdd = (quirkName: string) => { const quirk = quirkInfo[quirkName]; diff --git a/tgui/packages/tgui/interfaces/PreferencesMenu/data.ts b/tgui/packages/tgui/interfaces/PreferencesMenu/data.ts index 1758bbdcf3e..ca58e8b9c54 100644 --- a/tgui/packages/tgui/interfaces/PreferencesMenu/data.ts +++ b/tgui/packages/tgui/interfaces/PreferencesMenu/data.ts @@ -55,7 +55,7 @@ export type Quirk = { value: number; }; -// SKYRAT EDIT +// SKYRAT EDIT START export type Language = { description: string; name: string; @@ -80,6 +80,7 @@ export type Limb = { chosen_aug: string; chosen_style: string; aug_choices: Record; + costs: Record; markings: MarkingData; }; @@ -88,6 +89,7 @@ export type Organ = { name: string; chosen_organ: string; organ_choices: Record + costs: Record; }; // SKYRAT EDIT END @@ -182,6 +184,9 @@ export type PreferencesMenuData = { selected_languages: Language[]; unselected_languages: Language[]; total_language_points: number; + + quirks_balance: number; + positive_quirk_count: number; // SKYRAT EDIT END keybindings: Record; overflow_role: string; diff --git a/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/gender.ts b/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/gender.ts index 787a3c900cb..79457a1a64c 100644 --- a/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/gender.ts +++ b/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/gender.ts @@ -16,7 +16,7 @@ export const GENDERS = { }, [Gender.Other]: { - icon: "tg-non-binary", + icon: "question", // SKYRAT EDIT CHANGE - ORIGINAL: icon: "tg-non-binary" text: "Other", }, };