diff --git a/EpinelPS/Database/JsonDb.cs b/EpinelPS/Database/JsonDb.cs index 2848813..ed6e2f5 100644 --- a/EpinelPS/Database/JsonDb.cs +++ b/EpinelPS/Database/JsonDb.cs @@ -115,6 +115,14 @@ namespace EpinelPS.Database return result; } } + + public class JukeBoxSetting + { + public NetJukeboxLocation Location; + public NetJukeboxBgmType Type; + public int TableId; + + } public class User { // User info @@ -154,7 +162,14 @@ namespace EpinelPS.Database public List Characters = []; public NetWholeUserTeamData RepresentationTeamData = new(); public Dictionary ClearedTutorialData = []; + public NetWallpaperData[] WallpaperList = []; + public NetWallpaperBackground[] WallpaperBackground = []; + public NetWallpaperJukeboxFavorite[] WallpaperFavoriteList = []; + public NetWallpaperPlaylist[] WallpaperPlaylistList = []; + public NetWallpaperJukebox[] WallpaperJukeboxList = []; + + public Dictionary UserTeams = new Dictionary(); public Dictionary MainQuestData = new(); public int InfraCoreExp = 0; @@ -173,6 +188,9 @@ namespace EpinelPS.Database public Dictionary TowerProgress = new Dictionary(); + public JukeBoxSetting LobbyMusic = new() { Location = NetJukeboxLocation.NetJukeboxLocationLobby, TableId = 2, Type = NetJukeboxBgmType.NetJukeboxBgmTypeJukeboxTableId}; + public JukeBoxSetting CommanderMusic = new() { Location = NetJukeboxLocation.NetJukeboxLocationCommanderRoom, TableId = 5, Type = NetJukeboxBgmType.NetJukeboxBgmTypeJukeboxTableId }; + // Event data public Dictionary EventInfo = new(); diff --git a/EpinelPS/LobbyServer/LobbyHandler.cs b/EpinelPS/LobbyServer/LobbyHandler.cs index 93e0d98..27c4875 100644 --- a/EpinelPS/LobbyServer/LobbyHandler.cs +++ b/EpinelPS/LobbyServer/LobbyHandler.cs @@ -48,6 +48,7 @@ namespace EpinelPS.LobbyServer if (handler == null) { + Console.WriteLine("404: " + path); ctx.Response.StatusCode = 404; } else diff --git a/EpinelPS/LobbyServer/Msgs/Jukebox/SetTableId.cs b/EpinelPS/LobbyServer/Msgs/Jukebox/SetTableId.cs new file mode 100644 index 0000000..8b8d96c --- /dev/null +++ b/EpinelPS/LobbyServer/Msgs/Jukebox/SetTableId.cs @@ -0,0 +1,31 @@ +using EpinelPS.Database; +using EpinelPS.Utils; + +namespace EpinelPS.LobbyServer.Msgs.Jukebox +{ + [PacketPath("/jukebox/set/tableid")] + public class SetTableId : LobbyMsgHandler + { + protected override async Task HandleAsync() + { + var req = await ReadData(); + var user = GetUser(); + + var response = new ResSetJukeboxBgmTableId(); + + if (req.Location == NetJukeboxLocation.NetJukeboxLocationCommanderRoom) + { + user.CommanderMusic.TableId = req.JukeboxTableId; + user.CommanderMusic.Type = NetJukeboxBgmType.NetJukeboxBgmTypeJukeboxTableId; + } + else if (req.Location == NetJukeboxLocation.NetJukeboxLocationLobby) + { + user.LobbyMusic.TableId = req.JukeboxTableId; + user.LobbyMusic.Type = NetJukeboxBgmType.NetJukeboxBgmTypeJukeboxTableId; + } + JsonDb.Save(); + + await WriteDataAsync(response); + } + } +} diff --git a/EpinelPS/LobbyServer/Msgs/Outpost/GetOutpostData.cs b/EpinelPS/LobbyServer/Msgs/Outpost/GetOutpostData.cs index 47472cf..0f62393 100644 --- a/EpinelPS/LobbyServer/Msgs/Outpost/GetOutpostData.cs +++ b/EpinelPS/LobbyServer/Msgs/Outpost/GetOutpostData.cs @@ -21,7 +21,7 @@ namespace EpinelPS.LobbyServer.Msgs.Outpost { OutpostBattleLevel = user.OutpostBattleLevel, Jukebox = new() { SelectTid = 5 }, - JukeboxV2 = new NetUserJukeboxDataV2() { CommandBgm = new() { Type = NetJukeboxBgmType.NetJukeboxBgmTypeJukeboxTableId, JukeboxTableId = JsonDb.CurrentJukeboxBgm(2) } }, + JukeboxV2 = new NetUserJukeboxDataV2() { CommandBgm = new() { Type = NetJukeboxBgmType.NetJukeboxBgmTypeJukeboxTableId, JukeboxTableId = user.CommanderMusic.TableId } }, BattleTime = 864000000000, MaxBattleTime = 864000000000, SkinGroupId = 1000, diff --git a/EpinelPS/LobbyServer/Msgs/User/EnterLobbyServer.cs b/EpinelPS/LobbyServer/Msgs/User/EnterLobbyServer.cs index afd01f5..f198494 100644 --- a/EpinelPS/LobbyServer/Msgs/User/EnterLobbyServer.cs +++ b/EpinelPS/LobbyServer/Msgs/User/EnterLobbyServer.cs @@ -24,7 +24,7 @@ namespace EpinelPS.LobbyServer.Msgs.User response.OutpostBattleLevel = user.OutpostBattleLevel; response.OutpostBattleTime = new NetOutpostBattleTime() { MaxBattleTime = 864000000000, MaxOverBattleTime = 12096000000000, BattleTime = battleTimeMs }; - response.JukeboxV2 = new NetUserJukeboxDataV2() {CommandBgm = new NetJukeboxBgm() { JukeboxTableId = JsonDb.CurrentJukeboxBgm(2), Type = NetJukeboxBgmType.NetJukeboxBgmTypeJukeboxTableId, Location = NetJukeboxLocation.NetJukeboxLocationCommanderRoom } }; + response.JukeboxV2 = new NetUserJukeboxDataV2() { CommandBgm = new NetJukeboxBgm() { JukeboxTableId = user.CommanderMusic.TableId, Type = NetJukeboxBgmType.NetJukeboxBgmTypeJukeboxTableId, Location = NetJukeboxLocation.NetJukeboxLocationCommanderRoom } }; // Add default slot data if (user.RepresentationTeamData.Slots.Count == 0) diff --git a/EpinelPS/LobbyServer/Msgs/User/GetUser.cs b/EpinelPS/LobbyServer/Msgs/User/GetUser.cs index 16f2a4f..4b4ca27 100644 --- a/EpinelPS/LobbyServer/Msgs/User/GetUser.cs +++ b/EpinelPS/LobbyServer/Msgs/User/GetUser.cs @@ -39,8 +39,8 @@ namespace EpinelPS.LobbyServer.Msgs.User response.User.Tutorials.Add(new NetTutorialData() { GroupId = groupId, LastClearedTid = item.Key, LastClearedVersion = version }); } - response.CommanderRoomJukeboxBgm = new NetJukeboxBgm() { JukeboxTableId = JsonDb.CurrentJukeboxBgm(2), Type = NetJukeboxBgmType.NetJukeboxBgmTypeJukeboxTableId, Location = NetJukeboxLocation.NetJukeboxLocationCommanderRoom }; - response.LobbyJukeboxBgm = new NetJukeboxBgm() { JukeboxTableId = JsonDb.CurrentJukeboxBgm(1), Type = NetJukeboxBgmType.NetJukeboxBgmTypeJukeboxTableId, Location = NetJukeboxLocation.NetJukeboxLocationLobby }; + response.CommanderRoomJukeboxBgm = new NetJukeboxBgm() { JukeboxTableId = user.CommanderMusic.TableId, Type = NetJukeboxBgmType.NetJukeboxBgmTypeJukeboxTableId, Location = NetJukeboxLocation.NetJukeboxLocationCommanderRoom }; + response.LobbyJukeboxBgm = new NetJukeboxBgm() { JukeboxTableId = user.LobbyMusic.TableId, Type = NetJukeboxBgmType.NetJukeboxBgmTypeJukeboxTableId, Location = NetJukeboxLocation.NetJukeboxLocationLobby }; await WriteDataAsync(response); } diff --git a/EpinelPS/LobbyServer/Msgs/User/GetWallpaper.cs b/EpinelPS/LobbyServer/Msgs/User/GetWallpaper.cs index 8cdecc8..6f7ecdd 100644 --- a/EpinelPS/LobbyServer/Msgs/User/GetWallpaper.cs +++ b/EpinelPS/LobbyServer/Msgs/User/GetWallpaper.cs @@ -9,7 +9,16 @@ namespace EpinelPS.LobbyServer.Msgs.User { var req = await ReadData(); var response = new ResGetWallpaper(); - response.WallpaperList.AddRange(GetUser().WallpaperList); + var user = GetUser(); + + + response.WallpaperList.AddRange(user.WallpaperList); + response.WallpaperPlaylistList.AddRange(user.WallpaperPlaylistList); + response.WallpaperJukeboxList.AddRange(user.WallpaperJukeboxList); + response.WallpaperBackgroundList.AddRange(user.WallpaperBackground); + response.WallpaperFavoriteList.AddRange(user.WallpaperFavoriteList); + + // TODO: JukeboxIdList await WriteDataAsync(response); } diff --git a/EpinelPS/LobbyServer/Msgs/User/SetWallpaper.cs b/EpinelPS/LobbyServer/Msgs/User/SetWallpaper.cs index da3ada9..890b0b8 100644 --- a/EpinelPS/LobbyServer/Msgs/User/SetWallpaper.cs +++ b/EpinelPS/LobbyServer/Msgs/User/SetWallpaper.cs @@ -1,4 +1,5 @@ -using EpinelPS.Utils; +using EpinelPS.Database; +using EpinelPS.Utils; namespace EpinelPS.LobbyServer.Msgs.User { @@ -11,6 +12,12 @@ namespace EpinelPS.LobbyServer.Msgs.User var response = new ResSetWallpaper(); var user = GetUser(); user.WallpaperList = req.WallpaperList.ToArray(); + user.WallpaperBackground = req.WallpaperBackgroundList.ToArray(); + user.WallpaperFavoriteList = req.WallpaperFavoriteList.ToArray(); + user.WallpaperPlaylistList = req.WallpaperPlaylistList.ToArray(); + user.WallpaperJukeboxList = req.WallpaperJukeboxList.ToArray(); + + JsonDb.Save(); await WriteDataAsync(response); }