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 declent support for materials #586

Merged
merged 5 commits into from
Oct 16, 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
1 change: 1 addition & 0 deletions code/__DEFINES/bandastation/pronouns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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;\
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items/stacks/sheets/sheet_types.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions modular_bandastation/translations/_translations.dme
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "_translations.dm"

#include "code/defines.dm"

#include "code/bodyparts.dm"
#include "code/design.dm"
#include "code/moustache.dm"
Expand All @@ -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"
1 change: 1 addition & 0 deletions modular_bandastation/translations/code/defines.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define RU_NAMES_LENGTH 7 // 6 падежей, 1 base
45 changes: 4 additions & 41 deletions modular_bandastation/translations/code/pronouns.dm
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -141,7 +106,7 @@
. = "делает"

//////////////////////////////
// MARK: Client procs
// MARK: Client pronouns
//////////////////////////////
// Like clients, which do have gender.
/client/ru_p_they(capitalized, temp_gender)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -364,5 +329,3 @@
if((obscured & ITEM_SLOT_ICLOTHING) && skipface)
temp_gender = PLURAL
return ..()

#undef RU_NAMES_LENGTH
36 changes: 36 additions & 0 deletions modular_bandastation/translations/code/ru_names/ru_name_base.dm
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions modular_bandastation/translations/code/~undefs.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#undef RU_NAMES_LENGTH
Loading