Skip to content

Commit

Permalink
Update for latest HS version
Browse files Browse the repository at this point in the history
  • Loading branch information
ardittristan committed Sep 30, 2022
1 parent bd2119b commit dd5e00c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 50 deletions.
13 changes: 4 additions & 9 deletions HSReflection/Reflection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,14 @@ private static Dictionary<int, QuestRecord> GetQuestRecordsInternal()

dynamic? questPoolState = Services.QuestManager["m_questPoolState"];

dynamic? quests = Services.GameDbf["Quest"]?["m_recordsById"];
dynamic? quests = Services.GameDbf["Quest"]?["m_records"];

if (quests == null) return questRecords;

dynamic questKeys = quests["keySlots"];
dynamic questEntries = quests["_items"];

foreach (dynamic? questKey in questKeys)
foreach (dynamic quest in questEntries)
{
if (questKey == null) continue;

dynamic? quest = Map.GetValue(quests, questKey);
if (quest == null) continue;

int questPoolId = quest["m_questPoolId"];

dynamic? questPoolStateEntry = questPoolState == null
Expand All @@ -46,7 +41,7 @@ private static Dictionary<int, QuestRecord> GetQuestRecordsInternal()
DynamicUtil.TryCast<uint>(Map.GetValue(questPoolState, questPoolId) ?? 0) ?? 0
);

questRecords.Add(questKey, new QuestRecord()
questRecords.Add(quest["m_ID"], new QuestRecord()
{
CanAbandon = quest["m_canAbandon"],
Description = GetLocalization(quest["m_description"]),
Expand Down
4 changes: 2 additions & 2 deletions QuestOverlayPlugin/Overlay/QuestListButton.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ private async void OnMouseEnter(object sender, MouseEventArgs e)
return;
if (IsBattlegrounds)
{
Plugin.Instance.UpdateBattlegroundsQuestList();
Plugin.Instance.BattlegroundsQuestListVM.UpdateAsync();
Plugin.Instance.ShowBattlegroundsQuests();
}
else
{
Plugin.Instance.UpdateQuestList();
Plugin.Instance.QuestListVM.UpdateAsync();
Plugin.Instance.ShowQuests();
}
}
Expand Down
52 changes: 18 additions & 34 deletions QuestOverlayPlugin/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,27 @@ public void OnLoad()

GameEvents.OnInMenu.Add(Update);
GameEvents.OnInMenu.Add(OnGameStart);
GameEvents.OnInMenu.Add(UpdateQuestWindow);
GameEvents.OnGameEnd.Add(Update);
GameEvents.OnGameEnd.Add(UpdateQuestWindow);
GameEvents.OnModeChanged.Add(Update);
GameEvents.OnModeChanged.Add(OnGameStart);
GameEvents.OnModeChanged.Add(UpdateQuestWindow);
Watchers.ExperienceWatcher.NewExperienceHandler += UpdateEventHandler;
if (Core.Game.IsRunning) Update();
if (Core.Game.IsRunning) OnGameStart();

Extractor = new Extractor(
Path.Combine(Config.Instance.ConfigDir, "Plugins", "HearthstoneQuestOverlay", "TextureExtractor"),
Core.Game.MetaData.HearthstoneBuild.ToString());

#pragma warning disable CS4014

Extractor.ExtractAsync(CreateBundlePath(QUEST_ICONS_LOC));
#pragma warning restore CS4014
}

private void UpdateQuestWindow(Mode mode) => UpdateQuestWindow();
private void UpdateQuestWindow()
{
if (Settings.ShowPopupWindow) QuestListWindowVM.UpdateAsync();
}

private void OnGameStart(Mode mode) => OnGameStart();
Expand Down Expand Up @@ -199,10 +206,8 @@ private void OnGameExit(object sender, EventArgs e)
}
}

public static string CreateBundlePath(string bundleName)
{
return Path.Combine(Config.Instance.HearthstoneDirectory, @"Data\Win", bundleName + ".unity3d");
}
public static string CreateBundlePath(string bundleName) =>
Path.Combine(Config.Instance.HearthstoneDirectory, @"Data\Win", bundleName + ".unity3d");

private void InitSettings()
{
Expand Down Expand Up @@ -254,6 +259,8 @@ public void OnUnload()
Watchers.ExperienceWatcher.NewExperienceHandler -= UpdateEventHandler;

RemoveOverlay();
_questListWindow.Shutdown();
_questListWindowRT?.Dispose();
}

public void OnButtonPress()
Expand Down Expand Up @@ -352,30 +359,7 @@ internal void HideBattlegroundsQuestsButton()
_battlegroundsQuestListButtonBehavior.Hide();
}

internal void UpdateQuestList(bool force = false)
{
((QuestListViewModel)_questListView.DataContext).Update(force);
}

internal void UpdateBattlegroundsQuestList(bool force = false)
{
((QuestListViewModel)_battlegroundsQuestListView.DataContext).Update(force);
}

internal void ForceNextQuestUpdate()
{
((QuestListViewModel)_questListView.DataContext).ForceNext = true;
}

internal void ForceNextBattlegroundsQuestUpdate()
{
((QuestListViewModel)_battlegroundsQuestListView.DataContext).ForceNext = true;
}

internal void ForceNextQuestWindowUpdate()
{
((QuestListViewModel)_questListWindow.DataContext).ForceNext = true;
}
internal void ForceNextQuestWindowUpdate() => QuestListWindowVM.ForceNext = true;

internal void ShowQuests()
{
Expand Down Expand Up @@ -412,8 +396,8 @@ internal static void Update()
{
Instance.ShowOrHideQuestsButton();
Instance.ShowOrHideBattlegroundsQuestsButton();
Instance.ForceNextQuestUpdate();
Instance.ForceNextBattlegroundsQuestUpdate();
Instance.ForceNextQuestWindowUpdate();
Instance.QuestListVM.ForceNext = true;
Instance.BattlegroundsQuestListVM.ForceNext = true;
Instance.QuestListWindowVM.ForceNext = true;
}
}
1 change: 1 addition & 0 deletions QuestOverlayPlugin/QuestOverlayPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<NoWarn>1701;1702;4014</NoWarn>
</PropertyGroup>

<Target Name="PostBuild" AfterTargets="Build">
Expand Down
6 changes: 2 additions & 4 deletions QuestOverlayPlugin/Windows/QuestListWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ namespace QuestOverlayPlugin.Windows;
public partial class QuestListWindow : MetroWindow
{
private bool _appIsClosing;
public QuestListViewModel QuestListViewModelVM;

public QuestListWindow(QuestListViewModel questListViewModel)
{
InitializeComponent();

DataContext = questListViewModel;
QuestListViewModelVM = questListViewModel;
}

protected override void OnClosing(CancelEventArgs e)
Expand All @@ -35,7 +33,7 @@ internal void Shutdown()

private async void QuestListWindow_OnActivated(object sender, EventArgs e)
{
await QuestListViewModelVM.UpdateAsync();
await Plugin.Instance.QuestListWindowVM.UpdateAsync();
Topmost = true;
}

Expand All @@ -47,7 +45,7 @@ private void QuestListWindow_OnDeactivated(object sender, EventArgs e)

private async void QuestListWindow_OnLoaded(object sender, RoutedEventArgs e)
{
await QuestListViewModelVM.UpdateAsync();
await Plugin.Instance.QuestListWindowVM.UpdateAsync();
UpdateScaling();
}

Expand Down
2 changes: 1 addition & 1 deletion Version.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<Version>1.5.1</Version>
<Version>1.5.2</Version>
</PropertyGroup>
</Project>

0 comments on commit dd5e00c

Please sign in to comment.