New GUI for track only screen, used in network and loaded from replay
This commit is contained in:
parent
4d42010f2a
commit
fce3eec66f
@ -3,13 +3,16 @@
|
||||
<div x="0%" y="1%" width="100%" height="98%" layout="vertical-row" >
|
||||
|
||||
<div x="0" y="0" width="100%" layout="horizontal-row" height="8%">
|
||||
<icon-button id="back" height="100%" icon="gui/back.png"/>
|
||||
<header text_align="center" proportion="1" text="Ghost Replay Selection" align="center"/>
|
||||
<icon-button id="reload" height="90%" icon="gui/restart.png"/>
|
||||
<icon-button id="back" height="100%" icon="gui/back.png"/>
|
||||
<header text_align="center" proportion="1" I18N="In the ghost replay selection screen" text="Ghost Replay Selection" align="center"/>
|
||||
<icon-button id="reload" height="90%" icon="gui/restart.png"/>
|
||||
</div>
|
||||
|
||||
<box proportion="1" width="98%" align="center" layout="vertical-row" padding="6">
|
||||
<list id="replay_list" x="0" y="0" width="100%" height="100%"/>
|
||||
</box>
|
||||
|
||||
<spacer width="100%" height="2%" />
|
||||
<button x="1%" id="record-ghost" I18N="In the ghost replay selection screen" text="Record ghost replay" />
|
||||
</div>
|
||||
</stkgui>
|
||||
|
@ -3,15 +3,6 @@
|
||||
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
|
||||
|
||||
<div x="1%" y="1%" width="98%" height="96%" layout="vertical-row" >
|
||||
|
||||
<header width="80%" I18N="In the track selection screen" text="Grand Prix"
|
||||
align="center" text_align="center" />
|
||||
|
||||
<box width="100%" height="195" padding="0">
|
||||
<scrollable_toolbar id="gps" height="175" y="10" x="10" width="98%" align="center" label_location="each"
|
||||
square_items="true" child_width="175" child_height="120" />
|
||||
</box>
|
||||
|
||||
<header width="100%" I18N="In the track selection screen" text="All Tracks"
|
||||
align="center" text_align="center" />
|
||||
|
||||
|
30
data/gui/tracks_and_gp.stkgui
Normal file
30
data/gui/tracks_and_gp.stkgui
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<stkgui>
|
||||
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
|
||||
|
||||
<div x="1%" y="1%" width="98%" height="96%" layout="vertical-row" >
|
||||
|
||||
<header width="80%" I18N="In the track and grand prix selection screen" text="Grand Prix"
|
||||
align="center" text_align="center" />
|
||||
|
||||
<box width="100%" height="195" padding="0">
|
||||
<scrollable_toolbar id="gps" height="175" y="10" x="10" width="98%" align="center" label_location="each"
|
||||
square_items="true" child_width="175" child_height="120" />
|
||||
</box>
|
||||
|
||||
<header width="100%" I18N="In the track and grand prix selection screen" text="All Tracks"
|
||||
align="center" text_align="center" />
|
||||
|
||||
<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" max_rows="4"
|
||||
child_width="160" child_height="120" />
|
||||
<spacer width="20" height="13" />
|
||||
</box>
|
||||
|
||||
<!-- Populated dynamically at runtime -->
|
||||
<tabs width="100%" height="25" id="trackgroups"> </tabs>
|
||||
|
||||
<spacer width="100%" height="2%" />
|
||||
</div>
|
||||
</stkgui>
|
@ -1,5 +1,5 @@
|
||||
# Modify this file to change the last-modified date when you add/remove a file.
|
||||
# This will then trigger a new cmake run automatically.
|
||||
# This will then trigger a new cmake run automatically.
|
||||
file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp")
|
||||
file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
|
||||
file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*")
|
||||
|
@ -95,6 +95,9 @@ GUIEngine::EventPropagation
|
||||
|
||||
race_manager->setReverseTrack(reverse);
|
||||
|
||||
dynamic_cast<GhostReplaySelection*>(GUIEngine::getCurrentScreen())
|
||||
->setConfirmReplay();
|
||||
|
||||
if (race_manager->isWatchingReplay())
|
||||
race_manager->startWatchingReplay(track_name, laps);
|
||||
else
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "race/grand_prix_data.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/tracks_screen.hpp"
|
||||
#include "states_screens/tracks_and_gp_screen.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
@ -70,8 +70,8 @@ GPInfoDialog::GPInfoDialog(const std::string& gp_ident)
|
||||
GPInfoDialog::~GPInfoDialog()
|
||||
{
|
||||
GUIEngine::Screen* curr_screen = GUIEngine::getCurrentScreen();
|
||||
if (curr_screen->getName() == "tracks.stkgui")
|
||||
static_cast<TracksScreen*>(curr_screen)->setFocusOnGP(m_gp.getId());
|
||||
if (curr_screen->getName() == "tracks_and_gp.stkgui")
|
||||
static_cast<TracksAndGPScreen*>(curr_screen)->setFocusOnGP(m_gp.getId());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "states_screens/dialogs/ghost_replay_info_dialog.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/tracks_screen.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
@ -34,6 +35,8 @@ DEFINE_SCREEN_SINGLETON( GhostReplaySelection );
|
||||
GhostReplaySelection::GhostReplaySelection() : Screen("ghost_replay_selection.stkgui")
|
||||
{
|
||||
m_sort_desc = true;
|
||||
m_go_recording_ghost = false;
|
||||
m_choose_replay = false;
|
||||
} // GhostReplaySelection
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -141,6 +144,12 @@ void GhostReplaySelection::eventCallback(GUIEngine::Widget* widget,
|
||||
}
|
||||
new GhostReplayInfoDialog(selected_index);
|
||||
} // click on replay file
|
||||
else if (name == "record-ghost")
|
||||
{
|
||||
m_go_recording_ghost = true;
|
||||
TracksScreen::getInstance()->setOfficalTrack(false);
|
||||
TracksScreen::getInstance()->push();
|
||||
}
|
||||
|
||||
} // eventCallback
|
||||
|
||||
@ -200,3 +209,24 @@ void GhostReplaySelection::onColumnClicked(int column_id)
|
||||
} // onColumnClicked
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void GhostReplaySelection::tearDown()
|
||||
{
|
||||
if (m_go_recording_ghost)
|
||||
{
|
||||
m_go_recording_ghost = false;
|
||||
race_manager->setRecordRace(true);
|
||||
return;
|
||||
}
|
||||
if (m_choose_replay)
|
||||
{
|
||||
m_choose_replay = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset them when leave this screen normally (not from dialog)
|
||||
m_go_recording_ghost = false;
|
||||
race_manager->setRecordRace(false);
|
||||
|
||||
} // tearDown
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -44,6 +44,8 @@ private:
|
||||
GUIEngine::ListWidget* m_replay_list_widget;
|
||||
std::string m_file_to_be_deleted;
|
||||
bool m_sort_desc;
|
||||
bool m_go_recording_ghost;
|
||||
bool m_choose_replay;
|
||||
|
||||
public:
|
||||
|
||||
@ -54,6 +56,8 @@ public:
|
||||
|
||||
void onDeleteReplay(std::string& filename);
|
||||
|
||||
void setConfirmReplay() { m_choose_replay = true; }
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void loadedFromFile() OVERRIDE;
|
||||
|
||||
@ -68,7 +72,7 @@ public:
|
||||
|
||||
virtual void init() OVERRIDE;
|
||||
|
||||
virtual void tearDown() OVERRIDE {};
|
||||
virtual void tearDown() OVERRIDE;
|
||||
|
||||
/** \brief Implement IConfirmDialogListener callback */
|
||||
virtual void onConfirm() OVERRIDE;
|
||||
|
@ -200,6 +200,7 @@ void NetworkKartSelectionScreen::playerSelected(uint8_t player_id,
|
||||
//WaitingForOthersScreen::getInstance()->push();
|
||||
//return;
|
||||
}
|
||||
TracksScreen::getInstance()->setOfficalTrack(true);
|
||||
TracksScreen::getInstance()->push();
|
||||
} // playerSelected
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "states_screens/ghost_replay_selection.hpp"
|
||||
#include "states_screens/soccer_setup_screen.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/tracks_screen.hpp"
|
||||
#include "states_screens/tracks_and_gp_screen.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
const int CONFIG_CODE_NORMAL = 0;
|
||||
@ -204,13 +204,13 @@ void RaceSetupScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
{
|
||||
race_manager->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
|
||||
UserConfigParams::m_game_mode = CONFIG_CODE_NORMAL;
|
||||
TracksScreen::getInstance()->push();
|
||||
TracksAndGPScreen::getInstance()->push();
|
||||
}
|
||||
else if (selectedMode == IDENT_TTRIAL)
|
||||
{
|
||||
race_manager->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL);
|
||||
UserConfigParams::m_game_mode = CONFIG_CODE_TIMETRIAL;
|
||||
TracksScreen::getInstance()->push();
|
||||
TracksAndGPScreen::getInstance()->push();
|
||||
}
|
||||
else if (selectedMode == IDENT_FTL)
|
||||
{
|
||||
@ -220,7 +220,7 @@ void RaceSetupScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
|
||||
race_manager->setMinorMode(RaceManager::MINOR_MODE_FOLLOW_LEADER);
|
||||
UserConfigParams::m_game_mode = CONFIG_CODE_FTL;
|
||||
TracksScreen::getInstance()->push();
|
||||
TracksAndGPScreen::getInstance()->push();
|
||||
}
|
||||
else if (selectedMode == IDENT_STRIKES)
|
||||
{
|
||||
|
@ -99,6 +99,8 @@ void TrackInfoScreen::setTrack(Track *track)
|
||||
*/
|
||||
void TrackInfoScreen::init()
|
||||
{
|
||||
m_record_this_race = false;
|
||||
|
||||
const int max_arena_players = m_track->getMaxArenaPlayers();
|
||||
const bool has_laps = race_manager->modeHasLaps();
|
||||
const bool has_highscores = race_manager->modeHasHighscores();
|
||||
@ -229,8 +231,23 @@ void TrackInfoScreen::init()
|
||||
const bool record_available = race_manager->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL;
|
||||
m_record_race->setVisible(record_available);
|
||||
getWidget<LabelWidget>("record-race-text")->setVisible(record_available);
|
||||
if (record_available)
|
||||
if (race_manager->willRecordRace())
|
||||
{
|
||||
// willRecordRace() is true when it's pre-set by ghost replay selection
|
||||
// which force record this race
|
||||
m_record_this_race = true;
|
||||
m_record_race->setState(true);
|
||||
m_record_race->setActive(false);
|
||||
m_ai_kart_spinner->setValue(0);
|
||||
m_ai_kart_spinner->setActive(false);
|
||||
race_manager->setNumKarts(race_manager->getNumLocalPlayers());
|
||||
UserConfigParams::m_num_karts = race_manager->getNumLocalPlayers();
|
||||
}
|
||||
else if (record_available)
|
||||
{
|
||||
m_record_race->setActive(true);
|
||||
m_record_race->setState(false);
|
||||
}
|
||||
|
||||
// ---- High Scores
|
||||
m_highscore_label->setVisible(has_highscores);
|
||||
@ -321,6 +338,7 @@ void TrackInfoScreen::updateHighScores()
|
||||
void TrackInfoScreen::onEnterPressedInternal()
|
||||
{
|
||||
|
||||
race_manager->setRecordRace(m_record_this_race);
|
||||
// Create a copy of member variables we still need, since they will
|
||||
// not be accessible after dismiss:
|
||||
const int num_laps = race_manager->modeHasLaps() ? m_lap_spinner->getValue()
|
||||
@ -395,7 +413,7 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
else if (name == "record")
|
||||
{
|
||||
const bool record = m_record_race->getState();
|
||||
race_manager->setRecordRace(record);
|
||||
m_record_this_race = record;
|
||||
m_ai_kart_spinner->setValue(0);
|
||||
// Disable AI when recording ghost race
|
||||
if (record)
|
||||
|
@ -44,6 +44,8 @@ class TrackInfoScreen : public GUIEngine::Screen,
|
||||
/** A pointer to the track of which the info is shown. */
|
||||
Track *m_track;
|
||||
|
||||
bool m_record_this_race;
|
||||
|
||||
// When there is no need to tab through / click on images/labels, we can add directly
|
||||
// irrlicht labels (more complicated uses require the use of our widget set)
|
||||
/** Spinner for number of laps. */
|
||||
|
322
src/states_screens/tracks_and_gp_screen.cpp
Normal file
322
src/states_screens/tracks_and_gp_screen.cpp
Normal file
@ -0,0 +1,322 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2016 SuperTuxKart-Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "states_screens/tracks_and_gp_screen.hpp"
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "guiengine/widget.hpp"
|
||||
#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
|
||||
#include "guiengine/widgets/icon_button_widget.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "race/grand_prix_data.hpp"
|
||||
#include "race/grand_prix_manager.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/track_info_screen.hpp"
|
||||
#include "states_screens/gp_info_screen.hpp"
|
||||
#include "states_screens/waiting_for_others.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace GUIEngine;
|
||||
using namespace irr::core;
|
||||
using namespace irr::video;
|
||||
|
||||
static const char ALL_TRACK_GROUPS_ID[] = "all";
|
||||
|
||||
DEFINE_SCREEN_SINGLETON( TracksAndGPScreen );
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void TracksAndGPScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
const int playerID)
|
||||
{
|
||||
// -- track selection screen
|
||||
if (name == "tracks")
|
||||
{
|
||||
DynamicRibbonWidget* w2 = dynamic_cast<DynamicRibbonWidget*>(widget);
|
||||
if(!w2) return;
|
||||
|
||||
std::string selection = w2->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
if (UserConfigParams::logGUI())
|
||||
{
|
||||
Log::info("TracksAndGPScreen", "Clicked on track '%s'.",
|
||||
selection.c_str());
|
||||
}
|
||||
|
||||
UserConfigParams::m_last_track = selection;
|
||||
if (selection == "locked" && race_manager->getNumLocalPlayers() == 1)
|
||||
{
|
||||
unlock_manager->playLockSound();
|
||||
return;
|
||||
}
|
||||
else if (selection == RibbonWidget::NO_ITEM_ID)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (selection == "random_track")
|
||||
{
|
||||
if (m_random_track_list.empty()) return;
|
||||
|
||||
selection = m_random_track_list.front();
|
||||
m_random_track_list.pop_front();
|
||||
m_random_track_list.push_back(selection);
|
||||
|
||||
} // selection=="random_track"
|
||||
Track *track = track_manager->getTrack(selection);
|
||||
|
||||
if (track)
|
||||
{
|
||||
TrackInfoScreen::getInstance()->setTrack(track);
|
||||
TrackInfoScreen::getInstance()->push();
|
||||
} // if clicked_track
|
||||
|
||||
} // name=="tracks"
|
||||
else if (name == "gps")
|
||||
{
|
||||
DynamicRibbonWidget* gps_widget = dynamic_cast<DynamicRibbonWidget*>(widget);
|
||||
const std::string &selection =
|
||||
gps_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
|
||||
if (selection == "locked" && race_manager->getNumLocalPlayers()==1)
|
||||
{
|
||||
unlock_manager->playLockSound();
|
||||
}
|
||||
else
|
||||
{
|
||||
GPInfoScreen *gpis = GPInfoScreen::getInstance();
|
||||
gpis->setGP(selection);
|
||||
gpis->push();
|
||||
}
|
||||
}
|
||||
else if (name == "trackgroups")
|
||||
{
|
||||
RibbonWidget* tabs = this->getWidget<RibbonWidget>("trackgroups");
|
||||
UserConfigParams::m_last_used_track_group = tabs->getSelectionIDString(0);
|
||||
buildTrackList();
|
||||
}
|
||||
else if (name == "back")
|
||||
{
|
||||
StateManager::get()->escapePressed();
|
||||
}
|
||||
} // eventCallback
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void TracksAndGPScreen::beforeAddingWidget()
|
||||
{
|
||||
Screen::init();
|
||||
RibbonWidget* tabs = getWidget<RibbonWidget>("trackgroups");
|
||||
tabs->clearAllChildren();
|
||||
|
||||
const std::vector<std::string>& groups = track_manager->getAllTrackGroups();
|
||||
const int group_amount = (int)groups.size();
|
||||
|
||||
if (group_amount > 1)
|
||||
{
|
||||
//I18N: name of the tab that will show tracks from all groups
|
||||
tabs->addTextChild( _("All"), ALL_TRACK_GROUPS_ID );
|
||||
}
|
||||
|
||||
// Make group names being picked up by gettext
|
||||
#define FOR_GETTEXT_ONLY(x)
|
||||
//I18N: track group name
|
||||
FOR_GETTEXT_ONLY( _("all") )
|
||||
//I18N: track group name
|
||||
FOR_GETTEXT_ONLY( _("standard") )
|
||||
//I18N: track group name
|
||||
FOR_GETTEXT_ONLY( _("Add-Ons") )
|
||||
|
||||
// add behind the other categories
|
||||
for (int n=0; n<group_amount; n++)
|
||||
tabs->addTextChild( _(groups[n].c_str()), groups[n] );
|
||||
|
||||
DynamicRibbonWidget* tracks_widget = getWidget<DynamicRibbonWidget>("tracks");
|
||||
tracks_widget->setItemCountHint( (int)track_manager->getNumberOfTracks()+1 );
|
||||
} // beforeAddingWidget
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void TracksAndGPScreen::init()
|
||||
{
|
||||
DynamicRibbonWidget* gps_widget = getWidget<DynamicRibbonWidget>("gps");
|
||||
DynamicRibbonWidget* tracks_widget = getWidget<DynamicRibbonWidget>("tracks");
|
||||
assert(tracks_widget != NULL);
|
||||
|
||||
// Reset GP list everytime (accounts for locking changes, etc.)
|
||||
gps_widget->clearItems();
|
||||
gps_widget->setMaxLabelLength(30);
|
||||
|
||||
// Ensure that no GP and no track is NULL
|
||||
grand_prix_manager->checkConsistency();
|
||||
|
||||
// Build GP list
|
||||
const int gpAmount = grand_prix_manager->getNumberOfGrandPrix();
|
||||
for (int n=0; n<gpAmount; n++)
|
||||
{
|
||||
const GrandPrixData* gp = grand_prix_manager->getGrandPrix(n);
|
||||
const std::vector<std::string> tracks = gp->getTrackNames(true);
|
||||
|
||||
//Skip epmpty GPs
|
||||
if (gp->getNumberOfTracks()==0)
|
||||
continue;
|
||||
|
||||
std::vector<std::string> screenshots;
|
||||
for (unsigned int t=0; t<tracks.size(); t++)
|
||||
{
|
||||
const Track* curr = track_manager->getTrack(tracks[t]);
|
||||
screenshots.push_back(curr->getScreenshotFile());
|
||||
}
|
||||
assert(screenshots.size() > 0);
|
||||
|
||||
if (PlayerManager::getCurrentPlayer()->isLocked(gp->getId()) &&
|
||||
race_manager->getNumLocalPlayers() == 1)
|
||||
{
|
||||
gps_widget->addAnimatedItem(_("Locked!"), "locked",
|
||||
screenshots, 1.5f,
|
||||
LOCKED_BADGE | TROPHY_BADGE,
|
||||
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gps_widget->addAnimatedItem(translations->fribidize(gp->getName()),
|
||||
gp->getId(), screenshots, 1.5f,
|
||||
TROPHY_BADGE,
|
||||
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
||||
}
|
||||
}
|
||||
|
||||
// Random GP
|
||||
std::vector<std::string> screenshots;
|
||||
screenshots.push_back(file_manager->getAsset(FileManager::GUI, "main_help.png"));
|
||||
gps_widget->addAnimatedItem(translations->fribidize(GrandPrixData::getRandomGPName()),
|
||||
GrandPrixData::getRandomGPID(),
|
||||
screenshots, 1.5f, 0,
|
||||
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
||||
|
||||
gps_widget->updateItemDisplay();
|
||||
|
||||
|
||||
RibbonWidget* tabs = getWidget<RibbonWidget>("trackgroups");
|
||||
tabs->select(UserConfigParams::m_last_used_track_group, PLAYER_ID_GAME_MASTER);
|
||||
|
||||
buildTrackList();
|
||||
|
||||
// select old track for the game master (if found)
|
||||
irr_driver->setTextureErrorMessage(
|
||||
"While loading screenshot in track screen for last track '%s':",
|
||||
UserConfigParams::m_last_track);
|
||||
if (!tracks_widget->setSelection(UserConfigParams::m_last_track,
|
||||
PLAYER_ID_GAME_MASTER, true))
|
||||
{
|
||||
tracks_widget->setSelection(0, PLAYER_ID_GAME_MASTER, true);
|
||||
}
|
||||
irr_driver->unsetTextureErrorMessage();
|
||||
} // init
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** Rebuild the list of tracks and GPs. This need to be recomputed e.g. to
|
||||
* take unlocked tracks into account.
|
||||
*/
|
||||
void TracksAndGPScreen::buildTrackList()
|
||||
{
|
||||
DynamicRibbonWidget* tracks_widget = this->getWidget<DynamicRibbonWidget>("tracks");
|
||||
RibbonWidget* tabs = this->getWidget<RibbonWidget>("trackgroups");
|
||||
|
||||
// Reset track list everytime (accounts for locking changes, etc.)
|
||||
tracks_widget->clearItems();
|
||||
m_random_track_list.clear();
|
||||
|
||||
const std::string& curr_group_name = tabs->getSelectionIDString(0);
|
||||
|
||||
const int track_amount = (int)track_manager->getNumberOfTracks();
|
||||
|
||||
// First build a list of all tracks to be displayed
|
||||
// (e.g. exclude arenas, ...)
|
||||
PtrVector<Track, REF> tracks;
|
||||
for (int n = 0; n < track_amount; n++)
|
||||
{
|
||||
Track* curr = track_manager->getTrack(n);
|
||||
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_EASTER_EGG
|
||||
&& !curr->hasEasterEggs())
|
||||
continue;
|
||||
if (curr->isArena() || curr->isSoccer()||curr->isInternal()) continue;
|
||||
if (curr_group_name != ALL_TRACK_GROUPS_ID &&
|
||||
!curr->isInGroup(curr_group_name)) continue;
|
||||
|
||||
tracks.push_back(curr);
|
||||
} // for n<track_amount
|
||||
|
||||
tracks.insertionSort();
|
||||
for (unsigned int i = 0; i < tracks.size(); i++)
|
||||
{
|
||||
Track *curr = tracks.get(i);
|
||||
if (PlayerManager::getCurrentPlayer()->isLocked(curr->getIdent()) &&
|
||||
race_manager->getNumLocalPlayers() == 1)
|
||||
{
|
||||
tracks_widget->addItem(
|
||||
_("Locked: solve active challenges to gain access to more!"),
|
||||
"locked", curr->getScreenshotFile(), LOCKED_BADGE,
|
||||
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
||||
}
|
||||
else
|
||||
{
|
||||
tracks_widget->addItem(translations->fribidize(curr->getName()),
|
||||
curr->getIdent(),
|
||||
curr->getScreenshotFile(), 0,
|
||||
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
||||
m_random_track_list.push_back(curr->getIdent());
|
||||
}
|
||||
}
|
||||
|
||||
tracks_widget->addItem(_("Random Track"), "random_track",
|
||||
"/gui/track_random.png", 0 /* no badge */,
|
||||
IconButtonWidget::ICON_PATH_TYPE_RELATIVE);
|
||||
|
||||
tracks_widget->updateItemDisplay();
|
||||
std::random_shuffle( m_random_track_list.begin(), m_random_track_list.end() );
|
||||
} // buildTrackList
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void TracksAndGPScreen::setFocusOnTrack(const std::string& trackName)
|
||||
{
|
||||
DynamicRibbonWidget* tracks_widget = this->getWidget<DynamicRibbonWidget>("tracks");
|
||||
|
||||
// only the game master can select tracks,
|
||||
// so it's safe to use 'PLAYER_ID_GAME_MASTER'
|
||||
tracks_widget->setSelection(trackName, PLAYER_ID_GAME_MASTER, true);
|
||||
} // setFocusOnTrack
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void TracksAndGPScreen::setFocusOnGP(const std::string& gpName)
|
||||
{
|
||||
DynamicRibbonWidget* gps_widget = getWidget<DynamicRibbonWidget>("gps");
|
||||
|
||||
// only the game master can select tracks/GPs,
|
||||
// so it's safe to use 'PLAYER_ID_GAME_MASTER'
|
||||
gps_widget->setSelection(gpName, PLAYER_ID_GAME_MASTER, true);
|
||||
} // setFocusOnGP
|
||||
|
||||
// -----------------------------------------------------------------------------
|
66
src/states_screens/tracks_and_gp_screen.hpp
Normal file
66
src/states_screens/tracks_and_gp_screen.hpp
Normal file
@ -0,0 +1,66 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2016 SuperTuxKart-Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_TRACKS_AND_GP_SCREEN_HPP
|
||||
#define HEADER_TRACKS_AND_GP_SCREEN_HPP
|
||||
|
||||
#include "guiengine/screen.hpp"
|
||||
#include <deque>
|
||||
|
||||
namespace GUIEngine { class Widget; }
|
||||
|
||||
/**
|
||||
* \brief screen where the user can select a track or grand prix
|
||||
* \ingroup states_screens
|
||||
*/
|
||||
class TracksAndGPScreen : public GUIEngine::Screen,
|
||||
public GUIEngine::ScreenSingleton<TracksAndGPScreen>
|
||||
{
|
||||
friend class GUIEngine::ScreenSingleton<TracksAndGPScreen>;
|
||||
|
||||
private:
|
||||
|
||||
TracksAndGPScreen() : Screen("tracks_and_gp.stkgui") {}
|
||||
|
||||
/** adds the tracks from the current track group into the tracks ribbon */
|
||||
void buildTrackList();
|
||||
|
||||
std::deque<std::string> m_random_track_list;
|
||||
|
||||
public:
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void loadedFromFile() OVERRIDE {};
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void eventCallback(GUIEngine::Widget* widget,
|
||||
const std::string& name,
|
||||
const int playerID) OVERRIDE;
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void init() OVERRIDE;
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void beforeAddingWidget() OVERRIDE;
|
||||
|
||||
|
||||
void setFocusOnTrack(const std::string& trackName);
|
||||
void setFocusOnGP(const std::string& gpName);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -29,11 +29,8 @@
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/protocols/client_lobby_room_protocol.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include "race/grand_prix_data.hpp"
|
||||
#include "race/grand_prix_manager.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/track_info_screen.hpp"
|
||||
#include "states_screens/gp_info_screen.hpp"
|
||||
#include "states_screens/waiting_for_others.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
@ -97,7 +94,7 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
->getProtocol(PROTOCOL_LOBBY_ROOM);
|
||||
ClientLobbyRoomProtocol* clrp =
|
||||
static_cast<ClientLobbyRoomProtocol*>(protocol);
|
||||
// FIXME SPLITSCREEN: we need to supply the global player id of the
|
||||
// FIXME SPLITSCREEN: we need to supply the global player id of the
|
||||
// player selecting the track here. For now ... just vote the same
|
||||
// track for each local player.
|
||||
std::vector<NetworkPlayerProfile*> players =
|
||||
@ -116,31 +113,6 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
} // if clicked_track
|
||||
|
||||
} // name=="tracks"
|
||||
else if (name == "gps")
|
||||
{
|
||||
DynamicRibbonWidget* gps_widget = dynamic_cast<DynamicRibbonWidget*>(widget);
|
||||
const std::string &selection =
|
||||
gps_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
|
||||
if (selection == "locked" && race_manager->getNumLocalPlayers()==1)
|
||||
{
|
||||
unlock_manager->playLockSound();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(STKHost::existHost())
|
||||
{
|
||||
Log::warn("TracksScreen",
|
||||
"FIXME: for now do not select a grand prix.");
|
||||
}
|
||||
else
|
||||
{
|
||||
GPInfoScreen *gpis = GPInfoScreen::getInstance();
|
||||
gpis->setGP(selection);
|
||||
gpis->push();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (name == "trackgroups")
|
||||
{
|
||||
RibbonWidget* tabs = this->getWidget<RibbonWidget>("trackgroups");
|
||||
@ -170,15 +142,6 @@ void TracksScreen::beforeAddingWidget()
|
||||
tabs->addTextChild( _("All"), ALL_TRACK_GROUPS_ID );
|
||||
}
|
||||
|
||||
// Make group names being picked up by gettext
|
||||
#define FOR_GETTEXT_ONLY(x)
|
||||
//I18N: track group name
|
||||
FOR_GETTEXT_ONLY( _("all") )
|
||||
//I18N: track group name
|
||||
FOR_GETTEXT_ONLY( _("standard") )
|
||||
//I18N: track group name
|
||||
FOR_GETTEXT_ONLY( _("Add-Ons") )
|
||||
|
||||
// add behind the other categories
|
||||
for (int n=0; n<group_amount; n++)
|
||||
tabs->addTextChild( _(groups[n].c_str()), groups[n] );
|
||||
@ -191,64 +154,9 @@ void TracksScreen::beforeAddingWidget()
|
||||
|
||||
void TracksScreen::init()
|
||||
{
|
||||
DynamicRibbonWidget* gps_widget = getWidget<DynamicRibbonWidget>("gps");
|
||||
DynamicRibbonWidget* tracks_widget = getWidget<DynamicRibbonWidget>("tracks");
|
||||
assert(tracks_widget != NULL);
|
||||
|
||||
// Reset GP list everytime (accounts for locking changes, etc.)
|
||||
gps_widget->clearItems();
|
||||
gps_widget->setMaxLabelLength(30);
|
||||
|
||||
// Ensure that no GP and no track is NULL
|
||||
grand_prix_manager->checkConsistency();
|
||||
|
||||
// Build GP list
|
||||
const int gpAmount = grand_prix_manager->getNumberOfGrandPrix();
|
||||
for (int n=0; n<gpAmount; n++)
|
||||
{
|
||||
const GrandPrixData* gp = grand_prix_manager->getGrandPrix(n);
|
||||
const std::vector<std::string> tracks = gp->getTrackNames(true);
|
||||
|
||||
//Skip epmpty GPs
|
||||
if (gp->getNumberOfTracks()==0)
|
||||
continue;
|
||||
|
||||
std::vector<std::string> screenshots;
|
||||
for (unsigned int t=0; t<tracks.size(); t++)
|
||||
{
|
||||
const Track* curr = track_manager->getTrack(tracks[t]);
|
||||
screenshots.push_back(curr->getScreenshotFile());
|
||||
}
|
||||
assert(screenshots.size() > 0);
|
||||
|
||||
if (PlayerManager::getCurrentPlayer()->isLocked(gp->getId()) &&
|
||||
race_manager->getNumLocalPlayers() == 1)
|
||||
{
|
||||
gps_widget->addAnimatedItem(_("Locked!"), "locked",
|
||||
screenshots, 1.5f,
|
||||
LOCKED_BADGE | TROPHY_BADGE,
|
||||
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gps_widget->addAnimatedItem(translations->fribidize(gp->getName()),
|
||||
gp->getId(), screenshots, 1.5f,
|
||||
TROPHY_BADGE,
|
||||
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
||||
}
|
||||
}
|
||||
|
||||
// Random GP
|
||||
std::vector<std::string> screenshots;
|
||||
screenshots.push_back(file_manager->getAsset(FileManager::GUI, "main_help.png"));
|
||||
gps_widget->addAnimatedItem(translations->fribidize(GrandPrixData::getRandomGPName()),
|
||||
GrandPrixData::getRandomGPID(),
|
||||
screenshots, 1.5f, 0,
|
||||
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
||||
|
||||
gps_widget->updateItemDisplay();
|
||||
|
||||
|
||||
RibbonWidget* tabs = getWidget<RibbonWidget>("trackgroups");
|
||||
tabs->select(UserConfigParams::m_last_used_track_group, PLAYER_ID_GAME_MASTER);
|
||||
|
||||
@ -267,7 +175,7 @@ void TracksScreen::init()
|
||||
} // init
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** Rebuild the list of tracks and GPs. This need to be recomputed e.g. to
|
||||
/** Rebuild the list of tracks. This need to be recomputed e.g. to
|
||||
* take unlocked tracks into account.
|
||||
*/
|
||||
void TracksScreen::buildTrackList()
|
||||
@ -281,6 +189,14 @@ void TracksScreen::buildTrackList()
|
||||
|
||||
const std::string& curr_group_name = tabs->getSelectionIDString(0);
|
||||
|
||||
if (!(curr_group_name == DEFAULT_GROUP_NAME ||
|
||||
curr_group_name == ALL_TRACK_GROUPS_ID) && m_offical_track)
|
||||
{
|
||||
tracks_widget->setText(_("Only Offical track is supported."));
|
||||
tracks_widget->updateItemDisplay();
|
||||
return;
|
||||
}
|
||||
|
||||
const int track_amount = (int)track_manager->getNumberOfTracks();
|
||||
|
||||
// First build a list of all tracks to be displayed
|
||||
@ -293,6 +209,7 @@ void TracksScreen::buildTrackList()
|
||||
&& !curr->hasEasterEggs())
|
||||
continue;
|
||||
if (curr->isArena() || curr->isSoccer()||curr->isInternal()) continue;
|
||||
if (m_offical_track && !curr->isInGroup(DEFAULT_GROUP_NAME)) continue;
|
||||
if (curr_group_name != ALL_TRACK_GROUPS_ID &&
|
||||
!curr->isInGroup(curr_group_name)) continue;
|
||||
|
||||
@ -341,14 +258,3 @@ void TracksScreen::setFocusOnTrack(const std::string& trackName)
|
||||
} // setFocusOnTrack
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void TracksScreen::setFocusOnGP(const std::string& gpName)
|
||||
{
|
||||
DynamicRibbonWidget* gps_widget = getWidget<DynamicRibbonWidget>("gps");
|
||||
|
||||
// only the game master can select tracks/GPs,
|
||||
// so it's safe to use 'PLAYER_ID_GAME_MASTER'
|
||||
gps_widget->setSelection(gpName, PLAYER_ID_GAME_MASTER, true);
|
||||
} // setFocusOnGP
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -32,6 +32,7 @@ class TracksScreen : public GUIEngine::Screen,
|
||||
{
|
||||
friend class GUIEngine::ScreenSingleton<TracksScreen>;
|
||||
|
||||
private:
|
||||
TracksScreen() : Screen("tracks.stkgui") {}
|
||||
|
||||
/** adds the tracks from the current track group into the tracks ribbon */
|
||||
@ -39,6 +40,8 @@ class TracksScreen : public GUIEngine::Screen,
|
||||
|
||||
std::deque<std::string> m_random_track_list;
|
||||
|
||||
bool m_offical_track;
|
||||
|
||||
public:
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
@ -55,9 +58,9 @@ public:
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void beforeAddingWidget() OVERRIDE;
|
||||
|
||||
void setOfficalTrack(bool offical) { m_offical_track = offical; }
|
||||
|
||||
void setFocusOnTrack(const std::string& trackName);
|
||||
void setFocusOnGP(const std::string& gpName);
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user