# Follow Through for PC SDK Native

It is an example of how to link STOVE PC SDK with C++ language in the Windows Native development environment.

confirm Before proceeding with the following example, install STOVE Launcher (opens new window) in advance and refer to Preparing SDK development environment and obtain App key, App secret, and Game Id in advance. It wrote the example in Visual Studio 2015 Update 3. You will need to upgrade the project when you use a higher version of Visual Studio.

# Setting up STOVE Launcher

# Previous Client (Launcher v2)

  1. Download the STOVE launcher from the following link Download PC Client (opens new window).

  2. Create a PolicyConfig.json file in the folder where the STOVE launcher is installed.

  • Default installation location: C:\Program Files (x86)\Smilegate\STOVE
  1. Enter the contents below in the PolicyConfig.json file and create it when registering the STOVE Studio project.
  • You must run the STOVE launcher during SDK integration.

After creating PolicyConfig.json with the structure below, overwrite it in the C:\Program Files (x86)\Smilegate\STOVE folder. Check the Game ID in the project management menu of STOVE Studio (opens new window) and replace it.

{
"skip_check_game_list":
[
"id_hellostove"
]
}
1
2
3
4
5
6

Change "id_hellostove" to the gameID registered in STOVE Studio

  1. Run STOVE Launcher and log in with the STOVE ID registered in STOVE Studio.

# New Client (Launcher v3)

# A. Pre-preparation

This explains what you need to prepare in advance before proceeding with the build test.

# 1. Sign up for STOVE Studio and register a project

  • Log in to the studio with an account registered in STOVE and register as a store developer.
  • Register a new project through the "Release in Studio" menu on the studio screen.
  • When you register a new project, you can check the "Game ID" and "Application Key" values ​​on the project screen and obtain the project information required for PC SDK linkage.

# 2. Complete PC SDK linkage to game build

  • PC SDK must be linked to game build, and the studio's project information (game ID, application key) must be included accurately when linking SDK.

If project information is not entered accurately, build test will not proceed.

# 3. Download New Client

# B. Activate Developer Mode

Activating developer mode is the task of allowing New Client to recognize the game build (linked with PC SDK) running on the local PC.

# 1. Create developer mode configuration file

  • To activate the developer mode of New Client, the configuration file must be created with the name policyconfig.json. If the file name is not accurate, New Client will not recognize the configuration file. - Go to C:\Users\%username%\AppData\Local\STOVE\Config and create a policyconfig.json file.
Path: ...\AppData\Local\STOVE\Config\PolicyConfig.json
1

# 2. Enter the settings

The final step to activate the developer mode of the New client is to write the settings as shown in the box below.

Warning

If the Stove Launcher is on, you must restart the Stove Launcher after writing.

You can enter multiple game IDs registered in the studio in dev_game_list, and the game build that matches the entered game ID will communicate with the New client in developer mode and allow build testing on the local PC.

PolicyConfig.json
{
"stove_launcher_policy_config":
{
"dev_game_list": [ "Game ID", "Game ID", .... ]
}
}
1
2
3
4
5
6
7

If the developer mode of the New client is not activated, check if the location of the policyconfig.json file is correct, and check if the game ID entered in policyconfig.json exactly matches the game ID registered in the studio.

# C. Proceed with the build test

Since the developer mode of the New client has been activated through the process described above, all the difficult steps have been completed, and the build test is possible by simply running the game build linked to the PC SDK while the New client is running.

The build test can be conveniently performed by running the exe file directly or in the debug mode of the development tool (Visual Studio, Unity, Unreal, etc.) so that the debugging process can be performed.

If a test payment is required in a game build linked with the IAP SDK, the above method is not supported. To perform a test payment, you must upload the build to the studio, enter the Studio Test menu in the New client, and then attempt a test payment.

# Downloading a Follow Through HelloStove Project

Download the Follow Through HelloStove Project from the link below.

This project is yet not integrated with PC SDK. Now, we begin to integrate PC SDK.

# Configuring Project Settings

  • From the PC SDK download page, download the latest version of the Native (C/C++) distribution file (starting now referred to as StovePCSDK). After downloading and unpacking, copy the entire file under the HelloStove_Native folder.

Figure1

After StovePCSDK copy is complete, run Visual Studio and select HelloStove.sln to load the project.

# 1) C/C++ : Additional Include Directories Settings

Open the project property page (Alt + F7) and add the path StovePCSDK_{version number}/include to Additional include directories in the C/C++ configuration properties.

$(SolutionDir)StovePCSDK_2.1.0\include
1

Figure2

# 2) Linker : Additional Library Directories Settings

