-
-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
334 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
"target": "zip" | ||
}, | ||
"mac": { | ||
"darkModeSupport": true, | ||
"icon": "icons/app.icns", | ||
"target": "dmg" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "Twine", | ||
"version": "2.3.1", | ||
"version": "2.3.2", | ||
"author": "Chris Klimas <[email protected]>", | ||
"description": "a GUI for creating nonlinear stories", | ||
"license": "GPL-3.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
In a web context, opens or re-uses a browser window/tab to display a playable | ||
version of a story. In Electron, this publishes the content, then sends it to be | ||
viewed in a browser using a temp file. | ||
These are a single entrypoint so that individual UI parts don't have to worry | ||
about which context they're in to dispatch a play or test. | ||
*/ | ||
|
||
const { | ||
getStoryPlayHtml, | ||
getStoryProofingHtml, | ||
getStoryTestHtml | ||
} = require('./story-html'); | ||
const isElectron = require('../electron/is-electron'); | ||
const locale = require('../locale'); | ||
|
||
const windows = {}; | ||
|
||
function openWindow(url) { | ||
if (windows[url]) { | ||
try { | ||
windows[url].focus(); | ||
windows[url].location.reload(); | ||
return; | ||
} catch (e) { | ||
/* | ||
Fall through: try opening the window as usual. The problem probably | ||
is that the window has since been closed by the user. | ||
*/ | ||
} | ||
} | ||
|
||
windows[url] = window.open(url, url.replace(/\s/g, '_')); | ||
} | ||
|
||
module.exports = { | ||
playStory(store, storyId) { | ||
if (isElectron()) { | ||
getStoryPlayHtml(store, storyId) | ||
.then(html => | ||
window.twineElectron.ipcRenderer.send( | ||
'open-with-temp-file', | ||
html, | ||
'.html' | ||
) | ||
) | ||
.catch(e => { | ||
window.alert( | ||
locale.say( | ||
'An error occurred while publishing your story. (%s)', | ||
e.message | ||
) | ||
); | ||
}); | ||
} else { | ||
openWindow(`#stories/${storyId}/play`); | ||
} | ||
}, | ||
|
||
proofStory(store, storyId) { | ||
if (isElectron()) { | ||
getStoryProofingHtml(store, storyId) | ||
.then(html => | ||
window.twineElectron.ipcRenderer.send( | ||
'open-with-temp-file', | ||
html, | ||
'.html' | ||
) | ||
) | ||
.catch(e => { | ||
window.alert( | ||
locale.say( | ||
'An error occurred while publishing your story. (%s)', | ||
e.message | ||
) | ||
); | ||
}); | ||
} else { | ||
openWindow(`#stories/${storyId}/proof`); | ||
} | ||
}, | ||
|
||
testStory(store, storyId, startPassageId) { | ||
if (isElectron()) { | ||
getStoryTestHtml(store, storyId, startPassageId) | ||
.then(html => | ||
window.twineElectron.ipcRenderer.send( | ||
'open-with-temp-file', | ||
html, | ||
'.html' | ||
) | ||
) | ||
.catch(e => { | ||
window.alert( | ||
locale.say( | ||
'An error occurred while publishing your story. (%s)', | ||
e.message | ||
) | ||
); | ||
}); | ||
} else { | ||
if (startPassageId) { | ||
openWindow(`#stories/${storyId}/test/${startPassageId}`); | ||
} else { | ||
openWindow(`#stories/${storyId}/test`); | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.