mirror of
https://github.com/Terncode/pixel.horse.git
synced 2026-09-25 22:25:53 +02:00
Revert codestyle changes (#40)
* Revert "7f7efbb94bab8574e42d942ad82d414e007b2970" Code style changes should probably be part of a PR
This commit is contained in:
@@ -7,25 +7,25 @@ import { SUPPORTER_REWARDS_LIST } from '../../../common/constants';
|
||||
import { supporterLink, contactEmail } from '../../../client/data';
|
||||
|
||||
function toCredit(credit: Credit) {
|
||||
return {
|
||||
...credit,
|
||||
background: `url(${getUrl('images/avatars.jpg')})`,
|
||||
position: `${(credit.avatarIndex % 4) * -82}px ${Math.floor(credit.avatarIndex / 4) * -82}px`,
|
||||
};
|
||||
return {
|
||||
...credit,
|
||||
background: `url(${getUrl('images/avatars.jpg')})`,
|
||||
position: `${(credit.avatarIndex % 4) * -82}px ${Math.floor(credit.avatarIndex / 4) * -82}px`,
|
||||
};
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'about',
|
||||
templateUrl: 'about.pug',
|
||||
styleUrls: ['about.scss'],
|
||||
selector: 'about',
|
||||
templateUrl: 'about.pug',
|
||||
styleUrls: ['about.scss'],
|
||||
})
|
||||
export class About {
|
||||
readonly title = document.title;
|
||||
readonly emotes = emojis;
|
||||
readonly credits = CREDITS.map(toCredit);
|
||||
readonly contributors = CONTRIBUTORS;
|
||||
readonly changelog = CHANGELOG;
|
||||
readonly rewards = SUPPORTER_REWARDS_LIST;
|
||||
readonly patreonLink = supporterLink;
|
||||
readonly contactEmail = contactEmail;
|
||||
readonly title = document.title;
|
||||
readonly emotes = emojis;
|
||||
readonly credits = CREDITS.map(toCredit);
|
||||
readonly contributors = CONTRIBUTORS;
|
||||
readonly changelog = CHANGELOG;
|
||||
readonly rewards = SUPPORTER_REWARDS_LIST;
|
||||
readonly patreonLink = supporterLink;
|
||||
readonly contactEmail = contactEmail;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { ACCOUNT_NAME_MAX_LENGTH, ACCOUNT_NAME_MIN_LENGTH, HIDES_PER_PAGE } from '../../../common/constants';
|
||||
import { UpdateAccountData, SocialSiteInfo, OAuthProvider, HiddenPlayer } from '../../../common/interfaces';
|
||||
import {
|
||||
toSocialSiteInfo, cleanName, supporterTitle, supporterClass, isSupporterOrPastSupporter, supporterRewards
|
||||
toSocialSiteInfo, cleanName, supporterTitle, supporterClass, isSupporterOrPastSupporter, supporterRewards
|
||||
} from '../../../client/clientUtils';
|
||||
import { oauthProviders } from '../../../client/data';
|
||||
import { Model } from '../../services/model';
|
||||
@@ -10,121 +10,121 @@ import { getProviderIcon } from '../../shared/sign-in-box/sign-in-box';
|
||||
import { faStar, faExclamationCircle, faSync } from '../../../client/icons';
|
||||
|
||||
@Component({
|
||||
selector: 'account',
|
||||
templateUrl: 'account.pug',
|
||||
styleUrls: ['account.scss'],
|
||||
selector: 'account',
|
||||
templateUrl: 'account.pug',
|
||||
styleUrls: ['account.scss'],
|
||||
})
|
||||
export class Account implements OnInit, OnDestroy {
|
||||
readonly refreshIcon = faSync;
|
||||
readonly starIcon = faStar;
|
||||
readonly alertIcon = faExclamationCircle;
|
||||
readonly providers = oauthProviders.filter(p => !p.disabled);
|
||||
readonly nameMinLength = ACCOUNT_NAME_MIN_LENGTH;
|
||||
readonly nameMaxLength = ACCOUNT_NAME_MAX_LENGTH;
|
||||
readonly hidesPerPage = HIDES_PER_PAGE;
|
||||
data: UpdateAccountData = {
|
||||
name: '',
|
||||
birthdate: '',
|
||||
};
|
||||
sites?: SocialSiteInfo[];
|
||||
password?: string;
|
||||
removingSite?: boolean;
|
||||
mergeError?: string;
|
||||
removedAccount?: boolean;
|
||||
accountError?: string;
|
||||
accountSaved = false;
|
||||
hides: HiddenPlayer[] | undefined = undefined;
|
||||
page = 0;
|
||||
constructor(private model: Model) {
|
||||
}
|
||||
ngOnInit() {
|
||||
const account = this.account!;
|
||||
this.sites = account.sites && account.sites.map(toSocialSiteInfo);
|
||||
this.data = {
|
||||
name: account.name,
|
||||
birthdate: account.birthdate,
|
||||
};
|
||||
readonly refreshIcon = faSync;
|
||||
readonly starIcon = faStar;
|
||||
readonly alertIcon = faExclamationCircle;
|
||||
readonly providers = oauthProviders.filter(p => !p.disabled);
|
||||
readonly nameMinLength = ACCOUNT_NAME_MIN_LENGTH;
|
||||
readonly nameMaxLength = ACCOUNT_NAME_MAX_LENGTH;
|
||||
readonly hidesPerPage = HIDES_PER_PAGE;
|
||||
data: UpdateAccountData = {
|
||||
name: '',
|
||||
birthdate: '',
|
||||
};
|
||||
sites?: SocialSiteInfo[];
|
||||
password?: string;
|
||||
removingSite?: boolean;
|
||||
mergeError?: string;
|
||||
removedAccount?: boolean;
|
||||
accountError?: string;
|
||||
accountSaved = false;
|
||||
hides: HiddenPlayer[] | undefined = undefined;
|
||||
page = 0;
|
||||
constructor(private model: Model) {
|
||||
}
|
||||
ngOnInit() {
|
||||
const account = this.account!;
|
||||
this.sites = account.sites && account.sites.map(toSocialSiteInfo);
|
||||
this.data = {
|
||||
name: account.name,
|
||||
birthdate: account.birthdate,
|
||||
};
|
||||
|
||||
this.pageChanged();
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.model.mergedAccount = false;
|
||||
}
|
||||
pageChanged() {
|
||||
this.model.getHides(this.page)
|
||||
.then(result => this.hides = result);
|
||||
}
|
||||
get authError() {
|
||||
return this.model.authError;
|
||||
}
|
||||
get mergedAccount() {
|
||||
return this.model.mergedAccount;
|
||||
}
|
||||
get account() {
|
||||
return this.model.account;
|
||||
}
|
||||
get supporter() {
|
||||
return this.model.supporter;
|
||||
}
|
||||
get showSupporter() {
|
||||
return isSupporterOrPastSupporter(this.account);
|
||||
}
|
||||
get canSubmit() {
|
||||
return this.account && this.data.name && !!cleanName(this.data.name).length;
|
||||
}
|
||||
get supporterTitle() {
|
||||
return supporterTitle(this.account);
|
||||
}
|
||||
get supporterClass() {
|
||||
return supporterClass(this.account);
|
||||
}
|
||||
get supporterRewards() {
|
||||
return supporterRewards(this.account);
|
||||
}
|
||||
get showSupporterInfo() {
|
||||
const account = this.account;
|
||||
return !!(!this.supporter && account && account.sites && account.sites.some(s => s.provider === 'patreon'));
|
||||
}
|
||||
get showAccountAlert() {
|
||||
return this.model.missingBirthdate;
|
||||
}
|
||||
icon(id: string) {
|
||||
return getProviderIcon(id);
|
||||
}
|
||||
submit() {
|
||||
if (this.canSubmit) {
|
||||
this.resetAllMessages();
|
||||
this.data.name = cleanName(this.data.name).substr(0, ACCOUNT_NAME_MAX_LENGTH);
|
||||
this.model.updateAccount(this.data)
|
||||
.catch((e: Error) => this.accountError = e.message)
|
||||
.then(() => this.accountSaved = true);
|
||||
}
|
||||
}
|
||||
removeSite(site: SocialSiteInfo) {
|
||||
if (confirm('Are you sure you want to remove this social account ?')) {
|
||||
this.removingSite = true;
|
||||
this.resetAllMessages();
|
||||
this.model.removeSite(site.id)
|
||||
.then(() => this.sites = this.account!.sites!.map(toSocialSiteInfo))
|
||||
.then(() => this.removedAccount = true)
|
||||
.catch((e: Error) => this.mergeError = e.message)
|
||||
.then(() => this.removingSite = false);
|
||||
}
|
||||
}
|
||||
connectSite(provider: OAuthProvider) {
|
||||
this.model.connectSite(provider);
|
||||
}
|
||||
private resetAllMessages() {
|
||||
this.accountSaved = false;
|
||||
this.mergeError = undefined;
|
||||
this.accountError = undefined;
|
||||
this.removedAccount = false;
|
||||
this.model.authError = undefined;
|
||||
this.model.mergedAccount = false;
|
||||
}
|
||||
unhidePlayer(player: HiddenPlayer) {
|
||||
this.model.unhidePlayer(player.id)
|
||||
.then(() => this.pageChanged())
|
||||
.catch((e: Error) => console.error(e));
|
||||
}
|
||||
this.pageChanged();
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.model.mergedAccount = false;
|
||||
}
|
||||
pageChanged() {
|
||||
this.model.getHides(this.page)
|
||||
.then(result => this.hides = result);
|
||||
}
|
||||
get authError() {
|
||||
return this.model.authError;
|
||||
}
|
||||
get mergedAccount() {
|
||||
return this.model.mergedAccount;
|
||||
}
|
||||
get account() {
|
||||
return this.model.account;
|
||||
}
|
||||
get supporter() {
|
||||
return this.model.supporter;
|
||||
}
|
||||
get showSupporter() {
|
||||
return isSupporterOrPastSupporter(this.account);
|
||||
}
|
||||
get canSubmit() {
|
||||
return this.account && this.data.name && !!cleanName(this.data.name).length;
|
||||
}
|
||||
get supporterTitle() {
|
||||
return supporterTitle(this.account);
|
||||
}
|
||||
get supporterClass() {
|
||||
return supporterClass(this.account);
|
||||
}
|
||||
get supporterRewards() {
|
||||
return supporterRewards(this.account);
|
||||
}
|
||||
get showSupporterInfo() {
|
||||
const account = this.account;
|
||||
return !!(!this.supporter && account && account.sites && account.sites.some(s => s.provider === 'patreon'));
|
||||
}
|
||||
get showAccountAlert() {
|
||||
return this.model.missingBirthdate;
|
||||
}
|
||||
icon(id: string) {
|
||||
return getProviderIcon(id);
|
||||
}
|
||||
submit() {
|
||||
if (this.canSubmit) {
|
||||
this.resetAllMessages();
|
||||
this.data.name = cleanName(this.data.name).substr(0, ACCOUNT_NAME_MAX_LENGTH);
|
||||
this.model.updateAccount(this.data)
|
||||
.catch((e: Error) => this.accountError = e.message)
|
||||
.then(() => this.accountSaved = true);
|
||||
}
|
||||
}
|
||||
removeSite(site: SocialSiteInfo) {
|
||||
if (confirm('Are you sure you want to remove this social account ?')) {
|
||||
this.removingSite = true;
|
||||
this.resetAllMessages();
|
||||
this.model.removeSite(site.id)
|
||||
.then(() => this.sites = this.account!.sites!.map(toSocialSiteInfo))
|
||||
.then(() => this.removedAccount = true)
|
||||
.catch((e: Error) => this.mergeError = e.message)
|
||||
.then(() => this.removingSite = false);
|
||||
}
|
||||
}
|
||||
connectSite(provider: OAuthProvider) {
|
||||
this.model.connectSite(provider);
|
||||
}
|
||||
private resetAllMessages() {
|
||||
this.accountSaved = false;
|
||||
this.mergeError = undefined;
|
||||
this.accountError = undefined;
|
||||
this.removedAccount = false;
|
||||
this.model.authError = undefined;
|
||||
this.model.mergedAccount = false;
|
||||
}
|
||||
unhidePlayer(player: HiddenPlayer) {
|
||||
this.model.unhidePlayer(player.id)
|
||||
.then(() => this.pageChanged())
|
||||
.catch((e: Error) => console.error(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,43 +24,43 @@ import { ErrorReporter } from '../services/errorReporter';
|
||||
import { RollbarErrorReporter } from '../services/rollbarErrorReporter';
|
||||
|
||||
export const routes: Routes = [
|
||||
{ path: '', component: Home },
|
||||
{ path: 'help', component: Help },
|
||||
{ path: 'about', component: About },
|
||||
{ path: 'account', component: Account, canActivate: [AuthGuard] },
|
||||
{ path: 'character', component: Character, canActivate: [AuthGuard] },
|
||||
{ path: '**', redirectTo: '/', pathMatch: 'full' },
|
||||
{ path: '', component: Home },
|
||||
{ path: 'help', component: Help },
|
||||
{ path: 'about', component: About },
|
||||
{ path: 'account', component: Account, canActivate: [AuthGuard] },
|
||||
{ path: 'character', component: Character, canActivate: [AuthGuard] },
|
||||
{ path: '**', redirectTo: '/', pathMatch: 'full' },
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
BrowserModule,
|
||||
RouterModule,
|
||||
FormsModule,
|
||||
HttpClientModule,
|
||||
PopoverModule.forRoot(),
|
||||
ButtonsModule.forRoot(),
|
||||
TooltipModule.forRoot(),
|
||||
// TypeaheadModule.forRoot(),
|
||||
SharedModule,
|
||||
RouterModule.forRoot(routes),
|
||||
FontAwesomeModule,
|
||||
],
|
||||
declarations: [
|
||||
App,
|
||||
Home,
|
||||
Help,
|
||||
About,
|
||||
Account,
|
||||
Character,
|
||||
EditorBox,
|
||||
],
|
||||
providers: [
|
||||
{ provide: RollbarService, useFactory: rollbarFactory },
|
||||
{ provide: ErrorHandler, useClass: RollbarErrorHandler },
|
||||
{ provide: ErrorReporter, useClass: RollbarErrorReporter },
|
||||
],
|
||||
bootstrap: [App],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
RouterModule,
|
||||
FormsModule,
|
||||
HttpClientModule,
|
||||
PopoverModule.forRoot(),
|
||||
ButtonsModule.forRoot(),
|
||||
TooltipModule.forRoot(),
|
||||
// TypeaheadModule.forRoot(),
|
||||
SharedModule,
|
||||
RouterModule.forRoot(routes),
|
||||
FontAwesomeModule,
|
||||
],
|
||||
declarations: [
|
||||
App,
|
||||
Home,
|
||||
Help,
|
||||
About,
|
||||
Account,
|
||||
Character,
|
||||
EditorBox,
|
||||
],
|
||||
providers: [
|
||||
{ provide: RollbarService, useFactory: rollbarFactory },
|
||||
{ provide: ErrorHandler, useClass: RollbarErrorHandler },
|
||||
{ provide: ErrorReporter, useClass: RollbarErrorReporter },
|
||||
],
|
||||
bootstrap: [App],
|
||||
})
|
||||
export class AppModule {
|
||||
}
|
||||
|
||||
+167
-167
@@ -21,190 +21,190 @@ import { findEntityById } from '../../common/worldMap';
|
||||
import { isSelected } from '../../client/gameUtils';
|
||||
|
||||
export function tooltipConfig() {
|
||||
return Object.assign(new TooltipConfig(), { container: 'body' });
|
||||
return Object.assign(new TooltipConfig(), { container: 'body' });
|
||||
}
|
||||
|
||||
export function popoverConfig() {
|
||||
return Object.assign(new PopoverConfig(), { container: 'body' });
|
||||
return Object.assign(new PopoverConfig(), { container: 'body' });
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'pony-town-app',
|
||||
templateUrl: 'app.pug',
|
||||
styleUrls: ['app.scss'],
|
||||
providers: [
|
||||
{ provide: TooltipConfig, useFactory: tooltipConfig },
|
||||
{ provide: PopoverConfig, useFactory: popoverConfig },
|
||||
]
|
||||
selector: 'pony-town-app',
|
||||
templateUrl: 'app.pug',
|
||||
styleUrls: ['app.scss'],
|
||||
providers: [
|
||||
{ provide: TooltipConfig, useFactory: tooltipConfig },
|
||||
{ provide: PopoverConfig, useFactory: popoverConfig },
|
||||
]
|
||||
})
|
||||
export class App implements OnInit, OnDestroy {
|
||||
@ViewChild('announcer', { static: true }) announcer!: ElementRef;
|
||||
@ViewChild('announcerText', { static: true }) announcerText!: ElementRef;
|
||||
@ViewChild('reloadModal', { static: true }) reloadModal!: TemplateRef<any>;
|
||||
@ViewChild('signInModal', { static: true }) signInModal!: TemplateRef<any>;
|
||||
readonly version = version;
|
||||
readonly date = new Date();
|
||||
readonly emailIcon = faEnvelope;
|
||||
readonly twitterIcon = faTwitter;
|
||||
readonly patreonIcon = faPatreon;
|
||||
readonly cogIcon = faCog;
|
||||
readonly homeIcon = faHome;
|
||||
readonly helpIcon = faGamepad;
|
||||
readonly aboutIcon = faInfoCircle;
|
||||
readonly charactersIcon = faHorseHead;
|
||||
readonly contactEmail = contactEmail;
|
||||
readonly patreonLink = supporterLink;
|
||||
readonly twitterLink = twitterLink;
|
||||
readonly copyright = copyrightName;
|
||||
private url = location.pathname;
|
||||
private reloadModalRef?: BsModalRef;
|
||||
private reloadInterval?: any;
|
||||
private subscriptions: Subscription[] = [];
|
||||
constructor(
|
||||
private modalService: BsModalService,
|
||||
private gameService: GameService,
|
||||
private model: Model,
|
||||
private game: PonyTownGame,
|
||||
private router: Router,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private installService: InstallService,
|
||||
private errorReporter: ErrorReporter,
|
||||
) {
|
||||
}
|
||||
get canInstall() {
|
||||
return this.installService.canInstall;
|
||||
}
|
||||
get loading() {
|
||||
return this.model.loading;
|
||||
}
|
||||
get account() {
|
||||
return this.model.account;
|
||||
}
|
||||
get isMod() {
|
||||
return this.model.isMod;
|
||||
}
|
||||
get notifications() {
|
||||
return this.game.notifications;
|
||||
}
|
||||
get selected() {
|
||||
return this.gameService.selected;
|
||||
}
|
||||
get playing() {
|
||||
return this.gameService.playing;
|
||||
}
|
||||
get showActionBar() {
|
||||
return this.playing;
|
||||
}
|
||||
get editingActions() {
|
||||
return this.game.editingActions;
|
||||
}
|
||||
ngOnInit() {
|
||||
if (typeof ga !== 'undefined') {
|
||||
this.subscriptions.push(this.router.events.subscribe(event => {
|
||||
if (event instanceof NavigationEnd && this.url !== event.url) {
|
||||
ga('set', 'page', this.url = event.url);
|
||||
ga('send', 'pageview');
|
||||
}
|
||||
}));
|
||||
}
|
||||
@ViewChild('announcer', { static: true }) announcer!: ElementRef;
|
||||
@ViewChild('announcerText', { static: true }) announcerText!: ElementRef;
|
||||
@ViewChild('reloadModal', { static: true }) reloadModal!: TemplateRef<any>;
|
||||
@ViewChild('signInModal', { static: true }) signInModal!: TemplateRef<any>;
|
||||
readonly version = version;
|
||||
readonly date = new Date();
|
||||
readonly emailIcon = faEnvelope;
|
||||
readonly twitterIcon = faTwitter;
|
||||
readonly patreonIcon = faPatreon;
|
||||
readonly cogIcon = faCog;
|
||||
readonly homeIcon = faHome;
|
||||
readonly helpIcon = faGamepad;
|
||||
readonly aboutIcon = faInfoCircle;
|
||||
readonly charactersIcon = faHorseHead;
|
||||
readonly contactEmail = contactEmail;
|
||||
readonly patreonLink = supporterLink;
|
||||
readonly twitterLink = twitterLink;
|
||||
readonly copyright = copyrightName;
|
||||
private url = location.pathname;
|
||||
private reloadModalRef?: BsModalRef;
|
||||
private reloadInterval?: any;
|
||||
private subscriptions: Subscription[] = [];
|
||||
constructor(
|
||||
private modalService: BsModalService,
|
||||
private gameService: GameService,
|
||||
private model: Model,
|
||||
private game: PonyTownGame,
|
||||
private router: Router,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private installService: InstallService,
|
||||
private errorReporter: ErrorReporter,
|
||||
) {
|
||||
}
|
||||
get canInstall() {
|
||||
return this.installService.canInstall;
|
||||
}
|
||||
get loading() {
|
||||
return this.model.loading;
|
||||
}
|
||||
get account() {
|
||||
return this.model.account;
|
||||
}
|
||||
get isMod() {
|
||||
return this.model.isMod;
|
||||
}
|
||||
get notifications() {
|
||||
return this.game.notifications;
|
||||
}
|
||||
get selected() {
|
||||
return this.gameService.selected;
|
||||
}
|
||||
get playing() {
|
||||
return this.gameService.playing;
|
||||
}
|
||||
get showActionBar() {
|
||||
return this.playing;
|
||||
}
|
||||
get editingActions() {
|
||||
return this.game.editingActions;
|
||||
}
|
||||
ngOnInit() {
|
||||
if (typeof ga !== 'undefined') {
|
||||
this.subscriptions.push(this.router.events.subscribe(event => {
|
||||
if (event instanceof NavigationEnd && this.url !== event.url) {
|
||||
ga('set', 'page', this.url = event.url);
|
||||
ga('send', 'pageview');
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
if (isBrowserOutdated) {
|
||||
this.errorReporter.disable();
|
||||
}
|
||||
if (isBrowserOutdated) {
|
||||
this.errorReporter.disable();
|
||||
}
|
||||
|
||||
if (!DEVELOPMENT) {
|
||||
registerServiceWorker(`${host}sw.js`, () => {
|
||||
this.model.updating = true;
|
||||
setTimeout(() => {
|
||||
this.model.updatingTakesLongTime = true;
|
||||
}, 20 * SECOND);
|
||||
});
|
||||
}
|
||||
if (!DEVELOPMENT) {
|
||||
registerServiceWorker(`${host}sw.js`, () => {
|
||||
this.model.updating = true;
|
||||
setTimeout(() => {
|
||||
this.model.updatingTakesLongTime = true;
|
||||
}, 20 * SECOND);
|
||||
});
|
||||
}
|
||||
|
||||
if (DEVELOPMENT) {
|
||||
this.subscriptions.push(this.game.announcements.subscribe(message => {
|
||||
(this.announcer.nativeElement as HTMLElement).style.display = 'flex';
|
||||
const announcerText = this.announcerText.nativeElement as HTMLElement;
|
||||
announcerText.textContent = '';
|
||||
setTimeout(() => announcerText.textContent = message, 100);
|
||||
}));
|
||||
}
|
||||
if (DEVELOPMENT) {
|
||||
this.subscriptions.push(this.game.announcements.subscribe(message => {
|
||||
(this.announcer.nativeElement as HTMLElement).style.display = 'flex';
|
||||
const announcerText = this.announcerText.nativeElement as HTMLElement;
|
||||
announcerText.textContent = '';
|
||||
setTimeout(() => announcerText.textContent = message, 100);
|
||||
}));
|
||||
}
|
||||
|
||||
this.activatedRoute.queryParams.subscribe(({ error, merged, alert }) => {
|
||||
this.model.authError = error;
|
||||
this.model.accountAlert = alert;
|
||||
this.model.mergedAccount = !!merged;
|
||||
});
|
||||
this.activatedRoute.queryParams.subscribe(({ error, merged, alert }) => {
|
||||
this.model.authError = error;
|
||||
this.model.accountAlert = alert;
|
||||
this.model.mergedAccount = !!merged;
|
||||
});
|
||||
|
||||
this.subscriptions.push(this.model.protectionErrors.subscribe(() => {
|
||||
this.openReloadModal();
|
||||
}));
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(s => s.unsubscribe());
|
||||
}
|
||||
@HostListener('window:focus')
|
||||
focus() {
|
||||
this.model.verifyAccount();
|
||||
}
|
||||
signIn(provider: OAuthProvider) {
|
||||
this.model.signIn(provider);
|
||||
}
|
||||
signOut() {
|
||||
this.model.signOut();
|
||||
}
|
||||
openReloadModal() {
|
||||
if (!this.reloadModalRef) {
|
||||
this.reloadModalRef = this.modalService.show(
|
||||
this.reloadModal, { class: 'modal-lg', ignoreBackdropClick: true, keyboard: false });
|
||||
this.subscriptions.push(this.model.protectionErrors.subscribe(() => {
|
||||
this.openReloadModal();
|
||||
}));
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(s => s.unsubscribe());
|
||||
}
|
||||
@HostListener('window:focus')
|
||||
focus() {
|
||||
this.model.verifyAccount();
|
||||
}
|
||||
signIn(provider: OAuthProvider) {
|
||||
this.model.signIn(provider);
|
||||
}
|
||||
signOut() {
|
||||
this.model.signOut();
|
||||
}
|
||||
openReloadModal() {
|
||||
if (!this.reloadModalRef) {
|
||||
this.reloadModalRef = this.modalService.show(
|
||||
this.reloadModal, { class: 'modal-lg', ignoreBackdropClick: true, keyboard: false });
|
||||
|
||||
this.reloadInterval = setInterval(() => {
|
||||
if (checkIframeKey('reload-frame', 'gep84r9jshge4g')) {
|
||||
this.cancelReloadModal();
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
cancelReloadModal() {
|
||||
if (this.reloadModalRef) {
|
||||
this.reloadModalRef.hide();
|
||||
this.reloadModalRef = undefined;
|
||||
}
|
||||
this.reloadInterval = setInterval(() => {
|
||||
if (checkIframeKey('reload-frame', 'gep84r9jshge4g')) {
|
||||
this.cancelReloadModal();
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
cancelReloadModal() {
|
||||
if (this.reloadModalRef) {
|
||||
this.reloadModalRef.hide();
|
||||
this.reloadModalRef = undefined;
|
||||
}
|
||||
|
||||
clearInterval(this.reloadInterval);
|
||||
}
|
||||
chatLogNameClick(chatBox: ChatBox, message: ChatLogMessage) {
|
||||
if (!message.entityId) {
|
||||
return;
|
||||
}
|
||||
clearInterval(this.reloadInterval);
|
||||
}
|
||||
chatLogNameClick(chatBox: ChatBox, message: ChatLogMessage) {
|
||||
if (!message.entityId) {
|
||||
return;
|
||||
}
|
||||
|
||||
let entity = findEntityById(this.game.map, message.entityId);
|
||||
let entity = findEntityById(this.game.map, message.entityId);
|
||||
|
||||
if (entity && (!isPony(entity) || entity === this.game.player)) {
|
||||
return;
|
||||
}
|
||||
if (entity && (!isPony(entity) || entity === this.game.player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entity) {
|
||||
entity = { fake: true, type: PONY_TYPE, id: message.entityId, name: message.name } as FakeEntity as any;
|
||||
}
|
||||
if (!entity) {
|
||||
entity = { fake: true, type: PONY_TYPE, id: message.entityId, name: message.name } as FakeEntity as any;
|
||||
}
|
||||
|
||||
if (isSelected(this.game, message.entityId)) {
|
||||
this.game.whisperTo = entity;
|
||||
chatBox.setChatType('whisper');
|
||||
} else {
|
||||
this.game.select(entity as Pony);
|
||||
}
|
||||
}
|
||||
messageToFriend(chatBox: ChatBox, friend: Friend) {
|
||||
if (friend.entityId) {
|
||||
const entity: any = { id: friend.entityId, name: friend.actualName || 'unknown' };
|
||||
this.messageToPony(chatBox, entity);
|
||||
}
|
||||
}
|
||||
messageToPony(chatBox: ChatBox, pony: Entity) {
|
||||
setTimeout(() => {
|
||||
this.game.whisperTo = pony;
|
||||
chatBox.setChatType('whisper');
|
||||
});
|
||||
}
|
||||
if (isSelected(this.game, message.entityId)) {
|
||||
this.game.whisperTo = entity;
|
||||
chatBox.setChatType('whisper');
|
||||
} else {
|
||||
this.game.select(entity as Pony);
|
||||
}
|
||||
}
|
||||
messageToFriend(chatBox: ChatBox, friend: Friend) {
|
||||
if (friend.entityId) {
|
||||
const entity: any = { id: friend.entityId, name: friend.actualName || 'unknown' };
|
||||
this.messageToPony(chatBox, entity);
|
||||
}
|
||||
}
|
||||
messageToPony(chatBox: ChatBox, pony: Entity) {
|
||||
setTimeout(() => {
|
||||
this.game.whisperTo = pony;
|
||||
chatBox.setChatType('whisper');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { clamp } from 'lodash';
|
||||
import { PLAYER_NAME_MAX_LENGTH, PLAYER_DESC_MAX_LENGTH } from '../../../common/constants';
|
||||
import {
|
||||
PonyInfo, PonyObject, PonyState, SocialSiteInfo, ColorExtraSet, ColorExtra, CharacterTag, PonyEye, Eye, Muzzle,
|
||||
Iris, ExpressionExtra
|
||||
PonyInfo, PonyObject, PonyState, SocialSiteInfo, ColorExtraSet, ColorExtra, CharacterTag, PonyEye, Eye, Muzzle,
|
||||
Iris, ExpressionExtra
|
||||
} from '../../../common/interfaces';
|
||||
import { findById, toInt, cloneDeep, delay } from '../../../common/utils';
|
||||
import {
|
||||
SLEEVED_ACCESSORIES, frontHooves, mergedBackManes, mergedManes, mergedFacialHair, mergedEarAccessories,
|
||||
mergedChestAccessories, mergedFaceAccessories, mergedBackAccessories, mergedExtraAccessories, mergedHeadAccessories
|
||||
SLEEVED_ACCESSORIES, frontHooves, mergedBackManes, mergedManes, mergedFacialHair, mergedEarAccessories,
|
||||
mergedChestAccessories, mergedFaceAccessories, mergedBackAccessories, mergedExtraAccessories, mergedHeadAccessories
|
||||
} from '../../../client/ponyUtils';
|
||||
import { defaultPonyState, defaultDrawPonyOptions } from '../../../client/ponyHelpers';
|
||||
import { toPalette, getBaseFill, syncLockedPonyInfo } from '../../../common/ponyInfo';
|
||||
@@ -33,17 +33,17 @@ const frontHoofTitles = ['', 'Fetlocks', 'Paws', 'Claws', ''];
|
||||
const backHoofTitles = ['', 'Fetlocks', 'Paws', '', ''];
|
||||
|
||||
const horns = addLabels(sprites.horns, [
|
||||
'None', 'Unicorn horn', 'Short unicorn horn', 'Curved unicorn horn', 'Tiny deer antlers',
|
||||
'Short deer antlers', 'Medium deer antlers', 'Large deer antlers', 'Raindeer antlers', 'Goat horns',
|
||||
'Ram horns', 'Buffalo horns', 'Moose horns', 'Bug antenna', 'Long unicorn horn',
|
||||
'None', 'Unicorn horn', 'Short unicorn horn', 'Curved unicorn horn', 'Tiny deer antlers',
|
||||
'Short deer antlers', 'Medium deer antlers', 'Large deer antlers', 'Raindeer antlers', 'Goat horns',
|
||||
'Ram horns', 'Buffalo horns', 'Moose horns', 'Bug antenna', 'Long unicorn horn',
|
||||
]);
|
||||
|
||||
const wings = addLabels(sprites.wings[0]!, [
|
||||
'None', 'Pegasus wings', 'Bat wings', 'Gryphon wings', 'Bug wings'
|
||||
'None', 'Pegasus wings', 'Bat wings', 'Gryphon wings', 'Bug wings'
|
||||
]);
|
||||
|
||||
const ears = addLabels(sprites.ears, [
|
||||
'Regular ears', 'Fluffy ears', 'Long feathered ears', 'Bug ears', 'Short feathered ears', 'Deer ears',
|
||||
'Regular ears', 'Fluffy ears', 'Long feathered ears', 'Bug ears', 'Short feathered ears', 'Deer ears',
|
||||
]);
|
||||
|
||||
const noses = addTitles(sprites.noses[0], ['Pony muzzle', 'Gryphon beak', 'Deer nose']);
|
||||
@@ -51,451 +51,451 @@ const noses = addTitles(sprites.noses[0], ['Pony muzzle', 'Gryphon beak', 'Deer
|
||||
const flyAnimations = [{ ...stand, name: 'fly' }, fly, fly, fly, { ...flyBug, name: 'fly' }];
|
||||
|
||||
function eyeSprite(e: PonyEye | undefined) {
|
||||
return createEyeSprite(e, 0, sprites.defaultPalette);
|
||||
return createEyeSprite(e, 0, sprites.defaultPalette);
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'character',
|
||||
templateUrl: 'character.pug',
|
||||
styleUrls: ['character.scss'],
|
||||
selector: 'character',
|
||||
templateUrl: 'character.pug',
|
||||
styleUrls: ['character.scss'],
|
||||
})
|
||||
export class Character implements OnInit, OnDestroy {
|
||||
readonly debug = DEVELOPMENT || BETA;
|
||||
readonly playIcon = faPlay;
|
||||
readonly lockIcon = faLock;
|
||||
readonly saveIcon = faSave;
|
||||
readonly codeIcon = faCode;
|
||||
readonly infoIcon = faInfoCircle;
|
||||
readonly maxNameLength = PLAYER_NAME_MAX_LENGTH;
|
||||
readonly maxDescLength = PLAYER_DESC_MAX_LENGTH;
|
||||
readonly horns = horns;
|
||||
readonly manes = mergedManes;
|
||||
readonly backManes = mergedBackManes;
|
||||
readonly tails = sprites.tails[0];
|
||||
readonly wings = wings;
|
||||
readonly ears = ears;
|
||||
readonly facialHair = mergedFacialHair;
|
||||
readonly headAccessories = mergedHeadAccessories;
|
||||
readonly earAccessories = mergedEarAccessories;
|
||||
readonly faceAccessories = mergedFaceAccessories;
|
||||
readonly neckAccessories = sprites.neckAccessories[1];
|
||||
readonly frontLegAccessories = sprites.frontLegAccessories[1];
|
||||
readonly backLegAccessories = sprites.backLegAccessories[1];
|
||||
readonly backAccessories = mergedBackAccessories;
|
||||
readonly chestAccessories = mergedChestAccessories;
|
||||
readonly sleeveAccessories = sprites.frontLegSleeves[1];
|
||||
readonly waistAccessories = sprites.waistAccessories[1];
|
||||
readonly extraAccessories = mergedExtraAccessories;
|
||||
readonly frontHooves = addTitles(frontHooves[1], frontHoofTitles);
|
||||
readonly backHooves = addTitles(sprites.backLegHooves[1], backHoofTitles);
|
||||
readonly animations = [
|
||||
() => stand,
|
||||
() => trot,
|
||||
() => boop,
|
||||
() => sitDownUp,
|
||||
() => lieDownUp,
|
||||
() => flyAnimations[this.previewInfo!.wings!.type || 0],
|
||||
];
|
||||
readonly eyelashes: ColorExtraSet = sprites.eyeLeft[1]!.map(eyeSprite);
|
||||
readonly eyesLeft: ColorExtraSet = sprites.eyeLeft.map(e => e && e[0]).map(eyeSprite);
|
||||
readonly eyesRight: ColorExtraSet = sprites.eyeRight.map(e => e && e[0]).map(eyeSprite);
|
||||
readonly noses = noses;
|
||||
readonly heads = sprites.head1[1];
|
||||
readonly buttMarkState: ButtMarkEditorState = {
|
||||
brushType: 'brush',
|
||||
brush: 'orange',
|
||||
};
|
||||
muzzles: ColorExtraSet;
|
||||
fangs: ColorExtraSet;
|
||||
tags: CharacterTag[] = [
|
||||
emptyTag,
|
||||
];
|
||||
state = defaultPonyState();
|
||||
saved: PonyInfo[] = [];
|
||||
activeAnimation = 0;
|
||||
loaded = false;
|
||||
playAnimation = true;
|
||||
deleting = false;
|
||||
fixed = false;
|
||||
previewExtra = false;
|
||||
previewPony: PonyObject | undefined = undefined;
|
||||
sites: SocialSiteInfo[] = [];
|
||||
error?: string;
|
||||
canSaveFiles = isFileSaverSupported();
|
||||
private savingLocked = false;
|
||||
private interval?: any;
|
||||
private syncTimeout?: any;
|
||||
private animationTime = 0;
|
||||
constructor(private gameService: GameService, private model: Model) {
|
||||
this.createMuzzles();
|
||||
this.updateMuzzles();
|
||||
}
|
||||
private getMuzzleType() {
|
||||
return clamp(toInt(this.info && this.info.nose && this.info.nose.type), 0, sprites.noses[0].length);
|
||||
}
|
||||
createMuzzles() {
|
||||
const type = this.getMuzzleType();
|
||||
const happy = sprites.noses[0][type][0];
|
||||
readonly debug = DEVELOPMENT || BETA;
|
||||
readonly playIcon = faPlay;
|
||||
readonly lockIcon = faLock;
|
||||
readonly saveIcon = faSave;
|
||||
readonly codeIcon = faCode;
|
||||
readonly infoIcon = faInfoCircle;
|
||||
readonly maxNameLength = PLAYER_NAME_MAX_LENGTH;
|
||||
readonly maxDescLength = PLAYER_DESC_MAX_LENGTH;
|
||||
readonly horns = horns;
|
||||
readonly manes = mergedManes;
|
||||
readonly backManes = mergedBackManes;
|
||||
readonly tails = sprites.tails[0];
|
||||
readonly wings = wings;
|
||||
readonly ears = ears;
|
||||
readonly facialHair = mergedFacialHair;
|
||||
readonly headAccessories = mergedHeadAccessories;
|
||||
readonly earAccessories = mergedEarAccessories;
|
||||
readonly faceAccessories = mergedFaceAccessories;
|
||||
readonly neckAccessories = sprites.neckAccessories[1];
|
||||
readonly frontLegAccessories = sprites.frontLegAccessories[1];
|
||||
readonly backLegAccessories = sprites.backLegAccessories[1];
|
||||
readonly backAccessories = mergedBackAccessories;
|
||||
readonly chestAccessories = mergedChestAccessories;
|
||||
readonly sleeveAccessories = sprites.frontLegSleeves[1];
|
||||
readonly waistAccessories = sprites.waistAccessories[1];
|
||||
readonly extraAccessories = mergedExtraAccessories;
|
||||
readonly frontHooves = addTitles(frontHooves[1], frontHoofTitles);
|
||||
readonly backHooves = addTitles(sprites.backLegHooves[1], backHoofTitles);
|
||||
readonly animations = [
|
||||
() => stand,
|
||||
() => trot,
|
||||
() => boop,
|
||||
() => sitDownUp,
|
||||
() => lieDownUp,
|
||||
() => flyAnimations[this.previewInfo!.wings!.type || 0],
|
||||
];
|
||||
readonly eyelashes: ColorExtraSet = sprites.eyeLeft[1]!.map(eyeSprite);
|
||||
readonly eyesLeft: ColorExtraSet = sprites.eyeLeft.map(e => e && e[0]).map(eyeSprite);
|
||||
readonly eyesRight: ColorExtraSet = sprites.eyeRight.map(e => e && e[0]).map(eyeSprite);
|
||||
readonly noses = noses;
|
||||
readonly heads = sprites.head1[1];
|
||||
readonly buttMarkState: ButtMarkEditorState = {
|
||||
brushType: 'brush',
|
||||
brush: 'orange',
|
||||
};
|
||||
muzzles: ColorExtraSet;
|
||||
fangs: ColorExtraSet;
|
||||
tags: CharacterTag[] = [
|
||||
emptyTag,
|
||||
];
|
||||
state = defaultPonyState();
|
||||
saved: PonyInfo[] = [];
|
||||
activeAnimation = 0;
|
||||
loaded = false;
|
||||
playAnimation = true;
|
||||
deleting = false;
|
||||
fixed = false;
|
||||
previewExtra = false;
|
||||
previewPony: PonyObject | undefined = undefined;
|
||||
sites: SocialSiteInfo[] = [];
|
||||
error?: string;
|
||||
canSaveFiles = isFileSaverSupported();
|
||||
private savingLocked = false;
|
||||
private interval?: any;
|
||||
private syncTimeout?: any;
|
||||
private animationTime = 0;
|
||||
constructor(private gameService: GameService, private model: Model) {
|
||||
this.createMuzzles();
|
||||
this.updateMuzzles();
|
||||
}
|
||||
private getMuzzleType() {
|
||||
return clamp(toInt(this.info && this.info.nose && this.info.nose.type), 0, sprites.noses[0].length);
|
||||
}
|
||||
createMuzzles() {
|
||||
const type = this.getMuzzleType();
|
||||
const happy = sprites.noses[0][type][0];
|
||||
|
||||
this.muzzles = sprites.noses
|
||||
.slice()
|
||||
.map(n => n[type][0])
|
||||
.map(({ color, colors, mouth }) => ({ color, colors, extra: mouth, palettes: [sprites.defaultPalette] } as ColorExtra));
|
||||
this.muzzles = sprites.noses
|
||||
.slice()
|
||||
.map(n => n[type][0])
|
||||
.map(({ color, colors, mouth }) => ({ color, colors, extra: mouth, palettes: [sprites.defaultPalette] } as ColorExtra));
|
||||
|
||||
this.fangs = [undefined, { color: happy.color, colors: 3, extra: happy.fangs, palettes: [sprites.defaultPalette] }];
|
||||
}
|
||||
updateMuzzles() {
|
||||
const type = this.getMuzzleType();
|
||||
const happy = sprites.noses[0][type][0];
|
||||
this.fangs = [undefined, { color: happy.color, colors: 3, extra: happy.fangs, palettes: [sprites.defaultPalette] }];
|
||||
}
|
||||
updateMuzzles() {
|
||||
const type = this.getMuzzleType();
|
||||
const happy = sprites.noses[0][type][0];
|
||||
|
||||
this.muzzles!.forEach((m, i) => {
|
||||
if (m) {
|
||||
const { color, colors, mouth } = sprites.noses[i][type][0];
|
||||
m.color = color;
|
||||
m.colors = colors;
|
||||
m.extra = mouth;
|
||||
m.timestamp = Date.now();
|
||||
}
|
||||
});
|
||||
this.muzzles!.forEach((m, i) => {
|
||||
if (m) {
|
||||
const { color, colors, mouth } = sprites.noses[i][type][0];
|
||||
m.color = color;
|
||||
m.colors = colors;
|
||||
m.extra = mouth;
|
||||
m.timestamp = Date.now();
|
||||
}
|
||||
});
|
||||
|
||||
const fangs = this.fangs![1]!;
|
||||
fangs.color = happy.color;
|
||||
fangs.extra = happy.fangs;
|
||||
fangs.timestamp = Date.now();
|
||||
}
|
||||
get account() {
|
||||
return this.model.account;
|
||||
}
|
||||
get loading() {
|
||||
return this.model.loading || this.model.updating;
|
||||
}
|
||||
get updateWarning() {
|
||||
return this.gameService.updateWarning;
|
||||
}
|
||||
get playing() {
|
||||
return this.gameService.playing;
|
||||
}
|
||||
get previewInfo() {
|
||||
return this.previewPony ? this.previewPony.ponyInfo : this.pony.ponyInfo;
|
||||
}
|
||||
get previewName() {
|
||||
return this.previewPony ? this.previewPony.name : this.pony.name;
|
||||
}
|
||||
get previewTag() {
|
||||
return getPonyTag(this.previewPony || this.pony, this.account);
|
||||
}
|
||||
get customOutlines() {
|
||||
return this.info.customOutlines;
|
||||
}
|
||||
get ponies() {
|
||||
return this.model.ponies;
|
||||
}
|
||||
get pony() {
|
||||
return this.model.pony;
|
||||
}
|
||||
set pony(value: PonyObject) {
|
||||
this.model.selectPony(value);
|
||||
}
|
||||
get info() {
|
||||
return this.pony.ponyInfo!;
|
||||
}
|
||||
get maneFill() {
|
||||
return getBaseFill(this.info.mane);
|
||||
}
|
||||
get coatFill() {
|
||||
return this.info.coatFill;
|
||||
}
|
||||
get hoovesFill() {
|
||||
return getBaseFill(this.info.frontHooves);
|
||||
}
|
||||
get canExport() {
|
||||
return DEVELOPMENT;
|
||||
}
|
||||
get site() {
|
||||
return findById(this.sites, this.pony.site) || this.sites[0];
|
||||
}
|
||||
set site(value: SocialSiteInfo) {
|
||||
this.pony.site = value.id;
|
||||
}
|
||||
get tag() {
|
||||
return findById(this.tags, this.pony.tag) || this.tags[0];
|
||||
}
|
||||
set tag(value: CharacterTag) {
|
||||
this.pony.tag = value.id;
|
||||
}
|
||||
get lockEyeWhites() {
|
||||
return !this.info.unlockEyeWhites;
|
||||
}
|
||||
set lockEyeWhites(value) {
|
||||
this.info.unlockEyeWhites = !value;
|
||||
}
|
||||
get darken() {
|
||||
return !this.info.freeOutlines;
|
||||
}
|
||||
get lockFrontLegAccessory() {
|
||||
return !this.info.unlockFrontLegAccessory;
|
||||
}
|
||||
set lockFrontLegAccessory(value) {
|
||||
this.info.unlockFrontLegAccessory = !value;
|
||||
}
|
||||
get lockBackLegAccessory() {
|
||||
return !this.info.unlockBackLegAccessory;
|
||||
}
|
||||
set lockBackLegAccessory(value) {
|
||||
this.info.unlockBackLegAccessory = !value;
|
||||
}
|
||||
get lockEyelashColor() {
|
||||
return !this.info.unlockEyelashColor;
|
||||
}
|
||||
set lockEyelashColor(value) {
|
||||
this.info.unlockEyelashColor = !value;
|
||||
}
|
||||
icon(id: string) {
|
||||
return getProviderIcon(id);
|
||||
}
|
||||
hasSleeves(type: number) {
|
||||
return SLEEVED_ACCESSORIES.indexOf(type) !== -1;
|
||||
}
|
||||
ngOnInit() {
|
||||
if (this.model.account) {
|
||||
this.tags.push(...getAvailableTags(this.model.account));
|
||||
}
|
||||
const fangs = this.fangs![1]!;
|
||||
fangs.color = happy.color;
|
||||
fangs.extra = happy.fangs;
|
||||
fangs.timestamp = Date.now();
|
||||
}
|
||||
get account() {
|
||||
return this.model.account;
|
||||
}
|
||||
get loading() {
|
||||
return this.model.loading || this.model.updating;
|
||||
}
|
||||
get updateWarning() {
|
||||
return this.gameService.updateWarning;
|
||||
}
|
||||
get playing() {
|
||||
return this.gameService.playing;
|
||||
}
|
||||
get previewInfo() {
|
||||
return this.previewPony ? this.previewPony.ponyInfo : this.pony.ponyInfo;
|
||||
}
|
||||
get previewName() {
|
||||
return this.previewPony ? this.previewPony.name : this.pony.name;
|
||||
}
|
||||
get previewTag() {
|
||||
return getPonyTag(this.previewPony || this.pony, this.account);
|
||||
}
|
||||
get customOutlines() {
|
||||
return this.info.customOutlines;
|
||||
}
|
||||
get ponies() {
|
||||
return this.model.ponies;
|
||||
}
|
||||
get pony() {
|
||||
return this.model.pony;
|
||||
}
|
||||
set pony(value: PonyObject) {
|
||||
this.model.selectPony(value);
|
||||
}
|
||||
get info() {
|
||||
return this.pony.ponyInfo!;
|
||||
}
|
||||
get maneFill() {
|
||||
return getBaseFill(this.info.mane);
|
||||
}
|
||||
get coatFill() {
|
||||
return this.info.coatFill;
|
||||
}
|
||||
get hoovesFill() {
|
||||
return getBaseFill(this.info.frontHooves);
|
||||
}
|
||||
get canExport() {
|
||||
return DEVELOPMENT;
|
||||
}
|
||||
get site() {
|
||||
return findById(this.sites, this.pony.site) || this.sites[0];
|
||||
}
|
||||
set site(value: SocialSiteInfo) {
|
||||
this.pony.site = value.id;
|
||||
}
|
||||
get tag() {
|
||||
return findById(this.tags, this.pony.tag) || this.tags[0];
|
||||
}
|
||||
set tag(value: CharacterTag) {
|
||||
this.pony.tag = value.id;
|
||||
}
|
||||
get lockEyeWhites() {
|
||||
return !this.info.unlockEyeWhites;
|
||||
}
|
||||
set lockEyeWhites(value) {
|
||||
this.info.unlockEyeWhites = !value;
|
||||
}
|
||||
get darken() {
|
||||
return !this.info.freeOutlines;
|
||||
}
|
||||
get lockFrontLegAccessory() {
|
||||
return !this.info.unlockFrontLegAccessory;
|
||||
}
|
||||
set lockFrontLegAccessory(value) {
|
||||
this.info.unlockFrontLegAccessory = !value;
|
||||
}
|
||||
get lockBackLegAccessory() {
|
||||
return !this.info.unlockBackLegAccessory;
|
||||
}
|
||||
set lockBackLegAccessory(value) {
|
||||
this.info.unlockBackLegAccessory = !value;
|
||||
}
|
||||
get lockEyelashColor() {
|
||||
return !this.info.unlockEyelashColor;
|
||||
}
|
||||
set lockEyelashColor(value) {
|
||||
this.info.unlockEyelashColor = !value;
|
||||
}
|
||||
icon(id: string) {
|
||||
return getProviderIcon(id);
|
||||
}
|
||||
hasSleeves(type: number) {
|
||||
return SLEEVED_ACCESSORIES.indexOf(type) !== -1;
|
||||
}
|
||||
ngOnInit() {
|
||||
if (this.model.account) {
|
||||
this.tags.push(...getAvailableTags(this.model.account));
|
||||
}
|
||||
|
||||
this.sites = this.model.sites.filter(s => !!s.name);
|
||||
this.updateMuzzles();
|
||||
this.sites = this.model.sites.filter(s => !!s.name);
|
||||
this.updateMuzzles();
|
||||
|
||||
let last = Date.now();
|
||||
let last = Date.now();
|
||||
|
||||
return loadAndInitSpriteSheets().then(() => {
|
||||
this.loaded = true;
|
||||
this.interval = setInterval(() => {
|
||||
const now = Date.now();
|
||||
this.update((now - last) / 1000);
|
||||
last = now;
|
||||
}, 1000 / 24);
|
||||
});
|
||||
}
|
||||
ngOnDestroy() {
|
||||
clearInterval(this.interval);
|
||||
}
|
||||
changed() {
|
||||
if (!this.syncTimeout) {
|
||||
this.syncTimeout = requestAnimationFrame(() => {
|
||||
this.syncTimeout = undefined;
|
||||
syncLockedPonyInfo(this.info);
|
||||
});
|
||||
}
|
||||
return loadAndInitSpriteSheets().then(() => {
|
||||
this.loaded = true;
|
||||
this.interval = setInterval(() => {
|
||||
const now = Date.now();
|
||||
this.update((now - last) / 1000);
|
||||
last = now;
|
||||
}, 1000 / 24);
|
||||
});
|
||||
}
|
||||
ngOnDestroy() {
|
||||
clearInterval(this.interval);
|
||||
}
|
||||
changed() {
|
||||
if (!this.syncTimeout) {
|
||||
this.syncTimeout = requestAnimationFrame(() => {
|
||||
this.syncTimeout = undefined;
|
||||
syncLockedPonyInfo(this.info);
|
||||
});
|
||||
}
|
||||
|
||||
if (DEVELOPMENT || BETA) {
|
||||
this.state.blushColor = blushColor(parseColorWithAlpha(this.coatFill || '', 1));
|
||||
}
|
||||
}
|
||||
update(delta: number) {
|
||||
this.animationTime += delta;
|
||||
if (DEVELOPMENT || BETA) {
|
||||
this.state.blushColor = blushColor(parseColorWithAlpha(this.coatFill || '', 1));
|
||||
}
|
||||
}
|
||||
update(delta: number) {
|
||||
this.animationTime += delta;
|
||||
|
||||
const animation = this.animations[this.activeAnimation]();
|
||||
this.state.animation = animation;
|
||||
const animation = this.animations[this.activeAnimation]();
|
||||
this.state.animation = animation;
|
||||
|
||||
if (this.playAnimation) {
|
||||
this.state.animationFrame = Math.floor(this.animationTime * animation.fps) % animation.frames.length;
|
||||
}
|
||||
}
|
||||
copyCoatColorToTail() {
|
||||
if (this.info.tail && this.info.tail.fills) {
|
||||
this.info.tail.fills[0] = this.info.coatFill;
|
||||
this.changed();
|
||||
}
|
||||
}
|
||||
eyeColorLockChanged(locked: boolean) {
|
||||
if (locked) {
|
||||
this.info.eyeColorLeft = this.info.eyeColorRight;
|
||||
}
|
||||
}
|
||||
eyeWhiteLockChanged(locked: boolean) {
|
||||
if (locked) {
|
||||
this.info.eyeWhitesLeft = this.info.eyeWhites;
|
||||
}
|
||||
}
|
||||
eyeOpennessChanged(locked: boolean) {
|
||||
if (locked) {
|
||||
this.info.eyeOpennessLeft = this.info.eyeOpennessRight;
|
||||
}
|
||||
}
|
||||
eyelashLockChanged(locked: boolean) {
|
||||
if (locked) {
|
||||
this.info.eyelashColorLeft = this.info.eyelashColor;
|
||||
}
|
||||
}
|
||||
select(pony: PonyObject | undefined) {
|
||||
if (pony) {
|
||||
this.deleting = false;
|
||||
this.pony = pony;
|
||||
}
|
||||
}
|
||||
setActiveAnimation(index: number) {
|
||||
this.activeAnimation = index;
|
||||
this.animationTime = 0;
|
||||
}
|
||||
freeOutlinesChanged(_free: boolean) {
|
||||
this.changed();
|
||||
}
|
||||
darkenLockedOutlinesChanged(_darken: boolean) {
|
||||
this.changed();
|
||||
}
|
||||
get canSave() {
|
||||
return !this.model.pending && !!this.pony && !!this.pony.name && !this.savingLocked;
|
||||
}
|
||||
save() {
|
||||
if (this.canSave) {
|
||||
this.error = undefined;
|
||||
this.deleting = false;
|
||||
this.savingLocked = true;
|
||||
if (this.playAnimation) {
|
||||
this.state.animationFrame = Math.floor(this.animationTime * animation.fps) % animation.frames.length;
|
||||
}
|
||||
}
|
||||
copyCoatColorToTail() {
|
||||
if (this.info.tail && this.info.tail.fills) {
|
||||
this.info.tail.fills[0] = this.info.coatFill;
|
||||
this.changed();
|
||||
}
|
||||
}
|
||||
eyeColorLockChanged(locked: boolean) {
|
||||
if (locked) {
|
||||
this.info.eyeColorLeft = this.info.eyeColorRight;
|
||||
}
|
||||
}
|
||||
eyeWhiteLockChanged(locked: boolean) {
|
||||
if (locked) {
|
||||
this.info.eyeWhitesLeft = this.info.eyeWhites;
|
||||
}
|
||||
}
|
||||
eyeOpennessChanged(locked: boolean) {
|
||||
if (locked) {
|
||||
this.info.eyeOpennessLeft = this.info.eyeOpennessRight;
|
||||
}
|
||||
}
|
||||
eyelashLockChanged(locked: boolean) {
|
||||
if (locked) {
|
||||
this.info.eyelashColorLeft = this.info.eyelashColor;
|
||||
}
|
||||
}
|
||||
select(pony: PonyObject | undefined) {
|
||||
if (pony) {
|
||||
this.deleting = false;
|
||||
this.pony = pony;
|
||||
}
|
||||
}
|
||||
setActiveAnimation(index: number) {
|
||||
this.activeAnimation = index;
|
||||
this.animationTime = 0;
|
||||
}
|
||||
freeOutlinesChanged(_free: boolean) {
|
||||
this.changed();
|
||||
}
|
||||
darkenLockedOutlinesChanged(_darken: boolean) {
|
||||
this.changed();
|
||||
}
|
||||
get canSave() {
|
||||
return !this.model.pending && !!this.pony && !!this.pony.name && !this.savingLocked;
|
||||
}
|
||||
save() {
|
||||
if (this.canSave) {
|
||||
this.error = undefined;
|
||||
this.deleting = false;
|
||||
this.savingLocked = true;
|
||||
|
||||
this.model.savePony(this.pony)
|
||||
.catch((e: Error) => this.error = e.message)
|
||||
.then(() => delay(2000))
|
||||
.then(() => this.savingLocked = false);
|
||||
}
|
||||
}
|
||||
get canRevert() {
|
||||
return !!findById(this.ponies, this.pony.id);
|
||||
}
|
||||
revert() {
|
||||
if (this.canRevert) {
|
||||
this.select(findById(this.ponies, this.pony.id));
|
||||
}
|
||||
}
|
||||
get canDuplicate() {
|
||||
return this.ponies.length < this.model.characterLimit;
|
||||
}
|
||||
duplicate() {
|
||||
if (this.canDuplicate) {
|
||||
this.deleting = false;
|
||||
this.pony = cloneDeep(this.pony);
|
||||
this.pony.name = '';
|
||||
this.pony.id = '';
|
||||
}
|
||||
}
|
||||
export(index?: number) {
|
||||
const frameWidth = 80;
|
||||
const frameHeight = 90;
|
||||
const animations = index === undefined ? this.animations.map(a => a()) : [this.animations[index]()];
|
||||
const frames = animations.reduce((sum, a) => sum + a.frames.length, 0);
|
||||
const info = toPalette(this.info);
|
||||
const options = defaultDrawPonyOptions();
|
||||
this.model.savePony(this.pony)
|
||||
.catch((e: Error) => this.error = e.message)
|
||||
.then(() => delay(2000))
|
||||
.then(() => this.savingLocked = false);
|
||||
}
|
||||
}
|
||||
get canRevert() {
|
||||
return !!findById(this.ponies, this.pony.id);
|
||||
}
|
||||
revert() {
|
||||
if (this.canRevert) {
|
||||
this.select(findById(this.ponies, this.pony.id));
|
||||
}
|
||||
}
|
||||
get canDuplicate() {
|
||||
return this.ponies.length < this.model.characterLimit;
|
||||
}
|
||||
duplicate() {
|
||||
if (this.canDuplicate) {
|
||||
this.deleting = false;
|
||||
this.pony = cloneDeep(this.pony);
|
||||
this.pony.name = '';
|
||||
this.pony.id = '';
|
||||
}
|
||||
}
|
||||
export(index?: number) {
|
||||
const frameWidth = 80;
|
||||
const frameHeight = 90;
|
||||
const animations = index === undefined ? this.animations.map(a => a()) : [this.animations[index]()];
|
||||
const frames = animations.reduce((sum, a) => sum + a.frames.length, 0);
|
||||
const info = toPalette(this.info);
|
||||
const options = defaultDrawPonyOptions();
|
||||
|
||||
const canvas = drawCanvas(frameWidth * frames, frameHeight, sprites.paletteSpriteSheet, TRANSPARENT, batch => {
|
||||
let i = 0;
|
||||
const canvas = drawCanvas(frameWidth * frames, frameHeight, sprites.paletteSpriteSheet, TRANSPARENT, batch => {
|
||||
let i = 0;
|
||||
|
||||
animations.forEach(a => {
|
||||
for (let f = 0; f < a.frames.length; f++ , i++) {
|
||||
const state: PonyState = {
|
||||
...defaultPonyState(),
|
||||
animation: a,
|
||||
animationFrame: f,
|
||||
blinkFrame: 1,
|
||||
};
|
||||
animations.forEach(a => {
|
||||
for (let f = 0; f < a.frames.length; f++ , i++) {
|
||||
const state: PonyState = {
|
||||
...defaultPonyState(),
|
||||
animation: a,
|
||||
animationFrame: f,
|
||||
blinkFrame: 1,
|
||||
};
|
||||
|
||||
drawPony(batch, info, state, i * frameWidth + frameWidth / 2, frameHeight - 10, options);
|
||||
}
|
||||
});
|
||||
});
|
||||
drawPony(batch, info, state, i * frameWidth + frameWidth / 2, frameHeight - 10, options);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const name = animations.length === 1 ? animations[0].name : 'all';
|
||||
saveCanvas(canvas, `${this.pony.name}-${name}.png`);
|
||||
}
|
||||
import() {
|
||||
if (DEVELOPMENT) {
|
||||
const data = prompt('enter data');
|
||||
const name = animations.length === 1 ? animations[0].name : 'all';
|
||||
saveCanvas(canvas, `${this.pony.name}-${name}.png`);
|
||||
}
|
||||
import() {
|
||||
if (DEVELOPMENT) {
|
||||
const data = prompt('enter data');
|
||||
|
||||
if (data) {
|
||||
this.importPony(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
private importPony(data: string) {
|
||||
if (DEVELOPMENT) {
|
||||
this.pony.ponyInfo = decompressPonyString(data, true);
|
||||
const t = decompressPonyString(data, false);
|
||||
console.log(JSON.stringify(t, undefined, 2));
|
||||
}
|
||||
}
|
||||
addBlush() {
|
||||
if (DEVELOPMENT || BETA) {
|
||||
this.state = {
|
||||
...this.state,
|
||||
expression: createExpression(Eye.Neutral, Eye.Neutral, Muzzle.Smile, Iris.Forward, Iris.Forward, ExpressionExtra.Blush),
|
||||
};
|
||||
this.changed();
|
||||
}
|
||||
}
|
||||
testSize() {
|
||||
function stringifyValues(values: any[]): string {
|
||||
return values.map(x => JSON.stringify(x)).join(typeof values[0] === 'object' ? ',\n\t' : ', ');
|
||||
}
|
||||
if (data) {
|
||||
this.importPony(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
private importPony(data: string) {
|
||||
if (DEVELOPMENT) {
|
||||
this.pony.ponyInfo = decompressPonyString(data, true);
|
||||
const t = decompressPonyString(data, false);
|
||||
console.log(JSON.stringify(t, undefined, 2));
|
||||
}
|
||||
}
|
||||
addBlush() {
|
||||
if (DEVELOPMENT || BETA) {
|
||||
this.state = {
|
||||
...this.state,
|
||||
expression: createExpression(Eye.Neutral, Eye.Neutral, Muzzle.Smile, Iris.Forward, Iris.Forward, ExpressionExtra.Blush),
|
||||
};
|
||||
this.changed();
|
||||
}
|
||||
}
|
||||
testSize() {
|
||||
function stringifyValues(values: any[]): string {
|
||||
return values.map(x => JSON.stringify(x)).join(typeof values[0] === 'object' ? ',\n\t' : ', ');
|
||||
}
|
||||
|
||||
if (DEVELOPMENT) {
|
||||
const compressed = compressPonyString(this.info);
|
||||
const regularSize = JSON.stringify(this.info).length;
|
||||
const ponyInfoNumber = decompressPony(compressed);
|
||||
const precomp = precompressPony(ponyInfoNumber, BLACK, x => x) as any;
|
||||
const details = Object.keys(precomp)
|
||||
.filter(key => key !== 'version')
|
||||
.map(key => ({ key, values: precomp[key] || [] as any[] }))
|
||||
.map(({ key, values }) => `${key}: [\n\t${stringifyValues(values)}\n]`)
|
||||
.join(',\n');
|
||||
const serialized = compressPonyString(this.info);
|
||||
if (DEVELOPMENT) {
|
||||
const compressed = compressPonyString(this.info);
|
||||
const regularSize = JSON.stringify(this.info).length;
|
||||
const ponyInfoNumber = decompressPony(compressed);
|
||||
const precomp = precompressPony(ponyInfoNumber, BLACK, x => x) as any;
|
||||
const details = Object.keys(precomp)
|
||||
.filter(key => key !== 'version')
|
||||
.map(key => ({ key, values: precomp[key] || [] as any[] }))
|
||||
.map(({ key, values }) => `${key}: [\n\t${stringifyValues(values)}\n]`)
|
||||
.join(',\n');
|
||||
const serialized = compressPonyString(this.info);
|
||||
|
||||
console.log(serialized);
|
||||
console.log(details);
|
||||
console.log(`${serialized.length} / ${regularSize}`);
|
||||
}
|
||||
}
|
||||
testJSON() {
|
||||
if (DEVELOPMENT) {
|
||||
console.log(JSON.stringify(this.info, undefined, 2));
|
||||
}
|
||||
}
|
||||
exportPony() {
|
||||
const data = ponyToExport(this.pony) + '\r\n';
|
||||
saveAs(new Blob([data], { type: 'text/plain;charset=utf-8' }), `${this.pony.name}.txt`);
|
||||
}
|
||||
exportPonies() {
|
||||
const data = this.ponies.map(ponyToExport).join('\r\n') + '\r\n';
|
||||
saveAs(new Blob([data], { type: 'text/plain;charset=utf-8' }), 'ponies.txt');
|
||||
}
|
||||
async importPonies(file: File | undefined) {
|
||||
if (file) {
|
||||
const text = await readFileAsText(file);
|
||||
const lines = text.split(/\r?\n/g);
|
||||
let imported = 0;
|
||||
console.log(serialized);
|
||||
console.log(details);
|
||||
console.log(`${serialized.length} / ${regularSize}`);
|
||||
}
|
||||
}
|
||||
testJSON() {
|
||||
if (DEVELOPMENT) {
|
||||
console.log(JSON.stringify(this.info, undefined, 2));
|
||||
}
|
||||
}
|
||||
exportPony() {
|
||||
const data = ponyToExport(this.pony) + '\r\n';
|
||||
saveAs(new Blob([data], { type: 'text/plain;charset=utf-8' }), `${this.pony.name}.txt`);
|
||||
}
|
||||
exportPonies() {
|
||||
const data = this.ponies.map(ponyToExport).join('\r\n') + '\r\n';
|
||||
saveAs(new Blob([data], { type: 'text/plain;charset=utf-8' }), 'ponies.txt');
|
||||
}
|
||||
async importPonies(file: File | undefined) {
|
||||
if (file) {
|
||||
const text = await readFileAsText(file);
|
||||
const lines = text.split(/\r?\n/g);
|
||||
let imported = 0;
|
||||
|
||||
for (const line of lines) {
|
||||
try {
|
||||
const [name, info, desc = ''] = line.split(/\t/g);
|
||||
for (const line of lines) {
|
||||
try {
|
||||
const [name, info, desc = ''] = line.split(/\t/g);
|
||||
|
||||
if (name && info) {
|
||||
const pony: PonyObject = {
|
||||
name,
|
||||
id: '',
|
||||
info,
|
||||
desc,
|
||||
ponyInfo: decompressPonyString(info, true),
|
||||
};
|
||||
if (name && info) {
|
||||
const pony: PonyObject = {
|
||||
name,
|
||||
id: '',
|
||||
info,
|
||||
desc,
|
||||
ponyInfo: decompressPonyString(info, true),
|
||||
};
|
||||
|
||||
await this.model.savePony(pony, true);
|
||||
imported++;
|
||||
}
|
||||
} catch (e) {
|
||||
DEVELOPMENT && console.error(e);
|
||||
}
|
||||
}
|
||||
await this.model.savePony(pony, true);
|
||||
imported++;
|
||||
}
|
||||
} catch (e) {
|
||||
DEVELOPMENT && console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
alert(`Imported ${imported} ponies`);
|
||||
}
|
||||
}
|
||||
alert(`Imported ${imported} ponies`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ponyToExport(pony: PonyObject) {
|
||||
return `${pony.name}\t${pony.info}\t${pony.desc || ''}`.trim();
|
||||
return `${pony.name}\t${pony.info}\t${pony.desc || ''}`.trim();
|
||||
}
|
||||
|
||||
@@ -9,197 +9,197 @@ import { BLACK } from '../../../common/colors';
|
||||
import { Entity, Engine, EngineInfo, DebugFlags, tileTypeNames } from '../../../common/interfaces';
|
||||
|
||||
@Component({
|
||||
selector: 'editor-box',
|
||||
templateUrl: 'editor-box.pug',
|
||||
selector: 'editor-box',
|
||||
templateUrl: 'editor-box.pug',
|
||||
})
|
||||
export class EditorBox {
|
||||
readonly dev = DEVELOPMENT;
|
||||
readonly cogIcon = faCog;
|
||||
readonly editIcon = faEdit;
|
||||
readonly selectIcon = faDrawPolygon;
|
||||
readonly deleteIcon = faTrash;
|
||||
readonly checkIcon = faCheck;
|
||||
readonly emptyIcon = emptyIcon;
|
||||
readonly tiles = ['---', ...tileTypeNames];
|
||||
readonly engines = engines;
|
||||
readonly editorEntities: string[];
|
||||
readonly showFields: (keyof DebugFlags)[] = ['id', 'bounds', 'collider', 'cover', 'interact', 'trigger'];
|
||||
private showEditor = false;
|
||||
constructor(
|
||||
public model: Model,
|
||||
private game: PonyTownGame,
|
||||
private storage: StorageService,
|
||||
private zone: NgZone,
|
||||
) {
|
||||
this.game.editor.type = this.storage.getItem('editor-entity') || 'rock';
|
||||
this.showEditor = this.storage.getBoolean('show-editor');
|
||||
this.editorEntities = getEntityNames().slice().sort();
|
||||
}
|
||||
get editor() {
|
||||
return this.game.editor;
|
||||
}
|
||||
get hasElevation() {
|
||||
return this.game.engine === Engine.LayeredTiles;
|
||||
}
|
||||
get editorElevation() {
|
||||
return this.game.editor.elevation;
|
||||
}
|
||||
get editorSpecial() {
|
||||
return this.game.editor.special;
|
||||
}
|
||||
get editorEntity() {
|
||||
return this.game.editor.type;
|
||||
}
|
||||
set editorEntity(value: string) {
|
||||
this.game.editor.type = value;
|
||||
this.storage.setItem('editor-entity', value);
|
||||
}
|
||||
get editorTile() {
|
||||
return this.game.editor.tile;
|
||||
}
|
||||
set editorTile(value: number) {
|
||||
this.game.editor.tile = value;
|
||||
}
|
||||
get hasEditor() {
|
||||
return this.model.isMod && this.showEditor;
|
||||
}
|
||||
get oneEntity() {
|
||||
return this.editor.selectedEntities[0];
|
||||
}
|
||||
get singleEntity() {
|
||||
return this.editor.selectedEntities.length === 1;
|
||||
}
|
||||
get hasSelectedEntities() {
|
||||
return this.editor.selectedEntities.length > 0;
|
||||
}
|
||||
get isLightEntity() {
|
||||
return this.editor.selectedEntities.some(e => !!e.drawLight);
|
||||
}
|
||||
get isLightSpriteEntity() {
|
||||
return this.editor.selectedEntities.some(e => !!e.drawLightSprite);
|
||||
}
|
||||
get selectingEntities() {
|
||||
return this.game.editor.selectingEntities;
|
||||
}
|
||||
set selectingEntities(value) {
|
||||
this.game.editor.selectingEntities = value;
|
||||
}
|
||||
get shadowOpacity() {
|
||||
return getAlpha(this.game.shadowColor);
|
||||
}
|
||||
set shadowOpacity(value) {
|
||||
this.game.shadowColor = withAlpha(this.game.shadowColor, value);
|
||||
}
|
||||
private getEntityName(type: number) {
|
||||
return getEntityNameFromType(type);
|
||||
}
|
||||
private getEntityValue<T>(map: (entity: Entity) => T) {
|
||||
const entity = this.editor.selectedEntities[0] as any;
|
||||
return map(entity);
|
||||
}
|
||||
get entityName() {
|
||||
const entities = this.editor.selectedEntities;
|
||||
const types = entities.map(e => e.type);
|
||||
const names = uniq(types).map(type => this.getEntityName(type)).join(', ');
|
||||
return types.length === 1 ? `${names} [${entities[0].id}]` : names;
|
||||
}
|
||||
get entityLightColor() {
|
||||
return colorToHexRGB(this.getEntityValue(e => e && e.lightColor || BLACK));
|
||||
}
|
||||
set entityLightColor(value) {
|
||||
this.editor.selectedEntities.forEach(e => e.lightColor = parseColor(value));
|
||||
}
|
||||
get entityLightSpriteColor() {
|
||||
const entity = this.editor.selectedEntities[0];
|
||||
return colorToHexRGB(entity && entity.lightSpriteColor || BLACK);
|
||||
}
|
||||
set entityLightSpriteColor(value) {
|
||||
this.editor.selectedEntities.forEach(e => e.lightSpriteColor = parseColor(value));
|
||||
}
|
||||
get entityLightSpriteX() {
|
||||
const entity = this.editor.selectedEntities[0];
|
||||
return entity && entity.lightSpriteX || 0;
|
||||
}
|
||||
set entityLightSpriteX(value) {
|
||||
console.log('set x', value, this.editor.selectedEntities);
|
||||
this.editor.selectedEntities.forEach(e => e.lightSpriteX = value);
|
||||
}
|
||||
get entityLightSpriteY() {
|
||||
const entity = this.editor.selectedEntities[0];
|
||||
return entity && entity.lightSpriteY || 0;
|
||||
}
|
||||
set entityLightSpriteY(value) {
|
||||
this.editor.selectedEntities.forEach(e => e.lightSpriteY = value);
|
||||
}
|
||||
get entityLightScale() {
|
||||
return this.editor.selectedEntities.length ? this.editor.selectedEntities[0].lightScaleAdjust : 1;
|
||||
}
|
||||
set entityLightScale(value) {
|
||||
this.editor.selectedEntities.forEach(e => e.lightScaleAdjust = value);
|
||||
}
|
||||
get entityX() {
|
||||
return this.oneEntity.x;
|
||||
}
|
||||
set entityX(value) {
|
||||
this.oneEntity.x = value;
|
||||
const { id, x, y } = this.oneEntity;
|
||||
this.game.send(server => server.editorAction({
|
||||
type: 'move',
|
||||
entities: [{ id, x, y }],
|
||||
}));
|
||||
}
|
||||
get entityY() {
|
||||
return this.oneEntity.y;
|
||||
}
|
||||
set entityY(value) {
|
||||
this.oneEntity.y = value;
|
||||
const { id, x, y } = this.oneEntity;
|
||||
this.game.send(server => server.editorAction({
|
||||
type: 'move',
|
||||
entities: [{ id, x, y }],
|
||||
}));
|
||||
}
|
||||
editorClear() {
|
||||
this.game.send(server => server.editorAction({ type: 'clear' }));
|
||||
}
|
||||
clearLocalStorage() {
|
||||
this.storage.clear();
|
||||
}
|
||||
setEngine(engine: EngineInfo) {
|
||||
this.game.engine = engine.engine;
|
||||
}
|
||||
isActiveEngine(engine: EngineInfo) {
|
||||
return this.game.engine === engine.engine;
|
||||
}
|
||||
toggleEditor() {
|
||||
this.zone.run(() => {
|
||||
this.showEditor = !this.showEditor;
|
||||
this.storage.setBoolean('show-editor', this.showEditor);
|
||||
});
|
||||
}
|
||||
toggleSelecting() {
|
||||
this.selectingEntities = !this.selectingEntities;
|
||||
readonly dev = DEVELOPMENT;
|
||||
readonly cogIcon = faCog;
|
||||
readonly editIcon = faEdit;
|
||||
readonly selectIcon = faDrawPolygon;
|
||||
readonly deleteIcon = faTrash;
|
||||
readonly checkIcon = faCheck;
|
||||
readonly emptyIcon = emptyIcon;
|
||||
readonly tiles = ['---', ...tileTypeNames];
|
||||
readonly engines = engines;
|
||||
readonly editorEntities: string[];
|
||||
readonly showFields: (keyof DebugFlags)[] = ['id', 'bounds', 'collider', 'cover', 'interact', 'trigger'];
|
||||
private showEditor = false;
|
||||
constructor(
|
||||
public model: Model,
|
||||
private game: PonyTownGame,
|
||||
private storage: StorageService,
|
||||
private zone: NgZone,
|
||||
) {
|
||||
this.game.editor.type = this.storage.getItem('editor-entity') || 'rock';
|
||||
this.showEditor = this.storage.getBoolean('show-editor');
|
||||
this.editorEntities = getEntityNames().slice().sort();
|
||||
}
|
||||
get editor() {
|
||||
return this.game.editor;
|
||||
}
|
||||
get hasElevation() {
|
||||
return this.game.engine === Engine.LayeredTiles;
|
||||
}
|
||||
get editorElevation() {
|
||||
return this.game.editor.elevation;
|
||||
}
|
||||
get editorSpecial() {
|
||||
return this.game.editor.special;
|
||||
}
|
||||
get editorEntity() {
|
||||
return this.game.editor.type;
|
||||
}
|
||||
set editorEntity(value: string) {
|
||||
this.game.editor.type = value;
|
||||
this.storage.setItem('editor-entity', value);
|
||||
}
|
||||
get editorTile() {
|
||||
return this.game.editor.tile;
|
||||
}
|
||||
set editorTile(value: number) {
|
||||
this.game.editor.tile = value;
|
||||
}
|
||||
get hasEditor() {
|
||||
return this.model.isMod && this.showEditor;
|
||||
}
|
||||
get oneEntity() {
|
||||
return this.editor.selectedEntities[0];
|
||||
}
|
||||
get singleEntity() {
|
||||
return this.editor.selectedEntities.length === 1;
|
||||
}
|
||||
get hasSelectedEntities() {
|
||||
return this.editor.selectedEntities.length > 0;
|
||||
}
|
||||
get isLightEntity() {
|
||||
return this.editor.selectedEntities.some(e => !!e.drawLight);
|
||||
}
|
||||
get isLightSpriteEntity() {
|
||||
return this.editor.selectedEntities.some(e => !!e.drawLightSprite);
|
||||
}
|
||||
get selectingEntities() {
|
||||
return this.game.editor.selectingEntities;
|
||||
}
|
||||
set selectingEntities(value) {
|
||||
this.game.editor.selectingEntities = value;
|
||||
}
|
||||
get shadowOpacity() {
|
||||
return getAlpha(this.game.shadowColor);
|
||||
}
|
||||
set shadowOpacity(value) {
|
||||
this.game.shadowColor = withAlpha(this.game.shadowColor, value);
|
||||
}
|
||||
private getEntityName(type: number) {
|
||||
return getEntityNameFromType(type);
|
||||
}
|
||||
private getEntityValue<T>(map: (entity: Entity) => T) {
|
||||
const entity = this.editor.selectedEntities[0] as any;
|
||||
return map(entity);
|
||||
}
|
||||
get entityName() {
|
||||
const entities = this.editor.selectedEntities;
|
||||
const types = entities.map(e => e.type);
|
||||
const names = uniq(types).map(type => this.getEntityName(type)).join(', ');
|
||||
return types.length === 1 ? `${names} [${entities[0].id}]` : names;
|
||||
}
|
||||
get entityLightColor() {
|
||||
return colorToHexRGB(this.getEntityValue(e => e && e.lightColor || BLACK));
|
||||
}
|
||||
set entityLightColor(value) {
|
||||
this.editor.selectedEntities.forEach(e => e.lightColor = parseColor(value));
|
||||
}
|
||||
get entityLightSpriteColor() {
|
||||
const entity = this.editor.selectedEntities[0];
|
||||
return colorToHexRGB(entity && entity.lightSpriteColor || BLACK);
|
||||
}
|
||||
set entityLightSpriteColor(value) {
|
||||
this.editor.selectedEntities.forEach(e => e.lightSpriteColor = parseColor(value));
|
||||
}
|
||||
get entityLightSpriteX() {
|
||||
const entity = this.editor.selectedEntities[0];
|
||||
return entity && entity.lightSpriteX || 0;
|
||||
}
|
||||
set entityLightSpriteX(value) {
|
||||
console.log('set x', value, this.editor.selectedEntities);
|
||||
this.editor.selectedEntities.forEach(e => e.lightSpriteX = value);
|
||||
}
|
||||
get entityLightSpriteY() {
|
||||
const entity = this.editor.selectedEntities[0];
|
||||
return entity && entity.lightSpriteY || 0;
|
||||
}
|
||||
set entityLightSpriteY(value) {
|
||||
this.editor.selectedEntities.forEach(e => e.lightSpriteY = value);
|
||||
}
|
||||
get entityLightScale() {
|
||||
return this.editor.selectedEntities.length ? this.editor.selectedEntities[0].lightScaleAdjust : 1;
|
||||
}
|
||||
set entityLightScale(value) {
|
||||
this.editor.selectedEntities.forEach(e => e.lightScaleAdjust = value);
|
||||
}
|
||||
get entityX() {
|
||||
return this.oneEntity.x;
|
||||
}
|
||||
set entityX(value) {
|
||||
this.oneEntity.x = value;
|
||||
const { id, x, y } = this.oneEntity;
|
||||
this.game.send(server => server.editorAction({
|
||||
type: 'move',
|
||||
entities: [{ id, x, y }],
|
||||
}));
|
||||
}
|
||||
get entityY() {
|
||||
return this.oneEntity.y;
|
||||
}
|
||||
set entityY(value) {
|
||||
this.oneEntity.y = value;
|
||||
const { id, x, y } = this.oneEntity;
|
||||
this.game.send(server => server.editorAction({
|
||||
type: 'move',
|
||||
entities: [{ id, x, y }],
|
||||
}));
|
||||
}
|
||||
editorClear() {
|
||||
this.game.send(server => server.editorAction({ type: 'clear' }));
|
||||
}
|
||||
clearLocalStorage() {
|
||||
this.storage.clear();
|
||||
}
|
||||
setEngine(engine: EngineInfo) {
|
||||
this.game.engine = engine.engine;
|
||||
}
|
||||
isActiveEngine(engine: EngineInfo) {
|
||||
return this.game.engine === engine.engine;
|
||||
}
|
||||
toggleEditor() {
|
||||
this.zone.run(() => {
|
||||
this.showEditor = !this.showEditor;
|
||||
this.storage.setBoolean('show-editor', this.showEditor);
|
||||
});
|
||||
}
|
||||
toggleSelecting() {
|
||||
this.selectingEntities = !this.selectingEntities;
|
||||
|
||||
if (!this.selectingEntities) {
|
||||
this.editor.selectedEntities.length = 0;
|
||||
}
|
||||
}
|
||||
listEntities() {
|
||||
this.game.send(server => server.editorAction({ type: 'list' }));
|
||||
}
|
||||
deleteEntities() {
|
||||
const entities = this.editor.selectedEntities.map(e => e.id);
|
||||
this.game.send(server => server.editorAction({ type: 'remove', entities }));
|
||||
this.editor.selectedEntities.length = 0;
|
||||
}
|
||||
showEntitiesInfo() {
|
||||
console.log(this.editor.selectedEntities);
|
||||
}
|
||||
toggleShow(field: keyof DebugFlags) {
|
||||
(this.game.debug as any)[field] = !this.isShow(field);
|
||||
this.game.saveDebug();
|
||||
}
|
||||
isShow(field: keyof DebugFlags) {
|
||||
return !!this.game.debug[field];
|
||||
}
|
||||
if (!this.selectingEntities) {
|
||||
this.editor.selectedEntities.length = 0;
|
||||
}
|
||||
}
|
||||
listEntities() {
|
||||
this.game.send(server => server.editorAction({ type: 'list' }));
|
||||
}
|
||||
deleteEntities() {
|
||||
const entities = this.editor.selectedEntities.map(e => e.id);
|
||||
this.game.send(server => server.editorAction({ type: 'remove', entities }));
|
||||
this.editor.selectedEntities.length = 0;
|
||||
}
|
||||
showEntitiesInfo() {
|
||||
console.log(this.editor.selectedEntities);
|
||||
}
|
||||
toggleShow(field: keyof DebugFlags) {
|
||||
(this.game.debug as any)[field] = !this.isShow(field);
|
||||
this.game.saveDebug();
|
||||
}
|
||||
isShow(field: keyof DebugFlags) {
|
||||
return !!this.game.debug[field];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,16 +4,16 @@ import { faArrowLeft, faArrowRight, faArrowUp, faArrowDown } from '../../../clie
|
||||
import { contactEmail } from '../../../client/data';
|
||||
|
||||
@Component({
|
||||
selector: 'help',
|
||||
templateUrl: 'help.pug',
|
||||
styleUrls: ['help.scss'],
|
||||
selector: 'help',
|
||||
templateUrl: 'help.pug',
|
||||
styleUrls: ['help.scss'],
|
||||
})
|
||||
export class Help {
|
||||
readonly leftIcon = faArrowLeft;
|
||||
readonly rightIcon = faArrowRight;
|
||||
readonly upIcon = faArrowUp;
|
||||
readonly downIcon = faArrowDown;
|
||||
readonly emotes = emojis.map(e => e.names[0]);
|
||||
readonly mac = /Macintosh/.test(navigator.userAgent);
|
||||
readonly contactEmail = contactEmail;
|
||||
readonly leftIcon = faArrowLeft;
|
||||
readonly rightIcon = faArrowRight;
|
||||
readonly upIcon = faArrowUp;
|
||||
readonly downIcon = faArrowDown;
|
||||
readonly emotes = emojis.map(e => e.names[0]);
|
||||
readonly mac = /Macintosh/.test(navigator.userAgent);
|
||||
readonly contactEmail = contactEmail;
|
||||
}
|
||||
|
||||
@@ -6,51 +6,51 @@ import { InstallService } from '../../services/installService';
|
||||
import { OAuthProvider, PonyObject } from '../../../common/interfaces';
|
||||
|
||||
@Component({
|
||||
selector: 'home',
|
||||
templateUrl: 'home.pug',
|
||||
styleUrls: ['home.scss'],
|
||||
selector: 'home',
|
||||
templateUrl: 'home.pug',
|
||||
styleUrls: ['home.scss'],
|
||||
})
|
||||
export class Home {
|
||||
state = defaultPonyState();
|
||||
previewPony: PonyObject | undefined = undefined;
|
||||
error?: string;
|
||||
constructor(
|
||||
private gameService: GameService,
|
||||
private model: Model,
|
||||
private installService: InstallService,
|
||||
) {
|
||||
}
|
||||
get authError() {
|
||||
return this.model.authError;
|
||||
}
|
||||
get accountAlert() {
|
||||
return this.model.accountAlert;
|
||||
}
|
||||
get canInstall() {
|
||||
return this.installService.canInstall;
|
||||
}
|
||||
get playing() {
|
||||
return this.gameService.playing;
|
||||
}
|
||||
get loading() {
|
||||
return this.model.loading || this.model.updating;
|
||||
}
|
||||
get account() {
|
||||
return this.model.account;
|
||||
}
|
||||
get pony() {
|
||||
return this.model.pony;
|
||||
}
|
||||
get previewInfo() {
|
||||
return this.previewPony ? this.previewPony.ponyInfo : this.pony.ponyInfo;
|
||||
}
|
||||
get previewName() {
|
||||
return this.previewPony ? this.previewPony.name : this.pony.name;
|
||||
}
|
||||
get previewTag() {
|
||||
return getPonyTag(this.previewPony || this.pony, this.account);
|
||||
}
|
||||
signIn(provider: OAuthProvider) {
|
||||
this.model.signIn(provider);
|
||||
}
|
||||
state = defaultPonyState();
|
||||
previewPony: PonyObject | undefined = undefined;
|
||||
error?: string;
|
||||
constructor(
|
||||
private gameService: GameService,
|
||||
private model: Model,
|
||||
private installService: InstallService,
|
||||
) {
|
||||
}
|
||||
get authError() {
|
||||
return this.model.authError;
|
||||
}
|
||||
get accountAlert() {
|
||||
return this.model.accountAlert;
|
||||
}
|
||||
get canInstall() {
|
||||
return this.installService.canInstall;
|
||||
}
|
||||
get playing() {
|
||||
return this.gameService.playing;
|
||||
}
|
||||
get loading() {
|
||||
return this.model.loading || this.model.updating;
|
||||
}
|
||||
get account() {
|
||||
return this.model.account;
|
||||
}
|
||||
get pony() {
|
||||
return this.model.pony;
|
||||
}
|
||||
get previewInfo() {
|
||||
return this.previewPony ? this.previewPony.ponyInfo : this.pony.ponyInfo;
|
||||
}
|
||||
get previewName() {
|
||||
return this.previewPony ? this.previewPony.name : this.pony.name;
|
||||
}
|
||||
get previewTag() {
|
||||
return getPonyTag(this.previewPony || this.pony, this.account);
|
||||
}
|
||||
signIn(provider: OAuthProvider) {
|
||||
this.model.signIn(provider);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user