{{tag>service microsoft gdk xboxlive dragonscript}}
[[:start|Start Page]] >> [[:gamedev|Game Development with the Drag[en]gine]] >> [[:gamedev:servicemodules#service_listing|Service Listing]] >> **Microsoft GDK**
====== Microsoft GDK ======
The ''ServiceMsgdk'' Service Module provides access to the Microsoft GDK. With the GDK XBoxLive functionality can be used.
The Microsoft GDK is NDA covered. To be allowed to use it the developer has first to apply for the respective developer program and sign the NDA. Once the developer is accepted and has signed the NDA he gets access to the parameters required for use during service initialization.
The service has the unique identifier ''MicrosoftGdk''.
Support for this service is provided in the DragonScript Script Module using the class #@LinkApiDocDEDS2_HTML~classDragengine_1_1Services_1_1ServiceMsgdk,ServiceMsgdk~@#. This service implements the following interfaces:
* #@LinkApiDocDEDS2_HTML~interfaceDragengine_1_1Services_1_1User_1_1ServiceUser,ServiceUser~@#
* #@LinkApiDocDEDS2_HTML~interfaceDragengine_1_1Services_1_1Stats_1_1ServiceStats,ServiceStats~@#
====== Initialization ======
===== Automatic =====
The #@LinkApiDocDEDS2_HTML~classDragengine_1_1BaseGameApp,BaseGameApp~@# class automatically creates the ServiceMsgdk service instance if the following values are present in the ''configuration.ptree.xml'' file:
^ Tag ^ Value ^
| msgdk.pathGameConfig | Path to the ''MicrosoftGame.config'' file inside the ''.delga'' file. |
The values for all these tags can only be obtained after the developer has been accepted into the developer program and has signed the NDA.
An example ''configuration.ptree.xml'' file looks like his:
true
true
/MicrosoftGame.config
If the provided initialization data is incorrect creating the ServiceMsgdk service fails. This does not fail starting the application. Wait until all the services have finished initializing:
func void initGame()
// super call starts automatic initialize services
super.initGame()
// add listener called once all services have finished initialize, no matter if successfull or not
getBaseGameServices().setActionInitialized(BlockActionListener.new(block ActionEvent event
// services have initialized
launchApplication()
end))
// you can now do other things in the mean time like showing startup logos or videos
end
You can then check first if the MSGDK service has been created using:
if getBaseGameServices().getMsgdk() != null
// ServiceMsgdk is ready to be used
end
===== Manual =====
The ServiceMsgdk service can be manually created either by using the ''new'' constructor on the #@LinkApiDocDEDS2_HTML~classDragengine_1_1Services_1_1ServiceMsgdk,ServiceMsgdk~@# class using #@LinkApiDocDEDS2_HTML~classDragengine_1_1Services_1_1ServiceMsgdk_1_1InitParameters,ServiceMsgdk.InitParameters~@# setup with the initialization data or by calling ''initMsgdk()'' on #@LinkApiDocDEDS2_HTML~classDragengine_1_1BaseGameApp,BaseGameApp~@#. Using ''initMsgdk'' is preferred if manual creation is required.
====== ServiceUser ======
The service module provides user management support. Supported is logging in, logging, retrieving user information and retrieving user resources.
===== Login =====
The user can log in using different methods. The ''loginUser()'' call accepts a #@LinkApiDocDEDS2_HTML~classDragengine_1_1Services_1_1User_1_1ServiceUserCredentials,ServiceUserCredentials~@# instance. Depending on the set parameters one of the possible login methods is used.
==== Default User ====
If the ''credentials'' parameter is ''null'' the GDK tries to use the currently logged in XBoxLive account.
It is highly recommended to use ''true'' in the ''MicrosoftGame.config'' file. If SimpleUserMode is used the game will be hard-aborted with no explanation why if the there is no XBoxLive account currently logged in on the system which is a very frustrating user experience.
Optionally you can create an instance of #@LinkApiDocDEDS2_HTML~classDragengine_1_1Services_1_1User_1_1ServiceUserCredentials,ServiceUserCredentials~@# and manually set the ''defaultUser'' member to ''true''.
==== Login Dialog ====
If the ''credentials'' instance is empty (no value assigned after creating it) the GDK shows a login dialog overlay allowing the user to select which XBoxLive account to log in to. Once successful the login will be completed.
===== Authentication Provider =====
The service module provides ''Authentication Provider'' support to other modules. The provider has the unique identifier ''epic''. This feature allows other service modules to link accounts to the logged in XBoxLive account. For this to work you have to call ''getAuthToken()'' to asynchronously retrieve an authentication token. Once received in the listener this token can be used on other service modules supporting linking with XBoxLive accounts.
====== ServiceStats ======
The service module provides achievement and statistics support. Use ''setStatsAndAchievements()'' to set the value of individual statistics. Once the requirements are fulfilled server side the respective achievements will be unlocked. You can not use the same function for achievements since this is not supported by the GDK. Use ''getStatsAndAchievements()'' to retrieve the current stats and achievements state.