Implement basic version of characters #32

Merged
sebastian merged 8 commits from characters-2 into main 2024-04-13 11:59:09 +02:00
4 changed files with 32 additions and 4 deletions
Showing only changes of commit 862ed18e1a - Show all commits

View File

@ -71,6 +71,12 @@ function createWindow(): BrowserWindow {
click: () => {
win!.webContents.send('context-menu', "new-scriptaccount");
}
},
{
label: "Character",
click: () => {
win!.webContents.send('context-menu', "new-character");
}
}
]

View File

@ -118,6 +118,7 @@ export class AppComponent implements OnInit{
switch (modelComponentType) {
case ModelComponentType.SCRIPTACCOUNT: this.onCreateNewScriptAccount(); break
case ModelComponentType.GAMESYTEM: this.onCreateNewGamesystem(); break
case ModelComponentType.CHARACTER: this.onCreateNewCharacter(); break
}
}
@ -146,6 +147,15 @@ export class AppComponent implements OnInit{
}
}
private onCreateNewCharacter() {
const createdCharacter = this.gameModel!.createCharacter("New Character")
if(createdCharacter != undefined) {
this.editor?.openGameModelComponent(createdCharacter);
} else {
console.log("[DEBUG] [App-Component] ScriptAccount could not be created (Name not unique)");
}
}
private getSelectedModelComponent(): ModelComponent | undefined {
if(this.openContent == ModelComponentType.SCRIPTACCOUNT) {
if(this.scriptAccountOverview != undefined) {
@ -239,4 +249,6 @@ export class AppComponent implements OnInit{
this.gamesystemOverview.resetSelectedGamesystem()
}
}
}

View File

@ -16,8 +16,8 @@ export class GameModel {
constructor(gameModelName: string) {
this.gameModelName = gameModelName;
this.characters.push(new Character("Astrid Hofferson", "", ModelComponentType.CHARACTER))
this.characters.push(new Character("Hicks Haddock", "", ModelComponentType.CHARACTER))
this.characters.push(new Character("Astrid Hofferson", ""))
this.characters.push(new Character("Hicks Haddock", ""))
}
addGamesystem(gamesystem: Gamesystem<any, any>) {
@ -69,6 +69,16 @@ export class GameModel {
}
}
createCharacter(characterName: string) {
const searchedCharacter = this.characters.find(character => character.componentName === characterName);
if(searchedCharacter == undefined) {
const character = new Character(characterName, "");
this.characters.push(character)
return character
}
return undefined
}
removeScriptAccount(scriptAccount: ScriptAccount) {
if(scriptAccount != undefined) {
this.scriptAccounts = this.scriptAccounts.filter(s => s != scriptAccount);

View File

@ -3,7 +3,7 @@ import {ModelComponentType} from "../ModelComponentType";
export class Character extends ModelComponent{
constructor(componentName: string, componentDescription: string, type: ModelComponentType) {
super(componentName, componentDescription, type);
constructor(componentName: string, componentDescription: string) {
super(componentName, componentDescription, ModelComponentType.CHARACTER);
}
}