doom3-bfg/neo/sys/sys_localuser.h

193 lines
5.9 KiB
C
Raw Normal View History

2012-11-26 18:58:24 +00:00
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
2012-11-26 18:58:24 +00:00
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
2012-11-26 18:58:24 +00:00
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __SYS_LOCALUSER_H__
#define __SYS_LOCALUSER_H__
#include "sys_profile.h"
struct achievementDescription_t;
class idPlayerProfile;
class idProfileMgr;
enum onlineCaps_t
{
2012-11-26 18:58:24 +00:00
CAP_IS_ONLINE = BIT( 0 ),
CAP_BLOCKED_PERMISSION = BIT( 1 ),
CAP_CAN_PLAY_ONLINE = BIT( 2 ),
};
class idSerializer;
/*
================================================
localUserHandle_t
================================================
*/
struct localUserHandle_t
{
2012-11-26 18:58:24 +00:00
public:
typedef uint32 userHandleType_t;
2012-11-26 18:58:24 +00:00
localUserHandle_t() : handle( 0 ) {}
2012-11-26 18:58:24 +00:00
explicit localUserHandle_t( userHandleType_t handle_ ) : handle( handle_ ) {}
bool operator == ( const localUserHandle_t& other ) const
{
2012-11-26 18:58:24 +00:00
return handle == other.handle;
}
bool operator < ( const localUserHandle_t& other ) const
{
2012-11-26 18:58:24 +00:00
return handle < other.handle;
}
bool IsValid() const
{
return handle > 0;
}
void WriteToMsg( idBitMsg& msg )
{
2012-11-26 18:58:24 +00:00
msg.WriteLong( handle );
}
void ReadFromMsg( const idBitMsg& msg )
{
2012-11-26 18:58:24 +00:00
handle = msg.ReadLong();
}
void Serialize( idSerializer& ser );
2012-11-26 18:58:24 +00:00
private:
userHandleType_t handle;
};
/*
================================================
idLocalUser
2012-11-26 18:58:24 +00:00
An idLocalUser is a user holding a controller.
It represents someone controlling the menu or game.
They may not necessarily be in a game (which would be a session user of TYPE_GAME).
A controller user references an input device (which is a gamepad, keyboard, etc).
================================================
*/
class idLocalUser
{
public:
idLocalUser();
2012-11-26 18:58:24 +00:00
virtual ~idLocalUser() {}
void Pump();
2012-11-26 18:58:24 +00:00
virtual void PumpPlatform() = 0;
virtual bool IsPersistent() const
{
return IsProfileReady(); // True if this user is a persistent user, and can save stats, etc (signed in)
}
2012-11-26 18:58:24 +00:00
virtual bool IsProfileReady() const = 0; // True if IsPersistent is true AND profile is signed into LIVE service
virtual bool IsOnline() const = 0; // True if this user has online capabilities
virtual uint32 GetOnlineCaps() const = 0; // Returns combination of onlineCaps_t flags
virtual bool HasOwnerChanged() const
{
return false; // Whether or not the original persistent owner has changed since it was first registered
}
2012-11-26 18:58:24 +00:00
virtual int GetInputDevice() const = 0; // Input device of controller
virtual const char* GetGamerTag() const = 0; // Gamertag of user
2012-11-26 18:58:24 +00:00
virtual bool IsInParty() const = 0; // True if the user is in a party (do we support this on pc and ps3? )
virtual int GetPartyCount() const = 0; // Gets the amount of users in the party
2012-11-26 18:58:24 +00:00
// Storage related
virtual bool IsStorageDeviceAvailable() const; // Only false if the player has chosen to play without a storage device, only possible on 360, if available, everything needs to check for available space
virtual void ResetStorageDevice();
virtual bool StorageSizeAvailable( uint64 minSizeInBytes, int64& neededBytes );
2012-11-26 18:58:24 +00:00
// These set stats within the profile as a enum/value pair
virtual void SetStatInt( int stat, int value );
virtual void SetStatFloat( int stat, float value );
virtual int GetStatInt( int stat );
virtual float GetStatFloat( int stat );
virtual idPlayerProfile* GetProfile()
{
return GetProfileMgr().GetProfile();
}
const idPlayerProfile* GetProfile() const
{
return const_cast< idLocalUser* >( this )->GetProfile();
}
idProfileMgr& GetProfileMgr()
{
return profileMgr;
}
2012-11-26 18:58:24 +00:00
// Helper state to determine if the user is joining a party lobby or not
void SetJoiningLobby( int lobbyType, bool value )
{
joiningLobby[lobbyType] = value;
}
bool IsJoiningLobby( int lobbyType ) const
{
return joiningLobby[lobbyType];
}
bool CanPlayOnline() const
{
return ( GetOnlineCaps() & CAP_CAN_PLAY_ONLINE ) > 0;
}
localUserHandle_t GetLocalUserHandle() const
{
return localUserHandle;
}
void SetLocalUserHandle( localUserHandle_t newHandle )
{
localUserHandle = newHandle;
}
2012-11-26 18:58:24 +00:00
// Creates a new profile if one not already there
void LoadProfileSettings();
void SaveProfileSettings();
2012-11-26 18:58:24 +00:00
// Will attempt to sync the achievement bits between the server and the localUser when the achievement system is ready
void RequestSyncAchievements()
{
syncAchievementsRequested = true;
}
2012-11-26 18:58:24 +00:00
private:
bool joiningLobby[2];
localUserHandle_t localUserHandle;
idProfileMgr profileMgr;
2012-11-26 18:58:24 +00:00
bool syncAchievementsRequested;
};
#endif // __SYS_LOCALUSER_H__