Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ paginated_achievements_icons=10
# the emu will also resume recording playtime when the game is relaunched
# default=0
record_playtime=0
# 1=enable fetching and writing global achievement percentages at game start
# this will create a file named "achievements.json.glb" with global unlock percentages for each achievement
# default=1
enable_global_achievement_percentages=1
# interval in hours to update global achievement percentages
# 0=only update at game start
# any positive value=update at start and then every N hours during gameplay
# default=0
global_achievement_percentages_update_interval_hours=0

[main::connectivity]
# 1=prevent hooking OS networking APIs and allow any external requests
Expand Down
44 changes: 44 additions & 0 deletions generate_emu_config_old/generate_emu_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,23 @@ def get_stats_schema(client, game_id, owner_id):
client.send(message)
return client.wait_msg(EMsg.ClientGetUserStatsResponse, timeout=5)

def get_global_achievement_percentages(game_id):
"""Get global achievement percentages from Steam Web API"""
try:
# Using Steam Web API to get global achievement percentages
url = f"https://api.steampowered.com/ISteamUserStats/GetGlobalAchievementPercentagesForApp/v2/?gameid={game_id}"
response = requests.get(url, timeout=10)
if response.status_code == 200:
data = response.json()
if 'achievementpercentages' in data and 'achievements' in data['achievementpercentages']:
percentages = {}
for ach in data['achievementpercentages']['achievements']:
percentages[ach['name']] = ach['percent']
return percentages
except Exception as e:
print(f"[?] Error fetching global achievement percentages: {e}")
return None

def download_achievement_images(game_id : int, image_names : set[str], output_folder : str):
print(f"[ ] Found {len(image_names)} achievements images --- downloading to <OUT_DIR>\\steam_settings\\img folder")

Expand Down Expand Up @@ -439,6 +456,33 @@ def generate_achievement_stats(client, game_id : int, output_directory, backup_d
shutil.copy(os.path.join(get_exe_dir(), "steam_default_icon_locked.jpg"), achievement_images_dir)
download_achievement_images(game_id, images_to_download, achievement_images_dir)

# Fetch and save global achievement percentages
if achievements:
try:
global_percentages = get_global_achievement_percentages(game_id)
if global_percentages:
# Create achievements list with global percentages
achievements_global = []
for ach in achievements:
ach_name = ach.get('name', '')
ach_global = {
'name': ach_name,
'percentage': global_percentages.get(ach_name, 0.0)
}
achievements_global.append(ach_global)

# Write to achievements.json.glb
if achievements_global:
glb_file_path = os.path.join(output_directory, "achievements.json.glb")
with open(glb_file_path, 'wt', encoding='utf-8') as f:
json.dump(achievements_global, f, indent=2)
print(f"[ ] Writing global achievement percentages to <OUT_DIR>\\steam_settings\\achievements.json.glb")
else:
print(f"[?] Could not fetch global achievement percentages from Steam Web API")
except Exception as e:
print(f"[?] Error while processing global achievement percentages: {e}")
# Continue without global percentages - this is not critical

return achievements

def get_ugc_info(client, published_file_id):
Expand Down