From 9539ea810c688c6ae8e07f99c77479c0d7a03bc6 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Wed, 16 Oct 2024 17:40:03 +0300 Subject: [PATCH] Adds declent support for materials (#586) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## About The Pull Request Берут имена от их стаков --- code/__DEFINES/bandastation/pronouns.dm | 1 + .../items/stacks/sheets/sheet_types.dm | 1 + .../translations/_translations.dme | 6 +++ .../translations/code/defines.dm | 1 + .../translations/code/pronouns.dm | 45 ++----------------- .../code/ru_names/ru_name_base.dm | 36 +++++++++++++++ .../code/ru_names/ru_name_materials.dm | 9 ++++ .../translations/code/~undefs.dm | 1 + 8 files changed, 59 insertions(+), 41 deletions(-) create mode 100644 modular_bandastation/translations/code/defines.dm create mode 100644 modular_bandastation/translations/code/ru_names/ru_name_base.dm create mode 100644 modular_bandastation/translations/code/ru_names/ru_name_materials.dm create mode 100644 modular_bandastation/translations/code/~undefs.dm diff --git a/code/__DEFINES/bandastation/pronouns.dm b/code/__DEFINES/bandastation/pronouns.dm index 1b694ba3f89f4..1cb0ede906f01 100644 --- a/code/__DEFINES/bandastation/pronouns.dm +++ b/code/__DEFINES/bandastation/pronouns.dm @@ -20,6 +20,7 @@ /// Макрос для добавления значений для переменных #define RU_NAMES_LIST_INIT(base, nominative, genitive, dative, accusative, instrumental, prepositional)\ ru_names = RU_NAMES_LIST(base, nominative, genitive, dative, accusative, instrumental, prepositional);\ + ru_name_base = base;\ ru_name_nominative = nominative;\ ru_name_genitive = genitive;\ ru_name_dative = dative;\ diff --git a/code/game/objects/items/stacks/sheets/sheet_types.dm b/code/game/objects/items/stacks/sheets/sheet_types.dm index c32919094391a..7c253422c5fd9 100644 --- a/code/game/objects/items/stacks/sheets/sheet_types.dm +++ b/code/game/objects/items/stacks/sheets/sheet_types.dm @@ -153,6 +153,7 @@ GLOBAL_LIST_INIT(metal_recipes, list ( \ /obj/item/stack/sheet/iron name = "iron" + RU_NAMES_LIST_INIT("iron", "железо", "железа", "железу", "железо", "железом", "железе") desc = "Sheets made out of iron." singular_name = "iron sheet" icon_state = "sheet-metal" diff --git a/modular_bandastation/translations/_translations.dme b/modular_bandastation/translations/_translations.dme index ee3f2bf83bb79..cc5ced19dbe65 100644 --- a/modular_bandastation/translations/_translations.dme +++ b/modular_bandastation/translations/_translations.dme @@ -1,5 +1,7 @@ #include "_translations.dm" +#include "code/defines.dm" + #include "code/bodyparts.dm" #include "code/design.dm" #include "code/moustache.dm" @@ -8,3 +10,7 @@ #include "code/translate_attack_verb.dm" #include "code/translate_say.dm" #include "code/translate_suggest_ru_names.dm" +#include "code/ru_names/ru_name_base.dm" +#include "code/ru_names/ru_name_materials.dm" + +#include "code/~undefs.dm" diff --git a/modular_bandastation/translations/code/defines.dm b/modular_bandastation/translations/code/defines.dm new file mode 100644 index 0000000000000..aa02a60ce5ca0 --- /dev/null +++ b/modular_bandastation/translations/code/defines.dm @@ -0,0 +1 @@ +#define RU_NAMES_LENGTH 7 // 6 падежей, 1 base diff --git a/modular_bandastation/translations/code/pronouns.dm b/modular_bandastation/translations/code/pronouns.dm index ca5d8b52ae0a6..83cb744e5037f 100644 --- a/modular_bandastation/translations/code/pronouns.dm +++ b/modular_bandastation/translations/code/pronouns.dm @@ -1,39 +1,4 @@ -#define RU_NAMES_LENGTH 7 // 6 падежей, 1 base - -/atom - // code\__DEFINES\bandastation\pronouns.dm for more info - /// RU_NAMES_LIST_INIT("name", "именительный", "родительный", "дательный", "винительный", "творительный", "предложный") - var/list/ru_names - var/ru_name_nominative - var/ru_name_genitive - var/ru_name_dative - var/ru_name_accusative - var/ru_name_instrumental - var/ru_name_prepositional - -/// Необходимо использовать ПЕРЕД изменением var/name, и использовать только этот прок для изменения в рантайме склонений -/atom/proc/ru_names_rename(list/new_list) - if(length(new_list) != RU_NAMES_LENGTH) - CRASH("proc/ru_names_rename() received incorrect list!") - RU_NAMES_LIST_INIT(new_list["base"], new_list[NOMINATIVE], new_list[GENITIVE], new_list[DATIVE], new_list[ACCUSATIVE], new_list[INSTRUMENTAL], new_list[PREPOSITIONAL]) - -/** -* Процедура выбора правильного падежа для любого предмета, если у него указан словарь «ru_names», примерно такой: -* RU_NAMES_LIST_INIT("jaws of life", "челюсти жизни", "челюстей жизни", "челюстям жизни", "челюсти жизни", "челюстями жизни", "челюстях жизни") -*/ -/datum/proc/declent_ru(case_id, list/ru_names_override) - var/list/list_to_use = ru_names_override - if(length(list_to_use)) - return list_to_use[case_id] || src - return src - -/atom/declent_ru(case_id, list/ru_names_override) - var/list/list_to_use = ru_names_override || ru_names - if(length(list_to_use)) - if(list_to_use[case_id] && list_to_use["base"] == name) - return list_to_use[case_id] || name - return name - +// MARK: Helper procs /// Склонения, например "секунда", "секунды", "секунд". /proc/declension_ru(num, single_name, double_name, multiple_name) if(!isnum(num) || round(num) != num) @@ -141,7 +106,7 @@ . = "делает" ////////////////////////////// -// MARK: Client procs +// MARK: Client pronouns ////////////////////////////// // Like clients, which do have gender. /client/ru_p_they(capitalized, temp_gender) @@ -227,7 +192,7 @@ . = "делают" ////////////////////////////// -// MARK: Mob procs +// MARK: Mob pronouns ////////////////////////////// // Mobs (and atoms but atoms don't really matter write your own proc overrides) also have gender! /mob/ru_p_they(capitalized, temp_gender) @@ -313,7 +278,7 @@ . = "делают" ////////////////////////////// -// MARK: Human procs +// MARK: Human pronouns ////////////////////////////// // Humans need special handling, because they can have their gender hidden /mob/living/carbon/human/ru_p_they(temp_gender) @@ -364,5 +329,3 @@ if((obscured & ITEM_SLOT_ICLOTHING) && skipface) temp_gender = PLURAL return ..() - -#undef RU_NAMES_LENGTH diff --git a/modular_bandastation/translations/code/ru_names/ru_name_base.dm b/modular_bandastation/translations/code/ru_names/ru_name_base.dm new file mode 100644 index 0000000000000..7450b282703e4 --- /dev/null +++ b/modular_bandastation/translations/code/ru_names/ru_name_base.dm @@ -0,0 +1,36 @@ +/atom + // code\__DEFINES\bandastation\pronouns.dm for more info + /// RU_NAMES_LIST_INIT("name", "именительный", "родительный", "дательный", "винительный", "творительный", "предложный") + var/list/ru_names + var/ru_name_base + var/ru_name_nominative + var/ru_name_genitive + var/ru_name_dative + var/ru_name_accusative + var/ru_name_instrumental + var/ru_name_prepositional + +/datum/proc/ru_names_rename(list/new_list) + SHOULD_CALL_PARENT(FALSE) + CRASH("Unimplemented proc/ru_names_rename() was used") + +/// Необходимо использовать ПЕРЕД изменением var/name, и использовать только этот прок для изменения в рантайме склонений +/atom/ru_names_rename(list/new_list) + if(length(new_list) != RU_NAMES_LENGTH) + CRASH("proc/ru_names_rename() received incorrect list!") + RU_NAMES_LIST_INIT(new_list["base"], new_list[NOMINATIVE], new_list[GENITIVE], new_list[DATIVE], new_list[ACCUSATIVE], new_list[INSTRUMENTAL], new_list[PREPOSITIONAL]) + +/** +* Процедура выбора правильного падежа для любого предмета, если у него указан словарь «ru_names», примерно такой: +* RU_NAMES_LIST_INIT("jaws of life", "челюсти жизни", "челюстей жизни", "челюстям жизни", "челюсти жизни", "челюстями жизни", "челюстях жизни") +*/ +/datum/proc/declent_ru(case_id, list/ru_names_override) + SHOULD_CALL_PARENT(FALSE) + CRASH("Unimplemented proc/declent_ru() was used") + +/atom/declent_ru(case_id, list/ru_names_override) + var/list/list_to_use = ru_names_override || ru_names + if(length(list_to_use)) + if(list_to_use[case_id] && list_to_use["base"] == name) + return list_to_use[case_id] || name + return name diff --git a/modular_bandastation/translations/code/ru_names/ru_name_materials.dm b/modular_bandastation/translations/code/ru_names/ru_name_materials.dm new file mode 100644 index 0000000000000..ecdd5b9973621 --- /dev/null +++ b/modular_bandastation/translations/code/ru_names/ru_name_materials.dm @@ -0,0 +1,9 @@ +/datum/material/declent_ru(case_id, list/ru_names_override) + if(!ispath(sheet_type)) + CRASH("Sheet type couldn't be declented because it's not a path!") + var/atom/sheet = sheet_type + var/list/list_to_use = ru_names_override || RU_NAMES_LIST(sheet::ru_name_base, sheet::ru_name_nominative, sheet::ru_name_genitive, sheet::ru_name_dative, sheet::ru_name_accusative, sheet::ru_name_instrumental, sheet::ru_name_prepositional) + if(length(list_to_use)) + if(list_to_use[case_id] && list_to_use["base"] == name) + return list_to_use[case_id] || name + return name diff --git a/modular_bandastation/translations/code/~undefs.dm b/modular_bandastation/translations/code/~undefs.dm new file mode 100644 index 0000000000000..4e42fec73f2cf --- /dev/null +++ b/modular_bandastation/translations/code/~undefs.dm @@ -0,0 +1 @@ +#undef RU_NAMES_LENGTH