Skip to content

Commit

Permalink
0.1.19
Browse files Browse the repository at this point in the history
Improved:
* In non expert mode you are now warned (red border) about non existant items and you will be unable to save if any exist
* Items which did not show correctly before (like organs) are now shown again
* In the big view of an item you can see the entire item again, instead of only a part of it (for non square items)
* When using the update function for the GUI now the entire GUI is replaced instead of only parts meaning bigger updates can be done using that

Closes #61
  • Loading branch information
NetroScript committed Mar 1, 2020
1 parent f6d112f commit 5e5f04a
Show file tree
Hide file tree
Showing 8 changed files with 687 additions and 653 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Additionally you can export the loaded save to a .json file, which has a similar

**The Application uses a webbrowser as a GUI** (by default Chrome in App Mode, but during development FireFox was tried too - f.e. Opera should work too, but watch out for your Opera version - see [Issue #54](https://github.com/NetroScript/Graveyard-Keeper-Savefile-Editor/issues/54)).

I want to add I am not responsible if you break your save file, I try to mantain this editor in a way, in which it can't break save files (or not by mistake) but it is still possible that this editor produces a bugged save file (if you f.e. add an item in a quality in which the item doesn't exist.)
I want to add I am not responsible if you break your save file, I try to mantain this editor in a way, in which it can't break save files (or not by mistake) but it is still possible that this editor produces a bugged save file (if you for example add an item in a quality in which the item doesn't exist. - although in non expert mode the editor will prevent saving your file when a non existant item is selected)
That is why you always should backup your save files. (In the settings of the editor you can also set the number of backups the editor should create (which are zipped) - on saving the editor all backups are shifted by one, so if set it to 3 backups and save 4 times, your oldest backup is lost).

But I want to mention the last time someone asked for help due to a save broken by the save editor was in september 2018 and since then I also took additional measures.
Expand Down Expand Up @@ -77,10 +77,8 @@ The application supports variables in the path starting with 0.1.17. If you use
## Usage

Considering the application has a GUI it should be self explanatory.
If a name autocompletes to undefined, the item has no internal name or my localisation files are missing translations.
If you know an item exists, but it doesn't appear in the autocompletion box, leave me a message, this means I forgot some items in my list with items.
Same if an item doesn't have a preview image - if that happens please leave me a message with the internal id (written in parentheses) and a screenshot of the item in game (so I know which item in the spritesheet is the id)

If a red border appears around an item, it means the save editor doesn't have this item indexed. Either because the item doesn't exist, or it was added in an update which wasn't included yet in the editor.
Same if an item doesn't have a preview image - if that happens please leave me a message with the internal id (written in parentheses) and a screenshot of the item in game (so I know which item in the spritesheet is the id).

If you want to manually edit save files, when you change values, watch out if you change the type of the variable. F.e. if you would change a value from 0 to 1, the type would change and you would need to manually change the type to the correct one.
For information about the possible types, check types.py in the data folder.
Expand Down
9 changes: 9 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
0.1.19
=====

Improved:
* In non expert mode you are now warned (red border) about non existant items and you will be unable to save if any exist
* Items which did not show correctly before (like organs) are now shown again
* In the big view of an item you can see the entire item again, instead of only a part of it (for non square items)
* When using the update function for the GUI now the entire GUI is replaced instead of only parts meaning bigger updates can be done using that

0.1.18
=====

Expand Down
1,219 changes: 614 additions & 605 deletions data/html/css/items.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions data/html/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -680,4 +680,8 @@ p.timeoutput {

.miscbuttons .btn {
margin: 10px 0px 10px 0px;
}

.unknown_item {
border: dotted 2px red;
}
78 changes: 49 additions & 29 deletions data/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,9 @@
if(id.match(/^\d/)){
id = "_" + id
};
return id.replace(/(:1|:2|:3)$/, "").replace(/:/g, "__")
id = id.replace(/(:1|:2|:3)$/, "").replace(/:/g, "__")
if (!id.startsWith("embalm")) id = id.replace(/_-?\d_-?\d/, "")
return id
}

// Get the URL to the item icon by id
Expand Down Expand Up @@ -577,17 +579,9 @@
async function addItem(id, amount, durability, element) {

//Check for a quality of the item
let spl = id.split(":");
let quality = "";
if (spl.length > 1) {
let q = spl.slice(-1)[0];
if (q == "1") {
quality = " copper";
} else if (q == "2") {
quality = " silver";
} else if (q == "3") {
quality = " gold";
}
if(["1","2","3"].includes(id.split(":").pop())){
quality = [" copper", " silver", " gold"][parseInt(id.split(":").pop())-1]
}

//If the item can be repaired, add a button to do that
Expand Down Expand Up @@ -804,6 +798,13 @@
item.find(".itemid").text("(" + newid + ")");
}

if ( !settings["expert"]){
if(!gamedata.items.includes(newid)){
item.addClass("unknown_item");
} else {
item.removeClass("unknown_item");
}
}


});
Expand Down Expand Up @@ -842,6 +843,20 @@
$(e).find(".itemname").html(getLocalisation(id) + ' <div class="itemid">(' + id +
')</div>');
$(e).find(".itemname").removeClass("curactive");

