# 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

(1) Download STOVE Launcher from Download PC Client (opens new window).

(2) Create a PolicyConfig.json file in the folder where STOVE Launcher is installed.

  • Live default installation location : C:\Program Files (x86)\Smilegate\STOVE

(3) Enter the following contents in the PolicyConfig.json file and create it when registering the STOVE Studio project.

Warning

You must be logged in after running the STOVE launcher during SDK integration.

After creating PolicyConfig.json with the structure like below, add the following to it

  • Live : C:\Program Files (x86)\Smilegate\STOVE

Check the Game ID and replace it.




 



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

Note

You can change "id_hellostove" to the gameID registered with STOVE Partners.

(4) Run the STOVE Launcher and log in with the gameID you registered with STOVE.

# 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: 11/22/2023, 1:25:27 PM