This commit is contained in:
Michael Green
2024-12-15 11:17:13 +11:00
parent 142f3ed561
commit 7a9827923f
9 changed files with 47 additions and 21 deletions

View File

@@ -232,6 +232,7 @@ namespace gaseous_server.Classes.Metadata
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString); Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = @" string sql = @"
SELECT DISTINCT SELECT DISTINCT
view_Games_Roms.MetadataMapId,
view_Games_Roms.GameId, view_Games_Roms.GameId,
view_Games_Roms.PlatformId, view_Games_Roms.PlatformId,
Platform.`Name`, Platform.`Name`,
@@ -239,7 +240,7 @@ SELECT DISTINCT
User_RecentPlayedRoms.RomId AS MostRecentRomId, User_RecentPlayedRoms.RomId AS MostRecentRomId,
CASE User_RecentPlayedRoms.IsMediaGroup CASE User_RecentPlayedRoms.IsMediaGroup
WHEN 0 THEN GMR.`Name` WHEN 0 THEN GMR.`Name`
WHEN 1 THEN 'Media Group' WHEN 1 THEN view_Games_Roms.`MetadataGameName`
ELSE NULL ELSE NULL
END AS `MostRecentRomName`, END AS `MostRecentRomName`,
User_RecentPlayedRoms.IsMediaGroup AS MostRecentRomIsMediaGroup, User_RecentPlayedRoms.IsMediaGroup AS MostRecentRomIsMediaGroup,
@@ -247,7 +248,7 @@ SELECT DISTINCT
User_GameFavouriteRoms.RomId AS FavouriteRomId, User_GameFavouriteRoms.RomId AS FavouriteRomId,
CASE User_GameFavouriteRoms.IsMediaGroup CASE User_GameFavouriteRoms.IsMediaGroup
WHEN 0 THEN GFV.`Name` WHEN 0 THEN GFV.`Name`
WHEN 1 THEN 'Media Group' WHEN 1 THEN view_Games_Roms.`MetadataGameName`
ELSE NULL ELSE NULL
END AS `FavouriteRomName`, END AS `FavouriteRomName`,
User_GameFavouriteRoms.IsMediaGroup AS FavouriteRomIsMediaGroup User_GameFavouriteRoms.IsMediaGroup AS FavouriteRomIsMediaGroup
@@ -257,11 +258,11 @@ FROM
Platform ON view_Games_Roms.PlatformId = Platform.Id Platform ON view_Games_Roms.PlatformId = Platform.Id
LEFT JOIN LEFT JOIN
User_RecentPlayedRoms ON User_RecentPlayedRoms.UserId = @userid User_RecentPlayedRoms ON User_RecentPlayedRoms.UserId = @userid
AND User_RecentPlayedRoms.GameId = view_Games_Roms.GameId AND User_RecentPlayedRoms.GameId = view_Games_Roms.MetadataMapId
AND User_RecentPlayedRoms.PlatformId = view_Games_Roms.PlatformId AND User_RecentPlayedRoms.PlatformId = view_Games_Roms.PlatformId
LEFT JOIN LEFT JOIN
User_GameFavouriteRoms ON User_GameFavouriteRoms.UserId = @userid User_GameFavouriteRoms ON User_GameFavouriteRoms.UserId = @userid
AND User_GameFavouriteRoms.GameId = view_Games_Roms.GameId AND User_GameFavouriteRoms.GameId = view_Games_Roms.MetadataMapId
AND User_GameFavouriteRoms.PlatformId = view_Games_Roms.PlatformId AND User_GameFavouriteRoms.PlatformId = view_Games_Roms.PlatformId
LEFT JOIN LEFT JOIN
view_Games_Roms AS GMR ON GMR.Id = User_RecentPlayedRoms.RomId view_Games_Roms AS GMR ON GMR.Id = User_RecentPlayedRoms.RomId

View File

