From ad3ab315eaf3d91ea9852238a0eeb02b30186d5c Mon Sep 17 00:00:00 2001 From: iisaev Date: Wed, 21 Oct 2026 13:29:32 +0200 Subject: [PATCH] Line endings: LF everywhere .gitattributes forces LF (CRLF only for .bat/.cmd), core.autocrlf is off; files that differed only by CRLF are normalized. --- .gitattributes | 30 +++++ .gitignore | 74 +++++------ items/recipe/wolf_meat_to_ration.json | 26 ++-- locale/en.properties | 44 +++--- locale/ru.properties | 44 +++--- locale/scenarios_en.properties | 6 +- locale/scenarios_ru.properties | 6 +- recipes/cooking.json | 54 ++++---- src/CookingSettings.cs | 112 ++++++++-------- src/ui/RationStatisticsPanel.cs | 128 +++++++++--------- src/ui/workbench/RecipeIconItemBehaviour.cs | 140 ++++++++++---------- 11 files changed, 347 insertions(+), 317 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..3030c1a --- /dev/null +++ b/.gitattributes @@ -0,0 +1,30 @@ +# Line endings: LF everywhere, on every OS, whatever core.autocrlf says. +* text=auto eol=lf + +# cmd.exe misreads labels and goto in LF batch files, so they stay CRLF. +*.bat text eol=crlf +*.cmd text eol=crlf + +# Binaries: never converted, never diffed as text. +*.png binary +*.jpg binary +*.jpeg binary +*.webp binary +*.svg text +*.ogg binary +*.wav binary +*.mp3 binary +*.ttf binary +*.otf binary +*.woff binary +*.woff2 binary +*.dll binary +*.so binary +*.dylib binary +*.pdb binary +*.exe binary +*.zip binary +*.pck binary +*.moc3 binary +*.res binary +*.scn binary diff --git a/.gitignore b/.gitignore index bb88804..c301ca8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,37 +1,37 @@ -# Godot 4.x -.godot/ -.idea/ -sdk/ -bin/ -obj/ - -#ai -.omo/ -.opencode/ - -gen/ -obj/ -bin/ - -*.tres~ -*.tscn~ - -# GDScript LSP -.godot/ - -# Export -*.exe -*.dmg -*.apk -*.aab -*.pck -*.zip -*.log - -# OS -.DS_Store -Thumbs.db - -# Editor -*.import -*.godot.uid +# Godot 4.x +.godot/ +.idea/ +sdk/ +bin/ +obj/ + +#ai +.omo/ +.opencode/ + +gen/ +obj/ +bin/ + +*.tres~ +*.tscn~ + +# GDScript LSP +.godot/ + +# Export +*.exe +*.dmg +*.apk +*.aab +*.pck +*.zip +*.log + +# OS +.DS_Store +Thumbs.db + +# Editor +*.import +*.godot.uid diff --git a/items/recipe/wolf_meat_to_ration.json b/items/recipe/wolf_meat_to_ration.json index 6ad528a..c62304f 100644 --- a/items/recipe/wolf_meat_to_ration.json +++ b/items/recipe/wolf_meat_to_ration.json @@ -1,14 +1,14 @@ -{ - "Kind": "item", - "Items": [ - { - "Id": "recipe/wolf_meat_to_ration", - "Name": "items/recipe/wolf_meat_to_ration/name", - "Description": "items/recipe/wolf_meat_to_ration/desc", - "Cost": 1, - "Sprite": "recipe/cooking_recipe", - "ItemType": "Recipe,Used", - "ItemAction": "action/recipe/wolf_meat_to_ration" - } - ] +{ + "Kind": "item", + "Items": [ + { + "Id": "recipe/wolf_meat_to_ration", + "Name": "items/recipe/wolf_meat_to_ration/name", + "Description": "items/recipe/wolf_meat_to_ration/desc", + "Cost": 1, + "Sprite": "recipe/cooking_recipe", + "ItemType": "Recipe,Used", + "ItemAction": "action/recipe/wolf_meat_to_ration" + } + ] } diff --git a/locale/en.properties b/locale/en.properties index 2cc63bf..7d91534 100644 --- a/locale/en.properties +++ b/locale/en.properties @@ -1,22 +1,22 @@ -mod_cooking_name = Cooking -mod_cooking_desc = Cooking mechanic: the kitchen workbench in home_kitchen with recipe-based cooking (e.g. wolf meat into rations), a ration statistics panel and the cooking scenario. - -ui/cook/cook = Cook -ui/cook/close = Close -ui/cook/title = Food preparation -ui/cook/recipe_time = {0} minutes -ui/cook/recipe_out = Cooking result: {0} -ui/diner/rationcount = Rations: {0} -ui/diner/rationday = Daily consumption: {0} -ui/diner/rationmax = Supplies will last {0} days -items/food/ration/name = Ration -items/food/ration/desc = A daily ration unit for one person -items/food/wolf_meat/name = Wolf cutlet -items/food/wolf_meat/desc = Raw wolf meat -items/resource/branches/name = Branches -items/resource/branches/desc = Fuel for a campfire -recipe/wolf_meat_to_ration/name = Ration from wolf meat -recipe/wolf_meat_to_ration/desc = A recipe describing how to properly cook wolf meat to make it safe to eat -items/recipe/wolf_meat_to_ration/name = Recipe: ration from wolf meat -items/recipe/wolf_meat_to_ration/desc = Teaches how to cook wolf meat into rations that are safe to eat -mod_cooking/rations_per_character = Rations per person per day +mod_cooking_name = Cooking +mod_cooking_desc = Cooking mechanic: the kitchen workbench in home_kitchen with recipe-based cooking (e.g. wolf meat into rations), a ration statistics panel and the cooking scenario. + +ui/cook/cook = Cook +ui/cook/close = Close +ui/cook/title = Food preparation +ui/cook/recipe_time = {0} minutes +ui/cook/recipe_out = Cooking result: {0} +ui/diner/rationcount = Rations: {0} +ui/diner/rationday = Daily consumption: {0} +ui/diner/rationmax = Supplies will last {0} days +items/food/ration/name = Ration +items/food/ration/desc = A daily ration unit for one person +items/food/wolf_meat/name = Wolf cutlet +items/food/wolf_meat/desc = Raw wolf meat +items/resource/branches/name = Branches +items/resource/branches/desc = Fuel for a campfire +recipe/wolf_meat_to_ration/name = Ration from wolf meat +recipe/wolf_meat_to_ration/desc = A recipe describing how to properly cook wolf meat to make it safe to eat +items/recipe/wolf_meat_to_ration/name = Recipe: ration from wolf meat +items/recipe/wolf_meat_to_ration/desc = Teaches how to cook wolf meat into rations that are safe to eat +mod_cooking/rations_per_character = Rations per person per day diff --git a/locale/ru.properties b/locale/ru.properties index 20ea50f..756a5be 100644 --- a/locale/ru.properties +++ b/locale/ru.properties @@ -1,22 +1,22 @@ -mod_cooking_name = Готовка -mod_cooking_desc = Механика готовки: верстак на кухне home_kitchen с рецептами (например, волчье мясо в рационы), панель статистики рационов и сценар готовки. - -ui/cook/cook = Готовить -ui/cook/close = Выйти -ui/cook/title = Приготовление еды -ui/cook/recipe_time = {0} минут -ui/cook/recipe_out = Результат приготовления: {0} -ui/diner/rationcount = Пайков: {0} -ui/diner/rationday = Потребление в сутки: {0} -ui/diner/rationmax = Запасов хватит на {0} дней -items/food/ration/name = Рацион -items/food/ration/desc = Единица суточного рациона для одного человека -items/food/wolf_meat/name = Волчья вырезка -items/food/wolf_meat/desc = Сырое мясо волка -items/resource/branches/name = Ветки -items/resource/branches/desc = Топливо для костра -recipe/wolf_meat_to_ration/name = Рацион из волчьего мяса -recipe/wolf_meat_to_ration/desc = Рецепт описывает как правильно приготовить волчатину, чтобы безопасно употребить её в пищу -items/recipe/wolf_meat_to_ration/name = Рецепт: рацион из волчьего мяса -items/recipe/wolf_meat_to_ration/desc = Учит готовить из волчатины рационы, которые безопасно есть -mod_cooking/rations_per_character = Рационов на персонажа в сутки +mod_cooking_name = Готовка +mod_cooking_desc = Механика готовки: верстак на кухне home_kitchen с рецептами (например, волчье мясо в рационы), панель статистики рационов и сценар готовки. + +ui/cook/cook = Готовить +ui/cook/close = Выйти +ui/cook/title = Приготовление еды +ui/cook/recipe_time = {0} минут +ui/cook/recipe_out = Результат приготовления: {0} +ui/diner/rationcount = Пайков: {0} +ui/diner/rationday = Потребление в сутки: {0} +ui/diner/rationmax = Запасов хватит на {0} дней +items/food/ration/name = Рацион +items/food/ration/desc = Единица суточного рациона для одного человека +items/food/wolf_meat/name = Волчья вырезка +items/food/wolf_meat/desc = Сырое мясо волка +items/resource/branches/name = Ветки +items/resource/branches/desc = Топливо для костра +recipe/wolf_meat_to_ration/name = Рацион из волчьего мяса +recipe/wolf_meat_to_ration/desc = Рецепт описывает как правильно приготовить волчатину, чтобы безопасно употребить её в пищу +items/recipe/wolf_meat_to_ration/name = Рецепт: рацион из волчьего мяса +items/recipe/wolf_meat_to_ration/desc = Учит готовить из волчатины рационы, которые безопасно есть +mod_cooking/rations_per_character = Рационов на персонажа в сутки diff --git a/locale/scenarios_en.properties b/locale/scenarios_en.properties index bdfe0e8..ecf6c7e 100644 --- a/locale/scenarios_en.properties +++ b/locale/scenarios_en.properties @@ -1,3 +1,3 @@ -rooms/kitchen/prompt = A room equipped as a kitchen -rooms/kitchen/opt_exit = Leave -rooms/kitchen/opt_cook = Cook +rooms/kitchen/prompt = A room equipped as a kitchen +rooms/kitchen/opt_exit = Leave +rooms/kitchen/opt_cook = Cook diff --git a/locale/scenarios_ru.properties b/locale/scenarios_ru.properties index 2cb2f48..8608cf0 100644 --- a/locale/scenarios_ru.properties +++ b/locale/scenarios_ru.properties @@ -1,3 +1,3 @@ -rooms/kitchen/prompt = Комната оборудованная под кухню -rooms/kitchen/opt_exit = Выйти -rooms/kitchen/opt_cook = Готовить +rooms/kitchen/prompt = Комната оборудованная под кухню +rooms/kitchen/opt_exit = Выйти +rooms/kitchen/opt_cook = Готовить diff --git a/recipes/cooking.json b/recipes/cooking.json index ec31ceb..bb4dc30 100644 --- a/recipes/cooking.json +++ b/recipes/cooking.json @@ -1,28 +1,28 @@ -{ - "Kind": "recipe", - "Items": [ - { - "Id": "recipe/wolf_meat_to_ration", - "Name": "recipe/wolf_meat_to_ration/name", - "Description": "recipe/wolf_meat_to_ration/desc", - "Type": "Cooking", - "Time": 15, - "Input": [ - { - "Id": "food/wolf_meat", - "Count": 1 - }, - { - "Id": "resource/branches", - "Count": 2 - } - ], - "Output": [ - { - "Id": "food/ration", - "Count": 1 - } - ] - } - ] +{ + "Kind": "recipe", + "Items": [ + { + "Id": "recipe/wolf_meat_to_ration", + "Name": "recipe/wolf_meat_to_ration/name", + "Description": "recipe/wolf_meat_to_ration/desc", + "Type": "Cooking", + "Time": 15, + "Input": [ + { + "Id": "food/wolf_meat", + "Count": 1 + }, + { + "Id": "resource/branches", + "Count": 2 + } + ], + "Output": [ + { + "Id": "food/ration", + "Count": 1 + } + ] + } + ] } diff --git a/src/CookingSettings.cs b/src/CookingSettings.cs index c207b95..fa71733 100644 --- a/src/CookingSettings.cs +++ b/src/CookingSettings.cs @@ -1,56 +1,56 @@ -using System.Collections.Generic; -using Cthangover.Core.Mods; -using Cthangover.Core.Settings; - -namespace Cthangover.Cooking -{ - /// - /// Exposes a user-configurable setting for the number of rations - /// consumed per character per in-game day. Registered automatically - /// via when the cooking mod - /// assembly loads. - /// - /// The static property is the - /// canonical source of truth shared with RationStatisticsPanel - /// and any future consumption logic. It is updated by the core on - /// boot (from persisted JSON) and on every UI change. - /// - public class CookingSettings : IModSettings - { - /// - /// Current value for rations consumed per character per day. - /// Default is 1. Updated by on boot - /// and whenever the player changes the setting in the menu. - /// - public static int RationsPerCharacter { get; private set; } = 1; - - public IReadOnlyList GetDefinitions() - { - return new List - { - new() - { - Key = "rations_per_character", - Name = "mod_cooking/rations_per_character", - Type = SettingType.Slider, - DefaultValue = "1", - Min = 1f, - Max = 10f, - Step = 1f, - }, - }; - } - - public void WriteValues(DataBlob blob) - { - blob.SetInt("rations_per_character", RationsPerCharacter); - } - - public void ReadValues(DataBlob blob) - { - RationsPerCharacter = blob.GetInt("rations_per_character", 1); - if (RationsPerCharacter < 1) - RationsPerCharacter = 1; - } - } -} +using System.Collections.Generic; +using Cthangover.Core.Mods; +using Cthangover.Core.Settings; + +namespace Cthangover.Cooking +{ + /// + /// Exposes a user-configurable setting for the number of rations + /// consumed per character per in-game day. Registered automatically + /// via when the cooking mod + /// assembly loads. + /// + /// The static property is the + /// canonical source of truth shared with RationStatisticsPanel + /// and any future consumption logic. It is updated by the core on + /// boot (from persisted JSON) and on every UI change. + /// + public class CookingSettings : IModSettings + { + /// + /// Current value for rations consumed per character per day. + /// Default is 1. Updated by on boot + /// and whenever the player changes the setting in the menu. + /// + public static int RationsPerCharacter { get; private set; } = 1; + + public IReadOnlyList GetDefinitions() + { + return new List + { + new() + { + Key = "rations_per_character", + Name = "mod_cooking/rations_per_character", + Type = SettingType.Slider, + DefaultValue = "1", + Min = 1f, + Max = 10f, + Step = 1f, + }, + }; + } + + public void WriteValues(DataBlob blob) + { + blob.SetInt("rations_per_character", RationsPerCharacter); + } + + public void ReadValues(DataBlob blob) + { + RationsPerCharacter = blob.GetInt("rations_per_character", 1); + if (RationsPerCharacter < 1) + RationsPerCharacter = 1; + } + } +} diff --git a/src/ui/RationStatisticsPanel.cs b/src/ui/RationStatisticsPanel.cs index b6cfcba..b0b1890 100644 --- a/src/ui/RationStatisticsPanel.cs +++ b/src/ui/RationStatisticsPanel.cs @@ -1,65 +1,65 @@ -using Cthangover.Cooking; - -using System; -using Cthangover.Core.Settings; -using Cthangover.Core.UI; -using Godot; - +using Cthangover.Cooking; + +using System; +using Cthangover.Core.Settings; +using Cthangover.Core.UI; +using Godot; + using Cthangover.Mods.Interface.Base.Lists; -namespace Mods.Cooking.Rations -{ - /// - /// Displays live ration statistics on the dinner/ration UI screen. - /// Shows the player the current ration count, how many rations are - /// consumed daily (one per character), and the maximum number of days - /// the party can survive on available rations. Listens to - /// events to refresh - /// automatically whenever the inventory is modified. - /// - public class RationStatisticsPanel : Widget - { - private RichTextLabel label; - private Action _onInventoryChange; - - protected override void OnceConstruct() - { - label = GetNode("RationMargin/RationLabel"); - - _onInventoryChange = (_, _) => UpdateInfo(); - GameData.Instance.Runtime.Inventory.Change += _onInventoryChange; - } - - protected override void ShowConstruct() - { - UpdateInfo(); - } - - protected override void OnceDestruct() - { - GameData.Instance.Runtime.Inventory.Change -= _onInventoryChange; - } - - /// - /// Recomputes and refreshes the ration-statistics text. - /// Reads current ration inventory via - /// for "food/ration" and the total character count from - /// . Formats three localized lines: - /// total rations, daily consumption, and remaining days - /// (rations divided by character count, clamped to 1 minimum). - /// - public void UpdateInfo() - { - if (label == null) - return; - - var rationCount = GameData.Instance.Runtime.Inventory.CheckCount("food/ration"); - var characterCount = GameData.Instance.Runtime.CharacterData.Characters.Count; - var perChar = CookingSettings.RationsPerCharacter; - var dailyConsumption = characterCount * perChar; - - label.Text = string.Format(TranslationServer.Translate("ui/diner/rationcount"), rationCount) + - "\n" + string.Format(TranslationServer.Translate("ui/diner/rationday"), dailyConsumption) + - "\n" + string.Format(TranslationServer.Translate("ui/diner/rationmax"), rationCount / Mathf.Max(1, dailyConsumption)); - } - } -} +namespace Mods.Cooking.Rations +{ + /// + /// Displays live ration statistics on the dinner/ration UI screen. + /// Shows the player the current ration count, how many rations are + /// consumed daily (one per character), and the maximum number of days + /// the party can survive on available rations. Listens to + /// events to refresh + /// automatically whenever the inventory is modified. + /// + public class RationStatisticsPanel : Widget + { + private RichTextLabel label; + private Action _onInventoryChange; + + protected override void OnceConstruct() + { + label = GetNode("RationMargin/RationLabel"); + + _onInventoryChange = (_, _) => UpdateInfo(); + GameData.Instance.Runtime.Inventory.Change += _onInventoryChange; + } + + protected override void ShowConstruct() + { + UpdateInfo(); + } + + protected override void OnceDestruct() + { + GameData.Instance.Runtime.Inventory.Change -= _onInventoryChange; + } + + /// + /// Recomputes and refreshes the ration-statistics text. + /// Reads current ration inventory via + /// for "food/ration" and the total character count from + /// . Formats three localized lines: + /// total rations, daily consumption, and remaining days + /// (rations divided by character count, clamped to 1 minimum). + /// + public void UpdateInfo() + { + if (label == null) + return; + + var rationCount = GameData.Instance.Runtime.Inventory.CheckCount("food/ration"); + var characterCount = GameData.Instance.Runtime.CharacterData.Characters.Count; + var perChar = CookingSettings.RationsPerCharacter; + var dailyConsumption = characterCount * perChar; + + label.Text = string.Format(TranslationServer.Translate("ui/diner/rationcount"), rationCount) + + "\n" + string.Format(TranslationServer.Translate("ui/diner/rationday"), dailyConsumption) + + "\n" + string.Format(TranslationServer.Translate("ui/diner/rationmax"), rationCount / Mathf.Max(1, dailyConsumption)); + } + } +} diff --git a/src/ui/workbench/RecipeIconItemBehaviour.cs b/src/ui/workbench/RecipeIconItemBehaviour.cs index ffec702..40bfeef 100644 --- a/src/ui/workbench/RecipeIconItemBehaviour.cs +++ b/src/ui/workbench/RecipeIconItemBehaviour.cs @@ -1,71 +1,71 @@ -using Cthangover.Core.Items; -using Cthangover.Core.Settings; -using Cthangover.Core.UI; -using Cthangover.Core.UI.Theming; -using Cthangover.Core.Utils; -using Godot; - +using Cthangover.Core.Items; +using Cthangover.Core.Settings; +using Cthangover.Core.UI; +using Cthangover.Core.UI.Theming; +using Cthangover.Core.Utils; +using Godot; + using Cthangover.Mods.Interface.Base.Lists; -namespace Mods.Cooking.Workbench -{ - /// - /// Renders a single ingredient row inside a - /// on the cooking workbench. Displays the ingredient's item icon and the - /// required count. When is called, compares - /// inventory count against the recipe requirement and tints the icon and - /// count text grey if the player lacks enough items. - /// - public class RecipeIconItemBehaviour : Widget - { - private static readonly Color NormalColor = UiTokens.InkBright; - private static readonly Color NotItemsColor = UiTokens.Muted; - - private TextureRect img; - private Label txt; - private IIngredient ingredient; - - protected override void OnceConstruct() - { - img = GetNode("Img"); - txt = GetNode