Skip to content

Commit

Permalink
Make mapping dump actually work
Browse files Browse the repository at this point in the history
  • Loading branch information
suchmememanyskill committed Sep 24, 2024
1 parent a2a3f9a commit c84d1fd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
25 changes: 11 additions & 14 deletions css_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def store_path() -> str:
return os.path.join(get_theme_path(), "STORE")

def get_mappings_folder_path() -> str:
path = os.path.join(get_theme_path(), "__mappings")
path = os.path.join(get_theme_path(), "__mappings")

if not os.path.exists(path):
create_dir(path)
Expand Down Expand Up @@ -166,18 +166,6 @@ def store_write(key : str, val : str):
with open(path, 'w') as fp:
fp.write("\n".join([f"{x}:{items[x]}" for x in items]))

def save_mappings(val: str, version: str):
is_beta = is_steam_beta_active()
branch_str = "beta" if is_beta else "stable"
path = get_mappings_folder_path()

if not os.exists(path):
create_dir(path)

file_location = os.path.join(path, f"{version}.{branch_str}.json")
with open(file_location, 'w') as fp:
fp.write(val)

def get_steam_version() -> None|str:
path = os.path.join(get_steam_path(), "logs", "console_log.txt")

Expand All @@ -192,4 +180,13 @@ def get_steam_version() -> None|str:
if version != None and len(version) > 0:
return version

return None
return None

def save_mappings(val: str):
is_beta = is_steam_beta_active()
branch_str = "beta" if is_beta else "stable"
path = get_mappings_folder_path()

file_location = os.path.join(path, f"{get_steam_version()}.{branch_str}.json")
with open(file_location, 'w', encoding="utf-8") as fp:
fp.write(val)
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ async def store_write(self, key : str, val : str) -> dict:
util_store_write(key, val)
return Result(True).to_dict()

async def save_mappings(self, val: str, version: str) -> dict:
util_save_mappings(val, version)
async def save_mappings(self, val: str) -> dict:
util_save_mappings(val)
return Result(True).to_dict()

async def get_webpack_mappigns(self) -> dict:
Expand Down
5 changes: 1 addition & 4 deletions src/deckyPatches/dump-mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ export async function dumpMappings() {
if (!map) return;
const jsonStr = JSON.stringify(Object.fromEntries(map));

const steamInfo = await SteamClient.System.GetSystemInfo();
const version = String(steamInfo.nSteamVersion);

await saveMappings(jsonStr, version);
await saveMappings(jsonStr);
} catch (error) {
console.error("ERROR SAVING MAPPINGS", error);
}
Expand Down
4 changes: 2 additions & 2 deletions src/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,6 @@ export function generatePresetFromThemeNames(name: string, themeNames: string[])
});
}

export function saveMappings(val: string, version: string) {
return server!.callPluginMethod("save_mappings", { val: val, version: version });
export function saveMappings(val: string) {
return server!.callPluginMethod("save_mappings", { val: val });
}

0 comments on commit c84d1fd

Please sign in to comment.