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

Preference Menu fix up and clean up #415

Merged
merged 6 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
68 changes: 28 additions & 40 deletions maplestation_modules/code/modules/client/preferences/languages.dm
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,6 @@
action_delegations = list(
"set_language" = PROC_REF(set_language),
)
/// Static list of all "base" languages learnable via ui
/// (roundstart languages, languages readily available / common)
var/static/list/base_languages
/// Static list of all "bonus" languages learnable via ui
/// (rarer languages, not typically available roundstart, dictated by a required_species_id)
var/static/list/bonus_languages

/datum/preference_middleware/language/proc/set_language(list/params, mob/user)
var/datum/preference/additional_language/language_pref = GLOB.preference_entries[/datum/preference/additional_language]
Expand Down Expand Up @@ -161,48 +155,42 @@
/datum/preference_middleware/language/get_ui_data(mob/user)
var/list/data = list()

var/datum/species/species = preferences.read_preference(/datum/preference/choiced/species)
data["selected_lang"] = preferences.read_preference(/datum/preference/additional_language)
data["selected_species"] = preferences.read_preference(/datum/preference/choiced/species)
data["pref_name"] = preferences.read_preference(/datum/preference/name/real_name)
data["trilingual"] = ("Trilingual" in preferences.all_quirks)
data["bilingual"] = ("Bilingual" in preferences.all_quirks)
data["species"] = species

// This should all be moved to constant data when I figure out how tee hee
if(!length(base_languages) && !length(bonus_languages) && length(GLOB.language_datum_instances))
base_languages = list()
bonus_languages = list()

for(var/found_language in GLOB.language_datum_instances)
var/datum/language/found_instance = GLOB.language_datum_instances[found_language]
if(!found_instance.available_as_pref)
continue

var/list/lang_data = list()
lang_data["name"] = found_instance.name
lang_data["type"] = found_language
if(found_instance.banned_from_species)
lang_data["incompatible_with"] = initial(found_instance.banned_from_species.name)
if(found_instance.required_species)
lang_data["requires"] = initial(found_instance.required_species.name)
// Having a required species makes it a bonus language, otherwise it's a base language
if(found_instance.required_species)
UNTYPED_LIST_ADD(bonus_languages, lang_data)
else
UNTYPED_LIST_ADD(base_languages, lang_data)

for(var/list/lang_type as anything in base_languages + bonus_languages)
var/datum/language/lang_instance = GLOB.language_datum_instances[lang_type["type"]]
lang_type["pickable"] = !((lang_instance.banned_from_species && ispath(species, lang_instance.banned_from_species)) \
|| (lang_instance.required_species && !ispath(species, lang_instance.required_species)))

data["base_languages"] = base_languages
data["bonus_languages"] = bonus_languages
return data

/datum/preference_middleware/language/get_ui_static_data(mob/user)
/datum/preference_middleware/language/get_constant_data()
var/list/data = list()
// Again constant data when I figure it out
var/list/base_languages = list()
var/list/bonus_languages = list()
for(var/found_language in GLOB.language_datum_instances)
var/datum/language/found_instance = GLOB.language_datum_instances[found_language]
if(!found_instance.available_as_pref)
continue

var/list/lang_data = list()
lang_data["name"] = found_instance.name
lang_data["type"] = found_language

var/datum/species/banned_species = found_instance.banned_from_species
if(banned_species)
lang_data["incompatible_with"] = list("name" = initial(banned_species.name), "type" = banned_species)
var/datum/species/required_species = found_instance.required_species
if(required_species)
lang_data["requires"] = list("name" = initial(required_species.name), "type" = required_species)

// Having a required species makes it a bonus language, otherwise it's a base language
if(found_instance.required_species)
UNTYPED_LIST_ADD(bonus_languages, lang_data)
else
UNTYPED_LIST_ADD(base_languages, lang_data)

data["base_languages"] = base_languages
data["bonus_languages"] = bonus_languages
data["blacklisted_species"] = BLACKLISTED_SPECIES_FROM_LANGUAGES
return data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
/datum/preference/multiline_text/create_default_value()
return null

/datum/preference/multiline_text/compile_constant_data()
return list("maximum_length" = max_length)

/// Preferences that add onto flavor text datum
/datum/preference/multiline_text/flavor_datum
abstract_type = /datum/preference/multiline_text/flavor_datum
Expand Down Expand Up @@ -62,6 +65,7 @@
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
priority = PREFERENCE_PRIORITY_NAMES
max_length = MAX_MESSAGE_LEN

/datum/preference/multiline_text/record/New()
. = ..()
Expand Down
64 changes: 29 additions & 35 deletions maplestation_modules/code/modules/loadouts/loadout_ui/limbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,45 +94,39 @@
data["preview_flat_icon"] = cached_icon
return data

