-
Notifications
You must be signed in to change notification settings - Fork 22
Add panorama version of autosave indicator #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
vrad-exe
wants to merge
3
commits into
StrataSource:main
Choose a base branch
from
vrad-exe:feat/save-indicator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+132
−3
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or 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 hidden or 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,22 @@ | ||
| <root> | ||
| <styles> | ||
| <include src="file://{resources}/styles/main.scss" /> | ||
| <include src="file://{resources}/styles/hud/save-indicator.scss" /> | ||
| </styles> | ||
| <scripts> | ||
| <include src="file://{scripts}/common/dev.ts" /> | ||
| <include src="file://{scripts}/hud/save-indicator.ts" /> | ||
| </scripts> | ||
|
|
||
| <Panel class="save-indicator"> | ||
| <AnimatedImageStrip | ||
| id="Spinner" | ||
| animating="true" | ||
| defaultframe="0" | ||
| frametime="100ms" | ||
| src="file://{images}/hud/spinner_saving_strip.tga" | ||
| scaling="stretch-to-cover-preserve-aspect" | ||
| /> | ||
| <Label class="save-indicator__label" id="StatusLabel" text="#PORTAL2_Hud_GameSaved" /> | ||
| </Panel> | ||
| </root> | ||
This file contains hidden or 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 hidden or 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 hidden or 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,62 @@ | ||
| 'use strict'; | ||
|
|
||
| class SaveIndicator { | ||
| static fadeTimer: uuid | undefined = undefined; | ||
| static isAutoSave: boolean = false; | ||
|
|
||
| static { | ||
| $.RegisterForUnhandledEvent('GameSaved', this.onSaveStarted.bind(this)); | ||
| $.RegisterForUnhandledEvent('LayoutReloaded', this.hide.bind(this)); | ||
| $.RegisterForUnhandledEvent('LevelInitPostEntity', this.hide.bind(this)); | ||
|
|
||
| // Workaround for animation sometimes getting stuck when pausing/unpausing | ||
| $.RegisterForUnhandledEvent('GameUIStateChanged', (old: GameUIState, now: GameUIState) => { | ||
| if (now === GameUIState.INGAME) { | ||
| $<AnimatedImageStrip>('#Spinner')!.SetReadyForDisplay(false); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| static onSaveStarted(save_name: string, save_type: SaveType) { | ||
| if (!GameInterfaceAPI.GetSettingBool("save_hud")) return; | ||
|
|
||
| if (save_type == SaveType.Autosave) { | ||
| if (!GameInterfaceAPI.GetSettingBool("save_hud_autosave")) return; | ||
| this.isAutoSave = true; | ||
| } else { | ||
| this.isAutoSave = false; | ||
| } | ||
|
|
||
| const label = $<Label>('#StatusLabel'); | ||
| label?.SetLocalizationString(this.isAutoSave ? "#PORTAL2_Hud_AutoSavingGame" : "#PORTAL2_Hud_SavingGame"); | ||
|
|
||
| this.show(); | ||
| this.fadeOutTimer(); | ||
|
|
||
| } | ||
|
|
||
| static show() { | ||
| $.GetContextPanel().style.animation = 'FadeIn 0.01s ease-out 0s 1 normal forwards'; | ||
| } | ||
|
|
||
| static hide() { | ||
| $.GetContextPanel().style.animation = 'FadeOut 0.01s ease-out 0s 1 normal forwards'; | ||
| const kfs = $.GetContextPanel().CreateCopyOfCSSKeyframes('FadeOut'); | ||
| $.GetContextPanel().UpdateCurrentAnimationKeyframes(kfs); | ||
| } | ||
|
|
||
| static fadeOutTimer() { | ||
| if (this.fadeTimer !== undefined) $.CancelScheduled(this.fadeTimer); | ||
| // TODO: Remove hardcoded delay, fadeout should start after the save finishes | ||
| this.fadeTimer = $.Schedule(1, () => { | ||
| // Update the text label to say "saved" | ||
| const label = $<Label>('#StatusLabel'); | ||
| label?.SetLocalizationString(this.isAutoSave ? "#PORTAL2_Hud_GameAutoSaved" : "#PORTAL2_Hud_GameSaved"); | ||
|
|
||
| $.GetContextPanel().style.animation = 'FadeOut 1s ease-out 0s 1 normal forwards'; | ||
| const kfs = $.GetContextPanel().CreateCopyOfCSSKeyframes('FadeOut'); | ||
| $.GetContextPanel().UpdateCurrentAnimationKeyframes(kfs); | ||
| this.fadeTimer = undefined; | ||
| }); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,29 @@ | ||
| @use '../config' as *; | ||
|
|
||
| .save-indicator { | ||
| margin: 22px; | ||
| flow-children: right; | ||
| height: 90px; | ||
| width: fit-children; | ||
|
|
||
| &__label { | ||
| color: $bright-color; | ||
| font-size: 30px; | ||
|
|
||
| // Alternate style that matches Portal 2 | ||
| // color: #dddddd; | ||
| // font-family: 'Univers LT Std 57 Cn'; | ||
| // font-size: 34px; | ||
|
|
||
| vertical-align: center; | ||
| margin-left: 12px; | ||
| } | ||
|
|
||
| & > AnimatedImageStrip { | ||
| width:height-percentage(100%); | ||
| height: 100%; | ||
| } | ||
|
|
||
| // Temporary to prevent overlapping with VGUI version!!! Remove this!!! | ||
| margin-top: 120px; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something to note, we have an internally registered Save Indicator panel already from Revolution. I actually didn't know this and found it on accident when pulling up the other save files in the codebase. It's called
HudSaveIndicator.So you can drop the custom panel registration, and then change where you reference
SaveIndicatortoHudSaveIndicator: