commit 7a6cd423fc6bd8cbc593b520d8ca404c76504319 Author: KaGaMi_PC Date: Mon Jun 16 07:59:50 2025 +0800 Init diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0af181c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Godot 4+ specific ignores +.godot/ +/android/ diff --git a/.vs/ProjectEvaluation/test.metadata.v7.bin b/.vs/ProjectEvaluation/test.metadata.v7.bin new file mode 100644 index 0000000..4aa7c54 Binary files /dev/null and b/.vs/ProjectEvaluation/test.metadata.v7.bin differ diff --git a/.vs/ProjectEvaluation/test.projects.v7.bin b/.vs/ProjectEvaluation/test.projects.v7.bin new file mode 100644 index 0000000..2804777 Binary files /dev/null and b/.vs/ProjectEvaluation/test.projects.v7.bin differ diff --git a/.vs/Test/DesignTimeBuild/.dtbcache.v2 b/.vs/Test/DesignTimeBuild/.dtbcache.v2 new file mode 100644 index 0000000..a7fa689 Binary files /dev/null and b/.vs/Test/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/Test/FileContentIndex/3f07b048-c1be-4df3-acd2-3be585060024.vsidx b/.vs/Test/FileContentIndex/3f07b048-c1be-4df3-acd2-3be585060024.vsidx new file mode 100644 index 0000000..e0831f8 Binary files /dev/null and b/.vs/Test/FileContentIndex/3f07b048-c1be-4df3-acd2-3be585060024.vsidx differ diff --git a/.vs/Test/FileContentIndex/read.lock b/.vs/Test/FileContentIndex/read.lock new file mode 100644 index 0000000..e69de29 diff --git a/.vs/Test/v17/.futdcache.v2 b/.vs/Test/v17/.futdcache.v2 new file mode 100644 index 0000000..d35e7ed Binary files /dev/null and b/.vs/Test/v17/.futdcache.v2 differ diff --git a/.vs/Test/v17/.suo b/.vs/Test/v17/.suo new file mode 100644 index 0000000..f2539a1 Binary files /dev/null and b/.vs/Test/v17/.suo differ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..f233d82 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,47 @@ +{ + "version": "2.0.0", + "configurations": [ + { + "name": "Play in Editor", + "type": "godot-mono", + "mode": "playInEditor", + "request": "launch" + }, + { + "name": "Launch", + "type": "godot-mono", + "request": "launch", + "mode": "executable", + "preLaunchTask": "build", + "executable": "", + // See which arguments are available here: + // https://docs.godotengine.org/en/stable/getting_started/editor/command_line_tutorial.html + "executableArguments": [ + "--path", + "${workspaceRoot}" + ] + }, + { + "name": "Launch (Select Scene)", + "type": "godot-mono", + "request": "launch", + "mode": "executable", + "preLaunchTask": "build", + "executable": "", + // See which arguments are available here: + // https://docs.godotengine.org/en/stable/getting_started/editor/command_line_tutorial.html + "executableArguments": [ + "--path", + "${workspaceRoot}", + "${command:SelectLaunchScene}" + ] + }, + { + "name": "Attach", + "type": "godot-mono", + "request": "attach", + "address": "localhost", + "port": 23685 + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..a8033a3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "godotTools.editorPath.godot4": "k:\\Tool_Dev\\Godot\\Godot_v4.3-stable_mono_win64.exe" +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..01a6eb9 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,18 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "", + "type": "process", + "args": [ + "--build-solutions", + "--path", + "${workspaceRoot}", + "--no-window", + "-q" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/PROJECT_STRUCTURE.md b/PROJECT_STRUCTURE.md new file mode 100644 index 0000000..916d21b --- /dev/null +++ b/PROJECT_STRUCTURE.md @@ -0,0 +1,112 @@ +# 项目结构说明 + +## 📁 项目根目录结构 + +``` +test/ +├── 📁 scripts/ # 脚本文件(按功能分类) +│ ├── 📁 core/ # 核心系统脚本 +│ ├── 📁 data/ # 数据管理脚本 +│ ├── 📁 inventory/ # 库存系统脚本 +│ ├── 📁 production/ # 生产系统脚本 +│ └── 📁 ui/ # 用户界面脚本 +├── 📁 scenes/ # 场景文件 +├── 📁 data/ # 数据文件 +│ ├── 📁 config/ # 配置文件 +│ ├── 📁 translations/ # 本地化文件 +│ └── 📁 imports/ # 导入配置文件 +├── 📁 assets/ # 资源文件 +└── 📄 project.godot # 项目配置文件 +``` + +## 📂 详细文件分类 + +### 🔧 scripts/ - 脚本文件 + +#### 📁 core/ - 核心系统 +- `GameScene.cs` - 主游戏场景控制器 + +#### 📁 data/ - 数据管理 +- `GameData.cs` - 游戏数据管理器 +- `ResourceCategoryManager.cs` - 资源分类管理器 + +#### 📁 inventory/ - 库存系统 +- `InventoryManager.cs` - 库存管理器(单例) +- `InventoryTableManager.cs` - 库存表格UI管理器 +- `InventoryCategoryManager.cs` - 库存分类管理器 + +#### 📁 production/ - 生产系统 +- `ManualCollectionPanel.cs` - 手动采集面板 +- `ResourceGrid.cs` - 资源网格组件 + +#### 📁 ui/ - 用户界面 +- `DynamicTabManager.cs` - 动态标签页管理器(管理"合成"和"生产线"标签) +- `MainMenu.cs` - 主菜单控制器 + +### 📁 scenes/ - 场景文件 +- `game_scene.tscn` - 主游戏场景 +- `ItemPanel.tscn` - 物品面板模板 +- `InventoryItem.tscn` - 库存物品模板 + +### 📁 data/ - 数据文件 + +#### 📁 config/ - 配置文件 +- `items.csv` - 物品数据配置 +- `resource_categories.json` - 资源分类配置 +- `inventory_categories.json` - 库存分类配置 + +#### 📁 translations/ - 本地化文件 +- `items.*.translation` - 物品数据本地化文件(Godot自动生成) + +#### 📁 imports/ - 导入配置 +- `*.import` - Godot资源导入配置文件 + +### 📁 assets/ - 资源文件 +- 图片、音频、字体等游戏资源 + +## 🎮 游戏标签页结构 + +### 📋 合成标签 +包含以下分类: +- **手动采集** - 可手动采集的基础资源 +- **基础资源** - 原始材料 +- **液体资源** - 液体类资源 +- **冶炼成品** - 冶炼后的材料 +- **建筑设施** - 基础建筑和设备 + +### 🏭 生产线标签 +包含以下分类: +- **生产设备** - 高级生产设备(组装机、化工厂等) + +## 🎯 设计原则 + +1. **功能分离**: 按照功能模块分类存放脚本 +2. **数据分离**: 配置文件与自动生成文件分开存放 +3. **清晰结构**: 每个文件夹都有明确的职责 +4. **易于维护**: 相关功能的文件集中管理 + +## 📋 自动加载顺序 + +项目中的自动加载脚本按以下顺序加载: +1. `GameData` - 游戏基础数据 +2. `ResourceCategoryManager` - 资源分类管理 +3. `InventoryManager` - 库存管理 +4. `InventoryCategoryManager` - 库存分类管理 + +## 🔄 依赖关系 + +- UI层依赖于数据层和库存层 +- 生产系统依赖于库存系统 +- 所有系统都依赖于核心数据管理器 + +## ⚠️ 重要维护说明 + +### 防止 Translation 文件自动生成 + +Godot 会自动将 CSV 文件识别为本地化资源并生成 `.translation` 文件。为了保持 `data/config/` 文件夹的整洁: + +1. **CSV 导入设置**:确保 `data/config/items.csv.import` 使用 `importer="keep"` +2. **文件夹隔离**:使用 `.gdignore` 文件让 Godot 忽略 `translations/` 和 `imports/` 文件夹 +3. **定期清理**:如果发现 config 文件夹中出现新的 `.translation` 文件,及时删除 + +详细说明请参考 `data/README.md` 文件。 \ No newline at end of file diff --git a/Test.csproj b/Test.csproj new file mode 100644 index 0000000..53cc1f1 --- /dev/null +++ b/Test.csproj @@ -0,0 +1,8 @@ + + + net6.0 + net7.0 + net8.0 + true + + \ No newline at end of file diff --git a/Test.sln b/Test.sln new file mode 100644 index 0000000..91ba11d --- /dev/null +++ b/Test.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test.csproj", "{70D23D50-B427-4816-A2C3-FF2056DA4396}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + ExportDebug|Any CPU = ExportDebug|Any CPU + ExportRelease|Any CPU = ExportRelease|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {70D23D50-B427-4816-A2C3-FF2056DA4396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {70D23D50-B427-4816-A2C3-FF2056DA4396}.Debug|Any CPU.Build.0 = Debug|Any CPU + {70D23D50-B427-4816-A2C3-FF2056DA4396}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU + {70D23D50-B427-4816-A2C3-FF2056DA4396}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU + {70D23D50-B427-4816-A2C3-FF2056DA4396}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU + {70D23D50-B427-4816-A2C3-FF2056DA4396}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU + EndGlobalSection +EndGlobal diff --git a/assets/textures/PixPin_2025-06-15_11-35-40.png b/assets/textures/PixPin_2025-06-15_11-35-40.png new file mode 100644 index 0000000..639e878 Binary files /dev/null and b/assets/textures/PixPin_2025-06-15_11-35-40.png differ diff --git a/assets/textures/PixPin_2025-06-15_11-35-40.png.import b/assets/textures/PixPin_2025-06-15_11-35-40.png.import new file mode 100644 index 0000000..1e3d717 --- /dev/null +++ b/assets/textures/PixPin_2025-06-15_11-35-40.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://x8myw44ubs8k" +path="res://.godot/imported/PixPin_2025-06-15_11-35-40.png-f7908b72324f2ad4749c15407276e01d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/PixPin_2025-06-15_11-35-40.png" +dest_files=["res://.godot/imported/PixPin_2025-06-15_11-35-40.png-f7908b72324f2ad4749c15407276e01d.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/textures/icon.svg b/assets/textures/icon.svg new file mode 100644 index 0000000..9d8b7fa --- /dev/null +++ b/assets/textures/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/textures/icon.svg.import b/assets/textures/icon.svg.import new file mode 100644 index 0000000..f7cddc9 --- /dev/null +++ b/assets/textures/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ddesmcbvjwu20" +path="res://.godot/imported/icon.svg-958a189a5c2fe57391e3d9b3ea181aa4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/icon.svg" +dest_files=["res://.godot/imported/icon.svg-958a189a5c2fe57391e3d9b3ea181aa4.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/data/README.md b/data/README.md new file mode 100644 index 0000000..eaebc92 --- /dev/null +++ b/data/README.md @@ -0,0 +1,59 @@ +# 数据文件夹说明 + +## 📁 文件夹结构 + +### 📁 config/ - 配置文件 +包含游戏的核心配置文件: +- `items.csv` - 物品数据配置 +- `resource_categories.json` - 资源分类配置 +- `inventory_categories.json` - 库存分类配置 +- `items.csv.import` - CSV文件的导入设置 + +### 📁 translations/ - 本地化文件 +存放 Godot 自动生成的本地化文件(.translation)。 +这个文件夹包含 `.gdignore` 文件,告诉 Godot 忽略其中的内容。 + +### 📁 imports/ - 导入配置备份 +存放导入配置文件的备份。 +这个文件夹包含 `.gdignore` 文件,告诉 Godot 忽略其中的内容。 + +## ⚠️ 重要说明 + +### 防止 Translation 文件自动生成 + +如果你发现 `config/` 文件夹中又出现了 `.translation` 文件,说明 CSV 文件的导入设置被重置了。 + +**解决方法:** + +1. 检查 `data/config/items.csv.import` 文件 +2. 确保内容如下: + ``` + [remap] + + importer="keep" + type="" + + [deps] + + source_file="res://data/config/items.csv" + + [params] + ``` + +3. 如果不是这样,请修改为上述内容 +4. 删除任何新生成的 `.translation` 文件: + ```bash + del data\config\*.translation + ``` + +### 为什么会生成 Translation 文件? + +Godot 默认将 CSV 文件识别为本地化资源,会自动生成 `.translation` 文件。 +通过将导入器设置为 "keep",我们告诉 Godot 将 CSV 文件保持原样,不进行特殊处理。 + +## 🔧 维护建议 + +1. **不要手动编辑** `.import` 文件,除非必要 +2. **定期检查** config 文件夹,确保没有新的 translation 文件生成 +3. **备份重要配置** 在修改配置文件前先备份 +4. **使用版本控制** 跟踪配置文件的变化 \ No newline at end of file diff --git a/data/config/crafting_recipes.json b/data/config/crafting_recipes.json new file mode 100644 index 0000000..1b8dc1a --- /dev/null +++ b/data/config/crafting_recipes.json @@ -0,0 +1,17 @@ +{ + "recipes": [ + { + "id": "iron_ingot_smelting", + "outputItem": "iron_ingot", + "outputQuantity": 1, + "craftingMethod": "冶炼", + "craftingTime": 1.0, + "ingredients": [ + { + "itemId": "iron_ore", + "quantity": 1 + } + ] + } + ] +} \ No newline at end of file diff --git a/data/config/inventory_categories.json b/data/config/inventory_categories.json new file mode 100644 index 0000000..9bbd156 --- /dev/null +++ b/data/config/inventory_categories.json @@ -0,0 +1,20 @@ +{ + "categories": [ + { + "categoryName": "原材料", + "items": [ + "iron_ore", + "copper_ore", + "coal_ore", + "water" + ] + }, + { + "categoryName": "炼制成品", + "items": [ + "iron_ingot", + "copper_ingot" + ] + } + ] +} \ No newline at end of file diff --git a/data/config/items.csv b/data/config/items.csv new file mode 100644 index 0000000..bb30920 --- /dev/null +++ b/data/config/items.csv @@ -0,0 +1,13 @@ +Id,Name,Category,Description,Recipe,CraftTime,PowerConsumption,IconPath +iron_ore,铁矿,RawMaterial,基础原材料,可用于冶炼铁块,null,0,0,res://assets/textures/items/iron_ore.png +copper_ore,铜矿,RawMaterial,基础原材料,可用于冶炼铜块,null,0,0,res://assets/textures/items/copper_ore.png +stone_ore,石矿,RawMaterial,基础建筑材料,可用于建造建筑,null,0,0,res://assets/textures/items/stone_ore.png +coal_ore,煤矿,RawMaterial,重要的能源资源,可用于发电,null,0,0,res://assets/textures/items/coal_ore.png +water,水,RawMaterial,基础资源,可用于多种生产,null,0,0,res://assets/textures/items/water.png +crude_oil,原油,RawMaterial,重要的能源资源,可用于生产燃料,null,0,0,res://assets/textures/items/crude_oil.png +iron_ingot,铁块,ProcessedMaterial,由铁矿冶炼而成的基础材料,iron_ore:1,1.0,60.0,res://assets/textures/items/iron_ingot.png +copper_ingot,铜块,ProcessedMaterial,由铜矿冶炼而成的基础材料,copper_ore:1,1.0,60.0,res://assets/textures/items/copper_ingot.png +smelter,冶炼厂,Building,用于冶炼矿石的基础建筑,iron_ingot:4;copper_ingot:2,3.0,360.0,res://assets/textures/buildings/smelter.png +miner,采矿机,Building,自动采集矿石的基础建筑,iron_ingot:3;copper_ingot:1,2.0,420.0,res://assets/textures/buildings/miner.png +assembler,组装机,ProductionDevice,高级生产设备,可制造复杂物品,iron_ingot:6;copper_ingot:4,5.0,480.0,res://assets/textures/buildings/assembler.png +chemical_plant,化工厂,ProductionDevice,专业化工生产设备,可处理液体,iron_ingot:8;copper_ingot:6,6.0,600.0,res://assets/textures/buildings/chemical_plant.png \ No newline at end of file diff --git a/data/config/items.csv.import b/data/config/items.csv.import new file mode 100644 index 0000000..62cf302 --- /dev/null +++ b/data/config/items.csv.import @@ -0,0 +1,10 @@ +[remap] + +importer="keep" +type="" + +[deps] + +source_file="res://data/config/items.csv" + +[params] diff --git a/data/config/resource_categories.json b/data/config/resource_categories.json new file mode 100644 index 0000000..14fc9bc --- /dev/null +++ b/data/config/resource_categories.json @@ -0,0 +1,50 @@ +[ + { + "categoryName": "手动采集", + "itemIds": [ + "iron_ore", + "copper_ore", + "coal_ore", + "stone_ore", + "water", + "crude_oil" + ] + }, + { + "categoryName": "基础资源", + "itemIds": [ + "iron_ore", + "copper_ore", + "stone_ore", + "coal_ore" + ] + }, + { + "categoryName": "液体资源", + "itemIds": [ + "water", + "crude_oil" + ] + }, + { + "categoryName": "冶炼", + "itemIds": [ + "iron_ingot", + "copper_ingot" + ] + }, + { + "categoryName": "建筑设施", + "itemIds": [ + "smelter", + "miner" + ] + }, + { + "categoryName": "生产设备", + "itemIds": [ + "assembler", + "chemical_plant" + ] + } +] \ No newline at end of file diff --git a/data/translations/.gdignore b/data/translations/.gdignore new file mode 100644 index 0000000..e881406 --- /dev/null +++ b/data/translations/.gdignore @@ -0,0 +1,2 @@ +# Godot 会忽略这个文件夹中的所有文件 +# 这些是自动生成的本地化文件,不需要被 Godot 处理 \ No newline at end of file diff --git a/data/translations/items.Category.translation b/data/translations/items.Category.translation new file mode 100644 index 0000000..f361fc5 Binary files /dev/null and b/data/translations/items.Category.translation differ diff --git a/data/translations/items.CraftTime.translation b/data/translations/items.CraftTime.translation new file mode 100644 index 0000000..96833bb Binary files /dev/null and b/data/translations/items.CraftTime.translation differ diff --git a/data/translations/items.Description.translation b/data/translations/items.Description.translation new file mode 100644 index 0000000..3ac27ba Binary files /dev/null and b/data/translations/items.Description.translation differ diff --git a/data/translations/items.IconPath.translation b/data/translations/items.IconPath.translation new file mode 100644 index 0000000..e3121bc Binary files /dev/null and b/data/translations/items.IconPath.translation differ diff --git a/data/translations/items.Name.translation b/data/translations/items.Name.translation new file mode 100644 index 0000000..952d9ed Binary files /dev/null and b/data/translations/items.Name.translation differ diff --git a/data/translations/items.PowerConsumption.translation b/data/translations/items.PowerConsumption.translation new file mode 100644 index 0000000..95bc78a Binary files /dev/null and b/data/translations/items.PowerConsumption.translation differ diff --git a/data/translations/items.Recipe.translation b/data/translations/items.Recipe.translation new file mode 100644 index 0000000..5337296 Binary files /dev/null and b/data/translations/items.Recipe.translation differ diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..01ba086 --- /dev/null +++ b/project.godot @@ -0,0 +1,35 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="test" +run/main_scene="res://scenes/game_scene.tscn" +config/features=PackedStringArray("4.3", "C#", "Forward Plus") +config/icon="res://icon.svg" + +[autoload] + +GameData="*res://scripts/data/GameData.cs" +ResourceCategoryManager="*res://scripts/data/ResourceCategoryManager.cs" +InventoryManager="*res://scripts/inventory/InventoryManager.cs" +InventoryCategoryManager="*res://scripts/inventory/InventoryCategoryManager.cs" +CraftingRecipeManager="*res://scripts/data/CraftingRecipeManager.cs" + +[display] + +window/size/viewport_width=1280 +window/size/viewport_height=720 +window/stretch/mode="canvas_items" +window/stretch/aspect="expand" + +[dotnet] + +project/assembly_name="test" diff --git a/scenes/CraftingItem.tscn b/scenes/CraftingItem.tscn new file mode 100644 index 0000000..94a2ecf --- /dev/null +++ b/scenes/CraftingItem.tscn @@ -0,0 +1,129 @@ +[gd_scene load_steps=3 format=3 uid="uid://bod88mt8ewq2"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_1"] +bg_color = Color(0.12, 0.15, 0.18, 0.95) +border_width_left = 1 +border_width_top = 1 +border_width_right = 1 +border_width_bottom = 1 +border_color = Color(0.25, 0.35, 0.45, 0.8) +corner_radius_top_left = 6 +corner_radius_top_right = 6 +corner_radius_bottom_right = 6 +corner_radius_bottom_left = 6 +shadow_color = Color(0, 0, 0, 0.4) +shadow_size = 3 +shadow_offset = Vector2(1, 2) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_2"] +content_margin_left = 2.0 +content_margin_top = 2.0 +content_margin_right = 2.0 +content_margin_bottom = 2.0 +bg_color = Color(0.2, 0.2, 0.2, 1) +border_width_left = 1 +border_width_top = 1 +border_width_right = 1 +border_width_bottom = 1 +border_color = Color(0.4, 0.4, 0.4, 1) +corner_radius_top_left = 2 +corner_radius_top_right = 2 +corner_radius_bottom_right = 2 +corner_radius_bottom_left = 2 + +[node name="CraftingItem" type="Panel"] +custom_minimum_size = Vector2(220, 52) +theme_override_styles/panel = SubResource("StyleBoxFlat_1") + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 6 +theme_override_constants/margin_top = 4 +theme_override_constants/margin_right = 6 +theme_override_constants/margin_bottom = 4 + +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = 8 + +[node name="IconTexture" type="TextureRect" parent="MarginContainer/HBoxContainer"] +custom_minimum_size = Vector2(32, 32) +layout_mode = 2 +expand_mode = 1 +stretch_mode = 5 + +[node name="MiddleContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_constants/separation = 2 + +[node name="NameLabel" type="Label" parent="MarginContainer/HBoxContainer/MiddleContainer"] +layout_mode = 2 +theme_override_font_sizes/font_size = 12 +text = "物品名称" +vertical_alignment = 1 + +[node name="MaterialsLabel" type="Label" parent="MarginContainer/HBoxContainer/MiddleContainer"] +modulate = Color(0.7, 0.7, 0.7, 1) +layout_mode = 2 +theme_override_font_sizes/font_size = 8 +text = "材料: 1x铁矿" + +[node name="InfoRow" type="HBoxContainer" parent="MarginContainer/HBoxContainer/MiddleContainer"] +layout_mode = 2 +theme_override_constants/separation = 8 + +[node name="CraftTimeLabel" type="Label" parent="MarginContainer/HBoxContainer/MiddleContainer/InfoRow"] +modulate = Color(0.8, 0.9, 1, 1) +layout_mode = 2 +theme_override_font_sizes/font_size = 8 +text = "1.0s" + +[node name="MethodLabel" type="Label" parent="MarginContainer/HBoxContainer/MiddleContainer/InfoRow"] +modulate = Color(1, 0.9, 0.7, 1) +layout_mode = 2 +theme_override_font_sizes/font_size = 8 +text = "手动" + +[node name="RightContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer"] +layout_mode = 2 + +[node name="CraftButton" type="Button" parent="MarginContainer/HBoxContainer/RightContainer"] +custom_minimum_size = Vector2(48, 20) +layout_mode = 2 +size_flags_vertical = 4 +theme_override_font_sizes/font_size = 9 +text = "合成" + +[node name="QuantityContainer" type="HBoxContainer" parent="MarginContainer/HBoxContainer/RightContainer"] +layout_mode = 2 +theme_override_constants/separation = 1 + +[node name="MinusButton" type="Button" parent="MarginContainer/HBoxContainer/RightContainer/QuantityContainer"] +custom_minimum_size = Vector2(18, 16) +layout_mode = 2 +theme_override_font_sizes/font_size = 8 +text = "-" + +[node name="QuantityInput" type="LineEdit" parent="MarginContainer/HBoxContainer/RightContainer/QuantityContainer"] +custom_minimum_size = Vector2(20, 16) +layout_mode = 2 +theme_override_constants/minimum_character_width = 0 +theme_override_font_sizes/font_size = 8 +theme_override_styles/focus = SubResource("StyleBoxFlat_2") +theme_override_styles/normal = SubResource("StyleBoxFlat_2") +text = "1" +placeholder_text = "1" +alignment = 1 +context_menu_enabled = false + +[node name="PlusButton" type="Button" parent="MarginContainer/HBoxContainer/RightContainer/QuantityContainer"] +custom_minimum_size = Vector2(18, 16) +layout_mode = 2 +theme_override_font_sizes/font_size = 8 +text = "+" diff --git a/scenes/CraftingQueue.tscn b/scenes/CraftingQueue.tscn new file mode 100644 index 0000000..a1e2a04 --- /dev/null +++ b/scenes/CraftingQueue.tscn @@ -0,0 +1,69 @@ +[gd_scene load_steps=2 format=3 uid="uid://bvn8xh2ywxe"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_1"] +bg_color = Color(0.15, 0.15, 0.2, 0.8) +border_width_left = 1 +border_width_top = 1 +border_width_right = 1 +border_width_bottom = 1 +border_color = Color(0.3, 0.3, 0.4, 0.6) +corner_radius_top_left = 4 +corner_radius_top_right = 4 +corner_radius_bottom_right = 4 +corner_radius_bottom_left = 4 + +[node name="CraftingQueue" type="Panel"] +custom_minimum_size = Vector2(0, 80) +theme_override_styles/panel = SubResource("StyleBoxFlat_1") + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 8 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 8 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +layout_mode = 2 + +[node name="TitleLabel" type="Label" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "合成队列" +horizontal_alignment = 1 +theme_override_font_sizes/font_size = 12 + +[node name="HSeparator" type="HSeparator" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="QueueContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +theme_override_constants/separation = 4 + +[node name="Slot1" type="Panel" parent="MarginContainer/VBoxContainer/QueueContainer"] +custom_minimum_size = Vector2(48, 48) +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Slot2" type="Panel" parent="MarginContainer/VBoxContainer/QueueContainer"] +custom_minimum_size = Vector2(48, 48) +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Slot3" type="Panel" parent="MarginContainer/VBoxContainer/QueueContainer"] +custom_minimum_size = Vector2(48, 48) +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Slot4" type="Panel" parent="MarginContainer/VBoxContainer/QueueContainer"] +custom_minimum_size = Vector2(48, 48) +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Slot5" type="Panel" parent="MarginContainer/VBoxContainer/QueueContainer"] +custom_minimum_size = Vector2(48, 48) +layout_mode = 2 +size_flags_horizontal = 3 \ No newline at end of file diff --git a/scenes/InventoryItem.tscn b/scenes/InventoryItem.tscn new file mode 100644 index 0000000..b1ff1de --- /dev/null +++ b/scenes/InventoryItem.tscn @@ -0,0 +1,64 @@ +[gd_scene load_steps=2 format=3 uid="uid://b3sb2a63y77ra"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_1"] +bg_color = Color(0.2, 0.2, 0.2, 0.8) +corner_radius_top_left = 4 +corner_radius_top_right = 4 +corner_radius_bottom_right = 4 +corner_radius_bottom_left = 4 + +[node name="InventoryItem" type="Control"] +custom_minimum_size = Vector2(0, 35) +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 3 + +[node name="Background" type="Panel" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_1") + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 6 +theme_override_constants/margin_top = 3 +theme_override_constants/margin_right = 6 +theme_override_constants/margin_bottom = 3 + +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = 6 + +[node name="IconTexture" type="TextureRect" parent="MarginContainer/HBoxContainer"] +custom_minimum_size = Vector2(24, 24) +layout_mode = 2 +expand_mode = 1 +stretch_mode = 5 + +[node name="NameLabel" type="Label" parent="MarginContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_font_sizes/font_size = 11 +text = "物品名称" +vertical_alignment = 1 + +[node name="QuantityLabel" type="Label" parent="MarginContainer/HBoxContainer"] +custom_minimum_size = Vector2(30, 0) +layout_mode = 2 +theme_override_font_sizes/font_size = 11 +text = "999" +horizontal_alignment = 2 +vertical_alignment = 1 diff --git a/scenes/ItemPanel.tscn b/scenes/ItemPanel.tscn new file mode 100644 index 0000000..38aa9ca --- /dev/null +++ b/scenes/ItemPanel.tscn @@ -0,0 +1,127 @@ +[gd_scene load_steps=3 format=3 uid="uid://cihq67dbb8q7m"] + +[ext_resource type="Texture2D" uid="uid://x8myw44ubs8k" path="res://assets/textures/PixPin_2025-06-15_11-35-40.png" id="1_1w476"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_1"] +bg_color = Color(0.15, 0.15, 0.2, 0.95) +border_width_left = 1 +border_width_top = 1 +border_width_right = 1 +border_width_bottom = 1 +border_color = Color(0.3, 0.3, 0.4, 0.8) +corner_radius_top_left = 6 +corner_radius_top_right = 6 +corner_radius_bottom_right = 6 +corner_radius_bottom_left = 6 +shadow_color = Color(0, 0, 0, 0.3) +shadow_size = 2 +shadow_offset = Vector2(1, 1) + +[node name="ItemPanel" type="Panel"] +custom_minimum_size = Vector2(250, 64) +theme_override_styles/panel = SubResource("StyleBoxFlat_1") + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 5 +theme_override_constants/margin_top = 4 +theme_override_constants/margin_right = 5 +theme_override_constants/margin_bottom = 4 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +layout_mode = 2 + +[node name="TopRow" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="IconTexture" type="TextureRect" parent="MarginContainer/VBoxContainer/TopRow"] +custom_minimum_size = Vector2(36, 36) +layout_mode = 2 +texture = ExtResource("1_1w476") +expand_mode = 1 +stretch_mode = 5 + +[node name="MiddleContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/TopRow"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="TopInfoRow" type="HBoxContainer" parent="MarginContainer/VBoxContainer/TopRow/MiddleContainer"] +layout_mode = 2 + +[node name="NameLabel" type="Label" parent="MarginContainer/VBoxContainer/TopRow/MiddleContainer/TopInfoRow"] +layout_mode = 2 +theme_override_font_sizes/font_size = 11 +text = "物品名称" + +[node name="ProductionLabel" type="Label" parent="MarginContainer/VBoxContainer/TopRow/MiddleContainer/TopInfoRow"] +modulate = Color(0.8, 0.8, 0.8, 1) +layout_mode = 2 +theme_override_font_sizes/font_size = 9 +text = "50/s" + +[node name="Spacer" type="Control" parent="MarginContainer/VBoxContainer/TopRow/MiddleContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="RightContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/TopRow"] +layout_mode = 2 + +[node name="PowerLabel" type="Label" parent="MarginContainer/VBoxContainer/TopRow/RightContainer"] +modulate = Color(1, 0.8, 0.8, 1) +layout_mode = 2 +theme_override_font_sizes/font_size = 8 +text = "-300W" +horizontal_alignment = 2 + +[node name="RightSpacer" type="Control" parent="MarginContainer/VBoxContainer/TopRow/RightContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="BottomDeviceRow" type="HBoxContainer" parent="MarginContainer/VBoxContainer/TopRow/RightContainer"] +layout_mode = 2 + +[node name="MinusButton" type="Button" parent="MarginContainer/VBoxContainer/TopRow/RightContainer/BottomDeviceRow"] +custom_minimum_size = Vector2(16, 16) +layout_mode = 2 +theme_override_font_sizes/font_size = 10 +text = "-" + +[node name="DeviceLabel" type="Label" parent="MarginContainer/VBoxContainer/TopRow/RightContainer/BottomDeviceRow"] +modulate = Color(0.7, 0.7, 0.7, 1) +layout_mode = 2 +theme_override_font_sizes/font_size = 8 +text = "设备: 5" + +[node name="PlusButton" type="Button" parent="MarginContainer/VBoxContainer/TopRow/RightContainer/BottomDeviceRow"] +custom_minimum_size = Vector2(16, 16) +layout_mode = 2 +theme_override_font_sizes/font_size = 10 +text = "+" + +[node name="ProgressContainer" type="Control" parent="MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(0, 5) +layout_mode = 2 +size_flags_vertical = 0 + +[node name="ProgressBackground" type="ColorRect" parent="MarginContainer/VBoxContainer/ProgressContainer"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0.2, 0.2, 0.2, 1) + +[node name="ProgressFill" type="ColorRect" parent="MarginContainer/VBoxContainer/ProgressContainer"] +layout_mode = 1 +anchors_preset = -1 +anchor_right = 0.65 +anchor_bottom = 1.0 +grow_vertical = 2 +color = Color(0.3, 0.7, 0.3, 1) diff --git a/scenes/game_scene.tscn b/scenes/game_scene.tscn new file mode 100644 index 0000000..0669487 --- /dev/null +++ b/scenes/game_scene.tscn @@ -0,0 +1,228 @@ +[gd_scene load_steps=5 format=3 uid="uid://bw51wdor6ucmk"] + +[ext_resource type="Script" path="res://scripts/core/GameScene.cs" id="1_2k4vx"] +[ext_resource type="Script" path="res://scripts/ui/DynamicTabManager.cs" id="2_3k5vy"] +[ext_resource type="Script" path="res://scripts/inventory/InventoryTableManager.cs" id="3_inventory_table"] +[ext_resource type="Script" path="res://scripts/production/CraftingQueueManager.cs" id="4_crafting_queue"] + +[node name="GameScene" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_2k4vx") + +[node name="Background" type="ColorRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0.1, 0.1, 0.15, 1) + +[node name="HSplitContainer" type="HSplitContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +split_offset = 230 + +[node name="LeftPanel" type="Panel" parent="HSplitContainer"] +custom_minimum_size = Vector2(276, 0) +layout_mode = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/LeftPanel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="PowerInfo" type="Panel" parent="HSplitContainer/LeftPanel/VBoxContainer"] +custom_minimum_size = Vector2(0, 100) +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="HSplitContainer/LeftPanel/VBoxContainer/PowerInfo"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 10 + +[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/LeftPanel/VBoxContainer/PowerInfo/MarginContainer"] +layout_mode = 2 + +[node name="PowerTitle" type="Label" parent="HSplitContainer/LeftPanel/VBoxContainer/PowerInfo/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "电力系统" +horizontal_alignment = 1 + +[node name="HSeparator" type="HSeparator" parent="HSplitContainer/LeftPanel/VBoxContainer/PowerInfo/MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="PowerRow1" type="HBoxContainer" parent="HSplitContainer/LeftPanel/VBoxContainer/PowerInfo/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="PowerGeneration" type="Label" parent="HSplitContainer/LeftPanel/VBoxContainer/PowerInfo/MarginContainer/VBoxContainer/PowerRow1"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "发电: 0 KW" + +[node name="PowerConsumption" type="Label" parent="HSplitContainer/LeftPanel/VBoxContainer/PowerInfo/MarginContainer/VBoxContainer/PowerRow1"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "耗电: 0 KW" + +[node name="PowerRow2" type="HBoxContainer" parent="HSplitContainer/LeftPanel/VBoxContainer/PowerInfo/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="PowerStorage" type="Label" parent="HSplitContainer/LeftPanel/VBoxContainer/PowerInfo/MarginContainer/VBoxContainer/PowerRow2"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "蓄电: 0 KWh" + +[node name="PowerDischarge" type="Label" parent="HSplitContainer/LeftPanel/VBoxContainer/PowerInfo/MarginContainer/VBoxContainer/PowerRow2"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "放电: 0 KW" + +[node name="CraftingQueue" type="Panel" parent="HSplitContainer/LeftPanel/VBoxContainer"] +custom_minimum_size = Vector2(0, 80) +layout_mode = 2 +script = ExtResource("4_crafting_queue") + +[node name="MarginContainer" type="MarginContainer" parent="HSplitContainer/LeftPanel/VBoxContainer/CraftingQueue"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 8 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 8 + +[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/LeftPanel/VBoxContainer/CraftingQueue/MarginContainer"] +layout_mode = 2 + +[node name="TitleLabel" type="Label" parent="HSplitContainer/LeftPanel/VBoxContainer/CraftingQueue/MarginContainer/VBoxContainer"] +layout_mode = 2 +theme_override_font_sizes/font_size = 12 +text = "合成队列" +horizontal_alignment = 1 + +[node name="HSeparator" type="HSeparator" parent="HSplitContainer/LeftPanel/VBoxContainer/CraftingQueue/MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="QueueContainer" type="HBoxContainer" parent="HSplitContainer/LeftPanel/VBoxContainer/CraftingQueue/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +theme_override_constants/separation = 2 + +[node name="Slot1" type="Panel" parent="HSplitContainer/LeftPanel/VBoxContainer/CraftingQueue/MarginContainer/VBoxContainer/QueueContainer"] +custom_minimum_size = Vector2(30, 30) +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Slot2" type="Panel" parent="HSplitContainer/LeftPanel/VBoxContainer/CraftingQueue/MarginContainer/VBoxContainer/QueueContainer"] +custom_minimum_size = Vector2(30, 30) +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Slot3" type="Panel" parent="HSplitContainer/LeftPanel/VBoxContainer/CraftingQueue/MarginContainer/VBoxContainer/QueueContainer"] +custom_minimum_size = Vector2(30, 30) +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Slot4" type="Panel" parent="HSplitContainer/LeftPanel/VBoxContainer/CraftingQueue/MarginContainer/VBoxContainer/QueueContainer"] +custom_minimum_size = Vector2(30, 30) +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Slot5" type="Panel" parent="HSplitContainer/LeftPanel/VBoxContainer/CraftingQueue/MarginContainer/VBoxContainer/QueueContainer"] +custom_minimum_size = Vector2(30, 30) +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Slot6" type="Panel" parent="HSplitContainer/LeftPanel/VBoxContainer/CraftingQueue/MarginContainer/VBoxContainer/QueueContainer"] +custom_minimum_size = Vector2(30, 30) +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Slot7" type="Panel" parent="HSplitContainer/LeftPanel/VBoxContainer/CraftingQueue/MarginContainer/VBoxContainer/QueueContainer"] +custom_minimum_size = Vector2(30, 30) +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Slot8" type="Panel" parent="HSplitContainer/LeftPanel/VBoxContainer/CraftingQueue/MarginContainer/VBoxContainer/QueueContainer"] +custom_minimum_size = Vector2(30, 30) +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="InventoryPanel" type="Panel" parent="HSplitContainer/LeftPanel/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="MarginContainer" type="MarginContainer" parent="HSplitContainer/LeftPanel/VBoxContainer/InventoryPanel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 10 + +[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/LeftPanel/VBoxContainer/InventoryPanel/MarginContainer"] +layout_mode = 2 + +[node name="InventoryTitle" type="Label" parent="HSplitContainer/LeftPanel/VBoxContainer/InventoryPanel/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "库存" +horizontal_alignment = 1 + +[node name="HSeparator" type="HSeparator" parent="HSplitContainer/LeftPanel/VBoxContainer/InventoryPanel/MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="ScrollContainer" type="ScrollContainer" parent="HSplitContainer/LeftPanel/VBoxContainer/InventoryPanel/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +horizontal_scroll_mode = 0 + +[node name="InventoryTableManager" type="VBoxContainer" parent="HSplitContainer/LeftPanel/VBoxContainer/InventoryPanel/MarginContainer/VBoxContainer/ScrollContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +script = ExtResource("3_inventory_table") + +[node name="RightPanel" type="Panel" parent="HSplitContainer"] +layout_mode = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/RightPanel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="CategoryTabs" type="TabContainer" parent="HSplitContainer/RightPanel/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +theme_override_font_sizes/font_size = 24 +script = ExtResource("2_3k5vy") diff --git a/scenes/main_menu.tscn b/scenes/main_menu.tscn new file mode 100644 index 0000000..1017746 --- /dev/null +++ b/scenes/main_menu.tscn @@ -0,0 +1,70 @@ +[gd_scene load_steps=2 format=3 uid="uid://dc48a40brl4hm"] + +[ext_resource type="Script" path="res://scripts/MainMenu.cs" id="1_3k4vx"] + +[node name="MainMenu" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_3k4vx") + +[node name="Background" type="ColorRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0.15, 0.15, 0.25, 1) + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -120.0 +offset_top = -150.0 +offset_right = 120.0 +offset_bottom = 150.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Title" type="Label" parent="VBoxContainer"] +layout_mode = 2 +text = "游戏主菜单" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Spacer1" type="Control" parent="VBoxContainer"] +custom_minimum_size = Vector2(0, 30) +layout_mode = 2 + +[node name="NewGameBtn" type="Button" parent="VBoxContainer"] +custom_minimum_size = Vector2(240, 50) +layout_mode = 2 +text = "新游戏" + +[node name="LoadGameBtn" type="Button" parent="VBoxContainer"] +custom_minimum_size = Vector2(240, 50) +layout_mode = 2 +text = "载入存档" + +[node name="SettingsBtn" type="Button" parent="VBoxContainer"] +custom_minimum_size = Vector2(240, 50) +layout_mode = 2 +text = "设置" + +[node name="ExitBtn" type="Button" parent="VBoxContainer"] +custom_minimum_size = Vector2(240, 50) +layout_mode = 2 +text = "退出游戏" + +[connection signal="pressed" from="VBoxContainer/NewGameBtn" to="." method="_OnNewGameBtnPressed"] +[connection signal="pressed" from="VBoxContainer/LoadGameBtn" to="." method="_OnLoadGameBtnPressed"] +[connection signal="pressed" from="VBoxContainer/SettingsBtn" to="." method="_OnSettingsBtnPressed"] +[connection signal="pressed" from="VBoxContainer/ExitBtn" to="." method="_OnExitBtnPressed"] diff --git a/scenes/ss b/scenes/ss new file mode 100644 index 0000000..0069ab9 --- /dev/null +++ b/scenes/ss @@ -0,0 +1,64 @@ +[gd_scene format=3] + +[node name="ItemPanel" type="Panel"] +custom_minimum_size = Vector2(320, 60) + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="Icon" type="TextureRect" parent="HBoxContainer"] +custom_minimum_size = Vector2(48, 48) +expand = true +stretch_mode = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"] + +[node name="TopRow" type="HBoxContainer" parent="HBoxContainer/VBoxContainer"] + +[node name="NameLabel" type="Label" parent="HBoxContainer/VBoxContainer/TopRow"] +text = "物品名称 50/s" +custom_colors/font_color = Color(1, 0.85, 0.3) +theme_override_font_sizes/font_size = 18 + +[node name="PowerIcon" type="TextureRect" parent="HBoxContainer/VBoxContainer/TopRow"] +custom_minimum_size = Vector2(20, 20) +expand = false +stretch_mode = 2 + +[node name="PowerLabel" type="Label" parent="HBoxContainer/VBoxContainer/TopRow"] +text = "-360.0W" +custom_colors/font_color = Color(0.7, 0.9, 1) +theme_override_font_sizes/font_size = 14 + +[node name="RecipeRow" type="HBoxContainer" parent="HBoxContainer/VBoxContainer"] + +[node name="EqualIcon" type="TextureRect" parent="HBoxContainer/VBoxContainer/RecipeRow"] +custom_minimum_size = Vector2(16, 16) +expand = false +stretch_mode = 2 + +[node name="MaterialIcon" type="TextureRect" parent="HBoxContainer/VBoxContainer/RecipeRow"] +custom_minimum_size = Vector2(32, 32) +expand = false +stretch_mode = 2 + +[node name="ControlRow" type="HBoxContainer" parent="HBoxContainer/VBoxContainer"] + +[node name="MinusButton" type="Button" parent="HBoxContainer/VBoxContainer/ControlRow"] +text = "-" +custom_minimum_size = Vector2(32, 32) + +[node name="CountEdit" type="LineEdit" parent="HBoxContainer/VBoxContainer/ControlRow"] +text = "50" +custom_minimum_size = Vector2(48, 32) + +[node name="PlusButton" type="Button" parent="HBoxContainer/VBoxContainer/ControlRow"] +text = "+" +custom_minimum_size = Vector2(32, 32) + +[node name="ProgressBar" type="ProgressBar" parent="HBoxContainer/VBoxContainer"] +custom_minimum_size = Vector2(200, 8) +value = 50 +max_value = 100 \ No newline at end of file diff --git a/scenes/test.tscn b/scenes/test.tscn new file mode 100644 index 0000000..eb47169 --- /dev/null +++ b/scenes/test.tscn @@ -0,0 +1,26 @@ +[gd_scene format=3 uid="uid://b8kwq742j0g41"] + +[node name="Test" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 0 +offset_right = 183.0 +offset_bottom = 40.0 +alignment = 1 + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +text = "test" + +[node name="HSeparator" type="HSeparator" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 diff --git a/scripts/core/GameScene.cs b/scripts/core/GameScene.cs new file mode 100644 index 0000000..e779a30 --- /dev/null +++ b/scripts/core/GameScene.cs @@ -0,0 +1,136 @@ +using Godot; +using System; +using System.Collections.Generic; + +public partial class GameScene : Control +{ + // 资源类型枚举 + public enum ResourceType + { + IronOre, + CopperOre, + IronIngot, + CopperIngot + } + + // 资源数据结构 + public class ResourceData + { + public string Name { get; set; } + public int Amount { get; set; } + public ResourceType Type { get; set; } + public bool IsProcessed { get; set; } + } + + // 电力系统数据 + private float powerGeneration = 0; + private float powerConsumption = 0; + private float powerStorage = 0; + private float powerDischarge = 0; + + // 库存数据(保留用于兼容性,但主要由InventoryManager管理) + private Dictionary inventory = new Dictionary(); + + // UI引用 + private Label powerGenerationLabel; + private Label powerConsumptionLabel; + private Label powerStorageLabel; + private Label powerDischargeLabel; + private TabContainer categoryTabs; + private CraftingQueueManager craftingQueue; + + public override void _Ready() + { + GD.Print("GameScene _Ready 开始"); + + // 获取UI引用 + powerGenerationLabel = GetNode