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:
parent
3c9707ea84
commit
f2bff6701e
2
.gitignore
vendored
2
.gitignore
vendored
@ -12,3 +12,5 @@ yarn-error.log*
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
/App.js
|
||||
/package-lock.json
|
||||
|
||||
@ -25,7 +25,8 @@
|
||||
"vue-clipboard2": "^0.3.0",
|
||||
"vue-router": "^3.0.1",
|
||||
"vuex": "^3.0.1",
|
||||
"vuex-persistedstate": "^2.5.4"
|
||||
"vuex-persistedstate": "^2.5.4",
|
||||
"xml-js": "^1.6.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^7.1.2",
|
||||
|
||||
@ -109,6 +109,13 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="label">Upload</label>
|
||||
<div class="field has-addons">
|
||||
<div class="control">
|
||||
<input type="file" @change="OnFileChange"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="section">
|
||||
@ -142,6 +149,7 @@ import { faCopy, faTrash, faCloudUploadAlt } from '@fortawesome/fontawesome-free
|
||||
import 'mdi-vue/ContentCopyIcon'
|
||||
import 'mdi-vue/UploadIcon'
|
||||
import 'mdi-vue/DeleteIcon'
|
||||
import XmlJs from 'xml-js'
|
||||
export default {
|
||||
name: 'Settings',
|
||||
components: {
|
||||
@ -225,6 +233,30 @@ export default {
|
||||
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 () {
|
||||
if (this.DeleteConfirm) {
|
||||
this.$store.commit('resetData')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user