/datum/preference_middleware/limbs/get_ui_static_data(mob/user)
/datum/preference_middleware/limbs/get_constant_data()
var/list/data = list()
var/list/all_limb_data = list()
var/list/raw_limb_data = list(
BODY_ZONE_HEAD = list(),
BODY_ZONE_CHEST = list(),
BODY_ZONE_L_ARM = list(),
BODY_ZONE_R_ARM = list(),
BODY_ZONE_L_LEG = list(),
BODY_ZONE_R_LEG = list(),
)

// This should all be moved to constant data when I figure out how tee hee
var/static/list/limbs_data
if(isnull(limbs_data))
var/list/raw_data = list(
BODY_ZONE_HEAD = list(),
BODY_ZONE_CHEST = list(),
BODY_ZONE_L_ARM = list(),
BODY_ZONE_R_ARM = list(),
BODY_ZONE_L_LEG = list(),
BODY_ZONE_R_LEG = list(),
for(var/limb_type in GLOB.limb_loadout_options)
var/datum/limb_option_datum/limb_datum = GLOB.limb_loadout_options[limb_type]
var/limb_zone = limb_datum.ui_zone
if(isnull(limb_zone) || !islist(raw_limb_data[limb_zone]))
stack_trace("Invalid limb zone found in limb datums: [limb_zone || "null"]. (From: [limb_type])")
continue

var/list/limb_data = list(
"name" = limb_datum.name,
"tooltip" = limb_datum.desc,
"path" = limb_type,
)

for(var/limb_type in GLOB.limb_loadout_options)
var/datum/limb_option_datum/limb_datum = GLOB.limb_loadout_options[limb_type]
var/limb_zone = limb_datum.ui_zone

if(isnull(limb_zone) || !islist(raw_data[limb_zone]))
stack_trace("Invalid limb zone found in limb datums: [limb_zone || "null"]. (From: [limb_type])")
continue

var/list/limb_data = list(
"name" = limb_datum.name,
"tooltip" = limb_datum.desc,
"path" = limb_type,
)

UNTYPED_LIST_ADD(raw_data[limb_zone], limb_data)

limbs_data = list()
for(var/raw_list_key in raw_data)
var/list/ui_formatted_raw_list = list(
"category_name" = raw_list_key,
"category_data" = raw_data[raw_list_key],
)
UNTYPED_LIST_ADD(limbs_data, ui_formatted_raw_list)
UNTYPED_LIST_ADD(raw_limb_data[limb_zone], limb_data)

for(var/raw_list_key in raw_limb_data)
var/list/ui_formatted_raw_list = list(
"category_name" = raw_list_key,
"category_data" = raw_limb_data[raw_list_key],
)
UNTYPED_LIST_ADD(all_limb_data, ui_formatted_raw_list)

data["limbs"] = limbs_data
data["limbs"] = all_limb_data
return data
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ GLOBAL_LIST_INIT(loadout_categories, init_loadout_categories())
return character_preview_view

/datum/preference_middleware/loadout/on_new_character(mob/user)
character_preview_view.update_body()
character_preview_view?.update_body()

/datum/preference_middleware/loadout/proc/action_select_item(list/params, mob/user)
var/path_to_use = text2path(params["path"])
Expand Down Expand Up @@ -196,17 +196,17 @@ GLOBAL_LIST_INIT(loadout_categories, init_loadout_categories())
/datum/preference_middleware/loadout/get_ui_static_data(mob/user)
var/list/data = list()
data["loadout_preview_view"] = character_preview_view.assigned_map
return data

// This should all be moved to constant data when I figure out how tee hee
var/static/list/loadout_tabs
if(isnull(loadout_tabs))
loadout_tabs = list()
for(var/datum/loadout_category/category as anything in GLOB.loadout_categories)
UNTYPED_LIST_ADD(loadout_tabs, list(
"name" = category.category_name,
"title" = category.ui_title,
"contents" = category.items_to_ui_data(),
))
/datum/preference_middleware/loadout/get_constant_data()
var/list/data = list()
var/list/loadout_tabs = list()
for(var/datum/loadout_category/category as anything in GLOB.loadout_categories)
UNTYPED_LIST_ADD(loadout_tabs, list(
"name" = category.category_name,
"title" = category.ui_title,
"contents" = category.items_to_ui_data(),
))

data["loadout_tabs"] = loadout_tabs
data["tutorial_text"] = get_tutorial_text()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { useState } from 'react';
import { useBackend } from '../../backend';
import { Button, Stack } from '../../components';
import { Window } from '../../layouts';
import { LanguagePage } from '../_LanguagePicker'; // NON-MODULE CHANGE
import { LimbManagerPage } from '../_LimbManager'; // NON-MODULE CHANGE
import { LoadoutPage } from '../_LoadoutManager'; // NON-MODULE CHANGE
import { LanguagePage } from './_LanguagePicker'; // NON-MODULE CHANGE
import { LimbManagerPage } from './_LimbManager'; // NON-MODULE CHANGE
import { LoadoutPage } from './_LoadoutManager'; // NON-MODULE CHANGE
import { AntagsPage } from './AntagsPage';
import { PreferencesMenuData } from './data';
import { JobsPage } from './JobsPage';
Expand Down
Loading
Loading