Add EventManager and event handling system; implement event triggering and popup display

This commit is contained in:
2025-08-23 23:38:45 +02:00
parent c0d18507e3
commit cdd944b9b5
16 changed files with 379 additions and 26 deletions

40
Scripts/UI/EventPopup.cs Normal file
View File

@@ -0,0 +1,40 @@
using Godot;
using ParasiticGod.Scripts.Core;
using ParasiticGod.Scripts.Singletons;
namespace ParasiticGod.Scripts.UI;
[GlobalClass]
public partial class EventPopup : PanelContainer
{
[Export] private Label _titleLabel;
[Export] private RichTextLabel _descriptionLabel;
[Export] private VBoxContainer _optionsContainer;
[Export] private PackedScene _optionButtonScene; // A scene for a single button
public void DisplayEvent(EventDefinition eventDef)
{
_titleLabel.Text = eventDef.Title;
_descriptionLabel.Text = eventDef.Description;
foreach (var child in _optionsContainer.GetChildren())
{
child.QueueFree();
}
foreach (var option in eventDef.Options)
{
var button = _optionButtonScene.Instantiate<Button>();
button.Text = option.Text;
button.TooltipText = option.Tooltip;
button.Pressed += () =>
{
GameBus.Instance.ExecuteEffects(option.Effects);
QueueFree();
};
_optionsContainer.AddChild(button);
}
}
}

View File

@@ -0,0 +1 @@
uid://h1x5eqt0lc5m