Skip to content

Commit

Permalink
C4GUISpinBox: Use StartupBookScroll instead of a separate file so tha…
Browse files Browse the repository at this point in the history
…t the game runs with 358's Graphics.c4g
  • Loading branch information
Fulgen301 committed Oct 5, 2023
1 parent 223e023 commit 1e4711b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/C4Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,6 @@ bool Resource::Load(C4GroupSet &rFromGroup)
fctBigArrows.Set(fctBigArrows.Surface, 0, 0, fctBigArrows.Wdt / 4, fctBigArrows.Hgt);
if (!Game.GraphicsResource.LoadFile(fctProgressBar, "GUIProgress", rFromGroup)) return false;
fctProgressBar.Set(fctProgressBar.Surface, 1, 0, fctProgressBar.Wdt - 2, fctProgressBar.Hgt);
if (!Game.GraphicsResource.LoadFile(fctSpinBoxArrow, "GUISpinBoxArrow", rFromGroup)) return false;
// loaded sucessfully
pRes = this;
return true;
Expand Down
1 change: 0 additions & 1 deletion src/C4GuiResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class Resource
C4FacetExID fctCheckbox;
C4FacetExID fctBigArrows;
C4FacetExID fctProgressBar;
C4FacetExID fctSpinBoxArrow;
ScrollBarFacets sfctScroll;
C4Facet fctContext;

Expand Down
29 changes: 20 additions & 9 deletions src/C4GuiSpinBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "C4GuiResource.h"
#include "C4MouseControl.h"
#include "C4NumberParsing.h"
#include "C4Startup.h"
#include "StdApp.h"

#include <algorithm>
Expand Down Expand Up @@ -201,18 +202,28 @@ class SpinBox : public Edit
Edit::DrawElement(cgo);
if (arrowsRect.Wdt > 0)
{
static C4DrawTransform flipVerticalTransform = []{
C4DrawTransform t;
t.Set(1, 0, 0, 0, -1, 0, 0, 0, 1);
return t;
}();

C4Facet& arrow = GetRes()->fctSpinBoxArrow;
ScrollBarFacets &rUseGfx = C4Startup::Get()->Graphics.sfctBookScroll;
DynBarFacet bar = rUseGfx.barScroll;
if (upButtonPressed)
{
bar.fctBegin = rUseGfx.fctScrollDTop;
bar.fctBegin.Hgt += 1;
}
if (downButtonPressed)
{
bar.fctEnd = rUseGfx.fctScrollDBottom;
bar.fctEnd.Y += 1;
bar.fctEnd.Hgt += 1;
}
bar.fctBegin.Y += 1;
bar.fctBegin.Hgt -= 6;
bar.fctEnd.Y += 5;
bar.fctEnd.Hgt -= 6;

const auto x0 = cgo.TargetX + arrowsRect.x;
const auto y0 = cgo.TargetY + arrowsRect.y;
arrow.DrawT(cgo.Surface, x0 + upButtonPressed, - (y0 + upButtonPressed + arrow.Hgt), 0, 0, &flipVerticalTransform);
arrow.Draw(cgo.Surface, x0 + downButtonPressed, y0 + arrowsRect.Hgt - arrow.Hgt + downButtonPressed);
bar.fctBegin.Draw(cgo.Surface, x0, y0);
bar.fctEnd.Draw(cgo.Surface, x0, y0 + arrowsRect.Hgt - bar.fctEnd.Hgt + (downButtonPressed ? 2 : 0));
}
}

Expand Down

0 comments on commit 1e4711b

Please sign in to comment.