Skip to content

Commit

Permalink
MenuActionBar: Add powers_overlap_slots attribute
Browse files Browse the repository at this point in the history
The purpose of this property is to allow composition of the power icon
with the slot icon. Previous, only one or the other was drawn.
  • Loading branch information
dorkster committed May 4, 2024
1 parent aaa315b commit f16d4fb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Engine features:
* Added randomized items. Items can now be spawned with random level, quality, and bonus attributes.
* 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.

Engine fixes:

Expand Down
8 changes: 8 additions & 0 deletions docs/attribute-reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,12 @@ <h4>InputState: Default Keybindings</h4>

<p><strong>default.developer_menu</strong> | <code>[int, string], int : Bind, Type</code> | Bindings for "Developer Menu".</p>

<p><strong>default.developer_cmd_1</strong> | <code>[int, string], int : Bind, Type</code> | Bindings for "Developer Command 1".</p>

<p><strong>default.developer_cmd_2</strong> | <code>[int, string], int : Bind, Type</code> | Bindings for "Developer Command 2".</p>

<p><strong>default.developer_cmd_3</strong> | <code>[int, string], int : Bind, Type</code> | Bindings for "Developer Command 3".</p>

<hr />

<h4>ItemManager: Items</h4>
Expand Down Expand Up @@ -1312,6 +1318,8 @@ <h4>MenuActionBar</h4>

<p><strong>tooltip_length</strong> | <code>["short", "long_menu", "long_all"]</code> | The length of power descriptions in tooltips. 'short' will display only the power name. 'long_menu' (the default setting) will display full tooltips, but only for powers that are in the Powers menu. 'long_all' will display full tooltips for all powers.</p>

<p><strong>powers_overlap_slots</strong> | <code>bool</code> | When true, the power icon is drawn on top of the empty slot graphic for any given slot. If false, the empty slot graphic will only be drawn if there's not a power in the slot. The default value is false.</p>

<hr />

<h4>MenuActiveEffects</h4>
Expand Down
13 changes: 9 additions & 4 deletions src/MenuActionBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ MenuActionBar::MenuActionBar()
: sprite_emptyslot(NULL)
, sfx_unable_to_cast(0)
, tooltip_length(MenuPowers::TOOLTIP_LONG_MENU)
, powers_overlap_slots(false)
, slots_count(0)
, drag_prev_slot(-1)
, updated(false)
Expand Down Expand Up @@ -166,6 +167,10 @@ MenuActionBar::MenuActionBar()
else
infile.error("MenuActionBar: '%s' is not a valid tooltip_length setting.", infile.val.c_str());
}
// @ATTR powers_overlap_slots|bool|When true, the power icon is drawn on top of the empty slot graphic for any given slot. If false, the empty slot graphic will only be drawn if there's not a power in the slot. The default value is false.
else if (infile.key == "powers_overlap_slots") {
powers_overlap_slots = Parse::toBool(infile.val);
}

else infile.error("MenuActionBar: '%s' is not a valid key.", infile.key.c_str());
}
Expand Down Expand Up @@ -396,16 +401,16 @@ void MenuActionBar::render() {
for (unsigned i = 0; i < slots_count; i++) {
if (!slots[i]) continue;

if (hotkeys[i] != 0) {
slots[i]->render();
}
else {
if (hotkeys[i] == 0 || (powers_overlap_slots && slots[i]->enabled)) {
// TODO move this to WidgetSlot?
if (sprite_emptyslot) {
sprite_emptyslot->setDestFromRect(slots[i]->pos);
render_device->render(sprite_emptyslot);
}
}
if (hotkeys[i] != 0) {
slots[i]->render();
}
}

// render primary menu buttons
Expand Down
1 change: 1 addition & 0 deletions src/MenuActionBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class MenuActionBar : public Menu {
SoundID sfx_unable_to_cast;

int tooltip_length;
bool powers_overlap_slots;

public:
enum {
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, 38);
Version VersionInfo::ENGINE(1, 14, 39);
Version VersionInfo::MIN(0, 0, 0);
Version VersionInfo::MAX(USHRT_MAX, USHRT_MAX, USHRT_MAX);

Expand Down

0 comments on commit f16d4fb

Please sign in to comment.