1
0
mirror of https://github.com/kihashi/stardew_community_checklist.git synced 2025-10-19 08:03:17 +00:00

Started work on importing save file.

This commit is contained in:
Sempiternity87 2019-12-10 16:55:51 -08:00
parent 3c9707ea84
commit f2bff6701e
3 changed files with 36 additions and 1 deletions

2
.gitignore vendored
View File

@ -12,3 +12,5 @@ yarn-error.log*
*.ntvs* *.ntvs*
*.njsproj *.njsproj
*.sln *.sln
/App.js
/package-lock.json

View File

@ -25,7 +25,8 @@
"vue-clipboard2": "^0.3.0", "vue-clipboard2": "^0.3.0",
"vue-router": "^3.0.1", "vue-router": "^3.0.1",
"vuex": "^3.0.1", "vuex": "^3.0.1",
"vuex-persistedstate": "^2.5.4" "vuex-persistedstate": "^2.5.4",
"xml-js": "^1.6.11"
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^7.1.2", "autoprefixer": "^7.1.2",

View File

@ -109,6 +109,13 @@
</button> </button>
</div> </div>
</div> </div>
<label class="label">Upload</label>
<div class="field has-addons">
<div class="control">
<input type="file" @change="OnFileChange"/>
</div>
</div>
</div> </div>
</section> </section>
<section class="section"> <section class="section">
@ -142,6 +149,7 @@ import { faCopy, faTrash, faCloudUploadAlt } from '@fortawesome/fontawesome-free
import 'mdi-vue/ContentCopyIcon' import 'mdi-vue/ContentCopyIcon'
import 'mdi-vue/UploadIcon' import 'mdi-vue/UploadIcon'
import 'mdi-vue/DeleteIcon' import 'mdi-vue/DeleteIcon'
import XmlJs from 'xml-js'
export default { export default {
name: 'Settings', name: 'Settings',
components: { components: {
@ -225,6 +233,30 @@ export default {
alert('Data Loaded!') alert('Data Loaded!')
} }
}, },
OnFileChange: function (e) {
var files = e.target.files || e.dataTransfer.files
if (files.length) {
let file = files[0]
let reader = new FileReader()
reader.readAsText(file, 'UTF-8')
reader.onload = evt => {
let f = XmlJs.xml2js(evt.target.result, { compact: true, spaces: 2 })
console.log(f)
let locations = f.SaveGame.locations.GameLocation
for (let i = 0; i < locations.length; i++) {
if (locations[i].name._text === 'CommunityCenter') {
console.log(locations[i])
}
}
console.log('Done printing')
}
reader.onerror = evt => {
console.error(evt)
}
}
},
ConfirmDelete: function () { ConfirmDelete: function () {
if (this.DeleteConfirm) { if (this.DeleteConfirm) {
this.$store.commit('resetData') this.$store.commit('resetData')