Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
ThorConzales committed Sep 5, 2017
1 parent 31a7b42 commit c933822
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 25 deletions.
3 changes: 3 additions & 0 deletions Client/Client/Client.csproj
Expand Up @@ -40,6 +40,7 @@
<Content Include="src\app\reputations\reputations-page\reputations-page.component.html" /> <Content Include="src\app\reputations\reputations-page\reputations-page.component.html" />
<Content Include="src\app\reputations\save-reputation-dialog\save-reputation-dialog.component.html" /> <Content Include="src\app\reputations\save-reputation-dialog\save-reputation-dialog.component.html" />
<Content Include="src\app\settings\general-page\general-page.component.html" /> <Content Include="src\app\settings\general-page\general-page.component.html" />
<Content Include="src\app\settings\overlay-page\overlay-page.component.html" />
<Content Include="src\app\settings\settings-page\settings-page.component.html" /> <Content Include="src\app\settings\settings-page\settings-page.component.html" />
<Content Include="src\app\shared\assign-reputation-dialog\assign-reputation-dialog.component.html" /> <Content Include="src\app\shared\assign-reputation-dialog\assign-reputation-dialog.component.html" />
<Content Include="src\app\shared\confirmation-dialog\confirmation-dialog.component.html" /> <Content Include="src\app\shared\confirmation-dialog\confirmation-dialog.component.html" />
Expand Down Expand Up @@ -101,6 +102,8 @@
<TypeScriptCompile Include="src\app\settings\general-page\general-page.component.ts" /> <TypeScriptCompile Include="src\app\settings\general-page\general-page.component.ts" />
<TypeScriptCompile Include="src\app\settings\general-page\index.ts" /> <TypeScriptCompile Include="src\app\settings\general-page\index.ts" />
<TypeScriptCompile Include="src\app\settings\index.ts" /> <TypeScriptCompile Include="src\app\settings\index.ts" />
<TypeScriptCompile Include="src\app\settings\overlay-page\index.ts" />
<TypeScriptCompile Include="src\app\settings\overlay-page\overlay-page.component.ts" />
<TypeScriptCompile Include="src\app\settings\settings-page\index.ts" /> <TypeScriptCompile Include="src\app\settings\settings-page\index.ts" />
<TypeScriptCompile Include="src\app\settings\settings-page\settings-page.component.ts" /> <TypeScriptCompile Include="src\app\settings\settings-page\settings-page.component.ts" />
<TypeScriptCompile Include="src\app\settings\settings.module.ts" /> <TypeScriptCompile Include="src\app\settings\settings.module.ts" />
Expand Down
4 changes: 4 additions & 0 deletions Client/Client/src/app/app.models.ts
Expand Up @@ -35,6 +35,10 @@ export interface Configuration {
tosAccepted: boolean; tosAccepted: boolean;
skipSessionHelp: boolean; skipSessionHelp: boolean;
cmdPath: string; cmdPath: string;
overlayActiveTopPosition: number;
overlayActiveLeftPosition: number;
overlayInactiveTopPosition: number;
overlayInactiveLeftPosition: number;
} }


