Merge remote-tracking branch 'remotes/upstrem/master' into skiddingAI

This commit is contained in:
Guillaume P
2014-04-18 08:49:54 +02:00
88 changed files with 1058 additions and 633 deletions

32
data/gfx/droplet.xml Normal file
View File

@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<particles emitter="sphere" radius="5">
<spreading angle="45" />
<velocity x="0.000"
y="0.005"
z="0.000" />
<material file="particle_water.png" />
<!-- Amount of particles emitted per second -->
<rate min="5"
max="10" />
<!-- Minimal and maximal lifetime of a particle, in milliseconds. -->
<lifetime min="1000"
max="2000" />
<!-- Size of the particles -->
<size min="4.0"
max="7.2"
x-increase-factor="2.6"
y-increase-factor="2.6" />
<color min="255 255 255"
max="255 255 255" />
<fadeout time="3000" />
</particles>

View File

@@ -6,48 +6,94 @@
<spacer height="20" width="10" />
<!--
<div layout="horizontal-row" width="100%" height="fit">
<checkbox id="pixelshaders"/>
<spacer width="10" height="10"/>
<label text="Pixel Shaders (requires restart)" I18N="Video settings"/>
<label text="Pixel Shaders" I18N="Video settings"/>
</div>
<spacer height="4" width="10" />
-->
<div layout="horizontal-row" width="100%" height="fit">
<spacer width="50" height="10" />
<checkbox id="motionblur"/>
<checkbox id="dynamiclight"/>
<spacer width="10" height="10"/>
<label text="Motion blur" I18N="Video settings"/>
<label text="Dynamic lights" I18N="Video settings"/>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" width="100%" height="fit">
<spacer width="50" height="10" />
<checkbox id="mlaa"/>
<spacer width="10" height="10"/>
<label text="Anti-aliasing" I18N="Video settings"/>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" width="100%" height="fit">
<spacer width="50" height="10" />
<label text="Ambient Occlusion" I18N="Video settings"/>
<spacer width="10" height="10"/>
<gauge id="ssao" min_value="0" max_value="2" width="50%"/>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" width="100%" height="fit">
<spacer width="50" height="10" />
<label text="Shadows (requires restart)" I18N="Video settings"/>
<label text="Shadows" I18N="Video settings"/>
<spacer width="10" height="10"/>
<gauge id="shadows" min_value="0" max_value="2" width="50%"/>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" width="100%" height="fit">
<div layout="horizontal-row" width="50%" height="fit">
<checkbox id="bloom"/>
<spacer width="10" height="10"/>
<label text="Bloom" I18N="Video settings"/>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" width="50%" height="fit">
<checkbox id="motionblur"/>
<spacer width="10" height="10"/>
<label text="Motion blur" I18N="Video settings"/>
</div>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" width="100%" height="fit">
<div layout="horizontal-row" width="50%" height="fit">
<checkbox id="lightshaft"/>
<spacer width="10" height="10"/>
<label text="Light shaft (God rays)" I18N="Video settings"/>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" width="50%" height="fit">
<checkbox id="texture_compression"/>
<spacer width="10" height="10"/>
<label text="Texture compression" I18N="Video settings"/>
</div>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" width="100%" height="fit">
<div layout="horizontal-row" width="50%" height="fit">
<checkbox id="glow"/>
<spacer width="10" height="10"/>
<label text="Glow (outlines)" I18N="Video settings"/>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" width="50%" height="fit">
<checkbox id="mlaa"/>
<spacer width="10" height="10"/>
<label text="Anti-aliasing" I18N="Video settings"/>
</div>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" width="100%" height="fit">
<checkbox id="ssao"/>
<spacer width="10" height="10"/>
<label text="Ambient Occlusion" I18N="Video settings"/>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" width="100%" height="fit">
@@ -80,20 +126,13 @@
<gauge id="filtering" min_value="0" max_value="5" width="50%" />
</div>
<!--
<div layout="horizontal-row" width="100%" height="fit">
<label text="Anti-aliasing (requires restart)" I18N="Video settings" width="40%" />
<spacer width="10" height="10"/>
<gauge id="antialiasing" min_value="0" max_value="3" width="50%"/>
</div>
<spacer height="4" width="10" />
-->
<spacer height="10" width="10" />
<label text="* Restart STK to apply new settings" width="100%" text_align="center" I18N="Video settings"/>
<spacer proportion="1"/>
<button id="close" text="Close" align="center"/>
<button id="close" text="Apply" align="center"/>
</div>
</stkgui>

View File

@@ -16,7 +16,7 @@ void main()
vec3 col = texture(tex, uv).xyz;
float luma = getCIEYxy(col).x;
col *= smoothstep(1., 2., luma);
col *= smoothstep(1., 10., luma);
FragColor = vec4(col, 1.0);
}

View File

@@ -13,11 +13,11 @@ void main() {
/**
* Luma calculation requires gamma-corrected colors:
*/
float L = dot(pow(texture(colorMapG, uv).rgb, vec3(1./2.2)), weights);
float Lleft = dot(pow(texture(colorMapG, offset[0].xy).rgb, vec3(1./2.2)), weights);
float Ltop = dot(pow(texture(colorMapG, offset[0].zw).rgb, vec3(1./2.2)), weights);
float Lright = dot(pow(texture(colorMapG, offset[1].xy).rgb, vec3(1./2.2)), weights);
float Lbottom = dot(pow(texture(colorMapG, offset[1].zw).rgb, vec3(1./2.2)), weights);
float L = dot(texture(colorMapG, uv).rgb, weights);
float Lleft = dot(texture(colorMapG, offset[0].xy).rgb, weights);
float Ltop = dot(texture(colorMapG, offset[0].zw).rgb, weights);
float Lright = dot(texture(colorMapG, offset[1].xy).rgb, weights);
float Lbottom = dot(texture(colorMapG, offset[1].zw).rgb, weights);
vec4 delta = abs(vec4(L) - vec4(Lleft, Ltop, Lright, Lbottom));
vec4 edges = step(vec4(threshold), delta);

View File

@@ -26,16 +26,16 @@ void main() {
vec4 color = vec4(0.0);
// Add the contributions of the possible 4 lines that can cross this pixel:
vec4 C = pow(texture(colorMap, uv), vec4(1./2.2));
vec4 Cleft = pow(texture(colorMap, offset[0].xy), vec4(1./2.2));
vec4 Ctop = pow(texture(colorMap, offset[0].zw), vec4(1./2.2));
vec4 Cright = pow(texture(colorMap, offset[1].xy), vec4(1./2.2));
vec4 Cbottom = pow(texture(colorMap, offset[1].zw), vec4(1./2.2));
vec4 C = texture(colorMap, uv);
vec4 Cleft = texture(colorMap, offset[0].xy);
vec4 Ctop = texture(colorMap, offset[0].zw);
vec4 Cright = texture(colorMap, offset[1].xy);
vec4 Cbottom = texture(colorMap, offset[1].zw);
color = mix(C, Ctop, a.r) * w.r + color;
color = mix(C, Cbottom, a.g) * w.g + color;
color = mix(C, Cleft, a.b) * w.b + color;
color = mix(C, Cright, a.a) * w.a + color;
// Normalize the resulting color and we are finished!
FragColor = vec4(pow(color / sum, vec4(2.2)));
FragColor = vec4(color / sum);
}

View File

@@ -19,7 +19,7 @@ vec2 EncodeNormal(vec3 n);
void main()
{
// normal in Tangent Space
vec3 TS_normal = 2.0 * pow(texture(normalMap, uv).rgb, vec3(1./2.2)) - 1.0;
vec3 TS_normal = 2.0 * texture(normalMap, uv).rgb - 1.0;
// Because of interpolation, we need to renormalize
vec3 Frag_tangent = normalize(tangent);
vec3 Frag_normal = normalize(cross(Frag_tangent, bitangent));

View File

@@ -17,7 +17,7 @@ varying vec2 uv;
void main() {
float rim = 1.0 - dot(nor, vec3(0., 0., -1));
rim = smoothstep(0.5, 1.5, rim) * 0.35;
rim = smoothstep(0.5, 1.5, rim) * 0.15;
vec4 color = texture(Albedo, uv);
vec2 tc = gl_FragCoord.xy / screen;

View File

@@ -13,8 +13,8 @@ varying vec2 uv;
#define AO gl_FragColor.x
#endif
const float strengh = 4.;
const float radius = .4f;
const float strengh = 3.;
const float radius = 1.f;
#define SAMPLES 16
@@ -22,7 +22,7 @@ const float invSamples = strengh / SAMPLES;
vec3 rand(vec2 co)
{
return texture(noise_texture, co*20.16).xyz;
return texture(noise_texture, co * pow(3.14159265359, 2.)).xyz;
}
vec3 DecodeNormal(vec2 n);
@@ -61,7 +61,7 @@ void main(void)
occluderPos /= occluderPos.w;
bool isOccluded = isInsideTexture && (sampleProj.z > (2. * occluderFragmentDepth - 1.0)) && (distance(FragPos, occluderPos) < radius);
bl += isOccluded ? smoothstep(radius, 0, distance(samplePos, FragPos)) : 0.;
bl += isOccluded ? samplePoints[i].z * smoothstep(5 * radius, 0, distance(samplePos, FragPos)) : 0.;
}
AO = 1.0 - bl * invSamples;

View File

@@ -12,7 +12,7 @@ varying vec2 uv;
void main()
{
vec4 Color = texture(tex, uv) * color;
vec4 Color = texture(tex, uv) * pow(color, vec4(2.2));
// Premultiply alpha
FragColor = vec4(Color.rgb * Color.a, Color.a);
}

View File

@@ -21,7 +21,7 @@ varying vec2 uv;
void main()
{
vec4 diffusecolor = texture(tex, uv) * color;
vec4 diffusecolor = texture(tex, uv) * pow(color, vec4(2.2));
vec3 tmp = vec3(gl_FragCoord.xy / screen, gl_FragCoord.z);
tmp = 2. * tmp - 1.;

View File

@@ -25,7 +25,6 @@
#include "config/player_profile.hpp"
#include "config/user_config.hpp"
#include "io/file_manager.hpp"
#include "online/current_user.hpp"
#include "utils/log.hpp"
#include "utils/translation.hpp"

View File

@@ -26,7 +26,6 @@
#include "utils/log.hpp"
#include "utils/ptr_vector.hpp"
#include "utils/translation.hpp"
#include "online/current_user.hpp"
#include <sstream>
#include <fstream>

View File

@@ -23,7 +23,7 @@
#include "io/file_manager.hpp"
#include "io/utf_writer.hpp"
#include "io/xml_node.hpp"
#include "online/current_user.hpp"
#include "online/online_player_profile.hpp"
#include "utils/log.hpp"
#include "utils/translation.hpp"
@@ -56,14 +56,14 @@ void PlayerManager::setUserDetails(Online::HTTPRequest *request,
const std::string &action,
const std::string &php_name)
{
get()->getCurrentUser()->setUserDetails(request, action, php_name);
get()->getCurrentPlayer()->setUserDetails(request, action, php_name);
} // setUserDetails
// ----------------------------------------------------------------------------
/** Returns whether a user is signed in or not. */
bool PlayerManager::isCurrentLoggedIn()
{
return getCurrentUser()->isRegisteredUser();
return getCurrentPlayer()->isLoggedIn();
} // isCurrentLoggedIn
// ----------------------------------------------------------------------------
@@ -72,18 +72,93 @@ bool PlayerManager::isCurrentLoggedIn()
*/
unsigned int PlayerManager::getCurrentOnlineId()
{
return getCurrentUser()->getID();
return getCurrentPlayer()->getOnlineId();
} // getCurrentOnlineId
// ----------------------------------------------------------------------------
/** Returns the online state of the current player. It can be logged out,
* logging in, logged in, logging out, logged out, or guest.
*/
PlayerManager::OnlineState PlayerManager::getCurrentOnlineState()
PlayerProfile::OnlineState PlayerManager::getCurrentOnlineState()
{
return (OnlineState)getCurrentUser()->getUserState();
return getCurrentPlayer()->getOnlineState();
} // getCurrentOnlineState
// ----------------------------------------------------------------------------
/** Returns the online name of this player.
*/
const irr::core::stringw& PlayerManager::getCurrentOnlineUserName()
{
if (getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN ||
getCurrentOnlineState() == PlayerProfile::OS_GUEST )
return getCurrentOnlineProfile()->getUserName();
static core::stringw not_signed_in = _("Currently not signed in");
return not_signed_in;
} // getCurrentOnlineUserName
// ----------------------------------------------------------------------------
/** Sends a request to the server to see if any new information is
* available. (online friends, notifications, etc.).
*/
void PlayerManager::requestOnlinePoll()
{
getCurrentPlayer()->requestPoll();
} // requestOnlinePoll
// ----------------------------------------------------------------------------
/** Reconnect to the server using the saved session data.
*/
void PlayerManager::resumeSavedSession()
{
getCurrentPlayer()->requestSavedSession();
} // resumeSavedSession
// ----------------------------------------------------------------------------
/** Sends a message to the server that the client has been closed, if a
* user is signed in.
*/
void PlayerManager::onSTKQuit()
{
getCurrentPlayer()->onSTKQuit();
} // onSTKQuit
// ----------------------------------------------------------------------------
/** Create a signin request.
* \param username Name of user.
* \param password Password.
* \param save_session If true, the login credential will be saved to
* allow a password-less login.
* \param request_now Immediately submit this request to the
* RequestManager.
*/
Online::XMLRequest *PlayerManager::requestSignIn(const irr::core::stringw &username,
const irr::core::stringw &password,
bool save_session,
bool request_now)
{
return getCurrentPlayer()->requestSignIn(username, password, save_session,
request_now);
} // requestSignIn
// ----------------------------------------------------------------------------
/** Signs the current user out.
*/
void PlayerManager::requestSignOut()
{
getCurrentPlayer()->requestSignOut();
} // requestSignOut
// ----------------------------------------------------------------------------
/** Returns the current online profile (which is the list of all achievements
* and friends).
*/
Online::OnlineProfile* PlayerManager::getCurrentOnlineProfile()
{
return getCurrentPlayer()->getProfile();
} // getCurrentOnlineProfile
// ============================================================================
/** Constructor.
*/
@@ -126,7 +201,7 @@ void PlayerManager::load()
for(unsigned int i=0; i<m_player_data->getNumNodes(); i++)
{
const XMLNode *player_xml = m_player_data->getNode(i);
PlayerProfile *player = new PlayerProfile(player_xml);
PlayerProfile *player = new Online::OnlinePlayerProfile(player_xml);
m_all_players.push_back(player);
if(player->isDefault())
m_current_player = player;
@@ -136,21 +211,30 @@ void PlayerManager::load()
// ----------------------------------------------------------------------------
/** The 2nd loading stage. During this stage achievements and story mode
* data is read for each player.
* data is initialised for each player. In case of existing player (i.e. not
* first time start of stk) the data is read from the players.xml file,
* in case of a first time start new/empty data structures for the players
* (which were created by default) are created.
*/
void PlayerManager::loadRemainingData()
void PlayerManager::initRemainingData()
{
for (unsigned int i = 0; i<m_player_data->getNumNodes(); i++)
for (unsigned int i = 0; i<m_all_players.size(); i++)
{
const XMLNode *player_xml = m_player_data->getNode(i);
m_all_players[i].loadRemainingData(player_xml);
// On the first time STK is run, there is no player data,
// so just initialise the story and achievement data
// structures
if (!m_player_data)
m_all_players[i].initRemainingData();
else // not a first time start, load remaining data
m_all_players[i].loadRemainingData(m_player_data->getNode(i));
}
delete m_player_data;
m_player_data = NULL;
// Sort player by frequency
m_all_players.insertionSort(/*start*/0, /*desc*/true);
} // loadRemainingData
} // initRemainingData
// ----------------------------------------------------------------------------
/** Saves all player profiles to players.xml.
@@ -188,7 +272,7 @@ void PlayerManager::save()
*/
void PlayerManager::addNewPlayer(const core::stringw& name)
{
m_all_players.push_back( new PlayerProfile(name) );
m_all_players.push_back( new Online::OnlinePlayerProfile(name) );
} // addNewPlayer
// ----------------------------------------------------------------------------
@@ -257,13 +341,13 @@ void PlayerManager::addDefaultPlayer()
else if(getenv("LOGNAME")!=NULL) // Linux, Macs
username = getenv("LOGNAME");
// Set the name as the default name for all players.
m_all_players.push_back(new PlayerProfile(username.c_str()) );
// Set the name as the default name, but don't mark it as 'default'
// yet, since not having a default player forces the player selection
// screen to be shown.
m_all_players.push_back(new Online::OnlinePlayerProfile(username.c_str()) );
// add default guest player
m_all_players.push_back( new PlayerProfile(_LTR("Guest"), /*guest*/true) );
m_all_players.push_back(new Online::OnlinePlayerProfile(_LTR("Guest"), /*guest*/true));
} // addDefaultPlayer
// ----------------------------------------------------------------------------

View File

@@ -31,10 +31,12 @@
class AchievementsStatus;
namespace online
namespace Online
{
class CurrentUser;
class HTTPRequest;
class OnlineProfile;
class XMLRequest;
}
class PlayerProfile;
@@ -60,7 +62,7 @@ private:
PlayerProfile* m_current_player;
/** Saves the XML tree from players.xml for use in the 2nd
* loading stage (loadRemainingData). */
* loading stage (initRemainingData). */
const XMLNode *m_player_data;
void load();
@@ -86,7 +88,7 @@ public:
} // destroy
void save();
void loadRemainingData();
void initRemainingData();
unsigned int getUniqueId() const;
void addDefaultPlayer();
void addNewPlayer(const irr::core::stringw& name);
@@ -99,18 +101,18 @@ public:
const std::string &php_name = "");
static unsigned int getCurrentOnlineId();
static bool isCurrentLoggedIn();
static Online::OnlineProfile* getCurrentOnlineProfile();
/** The online state a player can be in. */
enum OnlineState
{
OS_SIGNED_OUT = 0,
OS_SIGNED_IN,
OS_GUEST,
OS_SIGNING_IN,
OS_SIGNING_OUT
};
static OnlineState getCurrentOnlineState();
static PlayerProfile::OnlineState getCurrentOnlineState();
static const irr::core::stringw& getCurrentOnlineUserName();
static void requestOnlinePoll();
static void resumeSavedSession();
static void onSTKQuit();
static void requestSignOut();
static Online::XMLRequest *requestSignIn(const irr::core::stringw &username,
const irr::core::stringw &password,
bool save_session,
bool request_now = true);
// ------------------------------------------------------------------------
/** Returns the current player. */
@@ -118,11 +120,7 @@ public:
{
return get()->m_current_player;
} // getCurrentPlayer
// ------------------------------------------------------------------------
static Online::CurrentUser* getCurrentUser()
{
return get()->m_current_player->getCurrentUser();
} // getCurrentUser
// ------------------------------------------------------------------------
PlayerProfile *getPlayer(const irr::core::stringw &name);
// ------------------------------------------------------------------------

