This commit is contained in:
parent
b62f93bfd5
commit
8016f55e85
@ -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 {app, BrowserWindow, dialog, globalShortcut, ipcMain, Menu, screen} from 'electron';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import {StorageModel} from "../src/app/game-model/fs/StorageModel";
|
import {GameModelLoader} from "./storage/loader/GameModelLoader";
|
||||||
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";
|
|
||||||
|
|
||||||
let win: BrowserWindow | null = null;
|
let win: BrowserWindow | null = null;
|
||||||
const args = process.argv.slice(1),
|
const args = process.argv.slice(1),
|
||||||
@ -96,15 +92,15 @@ function createWindow(): BrowserWindow {
|
|||||||
contextMenu.popup({ window: win!, x: params.x, y: params.y });
|
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")
|
console.log("Save Model")
|
||||||
SaveProject.saveProject(projectDirectory, storageModels);
|
SaveProject.saveProject(projectDirectory, storageModels);
|
||||||
})
|
})*/
|
||||||
|
|
||||||
ipcMain.on('delete-component', (event, deletedComponent: DeleteModel) => {
|
/*ipcMain.on('delete-component', (event, deletedComponent: DeleteModel) => {
|
||||||
console.log("Delete Model: ", deletedComponent)
|
console.log("Delete Model: ", deletedComponent)
|
||||||
deleteComponent(deletedComponent);
|
deleteComponent(deletedComponent);
|
||||||
})
|
})*/
|
||||||
|
|
||||||
const menuTemplate = [
|
const menuTemplate = [
|
||||||
{
|
{
|
||||||
@ -206,8 +202,8 @@ function loadDevProjectAtStart() {
|
|||||||
|
|
||||||
function openProjectFromFile(openProjectDir: string) {
|
function openProjectFromFile(openProjectDir: string) {
|
||||||
projectDirectory = openProjectDir
|
projectDirectory = openProjectDir
|
||||||
console.log("Open Project-Directory: ", openProjectDir)
|
const gameModelLoader = new GameModelLoader(openProjectDir);
|
||||||
const loadedProject = SaveProject.loadProject(openProjectDir)
|
const loadedProject = gameModelLoader.loadGameModel();
|
||||||
win!.webContents.send("open-project", loadedProject)
|
win!.webContents.send("open-project", loadedProject)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,11 +211,11 @@ function saveProject() {
|
|||||||
win!.webContents.send('get-project-data')
|
win!.webContents.send('get-project-data')
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteComponent(component: DeleteModel) {
|
/*function deleteComponent(component: DeleteModel) {
|
||||||
console.log("Delete Component")
|
console.log("Delete Component")
|
||||||
if(component.modeltype == ModelComponentType.SCRIPTACCOUNT) {
|
if(component.modeltype == ModelComponentType.SCRIPTACCOUNT) {
|
||||||
DeleteTransaction.deleteScriptAccount(projectDirectory, component.componentName);
|
DeleteTransaction.deleteScriptAccount(projectDirectory, component.componentName);
|
||||||
} else if(component.modeltype === ModelComponentType.GAMESYTEM) {
|
} else if(component.modeltype === ModelComponentType.GAMESYTEM) {
|
||||||
DeleteTransaction.deleteGamesystem(projectDirectory, component.componentName);
|
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>
|
<button mat-menu-item (click)="openGamesystemsOverview()">{{ModelComponentTypeUtillities.toString(ModelComponentType.GAMESYTEM)}}</button>
|
||||||
</mat-menu>
|
</mat-menu>
|
||||||
</div>
|
</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>
|
<app-gamescript-overview *ngIf="openContent == ModelComponentType.GAMESYTEM" #gamesystemOverview [gameModel]="gameModel" (openGamesystemEditor)="openModelComponent($event)"></app-gamescript-overview>
|
||||||
</mat-drawer>
|
</mat-drawer>
|
||||||
|
|
||||||
|
@ -1,24 +1,20 @@
|
|||||||
import {Component, NgZone, OnInit, ViewChild} from '@angular/core';
|
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 {MatDrawerContainer} from "@angular/material/sidenav";
|
||||||
import {ModelComponentTypeUtillities} from "./game-model/ModelComponentTypeUtillities";
|
|
||||||
import {GameModel} from "./game-model/GameModel";
|
|
||||||
import {EditorComponent} from "./editor/editor.component";
|
import {EditorComponent} from "./editor/editor.component";
|
||||||
import {ModelComponent} from "./game-model/ModelComponent";
|
|
||||||
import {
|
import {
|
||||||
ScriptAccountOverviewComponent
|
ScriptAccountOverviewComponent
|
||||||
} from "./side-overviews/script-account-overview/script-account-overview.component";
|
} from "./side-overviews/script-account-overview/script-account-overview.component";
|
||||||
import {MatDialog} from "@angular/material/dialog";
|
import {MatDialog} from "@angular/material/dialog";
|
||||||
import {DeleteConfirmationDialogComponent} from "./delete-confirmation-dialog/delete-confirmation-dialog.component";
|
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 {GamescriptOverviewComponent} from "./side-overviews/gamescript-overview/gamescript-overview.component";
|
||||||
import {LoadedProject} from "../../app/LoadedProject";
|
|
||||||
import {ProcessLoadedProject} from "./game-model/fs/ProcessLoadedProject";
|
import {ProjectService} from "./project/project.service";
|
||||||
import {StoreProject} from "./game-model/fs/store/StoreProject";
|
import {ModelComponentType} from "./project/game-model/ModelComponentType";
|
||||||
import {Gamesystem} from "./game-model/gamesystems/Gamesystem";
|
import {ModelComponentTypeUtillities} from "./project/game-model/ModelComponentTypeUtillities";
|
||||||
import {DeleteModel} from "./game-model/fs/DeleteModel";
|
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({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@ -35,44 +31,11 @@ export class AppComponent implements OnInit{
|
|||||||
|
|
||||||
gameModel: GameModel | undefined
|
gameModel: GameModel | undefined
|
||||||
|
|
||||||
constructor(private electronService: ElectronService,
|
constructor(private zone: NgZone,
|
||||||
private zone: NgZone,
|
private dialog: MatDialog,
|
||||||
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) {
|
onContextMenuMessageRecieved(message: string) {
|
||||||
@ -100,7 +63,7 @@ export class AppComponent implements OnInit{
|
|||||||
} break;
|
} break;
|
||||||
case ModelComponentType.GAMESYTEM: {
|
case ModelComponentType.GAMESYTEM: {
|
||||||
if(this.gamesystemOverview!.selectedGamesystem != undefined) {
|
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!);
|
this.editor!.openGameModelComponent(gamesystem!);
|
||||||
}
|
}
|
||||||
} break
|
} break
|
||||||
@ -115,11 +78,11 @@ export class AppComponent implements OnInit{
|
|||||||
dialogRef.afterClosed().subscribe(res => {
|
dialogRef.afterClosed().subscribe(res => {
|
||||||
if(res != undefined && res) {
|
if(res != undefined && res) {
|
||||||
if(affectedModelComponent instanceof ScriptAccount) {
|
if(affectedModelComponent instanceof ScriptAccount) {
|
||||||
this.gameModel!.removeScriptAccount(affectedModelComponent);
|
this.projectService!.gameModel!.removeScriptAccount(affectedModelComponent);
|
||||||
this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.SCRIPTACCOUNT))
|
//this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.SCRIPTACCOUNT))
|
||||||
} else if(affectedModelComponent instanceof Gamesystem) {
|
} else if(affectedModelComponent instanceof Gamesystem) {
|
||||||
this.gameModel!.removeGamesystem(affectedModelComponent);
|
//this.gameModel!.removeGamesystem(affectedModelComponent);
|
||||||
this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.GAMESYTEM))
|
//this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.GAMESYTEM))
|
||||||
this.gamesystemOverview!.refresh()
|
this.gamesystemOverview!.refresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,7 +97,7 @@ export class AppComponent implements OnInit{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onCreateNewScriptAccount() {
|
private onCreateNewScriptAccount() {
|
||||||
const createdScriptAccount = this.gameModel!.createScriptAccount("New ScriptAccount");
|
const createdScriptAccount = this.projectService!.gameModel!.createScriptAccount("New ScriptAccount");
|
||||||
if(createdScriptAccount != undefined) {
|
if(createdScriptAccount != undefined) {
|
||||||
this.editor?.openGameModelComponent(createdScriptAccount);
|
this.editor?.openGameModelComponent(createdScriptAccount);
|
||||||
} else {
|
} 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) {
|
if(createdGamesystem != undefined) {
|
||||||
this.gamesystemOverview!.refresh();
|
this.gamesystemOverview!.refresh();
|
||||||
this.editor?.openGameModelComponent(createdGamesystem);
|
this.editor?.openGameModelComponent(createdGamesystem);
|
||||||
@ -176,6 +139,7 @@ export class AppComponent implements OnInit{
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.gameModel = this.projectService.gameModel
|
||||||
/*this.gameModel = new GameModel("No More");
|
/*this.gameModel = new GameModel("No More");
|
||||||
this.gameModel.createScriptAccount("Temperature");
|
this.gameModel.createScriptAccount("Temperature");
|
||||||
this.gameModel.createScriptAccount("Luftfeuchtigkeit");
|
this.gameModel.createScriptAccount("Luftfeuchtigkeit");
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {Component, Inject} from '@angular/core';
|
import {Component, Inject} from '@angular/core';
|
||||||
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
||||||
import {ModelComponentTypeUtillities} from "../game-model/ModelComponentTypeUtillities";
|
import {ModelComponent} from "../project/game-model/ModelComponent";
|
||||||
import {ModelComponent} from "../game-model/ModelComponent";
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-delete-confirmation-dialog',
|
selector: 'app-delete-confirmation-dialog',
|
||||||
@ -13,7 +13,6 @@ export class DeleteConfirmationDialogComponent {
|
|||||||
constructor(private dialogRef: MatDialogRef<DeleteConfirmationDialogComponent>,
|
constructor(private dialogRef: MatDialogRef<DeleteConfirmationDialogComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public deleteModelComponent: ModelComponent) {
|
@Inject(MAT_DIALOG_DATA) public deleteModelComponent: ModelComponent) {
|
||||||
}
|
}
|
||||||
protected readonly ModelComponentTypeUtillities = ModelComponentTypeUtillities;
|
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
this.dialogRef.close(false);
|
this.dialogRef.close(false);
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
||||||
import {GameModel} from "../game-model/GameModel";
|
import {ModelComponent} from "../project/game-model/ModelComponent";
|
||||||
import {ModelComponent} from "../game-model/ModelComponent";
|
import {GameModel} from "../project/game-model/GameModel";
|
||||||
import {ModelComponentType} from "../game-model/ModelComponentType";
|
import {ScriptAccount} from "../project/game-model/scriptAccounts/ScriptAccount";
|
||||||
import {ScriptAccount} from "../game-model/scriptAccounts/ScriptAccount";
|
import {Gamesystem} from "../project/game-model/gamesystems/Gamesystem";
|
||||||
import {Gamesystem} from "../game-model/gamesystems/Gamesystem";
|
import {State} from "../project/game-model/gamesystems/states/State";
|
||||||
import {State} from "../game-model/gamesystems/states/State";
|
import {Transition} from "../project/game-model/gamesystems/transitions/Transition";
|
||||||
import {Transition} from "../game-model/gamesystems/transitions/Transition";
|
import {ModelComponentType} from "../project/game-model/ModelComponentType";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-editor',
|
selector: 'app-editor',
|
||||||
@ -43,9 +44,10 @@ export class EditorComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected readonly ModelComponentType = ModelComponentType;
|
|
||||||
|
|
||||||
onModelNameUpdate() {
|
onModelNameUpdate() {
|
||||||
this.onModelNameUpdateEmitter.emit(true);
|
this.onModelNameUpdateEmitter.emit(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected readonly ModelComponentType = ModelComponentType;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||||
import {GameModel} from "../../game-model/GameModel";
|
import {State} from "../../project/game-model/gamesystems/states/State";
|
||||||
import {Gamesystem} from "../../game-model/gamesystems/Gamesystem";
|
import {Gamesystem} from "../../project/game-model/gamesystems/Gamesystem";
|
||||||
import {State} from "../../game-model/gamesystems/states/State";
|
import { Transition } from '../../project/game-model/gamesystems/transitions/Transition';
|
||||||
import {Transition} from "../../game-model/gamesystems/transitions/Transition";
|
import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount";
|
||||||
import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem";
|
import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem";
|
||||||
import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem";
|
import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem";
|
||||||
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-gamesystem-editor',
|
selector: 'app-gamesystem-editor',
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import {Gamesystem} from "../../../game-model/gamesystems/Gamesystem";
|
import {Gamesystem} from "../../../project/game-model/gamesystems/Gamesystem";
|
||||||
import {SimpleGamesystem} from "../../../game-model/gamesystems/SimpleGamesystem";
|
import {SimpleGamesystem} from "../../../project/game-model/gamesystems/SimpleGamesystem";
|
||||||
import {ProductGamesystem} from "../../../game-model/gamesystems/ProductGamesystem";
|
import {ProductGamesystem} from "../../../project/game-model/gamesystems/ProductGamesystem";
|
||||||
import {State} from "../../../game-model/gamesystems/states/State";
|
import {State} from "../../../project/game-model/gamesystems/states/State";
|
||||||
import {ProductState} from "../../../game-model/gamesystems/states/ProductState";
|
import {SimpleState} from "../../../project/game-model/gamesystems/states/SimpleState";
|
||||||
import {SimpleState} from "../../../game-model/gamesystems/states/SimpleState";
|
import {ProductState} from "../../../project/game-model/gamesystems/states/ProductState";
|
||||||
|
|
||||||
export class LeafGamesystemCalculator {
|
export class LeafGamesystemCalculator {
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
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 {
|
import {
|
||||||
ProductTransitionEditorComponent
|
ProductTransitionEditorComponent
|
||||||
} from "../transition-editor/product-transition-editor/product-transition-editor.component";
|
} 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 {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||||
import {ScriptAccountCondition} from "../../../game-model/gamesystems/conditions/ScriptAccountCondition";
|
|
||||||
import {MatTableDataSource} from "@angular/material/table";
|
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({
|
@Component({
|
||||||
selector: 'app-scriptaccount-condition-editor',
|
selector: 'app-scriptaccount-condition-editor',
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {Component, Input} from '@angular/core';
|
import {Component, Input} from '@angular/core';
|
||||||
import {SimpleGamesystem} from "../../../game-model/gamesystems/SimpleGamesystem";
|
|
||||||
import {MatTableDataSource} from "@angular/material/table";
|
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({
|
@Component({
|
||||||
selector: 'app-simple-gamesystem-editor',
|
selector: 'app-simple-gamesystem-editor',
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||||
import {ProductGamesystem} from "../../../../game-model/gamesystems/ProductGamesystem";
|
|
||||||
import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem";
|
|
||||||
import {
|
import {
|
||||||
MatTableDataSource
|
MatTableDataSource
|
||||||
} from "@angular/material/table";
|
} 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 {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 {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({
|
@Component({
|
||||||
selector: 'app-product-state-editor',
|
selector: 'app-product-state-editor',
|
||||||
@ -55,7 +53,6 @@ export class ProductStateEditorComponent implements OnInit{
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
protected readonly SimpleState = SimpleState;
|
|
||||||
|
|
||||||
getLeafState(state: State<any>, i: number) {
|
getLeafState(state: State<any>, i: number) {
|
||||||
return LeafGamesystemCalculator.calcLeafStates(state)[i];
|
return LeafGamesystemCalculator.calcLeafStates(state)[i];
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
import {Component, Input, OnInit} from '@angular/core';
|
import {Component, Input, OnInit} from '@angular/core';
|
||||||
import {SimpleState} from "../../../../game-model/gamesystems/states/SimpleState";
|
|
||||||
import {MatTableDataSource} from "@angular/material/table";
|
import {MatTableDataSource} from "@angular/material/table";
|
||||||
import {animate, state, style, transition, trigger} from "@angular/animations";
|
import {animate, state, style, transition, trigger} from "@angular/animations";
|
||||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||||
import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem";
|
import {SimpleState} from "../../../../project/game-model/gamesystems/states/SimpleState";
|
||||||
import {ProductState} from "../../../../game-model/gamesystems/states/ProductState";
|
import {SimpleGamesystem} from "../../../../project/game-model/gamesystems/SimpleGamesystem";
|
||||||
import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator";
|
import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount";
|
||||||
import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount";
|
import {ScriptAccountCondition} from "../../../../project/game-model/gamesystems/conditions/ScriptAccountCondition";
|
||||||
import {ScriptAccountCondition} from "../../../../game-model/gamesystems/conditions/ScriptAccountCondition";
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-simple-state-editor',
|
selector: 'app-simple-state-editor',
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||||
import {ProductGamesystem} from "../../../../game-model/gamesystems/ProductGamesystem";
|
|
||||||
import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem";
|
|
||||||
import {
|
import {
|
||||||
MatTableDataSource
|
MatTableDataSource
|
||||||
} from "@angular/material/table";
|
} from "@angular/material/table";
|
||||||
import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator";
|
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 {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 {
|
class DisplayedColumnName {
|
||||||
displayedName: string
|
displayedName: string
|
||||||
internalName: string
|
internalName: string
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import {Component, Input, OnInit} from '@angular/core';
|
import {Component, Input, OnInit} from '@angular/core';
|
||||||
import {Transition} from "../../../../game-model/gamesystems/transitions/Transition";
|
|
||||||
import {MatTableDataSource} from "@angular/material/table";
|
import {MatTableDataSource} from "@angular/material/table";
|
||||||
import {ScriptAccountAction} from "../../../../game-model/gamesystems/actions/ScriptAccountAction";
|
import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount";
|
||||||
import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount";
|
import {Transition} from "../../../../project/game-model/gamesystems/transitions/Transition";
|
||||||
|
import {ScriptAccountAction} from "../../../../project/game-model/gamesystems/actions/ScriptAccountAction";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-scriptaccount-action-editor',
|
selector: 'app-scriptaccount-action-editor',
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import {Component, Input, OnInit} from '@angular/core';
|
import {Component, Input, OnInit} from '@angular/core';
|
||||||
import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem";
|
|
||||||
import {
|
import {
|
||||||
MatTableDataSource
|
MatTableDataSource
|
||||||
} from "@angular/material/table";
|
} from "@angular/material/table";
|
||||||
import {SimpleTransition} from "../../../../game-model/gamesystems/transitions/SimpleTransition";
|
|
||||||
import {animate, state, style, transition, trigger} from "@angular/animations";
|
import {animate, state, style, transition, trigger} from "@angular/animations";
|
||||||
import {SimpleState} from "../../../../game-model/gamesystems/states/SimpleState";
|
import {SimpleGamesystem} from "../../../../project/game-model/gamesystems/SimpleGamesystem";
|
||||||
import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount";
|
import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount";
|
||||||
import {ScriptAccountCondition} from "../../../../game-model/gamesystems/conditions/ScriptAccountCondition";
|
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({
|
@Component({
|
||||||
selector: 'app-simple-transition-editor',
|
selector: 'app-simple-transition-editor',
|
||||||
templateUrl: './simple-transition-editor.component.html',
|
templateUrl: './simple-transition-editor.component.html',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||||
import {ModelComponent} from "../../game-model/ModelComponent";
|
|
||||||
import {FormControl, Validators} from "@angular/forms";
|
import {FormControl, Validators} from "@angular/forms";
|
||||||
|
import {ModelComponent} from "../../project/game-model/ModelComponent";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-model-component-editor',
|
selector: 'app-model-component-editor',
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import {Component, Input, OnInit} from '@angular/core';
|
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 {MatFormField} from "@angular/material/form-field";
|
||||||
import {MatInput} from "@angular/material/input";
|
import {MatInput} from "@angular/material/input";
|
||||||
import {FormControl, FormGroupDirective, FormsModule, NgForm, Validators} from "@angular/forms";
|
import {FormControl, FormGroupDirective, FormsModule, NgForm, Validators} from "@angular/forms";
|
||||||
import {NgIf} from "@angular/common";
|
import {NgIf} from "@angular/common";
|
||||||
import {ErrorStateMatcher} from "@angular/material/core";
|
import {ErrorStateMatcher} from "@angular/material/core";
|
||||||
import {ElectronService} from "../../core/services";
|
import {ElectronService} from "../../core/services";
|
||||||
|
import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount";
|
||||||
|
|
||||||
export class MyErrorStateMatcher implements ErrorStateMatcher {
|
export class MyErrorStateMatcher implements ErrorStateMatcher {
|
||||||
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
|
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
|
||||||
|
@ -6,7 +6,6 @@ import {Transition} from "./transitions/Transition";
|
|||||||
import {SimpleState} from "./states/SimpleState";
|
import {SimpleState} from "./states/SimpleState";
|
||||||
import {SimpleGamesystem} from "./SimpleGamesystem";
|
import {SimpleGamesystem} from "./SimpleGamesystem";
|
||||||
import {GameModel} from "../GameModel";
|
import {GameModel} from "../GameModel";
|
||||||
import {ProductStateTrainer} from "../../../../e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer";
|
|
||||||
import {ScriptAccountCondition} from "./conditions/ScriptAccountCondition";
|
import {ScriptAccountCondition} from "./conditions/ScriptAccountCondition";
|
||||||
import {ScriptAccountAction} from "./actions/ScriptAccountAction";
|
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 {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 {FlatTreeControl} from "@angular/cdk/tree";
|
||||||
import {MatTreeFlatDataSource, MatTreeFlattener} from "@angular/material/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 {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 {
|
interface FlatNode {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {Component, EventEmitter, Input, NgZone, Output} from '@angular/core';
|
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 {ElectronService} from "../../core/services";
|
||||||
|
import {GameModel} from "../../project/game-model/GameModel";
|
||||||
|
import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-script-account-overview',
|
selector: 'app-script-account-overview',
|
||||||
|
Loading…
Reference in New Issue
Block a user