let iconholder = $(e).parent()
iconholder.removeClass("gold silver copper")
if(["1","2","3"].includes(id.split(":").pop())){
iconholder.addClass(["copper", "silver", "gold"][parseInt(id.split(":").pop())-1])
}

if ( !settings["expert"]){
if(!gamedata.items.includes(id)){
iconholder.addClass("unknown_item");
} else {
iconholder.removeClass("unknown_item");
}
}
}
}
catch(e) {
Expand Down Expand Up @@ -993,7 +1008,7 @@

// Check if the user filled all fields and isn't currently editing an item name
let t = canContinue();
if (t === true) {
if (t.length == 0) {
// Update the data from the form which wasn't updated yet
collectData();
let hashdata = window.location.hash.split("#")[1].split("|");
Expand All @@ -1018,10 +1033,14 @@
});
}
} else {
// Show message why the user can't continue
M.toast({
html: t
});
for(message in t){
// Show message why the user can't continue
M.toast({
html: t,
displayLength: 10000,
classes: "red darken-3"
});
}
}

}
Expand Down Expand Up @@ -1138,22 +1157,21 @@
if (val.split("(").length > 1) {
let id = val.split("(").pop().split(")")[0];

// Check if the quality changed
let spl = id.split(":");
if (spl.length > 1) {
let q = spl.slice(-1)[0];
if (q == "1") {
$(this.el).parents(".item").attr("class", "item add copper");
} else if (q == "2") {
$(this.el).parents(".item").attr("class", "item add silver");
} else if (q == "3") {
$(this.el).parents(".item").attr("class", "item add gold");
}
if(["1","2","3"].includes(id.split(":").pop())){
$(this.el).parents(".item").attr("class", "item add " + ["copper", "silver", "gold"][parseInt(id.split(":").pop())-1]);
} else {
$(this.el).parents(".item").attr("class", "item add");
}

$(this.el).parents(".item").find(".item_icon").attr("class", "item_icon " + sanitzize_item_id(id));;

if ( !settings["expert"]){
if(!gamedata.items.includes(newid)){
$(this.el).parents(".item").addClass("unknown_item");
} else {
$(this.el).parents(".item").removeClass("unknown_item");
}
}
}
}

Expand Down Expand Up @@ -1218,9 +1236,11 @@

// Check if a item didn't autocomplete, so that the user doesn't save old ID's
function canContinue() {
if ($(".currentlyediting").length > 0) return "Please auto complete all Items before saving";
let errors = []
if ($(".currentlyediting").length > 0) errors.push("Please auto complete all Items before saving");
if ($(".unknown_item").length > 0) errors.push("You currently have non existant items added (they have a red outline when expanded). Please change them. If you actually want to add an item the editor does not support, please enable expert mode in settings. (and reload this page)");

return true;
return errors;
}

// Load the settings file
Expand Down
Binary file modified data/html/rsc/item_source_file.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion data/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.18
0.1.19
20 changes: 7 additions & 13 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,22 @@ def updateitemversion():
response = urlopen("https://github.com/NetroScript/Graveyard-Keeper-Savefile-Editor/archive/master.zip")
# Load the downloaded in memory file as a zip file
zipfile = ZipFile(BytesIO(response.read()))
print("Deleting Old /rsc folder")
shutil.rmtree('./data/html/rsc', ignore_errors=True)
os.mkdir("./data/html/rsc")
print("Copying new rsc files")
print("Deleting Old Frontend (html folder)")
shutil.rmtree('./data/html', ignore_errors=True)
os.mkdir("./data/html")
print("Copying new frontend files")
# We iterate all files in the zip to be able to extract 1 whole specific folder
for zip_info in zipfile.infolist():
# We only want the rsc folder
if zip_info.filename.startswith("Graveyard-Keeper-Savefile-Editor-master/data/html/rsc/"):
if zip_info.filename.startswith("Graveyard-Keeper-Savefile-Editor-master/data/html/"):
# To prevent an error when there is no base name
if zip_info.filename[-1] == '/':
continue
# So we don't extract the whole folder structure we change the path in the zip info object
zip_info.filename = os.path.basename(zip_info.filename)
zipfile.extract(zip_info, "./data/html/rsc/")
zip_info.filename = zip_info.filename.split("/data/html/")[1]
zipfile.extract(zip_info, "./data/html/")

# Same as above but for individual files
print("Deleting old items.json")
os.remove("./data/html/items.json")
print("Copying new items.json")
info = zipfile.getinfo("Graveyard-Keeper-Savefile-Editor-master/data/html/items.json")
info.filename = os.path.basename(info.filename)
zipfile.extract(info, "./data/html/")
print("Deleting old locals.json")
os.remove("./data/locals.json")
print("Copying new locals.json")
Expand Down

0 comments on commit 5e5f04a

Please sign in to comment.