Add icon header to the list

This commit is contained in:
Benau 2018-12-17 16:38:38 +08:00
parent 4eff620ee6
commit f53060e0df
3 changed files with 87 additions and 6 deletions

13
data/gui/screens/tracks.stkgui Executable file → Normal file
View File

@ -2,7 +2,7 @@
<stkgui> <stkgui>
<icon-button id="back" x="0" y="0" height="8%" icon="gui/icons/back.png"/> <icon-button id="back" x="0" y="0" height="8%" icon="gui/icons/back.png"/>
<div id="all-track" x="1%" y="1%" width="98%" height="96%" layout="vertical-row" > <div id="all-track" x="1%" y="1%" width="60%" height="88%" layout="vertical-row" >
<header width="80%" I18N="In the track selection screen" text="All Tracks" <header width="80%" I18N="In the track selection screen" text="All Tracks"
align="center" text_align="center" /> align="center" text_align="center" />
@ -22,7 +22,7 @@
<spinner id="lap-spinner" width="20%" min_value="1" max_value="20" align="center" <spinner id="lap-spinner" width="20%" min_value="1" max_value="20" align="center"
wrap_around="true" /> wrap_around="true" />
<spacer width="2%"/> <spacer width="2%"/>
<label id="lap-text" width="48%" I18N="In the track screen" text_align="left"/> <label id="lap-text" width="78%" I18N="In the track screen" text_align="left"/>
</div> </div>
<spacer height="10"/> <spacer height="10"/>
<div width="100%" height="fit" layout="horizontal-row" > <div width="100%" height="fit" layout="horizontal-row" >
@ -33,6 +33,13 @@
<label id="reverse-text" width="78%" I18N="In the track screen" text_align="left"/> <label id="reverse-text" width="78%" I18N="In the track screen" text_align="left"/>
</div> </div>
</box> </box>
<progressbar x="1%" id="timer" height="4%" width="98%"></progressbar>
</div> </div>
<div id="vote" x="63%" y="1%" width="37%" height="88%" layout="vertical-row">
<div width="95%" proportion="2" layout="horizontal-row">
<box proportion="2" height="100%" layout="vertical-row">
<list id="vote-list" width="100%" height="100%" word_wrap="true"/>
</box>
</div>
</div>
<progressbar x="2%" y="93%" id="timer" height="4%" width="96%"></progressbar>
</stkgui> </stkgui>

View File

