Save states are now saved to the Gaseous host, making them available anywhere (#255)
* Added ability to save emulator state * Save states can now be fully managed during a game * Save states can also be launched from the game info screen
This commit is contained in:
159
gaseous-server/wwwroot/pages/dialogs/emulatorloadstate.html
Normal file
159
gaseous-server/wwwroot/pages/dialogs/emulatorloadstate.html
Normal file
@@ -0,0 +1,159 @@
|
||||
<div id="saved_states">
|
||||
|
||||
</div>
|
||||
|
||||
<script text="text/javascript">
|
||||
document.getElementById('modal-heading').innerHTML = "Load saved state";
|
||||
|
||||
console.log(modalVariables);
|
||||
|
||||
var statesUrl = '/api/v1.1/StateManager/' + modalVariables.romId + '?IsMediaGroup=' + modalVariables.IsMediaGroup;
|
||||
console.log(statesUrl);
|
||||
function LoadStates() {
|
||||
ajaxCall(
|
||||
statesUrl,
|
||||
'GET',
|
||||
function(result) {
|
||||
var statesBox = document.getElementById('saved_states');
|
||||
statesBox.innerHTML = '';
|
||||
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
var stateBox = document.createElement('div');
|
||||
stateBox.id = 'stateBox_' + result[i].id;
|
||||
stateBox.className = 'saved_state_box';
|
||||
|
||||
// screenshot panel
|
||||
var stateImageBox = document.createElement('div');
|
||||
stateImageBox.id = 'stateImageBox_' + result[i].id;
|
||||
stateImageBox.className = 'saved_state_image_box';
|
||||
|
||||
if (result[i].hasScreenshot == true) {
|
||||
var stateImage = document.createElement('img');
|
||||
stateImage.className = 'saved_state_image_image';
|
||||
stateImage.src = '/api/v1.1/StateManager/' + modalVariables.romId + '/' + result[i].id + '/Screenshot/image.png?IsMediaGroup=' + modalVariables.IsMediaGroup;
|
||||
stateImageBox.appendChild(stateImage);
|
||||
}
|
||||
stateBox.appendChild(stateImageBox);
|
||||
|
||||
// main panel
|
||||
var stateMainPanel = document.createElement('div');
|
||||
stateMainPanel.id = 'stateMainPanel_' + result[i].id;
|
||||
stateMainPanel.className = 'saved_state_main_box';
|
||||
|
||||
var stateName = document.createElement('input');
|
||||
stateName.id = 'stateName_' + result[i].id;
|
||||
stateName.type = 'text';
|
||||
stateName.className = 'saved_state_name';
|
||||
stateName.setAttribute('onblur', 'UpdateStateSave(' + result[i].id + ', ' + modalVariables.IsMediaGroup + ');');
|
||||
if (result[i].name) {
|
||||
stateName.value = result[i].name;
|
||||
} else {
|
||||
stateName.setAttribute('placeholder', "Untitled");
|
||||
}
|
||||
stateMainPanel.appendChild(stateName);
|
||||
|
||||
var stateTime = document.createElement('div');
|
||||
stateTime.id = 'stateTime_' + result[i].id;
|
||||
stateTime.className = 'saved_state_date';
|
||||
stateTime.innerHTML = moment(result[i].saveTime).format("YYYY-MM-DD h:mm:ss a");
|
||||
stateMainPanel.appendChild(stateTime);
|
||||
|
||||
var stateControls = document.createElement('div');
|
||||
stateControls.id = 'stateControls_' + result[i].id;
|
||||
stateControls.className = 'saved_state_controls';
|
||||
|
||||
var stateControlsLaunch= document.createElement('span');
|
||||
stateControlsLaunch.id = 'stateControlsLaunch_' + result[i].id;
|
||||
stateControlsLaunch.className = 'romstart';
|
||||
var emulatorTarget = '/index.html?page=emulator&engine=@engine&core=@core&platformid=@platformid&gameid=@gameid&romid=@romid&mediagroup=@mediagroup&rompath=@rompath&stateid=' + result[i].id;
|
||||
switch (getQueryString('page', 'string')) {
|
||||
case 'emulator':
|
||||
var mediagroupint = 0;
|
||||
if (modalVariables.IsMediaGroup == true) {
|
||||
mediagroupint = 1;
|
||||
}
|
||||
emulatorTarget = emulatorTarget.replaceAll('@engine', getQueryString('engine', 'string'));
|
||||
emulatorTarget = emulatorTarget.replaceAll('@core', getQueryString('core', 'string'));
|
||||
emulatorTarget = emulatorTarget.replaceAll('@platformid', getQueryString('platformid', 'string'));
|
||||
emulatorTarget = emulatorTarget.replaceAll('@gameid', getQueryString('gameid', 'string'));
|
||||
emulatorTarget = emulatorTarget.replaceAll('@romid', getQueryString('romid', 'string'));
|
||||
emulatorTarget = emulatorTarget.replaceAll('@mediagroup', mediagroupint);
|
||||
emulatorTarget = emulatorTarget.replaceAll('@rompath', getQueryString('rompath', 'string'));
|
||||
stateControlsLaunch.setAttribute("onclick", 'window.location.replace("' + emulatorTarget + '")');
|
||||
break;
|
||||
case 'game':
|
||||
console.log(modalVariables);
|
||||
emulatorTarget = emulatorTarget.replaceAll('@engine', modalVariables.engine);
|
||||
emulatorTarget = emulatorTarget.replaceAll('@core', modalVariables.core);
|
||||
emulatorTarget = emulatorTarget.replaceAll('@platformid', modalVariables.platformid);
|
||||
emulatorTarget = emulatorTarget.replaceAll('@gameid', modalVariables.gameid);
|
||||
emulatorTarget = emulatorTarget.replaceAll('@romid', modalVariables.romId);
|
||||
emulatorTarget = emulatorTarget.replaceAll('@mediagroup', modalVariables.mediagroup);
|
||||
emulatorTarget = emulatorTarget.replaceAll('@rompath', modalVariables.rompath);
|
||||
stateControlsLaunch.setAttribute("onclick", 'window.location.href = "' + emulatorTarget + '"');
|
||||
break;
|
||||
}
|
||||
|
||||
stateControlsLaunch.innerHTML = 'Launch';
|
||||
stateControlsLaunch.style.float = 'right';
|
||||
stateControls.appendChild(stateControlsLaunch);
|
||||
|
||||
var stateControlsDownload = document.createElement('a');
|
||||
stateControlsDownload.id = 'stateControlsDownload_' + result[i].id;
|
||||
stateControlsDownload.className = 'saved_state_buttonlink';
|
||||
stateControlsDownload.href = '/api/v1.1/StateManager/' + modalVariables.romId + '/' + result[i].id + '/State/savestate.state?IsMediaGroup=' + modalVariables.IsMediaGroup;
|
||||
stateControlsDownload.innerHTML = '<img src="/images/Download.svg" class="banner_button_image" alt="Download" title="Download" />';
|
||||
stateControls.appendChild(stateControlsDownload);
|
||||
|
||||
var stateControlsDelete = document.createElement('span');
|
||||
stateControlsDelete.id = 'stateControlsDelete_' + result[i].id;
|
||||
stateControlsDelete.className = 'saved_state_buttonlink';
|
||||
stateControlsDelete.setAttribute('onclick', 'DeleteStateSave(' + result[i].id + ', ' + modalVariables.IsMediaGroup + ');');
|
||||
stateControlsDelete.innerHTML = '<img src="/images/delete.svg" class="banner_button_image" alt="Delete" title="Delete" />';
|
||||
stateControls.appendChild(stateControlsDelete);
|
||||
|
||||
stateMainPanel.appendChild(stateControls);
|
||||
|
||||
stateBox.appendChild(stateMainPanel);
|
||||
|
||||
statesBox.appendChild(stateBox);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
LoadStates();
|
||||
|
||||
function DeleteStateSave(StateId, IsMediaGroup) {
|
||||
ajaxCall(
|
||||
'/api/v1.1/StateManager/' + modalVariables.romId + '/' + StateId + '?IsMediaGroup=' + IsMediaGroup,
|
||||
'DELETE',
|
||||
function(success) {
|
||||
LoadStates();
|
||||
},
|
||||
function (error) {
|
||||
LoadStates();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function UpdateStateSave(StateId, IsMediaGroup) {
|
||||
var stateName = document.getElementById('stateName_' + StateId);
|
||||
|
||||
var model = {
|
||||
"name": stateName.value
|
||||
};
|
||||
|
||||
ajaxCall(
|
||||
'/api/v1.1/StateManager/' + modalVariables.romId + '/' + StateId + '?IsMediaGroup=' + IsMediaGroup,
|
||||
'PUT',
|
||||
function(success) {
|
||||
LoadStates();
|
||||
},
|
||||
function (error) {
|
||||
LoadStates();
|
||||
},
|
||||
JSON.stringify(model)
|
||||
);
|
||||
}
|
||||
</script>
|
||||
@@ -1,4 +1,4 @@
|
||||
<p>Are you sure you want to delete this media group?</p>
|
||||
<p>Are you sure you want to delete this media group and all associated saved states?</p>
|
||||
<p><strong>Warning:</strong> This cannot be undone!</p>
|
||||
<div style="width: 100%; text-align: center;">
|
||||
<div style="display: inline-block; margin-right: 20px;">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<p>Are you sure you want to delete this ROM?</p>
|
||||
<p>Are you sure you want to delete this ROM and all associated saved states?</p>
|
||||
<p><strong>Warning:</strong> This cannot be undone!</p>
|
||||
<div style="width: 100%; text-align: center;">
|
||||
<div style="display: inline-block; margin-right: 20px;">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<p>Are you sure you want to delete the selected ROMs?</p>
|
||||
<p>Are you sure you want to delete the selected ROMs and any associated saved states?</p>
|
||||
<p><strong>Warning:</strong> This cannot be undone!</p>
|
||||
<div style="width: 100%; text-align: center;">
|
||||
<div style="display: inline-block; margin-right: 20px;">
|
||||
|
||||
Reference in New Issue
Block a user