@@ -193,7 +193,7 @@ namespace gaseous_server.Classes
public static void DeleteMediaGroup(long Id) public static void DeleteMediaGroup(long Id)
{ {
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString); Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "DELETE FROM RomMediaGroup WHERE Id=@id; DELETE FROM GameState WHERE RomId=@id AND IsMediaGroup=1; UPDATE UserTimeTracking SET PlatformId = NULL, IsMediaGroup = NULL, RomId = NULL WHERE RomId=@id AND IsMediaGroup = 1;"; string sql = "DELETE FROM RomMediaGroup WHERE Id=@id; DELETE FROM GameState WHERE RomId=@id AND IsMediaGroup=1; DELETE FROM User_GameFavouriteRoms WHERE RomId = @id AND IsMediaGroup = 1; DELETE FROM User_RecentPlayedRoms WHERE RomId = @id AND IsMediaGroup = 1; UPDATE UserTimeTracking SET PlatformId = NULL, IsMediaGroup = NULL, RomId = NULL WHERE RomId=@id AND IsMediaGroup = 1;";
Dictionary<string, object> dbDict = new Dictionary<string, object>(); Dictionary<string, object> dbDict = new Dictionary<string, object>();
dbDict.Add("id", Id); dbDict.Add("id", Id);
db.ExecuteCMD(sql, dbDict); db.ExecuteCMD(sql, dbDict);
@@ -296,7 +296,8 @@ namespace gaseous_server.Classes
GameRomMediaGroupItem mediaGroupItem = GetMediaGroup(Id); GameRomMediaGroupItem mediaGroupItem = GetMediaGroup(Id);
if (mediaGroupItem.Status == GameRomMediaGroupItem.GroupBuildStatus.WaitingForBuild) if (mediaGroupItem.Status == GameRomMediaGroupItem.GroupBuildStatus.WaitingForBuild)
{ {
Models.Game GameObject = Games.GetGame(HasheousClient.Models.MetadataSources.IGDB, mediaGroupItem.GameId); MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(mediaGroupItem.GameId).PreferredMetadataMapItem;
Models.Game GameObject = Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
Platform PlatformObject = Platforms.GetPlatform(mediaGroupItem.PlatformId); Platform PlatformObject = Platforms.GetPlatform(mediaGroupItem.PlatformId);
PlatformMapping.PlatformMapItem platformMapItem = PlatformMapping.GetPlatformMap(mediaGroupItem.PlatformId); PlatformMapping.PlatformMapItem platformMapItem = PlatformMapping.GetPlatformMap(mediaGroupItem.PlatformId);

View File

@@ -253,7 +253,7 @@ namespace gaseous_server.Classes
} }
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString); Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "DELETE FROM Games_Roms WHERE Id = @id; DELETE FROM GameState WHERE RomId = @id; UPDATE UserTimeTracking SET PlatformId = NULL, IsMediaGroup = NULL, RomId = NULL WHERE RomId = @id AND IsMediaGroup = 0;"; string sql = "DELETE FROM Games_Roms WHERE Id = @id; DELETE FROM GameState WHERE RomId = @id; DELETE FROM User_GameFavouriteRoms WHERE RomId = @id AND IsMediaGroup = 0; DELETE FROM User_RecentPlayedRoms WHERE RomId = @id AND IsMediaGroup = 0; UPDATE UserTimeTracking SET PlatformId = NULL, IsMediaGroup = NULL, RomId = NULL WHERE RomId = @id AND IsMediaGroup = 0;";
Dictionary<string, object> dbDict = new Dictionary<string, object>(); Dictionary<string, object> dbDict = new Dictionary<string, object>();
dbDict.Add("id", RomId); dbDict.Add("id", RomId);
db.ExecuteCMD(sql, dbDict); db.ExecuteCMD(sql, dbDict);

View File

