41#include <guichan/font.hpp>
57 void setQuests(
const std::vector<QuestEntry> &quests)
79 auto rowHeight = ListBox::getRowHeight();
82 rowHeight = std::max<unsigned>(rowHeight, icon->getHeight() + 2);
93 auto *model =
static_cast<QuestsModel *
>(getListModel());
98 auto completeIcon = theme->
getIcon(
"complete");
99 auto incompleteIcon = theme->getIcon(
"incomplete");
107 graphics->fillRectangle(gcn::Rectangle(0, rowHeight * mSelected,
108 getWidth(), rowHeight));
115 const int fontHeight = getFont()->getHeight();
117 for (
int i = 0, y = 0; i < model->getNumberOfElements();
125 auto &quest = model->getQuests()[i];
128 if (
const Image *icon = quest.completed ? completeIcon : incompleteIcon)
131 x += icon->getWidth() + 4;
143 , mHideCompletedCheckBox(new
CheckBox(
_(
"Hide completed"),
config.hideCompletedQuests))
162 questListScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
186 if (
event.getId() ==
"hideCompleted")
211 const QuestState *selectedQuestState =
nullptr;
212 int selectedVarId = -1;
216 selectedQuestState = selectedQuest.state;
217 selectedVarId = selectedQuest.varId;
224 std::stable_sort(newQuests.begin(), newQuests.end(), [](
const QuestEntry &a,
const QuestEntry &b) {
225 return a.completed > b.completed;
230 if (!selectedQuestState)
234 int newSelectedIndex = -1;
236 for (
int i = 0; i < static_cast<int>(newQuests.size()); ++i)
238 if (newQuests[i].state == selectedQuestState)
240 newSelectedIndex = i;
243 else if (newSelectedIndex == -1 && newQuests[i].varId == selectedVarId)
245 newSelectedIndex = i;
261 if (mSelectedQuestIndex < 0 || mSelectedQuestIndex >=
mQuestsModel->getNumberOfElements())
265 for (
const auto &row : quest.
rows())
283 row.text.c_str(), row.x, row.y));
A simple browser box able to handle links and forward events to the parent conteiner.
void addRow(std::string_view row)
Adds a text row to the browser.
void setLinkHandler(LinkHandler *handler)
Sets the handler for links.
void clearRows()
Remove all rows.
void listen(Event::Channel channel)
A central point of control for graphics.
void drawText(const std::string &text, int x, int y, gcn::Graphics::Alignment alignment, const gcn::Color &color, gcn::Font *font, bool outline=false, bool shadow=false, const std::optional< gcn::Color > &outlineColor={}, const std::optional< gcn::Color > &shadowColor={})
void setColor(const gcn::Color &color) override
bool drawImage(const Image *image, int x, int y)
Blits an image onto the screen.
Theme * getTheme() const
The global GUI theme.
Defines a class for loading and storing images.
void setRowHeight(int n, int h)
LayoutCell & setPadding(int p)
Sets the padding around the cell content.
A list box, meant to be used inside a scroll area.
const QuestVars & getQuestVars() const
void draw(gcn::Graphics *graphics) override
QuestsListBox(QuestsModel *model)
unsigned getRowHeight() const override
std::vector< QuestEntry > mQuests
const std::vector< QuestEntry > & getQuests() const
std::string getElementAt(int i) override
void setQuests(const std::vector< QuestEntry > &quests)
int getNumberOfElements() override
void valueChanged(const gcn::SelectionEvent &event) override
CheckBox * mHideCompletedCheckBox
BrowserBox * mQuestDetails
void action(const gcn::ActionEvent &event) override
std::unique_ptr< QuestsModel > mQuestsModel
QuestsListBox * mQuestsListBox
void updateQuestDetails()
void event(Event::Channel channel, const Event &event) override
std::unique_ptr< LinkHandler > mLinkHandler
ScrollArea * mQuestDetailsScrollArea
void registerWindowForReset(Window *window)
Enables the Reset Windows button.
int getGuiAlpha() const
Get the current GUI alpha value.
static const gcn::Color & getThemeColor(int type)
Gets the color associated with the type in the default palette (0).
const Image * getIcon(const std::string &name) const
void setMinHeight(int height)
Sets the minimum height of the window.
Layout & getLayout()
Gets the layout handler for this window.
void setWindowName(const std::string &name)
Sets the name of the window.
ContainerPlacer getPlacer(int x, int y)
Returns a proxy for adding widgets in an inner table of the layout.
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.
LayoutCell & place(int x, int y, gcn::Widget *, int w=1, int h=1)
Adds a widget to the window and sets it at given cell.
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 setMinWidth(int width)
Sets the minimum width of the window.
Config config
Global settings (config.xml)
PlayerHandler * getPlayerHandler()
std::vector< QuestEntry > getQuestsEntries(const QuestVars &questVars, bool skipCompleted)
std::string strprintf(char const *format,...)
A safe version of sprintf that returns a std::string of the result.
const std::vector< QuestRow > & rows() const