From 0036fe1e3ae10ed0df325110e5b24316ae999e7a Mon Sep 17 00:00:00 2001 From: aoitaku Date: Sun, 11 Mar 2018 18:35:28 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=E3=82=B3=E3=83=B3=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=83=8D=E3=83=B3=E3=83=88=E3=81=AE=E5=BD=B9=E5=89=B2?= =?UTF-8?q?=E3=81=AB=E5=BF=9C=E3=81=98=E3=81=A6=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E5=88=86=E9=9B=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/components/Project.vue | 166 +----------------- src/renderer/components/Project/Editor.vue | 32 ++-- .../components/Project/EditorHeader.vue | 117 ++++++++++-- .../components/Project/EditorHeader/Save.vue | 37 ++++ .../Project/EditorHeader/TestPlay.vue | 36 ++++ .../components/Project/EditorResult.vue | 27 +-- src/renderer/store.ts | 32 +++- 7 files changed, 242 insertions(+), 205 deletions(-) create mode 100644 src/renderer/components/Project/EditorHeader/Save.vue create mode 100644 src/renderer/components/Project/EditorHeader/TestPlay.vue diff --git a/src/renderer/components/Project.vue b/src/renderer/components/Project.vue index 5477303..565c4e1 100644 --- a/src/renderer/components/Project.vue +++ b/src/renderer/components/Project.vue @@ -1,39 +1,22 @@ diff --git a/src/renderer/components/Project/EditorHeader/Save.vue b/src/renderer/components/Project/EditorHeader/Save.vue new file mode 100644 index 0000000..2893d84 --- /dev/null +++ b/src/renderer/components/Project/EditorHeader/Save.vue @@ -0,0 +1,37 @@ + + + diff --git a/src/renderer/components/Project/EditorHeader/TestPlay.vue b/src/renderer/components/Project/EditorHeader/TestPlay.vue new file mode 100644 index 0000000..a886129 --- /dev/null +++ b/src/renderer/components/Project/EditorHeader/TestPlay.vue @@ -0,0 +1,36 @@ + + + diff --git a/src/renderer/components/Project/EditorResult.vue b/src/renderer/components/Project/EditorResult.vue index bc8f375..9fd0b71 100644 --- a/src/renderer/components/Project/EditorResult.vue +++ b/src/renderer/components/Project/EditorResult.vue @@ -1,16 +1,18 @@ diff --git a/src/renderer/store.ts b/src/renderer/store.ts index 3bbeb7c..7f70f55 100644 --- a/src/renderer/store.ts +++ b/src/renderer/store.ts @@ -1,23 +1,53 @@ import { ShowMessageParameters } from './commands/parameters' +import * as Parser from './parser' +import errorTransform from './parser-error-transform' +import resultTransform, { describeResult } from './parser-result-transform' export interface ISharedState { - selectedProject: string | null + selectedProject: string | null + selectedFile: string | null eventDataJSON: string parseResult: string source: string showMessageParameters: ShowMessageParameters + edited: boolean + busy: boolean } export interface IStore { state: ISharedState + initState (): void + updateSource (newValue: string): void } export const store: IStore = { state: { selectedProject: null, + selectedFile: null, eventDataJSON: '', parseResult: '', source: '', showMessageParameters: ["Actor1", 0, 0, 2], + edited: false, + busy: false, + }, + initState () { + this.state.selectedProject = null + this.state.selectedFile = null + this.state.eventDataJSON = '' + this.state.parseResult = '' + this.state.source = '' + this.state.edited = false + this.state.busy = false + }, + updateSource (newValue: string) { + this.state.source = newValue + try { + const result = resultTransform(Parser.parse(this.state.source)) + this.state.eventDataJSON = JSON.stringify(result) + this.state.parseResult = describeResult(result) + } catch (err) { + this.state.parseResult = errorTransform(err) + } }, }