@@ -59,12 +59,19 @@ namespace gaseous_server.Classes
DataTable nowPlayingData = db.ExecuteCMD(sql, dbDict); DataTable nowPlayingData = db.ExecuteCMD(sql, dbDict);
if (nowPlayingData.Rows.Count > 0) if (nowPlayingData.Rows.Count > 0)
{ {
NowPlaying = new Models.UserProfile.NowPlayingItem try
{ {
Game = Games.GetGame(HasheousClient.Models.MetadataSources.IGDB, (long)nowPlayingData.Rows[0]["GameId"]), NowPlaying = new Models.UserProfile.NowPlayingItem
Platform = Platforms.GetPlatform((long)nowPlayingData.Rows[0]["PlatformId"]), {
Duration = Convert.ToInt64(nowPlayingData.Rows[0]["SessionLength"]) Game = Games.GetGame(HasheousClient.Models.MetadataSources.IGDB, (long)nowPlayingData.Rows[0]["GameId"]),
}; Platform = Platforms.GetPlatform((long)nowPlayingData.Rows[0]["PlatformId"]),
Duration = Convert.ToInt64(nowPlayingData.Rows[0]["SessionLength"])
};
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
} }
// return the user profile object // return the user profile object

View File

@@ -1511,7 +1511,7 @@ namespace gaseous_server.Controllers
gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId); gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId);
Classes.RomMediaGroup.GameRomMediaGroupItem rom = Classes.RomMediaGroup.GetMediaGroup(RomGroupId); Classes.RomMediaGroup.GameRomMediaGroupItem rom = Classes.RomMediaGroup.GetMediaGroup(RomGroupId);
if (rom.GameId == MetadataMapId) if (rom != null)
{ {
Classes.RomMediaGroup.DeleteMediaGroup(RomGroupId); Classes.RomMediaGroup.DeleteMediaGroup(RomGroupId);
return Ok(rom); return Ok(rom);

View File

@@ -106,7 +106,7 @@
AgeRatingBoardStrings = versionFile.AgeRatingBoardStrings; AgeRatingBoardStrings = versionFile.AgeRatingBoardStrings;
AgeRatingStrings = versionFile.AgeRatingStrings; AgeRatingStrings = versionFile.AgeRatingStrings;
AgeRatingGroups = versionFile.AgeRatingGroups; AgeRatingGroups = versionFile.AgeRatingGroups;
emulatorDebugMode = versionFile.EmulatorDebugMode; emulatorDebugMode = versionFile.emulatorDebugMode;
// load scripts and style files // load scripts and style files
// update script links // update script links

View File

@@ -29,7 +29,7 @@ function SetupPage() {
gameData = result; gameData = result;
if (result.cover) { if (result.cover) {
emuBackground = '/api/v1.1/Games/' + gameId + '/cover/' + result.cover.id + '/image/original/' + result.cover.imageId + '.jpg'; emuBackground = '/api/v1.1/Games/' + gameId + '/cover/' + result.cover + '/image/original/' + result.cover + '.jpg';
} }
emuGameTitle = gameData.name; emuGameTitle = gameData.name;

View File

@@ -430,6 +430,7 @@ function LoadGamePlatforms() {
// 1. if FavouriteRomId is not null, load the rom, otherwise // 1. if FavouriteRomId is not null, load the rom, otherwise
// 2. if LastPlayedRomId is null, load the rom, otherwise // 2. if LastPlayedRomId is null, load the rom, otherwise
// 3. load the rom management dialog // 3. load the rom management dialog
console.log(result[i]);
if (result[i].emulatorConfiguration.emulatorType.length > 0 && result[i].emulatorConfiguration.core.length > 0 && result[i].favouriteRomId) { if (result[i].emulatorConfiguration.emulatorType.length > 0 && result[i].emulatorConfiguration.core.length > 0 && result[i].favouriteRomId) {
showSaveState = true; showSaveState = true;
romId = result[i].favouriteRomId; romId = result[i].favouriteRomId;
@@ -687,6 +688,7 @@ class RomManagement {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
}).then(response => response.json()).then(result => { }).then(response => response.json()).then(result => {
console.log(result);
// display media groups // display media groups
if (result.length == 0) { if (result.length == 0) {
this.MediaGroups.style.display = 'none'; this.MediaGroups.style.display = 'none';
@@ -821,7 +823,7 @@ class RomManagement {
let deleteButton = new ModalButton("Delete", 2, deleteWindow, function (callingObject) { let deleteButton = new ModalButton("Delete", 2, deleteWindow, function (callingObject) {
ajaxCall( ajaxCall(
'/api/v1.1/Games/' + gameData.id + '/romgroup/' + mediaGroup.id, '/api/v1.1/Games/' + gameId + '/romgroup/' + mediaGroup.id,
'DELETE', 'DELETE',
function (result) { function (result) {
thisObject.#loadRoms(); thisObject.#loadRoms();

View File

@@ -717,7 +717,7 @@ async function BuildLaunchLink(engine, core, platformId, gameId, romId, isMediaG
// fetch valid cores from json file /emulators/EmulatorJS/data/cores.json // fetch valid cores from json file /emulators/EmulatorJS/data/cores.json
let validCores = []; let validCores = [];
await fetch('/emulators/EmulatorJS/data/cores/cores.json', { await fetch('/api/v1.1/PlatformMaps', {
method: 'GET', method: 'GET',
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
@@ -728,11 +728,26 @@ async function BuildLaunchLink(engine, core, platformId, gameId, romId, isMediaG
validCores = data; validCores = data;
for (let i = 0; i < validCores.length; i++) { for (let i = 0; i < validCores.length; i++) {
if (validCores[i].name == core) { isValid = false;
isValid = true; if (validCores[i].webEmulator) {
if (validCores[i].webEmulator.availableWebEmulators) {
for (let y = 0; y < validCores[i].webEmulator.availableWebEmulators.length; y++) {
if (validCores[i].webEmulator.availableWebEmulators[y].emulatorType == engine) {
for (let x = 0; x < validCores[i].webEmulator.availableWebEmulators[y].availableWebEmulatorCores.length; x++) {
if (validCores[i].webEmulator.availableWebEmulators[y].availableWebEmulatorCores[x].core == core ||
validCores[i].webEmulator.availableWebEmulators[y].availableWebEmulatorCores[x].alternateCoreName == core
) {
isValid = true;
break;
}
}
}
}
}
}
if (isValid == true) {
break; break;
} else {
isValid = false;
} }
} }
if (isValid == false) { if (isValid == false) {