Minor Scene and GUI cleanup.

WorldChunkRefactoring
Martin Felis 2023-06-11 12:45:09 +02:00
parent 4b153bb6b5
commit 6afc0f3424
2 changed files with 180 additions and 159 deletions

View File

@ -43,29 +43,36 @@ public class Game : Spatial
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
// debugStatsContainer
Container debugStatsContainer = (Container) FindNode("DebugStatsContainer");
_framesPerSecondLabel = debugStatsContainer.GetNode<Label>("fps_label");
_tileLabel = debugStatsContainer.GetNode<Label>("tile_label");
_tileOffsetLabel = debugStatsContainer.GetNode<Label>("tile_offset_label");
_numTilesLabel = debugStatsContainer.GetNode<Label>("num_tiles_label");
_mouseWorldLabel = debugStatsContainer.GetNode<Label>("mouse_world_label");
_mouseTileLabel = debugStatsContainer.GetNode<Label>("mouse_tile_label");
_numCoordsAddedLabel = debugStatsContainer.GetNode<Label>("num_coords_added_label");
_numCoordsRemovedLabel = debugStatsContainer.GetNode<Label>("num_coords_removed_label");
// UI elements
_framesPerSecondLabel = GetNode<Label>("Control/HBoxContainer/GridContainer/fps_label");
_tileLabel = GetNode<Label>("Control/HBoxContainer/GridContainer/tile_label");
_tileOffsetLabel = GetNode<Label>("Control/HBoxContainer/GridContainer/tile_offset_label");
_numTilesLabel = GetNode<Label>("Control/HBoxContainer/GridContainer/num_tiles_label");
_mouseWorldLabel = GetNode<Label>("Control/HBoxContainer/GridContainer/mouse_world_label");
_mouseTileLabel = GetNode<Label>("Control/HBoxContainer/GridContainer/mouse_tile_label");
_numCoordsAddedLabel = GetNode<Label>("Control/HBoxContainer/GridContainer/num_coords_added_label");
_numCoordsRemovedLabel = GetNode<Label>("Control/HBoxContainer/GridContainer/num_coords_removed_label");
_worldTextureRect = (TextureRect)FindNode("WorldTextureRect");
_heightTextureRect = (TextureRect)FindNode("HeightTextureRect");
_generateWorldButton = (Button)FindNode("WorldGenerateButton");
Container worldGeneratorContainer = (Container)FindNode("WorldGeneratorContainer");
_worldTextureRect = worldGeneratorContainer.GetNode<TextureRect>("WorldTextureRect");
_heightTextureRect = worldGeneratorContainer.GetNode<TextureRect>("HeightTextureRect");
_generateWorldButton = worldGeneratorContainer.GetNode<Button>("WorldGenerateButton");
// scene nodes
_tileHighlight = GetNode<Spatial>("TileHighlight");
_mouseTileHighlight = GetNode<Spatial>("MouseTileHighlight");
_streamContainer = GetNode<StreamContainer>("StreamContainer");
_streamContainerArea = GetNode<Area>("StreamContainer/Area");
_streamContainerActiveTiles = GetNode<Spatial>("StreamContainer/ActiveTiles");
_streamContainer = (StreamContainer)FindNode("StreamContainer");
_streamContainerArea = _streamContainer.GetNode<Area>("Area");
_streamContainerActiveTiles = _streamContainer.GetNode<Spatial>("ActiveTiles");
_player = GetNode<Player>("Player");
_chest = GetNode<Chest>("Entities/Chest");
_tileWorld = GetNode<TileWorld>("TileWorld");
_camera = GetNode<Camera>("StreamContainer/Camera");
_camera = (Camera)FindNode("Camera");
_cameraOffset = _camera.GlobalTranslation - _player.GlobalTranslation;
Debug.Assert(_tileWorld != null);

View File

