1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-11-30 02:04:34 +00:00

Move controller button overlay padding into layout file

This commit is contained in:
Andrew Lanzone 2025-07-19 18:09:00 -07:00
parent b0bdd68e7c
commit ef50578a62
3 changed files with 221 additions and 184 deletions

View file

@ -31,8 +31,9 @@ namespace MWGui
for (size_t i = 0; i < mButtons.size(); i++) for (size_t i = 0; i < mButtons.size(); i++)
{ {
getWidget(mButtons[i].mImage, "Btn" + mButtons[i].mName + "Image"); getWidget(mButtons[i].mImage, "Btn" + mButtons[i].mLayoutName + "Image");
getWidget(mButtons[i].mText, "Btn" + mButtons[i].mName + "Text"); getWidget(mButtons[i].mText, "Btn" + mButtons[i].mLayoutName + "Text");
getWidget(mButtons[i].mHBox, "Btn" + mButtons[i].mLayoutName);
setIcon(mButtons[i].mImage, mButtons[i].mImagePath); setIcon(mButtons[i].mImage, mButtons[i].mImagePath);
} }
@ -77,27 +78,17 @@ namespace MWGui
int ControllerButtonsOverlay::updateButton(ControllerButtonsOverlay::Button button, const std::string& buttonStr) int ControllerButtonsOverlay::updateButton(ControllerButtonsOverlay::Button button, const std::string& buttonStr)
{ {
MyGUI::TextBox* text = mButtons[button].mText;
MyGUI::ImageBox* image = mButtons[button].mImage;
if (buttonStr.empty()) if (buttonStr.empty())
{ {
image->setVisible(false); mButtons[button].mHBox->setVisible(false);
image->setUserString("Hidden", "true"); mButtons[button].mHBox->setUserString("Hidden", "true");
text->setVisible(false);
text->setUserString("Hidden", "true");
return 0; return 0;
} }
else else
{ {
image->setVisible(true); mButtons[button].mHBox->setVisible(true);
image->setUserString("Hidden", "false"); mButtons[button].mHBox->setUserString("Hidden", "false");
mButtons[button].mText->setCaptionWithReplacing(buttonStr);
text->setCaptionWithReplacing(buttonStr);
text->setVisible(true);
text->setUserString("Hidden", "false");
text->setSize(text->getTextSize().width + 16, 48);
return 1; return 1;
} }
} }

View file

@ -41,10 +41,11 @@ namespace MWGui
struct ButtonDetails struct ButtonDetails
{ {
std::string mName; std::string mLayoutName;
std::string mImagePath; std::string mImagePath;
MyGUI::ImageBox* mImage = nullptr; MyGUI::ImageBox* mImage = nullptr;
MyGUI::TextBox* mText = nullptr; MyGUI::TextBox* mText = nullptr;
Gui::HBox* mHBox = nullptr;
}; };
std::array<ButtonDetails, Button::Button_Max> mButtons; std::array<ButtonDetails, Button::Button_Max> mButtons;

View file

