Skip to content

Commit

Permalink
fix: air bar fill direction when aligned left
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Kutyrev committed Jan 27, 2022
1 parent 4f25a2a commit c5b5a60
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
[Oo]bj/

.idea/
*.sln.DotSettings.user
/.DS_Store
2 changes: 1 addition & 1 deletion resources/modinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Adds a simple breathing system to the game",
"website": "https://github.com/squ1b3r/vs-oxygen-not-included",
"authors": ["Shoujiro"],
"version": "0.2.0",
"version": "0.2.1",
"dependency": {
"game": "1.15.10",
"survival": "1.15.10"
Expand Down
30 changes: 15 additions & 15 deletions src/Gui/HudElementAirBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,6 @@ private void UpdateAir()
_statbar.SetValues(currentAir.Value, 0.0f, maxAir);
}

private ElementBounds GetStatsBarBounds(float statsBarWidth)
{
var isRight = OxygenNotIncludedMod.Config.AirBarHorizontalAlignmentRight;
var alignment = isRight ? EnumDialogArea.RightTop : EnumDialogArea.LeftTop;
var alignmentOffsetX = isRight ? -2.0 : 1.0;

return ElementStdBounds.Statbar(alignment, statsBarWidth)
.WithFixedAlignmentOffset(alignmentOffsetX, OxygenNotIncludedMod.Config.AirBarVerticalAlignmentOffset)
.WithFixedHeight(10.0);
}

private void ComposeGuis()
{
const float statsBarParentWidth = 850f;
Expand All @@ -75,18 +64,29 @@ private void ComposeGuis()
fixedHeight = 100.0
}.WithFixedAlignmentOffset(0.0, 5.0);

var airBarBounds = GetStatsBarBounds(statsBarWidth);
var isRight = OxygenNotIncludedMod.Config.AirBarHorizontalAlignmentRight;
var alignment = isRight ? EnumDialogArea.RightTop : EnumDialogArea.LeftTop;
var alignmentOffsetX = isRight ? -2.0 : 1.0;

var airBarBounds = ElementStdBounds.Statbar(alignment, statsBarWidth)
.WithFixedAlignmentOffset(alignmentOffsetX, OxygenNotIncludedMod.Config.AirBarVerticalAlignmentOffset)
.WithFixedHeight(10.0);

var airBarParentBounds = statsBarBounds.FlatCopy().FixedGrow(0.0, 20.0);

Composers["oni:airbar"] = capi.Gui.CreateCompo("oni:statbar", airBarParentBounds)
var composer = capi.Gui.CreateCompo("oni:statbar", airBarParentBounds);

_statbar = new GuiElementStatbar(composer.Api, airBarBounds, airBarColor, isRight);

composer
.BeginChildElements(statsBarBounds)
.AddIf(airTree != null)
.AddInvStatbar(airBarBounds, airBarColor, "airstatsbar")
.AddInteractiveElement(_statbar, "airstatsbar")
.EndIf()
.EndChildElements()
.Compose();

_statbar = Composers["oni:airbar"].GetStatbar("airstatsbar");
Composers["oni:airbar"] = composer;

TryOpen();
}
Expand Down
2 changes: 1 addition & 1 deletion src/OxygenNotIncludedMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Description = "Adds a simple breathing system to the game",
Website = "https://github.com/squ1b3r/vs-oxygen-not-included",
Authors = new[] {"Shoujiro"},
Version = "0.2.0")]
Version = "0.2.1")]

namespace OxygenNotIncluded
{
Expand Down

0 comments on commit c5b5a60

Please sign in to comment.