View File

@@ -21,7 +21,7 @@
#include "achievements/achievements_manager.hpp"
#include "challenges/unlock_manager.hpp"
#include "config/player_manager.hpp"
#include "online/current_user.hpp"
#include "online/online_player_profile.hpp"
#include "io/xml_node.hpp"
#include "io/utf_writer.hpp"
#include "utils/string_utils.hpp"
@@ -39,16 +39,17 @@ PlayerProfile::PlayerProfile(const core::stringw& name, bool is_guest)
#ifdef DEBUG
m_magic_number = 0xABCD1234;
#endif
m_name = name;
m_local_name = name;
m_is_guest_account = is_guest;
m_is_default = false;
m_use_frequency = is_guest ? -1 : 0;
m_unique_id = PlayerManager::get()->getUniqueId();
m_story_mode_status = unlock_manager->createStoryModeStatus();
m_is_default = false;
m_current_user = new Online::CurrentUser();
m_achievements_status =
AchievementsManager::get()->createAchievementsStatus();
m_is_default = false;
m_saved_session = false;
m_saved_token = "";
m_saved_user_id = 0;
m_achievements_status = NULL;
m_story_mode_status = NULL;
} // PlayerProfile
//------------------------------------------------------------------------------
@@ -72,9 +73,8 @@ PlayerProfile::PlayerProfile(const XMLNode* node)
m_saved_user_id = 0;
m_story_mode_status = NULL;
m_achievements_status = NULL;
m_current_user = new Online::CurrentUser();
node->get("name", &m_name );
node->get("name", &m_local_name );
node->get("guest", &m_is_guest_account);
node->get("use-frequency", &m_use_frequency );
node->get("unique-id", &m_unique_id );
@@ -94,29 +94,42 @@ PlayerProfile::~PlayerProfile()
#ifdef DEBUG
m_magic_number = 0xDEADBEEF;
#endif
delete m_current_user;
} // ~PlayerProfile
//------------------------------------------------------------------------------
/** This function loads the achievement and story mode data. This
*/
/** This function loads the achievement and story mode data. These can only
* be loaded after the UnlockManager is created, which needs the karts
* and tracks to be loaded first.
*/
void PlayerProfile::loadRemainingData(const XMLNode *node)
{
const XMLNode *xml_story_mode = node->getNode("story-mode");
m_story_mode_status = unlock_manager->createStoryModeStatus(xml_story_mode);
m_story_mode_status =
unlock_manager->createStoryModeStatus(xml_story_mode);
const XMLNode *xml_achievements = node->getNode("achievements");
m_achievements_status = AchievementsManager::get()
->createAchievementsStatus(xml_achievements);
} // loadRemainingData
->createAchievementsStatus(xml_achievements);
} // initRemainingData
//------------------------------------------------------------------------------
/** Initialises the story- and achievement data structure in case of the first
* start of STK.
*/
void PlayerProfile::initRemainingData()
{
m_story_mode_status = unlock_manager->createStoryModeStatus();
m_achievements_status =
AchievementsManager::get()->createAchievementsStatus();
} // initRemainingData
//------------------------------------------------------------------------------
/** Writes the data for this player to the specified UTFWriter.
* \param out The utf writer to write the data to.
*/
void PlayerProfile::save(UTFWriter &out)
{
out << L" <player name=\"" << m_name
out << L" <player name=\"" << m_local_name
<< L"\" guest=\"" << m_is_guest_account
<< L"\" use-frequency=\"" << m_use_frequency << L"\"\n";
@@ -128,11 +141,11 @@ void PlayerProfile::save(UTFWriter &out)
<< L"\" saved-token=\"" << m_saved_token << L"\">\n";
{
assert(m_story_mode_status);
m_story_mode_status->save(out);
if(m_story_mode_status)
m_story_mode_status->save(out);
assert(m_achievements_status);
m_achievements_status->save(out);
if(m_achievements_status)
m_achievements_status->save(out);
}
out << L" </player>\n";
} // save

View File

@@ -20,6 +20,7 @@
#define HEADER_PLAYER_PROFILE_HPP
#include "challenges/story_mode_status.hpp"
#include "utils/leak_check.hpp"
#include "utils/no_copy.hpp"
#include "utils/types.hpp"
@@ -29,7 +30,13 @@ using namespace irr;
#include <string>
class AchievementsStatus;
namespace Online { class CurrentUser; }
namespace Online
{
class CurrentUser;
class HTTPRequest;
class OnlineProfile;
class XMLRequest;
}
class UTFWriter;
/** Class for managing player profiles (name, usage frequency,
@@ -41,13 +48,24 @@ class UTFWriter;
*/
class PlayerProfile : public NoCopy
{
private:
public:
/** The online state a player can be in. */
enum OnlineState
{
OS_SIGNED_OUT = 0,
OS_SIGNED_IN,
OS_GUEST,
OS_SIGNING_IN,
OS_SIGNING_OUT
};
Online::CurrentUser *m_current_user;
private:
LEAK_CHECK()
/** The name of the player (wide string, so it can be in native
* language). */
core::stringw m_name;
core::stringw m_local_name;
/** True if this account is a guest account. */
bool m_is_guest_account;
@@ -83,9 +101,10 @@ public:
PlayerProfile(const core::stringw &name, bool is_guest = false);
PlayerProfile(const XMLNode *node);
~PlayerProfile();
virtual ~PlayerProfile();
void save(UTFWriter &out);
void loadRemainingData(const XMLNode *node);
void initRemainingData();
void incrementUseFrequency();
bool operator<(const PlayerProfile &other);
bool operator>(const PlayerProfile &other);
@@ -93,8 +112,24 @@ public:
void saveSession(int user_id, const std::string &token);
void clearSession();
// ------------------------------------------------------------------------
Online::CurrentUser* getCurrentUser() { return m_current_user; }
/** Abstract virtual classes, to be implemented by the OnlinePlayer. */
virtual void setUserDetails(Online::HTTPRequest *request,
const std::string &action,
const std::string &php_script = "") = 0;
virtual uint32_t getOnlineId() const = 0;
virtual PlayerProfile::OnlineState getOnlineState() const = 0;
virtual Online::OnlineProfile* getProfile() const = 0;
virtual void requestPoll() const = 0;
virtual void requestSavedSession() = 0;
virtual void onSTKQuit() const = 0;
virtual Online::XMLRequest* requestSignIn(const irr::core::stringw &username,
const irr::core::stringw &password,
bool save_session,
bool request_now = true) = 0;
virtual void signIn(bool success, const XMLNode * input) = 0;
virtual void signOut(bool success, const XMLNode * input) = 0;
virtual void requestSignOut() = 0;
virtual bool isLoggedIn() const { return false; }
// ------------------------------------------------------------------------
/** Sets the name of this player. */
void setName(const core::stringw& name)
@@ -102,7 +137,7 @@ public:
#ifdef DEBUG
assert(m_magic_number == 0xABCD1234);
#endif
m_name = name;
m_local_name = name;
} // setName
// ------------------------------------------------------------------------
@@ -110,7 +145,7 @@ public:
core::stringw getName() const
{
assert(m_magic_number == 0xABCD1234);
return m_name.c_str();
return m_local_name.c_str();
} // getName
// ------------------------------------------------------------------------

View File

@@ -440,6 +440,21 @@ namespace UserConfigParams
PARAM_PREFIX IntUserConfigParam m_max_fps
PARAM_DEFAULT( IntUserConfigParam(120, "max_fps",
&m_video_group, "Maximum fps, should be at least 60") );
PARAM_PREFIX BoolUserConfigParam m_texture_compression
PARAM_DEFAULT(BoolUserConfigParam(true, "enable_texture_compression",
&m_video_group, "Enable Texture Compression"));
PARAM_PREFIX BoolUserConfigParam m_glow
PARAM_DEFAULT(BoolUserConfigParam(false, "enable_glow",
&m_video_group, "Enable Glow"));
PARAM_PREFIX BoolUserConfigParam m_bloom
PARAM_DEFAULT(BoolUserConfigParam(false, "enable_bloom",
&m_video_group, "Enable Bloom"));
PARAM_PREFIX BoolUserConfigParam m_light_shaft
PARAM_DEFAULT(BoolUserConfigParam(false, "enable_light_shaft",
&m_video_group, "Enable Light Shafts"));
PARAM_PREFIX BoolUserConfigParam m_dynamic_lights
PARAM_DEFAULT(BoolUserConfigParam(false, "enable_dynamic_lights",
&m_video_group, "Enable Dynamic Lights"));
// ---- Debug - not saved to config file
/** If gamepad debugging is enabled. */
@@ -589,10 +604,6 @@ namespace UserConfigParams
PARAM_DEFAULT( BoolUserConfigParam(false, "vsync",
&m_graphics_quality,
"Whether vertical sync is enabled") );
PARAM_PREFIX BoolUserConfigParam m_pixel_shaders
PARAM_DEFAULT( BoolUserConfigParam(false, "pixel_shaders",
&m_graphics_quality,
"Whether to enable pixel shaders (splatting, normal maps, ...)") );
PARAM_PREFIX BoolUserConfigParam m_motionblur
PARAM_DEFAULT( BoolUserConfigParam(false,
"motionblur_enabled", &m_graphics_quality,
@@ -601,10 +612,10 @@ namespace UserConfigParams
PARAM_DEFAULT( BoolUserConfigParam(false,
"mlaa", &m_graphics_quality,
"Whether MLAA anti-aliasing should be enabled") );
PARAM_PREFIX IntUserConfigParam m_ssao
PARAM_DEFAULT( IntUserConfigParam(0,
PARAM_PREFIX BoolUserConfigParam m_ssao
PARAM_DEFAULT(BoolUserConfigParam(false,
"ssao", &m_graphics_quality,
"Whether SSAO is enabled (0 = disabled, 1 = low, 2 = high") );
"Enable Screen Space Ambient Occlusion") );
PARAM_PREFIX IntUserConfigParam m_shadows
PARAM_DEFAULT( IntUserConfigParam(0,
"shadows", &m_graphics_quality,

View File

@@ -67,6 +67,7 @@ PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample;
PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex;
PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding;
PFNGLBLENDCOLORPROC glBlendColor;
#endif
static bool is_gl_init = false;
@@ -213,6 +214,7 @@ void initGL()
glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBlitFramebuffer");
glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)IRR_OGL_LOAD_EXTENSION("glGetUniformBlockIndex");
glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)IRR_OGL_LOAD_EXTENSION("glUniformBlockBinding");
glBlendColor = (PFNGLBLENDCOLORPROC)IRR_OGL_LOAD_EXTENSION("glBlendColor");
#ifdef DEBUG
glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)IRR_OGL_LOAD_EXTENSION("glDebugMessageCallbackARB");
#endif
@@ -308,7 +310,7 @@ GLuint getDepthTexture(irr::video::ITexture *tex)
std::set<irr::video::ITexture *> AlreadyTransformedTexture;
void transformTexturesTosRGB(irr::video::ITexture *tex)
void compressTexture(irr::video::ITexture *tex, bool srgb)
{
if (AlreadyTransformedTexture.find(tex) != AlreadyTransformedTexture.end())
return;
@@ -318,20 +320,27 @@ void transformTexturesTosRGB(irr::video::ITexture *tex)
memcpy(data, tex->lock(), w * h * 4);
tex->unlock();
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(tex));
if (irr_driver->getGLSLVersion() < 150)
unsigned internalFormat, Format;
if (tex->hasAlpha())
Format = GL_BGRA;
else
Format = GL_BGR;
if (!UserConfigParams::m_texture_compression)
{
if (tex->hasAlpha())
glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB_ALPHA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid *)data);
if (srgb)
internalFormat = (tex->hasAlpha()) ? GL_SRGB_ALPHA : GL_SRGB;
else
glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB, w, h, 0, GL_BGR, GL_UNSIGNED_BYTE, (GLvoid *)data);
internalFormat = (tex->hasAlpha()) ? GL_RGBA : GL_RGB;
}
else
{
if (tex->hasAlpha())
glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB_ALPHA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid *)data);
if (srgb)
internalFormat = (tex->hasAlpha()) ? GL_COMPRESSED_SRGB_ALPHA : GL_COMPRESSED_SRGB;
else
glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB, w, h, 0, GL_BGR, GL_UNSIGNED_BYTE, (GLvoid *)data);
internalFormat = (tex->hasAlpha()) ? GL_COMPRESSED_RGBA : GL_COMPRESSED_RGB;
}
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, w, h, 0, Format, GL_UNSIGNED_BYTE, (GLvoid *)data);
glGenerateMipmap(GL_TEXTURE_2D);
delete[] data;
}

View File

@@ -84,6 +84,7 @@ extern PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample;
extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
extern PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex;
extern PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding;
extern PFNGLBLENDCOLORPROC glBlendColor;
#ifdef DEBUG
extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
#endif
@@ -158,7 +159,7 @@ GLint LoadProgram(Types ... args)
GLuint getTextureGLuint(irr::video::ITexture *tex);
GLuint getDepthTexture(irr::video::ITexture *tex);
void transformTexturesTosRGB(irr::video::ITexture *tex);
void compressTexture(irr::video::ITexture *tex, bool srgb);
void blitFBO(GLuint Src, GLuint Dst, size_t width, size_t height);
void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect<s32>& destRect,

View File

@@ -360,7 +360,7 @@ void ParticleSystemProxy::setEmitter(scene::IParticleEmitter* emitter)
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
video::ITexture *tex = getMaterial(0).getTexture(0);
transformTexturesTosRGB(tex);
compressTexture(tex, true);
texture = getTextureGLuint(getMaterial(0).getTexture(0));
}

View File

@@ -427,7 +427,7 @@ void IrrDriver::initDevice()
glGetIntegerv(GL_MAJOR_VERSION, &GLMajorVersion);
glGetIntegerv(GL_MINOR_VERSION, &GLMinorVersion);
Log::info("IrrDriver", "OPENGL VERSION IS %d.%d", GLMajorVersion, GLMinorVersion);
m_glsl = (GLMajorVersion > 3 || (GLMajorVersion == 3 && GLMinorVersion >= 1)) && UserConfigParams::m_pixel_shaders;
m_glsl = (GLMajorVersion > 3 || (GLMajorVersion == 3 && GLMinorVersion >= 1));
// This remaps the window, so it has to be done before the clear to avoid flicker
m_device->setResizable(false);

View File

