Skip to content

Commit

Permalink
Merge pull request #128 from Benjamin-Dobell/fix/save-and-play
Browse files Browse the repository at this point in the history
Fix Save & Play
  • Loading branch information
onelivesleft authored Oct 25, 2020
2 parents 87f12ce + c9a6d97 commit a14e7f0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
11 changes: 8 additions & 3 deletions lib/info.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference path="../typings/hover.d.ts" />
var child_process = require('child_process');
var remote = require('electron').remote;
var Q = require('q');
function provider(p) {
function okInfo(text) {
Expand All @@ -10,11 +11,15 @@ function provider(p) {
return { valid: false, info: text.join('\n') };
}
function errInfo(text) {
atom.confirm({
remote.dialog.showMessageBox(remote.getCurrentWindow(), {
type: 'info',
normalizeAccessKeys: true,
message: "Hover Info Error" + text,
detailedMessage: text,
buttons: {
Close: function () { window.alert('ok'); }
buttons: ['Close']
}).then(function(event) {
if (event.response === 0) {
window.alert('ok')
}
});
return { valid: false, info: text };
Expand Down
39 changes: 20 additions & 19 deletions lib/tabletopsimulator-lua.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{CompositeDisposable} = require 'atom'
{BufferedProcess} = require 'atom'
{remote} = require 'electron'

net = require 'net'
fs = require 'fs'
Expand Down Expand Up @@ -1213,21 +1214,22 @@ module.exports = TabletopsimulatorLua =
if atom.config.get('tabletopsimulator-lua.loadSave.communicationMode') == 'disable'
return
# Confirm just in case they misclicked Save & Play
atom.confirm
remote.dialog.showMessageBox(remote.getCurrentWindow(), {
type: 'info',
normalizeAccessKeys: true,
message: 'Get Lua Scripts from game?'
detailedMessage: 'This will erase any changes that you have made in Atom since the last Save & Play.'
buttons:
'Get Scripts': ->
#destroyTTSEditors()
#deleteCachedFiles()
log_seperator(LOG_MSG)
log LOG_MSG, "Get Lua Scripts: Sending request to TTS..."
#if not TabletopsimulatorLua.if_connected
TabletopsimulatorLua.startConnection()
TabletopsimulatorLua.connection.write '{ messageID: ' + ATOM_MSG_GET_SCRIPTS + ' }'
log LOG_MSG, "Sent."
Cancel: -> return

buttons: ['Get Scripts', 'Cancel']
}).then((event) ->
if event.response == 0
#destroyTTSEditors()
#deleteCachedFiles()
log_seperator(LOG_MSG)
log LOG_MSG, "Get Lua Scripts: Sending request to TTS..."
#if not TabletopsimulatorLua.if_connected
TabletopsimulatorLua.startConnection()
TabletopsimulatorLua.connection.wri
)

# hack needed because atom 1.19 makes save() async
blocking_save: (editor) =>
Expand All @@ -1253,14 +1255,13 @@ module.exports = TabletopsimulatorLua =
# If TTS Save has been overwritten then confirm
if @objectsAddedToGame()
getObjects = @getObjects
exit = true
atom.confirm
return if remote.dialog.showMessageBoxSync(remote.getCurrentWindow(), {
type: 'info',
normalizeAccessKeys: true,
message: 'Overwrite Tabletop Simulator save?'
detailedMessage: 'Components have been added in Tabletop Simulator but have not been saved. If you continue any such components may be lost.'
buttons:
Overwrite: -> exit = false
Cancel: ->
return if exit
buttons: ['Overwrite', 'Cancel']
}) != 0

mutex.doingSaveAndPlay = true
log_seperator(LOG_MSG)
Expand Down

0 comments on commit a14e7f0

Please sign in to comment.