@ -6,204 +6,249 @@
<Widget type="HBox" position="0 0 800 48" align="Center Bottom" name="ButtonBox"> <Widget type="HBox" position="0 0 800 48" align="Center Bottom" name="ButtonBox">
<Property key="Padding" value="0"/> <Property key="Padding" value="0"/>
<Property key="Spacing" value="0"/> <Property key="Spacing" value="16"/>
<Widget type="Spacer"/> <Widget type="Spacer"/>
<Widget type="ImageBox" skin="ImageBox" align="Stretch" position="0 0 24 24" name="BtnLStickImage"> <Widget type="HBox" name="BtnLStick">
<Property key="Padding" value="0"/>
<Property key="Spacing" value="0"/>
<Widget type="ImageBox" skin="ImageBox" align="Center" position="0 0 24 24" name="BtnLStickImage">
<Property key="ImageTexture" value="textures\omw_steam_button_lstick.dds"/> <Property key="ImageTexture" value="textures\omw_steam_button_lstick.dds"/>
<Property key="Colour" value="#ccb589"/> <Property key="Colour" value="#ccb589"/>
<Property key="Alpha" value="0.7"/> <Property key="Alpha" value="0.7"/>
</Widget> </Widget>
<Widget type="TextBox" skin="HeaderText" align="Center" position="0 0 0 48" name="BtnLStickText"> <Widget type="AutoSizedTextBox" skin="HeaderText" name="BtnLStickText">
<Property key="Caption" value=""/> <Property key="Caption" value=""/>
<Property key="TextAlign" value="Left"/>
<Property key="TextShadow" value="true"/> <Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/> <Property key="TextShadowColour" value="0 0 0"/>
<Property key="ReadOnly" value="true"/> <Property key="ReadOnly" value="true"/>
</Widget> </Widget>
</Widget>
<Widget type="ImageBox" skin="ImageBox" align="Stretch" position="0 0 24 24" name="BtnRStickImage"> <Widget type="HBox" name="BtnRStick">
<Property key="Padding" value="0"/>
<Property key="Spacing" value="0"/>
<Widget type="ImageBox" skin="ImageBox" align="Center" position="0 0 24 24" name="BtnRStickImage">
<Property key="ImageTexture" value="textures\omw_steam_button_rstick.dds"/> <Property key="ImageTexture" value="textures\omw_steam_button_rstick.dds"/>
<Property key="Colour" value="#ccb589"/> <Property key="Colour" value="#ccb589"/>
<Property key="Alpha" value="0.7"/> <Property key="Alpha" value="0.7"/>
</Widget> </Widget>
<Widget type="TextBox" skin="HeaderText" align="Center" position="0 0 0 48" name="BtnRStickText"> <Widget type="AutoSizedTextBox" skin="HeaderText" name="BtnRStickText">
<Property key="Caption" value=""/> <Property key="Caption" value=""/>
<Property key="TextAlign" value="Left"/>
<Property key="TextShadow" value="true"/> <Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/> <Property key="TextShadowColour" value="0 0 0"/>
<Property key="ReadOnly" value="true"/> <Property key="ReadOnly" value="true"/>
</Widget> </Widget>
</Widget>
<Widget type="ImageBox" skin="ImageBox" align="Stretch" position="0 0 24 24" name="BtnDpadImage"> <Widget type="HBox" name="BtnDpad">
<Property key="Padding" value="0"/>
<Property key="Spacing" value="0"/>
<Widget type="ImageBox" skin="ImageBox" align="Center" position="0 0 24 24" name="BtnDpadImage">
<Property key="ImageTexture" value="textures\omw_steam_button_dpad.dds"/> <Property key="ImageTexture" value="textures\omw_steam_button_dpad.dds"/>
<Property key="Colour" value="#ccb589"/> <Property key="Colour" value="#ccb589"/>
<Property key="Alpha" value="0.7"/> <Property key="Alpha" value="0.7"/>
</Widget> </Widget>
<Widget type="TextBox" skin="HeaderText" align="Center" position="0 0 0 48" name="BtnDpadText"> <Widget type="AutoSizedTextBox" skin="HeaderText" name="BtnDpadText">
<Property key="Caption" value=""/> <Property key="Caption" value=""/>
<Property key="TextAlign" value="Left"/>
<Property key="TextShadow" value="true"/> <Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/> <Property key="TextShadowColour" value="0 0 0"/>
<Property key="ReadOnly" value="true"/> <Property key="ReadOnly" value="true"/>
</Widget> </Widget>
</Widget>
<Widget type="ImageBox" skin="ImageBox" align="Stretch" position="0 0 24 24" name="BtnAImage"> <Widget type="HBox" name="BtnA">
<Property key="Padding" value="0"/>
<Property key="Spacing" value="0"/>
<Widget type="ImageBox" skin="ImageBox" align="Center" position="0 0 24 24" name="BtnAImage">
<Property key="ImageTexture" value="textures\omw_steam_button_a.dds"/> <Property key="ImageTexture" value="textures\omw_steam_button_a.dds"/>
<Property key="Colour" value="#ccb589"/> <Property key="Colour" value="#ccb589"/>
<Property key="Alpha" value="0.7"/> <Property key="Alpha" value="0.7"/>
</Widget> </Widget>
<Widget type="TextBox" skin="HeaderText" align="Center" position="0 0 0 48" name="BtnAText"> <Widget type="AutoSizedTextBox" skin="HeaderText" name="BtnAText">
<Property key="Caption" value=""/> <Property key="Caption" value=""/>
<Property key="TextAlign" value="Left"/>
<Property key="TextShadow" value="true"/> <Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/> <Property key="TextShadowColour" value="0 0 0"/>
<Property key="ReadOnly" value="true"/> <Property key="ReadOnly" value="true"/>
</Widget> </Widget>
</Widget>
<Widget type="ImageBox" skin="ImageBox" align="Stretch" position="0 0 24 24" name="BtnMenuImage"> <Widget type="HBox" name="BtnMenu">
<Property key="Padding" value="0"/>
<Property key="Spacing" value="0"/>
<Widget type="ImageBox" skin="ImageBox" align="Center" position="0 0 24 24" name="BtnMenuImage">
<Property key="ImageTexture" value="textures\omw_steam_button_menu.dds"/> <Property key="ImageTexture" value="textures\omw_steam_button_menu.dds"/>
<Property key="Colour" value="#ccb589"/> <Property key="Colour" value="#ccb589"/>
<Property key="Alpha" value="0.7"/> <Property key="Alpha" value="0.7"/>
</Widget> </Widget>
<Widget type="TextBox" skin="HeaderText" align="Center" position="0 0 0 48" name="BtnMenuText"> <Widget type="AutoSizedTextBox" skin="HeaderText" name="BtnMenuText">
<Property key="Caption" value=""/> <Property key="Caption" value=""/>
<Property key="TextAlign" value="Left"/>
<Property key="TextShadow" value="true"/> <Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/> <Property key="TextShadowColour" value="0 0 0"/>
<Property key="ReadOnly" value="true"/> <Property key="ReadOnly" value="true"/>
</Widget> </Widget>
</Widget>
<Widget type="ImageBox" skin="ImageBox" align="Stretch" position="0 0 24 24" name="BtnViewImage"> <Widget type="HBox" name="BtnView">
<Property key="Padding" value="0"/>
<Property key="Spacing" value="0"/>
<Widget type="ImageBox" skin="ImageBox" align="Center" position="0 0 24 24" name="BtnViewImage">
<Property key="ImageTexture" value="textures\omw_steam_button_view.dds"/> <Property key="ImageTexture" value="textures\omw_steam_button_view.dds"/>
<Property key="Colour" value="#ccb589"/> <Property key="Colour" value="#ccb589"/>
<Property key="Alpha" value="0.7"/> <Property key="Alpha" value="0.7"/>
</Widget> </Widget>
<Widget type="TextBox" skin="HeaderText" align="Center" position="0 0 0 48" name="BtnViewText"> <Widget type="AutoSizedTextBox" skin="HeaderText" name="BtnViewText">
<Property key="Caption" value=""/> <Property key="Caption" value=""/>
<Property key="TextAlign" value="Left"/>
<Property key="TextShadow" value="true"/> <Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/> <Property key="TextShadowColour" value="0 0 0"/>
<Property key="ReadOnly" value="true"/> <Property key="ReadOnly" value="true"/>
</Widget> </Widget>
</Widget>
<Widget type="ImageBox" skin="ImageBox" align="Stretch" position="0 0 24 24" name="BtnL1Image"> <Widget type="HBox" name="BtnL1">
<Property key="Padding" value="0"/>
<Property key="Spacing" value="0"/>
<Widget type="ImageBox" skin="ImageBox" align="Center" position="0 0 24 24" name="BtnL1Image">
<Property key="ImageTexture" value="textures\omw_steam_button_l1.dds"/> <Property key="ImageTexture" value="textures\omw_steam_button_l1.dds"/>
<Property key="Colour" value="#ccb589"/> <Property key="Colour" value="#ccb589"/>
<Property key="Alpha" value="0.7"/> <Property key="Alpha" value="0.7"/>
</Widget> </Widget>
<Widget type="TextBox" skin="HeaderText" align="Center" position="0 0 0 48" name="BtnL1Text"> <Widget type="AutoSizedTextBox" skin="HeaderText" name="BtnL1Text">
<Property key="Caption" value=""/> <Property key="Caption" value=""/>
<Property key="TextAlign" value="Left"/>
<Property key="TextShadow" value="true"/> <Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/> <Property key="TextShadowColour" value="0 0 0"/>
<Property key="ReadOnly" value="true"/> <Property key="ReadOnly" value="true"/>
</Widget> </Widget>
</Widget>
<Widget type="ImageBox" skin="ImageBox" align="Stretch" position="0 0 24 24" name="BtnR1Image"> <Widget type="HBox" name="BtnR1">
<Property key="Padding" value="0"/>
<Property key="Spacing" value="0"/>
<Widget type="ImageBox" skin="ImageBox" align="Center" position="0 0 24 24" name="BtnR1Image">
<Property key="ImageTexture" value="textures\omw_steam_button_r1.dds"/> <Property key="ImageTexture" value="textures\omw_steam_button_r1.dds"/>
<Property key="Colour" value="#ccb589"/> <Property key="Colour" value="#ccb589"/>
<Property key="Alpha" value="0.7"/> <Property key="Alpha" value="0.7"/>
</Widget> </Widget>
<Widget type="TextBox" skin="HeaderText" align="Center" position="0 0 0 48" name="BtnR1Text"> <Widget type="AutoSizedTextBox" skin="HeaderText" name="BtnR1Text">
<Property key="Caption" value=""/> <Property key="Caption" value=""/>
<Property key="TextAlign" value="Left"/>
<Property key="TextShadow" value="true"/> <Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/> <Property key="TextShadowColour" value="0 0 0"/>
<Property key="ReadOnly" value="true"/> <Property key="ReadOnly" value="true"/>
</Widget> </Widget>
</Widget>
<Widget type="ImageBox" skin="ImageBox" align="Stretch" position="0 0 24 24" name="BtnYImage"> <Widget type="HBox" name="BtnY">
<Property key="Padding" value="0"/>
<Property key="Spacing" value="0"/>
<Widget type="ImageBox" skin="ImageBox" align="Center" position="0 0 24 24" name="BtnYImage">
<Property key="ImageTexture" value="textures\omw_steam_button_y.dds"/> <Property key="ImageTexture" value="textures\omw_steam_button_y.dds"/>
<Property key="Colour" value="#ccb589"/> <Property key="Colour" value="#ccb589"/>
<Property key="Alpha" value="0.7"/> <Property key="Alpha" value="0.7"/>
</Widget> </Widget>
<Widget type="TextBox" skin="HeaderText" align="Center" position="0 0 0 48" name="BtnYText"> <Widget type="AutoSizedTextBox" skin="HeaderText" name="BtnYText">
<Property key="Caption" value=""/> <Property key="Caption" value=""/>
<Property key="TextAlign" value="Left"/>
<Property key="TextShadow" value="true"/> <Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/> <Property key="TextShadowColour" value="0 0 0"/>
<Property key="ReadOnly" value="true"/> <Property key="ReadOnly" value="true"/>
</Widget> </Widget>
</Widget>
<Widget type="ImageBox" skin="ImageBox" align="Stretch" position="0 0 24 24" name="BtnL3Image"> <Widget type="HBox" name="BtnL3">
<Property key="Padding" value="0"/>
<Property key="Spacing" value="0"/>
<Widget type="ImageBox" skin="ImageBox" align="Center" position="0 0 24 24" name="BtnL3Image">
<Property key="ImageTexture" value="textures\omw_steam_button_l3.dds"/> <Property key="ImageTexture" value="textures\omw_steam_button_l3.dds"/>
<Property key="Colour" value="#ccb589"/> <Property key="Colour" value="#ccb589"/>
<Property key="Alpha" value="0.7"/> <Property key="Alpha" value="0.7"/>
</Widget> </Widget>
<Widget type="TextBox" skin="HeaderText" align="Center" position="0 0 0 48" name="BtnL3Text"> <Widget type="AutoSizedTextBox" skin="HeaderText" name="BtnL3Text">
<Property key="Caption" value=""/> <Property key="Caption" value=""/>
<Property key="TextAlign" value="Left"/>
<Property key="TextShadow" value="true"/> <Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/> <Property key="TextShadowColour" value="0 0 0"/>
<Property key="ReadOnly" value="true"/> <Property key="ReadOnly" value="true"/>
</Widget> </Widget>
</Widget>
<Widget type="ImageBox" skin="ImageBox" align="Stretch" position="0 0 24 24" name="BtnR3Image"> <Widget type="HBox" name="BtnR3">
<Property key="Padding" value="0"/>
<Property key="Spacing" value="0"/>
<Widget type="ImageBox" skin="ImageBox" align="Center" position="0 0 24 24" name="BtnR3Image">
<Property key="ImageTexture" value="textures\omw_steam_button_r3.dds"/> <Property key="ImageTexture" value="textures\omw_steam_button_r3.dds"/>
<Property key="Colour" value="#ccb589"/> <Property key="Colour" value="#ccb589"/>
<Property key="Alpha" value="0.7"/> <Property key="Alpha" value="0.7"/>
</Widget> </Widget>
<Widget type="TextBox" skin="HeaderText" align="Center" position="0 0 0 48" name="BtnR3Text"> <Widget type="AutoSizedTextBox" skin="HeaderText" name="BtnR3Text">
<Property key="Caption" value=""/> <Property key="Caption" value=""/>
<Property key="TextAlign" value="Left"/>
<Property key="TextShadow" value="true"/> <Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/> <Property key="TextShadowColour" value="0 0 0"/>
<Property key="ReadOnly" value="true"/> <Property key="ReadOnly" value="true"/>
</Widget> </Widget>
</Widget>
<Widget type="ImageBox" skin="ImageBox" align="Stretch" position="0 0 24 24" name="BtnL2Image"> <Widget type="HBox" name="BtnL2">
<Property key="Padding" value="0"/>
<Property key="Spacing" value="0"/>
<Widget type="ImageBox" skin="ImageBox" align="Center" position="0 0 24 24" name="BtnL2Image">
<Property key="ImageTexture" value="textures\omw_steam_button_l2.dds"/> <Property key="ImageTexture" value="textures\omw_steam_button_l2.dds"/>
<Property key="Colour" value="#ccb589"/> <Property key="Colour" value="#ccb589"/>
<Property key="Alpha" value="0.7"/> <Property key="Alpha" value="0.7"/>
</Widget> </Widget>
<Widget type="TextBox" skin="HeaderText" align="Center" position="0 0 0 48" name="BtnL2Text"> <Widget type="AutoSizedTextBox" skin="HeaderText" name="BtnL2Text">
<Property key="Caption" value=""/> <Property key="Caption" value=""/>
<Property key="TextAlign" value="Left"/>
<Property key="TextShadow" value="true"/> <Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/> <Property key="TextShadowColour" value="0 0 0"/>
<Property key="ReadOnly" value="true"/> <Property key="ReadOnly" value="true"/>
</Widget> </Widget>
</Widget>
<Widget type="ImageBox" skin="ImageBox" align="Stretch" position="0 0 24 24" name="BtnR2Image"> <Widget type="HBox" name="BtnR2">
<Property key="Padding" value="0"/>
<Property key="Spacing" value="0"/>
<Widget type="ImageBox" skin="ImageBox" align="Center" position="0 0 24 24" name="BtnR2Image">
<Property key="ImageTexture" value="textures\omw_steam_button_r2.dds"/> <Property key="ImageTexture" value="textures\omw_steam_button_r2.dds"/>
<Property key="Colour" value="#ccb589"/> <Property key="Colour" value="#ccb589"/>
<Property key="Alpha" value="0.7"/> <Property key="Alpha" value="0.7"/>
</Widget> </Widget>
<Widget type="TextBox" skin="HeaderText" align="Center" position="0 0 0 48" name="BtnR2Text"> <Widget type="AutoSizedTextBox" skin="HeaderText" name="BtnR2Text">
<Property key="Caption" value=""/> <Property key="Caption" value=""/>
<Property key="TextAlign" value="Left"/>
<Property key="TextShadow" value="true"/> <Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/> <Property key="TextShadowColour" value="0 0 0"/>
<Property key="ReadOnly" value="true"/> <Property key="ReadOnly" value="true"/>
</Widget> </Widget>
</Widget>
<Widget type="ImageBox" skin="ImageBox" align="Stretch" position="0 0 24 24" name="BtnXImage"> <Widget type="HBox" name="BtnX">
<Property key="Padding" value="0"/>
<Property key="Spacing" value="0"/>
<Widget type="ImageBox" skin="ImageBox" align="Center" position="0 0 24 24" name="BtnXImage">
<Property key="ImageTexture" value="textures\omw_steam_button_x.dds"/> <Property key="ImageTexture" value="textures\omw_steam_button_x.dds"/>
<Property key="Colour" value="#ccb589"/> <Property key="Colour" value="#ccb589"/>
<Property key="Alpha" value="0.7"/> <Property key="Alpha" value="0.7"/>
</Widget> </Widget>
<Widget type="TextBox" skin="HeaderText" align="Center" position="0 0 0 48" name="BtnXText"> <Widget type="AutoSizedTextBox" skin="HeaderText" name="BtnXText">
<Property key="Caption" value=""/> <Property key="Caption" value=""/>
<Property key="TextAlign" value="Left"/>
<Property key="TextShadow" value="true"/> <Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/> <Property key="TextShadowColour" value="0 0 0"/>
<Property key="ReadOnly" value="true"/> <Property key="ReadOnly" value="true"/>
</Widget> </Widget>
</Widget>
<Widget type="ImageBox" skin="ImageBox" align="Stretch" position="0 0 24 24" name="BtnBImage"> <Widget type="HBox" name="BtnB">
<Property key="Padding" value="0"/>
<Property key="Spacing" value="0"/>
<Widget type="ImageBox" skin="ImageBox" position="0 0 24 24" name="BtnBImage">
<Property key="ImageTexture" value="textures\omw_steam_button_b.dds"/> <Property key="ImageTexture" value="textures\omw_steam_button_b.dds"/>
<Property key="Colour" value="#ccb589"/> <Property key="Colour" value="#ccb589"/>
<Property key="Alpha" value="0.7"/> <Property key="Alpha" value="0.7"/>
</Widget> </Widget>
<Widget type="TextBox" skin="HeaderText" align="Center" position="0 0 0 48" name="BtnBText"> <Widget type="AutoSizedTextBox" skin="HeaderText" name="BtnBText">
<Property key="Caption" value=""/> <Property key="Caption" value=""/>
<Property key="TextAlign" value="Left"/>
<Property key="TextShadow" value="true"/> <Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/> <Property key="TextShadowColour" value="0 0 0"/>
<Property key="ReadOnly" value="true"/> <Property key="ReadOnly" value="true"/>
</Widget> </Widget>
</Widget>
<Widget type="Spacer"/> <Widget type="Spacer"/>
</Widget> </Widget>