@@ -413,17 +413,13 @@ void PostProcessing::renderSSAO(const core::matrix4 &invprojm, const core::matri
glUseProgram(FullScreenShader::SSAOShader::Program);
glBindVertexArray(FullScreenShader::SSAOShader::vao);
setTexture(0, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
setTexture(0, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_LINEAR, GL_LINEAR);
setTexture(1, irr_driver->getDepthStencilTexture(), GL_LINEAR, GL_LINEAR);
setTexture(2, getTextureGLuint(noise_tex), GL_NEAREST, GL_NEAREST);
setTexture(2, getTextureGLuint(noise_tex), GL_LINEAR, GL_LINEAR);
FullScreenShader::SSAOShader::setUniforms(projm, invprojm, 0, 1, 2);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glEnable(GL_DEPTH_TEST);
}
void PostProcessing::renderFog(const core::matrix4 &ipvmat)
@@ -621,46 +617,53 @@ void PostProcessing::render()
// Blit the base to tmp1
blitFBO(irr_driver->getFBO(FBO_COLORS), out_fbo, UserConfigParams::m_width, UserConfigParams::m_height);
const bool globalbloom = World::getWorld()->getTrack()->getBloom();
if (globalbloom)
if (UserConfigParams::m_bloom)
{
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_TMP2_WITH_DS));
renderBloom(out_rtt);
glClear(GL_STENCIL_BUFFER_BIT);
// To half
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_HALF1));
glViewport(0, 0, UserConfigParams::m_width / 2, UserConfigParams::m_height / 2);
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_TMP2));
renderGaussian6Blur(irr_driver->getFBO(FBO_HALF1), irr_driver->getRenderTargetTexture(RTT_HALF1),
irr_driver->getFBO(FBO_HALF2), irr_driver->getRenderTargetTexture(RTT_HALF2), UserConfigParams::m_width / 2, UserConfigParams::m_height / 2);
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_BLOOM_1024));
glViewport(0, 0, 1024, 1024);
renderPassThrough(out_rtt);
// To quarter
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_QUARTER1));
glViewport(0, 0, UserConfigParams::m_width / 4, UserConfigParams::m_height / 4);
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_HALF1));
renderGaussian6Blur(irr_driver->getFBO(FBO_QUARTER1), irr_driver->getRenderTargetTexture(RTT_QUARTER1),
irr_driver->getFBO(FBO_QUARTER2), irr_driver->getRenderTargetTexture(RTT_QUARTER2), UserConfigParams::m_width / 4, UserConfigParams::m_height / 4);
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_BLOOM_512));
glViewport(0, 0, 512, 512);
renderBloom(irr_driver->getRenderTargetTexture(RTT_BLOOM_1024));
// To eighth
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_EIGHTH1));
glViewport(0, 0, UserConfigParams::m_width / 8, UserConfigParams::m_height / 8);
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_QUARTER1));
renderGaussian6Blur(irr_driver->getFBO(FBO_EIGHTH1), irr_driver->getRenderTargetTexture(RTT_EIGHTH1),
irr_driver->getFBO(FBO_EIGHTH2), irr_driver->getRenderTargetTexture(RTT_EIGHTH2), UserConfigParams::m_width / 8, UserConfigParams::m_height / 8);
// Downsample
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_BLOOM_256));
glViewport(0, 0, 256, 256);
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_BLOOM_512));
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_BLOOM_128));
glViewport(0, 0, 128, 128);
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_BLOOM_256));
// Blur
glViewport(0, 0, 512, 512);
renderGaussian6Blur(irr_driver->getFBO(FBO_BLOOM_512), irr_driver->getRenderTargetTexture(RTT_BLOOM_512),
irr_driver->getFBO(FBO_TMP_512), irr_driver->getRenderTargetTexture(RTT_TMP_512), 512, 512);
glViewport(0, 0, 256, 256);
renderGaussian6Blur(irr_driver->getFBO(FBO_BLOOM_256), irr_driver->getRenderTargetTexture(RTT_BLOOM_256),
irr_driver->getFBO(FBO_TMP_256), irr_driver->getRenderTargetTexture(RTT_TMP_256), 256, 256);
glViewport(0, 0, 128, 128);
renderGaussian6Blur(irr_driver->getFBO(FBO_BLOOM_128), irr_driver->getRenderTargetTexture(RTT_BLOOM_128),
irr_driver->getFBO(FBO_TMP_128), irr_driver->getRenderTargetTexture(RTT_TMP_128), 128, 128);
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
// Additively blend on top of tmp1
glBindFramebuffer(GL_FRAMEBUFFER, out_fbo);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE);
glBlendEquation(GL_FUNC_ADD);
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_HALF1));
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_QUARTER1));
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_EIGHTH1));
glBlendColor(.125, .125, .125, .125);
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_BLOOM_128));
glBlendColor(.25, .25, .25, .25);
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_BLOOM_256));
glBlendColor(.5, .5, .5, .5);
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_BLOOM_512));
glDisable(GL_BLEND);
} // end if bloom
@@ -669,7 +672,7 @@ void PostProcessing::render()
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("- Godrays", 0xFF, 0x00, 0x00);
if (m_sunpixels > 30)//World::getWorld()->getTrack()->hasGodRays() && ) // god rays
if (UserConfigParams::m_light_shaft && m_sunpixels > 30)//World::getWorld()->getTrack()->hasGodRays() && ) // god rays
{
glEnable(GL_DEPTH_TEST);
// Grab the sky
@@ -747,28 +750,44 @@ void PostProcessing::render()
PROFILER_POP_CPU_MARKER();
}
if (UserConfigParams::m_mlaa) // MLAA. Must be the last pp filter.
{
PROFILER_PUSH_CPU_MARKER("- MLAA", 0xFF, 0x00, 0x00);
glDisable(GL_BLEND);
blitFBO(in_fbo, irr_driver->getFBO(FBO_MLAA_COLORS), UserConfigParams::m_width, UserConfigParams::m_height);
applyMLAA();
in_rtt = irr_driver->getRenderTargetTexture(RTT_MLAA_COLORS);
PROFILER_POP_CPU_MARKER();
}
computeLogLuminance(in_rtt);
// Final blit
// TODO : Use glBlitFramebuffer
glEnable(GL_FRAMEBUFFER_SRGB);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, out_fbo);
renderColorLevel(in_rtt);
std::swap(in_fbo, out_fbo);
std::swap(in_rtt, out_rtt);
if (irr_driver->getNormals())
{
glEnable(GL_FRAMEBUFFER_SRGB);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH));
glDisable(GL_FRAMEBUFFER_SRGB);
}
else if (irr_driver->getSSAOViz())
{
glEnable(GL_FRAMEBUFFER_SRGB);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_SSAO));
glDisable(GL_FRAMEBUFFER_SRGB);
}
else if (UserConfigParams::m_mlaa) // MLAA. Must be the last pp filter.
{
PROFILER_PUSH_CPU_MARKER("- MLAA", 0xFF, 0x00, 0x00);
glEnable(GL_FRAMEBUFFER_SRGB);
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_MLAA_COLORS));
renderPassThrough(in_rtt);
glDisable(GL_FRAMEBUFFER_SRGB);
applyMLAA();
blitFBO(irr_driver->getFBO(FBO_MLAA_COLORS), 0, UserConfigParams::m_width, UserConfigParams::m_height);
PROFILER_POP_CPU_MARKER();
}
else
renderColorLevel(in_rtt);
glDisable(GL_FRAMEBUFFER_SRGB);
{
glEnable(GL_FRAMEBUFFER_SRGB);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
renderPassThrough(in_rtt);
glDisable(GL_FRAMEBUFFER_SRGB);
}
}
} // render

View File

@@ -184,7 +184,7 @@ void IrrDriver::renderGLSL(float dt)
PROFILER_PUSH_CPU_MARKER("- Shadow", 0x30, 0x6F, 0x90);
// Shadows
if (!m_mipviz && !m_wireframe && UserConfigParams::m_shadows)
if (!m_mipviz && !m_wireframe && UserConfigParams::m_dynamic_lights && UserConfigParams::m_shadows)
//&& World::getWorld()->getTrack()->hasShadows())
{
renderShadows(camnode, camera);
@@ -214,7 +214,7 @@ void IrrDriver::renderGLSL(float dt)
PROFILER_PUSH_CPU_MARKER("- Glow", 0xFF, 0xFF, 0x00);
// Render anything glowing.
if (!m_mipviz && !m_wireframe)
if (!m_mipviz && !m_wireframe && UserConfigParams::m_glow)
{
irr_driver->setPhase(GLOW_PASS);
renderGlow(overridemat, glows, cambox, cam);
@@ -225,7 +225,7 @@ void IrrDriver::renderGLSL(float dt)
// Is the lens flare enabled & visible? Check last frame's query.
const bool hasflare = World::getWorld()->getTrack()->hasLensFlare();
const bool hasgodrays = World::getWorld()->getTrack()->hasGodRays();
if (true)//hasflare || hasgodrays)
if (UserConfigParams::m_light_shaft)//hasflare || hasgodrays)
{
irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver();
@@ -428,6 +428,9 @@ void IrrDriver::renderSolidFirstPass()
m_scene_manager->drawAll(scene::ESNRP_SOLID);
if (!UserConfigParams::m_dynamic_lights)
return;
glUseProgram(MeshShader::ObjectPass1Shader::Program);
for (unsigned i = 0; i < GroupedFPSM<FPSM_DEFAULT>::MeshSet.size(); ++i)
{
@@ -452,7 +455,14 @@ void IrrDriver::renderSolidSecondPass()
glClearColor(clearColor.getRed() / 255.f, clearColor.getGreen() / 255.f,
clearColor.getBlue() / 255.f, clearColor.getAlpha() / 255.f);
glClear(GL_COLOR_BUFFER_BIT);
glDepthMask(GL_FALSE);
if (UserConfigParams::m_dynamic_lights)
glDepthMask(GL_FALSE);
else
{
glDepthMask(GL_TRUE);
glClear(GL_DEPTH_BUFFER_BIT);
}
irr_driver->setPhase(SOLID_LIT_PASS);
glEnable(GL_DEPTH_TEST);
@@ -502,7 +512,6 @@ void IrrDriver::renderSolidSecondPass()
glUseProgram(MeshShader::UntexturedObjectShader::Program);
for (unsigned i = 0; i < GroupedSM<SM_UNTEXTURED>::MeshSet.size(); i++)
drawUntexturedObject(*GroupedSM<SM_UNTEXTURED>::MeshSet[i], GroupedSM<SM_UNTEXTURED>::MVPSet[i]);
}
void IrrDriver::renderTransparent()
@@ -514,7 +523,6 @@ void IrrDriver::renderTransparent()
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_CULL_FACE);
m_scene_manager->drawAll(scene::ESNRP_TRANSPARENT);
}
@@ -850,15 +858,21 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
video::SOverrideMaterial &overridemat,
int cam, float dt)
{
if (SkyboxCubeMap)
irr_driver->getSceneManager()->setAmbientLight(SColor(0, 0, 0, 0));
for (unsigned i = 0; i < sun_ortho_matrix.size(); i++)
sun_ortho_matrix[i] *= getInvViewMatrix();
glBindFramebuffer(GL_FRAMEBUFFER, m_rtts->getFBO(FBO_COMBINED_TMP1_TMP2));
irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver();
GLenum bufs[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
gl_driver->extGlDrawBuffers(2, bufs);
if (!UserConfigParams::m_dynamic_lights)
glClearColor(.5, .5, .5, .5);
glClear(GL_COLOR_BUFFER_BIT);
if (!UserConfigParams::m_dynamic_lights)
return;
if (SkyboxCubeMap)
irr_driver->getSceneManager()->setAmbientLight(SColor(0, 0, 0, 0));
const u32 lightcount = m_lights.size();
const core::vector3df &campos =
@@ -935,10 +949,12 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
glBindFramebuffer(GL_FRAMEBUFFER, m_rtts->getFBO(FBO_SSAO));
glClearColor(1., 1., 1., 1.);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, UserConfigParams::m_width / 2, UserConfigParams::m_height / 2);
m_post_processing->renderSSAO(irr_driver->getInvProjMatrix(), irr_driver->getProjMatrix());
// Blur it to reduce noise.
m_post_processing->renderGaussian6Blur(irr_driver->getFBO(FBO_SSAO), irr_driver->getRenderTargetTexture(RTT_SSAO),
irr_driver->getFBO(FBO_TMP4), irr_driver->getRenderTargetTexture(RTT_TMP4), UserConfigParams::m_width, UserConfigParams::m_height);
irr_driver->getFBO(FBO_HALF1), irr_driver->getRenderTargetTexture(RTT_HALF1), UserConfigParams::m_width / 2, UserConfigParams::m_height / 2);
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
}
}
@@ -1313,18 +1329,23 @@ void IrrDriver::generateSkyboxCubemap()
image->drop();
glBindTexture(GL_TEXTURE_CUBE_MAP, SkyboxCubeMap);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_COMPRESSED_SRGB_ALPHA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*)rgba[i]);
if (UserConfigParams::m_texture_compression)
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_COMPRESSED_SRGB_ALPHA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*)rgba[i]);
else
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_SRGB_ALPHA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*)rgba[i]);
}
testSH(rgba, w, h, blueSHCoeff, greenSHCoeff, redSHCoeff);
for (unsigned i = 0; i < 6; i++)
delete[] rgba[i];
/*for (unsigned i = 0; i < 6; i++)
{
glBindTexture(GL_TEXTURE_CUBE_MAP, ConvolutedSkyboxCubeMap);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_SRGB_ALPHA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*)rgba[i]);
}
for (unsigned i = 0; i < 6; i++)
delete[] rgba[i];
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);*/
}

View File

@@ -64,12 +64,11 @@ RTT::RTT()
const dimension2du eighth = res/8;
const dimension2du sixteenth = res/16;
const dimension2du ssaosize = UserConfigParams::m_ssao == 2 ? res : quarter;
const u16 shadowside = 1024;
const dimension2du shadowsize0(shadowside, shadowside);
const dimension2du shadowsize1(shadowside / 2, shadowside / 2);
const dimension2du shadowsize2(shadowside / 4, shadowside / 4);
const dimension2du shadowsize3(shadowside / 8, shadowside / 8);
const dimension2du warpvsize(1, 512);
const dimension2du warphsize(512, 1);
@@ -84,11 +83,11 @@ RTT::RTT()
RenderTargetTextures[RTT_TMP2] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_TMP3] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_TMP4] = generateRTT(res, GL_R16F, GL_RED, GL_FLOAT);
RenderTargetTextures[RTT_NORMAL_AND_DEPTH] = generateRTT(res, GL_RGB16F, GL_RGB, GL_FLOAT);
RenderTargetTextures[RTT_NORMAL_AND_DEPTH] = generateRTT(res, GL_RGBA16F, GL_RGB, GL_FLOAT);
RenderTargetTextures[RTT_COLOR] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_MLAA_COLORS] = generateRTT(res, GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE);
RenderTargetTextures[RTT_MLAA_COLORS] = generateRTT(res, GL_SRGB, GL_BGR, GL_UNSIGNED_BYTE);
RenderTargetTextures[RTT_LOG_LUMINANCE] = generateRTT(res, GL_R16F, GL_RED, GL_FLOAT);
RenderTargetTextures[RTT_SSAO] = generateRTT(res, GL_R16F, GL_RED, GL_FLOAT);
RenderTargetTextures[RTT_SSAO] = generateRTT(half, GL_R16F, GL_RED, GL_FLOAT);
RenderTargetTextures[RTT_DISPLACE] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_HALF1] = generateRTT(half, GL_RGBA16F, GL_BGRA, GL_FLOAT);
@@ -99,6 +98,14 @@ RTT::RTT()
RenderTargetTextures[RTT_QUARTER2] = generateRTT(quarter, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_EIGHTH2] = generateRTT(eighth, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_BLOOM_1024] = generateRTT(shadowsize0, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_BLOOM_512] = generateRTT(shadowsize1, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_TMP_512] = generateRTT(shadowsize1, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_BLOOM_256] = generateRTT(shadowsize2, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_TMP_256] = generateRTT(shadowsize2, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_BLOOM_128] = generateRTT(shadowsize3, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_TMP_128] = generateRTT(shadowsize3, GL_RGBA16F, GL_BGR, GL_FLOAT);
FrameBuffers[FBO_SSAO] = generateFBO(RenderTargetTextures[RTT_SSAO]);
// Clear this FBO to 1s so that if no SSAO is computed we can still use it.
glClearColor(1., 1., 1., 1.);
@@ -119,6 +126,14 @@ RTT::RTT()
FrameBuffers[FBO_EIGHTH1] = generateFBO(RenderTargetTextures[RTT_EIGHTH1]);
FrameBuffers[FBO_EIGHTH2] = generateFBO(RenderTargetTextures[RTT_EIGHTH2]);
FrameBuffers[FBO_BLOOM_1024] = generateFBO(RenderTargetTextures[RTT_BLOOM_1024]);
FrameBuffers[FBO_BLOOM_512] = generateFBO(RenderTargetTextures[RTT_BLOOM_512]);
FrameBuffers[FBO_TMP_512] = generateFBO(RenderTargetTextures[RTT_TMP_512]);
FrameBuffers[FBO_BLOOM_256] = generateFBO(RenderTargetTextures[RTT_BLOOM_256]);
FrameBuffers[FBO_TMP_256] = generateFBO(RenderTargetTextures[RTT_TMP_256]);
FrameBuffers[FBO_BLOOM_128] = generateFBO(RenderTargetTextures[RTT_BLOOM_128]);
FrameBuffers[FBO_TMP_128] = generateFBO(RenderTargetTextures[RTT_TMP_128]);
FrameBuffers[FBO_COMBINED_TMP1_TMP2] = generateFBO(RenderTargetTextures[RTT_TMP1], DepthStencilTexture);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, RenderTargetTextures[RTT_TMP2], 0);

View File

@@ -64,6 +64,14 @@ enum TypeRTT
RTT_DISPLACE,
RTT_MLAA_COLORS,
RTT_BLOOM_1024,
RTT_BLOOM_512,
RTT_TMP_512,
RTT_BLOOM_256,
RTT_TMP_256,
RTT_BLOOM_128,
RTT_TMP_128,
RTT_COUNT
};
@@ -86,6 +94,13 @@ enum TypeFBO
FBO_EIGHTH1,
FBO_EIGHTH2,
FBO_DISPLACE,
FBO_BLOOM_1024,
FBO_BLOOM_512,
FBO_TMP_512,
FBO_BLOOM_256,
FBO_TMP_256,
FBO_BLOOM_128,
FBO_TMP_128,
FBO_COUNT
};

View File

@@ -6,6 +6,7 @@
#include "config/user_config.hpp"
#include "modes/world.hpp"
#include "tracks/track.hpp"
#include "utils/profiler.hpp"
using namespace irr;
@@ -89,6 +90,7 @@ void STKAnimatedMesh::render()
if (!mb)
continue;
video::E_MATERIAL_TYPE type = mb->getMaterial().MaterialType;
f32 MaterialTypeParam = mb->getMaterial().MaterialTypeParam;
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(type);
if (!isObject(type))
{
@@ -100,7 +102,7 @@ void STKAnimatedMesh::render()
GLMesh &mesh = GLmeshes[i];
if (rnd->isTransparent())
{
TransparentMaterial TranspMat = MaterialTypeToTransparentMaterial(type);
TransparentMaterial TranspMat = MaterialTypeToTransparentMaterial(type, MaterialTypeParam);
initvaostate(mesh, TranspMat);
TransparentMesh[TranspMat].push_back(&mesh);
}
@@ -148,6 +150,8 @@ void STKAnimatedMesh::render()
core::matrix4 invmodel;
AbsoluteTransformation.getInverse(invmodel);
PROFILER_PUSH_CPU_MARKER("GATHER SOLID MESHES", 0xFC, 0xFA, 0x68);
GLMesh* mesh;
for_in(mesh, GeometricMesh[FPSM_DEFAULT])
{
@@ -163,11 +167,14 @@ void STKAnimatedMesh::render()
GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::TIMVSet.push_back(invmodel);
}
PROFILER_POP_CPU_MARKER();
return;
}
if (irr_driver->getPhase() == SOLID_LIT_PASS)
{
PROFILER_PUSH_CPU_MARKER("GATHER TRANSPARENT MESHES", 0xFC, 0xFA, 0x68);
core::matrix4 invmodel;
AbsoluteTransformation.getInverse(invmodel);
@@ -214,6 +221,7 @@ void STKAnimatedMesh::render()
GroupedSM<SM_UNTEXTURED>::TIMVSet.push_back(invmodel);
}
PROFILER_POP_CPU_MARKER();
return;
}
@@ -247,19 +255,25 @@ void STKAnimatedMesh::render()
if (World::getWorld()->getTrack()->isFogEnabled())
{
if (!TransparentMesh[TM_DEFAULT].empty())
if (!TransparentMesh[TM_DEFAULT].empty() || !TransparentMesh[TM_ADDITIVE].empty())
glUseProgram(MeshShader::TransparentFogShader::Program);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
for_in(mesh, TransparentMesh[TM_DEFAULT])
drawTransparentFogObject(*mesh, ModelViewProjectionMatrix, mesh->TextureMatrix);
glBlendFunc(GL_ONE, GL_ONE);
for_in(mesh, TransparentMesh[TM_ADDITIVE])
drawTransparentFogObject(*mesh, ModelViewProjectionMatrix, mesh->TextureMatrix);
}
else
{
if (!TransparentMesh[TM_DEFAULT].empty())
if (!TransparentMesh[TM_DEFAULT].empty() || !TransparentMesh[TM_ADDITIVE].empty())
glUseProgram(MeshShader::TransparentShader::Program);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
for_in(mesh, TransparentMesh[TM_DEFAULT])
drawTransparentObject(*mesh, ModelViewProjectionMatrix, mesh->TextureMatrix);
glBlendFunc(GL_ONE, GL_ONE);
for_in(mesh, TransparentMesh[TM_ADDITIVE])
drawTransparentObject(*mesh, ModelViewProjectionMatrix, mesh->TextureMatrix);
}
return;
}

