diff --git a/locals/UI.csv b/locals/UI.csv index 68564bb..8aaf0d3 100644 --- a/locals/UI.csv +++ b/locals/UI.csv @@ -17,4 +17,5 @@ create_room,创建房间,Create room,部屋を作ります close,关闭,Close,閉じます name,名称,Name,めいしょう describe,描述,Describe,ないよう -creation,创建,Creation,創建 \ No newline at end of file +creation,创建,Creation,創建 +default_room_name,房间{0},Room{0},部屋{0}です \ No newline at end of file diff --git a/locals/UI.en.translation b/locals/UI.en.translation index 1b26b39..91a4ec6 100644 Binary files a/locals/UI.en.translation and b/locals/UI.en.translation differ diff --git a/locals/UI.jp.translation b/locals/UI.jp.translation index b8e9d14..4d09760 100644 Binary files a/locals/UI.jp.translation and b/locals/UI.jp.translation differ diff --git a/locals/UI.zh.translation b/locals/UI.zh.translation index d44c8f1..4acfcee 100644 Binary files a/locals/UI.zh.translation and b/locals/UI.zh.translation differ diff --git a/locals/slogan.csv b/locals/slogan.csv index 9cc5764..76d8dd3 100644 --- a/locals/slogan.csv +++ b/locals/slogan.csv @@ -2,5 +2,5 @@ id,zh,en,jp slogan_1,游戏属于每一个人。,The game belongs to everyone.,ゲームはすべての人のものです。 slogan_2,如果你想要得到爱,你就播种爱。,"If you want love, you sow love.",愛を手に入れたければ、愛の種をまきます。 slogan_3,快乐?伤心?痛苦?,Happy? Sad? Pain?,楽しいですか?悲しいですか?苦しいですか? -slogan_4,0001 0011 0001 0101 0100 1111 0100,0001 0011 0001 0101 0100 1111 0100,0001 0011 0001 0101 0100 1111 0100 -slogan_5,kaWaYi!,kaWaYi!,kaWaYi! \ No newline at end of file +slogan_4,kaWaYi!,kaWaYi!,kaWaYi! +slogan_5,魔法是想象的世界。,Magic is an imaginary world.,魔法は想像の世界です。 \ No newline at end of file diff --git a/locals/slogan.en.translation b/locals/slogan.en.translation index d62e5db..bb72914 100644 Binary files a/locals/slogan.en.translation and b/locals/slogan.en.translation differ diff --git a/locals/slogan.jp.translation b/locals/slogan.jp.translation index c982d2c..384a262 100644 Binary files a/locals/slogan.jp.translation and b/locals/slogan.jp.translation differ diff --git a/locals/slogan.zh.translation b/locals/slogan.zh.translation index 110a195..ca53706 100644 Binary files a/locals/slogan.zh.translation and b/locals/slogan.zh.translation differ diff --git a/prefab/ui/RoomNode.tscn b/prefab/ui/RoomNode.tscn index f95ef32..89f86c0 100644 --- a/prefab/ui/RoomNode.tscn +++ b/prefab/ui/RoomNode.tscn @@ -3,6 +3,19 @@ [ext_resource type="Script" path="res://scripts/levelGraphEditor/RoomNode.cs" id="1_jiu7r"] [node name="RoomNode" type="GraphNode"] -offset_right = 571.0 -offset_bottom = 253.0 +offset_right = 363.0 +offset_bottom = 218.0 +slot/0/left_enabled = true +slot/0/left_type = 0 +slot/0/left_color = Color(1, 1, 1, 1) +slot/0/left_icon = null +slot/0/right_enabled = true +slot/0/right_type = 0 +slot/0/right_color = Color(1, 1, 1, 1) +slot/0/right_icon = null +slot/0/draw_stylebox = true script = ExtResource("1_jiu7r") + +[node name="DescribeLabel" type="Label" parent="."] +layout_mode = 2 +text = "describe" diff --git a/scenes/LevelGraphEditor.tscn b/scenes/LevelGraphEditor.tscn index 59147c1..223f54b 100644 --- a/scenes/LevelGraphEditor.tscn +++ b/scenes/LevelGraphEditor.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://ckl23uwxrjat4"] -[ext_resource type="Script" path="res://scripts/loader/uiLoader/LevelGraphEditorLoader.cs" id="1_7nyq6"] +[ext_resource type="Script" path="res://scripts/loader/uiLoader/LevelGraphEditorLoader.cs" id="1_g1axq"] [node name="LevelGraphEditor" type="Control"] layout_mode = 3 @@ -9,15 +9,17 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -script = ExtResource("1_7nyq6") +script = ExtResource("1_g1axq") [node name="GraphEdit" type="GraphEdit" parent="."] -visible = false layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_top = 39.0 +offset_left = 12.0 +offset_top = 52.0 +offset_right = -16.0 +offset_bottom = -13.0 grow_horizontal = 2 grow_vertical = 2 show_grid = false @@ -33,79 +35,104 @@ offset_bottom = 32.0 text = "level_graph_editor" [node name="CreateOrEditorPanel" type="Panel" parent="."] +visible = false layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_left = 45.0 -offset_top = 42.0 -offset_right = -39.0 -offset_bottom = -45.0 +offset_left = 15.0 +offset_top = 44.0 +offset_right = -16.0 +offset_bottom = -15.0 grow_horizontal = 2 grow_vertical = 2 [node name="Label" type="Label" parent="CreateOrEditorPanel"] -layout_mode = 0 -offset_left = 15.0 -offset_top = 11.0 -offset_right = 102.0 -offset_bottom = 36.0 +layout_mode = 1 +offset_left = 10.0 +offset_top = 13.0 +offset_right = 97.0 +offset_bottom = 38.0 text = "create_room" [node name="Label3" type="Label" parent="CreateOrEditorPanel"] -layout_mode = 0 -offset_left = 7.0 -offset_top = 109.0 -offset_right = 94.0 -offset_bottom = 134.0 +layout_mode = 1 +offset_left = 12.0 +offset_top = 106.0 +offset_right = 72.0 +offset_bottom = 131.0 text = "describe" [node name="RoomNameLineEdit" type="LineEdit" parent="CreateOrEditorPanel"] -layout_mode = 0 -offset_left = 75.0 -offset_top = 54.0 -offset_right = 1053.0 -offset_bottom = 87.0 +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_left = 100.0 +offset_top = 59.0 +offset_right = -8.0 +offset_bottom = 92.0 +grow_horizontal = 2 [node name="RoomDescriptionLineEdit" type="LineEdit" parent="CreateOrEditorPanel"] -layout_mode = 0 -offset_left = 82.0 -offset_top = 108.0 -offset_right = 1060.0 -offset_bottom = 141.0 +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_left = 100.0 +offset_top = 104.0 +offset_right = -8.0 +offset_bottom = 137.0 +grow_horizontal = 2 [node name="HideCreateRoomPanelButton" type="Button" parent="CreateOrEditorPanel"] layout_mode = 1 anchors_preset = 1 anchor_left = 1.0 anchor_right = 1.0 -offset_left = -46.0 -offset_bottom = 33.0 +offset_left = -57.0 +offset_top = 6.0 +offset_right = -11.0 +offset_bottom = 39.0 grow_horizontal = 0 text = "close" [node name="Label2" type="Label" parent="CreateOrEditorPanel"] -layout_mode = 0 -offset_left = 22.0 -offset_top = 56.0 -offset_right = 62.0 -offset_bottom = 81.0 +layout_mode = 1 +offset_left = 13.0 +offset_top = 60.0 +offset_right = 48.0 +offset_bottom = 85.0 text = "name" [node name="CreateRoomButton" type="Button" parent="CreateOrEditorPanel"] -layout_mode = 0 -offset_left = 972.0 -offset_top = 507.0 -offset_right = 1039.0 -offset_bottom = 540.0 +layout_mode = 1 +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -80.0 +offset_top = -46.0 +offset_right = -13.0 +offset_bottom = -13.0 +grow_horizontal = 0 +grow_vertical = 0 text = "creation" -[node name="ShowCreateRoomPanelButton" type="Button" parent="."] +[node name="HBoxContainer" type="HBoxContainer" parent="."] layout_mode = 1 anchors_preset = 1 anchor_left = 1.0 anchor_right = 1.0 -offset_left = -95.0 -offset_bottom = 33.0 +offset_left = -160.0 +offset_top = 4.0 +offset_right = -15.0 +offset_bottom = 47.0 grow_horizontal = 0 + +[node name="ShowCreateRoomPanelButton" type="Button" parent="HBoxContainer"] +layout_mode = 2 text = "create_room" + +[node name="ReturnButton" type="Button" parent="HBoxContainer"] +layout_mode = 2 +text = "close" diff --git a/scripts/SloganProvider.cs b/scripts/SloganProvider.cs index 2e2650f..eab2e37 100644 --- a/scripts/SloganProvider.cs +++ b/scripts/SloganProvider.cs @@ -1,4 +1,7 @@ -using Godot; +using System.Collections.Generic; +using System.IO; +using Godot; +using FileAccess = Godot.FileAccess; namespace ColdMint.scripts; @@ -8,19 +11,55 @@ namespace ColdMint.scripts; /// public static class SloganProvider { + private static string _csvPath = "res://locals/slogan.csv"; + + private static string[]? _sloganKeys; + /// - /// Define how many banners you want to display - /// 定义共有多少条标语需要展示 + /// Loading CSV file + /// 加载CSV文件 /// - private const int Total = 5; + public static void LoadSloganCsv() + { + var exists = FileAccess.FileExists(_csvPath); + if (!exists) + { + return; + } + + using var file = FileAccess.Open(_csvPath, FileAccess.ModeFlags.Read); + var content = file.GetAsText(); + var lineStrings = content.Split('\n'); + var keys = new List(); + foreach (var lineString in lineStrings) + { + var index = lineString.IndexOf(','); + if (index > -1) + { + keys.Add(lineString[..index]); + } + } + + if (keys.Count > 0) + { + keys.RemoveAt(0); + } + + _sloganKeys = keys.ToArray(); + } /// /// Swipe the machine to get a slogan /// 刷机获取一个标语 /// /// - public static string GetSlogan() + public static string? GetSlogan() { - return TranslationServer.Translate("slogan_" + GD.RandRange(1, Total)); + if (_sloganKeys == null || _sloganKeys.Length == 0) + { + return null; + } + + return TranslationServer.Translate(_sloganKeys[GD.Randi() % _sloganKeys.Length]); } } \ No newline at end of file diff --git a/scripts/levelGraphEditor/RoomNode.cs b/scripts/levelGraphEditor/RoomNode.cs index 89a5054..8964274 100644 --- a/scripts/levelGraphEditor/RoomNode.cs +++ b/scripts/levelGraphEditor/RoomNode.cs @@ -4,5 +4,34 @@ namespace ColdMint.scripts.levelGraphEditor; public partial class RoomNode : GraphNode { + private Label? _describeLabel; + private IRoomNodeData? _roomNodeData; + + public IRoomNodeData? RoomNodeData + { + get => _roomNodeData; + set + { + if (_describeLabel == null || value == null) return; + Title = value.Title; + if (value.Description.Length == 0) + { + _describeLabel.Visible = false; + } + else + { + _describeLabel.Visible = true; + _describeLabel.Text = value.Description; + } + + _roomNodeData = value; + } + } + + public override void _Ready() + { + base._Ready(); + _describeLabel = GetNode