WIP
This commit is contained in:
@@ -370,7 +370,23 @@ namespace gaseous_server.Classes
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Logging.Log(Logging.LogType.Information, "Metadata Refresh", "(" + StatusCounter + "/" + dt.Rows.Count + "): Refreshing metadata for platform " + dr["name"] + " (" + dr["id"] + ")");
|
Logging.Log(Logging.LogType.Information, "Metadata Refresh", "(" + StatusCounter + "/" + dt.Rows.Count + "): Refreshing metadata for platform " + dr["name"] + " (" + dr["id"] + ")");
|
||||||
Metadata.Platforms.GetPlatform((long)dr["id"], MetadataSources.None);
|
|
||||||
|
HasheousClient.Models.MetadataSources metadataSource = HasheousClient.Models.MetadataSources.None;
|
||||||
|
|
||||||
|
// fetch the platform metadata
|
||||||
|
Platform platform = Metadata.Platforms.GetPlatform((long)dr["id"], metadataSource);
|
||||||
|
|
||||||
|
// fetch the platform metadata from Hasheous
|
||||||
|
if (Config.MetadataConfiguration.SignatureSource == HasheousClient.Models.MetadataModel.SignatureSources.Hasheous)
|
||||||
|
{
|
||||||
|
Communications.PopulateHasheousPlatformData((long)dr["id"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// force platformLogo refresh
|
||||||
|
if (platform.PlatformLogo != null)
|
||||||
|
{
|
||||||
|
Metadata.PlatformLogos.GetPlatformLogo(platform.PlatformLogo, metadataSource);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@@ -43,7 +43,7 @@ namespace gaseous_server.Controllers.v1_1
|
|||||||
[MapToApiVersion("1.1")]
|
[MapToApiVersion("1.1")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType(typeof(GameReturnPackage), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(GameReturnPackage), StatusCodes.Status200OK)]
|
||||||
public async Task<IActionResult> Game_v1_1(GameSearchModel model, int pageNumber = 0, int pageSize = 0)
|
public async Task<IActionResult> Game_v1_1(GameSearchModel model, int pageNumber = 0, int pageSize = 0, bool returnSummary = true, bool returnGames = true)
|
||||||
{
|
{
|
||||||
var user = await _userManager.GetUserAsync(User);
|
var user = await _userManager.GetUserAsync(User);
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ namespace gaseous_server.Controllers.v1_1
|
|||||||
model.GameAgeRating.IncludeUnrated = false;
|
model.GameAgeRating.IncludeUnrated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(GetGames(model, user.Id, pageNumber, pageSize));
|
return Ok(GetGames(model, user.Id, pageNumber, pageSize, returnSummary, returnGames));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -190,7 +190,7 @@ namespace gaseous_server.Controllers.v1_1
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameReturnPackage GetGames(GameSearchModel model, string userid, int pageNumber = 0, int pageSize = 0)
|
public static GameReturnPackage GetGames(GameSearchModel model, string userid, int pageNumber = 0, int pageSize = 0, bool returnSummary = true, bool returnGames = true)
|
||||||
{
|
{
|
||||||
string whereClause = "";
|
string whereClause = "";
|
||||||
string havingClause = "";
|
string havingClause = "";
|
||||||
@@ -551,89 +551,100 @@ FROM
|
|||||||
Relation_Game_Themes ON Game.Id = Relation_Game_Themes.GameId
|
Relation_Game_Themes ON Game.Id = Relation_Game_Themes.GameId
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
Favourites ON Game.MetadataMapId = Favourites.GameId AND Favourites.UserId = @userid " + whereClause + " " + havingClause + " " + orderByClause;
|
Favourites ON Game.MetadataMapId = Favourites.GameId AND Favourites.UserId = @userid " + whereClause + " " + havingClause + " " + orderByClause;
|
||||||
List<Games.MinimalGameItem> RetVal = new List<Games.MinimalGameItem>();
|
|
||||||
|
// if (returnGames == true)
|
||||||
|
// {
|
||||||
|
// sql += " LIMIT @pageOffset, @pageSize";
|
||||||
|
// whereParams.Add("pageOffset", pageSize * (pageNumber - 1));
|
||||||
|
// whereParams.Add("pageSize", pageSize);
|
||||||
|
// }
|
||||||
|
|
||||||
DataTable dbResponse = db.ExecuteCMD(sql, whereParams, new Database.DatabaseMemoryCacheOptions(CacheEnabled: true, ExpirationSeconds: 60));
|
DataTable dbResponse = db.ExecuteCMD(sql, whereParams, new Database.DatabaseMemoryCacheOptions(CacheEnabled: true, ExpirationSeconds: 60));
|
||||||
|
|
||||||
// get count
|
// get count
|
||||||
int RecordCount = dbResponse.Rows.Count;
|
int? RecordCount = null;
|
||||||
|
if (returnSummary == true)
|
||||||
// compile data for return
|
|
||||||
int pageOffset = pageSize * (pageNumber - 1);
|
|
||||||
for (int i = pageOffset; i < dbResponse.Rows.Count; i++)
|
|
||||||
{
|
{
|
||||||
if (pageNumber != 0 && pageSize != 0)
|
RecordCount = dbResponse.Rows.Count;
|
||||||
{
|
|
||||||
if (i >= (pageOffset + pageSize))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Models.Game retGame = Storage.BuildCacheObject<Models.Game>(new Models.Game(), dbResponse.Rows[i]);
|
|
||||||
retGame.MetadataMapId = (long)dbResponse.Rows[i]["MetadataMapId"];
|
|
||||||
retGame.MetadataSource = (HasheousClient.Models.MetadataSources)dbResponse.Rows[i]["GameIdType"];
|
|
||||||
|
|
||||||
Games.MinimalGameItem retMinGame = new Games.MinimalGameItem(retGame);
|
|
||||||
retMinGame.Index = i;
|
|
||||||
if (dbResponse.Rows[i]["RomSaveCount"] != DBNull.Value || dbResponse.Rows[i]["MediaGroupSaveCount"] != DBNull.Value)
|
|
||||||
{
|
|
||||||
retMinGame.HasSavedGame = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
retMinGame.HasSavedGame = false;
|
|
||||||
}
|
|
||||||
if ((int)dbResponse.Rows[i]["Favourite"] == 0)
|
|
||||||
{
|
|
||||||
retMinGame.IsFavourite = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
retMinGame.IsFavourite = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
RetVal.Add(retMinGame);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// build alpha list
|
// compile data for return
|
||||||
Dictionary<string, int> AlphaList = new Dictionary<string, int>();
|
List<Games.MinimalGameItem>? RetVal = null;
|
||||||
if (orderByField == "NameThe" || orderByField == "Name")
|
if (returnGames == true)
|
||||||
{
|
{
|
||||||
int CurrentPage = 1;
|
RetVal = new List<Games.MinimalGameItem>();
|
||||||
int NextPageIndex = pageSize;
|
foreach (int i in Enumerable.Range(0, dbResponse.Rows.Count))
|
||||||
|
{
|
||||||
|
Models.Game retGame = Storage.BuildCacheObject<Models.Game>(new Models.Game(), dbResponse.Rows[i]);
|
||||||
|
retGame.MetadataMapId = (long)dbResponse.Rows[i]["MetadataMapId"];
|
||||||
|
retGame.MetadataSource = (HasheousClient.Models.MetadataSources)dbResponse.Rows[i]["GameIdType"];
|
||||||
|
|
||||||
string alphaSearchField;
|
Games.MinimalGameItem retMinGame = new Games.MinimalGameItem(retGame);
|
||||||
if (orderByField == "NameThe")
|
retMinGame.Index = i;
|
||||||
{
|
if (dbResponse.Rows[i]["RomSaveCount"] != DBNull.Value || dbResponse.Rows[i]["MediaGroupSaveCount"] != DBNull.Value)
|
||||||
alphaSearchField = "NameThe";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
alphaSearchField = "Name";
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < dbResponse.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
if (NextPageIndex == i + 1)
|
|
||||||
{
|
{
|
||||||
NextPageIndex += pageSize;
|
retMinGame.HasSavedGame = true;
|
||||||
CurrentPage += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
string firstChar = dbResponse.Rows[i][alphaSearchField].ToString().Substring(0, 1).ToUpperInvariant();
|
|
||||||
if ("ABCDEFGHIJKLMNOPQRSTUVWXYZ".Contains(firstChar))
|
|
||||||
{
|
|
||||||
if (!AlphaList.ContainsKey(firstChar))
|
|
||||||
{
|
|
||||||
AlphaList.Add(firstChar, CurrentPage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!AlphaList.ContainsKey("#"))
|
retMinGame.HasSavedGame = false;
|
||||||
|
}
|
||||||
|
if ((int)dbResponse.Rows[i]["Favourite"] == 0)
|
||||||
|
{
|
||||||
|
retMinGame.IsFavourite = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retMinGame.IsFavourite = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
RetVal.Add(retMinGame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, int>? AlphaList = null;
|
||||||
|
if (returnSummary == true)
|
||||||
|
{
|
||||||
|
AlphaList = new Dictionary<string, int>();
|
||||||
|
|
||||||
|
// build alpha list
|
||||||
|
if (orderByField == "NameThe" || orderByField == "Name")
|
||||||
|
{
|
||||||
|
int CurrentPage = 1;
|
||||||
|
int NextPageIndex = pageSize;
|
||||||
|
|
||||||
|
string alphaSearchField;
|
||||||
|
if (orderByField == "NameThe")
|
||||||
|
{
|
||||||
|
alphaSearchField = "NameThe";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alphaSearchField = "Name";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < dbResponse.Rows.Count; i++)
|
||||||
|
{
|
||||||
|
if (NextPageIndex == i + 1)
|
||||||
{
|
{
|
||||||
AlphaList.Add("#", 1);
|
NextPageIndex += pageSize;
|
||||||
|
CurrentPage += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
string firstChar = dbResponse.Rows[i][alphaSearchField].ToString().Substring(0, 1).ToUpperInvariant();
|
||||||
|
if ("ABCDEFGHIJKLMNOPQRSTUVWXYZ".Contains(firstChar))
|
||||||
|
{
|
||||||
|
if (!AlphaList.ContainsKey(firstChar))
|
||||||
|
{
|
||||||
|
AlphaList.Add(firstChar, CurrentPage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!AlphaList.ContainsKey("#"))
|
||||||
|
{
|
||||||
|
AlphaList.Add("#", 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -669,9 +680,9 @@ FROM
|
|||||||
this.Games = minimalGames;
|
this.Games = minimalGames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Count { get; set; }
|
public int? Count { get; set; }
|
||||||
public List<Games.MinimalGameItem> Games { get; set; } = new List<Games.MinimalGameItem>();
|
public List<Games.MinimalGameItem>? Games { get; set; } = new List<Games.MinimalGameItem>();
|
||||||
public Dictionary<string, int> AlphaList { get; set; }
|
public Dictionary<string, int>? AlphaList { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -107,11 +107,6 @@ namespace gaseous_server.Models
|
|||||||
Storage.NewCacheValue(HasheousClient.Models.MetadataSources.None, platform);
|
Storage.NewCacheValue(HasheousClient.Models.MetadataSources.None, platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.MetadataConfiguration.SignatureSource == HasheousClient.Models.MetadataModel.SignatureSources.Hasheous)
|
|
||||||
{
|
|
||||||
Communications.PopulateHasheousPlatformData(mapItem.IGDBId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Storage.GetCacheStatus(HasheousClient.Models.MetadataSources.IGDB, "Platform", mapItem.IGDBId) == Storage.CacheStatus.NotPresent)
|
if (Storage.GetCacheStatus(HasheousClient.Models.MetadataSources.IGDB, "Platform", mapItem.IGDBId) == Storage.CacheStatus.NotPresent)
|
||||||
{
|
{
|
||||||
Storage.NewCacheValue(HasheousClient.Models.MetadataSources.IGDB, platform);
|
Storage.NewCacheValue(HasheousClient.Models.MetadataSources.IGDB, platform);
|
||||||
|
@@ -613,221 +613,225 @@ class RomManagement {
|
|||||||
this.#SetupFixPlatformDropDown();
|
this.#SetupFixPlatformDropDown();
|
||||||
|
|
||||||
// add buttons
|
// add buttons
|
||||||
let platformMappingButton = new ModalButton('Metadata Mapping', 0, this, async function (callingObject) {
|
if (userProfile.roles.includes("Admin")) {
|
||||||
let metadataModal = await new Modal('messagebox');
|
let platformMappingButton = new ModalButton('Metadata Mapping', 0, this, async function (callingObject) {
|
||||||
await metadataModal.BuildModal();
|
let metadataModal = await new Modal('messagebox');
|
||||||
|
await metadataModal.BuildModal();
|
||||||
|
|
||||||
// override the dialog size
|
// override the dialog size
|
||||||
metadataModal.modalElement.style = 'width: 600px; height: 400px; min-width: unset; min-height: 400px; max-width: unset; max-height: 400px;';
|
metadataModal.modalElement.style = 'width: 600px; height: 400px; min-width: unset; min-height: 400px; max-width: unset; max-height: 400px;';
|
||||||
|
|
||||||
// set the title
|
// set the title
|
||||||
metadataModal.modalElement.querySelector('#modal-header-text').innerHTML = callingObject.Platform.name + ' Metadata Mapping';
|
metadataModal.modalElement.querySelector('#modal-header-text').innerHTML = callingObject.Platform.name + ' Metadata Mapping';
|
||||||
|
|
||||||
// set the content
|
// set the content
|
||||||
let metadataContent = metadataModal.modalElement.querySelector('#modal-body');
|
let metadataContent = metadataModal.modalElement.querySelector('#modal-body');
|
||||||
|
|
||||||
// fetch the metadata map
|
// fetch the metadata map
|
||||||
let metadataMap = await fetch('/api/v1.1/Games/' + callingObject.Platform.metadataMapId + '/metadata', {
|
let metadataMap = await fetch('/api/v1.1/Games/' + callingObject.Platform.metadataMapId + '/metadata', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
}).then(response => response.json());
|
}).then(response => response.json());
|
||||||
console.log(metadataMap);
|
console.log(metadataMap);
|
||||||
|
|
||||||
metadataMap.metadataMapItems.forEach(element => {
|
metadataMap.metadataMapItems.forEach(element => {
|
||||||
let itemSection = document.createElement('div');
|
let itemSection = document.createElement('div');
|
||||||
itemSection.className = 'section';
|
itemSection.className = 'section';
|
||||||
|
|
||||||
// header
|
// header
|
||||||
let itemSectionHeader = document.createElement('div');
|
let itemSectionHeader = document.createElement('div');
|
||||||
itemSectionHeader.className = 'section-header';
|
itemSectionHeader.className = 'section-header';
|
||||||
|
|
||||||
let itemSectionHeaderRadio = document.createElement('input');
|
let itemSectionHeaderRadio = document.createElement('input');
|
||||||
itemSectionHeaderRadio.id = 'platformMappingSource_' + element.sourceType;
|
itemSectionHeaderRadio.id = 'platformMappingSource_' + element.sourceType;
|
||||||
itemSectionHeaderRadio.type = 'radio';
|
itemSectionHeaderRadio.type = 'radio';
|
||||||
itemSectionHeaderRadio.name = 'platformMappingSource';
|
itemSectionHeaderRadio.name = 'platformMappingSource';
|
||||||
itemSectionHeaderRadio.value = element.sourceType;
|
itemSectionHeaderRadio.value = element.sourceType;
|
||||||
itemSectionHeaderRadio.style.margin = '0px';
|
itemSectionHeaderRadio.style.margin = '0px';
|
||||||
itemSectionHeaderRadio.style.height = 'unset';
|
itemSectionHeaderRadio.style.height = 'unset';
|
||||||
itemSectionHeaderRadio.addEventListener('change', () => {
|
itemSectionHeaderRadio.addEventListener('change', () => {
|
||||||
metadataMap.metadataMapItems.forEach(element => {
|
metadataMap.metadataMapItems.forEach(element => {
|
||||||
element.preferred = false;
|
element.preferred = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
element.preferred = true;
|
||||||
|
console.log('Selected: ' + element.sourceType);
|
||||||
|
console.log(metadataMap);
|
||||||
});
|
});
|
||||||
|
if (element.preferred == true) {
|
||||||
|
itemSectionHeaderRadio.checked = true;
|
||||||
|
}
|
||||||
|
itemSectionHeader.appendChild(itemSectionHeaderRadio);
|
||||||
|
|
||||||
element.preferred = true;
|
let itemSectionHeaderLabel = document.createElement('label');
|
||||||
console.log('Selected: ' + element.sourceType);
|
itemSectionHeaderLabel.htmlFor = 'platformMappingSource_' + element.sourceType;
|
||||||
console.log(metadataMap);
|
itemSectionHeaderLabel.style.marginLeft = '10px';
|
||||||
});
|
itemSectionHeaderLabel.innerHTML = element.sourceType;
|
||||||
if (element.preferred == true) {
|
itemSectionHeader.appendChild(itemSectionHeaderLabel);
|
||||||
itemSectionHeaderRadio.checked = true;
|
|
||||||
}
|
|
||||||
itemSectionHeader.appendChild(itemSectionHeaderRadio);
|
|
||||||
|
|
||||||
let itemSectionHeaderLabel = document.createElement('label');
|
itemSection.appendChild(itemSectionHeader);
|
||||||
itemSectionHeaderLabel.htmlFor = 'platformMappingSource_' + element.sourceType;
|
|
||||||
itemSectionHeaderLabel.style.marginLeft = '10px';
|
|
||||||
itemSectionHeaderLabel.innerHTML = element.sourceType;
|
|
||||||
itemSectionHeader.appendChild(itemSectionHeaderLabel);
|
|
||||||
|
|
||||||
itemSection.appendChild(itemSectionHeader);
|
// content
|
||||||
|
let itemSectionContent = document.createElement('div');
|
||||||
|
itemSectionContent.className = 'section-body';
|
||||||
|
switch (element.sourceType) {
|
||||||
|
case 'None':
|
||||||
|
let noneContent = document.createElement('div');
|
||||||
|
noneContent.className = 'section-body-content';
|
||||||
|
|
||||||
// content
|
let noneContentLabel = document.createElement('label');
|
||||||
let itemSectionContent = document.createElement('div');
|
noneContentLabel.innerHTML = 'No Metadata Source';
|
||||||
itemSectionContent.className = 'section-body';
|
noneContent.appendChild(noneContentLabel);
|
||||||
switch (element.sourceType) {
|
|
||||||
case 'None':
|
|
||||||
let noneContent = document.createElement('div');
|
|
||||||
noneContent.className = 'section-body-content';
|
|
||||||
|
|
||||||
let noneContentLabel = document.createElement('label');
|
itemSectionContent.appendChild(noneContent);
|
||||||
noneContentLabel.innerHTML = 'No Metadata Source';
|
break;
|
||||||
noneContent.appendChild(noneContentLabel);
|
|
||||||
|
|
||||||
itemSectionContent.appendChild(noneContent);
|
default:
|
||||||
break;
|
let contentLabel2 = document.createElement('div');
|
||||||
|
contentLabel2.innerHTML = 'ID: ' + element.sourceId;
|
||||||
|
itemSectionContent.appendChild(contentLabel2);
|
||||||
|
|
||||||
default:
|
let contentLabel3 = document.createElement('div');
|
||||||
let contentLabel2 = document.createElement('div');
|
contentLabel3.innerHTML = 'Slug: ' + element.sourceSlug;
|
||||||
contentLabel2.innerHTML = 'ID: ' + element.sourceId;
|
itemSectionContent.appendChild(contentLabel3);
|
||||||
itemSectionContent.appendChild(contentLabel2);
|
|
||||||
|
|
||||||
let contentLabel3 = document.createElement('div');
|
if (element.link) {
|
||||||
contentLabel3.innerHTML = 'Slug: ' + element.sourceSlug;
|
if (element.link.length > 0) {
|
||||||
itemSectionContent.appendChild(contentLabel3);
|
let contentLabel4 = document.createElement('div');
|
||||||
|
contentLabel4.innerHTML = 'Link: <a href="' + element.link + '" target="_blank" rel="noopener noreferrer" class="romlink">' + element.link + '</a>';
|
||||||
if (element.link) {
|
itemSectionContent.appendChild(contentLabel4);
|
||||||
if (element.link.length > 0) {
|
}
|
||||||
let contentLabel4 = document.createElement('div');
|
|
||||||
contentLabel4.innerHTML = 'Link: <a href="' + element.link + '" target="_blank" rel="noopener noreferrer" class="romlink">' + element.link + '</a>';
|
|
||||||
itemSectionContent.appendChild(contentLabel4);
|
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
itemSection.appendChild(itemSectionContent);
|
itemSection.appendChild(itemSectionContent);
|
||||||
|
|
||||||
metadataContent.appendChild(itemSection);
|
metadataContent.appendChild(itemSection);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// setup the buttons
|
||||||
|
let okButton = new ModalButton('OK', 1, callingObject, async function (callingObject) {
|
||||||
|
let model = metadataMap.metadataMapItems;
|
||||||
|
|
||||||
|
await fetch('/api/v1.1/Games/' + callingObject.Platform.metadataMapId + '/metadata', {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(model)
|
||||||
|
}).then(response => response.json()).then(result => {
|
||||||
|
location.reload(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
metadataModal.addButton(okButton);
|
||||||
|
|
||||||
|
let cancelButton = new ModalButton('Cancel', 0, metadataModal, async function (callingObject) {
|
||||||
|
metadataModal.close();
|
||||||
|
});
|
||||||
|
metadataModal.addButton(cancelButton);
|
||||||
|
|
||||||
|
// show the dialog
|
||||||
|
await metadataModal.open();
|
||||||
});
|
});
|
||||||
|
this.romsModal.addButton(platformMappingButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.Platform.id != 0) {
|
||||||
|
let platformEditButton = new ModalButton('Configure Emulator', 0, this, async function (callingObject) {
|
||||||
|
let mappingModal = await new Modal('messagebox');
|
||||||
|
await mappingModal.BuildModal();
|
||||||
|
|
||||||
// setup the buttons
|
// override the dialog size
|
||||||
let okButton = new ModalButton('OK', 1, callingObject, async function (callingObject) {
|
mappingModal.modalElement.style = 'width: 600px; height: 80%; min-width: unset; min-height: 400px; max-width: unset; max-height: 80%;';
|
||||||
let model = metadataMap.metadataMapItems;
|
|
||||||
|
|
||||||
await fetch('/api/v1.1/Games/' + callingObject.Platform.metadataMapId + '/metadata', {
|
// get the platform map
|
||||||
method: 'PUT',
|
let platformMap = await fetch('/api/v1.1/PlatformMaps/' + callingObject.Platform.id, {
|
||||||
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
}
|
||||||
body: JSON.stringify(model)
|
}).then(response => response.json());
|
||||||
}).then(response => response.json()).then(result => {
|
let defaultPlatformMap = platformMap;
|
||||||
location.reload(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
metadataModal.addButton(okButton);
|
|
||||||
|
|
||||||
let cancelButton = new ModalButton('Cancel', 0, metadataModal, async function (callingObject) {
|
// get the user emulation configuration
|
||||||
metadataModal.close();
|
let userEmuConfig = await fetch('/api/v1.1/Games/' + callingObject.Platform.metadataMapId + '/emulatorconfiguration/' + callingObject.Platform.id, {
|
||||||
});
|
method: 'GET',
|
||||||
metadataModal.addButton(cancelButton);
|
|
||||||
|
|
||||||
// show the dialog
|
|
||||||
await metadataModal.open();
|
|
||||||
});
|
|
||||||
this.romsModal.addButton(platformMappingButton);
|
|
||||||
|
|
||||||
let platformEditButton = new ModalButton('Configure Emulator', 0, this, async function (callingObject) {
|
|
||||||
let mappingModal = await new Modal('messagebox');
|
|
||||||
await mappingModal.BuildModal();
|
|
||||||
|
|
||||||
// override the dialog size
|
|
||||||
mappingModal.modalElement.style = 'width: 600px; height: 80%; min-width: unset; min-height: 400px; max-width: unset; max-height: 80%;';
|
|
||||||
|
|
||||||
// get the platform map
|
|
||||||
let platformMap = await fetch('/api/v1.1/PlatformMaps/' + callingObject.Platform.id, {
|
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
|
||||||
}).then(response => response.json());
|
|
||||||
let defaultPlatformMap = platformMap;
|
|
||||||
|
|
||||||
// get the user emulation configuration
|
|
||||||
let userEmuConfig = await fetch('/api/v1.1/Games/' + callingObject.Platform.metadataMapId + '/emulatorconfiguration/' + callingObject.Platform.id, {
|
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
|
||||||
}).then(response => response.json());
|
|
||||||
if (userEmuConfig) {
|
|
||||||
if (userEmuConfig.emulatorType || userEmuConfig.core) {
|
|
||||||
platformMap.webEmulator.type = userEmuConfig.emulatorType;
|
|
||||||
platformMap.webEmulator.core = userEmuConfig.core;
|
|
||||||
}
|
|
||||||
if (userEmuConfig.enableBIOSFiles) {
|
|
||||||
platformMap.enabledBIOSHashes = userEmuConfig.enableBIOSFiles;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the title
|
|
||||||
mappingModal.modalElement.querySelector('#modal-header-text').innerHTML = callingObject.Platform.name + ' Emulation Settings';
|
|
||||||
|
|
||||||
// set the content
|
|
||||||
let mappingContent = mappingModal.modalElement.querySelector('#modal-body');
|
|
||||||
mappingContent.innerHTML = '';
|
|
||||||
let emuConfig = await new WebEmulatorConfiguration(platformMap)
|
|
||||||
emuConfig.open();
|
|
||||||
mappingContent.appendChild(emuConfig.panel);
|
|
||||||
|
|
||||||
// setup the buttons
|
|
||||||
let resetButton = new ModalButton('Reset to Default', 0, callingObject, async function (callingObject) {
|
|
||||||
await fetch('/api/v1.1/Games/' + callingObject.Platform.metadataMapId + '/emulatorconfiguration/' + callingObject.Platform.id, {
|
|
||||||
method: 'DELETE'
|
|
||||||
});
|
|
||||||
callingObject.Platform.emulatorConfiguration.emulatorType = defaultPlatformMap.webEmulator.type;
|
|
||||||
callingObject.Platform.emulatorConfiguration.core = defaultPlatformMap.webEmulator.core;
|
|
||||||
callingObject.Platform.emulatorConfiguration.enabledBIOSHashes = defaultPlatformMap.enabledBIOSHashes;
|
|
||||||
callingObject.#loadRoms();
|
|
||||||
callingObject.OkCallback();
|
|
||||||
mappingModal.close();
|
|
||||||
});
|
|
||||||
mappingModal.addButton(resetButton);
|
|
||||||
|
|
||||||
let okButton = new ModalButton('OK', 1, callingObject, async function (callingObject) {
|
|
||||||
let model = {
|
|
||||||
EmulatorType: emuConfig.PlatformMap.webEmulator.type,
|
|
||||||
Core: emuConfig.PlatformMap.webEmulator.core,
|
|
||||||
EnableBIOSFiles: emuConfig.PlatformMap.enabledBIOSHashes
|
|
||||||
}
|
|
||||||
|
|
||||||
await fetch('/api/v1.1/Games/' + callingObject.Platform.metadataMapId + '/emulatorconfiguration/' + callingObject.Platform.id, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
}
|
||||||
body: JSON.stringify(model)
|
}).then(response => response.json());
|
||||||
|
if (userEmuConfig) {
|
||||||
|
if (userEmuConfig.emulatorType || userEmuConfig.core) {
|
||||||
|
platformMap.webEmulator.type = userEmuConfig.emulatorType;
|
||||||
|
platformMap.webEmulator.core = userEmuConfig.core;
|
||||||
|
}
|
||||||
|
if (userEmuConfig.enableBIOSFiles) {
|
||||||
|
platformMap.enabledBIOSHashes = userEmuConfig.enableBIOSFiles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the title
|
||||||
|
mappingModal.modalElement.querySelector('#modal-header-text').innerHTML = callingObject.Platform.name + ' Emulation Settings';
|
||||||
|
|
||||||
|
// set the content
|
||||||
|
let mappingContent = mappingModal.modalElement.querySelector('#modal-body');
|
||||||
|
mappingContent.innerHTML = '';
|
||||||
|
let emuConfig = await new WebEmulatorConfiguration(platformMap)
|
||||||
|
emuConfig.open();
|
||||||
|
mappingContent.appendChild(emuConfig.panel);
|
||||||
|
|
||||||
|
// setup the buttons
|
||||||
|
let resetButton = new ModalButton('Reset to Default', 0, callingObject, async function (callingObject) {
|
||||||
|
await fetch('/api/v1.1/Games/' + callingObject.Platform.metadataMapId + '/emulatorconfiguration/' + callingObject.Platform.id, {
|
||||||
|
method: 'DELETE'
|
||||||
|
});
|
||||||
|
callingObject.Platform.emulatorConfiguration.emulatorType = defaultPlatformMap.webEmulator.type;
|
||||||
|
callingObject.Platform.emulatorConfiguration.core = defaultPlatformMap.webEmulator.core;
|
||||||
|
callingObject.Platform.emulatorConfiguration.enabledBIOSHashes = defaultPlatformMap.enabledBIOSHashes;
|
||||||
|
callingObject.#loadRoms();
|
||||||
|
callingObject.OkCallback();
|
||||||
|
mappingModal.close();
|
||||||
});
|
});
|
||||||
callingObject.Platform.emulatorConfiguration.emulatorType = emuConfig.PlatformMap.webEmulator.type;
|
mappingModal.addButton(resetButton);
|
||||||
callingObject.Platform.emulatorConfiguration.core = emuConfig.PlatformMap.webEmulator.core;
|
|
||||||
callingObject.Platform.emulatorConfiguration.enabledBIOSHashes = emuConfig.PlatformMap.enabledBIOSHashes;
|
|
||||||
|
|
||||||
callingObject.#loadRoms();
|
let okButton = new ModalButton('OK', 1, callingObject, async function (callingObject) {
|
||||||
callingObject.OkCallback();
|
let model = {
|
||||||
mappingModal.close();
|
EmulatorType: emuConfig.PlatformMap.webEmulator.type,
|
||||||
|
Core: emuConfig.PlatformMap.webEmulator.core,
|
||||||
|
EnableBIOSFiles: emuConfig.PlatformMap.enabledBIOSHashes
|
||||||
|
}
|
||||||
|
|
||||||
|
await fetch('/api/v1.1/Games/' + callingObject.Platform.metadataMapId + '/emulatorconfiguration/' + callingObject.Platform.id, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(model)
|
||||||
|
});
|
||||||
|
callingObject.Platform.emulatorConfiguration.emulatorType = emuConfig.PlatformMap.webEmulator.type;
|
||||||
|
callingObject.Platform.emulatorConfiguration.core = emuConfig.PlatformMap.webEmulator.core;
|
||||||
|
callingObject.Platform.emulatorConfiguration.enabledBIOSHashes = emuConfig.PlatformMap.enabledBIOSHashes;
|
||||||
|
|
||||||
|
callingObject.#loadRoms();
|
||||||
|
callingObject.OkCallback();
|
||||||
|
mappingModal.close();
|
||||||
|
});
|
||||||
|
mappingModal.addButton(okButton);
|
||||||
|
|
||||||
|
let cancelButton = new ModalButton('Cancel', 0, mappingModal, async function (callingObject) {
|
||||||
|
mappingModal.close();
|
||||||
|
});
|
||||||
|
mappingModal.addButton(cancelButton);
|
||||||
|
|
||||||
|
// show the dialog
|
||||||
|
await mappingModal.open();
|
||||||
});
|
});
|
||||||
mappingModal.addButton(okButton);
|
this.romsModal.addButton(platformEditButton);
|
||||||
|
}
|
||||||
let cancelButton = new ModalButton('Cancel', 0, mappingModal, async function (callingObject) {
|
|
||||||
mappingModal.close();
|
|
||||||
});
|
|
||||||
mappingModal.addButton(cancelButton);
|
|
||||||
|
|
||||||
// show the dialog
|
|
||||||
await mappingModal.open();
|
|
||||||
});
|
|
||||||
this.romsModal.addButton(platformEditButton);
|
|
||||||
|
|
||||||
let closeButton = new ModalButton('Close', 0, this, function (callingObject) {
|
let closeButton = new ModalButton('Close', 0, this, function (callingObject) {
|
||||||
callingObject.romsModal.close();
|
callingObject.romsModal.close();
|
||||||
|
Reference in New Issue
Block a user