Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
etorth committed Nov 15, 2024
1 parent 1e4ce3e commit 98b0a3b
Show file tree
Hide file tree
Showing 25 changed files with 378 additions and 256 deletions.
22 changes: 10 additions & 12 deletions client/src/alphaonbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ extern PNGTexDB *g_progUseDB;
extern SDLDevice *g_sdlDevice;

AlphaOnButton::AlphaOnButton(
dir8_t dir,
int x,
int y,
Widget::VarDir argDir,
Widget::VarOff argX,
Widget::VarOff argY,

int onOffX,
int onOffY,
Expand All @@ -28,11 +28,12 @@ AlphaOnButton::AlphaOnButton(
bool triggerOnDone,
Widget *pwidget,
bool autoDelete)

: ButtonBase
{
dir,
x,
y,
std::move(argDir),
std::move(argX),
std::move(argY),
0,
0,

Expand Down Expand Up @@ -63,15 +64,12 @@ AlphaOnButton::AlphaOnButton(
, m_onOffY(onOffY)
, m_onRadius(onRadius)
{

auto texPtr = g_progUseDB->retrieve(m_texID);
if(!texPtr){
if(auto texPtr = g_progUseDB->retrieve(m_texID); !texPtr){
throw fflerror("can't load down texture: %llu", to_llu(m_texID));
}

const auto [texW, texH] = SDLDeviceHelper::getTextureSize(texPtr);
m_w = texW;
m_h = texH;
setSize([this](const Widget *){ return SDLDeviceHelper::getTextureWidth (g_progUseDB->retrieve(m_texID)); },
[this](const Widget *){ return SDLDeviceHelper::getTextureHeight(g_progUseDB->retrieve(m_texID)); });
}

void AlphaOnButton::drawEx(int dstX, int dstY, int, int, int, int) const
Expand Down
6 changes: 3 additions & 3 deletions client/src/alphaonbutton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class AlphaOnButton: public ButtonBase

public:
AlphaOnButton(
dir8_t,
int,
int,
Widget::VarDir,
Widget::VarOff,
Widget::VarOff,

int,
int,
Expand Down
6 changes: 3 additions & 3 deletions client/src/controlboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1343,15 +1343,15 @@ void ControlBoard::setButtonLoc()
m_buttonMute .moveTo(boardW - 178 - 220, 87);

m_slider.moveTo(w() - 178 - 176, 40 - modeDiffY);
m_slider.resizeHeight(60 + modeDiffY);
m_slider.setH(60 + modeDiffY);
}
else{
m_buttonSwitchMode.moveTo(boardW - 178 - 181, 3);
m_levelBox.moveTo((boardW - 178 - 166) / 2, 4);
m_arcAniBoard.moveTo((boardW - 178 - 166 - m_arcAniBoard.w()) / 2, -13);

m_slider.moveTo(w() - 178 - 176, 40);
m_slider.resizeHeight(60);
m_slider.setH(60);
}
}

Expand All @@ -1367,7 +1367,7 @@ void ControlBoard::onWindowResize(int winW, int winH)
{
const auto prevWidth = w();
m_right.moveBy(winW - w(), 0);
m_w = winW;
setW(winW);

m_logBoard.setLineWidth(m_logBoard.getLineWidth() + (winW - prevWidth));
const int maxStretchH = winH - 47 - 55;
Expand Down
73 changes: 46 additions & 27 deletions client/src/gfxcropboard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,26 @@ class GfxCropBoard: public Widget
const Widget * const m_gfxWidget;

private:
const int m_brdCropX;
const int m_brdCropY;
const int m_brdCropW;
const int m_brdCropH;
const Widget::VarOff m_brdCropX;
const Widget::VarOff m_brdCropY;
const Widget::VarOff m_brdCropW;
const Widget::VarOff m_brdCropH;

private:
const std::array<int, 4> m_margin;

public:
GfxCropBoard(
dir8_t argDir,

int argX,
int argY,
Widget::VarDir argDir,
Widget::VarOff argX,
Widget::VarOff argY,

const Widget *argWidget,

int argBrdCropX, // crop on gfx widget
int argBrdCropY, // ...
int argBrdCropW, // ...
int argBrdCropH, // ...
Widget::VarOff argBrdCropX, // crop on gfx widget
Widget::VarOff argBrdCropY, // ...
Widget::VarOff argBrdCropW, // crop width, don't use Widget::VarSize, support over-cropping
Widget::VarOff argBrdCropH, // ...

std::array<int, 4> argMargin = {0, 0, 0, 0},

Expand All @@ -37,9 +36,9 @@ class GfxCropBoard: public Widget

: Widget
{
argDir,
argX,
argY,
std::move(argDir),
std::move(argX),
std::move(argY),
0,
0,

Expand All @@ -51,15 +50,29 @@ class GfxCropBoard: public Widget

, m_gfxWidget([argWidget]{ fflassert(argWidget); return argWidget; }())

, m_brdCropX(argBrdCropX)
, m_brdCropY(argBrdCropY)
, m_brdCropW([argBrdCropW]{ fflassert(argBrdCropW >= 0); return argBrdCropW; }())
, m_brdCropH([argBrdCropH]{ fflassert(argBrdCropH >= 0); return argBrdCropH; }())
, m_brdCropX(std::move(argBrdCropX))
, m_brdCropY(std::move(argBrdCropY))
, m_brdCropW(std::move(argBrdCropW))
, m_brdCropH(std::move(argBrdCropH))

, m_margin(argMargin)
{
setW(m_brdCropW + m_margin[2] + m_margin[3]); // respect blank space by over-cropping
setH(m_brdCropH + m_margin[0] + m_margin[1]);
// respect blank space by over-cropping
// if cropped size bigger than gfx size, we fill with blank

setSize([this](const Widget *)
{
const auto cropW = Widget::evalOff(m_brdCropW, this);
fflassert(cropW >= 0);
return cropW + m_margin[2] + m_margin[3];
},

[this](const Widget *)
{
const auto cropH = Widget::evalOff(m_brdCropH, this);
fflassert(cropH >= 0);
return cropH + m_margin[0] + m_margin[1];
});
}

public:
Expand All @@ -69,10 +82,16 @@ class GfxCropBoard: public Widget
return;
}

int brdCropX = m_brdCropX;
int brdCropY = m_brdCropY;
int brdCropW = m_brdCropW;
int brdCropH = m_brdCropH;
const int brdCropXOrig = Widget::evalOff(m_brdCropX, this);
const int brdCropYOrig = Widget::evalOff(m_brdCropY, this);

int brdCropX = brdCropXOrig;
int brdCropY = brdCropYOrig;
int brdCropW = Widget::evalOff(m_brdCropW, this);
int brdCropH = Widget::evalOff(m_brdCropH, this);

fflassert(brdCropW >= 0);
fflassert(brdCropH >= 0);

if(!mathf::rectangleOverlapRegion<int>(0, 0, m_gfxWidget->w(), m_gfxWidget->h(), brdCropX, brdCropY, brdCropW, brdCropH)){
return;
Expand All @@ -93,8 +112,8 @@ class GfxCropBoard: public Widget
w(),
h(),

m_margin[2] + brdCropX - m_brdCropX,
m_margin[0] + brdCropY - m_brdCropY,
m_margin[2] + brdCropX - brdCropXOrig,
m_margin[0] + brdCropY - brdCropYOrig,

brdCropW,
brdCropH)){
Expand Down
18 changes: 9 additions & 9 deletions client/src/gfxcutoutboard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ class GfxCutoutBoard: public Widget

public:
GfxCutoutBoard(
dir8_t argDir,

int argX,
int argY,
Widget::VarDir argDir,
Widget::VarOff argX,
Widget::VarOff argY,

const Widget *argWidget,

Expand All @@ -35,11 +34,12 @@ class GfxCutoutBoard: public Widget

: Widget
{
argDir,
argX,
argY,
argWidget->w(),
argWidget->h(),
std::move(argDir),
std::move(argX),
std::move(argY),

[argWidget](const Widget *){ return argWidget->w(); },
[argWidget](const Widget *){ return argWidget->h(); },

{},

Expand Down
20 changes: 10 additions & 10 deletions client/src/gfxdupboard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class GfxDupBoard: public Widget

public:
GfxDupBoard(
dir8_t argDir,
Widget::VarDir argDir,
Widget::VarOff argX,
Widget::VarOff argY,

int argX,
int argY,
int argW,
int argH,
Widget::VarSize argW,
Widget::VarSize argH,

const Widget *argWidget,

Expand All @@ -23,11 +23,11 @@ class GfxDupBoard: public Widget

: Widget
{
argDir,
argX,
argY,
argW,
argH,
std::move(argDir),
std::move(argX),
std::move(argY),
std::move(argW),
std::move(argH),

{},

Expand Down
4 changes: 2 additions & 2 deletions client/src/gui/npcchatboard/npcchatboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ void NPCChatBoard::loadXML(uint64_t uid, const char *eventPath, const char *xmlS
}
m_chatBoard.loadXML(xmlString);

m_w = 386;
m_h = 160 + getMiddlePixels() + 44;
setW(386);
setH(160 + getMiddlePixels() + 44);

m_buttonClose.moveTo(w() - 40, h() - 43);
if(auto texPtr = g_progUseDB->retrieve(getNPCFaceKey())){
Expand Down
19 changes: 8 additions & 11 deletions client/src/gui/skillboard/skillboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ SkillBoard::MagicIconButton::MagicIconButton(int argX, int argY, uint32_t argMag
{
// leave some pixels to draw level label
// since level can change during run, can't get the exact size here
m_w = m_icon.w() + 8;
m_h = m_icon.h() + 8;
setW(m_icon.w() + 8);
setH(m_icon.h() + 8);
}

void SkillBoard::MagicIconButton::drawEx(int dstX, int dstY, int srcX, int srcY, int srcW, int srcH) const
Expand Down Expand Up @@ -203,15 +203,12 @@ SkillBoard::SkillPage::SkillPage(uint32_t pageImage, SkillBoardConfig *configPtr

, m_pageImage(pageImage)
{
std::tie(m_w, m_h) = [this]() -> std::tuple<int, int>
{
if(auto texPtr = g_progUseDB->retrieve(m_pageImage)){
return SDLDeviceHelper::getTextureSize(texPtr);
}
if(auto texPtr = g_progUseDB->retrieve(m_pageImage)){
setSize(SDLDeviceHelper::getTextureWidth(texPtr), SDLDeviceHelper::getTextureHeight(texPtr));
}

const auto r = SkillBoard::getPageRectange();
return {r[2], r[3]};
}();
const auto r = SkillBoard::getPageRectange();
setSize(r[2], r[3]);
}

void SkillBoard::SkillPage::drawEx(int dstX, int dstY, int srcX, int srcY, int srcW, int srcH) const
Expand Down Expand Up @@ -406,7 +403,7 @@ SkillBoard::SkillBoard(int argX, int argY, ProcessRun *runPtr, Widget *widgetPtr
{
setShow(false);
if(auto texPtr = g_progUseDB->retrieve(0X05000000)){
std::tie(m_w, m_h) = SDLDeviceHelper::getTextureSize(texPtr);
setSize(SDLDeviceHelper::getTextureHeight(texPtr), SDLDeviceHelper::getTextureWidth(texPtr));
}
else{
throw fflerror("no valid inventory frame texture");
Expand Down
3 changes: 2 additions & 1 deletion client/src/guimanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ Widget *GUIManager::getWidget(const std::string &name)

void GUIManager::onWindowResize()
{
std::tie(m_w, m_h) = g_sdlDevice->getRendererSize();
setW(g_sdlDevice->getRendererWidth ());
setH(g_sdlDevice->getRendererHeight());
m_runtimeConfigBoard.updateWindowSizeLabel(w(), h(), true);

m_controlBoard.onWindowResize(w(), h());
Expand Down
31 changes: 20 additions & 11 deletions client/src/inputstringboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,27 @@
extern PNGTexDB *g_progUseDB;
extern SDLDevice *g_sdlDevice;

InputStringBoard::InputStringBoard(dir8_t dir, int x, int y, bool security, Widget *widgetPtr, bool autoDelete)
InputStringBoard::InputStringBoard(
Widget::VarDir argDir,
Widget::VarOff argX,
Widget::VarOff argY,

bool argSecurity,

Widget *argParent,
bool argAutoDelete)

: Widget
{
dir,
x,
y,
std::move(argDir),
std::move(argX),
std::move(argY),
0,
0,
{},

widgetPtr,
autoDelete
argParent,
argAutoDelete,
}

, m_input
Expand All @@ -29,7 +38,7 @@ InputStringBoard::InputStringBoard(dir8_t dir, int x, int y, bool security, Widg
225,
315,
23,
security,
argSecurity,

1,
14,
Expand Down Expand Up @@ -120,12 +129,12 @@ InputStringBoard::InputStringBoard(dir8_t dir, int x, int y, bool security, Widg
}
{
setShow(false);
if(auto texPtr = g_progUseDB->retrieve(0X07000000)){
std::tie(m_w, m_h) = SDLDeviceHelper::getTextureSize(texPtr);
}
else{
if(auto texPtr = g_progUseDB->retrieve(0X07000000); !texPtr){
throw fflerror("no valid purchase count board frame texture");
}

setSize([this](const Widget *){ return SDLDeviceHelper::getTextureWidth (g_progUseDB->retrieve(0X07000000)); },
[this](const Widget *){ return SDLDeviceHelper::getTextureHeight(g_progUseDB->retrieve(0X07000000)); });
}

void InputStringBoard::update(double ms)
Expand Down
Loading

0 comments on commit 98b0a3b

Please sign in to comment.