DOOM-3-BFG

DOOM 3 BFG Edition
Log | Files | Refs

sys_achievements.h (5479B)


      1 /*
      2 ===========================================================================
      3 
      4 Doom 3 BFG Edition GPL Source Code
      5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 
      6 
      7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").  
      8 
      9 Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
     10 it under the terms of the GNU General Public License as published by
     11 the Free Software Foundation, either version 3 of the License, or
     12 (at your option) any later version.
     13 
     14 Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
     15 but WITHOUT ANY WARRANTY; without even the implied warranty of
     16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17 GNU General Public License for more details.
     18 
     19 You should have received a copy of the GNU General Public License
     20 along with Doom 3 BFG Edition Source Code.  If not, see <http://www.gnu.org/licenses/>.
     21 
     22 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.
     23 
     24 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.
     25 
     26 ===========================================================================
     27 */
     28 #ifndef __SYS_ACHIEVEMENTS_H__
     29 #define __SYS_ACHIEVEMENTS_H__
     30 
     31 class idLocalUser;
     32 
     33 // data structure for online achievement entry descriptions
     34 // this is used for testing purposes to make sure that the consoles
     35 // achievement settings match the game's decls
     36 struct achievementDescription_t {
     37 	void	Clear() {
     38 		name[0] = '\0';
     39 		description[0] = '\0';
     40 		hidden = false;
     41 	};
     42 	char	name[500];
     43 	char	description[1000];
     44 	bool	hidden;
     45 };
     46 
     47 /*
     48 ================================================
     49 idAchievementSystem 
     50 ================================================
     51 */
     52 class idAchievementSystem {
     53 public:
     54 	static const int MAX_ACHIEVEMENTS = 128;		// This matches the max number of achievements bits in the profile
     55 
     56 	virtual			~idAchievementSystem() {}
     57 
     58 	// PC and PS3 initialize for the system, not for a particular controller
     59 	virtual void	Init() {}
     60 
     61 	// PS3 has to wait to install the .TRP file until *after* we determine there's enough space, for consistent user messaging
     62 	virtual void	Start() {}
     63 
     64 	// Do any necessary cleanup
     65 	virtual void	Shutdown() {}
     66 
     67 	// Is the achievement system ready for requests
     68 	virtual bool	IsInitialized() { return false; }
     69 	
     70 	// Add a local user to the system
     71 	virtual void	RegisterLocalUser( idLocalUser * user ) {}
     72 
     73 	// This is only necessary on the 360 right now, we need this because the 360 maintains a buffer of pending actions
     74 	// per user.  If a user is removed from the system, we need to inform the system so it can cancel it's in flight actions
     75 	// and allow the buffers to be reused
     76 	virtual void	RemoveLocalUser( idLocalUser * user ) {}
     77 
     78 	// Unlocks the achievement, all platforms silently fail if the achievement has already been unlocked
     79 	virtual void	AchievementUnlock( idLocalUser * user, const int achievementID ) = 0;
     80 
     81 	// Puts the achievement back to its original state, platform implementation may not allow this
     82 	virtual void	AchievementLock( idLocalUser * user, const int achievementID ) {}
     83 
     84 	// Puts alls achievements back to their original state, platform implementation may not allow this
     85 	virtual void	AchievementLockAll( idLocalUser * user, const int maxId ) {}
     86 
     87 	// Should be done every frame
     88 	virtual void	Pump() = 0;
     89 
     90 	// Cancels all in-flight achievements for all users if NULL, resets the system so a Init() must be re-issued
     91 	virtual void	Reset( idLocalUser * user = NULL ) {}
     92 
     93 	// Cancels all in-flight achievements, not very useful on PC
     94 	virtual void	Cancel( idLocalUser * user ) {}
     95 
     96 	// Retrieves textual information about a given achievement
     97 	// returns false if there was an error
     98 	virtual bool	GetAchievementDescription( idLocalUser * user, const int id, achievementDescription_t & data ) const { return false; }
     99 
    100 	// How much storage is required
    101 	// returns false if there was an error
    102 	virtual bool	GetRequiredStorage( uint64 & requiredSizeTrophiesBytes ) { requiredSizeTrophiesBytes = 0; return true; }
    103 
    104 	// Retrieves state about of all achievements cached locally (may not be online yet)
    105 	// returns false if there was an error
    106 	virtual bool	GetAchievementState( idLocalUser * user, idArray< bool, idAchievementSystem::MAX_ACHIEVEMENTS > & achievements ) const { return false; }
    107 
    108 	// Sets state of all the achievements within list (for debug purposes only)
    109 	// returns false if there was an error
    110 	virtual bool	SetAchievementState( idLocalUser * user, idArray< bool, idAchievementSystem::MAX_ACHIEVEMENTS > & achievements ) { return false; }
    111 
    112 	// You want to get the server's cached achievement status into the user because the profile may not have been
    113 	// saved with the achievement bits after an achievement was granted.
    114 	void			SyncAchievementBits( idLocalUser * user );
    115 
    116 protected:
    117 	// Retrieves the index from the local user list
    118 	int				GetLocalUserIndex( idLocalUser * user ) const { return users.FindIndex( user ); }
    119 
    120 	idStaticList< idLocalUser *, MAX_LOCAL_PLAYERS > users;
    121 };
    122 
    123 #endif // __SYS_ACHIEVEMENTS_H__