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

Dev #81

Merged
merged 9 commits into from
Dec 18, 2024
Merged

Dev #81

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: 3 additions & 3 deletions .github/workflows/buildandtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and Test

on:
push:
branches: [ "dev" ]
branches: [ dev ]
paths-ignore:
- "**.md"
- "**.ps1"
Expand All @@ -12,11 +12,11 @@ on:
- '**/*.gitattributes'
- '**/*.yml'
pull_request:
branches: [ "dev", "main" ]
branches: [ dev, main ]

jobs:
build:
name: "Build and Test"
name: Build and Test
# use ubuntu-latest image to run steps on
runs-on: ubuntu-latest

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy to GitHub Pages

on:
push:
branches: [ "main" ]
branches: [ main ]
paths-ignore:
- "**.md"
- "**.ps1"
Expand All @@ -14,7 +14,7 @@ on:

jobs:
deploy:
name: "Deploy to GitHub Pages"
name: Deploy to GitHub Pages
# use ubuntu-latest image to run steps on
runs-on: ubuntu-latest
steps:
Expand Down
73 changes: 37 additions & 36 deletions Pkmds.Web/Components/BasePkmdsComponent.razor
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
@code {
public const string ColumnClass = "d-flex align-center justify-center";
protected const string ColumnClass = "d-flex align-center justify-center";

public static RenderFragment TypeSummary(byte type1, byte type2) =>
@<MudStack Row
Class="my-2"
AlignItems="@AlignItems.Center">
<MudText>
Type:
</MudText>
<MudImage Src="@SpriteHelper.GetTypeWideSpriteFileName(type1)"
Alt="@GameInfo.Strings.Types[type1]"
title="@GameInfo.Strings.Types[type1]"
ObjectFit="@ObjectFit.Contain"
ObjectPosition="@ObjectPosition.Center" />
@if (type1 != type2)
{
<MudImage Src="@SpriteHelper.GetTypeWideSpriteFileName(type2)"
Alt="@GameInfo.Strings.Types[type2]"
title="@GameInfo.Strings.Types[type2]"
ObjectFit="@ObjectFit.Contain"
ObjectPosition="@ObjectPosition.Center" />
}
</MudStack>;
private static RenderFragment TypeSummary(byte type1, byte type2) =>
@<MudStack Row
Class="my-2"
AlignItems="@AlignItems.Center">
<MudText>
Type:
</MudText>
<MudImage Src="@SpriteHelper.GetTypeWideSpriteFileName(type1)"
Alt="@GameInfo.Strings.Types[type1]"
title="@GameInfo.Strings.Types[type1]"
ObjectFit="@ObjectFit.Contain"
ObjectPosition="@ObjectPosition.Center"/>
@if (type1 != type2)
{
<MudImage Src="@SpriteHelper.GetTypeWideSpriteFileName(type2)"
Alt="@GameInfo.Strings.Types[type2]"
title="@GameInfo.Strings.Types[type2]"
ObjectFit="@ObjectFit.Contain"
ObjectPosition="@ObjectPosition.Center"/>
}
</MudStack>;

public static RenderFragment TypeSummary((byte Type1, byte Type2) types) =>
protected static RenderFragment TypeSummary((byte Type1, byte Type2) types) =>
TypeSummary(types.Type1, types.Type2);

public static RenderFragment MoveTypeSummary(byte type) =>
@<MudImage Src="@SpriteHelper.GetTypeSquareSpriteFileName(type)"
Alt="@GameInfo.Strings.Types[type]"
title="@GameInfo.Strings.Types[type]"
ObjectFit="@ObjectFit.Contain"
ObjectPosition="@ObjectPosition.Center"
Width="30"/>;
protected static RenderFragment MoveTypeSummary(byte type) =>
@<MudImage Src="@SpriteHelper.GetTypeSquareSpriteFileName(type)"
Alt="@GameInfo.Strings.Types[type]"
title="@GameInfo.Strings.Types[type]"
ObjectFit="@ObjectFit.Contain"
ObjectPosition="@ObjectPosition.Center"
Width="30"/>;

public static RenderFragment MoveCategorySummary(int categoryId) =>
@<MudImage Src="@SpriteHelper.GetMoveCategorySpriteFileName(categoryId)"
Alt="@GameInfoExtensions.GetCategoryName(categoryId)"
title="@GameInfoExtensions.GetCategoryName(categoryId)"
ObjectFit="@ObjectFit.Contain"
ObjectPosition="@ObjectPosition.Center"
Width="30" />;
@<MudImage Src="@SpriteHelper.GetMoveCategorySpriteFileName(categoryId)"
Alt="@GameInfoExtensions.GetCategoryName(categoryId)"
title="@GameInfoExtensions.GetCategoryName(categoryId)"
ObjectFit="@ObjectFit.Contain"
ObjectPosition="@ObjectPosition.Center"
Width="30"/>;

}
6 changes: 2 additions & 4 deletions Pkmds.Web/Components/BoxComponent.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ namespace Pkmds.Web.Components;

