From 968fa7d7234d66cc1795fc7de513773759e78e6c Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Sun, 12 May 2024 23:06:07 +0800 Subject: [PATCH] =?UTF-8?q?Support=20for=20connecting=20nodes.=20Adding=20?= =?UTF-8?q?taglines=20does=20not=20require=20changing=20random=20ranges=20?= =?UTF-8?q?in=20the=20code.=20=E6=94=AF=E6=8C=81=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E4=BA=86=E3=80=82=E6=B7=BB=E5=8A=A0=E6=A0=87?= =?UTF-8?q?=E8=AF=AD=E6=97=A0=E9=9C=80=E5=88=B0=E4=BB=A3=E7=A0=81=E5=86=85?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=9A=8F=E6=9C=BA=E8=8C=83=E5=9B=B4=E4=BA=86?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locals/UI.csv | 3 +- locals/UI.en.translation | Bin 1138 -> 1162 bytes locals/UI.jp.translation | Bin 1305 -> 1337 bytes locals/UI.zh.translation | Bin 1161 -> 1189 bytes locals/slogan.csv | 4 +- locals/slogan.en.translation | Bin 650 -> 634 bytes locals/slogan.jp.translation | Bin 769 -> 769 bytes locals/slogan.zh.translation | Bin 481 -> 701 bytes prefab/ui/RoomNode.tscn | 17 ++- scenes/LevelGraphEditor.tscn | 113 +++++++++++------- scripts/SloganProvider.cs | 51 +++++++- scripts/levelGraphEditor/RoomNode.cs | 29 +++++ .../loader/uiLoader/LevelGraphEditorLoader.cs | 45 ++++++- scripts/loader/uiLoader/MainMenuLoader.cs | 14 +-- 14 files changed, 211 insertions(+), 65 deletions(-) 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 1b26b391e73160d27bb3e91d49b2fbc2c6549dc3..91a4ec6952ebb51aca975098f960f96842f5a5a4 100644 GIT binary patch delta 145 zcmeyw(Z#tznvvDWurw!QvI1k0sT~6Yg9{LQ0r7t*2tZg1bb&M%6l*NK%>$C)0P;B|&u2Q!$gw$@nVC@}C_g{9+Mt$!9Vh|P J7!(}j3;^PGCnW#? delta 121 zcmeC;{KTb%7 diff --git a/locals/UI.jp.translation b/locals/UI.jp.translation index b8e9d1491a26c63460f68a38b235b4541a6528e2..4d09760515d7d83799096413d4adff7a4ba5e5fd 100644 GIT binary patch delta 155 zcmbQqwUcXuG$U(%c}1$hWCg}TQ#%F*1{Waq0^-xMDArhdn`atOLIB7Yn7oeZFype#Ma(l9+MxDv UC^*O&0BFlFIRF3v delta 123 zcmdnVHIr+DG$U(@L8(dlWCg}TQ!54r1_vN^1LFTs;Df{t0g1G=MZO6l*NK&BG3q-~#fwCa+^U%qY0Ih?$E~@>$3Jm(#aY8`J_N O7}$Xrq&p}$$Qb~%Un$-I delta 122 zcmZ3=*~z&@I$4;>*2=)Z pz)%5*K?I0p2q6p<41oZ|HDJh23{Q;AR0L{dU9(h diff --git a/locals/slogan.jp.translation b/locals/slogan.jp.translation index c982d2ceede9e47d43d20b4e582893bbe622fdcd..384a262296f338beca369493736fea182faf5da8 100644 GIT binary patch delta 130 zcmZo*O%y@pX64MIv?8NZI$V^3smusgy+dTDg;3PLx$p(@DhS$1TBc@9eom9BsZCpuj1_@SkYA}U z6#DI^O1vi;(ODPeqWxJAsumR^h%*sJg=`0Or1x(Pij{x!wHP-7stcvlQthA>(Dp=i z^8R%Kk#0ol22!B153cOZ7;FrrVpLWs&}>K z*t3p(?qo7gv-8YN&3lIj&fT%MaPyp+bMJTD#I>JD=dwvi_d4xuT>57#F!}6<3+Hw{ zmpyW_r|!c7I{wc7^KuFuHpNHysMf(=E;qfKEpPXVR!pDxdy9^}?QbP%KFdDpp+i4Y9Fpq49vKfPU)9h!Z0fBtj4isM2yf zZv=HlEFBQ#0|PH0V1hwLb_dl3*gE_<5I$FoFeKiII6KkW38R(SN-vsiOX5j`Y>NJPvAK#>I)*u3_q?_f2$gFeQd2`il?l+` 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