issue-15 #21
@ -1,50 +0,0 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
exports.DeleteTransaction = void 0;
 | 
			
		||||
const path = require("node:path");
 | 
			
		||||
const fs = require("fs");
 | 
			
		||||
class DeleteTransaction {
 | 
			
		||||
    static deleteScriptAccount(projectDir, componentName) {
 | 
			
		||||
        const filename = path.join(projectDir, "script-accounts", componentName + ".json");
 | 
			
		||||
        fs.unlinkSync(filename);
 | 
			
		||||
        console.log("Delete ", filename);
 | 
			
		||||
    }
 | 
			
		||||
    static deleteGamesystem(projectDir, componentName) {
 | 
			
		||||
        const gamesystemDir = path.join(projectDir, "gamesystems");
 | 
			
		||||
        const gamesystemFile = this.findGamesystemPath(gamesystemDir, componentName);
 | 
			
		||||
        try {
 | 
			
		||||
            if (gamesystemFile != undefined) {
 | 
			
		||||
                console.log("Delete Gamesystem under File: ", gamesystemFile);
 | 
			
		||||
                if (fs.lstatSync(gamesystemFile).isDirectory()) {
 | 
			
		||||
                    fs.rmSync(gamesystemFile, { recursive: true, force: true });
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    fs.unlinkSync(gamesystemFile);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (e) {
 | 
			
		||||
            console.log(e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    static findGamesystemPath(gamesystemRootDir, searchedFilename) {
 | 
			
		||||
        const directoriesToProcess = [];
 | 
			
		||||
        directoriesToProcess.push(gamesystemRootDir);
 | 
			
		||||
        while (directoriesToProcess.length > 0) {
 | 
			
		||||
            const currentDirectory = directoriesToProcess.shift();
 | 
			
		||||
            const filesInDirectory = fs.readdirSync(currentDirectory);
 | 
			
		||||
            for (let i = 0; i < filesInDirectory.length; i++) {
 | 
			
		||||
                const currentFile = path.join(currentDirectory, filesInDirectory[i]);
 | 
			
		||||
                if (fs.lstatSync(currentFile).isDirectory()) {
 | 
			
		||||
                    directoriesToProcess.push(currentFile);
 | 
			
		||||
                }
 | 
			
		||||
                if (path.parse(path.basename(currentFile)).name === searchedFilename) {
 | 
			
		||||
                    return currentFile;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return undefined;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.DeleteTransaction = DeleteTransaction;
 | 
			
		||||
//# sourceMappingURL=DeleteModel.js.map
 | 
			
		||||
@ -1,50 +0,0 @@
 | 
			
		||||
import * as path from "node:path";
 | 
			
		||||
import * as fs from "fs";
 | 
			
		||||
import {json} from "node:stream/consumers";
 | 
			
		||||
 | 
			
		||||
export class DeleteTransaction {
 | 
			
		||||
  static deleteScriptAccount(projectDir: string, componentName: string) {
 | 
			
		||||
    const filename = path.join(projectDir, "script-accounts", componentName + ".json")
 | 
			
		||||
    fs.unlinkSync(filename)
 | 
			
		||||
    console.log("Delete ", filename)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static deleteGamesystem(projectDir: string, componentName: string) {
 | 
			
		||||
    const gamesystemDir = path.join(projectDir, "gamesystems")
 | 
			
		||||
    const gamesystemFile = this.findGamesystemPath(gamesystemDir, componentName)
 | 
			
		||||
    try {
 | 
			
		||||
      if(gamesystemFile != undefined) {
 | 
			
		||||
        console.log("Delete Gamesystem under File: ", gamesystemFile)
 | 
			
		||||
        if(fs.lstatSync(gamesystemFile).isDirectory()) {
 | 
			
		||||
          fs.rmSync(gamesystemFile, {recursive: true, force: true})
 | 
			
		||||
        } else {
 | 
			
		||||
          fs.unlinkSync(gamesystemFile)
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }catch (e) {
 | 
			
		||||
      console.log(e)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static findGamesystemPath(gamesystemRootDir: string, searchedFilename: string) {
 | 
			
		||||
    const directoriesToProcess: string[] = [];
 | 
			
		||||
    directoriesToProcess.push(gamesystemRootDir);
 | 
			
		||||
    while(directoriesToProcess.length > 0) {
 | 
			
		||||
      const currentDirectory = directoriesToProcess.shift();
 | 
			
		||||
      const filesInDirectory = fs.readdirSync(currentDirectory!)
 | 
			
		||||
      for(let i=0; i<filesInDirectory.length; i++) {
 | 
			
		||||
        const currentFile = path.join(currentDirectory!, filesInDirectory[i])
 | 
			
		||||
        if(fs.lstatSync(currentFile).isDirectory()) {
 | 
			
		||||
          directoriesToProcess.push(currentFile);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(path.parse(path.basename(currentFile)).name === searchedFilename) {
 | 
			
		||||
          return currentFile;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return undefined
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -1,11 +0,0 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
exports.LoadModel = void 0;
 | 
			
		||||
class LoadModel {
 | 
			
		||||
    constructor(jsonString, modelType) {
 | 
			
		||||
        this.jsonString = jsonString;
 | 
			
		||||
        this.modelType = modelType;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.LoadModel = LoadModel;
 | 
			
		||||
//# sourceMappingURL=LoadModel.js.map
 | 
			
		||||
@ -1,12 +0,0 @@
 | 
			
		||||
import {ModelComponentType} from "../src/app/game-model/ModelComponentType";
 | 
			
		||||
 | 
			
		||||
export class LoadModel {
 | 
			
		||||
  jsonString: string
 | 
			
		||||
  modelType: ModelComponentType
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  constructor(jsonString: string, modelType: ModelComponentType) {
 | 
			
		||||
    this.jsonString = jsonString;
 | 
			
		||||
    this.modelType = modelType;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -1,11 +0,0 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
exports.LoadedProject = void 0;
 | 
			
		||||
class LoadedProject {
 | 
			
		||||
    constructor(projectName, loadedModels) {
 | 
			
		||||
        this.projectName = projectName;
 | 
			
		||||
        this.loadedModels = loadedModels;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.LoadedProject = LoadedProject;
 | 
			
		||||
//# sourceMappingURL=LoadedProject.js.map
 | 
			
		||||
@ -1,12 +0,0 @@
 | 
			
		||||
import {LoadModel} from "./LoadModel";
 | 
			
		||||
 | 
			
		||||
export class LoadedProject {
 | 
			
		||||
  projectName: string
 | 
			
		||||
  loadedModels: LoadModel[]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  constructor(projectName: string, loadedModels: LoadModel[]) {
 | 
			
		||||
    this.projectName = projectName;
 | 
			
		||||
    this.loadedModels = loadedModels;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -1,12 +0,0 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
exports.RecursiveLoadModel = void 0;
 | 
			
		||||
const LoadModel_1 = require("./LoadModel");
 | 
			
		||||
class RecursiveLoadModel extends LoadModel_1.LoadModel {
 | 
			
		||||
    constructor(jsonString, modelType, parentLoadModelname) {
 | 
			
		||||
        super(jsonString, modelType);
 | 
			
		||||
        this.parentLoadModelname = parentLoadModelname;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.RecursiveLoadModel = RecursiveLoadModel;
 | 
			
		||||
//# sourceMappingURL=RecursiveLoadModel.js.map
 | 
			
		||||
@ -1,12 +0,0 @@
 | 
			
		||||
import {LoadModel} from "./LoadModel";
 | 
			
		||||
import {ModelComponentType} from "../src/app/game-model/ModelComponentType";
 | 
			
		||||
 | 
			
		||||
export class RecursiveLoadModel extends LoadModel {
 | 
			
		||||
  parentLoadModelname: string
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  constructor(jsonString: string, modelType: ModelComponentType, parentLoadModelname: string) {
 | 
			
		||||
    super(jsonString, modelType);
 | 
			
		||||
    this.parentLoadModelname = parentLoadModelname;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -1,105 +0,0 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
exports.SaveProject = void 0;
 | 
			
		||||
const fs = require("fs");
 | 
			
		||||
const path = require("node:path");
 | 
			
		||||
const LoadModel_1 = require("./LoadModel");
 | 
			
		||||
const ModelComponentType_1 = require("../src/app/game-model/ModelComponentType");
 | 
			
		||||
const LoadedProject_1 = require("./LoadedProject");
 | 
			
		||||
const RecursiveLoadModel_1 = require("./RecursiveLoadModel");
 | 
			
		||||
class SaveProject {
 | 
			
		||||
    static saveProject(projectDir, storageModels) {
 | 
			
		||||
        if (!fs.existsSync(projectDir)) {
 | 
			
		||||
            fs.mkdirSync(projectDir, { recursive: true });
 | 
			
		||||
        }
 | 
			
		||||
        console.log(storageModels);
 | 
			
		||||
        storageModels.forEach(storageModel => {
 | 
			
		||||
            let modelDir = path.join(projectDir, storageModel.storageRootDir);
 | 
			
		||||
            storageModel.storagePath.forEach(pathElement => modelDir = path.join(modelDir, pathElement));
 | 
			
		||||
            if (!fs.existsSync(modelDir)) {
 | 
			
		||||
                fs.mkdirSync(modelDir, { recursive: true });
 | 
			
		||||
            }
 | 
			
		||||
            const filePath = path.join(modelDir, storageModel.fileName + ".json");
 | 
			
		||||
            fs.writeFile(filePath, storageModel.jsonString, 'utf-8', (err) => {
 | 
			
		||||
                if (err) {
 | 
			
		||||
                    console.error('Error writing JSON to file:', err);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    console.log('JSON file saved successfully:', filePath);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    static loadProject(projectDir) {
 | 
			
		||||
        let loadedScriptAccounts = SaveProject.loadScriptAccounts(projectDir);
 | 
			
		||||
        loadedScriptAccounts = loadedScriptAccounts.concat(SaveProject.loadGamesystems(projectDir));
 | 
			
		||||
        return new LoadedProject_1.LoadedProject(path.basename(projectDir), loadedScriptAccounts);
 | 
			
		||||
    }
 | 
			
		||||
    static loadScriptAccounts(projectDir) {
 | 
			
		||||
        const scriptAccountDir = path.join(projectDir, "script-accounts");
 | 
			
		||||
        if (!fs.existsSync(scriptAccountDir)) {
 | 
			
		||||
            return [];
 | 
			
		||||
        }
 | 
			
		||||
        const loadedScriptAccounts = [];
 | 
			
		||||
        const scriptAccountFileNames = fs.readdirSync(scriptAccountDir);
 | 
			
		||||
        scriptAccountFileNames.forEach(scriptAccountFileName => {
 | 
			
		||||
            const scriptAccountFile = path.join(scriptAccountDir, scriptAccountFileName);
 | 
			
		||||
            const scriptAccountData = fs.readFileSync(scriptAccountFile, 'utf-8');
 | 
			
		||||
            loadedScriptAccounts.push({
 | 
			
		||||
                modelType: ModelComponentType_1.ModelComponentType.SCRIPTACCOUNT,
 | 
			
		||||
                jsonString: scriptAccountData
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
        return loadedScriptAccounts;
 | 
			
		||||
    }
 | 
			
		||||
    static loadGamesystems(projectDir) {
 | 
			
		||||
        const gamesystemDir = path.join(projectDir, "gamesystems");
 | 
			
		||||
        if (fs.existsSync(gamesystemDir)) {
 | 
			
		||||
            const loadedGamesystems = this.loadGamesystemsRecursively(gamesystemDir);
 | 
			
		||||
            console.log("LoadedGamesystems: ", loadedGamesystems.length);
 | 
			
		||||
            return loadedGamesystems;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            return [];
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    static loadGamesystemsRecursively(gamesystemDir) {
 | 
			
		||||
        let loadedGamesystems = [];
 | 
			
		||||
        const gamesystemFileNames = fs.readdirSync(gamesystemDir);
 | 
			
		||||
        gamesystemFileNames.forEach(fileName => {
 | 
			
		||||
            const gamesystemPath = path.join(gamesystemDir, fileName);
 | 
			
		||||
            if (fs.lstatSync(gamesystemPath).isDirectory()) {
 | 
			
		||||
                const childModels = SaveProject.loadGamesystemsRecursively(gamesystemPath);
 | 
			
		||||
                loadedGamesystems = loadedGamesystems.concat(childModels);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                const gamesystemData = fs.readFileSync(path.join(gamesystemDir, fileName), "utf-8");
 | 
			
		||||
                if (path.parse(fileName).name === path.basename(gamesystemDir)) {
 | 
			
		||||
                    if ((path.basename(gamesystemDir) === path.parse(fileName).name) && path.basename(path.parse(gamesystemDir).dir) === "gamesystems") {
 | 
			
		||||
                        const loadedModel = new LoadModel_1.LoadModel(gamesystemData, ModelComponentType_1.ModelComponentType.GAMESYTEM);
 | 
			
		||||
                        loadedGamesystems.unshift(loadedModel);
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        const loadedModel = new RecursiveLoadModel_1.RecursiveLoadModel(gamesystemData, ModelComponentType_1.ModelComponentType.GAMESYTEM, path.basename(gamesystemDir));
 | 
			
		||||
                        loadedGamesystems.unshift(loadedModel);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    const secondCon = path.basename(gamesystemDir) === path.parse(fileName).name;
 | 
			
		||||
                    const thirdCon = path.basename(path.parse(gamesystemDir).dir) === "gamesystems";
 | 
			
		||||
                    if (path.basename(gamesystemDir) === "gamesystems") {
 | 
			
		||||
                        const loadedModel = new LoadModel_1.LoadModel(gamesystemData, ModelComponentType_1.ModelComponentType.GAMESYTEM);
 | 
			
		||||
                        loadedGamesystems.push(loadedModel);
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        const loadedModel = new RecursiveLoadModel_1.RecursiveLoadModel(gamesystemData, ModelComponentType_1.ModelComponentType.GAMESYTEM, path.basename(gamesystemDir));
 | 
			
		||||
                        loadedGamesystems.push(loadedModel);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        return loadedGamesystems;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.SaveProject = SaveProject;
 | 
			
		||||
//# sourceMappingURL=SaveProject.js.map
 | 
			
		||||
@ -1,114 +0,0 @@
 | 
			
		||||
import {StorageModel} from "../src/app/game-model/fs/StorageModel";
 | 
			
		||||
import * as fs from "fs";
 | 
			
		||||
import * as path from "node:path";
 | 
			
		||||
import {LoadModel} from "./LoadModel";
 | 
			
		||||
import {ModelComponentType} from "../src/app/game-model/ModelComponentType";
 | 
			
		||||
import {LoadedProject} from "./LoadedProject";
 | 
			
		||||
import {RecursiveLoadModel} from "./RecursiveLoadModel";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export class SaveProject {
 | 
			
		||||
  static saveProject(projectDir: string, storageModels: StorageModel[]) {
 | 
			
		||||
    if(!fs.existsSync(projectDir)) {
 | 
			
		||||
      fs.mkdirSync(projectDir, {recursive: true});
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    console.log(storageModels)
 | 
			
		||||
    storageModels.forEach(storageModel => {
 | 
			
		||||
      let modelDir = path.join(projectDir, storageModel.storageRootDir);
 | 
			
		||||
      storageModel.storagePath.forEach(pathElement => modelDir = path.join(modelDir, pathElement));
 | 
			
		||||
      if(!fs.existsSync(modelDir)) {
 | 
			
		||||
        fs.mkdirSync(modelDir, {recursive: true});
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      const filePath = path.join(modelDir, storageModel.fileName + ".json");
 | 
			
		||||
      fs.writeFile(filePath, storageModel.jsonString ,'utf-8', (err) => {
 | 
			
		||||
        if (err) {
 | 
			
		||||
          console.error('Error writing JSON to file:', err);
 | 
			
		||||
        } else {
 | 
			
		||||
          console.log('JSON file saved successfully:', filePath);
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static loadProject(projectDir: string) {
 | 
			
		||||
    let loadedScriptAccounts: LoadModel[] = SaveProject.loadScriptAccounts(projectDir)
 | 
			
		||||
    loadedScriptAccounts = loadedScriptAccounts.concat(SaveProject.loadGamesystems(projectDir))
 | 
			
		||||
    return new LoadedProject(path.basename(projectDir), loadedScriptAccounts);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static loadScriptAccounts(projectDir: string): LoadModel[] {
 | 
			
		||||
    const scriptAccountDir = path.join(projectDir, "script-accounts");
 | 
			
		||||
    if (!fs.existsSync(scriptAccountDir)) {
 | 
			
		||||
      return [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const loadedScriptAccounts: LoadModel[] = [];
 | 
			
		||||
 | 
			
		||||
    const scriptAccountFileNames = fs.readdirSync(scriptAccountDir);
 | 
			
		||||
    scriptAccountFileNames.forEach(scriptAccountFileName => {
 | 
			
		||||
      const scriptAccountFile = path.join(scriptAccountDir, scriptAccountFileName)
 | 
			
		||||
      const scriptAccountData: string = fs.readFileSync(scriptAccountFile, 'utf-8');
 | 
			
		||||
 | 
			
		||||
      loadedScriptAccounts.push({
 | 
			
		||||
        modelType: ModelComponentType.SCRIPTACCOUNT,
 | 
			
		||||
        jsonString: scriptAccountData
 | 
			
		||||
      });
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    return loadedScriptAccounts;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static loadGamesystems(projectDir: string): LoadModel[] {
 | 
			
		||||
    const gamesystemDir = path.join(projectDir, "gamesystems");
 | 
			
		||||
    if(fs.existsSync(gamesystemDir)) {
 | 
			
		||||
      const loadedGamesystems = this.loadGamesystemsRecursively(gamesystemDir);
 | 
			
		||||
      console.log("LoadedGamesystems: ", loadedGamesystems.length);
 | 
			
		||||
      return loadedGamesystems;
 | 
			
		||||
    } else {
 | 
			
		||||
      return []
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static loadGamesystemsRecursively(gamesystemDir: string): LoadModel[] {
 | 
			
		||||
    let loadedGamesystems: LoadModel[] = [];
 | 
			
		||||
    const gamesystemFileNames = fs.readdirSync(gamesystemDir);
 | 
			
		||||
 | 
			
		||||
    gamesystemFileNames.forEach(fileName => {
 | 
			
		||||
      const gamesystemPath = path.join(gamesystemDir, fileName);
 | 
			
		||||
 | 
			
		||||
      if(fs.lstatSync(gamesystemPath).isDirectory()) {
 | 
			
		||||
        const childModels: LoadModel[] = SaveProject.loadGamesystemsRecursively(gamesystemPath);
 | 
			
		||||
        loadedGamesystems = loadedGamesystems.concat(childModels);
 | 
			
		||||
      } else {
 | 
			
		||||
        const gamesystemData = fs.readFileSync(path.join(gamesystemDir, fileName), "utf-8");
 | 
			
		||||
        if(path.parse(fileName).name === path.basename(gamesystemDir) ) {
 | 
			
		||||
          if((path.basename(gamesystemDir) === path.parse(fileName).name) && path.basename(path.parse(gamesystemDir).dir) === "gamesystems") {
 | 
			
		||||
            const loadedModel = new LoadModel(gamesystemData, ModelComponentType.GAMESYTEM);
 | 
			
		||||
            loadedGamesystems.unshift(loadedModel)
 | 
			
		||||
          } else {
 | 
			
		||||
            const loadedModel = new RecursiveLoadModel(gamesystemData, ModelComponentType.GAMESYTEM, path.basename(gamesystemDir))
 | 
			
		||||
            loadedGamesystems.unshift(loadedModel);
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
        } else {
 | 
			
		||||
          const secondCon = path.basename(gamesystemDir) === path.parse(fileName).name
 | 
			
		||||
          const thirdCon = path.basename(path.parse(gamesystemDir).dir) === "gamesystems"
 | 
			
		||||
 | 
			
		||||
          if(path.basename(gamesystemDir) === "gamesystems"){
 | 
			
		||||
            const loadedModel = new LoadModel(gamesystemData, ModelComponentType.GAMESYTEM)
 | 
			
		||||
            loadedGamesystems.push(loadedModel);
 | 
			
		||||
          } else {
 | 
			
		||||
 | 
			
		||||
            const loadedModel = new RecursiveLoadModel(gamesystemData, ModelComponentType.GAMESYTEM, path.basename(gamesystemDir))
 | 
			
		||||
            loadedGamesystems.push(loadedModel);
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    })
 | 
			
		||||
    return loadedGamesystems;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -1,12 +0,0 @@
 | 
			
		||||
class StorageModel {
 | 
			
		||||
  jsonString: string
 | 
			
		||||
  fileName: string
 | 
			
		||||
  storageDir: string
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  constructor(jsonString: string, fileName: string, storageDir: string) {
 | 
			
		||||
    this.jsonString = jsonString;
 | 
			
		||||
    this.fileName = fileName;
 | 
			
		||||
    this.storageDir = storageDir;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										22
									
								
								app/main.ts
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								app/main.ts
									
									
									
									
									
								
							@ -1,11 +1,7 @@
 | 
			
		||||
import {app, BrowserWindow, dialog, globalShortcut, ipcMain, Menu, screen} from 'electron';
 | 
			
		||||
import * as path from 'path';
 | 
			
		||||
import * as fs from 'fs';
 | 
			
		||||
import {StorageModel} from "../src/app/game-model/fs/StorageModel";
 | 
			
		||||
import {SaveProject} from "./SaveProject";
 | 
			
		||||
import {DeleteModel} from "../src/app/game-model/fs/DeleteModel";
 | 
			
		||||
import {ModelComponentType} from "../src/app/game-model/ModelComponentType";
 | 
			
		||||
import {DeleteTransaction} from "./DeleteModel";
 | 
			
		||||
import {GameModelLoader} from "./storage/loader/GameModelLoader";
 | 
			
		||||
 | 
			
		||||
let win: BrowserWindow | null = null;
 | 
			
		||||
const args = process.argv.slice(1),
 | 
			
		||||
@ -96,15 +92,15 @@ function createWindow(): BrowserWindow {
 | 
			
		||||
    contextMenu.popup({ window: win!, x: params.x, y: params.y });
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  ipcMain.on('save-model', (event, storageModels: StorageModel[]) => {
 | 
			
		||||
  /*ipcMain.on('save-model', (event, storageModels: StorageModel[]) => {
 | 
			
		||||
    console.log("Save Model")
 | 
			
		||||
    SaveProject.saveProject(projectDirectory, storageModels);
 | 
			
		||||
  })
 | 
			
		||||
  })*/
 | 
			
		||||
 | 
			
		||||
  ipcMain.on('delete-component', (event, deletedComponent: DeleteModel) => {
 | 
			
		||||
  /*ipcMain.on('delete-component', (event, deletedComponent: DeleteModel) => {
 | 
			
		||||
    console.log("Delete Model: ", deletedComponent)
 | 
			
		||||
      deleteComponent(deletedComponent);
 | 
			
		||||
  })
 | 
			
		||||
  })*/
 | 
			
		||||
 | 
			
		||||
  const menuTemplate = [
 | 
			
		||||
    {
 | 
			
		||||
@ -206,8 +202,8 @@ function loadDevProjectAtStart() {
 | 
			
		||||
 | 
			
		||||
function openProjectFromFile(openProjectDir: string) {
 | 
			
		||||
  projectDirectory = openProjectDir
 | 
			
		||||
  console.log("Open Project-Directory: ", openProjectDir)
 | 
			
		||||
  const loadedProject = SaveProject.loadProject(openProjectDir)
 | 
			
		||||
  const gameModelLoader = new GameModelLoader(openProjectDir);
 | 
			
		||||
  const loadedProject = gameModelLoader.loadGameModel();
 | 
			
		||||
  win!.webContents.send("open-project", loadedProject)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -215,11 +211,11 @@ function saveProject() {
 | 
			
		||||
  win!.webContents.send('get-project-data')
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function deleteComponent(component: DeleteModel) {
 | 
			
		||||
/*function deleteComponent(component: DeleteModel) {
 | 
			
		||||
  console.log("Delete Component")
 | 
			
		||||
  if(component.modeltype == ModelComponentType.SCRIPTACCOUNT) {
 | 
			
		||||
    DeleteTransaction.deleteScriptAccount(projectDirectory, component.componentName);
 | 
			
		||||
  } else if(component.modeltype === ModelComponentType.GAMESYTEM) {
 | 
			
		||||
    DeleteTransaction.deleteGamesystem(projectDirectory, component.componentName);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
}*/
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										13
									
								
								app/storage/FileUtils.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								app/storage/FileUtils.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
			
		||||
import * as fs from "fs";
 | 
			
		||||
import * as path from "node:path";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export class FileUtils {
 | 
			
		||||
  public static listFilesInDirectory(directory: string) {
 | 
			
		||||
    if(fs.lstatSync(directory).isDirectory()) {
 | 
			
		||||
      return fs.readdirSync(directory).map(fileName => path.join(directory, fileName))
 | 
			
		||||
    } else {
 | 
			
		||||
      return [];
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										6
									
								
								app/storage/ModelComponentFileDirectory.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								app/storage/ModelComponentFileDirectory.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
export class ModelComponentFileDirectory {
 | 
			
		||||
  public static SCRIPTACCOUNT_DIR_NAME = "script-accounts"
 | 
			
		||||
  public static GAMESYSTEM_DIR_NAME = "gamesystems";
 | 
			
		||||
  public static GAMESYSTEM_SIMPLE_DIR_NAME = "simple";
 | 
			
		||||
  public static GAMESYSTEM_PRODUCT_DIR_NAME = "product";
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										13
									
								
								app/storage/StoreComponent.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								app/storage/StoreComponent.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
			
		||||
import {ModelComponentType} from "../../src/app/project/game-model/ModelComponentType";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export class StoreComponent {
 | 
			
		||||
  jsonString: string
 | 
			
		||||
  fileName: string
 | 
			
		||||
  componentType: ModelComponentType
 | 
			
		||||
  constructor(jsonString: string, fileName: string, componentType: ModelComponentType) {
 | 
			
		||||
    this.jsonString = jsonString;
 | 
			
		||||
    this.fileName = fileName;
 | 
			
		||||
    this.componentType = componentType
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										12
									
								
								app/storage/StoredGameModel.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								app/storage/StoredGameModel.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
import {StoreComponent} from "./StoreComponent";
 | 
			
		||||
 | 
			
		||||
export class StoredGameModel {
 | 
			
		||||
  gameModelName: string
 | 
			
		||||
  loadedModels: StoreComponent[]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  constructor(gameModelName: string, loadedModels: StoreComponent[]) {
 | 
			
		||||
    this.gameModelName = gameModelName;
 | 
			
		||||
    this.loadedModels = loadedModels;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										43
									
								
								app/storage/loader/GameModelLoader.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								app/storage/loader/GameModelLoader.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,43 @@
 | 
			
		||||
import {StoredGameModel} from "../StoredGameModel";
 | 
			
		||||
import {StoreComponent} from "../StoreComponent";
 | 
			
		||||
import * as path from "node:path";
 | 
			
		||||
import * as fs from "fs";
 | 
			
		||||
import {ModelComponentFileDirectory} from "../ModelComponentFileDirectory";
 | 
			
		||||
import {ScriptAccountLoader} from "./ScriptAccountLoader";
 | 
			
		||||
 | 
			
		||||
export class GameModelLoader {
 | 
			
		||||
  gameModelDir: string
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  constructor(gameModelDir: string) {
 | 
			
		||||
    this.gameModelDir = gameModelDir;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  loadGameModel(): StoredGameModel {
 | 
			
		||||
    const gameModelName = path.basename(this.gameModelDir)
 | 
			
		||||
    const gameModelComponents: StoreComponent[] = this.loadGameModelComponents();
 | 
			
		||||
 | 
			
		||||
    return new StoredGameModel(gameModelName, gameModelComponents);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private loadGameModelComponents(): StoreComponent[] {
 | 
			
		||||
    let gameModelComponents: StoreComponent[] = this.loadScriptAccountComponents()
 | 
			
		||||
    gameModelComponents = gameModelComponents.concat(this.loadGamesystems())
 | 
			
		||||
    return gameModelComponents
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private loadScriptAccountComponents() {
 | 
			
		||||
    const scriptAccountDir = path.join(this.gameModelDir, ModelComponentFileDirectory.SCRIPTACCOUNT_DIR_NAME);
 | 
			
		||||
    const scriptAccountLoader = new ScriptAccountLoader(scriptAccountDir);
 | 
			
		||||
    return scriptAccountLoader.loadScriptAccounts()
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private loadGamesystems(): StoreComponent[] {
 | 
			
		||||
    return []
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										34
									
								
								app/storage/loader/ScriptAccountLoader.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								app/storage/loader/ScriptAccountLoader.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,34 @@
 | 
			
		||||
import {StoreComponent} from "../StoreComponent";
 | 
			
		||||
import {FileUtils} from "../FileUtils";
 | 
			
		||||
import {ModelComponentType} from "../../../src/app/project/game-model/ModelComponentType";
 | 
			
		||||
import * as fs from "fs";
 | 
			
		||||
import {ModelComponentFileDirectory} from "../ModelComponentFileDirectory";
 | 
			
		||||
import {load} from "@angular-devkit/build-angular/src/utils/server-rendering/esm-in-memory-loader/loader-hooks";
 | 
			
		||||
 | 
			
		||||
export class ScriptAccountLoader {
 | 
			
		||||
  scriptAccountDir: string
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  constructor(scriptAccountDir: string) {
 | 
			
		||||
    this.scriptAccountDir = scriptAccountDir;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  loadScriptAccounts(): StoreComponent[] {
 | 
			
		||||
    const scriptAccountFiles = FileUtils.listFilesInDirectory(this.scriptAccountDir);
 | 
			
		||||
    const loadedScriptAccounts: StoreComponent[] = []
 | 
			
		||||
    scriptAccountFiles.forEach(scriptAccountFile => {
 | 
			
		||||
      const loadedScriptAccount = this.loadScriptAccount(scriptAccountFile);
 | 
			
		||||
      if(loadedScriptAccount != undefined) {
 | 
			
		||||
        loadedScriptAccounts.push(loadedScriptAccount)
 | 
			
		||||
      }
 | 
			
		||||
    })
 | 
			
		||||
    return loadedScriptAccounts;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private loadScriptAccount(scriptAccountFile: string) {
 | 
			
		||||
    if(scriptAccountFile.endsWith(".json")) {
 | 
			
		||||
      const scriptAccountData = fs.readFileSync(scriptAccountFile, 'utf-8');
 | 
			
		||||
      return new StoreComponent(scriptAccountData, scriptAccountFile, ModelComponentType.SCRIPTACCOUNT);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -22,7 +22,7 @@
 | 
			
		||||
          <button mat-menu-item (click)="openGamesystemsOverview()">{{ModelComponentTypeUtillities.toString(ModelComponentType.GAMESYTEM)}}</button>
 | 
			
		||||
        </mat-menu>
 | 
			
		||||
      </div>
 | 
			
		||||
      <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]="projectService.gameModel" (onOpenScriptAccount)="openModelComponent($event)"></app-script-account-overview>
 | 
			
		||||
      <app-gamescript-overview *ngIf="openContent == ModelComponentType.GAMESYTEM" #gamesystemOverview [gameModel]="gameModel" (openGamesystemEditor)="openModelComponent($event)"></app-gamescript-overview>
 | 
			
		||||
    </mat-drawer>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,24 +1,20 @@
 | 
			
		||||
import {Component, NgZone, OnInit, ViewChild} from '@angular/core';
 | 
			
		||||
import {ElectronService} from './core/services';
 | 
			
		||||
import {APP_CONFIG} from '../environments/environment';
 | 
			
		||||
import {ModelComponentType} from "./game-model/ModelComponentType";
 | 
			
		||||
import {MatDrawerContainer} from "@angular/material/sidenav";
 | 
			
		||||
import {ModelComponentTypeUtillities} from "./game-model/ModelComponentTypeUtillities";
 | 
			
		||||
import {GameModel} from "./game-model/GameModel";
 | 
			
		||||
import {EditorComponent} from "./editor/editor.component";
 | 
			
		||||
import {ModelComponent} from "./game-model/ModelComponent";
 | 
			
		||||
import {
 | 
			
		||||
  ScriptAccountOverviewComponent
 | 
			
		||||
} from "./side-overviews/script-account-overview/script-account-overview.component";
 | 
			
		||||
import {MatDialog} from "@angular/material/dialog";
 | 
			
		||||
import {DeleteConfirmationDialogComponent} from "./delete-confirmation-dialog/delete-confirmation-dialog.component";
 | 
			
		||||
import {ScriptAccount} from "./game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
import {GamescriptOverviewComponent} from "./side-overviews/gamescript-overview/gamescript-overview.component";
 | 
			
		||||
import {LoadedProject} from "../../app/LoadedProject";
 | 
			
		||||
import {ProcessLoadedProject} from "./game-model/fs/ProcessLoadedProject";
 | 
			
		||||
import {StoreProject} from "./game-model/fs/store/StoreProject";
 | 
			
		||||
import {Gamesystem} from "./game-model/gamesystems/Gamesystem";
 | 
			
		||||
import {DeleteModel} from "./game-model/fs/DeleteModel";
 | 
			
		||||
 | 
			
		||||
import {ProjectService} from "./project/project.service";
 | 
			
		||||
import {ModelComponentType} from "./project/game-model/ModelComponentType";
 | 
			
		||||
import {ModelComponentTypeUtillities} from "./project/game-model/ModelComponentTypeUtillities";
 | 
			
		||||
import {ScriptAccount} from "./project/game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
import {Gamesystem} from "./project/game-model/gamesystems/Gamesystem";
 | 
			
		||||
import {ModelComponent} from "./project/game-model/ModelComponent";
 | 
			
		||||
import {GameModel} from "./project/game-model/GameModel";
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-root',
 | 
			
		||||
@ -35,44 +31,11 @@ export class AppComponent implements OnInit{
 | 
			
		||||
 | 
			
		||||
  gameModel: GameModel | undefined
 | 
			
		||||
 | 
			
		||||
  constructor(private electronService: ElectronService,
 | 
			
		||||
              private zone: NgZone,
 | 
			
		||||
              private dialog: MatDialog
 | 
			
		||||
  constructor(private zone: NgZone,
 | 
			
		||||
              private dialog: MatDialog,
 | 
			
		||||
              private projectService: ProjectService
 | 
			
		||||
  ) {
 | 
			
		||||
    console.log('APP_CONFIG', APP_CONFIG);
 | 
			
		||||
    if(this.gameModel == undefined)  {
 | 
			
		||||
      this.gameModel = new GameModel("Unknown GameModel")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (electronService.isElectron) {
 | 
			
		||||
      console.log(process.env);
 | 
			
		||||
      console.log('Run in electron');
 | 
			
		||||
      console.log('Electron ipcRenderer', this.electronService.ipcRenderer);
 | 
			
		||||
      console.log('NodeJS childProcess', this.electronService.childProcess);
 | 
			
		||||
 | 
			
		||||
      electronService.ipcRenderer.on('context-menu', (event: any, message: string) => {
 | 
			
		||||
        this.zone.run(() => {
 | 
			
		||||
          this.onContextMenuMessageRecieved(message);
 | 
			
		||||
        });
 | 
			
		||||
      })
 | 
			
		||||
 | 
			
		||||
      electronService.ipcRenderer.on('get-project-data', (event: any, message: string) => {
 | 
			
		||||
        this.zone.run(() => {
 | 
			
		||||
          this.saveGameModel();
 | 
			
		||||
        })
 | 
			
		||||
      })
 | 
			
		||||
 | 
			
		||||
      electronService.ipcRenderer.on('open-project', (event: any, loadedProject: LoadedProject) => {
 | 
			
		||||
        this.gameModel = ProcessLoadedProject.processLoadedProject(loadedProject)
 | 
			
		||||
      })
 | 
			
		||||
    } else {
 | 
			
		||||
      console.log('Run in browser');
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  saveGameModel() {
 | 
			
		||||
    const storageModels = StoreProject.storeProject(this.gameModel!);
 | 
			
		||||
    this.electronService.ipcRenderer.send('save-model', storageModels)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  onContextMenuMessageRecieved(message: string) {
 | 
			
		||||
@ -100,7 +63,7 @@ export class AppComponent implements OnInit{
 | 
			
		||||
      } break;
 | 
			
		||||
      case ModelComponentType.GAMESYTEM: {
 | 
			
		||||
        if(this.gamesystemOverview!.selectedGamesystem != undefined) {
 | 
			
		||||
          const gamesystem = this.gameModel!.findGamesystem(this.gamesystemOverview!.selectedGamesystemName!);
 | 
			
		||||
          const gamesystem = this.projectService!.gameModel!.findGamesystem(this.gamesystemOverview!.selectedGamesystemName!);
 | 
			
		||||
          this.editor!.openGameModelComponent(gamesystem!);
 | 
			
		||||
        }
 | 
			
		||||
      } break
 | 
			
		||||
@ -115,11 +78,11 @@ export class AppComponent implements OnInit{
 | 
			
		||||
    dialogRef.afterClosed().subscribe(res => {
 | 
			
		||||
      if(res != undefined && res) {
 | 
			
		||||
        if(affectedModelComponent instanceof ScriptAccount) {
 | 
			
		||||
          this.gameModel!.removeScriptAccount(affectedModelComponent);
 | 
			
		||||
          this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.SCRIPTACCOUNT))
 | 
			
		||||
          this.projectService!.gameModel!.removeScriptAccount(affectedModelComponent);
 | 
			
		||||
          //this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.SCRIPTACCOUNT))
 | 
			
		||||
        } else if(affectedModelComponent instanceof Gamesystem) {
 | 
			
		||||
          this.gameModel!.removeGamesystem(affectedModelComponent);
 | 
			
		||||
          this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.GAMESYTEM))
 | 
			
		||||
          //this.gameModel!.removeGamesystem(affectedModelComponent);
 | 
			
		||||
          //this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.GAMESYTEM))
 | 
			
		||||
          this.gamesystemOverview!.refresh()
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
@ -134,7 +97,7 @@ export class AppComponent implements OnInit{
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private onCreateNewScriptAccount() {
 | 
			
		||||
    const createdScriptAccount = this.gameModel!.createScriptAccount("New ScriptAccount");
 | 
			
		||||
    const createdScriptAccount = this.projectService!.gameModel!.createScriptAccount("New ScriptAccount");
 | 
			
		||||
    if(createdScriptAccount != undefined) {
 | 
			
		||||
      this.editor?.openGameModelComponent(createdScriptAccount);
 | 
			
		||||
    } else {
 | 
			
		||||
@ -151,7 +114,7 @@ export class AppComponent implements OnInit{
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    const createdGamesystem = this.gameModel!.createGamesystem("New Gamesystem", parentGamesystemName);
 | 
			
		||||
    const createdGamesystem = this.projectService!.gameModel!.createGamesystem("New Gamesystem", parentGamesystemName);
 | 
			
		||||
    if(createdGamesystem != undefined) {
 | 
			
		||||
      this.gamesystemOverview!.refresh();
 | 
			
		||||
      this.editor?.openGameModelComponent(createdGamesystem);
 | 
			
		||||
@ -176,6 +139,7 @@ export class AppComponent implements OnInit{
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  ngOnInit() {
 | 
			
		||||
    this.gameModel = this.projectService.gameModel
 | 
			
		||||
    /*this.gameModel = new GameModel("No More");
 | 
			
		||||
    this.gameModel.createScriptAccount("Temperature");
 | 
			
		||||
    this.gameModel.createScriptAccount("Luftfeuchtigkeit");
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
import {Component, Inject} from '@angular/core';
 | 
			
		||||
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
 | 
			
		||||
import {ModelComponentTypeUtillities} from "../game-model/ModelComponentTypeUtillities";
 | 
			
		||||
import {ModelComponent} from "../game-model/ModelComponent";
 | 
			
		||||
import {ModelComponent} from "../project/game-model/ModelComponent";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-delete-confirmation-dialog',
 | 
			
		||||
@ -13,7 +13,6 @@ export class DeleteConfirmationDialogComponent {
 | 
			
		||||
  constructor(private dialogRef: MatDialogRef<DeleteConfirmationDialogComponent>,
 | 
			
		||||
              @Inject(MAT_DIALOG_DATA) public deleteModelComponent: ModelComponent) {
 | 
			
		||||
  }
 | 
			
		||||
  protected readonly ModelComponentTypeUtillities = ModelComponentTypeUtillities;
 | 
			
		||||
 | 
			
		||||
  cancel() {
 | 
			
		||||
    this.dialogRef.close(false);
 | 
			
		||||
 | 
			
		||||
@ -1,11 +1,12 @@
 | 
			
		||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
 | 
			
		||||
import {GameModel} from "../game-model/GameModel";
 | 
			
		||||
import {ModelComponent} from "../game-model/ModelComponent";
 | 
			
		||||
import {ModelComponentType} from "../game-model/ModelComponentType";
 | 
			
		||||
import {ScriptAccount} from "../game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
import {Gamesystem} from "../game-model/gamesystems/Gamesystem";
 | 
			
		||||
import {State} from "../game-model/gamesystems/states/State";
 | 
			
		||||
import {Transition} from "../game-model/gamesystems/transitions/Transition";
 | 
			
		||||
import {ModelComponent} from "../project/game-model/ModelComponent";
 | 
			
		||||
import {GameModel} from "../project/game-model/GameModel";
 | 
			
		||||
import {ScriptAccount} from "../project/game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
import {Gamesystem} from "../project/game-model/gamesystems/Gamesystem";
 | 
			
		||||
import {State} from "../project/game-model/gamesystems/states/State";
 | 
			
		||||
import {Transition} from "../project/game-model/gamesystems/transitions/Transition";
 | 
			
		||||
import {ModelComponentType} from "../project/game-model/ModelComponentType";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-editor',
 | 
			
		||||
@ -43,9 +44,10 @@ export class EditorComponent {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected readonly ModelComponentType = ModelComponentType;
 | 
			
		||||
 | 
			
		||||
  onModelNameUpdate() {
 | 
			
		||||
    this.onModelNameUpdateEmitter.emit(true);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected readonly ModelComponentType = ModelComponentType;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,11 +1,10 @@
 | 
			
		||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
 | 
			
		||||
import {GameModel} from "../../game-model/GameModel";
 | 
			
		||||
import {Gamesystem} from "../../game-model/gamesystems/Gamesystem";
 | 
			
		||||
import {State} from "../../game-model/gamesystems/states/State";
 | 
			
		||||
import {Transition} from "../../game-model/gamesystems/transitions/Transition";
 | 
			
		||||
import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem";
 | 
			
		||||
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
import {State} from "../../project/game-model/gamesystems/states/State";
 | 
			
		||||
import {Gamesystem} from "../../project/game-model/gamesystems/Gamesystem";
 | 
			
		||||
import { Transition } from '../../project/game-model/gamesystems/transitions/Transition';
 | 
			
		||||
import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem";
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-gamesystem-editor',
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,9 @@
 | 
			
		||||
import {Gamesystem} from "../../../game-model/gamesystems/Gamesystem";
 | 
			
		||||
import {SimpleGamesystem} from "../../../game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
import {ProductGamesystem} from "../../../game-model/gamesystems/ProductGamesystem";
 | 
			
		||||
import {State} from "../../../game-model/gamesystems/states/State";
 | 
			
		||||
import {ProductState} from "../../../game-model/gamesystems/states/ProductState";
 | 
			
		||||
import {SimpleState} from "../../../game-model/gamesystems/states/SimpleState";
 | 
			
		||||
import {Gamesystem} from "../../../project/game-model/gamesystems/Gamesystem";
 | 
			
		||||
import {SimpleGamesystem} from "../../../project/game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
import {ProductGamesystem} from "../../../project/game-model/gamesystems/ProductGamesystem";
 | 
			
		||||
import {State} from "../../../project/game-model/gamesystems/states/State";
 | 
			
		||||
import {SimpleState} from "../../../project/game-model/gamesystems/states/SimpleState";
 | 
			
		||||
import {ProductState} from "../../../project/game-model/gamesystems/states/ProductState";
 | 
			
		||||
 | 
			
		||||
export class LeafGamesystemCalculator {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,9 @@
 | 
			
		||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
 | 
			
		||||
import {ProductGamesystem} from "../../../game-model/gamesystems/ProductGamesystem";
 | 
			
		||||
import {ProductStateEditorComponent} from "../state-editor/product-state-editor/product-state-editor.component";
 | 
			
		||||
import {SimpleGamesystem} from "../../../game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
import {
 | 
			
		||||
  ProductTransitionEditorComponent
 | 
			
		||||
} from "../transition-editor/product-transition-editor/product-transition-editor.component";
 | 
			
		||||
import {ProductGamesystem} from "../../../project/game-model/gamesystems/ProductGamesystem";
 | 
			
		||||
import {SimpleGamesystem} from "../../../project/game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
 | 
			
		||||
import {ScriptAccountCondition} from "../../../game-model/gamesystems/conditions/ScriptAccountCondition";
 | 
			
		||||
import {MatTableDataSource} from "@angular/material/table";
 | 
			
		||||
import {ScriptAccount} from "../../../game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
import {ScriptAccountCondition} from "../../../project/game-model/gamesystems/conditions/ScriptAccountCondition";
 | 
			
		||||
import {ScriptAccount} from "../../../project/game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-scriptaccount-condition-editor',
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
import {Component, Input} from '@angular/core';
 | 
			
		||||
import {SimpleGamesystem} from "../../../game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
import {MatTableDataSource} from "@angular/material/table";
 | 
			
		||||
import {ScriptAccount} from "../../../game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
import {SimpleGamesystem} from "../../../project/game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
import {ScriptAccount} from "../../../project/game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-simple-gamesystem-editor',
 | 
			
		||||
 | 
			
		||||
@ -1,15 +1,13 @@
 | 
			
		||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
 | 
			
		||||
import {ProductGamesystem} from "../../../../game-model/gamesystems/ProductGamesystem";
 | 
			
		||||
import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
import {
 | 
			
		||||
  MatTableDataSource
 | 
			
		||||
} from "@angular/material/table";
 | 
			
		||||
import {SimpleState} from "../../../../game-model/gamesystems/states/SimpleState";
 | 
			
		||||
import {State} from "../../../../game-model/gamesystems/states/State";
 | 
			
		||||
import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator";
 | 
			
		||||
import {ProductTransition} from "../../../../game-model/gamesystems/transitions/ProductTransition";
 | 
			
		||||
import {ProductState} from "../../../../game-model/gamesystems/states/ProductState";
 | 
			
		||||
import {animate, state, style, transition, trigger} from "@angular/animations";
 | 
			
		||||
import {ProductGamesystem} from "../../../../project/game-model/gamesystems/ProductGamesystem";
 | 
			
		||||
import {SimpleGamesystem} from "../../../../project/game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
import {ProductState} from "../../../../project/game-model/gamesystems/states/ProductState";
 | 
			
		||||
import {State} from "../../../../project/game-model/gamesystems/states/State";
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-product-state-editor',
 | 
			
		||||
@ -55,7 +53,6 @@ export class ProductStateEditorComponent implements OnInit{
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected readonly SimpleState = SimpleState;
 | 
			
		||||
 | 
			
		||||
  getLeafState(state: State<any>, i: number) {
 | 
			
		||||
    return LeafGamesystemCalculator.calcLeafStates(state)[i];
 | 
			
		||||
 | 
			
		||||
@ -1,13 +1,11 @@
 | 
			
		||||
import {Component, Input, OnInit} from '@angular/core';
 | 
			
		||||
import {SimpleState} from "../../../../game-model/gamesystems/states/SimpleState";
 | 
			
		||||
import {MatTableDataSource} from "@angular/material/table";
 | 
			
		||||
import {animate, state, style, transition, trigger} from "@angular/animations";
 | 
			
		||||
import {MatSnackBar} from "@angular/material/snack-bar";
 | 
			
		||||
import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
import {ProductState} from "../../../../game-model/gamesystems/states/ProductState";
 | 
			
		||||
import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator";
 | 
			
		||||
import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
import {ScriptAccountCondition} from "../../../../game-model/gamesystems/conditions/ScriptAccountCondition";
 | 
			
		||||
import {SimpleState} from "../../../../project/game-model/gamesystems/states/SimpleState";
 | 
			
		||||
import {SimpleGamesystem} from "../../../../project/game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
import {ScriptAccountCondition} from "../../../../project/game-model/gamesystems/conditions/ScriptAccountCondition";
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-simple-state-editor',
 | 
			
		||||
 | 
			
		||||
@ -1,13 +1,13 @@
 | 
			
		||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
 | 
			
		||||
import {ProductGamesystem} from "../../../../game-model/gamesystems/ProductGamesystem";
 | 
			
		||||
import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
import {
 | 
			
		||||
  MatTableDataSource
 | 
			
		||||
} from "@angular/material/table";
 | 
			
		||||
import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator";
 | 
			
		||||
import {ProductTransition} from "../../../../game-model/gamesystems/transitions/ProductTransition";
 | 
			
		||||
import {ProductState} from "../../../../game-model/gamesystems/states/ProductState";
 | 
			
		||||
import {animate, state, style, transition, trigger} from "@angular/animations";
 | 
			
		||||
import {ProductGamesystem} from "../../../../project/game-model/gamesystems/ProductGamesystem";
 | 
			
		||||
import {SimpleGamesystem} from "../../../../project/game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
import {ProductTransition} from "../../../../project/game-model/gamesystems/transitions/ProductTransition";
 | 
			
		||||
import {ProductState} from "../../../../project/game-model/gamesystems/states/ProductState";
 | 
			
		||||
class DisplayedColumnName {
 | 
			
		||||
  displayedName: string
 | 
			
		||||
  internalName: string
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,8 @@
 | 
			
		||||
import {Component, Input, OnInit} from '@angular/core';
 | 
			
		||||
import {Transition} from "../../../../game-model/gamesystems/transitions/Transition";
 | 
			
		||||
import {MatTableDataSource} from "@angular/material/table";
 | 
			
		||||
import {ScriptAccountAction} from "../../../../game-model/gamesystems/actions/ScriptAccountAction";
 | 
			
		||||
import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
import {Transition} from "../../../../project/game-model/gamesystems/transitions/Transition";
 | 
			
		||||
import {ScriptAccountAction} from "../../../../project/game-model/gamesystems/actions/ScriptAccountAction";
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-scriptaccount-action-editor',
 | 
			
		||||
 | 
			
		||||
@ -1,13 +1,13 @@
 | 
			
		||||
import {Component, Input, OnInit} from '@angular/core';
 | 
			
		||||
import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
import {
 | 
			
		||||
  MatTableDataSource
 | 
			
		||||
} from "@angular/material/table";
 | 
			
		||||
import {SimpleTransition} from "../../../../game-model/gamesystems/transitions/SimpleTransition";
 | 
			
		||||
import {animate, state, style, transition, trigger} from "@angular/animations";
 | 
			
		||||
import {SimpleState} from "../../../../game-model/gamesystems/states/SimpleState";
 | 
			
		||||
import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
import {ScriptAccountCondition} from "../../../../game-model/gamesystems/conditions/ScriptAccountCondition";
 | 
			
		||||
import {SimpleGamesystem} from "../../../../project/game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
import {SimpleTransition} from "../../../../project/game-model/gamesystems/transitions/SimpleTransition";
 | 
			
		||||
import {SimpleState} from "../../../../project/game-model/gamesystems/states/SimpleState";
 | 
			
		||||
import {ScriptAccountCondition} from "../../../../project/game-model/gamesystems/conditions/ScriptAccountCondition";
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-simple-transition-editor',
 | 
			
		||||
  templateUrl: './simple-transition-editor.component.html',
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
 | 
			
		||||
import {ModelComponent} from "../../game-model/ModelComponent";
 | 
			
		||||
import {FormControl, Validators} from "@angular/forms";
 | 
			
		||||
import {ModelComponent} from "../../project/game-model/ModelComponent";
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-model-component-editor',
 | 
			
		||||
 | 
			
		||||
@ -1,12 +1,12 @@
 | 
			
		||||
import {Component, Input, OnInit} from '@angular/core';
 | 
			
		||||
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
import {ModelComponent} from "../../game-model/ModelComponent";
 | 
			
		||||
 | 
			
		||||
import {MatFormField} from "@angular/material/form-field";
 | 
			
		||||
import {MatInput} from "@angular/material/input";
 | 
			
		||||
import {FormControl, FormGroupDirective, FormsModule, NgForm, Validators} from "@angular/forms";
 | 
			
		||||
import {NgIf} from "@angular/common";
 | 
			
		||||
import {ErrorStateMatcher} from "@angular/material/core";
 | 
			
		||||
import {ElectronService} from "../../core/services";
 | 
			
		||||
import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
 | 
			
		||||
export class MyErrorStateMatcher implements ErrorStateMatcher {
 | 
			
		||||
  isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,6 @@ import {Transition} from "./transitions/Transition";
 | 
			
		||||
import {SimpleState} from "./states/SimpleState";
 | 
			
		||||
import {SimpleGamesystem} from "./SimpleGamesystem";
 | 
			
		||||
import {GameModel} from "../GameModel";
 | 
			
		||||
import {ProductStateTrainer} from "../../../../e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer";
 | 
			
		||||
import {ScriptAccountCondition} from "./conditions/ScriptAccountCondition";
 | 
			
		||||
import {ScriptAccountAction} from "./actions/ScriptAccountAction";
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								src/app/project/parser/ScriptAccountParser.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/app/project/parser/ScriptAccountParser.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
import {StoreComponent} from "../../../../app/storage/StoreComponent";
 | 
			
		||||
import {ScriptAccount} from "../game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
 | 
			
		||||
export class ScriptAccountParser {
 | 
			
		||||
 | 
			
		||||
  public static parseScriptAccount(storedComponent: StoreComponent): ScriptAccount {
 | 
			
		||||
    console.log("Parse ScriptAccount: ", storedComponent.fileName)
 | 
			
		||||
    const parsedScriptAccount = new ScriptAccount("", "");
 | 
			
		||||
    Object.assign(parsedScriptAccount, JSON.parse(storedComponent.jsonString));
 | 
			
		||||
    return parsedScriptAccount;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -1,13 +1,13 @@
 | 
			
		||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
 | 
			
		||||
import {Gamesystem} from "../../game-model/gamesystems/Gamesystem";
 | 
			
		||||
import {State} from "../../game-model/gamesystems/states/State";
 | 
			
		||||
import {Transition} from "../../game-model/gamesystems/transitions/Transition";
 | 
			
		||||
import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem";
 | 
			
		||||
import {FlatTreeControl} from "@angular/cdk/tree";
 | 
			
		||||
import {MatTreeFlatDataSource, MatTreeFlattener} from "@angular/material/tree";
 | 
			
		||||
import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
import {GameModel} from "../../game-model/GameModel";
 | 
			
		||||
import {ElectronService} from "../../core/services";
 | 
			
		||||
import {GameModel} from "../../project/game-model/GameModel";
 | 
			
		||||
import {Gamesystem} from "../../project/game-model/gamesystems/Gamesystem";
 | 
			
		||||
import {State} from "../../project/game-model/gamesystems/states/State";
 | 
			
		||||
import {Transition} from "../../project/game-model/gamesystems/transitions/Transition";
 | 
			
		||||
import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem";
 | 
			
		||||
import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
interface FlatNode {
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
import {Component, EventEmitter, Input, NgZone, Output} from '@angular/core';
 | 
			
		||||
import {GameModel} from "../../game-model/GameModel";
 | 
			
		||||
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
import {ElectronService} from "../../core/services";
 | 
			
		||||
import {GameModel} from "../../project/game-model/GameModel";
 | 
			
		||||
import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount";
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-script-account-overview',
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user