Revert codestyle changes (#40)

* Revert "7f7efbb94bab8574e42d942ad82d414e007b2970"

Code style changes should probably be part of a PR
This commit is contained in:
Eliot Partridge
2019-08-30 10:53:14 -05:00
committed by GitHub
parent eefd9e9a2c
commit caf70a864f
446 changed files with 70667 additions and 70655 deletions
@@ -8,77 +8,77 @@ import { ACTIONS_LIMIT } from '../../../common/constants';
import { last } from '../../../common/utils';
@Component({
selector: 'action-bar',
templateUrl: 'action-bar.pug',
styleUrls: ['action-bar.scss'],
selector: 'action-bar',
templateUrl: 'action-bar.pug',
styleUrls: ['action-bar.scss'],
})
export class ActionBar {
@ViewChild('scroller', { static: true }) scroller!: ElementRef;
@Input() blurred = false;
activeAction: ButtonAction | undefined = undefined;
shortcuts = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '='];
private _editable = false;
constructor(private game: PonyTownGame, private settings: SettingsService) {
}
@Input() get editable() {
return this._editable;
}
set editable(value) {
if (this._editable !== value) {
this._editable = value;
this.updateFreeSlots();
@ViewChild('scroller', { static: true }) scroller!: ElementRef;
@Input() blurred = false;
activeAction: ButtonAction | undefined = undefined;
shortcuts = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '='];
private _editable = false;
constructor(private game: PonyTownGame, private settings: SettingsService) {
}
@Input() get editable() {
return this._editable;
}
set editable(value) {
if (this._editable !== value) {
this._editable = value;
this.updateFreeSlots();
if (!value) {
this.save();
}
}
}
get actions() {
return this.game.actions;
}
get mobile() {
return isMobile;
}
get hasScroller() {
return this.editable && isMobile;
}
get blurCount() {
const boxWidth = isMobile ? 50 : 40;
const width = 450 + this.scroller.nativeElement.scrollLeft;
return Math.floor(width / boxWidth);
}
use(action: ButtonAction | undefined) {
useAction(this.game, action);
}
drag(index: number) {
this.actions[index].action = undefined;
this.updateFreeSlots();
}
drop(action: ButtonAction | undefined, index: number) {
this.actions[index].action = action;
this.updateFreeSlots();
}
save() {
const settings = { ...this.settings.account, actions: serializeActions(this.actions) };
this.settings.saveAccountSettings(settings);
}
scroll(e: MouseWheelEvent) {
if (e.deltaY) {
const delta = e.deltaY > 0 ? 1 : -1;
this.scroller.nativeElement.scrollLeft += delta * 20;
}
}
private updateFreeSlots() {
const actions = this.actions;
if (!value) {
this.save();
}
}
}
get actions() {
return this.game.actions;
}
get mobile() {
return isMobile;
}
get hasScroller() {
return this.editable && isMobile;
}
get blurCount() {
const boxWidth = isMobile ? 50 : 40;
const width = 450 + this.scroller.nativeElement.scrollLeft;
return Math.floor(width / boxWidth);
}
use(action: ButtonAction | undefined) {
useAction(this.game, action);
}
drag(index: number) {
this.actions[index].action = undefined;
this.updateFreeSlots();
}
drop(action: ButtonAction | undefined, index: number) {
this.actions[index].action = action;
this.updateFreeSlots();
}
save() {
const settings = { ...this.settings.account, actions: serializeActions(this.actions) };
this.settings.saveAccountSettings(settings);
}
scroll(e: MouseWheelEvent) {
if (e.deltaY) {
const delta = e.deltaY > 0 ? 1 : -1;
this.scroller.nativeElement.scrollLeft += delta * 20;
}
}
private updateFreeSlots() {
const actions = this.actions;
if (this.editable) {
while (actions.length < 5 || (last(actions)!.action !== undefined && actions.length < ACTIONS_LIMIT)) {
actions.push({ action: undefined });
}
} else {
while (actions.length > 0 && last(actions)!.action === undefined) {
actions.pop();
}
}
}
if (this.editable) {
while (actions.length < 5 || (last(actions)!.action !== undefined && actions.length < ACTIONS_LIMIT)) {
actions.push({ action: undefined });
}
} else {
while (actions.length > 0 && last(actions)!.action === undefined) {
actions.pop();
}
}
}
}