@ -45,31 +45,170 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0 )
[node name="TileWorld" parent="." instance=ExtResource( 8 )]
[node name="Control" type="Control" parent="."]
[node name="DebugContainer" type="PanelContainer" parent="."]
visible = false
self_modulate = Color( 1, 1, 1, 0.443137 )
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -141.0
margin_top = -172.0
grow_horizontal = 0
grow_vertical = 0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="DebugStatsContainer" type="GridContainer" parent="DebugContainer"]
margin_left = 7.0
margin_top = 7.0
margin_right = 134.0
margin_bottom = 165.0
grow_horizontal = 0
grow_vertical = 0
mouse_filter = 2
columns = 2
[node name="Label9" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_right = 103.0
margin_bottom = 14.0
rect_pivot_offset = Vector2( -335, -33 )
text = "FPS"
[node name="fps_label" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_left = 107.0
margin_right = 127.0
margin_bottom = 14.0
text = "0,0"
[node name="Label" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_top = 18.0
margin_right = 103.0
margin_bottom = 32.0
rect_pivot_offset = Vector2( -335, -33 )
text = "Tile"
[node name="tile_label" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_left = 107.0
margin_top = 18.0
margin_right = 127.0
margin_bottom = 32.0
text = "0,0"
[node name="Label2" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_top = 36.0
margin_right = 103.0
margin_bottom = 50.0
text = "Tile Offset"
[node name="tile_offset_label" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_left = 107.0
margin_top = 36.0
margin_right = 127.0
margin_bottom = 50.0
text = "0,0"
[node name="Label4" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_top = 54.0
margin_right = 103.0
margin_bottom = 68.0
rect_pivot_offset = Vector2( -335, -33 )
text = "Mouse World"
[node name="mouse_world_label" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_left = 107.0
margin_top = 54.0
margin_right = 127.0
margin_bottom = 68.0
text = "0,0"
[node name="Label6" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_top = 72.0
margin_right = 103.0
margin_bottom = 86.0
rect_pivot_offset = Vector2( -335, -33 )
text = "Mouse Tile"
[node name="mouse_tile_label" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_left = 107.0
margin_top = 72.0
margin_right = 127.0
margin_bottom = 86.0
text = "0,0"
[node name="Label3" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_top = 90.0
margin_right = 103.0
margin_bottom = 104.0
text = "#Tiles"
[node name="num_tiles_label" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_left = 107.0
margin_top = 90.0
margin_right = 127.0
margin_bottom = 104.0
text = "0"
[node name="Label5" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_top = 108.0
margin_right = 103.0
margin_bottom = 122.0
text = "#Active"
[node name="num_active_tiles_label" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_left = 107.0
margin_top = 108.0
margin_right = 127.0
margin_bottom = 122.0
text = "0"
[node name="Label7" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_top = 126.0
margin_right = 103.0
margin_bottom = 140.0
text = "#Tiles Added"
[node name="num_coords_added_label" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_left = 107.0
margin_top = 126.0
margin_right = 127.0
margin_bottom = 140.0
text = "0"
[node name="Label8" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_top = 144.0
margin_right = 103.0
margin_bottom = 158.0
text = "#Tiles Removed"
[node name="num_coords_removed_label" type="Label" parent="DebugContainer/DebugStatsContainer"]
margin_left = 107.0
margin_top = 144.0
margin_right = 127.0
margin_bottom = 158.0
text = "0"
[node name="Generator Container" type="Control" parent="."]
margin_right = 40.0
margin_bottom = 40.0
mouse_filter = 2
[node name="HBoxContainer" type="HBoxContainer" parent="Control"]
margin_right = 127.0
margin_bottom = 158.0
mouse_filter = 2
alignment = 2
[node name="WorldGeneratorUI" type="VBoxContainer" parent="Control/HBoxContainer"]
margin_right = 100.0
margin_bottom = 248.0
[node name="WorldGeneratorContainer" type="VBoxContainer" parent="Generator Container"]
margin_left = 10.0
margin_top = 10.0
margin_right = 110.0
margin_bottom = 258.0
alignment = 2
script = ExtResource( 12 )
[node name="WorldTextureRect" type="TextureRect" parent="Control/HBoxContainer/WorldGeneratorUI"]
[node name="WorldTextureRect" type="TextureRect" parent="Generator Container/WorldGeneratorContainer"]
margin_right = 100.0
margin_bottom = 100.0
rect_min_size = Vector2( 100, 100 )
stretch_mode = 1
flip_v = true
[node name="HeightTextureRect" type="TextureRect" parent="Control/HBoxContainer/WorldGeneratorUI"]
[node name="HeightTextureRect" type="TextureRect" parent="Generator Container/WorldGeneratorContainer"]
margin_top = 104.0
margin_right = 100.0
margin_bottom = 204.0
@ -77,18 +216,18 @@ rect_min_size = Vector2( 100, 100 )
stretch_mode = 1
flip_v = true
[node name="WorldGenerateButton" type="Button" parent="Control/HBoxContainer/WorldGeneratorUI"]
[node name="WorldGenerateButton" type="Button" parent="Generator Container/WorldGeneratorContainer"]
margin_top = 208.0
margin_right = 100.0
margin_bottom = 228.0
text = "Generate"
[node name="HBoxContainer" type="HBoxContainer" parent="Control/HBoxContainer/WorldGeneratorUI"]
[node name="HBoxContainer" type="HBoxContainer" parent="Generator Container/WorldGeneratorContainer"]
margin_top = 232.0
margin_right = 100.0
margin_bottom = 248.0
[node name="WorldSizeSlider" type="HSlider" parent="Control/HBoxContainer/WorldGeneratorUI/HBoxContainer"]
[node name="WorldSizeSlider" type="HSlider" parent="Generator Container/WorldGeneratorContainer/HBoxContainer"]
margin_right = 88.0
margin_bottom = 16.0
size_flags_horizontal = 3
@ -96,140 +235,15 @@ min_value = 1.0
max_value = 512.0
value = 1.0
[node name="WorldSizeLabel" type="Label" parent="Control/HBoxContainer/WorldGeneratorUI/HBoxContainer"]
[node name="WorldSizeLabel" type="Label" parent="Generator Container/WorldGeneratorContainer/HBoxContainer"]
margin_left = 92.0
margin_top = 1.0
margin_right = 100.0
margin_bottom = 15.0
text = "4"
[node name="GridContainer" type="GridContainer" parent="Control/HBoxContainer"]
margin_left = 104.0
margin_right = 231.0
margin_bottom = 248.0
mouse_filter = 2
columns = 2
[node name="Label9" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_right = 103.0
margin_bottom = 14.0
rect_pivot_offset = Vector2( -335, -33 )
text = "FPS"
[node name="fps_label" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_left = 107.0
margin_right = 127.0
margin_bottom = 14.0
text = "0,0"
[node name="Label" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_top = 18.0
margin_right = 103.0
margin_bottom = 32.0
rect_pivot_offset = Vector2( -335, -33 )
text = "Tile"
[node name="tile_label" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_left = 107.0
margin_top = 18.0
margin_right = 127.0
margin_bottom = 32.0
text = "0,0"
[node name="Label2" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_top = 36.0
margin_right = 103.0
margin_bottom = 50.0
text = "Tile Offset"
[node name="tile_offset_label" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_left = 107.0
margin_top = 36.0
margin_right = 127.0
margin_bottom = 50.0
text = "0,0"
[node name="Label4" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_top = 54.0
margin_right = 103.0
margin_bottom = 68.0
rect_pivot_offset = Vector2( -335, -33 )
text = "Mouse World"
[node name="mouse_world_label" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_left = 107.0
margin_top = 54.0
margin_right = 127.0
margin_bottom = 68.0
text = "0,0"
[node name="Label6" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_top = 72.0
margin_right = 103.0
margin_bottom = 86.0
rect_pivot_offset = Vector2( -335, -33 )
text = "Mouse Tile"
[node name="mouse_tile_label" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_left = 107.0
margin_top = 72.0
margin_right = 127.0
margin_bottom = 86.0
text = "0,0"
[node name="Label3" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_top = 90.0
margin_right = 103.0
margin_bottom = 104.0
text = "#Tiles"
[node name="num_tiles_label" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_left = 107.0
margin_top = 90.0
margin_right = 127.0
margin_bottom = 104.0
text = "0"
[node name="Label5" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_top = 108.0
margin_right = 103.0
margin_bottom = 122.0
text = "#Active"
[node name="num_active_tiles_label" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_left = 107.0
margin_top = 108.0
margin_right = 127.0
margin_bottom = 122.0
text = "0"
[node name="Label7" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_top = 126.0
margin_right = 103.0
margin_bottom = 140.0
text = "#Tiles Added"
[node name="num_coords_added_label" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_left = 107.0
margin_top = 126.0
margin_right = 127.0
margin_bottom = 140.0
text = "0"
[node name="Label8" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_top = 144.0
margin_right = 103.0
margin_bottom = 158.0
text = "#Tiles Removed"
[node name="num_coords_removed_label" type="Label" parent="Control/HBoxContainer/GridContainer"]
margin_left = 107.0
margin_top = 144.0
margin_right = 127.0
margin_bottom = 158.0
text = "0"
[node name="StreamContainer" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 2.98023e-08, 0, -2.98023e-08, 1, 0, 0, -4.76837e-07 )
script = ExtResource( 1 )
Dimensions = Vector2( 30, 30 )
World = NodePath("../TileWorld")
@ -249,7 +263,7 @@ material/0 = SubResource( 2 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
shape = SubResource( 9 )
[node name="Camera" type="Camera" parent="StreamContainer"]
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.511698, 0.859165, 0, -0.859165, 0.511698, 1.7053e-13, 10.6428, 6.65615 )
current = true
fov = 60.0
@ -307,6 +321,6 @@ transform = Transform( 0.550568, 0, -0.83479, 0, 1, 0, 0.83479, 0, 0.550568, 4.8
[node name="Chest2" parent="Entities" instance=ExtResource( 7 )]
transform = Transform( 0.793576, 0, -0.608471, 0, 1, 0, 0.608471, 0, 0.793576, 2.79265, 0, -5.36551 )
[connection signal="value_changed" from="Control/HBoxContainer/WorldGeneratorUI/HBoxContainer/WorldSizeSlider" to="Control/HBoxContainer/WorldGeneratorUI" method="_on_HSlider_value_changed"]
[connection signal="value_changed" from="Generator Container/WorldGeneratorContainer/HBoxContainer/WorldSizeSlider" to="Generator Container/WorldGeneratorContainer" method="_on_HSlider_value_changed"]
[editable path="Entities/Chest"]