-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- only write to disk on specific timer properties changing
- tooltips, but they're kinda bad with full list refresh - debugger logging
- Loading branch information
Showing
15 changed files
with
192 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 24 additions & 11 deletions
35
src/Dota2Helper/Core/Listeners/DynamicListenerStrategy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,40 @@ | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Avalonia.Controls; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Dota2Helper.Core.Listeners; | ||
|
||
public class DynamicListenerStrategy(List<IDotaListener> listeners) : IListenerStrategy | ||
public class DynamicListenerStrategy( | ||
ILogger<DynamicListenerStrategy> logger, | ||
FakeDotaListener fakeDotaListener, | ||
DotaListener dotaListener) : IListenerStrategy | ||
{ | ||
public IDotaListener Current | ||
public async Task<IDotaListener> GetListener(CancellationToken cancellationToken) | ||
{ | ||
get | ||
if (Design.IsDesignMode) | ||
{ | ||
if (Design.IsDesignMode) | ||
{ | ||
return listeners.First(l => l.GetType() == typeof(FakeDotaListener)); | ||
} | ||
return fakeDotaListener; | ||
} | ||
|
||
if (Process.GetProcessesByName("dota2").Any()) | ||
if (Process.GetProcessesByName("dota2").Any()) | ||
{ | ||
logger.LogInformation("Dota 2 is running, using DotaListener"); | ||
|
||
var state = await dotaListener.GetStateAsync(cancellationToken); | ||
|
||
if (state != null) | ||
{ | ||
return listeners.First(l => l.GetType() == typeof(DotaListener)); | ||
logger.LogInformation("DotaListener is working"); | ||
return dotaListener; | ||
} | ||
|
||
return listeners.First(l => l.GetType() == typeof(FakeDotaListener)); | ||
} | ||
|
||
logger.LogInformation("Dota 2 is not running, using FakeDotaListener"); | ||
|
||
return fakeDotaListener; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Dota2Helper.Core.Gsi; | ||
|
||
namespace Dota2Helper.Core.Listeners; | ||
|
||
public interface IDotaListener : IDisposable | ||
{ | ||
Task<GameState?> GetStateAsync(); | ||
Task<GameState?> GetStateAsync(CancellationToken cancellationToken); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
namespace Dota2Helper.Core.Listeners; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Dota2Helper.Core.Listeners; | ||
|
||
public interface IListenerStrategy | ||
{ | ||
IDotaListener Current { get; } | ||
Task<IDotaListener> GetListener(CancellationToken cancellationToken); | ||
} |
Oops, something went wrong.