Skip to content

Commit 40a7281

Browse files
committed
Fix up EventScene
Prep for eventual integration
1 parent 8ffb8cb commit 40a7281

5 files changed

Lines changed: 52 additions & 24 deletions

File tree

Classes/Events/EventDatabase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/// <summary>
66
/// Holds all game events and their associated logic.
77
/// </summary>
8-
public partial class EventDatabase : Node
8+
public partial class EventDatabase
99
{
1010
public static readonly EventTemplate[] EventDictionary = new[]
1111
{

Classes/Events/EventTemplate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public delegate void EventAction();
66

7-
public partial class EventTemplate : Resource
7+
public partial class EventTemplate
88
{
99
public int Id;
1010
public string EventDescription;

Scenes/AreaBasedBackground.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ public partial class AreaBasedBackground : TextureRect
66
{
77
public override void _Ready()
88
{
9-
Texture = GD.Load<Texture2D>(StageProducer.CurLevel.BackgroundPath);
9+
if (StageProducer.CurLevel == null)
10+
Texture = GD.Load<Texture2D>("res://SharedAssets/BackGround_Full.png");
11+
else
12+
Texture = GD.Load<Texture2D>(StageProducer.CurLevel.BackgroundPath);
1013
}
1114
}

Scenes/EventScene/EventScene.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,34 @@ public partial class EventScene : Node
1919
[Export]
2020
private VBoxContainer _buttonContainer;
2121

22-
private Theme _buttonTheme; // Store the theme
22+
private static Theme _buttonTheme = GD.Load<Theme>("res://Scenes/UI/Assets/GeneralTheme.tres"); // Store the theme
2323

24+
public static EventScene NewEventScene(int eventId = 0)
25+
{
26+
EventScene result = GD.Load<PackedScene>(LoadPath).Instantiate<EventScene>();
27+
result._player = GD.Load<PackedScene>(PlayerPuppet.LoadPath).Instantiate<PlayerPuppet>();
28+
result.PlayerMarker.AddChild(result._player);
29+
result.DisplayEvent(eventId);
30+
return result;
31+
}
32+
33+
//Eventually remove this, once integrated into game
2434
public override void _Ready()
2535
{
2636
_player = GD.Load<PackedScene>(PlayerPuppet.LoadPath).Instantiate<PlayerPuppet>();
2737
PlayerMarker.AddChild(_player);
2838

29-
// Load the theme from the path
30-
_buttonTheme = GD.Load<Theme>("res://Scenes/UI/Assets/GeneralTheme.tres");
31-
3239
DisplayEvent(0);
3340
}
3441

42+
public override void _Process(double delta)
43+
{
44+
if (GetViewport().GuiGetFocusOwner() == null && _buttonContainer != null)
45+
{
46+
_buttonContainer.GetChild<Control>(0).GrabFocus();
47+
}
48+
}
49+
3550
/// <summary>
3651
/// Displays the event with the given index.
3752
/// </summary>
@@ -60,7 +75,10 @@ public void DisplayEvent(int eventIndex)
6075
eventTemplate.OptionActions[capturedIndex]?.Invoke();
6176
StageProducer.LiveInstance.TransitionStage(Stages.Map);
6277
};
63-
78+
if (capturedIndex == 0)
79+
{
80+
button.GrabFocus();
81+
}
6482
_buttonContainer.AddChild(button);
6583
}
6684
}

Scenes/EventScene/EventScene.tscn

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
[gd_scene load_steps=7 format=3 uid="uid://u7oppwtmvmci"]
1+
[gd_scene load_steps=8 format=3 uid="uid://u7oppwtmvmci"]
22

33
[ext_resource type="Script" uid="uid://md1vhln8ji5h" path="res://Scenes/EventScene/EventScene.cs" id="1_x82kl"]
44
[ext_resource type="AudioStream" uid="uid://be5ial13ynf3o" path="res://Audio/Song1.ogg" id="2_vywvm"]
5+
[ext_resource type="Script" uid="uid://pl57giqyhckb" path="res://Scenes/UI/Scripts/MenuModule.cs" id="2_x82kl"]
56
[ext_resource type="Texture2D" uid="uid://qhwve7fik4do" path="res://SharedAssets/BackGround_Full.png" id="4_l56en"]
67
[ext_resource type="Texture2D" uid="uid://8u3xvcma81d" path="res://Scenes/UI/Assets/UI_CrystalFrame.png" id="5_erk58"]
78
[ext_resource type="Script" uid="uid://cp6t6haqyef7o" path="res://Scenes/AreaBasedBackground.cs" id="5_v3lan"]
@@ -15,6 +16,10 @@ EventSprite = NodePath("EventSprite")
1516
_eventDescription = NodePath("Control/MarginContainer/PanelContainer/HBoxContainer/DescBox/DescMargin/Description")
1617
_buttonContainer = NodePath("Control/MarginContainer/PanelContainer/HBoxContainer/ButtonContainer/VBoxContainer")
1718

19+
[node name="UILayer" type="CanvasLayer" parent="." node_paths=PackedStringArray("CurSceneNode")]
20+
script = ExtResource("2_x82kl")
21+
CurSceneNode = NodePath("..")
22+
1823
[node name="Audio" type="AudioStreamPlayer" parent="."]
1924
unique_name_in_owner = true
2025
stream = ExtResource("2_vywvm")
@@ -35,27 +40,28 @@ script = ExtResource("5_v3lan")
3540

3641
[node name="Control" type="Control" parent="."]
3742
layout_mode = 3
38-
anchors_preset = 0
39-
offset_right = 650.0
40-
offset_bottom = 40.0
43+
anchors_preset = 15
44+
anchor_right = 1.0
45+
anchor_bottom = 1.0
46+
offset_right = 640.0
47+
offset_bottom = 360.0
48+
grow_horizontal = 2
49+
grow_vertical = 2
50+
size_flags_horizontal = 3
51+
size_flags_vertical = 3
4152

4253
[node name="MarginContainer" type="MarginContainer" parent="Control"]
54+
custom_minimum_size = Vector2(0, 180)
4355
layout_mode = 1
44-
anchors_preset = 15
56+
anchors_preset = 12
57+
anchor_top = 1.0
4558
anchor_right = 1.0
4659
anchor_bottom = 1.0
47-
offset_left = -50.0
48-
offset_top = 160.0
49-
offset_right = 40.0
50-
offset_bottom = 340.0
60+
offset_top = -105.0
5161
grow_horizontal = 2
52-
grow_vertical = 2
62+
grow_vertical = 0
5363
size_flags_horizontal = 3
5464
size_flags_vertical = 3
55-
theme_override_constants/margin_left = 50
56-
theme_override_constants/margin_top = 20
57-
theme_override_constants/margin_right = 50
58-
theme_override_constants/margin_bottom = 20
5965

6066
[node name="PanelContainer" type="PanelContainer" parent="Control/MarginContainer"]
6167
layout_mode = 2
@@ -79,9 +85,10 @@ layout_mode = 2
7985
layout_mode = 2
8086
size_flags_horizontal = 3
8187
size_flags_vertical = 3
82-
theme_override_constants/margin_top = 7
88+
theme_override_constants/margin_left = 5
89+
theme_override_constants/margin_top = 5
8390
theme_override_constants/margin_right = -10
84-
theme_override_constants/margin_bottom = 7
91+
theme_override_constants/margin_bottom = 5
8592

8693
[node name="DescBackground" type="NinePatchRect" parent="Control/MarginContainer/PanelContainer/HBoxContainer/DescBox"]
8794
layout_mode = 2

0 commit comments

Comments
 (0)