mirror of
https://github.com/IvarK/AntimatterDimensionsSourceCode.git
synced 2024-11-10 14:12:02 +00:00
Vuefy cloud conflict poopoop
This commit is contained in:
parent
17f41849e3
commit
da2dd877d8
16
index.html
16
index.html
@ -2751,21 +2751,6 @@
|
||||
<div id="offlinePopup" style="height: 150px">You made X antimatter and stuff</div>
|
||||
<button class="storebtn" style="font-size: 15px" onclick="closeToolTip()" style="display: inline">Okay</button>
|
||||
</div>
|
||||
<div class="popup savemenu" id="cloudloadconflict">
|
||||
<strong>Your cloud save appears to be older than your local save. Please select which one you would like to keep.</strong>
|
||||
<div id="local">
|
||||
<strong>Save #<span class="save_id"></span> (local):</strong>
|
||||
<span>Infinities: <span class="save_infinities"></span></span>
|
||||
<span>Eternities: <span class="save_eternities"></span></span>
|
||||
<button class="storebtn" style="font-size: 15px" style="display: inline">Load local</button>
|
||||
</div>
|
||||
<div id="cloud">
|
||||
<strong>Save #<span class="save_id"></span> (cloud):</strong>
|
||||
<span>Infinities: <span class="save_infinities"></span></span>
|
||||
<span>Eternities: <span class="save_eternities"></span></span>
|
||||
<button class="storebtn" style="font-size: 15px" style="display: inline">Load cloud</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="popup savemenu" id="cloudsaveconflict">
|
||||
<strong>Your local save appears to be older than your cloud save. Would you like to overwrite the cloud save?</strong>
|
||||
<div id="local">
|
||||
@ -2837,6 +2822,7 @@
|
||||
<script type="text/javascript" src="javascripts/components/modals/modal-popup.js"></script>
|
||||
<script type="text/javascript" src="javascripts/components/modals/modal-options.js"></script>
|
||||
<script type="text/javascript" src="javascripts/components/modals/modal-load-game.js"></script>
|
||||
<script type="text/javascript" src="javascripts/components/modals/modal-cloud.js"></script>
|
||||
<script type="text/javascript" src="javascripts/core/app/ui.init.js"></script>
|
||||
<script type="text/javascript" src="javascripts/core/app/themes.js"></script>
|
||||
<script type="text/javascript" src="javascripts/core/app/notations.js"></script>
|
||||
|
46
javascripts/components/modals/modal-cloud.js
Normal file
46
javascripts/components/modals/modal-cloud.js
Normal file
@ -0,0 +1,46 @@
|
||||
Vue.component('modal-cloud-load-conflict', {
|
||||
props: ['model', 'view'],
|
||||
template:
|
||||
'<div class="modal-options">\
|
||||
<strong>Your cloud save appears to be older than your local save. Please select which one you would like to keep.</strong>\
|
||||
<modal-cloud-conflict-record :view="conflict.local" :saveId="conflict.saveId" saveType="local">\
|
||||
<primary-button @click="handleClick(false)">Load local</primary-button>\
|
||||
</modal-cloud-conflict-record>\
|
||||
<modal-cloud-conflict-record :view="conflict.cloud" :saveId="conflict.saveId" saveType="cloud">\
|
||||
<primary-button @click="handleClick(true)">Load cloud</primary-button>\
|
||||
</modal-cloud-conflict-record>\
|
||||
</div>',
|
||||
computed: {
|
||||
conflict: function() {
|
||||
return this.view.modal.cloudConflicts[0];
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClick: function(invokeCallback) {
|
||||
let conflicts = this.view.modal.cloudConflicts;
|
||||
let isLastConflict = conflicts.length === 1;
|
||||
if (invokeCallback) {
|
||||
this.conflict.callback(isLastConflict)
|
||||
}
|
||||
if (isLastConflict){
|
||||
ui.hideModal();
|
||||
}
|
||||
conflicts.shift();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Vue.component('modal-cloud-conflict-record', {
|
||||
props: {
|
||||
saveId: Number,
|
||||
view: Object,
|
||||
saveType: String
|
||||
},
|
||||
template:
|
||||
'<div>\
|
||||
<strong>Save #{{ saveId + 1 }} ({{ saveType }}):</strong>\
|
||||
<span>Infinities: {{ view.infinities }}</span>\
|
||||
<span>Eternities: {{ view.eternities }}</span>\
|
||||
<slot></slot>\
|
||||
</div>'
|
||||
});
|
@ -1,7 +1,7 @@
|
||||
Vue.component('modal-popup', {
|
||||
props: ['view', 'model'],
|
||||
template:
|
||||
'<div class="modal savemenu" style="display: flex">\
|
||||
<div :is="view.modal.current" @close="emitClose" :model="model"/>\
|
||||
'<div class="modal">\
|
||||
<div :is="view.modal.current" @close="emitClose" :model="model" :view="view"/>\
|
||||
</div>'
|
||||
});
|
@ -7,7 +7,8 @@ var ui = {
|
||||
actions: { },
|
||||
view: {
|
||||
modal: {
|
||||
current: undefined
|
||||
current: undefined,
|
||||
cloudConflicts: [ ]
|
||||
}
|
||||
}
|
||||
};
|
@ -21,6 +21,26 @@ ui = new Vue({
|
||||
},
|
||||
hideModal: function () {
|
||||
ui.view.modal.current = undefined;
|
||||
ui.view.modal.cloudConflicts = [];
|
||||
},
|
||||
addCloudConflict: function(saveId, cloudSave, localSave, callback) {
|
||||
ui.view.modal.cloudConflicts.push({
|
||||
saveId: saveId,
|
||||
cloud: getSaveInfo(cloudSave),
|
||||
local: getSaveInfo(localSave),
|
||||
callback: callback,
|
||||
// Use closure here so Vue doesn't bother to convert save to reactive object
|
||||
getCloudSave: function() {
|
||||
return cloudSave;
|
||||
}
|
||||
});
|
||||
|
||||
function getSaveInfo(save) {
|
||||
return {
|
||||
infinities: save ? save.infinitied : 0,
|
||||
eternities: save ? save.eternities : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -28,7 +48,8 @@ ui = new Vue({
|
||||
var Modal = {
|
||||
animationOptions: "modal-animation-options",
|
||||
confirmationOptions: "modal-confirmation-options",
|
||||
loadGame: "modal-load-options"
|
||||
loadGame: "modal-load-game",
|
||||
cloudLoadConflict: "modal-cloud-load-conflict"
|
||||
};
|
||||
|
||||
var updateVue = function () {
|
||||
|
@ -168,42 +168,45 @@ function getRootFromChunks(chunks) {
|
||||
));
|
||||
}
|
||||
|
||||
// if both of them are the same, undefined will be returned
|
||||
function newestSave(first, second) {
|
||||
function getSaveInfo(save) {
|
||||
return {
|
||||
infinities: save ? save.infinitied : 0,
|
||||
eternities: save ? save.eternities : 0
|
||||
}
|
||||
}
|
||||
let firstInfo = getSaveInfo(first);
|
||||
let secondInfo = getSaveInfo(second);
|
||||
if (firstInfo.eternities === secondInfo.eternities && firstInfo.infinities === secondInfo.infinities) {
|
||||
return undefined;
|
||||
}
|
||||
if (firstInfo.eternities > secondInfo.eternities) {
|
||||
return first;
|
||||
}
|
||||
if (firstInfo.infinities > secondInfo.infinities) {
|
||||
return first;
|
||||
}
|
||||
return second;
|
||||
}
|
||||
|
||||
function playFabLoadCheck() {
|
||||
var cloudconflict = document.getElementById("cloudloadconflict");
|
||||
loadFromPlayFab(function(cloudRoot) {
|
||||
$.notify("Loaded from cloud", "info")
|
||||
$.notify("Loaded from cloud", "info");
|
||||
|
||||
for (var i = 0; i < 3; i++) {
|
||||
let saveId = i;
|
||||
var cloudInfinitied = cloudRoot.saves[saveId] ? cloudRoot.saves[saveId].infinitied : 0;
|
||||
var cloudEternities = cloudRoot.saves[saveId] ? cloudRoot.saves[saveId].eternities : 0;
|
||||
var localInfinitied = saves[saveId] ? saves[saveId].infinitied : 0;
|
||||
var localEternities = saves[saveId] ? saves[saveId].eternities : 0;
|
||||
if (cloudEternities < localEternities || (cloudEternities == localEternities && cloudInfinitied < localInfinitied)) {
|
||||
let el = cloudconflict.cloneNode(true);
|
||||
el.style.display = "flex";
|
||||
var localEl = el.querySelector("#local");
|
||||
var cloudEl = el.querySelector("#cloud");
|
||||
|
||||
localEl.querySelector(".save_id").textContent = saveId + 1;
|
||||
localEl.querySelector(".save_infinities").textContent = localInfinitied;
|
||||
localEl.querySelector(".save_eternities").textContent = localEternities;
|
||||
localEl.querySelector(".storebtn").onclick = function() {
|
||||
el.remove();
|
||||
};
|
||||
|
||||
cloudEl.querySelector(".save_id").textContent = saveId + 1;
|
||||
cloudEl.querySelector(".save_infinities").textContent = cloudInfinitied;
|
||||
cloudEl.querySelector(".save_eternities").textContent = cloudEternities;
|
||||
cloudEl.querySelector(".storebtn").onclick = function() {
|
||||
load_cloud_save(saveId, cloudRoot.saves[saveId]);
|
||||
el.remove();
|
||||
};
|
||||
|
||||
document.body.appendChild(el);
|
||||
let cloudSave = cloudRoot.saves[saveId];
|
||||
let localSave = saves[saveId];
|
||||
let newestSave = newestSave(cloudSave, localSave);
|
||||
function loadCurrentCloudSave() {
|
||||
load_cloud_save(saveId, cloudSave);
|
||||
}
|
||||
if (newestSave === localSave) {
|
||||
ui.addCloudConflict(saveId, cloudSave, localSave, loadCurrentCloudSave);
|
||||
ui.showModal(Modal.cloudLoadConflict);
|
||||
} else {
|
||||
load_cloud_save(saveId, cloudRoot.saves[saveId]);
|
||||
loadCurrentCloudSave();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -226,7 +229,14 @@ function playFabSaveCheck() {
|
||||
var cloudEternities = cloudRoot.saves[saveId] ? cloudRoot.saves[saveId].eternities : 0;
|
||||
var localInfinitied = saves[saveId] ? saves[saveId].infinitied : 0;
|
||||
var localEternities = saves[saveId] ? saves[saveId].eternities : 0;
|
||||
function saveCurrent(isLastConflict) {
|
||||
cloudRoot.saves[saveId] = saves[saveId];
|
||||
if (isLastConflict){
|
||||
saveToPlayFab(cloudRoot);
|
||||
}
|
||||
}
|
||||
if (cloudEternities > localEternities || (cloudEternities == localEternities && cloudInfinitied > localInfinitied)) {
|
||||
ui.addCloudConflict(saveId, cloudRoot.saves[saveId], saves[saveId], saveCurrent);
|
||||
popupsWaiting++;
|
||||
let el = cloudconflict.cloneNode(true);
|
||||
el.style.display = "flex";
|
||||
|
@ -705,20 +705,54 @@ button {
|
||||
top: 50%;
|
||||
transform: translateX(-50%) translateY(-50%);
|
||||
border: 3px solid black;
|
||||
width: 300px;
|
||||
height: 120px;
|
||||
background-color: #E0E0E0;
|
||||
border-radius: 6px;
|
||||
text-align:center;
|
||||
z-index: 2;
|
||||
color: black;
|
||||
font-family: Typewriter;
|
||||
padding: 10px;
|
||||
padding-bottom: 15px;
|
||||
font-family: Typewriter, serif;
|
||||
padding: 10px 10px 15px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.modal-message {
|
||||
width: 300px;
|
||||
height: 120px;
|
||||
}
|
||||
|
||||
.modal-options {
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.modal-options div {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.modal-options .closebtn {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
font-size: 1.5rem;
|
||||
line-height: 1.5rem;
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
}
|
||||
|
||||
.modal-options .storebtn {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.modal-options button {
|
||||
fontSize: 15px
|
||||
font-size: 15px
|
||||
}
|
||||
|
||||
.savemenu {
|
||||
|
Loading…
Reference in New Issue
Block a user