export interface BasePlayer { export interface BasePlayer {
Expand Down
@@ -1,13 +1,10 @@
<center-spinner *ngIf="loading"></center-spinner> <center-spinner *ngIf="loading"></center-spinner>
<div *ngIf="!loading" style="padding: 10px;"> <div *ngIf="!loading" style="padding: 10px;">
<md-slide-toggle style="display: block;" color="primary" [checked]="conf.showOverlay" [(ngModel)]="conf.showOverlay">Show overlay</md-slide-toggle> <md-input-container style="width: 100%;">
<md-slide-toggle style="display: block; margin-top: 10px;" color="primary" [checked]="conf.showOverlayWhenFocused" [(ngModel)]="conf.showOverlayWhenFocused">Show overlay only when the game is focused</md-slide-toggle> <input mdInput placeholder="Steam API Key" [value]="conf.steamApiKey" [(ngModel)]="conf.steamApiKey"/>
<md-slide-toggle style="display: block; margin-top: 10px;" color="primary" [checked]="conf.showOverlayWhenInLobby" [(ngModel)]="conf.showOverlayWhenInLobby">Show overlay only when you are in lobby (<strong>you must start the session before joining or hosting a lobby, otherwhise overlay won't be shown</strong>)</md-slide-toggle>
<md-input-container style="width: 100%; margin-top: 20px;">
<input mdInput placeholder="Steam API Key" [value]="conf.steamApiKey" [(ngModel)]="conf.steamApiKey" />
</md-input-container> </md-input-container>
<md-input-container style="width: 100%;"> <md-input-container style="width: 100%;">
<input mdInput placeholder="CMD Path" [value]="conf.cmdPath" [(ngModel)]="conf.cmdPath" /> <input mdInput placeholder="CMD Path" [value]="conf.cmdPath" [(ngModel)]="conf.cmdPath"/>
</md-input-container> </md-input-container>
<div style="text-align: center;"> <div style="text-align: center;">
<button md-raised-button class="primaryButton" (click)="save()">Save</button> <button md-raised-button class="primaryButton" (click)="save()">Save</button>
Expand Down
Expand Up @@ -36,7 +36,7 @@ export class GeneralPageComponent implements OnInit {
}, error => { }, error => {
this.loading = false; this.loading = false;
console.error("Failed to save settings", error); console.error("Failed to save settings", error);
this.appService.toastError("Failed to save settings."); this.appService.toastError("Failed to save settings, check the logs.");
}); });
} }
} }
1 change: 1 addition & 0 deletions Client/Client/src/app/settings/overlay-page/index.ts
@@ -0,0 +1 @@
export * from './overlay-page.component';
@@ -0,0 +1,28 @@
<center-spinner *ngIf="loading"></center-spinner>
<div *ngIf="!loading" style="padding: 10px;">
<md-slide-toggle style="display: block;" color="primary" [checked]="conf.showOverlay" [(ngModel)]="conf.showOverlay">Show overlay</md-slide-toggle>
<md-slide-toggle style="display: block; margin-top: 10px;" color="primary" [checked]="conf.showOverlayWhenFocused" [(ngModel)]="conf.showOverlayWhenFocused">Show overlay only when the game is focused</md-slide-toggle>
<md-slide-toggle style="display: block; margin-top: 10px;" color="primary" [checked]="conf.showOverlayWhenInLobby" [(ngModel)]="conf.showOverlayWhenInLobby">Show overlay only when you are in lobby (<strong>you must start the session before joining or hosting a lobby, otherwhise overlay won't be shown</strong>)</md-slide-toggle>
<div style="font-size: 20px; margin-top: 10px; margin-bottom: 5px;">Overlay Position</div>
<div style="display: inline-block; width: 200px;">
<div style="font-size: 16px; margin-bottom: 5px;">When game is active</div>
<md-input-container style="display: inline-block; width: 50px;">
<input mdInput="number" placeholder="Top" [value]="overlayActiveTopPosition" [(ngModel)]="overlayActiveTopPosition">
</md-input-container>
<md-input-container style="display: inline-block; width: 50px;">
<input mdInput="number" placeholder="Left" [value]="overlayActiveLeftPosition" [(ngModel)]="overlayActiveLeftPosition">
</md-input-container>
</div>
<div style="display: inline-block; width: 200px;">
<div style="font-size: 16px; margin-bottom: 5px;">When game is inactive</div>
<md-input-container style="display: inline-block; width: 50px;">
<input mdInput="number" placeholder="Top" [value]="overlayInactiveTopPosition" [(ngModel)]="overlayInactiveTopPosition">
</md-input-container>
<md-input-container style="display: inline-block; width: 50px;">
<input mdInput="number" placeholder="Left" [value]="overlayInactiveLeftPosition" [(ngModel)]="overlayInactiveLeftPosition">
</md-input-container>
</div>
<div style="text-align: center;">
<button md-raised-button class="primaryButton" (click)="save()">Save</button>
</div>
</div>
@@ -0,0 +1,46 @@
import { Component, OnInit } from '@angular/core';

import { Configuration } from '../../app.models';
import { ConfigurationService, AppService, TrackingService } from '../../shared';

@Component({
selector: 'overlay-page',
templateUrl: 'overlay-page.component.html'
})
export class OverlayPageComponent implements OnInit {
public loading = false;
public conf: Configuration;
public overlayActiveTopPosition: number;
public overlayActiveLeftPosition: number;
public overlayInactiveTopPosition: number;
public overlayInactiveLeftPosition: number;

constructor(private configurationService: ConfigurationService, private appService: AppService, private trackingService: TrackingService) {
}

public ngOnInit() {
this.readConfiguration();
}

private readConfiguration() {
this.loading = true;
this.configurationService.getConfiguration(() => {
this.conf = this.configurationService.configuration;
this.loading = false;
});
}

public save() {
this.loading = true;
this.configurationService.configuration = this.conf;
this.configurationService.saveConfiguration().subscribe(() => {
this.appService.toastSuccess("Settings saved.");
this.readConfiguration();
this.trackingService.sendEvent("Settings", "OverlaySettingsSaved");
}, error => {
this.loading = false;
console.error("Failed to save settings", error);
this.appService.toastError("Failed to save settings, check the logs.");
});
}
}
@@ -1 +1,4 @@
<general-page></general-page> <md-tab-group>
<md-tab label="Overlay"><overlay-page></overlay-page></md-tab>
<md-tab label="General"><general-page></general-page></md-tab>
</md-tab-group>
7 changes: 4 additions & 3 deletions Client/Client/src/app/settings/settings.module.ts
@@ -1,16 +1,17 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { MdButtonModule, MdInputModule, MdSlideToggleModule } from '@angular/material'; import { MdButtonModule, MdInputModule, MdSlideToggleModule, MdTabsModule } from '@angular/material';


import { CenterSpinnerModule } from '../shared' import { CenterSpinnerModule } from '../shared'
import { SettingsPageComponent } from './settings-page'; import { SettingsPageComponent } from './settings-page';
import { GeneralPageComponent } from './general-page'; import { GeneralPageComponent } from './general-page';
import { OverlayPageComponent } from './overlay-page';


@NgModule({ @NgModule({
imports: [BrowserModule, FormsModule, MdButtonModule, MdInputModule, MdSlideToggleModule, CenterSpinnerModule], imports: [BrowserModule, FormsModule, MdButtonModule, MdInputModule, MdSlideToggleModule, MdTabsModule, CenterSpinnerModule],
exports: [SettingsPageComponent], exports: [SettingsPageComponent],
declarations: [SettingsPageComponent, GeneralPageComponent], declarations: [SettingsPageComponent, GeneralPageComponent, OverlayPageComponent],
entryComponents: [] entryComponents: []
}) })
export class SettingsModule { } export class SettingsModule { }
18 changes: 9 additions & 9 deletions Client/Client/src/app/shared/app.service.ts
Expand Up @@ -19,15 +19,15 @@ export class AppService {
} }


