forked from IsThereAnyDeal/AugmentedSteam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
96 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<script lang="ts" context="module"> | ||
// @ts-ignore | ||
import self_ from "./FAchievementBar.svelte"; | ||
import {SyncedStorage} from "../../../../modulesCore"; | ||
import {Feature, RequestData, User} from "../../../modulesContent"; | ||
import type {CApp} from "./CApp"; | ||
export class FAchievementBar extends Feature<CApp> { | ||
override checkPrerequisites(): boolean { | ||
return SyncedStorage.get("showachinstore") | ||
&& this.context.hasAchievements | ||
&& this.context.isOwnedAndPlayed; | ||
} | ||
override async apply(): Promise<void> { | ||
let response; | ||
try { | ||
const token = await User.accessToken; | ||
response = await RequestData.post( | ||
`https://api.steampowered.com/IPlayerService/GetAchievementsProgress/v1/?access_token=${token}`, | ||
{"steamid": User.steamId, "appids[0]": this.context.communityAppid}, | ||
{"credentials": "omit"} | ||
); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
response = response?.response?.achievement_progress?.[0]; | ||
if (!response) { | ||
console.warn("Failed to retrieve achievement stats"); | ||
return; | ||
} | ||
/** | ||
* If you don't own the game, all values will be 0, | ||
* just as if you own the game but have no achievements, | ||
* so it's important to check for ownership `this.context.isOwnedAndPlayed`. | ||
*/ | ||
const {unlocked, total, percentage} = response; | ||
const target = document.querySelector("#my_activity")!; | ||
(new self_({ | ||
target, | ||
anchor: target.firstElementChild, | ||
props: { | ||
unlocked, | ||
total, | ||
percentage: Math.round(percentage) | ||
} | ||
})); | ||
} | ||
} | ||
</script> | ||
|
||
<script lang="ts"> | ||
import {Localization} from "../../../../modulesCore"; | ||
export let unlocked: number | ||
export let total: number; | ||
export let percentage: number; | ||
let achievementStr = Localization.str.achievements.summary | ||
.replace("__unlocked__", unlocked) | ||
.replace("__total__", total) | ||
.replace("__percentage__", percentage); | ||
</script> | ||
|
||
|
||
<div class="es-achieveBar-store"> | ||
<div>{achievementStr}</div> | ||
<div class="achieveBar"> | ||
<div style="width: {percentage}%;" class="achieveBarProgress"></div> | ||
</div> | ||
</div> | ||
|
||
|
||
<style> | ||
.es-achieveBar-store { | ||
float: right; | ||
} | ||
.es-achieveBar-store .achieveBar { | ||
background: #3a3a3a; | ||
padding: 1px; | ||
border: 1px solid #aeaeae; | ||
width: 176.9px; | ||
} | ||
.es-achieveBar-store .achieveBarProgress { | ||
height: 8px; | ||
background-color: #aeaeae; | ||
} | ||
</style> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters