Documentation by YARD 0.8.7.6
cyanic's Quick and Easy Steamworks Achievements Integration for Ruby github.com/GMMan/RGSS_SteamUserStatsLite r4 06/16/16
Drop steam_api.dll into the root of your project. Requires Steamworks SDK version >= 1.37.
“Miller complained about how hard achievements were to implement in C++, so this was born.”
Top Level Namespace
Defined Under Namespace
Classes: SteamAPIContext, SteamUserStatsLite
Class: SteamAPIContext
- Inherits:
-
Object
- Object
- SteamAPIContext
- Defined in:
- steam_user_stats_lite.rb
Overview
A context class to get Steamworks pointers to interfaces.
Constant Summary
Instance Method Summary (collapse)
-
- (SteamAPIContext) initialize
constructor
Instantiates a new instance of
SteamAPIContext
. -
- (true, false) initted?
Checks if context is initialized.
-
- (Fixnum?) steam_apps
Gets the ISteamApps pointer.
-
- (Fixnum?) steam_client
Gets the ISteamClient pointer.
-
- (Fixnum?) steam_user_stats
Gets the ISteamUserStats pointer.
Constructor Details
- (SteamAPIContext) initialize
Instantiates a new instance of SteamAPIContext
.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'steam_user_stats_lite.rb', line 26 def initialize @initted = false @h_steam_user = @@dll_SteamAPI_GetHSteamUser.call if (@h_steam_pipe = @@dll_SteamAPI_GetHSteamPipe.call) != 0 return if (@steam_client = @@dll_SteamInternal_CreateInterface.call(STEAMCLIENT_INTERFACE_VERSION)) == 0 return if (@steam_user_stats = @@dll_SteamAPI_ISteamClient_GetISteamUserStats.call(@steam_client, @h_steam_user, @h_steam_pipe, STEAMUSERSTATS_INTERFACE_VERSION)) == 0 return if (@steam_apps = @@dll_SteamAPI_ISteamClient_GetISteamApps.call(@steam_client, @h_steam_user, @h_steam_pipe, STEAMAPPS_INTERFACE_VERSION)) == 0 @initted = true end end |
Instance Method Details
- (true, false) initted?
Checks if context is initialized.
41 42 43 |
# File 'steam_user_stats_lite.rb', line 41 def initted? @initted end |
- (Fixnum?) steam_apps
Gets the ISteamApps pointer
62 63 64 |
# File 'steam_user_stats_lite.rb', line 62 def steam_apps @steam_apps if initted? end |
- (Fixnum?) steam_client
Gets the ISteamClient pointer
48 49 50 |
# File 'steam_user_stats_lite.rb', line 48 def steam_client @steam_client if initted? end |
- (Fixnum?) steam_user_stats
Gets the ISteamUserStats pointer
55 56 57 |
# File 'steam_user_stats_lite.rb', line 55 def steam_user_stats @steam_user_stats if initted? end |
Class: SteamUserStatsLite
- Inherits:
-
Object
- Object
- SteamUserStatsLite
- Defined in:
- steam_user_stats_lite.rb
Overview
A simple class for Steamworks UserStats integration.
Class Method Summary (collapse)
-
+ (SteamUserStatsLite) instance
Gets the global instance of SteamUserStatsLite.
-
+ (true, false) restart_app_if_necessary(app_id)
Restarts the app if Steamworks is not availble.
Instance Method Summary (collapse)
-
- (true, false) clear_achievement(name)
Sets an achievement as locked.
-
- (true, ...) get_achievement(name)
Gets an achievement's state.
-
- (<Object, Time>) get_achievement_and_unlock_time(name)
Gets an achievement's state and unlock time.
-
- (String) get_achievement_display_attribute(name, key)
Gets the value of an achievement's display attribute.
-
- (String) get_achievement_name(achievement)
Gets the name of an achievement by its index.
-
- (Integer?) get_num_achievements
Gets the number of achievements.
-
- (Float?) get_stat_float(name)
Gets the value of an FLOAT stat.
-
- (Integer?) get_stat_int(name)
Gets the value of an INT stat.
-
- (SteamUserStatsLite) initialize
constructor
Instantiates a new instance of
SteamUserStatsLite
. -
- (true, false) initted?
Checks if Steamworks is initialized.
-
- (true, ...) is_dlc_installed(app_id)
Checks if a DLC is installed.
-
- (true, ...) is_subscribed
Checks if current app is owned.
-
- (true, false) request_current_stats
Pulls current user's stats from Steam.
-
- (true, false) reset_all_stats(achievements_too)
Resets all stats.
-
- (true, false) set_achievement(name)
Sets an achievement as unlocked.
-
- (true, false) set_stat(name, val)
Sets the value of a stat.
-
- (void) shutdown
Shuts down Steamworks.
-
- (void) update
Runs Steam callbacks.
-
- (true, false) update_avg_rate_stat(name, count_this_session, session_length)
Updates an AVGRATE stat.
Constructor Details
- (SteamUserStatsLite) initialize
Instantiates a new instance of SteamUserStatsLite
.
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'steam_user_stats_lite.rb', line 90 def initialize @initted = false api_initted = @@dll_SteamAPI_Init.call % 256 != 0 if api_initted @context = SteamAPIContext.new if @context.initted? @i_apps = @context.steam_apps @i_user_stats = @context.steam_user_stats @initted = true end end end |
Class Method Details
+ (SteamUserStatsLite) instance
Gets the global instance of SteamUserStatsLite.
348 349 350 |
# File 'steam_user_stats_lite.rb', line 348 def self.instance @@instance end |
+ (true, false) restart_app_if_necessary(app_id)
Restarts the app if Steamworks is not availble.
126 127 128 |
# File 'steam_user_stats_lite.rb', line 126 def self.restart_app_if_necessary(app_id) @@dll_SteamAPI_RestartAppIfNecessary.call(app_id) % 256 != 0 end |
Instance Method Details
- (true, false) clear_achievement(name)
Sets an achievement as locked.
272 273 274 275 276 277 278 279 |
# File 'steam_user_stats_lite.rb', line 272 def clear_achievement(name) if initted? ok = @@dll_SteamAPI_ISteamUserStats_ClearAchievement.call(@i_user_stats, name) % 256 != 0 @@dll_SteamAPI_ISteamUserStats_StoreStats.call(@i_user_stats) % 256 != 0 && ok else false end end |
- (true, ...) get_achievement(name)
Gets an achievement's state.
241 242 243 244 245 246 247 248 249 |
# File 'steam_user_stats_lite.rb', line 241 def get_achievement(name) if initted? val = ' ' ok = @@dll_SteamAPI_ISteamUserStats_GetAchievement.call(@i_user_stats, name, val) % 256 != 0 ok ? val.unpack('C')[0] != 0 : nil else nil end end |
- (<Object, Time>) get_achievement_and_unlock_time(name)
Gets an achievement's state and unlock time.
285 286 287 288 289 290 291 292 293 294 |
# File 'steam_user_stats_lite.rb', line 285 def get_achievement_and_unlock_time(name) if initted? achieved = ' ' unlock_time = ' ' * 4 ok = @@dll_SteamAPI_ISteamUserStats_GetAchievementAndUnlockTime.call(@i_user_stats, name, achieved, unlock_time) % 256 != 0 ok ? [achieved.unpack('C')[0] != 0, Time.at(unlock_time.unpack('L')[0])] : nil else nil end end |
- (String) get_achievement_display_attribute(name, key)
Gets the value of an achievement's display attribute.
301 302 303 304 305 306 307 |
# File 'steam_user_stats_lite.rb', line 301 def get_achievement_display_attribute(name, key) if initted? @@dll_SteamAPI_ISteamUserStats_GetAchievementDisplayAttribute.call @i_user_stats, name, key else nil end end |
- (String) get_achievement_name(achievement)
Gets the name of an achievement by its index.
324 325 326 327 328 329 330 |
# File 'steam_user_stats_lite.rb', line 324 def get_achievement_name(achievement) if initted? @@dll_SteamAPI_ISteamUserStats_GetAchievementName.call @i_user_stats, achievement else nil end end |
- (Integer?) get_num_achievements
Gets the number of achievements.
312 313 314 315 316 317 318 |
# File 'steam_user_stats_lite.rb', line 312 def get_num_achievements if initted? @@dll_SteamAPI_ISteamUserStats_GetNumAchievements.call @i_user_stats else nil end end |
- (Float?) get_stat_float(name)
Gets the value of an FLOAT stat.
189 190 191 192 193 194 195 196 197 |
# File 'steam_user_stats_lite.rb', line 189 def get_stat_float(name) if initted? val = ' ' * 4 ok = @@dll_SteamAPI_ISteamUserStats_GetStat0.call(@i_user_stats, name, val) % 256 != 0 ok ? val.unpack('f')[0] : nil else nil end end |
- (Integer?) get_stat_int(name)
Gets the value of an INT stat.
175 176 177 178 179 180 181 182 183 |
# File 'steam_user_stats_lite.rb', line 175 def get_stat_int(name) if initted? val = ' ' * 4 ok = @@dll_SteamAPI_ISteamUserStats_GetStat.call(@i_user_stats, name, val) % 256 != 0 ok ? val.unpack('I')[0] : nil else nil end end |
- (true, false) initted?
Checks if Steamworks is initialized.
118 119 120 |
# File 'steam_user_stats_lite.rb', line 118 def initted? @initted end |
- (true, ...) is_dlc_installed(app_id)
Checks if a DLC is installed.
152 153 154 155 156 157 158 |
# File 'steam_user_stats_lite.rb', line 152 def is_dlc_installed(app_id) if initted? @@dll_SteamAPI_ISteamApps_BIsDlcInstalled.call(@i_apps, app_id) % 256 != 0 else nil end end |
- (true, ...) is_subscribed
Checks if current app is owned.
140 141 142 143 144 145 146 |
# File 'steam_user_stats_lite.rb', line 140 def is_subscribed if initted? @@dll_SteamAPI_ISteamApps_BIsSubscribed.call(@i_apps) % 256 != 0 else nil end end |
- (true, false) request_current_stats
Pulls current user's stats from Steam.
163 164 165 166 167 168 169 |
# File 'steam_user_stats_lite.rb', line 163 def request_current_stats if initted? @@dll_SteamAPI_ISteamUserStats_RequestCurrentStats.call(@i_user_stats) % 256 != 0 else false end end |
- (true, false) reset_all_stats(achievements_too)
Resets all stats.
336 337 338 339 340 341 342 343 |
# File 'steam_user_stats_lite.rb', line 336 def reset_all_stats(achievements_too) if initted? ok = @@dll_SteamAPI_ISteamUserStats_ResetAllStats.call(@i_user_stats, achievements_too ? 1 : 0) % 256 != 0 @@dll_SteamAPI_ISteamUserStats_StoreStats.call(@i_user_stats) % 256 != 0 && ok else false end end |
- (true, false) set_achievement(name)
Sets an achievement as unlocked.
259 260 261 262 263 264 265 266 |
# File 'steam_user_stats_lite.rb', line 259 def set_achievement(name) if initted? ok = @@dll_SteamAPI_ISteamUserStats_SetAchievement.call(@i_user_stats, name) % 256 != 0 @@dll_SteamAPI_ISteamUserStats_StoreStats.call(@i_user_stats) % 256 != 0 && ok else false end end |
- (true, false) set_stat(name, val)
Sets the value of a stat.
208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'steam_user_stats_lite.rb', line 208 def set_stat(name, val) if initted? if val.is_a? Float ok = @@dll_SteamAPI_ISteamUserStats_SetStat0.call(@i_user_stats, name, self.class.pack_float(val)) % 256 != 0 else ok = @@dll_SteamAPI_ISteamUserStats_SetStat.call(@i_user_stats, name, val.to_i) % 256 != 0 end @@dll_SteamAPI_ISteamUserStats_StoreStats.call(@i_user_stats) % 256 != 0 && ok else false end end |
- (void) shutdown
This method returns an undefined value.
Shuts down Steamworks.
106 107 108 109 110 111 112 113 |
# File 'steam_user_stats_lite.rb', line 106 def shutdown if @initted @i_apps = nil @i_user_stats = nil @@dll_SteamAPI_Shutdown.call @initted = false end end |
- (void) update
This method returns an undefined value.
Runs Steam callbacks.
133 134 135 |
# File 'steam_user_stats_lite.rb', line 133 def update @@dll_SteamAPI_RunCallbacks.call if initted? end |
- (true, false) update_avg_rate_stat(name, count_this_session, session_length)
Updates an AVGRATE stat.
227 228 229 230 231 232 233 234 235 |
# File 'steam_user_stats_lite.rb', line 227 def update_avg_rate_stat(name, count_this_session, session_length) if initted? packed = self.class.pack_double session_length ok = @@dll_SteamAPI_ISteamUserStats_UpdateAvgRateStat.call(@i_user_stats, name, self.class.pack_float(count_this_session.to_f), packed[0], packed[1]) % 256 != 0 @@dll_SteamAPI_ISteamUserStats_StoreStats.call(@i_user_stats) % 256 != 0 && ok else false end end |