main #48

Closed
sebastian wants to merge 44 commits from main into inventory
3 changed files with 32 additions and 34 deletions
Showing only changes of commit 92608125fb - Show all commits

View File

@ -33,6 +33,7 @@ import {ItemgroupCreator} from "./project/game-model/utils/creator/ItemgroupCrea
import {ItemOverviewComponent} from "./side-overviews/item-overview/item-overview.component"; import {ItemOverviewComponent} from "./side-overviews/item-overview/item-overview.component";
import {Overview} from "./side-overviews/Overview"; import {Overview} from "./side-overviews/Overview";
import {ItemCreator} from "./project/game-model/utils/creator/ItemCreator"; import {ItemCreator} from "./project/game-model/utils/creator/ItemCreator";
import {ScriptAccountCreator} from "./project/game-model/utils/creator/ScriptAccountCreator";
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -86,7 +87,7 @@ export class AppComponent implements OnInit{
} else if(message.startsWith("new")) { } else if(message.startsWith("new")) {
const splittedMessage = message.split("-"); const splittedMessage = message.split("-");
const modelComponentType = ModelComponentTypeUtillities.fromString(splittedMessage[1]); const modelComponentType = ModelComponentTypeUtillities.fromString(splittedMessage[1]);
if(modelComponentType) { if(modelComponentType !== undefined) {
let creationContext = ""; let creationContext = "";
if(splittedMessage.length > 2) { if(splittedMessage.length > 2) {
creationContext = splittedMessage[2]; creationContext = splittedMessage[2];
@ -100,6 +101,9 @@ export class AppComponent implements OnInit{
case ModelComponentType.ITEM: { case ModelComponentType.ITEM: {
componentCreator = new ItemCreator(creationContext, this.gameModel!, this.selectedModelComponent); componentCreator = new ItemCreator(creationContext, this.gameModel!, this.selectedModelComponent);
} break } break
case ModelComponentType.SCRIPTACCOUNT: {
componentCreator = new ScriptAccountCreator(creationContext, this.gameModel!, this.selectedModelComponent);
} break
} }
if(componentCreator) { if(componentCreator) {
@ -162,23 +166,6 @@ export class AppComponent implements OnInit{
}) })
} }
private onCreateModelComponent(modelComponentType: ModelComponentType, templateType: TemplateType | undefined) {
switch (modelComponentType) {
case ModelComponentType.SCRIPTACCOUNT: this.onCreateNewScriptAccount(); break
case ModelComponentType.GAMESYTEM: this.onCreateNewGamesystem(templateType); break
case ModelComponentType.CHARACTER: this.onCreateNewCharacter(); break
}
}
private onCreateNewScriptAccount() {
const createdScriptAccount = this.gameModel!.createScriptAccount("New ScriptAccount");
if(createdScriptAccount != undefined) {
this.editor?.openGameModelComponent(createdScriptAccount);
} else {
console.log("[DEBUG] [App-Component] ScriptAccount could not be created (Name not unique)");
}
}
private onCreateNewGamesystem(templateType: TemplateType | undefined) { private onCreateNewGamesystem(templateType: TemplateType | undefined) {
let parentGamesystemName = undefined let parentGamesystemName = undefined
if(this.openContent != ModelComponentType.GAMESYTEM) { if(this.openContent != ModelComponentType.GAMESYTEM) {
@ -349,7 +336,4 @@ export class AppComponent implements OnInit{
return undefined; return undefined;
} }
} }
protected readonly open = open;
} }

View File

@ -61,16 +61,12 @@ export class GameModel {
} }
} }
createScriptAccount(scriptAccountName: string) { addScriptAccount(scriptAccount: ScriptAccount) {
if(scriptAccountName != undefined && scriptAccountName.length > 0) { if(!this.scriptAccounts.find(sA => sA.componentName === scriptAccount.componentName)) {
const scriptAccount = new ScriptAccount(scriptAccountName, ""); this.scriptAccounts.push(scriptAccount)
const searchedScriptAccount = this.scriptAccounts.find(s => s.componentName === scriptAccount.componentName); return true;
if(searchedScriptAccount == undefined) {
this.scriptAccounts.push(scriptAccount);
return scriptAccount;
}
} }
return undefined; return false;
} }
createSimpleGamesystem(gamesystemName: string, templateType: TemplateType | undefined, pushToTop: boolean = true) { createSimpleGamesystem(gamesystemName: string, templateType: TemplateType | undefined, pushToTop: boolean = true) {
@ -194,10 +190,6 @@ export class GameModel {
} }
} }
addScriptAccount(scriptAccount: ScriptAccount) {
this.scriptAccounts.push(scriptAccount);
}
generateProductSystemContents() { generateProductSystemContents() {
this.gamesystems.forEach(gamesystem => { this.gamesystems.forEach(gamesystem => {
if(gamesystem instanceof ProductGamesystem) { if(gamesystem instanceof ProductGamesystem) {

View File

@ -0,0 +1,22 @@
import {ModelComponentCreator} from "./ModelComponentCreator";
import {GameModel} from "../../GameModel";
import {ModelComponent} from "../../ModelComponent";
import {ScriptAccount} from "../../scriptAccounts/ScriptAccount";
export class ScriptAccountCreator extends ModelComponentCreator {
constructor(context: string, gameModel: GameModel, selectedComponent: ModelComponent | undefined) {
super(context, gameModel, selectedComponent);
}
createModelComponent(): ModelComponent | undefined {
const scriptAccount = new ScriptAccount("New ScriptAccount", "");
if(this.gameModel.addScriptAccount(scriptAccount)) {
return scriptAccount;
} else {
return undefined;
}
}
}