Some fixes for achievements screen.

Give a bit more space for text, use separate table for main goal, avoid overlapped text in main goal table etc.
This commit is contained in:
Deve 2018-11-11 01:38:27 +01:00
parent 87ce3931e5
commit bf26e4add3
3 changed files with 95 additions and 44 deletions

View File

@ -1,17 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<stkgui>
<div x="2%" y="2%" width="100%" height="96%" layout="vertical-row">
<div x="2%" y="1%" width="96%" height="98%" layout="vertical-row">
<!-- The achievement's name is filled in the header at runtime -->
<header id="title" width="100%" align="center" text_align="center"/>
<label id="description" width="90%" proportion="1" align="center"
<label id="description" width="100%" proportion="2" align="center"
text_align="center" word_wrap="true" text=""/>
<box width="90%" proportion="2" align="center" layout="vertical-row">
<div width="100%" proportion="2" layout="vertical-row">
<div width="100%" height="100%" layout="horizontal-row">
<div width="66%" height="100%" layout="vertical-row">
<spacer width="20" proportion="1"/>
<label width="100%" align="center"
text_align="center" text="Goal"/>
<spacer width="20" proportion="1"/>
<label id="main-goal-description" width="100%" align="center"
text_align="center" word_wrap="true" text=""/>
<spacer width="20" proportion="2"/>
</div>
<div width="33%" height="100%" layout="vertical-row">
<spacer width="20" proportion="1"/>
<label width="100%" align="center"
text_align="center" text="Progress"/>
<spacer width="20" proportion="1"/>
<label id="main-goal-progress" width="100%" align="center"
text_align="center" word_wrap="true" text=""/>
<spacer width="20" proportion="2"/>
</div>
</div>
</div>
<box width="100%" proportion="3" align="center" layout="vertical-row">
<list id="progress-tree" x="0" y="0" width="100%" height="100%" word_wrap="true"/>
</box>
<buttonbar id="options" width="90%" height="15%" align="center">
<buttonbar id="options" width="100%" height="14%" align="center">
<icon-button id="ok" width="128" height="128"
icon="gui/icons/green_check.png" text="OK"
label_location="bottom"/>

View File

@ -37,29 +37,40 @@ using namespace Online;
// ----------------------------------------------------------------------------
AchievementProgressDialog::AchievementProgressDialog(Achievement *achievement)
: ModalDialog(0.9f,0.9f), m_achievement(achievement),
: ModalDialog(0.95f,0.92f), m_achievement(achievement),
m_self_destroy(false)
{
loadFromFile("online/achievement_progress_dialog.stkgui");
m_progress_table = getWidget<ListWidget>("progress-tree");
assert(m_progress_table != NULL);
m_depth = m_achievement->getInfo()->getDepth();
m_progress_table = getWidget<ListWidget>("progress-tree");
assert(m_progress_table != NULL);
m_progress_table->clear();
std::vector<ListWidget::ListCell> row;
for (int i=0;i<m_depth;i++)
m_main_goal_description = getWidget<LabelWidget>("main-goal-description");
assert(m_main_goal_description != NULL);
m_main_goal_progress = getWidget<LabelWidget>("main-goal-progress");
assert(m_main_goal_progress != NULL);
if (m_depth > 1)
{
row.push_back(ListWidget::ListCell
(_C("achievement_info", "Goal"), -1, 2, true));
row.push_back(ListWidget::ListCell
(_C("achievement_info", "Progress"), -1, 1, true));
std::vector<ListWidget::ListCell> row;
for (int i = 1; i < m_depth; i++)
{
row.push_back(ListWidget::ListCell
(_C("achievement_info", "Subgoals"), -1, 2, true));
row.push_back(ListWidget::ListCell
(_C("achievement_info", "Progress"), -1, 1, true));
}
m_progress_table->addItem(StringUtils::toString(0), row);
}
m_progress_table->addItem(StringUtils::toString(0), row);
m_row_counter = 1;
recursiveFillTable(m_achievement->m_progress_goal_tree, m_achievement->m_achievement_info->m_goal_tree, 0);
recursiveFillTable(m_achievement->m_progress_goal_tree,
m_achievement->m_achievement_info->m_goal_tree, 0);
} // AchievementProgressDialog
// -----------------------------------------------------------------------------
@ -86,35 +97,50 @@ void AchievementProgressDialog::recursiveFillTable(AchievementInfo::goalTree &pr
}
if (m_achievement->isAchieved() || goal > target)
goal = target;
std::vector<ListWidget::ListCell> row;
for (int i=0;i<m_depth;i++)
{
//TODO : for sum, indicate if a subgoal counts towards or against it
if (i==depth)
{
std::string temp = StringUtils::toString(goal) + "/" +
StringUtils::toString(target);
core::stringw progress_string(temp.c_str());
core::stringw goal_name = niceGoalName(progress.type);
row.push_back(ListWidget::ListCell
(goal_name, -1, 2, true));
row.push_back(ListWidget::ListCell
(progress_string, -1, 1, true));
}
else
{
row.push_back(ListWidget::ListCell
(" ", -1, 2, true));
row.push_back(ListWidget::ListCell
(" ", -1, 1, true));
}
goal = target;
}
if (depth == 0)
{
std::string temp = StringUtils::toString(goal) + "/" +
StringUtils::toString(target);
core::stringw progress_string(temp.c_str());
core::stringw goal_name = niceGoalName(progress.type);
m_main_goal_description->setText(goal_name, false);
m_main_goal_progress->setText(progress_string, false);
}
else
{
std::vector<ListWidget::ListCell> row;
for (int i = 1; i < m_depth; i++)
{
//TODO : for sum, indicate if a subgoal counts towards or against it
if (i == depth)
{
std::string temp = StringUtils::toString(goal) + "/" +
StringUtils::toString(target);
core::stringw progress_string(temp.c_str());
core::stringw goal_name = niceGoalName(progress.type);
row.push_back(ListWidget::ListCell
(goal_name, -1, 2, true));
row.push_back(ListWidget::ListCell
(progress_string, -1, 1, true));
}
else
{
row.push_back(ListWidget::ListCell
(" ", -1, 2, true));
row.push_back(ListWidget::ListCell
(" ", -1, 1, true));
}
}
m_progress_table->addItem(StringUtils::toString(m_row_counter), row);
m_row_counter++;
}
m_progress_table->addItem(StringUtils::toString(m_row_counter), row);
m_row_counter++;
for (unsigned int i=0;i<progress.children.size();i++)
for (unsigned int i = 0; i < progress.children.size(); i++)
{
recursiveFillTable(progress.children[i],reference.children[i],depth+1);
}

View File

@ -48,6 +48,8 @@ private:
int m_row_counter;//Used in the recurisve table filling
GUIEngine::ListWidget* m_progress_table;
GUIEngine::LabelWidget* m_main_goal_description;
GUIEngine::LabelWidget* m_main_goal_progress;
GUIEngine::RibbonWidget* m_options_widget;