Skip to content

Commit

Permalink
attemps at fixing MissingResourceException
Browse files Browse the repository at this point in the history
Moving texture load from init to another class and moving UI reset in it own function, onInitialize is now called only at the loading of mod, reset is now used when updating config
  • Loading branch information
PlexusDuMenton committed Jun 23, 2019
1 parent 8b54fdf commit f5e4747
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
2 changes: 1 addition & 1 deletion ConfigFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public override void OnChanged()
{
AnotherRpgMod.visualConfig = this;
if (AnotherRpgMod.Instance!= null) {
AnotherRpgMod.Instance.healthBar.OnInitialize();
AnotherRpgMod.Instance.healthBar.Reset();
AnotherRpgMod.Instance.OpenST.OnInitialize();
AnotherRpgMod.Instance.openStatMenu.OnInitialize();
}
Expand Down
52 changes: 35 additions & 17 deletions UI/HealthBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,25 +295,14 @@ public void Erase()

public override void OnInitialize()
{
Erase();

buffTTPanel = new UIElement();
buffTTPanel.Left.Set(10 * scale, 0f);
buffTTPanel.Top.Set(Main.screenHeight - baseUiHeight + YDefaultOffSet + 185 * scale, 0f);
buffTTPanel.Width.Set(0, 0f);
buffTTPanel.Height.Set(0, 0f);
LoadTexture();
Reset();

buffPanel = new UIElement();
buffPanel.Left.Set(10 * scale, 0f);
buffPanel.Top.Set(Main.screenHeight - baseUiHeight + YDefaultOffSet + 185 * scale, 0f);
buffPanel.Width.Set(1000, 0f);
buffPanel.Height.Set(400, 0f);
YDefaultOffSet = -Config.vConfig.HealthBarYoffSet;
scale = Config.vConfig.HealthBarScale;

player = Main.player[Main.myPlayer];
}


public void LoadTexture()
{

float[] baseUiOffset =
{
Expand All @@ -335,6 +324,35 @@ public override void OnInitialize()

};

Overlay = new UIOverlay(ModContent.GetTexture("AnotherRpgMod/Textures/UI/OverlayHealthBar"));
}

public void Reset()
{
Erase();

buffTTPanel = new UIElement();
buffTTPanel.Left.Set(10 * scale, 0f);
buffTTPanel.Top.Set(Main.screenHeight - baseUiHeight + YDefaultOffSet + 185 * scale, 0f);
buffTTPanel.Width.Set(0, 0f);
buffTTPanel.Height.Set(0, 0f);

buffPanel = new UIElement();
buffPanel.Left.Set(10 * scale, 0f);
buffPanel.Top.Set(Main.screenHeight - baseUiHeight + YDefaultOffSet + 185 * scale, 0f);
buffPanel.Width.Set(1000, 0f);
buffPanel.Height.Set(400, 0f);
YDefaultOffSet = -Config.vConfig.HealthBarYoffSet;
scale = Config.vConfig.HealthBarScale;

player = Main.player[Main.myPlayer];








MainPanel[0] = new UIElement();
MainPanel[0].SetPadding(0);
Expand All @@ -345,7 +363,7 @@ public override void OnInitialize()
MainPanel[0].Left.Set(0, 0f);
MainPanel[0].Top.Set(Main.screenHeight - baseUiHeight + YDefaultOffSet, 0f);

Overlay = new UIOverlay(ModContent.GetTexture("AnotherRpgMod/Textures/UI/OverlayHealthBar"));

Overlay.ImageScale = scale;
Overlay.HAlign = 0;
Overlay.VAlign = 0;
Expand Down

0 comments on commit f5e4747

Please sign in to comment.