GUI work for profiles. A common inherited base screen for the different tabs. Friends screen added.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13434 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
unitraxx 2013-08-07 15:03:33 +00:00
parent bf5eccf4ed
commit b0ff13299c
9 changed files with 194 additions and 86 deletions

View File

@ -0,0 +1,33 @@
<stkgui>
<div x="1%" y="1%" width="98%" height="98%" layout="vertical-row" >
<header id="title" text_align="center" width="80%" align="center" text="..."/>
<spacer height="25" width="10"/>
<tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
<icon-button id="tab_overview" width="128" height="128" icon="gui/options_video.png" />
<icon-button id="tab_friends" width="128" height="128" icon="gui/options_video.png" I18N="Section in the profile menu" text="Friends"/>
</tabs>
<box proportion="1" width="100%" layout="vertical-row">
<div x="1%" y="2%" width="98%" height="96%" layout="vertical-row" >
<div proportion="1" width="100%" layout="horizontal-row">
<box proportion="1" height="100%" align="center" layout="vertical-row" padding="0">
<list id="friends_list" x="0" y="0" width="100%" height="100%"/>
</box>
<spacer width="2%" height="10"/>
<div proportion="1" height="100%" layout="vertical-row" > </div>
</div>
<div proportion="1" width="100%" layout="horizontal-row" > </div>
</div>
</box>
</div>
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
</stkgui>

View File

@ -8,6 +8,7 @@
<tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
<icon-button id="tab_overview" width="128" height="128" icon="gui/options_video.png" I18N="Section in the profile menu" text="Overview"/>
<icon-button id="tab_friends" width="128" height="128" icon="gui/options_video.png" />
</tabs>
<box proportion="1" width="100%" layout="vertical-row">

View File

@ -229,6 +229,7 @@ src/states_screens/main_menu_screen.cpp
src/states_screens/networking_lobby.cpp
src/states_screens/network_kart_selection.cpp
src/states_screens/offline_kart_selection.cpp
src/states_screens/online_profile_base.cpp
src/states_screens/online_profile_friends.cpp
src/states_screens/online_profile_overview.cpp
src/states_screens/online_screen.cpp
@ -527,6 +528,7 @@ src/states_screens/main_menu_screen.hpp
src/states_screens/networking_lobby.hpp
src/states_screens/network_kart_selection.hpp
src/states_screens/offline_kart_selection.hpp
src/states_screens/online_profile_base.hpp
src/states_screens/online_profile_friends.hpp
src/states_screens/online_profile_overview.hpp
src/states_screens/online_screen.hpp

View File

@ -0,0 +1,86 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013 Glenn De Jonghe
//
// 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/online_profile_base.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/scalable_font.hpp"
#include "guiengine/screen.hpp"
#include "guiengine/widget.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/translation.hpp"
#include "states_screens/online_profile_overview.hpp"
#include "states_screens/online_profile_friends.hpp"
#include <iostream>
#include <sstream>
using namespace GUIEngine;
using namespace irr::core;
using namespace irr::gui;
using namespace Online;
OnlineProfileBase::OnlineProfileBase(const char* filename) : Screen(filename)
{
} // OnlineProfileBase
// -----------------------------------------------------------------------------
void OnlineProfileBase::loadedFromFile()
{
m_profile_tabs = this->getWidget<RibbonWidget>("profile_tabs");
assert(m_profile_tabs != NULL);
LabelWidget * header = this->getWidget<LabelWidget>("title");
assert(header != NULL);
header->setText(_("Your profile"), false);
m_overview_tab = (IconButtonWidget *) m_profile_tabs->findWidgetNamed("tab_overview");
assert(m_overview_tab != NULL);
m_friends_tab = (IconButtonWidget *) m_profile_tabs->findWidgetNamed("tab_friends");
assert(m_friends_tab != NULL);
} // loadedFromFile
// -----------------------------------------------------------------------------
void OnlineProfileBase::init()
{
Screen::init();
m_overview_tab->setTooltip( _("Overview") );
m_friends_tab->setTooltip( _("Friends") );
} // init
// -----------------------------------------------------------------------------
void OnlineProfileBase::eventCallback(Widget* widget, const std::string& name, const int playerID)
{
if (name == m_profile_tabs->m_properties[PROP_ID])
{
std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str();
if (selection == m_overview_tab->m_properties[PROP_ID]) StateManager::get()->replaceTopMostScreen(OnlineProfileOverview::getInstance());
else if (selection == m_friends_tab->m_properties[PROP_ID]) StateManager::get()->replaceTopMostScreen(OnlineProfileFriends::getInstance());
}
else if (name == "back")
{
StateManager::get()->escapePressed();
}
} // eventCallback

