Skip to content

Commit

Permalink
Refactor MenuPowers
Browse files Browse the repository at this point in the history
This commit simplifies the how the data for MenuPowers is stored and
used. Base powers and upgrades are now link together, so handling
upgrades (and potential downgrades) is now much easier. Each cell, or
"group", contains its position data, a list of powers, and an index for
the currently enabled power.

Also added was a way to skip over invisible slots when using keyboard
navigation. Previously, these slots could be selected, but there would
be no indication as they weren't being rendered.
  • Loading branch information
dorkster committed Aug 16, 2018
1 parent ab48abb commit 6612cec
Show file tree
Hide file tree
Showing 9 changed files with 379 additions and 435 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Engine fixes:
* The user keybindings are now reset if the keybindings file is not forwards compatible. Anyone using remapped keys will need to set them again with this update.
* Improved performance when dealing with campaign statuses.
* Fix NPCs/enemies not begin affected by statuses set in on_load events until the player re-entered the map.
* Various fixes to MenuPowers, including better handling of when powers no longer meet their requirements.
* Lots of code cleanup.

New translations:
Expand Down
2 changes: 1 addition & 1 deletion src/EventManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ bool EventManager::executeEvent(Event &ev) {
pc->stats.powers_list.push_back(pc_class->powers[j]);
}
}
menu_powers->applyPowerUpgrades();
menu_powers->setUnlockedPowers();

menu_act->clear();
if (pc_class && !use_engine_defaults) {
Expand Down
4 changes: 2 additions & 2 deletions src/MenuManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ MenuManager::MenuManager(StatBlock *_stats)
mini = new MenuMiniMap();
chr = new MenuCharacter(stats);
inv = new MenuInventory(stats);
pow = new MenuPowers(stats, act);
pow = new MenuPowers();
questlog = new MenuLog();
stash = new MenuStash(stats);
book = new MenuBook();
Expand Down Expand Up @@ -1060,7 +1060,7 @@ void MenuManager::dragAndDropWithKeyboard() {
// clear power dragging if power slot was pressed twice
else if (slotClick == WidgetSlot::ACTIVATED) {
if (drag_power > 0) {
pow->upgradeByCell(slot_index);
pow->upgradeBySlotIndex(slot_index);
}
drag_src = DRAG_SRC_NONE;
drag_power = 0;
Expand Down
Loading

0 comments on commit 6612cec

Please sign in to comment.