main #48
@ -33,6 +33,7 @@ import {ItemgroupCreator} from "./project/game-model/utils/creator/ItemgroupCrea
 | 
			
		||||
import {ItemOverviewComponent} from "./side-overviews/item-overview/item-overview.component";
 | 
			
		||||
import {Overview} from "./side-overviews/Overview";
 | 
			
		||||
import {ItemCreator} from "./project/game-model/utils/creator/ItemCreator";
 | 
			
		||||
import {ScriptAccountCreator} from "./project/game-model/utils/creator/ScriptAccountCreator";
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-root',
 | 
			
		||||
@ -86,7 +87,7 @@ export class AppComponent implements OnInit{
 | 
			
		||||
    } else if(message.startsWith("new")) {
 | 
			
		||||
      const splittedMessage = message.split("-");
 | 
			
		||||
      const modelComponentType = ModelComponentTypeUtillities.fromString(splittedMessage[1]);
 | 
			
		||||
      if(modelComponentType) {
 | 
			
		||||
      if(modelComponentType !== undefined) {
 | 
			
		||||
        let creationContext = "";
 | 
			
		||||
        if(splittedMessage.length > 2) {
 | 
			
		||||
          creationContext = splittedMessage[2];
 | 
			
		||||
@ -100,6 +101,9 @@ export class AppComponent implements OnInit{
 | 
			
		||||
          case ModelComponentType.ITEM: {
 | 
			
		||||
            componentCreator = new ItemCreator(creationContext, this.gameModel!, this.selectedModelComponent);
 | 
			
		||||
          } break
 | 
			
		||||
          case ModelComponentType.SCRIPTACCOUNT: {
 | 
			
		||||
            componentCreator = new ScriptAccountCreator(creationContext, this.gameModel!, this.selectedModelComponent);
 | 
			
		||||
          } break
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        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) {
 | 
			
		||||
    let parentGamesystemName = undefined
 | 
			
		||||
    if(this.openContent != ModelComponentType.GAMESYTEM) {
 | 
			
		||||
@ -349,7 +336,4 @@ export class AppComponent implements OnInit{
 | 
			
		||||
      return undefined;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  protected readonly open = open;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -61,16 +61,12 @@ export class GameModel {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  createScriptAccount(scriptAccountName: string) {
 | 
			
		||||
    if(scriptAccountName != undefined && scriptAccountName.length > 0) {
 | 
			
		||||
      const scriptAccount = new ScriptAccount(scriptAccountName, "");
 | 
			
		||||
      const searchedScriptAccount = this.scriptAccounts.find(s => s.componentName === scriptAccount.componentName);
 | 
			
		||||
      if(searchedScriptAccount == undefined) {
 | 
			
		||||
        this.scriptAccounts.push(scriptAccount);
 | 
			
		||||
        return scriptAccount;
 | 
			
		||||
      }
 | 
			
		||||
  addScriptAccount(scriptAccount: ScriptAccount) {
 | 
			
		||||
    if(!this.scriptAccounts.find(sA => sA.componentName === scriptAccount.componentName)) {
 | 
			
		||||
      this.scriptAccounts.push(scriptAccount)
 | 
			
		||||
      return true;
 | 
			
		||||
    }
 | 
			
		||||
    return undefined;
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  createSimpleGamesystem(gamesystemName: string, templateType: TemplateType | undefined, pushToTop: boolean = true) {
 | 
			
		||||
@ -194,10 +190,6 @@ export class GameModel {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  addScriptAccount(scriptAccount: ScriptAccount) {
 | 
			
		||||
    this.scriptAccounts.push(scriptAccount);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  generateProductSystemContents() {
 | 
			
		||||
    this.gamesystems.forEach(gamesystem => {
 | 
			
		||||
      if(gamesystem instanceof ProductGamesystem) {
 | 
			
		||||
 | 
			
		||||
@ -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;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user