Skip to content

Commit

Permalink
Initial sort is by age (serialized ID). Hooked up next and previous d…
Browse files Browse the repository at this point in the history
…weller on Dweller_Info dialog.
  • Loading branch information
jake1164 committed Nov 16, 2024
1 parent 12a804d commit 087f8da
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
35 changes: 32 additions & 3 deletions ShelterViewer/Components/Dwellers/DwellerInfo_Dialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@

</MudCardContent>
<MudCardActions>
<MudButton Color="Color.Primary">Previous</MudButton>
<MudButton Color="Color.Primary">Next</MudButton>
<MudButton Color="Color.Primary" OnClick="PreviousDweller" Disabled="@(_current == 0)">Previous</MudButton>
<MudButton Color="Color.Primary" OnClick="NextDweller" Disabled="@(_current == Dwellers.Length - 1)">Next</MudButton>
</MudCardActions>
</MudCard>
</DialogContent>
Expand Down Expand Up @@ -87,7 +87,36 @@
private MudDialogInstance MudDialog { get; set; } = null!;

[Parameter, EditorRequired]
public Dweller Dweller { get; set; } = null!;
public int DwellerId { get; set; }

[Parameter, EditorRequired]
public Dweller[] Dwellers { get; set; } = null!;

private int _current = 0;
private Dweller Dweller { get { return Dwellers[_current]; }}

protected override void OnInitialized()
{
_current = Array.FindIndex(Dwellers, i => i.serializeId == DwellerId);
}

private void NextDweller()
{
if (_current < Dwellers.Length)
{
_current++;
StateHasChanged();
}
}

private void PreviousDweller()
{
if (_current > 0)
{
_current--;
StateHasChanged();
}
}

private void CloseDialog() => MudDialog.Close(DialogResult.Ok(true));
}
5 changes: 3 additions & 2 deletions ShelterViewer/Pages/Dwellers.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

<MudDataGrid T="Dweller" Items="DwellerList" Filterable="true" >
<Columns>

<PropertyColumn Property="x => x.firstName" Title="First Name" />
<PropertyColumn Property="x => x.lastName" Title="Last Name" />
<PropertyColumn Property="x => x.Gender" Title="Gender" />

<!-- Theme Rarity? add icon?
<PropertyColumn Property="x => x.rarity" Title="Rarity" />
-->
Expand Down Expand Up @@ -80,7 +80,8 @@
var options = new DialogOptions() { MaxWidth = MaxWidth.Large, FullWidth = true };
var parameters = new DialogParameters<DwellerInfo_Dialog>
{
{ "Dweller", selectedDweller }
{ "DwellerId", selectedDweller.serializeId },
{ "Dwellers", DwellerList.ToArray() }
};
return DialogService.ShowAsync<DwellerInfo_Dialog>("Dweller Info", parameters, options);
}
Expand Down
7 changes: 3 additions & 4 deletions ShelterViewer/Services/VaultService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,9 @@ public void InitializeVault(string vaultJsonString)
_vaultData = JsonConvert.DeserializeObject<dynamic>(VaultString, settings);

VaultData = System.Text.Json.JsonSerializer.Deserialize<VaultData>(VaultString, new JsonSerializerOptions());

//_dwellers = GetDwellers();
//_rooms = GetRooms();
_items = GetItems();
VaultData!.dwellers.dwellers = VaultData!.dwellers.dwellers.ToList().OrderBy(x => x.serializeId).ToArray(); // Order by ID initially.

_items = GetItems(); // Items are spread across users.
ProcessDwellers(); // Do this on the first click of dwellers?
NotifyPropertyChanged();

Expand Down

0 comments on commit 087f8da

Please sign in to comment.