View File

@ -0,0 +1,55 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013 Glenn De Jonghe
//
// 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_ONLINE_PROFILE_BASE_HPP__
#define __HEADER_ONLINE_PROFILE_BASE_HPP__
#include <string>
#include <irrString.h>
#include "guiengine/screen.hpp"
#include "guiengine/widgets.hpp"
namespace GUIEngine { class Widget; }
/**
* \brief Online profiel overview screen
* \ingroup states_screens
*/
class OnlineProfileBase : public GUIEngine::Screen
{
protected:
OnlineProfileBase(const char* filename);
GUIEngine::RibbonWidget* m_profile_tabs;
GUIEngine::IconButtonWidget * m_overview_tab;
GUIEngine::IconButtonWidget * m_friends_tab;
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;
};
#endif

View File

@ -1,5 +1,5 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2010 Glenn De Jonghe
// Copyright (C) 2013 Glenn De Jonghe
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -38,59 +38,28 @@ DEFINE_SCREEN_SINGLETON( OnlineProfileFriends );
// -----------------------------------------------------------------------------
OnlineProfileFriends::OnlineProfileFriends() : Screen("online/profile_overview.stkgui")
OnlineProfileFriends::OnlineProfileFriends() : OnlineProfileBase("online/profile_friends.stkgui")
{
} // OnlineProfileFriends
// -----------------------------------------------------------------------------
void OnlineProfileFriends::loadedFromFile()
{
m_profile_tabs = this->getWidget<RibbonWidget>("profile_tabs");
assert(m_profile_tabs != NULL);
LabelWidget * header = this->getWidget<LabelWidget>("title");
assert(header != NULL);
header->setText(_("Your profile"), false);
OnlineProfileBase::loadedFromFile();
} // loadedFromFile
// -----------------------------------------------------------------------------
void OnlineProfileFriends::init()
{
Screen::init();
m_profile_tabs->select( "tab_players", PLAYER_ID_GAME_MASTER );
/*
tabBar->getRibbonChildren()[0].setTooltip( _("Graphics") );
tabBar->getRibbonChildren()[1].setTooltip( _("Audio") );
tabBar->getRibbonChildren()[2].setTooltip( _("User Interface") );
tabBar->getRibbonChildren()[4].setTooltip( _("Controls") );*/
OnlineProfileBase::init();
m_profile_tabs->select( m_friends_tab->m_properties[PROP_ID], PLAYER_ID_GAME_MASTER );
} // init
// -----------------------------------------------------------------------------
void OnlineProfileFriends::tearDown()
{
Screen::tearDown();
} // tearDown
// -----------------------------------------------------------------------------
void OnlineProfileFriends::eventCallback(Widget* widget, const std::string& name, const int playerID)
{
if (name == m_profile_tabs->m_properties[PROP_ID])
{
std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str();
//if (selection == "tab_audio") StateManager::get()->replaceTopMostScreen(OptionsScreenAudio::getInstance());
}
else if (name == "back")
{
StateManager::get()->escapePressed();
}
OnlineProfileBase::eventCallback( widget, name, playerID);
} // eventCallback

View File

