Skip to content

Commit

Permalink
Fixed issues in save system, smaller save files
Browse files Browse the repository at this point in the history
  • Loading branch information
Ville Talonpoika committed Feb 27, 2016
1 parent b5e234d commit b488dac
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
16 changes: 10 additions & 6 deletions novel.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ NovelManager = (function() {
if (novelData.novel.version !== loadedData.version) {
console.warn("WARNING! novel version mismatch");
}
novelData.novel = loadedData;
novelData.novel.inventories = loadedData.inventories;
novelData.debugMode = novelData.novel.debugMode;
soundManager.init();
return sceneManager.updateScene(novelData.novel.currentScene, true);
return sceneManager.updateScene(loadedData.currentScene, true);
};

NovelManager.prototype.start = function() {
Expand All @@ -86,8 +86,12 @@ NovelManager = (function() {
};

NovelManager.prototype.saveDataAsJson = function() {
var save;
save = btoa(JSON.stringify(novelData.novel));
var save, saveData;
saveData = novelData.novel;
delete saveData.scenes;
delete saveData.tagPresets;
delete saveData.sounds;
save = btoa(JSON.stringify(saveData));
return save;
};

Expand Down Expand Up @@ -1521,7 +1525,7 @@ UI = (function() {

UI.prototype.showLoadNotification = function() {
var e;
if (gameArea.game.settings.saveMode === "text") {
if (novelArea.novel.settings.saveMode === "text") {
e = document.getElementById("load-notification");
return e.style.display = 'block';
} else {
Expand All @@ -1534,7 +1538,7 @@ UI = (function() {
e = document.getElementById("load-notification");
if (load) {
textArea = e.querySelectorAll("textarea");
novelManager.loadGame(textArea[0].value);
novelManager.loadData(textArea[0].value);
textArea[0].value = "";
}
return e.style.display = 'none';
Expand Down
4 changes: 2 additions & 2 deletions novel.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "novel-js",
"version": "0.4.0",
"version": "0.4.1",
"description": "A lightweight JavaScript text game engine",
"author": "Ville Talonpoika <[email protected]> (http://nanof.us)",
"license": "MIT",
Expand Down
10 changes: 7 additions & 3 deletions src/NovelManager.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class NovelManager
return
if novelData.novel.version != loadedData.version
console.warn "WARNING! novel version mismatch"
novelData.novel = loadedData
novelData.novel.inventories = loadedData.inventories
novelData.debugMode = novelData.novel.debugMode
soundManager.init()
sceneManager.updateScene(novelData.novel.currentScene,true)
sceneManager.updateScene(loadedData.currentScene,true)

# Start the novel by loading the default novel.json
start: ->
Expand All @@ -70,7 +70,11 @@ class NovelManager

# Converts the novel's state into json and Base64 encode it
saveDataAsJson: () ->
save = btoa(JSON.stringify(novelData.novel))
saveData = novelData.novel
delete saveData.scenes
delete saveData.tagPresets
delete saveData.sounds
save = btoa(JSON.stringify(saveData))
return save

# Save novel in the defined way
Expand Down
4 changes: 2 additions & 2 deletions src/UI.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class UI

# Show the load notification window
showLoadNotification: ->
if gameArea.game.settings.saveMode == "text"
if novelArea.novel.settings.saveMode == "text"
e = document.getElementById("load-notification")
e.style.display = 'block';
else
Expand All @@ -28,7 +28,7 @@ class UI
e = document.getElementById("load-notification")
if load
textArea = e.querySelectorAll("textarea")
novelManager.loadGame(textArea[0].value)
novelManager.loadData(textArea[0].value)
textArea[0].value = ""
e.style.display = 'none'

Expand Down

0 comments on commit b488dac

Please sign in to comment.