@ -20,6 +20,7 @@
#include "challenges/unlock_manager.hpp" #include "challenges/unlock_manager.hpp"
#include "config/player_manager.hpp" #include "config/player_manager.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/stk_tex_manager.hpp" #include "graphics/stk_tex_manager.hpp"
#include "guiengine/message_queue.hpp" #include "guiengine/message_queue.hpp"
#include "guiengine/scalable_font.hpp" #include "guiengine/scalable_font.hpp"
@ -27,7 +28,7 @@
#include "guiengine/widgets/check_box_widget.hpp" #include "guiengine/widgets/check_box_widget.hpp"
#include "guiengine/widgets/dynamic_ribbon_widget.hpp" #include "guiengine/widgets/dynamic_ribbon_widget.hpp"
#include "guiengine/widgets/icon_button_widget.hpp" #include "guiengine/widgets/icon_button_widget.hpp"
#include "guiengine/widgets/label_widget.hpp" #include "guiengine/widgets/list_widget.hpp"
#include "guiengine/widgets/progress_bar_widget.hpp" #include "guiengine/widgets/progress_bar_widget.hpp"
#include "guiengine/widgets/spinner_widget.hpp" #include "guiengine/widgets/spinner_widget.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
@ -167,6 +168,7 @@ void TracksScreen::beforeAddingWidget()
if (m_bottom_box_height == -1) if (m_bottom_box_height == -1)
m_bottom_box_height = rect_box->m_h; m_bottom_box_height = rect_box->m_h;
m_vote_list = getWidget<ListWidget>("vote-list");
if (m_network_tracks) if (m_network_tracks)
{ {
@ -181,10 +183,78 @@ void TracksScreen::beforeAddingWidget()
assert(m_reversed != NULL); assert(m_reversed != NULL);
m_reversed->m_properties[GUIEngine::PROP_ALIGN] = "center"; m_reversed->m_properties[GUIEngine::PROP_ALIGN] = "center";
m_reversed->setVisible(true); m_reversed->setVisible(true);
m_timer->setVisible(true);
getWidget("all-track")->m_properties[GUIEngine::PROP_WIDTH] = "60%";
getWidget("vote")->setVisible(true);
m_vote_list->setVisible(true);
m_vote_list->clearColumns();
auto cl = LobbyProtocol::get<ClientLobby>();
assert(cl);
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
{
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON,
"difficulty_medium.png")), 5);
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON,
"track_random.png")), 2);
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::MODEL,
"swap-icon.png")), 1);
}
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
{
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON,
"difficulty_medium.png")), 6);
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON,
"track_random.png")), 2);
}
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
{
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON,
"difficulty_medium.png")), 4);
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON,
"track_random.png")), 2);
if (cl->getGameSetup()->isSoccerGoalTarget())
{
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON,
"soccer_ball_normal.png")), 1);
}
else
{
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON,
"loading.png")), 1);
}
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::MODEL,
"swap-icon.png")), 1);
}
else
{
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON,
"difficulty_medium.png")), 4);
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON,
"track_random.png")), 2);
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON,
"lap_flag.png")), 1);
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON,
"restart.png")), 1);
}
calculateLayout(); calculateLayout();
} }
else else
{ {
m_timer->setVisible(false);
rect_box->setVisible(false); rect_box->setVisible(false);
rect_box->m_properties[GUIEngine::PROP_HEIGHT] = "0"; rect_box->m_properties[GUIEngine::PROP_HEIGHT] = "0";
m_laps = NULL; m_laps = NULL;
@ -193,6 +263,10 @@ void TracksScreen::beforeAddingWidget()
getWidget("lap-spinner")->setVisible(false); getWidget("lap-spinner")->setVisible(false);
getWidget("reverse-text")->setVisible(false); getWidget("reverse-text")->setVisible(false);
getWidget("reverse")->setVisible(false); getWidget("reverse")->setVisible(false);
getWidget("all-track")->m_properties[GUIEngine::PROP_WIDTH] = "98%";
getWidget("vote")->setVisible(false);
m_vote_list->setVisible(false);
m_vote_list->clearColumns();
calculateLayout(); calculateLayout();
} }

View File

@ -19,7 +19,6 @@
#define HEADER_TRACKS_SCREEN_HPP #define HEADER_TRACKS_SCREEN_HPP
#include "guiengine/screen.hpp" #include "guiengine/screen.hpp"
#include "utils/synchronised.hpp"
#include <deque> #include <deque>
#include <string> #include <string>
@ -32,7 +31,7 @@ namespace GUIEngine
{ {
class CheckBoxWidget; class CheckBoxWidget;
class CheckBoxWidget; class CheckBoxWidget;
class LabelWidget; class ListWidget;
class SpinnerWidget; class SpinnerWidget;
class ProgressBarWidget; class ProgressBarWidget;
} }
@ -51,6 +50,7 @@ private:
Track* m_selected_track = NULL; Track* m_selected_track = NULL;
GUIEngine::CheckBoxWidget* m_reversed; GUIEngine::CheckBoxWidget* m_reversed;
GUIEngine::SpinnerWidget* m_laps; GUIEngine::SpinnerWidget* m_laps;
GUIEngine::ListWidget* m_vote_list;
/** Pointer to progress bar widget which is used as a timer /** Pointer to progress bar widget which is used as a timer
* (going backwards). */ * (going backwards). */