Removed popup from the game, added simple options and menu. Added spawn to tiles and reworked content spawning
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user