public partial class BoxComponent : IDisposable
{
[Parameter]
public int BoxNumber { get; set; }
[Parameter] public int BoxNumber { get; set; }

private BoxEdit? BoxEdit { get; set; }

Expand Down Expand Up @@ -38,9 +37,8 @@ private void ReloadBox()
return;
}

BoxEdit = new BoxEdit(AppState.SaveFile);
BoxEdit = new(AppState.SaveFile);
BoxEdit.LoadBox(BoxNumber);
RefreshService.Refresh();
}
}

6 changes: 2 additions & 4 deletions Pkmds.Web/Components/BoxGrid.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ namespace Pkmds.Web.Components;

public partial class BoxGrid : IDisposable
{
[Parameter, EditorRequired]
public BoxEdit? BoxEdit { get; set; }
[Parameter, EditorRequired] public BoxEdit? BoxEdit { get; set; }

[Parameter, EditorRequired]
public int BoxNumber { get; set; }
[Parameter, EditorRequired] public int BoxNumber { get; set; }

private string BoxGridClass =>
AppState.SaveFile?.BoxSlotCount == 20 ? "box-grid-20" : "box-grid-30";
Expand Down
3 changes: 1 addition & 2 deletions Pkmds.Web/Components/BoxSlotComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ namespace Pkmds.Web.Components;

public class BoxSlotComponent : PokemonSlotComponent
{
[Parameter, EditorRequired]
public int BoxNumber { get; set; }
[Parameter, EditorRequired] public int BoxNumber { get; set; }
}
42 changes: 19 additions & 23 deletions Pkmds.Web/Components/DateOnlyPicker.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,23 @@ namespace Pkmds.Web.Components;

public partial class DateOnlyPicker
{
[CascadingParameter]
public EditContext? EditContext { get; set; }
[CascadingParameter] public EditContext? EditContext { get; set; }

[Parameter, EditorRequired]
public DateOnly? Date { get; set; }
[Parameter, EditorRequired] public DateOnly? Date { get; set; }

[Parameter]
public EventCallback<DateOnly?> DateChanged { get; set; }
[Parameter] public EventCallback<DateOnly?> DateChanged { get; set; }

[Parameter, EditorRequired]
public string? Label { get; set; }
[Parameter, EditorRequired] public string? Label { get; set; }

[Parameter]
public Expression<Func<DateOnly?>>? For { get; set; }
[Parameter] public Expression<Func<DateOnly?>>? For { get; set; }

[Parameter]
public bool ReadOnly { get; set; }
[Parameter] public bool ReadOnly { get; set; }

[Parameter]
public string? HelperText { get; set; }
[Parameter] public string? HelperText { get; set; }

[Parameter]
public Variant Variant { get; set; } = Variant.Outlined;
[Parameter] public Variant Variant { get; set; } = Variant.Outlined;

[Parameter]
public Color Color { get; set; } = Color.Default;
[Parameter] public Color Color { get; set; } = Color.Default;

private MudDatePicker? datePickerRef;

Expand All @@ -36,11 +27,13 @@ private DateTime? DateBindTarget
get => Date?.ToDateTime(TimeOnly.MinValue);
set
{
if (value is not null)
if (value is null)
{
Date = DateOnly.FromDateTime((DateTime)value);
DateChanged.InvokeAsync(Date);
return;
}

Date = DateOnly.FromDateTime((DateTime)value);
DateChanged.InvokeAsync(Date);
}
}

Expand All @@ -53,11 +46,14 @@ protected override void OnAfterRender(bool firstRender)

if (EditContext is null)
{
throw new Exception("Using 'For' without an 'EditContext' is not supported. Are you missing an 'EditForm'?");
throw new(
"Using 'For' without an 'EditContext' is not supported. Are you missing an 'EditForm'?");
}

// Get the private field _fieldidentifier by reflection.
var fieldIdentifierField = typeof(MudFormComponent<DateTime?, string>).GetField("_fieldIdentifier", BindingFlags.Instance | BindingFlags.NonPublic);
var fieldIdentifierField =
typeof(MudFormComponent<DateTime?, string>).GetField("_fieldIdentifier",
BindingFlags.Instance | BindingFlags.NonPublic);

// Set the field identifier with our DateOnly? expression, avoiding the type issue between DateOnly vs DateTime
fieldIdentifierField?.SetValue(datePickerRef, FieldIdentifier.Create(For));
Expand Down
30 changes: 10 additions & 20 deletions Pkmds.Web/Components/Dialogs/ConfirmActionDialog.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,25 @@ namespace Pkmds.Web.Components.Dialogs;

public partial class ConfirmActionDialog
{
[CascadingParameter]
private MudDialogInstance? MudDialog { get; set; }
[CascadingParameter] private MudDialogInstance? MudDialog { get; set; }

[Parameter]
public string Title { get; set; } = "Confirm Action";
[Parameter] public string Title { get; set; } = "Confirm Action";

[Parameter]
public string Message { get; set; } = "Are you sure you want to perform this action?";
[Parameter] public string Message { get; set; } = "Are you sure you want to perform this action?";

[Parameter]
public string ConfirmText { get; set; } = "Confirm";
[Parameter] public string ConfirmText { get; set; } = "Confirm";

[Parameter]
public string ConfirmIcon { get; set; } = Icons.Material.Filled.Check;
[Parameter] public string ConfirmIcon { get; set; } = Icons.Material.Filled.Check;

[Parameter]
public Color ConfirmColor { get; set; } = Color.Primary;
[Parameter] public Color ConfirmColor { get; set; } = Color.Primary;

[Parameter]
public string CancelText { get; set; } = "Cancel";
[Parameter] public string CancelText { get; set; } = "Cancel";

[Parameter]
public string CancelIcon { get; set; } = Icons.Material.Filled.Clear;
[Parameter] public string CancelIcon { get; set; } = Icons.Material.Filled.Clear;

[Parameter]
public Color CancelColor { get; set; } = Color.Secondary;
[Parameter] public Color CancelColor { get; set; } = Color.Secondary;

[Parameter]
public EventCallback<bool> OnConfirm { get; set; }
[Parameter] public EventCallback<bool> OnConfirm { get; set; }

private void Confirm()
{
Expand Down
10 changes: 5 additions & 5 deletions Pkmds.Web/Components/Dialogs/ShowdownExportDialog.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ namespace Pkmds.Web.Components.Dialogs;

public partial class ShowdownExportDialog
{
[Parameter]
public PKM? Pokemon { get; set; }
[Parameter] public PKM? Pokemon { get; set; }

[CascadingParameter]
private MudDialogInstance? MudDialog { get; set; }
[CascadingParameter] private MudDialogInstance? MudDialog { get; set; }

private string ShowdownExport => Pokemon is not null ? AppService.ExportPokemonAsShowdown(Pokemon) : AppService.ExportPartyAsShowdown();
private string ShowdownExport => Pokemon is not null
? AppService.ExportPokemonAsShowdown(Pokemon)
: AppService.ExportPartyAsShowdown();

private void Close() => MudDialog?.Close();
}
27 changes: 15 additions & 12 deletions Pkmds.Web/Components/EditForms/PokemonEditForm.razor
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
@inherits BasePkmdsComponent

@if (Pokemon is not null &&
AppState.SaveFile is { Context: { } saveFileEntityContext, Generation: { } saveGeneration } saveFile &&
saveFileEntityContext is not
EntityContext.None or
EntityContext.SplitInvalid or
EntityContext.MaxInvalid &&
AppState.SelectedSlotsAreValid)
AppState.SaveFile is
{
Context: not
(EntityContext.None or
EntityContext.SplitInvalid or
EntityContext.MaxInvalid),
Generation: var saveGeneration
} &&
AppState.SelectedSlotsAreValid)
{
<MudStack Row
Justify="@Justify.FlexStart">
Expand Down Expand Up @@ -80,33 +83,33 @@ AppState.SelectedSlotsAreValid)
Border>

<MudTabPanel Text="Main">
<MainTab Pokemon="@Pokemon" />
<MainTab Pokemon="@Pokemon"/>
</MudTabPanel>

@if (saveGeneration >= 2)
{
<MudTabPanel Text="Met">
<MetTab Pokemon="@Pokemon" />
<MetTab Pokemon="@Pokemon"/>
</MudTabPanel>
}

<MudTabPanel Text="Stats">
<StatsTab Pokemon="@Pokemon" />
<StatsTab Pokemon="@Pokemon"/>
</MudTabPanel>

<MudTabPanel Text="Moves">
<MovesTab Pokemon="@Pokemon" />
<MovesTab Pokemon="@Pokemon"/>
</MudTabPanel>

@if (saveGeneration >= 3)
{
<MudTabPanel Text="Cosmetic">
<CosmeticTab Pokemon="@Pokemon" />
<CosmeticTab Pokemon="@Pokemon"/>
</MudTabPanel>
}

<MudTabPanel Text="OT/Misc">
<OtMiscTab Pokemon="@Pokemon" />
<OtMiscTab Pokemon="@Pokemon"/>
</MudTabPanel>

</MudTabs>
Expand Down
Loading
Loading