75 lines
2.6 KiB
Text
75 lines
2.6 KiB
Text
@inject GameService GameService
|
|
|
|
<Flex Vertical Gap="FlexGap.Large">
|
|
<Table TItem="SavePath" DataSource="@SavePaths" HidePagination="true" Responsive>
|
|
<PropertyColumn Property="p => p.Type">
|
|
<Select @bind-Value="context.Type" TItem="SavePathType" TItemValue="SavePathType" DataSource="Enum.GetValues<SavePathType>()">
|
|
<LabelTemplate Context="Value">@Value.GetDisplayName()</LabelTemplate>
|
|
<ItemTemplate Context="Value">@Value.GetDisplayName()</ItemTemplate>
|
|
</Select>
|
|
</PropertyColumn>
|
|
<PropertyColumn Property="p => p.Path">
|
|
@if (context.Type == SavePathType.Registry)
|
|
{
|
|
<InputRegistry @bind-Value="context.Path" />
|
|
}
|
|
else
|
|
{
|
|
<FilePicker @bind-Value="context.Path" ArchiveId="@ArchiveId" AllowDirectories="true" />
|
|
}
|
|
</PropertyColumn>
|
|
<PropertyColumn Property="p => p.WorkingDirectory" Title="Working Directory">
|
|
<Input @bind-Value="context.WorkingDirectory" Disabled="@(context.Type == SavePathType.Registry)" />
|
|
</PropertyColumn>
|
|
<PropertyColumn Property="p => p.IsRegex" Title="Regex">
|
|
<Checkbox @bind-Checked="context.IsRegex" Disabled="@(context.Type == SavePathType.Registry)" />
|
|
</PropertyColumn>
|
|
<ActionColumn>
|
|
<Flex Gap="FlexGap.Small" Justify="FlexJustify.End">
|
|
<Button OnClick="() => RemovePath(context)" Type="@ButtonType.Text" Danger Icon="@IconType.Outline.Close" />
|
|
</Flex>
|
|
</ActionColumn>
|
|
</Table>
|
|
|
|
<Flex Justify="FlexJustify.End">
|
|
<Button OnClick="AddPath" Type="@ButtonType.Primary">Add Path</Button>
|
|
</Flex>
|
|
</Flex>
|
|
|
|
@code {
|
|
[Parameter] public Guid GameId { get; set; }
|
|
[Parameter] public Guid ArchiveId { get; set; }
|
|
|
|
ICollection<SavePath> SavePaths = new List<SavePath>();
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
var game = await GameService.Include(g => g.SavePaths).GetAsync(GameId);
|
|
|
|
if (game.SavePaths != null)
|
|
SavePaths = game.SavePaths;
|
|
}
|
|
|
|
async Task AddPath()
|
|
{
|
|
SavePaths.Add(new SavePath()
|
|
{
|
|
GameId = GameId,
|
|
WorkingDirectory = "{InstallDir}"
|
|
});
|
|
}
|
|
|
|
async Task RemovePath(SavePath path)
|
|
{
|
|
SavePaths.Remove(path);
|
|
}
|
|
|
|
public async Task Save()
|
|
{
|
|
var game = await GameService.Include(g => g.SavePaths).GetAsync(GameId);
|
|
|
|
game.SavePaths = SavePaths;
|
|
|
|
await GameService.UpdateAsync(game);
|
|
}
|
|
}
|