Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple profiles #72

Merged
merged 8 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions TarkovMonitor/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
<setting name="customLogsPath" serializeAs="String">
<value />
</setting>
<setting name="customMap" serializeAs="String">
<value />
</setting>
<setting name="tarkovTrackerTokens" serializeAs="String">
<value>{}</value>
</setting>
</TarkovMonitor.Properties.Settings>
</userSettings>
</configuration>
29 changes: 18 additions & 11 deletions TarkovMonitor/Blazor/Pages/RawLogs/ForceReadDialog.razor
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
@using System.ComponentModel
@using Humanizer
@inject MessageLog messageLog
@inject GameWatcher eft

<MudDialog>
<DialogContent>
@if (eft.LogsPath != "")
<MudText>
Current profile: @eft.CurrentProfile.Id (@eft.CurrentProfile.Type)
</MudText>
<MudText>
If you want to update progress for a different profile, activate that profile in the game.
</MudText>
@if (customWatcher.LogsPath != "")
{
if (breakpoints != null)
{
<MudSelect @bind-Value="selectedBreakpoint" Label="Read previous logs" HelperText="Choose the starting point from which to read logs" OpenIcon="@Icons.Material.Filled.TextSnippet" AdornmentColor="Color.Secondary">
@foreach (LogDetails breakpoint in breakpoints)
{
<MudSelectItem Value="@breakpoint">(@breakpoint.Date.ToLongDateString() - @breakpoint.Date.Humanize()) | @breakpoint.Version | Profile: @breakpoint.ProfileId</MudSelectItem>
<MudSelectItem Value="@breakpoint">@breakpoint.Version | @breakpoint.Date.ToLongDateString() - @breakpoint.Date.Humanize()</MudSelectItem>
}
</MudSelect>
<p>Select a starting point to read previous logs and update your quest progress. All logs from that point forward with the same profile ID will be read and that cumulative progress will be synced to Tarkov Tracker.</p>
<p>Select a starting point to read previous logs and update your quest progress. All logs from that point forward for the same will be read and that cumulative progress will be synced to Tarkov Tracker.</p>
<p><strong>WARNING: </strong>You can mess up your Tarkov Tracker saved quest progress if you pick an invalid starting date, so proceed with caution.</p>
}
else
Expand All @@ -36,7 +43,7 @@
@code {
[CascadingParameter] MudDialogInstance MudDialog { get; set; }

internal GameWatcher eft = new();
internal GameWatcher customWatcher = new();
LogDetails? selectedBreakpoint;
List<LogDetails>? breakpoints;
Dictionary<string, TarkovMonitor.TaskStatus> TaskStatuses = new();
Expand All @@ -50,15 +57,15 @@
{
if (e.PropertyName == "customLogsPath")
{
eft.LogsPath = Properties.Settings.Default.customLogsPath;
customWatcher.LogsPath = Properties.Settings.Default.customLogsPath;
Task.Run(GetBreakPoints);
}
};
}

private void GetBreakPoints()
{
breakpoints = eft.GetLogBreakpoints();
breakpoints = customWatcher.GetLogBreakpoints(eft.CurrentProfile.Id);
InvokeAsync(() => StateHasChanged());
}

Expand All @@ -80,9 +87,9 @@
try
{
//eft.ProcessLogs(selectedPath);
eft.TaskModified += UpdateTaskStatus;
eft.ProcessLogsFromBreakpoint(selectedBreakpoint);
eft.TaskModified -= UpdateTaskStatus;
customWatcher.TaskModified += UpdateTaskStatus;
customWatcher.ProcessLogsFromBreakpoint(selectedBreakpoint);
customWatcher.TaskModified -= UpdateTaskStatus;
foreach (var kvp in TaskStatuses)
{
if (kvp.Value == TarkovMonitor.TaskStatus.Started)
Expand Down Expand Up @@ -143,8 +150,8 @@
}
}

private void UpdateTaskStatus(object? sender, TaskStatusMessageEventArgs e)
private void UpdateTaskStatus(object? sender, LogContentEventArgs<TaskStatusMessageLogContent> e)
{
TaskStatuses[e.TaskId] = e.Status;
TaskStatuses[e.LogContent.TaskId] = e.LogContent.Status;
}
}
29 changes: 24 additions & 5 deletions TarkovMonitor/Blazor/Pages/Settings/Settings.razor
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</MudSelect>
</div>
</MudPaper>
</MudItem>
</MudItem>

<MudItem xs="12">
<MudPaper Class="pa-2 ma-2 mx-4" Elevation="3">
Expand Down Expand Up @@ -99,6 +99,13 @@
<div>
<MudSwitch @bind-Checked="@NavigateMapOnPositionUpdateSwitch" Label="Switch to Tarkov.dev map on position update (via screenshot)" Color="Color.Info" />
</div>
<MudSelect @bind-Value="@MapOverrideSelect" T="string" Label="Offline Map" ShrinkLabel="true" HelperText="Map to use for offline raids" AnchorOrigin="Origin.BottomCenter" xs="3">
<MudSelectItem T="string" Value="@string.Empty">None</MudSelectItem>
@foreach (var map in TarkovDev.Maps)
{
<MudSelectItem T="string" Value="@map.nameId">@map.name</MudSelectItem>
}
</MudSelect>
</MudPaper>
</MudItem>

Expand Down Expand Up @@ -298,6 +305,19 @@
}
}

public string MapOverrideSelect
{
get
{
return Properties.Settings.Default.customMap;
}
set
{
Properties.Settings.Default.customMap = value;
Properties.Settings.Default.Save();
}
}

public bool MinimizeAtStartupSwitch
{
get
Expand Down Expand Up @@ -367,7 +387,7 @@
{
get
{
return Properties.Settings.Default.tarkovTrackerToken.Length != 22;
return TarkovTracker.GetToken(eft.CurrentProfile.Id).Length != 22;
}
set
{
Expand All @@ -389,12 +409,11 @@
{
get
{
return Properties.Settings.Default.tarkovTrackerToken;
return TarkovTracker.GetToken(eft.CurrentProfile.Id);
}
set
{
Properties.Settings.Default.tarkovTrackerToken = value;
Properties.Settings.Default.Save();
TarkovTracker.SetToken(eft.CurrentProfile.Id, value);
}
}

Expand Down
Loading
Loading