-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixed icons being off-center * added ui for entity grid, #292 * added visible grid
- Loading branch information
Showing
21 changed files
with
530 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
webapp/src/app/components/toolbar/grid-menu/grid-menu.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<div class="flex flex-row items-center h-full"> | ||
<ng-container | ||
*ngIf="gridSettings() as settings" | ||
> | ||
<mat-checkbox | ||
[ngModel]="settings.enableGrid" | ||
(ngModelChange)="update({enableGrid: $event})" | ||
color="primary" | ||
> | ||
Entity Grid | ||
</mat-checkbox> | ||
<div class="ml-2"> | ||
<button | ||
mat-icon-button | ||
(click)="toggleSettings()" | ||
> | ||
<mat-icon>settings</mat-icon> | ||
</button> | ||
</div> | ||
<div | ||
*ngIf="settings.showSettings" | ||
@openClose | ||
class="flex flex-row gap-2.5 items-center extended-menu ml-2" | ||
> | ||
<mat-form-field | ||
appearance="outline" | ||
class="no-padding-form-field point-form-field" | ||
> | ||
<mat-label>Size</mat-label> | ||
<app-point-input | ||
[ngModel]="settings.size" | ||
(ngModelChange)="update({size: $event})" | ||
></app-point-input> | ||
</mat-form-field> | ||
|
||
<mat-form-field | ||
appearance="outline" | ||
class="no-padding-form-field point-form-field" | ||
> | ||
<mat-label>Offset</mat-label> | ||
<app-point-input | ||
[ngModel]="settings.offset" | ||
[min]="-999" | ||
(ngModelChange)="update({offset: $event})" | ||
></app-point-input> | ||
</mat-form-field> | ||
<input | ||
type="color" | ||
[ngModel]="settings.color" | ||
(ngModelChange)="update({color: $event})" | ||
/> | ||
<mat-checkbox | ||
[ngModel]="settings.visible" | ||
(ngModelChange)="update({visible: $event})" | ||
color="primary" | ||
> | ||
Visible | ||
</mat-checkbox> | ||
</div> | ||
</ng-container> | ||
</div> |
15 changes: 15 additions & 0 deletions
15
webapp/src/app/components/toolbar/grid-menu/grid-menu.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
:host { | ||
display: flex; | ||
align-items: center; | ||
height: 100%; | ||
} | ||
|
||
.point-form-field { | ||
width: 170px; | ||
} | ||
|
||
.extended-menu { | ||
overflow-x: hidden; | ||
min-width: 0; | ||
height: 100%; | ||
} |
96 changes: 96 additions & 0 deletions
96
webapp/src/app/components/toolbar/grid-menu/grid-menu.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { Component, effect, OnInit } from '@angular/core'; | ||
import { MatCheckbox } from '@angular/material/checkbox'; | ||
import { MatIconButton } from '@angular/material/button'; | ||
import { MatIcon } from '@angular/material/icon'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { Globals } from '../../../services/globals'; | ||
import { NgIf } from '@angular/common'; | ||
import { MatFormField, MatLabel } from '@angular/material/form-field'; | ||
import { MatInput } from '@angular/material/input'; | ||
import { PointInputComponent } from '../vec-input/point-input.component'; | ||
import { Helper } from '../../../services/phaser/helper'; | ||
import { Point } from '../../../models/cross-code-map'; | ||
import { animate, state, style, transition, trigger } from '@angular/animations'; | ||
import { GlobalEventsService } from '../../../services/global-events.service'; | ||
|
||
export interface GridSettings { | ||
size: Point; | ||
offset: Point; | ||
color: string; | ||
enableGrid: boolean; | ||
showSettings?: boolean; | ||
visible?: boolean; | ||
} | ||
|
||
const gridSettingsKey = 'gridSettingsKey'; | ||
|
||
@Component({ | ||
selector: 'app-grid-menu', | ||
standalone: true, | ||
animations: [ | ||
trigger('openClose', [ | ||
state('void', style({ | ||
width: '0', | ||
margin: '0' | ||
})), | ||
transition('* <=> *', [ | ||
animate('100ms ease'), | ||
]), | ||
]) | ||
], | ||
imports: [ | ||
MatCheckbox, | ||
MatIconButton, | ||
MatIcon, | ||
FormsModule, | ||
NgIf, | ||
MatFormField, | ||
MatInput, | ||
MatLabel, | ||
PointInputComponent | ||
], | ||
templateUrl: './grid-menu.component.html', | ||
styleUrl: './grid-menu.component.scss' | ||
}) | ||
export class GridMenuComponent implements OnInit { | ||
|
||
gridSettings = Globals.gridSettings; | ||
|
||
constructor( | ||
events: GlobalEventsService | ||
) { | ||
effect(() => { | ||
const settings = this.gridSettings(); | ||
localStorage.setItem(gridSettingsKey, JSON.stringify(settings)); | ||
events.gridSettings.next(settings); | ||
}); | ||
} | ||
|
||
ngOnInit() { | ||
try { | ||
const settings = JSON.parse(localStorage.getItem(gridSettingsKey)!) as Partial<GridSettings>; | ||
Globals.gridSettings.update(old => ({ | ||
...old, | ||
...settings | ||
})); | ||
} catch (e) { | ||
} | ||
} | ||
|
||
update(newSettings: Partial<GridSettings>) { | ||
Globals.gridSettings.update(old => { | ||
const cpy = Helper.copy(old); | ||
Object.assign(cpy, newSettings); | ||
return cpy; | ||
}); | ||
} | ||
|
||
protected readonly MatCheckbox = MatCheckbox; | ||
|
||
toggleSettings() { | ||
Globals.gridSettings.update(old => ({ | ||
...old, | ||
showSettings: !old.showSettings | ||
})); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
webapp/src/app/components/toolbar/toolbar-divider/toolbar-divider.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
:host { | ||
width: 1px; | ||
height: 100%; | ||
background: rgba(255, 255, 255, 0.24); | ||
margin: 0 28px; | ||
} |
11 changes: 11 additions & 0 deletions
11
webapp/src/app/components/toolbar/toolbar-divider/toolbar-divider.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-toolbar-divider', | ||
standalone: true, | ||
imports: [], | ||
template: '', | ||
styleUrl: './toolbar-divider.component.scss' | ||
}) | ||
export class ToolbarDividerComponent { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
webapp/src/app/components/toolbar/vec-input/point-input.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div role="group" class="flex flex-row gap-1.5" | ||
[formGroup]="parts" | ||
(focusin)="onFocusIn($event)" | ||
(focusout)="onFocusOut($event)"> | ||
<span class="input-label">X:</span> | ||
<input formControlName="x" | ||
[min]="min" | ||
max="999" | ||
type="number" | ||
(input)="update()" | ||
> | ||
<span class="input-label">Y:</span> | ||
<input formControlName="y" | ||
[min]="min" | ||
max="999" | ||
type="number" | ||
(input)="update()" | ||
> | ||
</div> |
21 changes: 21 additions & 0 deletions
21
webapp/src/app/components/toolbar/vec-input/point-input.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
input { | ||
border: none; | ||
background: none; | ||
padding: 0 0 0 4px; | ||
outline: none; | ||
font: inherit; | ||
color: currentcolor; | ||
min-width: 0; | ||
flex: 1; | ||
background: rgba(255, 255, 255, 0.1); | ||
border-radius: 1px; | ||
} | ||
|
||
.input-label { | ||
opacity: 0; | ||
transition: opacity 200ms; | ||
} | ||
|
||
:host.floating .input-label { | ||
opacity: 1; | ||
} |
Oops, something went wrong.