constructor(private toastsManager: ToastsManager, private trackingService: TrackingService, private configurationService: ConfigurationService) { constructor(private toastsManager: ToastsManager, private trackingService: TrackingService, private configurationService: ConfigurationService) {
this.startBackend(); //this.startBackend();
window.onbeforeunload = (e) => { //window.onbeforeunload = (e) => {
if (this.nethookActive) { // if (this.nethookActive) {
this.stopNethook(() => { }); // this.stopNethook(() => { });
} // }
if (this.backendProcess) { // if (this.backendProcess) {
this.backendProcess.kill(); // this.backendProcess.kill();
} // }
} //}
} }


public toastInfo(message: string) { public toastInfo(message: string) {
Expand Down
3 changes: 0 additions & 3 deletions Client/Client/src/app/shared/configuration.service.ts
Expand Up @@ -15,9 +15,6 @@ export class ConfigurationService {
this.configuration = configuration; this.configuration = configuration;
done(true); done(true);
}, error => { }, error => {
//this.configuration = {
// clientVersion: 0
//};
console.log("Error while reading configuration", error); console.log("Error while reading configuration", error);
done(false); done(false);
}); });
Expand Down
4 changes: 4 additions & 0 deletions Commons/Models/Configuration.cs
Expand Up @@ -14,5 +14,9 @@ public class Configuration {
public bool TosAccepted { get; set; } public bool TosAccepted { get; set; }
public bool SkipSessionHelp { get; set; } public bool SkipSessionHelp { get; set; }
public string CmdPath { get; set; } public string CmdPath { get; set; }
public int OverlayActiveTopPosition { get; set; }
public int OverlayActiveLeftPosition { get; set; }
public int OverlayInactiveTopPosition { get; set; }
public int OverlayInactiveLeftPosition { get; set; }
} }
} }
2 changes: 1 addition & 1 deletion Overlay/MainWindow.xaml
Expand Up @@ -11,7 +11,7 @@
Visibility="Hidden" Visibility="Hidden"
Top="0" Top="0"
Left="0" Left="0"
Title="MainWindow" Height="200" Width="715.96"> Title="MainWindow" Height="200" Width="716">
<Window.Background> <Window.Background>
<SolidColorBrush Opacity="0.5" Color="Black" /> <SolidColorBrush Opacity="0.5" Color="Black" />
</Window.Background> </Window.Background>
Expand Down

0 comments on commit c933822

Please sign in to comment.