Removed popup from the game, added simple options and menu. Added spawn to tiles and reworked content spawning

This commit is contained in:
=
2026-05-01 18:34:48 +02:00
parent 95455597da
commit dd81c2ff2e
13 changed files with 181 additions and 113 deletions
+7 -1
View File
@@ -7,9 +7,15 @@ public class LightHandler
public static void RedrawLights(Color color)
{
List<OmniLight3D> availableLights = new();
foreach(OmniLight3D light in lights)
{
light.LightColor = color;
if (GodotObject.IsInstanceValid(light))
{
light.LightColor = color;
availableLights.Add(light);
}
}
lights = [..availableLights];
}
}
+50 -2
View File
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Godot;
@@ -6,12 +7,16 @@ public partial class UIHandler : Control
{
[Export] CodingWindow codingWindow;
[Export] RobotList robotList;
[Export] Information information;
[Export] Camera3D mainCam;
[Export] Map map;
[Export] RichTextLabel FPS;
[Export] RichTextLabel RAM;
[Export] PanelContainer options;
[Export] Control uiContent;
[Export] PanelContainer menu;
public override void _Ready()
{
GetNode<ColorPickerButton>("./MainUI/HeaderContainer/Header/LightColor").Color = GameData.lightColor;
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
@@ -31,6 +36,31 @@ public partial class UIHandler : Control
map.ShowMap();
}
}
if (Input.IsActionJustPressed("menu"))
{
HandleMenu();
}
DisplayStats();
}
public void HandleMenu()
{
bool shouldMenuOpen = true;
foreach (PanelContainer element in uiContent.GetChildren())
{
if (element.Visible)
{
element.Visible = false;
shouldMenuOpen = false;
}
}
if (shouldMenuOpen)
{
menu.Visible = true;
}
}
public void ChangeColor(Color color)
@@ -43,4 +73,22 @@ public partial class UIHandler : Control
{
codingWindow.ShowWindow(robot);
}
public void DisplayStats()
{
FPS.Text = Engine.GetFramesPerSecond().ToString() + " FPS";
double memory = Process.GetCurrentProcess().WorkingSet64 / (1024 * 1024);
string memoryDisplay = memory > 1024 ? Math.Round(memory / 1024, 2).ToString() + " GB" : memory.ToString() + " MB";
RAM.Text = memoryDisplay;
}
public void ShowOptions()
{
options.Visible = true;
}
public void ExitGame()
{
GetTree().ChangeSceneToFile("res://Scenes/MainMenu.tscn");
}
}