Add the path to the folder StovePCSDK_{version number}/bin in the Additional library directory of the Linker-General configuration property on the project property page.

$(SolutionDir)StovePCSDK_2.1.0\bin\$(Platform)\$(Configuration)
1

Figure3

# 3) Additional Dependencies Settings

Add StovePCSDK.lib to the project property page’s Additional Dependencies.

StovePCSDK.lib
1

Figure4

  • After following up to this point, build the project and check whether any errors occur. If an error occurs, check the above steps to solve the problem.

# 4) Modifying HelloStoveDlg.h header file

Open the HelloStoveDlg.h file of the HelloStove project and add the code below.

#pragma once
#include "afxwin.h" 

/*Add the 'Follow Through' code here.*/ 
#include "StovePCSDK.h"
1
2
3
4
5

# 5) Building

Run Build Solution from the Build menu. If you have done all the settings in the previous tutorial, it will generally build without any errors. If a build error occurs, check the error message and check whether there is an error in the path of the project settings or missing in the StovePCSDK file copy.

# SDK Initialization

To use StovePCSDK, you need to execute the initialization function first. For initialization, input appropriate values to the StovePCConfig and StovePCCallback structures and call the StovePC_Init function. To use the StovePC_Init function, enter the following into the CHelloStoveDlg::OnBnClickedInit function.

