Skip to content

Commit

Permalink
Various improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
Paloys committed Jul 16, 2022
1 parent 965bb76 commit dfe6dac
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace GoldenTrainer
{
public class CompleteDisplay : Entity
public class CompletionDisplay : Entity
{
private const float TextPadLeft = 144;
private const float TextPadRight = 6;
Expand All @@ -19,7 +19,9 @@ public class CompleteDisplay : Entity

private float _width;

public CompleteDisplay(Level level)


public CompletionDisplay(Level level)
{
_level = level;
_bg = GFX.Gui["strawberryCountBG"];
Expand Down Expand Up @@ -68,12 +70,19 @@ public override void Update()
{
GoldenTrainerModule.Instance.CompletionCount = 0;
GoldenTrainerModule.Settings.ActivateMod = !GoldenTrainerModule.Settings.ActivateMod;
this.Visible = GoldenTrainerModule.Settings.ActivateMod;
}

base.Update();

Y = Calc.Approach(Y, GetYPosition(), Engine.DeltaTime * 800f);







if (!_level.Paused)
{
_lerp = Calc.Approach(_lerp, 1f, 1.2f * Engine.RawDeltaTime);
Expand All @@ -86,22 +95,20 @@ public override void Update()

public override void Render()
{
if (GoldenTrainerModule.Settings.ActivateMod)
{
var basePos = Vector2.Lerp(new Vector2(0 - _width, Y), new Vector2(0, Y), Ease.CubeOut(_lerp)).Round();

_bg.Draw(new Vector2(_width - _bg.Width + basePos.X, Y));
this.Visible = GoldenTrainerModule.Settings.ActivateMod;
var basePos = Vector2.Lerp(new Vector2(0 - _width, Y), new Vector2(0, Y), Ease.CubeOut(_lerp)).Round();

_bg.Draw(new Vector2(_width - _bg.Width + basePos.X, Y));

if (_width > _bg.Width + basePos.X)
{
Draw.Rect(0, Y, _width - _bg.Width + basePos.X, 38f, Color.Black);
}
_berry.Draw(new Vector2(basePos.X, Y - 40));
_x.Draw(new Vector2(basePos.X + 94, Y - 15));

ActiveFont.DrawOutline(_text, new Vector2(basePos.X + TextPadLeft, Y - 25f), Vector2.Zero, Vector2.One, Color.White, 2f, Color.Black);
if (_width > _bg.Width + basePos.X)
{
Draw.Rect(0, Y, _width - _bg.Width + basePos.X, 38f, Color.Black);
}
_berry.Draw(new Vector2(basePos.X, Y - 40));
_x.Draw(new Vector2(basePos.X + 94, Y - 15));

ActiveFont.DrawOutline(_text, new Vector2(basePos.X + TextPadLeft, Y - 25f), Vector2.Zero, Vector2.One, Color.White, 2f, Color.Black);
}
}
}
28 changes: 17 additions & 11 deletions GoldenTrainer/GoldenTrainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,21 @@ public GoldenTrainerModule()
public override Type SettingsType => typeof(ExampleModuleSettings);
public static ExampleModuleSettings Settings => (ExampleModuleSettings)Instance._Settings;

public int CompletionCount { get; set; } = 0;

private bool DeathCausedByMod { get; set; } = false;

public CompleteDisplay display = null;
private int _completionCount = 0;

public int CompletionCount
{
get { return _completionCount; }
set
{
_completionCount = value;
display.SetDisplayText(_completionCount + "/" + GoldenTrainerModule.Settings.NumberOfCompletions.ToString());
}
}

public CompletionDisplay display = null;
public Level level = null;

// Initialized in LoadContent, after graphics and other assets have been loaded.
Expand All @@ -45,12 +55,10 @@ public override void Load()
On.Celeste.LevelLoader.LoadingThread += (orig, self) =>
{
orig(self);
display = new CompleteDisplay(self.Level);
if (Settings.ActivateMod)
{
self.Level.Add(display);
display.SetDisplayText(Instance.CompletionCount.ToString() + "/" + Settings.NumberOfCompletions.ToString());
}
display = new CompletionDisplay(self.Level);
self.Level.Add(display);
display.SetDisplayText(CompletionCount.ToString() + "/" + Settings.NumberOfCompletions.ToString());
display.Visible = Settings.ActivateMod;
level = self.Level;
};
}
Expand Down Expand Up @@ -82,7 +90,6 @@ private void RespawnAtEnd(Level level, LevelData next, Vector2 direction)
{
CompletionCount = 0;
}
display.SetDisplayText(CompletionCount.ToString() + "/" + Settings.NumberOfCompletions.ToString());
}
}

Expand All @@ -95,7 +102,6 @@ private void ResetUponDeath(Player player)
CompletionCount = 0;
}
DeathCausedByMod = false;
display.SetDisplayText(CompletionCount.ToString() + "/" + Settings.NumberOfCompletions.ToString());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion GoldenTrainer/GoldenTrainer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CompleteDisplay.cs" />
<Compile Include="CompletionDisplay.cs" />
<Compile Include="ExampleModuleSettings.cs" />
<Compile Include="GoldenTrainer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down

0 comments on commit dfe6dac

Please sign in to comment.