Refactor DataTables and cleanup redundant code
Refactored `WeaponTable` grid to use a typed parameter and improve readability. Removed outdated or unnecessary sample comments, consolidated duplicate code, and reorganized theme-related components in `PageLayout`. Simplified initialization logic and improved formatting consistency.
This commit is contained in:
@@ -6,7 +6,8 @@
|
|||||||
@using Services.Website
|
@using Services.Website
|
||||||
@implements IDisposable
|
@implements IDisposable
|
||||||
|
|
||||||
<MudThemeProvider/>
|
|
||||||
|
<MudThemeProvider @ref="@_mudThemeProvider" @bind-IsDarkMode="@_isDarkMode"/>
|
||||||
<MudPopoverProvider/>
|
<MudPopoverProvider/>
|
||||||
<MudDialogProvider/>
|
<MudDialogProvider/>
|
||||||
<MudSnackbarProvider/>
|
<MudSnackbarProvider/>
|
||||||
@@ -75,9 +76,6 @@
|
|||||||
</MudLayout>
|
</MudLayout>
|
||||||
|
|
||||||
|
|
||||||
<MudThemeProvider @ref="@_mudThemeProvider" @bind-IsDarkMode="@_isDarkMode"/>
|
|
||||||
<MudDialogProvider/>
|
|
||||||
<MudSnackbarProvider/>
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
@layout PageLayout
|
@layout PageLayout
|
||||||
|
|
||||||
@using IGP.Pages.DataTables.Parts
|
@using IGP.Pages.DataTables.Parts
|
||||||
@inherits BasePage
|
@inherits BasePage
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
<h3>WeaponTable</h3>
|
<h3>WeaponTable</h3>
|
||||||
|
|
||||||
|
|
||||||
<MudDataGrid Items="@_entityWeapons" SortMode="SortMode.Multiple" Filterable="true">
|
<MudDataGrid T="EntityWeaponModel" Items="@_entityWeapons"
|
||||||
|
SortMode="SortMode.Multiple"
|
||||||
|
Filterable="true"
|
||||||
|
Hideable="true">
|
||||||
<Columns>
|
<Columns>
|
||||||
<PropertyColumn Property="x => x.Range" Title="Range"/>
|
<PropertyColumn Property="x => x.Range" Title="Range"/>
|
||||||
<PropertyColumn Property="x => x.Damage" Title="Damage"/>
|
<PropertyColumn Property="x => x.Damage" Title="Damage"/>
|
||||||
@@ -10,60 +13,18 @@
|
|||||||
<PropertyColumn Property="x => x.DamagePerSecondLight()" Title="DPS (Light)"/>
|
<PropertyColumn Property="x => x.DamagePerSecondLight()" Title="DPS (Light)"/>
|
||||||
<PropertyColumn Property="x => x.DamagePerSecondMedium()" Title="DPS (Medium)"/>
|
<PropertyColumn Property="x => x.DamagePerSecondMedium()" Title="DPS (Medium)"/>
|
||||||
<PropertyColumn Property="x => x.DamagePerSecondHeavy()" Title="DPS (Heavy)"/>
|
<PropertyColumn Property="x => x.DamagePerSecondHeavy()" Title="DPS (Heavy)"/>
|
||||||
|
|
||||||
|
|
||||||
<PropertyColumn Property="x => x.Parent.GetName()" Title="Owner Name"/>
|
<PropertyColumn Property="x => x.Parent.GetName()" Title="Owner Name"/>
|
||||||
|
|
||||||
<PropertyColumn Property="x => x.Parent.GetFaction()" Title="Faction"/>
|
<PropertyColumn Property="x => x.Parent.GetFaction()" Title="Faction"/>
|
||||||
<PropertyColumn Property="x => x.Parent.GetImmortal()" Title="Immortal"/>
|
<PropertyColumn Property="x => x.Parent.GetImmortal()" Title="Immortal"/>
|
||||||
</Columns>
|
</Columns>
|
||||||
</MudDataGrid>
|
|
||||||
|
|
||||||
@{
|
|
||||||
/**
|
|
||||||
|
|
||||||
<MudDataGrid T="Element" MultiSelection="true" Items="@Elements" SortMode="SortMode.Multiple" Filterable="true" QuickFilter="@_quickFilter"
|
|
||||||
Hideable="true" RowClick="@RowClicked" RowContextMenuClick="RowRightClicked" SelectedItemsChanged="@SelectedItemsChanged">
|
|
||||||
<ToolBarContent>
|
|
||||||
<MudText Typo="Typo.h6">Periodic Elements</MudText>
|
|
||||||
<MudSpacer />
|
|
||||||
<MudTextField @bind-Value="_searchString" Placeholder="Search" Adornment="Adornment.Start" Immediate="true"
|
|
||||||
AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0"></MudTextField>
|
|
||||||
</ToolBarContent>
|
|
||||||
<Columns>
|
|
||||||
<SelectColumn T="Element" />
|
|
||||||
<PropertyColumn Property="x => x.Number" Title="Nr" Sortable="false" Filterable="false" />
|
|
||||||
<PropertyColumn Property="x => x.Sign" />
|
|
||||||
<PropertyColumn Property="x => x.Name" SortBy="@_sortBy" />
|
|
||||||
<PropertyColumn Property="x => x.Position" />
|
|
||||||
<PropertyColumn Property="x => x.Molar" Title="Molar mass" />
|
|
||||||
<PropertyColumn Property="x => x.Group" Title="Category" />
|
|
||||||
</Columns>
|
|
||||||
<PagerContent>
|
<PagerContent>
|
||||||
<MudDataGridPager T="Element" />
|
<MudDataGridPager T="EntityWeaponModel" />
|
||||||
</PagerContent>
|
</PagerContent>
|
||||||
</MudDataGrid>
|
</MudDataGrid>
|
||||||
|
|
||||||
|
|
||||||
<div class="d-flex flex-wrap mt-4">
|
|
||||||
<MudSwitch @bind-Value="@_sortNameByLength" Color="Color.Primary">Sort Name Column By Length</MudSwitch>
|
|
||||||
</div>
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
List<EntityWeaponModel> _entityWeapons;
|
IEnumerable<EntityWeaponModel> _entityWeapons = DATA.Get()
|
||||||
|
|
||||||
protected override void OnInitialized()
|
|
||||||
{
|
|
||||||
base.OnInitialized();
|
|
||||||
|
|
||||||
_entityWeapons = DATA.Get()
|
|
||||||
.SelectMany(e => e.Value.EntityParts)
|
.SelectMany(e => e.Value.EntityParts)
|
||||||
.OfType<EntityWeaponModel>()
|
.OfType<EntityWeaponModel>()
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using Blazor.Analytics;
|
|
||||||
using Blazored.LocalStorage;
|
using Blazored.LocalStorage;
|
||||||
using IGP;
|
using IGP;
|
||||||
using Microsoft.AspNetCore.Components.Web;
|
using Microsoft.AspNetCore.Components.Web;
|
||||||
@@ -39,12 +38,6 @@ builder.Services.AddBlazoredLocalStorageAsSingleton(config =>
|
|||||||
config.JsonSerializerOptions.WriteIndented = false;
|
config.JsonSerializerOptions.WriteIndented = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
builder.Services.AddGoogleAnalytics("G-S96LW7TVFY");
|
|
||||||
#else
|
|
||||||
builder.Services.AddGoogleAnalytics(builder.Configuration["GATag"]);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
builder.Services.AddScoped<INavigationService, NavigationService>();
|
builder.Services.AddScoped<INavigationService, NavigationService>();
|
||||||
builder.Services.AddScoped<IKeyService, KeyService>();
|
builder.Services.AddScoped<IKeyService, KeyService>();
|
||||||
builder.Services.AddScoped<IImmortalSelectionService, ImmortalSelectionService>();
|
builder.Services.AddScoped<IImmortalSelectionService, ImmortalSelectionService>();
|
||||||
@@ -79,12 +72,6 @@ builder.Services.AddScoped(sp => new HttpClient
|
|||||||
|
|
||||||
builder.Services.AddMudServices();
|
builder.Services.AddMudServices();
|
||||||
|
|
||||||
#if NO_SQL
|
|
||||||
|
|
||||||
#else
|
|
||||||
//builder.Services.AddDbContext<DatabaseContext>(options => { options.UseSqlite("Data Source=./Database.db"); });
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
await builder.Build().RunAsync();
|
await builder.Build().RunAsync();
|
||||||
|
|
||||||
|
|||||||
@@ -1376,7 +1376,8 @@ public class DATA
|
|||||||
.AddPart(new EntityMovementModel { Speed = 532, Movement = MovementType.Air })
|
.AddPart(new EntityMovementModel { Speed = 532, Movement = MovementType.Air })
|
||||||
.AddPart(new EntityWeaponModel
|
.AddPart(new EntityWeaponModel
|
||||||
{
|
{
|
||||||
Damage = 100, LightDamage = 100, MediumDamage = 130, HeavyDamage = 160, Range = 20, AttacksPerSecond = 1,
|
Damage = 100, LightDamage = 100, MediumDamage = 130, HeavyDamage = 160, Range = 20,
|
||||||
|
AttacksPerSecond = 1,
|
||||||
Targets =
|
Targets =
|
||||||
TargetType.Air
|
TargetType.Air
|
||||||
})
|
})
|
||||||
@@ -3656,7 +3657,7 @@ public class DATA
|
|||||||
Description = "Passively harvest pyre.",
|
Description = "Passively harvest pyre.",
|
||||||
Notes = ""
|
Notes = ""
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,13 +47,16 @@ public class EntityModel
|
|||||||
|
|
||||||
public string GetFaction()
|
public string GetFaction()
|
||||||
{
|
{
|
||||||
var entityInfo = EntityParts.FirstOrDefault(a => a.GetType() == typeof(EntityFactionModel)) as EntityFactionModel;
|
var entityInfo =
|
||||||
|
EntityParts.FirstOrDefault(a => a.GetType() == typeof(EntityFactionModel)) as EntityFactionModel;
|
||||||
return entityInfo == null ? string.Empty : DATA.Get()[entityInfo.Faction].GetName();
|
return entityInfo == null ? string.Empty : DATA.Get()[entityInfo.Faction].GetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetImmortal()
|
public string GetImmortal()
|
||||||
{
|
{
|
||||||
var entityInfo = EntityParts.FirstOrDefault(a => a.GetType() == typeof(EntityVanguardAddedModel)) as EntityVanguardAddedModel;
|
var entityInfo =
|
||||||
|
EntityParts.FirstOrDefault(a =>
|
||||||
|
a.GetType() == typeof(EntityVanguardAddedModel)) as EntityVanguardAddedModel;
|
||||||
return entityInfo == null ? string.Empty : DATA.Get()[entityInfo.ImmortalId].GetName();
|
return entityInfo == null ? string.Empty : DATA.Get()[entityInfo.ImmortalId].GetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,52 +12,6 @@ public class EntityWeaponModel : IEntityPartInterface
|
|||||||
public float AttacksPerSecond { get; set; } = 0;
|
public float AttacksPerSecond { get; set; } = 0;
|
||||||
public float SecondsBetweenAttacks { get; set; } = 0;
|
public float SecondsBetweenAttacks { get; set; } = 0;
|
||||||
|
|
||||||
public float DamagePerSecond()
|
|
||||||
{
|
|
||||||
if (SecondsBetweenAttacks == 0)
|
|
||||||
{
|
|
||||||
return Damage * AttacksPerSecond;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Damage / SecondsBetweenAttacks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float DamagePerSecondLight()
|
|
||||||
{
|
|
||||||
var damage = LightDamage != 0 ? LightDamage : Damage;
|
|
||||||
|
|
||||||
if (SecondsBetweenAttacks == 0)
|
|
||||||
{
|
|
||||||
return damage * AttacksPerSecond;
|
|
||||||
}
|
|
||||||
|
|
||||||
return damage / SecondsBetweenAttacks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float DamagePerSecondMedium()
|
|
||||||
{
|
|
||||||
var damage = MediumDamage != 0 ? MediumDamage : Damage;
|
|
||||||
|
|
||||||
if (SecondsBetweenAttacks == 0)
|
|
||||||
{
|
|
||||||
return damage * AttacksPerSecond;
|
|
||||||
}
|
|
||||||
|
|
||||||
return damage / SecondsBetweenAttacks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float DamagePerSecondHeavy()
|
|
||||||
{
|
|
||||||
var damage = HeavyDamage != 0 ? HeavyDamage : Damage;
|
|
||||||
|
|
||||||
if (SecondsBetweenAttacks == 0)
|
|
||||||
{
|
|
||||||
return damage * AttacksPerSecond;
|
|
||||||
}
|
|
||||||
|
|
||||||
return damage / SecondsBetweenAttacks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float Cooldown { get; set; } = 0;
|
public float Cooldown { get; set; } = 0;
|
||||||
public float Charges { get; set; } = 0;
|
public float Charges { get; set; } = 0;
|
||||||
|
|
||||||
@@ -77,4 +31,38 @@ public class EntityWeaponModel : IEntityPartInterface
|
|||||||
public int EthericDamageBonus { get; set; } = 0;
|
public int EthericDamageBonus { get; set; } = 0;
|
||||||
public string Targets { get; set; } = TargetType.All;
|
public string Targets { get; set; } = TargetType.All;
|
||||||
public string Attack { get; set; } = AttackType.DPS;
|
public string Attack { get; set; } = AttackType.DPS;
|
||||||
|
|
||||||
|
public float DamagePerSecond()
|
||||||
|
{
|
||||||
|
if (SecondsBetweenAttacks == 0) return Damage * AttacksPerSecond;
|
||||||
|
|
||||||
|
return Damage / SecondsBetweenAttacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float DamagePerSecondLight()
|
||||||
|
{
|
||||||
|
var damage = LightDamage != 0 ? LightDamage : Damage;
|
||||||
|
|
||||||
|
if (SecondsBetweenAttacks == 0) return damage * AttacksPerSecond;
|
||||||
|
|
||||||
|
return damage / SecondsBetweenAttacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float DamagePerSecondMedium()
|
||||||
|
{
|
||||||
|
var damage = MediumDamage != 0 ? MediumDamage : Damage;
|
||||||
|
|
||||||
|
if (SecondsBetweenAttacks == 0) return damage * AttacksPerSecond;
|
||||||
|
|
||||||
|
return damage / SecondsBetweenAttacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float DamagePerSecondHeavy()
|
||||||
|
{
|
||||||
|
var damage = HeavyDamage != 0 ? HeavyDamage : Damage;
|
||||||
|
|
||||||
|
if (SecondsBetweenAttacks == 0) return damage * AttacksPerSecond;
|
||||||
|
|
||||||
|
return damage / SecondsBetweenAttacks;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user