Core/Players: PlayerChoice improvements

Port From (https://github.com/TrinityCore/TrinityCore/commit/e59059e1bd2f67691e2da0105771b0cb55b123a4)
This commit is contained in:
Hondacrx
2025-08-18 16:57:28 -04:00
parent 1f6f9013c7
commit cd0ffc6975
9 changed files with 284 additions and 212 deletions
+18 -106
View File
@@ -10152,7 +10152,10 @@ namespace Game
uint oldMSTime = Time.GetMSTime();
_playerChoices.Clear();
SQLResult choiceResult = DB.World.Query("SELECT ChoiceId, UiTextureKitId, SoundKitId, CloseSoundKitId, Duration, Question, PendingChoiceText, HideWarboardHeader, KeepOpenAfterChoice FROM playerchoice");
// 0 1 2 3 4 5 6
SQLResult choiceResult = DB.World.Query("SELECT ChoiceId, UiTextureKitId, SoundKitId, CloseSoundKitId, Duration, Question, PendingChoiceText, " +
//7 8 9 10 11 12 13
"InfiniteRange, HideWarboardHeader, KeepOpenAfterChoice, ShowChoicesAsList, ForceDontShowChoicesAsList, MaxResponses, ScriptName FROM playerchoice");
if (choiceResult.IsEmpty())
{
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 player choices. DB table `playerchoice` is empty.");
@@ -10174,18 +10177,26 @@ namespace Game
choice.UiTextureKitId = choiceResult.Read<int>(1);
choice.SoundKitId = choiceResult.Read<uint>(2);
choice.CloseSoundKitId = choiceResult.Read<uint>(3);
choice.Duration = choiceResult.Read<long>(4);
choice.Duration = TimeSpan.FromSeconds(choiceResult.Read<long>(4));
choice.Question = choiceResult.Read<string>(5);
choice.PendingChoiceText = choiceResult.Read<string>(6);
choice.HideWarboardHeader = choiceResult.Read<bool>(7);
choice.KeepOpenAfterChoice = choiceResult.Read<bool>(8);
choice.InfiniteRange = choiceResult.Read<bool>(7);
choice.HideWarboardHeader = choiceResult.Read<bool>(8);
choice.KeepOpenAfterChoice = choiceResult.Read<bool>(9);
choice.ShowChoicesAsList = choiceResult.Read<bool>(10);
choice.ForceDontShowChoicesAsList = choiceResult.Read<bool>(11);
if (!choiceResult.IsNull(12))
choice.MaxResponses = choiceResult.Read<uint>(12);
choice.ScriptId = GetScriptId(choiceResult.Read<string>(13));
_playerChoices[choice.ChoiceId] = choice;
} while (choiceResult.NextRow());
// 0 1 2 3 4 5
SQLResult responses = DB.World.Query("SELECT ChoiceId, ResponseId, ResponseIdentifier, ChoiceArtFileId, Flags, WidgetSetID, " +
// 0 1 2 3 4 5
SQLResult responses = DB.World.Query("SELECT ChoiceId, ResponseId, NULL, ChoiceArtFileId, Flags, WidgetSetID, " +
//6 7 8 9 10 11 12 13 14 15 16
"UiTextureAtlasElementID, SoundKitID, GroupID, UiTextureKitID, Answer, Header, SubHeader, ButtonTooltip, Description, Confirmation, RewardQuestID " +
"FROM playerchoice_response ORDER BY `Index` ASC");
@@ -10206,9 +10217,8 @@ namespace Game
PlayerChoiceResponse response = new();
response.ResponseId = responseId;
response.ResponseIdentifier = responses.Read<ushort>(2);
response.ChoiceArtFileId = responses.Read<int>(3);
response.Flags = responses.Read<int>(4);
response.Flags = (PlayerChoiceResponseFlags)responses.Read<int>(4);
response.WidgetSetID = responses.Read<uint>(5);
response.UiTextureAtlasElementID = responses.Read<uint>(6);
response.SoundKitID = responses.Read<uint>(7);
@@ -12665,104 +12675,6 @@ namespace Game
public StringArray Confirmation = new((int)Locale.Total);
}
public class PlayerChoiceResponseRewardItem
{
public PlayerChoiceResponseRewardItem() { }
public PlayerChoiceResponseRewardItem(uint id, List<uint> bonusListIDs, int quantity)
{
Id = id;
BonusListIDs = bonusListIDs;
Quantity = quantity;
}
public uint Id;
public List<uint> BonusListIDs = new();
public int Quantity;
}
public class PlayerChoiceResponseRewardEntry
{
public PlayerChoiceResponseRewardEntry(uint id, int quantity)
{
Id = id;
Quantity = quantity;
}
public uint Id;
public int Quantity;
}
public class PlayerChoiceResponseReward
{
public int TitleId;
public int PackageId;
public int SkillLineId;
public uint SkillPointCount;
public uint ArenaPointCount;
public uint HonorPointCount;
public ulong Money;
public uint Xp;
public List<PlayerChoiceResponseRewardItem> Items = new();
public List<PlayerChoiceResponseRewardEntry> Currency = new();
public List<PlayerChoiceResponseRewardEntry> Faction = new();
public List<PlayerChoiceResponseRewardItem> ItemChoices = new();
}
public struct PlayerChoiceResponseMawPower
{
public int TypeArtFileID;
public int? Rarity;
public int SpellID;
public int MaxStacks;
}
public class PlayerChoiceResponse
{
public int ResponseId;
public ushort ResponseIdentifier;
public int ChoiceArtFileId;
public int Flags;
public uint WidgetSetID;
public uint UiTextureAtlasElementID;
public uint SoundKitID;
public byte GroupID;
public int UiTextureKitID;
public string Answer;
public string Header;
public string SubHeader;
public string ButtonTooltip;
public string Description;
public string Confirmation;
public PlayerChoiceResponseReward Reward;
public uint? RewardQuestID;
public PlayerChoiceResponseMawPower? MawPower;
}
public class PlayerChoice
{
public int ChoiceId;
public int UiTextureKitId;
public uint SoundKitId;
public uint CloseSoundKitId;
public long Duration;
public string Question;
public string PendingChoiceText;
public List<PlayerChoiceResponse> Responses = new();
public bool HideWarboardHeader;
public bool KeepOpenAfterChoice;
public PlayerChoiceResponse GetResponse(int responseId)
{
return Responses.Find(playerChoiceResponse => playerChoiceResponse.ResponseId == responseId);
}
public PlayerChoiceResponse GetResponseByIdentifier(int responseIdentifier)
{
return Responses.Find(playerChoiceResponse => playerChoiceResponse.ResponseIdentifier == responseIdentifier);
}
}
public class ClassAvailability
{
public byte ClassID;
+119
View File
@@ -0,0 +1,119 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
namespace Game
{
public class PlayerChoiceResponseRewardItem
{
public uint Id;
public List<uint> BonusListIDs = new();
public int Quantity;
public PlayerChoiceResponseRewardItem() { }
public PlayerChoiceResponseRewardItem(uint id, List<uint> bonusListIDs, int quantity)
{
Id = id;
BonusListIDs = bonusListIDs;
Quantity = quantity;
}
}
public class PlayerChoiceResponseRewardEntry
{
public uint Id;
public int Quantity;
public PlayerChoiceResponseRewardEntry(uint id, int quantity)
{
Id = id;
Quantity = quantity;
}
}
public class PlayerChoiceResponseReward
{
public int TitleId;
public int PackageId;
public int SkillLineId;
public uint SkillPointCount;
public uint ArenaPointCount;
public uint HonorPointCount;
public ulong Money;
public uint Xp;
public List<PlayerChoiceResponseRewardItem> Items = new();
public List<PlayerChoiceResponseRewardEntry> Currency = new();
public List<PlayerChoiceResponseRewardEntry> Faction = new();
public List<PlayerChoiceResponseRewardItem> ItemChoices = new();
}
public struct PlayerChoiceResponseMawPower
{
public int TypeArtFileID;
public int? Rarity;
public int SpellID;
public int MaxStacks;
}
public enum PlayerChoiceResponseFlags
{
None = 0x000,
DisabledButton = 0x001, // Disables single button
DesaturateArt = 0x002,
DisabledOption = 0x004, // Disables the entire group of options
ConsolidateWidgets = 0x020,
ShowCheckmark = 0x040,
HideButtonShowText = 0x080,
Selected = 0x100,
}
public class PlayerChoiceResponse
{
public int ResponseId;
public int ChoiceArtFileId;
public PlayerChoiceResponseFlags Flags;
public uint WidgetSetID;
public uint UiTextureAtlasElementID;
public uint SoundKitID;
public byte GroupID;
public int UiTextureKitID;
public string Answer;
public string Header;
public string SubHeader;
public string ButtonTooltip;
public string Description;
public string Confirmation;
public PlayerChoiceResponseReward Reward;
public uint? RewardQuestID;
public PlayerChoiceResponseMawPower? MawPower;
}
public class PlayerChoice
{
public int ChoiceId;
public int UiTextureKitId;
public uint SoundKitId;
public uint CloseSoundKitId;
public TimeSpan Duration;
public string Question;
public string PendingChoiceText;
public List<PlayerChoiceResponse> Responses = new();
public bool InfiniteRange;
public bool HideWarboardHeader;
public bool KeepOpenAfterChoice;
public bool ShowChoicesAsList;
public bool ForceDontShowChoicesAsList;
public uint MaxResponses;
public uint ScriptId;
public PlayerChoiceResponse GetResponse(int responseId)
{
return Responses.Find(playerChoiceResponse => playerChoiceResponse.ResponseId == responseId);
}
}
}