Skip to content

Commit

Permalink
MenuConfig: Add 'background_offset' attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
dorkster committed May 5, 2024
1 parent d0f01e5 commit 9fb513d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Engine features:
* Added 'default_zoom_level' property to menu/minimap.txt config.
* Added support for developer mode command shortcuts.
* Added 'powers_overlap_slots' to menu/actionbar.txt config.
* Added 'background_offset' to menu/config.txt config.

Engine fixes:

Expand Down
2 changes: 2 additions & 0 deletions docs/attribute-reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,8 @@ <h4>MenuConfig</h4>

<p><strong>tab_offset</strong> | <code>point</code> | Offset for the row of tabs.</p>

<p><strong>background_offset</strong> | <code>point</code> | Offset of the background image. Defaults to a calculated value based on the tab height.</p>

<p><strong>activemods</strong> | <code>int, int, int, int : Label X, Label Y, Widget X, Widget Y</code> | Position of the "Active Mods" list box relative to the frame.</p>

<p><strong>activemods_height</strong> | <code>int</code> | Number of visible rows for the "Active Mods" list box.</p>
Expand Down
11 changes: 8 additions & 3 deletions src/MenuConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ MenuConfig::MenuConfig (bool _is_game_state)
, frame(0,0)
, frame_offset(11,8)
, tab_offset(3,0)
, background_offset(0, tab_control->getTabHeight() - (tab_control->getTabHeight() / 16))
, scrollpane_color(0,0,0,0)
, scrollpane_padding(8, 40) // appropriate defaults for fantasycore widget sizes
, scrollpane_separator_color(font->getColor(FontEngine::COLOR_WIDGET_DISABLED))
Expand Down Expand Up @@ -619,6 +620,11 @@ bool MenuConfig::parseKey(FileParser &infile, int &x1, int &y1, int &x2, int &y2
tab_offset.x = x1;
tab_offset.y = y1;
}
else if (infile.key == "background_offset") {
// @ATTR background_offset|point|Offset of the background image. Defaults to a calculated value based on the tab height.
background_offset.x = x1;
background_offset.y = y1;
}
else if (infile.key == "activemods") {
// @ATTR activemods|int, int, int, int : Label X, Label Y, Widget X, Widget Y|Position of the "Active Mods" list box relative to the frame.
placeLabeledWidget(activemods_lb, activemods_lstb, x1, y1, x2, y2, msg->get("Active Mods"));
Expand Down Expand Up @@ -1331,10 +1337,9 @@ void MenuConfig::logicMods() {
}

void MenuConfig::render() {
int tabheight = tab_control->getTabHeight();
Rect pos;
pos.x = (settings->view_w - eset->resolutions.frame_w)/2;
pos.y = (settings->view_h - eset->resolutions.frame_h)/2 + tabheight - tabheight/16;
pos.x = (settings->view_w - eset->resolutions.frame_w)/2 + background_offset.x;
pos.y = (settings->view_h - eset->resolutions.frame_h)/2 + background_offset.y;

if (background) {
background->setDestFromRect(pos);
Expand Down
1 change: 1 addition & 0 deletions src/MenuConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ class MenuConfig {
Point frame;
Point frame_offset;
Point tab_offset;
Point background_offset;
Rect scrollpane;
Color scrollpane_color;
Point scrollpane_padding;
Expand Down
2 changes: 1 addition & 1 deletion src/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ FLARE. If not, see http://www.gnu.org/licenses/

#include <SDL.h>

Version VersionInfo::ENGINE(1, 14, 40);
Version VersionInfo::ENGINE(1, 14, 41);
Version VersionInfo::MIN(0, 0, 0);
Version VersionInfo::MAX(USHRT_MAX, USHRT_MAX, USHRT_MAX);

Expand Down

0 comments on commit 9fb513d

Please sign in to comment.