47#define ABILITIES_WIDTH 200
48#define ABILITIES_HEIGHT 32
55 void update(
int current,
int needed);
89 if (event.getId() ==
"use")
91 auto *disp =
dynamic_cast<AbilityEntry*
>(
event.getSource()->getParent());
111 else if (event.getId() ==
"close")
121 bool foundNew =
false;
122 unsigned int found = 0;
124 for (
auto &[
id, ability] : abilityData)
135 e->second->update(ability.currentMana, ability.neededMana);
139 if (foundNew || found !=
mEntries.size())
152 for (
auto &[
id, ability] : abilityData)
154 Log::info(
"Updating ability GUI for %d",
id);
159 info->rechargeCurrent = ability.currentMana;
160 info->rechargeNeeded = ability.neededMana;
162 entry->setPosition(0, vPos);
163 vPos += entry->getHeight() + 3;
169 Log::warn(
"No info available of ability %d",
id);
180 if (!info->icon.empty())
185 mIcon->setPosition(1, 0);
193 mUse->setPosition(getWidth() -
mUse->getWidth(), 5);
196 if (info->rechargeable)
198 float progress = (float)info->rechargeCurrent / (
float)info->rechargeNeeded;
210 float progress = (float)current / (
float)needed;
void rebuild(const std::map< int, Ability > &abilityData)
void action(const gcn::ActionEvent &actionEvent) override
Called when receiving actions from widget.
std::map< int, AbilityEntry * > mEntries
~AbilitiesWindow() override
void draw(gcn::Graphics *graphics) override
AbilityEntry(AbilityInfo *info)
void update(int current, int needed)
ProgressBar * mRechargeBar
Being * getTarget() const
Returns the current target of the player.
virtual void use(int id)=0
virtual void useOn(int id, int beingId)=0
void setProgress(float progress)
Sets the current progress.
void setSmoothProgress(bool smoothProgress)
Set whether the progress is moved smoothly.
void registerWindowForReset(Window *window)
Enables the Reset Windows button.
static ResourceRef< Image > getImageFromTheme(const std::string &path)
void draw(gcn::Graphics *graphics) override
Draws the window contents.
void center()
Positions the window in the center of it's parent.
virtual void setVisible(bool visible)
Overloads window setVisible by Guichan to allow sticky window handling.
void setWindowName(const std::string &name)
Sets the name of the window.
void setResizable(bool resize)
Sets whether or not the window can be resized.
void setSaveVisible(bool save)
Sets whether the window will save it's visibility.
void setCloseButton(bool flag)
Sets whether or not the window has a close button.
void setDefaultSize()
Set the default win pos and size to the current ones.
void loadWindowState()
Reads the position (and the size for resizable windows) in the configuration based on the given strin...
void delete_all(Container &c)
AbilitiesWindow * abilitiesWindow
LocalPlayer * local_player
AbilityInfo * get(int id)
Gets the ability info for ID.
void warn(const char *log_text,...) LOG_PRINTF_ATTR
void info(const char *log_text,...) LOG_PRINTF_ATTR
AbilityHandler * getAbilityHandler()
const std::map< int, Ability > & getAbilityStatus()
Returns the status all abilities.
WindowContainer * windowContainer