Skip to content

Commit

Permalink
improved adding levels in map settings a bit, #255
Browse files Browse the repository at this point in the history
  • Loading branch information
Vegita2 committed Jun 27, 2024
1 parent 773a0a6 commit 9671145
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Show exact match at first position in search [#296](https://github.com/CCDirectLink/crosscode-map-editor/issues/296)
- Changed GlowingLine Step size from 16 to 8 [#276](https://github.com/CCDirectLink/crosscode-map-editor/issues/276)
- Moving an Entity is now tracked in the history [#270](https://github.com/CCDirectLink/crosscode-map-editor/issues/270)
- Adding a new level in Map Settings guesses the correct level instead of using 0 [#255](https://github.com/CCDirectLink/crosscode-map-editor/issues/255)

## [1.5.0] 2024-03-20
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
<input type="text" class="default-input grow" [(ngModel)]="settings.name">
</div>
<hr>

<!--Map Size-->
<div class="flex flex-row gap-2 items-baseline">
<span class="w-24">Map Size:</span>
<span>width: </span>
<input type="number" class="default-input small-input" min="1" [ngModel]="settings.mapWidth" (change)="onNumberChange($event, 'mapWidth')">
<input type="number" class="default-input small-input" min="1" [ngModel]="settings.mapWidth"
(change)="onNumberChange($event, 'mapWidth')">
<span>height: </span>
<input type="number" class="default-input small-input" min="1" [ngModel]="settings.mapHeight" (change)="onNumberChange($event, 'mapHeight')">
<input type="number" class="default-input small-input" min="1" [ngModel]="settings.mapHeight"
(change)="onNumberChange($event, 'mapHeight')">
</div>

<hr>
Expand All @@ -22,12 +24,20 @@
<span class="w-24">Levels: </span>
<div class="flex flex-col gap-1 grow">
<div class="flex flex-row gap-2 items-baseline" *ngFor="let level of settings.levels; let i=index">
<span>Level {{i}}:</span>
<input class="default-input grow" [(ngModel)]="level.height">
<button mat-stroked-button *ngIf="settings.levels.length > 1" (click)="settings.levels.splice(i, 1)" tabindex="-1">Remove</button>
<span>Level {{ i }}:</span>
<input
type="number"
step="16"
class="default-input grow"
[ngModel]="level.height"
(ngModelChange)="level.height = +$event"
>
<button mat-stroked-button *ngIf="settings.levels.length > 1" (click)="settings.levels.splice(i, 1)"
tabindex="-1">Remove
</button>
</div>
<div>
<button mat-stroked-button (click)="settings.levels.push({height: 0})">Add Level</button>
<button mat-stroked-button (click)="settings.levels.push({height: guessHeight()})">Add Level</button>
</div>
</div>
</div>
Expand All @@ -39,7 +49,7 @@
<div class="grow">
<mat-select [(ngModel)]="settings.masterLevel" class="default-input">
<mat-option *ngFor="let level of settings.levels; let i=index" [value]="i">
{{i}}
{{ i }}
</mat-option>
</mat-select>
</div>
Expand All @@ -50,14 +60,15 @@
<div class="attributes-container flex flex-rwo flex-wrap">
<div class="attribute-tile">
<div class="attribute flex flex-row items-baseline">
<span >cameraInBounds: </span>
<span>cameraInBounds: </span>
<mat-checkbox class="material-input" color="primary"
[(ngModel)]="settings.attributes.cameraInBounds"></mat-checkbox>
[(ngModel)]="settings.attributes.cameraInBounds"></mat-checkbox>
</div>
</div>

<div *ngFor="let prop of mapSettings | keyvalue" class="attribute-tile">
<app-string-widget [key]="$any(prop.key)" [custom]="$any(settings.attributes)" [attribute]="$any({options:prop.value})" ></app-string-widget>
<app-string-widget [key]="$any(prop.key)" [custom]="$any(settings.attributes)"
[attribute]="$any({options:prop.value})"></app-string-widget>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ export class MapContentSettingsComponent implements OnInit {
}>();
mapSettings = mapSettingsjson.default;

constructor() { }

constructor() {
}

ngOnInit() {

if (this.settings.levels.length < 1) {
Expand Down Expand Up @@ -53,12 +54,23 @@ export class MapContentSettingsComponent implements OnInit {
// Parent won't update field if same value
// force update value property
numElement.value = value + '';

this.onSettingsChange.emit({
property,
value
});
}
}


guessHeight(): number {
const levels = this.settings.levels;
if (levels.length === 0) {
return 0;
}
if (levels.length === 1) {
return levels[0].height + 16;
}
const [l1, l2] = levels.slice(-2);
return l2.height + (l2.height - l1.height);
}
}

0 comments on commit 9671145

Please sign in to comment.