sync fwk
parent
ba6aacaf5b
commit
433d741838
|
@ -3353,7 +3353,7 @@ unsigned play;
|
||||||
bool paused;
|
bool paused;
|
||||||
struct atlas_t *a;
|
struct atlas_t *a;
|
||||||
} sprite_t;
|
} sprite_t;
|
||||||
enum { OBJTYPE_sprite_t = 10 }; typedef struct { unsigned static_assert_on_L__LINE__ : !!(10 <= 255); } static_assert_on_Lconcat(_L,3977)___COUNTER__; typedef struct { unsigned static_assert_on_L__LINE__ : !!(sizeof(sprite_t)); } static_assert_on_Lconcat(_L,3977)___COUNTER__;;
|
enum { OBJTYPE_sprite_t = 10 }; typedef struct { unsigned static_assert_on_L__LINE__ : !!(10 <= 255); } static_assert_on_Lconcat(_L,3980)___COUNTER__; typedef struct { unsigned static_assert_on_L__LINE__ : !!(sizeof(sprite_t)); } static_assert_on_Lconcat(_L,3980)___COUNTER__;;
|
||||||
void sprite_ctor(sprite_t *s);
|
void sprite_ctor(sprite_t *s);
|
||||||
void sprite_dtor(sprite_t *s);
|
void sprite_dtor(sprite_t *s);
|
||||||
void sprite_tick(sprite_t *s);
|
void sprite_tick(sprite_t *s);
|
||||||
|
@ -3391,6 +3391,12 @@ atlas_t atlas;
|
||||||
float scale;
|
float scale;
|
||||||
} skinned_t;
|
} skinned_t;
|
||||||
guiskin_t gui_skinned(const char *asefile, float scale);
|
guiskin_t gui_skinned(const char *asefile, float scale);
|
||||||
|
bool steam_init(unsigned app_id);
|
||||||
|
void steam_tick();
|
||||||
|
void steam_trophy(const char *trophy_id, bool redeem);
|
||||||
|
void steam_screenshot();
|
||||||
|
void steam_destroy();
|
||||||
|
int ui_steam();
|
||||||
void* thread( int (*thread_func)(void* user_data), void* user_data );
|
void* thread( int (*thread_func)(void* user_data), void* user_data );
|
||||||
void thread_destroy( void *thd );
|
void thread_destroy( void *thd );
|
||||||
int argc();
|
int argc();
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
#include "v4k.h"
|
#include "v4k.h"
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
window_create(0.75, 0);
|
|
||||||
|
|
||||||
steam_init(0); // steam_appid: 0 to use SpaceWar vanilla project from Valve
|
steam_init(0); // steam_appid: 0 to use SpaceWar vanilla project from Valve
|
||||||
|
|
||||||
|
window_create(0.75, 0);
|
||||||
|
|
||||||
while( window_swap() ) {
|
while( window_swap() ) {
|
||||||
steam_tick();
|
steam_tick();
|
||||||
|
|
||||||
|
|
3326
engine/joint/v4k.h
3326
engine/joint/v4k.h
File diff suppressed because it is too large
Load Diff
|
@ -23,6 +23,9 @@ API void script_call(const char *lua_function);
|
||||||
|
|
||||||
API bool script_tests();
|
API bool script_tests();
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// script framework
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SCRIPT_LUA = 1,
|
SCRIPT_LUA = 1,
|
||||||
SCRIPT_DEBUGGER = 2,
|
SCRIPT_DEBUGGER = 2,
|
||||||
|
|
|
@ -0,0 +1,189 @@
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// steam framework
|
||||||
|
// - rlyeh, public domain
|
||||||
|
//
|
||||||
|
// hints:
|
||||||
|
// - steam must be running in background
|
||||||
|
// - steamworks dll must be close to executable (may be "steam_api64.dll", "libsteam_api.dylib" or "libsteam_api.so")
|
||||||
|
// - family mode should be off (achievements not displayed otherwise)
|
||||||
|
//
|
||||||
|
// [src] https://steamdb.info/app/480/
|
||||||
|
// [src] https://steamdb.info/app/480/stats/
|
||||||
|
// [src] https://partner.steamgames.com/doc/
|
||||||
|
// [src] dumpbin /exports steam_api64.dll
|
||||||
|
|
||||||
|
#ifndef STEAM_APPID
|
||||||
|
#define STEAM_APPID 480
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef STEAM_DLL
|
||||||
|
#define STEAM_DLL ifdef(win32, "steam_api64.dll", "libsteam_api" ifdef(osx, ".dylib", ".so"))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define STEAM_API_DECL(ret,name,args) API ret (*name) args;
|
||||||
|
#define STEAM_API_DEFN(ret,name,args) ret (*name) args;
|
||||||
|
#define STEAM_API_LOAD(ret,name,args) name = dll(STEAM_DLL, #name); if(!name) PRINTF("Cannot load `" STEAM_DLL "@%s`\n", #name);
|
||||||
|
|
||||||
|
STEAM_API(STEAM_API_DECL);
|
||||||
|
STEAM_API(STEAM_API_DEFN);
|
||||||
|
|
||||||
|
struct steam_t {
|
||||||
|
intptr_t iclient;
|
||||||
|
intptr_t iapps;
|
||||||
|
intptr_t ifriends;
|
||||||
|
intptr_t ihtmlsurface;
|
||||||
|
intptr_t imatchmaking;
|
||||||
|
intptr_t imatchmakingservers;
|
||||||
|
intptr_t inetworking;
|
||||||
|
intptr_t iremoteplay;
|
||||||
|
intptr_t iremotestorage;
|
||||||
|
intptr_t iscreenshots;
|
||||||
|
intptr_t iuser;
|
||||||
|
intptr_t iuserstats;
|
||||||
|
intptr_t iutils;
|
||||||
|
uint64_t steamid;
|
||||||
|
|
||||||
|
int num_friends;
|
||||||
|
bool running, overlay;
|
||||||
|
bool logged, behindnat;
|
||||||
|
char status[256], username[256], language[32];
|
||||||
|
} steam = {0};
|
||||||
|
|
||||||
|
static
|
||||||
|
void steam_message_cb(int severity, const char *message) {
|
||||||
|
/**/ if( severity == 0 ) printf("%s", message);
|
||||||
|
else if( severity == 1 ) printf("Warning: %s", message);
|
||||||
|
else printf("Unknown severity %d: %s", severity, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool steam_init(unsigned app_id) {
|
||||||
|
struct steam_t z = {0};
|
||||||
|
steam = z;
|
||||||
|
|
||||||
|
app_id = app_id ? app_id : STEAM_APPID;
|
||||||
|
|
||||||
|
// Steam installed?
|
||||||
|
HKEY hSteamProcess;
|
||||||
|
if( RegOpenKeyExA(HKEY_CURRENT_USER,"Software\\Valve\\Steam\\ActiveProcess", 0, KEY_READ, &hSteamProcess) ) {
|
||||||
|
return !strcpy(steam.status, "Err: steam not installed");
|
||||||
|
}
|
||||||
|
RegCloseKey(hSteamProcess);
|
||||||
|
|
||||||
|
// dll present?
|
||||||
|
if( !file_exist(STEAM_DLL) ) {
|
||||||
|
return !strcpy(steam.status, "Err: " STEAM_DLL " not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load symbols
|
||||||
|
STEAM_API(STEAM_API_LOAD);
|
||||||
|
if( !SteamAPI_Init ) SteamAPI_Init = SteamAPI_InitSafe;
|
||||||
|
|
||||||
|
// Initialize
|
||||||
|
char *app_id_str = va("%d", app_id);
|
||||||
|
//if( !file_exist("steam_appid.txt") ) file_write("steam_appid.txt", app_id_str, strlen(app_id_str));
|
||||||
|
if( !getenv("SteamAppId") ) SetEnvironmentVariableA("SteamAppId", app_id_str);
|
||||||
|
|
||||||
|
int started = SteamAPI_Init && SteamAPI_Init();
|
||||||
|
if( !started ) {
|
||||||
|
return !strcpy(steam.status, "Err: steam not running");
|
||||||
|
}
|
||||||
|
|
||||||
|
SteamAPI_RestartAppIfNecessary(app_id);
|
||||||
|
|
||||||
|
// Create interfaces
|
||||||
|
steam.iclient = (intptr_t)SteamInternal_CreateInterface("SteamClient020");
|
||||||
|
if( !steam.iclient ) {
|
||||||
|
return !strcpy(steam.status, "Err: incompatible dll");
|
||||||
|
}
|
||||||
|
|
||||||
|
HSteamPipe hpipe = SteamAPI_ISteamClient_CreateSteamPipe(steam.iclient);
|
||||||
|
HSteamUser huser = SteamAPI_ISteamClient_ConnectToGlobalUser(steam.iclient, hpipe);
|
||||||
|
|
||||||
|
steam.iapps = (intptr_t)SteamAPI_ISteamClient_GetISteamApps(steam.iclient, huser, hpipe, "STEAMAPPS_INTERFACE_VERSION008");
|
||||||
|
steam.ifriends = (intptr_t)SteamAPI_ISteamClient_GetISteamFriends(steam.iclient, huser, hpipe, "SteamFriends017"); // 015
|
||||||
|
steam.ihtmlsurface = (intptr_t)SteamAPI_ISteamClient_GetISteamHTMLSurface(steam.iclient, huser, hpipe, "STEAMHTMLSURFACE_INTERFACE_VERSION_005");
|
||||||
|
steam.imatchmaking = (intptr_t)SteamAPI_ISteamClient_GetISteamMatchmaking(steam.iclient, huser, hpipe, "SteamMatchMaking009");
|
||||||
|
steam.imatchmakingservers = (intptr_t)SteamAPI_ISteamClient_GetISteamMatchmakingServers(steam.iclient, huser, hpipe, "SteamMatchMakingServers002");
|
||||||
|
steam.inetworking = (intptr_t)SteamAPI_ISteamClient_GetISteamNetworking(steam.iclient, huser, hpipe, "SteamNetworking006");
|
||||||
|
//steam.iremoteplay = (intptr_t)SteamAPI_ISteamClient_GetISteamRemotePlay(steam.iclient, huser, hpipe, "STEAMREMOTEPLAY_INTERFACE_VERSION001");
|
||||||
|
steam.iremotestorage = (intptr_t)SteamAPI_ISteamClient_GetISteamRemoteStorage(steam.iclient, huser, hpipe, "STEAMREMOTESTORAGE_INTERFACE_VERSION014");
|
||||||
|
steam.iscreenshots = (intptr_t)SteamAPI_ISteamClient_GetISteamScreenshots(steam.iclient, huser, hpipe, "STEAMSCREENSHOTS_INTERFACE_VERSION003");
|
||||||
|
steam.iuser = (intptr_t)SteamAPI_ISteamClient_GetISteamUser(steam.iclient, huser, hpipe, "SteamUser021"); // 019
|
||||||
|
steam.iuserstats = (intptr_t)SteamAPI_ISteamClient_GetISteamUserStats(steam.iclient, huser, hpipe, "STEAMUSERSTATS_INTERFACE_VERSION012");
|
||||||
|
steam.iutils = (intptr_t)SteamAPI_ISteamClient_GetISteamUtils(steam.iclient, hpipe, "SteamUtils010");
|
||||||
|
|
||||||
|
SteamAPI_ISteamClient_SetWarningMessageHook(steam.iclient, steam_message_cb);
|
||||||
|
|
||||||
|
// Retrieve some vars
|
||||||
|
steam.running = SteamAPI_IsSteamRunning();
|
||||||
|
steam.steamid = SteamAPI_ISteamUser_GetSteamID(steam.iuser);
|
||||||
|
steam.logged = SteamAPI_ISteamUser_BLoggedOn(steam.iuser);
|
||||||
|
steam.behindnat = SteamAPI_ISteamUser_BIsBehindNAT(steam.iuser);
|
||||||
|
steam.num_friends = SteamAPI_ISteamFriends_GetFriendCount(steam.ifriends, k_EFriendFlagAll);
|
||||||
|
strncpy(steam.username, SteamAPI_ISteamFriends_GetPersonaName(steam.ifriends), sizeof(steam.username));
|
||||||
|
strncpy(steam.language, SteamAPI_ISteamUtils_GetSteamUILanguage(steam.iutils), sizeof(steam.language)); // SteamAPI_ISteamApps_GetCurrentGameLanguage(steam.iapps)
|
||||||
|
|
||||||
|
if(steam.logged)
|
||||||
|
SteamAPI_ISteamUserStats_RequestCurrentStats(steam.iuserstats);
|
||||||
|
|
||||||
|
ASSERT(steam.iapps);
|
||||||
|
ASSERT(steam.ifriends);
|
||||||
|
ASSERT(steam.ihtmlsurface);
|
||||||
|
ASSERT(steam.imatchmaking);
|
||||||
|
ASSERT(steam.imatchmakingservers);
|
||||||
|
ASSERT(steam.inetworking);
|
||||||
|
// ASSERT(steam.iremoteplay);
|
||||||
|
ASSERT(steam.iremotestorage);
|
||||||
|
ASSERT(steam.iscreenshots);
|
||||||
|
ASSERT(steam.iuser);
|
||||||
|
ASSERT(steam.iuserstats);
|
||||||
|
ASSERT(steam.iutils);
|
||||||
|
|
||||||
|
strcpy(steam.status, "Ok");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void steam_tick() {
|
||||||
|
if( steam.iclient ) {
|
||||||
|
SteamAPI_RunCallbacks();
|
||||||
|
steam.overlay = SteamAPI_ISteamUtils_IsOverlayEnabled(steam.iutils);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void steam_trophy(const char *trophy_id, bool redeem) {
|
||||||
|
if( steam.iclient && steam.logged ) {
|
||||||
|
if( redeem )
|
||||||
|
SteamAPI_ISteamUserStats_SetAchievement(steam.iuserstats, trophy_id);
|
||||||
|
else
|
||||||
|
SteamAPI_ISteamUserStats_ClearAchievement(steam.iuserstats, trophy_id);
|
||||||
|
SteamAPI_ISteamUserStats_StoreStats(steam.iuserstats);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void steam_screenshot() {
|
||||||
|
if( steam.iclient ) {
|
||||||
|
SteamAPI_ISteamScreenshots_TriggerScreenshot(steam.iscreenshots);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void steam_destroy() {
|
||||||
|
if( steam.iclient ) {
|
||||||
|
steam.iclient = 0;
|
||||||
|
SteamAPI_Shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ui_steam() {
|
||||||
|
ui_disable();
|
||||||
|
|
||||||
|
ui_label2("Status", steam.status);
|
||||||
|
ui_label2("Username", steam.username);
|
||||||
|
ui_label2("Language", steam.language);
|
||||||
|
ui_label2("Friends", va("%d", steam.num_friends));
|
||||||
|
ui_label2("SteamID", va("%llu", steam.steamid));
|
||||||
|
ui_bool("Overlay?", &steam.overlay);
|
||||||
|
|
||||||
|
ui_enable();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// steam framework
|
||||||
|
|
||||||
|
API bool steam_init(unsigned app_id);
|
||||||
|
API void steam_tick();
|
||||||
|
API void steam_trophy(const char *trophy_id, bool redeem);
|
||||||
|
API void steam_screenshot();
|
||||||
|
API void steam_destroy();
|
||||||
|
|
||||||
|
API int ui_steam();
|
Loading…
Reference in New Issue