From 073e5a43149cf31a763810e6694995fb1e1b7782 Mon Sep 17 00:00:00 2001 From: Alayan Date: Thu, 3 Sep 2020 21:14:11 +0200 Subject: [PATCH] Improve the GP editor's track picker layout and behavior This improves things for #4378 but is not a comprehensive solution. It also includes unrelated improvements to this screen. - Switch from 2 track rows to 3 track rows. This allows to show more tracks at once. Nonetheless amount of white space between track pictures is still significant. Showing the track name below each track is part of the issue, as it needs space on the bottom and margins on the side to avoid track names overflowing onto each other. Word-wrap for track title would incur a small vertical cost while gaining a lot of horizontal space. Alternatively, the track names could be hidden and only shown on hover (like the game's main track selection screeen). - Select the standard set of tracks by default instead of all. - Reduce the amount of vertical spacing for the buttons below the track picker. - Group laps/reverse and ok/cancel vertically instead of horizontally. This creates clear visual blocks, as the reduced vertical spacing didn't work out well otherwise. - Add a new selected track picture. The selected track's name is always shown as title, but some users may miss it or not know track names well enough. Now, which track is going to be added to the GP when clicking ok is obvious. - When selecting a different track, change the lap number to the track's default. --- data/gui/screens/edit_track.stkgui | 70 +++++++++------ src/states_screens/edit_track_screen.cpp | 104 ++++++++++++++--------- src/states_screens/edit_track_screen.hpp | 4 +- 3 files changed, 109 insertions(+), 69 deletions(-) diff --git a/data/gui/screens/edit_track.stkgui b/data/gui/screens/edit_track.stkgui index caefe535d..4b43b7028 100644 --- a/data/gui/screens/edit_track.stkgui +++ b/data/gui/screens/edit_track.stkgui @@ -5,52 +5,70 @@
- - + - + + -
+ + - + -
diff --git a/src/states_screens/edit_track_screen.cpp b/src/states_screens/edit_track_screen.cpp index 8fe1b9801..2e43aae70 100644 --- a/src/states_screens/edit_track_screen.cpp +++ b/src/states_screens/edit_track_screen.cpp @@ -17,6 +17,8 @@ #include "states_screens/edit_track_screen.hpp" +#include "graphics/stk_tex_manager.hpp" + #include "guiengine/widgets/button_widget.hpp" #include "guiengine/widgets/check_box_widget.hpp" #include "guiengine/widgets/dynamic_ribbon_widget.hpp" @@ -36,7 +38,7 @@ const char* EditTrackScreen::ALL_TRACKS_GROUP_ID = "all"; // ----------------------------------------------------------------------------- EditTrackScreen::EditTrackScreen() - : Screen("edit_track.stkgui"), m_track_group(ALL_TRACKS_GROUP_ID), + : Screen("edit_track.stkgui"), m_track_group("standard"), m_track(NULL), m_laps(0), m_reverse(false), m_result(false) { @@ -89,47 +91,10 @@ void EditTrackScreen::loadedFromFile() DynamicRibbonWidget* tracks_widget = getWidget("tracks"); assert(tracks_widget != NULL); tracks_widget->setMaxLabelLength(MAX_LABEL_LENGTH); -} -// ----------------------------------------------------------------------------- -void EditTrackScreen::eventCallback(GUIEngine::Widget* widget, const std::string& name, - const int playerID) -{ - if (name == "ok") - { - m_result = true; - StateManager::get()->popMenu(); - } - else if (name == "cancel") - { - m_result = false; - StateManager::get()->popMenu(); - } - else if (name == "tracks") - { - DynamicRibbonWidget* tracks = getWidget("tracks"); - assert(tracks != NULL); - selectTrack(tracks->getSelectionIDString(PLAYER_ID_GAME_MASTER)); - } - else if (name == "trackgroups") - { - RibbonWidget* tabs = getWidget("trackgroups"); - assert(tabs != NULL); - m_track_group = tabs->getSelectionIDString(PLAYER_ID_GAME_MASTER); - loadTrackList(); - } - else if (name == "laps") - { - SpinnerWidget* laps = getWidget("laps"); - assert(laps != NULL); - m_laps = laps->getValue(); - } - else if (name == "reverse") - { - CheckBoxWidget* reverse = getWidget("reverse"); - assert(reverse != NULL); - m_reverse = reverse->getState(); - } + m_screenshot = getWidget("screenshot"); + m_screenshot->setFocusable(false); + m_screenshot->m_tab_stop = false; } // ----------------------------------------------------------------------------- @@ -173,6 +138,47 @@ void EditTrackScreen::init() selectTrack(m_track->getIdent()); } +// ----------------------------------------------------------------------------- +void EditTrackScreen::eventCallback(GUIEngine::Widget* widget, const std::string& name, + const int playerID) +{ + if (name == "ok") + { + m_result = true; + StateManager::get()->popMenu(); + } + else if (name == "cancel") + { + m_result = false; + StateManager::get()->popMenu(); + } + else if (name == "tracks") + { + DynamicRibbonWidget* tracks = getWidget("tracks"); + assert(tracks != NULL); + selectTrack(tracks->getSelectionIDString(PLAYER_ID_GAME_MASTER)); + } + else if (name == "trackgroups") + { + RibbonWidget* tabs = getWidget("trackgroups"); + assert(tabs != NULL); + m_track_group = tabs->getSelectionIDString(PLAYER_ID_GAME_MASTER); + loadTrackList(); + } + else if (name == "laps") + { + SpinnerWidget* laps = getWidget("laps"); + assert(laps != NULL); + m_laps = laps->getValue(); + } + else if (name == "reverse") + { + CheckBoxWidget* reverse = getWidget("reverse"); + assert(reverse != NULL); + m_reverse = reverse->getState(); + } +} + // ----------------------------------------------------------------------------- void EditTrackScreen::loadTrackList() { @@ -223,10 +229,24 @@ void EditTrackScreen::selectTrack(const std::string& id) tracks->setSelection(m_track->getIdent(), PLAYER_ID_GAME_MASTER, true); selected_track->setText(m_track->getName(), true); - laps->setValue(m_laps); + laps->setValue(m_track->getDefaultNumberOfLaps()); reverse->setVisible(m_track->reverseAvailable()); label_reverse->setVisible(m_track->reverseAvailable()); + + // Display the track's preview picture in a box, + // so that the current selection remains obvious even + // if the player doesn't notice the track name in title + irr::video::ITexture* image = STKTexManager::getInstance() + ->getTexture(m_track->getScreenshotFile(), + "While loading screenshot for track '%s':", m_track->getFilename()); + if(!image) + { + image = STKTexManager::getInstance()->getTexture(GUIEngine::getSkin()->getThemedIcon("gui/icons/track_unknown.png"), + "While loading screenshot for track '%s':", m_track->getFilename()); + } + if (image != NULL) + m_screenshot->setImage(image); } else { diff --git a/src/states_screens/edit_track_screen.hpp b/src/states_screens/edit_track_screen.hpp index 1d9d753c4..d7cda62c0 100644 --- a/src/states_screens/edit_track_screen.hpp +++ b/src/states_screens/edit_track_screen.hpp @@ -19,7 +19,7 @@ #define HEADER_EDIT_TRACK_SCREEN_HPP #include "guiengine/screen.hpp" - +#include "guiengine/widgets.hpp" namespace GUIEngine { class Widget; } @@ -51,6 +51,8 @@ class EditTrackScreen : bool m_reverse; bool m_result; + GUIEngine::IconButtonWidget* m_screenshot; + public: ~EditTrackScreen();