Merge branch 'master' of github.com:supertuxkart/stk-code
This commit is contained in:
commit
7744b056ea
29
data/gui/online/lan.stkgui
Normal file
29
data/gui/online/lan.stkgui
Normal file
@ -0,0 +1,29 @@
|
||||
<?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="98%" layout="vertical-row" >
|
||||
<header id="title" text_align="center" width="80%" align="center" text="Local Networking"/>
|
||||
|
||||
<spacer height="5%" width="10"/>
|
||||
<icon id="logo" align="center" proportion="1" width="100%" icon="gui/logo.png"/>
|
||||
<spacer height="5%" width="10"/>
|
||||
|
||||
<buttonbar id="lan" proportion="1" width="90%" align="center">
|
||||
<icon-button id="find_lan_server" width="128" height="128"
|
||||
icon="gui/online/menu_find_server.png" focus_icon="gui/online/menu_find_server_hover.png"
|
||||
I18N="In the online multiplayer screen" text="Find Server"/>
|
||||
<icon-button id="create_lan_server" width="128" height="128"
|
||||
icon="gui/online/menu_create_server.png" focus_icon="gui/online/menu_create_server_hover.png"
|
||||
I18N="In the online multiplayer screen" text="Create Server"/>
|
||||
<!--
|
||||
<icon-button id="manage_user" width="128" height="128"
|
||||
icon="gui/options_players.png"
|
||||
I18N="In the online multiplayer screen" text="Users"/>
|
||||
-->
|
||||
</buttonbar>
|
||||
|
||||
<spacer height="10%" width="10"/>
|
||||
|
||||
</div>
|
||||
</stkgui>
|
29
data/gui/online/online.stkgui
Normal file
29
data/gui/online/online.stkgui
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<stkgui>
|
||||
<div x="0" y="0" width="100%" height="100%" layout="vertical-row" >
|
||||
<header text_align="center" width="80%" align="center" text="Online"/>
|
||||
<spacer height="15" width="10"/>
|
||||
<button id="user-id" width="20%" height="fit" align="center"/>
|
||||
<spacer height="15" width="10"/>
|
||||
<icon id="logo" align="center" proportion="4" width="100%" icon="gui/logo.png"/>
|
||||
|
||||
<spacer height="15" width="10"/>
|
||||
|
||||
<buttonbar id="menu_toprow" proportion="3" width="90%" align="center">
|
||||
<icon-button id="lan" width="128" height="128"
|
||||
icon="gui/menu_multi.png" focus_icon="gui/menu_multi_focus.png"
|
||||
I18N="Networking menu button" text="Local Networking"/>
|
||||
<icon-button id="wan" width="128" height="128"
|
||||
icon="gui/menu_multi.png" focus_icon="gui/menu_multi_focus.png"
|
||||
I18N="Networking menu button" text="Global Networking"/>
|
||||
<icon-button id="online" width="128" height="128"
|
||||
icon="gui/menu_online.png" focus_icon="gui/menu_online_focus.png"
|
||||
I18N="Networking menu button" text="Your profile"/>
|
||||
</buttonbar>
|
||||
|
||||
<spacer height="10%" width="10"/>
|
||||
|
||||
</div>
|
||||
|
||||
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
|
||||
</stkgui>
|
@ -9,7 +9,6 @@
|
||||
<spacer height="25" width="10"/>
|
||||
|
||||
<tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
|
||||
<icon-button id="tab_servers" width="128" height="128" icon="gui/main_network.png"/>
|
||||
<icon-button id="tab_achievements" width="128" height="128" icon="gui/gp_copy.png"
|
||||
I18N="Section in the profile screen" text="Achievements"/>
|
||||
<icon-button id="tab_friends" width="128" height="128" icon="gui/options_players.png"/>
|
||||
|
@ -9,7 +9,6 @@
|
||||
<spacer height="25" width="10"/>
|
||||
|
||||
<tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
|
||||
<icon-button id="tab_servers" width="128" height="128" icon="gui/main_network.png"/>
|
||||
<icon-button id="tab_achievements" width="128" height="128" icon="gui/gp_copy.png"/>
|
||||
<icon-button id="tab_friends" width="128" height="128" icon="gui/options_players.png"
|
||||
I18N="Section in the profile screen" text="Friends"/>
|
||||
|
@ -3,46 +3,13 @@
|
||||
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
|
||||
|
||||
<div x="1%" y="1%" width="98%" height="98%" layout="vertical-row" >
|
||||
<header id="title" text_align="center" width="80%" align="center" text="..."/>
|
||||
<header id="title" text_align="center" width="80%" align="center" text="Global Networking"/>
|
||||
|
||||
<spacer height="25" width="10"/>
|
||||
<spacer height="5%" width="10"/>
|
||||
<icon id="logo" align="center" proportion="1" width="100%" icon="gui/logo.png"/>
|
||||
<spacer height="5%" width="10"/>
|
||||
|
||||
<tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
|
||||
<icon-button id="tab_servers" width="128" height="128" icon="gui/main_network.png" I18N="Section in the profile screen" text="Servers"/>
|
||||
<icon-button id="tab_achievements" width="128" height="128" icon="gui/gp_copy.png"/>
|
||||
<icon-button id="tab_friends" width="128" height="128" icon="gui/options_players.png" />
|
||||
<icon-button id="tab_settings" width="128" height="128" icon="gui/main_options.png" />
|
||||
</tabs>
|
||||
|
||||
<box proportion="1" width="100%" layout="vertical-row">
|
||||
<div x="1%" y="2%" width="98%" height="96%" layout="vertical-row" >
|
||||
|
||||
<spacer height="5%" width="25"/>
|
||||
|
||||
<box width="100%" proportion="1" padding="10" layout="vertical-row">
|
||||
<bright width="100%" text="Local Networking" align="center" text_align="left" />
|
||||
|
||||
<buttonbar id="lan" proportion="2" width="90%" align="center">
|
||||
<icon-button id="find_lan_server" width="128" height="128"
|
||||
icon="gui/online/menu_find_server.png" focus_icon="gui/online/menu_find_server_hover.png"
|
||||
I18N="In the online multiplayer screen" text="Find Server"/>
|
||||
<icon-button id="create_lan_server" width="128" height="128"
|
||||
icon="gui/online/menu_create_server.png" focus_icon="gui/online/menu_create_server_hover.png"
|
||||
I18N="In the online multiplayer screen" text="Create Server"/>
|
||||
<!--
|
||||
<icon-button id="manage_user" width="128" height="128"
|
||||
icon="gui/options_players.png"
|
||||
I18N="In the online multiplayer screen" text="Users"/>
|
||||
-->
|
||||
</buttonbar>
|
||||
</box>
|
||||
|
||||
<spacer height="5%" width="25"/>
|
||||
|
||||
<box width="100%" proportion="1" padding="10" layout="vertical-row">
|
||||
<bright width="100%" text="Global Networking" align="center" text_align="left" />
|
||||
|
||||
<buttonbar id="wan" proportion="2" width="90%" align="center">
|
||||
<buttonbar id="wan" proportion="1" width="90%" align="center">
|
||||
<icon-button id="find_wan_server" width="128" height="128"
|
||||
icon="gui/online/menu_find_server.png" focus_icon="gui/online/menu_find_server_hover.png"
|
||||
I18N="In the online multiplayer screen" text="Find Server"/>
|
||||
@ -53,9 +20,8 @@
|
||||
icon="gui/online/menu_quick_play.png" focus_icon="gui/online/menu_quick_play_hover.png"
|
||||
I18N="In the online multiplayer screen" text="Quick Play"/>
|
||||
</buttonbar>
|
||||
</box>
|
||||
|
||||
<spacer height="10%" width="10"/>
|
||||
|
||||
</div>
|
||||
</box>
|
||||
</div>
|
||||
</stkgui>
|
||||
|
@ -8,7 +8,6 @@
|
||||
<spacer height="25" width="10"/>
|
||||
|
||||
<tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
|
||||
<icon-button id="tab_servers" width="128" height="128" icon="gui/main_network.png"/>
|
||||
<icon-button id="tab_achievements" width="128" height="128" icon="gui/gp_copy.png"/>
|
||||
<icon-button id="tab_friends" width="128" height="128" icon="gui/options_players.png" />
|
||||
<icon-button id="tab_settings" width="128" height="128" icon="gui/main_options.png"
|
||||
|
@ -182,6 +182,7 @@ namespace scene
|
||||
virtual s32 getAnimationSet() const = 0;
|
||||
virtual void addAnimationSet(u32 start, u32 end) = 0;
|
||||
virtual void useAnimationSet(u32 set_num) = 0;
|
||||
virtual void removeAllAnimationSet() = 0;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
|
@ -167,6 +167,7 @@ namespace scene
|
||||
m_animation_set.push_back(start);
|
||||
m_animation_set.push_back(end);
|
||||
}
|
||||
virtual void removeAllAnimationSet() { m_animation_set.clear(); }
|
||||
virtual void useAnimationSet(u32 set_num);
|
||||
virtual void setFrameLoopOnce(s32 begin, s32 end);
|
||||
protected:
|
||||
|
@ -68,7 +68,7 @@ namespace scene
|
||||
|
||||
//! constructor
|
||||
CSkinnedMesh::CSkinnedMesh()
|
||||
: SkinningBuffers(0), AnimationFrames(0.f), FramesPerSecond(25.f),
|
||||
: AnimationFrames(0.f), SkinningBuffers(0), FramesPerSecond(25.f),
|
||||
LastAnimatedFrame(-1), SkinnedLastFrame(false),
|
||||
InterpolationMode(EIM_LINEAR),
|
||||
HasAnimation(false), PreparedForSkinning(false),
|
||||
|
@ -175,6 +175,8 @@ namespace scene
|
||||
|
||||
u32 getTotalJoints() const { return m_total_joints; }
|
||||
|
||||
f32 AnimationFrames;
|
||||
|
||||
private:
|
||||
void toStaticPose();
|
||||
|
||||
@ -215,7 +217,6 @@ private:
|
||||
|
||||
core::aabbox3d<f32> BoundingBox;
|
||||
|
||||
f32 AnimationFrames;
|
||||
f32 FramesPerSecond;
|
||||
|
||||
f32 LastAnimatedFrame;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/mini_glm.hpp"
|
||||
|
||||
#include "../../lib/irrlicht/source/Irrlicht/CSkinnedMesh.h"
|
||||
const uint8_t VERSION_NOW = 1;
|
||||
|
||||
#include <algorithm>
|
||||
@ -47,7 +48,7 @@ scene::IAnimatedMesh* SPMeshLoader::createMesh(io::IReadFile* f)
|
||||
}
|
||||
m_bind_frame = 0;
|
||||
m_joint_count = 0;
|
||||
//m_frame_count = 0;
|
||||
m_frame_count = 0;
|
||||
m_mesh = NULL;
|
||||
m_mesh = m_scene_manager->createSkinnedMesh();
|
||||
io::IFileSystem* fs = m_scene_manager->getFileSystem();
|
||||
@ -196,6 +197,9 @@ scene::IAnimatedMesh* SPMeshLoader::createMesh(io::IReadFile* f)
|
||||
f->read(&pre_computed_size, 2);
|
||||
}
|
||||
m_mesh->finalize();
|
||||
// Because the last frame in spm is usable
|
||||
static_cast<scene::CSkinnedMesh*>(m_mesh)->AnimationFrames =
|
||||
(float)m_frame_count + 1.0f;
|
||||
m_all_armatures.clear();
|
||||
m_to_bind_pose_matrices.clear();
|
||||
m_joints.clear();
|
||||
@ -366,8 +370,8 @@ void SPMeshLoader::createAnimationData(irr::io::IReadFile* spm)
|
||||
}
|
||||
for (unsigned i = 0; i < armature_size; i++)
|
||||
{
|
||||
//m_frame_count = std::max(m_frame_count,
|
||||
// (unsigned)m_all_armatures[i].m_frame_pose_matrices.back().first);
|
||||
m_frame_count = std::max(m_frame_count,
|
||||
(unsigned)m_all_armatures[i].m_frame_pose_matrices.back().first);
|
||||
m_joint_count += m_all_armatures[i].m_joint_used;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ private:
|
||||
unsigned id);
|
||||
};
|
||||
// ------------------------------------------------------------------------
|
||||
unsigned m_bind_frame, m_joint_count;//, m_frame_count;
|
||||
unsigned m_bind_frame, m_joint_count, m_frame_count;
|
||||
// ------------------------------------------------------------------------
|
||||
std::vector<Armature> m_all_armatures;
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -295,6 +295,33 @@ namespace Scripting
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Remove all animation set for a skeletal animation */
|
||||
void removeAllAnimationSet(/** \cond DOXYGEN_IGNORE */void *memory /** \endcond */)
|
||||
{
|
||||
if (memory)
|
||||
{
|
||||
((scene::IAnimatedMeshSceneNode*)(memory))->removeAllAnimationSet();
|
||||
}
|
||||
}
|
||||
|
||||
/** Add an animation set for a skeletal animation */
|
||||
void addAnimationSet(int start/** \cond DOXYGEN_IGNORE */, int end/** \cond DOXYGEN_IGNORE */, /** \cond DOXYGEN_IGNORE */void *memory /** \endcond */)
|
||||
{
|
||||
if (memory)
|
||||
{
|
||||
((scene::IAnimatedMeshSceneNode*)(memory))->addAnimationSet(start, end);
|
||||
}
|
||||
}
|
||||
|
||||
/** use an current frame for a skeletal animation */
|
||||
void useAnimationSet(int set_num /** \cond DOXYGEN_IGNORE */, void *memory /** \endcond */)
|
||||
{
|
||||
if (memory)
|
||||
{
|
||||
((scene::IAnimatedMeshSceneNode*)(memory))->useAnimationSet(set_num);
|
||||
}
|
||||
}
|
||||
|
||||
/** Sets the current frame for a skeletal animation */
|
||||
void setCurrentFrame(int frame /** \cond DOXYGEN_IGNORE */, void *memory /** \endcond */)
|
||||
{
|
||||
@ -465,6 +492,8 @@ namespace Scripting
|
||||
r = engine->RegisterObjectMethod("TrackObject", "void moveTo(const Vec3 &in, bool)", asMETHOD(::TrackObject, moveTo), asCALL_THISCALL); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "Vec3 getCenterPosition()", asFUNCTION(TrackObject::getCenterPosition), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "Vec3 getOrigin()", asFUNCTION(TrackObject::getOrigin), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "TrackObject@ getParentLibrary()", asMETHOD(::TrackObject, getParentLibrary), asCALL_THISCALL); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "string getName()", asMETHOD(::TrackObject, getName), asCALL_THISCALL); assert(r >= 0);
|
||||
|
||||
// PhysicalObject
|
||||
r = engine->RegisterObjectMethod("PhysicalObject", "bool isFlattenKartObject()", asMETHOD(PhysicalObject, isFlattenKartObject), asCALL_THISCALL); assert(r >= 0);
|
||||
@ -476,6 +505,9 @@ namespace Scripting
|
||||
r = engine->RegisterObjectMethod("Mesh", "void setFrameLoopOnce(int start, int end)", asFUNCTION(Mesh::setFrameLoopOnce), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Mesh", "int getFrameNr()", asFUNCTION(Mesh::getFrameNr), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Mesh", "int getAnimationSet()", asFUNCTION(Mesh::getAnimationSet), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Mesh", "void useAnimationSet(int set_num)", asFUNCTION(Mesh::useAnimationSet), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Mesh", "void addAnimationSet(int start, int end)", asFUNCTION(Mesh::addAnimationSet), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Mesh", "void removeAllAnimationSet()", asFUNCTION(Mesh::removeAllAnimationSet), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Mesh", "void setCurrentFrame(int frame)", asFUNCTION(Mesh::setCurrentFrame), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
//r = engine->RegisterObjectMethod("Mesh", "void move(Vec3 &in)", asFUNCTION(movePresentation), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "states_screens/offline_kart_selection.hpp"
|
||||
#include "states_screens/online_profile_achievements.hpp"
|
||||
#include "states_screens/online_profile_servers.hpp"
|
||||
#include "states_screens/online_screen.hpp"
|
||||
#include "states_screens/options_screen_video.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/user_screen.hpp"
|
||||
@ -75,9 +76,6 @@ bool MainMenuScreen::m_enable_online = false;
|
||||
|
||||
MainMenuScreen::MainMenuScreen() : Screen("main_menu.stkgui")
|
||||
{
|
||||
m_online_string = _("Online");
|
||||
//I18N: Used as a verb, appears on the main menu (login button)
|
||||
m_login_string = _("Login");
|
||||
} // MainMenuScreen
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -151,10 +149,7 @@ void MainMenuScreen::init()
|
||||
w->setBadge(LOADING_BADGE);
|
||||
}
|
||||
|
||||
m_online = getWidget<IconButtonWidget>("online");
|
||||
|
||||
if(!m_enable_online)
|
||||
m_online->setActive(false);
|
||||
IconButtonWidget* online = getWidget<IconButtonWidget>("online");
|
||||
|
||||
LabelWidget* w = getWidget<LabelWidget>("info_addons");
|
||||
const core::stringw &news_text = NewsManager::get()->getNextNewsMessage();
|
||||
@ -179,32 +174,25 @@ void MainMenuScreen::init()
|
||||
} // init
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void MainMenuScreen::onUpdate(float delta)
|
||||
|
||||
void MainMenuScreen::onUpdate(float delta)
|
||||
{
|
||||
PlayerProfile *player = PlayerManager::getCurrentPlayer();
|
||||
if(PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_GUEST ||
|
||||
PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN)
|
||||
{
|
||||
m_user_id->setText(player->getLastOnlineName() + "@stk");
|
||||
m_online->setActive(true);
|
||||
m_online->setLabel(m_online_string);
|
||||
}
|
||||
else if (PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_OUT)
|
||||
{
|
||||
m_online->setActive(true);
|
||||
m_online->setLabel(m_login_string);
|
||||
m_user_id->setText(player->getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
// now must be either logging in or logging out
|
||||
m_online->setActive(false);
|
||||
m_user_id->setText(player->getName());
|
||||
}
|
||||
|
||||
m_online->setLabel(PlayerManager::getCurrentOnlineId() ? m_online_string
|
||||
: m_login_string);
|
||||
IconButtonWidget* addons_icon = getWidget<IconButtonWidget>("addons");
|
||||
if (addons_icon != NULL)
|
||||
{
|
||||
@ -472,6 +460,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
}
|
||||
else if (selection == "story")
|
||||
{
|
||||
NetworkConfig::get()->unsetNetworking();
|
||||
PlayerProfile *player = PlayerManager::getCurrentPlayer();
|
||||
if (player->isFirstTime())
|
||||
{
|
||||
@ -504,6 +493,12 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
}
|
||||
}
|
||||
else if (selection == "online")
|
||||
{
|
||||
if (MainMenuScreen::m_enable_online)
|
||||
{
|
||||
OnlineScreen::getInstance()->push();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UserConfigParams::m_internet_status != RequestManager::IPERM_ALLOWED)
|
||||
{
|
||||
@ -517,13 +512,14 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
if (PlayerManager::getCurrentOnlineId())
|
||||
{
|
||||
ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId());
|
||||
OnlineProfileServers::getInstance()->push();
|
||||
TabOnlineProfileAchievements::getInstance()->push();
|
||||
}
|
||||
else
|
||||
{
|
||||
UserScreen::getInstance()->push();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (selection == "addons")
|
||||
{
|
||||
// Don't go to addons if there is no internet, unless some addons are
|
||||
|
@ -32,13 +32,6 @@ class MainMenuScreen : public GUIEngine::Screen, public GUIEngine::ScreenSinglet
|
||||
private:
|
||||
friend class GUIEngine::ScreenSingleton<MainMenuScreen>;
|
||||
|
||||
core::stringw m_online_string;
|
||||
|
||||
core::stringw m_login_string;
|
||||
|
||||
/** Keep the widget to avoid looking it up every frame. */
|
||||
GUIEngine::IconButtonWidget* m_online;
|
||||
|
||||
/** Keep the widget to to the user name. */
|
||||
GUIEngine::ButtonWidget *m_user_id;
|
||||
|
||||
|
112
src/states_screens/online_lan.cpp
Normal file
112
src/states_screens/online_lan.cpp
Normal file
@ -0,0 +1,112 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010-2015 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_servers.hpp"
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widget.hpp"
|
||||
#include "network/network_config.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/protocols/connect_to_server.hpp"
|
||||
#include "network/protocols/request_connection.hpp"
|
||||
#include "network/servers_manager.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/create_server_screen.hpp"
|
||||
#include "states_screens/networking_lobby.hpp"
|
||||
#include "states_screens/online_lan.hpp"
|
||||
#include "states_screens/server_selection.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
#include <IGUIButton.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
using namespace GUIEngine;
|
||||
using namespace irr::core;
|
||||
using namespace irr::gui;
|
||||
using namespace Online;
|
||||
|
||||
DEFINE_SCREEN_SINGLETON( OnlineLanScreen );
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
OnlineLanScreen::OnlineLanScreen() : GUIEngine::Screen("online/lan.stkgui")
|
||||
{
|
||||
} // OnlineLanScreen
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void OnlineLanScreen::loadedFromFile()
|
||||
{
|
||||
} // loadedFromFile
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void OnlineLanScreen::init()
|
||||
{
|
||||
RibbonWidget* ribbon = getWidget<RibbonWidget>("lan");
|
||||
assert(ribbon != NULL);
|
||||
ribbon->select("find_lan_server", PLAYER_ID_GAME_MASTER);
|
||||
ribbon->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
} // init
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void OnlineLanScreen::eventCallback(Widget* widget, const std::string& name, const int playerID)
|
||||
{
|
||||
if (name == "back")
|
||||
{
|
||||
StateManager::get()->popMenu();
|
||||
return;
|
||||
}
|
||||
if (name == "lan")
|
||||
{
|
||||
RibbonWidget* ribbon = dynamic_cast<RibbonWidget*>(widget);
|
||||
std::string selection = ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
if (selection == "create_lan_server")
|
||||
{
|
||||
NetworkConfig::get()->setIsLAN();
|
||||
NetworkConfig::get()->setIsServer(true);
|
||||
CreateServerScreen::getInstance()->push();
|
||||
// TODO: create lan server
|
||||
}
|
||||
else if (selection == "find_lan_server")
|
||||
{
|
||||
NetworkConfig::get()->setIsLAN();
|
||||
NetworkConfig::get()->setIsServer(false);
|
||||
ServerSelection::getInstance()->push();
|
||||
}
|
||||
}
|
||||
|
||||
} // eventCallback
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Also called when pressing the back button. It resets the flags to indicate
|
||||
* a networked game.
|
||||
*/
|
||||
bool OnlineLanScreen::onEscapePressed()
|
||||
{
|
||||
NetworkConfig::get()->unsetNetworking();
|
||||
//StateManager::get()->popMenu();
|
||||
return true;
|
||||
} // onEscapePressed
|
||||
|
57
src/states_screens/online_lan.hpp
Normal file
57
src/states_screens/online_lan.hpp
Normal file
@ -0,0 +1,57 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2013-2015 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_OLAN_HPP__
|
||||
#define __HEADER_OLAN_HPP__
|
||||
|
||||
#include <string>
|
||||
#include <irrString.h>
|
||||
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widgets.hpp"
|
||||
#include "states_screens/online_profile_base.hpp"
|
||||
|
||||
namespace GUIEngine { class Widget; }
|
||||
|
||||
|
||||
/**
|
||||
* \brief Online profiel overview screen
|
||||
* \ingroup states_screens
|
||||
*/
|
||||
class OnlineLanScreen : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<OnlineLanScreen>
|
||||
{
|
||||
protected:
|
||||
OnlineLanScreen();
|
||||
|
||||
public:
|
||||
friend class GUIEngine::ScreenSingleton<OnlineLanScreen>;
|
||||
|
||||
/** \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;
|
||||
virtual bool onEscapePressed() OVERRIDE;
|
||||
|
||||
}; // class OnlineProfileServers
|
||||
|
||||
#endif
|
@ -42,7 +42,6 @@ using namespace Online;
|
||||
OnlineProfileBase::OnlineProfileBase(const std::string &filename)
|
||||
: Screen(filename.c_str())
|
||||
{
|
||||
m_servers_tab = NULL;
|
||||
m_friends_tab = NULL;
|
||||
m_achievements_tab = NULL;
|
||||
m_settings_tab = NULL;
|
||||
@ -63,9 +62,6 @@ void OnlineProfileBase::loadedFromFile()
|
||||
m_friends_tab = (IconButtonWidget *)m_profile_tabs->findWidgetNamed("tab_friends");
|
||||
assert(m_friends_tab != NULL);
|
||||
|
||||
m_servers_tab = (IconButtonWidget *)m_profile_tabs->findWidgetNamed("tab_servers");
|
||||
assert(m_servers_tab != NULL);
|
||||
|
||||
m_achievements_tab = (IconButtonWidget*)m_profile_tabs->findWidgetNamed("tab_achievements");
|
||||
assert(m_profile_tabs == NULL || m_achievements_tab != NULL);
|
||||
|
||||
@ -107,7 +103,6 @@ void OnlineProfileBase::init()
|
||||
|
||||
if (m_profile_tabs)
|
||||
{
|
||||
m_servers_tab->setTooltip(_("Servers"));
|
||||
m_friends_tab->setTooltip(_("Friends"));
|
||||
m_achievements_tab->setTooltip(_("Achievements"));
|
||||
m_settings_tab->setTooltip(_("Account Settings"));
|
||||
@ -159,8 +154,6 @@ void OnlineProfileBase::eventCallback(Widget* widget, const std::string& name,
|
||||
sm->replaceTopMostScreen(TabOnlineProfileAchievements::getInstance());
|
||||
else if (selection == m_settings_tab->m_properties[PROP_ID])
|
||||
sm->replaceTopMostScreen(OnlineProfileSettings::getInstance());
|
||||
else if (selection == m_servers_tab->m_properties[PROP_ID])
|
||||
sm->replaceTopMostScreen(OnlineProfileServers::getInstance());
|
||||
}
|
||||
else if (name == "back")
|
||||
{
|
||||
|
@ -42,7 +42,6 @@ protected:
|
||||
/** Pointer to the various widgets on the screen. */
|
||||
GUIEngine::LabelWidget * m_header;
|
||||
GUIEngine::RibbonWidget* m_profile_tabs;
|
||||
GUIEngine::IconButtonWidget * m_servers_tab;
|
||||
GUIEngine::IconButtonWidget * m_friends_tab;
|
||||
GUIEngine::IconButtonWidget * m_achievements_tab;
|
||||
GUIEngine::IconButtonWidget * m_settings_tab;
|
||||
|
@ -48,7 +48,7 @@ DEFINE_SCREEN_SINGLETON( OnlineProfileServers );
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
OnlineProfileServers::OnlineProfileServers() : OnlineProfileBase("online/profile_servers.stkgui")
|
||||
OnlineProfileServers::OnlineProfileServers() : GUIEngine::Screen("online/profile_servers.stkgui")
|
||||
{
|
||||
} // OnlineProfileServers
|
||||
|
||||
@ -56,44 +56,28 @@ OnlineProfileServers::OnlineProfileServers() : OnlineProfileBase("online/profile
|
||||
|
||||
void OnlineProfileServers::loadedFromFile()
|
||||
{
|
||||
OnlineProfileBase::loadedFromFile();
|
||||
} // loadedFromFile
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void OnlineProfileServers::init()
|
||||
{
|
||||
OnlineProfileBase::init();
|
||||
m_profile_tabs->select( m_servers_tab->m_properties[PROP_ID], PLAYER_ID_GAME_MASTER );
|
||||
m_servers_tab->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
// OnlineScreen::getInstance()->push();
|
||||
RibbonWidget* ribbon = getWidget<RibbonWidget>("wan");
|
||||
assert(ribbon != NULL);
|
||||
ribbon->select("find_wan_server", PLAYER_ID_GAME_MASTER);
|
||||
ribbon->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
} // init
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void OnlineProfileServers::eventCallback(Widget* widget, const std::string& name, const int playerID)
|
||||
{
|
||||
OnlineProfileBase::eventCallback( widget, name, playerID);
|
||||
|
||||
if (name == "lan")
|
||||
if (name == "back")
|
||||
{
|
||||
RibbonWidget* ribbon = dynamic_cast<RibbonWidget*>(widget);
|
||||
std::string selection = ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
if (selection == "create_lan_server")
|
||||
{
|
||||
NetworkConfig::get()->setIsLAN();
|
||||
NetworkConfig::get()->setIsServer(true);
|
||||
CreateServerScreen::getInstance()->push();
|
||||
// TODO: create lan server
|
||||
StateManager::get()->popMenu();
|
||||
return;
|
||||
}
|
||||
else if (selection == "find_lan_server")
|
||||
{
|
||||
NetworkConfig::get()->setIsLAN();
|
||||
NetworkConfig::get()->setIsServer(false);
|
||||
ServerSelection::getInstance()->push();
|
||||
}
|
||||
}
|
||||
else if (name == "wan")
|
||||
if (name == "wan")
|
||||
{
|
||||
RibbonWidget* ribbon = dynamic_cast<RibbonWidget*>(widget);
|
||||
std::string selection = ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
@ -176,6 +160,6 @@ void OnlineProfileServers::doQuickPlay()
|
||||
bool OnlineProfileServers::onEscapePressed()
|
||||
{
|
||||
NetworkConfig::get()->unsetNetworking();
|
||||
return OnlineProfileBase::onEscapePressed();
|
||||
return true;
|
||||
} // onEscapePressed
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace GUIEngine { class Widget; }
|
||||
* \brief Online profiel overview screen
|
||||
* \ingroup states_screens
|
||||
*/
|
||||
class OnlineProfileServers : public OnlineProfileBase, public GUIEngine::ScreenSingleton<OnlineProfileServers>
|
||||
class OnlineProfileServers : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<OnlineProfileServers>
|
||||
{
|
||||
protected:
|
||||
OnlineProfileServers();
|
||||
|
198
src/states_screens/online_screen.cpp
Normal file
198
src/states_screens/online_screen.cpp
Normal file
@ -0,0 +1,198 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2009-2015 Marianne Gagnon
|
||||
//
|
||||
// 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/main_menu_screen.hpp"
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
#include "guiengine/widgets/list_widget.hpp"
|
||||
#include "guiengine/widgets/ribbon_widget.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "input/keyboard_device.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "main_loop.hpp"
|
||||
#include "network/network_config.hpp"
|
||||
#include "online/request_manager.hpp"
|
||||
#include "states_screens/online_lan.hpp"
|
||||
#include "states_screens/online_profile_achievements.hpp"
|
||||
#include "states_screens/online_profile_servers.hpp"
|
||||
#include "states_screens/online_screen.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/user_screen.hpp"
|
||||
#include "states_screens/dialogs/message_dialog.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
using namespace GUIEngine;
|
||||
using namespace Online;
|
||||
|
||||
DEFINE_SCREEN_SINGLETON( OnlineScreen );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
OnlineScreen::OnlineScreen() : Screen("online/online.stkgui")
|
||||
{
|
||||
m_online_string = _("Your profile");
|
||||
//I18N: Used as a verb, appears on the main networking menu (login button)
|
||||
m_login_string = _("Login");
|
||||
} // OnlineScreen
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void OnlineScreen::loadedFromFile()
|
||||
{
|
||||
} // loadedFromFile
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void OnlineScreen::beforeAddingWidget()
|
||||
{
|
||||
bool is_logged_in = false;
|
||||
PlayerProfile *player = PlayerManager::getCurrentPlayer();
|
||||
if (PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_GUEST ||
|
||||
PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN)
|
||||
{
|
||||
is_logged_in = true;
|
||||
}
|
||||
|
||||
IconButtonWidget* wan = getWidget<IconButtonWidget>("wan");
|
||||
wan->setActive(is_logged_in);
|
||||
wan->setVisible(is_logged_in);
|
||||
} // beforeAddingWidget
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
void OnlineScreen::init()
|
||||
{
|
||||
Screen::init();
|
||||
|
||||
m_online = getWidget<IconButtonWidget>("online");
|
||||
|
||||
if (!MainMenuScreen::m_enable_online)
|
||||
m_online->setActive(false);
|
||||
|
||||
m_user_id = getWidget<ButtonWidget>("user-id");
|
||||
assert(m_user_id);
|
||||
|
||||
RibbonWidget* r = getWidget<RibbonWidget>("menu_toprow");
|
||||
r->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
|
||||
} // init
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void OnlineScreen::onUpdate(float delta)
|
||||
{
|
||||
PlayerProfile *player = PlayerManager::getCurrentPlayer();
|
||||
if (PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_GUEST ||
|
||||
PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN)
|
||||
{
|
||||
m_online->setActive(true);
|
||||
m_online->setLabel(m_online_string);
|
||||
m_user_id->setText(player->getLastOnlineName() + "@stk");
|
||||
}
|
||||
else if (PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_OUT)
|
||||
{
|
||||
m_online->setActive(true);
|
||||
m_online->setLabel(m_login_string);
|
||||
m_user_id->setText(player->getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
// now must be either logging in or logging out
|
||||
m_online->setActive(false);
|
||||
m_user_id->setText(player->getName());
|
||||
}
|
||||
|
||||
m_online->setLabel(PlayerManager::getCurrentOnlineId() ? m_online_string
|
||||
: m_login_string);
|
||||
} // onUpdate
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void OnlineScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
const int playerID)
|
||||
{
|
||||
if (name == "user-id")
|
||||
{
|
||||
UserScreen::getInstance()->push();
|
||||
return;
|
||||
}
|
||||
else if (name == "back")
|
||||
{
|
||||
StateManager::get()->popMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
RibbonWidget* ribbon = dynamic_cast<RibbonWidget*>(widget);
|
||||
if (ribbon == NULL) return; // what's that event??
|
||||
|
||||
// ---- A ribbon icon was clicked
|
||||
std::string selection =
|
||||
ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
|
||||
if (selection == "lan")
|
||||
{
|
||||
OnlineLanScreen::getInstance()->push();
|
||||
}
|
||||
else if (selection == "wan")
|
||||
{
|
||||
OnlineProfileServers::getInstance()->push();
|
||||
}
|
||||
else if (selection == "online")
|
||||
{
|
||||
if (UserConfigParams::m_internet_status != RequestManager::IPERM_ALLOWED)
|
||||
{
|
||||
new MessageDialog(_("You can not play online without internet access. "
|
||||
"If you want to play online, go to options, select "
|
||||
" tab 'User Interface', and edit "
|
||||
"\"Connect to the Internet\"."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerManager::getCurrentOnlineId())
|
||||
{
|
||||
ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId());
|
||||
TabOnlineProfileAchievements::getInstance()->push();
|
||||
}
|
||||
else
|
||||
{
|
||||
UserScreen::getInstance()->push();
|
||||
}
|
||||
}
|
||||
} // eventCallback
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void OnlineScreen::tearDown()
|
||||
{
|
||||
} // tearDown
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void OnlineScreen::onDisabledItemClicked(const std::string& item)
|
||||
{
|
||||
} // onDisabledItemClicked
|
71
src/states_screens/online_screen.hpp
Normal file
71
src/states_screens/online_screen.hpp
Normal file
@ -0,0 +1,71 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2009-2015 Marianne Gagnon
|
||||
//
|
||||
// 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_SCREEN_HPP
|
||||
#define HEADER_ONLINE_SCREEN_HPP
|
||||
|
||||
#include "guiengine/screen.hpp"
|
||||
|
||||
namespace GUIEngine { class Widget; class ListWidget;
|
||||
class ButtonWidget; class IconButtonWidget; }
|
||||
|
||||
/**
|
||||
* \brief Handles the networking main menu
|
||||
* \ingroup states_screens
|
||||
*/
|
||||
class OnlineScreen : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<OnlineScreen>
|
||||
{
|
||||
private:
|
||||
friend class GUIEngine::ScreenSingleton<OnlineScreen>;
|
||||
|
||||
core::stringw m_online_string;
|
||||
|
||||
core::stringw m_login_string;
|
||||
|
||||
/** Keep the widget to to the user name. */
|
||||
GUIEngine::ButtonWidget *m_user_id;
|
||||
|
||||
/** Keep the widget to avoid looking it up every frame. */
|
||||
GUIEngine::IconButtonWidget* m_online;
|
||||
|
||||
OnlineScreen();
|
||||
|
||||
public:
|
||||
|
||||
virtual void onUpdate(float delta) OVERRIDE;
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void loadedFromFile() OVERRIDE;
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void beforeAddingWidget() 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 tearDown() OVERRIDE;
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void onDisabledItemClicked(const std::string& item) OVERRIDE;
|
||||
};
|
||||
|
||||
#endif
|
@ -400,7 +400,7 @@ void BaseUserScreen::eventCallback(Widget* widget,
|
||||
*/
|
||||
void BaseUserScreen::closeScreen()
|
||||
{
|
||||
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
||||
StateManager::get()->popMenu();
|
||||
} // closeScreen
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -466,6 +466,7 @@ void Track::cleanup()
|
||||
}
|
||||
#endif
|
||||
|
||||
m_meta_library.clear();
|
||||
Scripting::ScriptEngine::getInstance()->cleanupCache();
|
||||
|
||||
m_current_track = NULL;
|
||||
@ -1757,6 +1758,14 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
|
||||
|
||||
loadObjects(root, path, model_def_loader, true, NULL, NULL);
|
||||
|
||||
// Correct the parenting of meta library
|
||||
for (auto& p : m_meta_library)
|
||||
{
|
||||
auto* ln = p.first->getPresentation<TrackObjectPresentationLibraryNode>();
|
||||
assert(ln);
|
||||
p.second->setParent(ln->getNode());
|
||||
}
|
||||
|
||||
model_def_loader.cleanLibraryNodesAfterLoad();
|
||||
|
||||
Scripting::ScriptEngine::getInstance()->compileLoadedScripts();
|
||||
|
@ -374,6 +374,8 @@ private:
|
||||
/** List of all bezier curves in the track - for e.g. camera, ... */
|
||||
std::vector<BezierCurve*> m_all_curves;
|
||||
|
||||
std::vector<std::pair<TrackObject*, scene::ISceneNode*> > m_meta_library;
|
||||
|
||||
/** The number of laps the track will be raced in a random GP.
|
||||
* m_actual_number_of_laps is initialised with this value.*/
|
||||
int m_default_number_of_laps;
|
||||
@ -672,6 +674,10 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Adds mesh to cleanup list */
|
||||
void addCachedMesh(scene::IMesh* mesh) { m_all_cached_meshes.push_back(mesh); }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Adds the parent of the meta library for correction later */
|
||||
void addMetaLibrary(TrackObject* parent, scene::ISceneNode* meta_library)
|
||||
{ m_meta_library.emplace_back(parent, meta_library); }
|
||||
}; // class Track
|
||||
|
||||
#endif
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "physics/physical_object.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "scriptengine/script_engine.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/model_definition_loader.hpp"
|
||||
|
||||
#include <IAnimatedMeshSceneNode.h>
|
||||
@ -160,6 +161,11 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent,
|
||||
{
|
||||
xml_node.get("name", &m_name);
|
||||
m_presentation = new TrackObjectPresentationLibraryNode(this, xml_node, model_def_loader);
|
||||
if (parent_library != NULL)
|
||||
{
|
||||
Track::getCurrentTrack()->addMetaLibrary(parent_library,
|
||||
(dynamic_cast<TrackObjectPresentationLibraryNode*>(m_presentation))->getNode());
|
||||
}
|
||||
}
|
||||
else if (type == "sfx-emitter")
|
||||
{
|
||||
|
@ -180,6 +180,7 @@ TrackObjectPresentationLibraryNode::TrackObjectPresentationLibraryNode(
|
||||
{
|
||||
m_parent = NULL;
|
||||
m_start_executed = false;
|
||||
m_reset_executed = false;
|
||||
|
||||
std::string name;
|
||||
xml_node.get("name", &name);
|
||||
@ -289,6 +290,22 @@ void TrackObjectPresentationLibraryNode::update(float dt)
|
||||
m_start_executed = true;
|
||||
std::string fn_name = StringUtils::insertValues("void %s::onStart(const string)", m_name.c_str());
|
||||
|
||||
if (m_parent != NULL)
|
||||
{
|
||||
std::string lib_id = m_parent->getID();
|
||||
std::string* lib_id_ptr = &lib_id;
|
||||
|
||||
Scripting::ScriptEngine::getInstance()->runFunction(false, fn_name,
|
||||
[&](asIScriptContext* ctx) {
|
||||
ctx->SetArgObject(0, lib_id_ptr);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!m_reset_executed)
|
||||
{
|
||||
m_reset_executed = true;
|
||||
std::string fn_name = StringUtils::insertValues("void %s::onReset(const string)", m_name.c_str());
|
||||
|
||||
if (m_parent != NULL)
|
||||
{
|
||||
std::string lib_id = m_parent->getID();
|
||||
|
@ -187,13 +187,18 @@ class TrackObjectPresentationLibraryNode : public TrackObjectPresentationSceneNo
|
||||
TrackObject* m_parent;
|
||||
using TrackObjectPresentationSceneNode::move;
|
||||
std::string m_name;
|
||||
bool m_start_executed;
|
||||
bool m_start_executed, m_reset_executed;
|
||||
public:
|
||||
TrackObjectPresentationLibraryNode(TrackObject* parent,
|
||||
const XMLNode& xml_node,
|
||||
ModelDefinitionLoader& model_def_loader);
|
||||
virtual ~TrackObjectPresentationLibraryNode();
|
||||
virtual void update(float dt);
|
||||
virtual void update(float dt) OVERRIDE;
|
||||
virtual void reset() OVERRIDE
|
||||
{
|
||||
m_reset_executed = false;
|
||||
TrackObjectPresentationSceneNode::reset();
|
||||
}
|
||||
void move(const core::vector3df& xyz, const core::vector3df& hpr,
|
||||
const core::vector3df& scale, bool isAbsoluteCoord, bool moveChildrenPhysicalBodies);
|
||||
}; // TrackObjectPresentationLibraryNode
|
||||
|
Loading…
Reference in New Issue
Block a user