mirror of
https://github.com/IvarK/AntimatterDimensionsSourceCode.git
synced 2024-11-25 21:51:50 +00:00
Merge pull request #2704 from IvarK/fix-switch-mode-inconsistent
Fix reactivity issues on switching modes
This commit is contained in:
commit
b6a8f4abac
@ -26,10 +26,7 @@ export default {
|
||||
set(value) {
|
||||
this.$viewModel.tabs.reality.automator.editorScriptID = value;
|
||||
}
|
||||
},
|
||||
currentScriptContent() {
|
||||
return player.reality.automator.scripts[this.currentScriptID].content;
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
update() {
|
||||
@ -42,7 +39,7 @@ export default {
|
||||
// This saves the script after converting it.
|
||||
BlockAutomator.parseTextFromBlocks();
|
||||
player.reality.automator.type = AUTOMATOR_TYPE.TEXT;
|
||||
} else if (BlockAutomator.fromText(this.currentScriptContent)) {
|
||||
} else if (BlockAutomator.fromText(player.reality.automator.scripts[this.currentScriptID].content)) {
|
||||
AutomatorBackend.saveScript(scriptID, AutomatorTextUI.editor.getDoc().getValue());
|
||||
player.reality.automator.type = AUTOMATOR_TYPE.BLOCK;
|
||||
} else {
|
||||
|
@ -73,7 +73,12 @@ export default {
|
||||
},
|
||||
rewind: () => AutomatorBackend.restart(),
|
||||
play() {
|
||||
if (this.hasErrors) return;
|
||||
if (this.hasErrors) {
|
||||
// This shouldn't be needed but someone's save was still on MODE.RUN when the script had errors so this
|
||||
// is just an additional layer of failsafe in case something goes wrong
|
||||
AutomatorBackend.mode = AUTOMATOR_MODE.PAUSED;
|
||||
return;
|
||||
}
|
||||
if (this.isRunning) {
|
||||
AutomatorBackend.pause();
|
||||
return;
|
||||
|
@ -62,14 +62,16 @@ export default {
|
||||
this.$nextTick(() => BlockAutomator.fromText(this.currentScript));
|
||||
},
|
||||
toggleAutomatorMode() {
|
||||
if (AutomatorBackend.state.mode === AUTOMATOR_MODE.PAUSE || !player.options.confirmations.switchAutomatorMode) {
|
||||
if (AutomatorBackend.mode !== AUTOMATOR_MODE.RUN || !player.options.confirmations.switchAutomatorMode) {
|
||||
const scriptID = this.currentScriptID;
|
||||
Tutorial.moveOn(TUTORIAL_STATE.AUTOMATOR);
|
||||
if (this.automatorType === AUTOMATOR_TYPE.BLOCK) {
|
||||
// This saves the script after converting it.
|
||||
BlockAutomator.parseTextFromBlocks();
|
||||
player.reality.automator.type = AUTOMATOR_TYPE.TEXT;
|
||||
} else if (BlockAutomator.fromText(this.currentScriptContent)) {
|
||||
// Don't use this.currentScriptContent here due to reactivity issues, but on the other hand reactively
|
||||
// updating content might lead to decreased performance.
|
||||
} else if (BlockAutomator.fromText(player.reality.automator.scripts[this.currentScriptID].content)) {
|
||||
AutomatorBackend.saveScript(scriptID, AutomatorTextUI.editor.getDoc().getValue());
|
||||
player.reality.automator.type = AUTOMATOR_TYPE.BLOCK;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user