Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add favorite to network track & Fix Android favorite kart #5202

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/gui/screens/arenas.stkgui
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div width="fit" height="100%" layout="horizontal-row" align="center">
<checkbox id="favorite" align="center"/>
<spacer width="5%" height="100%" />
<tiny-header width="fit" height="100%" I18N="Section in arena tracksselection screen" text="Edit favorite arenas"/>
<tiny-header width="fit" height="100%" I18N="Section in arena tracks selection screen" text="Edit favorite arenas"/>
</div>
</div>

Expand Down
55 changes: 27 additions & 28 deletions data/gui/screens/karts.stkgui
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,37 @@
align="center" text_align="center" />
<spacer height="1%" width="25"/>

<placeholder id="playerskarts" width="100%" height="65%" align="center" proportion="4">
<placeholder id="playerskarts" width="100%" align="center" proportion="1">
<!-- Contents is added programatically -->
</placeholder>

<spacer height="1f"/>
<div width="100%" height="35%" layout="horizontal-row" >
<div id="kartlist" width="85%" height="100%" layout="vertical-row" >
<box proportion="2" width="100%" layout="vertical-row" padding="2">
<spacer height="5%"/>
<div width="95%" height="1f" layout="horizontal-row" align="center">
<label text="Kart Class" align="center" I18N="In karts selection screen, determine the kart group shown on the list"/>
<spacer width="1%" />
<spinner id="kart_class" proportion="2" align="center" min_value="0" wrap_around="true"/>
<spacer width="3%"/>
<textbox proportion="3" id="search" align="center"/>
<spacer width="3%"/>
<checkbox id="favorite"/>
<spacer width="1%"/>
<label width="fit" height="100%" I18N="In the track and grand prix selection screen" text="Edit favorite karts"/>
</div>
<spacer height="3%"/>
<ribbon_grid id="karts" proportion="1" square_items="true" width="100%" align="center"
child_width="90" child_height="90"/>
</box>
<!-- Groups will be added dynamically at runtime -->
<tabs width="98%" x="1%" height="1f" id="kartgroups">
</tabs>
<spacer width="100%" height="2%"/>
</div>
<spacer width="5%"/>
<icon-button id="continue" icon="gui/icons/green_check.png" text="Continue"/>
<spacer width="5%"/>
<div width="100%" height="35%" layout="vertical-row" >
<box proportion="2" width="100%" layout="vertical-row" padding="2">
<spacer height="5%"/>
<div width="95%" height="1f" layout="horizontal-row" align="center">
<label text="Kart Class" align="center" I18N="In karts selection screen, determine the kart group shown on the list"/>
<spacer width="1%" />
<spinner id="kart_class" proportion="2" align="center" min_value="0" wrap_around="true"/>
<spacer width="3%"/>
<textbox proportion="3" id="search" align="center"/>
<spacer width="3%"/>
<checkbox id="favorite"/>
<spacer width="1%"/>
<label width="fit" height="100%" I18N="In the track and grand prix selection screen" text="Edit favorite karts"/>
</div>
<spacer height="3%"/>
<div width="100%" proportion="1" layout="horizontal-row" align="center">
<ribbon_grid id="karts" square_items="true" width="100%" height="100%" align="center"
child_width="90" child_height="90"/>
<spacer width="3%">
<icon-button id="continue" y="10%" icon="gui/icons/green_check.png" text="Continue"/>
</div>
</box>
<!-- Groups will be added dynamically at runtime -->
<tabs width="98%" x="1%" height="1f" id="kartgroups">
</tabs>
<spacer width="100%" height="2%"/>
</div>
</div>

Expand Down
57 changes: 28 additions & 29 deletions data/gui/screens/online/network_karts.stkgui
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,37 @@
<header width="80%" height="8%" align="center" text_align="center" I18N="In the kart selection (player setup) screen" text="Choose a Kart"/>
<spacer width="100%" height="1%"/>

<placeholder id="playerskarts" width="100%" height="70%" align="center" proportion="5">
<placeholder id="playerskarts" width="100%" align="center" proportion="1">
<!-- Contents is added programatically -->
</placeholder>