@ -24,6 +24,7 @@
#include "guiengine/screen.hpp"
#include "guiengine/widgets.hpp"
#include "states_screens/online_profile_base.hpp"
namespace GUIEngine { class Widget; }
@ -32,13 +33,11 @@ namespace GUIEngine { class Widget; }
* \brief Online profiel overview screen
* \ingroup states_screens
*/
class OnlineProfileFriends : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<OnlineProfileFriends>
class OnlineProfileFriends : public OnlineProfileBase, public GUIEngine::ScreenSingleton<OnlineProfileFriends>
{
private:
OnlineProfileFriends();
GUIEngine::RibbonWidget* m_profile_tabs;
public:
friend class GUIEngine::ScreenSingleton<OnlineProfileFriends>;
@ -46,14 +45,10 @@ public:
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;
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 tearDown() OVERRIDE;
};
#endif

View File

@ -38,22 +38,15 @@ DEFINE_SCREEN_SINGLETON( OnlineProfileOverview );
// -----------------------------------------------------------------------------
OnlineProfileOverview::OnlineProfileOverview() : Screen("online/profile_overview.stkgui")
OnlineProfileOverview::OnlineProfileOverview() : OnlineProfileBase("online/profile_overview.stkgui")
{
} // OnlineProfileOverview
// -----------------------------------------------------------------------------
void OnlineProfileOverview::loadedFromFile()
{
m_profile_tabs = this->getWidget<RibbonWidget>("profile_tabs");
assert(m_profile_tabs != NULL);
LabelWidget * header = this->getWidget<LabelWidget>("title");
assert(header != NULL);
header->setText(_("Your profile"), false);
OnlineProfileBase::loadedFromFile();
} // loadedFromFile
@ -61,36 +54,14 @@ void OnlineProfileOverview::loadedFromFile()
void OnlineProfileOverview::init()
{
Screen::init();
m_profile_tabs->select( "tab_players", PLAYER_ID_GAME_MASTER );
/*
tabBar->getRibbonChildren()[0].setTooltip( _("Graphics") );
tabBar->getRibbonChildren()[1].setTooltip( _("Audio") );
tabBar->getRibbonChildren()[2].setTooltip( _("User Interface") );
tabBar->getRibbonChildren()[4].setTooltip( _("Controls") );*/
OnlineProfileBase::init();
m_profile_tabs->select( m_overview_tab->m_properties[PROP_ID], PLAYER_ID_GAME_MASTER );
} // init
// -----------------------------------------------------------------------------
void OnlineProfileOverview::tearDown()
{
Screen::tearDown();
} // tearDown
// -----------------------------------------------------------------------------
void OnlineProfileOverview::eventCallback(Widget* widget, const std::string& name, const int playerID)
{
if (name == m_profile_tabs->m_properties[PROP_ID])
{
std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str();
//if (selection == "tab_audio") StateManager::get()->replaceTopMostScreen(OptionsScreenAudio::getInstance());
}
else if (name == "back")
{
StateManager::get()->escapePressed();
}
OnlineProfileBase::eventCallback( widget, name, playerID);
} // eventCallback

View File

@ -24,6 +24,7 @@
#include "guiengine/screen.hpp"
#include "guiengine/widgets.hpp"
#include "states_screens/online_profile_base.hpp"
namespace GUIEngine { class Widget; }
@ -32,13 +33,11 @@ namespace GUIEngine { class Widget; }
* \brief Online profiel overview screen
* \ingroup states_screens
*/
class OnlineProfileOverview : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<OnlineProfileOverview>
class OnlineProfileOverview : public OnlineProfileBase, public GUIEngine::ScreenSingleton<OnlineProfileOverview>
{
private:
protected:
OnlineProfileOverview();
GUIEngine::RibbonWidget* m_profile_tabs;
public:
friend class GUIEngine::ScreenSingleton<OnlineProfileOverview>;
@ -51,9 +50,6 @@ public:
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void init() OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void tearDown() OVERRIDE;
};
#endif