Fix music saving

This commit is contained in:
Mikhail
2024-09-21 10:46:30 -04:00
parent 9e49fd31ae
commit b7a9d0de32
8 changed files with 72 additions and 6 deletions

View File

@@ -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<Character> Characters = [];
public NetWholeUserTeamData RepresentationTeamData = new();
public Dictionary<int, ClearedTutorialData> ClearedTutorialData = [];
public NetWallpaperData[] WallpaperList = [];
public NetWallpaperBackground[] WallpaperBackground = [];
public NetWallpaperJukeboxFavorite[] WallpaperFavoriteList = [];
public NetWallpaperPlaylist[] WallpaperPlaylistList = [];
public NetWallpaperJukebox[] WallpaperJukeboxList = [];
public Dictionary<int, NetUserTeamData> UserTeams = new Dictionary<int, NetUserTeamData>();
public Dictionary<int, bool> MainQuestData = new();
public int InfraCoreExp = 0;
@@ -173,6 +188,9 @@ namespace EpinelPS.Database
public Dictionary<int, int> TowerProgress = new Dictionary<int, int>();
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<int, EventData> EventInfo = new();

View File

@@ -48,6 +48,7 @@ namespace EpinelPS.LobbyServer
if (handler == null)
{
Console.WriteLine("404: " + path);
ctx.Response.StatusCode = 404;
}
else

View File

@@ -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<ReqSetJukeboxBgmTableId>();
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);
}
}
}

View File

@@ -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,

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -9,7 +9,16 @@ namespace EpinelPS.LobbyServer.Msgs.User
{
var req = await ReadData<ReqGetWallpaper>();
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);
}

View File

@@ -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);
}