Skip to content

Commit

Permalink
Merge branch 'develop' into steam-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphiiko committed Dec 17, 2023
2 parents a8eb813 + 0f44a5d commit 7248041
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Detection for initialization failures and error handling.
- Basic support for OSCQuery
- Status information view to the settings, for showing technical information regarding OyasumiVR and some of its internals.
- Automation for running a OSC script whenever the user prepares to go to sleep.

### Changed

Expand Down
1 change: 1 addition & 0 deletions src-ui/app/models/automations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export interface TurnOffLighthousesOnSteamVRStopAutomationConfig extends Automat
export interface OscGeneralAutomationConfig extends AutomationConfig {
onSleepModeEnable?: OscScript;
onSleepModeDisable?: OscScript;
onSleepPreparation?: OscScript;
}

export interface SleepingAnimationsAutomationConfig extends AutomationConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { distinctUntilChanged, map, skip } from 'rxjs';
import { OscGeneralAutomationConfig } from '../../models/automations';
import { SleepService } from '../sleep.service';
import { OscService } from '../osc.service';
import { SleepPreparationService } from '../sleep-preparation.service';

@Injectable({
providedIn: 'root',
Expand All @@ -14,7 +15,8 @@ export class OscGeneralAutomationsService {
constructor(
private automationConfigService: AutomationConfigService,
private sleepService: SleepService,
private osc: OscService
private osc: OscService,
private sleepPreparation: SleepPreparationService
) {}

async init() {
Expand All @@ -24,6 +26,7 @@ export class OscGeneralAutomationsService {
this.sleepService.mode
.pipe(distinctUntilChanged(), skip(1))
.subscribe((sleepMode) => this.onSleepModeChange(sleepMode));
this.sleepPreparation.onSleepPreparation.subscribe(() => this.onSleepPreparation());
}

private onSleepModeChange(sleepMode: boolean) {
Expand All @@ -34,4 +37,10 @@ export class OscGeneralAutomationsService {
this.osc.queueScript(this.config.onSleepModeDisable, 'OSC_GENERAL_ON_SLEEP_MODE_DISABLE');
}
}

private onSleepPreparation() {
if (this.config?.onSleepPreparation) {
this.osc.queueScript(this.config.onSleepPreparation, 'OSC_GENERAL_ON_SLEEP_PREPARATION');
}
}
}
1 change: 1 addition & 0 deletions src-ui/app/services/sleep-preparation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class SleepPreparationService {
public readonly sleepPreparationAvailable = this.automationConfigService.configs.pipe(
map((configs) =>
[
(configs.OSC_GENERAL.onSleepPreparation?.commands.length ?? 0) > 0,
configs.SET_BRIGHTNESS_ON_SLEEP_PREPARATION.enabled,
configs.SYSTEM_MIC_MUTE_AUTOMATIONS.onSleepPreparationState !== 'NONE',
configs.SYSTEM_MIC_MUTE_AUTOMATIONS.controllerBinding &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@
></app-osc-script-button>
</div>
</div>
<div class="setting-row">
<div class="setting-row-label" translate>
<span translate>oscAutomations.general.onSleepPreparation.title</span>
<span translate>oscAutomations.general.onSleepPreparation.description</span>
</div>
<div class="setting-row-action">
<app-osc-script-button
[label]="'oscAutomations.general.onSleepPreparation.script'"
[script]="config.onSleepPreparation"
(scriptChange)="setOscScript('onSleepPreparation', $event)"
></app-osc-script-button>
</div>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class OscAutomationsViewComponent implements OnInit {
}

async setOscScript(
event: 'onSleepModeEnable' | 'onSleepModeDisable',
event: 'onSleepModeEnable' | 'onSleepModeDisable' | 'onSleepPreparation',
script: OscScript | undefined
) {
await this.automationConfigService.updateAutomationConfig<OscGeneralAutomationConfig>(
Expand Down
5 changes: 5 additions & 0 deletions src-ui/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,11 @@
"description": "Send these OSC commands",
"script": "Sleep Mode Enabled",
"title": "When I go to sleep"
},
"onSleepPreparation": {
"description": "Send these OSC commands",
"script": "Sleep Preparation",
"title": "When I prepare to go to sleep"
}
},
"sleepingAnimations": {
Expand Down

0 comments on commit 7248041

Please sign in to comment.