Files
gaseous-server/gaseous-server/wwwroot/pages/emulator.html
Michael Green cebab38dd6 Provide ability to upload save states (#371)
This change provides the ability to upload save states.

When a state is downloaded, the state (savestate.state), screenshot
(screenshot.jpg), and a json file (rominfo.json) describing the save
state are zipped and downloaded.

The json file description is defined as follows:
```json
{
  "Name": "Super Mario Bros. (1985-09-13)(Nintendo)(JP-US).zip",
  "StateDateTime": "2024-06-24T05:34:38",
  "StateName": "",
  "MD5": "7d158dcd242e77ba249ac8342474aa77",
  "SHA1": "3d4b04dc78f9d998f17d9fe9ad982a83b5ed72df",
  "Type": "ROM"
}
```

| Attribute | Value |
| -------- | ------|
| Name | The name of the ROM that the state belongs to. This is merely a
convenience attribute. |
| StateDateTime | The date and time (in UTC) when the state was
initially saved. |
| StateName | The name of the state |
| MD5 | The MD5 hash of the ROM that the state belongs to. |
| SHA1 | The SHA1 hash of the ROM that the state belongs to. |
| Type | Whether the state belongs to a ROM or ROM Group |

If the zip is re-uploaded, the above json file will be used to
automatically match the saved state to the ROM that created it.

If a zip is uploaded without the above three files, the upload will
fail.

If a file is uploaded that is not a zip, it will be stored against the
currently running ROM and a warning will be displayed that Gaseous was
unable to verify that the state belongs to the ROM, and may not function
as expected.

Closes #336
2024-06-24 22:38:54 +10:00

105 lines
3.7 KiB
HTML

<div id="bgImage">
<div id="bgImage_Opacity"></div>
</div>
<div id="emulator" class="emulator_fullscreen"></div>
<script type="text/javascript">
var gameId = getQueryString('gameid', 'int');
var romId = getQueryString('romid', 'int');
var platformId = getQueryString('platformid', 'int');
var IsMediaGroupInt = getQueryString('mediagroup', 'int');
var IsMediaGroup = false;
if (IsMediaGroupInt == 1) { IsMediaGroup = true; }
var StateUrl = undefined;
if (getQueryString('stateid', 'int')) {
StateUrl = '/api/v1.1/StateManager/' + romId + '/' + getQueryString('stateid', 'int') + '/State/savestate.state?StateOnly=true&IsMediaGroup=' + IsMediaGroup;
}
var gameData;
var artworks = null;
var artworksPosition = 0;
var emuGameTitle = '';
var emuBios = '';
var emuBackground = '';
console.log("Loading rom url: " + decodeURIComponent(getQueryString('rompath', 'string')));
ajaxCall('/api/v1.1/Games/' + gameId, 'GET', function (result) {
gameData = result;
// load artwork
if (result.artworks) {
artworks = result.artworks.ids;
var startPos = randomIntFromInterval(0, result.artworks.ids.length);
artworksPosition = startPos;
rotateBackground();
} else {
if (result.cover) {
var bg = document.getElementById('bgImage');
bg.setAttribute('style', 'background-image: url("/api/v1.1/Games/' + gameId + '/cover/image/original/' + result.cover.imageId + '.jpg"); background-position: center; background-repeat: no-repeat; background-size: cover; filter: blur(10px); -webkit-filter: blur(10px);');
}
}
if (result.cover) {
emuBackground = '/api/v1.1/Games/' + gameId + '/cover/image/original/' + result.cover.imageId + '.jpg';
}
emuGameTitle = gameData.name;
});
ajaxCall('/api/v1.1/Bios/' + platformId, 'GET', function (result) {
if (result.length == 0) {
emuBios = '';
} else {
emuBios = '/api/v1.1/Bios/zip/' + platformId;
console.log("Using BIOS link: " + emuBios);
}
switch (getQueryString('engine', 'string')) {
case 'EmulatorJS':
console.log("Emulator: " + getQueryString('engine', 'string'));
console.log("Core: " + getQueryString('core', 'string'));
$('#emulator').load('/emulators/EmulatorJS.html?v=' + AppVersion);
break;
}
});
function rotateBackground() {
if (artworks) {
artworksPosition += 1;
if (artworks[artworksPosition] == null) {
artworksPosition = 0;
}
var bg = document.getElementById('bgImage');
bg.setAttribute('style', 'background-image: url("/api/v1.1/Games/' + gameId + '/artwork/' + artworks[artworksPosition] + '/image/original/' + artworks[artworksPosition] + '.jpg"); background-position: center; background-repeat: no-repeat; background-size: cover; filter: blur(10px); -webkit-filter: blur(10px);');
}
}
// statistics
var SessionId = undefined;
function SaveStatistics() {
var model;
if (SessionId == undefined) {
ajaxCall(
'/api/v1.1/Statistics/Games/' + gameId,
'POST',
function (success) {
SessionId = success.sessionId;
}
);
} else {
ajaxCall(
'/api/v1.1/Statistics/Games/' + gameId + '/' + SessionId,
'PUT',
function (success) {
}
);
}
}
setInterval(SaveStatistics, 60000);
</script>