<spacer height="1f"/>
<div width="100%" height="35%" layout="horizontal-row" >
<div id="kartlist" width="85%" height="100%" layout="vertical-row" >
<box proportion="2" width="100%" layout="vertical-row" padding="2">
<spacer height="5%"/>
<div width="95%" height="1f" layout="horizontal-row" align="center">
<label text="Kart Class" align="center" I18N="In karts selection screen, determine the kart group shown on the list"/>
<spacer width="1%" />
<spinner id="kart_class" proportion="2" align="center" min_value="0" wrap_around="true"/>
<spacer width="3%"/>
<textbox proportion="3" id="search" align="center"/>
<spacer width="3%"/>
<checkbox id="favorite"/>
<spacer width="1%"/>
<label width="fit" height="100%" I18N="In the track and grand prix selection screen" text="Edit favorite karts"/>
</div>
<spacer height="3%"/>
<ribbon_grid id="karts" proportion="1" square_items="true" width="100%" align="center"
child_width="90" child_height="90" max_rows="2"/>
</box>
<!-- Groups will be added dynamically at runtime -->
<tabs width="98%" x="1%" height="1f" id="kartgroups">
</tabs>
<spacer width="100%" height="2%"/>
</div>
<spacer width="5%"/>
<icon-button id="continue" proportion="1" icon="gui/icons/green_check.png" text="Continue"/>
<spacer width="5%"/>
<spacer height="2%"/>
<div width="100%" height="38%" layout="vertical-row" >
<box proportion="2" width="100%" layout="vertical-row" padding="2">
<spacer height="5%"/>
<div width="95%" height="1f" layout="horizontal-row" align="center">
<label text="Kart Class" align="center" I18N="In karts selection screen, determine the kart group shown on the list"/>
<spacer width="1%" />
<spinner id="kart_class" proportion="2" align="center" min_value="0" wrap_around="true"/>
<spacer width="3%"/>
<textbox proportion="3" id="search" align="center"/>
<spacer width="3%"/>
<checkbox id="favorite"/>
<spacer width="1%"/>
<label width="fit" height="100%" I18N="In the track and grand prix selection screen" text="Edit favorite karts"/>
</div>
<spacer height="3%"/>
<div width="100%" proportion="1" layout="horizontal-row" align="center">
<ribbon_grid id="karts" square_items="true" width="100%" height="100%" align="center"
child_width="90" child_height="90"/>
<spacer width="3%">
<icon-button id="continue" y="10%" icon="gui/icons/green_check.png" text="Continue"/>
</div>
</box>
<!-- Groups will be added dynamically at runtime -->
<tabs width="98%" x="1%" height="1f" id="kartgroups">
</tabs>
<spacer width="100%" height="2%"/>
</div>
</div>
<progressbar x="2%" y="93%" id="timer" height="1f" width="96%"></progressbar>
Expand Down
14 changes: 11 additions & 3 deletions data/gui/screens/tracks.stkgui
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
<icon-button id="back" x="1%" y="0" height="9%" icon="gui/icons/back.png"/>

<div id="all-track" x="1%" y="1%" width="60%" height="88%" layout="vertical-row" >
<header height="8%" width="80%" I18N="In the track selection screen" text="All Tracks"
align="center" text_align="center" />
<spacer width="100%" height="1%" />

<div width="100%" height="8%" layout="horizontal-row" >
<header height="100%" width="60%" I18N="In the track selection screen" text="All Tracks"
align="center" text_align="center" />
<div width="fit" height="100%" layout="horizontal-row" align="center">
<checkbox id="favorite" align="center"/>
<spacer width="5%"/>
<tiny-header width="fit" height="100%" I18N="In the track and grand prix selection screen" text="Edit favorite tracks"/>
</div>
</div>

<spacer width="100%" height="1%" />
<box proportion="1" width="100%" layout="vertical-row" padding="1">
<ribbon_grid id="tracks" proportion="1" width="100%" square_items="true"
label_location="bottom" align="center"
Expand Down
9 changes: 3 additions & 6 deletions src/states_screens/kart_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ void KartSelectionScreen::beforeAddingWidget()
);
if (useContinueButton())
{
getWidget("kartlist")->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
Expand Down Expand Up @@ -418,9 +418,6 @@ void KartSelectionScreen::init()

DynamicRibbonWidget* w = getWidget<DynamicRibbonWidget>("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);
Expand Down Expand Up @@ -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")
Expand Down
23 changes: 22 additions & 1 deletion src/states_screens/online/tracks_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CheckBoxWidget>("favorite")->getState()
&& !PlayerManager::getCurrentPlayer()->isFavoriteTrack(host_vote->m_track_name))
{
PlayerManager::getCurrentPlayer()->addFavoriteTrack(host_vote->m_track_name);
buildTrackList();
}
}
}
}
Expand Down Expand Up @@ -130,7 +138,16 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name,

if (m_selected_track)
{
if (STKHost::existHost())
if (getWidget<CheckBoxWidget>("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();
Expand Down Expand Up @@ -343,6 +360,10 @@ void TracksScreen::beforeAddingWidget()

RibbonWidget* tabs = getWidget<RibbonWidget>("trackgroups");
tabs->clearAllChildren();

CheckBoxWidget* favorite_cb = getWidget<CheckBoxWidget>("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;
Expand Down
Loading