Skip to content

Commit 8b7643a

Browse files
authored
Merge pull request #794 from C7-Game/yegor/assembly-unloading
Fix assembly unloading issues (#793)
2 parents d4d7a9c + f34cbb7 commit 8b7643a

File tree

6 files changed

+24
-22
lines changed

6 files changed

+24
-22
lines changed

C7/UIElements/Civ3TextureButton.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
using Godot;
2-
using System.Collections.Generic;
32

43
[GlobalClass]
54
[Tool]
65
public partial class Civ3TextureButton : TextureButton {
6+
[Export] string textureConfigKey;
7+
8+
public override void _Ready() {
9+
if (textureConfigKey != null) {
10+
TextureLoader.SetButtonTextures(this, textureConfigKey);
11+
}
12+
}
13+
714
public override void _ValidateProperty(Godot.Collections.Dictionary property) {
815
Util.ApplyNoSaveFlag(property, [PropertyName.TextureNormal, PropertyName.TextureHover, PropertyName.TexturePressed]);
916
}

C7/UIElements/Civ3TextureRect.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
using Godot;
2-
using System.Collections.Generic;
32

43
[GlobalClass]
54
[Tool]
65
public partial class Civ3TextureRect : TextureRect {
6+
[Export] string textureConfigKey;
7+
8+
public override void _Ready() {
9+
if (textureConfigKey != null) {
10+
Texture = TextureLoader.Load(textureConfigKey);
11+
}
12+
}
13+
714
public override void _ValidateProperty(Godot.Collections.Dictionary property) {
815
Util.ApplyNoSaveFlag(property, [PropertyName.Texture]);
916
}

C7/UIElements/NewGame/PlayerSetup.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using C7GameData.Save;
1010
using Serilog;
1111

12-
[Tool]
1312
public partial class PlayerSetup : Control {
1413
private static ILogger log = LogManager.ForContext<PlayerSetup>();
1514

@@ -42,8 +41,6 @@ public partial class PlayerSetup : Control {
4241

4342
// Called when the node enters the scene tree for the first time.
4443
public override void _Ready() {
45-
background.Texture = TextureLoader.Load("player_setup.background");
46-
4744
SaveGame save = GetSave();
4845

4946
// Set up buttons for the civs the player can play as.
@@ -103,10 +100,7 @@ public override void _Ready() {
103100
container.CustomMinimumSize = new Vector2(843.0f / difficultyContainer.Columns, 0);
104101
}
105102

106-
TextureLoader.SetButtonTextures(confirm, "ui.confirm");
107103
confirm.Pressed += CreateGame;
108-
109-
TextureLoader.SetButtonTextures(cancel, "ui.cancel");
110104
cancel.Pressed += BackToMainMenu;
111105
}
112106

C7/UIElements/NewGame/ScenarioSetup.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using C7GameData.Save;
1010
using Serilog;
1111

12-
[Tool]
1312
public partial class ScenarioSetup : Control {
1413
private static ILogger log = LogManager.ForContext<ScenarioSetup>();
1514

@@ -34,8 +33,6 @@ public partial class ScenarioSetup : Control {
3433

3534
// Called when the node enters the scene tree for the first time.
3635
public override void _Ready() {
37-
background.Texture = TextureLoader.Load("player_setup.background");
38-
3936
SaveGame save = GetSave();
4037

4138
// Set up buttons for the civs the player can play as.
@@ -89,10 +86,7 @@ public override void _Ready() {
8986
container.CustomMinimumSize = new Vector2(843.0f / difficultyContainer.Columns, 0);
9087
}
9188

92-
TextureLoader.SetButtonTextures(confirm, "ui.confirm");
9389
confirm.Pressed += CreateGame;
94-
95-
TextureLoader.SetButtonTextures(cancel, "ui.cancel");
9690
cancel.Pressed += BackToMainMenu;
9791
}
9892

@@ -110,13 +104,7 @@ private void DisplaySelectedLeader() {
110104
}
111105

112106
private SaveGame GetSave() {
113-
string loadGamePath;
114-
try {
115-
loadGamePath = GetNode<GlobalSingleton>("/root/GlobalSingleton").LoadGamePath;
116-
} catch (Exception e) {
117-
// Provide a default for the editor, which can't use GlobalSingleton
118-
loadGamePath = Util.Civ3MediaPath("Conquests/Conquests/9 WWII in the Pacific.biq");
119-
}
107+
string loadGamePath = GetNode<GlobalSingleton>("/root/GlobalSingleton").LoadGamePath;
120108
return SaveManager.LoadSave(loadGamePath,
121109
GamePaths.DefaultBicPath,
122110
(string scenarioSearchPath) => {

C7/UIElements/NewGame/player_setup.tscn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ loadingLabel = NodePath("Background/LoadingLabel")
3939
[node name="Background" type="TextureRect" parent="."]
4040
layout_mode = 2
4141
script = ExtResource("2")
42+
textureConfigKey = "player_setup.background"
4243

4344
[node name="Label" type="Label" parent="Background"]
4445
layout_mode = 0
@@ -130,6 +131,7 @@ offset_right = 979.0
130131
offset_bottom = 747.0
131132
shortcut = SubResource("Shortcut_33b04")
132133
script = ExtResource("3")
134+
textureConfigKey = "ui.confirm"
133135

134136
[node name="Cancel" type="TextureButton" parent="Background"]
135137
layout_mode = 0
@@ -139,6 +141,7 @@ offset_right = 1007.0
139141
offset_bottom = 748.0
140142
shortcut = SubResource("Shortcut_7oyjg")
141143
script = ExtResource("3")
144+
textureConfigKey = "ui.cancel"
142145

143146
[node name="LoadingLabel" type="Label" parent="Background"]
144147
visible = false

C7/UIElements/NewGame/scenario_setup.tscn

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[gd_scene load_steps=9 format=3 uid="uid://3453656756"]
22

3-
[ext_resource type="Script" path="res://UIElements/NewGame/ScenarioSetup.cs" id="1"]
3+
[ext_resource type="Script" uid="uid://dpe8ukuhvtdvx" path="res://UIElements/NewGame/ScenarioSetup.cs" id="1"]
44
[ext_resource type="Script" uid="uid://doqipc4rnaotx" path="res://UIElements/Civ3TextureRect.cs" id="2"]
55
[ext_resource type="Script" uid="uid://dcrdcjop64t6t" path="res://UIElements/Civ3TextureButton.cs" id="3"]
66

@@ -38,6 +38,7 @@ loadingLabel = NodePath("Background/LoadingLabel")
3838
[node name="Background" type="TextureRect" parent="."]
3939
layout_mode = 2
4040
script = ExtResource("2")
41+
textureConfigKey = "player_setup.background"
4142

4243
[node name="Label" type="Label" parent="Background"]
4344
layout_mode = 0
@@ -112,6 +113,7 @@ offset_right = 979.0
112113
offset_bottom = 747.0
113114
shortcut = SubResource("Shortcut_33b04")
114115
script = ExtResource("3")
116+
textureConfigKey = "ui.confirm"
115117

116118
[node name="Cancel" type="TextureButton" parent="Background"]
117119
layout_mode = 0
@@ -121,6 +123,7 @@ offset_right = 1007.0
121123
offset_bottom = 748.0
122124
shortcut = SubResource("Shortcut_7oyjg")
123125
script = ExtResource("3")
126+
textureConfigKey = "ui.cancel"
124127

125128
[node name="LoadingLabel" type="Label" parent="Background"]
126129
visible = false

0 commit comments

Comments
 (0)