From 979fe2197916a30f2a80a8531d687f6aacce6176 Mon Sep 17 00:00:00 2001 From: CodingJellyfish Date: Thu, 7 Nov 2024 23:35:35 +0800 Subject: [PATCH] Add favorite to network track & Fix Android favorite kart --- data/gui/screens/arenas.stkgui | 2 +- data/gui/screens/karts.stkgui | 55 ++++++++++--------- data/gui/screens/online/network_karts.stkgui | 57 ++++++++++---------- data/gui/screens/tracks.stkgui | 14 +++-- src/states_screens/kart_selection.cpp | 9 ++-- src/states_screens/online/tracks_screen.cpp | 23 +++++++- 6 files changed, 92 insertions(+), 68 deletions(-) diff --git a/data/gui/screens/arenas.stkgui b/data/gui/screens/arenas.stkgui index ef416f501ea..e4ecb37b455 100644 --- a/data/gui/screens/arenas.stkgui +++ b/data/gui/screens/arenas.stkgui @@ -11,7 +11,7 @@
- +
diff --git a/data/gui/screens/karts.stkgui b/data/gui/screens/karts.stkgui index f6998767625..2351e815c37 100644 --- a/data/gui/screens/karts.stkgui +++ b/data/gui/screens/karts.stkgui @@ -7,38 +7,37 @@ align="center" text_align="center" /> - + -
-
- - -
-
- - -
- - - - -
- - - +
+ + +
+
+ +
+ + + +
+
+ + + +
diff --git a/data/gui/screens/online/network_karts.stkgui b/data/gui/screens/online/network_karts.stkgui index ade06ac4f82..494d6a58615 100644 --- a/data/gui/screens/online/network_karts.stkgui +++ b/data/gui/screens/online/network_karts.stkgui @@ -4,38 +4,37 @@
- + - -
-
- - -
-
- - -
- - - - -
- - - + +
+ + +
+
+ +
+ + + +
+
+ + + +
diff --git a/data/gui/screens/tracks.stkgui b/data/gui/screens/tracks.stkgui index 4d5212534ab..dd01abbda88 100644 --- a/data/gui/screens/tracks.stkgui +++ b/data/gui/screens/tracks.stkgui @@ -3,10 +3,18 @@
-
- + +
+
+
+ + + +
+
+ m_properties[GUIEngine::PROP_WIDTH] = "85%"; + getWidget("karts")->m_properties[GUIEngine::PROP_WIDTH] = "85%"; getWidget("continue")->setVisible(true); } else { - getWidget("kartlist")->m_properties[GUIEngine::PROP_WIDTH] = "100%"; + getWidget("karts")->m_properties[GUIEngine::PROP_WIDTH] = "100%"; getWidget("continue")->setVisible(false); } // Remove dispatcher from m_widgets before calculateLayout otherwise a @@ -418,9 +418,6 @@ void KartSelectionScreen::init() DynamicRibbonWidget* w = getWidget("karts"); assert( w != NULL ); - // Only allow keyboard and gamepad to choose kart without continue button in - // multitouch GUI, so mouse (touch) clicking can be used as previewing karts - w->setEventCallbackActive(Input::IT_MOUSEBUTTON, !useContinueButton()); KartHoverListener* karthoverListener = new KartHoverListener(this); w->registerHoverListener(karthoverListener); @@ -1233,7 +1230,7 @@ void KartSelectionScreen::eventCallback(Widget* widget, } setKartsFromCurrentGroup(); } - else if (m_kart_widgets.size() > unsigned(player_id)) + else if (m_kart_widgets.size() > unsigned(player_id) && !useContinueButton()) playerConfirm(player_id); } else if (name == "kart_class") diff --git a/src/states_screens/online/tracks_screen.cpp b/src/states_screens/online/tracks_screen.cpp index b6d2ec407d2..752c4f609bb 100644 --- a/src/states_screens/online/tracks_screen.cpp +++ b/src/states_screens/online/tracks_screen.cpp @@ -91,6 +91,14 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name, m_laps->setValue(host_vote->m_num_laps); m_reversed->setState(host_vote->m_reverse); voteForPlayer(); + + // If editing favorite, also favorite that track + if (getWidget("favorite")->getState() + && !PlayerManager::getCurrentPlayer()->isFavoriteTrack(host_vote->m_track_name)) + { + PlayerManager::getCurrentPlayer()->addFavoriteTrack(host_vote->m_track_name); + buildTrackList(); + } } } } @@ -130,7 +138,16 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name, if (m_selected_track) { - if (STKHost::existHost()) + if (getWidget("favorite")->getState()) + { + if(PlayerManager::getCurrentPlayer()->isFavoriteTrack(m_selected_track->getIdent())) + PlayerManager::getCurrentPlayer()->removeFavoriteTrack(m_selected_track->getIdent()); + else + PlayerManager::getCurrentPlayer()->addFavoriteTrack(m_selected_track->getIdent()); + + buildTrackList(); + } + else if (STKHost::existHost()) { w2->setBadge(selection, OK_BADGE); voteForPlayer(); @@ -343,6 +360,10 @@ void TracksScreen::beforeAddingWidget() RibbonWidget* tabs = getWidget("trackgroups"); tabs->clearAllChildren(); + + CheckBoxWidget* favorite_cb = getWidget("favorite"); + assert( favorite_cb != NULL ); + favorite_cb->setState(false); RaceManager::MinorRaceModeType minor_mode = RaceManager::get()->getMinorMode(); bool is_soccer = minor_mode == RaceManager::MINOR_MODE_SOCCER;