View File

@@ -35,7 +35,7 @@ void STKBillboard::render()
core::vector3df pos = getAbsolutePosition();
glBindVertexArray(billboardvao);
video::ITexture *tex = Material.getTexture(0);
transformTexturesTosRGB(tex);
compressTexture(tex, true);
GLuint texid = getTextureGLuint(tex);
setTexture(0, texid, GL_LINEAR, GL_LINEAR);
glUseProgram(MeshShader::BillboardShader::Program);

View File

@@ -186,11 +186,27 @@ static void drawFSPMDefault(GLMesh &mesh, size_t instance_count)
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (mesh.textures[0])
{
compressTexture(mesh.textures[0], true);
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
}
else
{
setTexture(0, 0, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, false);
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ONE };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
MeshShader::InstancedObjectPass1Shader::setUniforms(0);
glBindVertexArray(mesh.vao_first_pass);
glDrawElementsInstanced(ptype, count, itype, 0, instance_count);
if (!mesh.textures[0])
{
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
}
static void drawShadowDefault(GLMesh &mesh, size_t instance_count)
@@ -214,6 +230,7 @@ static void drawFSPMAlphaRefTexture(GLMesh &mesh, size_t instance_count)
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::InstancedObjectRefPass1Shader::setUniforms(0);
@@ -228,6 +245,7 @@ static void drawShadowAlphaRefTexture(GLMesh &mesh, size_t instance_count)
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::InstancedRefShadowShader::setUniforms(0);
@@ -243,6 +261,7 @@ static void drawFSPMGrass(GLMesh &mesh, const core::vector3df &windDir, size_t i
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::InstancedGrassPass1Shader::setUniforms(windDir, 0);
@@ -272,6 +291,7 @@ static void drawSMAlphaRefTexture(GLMesh &mesh, const core::matrix4 &ModelViewPr
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(MeshShader::InstancedObjectRefPass2Shader::TU_Albedo, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::InstancedObjectRefPass2Shader::setUniforms(ModelViewProjectionMatrix, core::matrix4::EM4CONST_IDENTITY);
@@ -287,6 +307,7 @@ static void drawSMGrass(GLMesh &mesh, const core::matrix4 &ModelViewProjectionMa
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(MeshShader::InstancedGrassPass2Shader::TU_Albedo, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
setTexture(MeshShader::InstancedGrassPass2Shader::TU_dtex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT);

View File

@@ -45,12 +45,17 @@ ShadedMaterial MaterialTypeToShadedMaterial(video::E_MATERIAL_TYPE type, video::
return SM_DEFAULT;
}
TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE type)
TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE type, f32 MaterialTypeParam)
{
if (type == irr_driver->getShader(ES_BUBBLES))
return TM_BUBBLE;
else
return TM_DEFAULT;
video::E_BLEND_FACTOR srcFact, DstFact;
video::E_MODULATE_FUNC mod;
u32 alpha;
unpack_textureBlendFunc(srcFact, DstFact, mod, alpha, MaterialTypeParam);
if (DstFact == video::EBF_ONE)
return TM_ADDITIVE;
return TM_DEFAULT;
}
GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_texcoord, GLuint attrib_second_texcoord, GLuint attrib_normal, GLuint attrib_tangent, GLuint attrib_bitangent, GLuint attrib_color, size_t stride)
@@ -178,12 +183,7 @@ GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb)
}
ITexture *tex;
for (unsigned i = 0; i < 6; i++)
{
tex = mb->getMaterial().getTexture(i);
if (tex)
transformTexturesTosRGB(tex);
result.textures[i] = tex;
}
result.textures[i] = mb->getMaterial().getTexture(i);
result.TextureMatrix = 0;
return result;
}
@@ -225,7 +225,10 @@ void drawObjectPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjecti
size_t count = mesh.IndexCount;
if (mesh.textures[0])
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
{
compressTexture(mesh.textures[0], true);
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
}
else
{
setTexture(0, 0, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, false);
@@ -252,7 +255,7 @@ void drawObjectRefPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProje
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::ObjectRefPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix, 0);
@@ -269,6 +272,7 @@ void drawGrassPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::GrassPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, windDir, 0);
@@ -286,6 +290,7 @@ void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelMatrix, const
size_t count = mesh.IndexCount;
assert(mesh.textures[1]);
compressTexture(mesh.textures[1], false);
setTexture(0, getTextureGLuint(mesh.textures[1]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::NormalMapShader::setUniforms(ModelMatrix, InverseModelMatrix, 0);
@@ -336,6 +341,7 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
size_t count = mesh.IndexCount;
// Texlayout
compressTexture(mesh.textures[1], true);
setTexture(MeshShader::SplattingShader::TU_tex_layout, getTextureGLuint(mesh.textures[1]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz())
{
@@ -348,6 +354,7 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
//Tex detail0
compressTexture(mesh.textures[2], true);
setTexture(MeshShader::SplattingShader::TU_tex_detail0, getTextureGLuint(mesh.textures[2]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz())
{
@@ -360,6 +367,7 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
//Tex detail1
compressTexture(mesh.textures[3], true);
setTexture(MeshShader::SplattingShader::TU_tex_detail1, getTextureGLuint(mesh.textures[3]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz())
{
@@ -371,6 +379,7 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
GLint swizzleMask[] = {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA};
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
compressTexture(mesh.textures[4], true);
//Tex detail2
setTexture(MeshShader::SplattingShader::TU_tex_detail2, getTextureGLuint(mesh.textures[4]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz())
@@ -384,6 +393,7 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
//Tex detail3
compressTexture(mesh.textures[5], true);
setTexture(MeshShader::SplattingShader::TU_tex_detail3, getTextureGLuint(mesh.textures[5]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz())
{
@@ -410,6 +420,7 @@ void drawObjectRefPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjec
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(MeshShader::ObjectRefPass2Shader::TU_Albedo, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz())
{
@@ -438,6 +449,7 @@ void drawCaustics(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionM
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(MeshShader::CausticsShader::TU_Albedo, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz())
{
@@ -451,6 +463,7 @@ void drawCaustics(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionM
}
if (!CausticTex)
CausticTex = irr_driver->getTexture(file_manager->getAsset("textures/caustics.png").c_str());
compressTexture(CausticTex, false);
setTexture(MeshShader::CausticsShader::TU_caustictex, getTextureGLuint(CausticTex), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::CausticsShader::setUniforms(ModelViewProjectionMatrix, dir, dir2,
@@ -469,6 +482,7 @@ void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(MeshShader::GrassPass2Shader::TU_Albedo, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz())
{
@@ -509,6 +523,7 @@ void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjec
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(MeshShader::ObjectRimLimitShader::TU_Albedo, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz())
{
@@ -535,6 +550,7 @@ void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(MeshShader::ObjectUnlitShader::TU_tex, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz())
{
@@ -561,6 +577,7 @@ void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelView
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(MeshShader::DetailledObjectPass2Shader::TU_Albedo, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz())
{
@@ -572,7 +589,7 @@ void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelView
GLint swizzleMask[] = {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA};
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
compressTexture(mesh.textures[1], true);
setTexture(MeshShader::DetailledObjectPass2Shader::TU_detail, getTextureGLuint(mesh.textures[1]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::DetailledObjectPass2Shader::setUniforms(ModelViewProjectionMatrix);
@@ -589,6 +606,7 @@ void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(MeshShader::ObjectPass2Shader::TU_Albedo, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz())
{
@@ -615,6 +633,7 @@ void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewPro
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::TransparentShader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, 0);
@@ -645,6 +664,7 @@ void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelView
tmpcol.getGreen() / 255.0f,
tmpcol.getBlue() / 255.0f);
compressTexture(mesh.textures[0], true);
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
glUseProgram(MeshShader::TransparentFogShader::Program);
@@ -665,6 +685,7 @@ void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatr
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::BubbleShader::setUniforms(ModelViewProjectionMatrix, 0, time, transparency);
@@ -681,6 +702,7 @@ void drawShadowRef(const GLMesh &mesh, const core::matrix4 &ModelMatrix)
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::RefShadowShader::setUniforms(ModelMatrix, 0);
@@ -833,10 +855,10 @@ void initvaostate(GLMesh &mesh, TransparentMaterial TranspMat)
MeshShader::BubbleShader::attrib_position, MeshShader::BubbleShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
break;
case TM_DEFAULT:
case TM_ADDITIVE:
if (World::getWorld()->getTrack()->isFogEnabled())
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::TransparentFogShader::attrib_position, MeshShader::TransparentFogShader::attrib_texcoord, -1, -1, -1, -1, MeshShader::TransparentFogShader::attrib_color, mesh.Stride);
else
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::TransparentShader::attrib_position, MeshShader::TransparentShader::attrib_texcoord, -1, -1, -1, -1, MeshShader::TransparentShader::attrib_color, mesh.Stride);

View File

@@ -35,6 +35,7 @@ enum ShadedMaterial
enum TransparentMaterial
{
TM_DEFAULT,
TM_ADDITIVE,
TM_BUBBLE,
TM_COUNT
};
@@ -139,6 +140,6 @@ void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatr
GeometricMaterial MaterialTypeToGeometricMaterial(video::E_MATERIAL_TYPE);
ShadedMaterial MaterialTypeToShadedMaterial(video::E_MATERIAL_TYPE, irr::video::ITexture **textures);
TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE);
TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE, f32 MaterialTypeParam);
#endif // STKMESH_H

View File

@@ -46,6 +46,7 @@ void STKMeshSceneNode::setFirstTimeMaterial()
if (!mb)
continue;
video::E_MATERIAL_TYPE type = mb->getMaterial().MaterialType;
f32 MaterialTypeParam = mb->getMaterial().MaterialTypeParam;
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(type);
if (!isObject(type))
{
@@ -58,7 +59,7 @@ void STKMeshSceneNode::setFirstTimeMaterial()
GLMesh &mesh = GLmeshes[i];
if (rnd->isTransparent())
{
TransparentMaterial TranspMat = MaterialTypeToTransparentMaterial(type);
TransparentMaterial TranspMat = MaterialTypeToTransparentMaterial(type, MaterialTypeParam);
initvaostate(mesh, TranspMat);
TransparentMesh[TranspMat].push_back(&mesh);
}
@@ -500,17 +501,25 @@ void STKMeshSceneNode::render()
if (World::getWorld()->getTrack()->isFogEnabled())
{
if (!TransparentMesh[TM_DEFAULT].empty())
if (!TransparentMesh[TM_DEFAULT].empty() || !TransparentMesh[TM_ADDITIVE].empty())
glUseProgram(MeshShader::TransparentFogShader::Program);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
for_in(mesh, TransparentMesh[TM_DEFAULT])
drawTransparentFogObject(*mesh, ModelViewProjectionMatrix, (*mesh).TextureMatrix);
glBlendFunc(GL_ONE, GL_ONE);
for_in(mesh, TransparentMesh[TM_ADDITIVE])
drawTransparentFogObject(*mesh, ModelViewProjectionMatrix, (*mesh).TextureMatrix);
}
else
{
if (!TransparentMesh[TM_DEFAULT].empty())
if (!TransparentMesh[TM_DEFAULT].empty() || !TransparentMesh[TM_ADDITIVE].empty())
glUseProgram(MeshShader::TransparentShader::Program);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
for_in(mesh, TransparentMesh[TM_DEFAULT])
drawTransparentObject(*mesh, ModelViewProjectionMatrix, (*mesh).TextureMatrix);
glBlendFunc(GL_ONE, GL_ONE);
for_in(mesh, TransparentMesh[TM_ADDITIVE])
drawTransparentObject(*mesh, ModelViewProjectionMatrix, (*mesh).TextureMatrix);
}
return;
}

View File

@@ -178,7 +178,6 @@
#include "network/server_network_manager.hpp"
#include "network/protocol_manager.hpp"
#include "network/protocols/server_lobby_room_protocol.hpp"
#include "online/current_user.hpp"
#include "online/profile_manager.hpp"
#include "online/request_manager.hpp"
#include "online/servers_manager.hpp"
@@ -966,7 +965,7 @@ int handleCmdLine()
{
irr::core::stringw s;
Online::XMLRequest* request =
PlayerManager::getCurrentUser()->requestSignIn(login, password, false, false);
PlayerManager::requestSignIn(login, password, false, false);
request->executeNow();
if (request->isSuccess())
@@ -1178,7 +1177,7 @@ int main(int argc, char *argv[] )
// Reading the rest of the player data needs the unlock manager to
// initialise the game slots of all players and the AchievementsManager
// to initialise the AchievementsStatus, so it is done only now.
PlayerManager::get()->loadRemainingData();
PlayerManager::get()->initRemainingData();
GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI,
"gui_lock.png" ) );

View File

@@ -23,7 +23,6 @@
#include "network/network_manager.hpp"
#include "network/network_world.hpp"
#include "network/protocols/start_game_protocol.hpp"
#include "online/current_user.hpp"
#include "online/online_profile.hpp"
#include "states_screens/network_kart_selection.hpp"
#include "states_screens/state_manager.hpp"
@@ -377,7 +376,7 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
NetworkPlayerProfile* profile = new NetworkPlayerProfile();
profile->kart_name = "";
profile->race_id = data.gui8(1);
profile->user_profile = PlayerManager::getCurrentUser()->getProfile();
profile->user_profile = PlayerManager::getCurrentOnlineProfile();
m_setup->addPlayer(profile);
// connection token
uint32_t token = data.gui32(3);

View File

@@ -25,7 +25,6 @@
#include "network/protocols/hide_public_address.hpp"
#include "network/protocols/request_connection.hpp"
#include "network/protocols/ping_protocol.hpp"
#include "online/current_user.hpp"
#include "utils/time.hpp"
#include "utils/log.hpp"

View File

@@ -27,7 +27,6 @@
#include "network/protocols/ping_protocol.hpp"
#include "network/protocols/quick_join_protocol.hpp"
#include "network/protocols/client_lobby_room_protocol.hpp"
#include "online/current_user.hpp"
#include "utils/time.hpp"
#include "utils/log.hpp"

View File

@@ -19,11 +19,10 @@
#include "network/protocols/get_peer_address.hpp"
#include "config/player_manager.hpp"
#include "config/user_config.hpp"
#include "network/protocol_manager.hpp"
#include "network/network_manager.hpp"
#include "online/request_manager.hpp"
#include "online/current_user.hpp"
#include "config/user_config.hpp"
#include "utils/log.hpp"
GetPeerAddress::GetPeerAddress(uint32_t peer_id, CallbackObject* callback_object) : Protocol(callback_object, PROTOCOL_SILENT)

View File

@@ -22,7 +22,6 @@
#include "config/user_config.hpp"
#include "network/protocol_manager.hpp"
#include "online/request_manager.hpp"
#include "online/current_user.hpp"
#include "utils/log.hpp"
HidePublicAddress::HidePublicAddress() : Protocol(NULL, PROTOCOL_SILENT)

View File

@@ -21,7 +21,6 @@
#include "config/player_manager.hpp"
#include "config/user_config.hpp"
#include "network/network_manager.hpp"
#include "online/current_user.hpp"
#include "online/request_manager.hpp"
#include "utils/log.hpp"

View File

@@ -22,7 +22,6 @@
#include "config/user_config.hpp"
#include "network/protocol_manager.hpp"
#include "online/servers_manager.hpp"
#include "online/current_user.hpp"
using namespace Online;

View File

@@ -2,7 +2,6 @@
#define HEADER_REQUEST_CONNECTION_HPP
#include "network/protocol.hpp"
#include "online/current_user.hpp"
#include "online/xml_request.hpp"
class RequestConnection : public Protocol

View File

@@ -28,7 +28,6 @@
#include "network/protocols/start_server.hpp"
#include "network/protocols/start_game_protocol.hpp"
#include "network/server_network_manager.hpp"
#include "online/current_user.hpp"
#include "online/online_profile.hpp"
#include "online/request_manager.hpp"
#include "utils/log.hpp"

View File

@@ -22,7 +22,6 @@
#include "config/user_config.hpp"
#include "network/network_manager.hpp"
#include "online/request_manager.hpp"
#include "online/current_user.hpp"
#include "utils/log.hpp"
ShowPublicAddress::ShowPublicAddress() : Protocol(NULL, PROTOCOL_SILENT)

View File

@@ -10,7 +10,6 @@
#include "network/game_setup.hpp"
#include "network/network_world.hpp"
#include "network/protocols/synchronization_protocol.hpp"
#include "online/current_user.hpp"
#include "online/online_profile.hpp"
#include "race/race_manager.hpp"
#include "states_screens/state_manager.hpp"
@@ -19,8 +18,8 @@
#include "utils/log.hpp"
#include "utils/time.hpp"
StartGameProtocol::StartGameProtocol(GameSetup* game_setup) :
Protocol(NULL, PROTOCOL_START_GAME)
StartGameProtocol::StartGameProtocol(GameSetup* game_setup)
: Protocol(NULL, PROTOCOL_START_GAME)
{
m_game_setup = game_setup;
std::vector<NetworkPlayerProfile*> players = m_game_setup->getPlayers();
@@ -106,7 +105,8 @@ void StartGameProtocol::update()
// have to add self first
for (unsigned int i = 0; i < players.size(); i++)
{
bool is_me = (players[i]->user_profile == PlayerManager::getCurrentUser()->getProfile());
bool is_me = (players[i]->user_profile ==
PlayerManager::getCurrentOnlineProfile());
if (is_me)
{
NetworkPlayerProfile* profile = players[i];
@@ -134,7 +134,8 @@ void StartGameProtocol::update()
}
for (unsigned int i = 0; i < players.size(); i++)
{
bool is_me = (players[i]->user_profile == PlayerManager::getCurrentUser()->getProfile());
bool is_me = (players[i]->user_profile ==
PlayerManager::getCurrentOnlineProfile());
NetworkPlayerProfile* profile = players[i];
RemoteKartInfo rki(profile->race_id, profile->kart_name,
profile->user_profile->getUserName(), profile->race_id, !is_me);

View File

@@ -21,7 +21,6 @@
#include "config/player_manager.hpp"
#include "config/user_config.hpp"
#include "network/network_manager.hpp"
#include "online/current_user.hpp"
#include "online/request_manager.hpp"
StartServer::StartServer() : Protocol(NULL, PROTOCOL_SILENT)

View File

@@ -21,7 +21,6 @@
#include "config/player_manager.hpp"
#include "config/user_config.hpp"
#include "network/network_manager.hpp"
#include "online/current_user.hpp"
#include "online/request_manager.hpp"
StopServer::StopServer() : Protocol(NULL, PROTOCOL_SILENT)

View File

@@ -17,7 +17,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "online/current_user.hpp"
#include "online/online_player_profile.hpp"
#include "achievements/achievements_manager.hpp"
#include "config/player_manager.hpp"
@@ -51,7 +51,7 @@ namespace Online
* \param request The http request.
* \param action If not empty, the action to be set.
*/
void CurrentUser::setUserDetails(HTTPRequest *request,
void OnlinePlayerProfile::setUserDetails(HTTPRequest *request,
const std::string &action,
const std::string &php_script)
{
@@ -62,37 +62,47 @@ namespace Online
if (m_profile)
request->addParameter("userid", m_profile->getID());
if(m_state == US_SIGNED_IN)
if(m_online_state == OS_SIGNED_IN)
request->addParameter("token", m_token);
if (action.size() > 0)
request->addParameter("action", action);
} // setUserDetails
// ========================================================================
CurrentUser::CurrentUser()
OnlinePlayerProfile::OnlinePlayerProfile(const XMLNode *player)
: PlayerProfile(player)
{
m_state = US_SIGNED_OUT;
m_online_state = OS_SIGNED_OUT;
m_token = "";
m_save_session = false;
m_profile = NULL;
} // CurrentUser
} // OnlinePlayerProfile
// ------------------------------------------------------------------------
OnlinePlayerProfile::OnlinePlayerProfile(const core::stringw &name, bool is_guest)
: PlayerProfile(name, is_guest)
{
m_online_state = OS_SIGNED_OUT;
m_token = "";
m_save_session = false;
m_profile = NULL;
} // OnlinePlayerProfile
// ------------------------------------------------------------------------
/** Request a login using the saved credentials of the user.
*/
void CurrentUser::requestSavedSession()
void OnlinePlayerProfile::requestSavedSession()
{
SignInRequest * request = NULL;
const PlayerProfile *cp = PlayerManager::getCurrentPlayer();
if (m_state == US_SIGNED_OUT && cp->hasSavedSession() )
if (m_online_state == OS_SIGNED_OUT && hasSavedSession() )
{
request = new SignInRequest(true);
request->setServerURL("client-user.php");
request->addParameter("action","saved-session");
request->addParameter("userid", cp->getSavedUserId());
request->addParameter("token", cp->getSavedToken());
request->addParameter("action", "saved-session" );
request->addParameter("userid", getSavedUserId());
request->addParameter("token", getSavedToken() );
request->queue();
m_state = US_SIGNING_IN;
m_online_state = OS_SIGNING_IN;
}
} // requestSavedSession
@@ -105,12 +115,12 @@ namespace Online
* \param request_now Immediately submit this request to the
* RequestManager.
*/
CurrentUser::SignInRequest*
CurrentUser::requestSignIn(const core::stringw &username,
OnlinePlayerProfile::SignInRequest*
OnlinePlayerProfile::requestSignIn(const core::stringw &username,
const core::stringw &password,
bool save_session, bool request_now)
{
assert(m_state == US_SIGNED_OUT);
assert(m_online_state == OS_SIGNED_OUT);
m_save_session = save_session;
SignInRequest * request = new SignInRequest(false);
request->setServerURL("client-user.php");
@@ -121,7 +131,7 @@ namespace Online
if (request_now)
{
request->queue();
m_state = US_SIGNING_IN;
m_online_state = OS_SIGNING_IN;
}
return request;
} // requestSignIn
@@ -129,9 +139,9 @@ namespace Online
// ------------------------------------------------------------------------
/** Called when the signin request is finished.
*/
void CurrentUser::SignInRequest::callback()
void OnlinePlayerProfile::SignInRequest::callback()
{
PlayerManager::getCurrentUser()->signIn(isSuccess(), getXMLData());
PlayerManager::getCurrentPlayer()->signIn(isSuccess(), getXMLData());
GUIEngine::Screen *screen = GUIEngine::getCurrentScreen();
LoginScreen *login = dynamic_cast<LoginScreen*>(screen);
if(login)
@@ -151,7 +161,7 @@ namespace Online
* successful login attemp.
* \param input Xml tree with the complete server response.
*/
void CurrentUser::signIn(bool success, const XMLNode * input)
void OnlinePlayerProfile::signIn(bool success, const XMLNode * input)
{
if (success)
{
@@ -162,11 +172,10 @@ namespace Online
int userid_fetched = input->get("userid", &userid);
m_profile = new OnlineProfile(userid, username, true);
assert(token_fetched && username_fetched && userid_fetched);
m_state = US_SIGNED_IN;
if(saveSession())
m_online_state = OS_SIGNED_IN;
if(doSaveSession())
{
PlayerManager::getCurrentPlayer()->saveSession(getID(),
getToken() );
saveSession(getOnlineId(), getToken() );
}
ProfileManager::get()->addPersistent(m_profile);
std::string achieved_string("");
@@ -180,42 +189,42 @@ namespace Online
} // if success
else
{
m_state = US_SIGNED_OUT;
m_online_state = OS_SIGNED_OUT;
}
} // signIn
// ------------------------------------------------------------------------
void CurrentUser::requestSignOut()
void OnlinePlayerProfile::requestSignOut()
{
assert(m_state == US_SIGNED_IN || m_state == US_GUEST);
assert(m_online_state == OS_SIGNED_IN || m_online_state == OS_GUEST);
SignOutRequest * request = new SignOutRequest();
request->setServerURL("client-user.php");
request->addParameter("action","disconnect");
request->addParameter("token", getToken());
request->addParameter("userid", getID());
request->addParameter("userid", getOnlineId());
request->queue();
m_state = US_SIGNING_OUT;
m_online_state = OS_SIGNING_OUT;
} // requestSignOut
// --------------------------------------------------------------------
void CurrentUser::SignOutRequest::callback()
void OnlinePlayerProfile::SignOutRequest::callback()
{
PlayerManager::getCurrentUser()->signOut(isSuccess(), getXMLData());
PlayerManager::getCurrentPlayer()->signOut(isSuccess(), getXMLData());
} // SignOutRequest::callback
// ------------------------------------------------------------------------
void CurrentUser::signOut(bool success, const XMLNode * input)
void OnlinePlayerProfile::signOut(bool success, const XMLNode * input)
{
if(!success)
{
Log::warn("CurrentUser::signOut", "%s",
Log::warn("OnlinePlayerProfile::signOut", "%s",
"There were some connection issues while signing out. "
"Report a bug if this caused issues.");
}
m_token = "";
ProfileManager::get()->clearPersistent();
m_profile = NULL;
m_state = US_SIGNED_OUT;
m_online_state = OS_SIGNED_OUT;
PlayerManager::getCurrentPlayer()->clearSession();
} // signOut
@@ -223,14 +232,14 @@ namespace Online
/** Sends a request to the server to see if any new information is
* available. (online friends, notifications, etc.).
*/
void CurrentUser::requestPoll() const
void OnlinePlayerProfile::requestPoll() const
{
assert(m_state == US_SIGNED_IN);
CurrentUser::PollRequest * request = new CurrentUser::PollRequest();
assert(m_online_state == OS_SIGNED_IN);
OnlinePlayerProfile::PollRequest * request = new OnlinePlayerProfile::PollRequest();
request->setServerURL("client-user.php");
request->addParameter("action", "poll");
request->addParameter("token", getToken());
request->addParameter("userid", getID());
request->addParameter("userid", getOnlineId());
request->queue();
} // requestPoll()
@@ -238,13 +247,13 @@ namespace Online
/** Callback for the poll request. Parses the information and spawns
* notifications accordingly.
*/
void CurrentUser::PollRequest::callback()
void OnlinePlayerProfile::PollRequest::callback()
{
if(isSuccess())
{
if (!PlayerManager::getCurrentUser()->isRegisteredUser())
if (!PlayerManager::getCurrentPlayer()->isLoggedIn())
return;
if (PlayerManager::getCurrentUser()->getProfile()->hasFetchedFriends())
if (PlayerManager::getCurrentPlayer()->getProfile()->hasFetchedFriends())
{
std::string online_friends_string("");
if(getXMLData()->get("online", &online_friends_string) == 1)
@@ -253,7 +262,7 @@ namespace Online
StringUtils::splitToUInt(online_friends_string, ' ');
bool went_offline = false;
std::vector<uint32_t> friends =
PlayerManager::getCurrentUser()->getProfile()->getFriends();
PlayerManager::getCurrentPlayer()->getProfile()->getFriends();
std::vector<core::stringw> to_notify;
for(unsigned int i = 0; i < friends.size(); ++i)
{
@@ -329,7 +338,7 @@ namespace Online
}
else
{
PlayerManager::getCurrentUser()->getProfile()->fetchFriends();
PlayerManager::getCurrentPlayer()->getProfile()->fetchFriends();
}
int friend_request_count = 0;
@@ -374,43 +383,31 @@ namespace Online
/** Sends a message to the server that the client has been closed, if a
* user is signed in.
*/
void CurrentUser::onSTKQuit() const
void OnlinePlayerProfile::onSTKQuit() const
{
if(isRegisteredUser())
if(isLoggedIn())
{
HTTPRequest * request =
new HTTPRequest(true, RequestManager::HTTP_MAX_PRIORITY);
request->setServerURL("client-user.php");
request->addParameter("action", "client-quit");
request->addParameter("token", getToken());
request->addParameter("userid", getID());
request->addParameter("userid", getOnlineId());
request->queue();
}
}
// ------------------------------------------------------------------------
/** \return the username if signed in. */
core::stringw CurrentUser::getUserName() const
{
if((m_state == US_SIGNED_IN ) || (m_state == US_GUEST))
{
assert(m_profile != NULL);
return m_profile->getUserName();
}
return _("Currently not signed in");
} // getUserName
// ------------------------------------------------------------------------
/** \return the online id, or 0 if the user is not signed in.
*/
uint32_t CurrentUser::getID() const
uint32_t OnlinePlayerProfile::getOnlineId() const
{
if((m_state == US_SIGNED_IN ))
if((m_online_state == OS_SIGNED_IN ))
{
assert(m_profile != NULL);
return m_profile->getID();
}
return 0;
} // getID
} // getOnlineId
} // namespace Online

View File

@@ -19,12 +19,12 @@
#ifndef HEADER_CURRENT_ONLINE_USER_HPP
#define HEADER_CURRENT_ONLINE_USER_HPP
#include "config/player_profile.hpp"
#include "online/http_request.hpp"
#include "online/online_profile.hpp"
#include "online/request_manager.hpp"
#include "online/server.hpp"
#include "online/xml_request.hpp"
#include "utils/leak_check.hpp"
#include "utils/synchronised.hpp"
#include "utils/types.hpp"
@@ -46,10 +46,8 @@ namespace Online
* \brief Class that represents an online registered user
* \ingroup online
*/
class CurrentUser
class OnlinePlayerProfile : public PlayerProfile
{
private:
LEAK_CHECK()
public:
// ----------------------------------------------------------------
class SignInRequest : public XMLRequest
@@ -80,63 +78,70 @@ namespace Online
bool m_save_session;
OnlineProfile *m_profile;
bool saveSession() const { return m_save_session; }
/** The state of the player (logged in, logging in, ...) */
PlayerProfile::OnlineState m_online_state;
bool doSaveSession() const { return m_save_session; }
void signIn (bool success, const XMLNode * input);
void signOut (bool success, const XMLNode * input);
virtual void signIn(bool success, const XMLNode * input);
virtual void signOut(bool success, const XMLNode * input);
// For now declare functions that will become part of PlayerManager
// or Playerprofile to be private, and give only PlayerManager
// access to them. FIXME
// FIXME: This apparently does not compile on linux :(
// So I'll make this all public for now again
// friend class PlayerManager;
// So for now (while this is needed) I'll only add this on
// windows only (where it works).
#ifdef WIN32
friend class PlayerManager;
public:
uint32_t getID() const;
void setUserDetails(HTTPRequest *request,
const std::string &action,
const std::string &php_script = "");
bool isRegisteredUser() const { return m_state == US_SIGNED_IN; }
/** Returns the user state. */
enum UserState
{
US_SIGNED_OUT = 0,
US_SIGNED_IN,
US_GUEST,
US_SIGNING_IN,
US_SIGNING_OUT
};
UserState m_state;
const UserState getUserState() const { return m_state; }
#else
public:
#endif
virtual uint32_t getOnlineId() const;
virtual void setUserDetails(Online::HTTPRequest *request,
const std::string &action,
const std::string &php_script = "");
public:
CurrentUser();
void requestSavedSession();
SignInRequest * requestSignIn( const irr::core::stringw &username,
const irr::core::stringw &password,
bool save_session,
bool request_now = true);
void requestSignOut();
void requestFriendRequest(const uint32_t friend_id) const;
void onSTKQuit() const;
void requestPoll() const;
irr::core::stringw getUserName() const;
virtual void requestPoll() const;
virtual void onSTKQuit() const;
// ----------------------------------------------------------------
/** Returns if this user is logged in. */
virtual bool isLoggedIn() const
{
return m_online_state == PlayerProfile::OS_SIGNED_IN;
} // isLoggedIn
// ----------------------------------------------------------------
/** The online state of the player (i.e. logged out, logging in,
* logged in, ...). */
PlayerProfile::OnlineState getOnlineState() const
{
return m_online_state;
} // getOnlineState
// ----------------------------------------------------------------
/** Returns a pointer to the profile associated with the current
* user. */
OnlineProfile* getProfile() const { return m_profile; }
// ----------------------------------------------------------------
/** Returns the session token of the signed in user. */
const std::string& getToken() const { return m_token; }
// ----------------------------------------------------------------
/** Returns a pointer to the profile associated with the current
* user. */
OnlineProfile* getProfile() const { return m_profile; }
virtual void requestSavedSession();
virtual void requestSignOut();
virtual SignInRequest *requestSignIn(const irr::core::stringw &username,
const irr::core::stringw &password,
bool save_session,
bool request_now = true);
public:
OnlinePlayerProfile(const XMLNode *player);
OnlinePlayerProfile(const core::stringw &name, bool is_guest = false);
virtual ~OnlinePlayerProfile() {};
// ----------------------------------------------------------------
}; // class CurrentUser
}; // class OnlinePlayerProfile
} // namespace Online

View File

@@ -19,7 +19,6 @@
#include "online/profile_manager.hpp"
#include "online/current_user.hpp"
#include "online/online_profile.hpp"
#include "utils/log.hpp"
#include "utils/translation.hpp"

View File

@@ -21,7 +21,6 @@
#include "online/request_manager.hpp"
#include "config/player_manager.hpp"
#include "online/current_user.hpp"
#include "states_screens/state_manager.hpp"
#include <iostream>
@@ -129,7 +128,10 @@ namespace Online
errno);
}
pthread_attr_destroy(&attr);
PlayerManager::getCurrentUser()->requestSavedSession();
// In case that login id was not saved (or first start of stk),
// current player would not be defined at this stage.
if(PlayerManager::getCurrentPlayer())
PlayerManager::resumeSavedSession();
} // startNetworkThread
// ------------------------------------------------------------------------
@@ -147,7 +149,7 @@ namespace Online
// a download, which mean we can get the mutex and ask the service
// thread here to cancel properly.
//cancelAllDownloads(); FIXME if used this way it also cancels the client-quit action
PlayerManager::getCurrentUser()->onSTKQuit();
PlayerManager::onSTKQuit();
addRequest(new Request(true, HTTP_MAX_PRIORITY, Request::RT_QUIT));
} // stopNetworkThread
@@ -277,8 +279,12 @@ namespace Online
{
handleResultQueue();
//Database polling starts here, only needed for registered users
if (!PlayerManager::isCurrentLoggedIn())
// Database polling starts here, only needed for registered users. If
// there is no player data yet (i.e. either because first time start
// of stk, and loging screen hasn't finished yet, or no default player
// was saved), don't do anything
if (!PlayerManager::getCurrentPlayer() ||
!PlayerManager::isCurrentLoggedIn())
return;
m_time_since_poll += dt;
@@ -288,7 +294,7 @@ namespace Online
if(m_time_since_poll > interval)
{
m_time_since_poll = 0;
PlayerManager::getCurrentUser()->requestPoll();
PlayerManager::requestOnlinePoll();
}
} // update

View File

@@ -218,30 +218,49 @@ bool GrandPrixData::checkConsistency(bool chatty) const
/** Returns true if the track is available. This is used to test if Fort Magma
* is available (this way FortMagma is not used in the last Grand Prix in
* story mode, but will be available once all challenges are done and nolok
* is unlocked).
* is unlocked). It also prevents people from using the grand prix editor as
* a way to play tracks that still haven't been unlocked
*/
bool GrandPrixData::isTrackAvailable(const std::string &id) const
bool GrandPrixData::isTrackAvailable(const std::string &id, bool includeLocked) const
{
return id!="fortmagma" ||
!PlayerManager::getCurrentPlayer()->isLocked("fortmagma");
if (includeLocked)
return true;
else if (id == "fortmagma")
return !PlayerManager::getCurrentPlayer()->isLocked("fortmagma");
else
return (!m_editable || !PlayerManager::get()->getCurrentPlayer()->isLocked(id));
} // isTrackAvailable
// ----------------------------------------------------------------------------
void GrandPrixData::getLaps(std::vector<int> *laps) const
std::vector<std::string> GrandPrixData::getTrackNames(bool includeLocked) const
{
laps->clear();
std::vector<std::string> names;
for (unsigned int i = 0; i < m_tracks.size(); i++)
{
if(isTrackAvailable(m_tracks[i], includeLocked))
names.push_back(m_tracks[i]);
} // for i
return names;
} // getTrackNames
// ----------------------------------------------------------------------------
std::vector<int> GrandPrixData::getLaps(bool includeLocked) const
{
std::vector<int> laps;
for (unsigned int i = 0; i< m_tracks.size(); i++)
if(isTrackAvailable(m_tracks[i]))
laps->push_back(m_laps[i]);
if(isTrackAvailable(m_tracks[i], includeLocked))
laps.push_back(m_laps[i]);
return laps;
} // getLaps
// ----------------------------------------------------------------------------
void GrandPrixData::getReverse(std::vector<bool> *reverse) const
std::vector<bool> GrandPrixData::getReverse(bool includeLocked) const
{
reverse->clear();
std::vector<bool> reverse;
for (unsigned int i = 0; i< m_tracks.size(); i++)
if(isTrackAvailable(m_tracks[i]))
reverse->push_back(m_reversed[i]);
if(isTrackAvailable(m_tracks[i], includeLocked))
reverse.push_back(m_reversed[i]);
return reverse;
} // getReverse
// ----------------------------------------------------------------------------
@@ -251,15 +270,18 @@ bool GrandPrixData::isEditable() const
} // isEditable
// ----------------------------------------------------------------------------
unsigned int GrandPrixData::getNumberOfTracks() const
unsigned int GrandPrixData::getNumberOfTracks(bool includeLocked) const
{
return m_tracks.size();
if (includeLocked)
return m_tracks.size();
else
return getTrackNames(false).size();
}
// ----------------------------------------------------------------------------
irr::core::stringw GrandPrixData::getTrackName(const unsigned int track) const
{
assert(track < getNumberOfTracks());
assert(track < getNumberOfTracks(true));
Track* t = track_manager->getTrack(m_tracks[track]);
assert(t != NULL);
return t->getName();
@@ -268,28 +290,28 @@ irr::core::stringw GrandPrixData::getTrackName(const unsigned int track) const
// ----------------------------------------------------------------------------
const std::string& GrandPrixData::getTrackId(const unsigned int track) const
{
assert(track < getNumberOfTracks());
assert(track < getNumberOfTracks(true));
return m_tracks[track];
}
// ----------------------------------------------------------------------------
unsigned int GrandPrixData::getLaps(const unsigned int track) const
{
assert(track < getNumberOfTracks());
assert(track < getNumberOfTracks(true));
return m_laps[track];
}
// ----------------------------------------------------------------------------
bool GrandPrixData::getReverse(const unsigned int track) const
{
assert(track < getNumberOfTracks());
assert(track < getNumberOfTracks(true));
return m_reversed[track];
}
// ----------------------------------------------------------------------------
void GrandPrixData::moveUp(const unsigned int track)
{
assert (track > 0 && track < getNumberOfTracks());
assert (track > 0 && track < getNumberOfTracks(true));
std::swap(m_tracks[track], m_tracks[track - 1]);
std::swap(m_laps[track], m_laps[track - 1]);
@@ -301,7 +323,7 @@ void GrandPrixData::moveUp(const unsigned int track)
// ----------------------------------------------------------------------------
void GrandPrixData::moveDown(const unsigned int track)
{
assert (track < (getNumberOfTracks() - 1));
assert (track < (getNumberOfTracks(true) - 1));
std::swap(m_tracks[track], m_tracks[track + 1]);
std::swap(m_laps[track], m_laps[track + 1]);
@@ -316,7 +338,7 @@ void GrandPrixData::addTrack(Track* track, unsigned int laps, bool reverse,
{
int n;
n = getNumberOfTracks();
n = getNumberOfTracks(true);
assert (track != NULL);
assert (laps > 0);
assert (position >= -1 && position < n);
@@ -342,7 +364,7 @@ void GrandPrixData::addTrack(Track* track, unsigned int laps, bool reverse,
void GrandPrixData::editTrack(unsigned int t, Track* track,
unsigned int laps, bool reverse)
{
assert (t < getNumberOfTracks());
assert (t < getNumberOfTracks(true));
assert (track != NULL);
assert (laps > 0);
@@ -354,23 +376,11 @@ void GrandPrixData::editTrack(unsigned int t, Track* track,
// ----------------------------------------------------------------------------
void GrandPrixData::remove(const unsigned int track)
{
assert (track < getNumberOfTracks());
assert (track < getNumberOfTracks(true));
m_tracks.erase(m_tracks.begin() + track);
m_laps.erase(m_laps.begin() + track);
m_reversed.erase(m_reversed.begin() + track);
}
// ----------------------------------------------------------------------------
const std::vector<std::string>& GrandPrixData::getTrackNames() const
{
m_really_available_tracks.clear();
for (unsigned int i = 0; i < m_tracks.size(); i++)
{
if(isTrackAvailable(m_tracks[i]))
m_really_available_tracks.push_back(m_tracks[i]);
} // for i
return m_really_available_tracks;
} // getTrackNames
/* EOF */

View File

@@ -51,15 +51,6 @@ private:
* (ie. 'volcano'). */
std::vector<std::string> m_tracks;
/** This is the list of actually available tracks. In the last GP Fort
* Magma can not be used untill the final challenge. In order to provide
* still 5 tracks/GP, the last GP is only using 4 tracks in story mode,
* but (once nolok is unlocked) Fort Magma is added after that. So this
* list is always re-evaluated depending on the state of Nolok (i.e. if
* nolok is unlocked, Fort Magma is available, otherwise not).
* Mark this member mutable so that getTrackNames can be const. */
mutable std::vector<std::string> m_really_available_tracks;
/** The number of laps that each track should be raced, in the right order */
std::vector<int> m_laps;
@@ -69,7 +60,13 @@ private:
/** Wether the user can edit this grand prix or not */
bool m_editable;
bool isTrackAvailable(const std::string &id) const;
/** In the last GP Fort Magma can not be used untill the final challenge.
* In order to provide still 5 tracks/GP, the last GP is only using 4
* tracks in story mode, but once nolok is unlocked Fort Magma becomes
* available (i.e. if nolok is unlocked, Fort Magma is available, otherwise
* not).
*/
bool isTrackAvailable(const std::string &id, bool includeLocked) const;
public:
@@ -87,23 +84,23 @@ public:
void reload();
bool writeToFile();
bool checkConsistency(bool chatty=true) const;
const std::vector<std::string>& getTrackNames() const;
void getLaps(std::vector<int> *laps) const;
void getReverse(std::vector<bool> *reverse) const;
bool isEditable() const;
unsigned int getNumberOfTracks() const;
const std::string& getTrackId(const unsigned int track) const;
irr::core::stringw getTrackName(const unsigned int track) const;
unsigned int getLaps(const unsigned int track) const;
bool getReverse(const unsigned int track) const;
void moveUp(const unsigned int track);
void moveDown(const unsigned int track);
void addTrack(Track* track, unsigned int laps,
bool reverse, int position=-1);
void editTrack(unsigned int t, Track* track,
unsigned int laps, bool reverse);
void remove(const unsigned int track);
bool checkConsistency(bool chatty=true) const;
std::vector<std::string> getTrackNames(const bool includeLocked=false) const;
std::vector<int> getLaps(const bool includeLocked=false) const;
std::vector<bool> getReverse(const bool includeLocked=false) const;
bool isEditable() const;
unsigned int getNumberOfTracks(const bool includeLocked=false) const;
const std::string& getTrackId(const unsigned int track) const;
irr::core::stringw getTrackName(const unsigned int track) const;
unsigned int getLaps(const unsigned int track) const;
bool getReverse(const unsigned int track) const;
void moveUp(const unsigned int track);
void moveDown(const unsigned int track);
void addTrack(Track* track, unsigned int laps,
bool reverse, int position=-1);
void editTrack(unsigned int t, Track* track,
unsigned int laps, bool reverse);
void remove(const unsigned int track);
// ------------------------------------------------------------------------
/** @return the (potentially translated) user-visible name of the Grand

View File

@@ -284,8 +284,8 @@ void RaceManager::startNew(bool from_overworld)
{
// GP: get tracks, laps and reverse info from grand prix
m_tracks = m_grand_prix.getTrackNames();
m_grand_prix.getLaps(&m_num_laps);
m_grand_prix.getReverse(&m_reverse_track);
m_num_laps = m_grand_prix.getLaps();
m_reverse_track = m_grand_prix.getReverse();
}
//assert(m_player_karts.size() > 0);

View File

@@ -58,7 +58,7 @@ void CreateServerScreen::loadedFromFile()
m_name_widget = getWidget<TextBoxWidget>("name");
assert(m_name_widget != NULL);
m_name_widget->setText(PlayerManager::getCurrentUser()->getUserName() + _("'s server"));
m_name_widget->setText(PlayerManager::getCurrentOnlineUserName() + _("'s server"));
m_max_players_widget = getWidget<SpinnerWidget>("max_players");
assert(m_max_players_widget != NULL);
m_max_players_widget->setValue(8);

View File

@@ -20,7 +20,6 @@
#include "guiengine/screen.hpp"
#include "guiengine/widgets.hpp"
#include "online/current_user.hpp"
#include "online/xml_request.hpp"

View File

@@ -20,10 +20,11 @@
#include "audio/sfx_manager.hpp"
#include "config/player_manager.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/widgets.hpp"
#include "online/messages.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/translation.hpp"
#include "utils/string_utils.hpp"
#include "online/messages.hpp"
#include <IGUIEnvironment.h>
#include <irrString.h>

View File

@@ -19,13 +19,17 @@
#ifndef HEADER_CHANGE_PASSWORD_DIALOG_HPP
#define HEADER_CHANGE_PASSWORD_DIALOG_HPP
#include "online/current_user.hpp"
#include "guiengine/modaldialog.hpp"
#include "guiengine/widgets.hpp"
#include <irrString.h>
namespace GUIEngine
{
class IconButtonWidget;
class LabelWidget;
class RibbonWidget;
}
/**
* \brief Dialog that allows a user to sign in
* \ingroup states_screens

View File

@@ -33,7 +33,7 @@ using namespace irr::gui;
// -----------------------------------------------------------------------------
CustomVideoSettingsialog::CustomVideoSettingsialog(const float w, const float h) :
CustomVideoSettingsDialog::CustomVideoSettingsDialog(const float w, const float h) :
ModalDialog(w, h)
{
loadFromFile("custom_video_settings.stkgui");
@@ -41,13 +41,13 @@ CustomVideoSettingsialog::CustomVideoSettingsialog(const float w, const float h)
// -----------------------------------------------------------------------------
CustomVideoSettingsialog::~CustomVideoSettingsialog()
CustomVideoSettingsDialog::~CustomVideoSettingsDialog()
{
}
// -----------------------------------------------------------------------------
void CustomVideoSettingsialog::beforeAddingWidgets()
void CustomVideoSettingsDialog::beforeAddingWidgets()
{
getWidget<CheckBoxWidget>("anim_gfx")->setState( UserConfigParams::m_graphical_effects );
getWidget<CheckBoxWidget>("weather_gfx")->setState( UserConfigParams::m_weather_effects );
@@ -76,56 +76,67 @@ void CustomVideoSettingsialog::beforeAddingWidgets()
filtering->setValue( value );
/*
SpinnerWidget* antialias = getWidget<SpinnerWidget>("antialiasing");
antialias->addLabel( _("Disabled") ); // 0
antialias->addLabel( L"x2" ); // 1
antialias->addLabel( L"x4" ); // 2
antialias->addLabel( L"x8" ); // 3
antialias->setValue( UserConfigParams::m_antialiasing );
*/
SpinnerWidget* ssao = getWidget<SpinnerWidget>("ssao");
ssao->addLabel( _("Disabled") ); // 0
ssao->addLabel( _("low") ); // 1
ssao->addLabel( _("high") ); // 2
ssao->setValue( UserConfigParams::m_ssao );
SpinnerWidget* shadows = getWidget<SpinnerWidget>("shadows");
shadows->addLabel( _("Disabled") ); // 0
shadows->addLabel( _("low") ); // 1
shadows->addLabel( _("high") ); // 2
shadows->addLabel( _("low") ); // 1
shadows->addLabel( _("high") ); // 2
shadows->setValue( UserConfigParams::m_shadows );
getWidget<CheckBoxWidget>("motionblur")->setState( UserConfigParams::m_motionblur );
getWidget<CheckBoxWidget>("mlaa")->setState( UserConfigParams::m_mlaa );
getWidget<CheckBoxWidget>("pixelshaders")->setState(UserConfigParams::m_pixel_shaders);
getWidget<CheckBoxWidget>("dynamiclight")->setState(UserConfigParams::m_dynamic_lights);
getWidget<CheckBoxWidget>("lightshaft")->setState(UserConfigParams::m_light_shaft);
getWidget<CheckBoxWidget>("motionblur")->setState(UserConfigParams::m_motionblur);
getWidget<CheckBoxWidget>("mlaa")->setState(UserConfigParams::m_mlaa);
getWidget<CheckBoxWidget>("glow")->setState(UserConfigParams::m_glow);
getWidget<CheckBoxWidget>("ssao")->setState(UserConfigParams::m_ssao);
getWidget<CheckBoxWidget>("bloom")->setState(UserConfigParams::m_bloom);
getWidget<CheckBoxWidget>("texture_compression")->setState(UserConfigParams::m_texture_compression);
}
// -----------------------------------------------------------------------------
GUIEngine::EventPropagation CustomVideoSettingsialog::processEvent(const std::string& eventSource)
GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::string& eventSource)
{
if (eventSource == "close")
{
bool dynamic_light = getWidget<CheckBoxWidget>("dynamiclight")->getState();
UserConfigParams::m_dynamic_lights = dynamic_light;
UserConfigParams::m_graphical_effects =
getWidget<CheckBoxWidget>("anim_gfx")->getState();
UserConfigParams::m_weather_effects =
getWidget<CheckBoxWidget>("weather_gfx")->getState();
//UserConfigParams::m_antialiasing =
// getWidget<SpinnerWidget>("antialiasing")->getValue();
UserConfigParams::m_motionblur =
getWidget<CheckBoxWidget>("motionblur")->getState();
UserConfigParams::m_show_steering_animations =
getWidget<SpinnerWidget>("steering_animations")->getValue();
UserConfigParams::m_pixel_shaders =
getWidget<CheckBoxWidget>("pixelshaders")->getState();
if (dynamic_light)
{
UserConfigParams::m_shadows =
getWidget<SpinnerWidget>("shadows")->getValue();
}
else
{
UserConfigParams::m_shadows = 0;
}
UserConfigParams::m_mlaa =
getWidget<CheckBoxWidget>("mlaa")->getState();
UserConfigParams::m_ssao =
getWidget<SpinnerWidget>("ssao")->getValue();
UserConfigParams::m_shadows =
getWidget<SpinnerWidget>("shadows")->getValue();
UserConfigParams::m_ssao =
getWidget<CheckBoxWidget>("ssao")->getState();
UserConfigParams::m_light_shaft =
getWidget<CheckBoxWidget>("lightshaft")->getState();
UserConfigParams::m_glow =
getWidget<CheckBoxWidget>("glow")->getState();
UserConfigParams::m_bloom =
getWidget<CheckBoxWidget>("bloom")->getState();
UserConfigParams::m_texture_compression =
getWidget<CheckBoxWidget>("texture_compression")->getState();
switch (getWidget<SpinnerWidget>("filtering")->getValue())
{

View File

@@ -25,15 +25,15 @@
* \brief Dialog that allows the player to select custom video settings
* \ingroup states_screens
*/
class CustomVideoSettingsialog : public GUIEngine::ModalDialog
class CustomVideoSettingsDialog : public GUIEngine::ModalDialog
{
public:
/**
* Creates a modal dialog with given percentage of screen width and height
*/
CustomVideoSettingsialog(const float percentWidth, const float percentHeight);
~CustomVideoSettingsialog();
CustomVideoSettingsDialog(const float percentWidth, const float percentHeight);
~CustomVideoSettingsDialog();
virtual void beforeAddingWidgets();

View File

@@ -75,7 +75,7 @@ GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const floa
// ---- Track listings
const std::vector<std::string>& tracks = gp->getTrackNames();
const std::vector<std::string> tracks = gp->getTrackNames();
const int trackAmount = tracks.size();
int height_of_one_line = (y2 - y1)/(trackAmount+1);
@@ -130,7 +130,7 @@ GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const floa
m_screenshot_widget->m_w = m_area.getWidth()/2;
m_screenshot_widget->m_h = y2 - y1 - 10;
Track* track = track_manager->getTrack(tracks[0]);
Track* track = (tracks.size() == 0 ? NULL : track_manager->getTrack(tracks[0]));
m_screenshot_widget->m_properties[PROP_ICON] = (track != NULL ?
track->getScreenshotFile().c_str() :
@@ -152,7 +152,12 @@ GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const floa
race_manager->getNumberOfKarts(),
race_manager->getNumLocalPlayers());
if (gp_ok)
if (tracks.size() == 0)
{
okBtn->m_properties[PROP_ID] = "cannot_start";
okBtn->setText(_("Sorry, no tracks available"));
}
else if (gp_ok)
{
okBtn->m_properties[PROP_ID] = "start";
okBtn->setText(_("Start Grand Prix"));
@@ -265,14 +270,15 @@ void GPInfoDialog::onUpdate(float dt)
const GrandPrixData* gp = grand_prix_manager->getGrandPrix(m_gp_ident);
assert(gp != NULL);
const std::vector<std::string>& tracks = gp->getTrackNames();
const std::vector<std::string> tracks = gp->getTrackNames();
if (frameAfter >= (int)tracks.size())
{
frameAfter = 0;
m_curr_time = 0;
}
Track* track = track_manager->getTrack(tracks[frameAfter]);
Track* track = (tracks.size() == 0 ? NULL :
track_manager->getTrack(tracks[frameAfter]));
std::string fn = track ? track->getScreenshotFile()
: file_manager->getAsset(FileManager::GUI, "main_help.png");
m_screenshot_widget->setImage(fn.c_str(), IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);

View File

@@ -35,7 +35,7 @@ using namespace Online;
// -----------------------------------------------------------------------------
NotificationDialog::NotificationDialog(Type type, const core::stringw info)
NotificationDialog::NotificationDialog(Type type, const core::stringw &info)
: ModalDialog(0.8f,0.5f)
{
m_info = info;

View File

@@ -19,13 +19,12 @@
#ifndef HEADER_NOTIFICATION_DIALOG_HPP
#define HEADER_NOTIFICATION_DIALOG_HPP
#include <irrString.h>
#include "guiengine/modaldialog.hpp"
#include "guiengine/widgets.hpp"
#include "online/current_user.hpp"
#include "utils/types.hpp"
#include <irrString.h>
/**
* \brief Dialog that allows a user to sign in
@@ -53,7 +52,7 @@ private:
GUIEngine::IconButtonWidget * m_cancel_widget;
public:
NotificationDialog(Type type, const core::stringw info);
NotificationDialog(Type type, const core::stringw &info);
~NotificationDialog();
virtual void beforeAddingWidgets();

View File

@@ -20,10 +20,10 @@
#include "audio/sfx_manager.hpp"
#include "config/player_manager.hpp"
#include "guiengine/engine.hpp"
#include "online/messages.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/translation.hpp"
#include "utils/string_utils.hpp"
#include "online/messages.hpp"
#include <IGUIEnvironment.h>

View File

@@ -19,11 +19,14 @@
#ifndef HEADER_RECOVERY_DIALOG_HPP
#define HEADER_RECOVERY_DIALOG_HPP
#include <irrString.h>
#include "guiengine/modaldialog.hpp"
#include "guiengine/widgets.hpp"
#include "online/current_user.hpp"
namespace Online
{
class XMLRequest;
}
/**
* \brief Dialog that allows a user to recover his account

View File

@@ -17,16 +17,16 @@
#include "states_screens/dialogs/registration_dialog.hpp"
#include <IGUIEnvironment.h>
#include "audio/sfx_manager.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/widgets.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/register_screen.hpp"
#include "utils/translation.hpp"
#include "utils/string_utils.hpp"
#include "online/messages.hpp"
#include <IGUIEnvironment.h>
using namespace GUIEngine;
using namespace irr;

View File

@@ -19,11 +19,8 @@
#ifndef HEADER_REGISTRATION_DIALOG_HPP
#define HEADER_REGISTRATION_DIALOG_HPP
#include <irrString.h>
#include "guiengine/modaldialog.hpp"
#include "guiengine/widgets.hpp"
#include "online/current_user.hpp"
/**
* \brief Dialog that allows a user to register
* \ingroup states_screens

View File

@@ -21,7 +21,6 @@
#include "guiengine/engine.hpp"
#include "network/protocol_manager.hpp"
#include "network/protocols/connect_to_server.hpp"
#include "online/current_user.hpp"
#include "online/messages.hpp"
#include "online/servers_manager.hpp"
#include "states_screens/dialogs/registration_dialog.hpp"

View File

@@ -19,17 +19,15 @@
#ifndef HEADER_SERVER_INFO_DIALOG_HPP
#define HEADER_SERVER_INFO_DIALOG_HPP
#include <irrString.h>
#include "guiengine/modaldialog.hpp"
#include "guiengine/widgets/icon_button_widget.hpp"
#include "guiengine/widgets/ribbon_widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "network/protocols/request_connection.hpp"
#include "online/current_user.hpp"
#include "online/server.hpp"
#include "utils/types.hpp"
#include <irrString.h>
/**
* \brief Dialog that allows a user to sign in

View File

@@ -35,35 +35,38 @@ using namespace irr;
using namespace irr::gui;
using namespace Online;
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
UserInfoDialog::UserInfoDialog(uint32_t showing_id, const core::stringw info, bool error, bool from_queue)
: ModalDialog(0.8f,0.8f), m_showing_id(showing_id)
UserInfoDialog::UserInfoDialog(uint32_t showing_id, const core::stringw info,
bool error, bool from_queue)
: ModalDialog(0.8f,0.8f), m_showing_id(showing_id)
{
m_error = error;
m_info = info;
if(!from_queue) load();
}
} // UserInfoDialog
// ----------------------------------------------------------------------------
void UserInfoDialog::load()
{
loadFromFile("online/user_info_dialog.stkgui");
if(m_error)
m_info_widget->setErrorColor();
m_name_widget->setText(m_profile->getUserName(),false);
m_name_widget->setText(m_online_profile->getUserName(),false);
m_info_widget->setText(m_info, false);
if(m_remove_widget->isVisible() && !m_profile->isFriend())
if(m_remove_widget->isVisible() && !m_online_profile->isFriend())
m_remove_widget->setLabel("Cancel Request");
}
} // load
// ----------------------------------------------------------------------------
void UserInfoDialog::beforeAddingWidgets()
{
m_profile = ProfileManager::get()->getProfileByID(m_showing_id);
m_online_profile = ProfileManager::get()->getProfileByID(m_showing_id);
// Avoid a crash in case that an invalid m_showing_id is given
// (which can only happen if there's a problem on the server).
if (!m_profile)
m_profile = PlayerManager::getCurrentUser()->getProfile();
if (!m_online_profile)
m_online_profile = PlayerManager::getCurrentOnlineProfile();
m_self_destroy = false;
m_enter_profile = false;
m_processing = false;
@@ -91,17 +94,18 @@ void UserInfoDialog::beforeAddingWidgets()
m_accept_widget->setVisible(false);
m_decline_widget->setVisible(false);
m_remove_widget->setVisible(false);
if(m_profile->isCurrentUser())
if(m_online_profile->isCurrentUser())
{
m_friend_widget->setVisible(false);
}
if(m_profile->isFriend())
if(m_online_profile->isFriend())
{
m_friend_widget->setVisible(false);
m_remove_widget->setVisible(true);
}
OnlineProfile::RelationInfo * relation_info = m_profile->getRelationInfo();
OnlineProfile::RelationInfo * relation_info =
m_online_profile->getRelationInfo();
if(relation_info != NULL)
{
if(relation_info->isPending())
@@ -119,14 +123,12 @@ void UserInfoDialog::beforeAddingWidgets()
}
}
}
} // beforeAddingWidgets
// -----------------------------------------------------------------------------
UserInfoDialog::~UserInfoDialog()
{
}
} // ~UserInfoDialog
// -----------------------------------------------------------------------------
/** Sends a friend request to the server. When the request is finished, it
@@ -148,7 +150,7 @@ void UserInfoDialog::sendFriendRequest()
core::stringw info_text("");
if (isSuccess())
{
PlayerManager::getCurrentUser()->getProfile()->addFriend(id);
PlayerManager::getCurrentOnlineProfile()->addFriend(id);
OnlineProfile::RelationInfo *info =
new OnlineProfile::RelationInfo(_("Today"), false,
true, false);
@@ -171,7 +173,7 @@ void UserInfoDialog::sendFriendRequest()
FriendRequest *request = new FriendRequest();
PlayerManager::setUserDetails(request, "friend-request");
request->addParameter("friendid", m_profile->getID());
request->addParameter("friendid", m_online_profile->getID());
request->queue();
m_processing = true;
@@ -222,7 +224,7 @@ void UserInfoDialog::acceptFriendRequest()
AcceptFriendRequest *request = new AcceptFriendRequest();
PlayerManager::setUserDetails(request, "accept-friend-request");
request->addParameter("friendid", m_profile->getID());
request->addParameter("friendid", m_online_profile->getID());
request->queue();
m_processing = true;
m_options_widget->setDeactivated();
@@ -249,7 +251,7 @@ void UserInfoDialog::declineFriendRequest()
core::stringw info_text("");
if (isSuccess())
{
PlayerManager::getCurrentUser()->getProfile()->removeFriend(id);
PlayerManager::getCurrentOnlineProfile()->removeFriend(id);
ProfileManager::get()->moveToCache(id);
ProfileManager::get()->getProfileByID(id)
->deleteRelationalInfo();
@@ -268,7 +270,7 @@ void UserInfoDialog::declineFriendRequest()
// ----------------------------------------------------------------
DeclineFriendRequest *request = new DeclineFriendRequest();
PlayerManager::setUserDetails(request, "decline-friend-request");
request->addParameter("friendid", m_profile->getID());
request->addParameter("friendid", m_online_profile->getID());
request->queue();
m_processing = true;
@@ -290,7 +292,7 @@ void UserInfoDialog::removeExistingFriend()
core::stringw info_text("");
if (isSuccess())
{
PlayerManager::getCurrentUser()->getProfile()->removeFriend(m_id);
PlayerManager::getCurrentOnlineProfile()->removeFriend(m_id);
ProfileManager *pm = ProfileManager::get();
pm->moveToCache(m_id);
pm->getProfileByID(m_id)->deleteRelationalInfo();
@@ -312,7 +314,7 @@ void UserInfoDialog::removeExistingFriend()
}; // RemoveFriendRequest
// ------------------------------------------------------------------------
int friend_id = m_profile->getID();
int friend_id = m_online_profile->getID();
RemoveFriendRequest * request = new RemoveFriendRequest(friend_id);
PlayerManager::setUserDetails(request, "remove-friend");
request->addParameter("friendid", friend_id);
@@ -338,7 +340,7 @@ void UserInfoDialog::removePendingFriend()
core::stringw info_text("");
if (isSuccess())
{
PlayerManager::getCurrentUser()->getProfile()->removeFriend(id);
PlayerManager::getCurrentOnlineProfile()->removeFriend(id);
ProfileManager *pm = ProfileManager::get();
pm->moveToCache(id);
pm->getProfileByID(id)->deleteRelationalInfo();
@@ -359,7 +361,7 @@ void UserInfoDialog::removePendingFriend()
CancelFriendRequest * request = new CancelFriendRequest();
PlayerManager::setUserDetails(request, "cancel-friend-request");
request->addParameter("friendid", m_profile->getID());
request->addParameter("friendid", m_online_profile->getID());
request->queue();
} // removePendingFriend
@@ -377,7 +379,7 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even
}
else if(selection == m_enter_widget->m_properties[PROP_ID])
{
ProfileManager::get()->setVisiting(m_profile->getID());
ProfileManager::get()->setVisiting(m_online_profile->getID());
m_enter_profile = true;
m_options_widget->setDeactivated();
return GUIEngine::EVENT_BLOCK;
@@ -389,8 +391,8 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even
}
else if(selection == m_remove_widget->m_properties[PROP_ID])
{
if (m_profile->getRelationInfo() &&
m_profile->getRelationInfo()->isPending() )
if (m_online_profile->getRelationInfo() &&
m_online_profile->getRelationInfo()->isPending() )
removePendingFriend();
else
removeExistingFriend();
@@ -411,20 +413,19 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even
}
}
return GUIEngine::EVENT_LET;
}
} // processEvent
// -----------------------------------------------------------------------------
void UserInfoDialog::deactivate()
{
m_options_widget->setDeactivated();
}
} // deactivate
// -----------------------------------------------------------------------------
void UserInfoDialog::activate()
{
}
} // activate
// -----------------------------------------------------------------------------
@@ -445,7 +446,7 @@ bool UserInfoDialog::onEscapePressed()
if (m_cancel_widget->isActivated())
m_self_destroy = true;
return false;
}
} // onEscapePressed
// -----------------------------------------------------------------------------
@@ -465,4 +466,4 @@ void UserInfoDialog::onUpdate(float dt)
StateManager::get()->replaceTopMostScreen(OnlineProfileOverview::getInstance());
return;
}
}
} // onUpdate

View File

@@ -21,12 +21,15 @@
#include "guiengine/modaldialog.hpp"
#include "guiengine/widgets.hpp"
#include "online/current_user.hpp"
#include "online/profile_manager.hpp"
#include "utils/types.hpp"
#include <irrString.h>
namespace Online
{
class OnlineProfile;
}
/**
* \brief Dialog that allows a user to sign in
* \ingroup states_screens
@@ -44,7 +47,7 @@ private:
irr::core::stringw m_info;
const uint32_t m_showing_id;
Online::OnlineProfile * m_profile;
Online::OnlineProfile * m_online_profile;
GUIEngine::LabelWidget * m_name_widget;
GUIEngine::LabelWidget * m_info_widget;

View File

@@ -18,18 +18,16 @@
#include "states_screens/dialogs/vote_dialog.hpp"
#include "addons/addons_manager.hpp"
#include "config/player_manager.hpp"
#include "audio/sfx_manager.hpp"
#include "config/player_manager.hpp"
#include "guiengine/engine.hpp"
#include "online/messages.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/translation.hpp"
#include "utils/string_utils.hpp"
#include "online/current_user.hpp"
#include "online/messages.hpp"
#include <IGUIEnvironment.h>
using namespace GUIEngine;
using namespace irr;
using namespace irr::gui;

View File

@@ -19,12 +19,16 @@
#ifndef HEADER_VOTE_DIALOG_HPP
#define HEADER_VOTE_DIALOG_HPP
#include <irrString.h>
#include "guiengine/modaldialog.hpp"
#include "guiengine/widgets.hpp"
#include "online/current_user.hpp"
#include <irrString.h>
namespace Online
{
class XMLRequest;
}
/**
* \brief Dialog that allows a user to sign in
* \ingroup states_screens

View File

@@ -199,8 +199,8 @@ void EditGPScreen::onConfirm()
if (m_action == "remove")
{
m_gp->remove(m_selected);
setSelected(m_selected >= (int)m_gp->getNumberOfTracks() ?
m_gp->getNumberOfTracks() - 1 : m_selected);
setSelected(m_selected >= (int)m_gp->getNumberOfTracks(true) ?
m_gp->getNumberOfTracks(true) - 1 : m_selected);
loadList(m_selected);
setModified(true);
}
@@ -228,7 +228,7 @@ void EditGPScreen::loadList(const int selected)
m_icon_bank->scaleToHeight (64);
m_list->setIcons(m_icon_bank, 64);
for (unsigned int i = 0; i < m_gp->getNumberOfTracks(); i++)
for (unsigned int i = 0; i < m_gp->getNumberOfTracks(true); i++)
{
std::vector<GUIEngine::ListWidget::ListCell> row;
@@ -290,8 +290,8 @@ void EditGPScreen::edit()
{
edit_screen->setSelection(track_manager->getTrack(
m_gp->getTrackId(m_selected)),
m_gp->getLaps(m_selected),
m_gp->getReverse(m_selected));
m_gp->getLaps((unsigned int)m_selected),
m_gp->getReverse((unsigned int)m_selected));
StateManager::get()->pushScreen(edit_screen);
}
}

View File

@@ -625,7 +625,7 @@ void FeatureUnlockedCutScene::addUnlockedGP(const GrandPrixData* gp)
}
else
{
const std::vector<std::string>& gptracks = gp->getTrackNames();
const std::vector<std::string> gptracks = gp->getTrackNames();
const int trackAmount = gptracks.size();
if (trackAmount == 0)

View File

@@ -171,7 +171,7 @@ void GrandPrixEditorScreen::loadTrackList (const std::string& gpname)
assert(tracks_widget != NULL);
const GrandPrixData* gp = grand_prix_manager->getGrandPrix(gpname);
const std::vector<std::string>& tracks = gp->getTrackNames();
const std::vector<std::string> tracks = gp->getTrackNames(true);
tracks_widget->clearItems();
tracks_widget->setItemCountHint(tracks.size());
@@ -209,7 +209,7 @@ void GrandPrixEditorScreen::loadGPList()
for (unsigned int i = 0; i < grand_prix_manager->getNumberOfGrandPrix(); i++)
{
const GrandPrixData* gp = grand_prix_manager->getGrandPrix(i);
const std::vector<std::string>& tracks = gp->getTrackNames();
const std::vector<std::string> tracks = gp->getTrackNames(true);
std::vector<std::string> sshot_files;
for (unsigned int t=0; t<tracks.size(); t++)

View File

@@ -24,7 +24,6 @@
#include "guiengine/widgets/ribbon_widget.hpp"
#include "guiengine/widgets/text_box_widget.hpp"
#include "guiengine/widgets/check_box_widget.hpp"
#include "online/current_user.hpp"
#include "online/messages.hpp"
#include "states_screens/guest_login_screen.hpp"
#include "states_screens/online_screen.hpp"
@@ -99,8 +98,7 @@ void LoginScreen::login()
m_options_widget->setDeactivated();
info_widget->setDefaultColor();
bool remember = getWidget<CheckBoxWidget>("remember")->getState();
PlayerManager::getCurrentUser()->requestSignIn(username, password,
remember );
PlayerManager::requestSignIn(username, password, remember);
}
} // login

View File

@@ -146,13 +146,13 @@ void MainMenuScreen::init()
void MainMenuScreen::onUpdate(float delta)
{
if(PlayerManager::getCurrentOnlineState() == PlayerManager::OS_GUEST ||
PlayerManager::getCurrentOnlineState() == PlayerManager::OS_SIGNED_IN)
if(PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_GUEST ||
PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN)
{
m_online->setActivated();
m_online->setLabel( _("Online"));
}
else if (PlayerManager::getCurrentOnlineState() == PlayerManager::OS_SIGNED_OUT)
else if (PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_OUT)
{
m_online->setActivated();
m_online->setLabel( _("Login" ));

View File

@@ -10,7 +10,6 @@
#include "network/protocol_manager.hpp"
#include "network/protocols/client_lobby_room_protocol.hpp"
#include "network/network_manager.hpp"
#include "online/current_user.hpp"
#include "states_screens/state_manager.hpp"
static const char RANDOM_KART_ID[] = "randomkart";
@@ -68,7 +67,7 @@ void NetworkKartSelectionScreen::init()
for (unsigned int i = 0; i < players.size(); i++)
{
if (players[i]->user_profile == PlayerManager::getCurrentUser()->getProfile())
if (players[i]->user_profile == PlayerManager::getCurrentOnlineProfile())
{
m_id_mapping.insert(m_id_mapping.begin(),players[i]->race_id); //!< first kart widget always me
Log::info("NKSS", "Insert %d at pos 0", players[i]->race_id);

View File

@@ -56,7 +56,7 @@ DEFINE_SCREEN_SINGLETON( OnlineScreen );
OnlineScreen::OnlineScreen() : Screen("online/main.stkgui")
{
m_recorded_state = PlayerManager::OS_SIGNED_OUT;
m_recorded_state = PlayerProfile::OS_SIGNED_OUT;
} // OnlineScreen
// ----------------------------------------------------------------------------
@@ -98,7 +98,7 @@ void OnlineScreen::loadedFromFile()
*/
bool OnlineScreen::hasStateChanged()
{
PlayerManager::OnlineState previous_state = m_recorded_state;
PlayerProfile::OnlineState previous_state = m_recorded_state;
m_recorded_state = PlayerManager::getCurrentOnlineState();
if (previous_state != m_recorded_state)
return true;
@@ -112,9 +112,9 @@ void OnlineScreen::beforeAddingWidget()
m_bottom_menu_widget->setVisible(true);
m_top_menu_widget->setVisible(true);
hasStateChanged();
if (m_recorded_state == PlayerManager::OS_SIGNED_OUT ||
m_recorded_state == PlayerManager::OS_SIGNING_IN ||
m_recorded_state == PlayerManager::OS_SIGNING_OUT)
if (m_recorded_state == PlayerProfile::OS_SIGNED_OUT ||
m_recorded_state == PlayerProfile::OS_SIGNING_IN ||
m_recorded_state == PlayerProfile::OS_SIGNING_OUT)
{
m_quick_play_widget->setDeactivated();
m_find_server_widget->setDeactivated();
@@ -122,7 +122,7 @@ void OnlineScreen::beforeAddingWidget()
m_sign_out_widget->setVisible(false);
m_profile_widget->setVisible(false);
}
else if (m_recorded_state == PlayerManager::OS_GUEST)
else if (m_recorded_state == PlayerProfile::OS_GUEST)
{
m_find_server_widget->setDeactivated();
m_create_server_widget->setDeactivated();
@@ -138,7 +138,7 @@ void OnlineScreen::init()
setInitialFocus();
DemoWorld::resetIdleTime();
core::stringw m = _("Signed in as: %s.",
PlayerManager::getCurrentUser()->getUserName());
PlayerManager::getCurrentOnlineUserName());
m_online_status_widget->setText(m, false);
} // init
@@ -151,11 +151,11 @@ void OnlineScreen::onUpdate(float delta)
return;
}
if (m_recorded_state == PlayerManager::OS_SIGNING_IN)
if (m_recorded_state == PlayerProfile::OS_SIGNING_IN)
{
m_online_status_widget->setText(Messages::signingIn(), false);
}
else if (m_recorded_state == PlayerManager::OS_SIGNING_OUT)
else if (m_recorded_state == PlayerProfile::OS_SIGNING_OUT)
{
m_online_status_widget->setText(Messages::signingOut(), false);
}
@@ -226,7 +226,7 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name,
if (selection == m_sign_out_widget->m_properties[PROP_ID])
{
PlayerManager::getCurrentUser()->requestSignOut();
PlayerManager::requestSignOut();
StateManager::get()->popMenu();
}
else if (selection == m_profile_widget->m_properties[PROP_ID])
@@ -259,7 +259,7 @@ void OnlineScreen::tearDown()
*/
void OnlineScreen::setInitialFocus()
{
if (m_recorded_state == PlayerManager::OS_SIGNED_IN)
if (m_recorded_state == PlayerProfile::OS_SIGNED_IN)
m_top_menu_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
else
m_bottom_menu_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);

View File

@@ -54,7 +54,7 @@ private:
GUIEngine::IconButtonWidget * m_profile_widget;
GUIEngine::IconButtonWidget * m_sign_out_widget;
PlayerManager::OnlineState m_recorded_state;
PlayerProfile::OnlineState m_recorded_state;
bool hasStateChanged();
void setInitialFocus();

View File

@@ -20,8 +20,8 @@
#include "audio/sfx_manager.hpp"
#include "config/player_manager.hpp"
#include "guiengine/modaldialog.hpp"
#include "online/current_user.hpp"
#include "online/messages.hpp"
#include "online/profile_manager.hpp"
#include "states_screens/dialogs/user_info_dialog.hpp"
#include "states_screens/dialogs/message_dialog.hpp"
#include "states_screens/state_manager.hpp"

View File

@@ -45,19 +45,56 @@ using namespace GUIEngine;
DEFINE_SCREEN_SINGLETON( OptionsScreenVideo );
// Look-up table for GFX levels
static const bool GFX [] = {false, true, true, true, true, true, true};
static const int GFX_ANIM_KARTS[] = {0, 1, 2, 2, 2, 2, 2 };
static const bool GFX_WEATHER [] = {false, false, true, true, true, true, true};
static const bool GFX_MOTIONBLUR[] = {false, false, false, false, true, true, true};
static const bool GFX_PIXEL_SHADERS[] =
{false, false, true, true, true, true, true};
static const bool GFX_MLAA[] = {false, false, false, false, false, true, true};
static const int GFX_SSAO[] = {0, 0, 0, 1, 1, 1, 2 };
static const int GFX_SHADOWS[] = {0, 0, 0, 1, 1, 2, 2 };
struct GFXPreset
{
bool lights;
int shadows;
bool bloom;
bool motionblur;
bool lightshaft;
bool glow;
bool mlaa;
bool ssao;
bool weather;
bool animatedScenery;
int animatedCharacters;
int anisotropy;
};
static GFXPreset GFX_PRESETS[] =
{
{
false /* light */, 0 /* shadow */, false /* bloom */, false /* motionblur */,
false /* lightshaft */, false /* glow */, false /* mlaa */, false /* ssao */, false /* weather */,
false /* animatedScenery */, 0 /* animatedCharacters */, 0 /* anisotropy */
},
static const int GFX_LEVEL_AMOUNT = 7;
{
false /* light */, 0 /* shadow */, false /* bloom */, false /* motionblur */,
false /* lightshaft */, false /* glow */, false /* mlaa */, false /* ssao */, false /* weather */,
true /* animatedScenery */, 1 /* animatedCharacters */, 4 /* anisotropy */
},
{
true /* light */, 0 /* shadow */, false /* bloom */, false /* motionblur */,
false /* lightshaft */, false /* glow */, false /* mlaa */, false /* ssao */, true /* weather */,
true /* animatedScenery */, 1 /* animatedCharacters */, 4 /* anisotropy */
},
{
true /* light */, 0 /* shadow */, false /* bloom */, true /* motionblur */,
true /* lightshaft */, true /* glow */, true /* mlaa */, false /* ssao */, true /* weather */,
true /* animatedScenery */, 1 /* animatedCharacters */, 8 /* anisotropy */
},
{
true /* light */, 2 /* shadow */, true /* bloom */, true /* motionblur */,
true /* lightshaft */, true /* glow */, true /* mlaa */, true /* ssao */, true /* weather */,
true /* animatedScenery */, 2 /* animatedCharacters */, 8 /* anisotropy */
}
};
static const int GFX_LEVEL_AMOUNT = 5;
// ----------------------------------------------------------------------------
@@ -310,17 +347,21 @@ void OptionsScreenVideo::updateGfxSlider()
bool found = false;
for (int l=0; l<GFX_LEVEL_AMOUNT; l++)
{
if (UserConfigParams::m_show_steering_animations == GFX_ANIM_KARTS[l]&&
UserConfigParams::m_graphical_effects == GFX[l] &&
UserConfigParams::m_weather_effects == GFX_WEATHER[l] &&
//UserConfigParams::m_antialiasing == GFX_ANTIALIAS[l] &&
UserConfigParams::m_motionblur == GFX_MOTIONBLUR[l] &&
UserConfigParams::m_mlaa == GFX_MLAA[l] &&
UserConfigParams::m_ssao == GFX_SSAO[l] &&
UserConfigParams::m_shadows == GFX_SHADOWS[l] &&
UserConfigParams::m_pixel_shaders == GFX_PIXEL_SHADERS[l])
if (GFX_PRESETS[l].animatedCharacters == UserConfigParams::m_show_steering_animations &&
GFX_PRESETS[l].animatedScenery == UserConfigParams::m_graphical_effects &&
GFX_PRESETS[l].anisotropy == UserConfigParams::m_anisotropic &&
GFX_PRESETS[l].bloom == UserConfigParams::m_bloom &&
GFX_PRESETS[l].glow == UserConfigParams::m_glow &&
GFX_PRESETS[l].lights == UserConfigParams::m_dynamic_lights &&
GFX_PRESETS[l].lightshaft == UserConfigParams::m_light_shaft &&
GFX_PRESETS[l].mlaa == UserConfigParams::m_mlaa &&
GFX_PRESETS[l].motionblur == UserConfigParams::m_motionblur &&
//GFX_PRESETS[l].shaders == UserConfigParams::m_pixel_shaders
GFX_PRESETS[l].shadows == UserConfigParams::m_shadows &&
GFX_PRESETS[l].ssao == UserConfigParams::m_ssao &&
GFX_PRESETS[l].weather == UserConfigParams::m_weather_effects)
{
gfx->setValue(l+1);
gfx->setValue(l + 1);
found = true;
break;
}
@@ -358,24 +399,9 @@ void OptionsScreenVideo::updateTooltip()
//I18N: if no kart animations are enabled
const core::stringw none = _LTR("None");
/*
core::stringw antialias_label;
switch ((int)UserConfigParams::m_antialiasing)
{
case 0:
antialias_label = disabled; break;
case 1:
antialias_label = L"x2"; break;
case 2:
antialias_label = L"x4"; break;
case 3:
antialias_label = L"x8"; break;
}
*/
//I18N: in graphical options
tooltip = tooltip + L"\n" + _("Pixel shaders : %s",
UserConfigParams::m_pixel_shaders ? enabled : disabled);
// tooltip = tooltip + L"\n" + _("Pixel shaders : %s",
// UserConfigParams::m_pixel_shaders ? enabled : disabled);
//I18N: in graphical options
tooltip = _("Animated Scenery : %s",
UserConfigParams::m_graphical_effects ? enabled : disabled);
@@ -388,8 +414,8 @@ void OptionsScreenVideo::updateTooltip()
? all
: (UserConfigParams::m_show_steering_animations == 1 ? me : none));
//I18N: in graphical options
//tooltip = tooltip + L"\n" + _("Anti-aliasing (requires restart) : %s",
// antialias_label);
tooltip = tooltip + L"\n" + _("Dynamic lights : %s",
UserConfigParams::m_dynamic_lights ? enabled : disabled);
//I18N: in graphical options
tooltip = tooltip + L"\n" + _("Motion blur: %s",
UserConfigParams::m_motionblur ? enabled : disabled);
@@ -404,8 +430,17 @@ void OptionsScreenVideo::updateTooltip()
tooltip = tooltip + L"\n" + _("Shadows: %s",
UserConfigParams::m_shadows == 1 ? "low" : UserConfigParams::m_shadows == 2 ?
"high" : disabled);
//I18N: in graphical options
tooltip = tooltip + L"\n" + _("Bloom : %s",
UserConfigParams::m_bloom ? enabled : disabled);
//I18N: in graphical options
tooltip = tooltip + L"\n" + _("Glow (outlines) : %s",
UserConfigParams::m_glow ? enabled : disabled);
//I18N: in graphical options
tooltip = tooltip + L"\n" + _("Light shaft (God rays) : %s",
UserConfigParams::m_light_shaft ? enabled : disabled);
gfx->setTooltip(tooltip);
} // updateTooltip
@@ -441,7 +476,7 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
}
else if(name == "custom")
{
new CustomVideoSettingsialog(0.8f, 0.8f);
new CustomVideoSettingsDialog(0.8f, 0.9f);
}
else if(name == "apply_resolution")
{
@@ -473,17 +508,21 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
getWidget<GUIEngine::SpinnerWidget>("gfx_level");
assert( gfx_level != NULL );
const int level = gfx_level->getValue();
const int level = gfx_level->getValue() - 1;
UserConfigParams::m_show_steering_animations = GFX_ANIM_KARTS[level-1];
UserConfigParams::m_graphical_effects = GFX[level-1];
UserConfigParams::m_weather_effects = GFX_WEATHER[level-1];
//UserConfigParams::m_antialiasing = GFX_ANTIALIAS[level-1];
UserConfigParams::m_motionblur = GFX_MOTIONBLUR[level-1];
UserConfigParams::m_pixel_shaders = GFX_PIXEL_SHADERS[level-1];
UserConfigParams::m_mlaa = GFX_MLAA[level-1];
UserConfigParams::m_ssao = GFX_SSAO[level-1];
UserConfigParams::m_shadows = GFX_SHADOWS[level-1];
UserConfigParams::m_show_steering_animations = GFX_PRESETS[level].animatedCharacters;
UserConfigParams::m_graphical_effects = GFX_PRESETS[level].animatedScenery;
UserConfigParams::m_anisotropic = GFX_PRESETS[level].anisotropy;
UserConfigParams::m_bloom = GFX_PRESETS[level].bloom;
UserConfigParams::m_glow = GFX_PRESETS[level].glow;
UserConfigParams::m_dynamic_lights = GFX_PRESETS[level].lights;
UserConfigParams::m_light_shaft = GFX_PRESETS[level].lightshaft;
UserConfigParams::m_mlaa = GFX_PRESETS[level].mlaa;
UserConfigParams::m_motionblur = GFX_PRESETS[level].motionblur;
//UserConfigParams::m_pixel_shaders = GFX_PRESETS[level].shaders;
UserConfigParams::m_shadows = GFX_PRESETS[level].shadows;
UserConfigParams::m_ssao = GFX_PRESETS[level].ssao;
UserConfigParams::m_weather_effects = GFX_PRESETS[level].weather;
updateGfxSlider();
}

View File

@@ -91,7 +91,7 @@ void RaceResultGUI::init()
(m_sshot_height + SSHOT_SEPARATION))); //Show at least one
// Calculate screenshot scrolling parameters
const std::vector<std::string>& tracks =
const std::vector<std::string> tracks =
race_manager->getGrandPrix()->getTrackNames();
int n_tracks = tracks.size();
int currentTrack = race_manager->getTrackNumber();
@@ -103,7 +103,7 @@ void RaceResultGUI::init()
}
else
{
m_start_track = currentTrack;
m_start_track = 0;
m_end_track = tracks.size();
}
} // init
@@ -1295,7 +1295,7 @@ void RaceResultGUI::displayHighScores()
// ----------------------------------------------------------------------------
void RaceResultGUI::displayScreenShots()
{
const std::vector<std::string>& tracks =
const std::vector<std::string> tracks =
race_manager->getGrandPrix()->getTrackNames();
int currentTrack = race_manager->getTrackNumber();

View File

@@ -21,8 +21,8 @@
#include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/ribbon_widget.hpp"
#include "guiengine/widgets/text_box_widget.hpp"
#include "online/current_user.hpp"
#include "online/messages.hpp"
#include "online/xml_request.hpp"
#include "states_screens/dialogs/registration_dialog.hpp"
#include "states_screens/dialogs/message_dialog.hpp"
#include "states_screens/guest_login_screen.hpp"

View File

@@ -119,6 +119,11 @@ void StoryModeLobbyScreen::eventCallback(Widget* widget,
}
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
// Since only now the current player is defined, we have to request
// a login (if an online login was saved). If the current player was
// saved, this request will be started much earlier in the startup
// sequence from the RequestManager.
PlayerManager::resumeSavedSession();
}
} // eventCallback

View File

@@ -215,7 +215,7 @@ void TracksScreen::init()
{
const GrandPrixData* gp = grand_prix_manager->getGrandPrix(n);
const std::vector<std::string> &tracks = gp->getTrackNames();
const std::vector<std::string> tracks = gp->getTrackNames(true);
std::vector<std::string> sshot_files;
for (unsigned int t=0; t<tracks.size(); t++)

View File

@@ -615,7 +615,7 @@ TrackObjectPresentationParticles::TrackObjectPresentationParticles(const XMLNode
}
catch (std::runtime_error& e)
{
fprintf(stderr, "[Track] WARNING: Could not load particles '%s'; cause :\n %s", path.c_str(), e.what());
Log::warn ("Track", "Could not load particles '%s'; cause :\n %s", path.c_str(), e.what());
}
}

View File

@@ -44,7 +44,7 @@ Profiler profiler;
#ifdef WIN32
#include <windows.h>
static double _getTimeMilliseconds()
double getTimeMilliseconds()
{
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
@@ -57,7 +57,7 @@ Profiler profiler;
#else
#include <sys/time.h>
static double _getTimeMilliseconds()
double getTimeMilliseconds()
{
struct timeval tv;
gettimeofday(&tv, NULL);
@@ -71,7 +71,7 @@ Profiler::Profiler()
{
m_thread_infos.resize(1); // TODO: monothread now, should support multithreading
m_write_id = 0;
m_time_last_sync = _getTimeMilliseconds();
m_time_last_sync = getTimeMilliseconds();
m_time_between_sync = 0.0;
m_freeze_state = UNFROZEN;
m_capture_report = false;
@@ -120,7 +120,7 @@ void Profiler::pushCpuMarker(const char* name, const video::SColor& color)
ThreadInfo& ti = getThreadInfo();
MarkerStack& markers_stack = ti.markers_stack[m_write_id];
double start = _getTimeMilliseconds() - m_time_last_sync;
double start = getTimeMilliseconds() - m_time_last_sync;
size_t layer = markers_stack.size();
// Add to the stack of current markers
@@ -143,7 +143,7 @@ void Profiler::popCpuMarker()
// Update the date of end of the marker
Marker& marker = markers_stack.top();
marker.end = _getTimeMilliseconds() - m_time_last_sync;
marker.end = getTimeMilliseconds() - m_time_last_sync;
// Remove the marker from the stack and add it to the list of markers done
markers_done.push_front(marker);
@@ -158,8 +158,8 @@ void Profiler::synchronizeFrame()
if(m_freeze_state == FROZEN)
return;
// Avoid using several times _getTimeMilliseconds(), which would yield different results
double now = _getTimeMilliseconds();
// Avoid using several times getTimeMilliseconds(), which would yield different results
double now = getTimeMilliseconds();
// Swap buffers
int old_write_id = m_write_id;

View File

@@ -31,6 +31,8 @@
class Profiler;
extern Profiler profiler;
double getTimeMilliseconds();
#define ENABLE_PROFILER
#ifdef ENABLE_PROFILER