This commit is contained in:
parent
c66049c4d8
commit
7132030a81
@ -32,7 +32,7 @@
|
|||||||
<app-script-account-overview *ngIf="openContent == ModelComponentType.SCRIPTACCOUNT" #scriptAccountOverview [gameModel]="gameModel" (onOpenScriptAccount)="openModelComponent($event)"></app-script-account-overview>
|
<app-script-account-overview *ngIf="openContent == ModelComponentType.SCRIPTACCOUNT" #scriptAccountOverview [gameModel]="gameModel" (onOpenScriptAccount)="openModelComponent($event)"></app-script-account-overview>
|
||||||
<app-gamescript-overview *ngIf="openContent == ModelComponentType.GAMESYTEM" #gamesystemOverview [gameModel]="gameModel" (openGamesystemEditor)="openModelComponent($event)"></app-gamescript-overview>
|
<app-gamescript-overview *ngIf="openContent == ModelComponentType.GAMESYTEM" #gamesystemOverview [gameModel]="gameModel" (openGamesystemEditor)="openModelComponent($event)"></app-gamescript-overview>
|
||||||
<app-character-overview *ngIf="openContent == ModelComponentType.CHARACTER" #characterOverview [gameModel]="gameModel" (onOpenCharacterEditor)="openModelComponent($event)"></app-character-overview>
|
<app-character-overview *ngIf="openContent == ModelComponentType.CHARACTER" #characterOverview [gameModel]="gameModel" (onOpenCharacterEditor)="openModelComponent($event)"></app-character-overview>
|
||||||
<app-item-overview *ngIf="openContent == ModelComponentType.ITEMGROUP || openContent == ModelComponentType.ITEM" #itemOverview [gameModel]="gameModel"></app-item-overview>
|
<app-item-overview *ngIf="openContent == ModelComponentType.ITEMGROUP || openContent == ModelComponentType.ITEM" #itemOverview [gameModel]="gameModel" (openItemgroupEmitter)="openModelComponent($event)"></app-item-overview>
|
||||||
</mat-drawer>
|
</mat-drawer>
|
||||||
|
|
||||||
<div class="example-sidenav-content">
|
<div class="example-sidenav-content">
|
||||||
|
@ -83,6 +83,7 @@ import {
|
|||||||
StateInitialCellComponent
|
StateInitialCellComponent
|
||||||
} from "./editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component";
|
} from "./editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component";
|
||||||
import {ItemOverviewComponent} from "./side-overviews/item-overview/item-overview.component";
|
import {ItemOverviewComponent} from "./side-overviews/item-overview/item-overview.component";
|
||||||
|
import {ItemGroupEditorComponent} from "./editor/items/item-group-editor/item-group-editor.component";
|
||||||
|
|
||||||
// AoT requires an exported function for factories
|
// AoT requires an exported function for factories
|
||||||
const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json');
|
const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json');
|
||||||
@ -111,69 +112,70 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl
|
|||||||
StateInitialCellComponent,
|
StateInitialCellComponent,
|
||||||
ItemOverviewComponent
|
ItemOverviewComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
CoreModule,
|
CoreModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
TranslateModule.forRoot({
|
TranslateModule.forRoot({
|
||||||
loader: {
|
loader: {
|
||||||
provide: TranslateLoader,
|
provide: TranslateLoader,
|
||||||
useFactory: httpLoaderFactory,
|
useFactory: httpLoaderFactory,
|
||||||
deps: [HttpClient]
|
deps: [HttpClient]
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
BrowserAnimationsModule,
|
BrowserAnimationsModule,
|
||||||
MatIcon,
|
MatIcon,
|
||||||
MatToolbar,
|
MatToolbar,
|
||||||
MatButton,
|
MatButton,
|
||||||
MatFormField,
|
MatFormField,
|
||||||
MatInput,
|
MatInput,
|
||||||
MatDrawerContainer,
|
MatDrawerContainer,
|
||||||
MatDrawer,
|
MatDrawer,
|
||||||
MatIconButton,
|
MatIconButton,
|
||||||
MatMenuTrigger,
|
MatMenuTrigger,
|
||||||
MatMenu,
|
MatMenu,
|
||||||
MatMenuItem,
|
MatMenuItem,
|
||||||
MatListItem,
|
MatListItem,
|
||||||
MatActionList,
|
MatActionList,
|
||||||
MatTabGroup,
|
MatTabGroup,
|
||||||
MatTab,
|
MatTab,
|
||||||
MatTabLabel,
|
MatTabLabel,
|
||||||
MatLabel,
|
MatLabel,
|
||||||
MatFormField,
|
MatFormField,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
MatError,
|
MatError,
|
||||||
MatDialogTitle,
|
MatDialogTitle,
|
||||||
MatDialogContent,
|
MatDialogContent,
|
||||||
MatDialogActions,
|
MatDialogActions,
|
||||||
MatMiniFabButton,
|
MatMiniFabButton,
|
||||||
MatTreeModule,
|
MatTreeModule,
|
||||||
MatTable,
|
MatTable,
|
||||||
MatColumnDef,
|
MatColumnDef,
|
||||||
MatHeaderCell,
|
MatHeaderCell,
|
||||||
MatHeaderCellDef,
|
MatHeaderCellDef,
|
||||||
MatCellDef,
|
MatCellDef,
|
||||||
MatCell,
|
MatCell,
|
||||||
MatHeaderRow,
|
MatHeaderRow,
|
||||||
MatRow,
|
MatRow,
|
||||||
MatHeaderRowDef,
|
MatHeaderRowDef,
|
||||||
MatRowDef,
|
MatRowDef,
|
||||||
MatCheckbox,
|
MatCheckbox,
|
||||||
MatSelect,
|
MatSelect,
|
||||||
MatOption,
|
MatOption,
|
||||||
MatHint,
|
MatHint,
|
||||||
MatTooltip,
|
MatTooltip,
|
||||||
MatCard,
|
MatCard,
|
||||||
MatCardContent,
|
MatCardContent,
|
||||||
MatCardHeader,
|
MatCardHeader,
|
||||||
MatAccordion,
|
MatAccordion,
|
||||||
MatExpansionPanel,
|
MatExpansionPanel,
|
||||||
MatExpansionPanelTitle,
|
MatExpansionPanelTitle,
|
||||||
MatCardTitle,
|
MatCardTitle,
|
||||||
MatExpansionPanelHeader
|
MatExpansionPanelHeader,
|
||||||
],
|
ItemGroupEditorComponent
|
||||||
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
})
|
})
|
||||||
|
@ -20,5 +20,6 @@
|
|||||||
>
|
>
|
||||||
|
|
||||||
</app-character-editor>
|
</app-character-editor>
|
||||||
|
<app-item-group-editor *ngIf="modelComponent.type === ModelComponentType.ITEMGROUP"></app-item-group-editor>
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
</mat-tab-group>
|
</mat-tab-group>
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
<p>item-group-editor works!</p>
|
@ -0,0 +1,23 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ItemGroupEditorComponent } from './item-group-editor.component';
|
||||||
|
|
||||||
|
describe('ItemGroupEditorComponent', () => {
|
||||||
|
let component: ItemGroupEditorComponent;
|
||||||
|
let fixture: ComponentFixture<ItemGroupEditorComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [ItemGroupEditorComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(ItemGroupEditorComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,12 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-item-group-editor',
|
||||||
|
standalone: true,
|
||||||
|
imports: [],
|
||||||
|
templateUrl: './item-group-editor.component.html',
|
||||||
|
styleUrl: './item-group-editor.component.scss'
|
||||||
|
})
|
||||||
|
export class ItemGroupEditorComponent {
|
||||||
|
|
||||||
|
}
|
@ -69,7 +69,7 @@ export class GameModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static findItemgroupByName(name: string, itemgroups: ItemGroup[]) {
|
public static findItemgroupByName(name: string, itemgroups: ItemGroup[]) {
|
||||||
const itemgroupQueue: ItemGroup[] = itemgroups.concat();
|
const itemgroupQueue: ItemGroup[] = itemgroups.concat();
|
||||||
while(itemgroupQueue.length > 0 ) {
|
while(itemgroupQueue.length > 0 ) {
|
||||||
const currentItemgroup = itemgroupQueue.shift()!;
|
const currentItemgroup = itemgroupQueue.shift()!;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl">
|
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl">
|
||||||
<!-- This is the tree node template for leaf nodes -->
|
<!-- This is the tree node template for leaf nodes -->
|
||||||
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding matTreeNodePaddingIndent="10">
|
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding matTreeNodePaddingIndent="10" (click)="onSelectItem(node)" (contextmenu)="onSelectItem(node)" (dblclick)="openItemEditor(node)">
|
||||||
<!-- use a disabled button to provide padding for tree leaf -->
|
<!-- use a disabled button to provide padding for tree leaf -->
|
||||||
<button class="small-icon-button" mat-icon-button disabled></button>
|
<button class="small-icon-button" mat-icon-button disabled></button>
|
||||||
<mat-icon class="small-icon-button" *ngIf="node.type == ModelComponentType.ITEMGROUP">folder</mat-icon>
|
<mat-icon class="small-icon-button" *ngIf="node.type == ModelComponentType.ITEMGROUP">folder</mat-icon>
|
||||||
@ -8,7 +8,7 @@
|
|||||||
{{node.name}}
|
{{node.name}}
|
||||||
</mat-tree-node>
|
</mat-tree-node>
|
||||||
<!-- This is the tree node template for expandable nodes -->
|
<!-- This is the tree node template for expandable nodes -->
|
||||||
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding matTreeNodePaddingIndent="10">
|
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding matTreeNodePaddingIndent="10" (click)="onSelectItem(node)" (contextmenu)="onSelectItem(node)" (dblclick)="openItemEditor(node)">
|
||||||
<button class="small-icon-button" mat-icon-button matTreeNodeToggle
|
<button class="small-icon-button" mat-icon-button matTreeNodeToggle
|
||||||
[attr.aria-label]="'Toggle ' + node.name">
|
[attr.aria-label]="'Toggle ' + node.name">
|
||||||
<mat-icon class="mat-icon-rtl-mirror">
|
<mat-icon class="mat-icon-rtl-mirror">
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
import {Component, Input, OnInit} from '@angular/core';
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||||
import {GameModel} from "../../project/game-model/GameModel";
|
import {GameModel} from "../../project/game-model/GameModel";
|
||||||
import {FlatTreeControl} from "@angular/cdk/tree";
|
import {FlatTreeControl} from "@angular/cdk/tree";
|
||||||
import {MatTreeFlatDataSource, MatTreeFlattener} from "@angular/material/tree";
|
import {MatTreeFlatDataSource, MatTreeFlattener} from "@angular/material/tree";
|
||||||
import {ItemGroup} from "../../project/game-model/inventory/ItemGroup";
|
|
||||||
import {AbstractItemGroup} from "../../project/game-model/inventory/AbstractItemGroup";
|
import {AbstractItemGroup} from "../../project/game-model/inventory/AbstractItemGroup";
|
||||||
import {ConcreteItemGroup} from "../../project/game-model/inventory/ConcreteItemGroup";
|
import {ConcreteItemGroup} from "../../project/game-model/inventory/ConcreteItemGroup";
|
||||||
import {ModelComponent} from "../../project/game-model/ModelComponent";
|
import {ModelComponent} from "../../project/game-model/ModelComponent";
|
||||||
import {Item} from "../../project/game-model/inventory/Item";
|
|
||||||
import {ModelComponentType} from "../../project/game-model/ModelComponentType";
|
import {ModelComponentType} from "../../project/game-model/ModelComponentType";
|
||||||
|
import {ItemGroup} from "../../project/game-model/inventory/ItemGroup";
|
||||||
|
|
||||||
interface FlatNode {
|
interface FlatNode {
|
||||||
expandable: boolean,
|
expandable: boolean,
|
||||||
@ -24,6 +23,7 @@ interface FlatNode {
|
|||||||
export class ItemOverviewComponent implements OnInit{
|
export class ItemOverviewComponent implements OnInit{
|
||||||
|
|
||||||
@Input() gameModel: GameModel | undefined
|
@Input() gameModel: GameModel | undefined
|
||||||
|
@Output() openItemgroupEmitter: EventEmitter<ItemGroup> = new EventEmitter();
|
||||||
|
|
||||||
private _transformer = (node: ModelComponent, level: number) => {
|
private _transformer = (node: ModelComponent, level: number) => {
|
||||||
if(node instanceof AbstractItemGroup) {
|
if(node instanceof AbstractItemGroup) {
|
||||||
@ -64,6 +64,7 @@ export class ItemOverviewComponent implements OnInit{
|
|||||||
);
|
);
|
||||||
|
|
||||||
dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
|
dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
|
||||||
|
selectedItem: FlatNode | undefined
|
||||||
|
|
||||||
hasChild = (_: number, node: FlatNode) => node.expandable;
|
hasChild = (_: number, node: FlatNode) => node.expandable;
|
||||||
|
|
||||||
@ -82,4 +83,17 @@ export class ItemOverviewComponent implements OnInit{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected readonly ModelComponentType = ModelComponentType;
|
protected readonly ModelComponentType = ModelComponentType;
|
||||||
|
|
||||||
|
onSelectItem(node: FlatNode) {
|
||||||
|
this.selectedItem = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
openItemEditor(node: FlatNode) {
|
||||||
|
if(node.type == ModelComponentType.ITEMGROUP) {
|
||||||
|
const itemGroup = GameModel.findItemgroupByName(node.name, this.gameModel!.itemgroups);
|
||||||
|
if(itemGroup) {
|
||||||
|
this.openItemgroupEmitter.emit(itemGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user