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
|
||||
@implements IDisposable
|
||||
|
||||
<MudThemeProvider/>
|
||||
|
||||
<MudThemeProvider @ref="@_mudThemeProvider" @bind-IsDarkMode="@_isDarkMode"/>
|
||||
<MudPopoverProvider/>
|
||||
<MudDialogProvider/>
|
||||
<MudSnackbarProvider/>
|
||||
@@ -75,9 +76,6 @@
|
||||
</MudLayout>
|
||||
|
||||
|
||||
<MudThemeProvider @ref="@_mudThemeProvider" @bind-IsDarkMode="@_isDarkMode"/>
|
||||
<MudDialogProvider/>
|
||||
<MudSnackbarProvider/>
|
||||
|
||||
@code {
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
@layout PageLayout
|
||||
|
||||
@using IGP.Pages.DataTables.Parts
|
||||
@inherits BasePage
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
<h3>WeaponTable</h3>
|
||||
|
||||
|
||||
<MudDataGrid Items="@_entityWeapons" SortMode="SortMode.Multiple" Filterable="true">
|
||||
<MudDataGrid T="EntityWeaponModel" Items="@_entityWeapons"
|
||||
SortMode="SortMode.Multiple"
|
||||
Filterable="true"
|
||||
Hideable="true">
|
||||
<Columns>
|
||||
<PropertyColumn Property="x => x.Range" Title="Range"/>
|
||||
<PropertyColumn Property="x => x.Damage" Title="Damage"/>
|
||||
@@ -10,60 +13,18 @@
|
||||
<PropertyColumn Property="x => x.DamagePerSecondLight()" Title="DPS (Light)"/>
|
||||
<PropertyColumn Property="x => x.DamagePerSecondMedium()" Title="DPS (Medium)"/>
|
||||
<PropertyColumn Property="x => x.DamagePerSecondHeavy()" Title="DPS (Heavy)"/>
|
||||
|
||||
|
||||
<PropertyColumn Property="x => x.Parent.GetName()" Title="Owner Name"/>
|
||||
|
||||
<PropertyColumn Property="x => x.Parent.GetFaction()" Title="Faction"/>
|
||||
<PropertyColumn Property="x => x.Parent.GetImmortal()" Title="Immortal"/>
|
||||
</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>
|
||||
<MudDataGridPager T="Element" />
|
||||
<MudDataGridPager T="EntityWeaponModel" />
|
||||
</PagerContent>
|
||||
</MudDataGrid>
|
||||
|
||||
|
||||
<div class="d-flex flex-wrap mt-4">
|
||||
<MudSwitch @bind-Value="@_sortNameByLength" Color="Color.Primary">Sort Name Column By Length</MudSwitch>
|
||||
</div>
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@code {
|
||||
List<EntityWeaponModel> _entityWeapons;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
|
||||
_entityWeapons = DATA.Get()
|
||||
IEnumerable<EntityWeaponModel> _entityWeapons = DATA.Get()
|
||||
.SelectMany(e => e.Value.EntityParts)
|
||||
.OfType<EntityWeaponModel>()
|
||||
.ToList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Blazor.Analytics;
|
||||
using Blazored.LocalStorage;
|
||||
using IGP;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
@@ -39,12 +38,6 @@ builder.Services.AddBlazoredLocalStorageAsSingleton(config =>
|
||||
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<IKeyService, KeyService>();
|
||||
builder.Services.AddScoped<IImmortalSelectionService, ImmortalSelectionService>();
|
||||
@@ -79,12 +72,6 @@ builder.Services.AddScoped(sp => new HttpClient
|
||||
|
||||
builder.Services.AddMudServices();
|
||||
|
||||
#if NO_SQL
|
||||
|
||||
#else
|
||||
//builder.Services.AddDbContext<DatabaseContext>(options => { options.UseSqlite("Data Source=./Database.db"); });
|
||||
#endif
|
||||
|
||||
|
||||
await builder.Build().RunAsync();
|
||||
|
||||
|
||||
@@ -1376,7 +1376,8 @@ public class DATA
|
||||
.AddPart(new EntityMovementModel { Speed = 532, Movement = MovementType.Air })
|
||||
.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 =
|
||||
TargetType.Air
|
||||
})
|
||||
@@ -3656,7 +3657,7 @@ public class DATA
|
||||
Description = "Passively harvest pyre.",
|
||||
Notes = ""
|
||||
})
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -47,13 +47,16 @@ public class EntityModel
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,52 +12,6 @@ public class EntityWeaponModel : IEntityPartInterface
|
||||
public float AttacksPerSecond { 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 Charges { get; set; } = 0;
|
||||
|
||||
@@ -77,4 +31,38 @@ public class EntityWeaponModel : IEntityPartInterface
|
||||
public int EthericDamageBonus { get; set; } = 0;
|
||||
public string Targets { get; set; } = TargetType.All;
|
||||
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