void CHelloStoveDlg::OnBnClickedInit()
{
    /*Add the 'Follow Through' code here.*/

    //config
    StovePCConfig config;
    memset(&config, 0, sizeof(StovePCConfig));

    config.env = "LIVE";
    config.appKey = "YOUR_APP_KEY";
    config.secretKey = "YOUR_SECRET_KEY";
    config.gameId = L"YOUR_GAME_ID";
    config.logLevel = StovePCLogLevel::STOVE_PC_LOG_LEVEL_DEBUG;
    config.logPath = L"";

    //callback 
    StovePCCallback callback;
    memset(&callback, 0, sizeof(StovePCCallback));

    callback.OnError = OnError;
    callback.OnInitComplete = OnInitComplete;
    callback.OnToken = OnToken;
    callback.OnUser = OnUser;

    //initialize
    StovePCResult result = StovePC_Init(config, callback);
    if (result != StovePCResult::STOVE_PC_NO_ERROR)
    {
        //StovePCSDK initialize fail
        _displayConfig(config);
        CString log;
        log.Format(L"[Error] StovePC_Init, Result %d", result);
        OnLog(log);
    }
    else
    {
        //StovePCSDK initialize success
        _displayConfig(config);
        OnLog(L"[Success] StovePC_Init");

        //You have successfully called the StovePC_Init function. 
        //Now, regularly call in the StovePC_RunCallback function from the timer.
        SetTimer(USER_TIMER, 500, NULL);
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

Precautions

The PCSDK log path must be set as an absolute path. ex) C:\Program Files\{Your Game Folder}\Logs Do not add "\" at the end. PCSDK automatically adds the file name "StovePCSDK.log".
If "" is set as an empty string, PCSDK automatically creates a log in the path of the game executable file folder or the folder where the PCSDK DLL is located.

confirm "YOUR_APP_KEY", "YOUR_SECRET_KEY", and "YOUR_GAME_ID" must be changed to data previously issued by STOVE Studio (opens new window). If you call the StovePC_Init function without logging into the stove launcher with the stove account applied for entry into STOVE Studio, error code 150 (sgup initialization failure) occurs.

We also included the following in the code above. If the StovePC_Init function returns value called from the CHelloStoveDlg::OnBnClickedInit function is successful (that is, when it return STOVE_PC_NO_ERROR), you need to put the StovePC_RunCallback function on the timer. We code the example to follow to call the StovePC_RunCallback function every 500ms through MFC's SetTimer function. When the callback CHelloStoveDlg::OnTimer function is executed periodically through SetTimer, add the StovePC_RunCallback function as shown in the code below.

void CHelloStoveDlg::OnTimer(UINT_PTR nIDEvent)
{
    if (nIDEvent == USER_TIMER)
    {
        /*Add the 'Follow Through' code here.*/
        StovePC_RunCallback(); 
    }
    CDialogEx::OnTimer(nIDEvent);
}
1
2
3
4
5
6
7
8
9

Comment out the OnInitComplete function, it calls back the function when the StovePC_Init function is ordinarily complete, and input the code below.

Also, if the StovePC_Init function is executed normally, the callback OnInitComplete function is called. In other words, when it calls the OnInitComplete function, it means that it executes the StovePC_Init function successfully. As shown in the code below, you can log the successful initialization of StovePCSDK.

void OnInitComplete()
{
    /*Add the 'Follow Through' code here.*/

    OnLog(L"[Success] InitComplete\n");
}

1
2
3
4
5
6
7

It calls the OnError function when the StovePC_Init function or any other function call from StovePCSDK fails. You can check by writing the code below to narrow the function error of StovePCSDK.

void OnError(const StovePCError error)
{
    /*Add the 'Follow Through' code here.*/

    OnLog(L"[Error]\n");

    CString log;
    log.Format(L"StovePCError occurred\n -funcType: %d, result:%d, externalError: %d", error.functionType, error.result, error.externalError);

    OnLog(log);
}
1
2
3
4
5
6
7
8
9
10
11

# SDK Termination

After all uses of StovePCSDK, the StovePC_UnInit function call is required to clean up resources. Add the code that calls the StovePC_UnInit function to the CHelloStove::OnBnClickedUnInit function as shown below.

void CHelloStoveDlg::OnBnClickedUnInit()
{
    /*Add the 'Follow Through' code here.*/

    StovePCResult result = StovePC_UnInit();
    if (result != STOVE_PC_NO_ERROR)
    {
        CString log;
        log.Format(L"[Error] StovePC_UnInit, Result %d", result);
        OnLog(log);
    }
    else
    {
        OnLog(L"[Success] StovePC_UnInit");
    }
}
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

confirm The following codes assume that StovePCSDK initialization is successful.

# Acquiring User Information

To get the user's information logged into the stove launcher, you can check it with the StovePC_GetUser function. To check the operation of the StovePC_GetUser function, add it to the CHelloStoveDlg::OnBnClickedGetUser function.

void CHelloStoveDlg::OnBnClickedGetUser()
{
    /*Add the 'Follow Through' code here.*/

    StovePCResult result = StovePC_GetUser();
    if (result != STOVE_PC_NO_ERROR)
    {
        CString log;
        log.Format(L"[Error] StovePC_GetUser, Result %d", result);
        OnLog(log);
    }
    else
    {
        OnLog(L"[Success] StovePC_GetUser");
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

Comment out the OnUser function. It calls back the function when it usually calls the StovePC_GetUser function and input the code below.

When it calls the StovePC_GetUser function usually, it calls the callback OnUser function. When it reaches the callback OnUser function, you can extract the user's information through the StovePCUser argument.

void OnUser(const StovePCUser user)
{
    /*Add the 'Follow Through' code here.*/

    OnLog(L"<User>");

    CString log;
 
    log.Format(L"memberNo : %I64d", user.memberNo);
    OnLog(log);
 
    log.Format(L"nickname : %s", user.nickname);
    OnLog(log);
 
    log.Format(L"gameUserId : %s", user.gameUserId);
    OnLog(log);

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

# Acquiring Token Information

The StovePC_GetToken function is used to get the token information of the user logged into the stove launcher. Add the StovePC_GetToken function to the CHelloStoveDlg::OnBnClickedGetToken function to request token information from StovePCSDK.

void CHelloStoveDlg::OnBnClickedGetToken()
{
    /*Add the 'Follow Through' code here.*/

    StovePCResult result = StovePC_GetToken();
    if (result != STOVE_PC_NO_ERROR)
    {
        CString log;
        log.Format(L"[Error] StovePC_GetToken, Result %d", result);
        OnLog(log);
    }
    else
    {
        OnLog(L"[Success] StovePC_GetToken");
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

confirm What is a token? It is the access token of the logged-in user in STOVE Launcher, and the game server passes this access token to the stove authentication server to validate the logged-in user.
For a detailed explanation of Access Token, please get in touch with store.support@smilegate.com for technical support.

Comment out the OnToken function. It calls back the function when it usually calls the StovePC_GetToken function and input the code below.

void OnToken(const StovePCToken token)
{
    /*Add the 'Follow Through' code here.*/

    OnLog(L"<Token>");

    CString log;
    log.Format(L"accessToken : %s", MtoW(token.accessToken));
    OnLog(log);
}
1
2
3
4
5
6
7
8
9
10

confirm A token is the key information issued through the launcher’s login.
Token information is managed within PC SDK, so developers will not need to use this without any specific reason.

# Build and Execute

Overwrite the HelloStove_Native\bin\{platform}\Release folder with the StovePCSDK_{version number}\bin\{platform}\Release folder.

Figure5

Execute the STOVE Launcher and log in.

Now, Press F5 to build and execute the HelloStove project.
Run the buttons on the UI screen in order and check if they work correctly.

Figure6

Congratulations!
You have successfully completed the PC SDK Native Follow Through.

Last Updated: 9/26/2024, 2:55:28 PM