diff --git a/Program.cs b/Program.cs index 43386d4..0381b92 100644 --- a/Program.cs +++ b/Program.cs @@ -25,7 +25,7 @@ builder.Services.AddControllers(); builder.Services.AddRazorPages() .AddRazorPagesOptions(options => { - options.RootDirectory = "/Admin/Pages"; + options.RootDirectory = "/Services/Admin/Pages"; }); // ---- Session for Admin Auth ---- diff --git a/Services/Admin/Pages/AdminPageModel.cs b/Services/Admin/Pages/AdminPageModel.cs index fbdc161..36aef68 100644 --- a/Services/Admin/Pages/AdminPageModel.cs +++ b/Services/Admin/Pages/AdminPageModel.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace VoidScavengers.Admin.Pages; +namespace VoidScavengers.Services.Admin.Pages; /// /// Base class for all admin pages that require authentication diff --git a/Services/Admin/Pages/Assets/Index.cshtml b/Services/Admin/Pages/Assets/Index.cshtml index 5815f26..5c51bfc 100644 --- a/Services/Admin/Pages/Assets/Index.cshtml +++ b/Services/Admin/Pages/Assets/Index.cshtml @@ -1,210 +1,16 @@ @page "/admin/assets" -@model VoidScavengers.Admin.Pages.Assets.IndexModel +@model Assets.IndexModel @{ ViewData["Title"] = "CDN Assets"; }
-
-
-

CDN Assets

-

Browse and manage assets from your CDN

-
- - - - - Sync from CDN - +
+

CDN Assets

+

Browse assets (@Model.AssetCount total)

- -
-
-
- - - -
-
-

CDN Base URL

-

@Model.CdnBaseUrl

-
-
-

Registered Assets

-

@Model.AssetCount

-
-
-
- - -
-
-
- - -
-
- - -
- - Clear -
-
- - -
- @foreach (var asset in Model.Assets) - { -
-
- @if (asset.AssetType == Server.Data.Entities.ClientAssetType.Texture) - { - @asset.FilePath - - } - else if (asset.AssetType == Server.Data.Entities.ClientAssetType.Scene) - { - - - - } - else if (asset.AssetType == Server.Data.Entities.ClientAssetType.Script) - { - - - - } - else - { - - - - } -
-

@System.IO.Path.GetFileName(asset.FilePath)

-
- } - - @if (!Model.Assets.Any()) - { -
-

No assets found.

-

Assets are registered in the client_assets table.

-
- } -
- - - @if (Model.TotalPages > 1) - { -
-

- Showing @((Model.Page - 1) * Model.PageSize + 1) to @Math.Min(Model.Page * Model.PageSize, Model.TotalCount) of @Model.TotalCount assets -

-
- @if (Model.Page > 1) - { - Previous - } - Page @Model.Page of @Model.TotalPages - @if (Model.Page < Model.TotalPages) - { - Next - } -
-
- } -
- - -
- - -
-
-

CDN Assets

-

@Model.AssetCount assets registered

-
-
-

CDN Base URL: @Model.CdnBaseUrl

- - Browse Assets - -
-
diff --git a/Services/Admin/Pages/Index.cshtml.cs b/Services/Admin/Pages/Index.cshtml.cs index 38a9265..19c05d5 100644 --- a/Services/Admin/Pages/Index.cshtml.cs +++ b/Services/Admin/Pages/Index.cshtml.cs @@ -1,8 +1,7 @@ -using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.EntityFrameworkCore; using Server.Data; -namespace VoidScavengers.Admin.Pages; +namespace VoidScavengers.Services.Admin.Pages; public class IndexModel : AdminPageModel { @@ -17,8 +16,6 @@ public class IndexModel : AdminPageModel public int MobCount { get; set; } public int RecipeCount { get; set; } public int PlayerCount { get; set; } - public int AssetCount { get; set; } - public string CdnBaseUrl { get; set; } = "https://assets.aeternalisgames.com"; public async Task OnGetAsync() { @@ -26,13 +23,5 @@ public class IndexModel : AdminPageModel MobCount = await _db.DungeonMobDefinitions.CountAsync(); RecipeCount = await _db.DungeonCraftingRecipes.CountAsync(); PlayerCount = await _db.Accounts.CountAsync(); - AssetCount = await _db.ClientAssets.CountAsync(); - - // Get CDN URL from environment if set - var cdnUrl = Environment.GetEnvironmentVariable("CDN_BASE_URL"); - if (!string.IsNullOrEmpty(cdnUrl)) - { - CdnBaseUrl = cdnUrl; - } } } diff --git a/Services/Admin/Pages/Items/Edit.cshtml b/Services/Admin/Pages/Items/Edit.cshtml deleted file mode 100644 index 78e0ae1..0000000 --- a/Services/Admin/Pages/Items/Edit.cshtml +++ /dev/null @@ -1,338 +0,0 @@ -@page "/admin/items/edit" -@model VoidScavengers.Admin.Pages.Items.EditModel -@{ - ViewData["Title"] = Model.IsNew ? "Create Item" : $"Edit: {Model.Item.Name}"; -} - -
- -
- - - - - -
-

@(Model.IsNew ? "Create Item" : "Edit Item")

-

@(Model.IsNew ? "Add a new item definition" : $"Editing item #{Model.Item.Id}")

-
-
- - @if (!string.IsNullOrEmpty(Model.Message)) - { -
- @Model.Message -
- } - -
- @Html.AntiForgeryToken() - - - -
-
-

Basic Information

-
-
-
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- -
-
-
- - -
-
-

Stacking

-
-
-
- -
-
- - -
-
-
- - -
-
-

Visual

-
-
-
- -
- - -
-

Path relative to CDN root

-
- -
- -
- -
- - - -
-
-
- -
- -
- - -
-
-
-
- - -
-
-

Stat Requirements

-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - -
-
-

Stat Bonuses (When Equipped)

-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - -
-
-

Combat Stats

-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - -
-
-

Consumable Effects

-
-
-
- - -
-
- - -
-
- - -
-
-
- - -
- - Cancel - - @if (!Model.IsNew) - { -
- - } -
-
-
- -@section Scripts { - -} diff --git a/Services/Admin/Pages/Items/Edit.cshtml.cs b/Services/Admin/Pages/Items/Edit.cshtml.cs deleted file mode 100644 index 3418e6c..0000000 --- a/Services/Admin/Pages/Items/Edit.cshtml.cs +++ /dev/null @@ -1,180 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using Server.Data; -using Server.Data.Entities; - -namespace VoidScavengers.Admin.Pages.Items; - -public class EditModel : AdminPageModel -{ - private readonly GameDbContext _db; - - public EditModel(GameDbContext db) - { - _db = db; - } - - [BindProperty] - public DungeonItemDefinition Item { get; set; } = new(); - - public bool IsNew => Item.Id == 0; - public string? Message { get; set; } - public bool IsError { get; set; } - public string CdnBaseUrl { get; set; } = "https://assets.aeternalisgames.com"; - - public async Task OnGetAsync(int? id) - { - // Get CDN URL from environment - var cdnUrl = Environment.GetEnvironmentVariable("CDN_BASE_URL"); - if (!string.IsNullOrEmpty(cdnUrl)) - { - CdnBaseUrl = cdnUrl; - } - - if (id.HasValue) - { - var item = await _db.DungeonItemDefinitions.FindAsync(id.Value); - if (item != null) - { - Item = item; - } - } - else - { - // Set defaults for new item - Item.IsEnabled = true; - Item.RequiredLevel = 1; - Item.MaxStack = 1; - } - } - - public async Task OnPostAsync(string? action) - { - // Get CDN URL from environment - var cdnUrl = Environment.GetEnvironmentVariable("CDN_BASE_URL"); - if (!string.IsNullOrEmpty(cdnUrl)) - { - CdnBaseUrl = cdnUrl; - } - - if (!ModelState.IsValid) - { - Message = "Please fix the errors below."; - IsError = true; - return Page(); - } - - try - { - if (action == "duplicate") - { - // Create a duplicate - var newItem = new DungeonItemDefinition - { - Name = Item.Name + " (Copy)", - Description = Item.Description, - Type = Item.Type, - Rarity = Item.Rarity, - EquipSlot = Item.EquipSlot, - RequiredStrength = Item.RequiredStrength, - RequiredIntelligence = Item.RequiredIntelligence, - RequiredWisdom = Item.RequiredWisdom, - RequiredDexterity = Item.RequiredDexterity, - RequiredLevel = Item.RequiredLevel, - BonusStrength = Item.BonusStrength, - BonusIntelligence = Item.BonusIntelligence, - BonusWisdom = Item.BonusWisdom, - BonusEndurance = Item.BonusEndurance, - BonusDexterity = Item.BonusDexterity, - BonusHealth = Item.BonusHealth, - BonusMana = Item.BonusMana, - MinDamage = Item.MinDamage, - MaxDamage = Item.MaxDamage, - AttackRange = Item.AttackRange, - DamageType = Item.DamageType, - Armor = Item.Armor, - MagicResist = Item.MagicResist, - HealAmount = Item.HealAmount, - ManaRestore = Item.ManaRestore, - StaminaRestore = Item.StaminaRestore, - Stackable = Item.Stackable, - MaxStack = Item.MaxStack, - SpritePath = Item.SpritePath, - TintColor = Item.TintColor, - IsEnabled = Item.IsEnabled - }; - - _db.DungeonItemDefinitions.Add(newItem); - await _db.SaveChangesAsync(); - - return RedirectToPage("/Items/Edit", new { id = newItem.Id }); - } - - if (Item.Id == 0) - { - // Create new - _db.DungeonItemDefinitions.Add(Item); - await _db.SaveChangesAsync(); - - Message = $"Item '{Item.Name}' created successfully with ID {Item.Id}"; - return RedirectToPage("/Items/Edit", new { id = Item.Id }); - } - else - { - // Update existing - var existing = await _db.DungeonItemDefinitions.FindAsync(Item.Id); - if (existing == null) - { - Message = "Item not found."; - IsError = true; - return Page(); - } - - // Update all properties - existing.Name = Item.Name; - existing.Description = Item.Description; - existing.Type = Item.Type; - existing.Rarity = Item.Rarity; - existing.EquipSlot = Item.EquipSlot; - existing.RequiredStrength = Item.RequiredStrength; - existing.RequiredIntelligence = Item.RequiredIntelligence; - existing.RequiredWisdom = Item.RequiredWisdom; - existing.RequiredDexterity = Item.RequiredDexterity; - existing.RequiredLevel = Item.RequiredLevel; - existing.BonusStrength = Item.BonusStrength; - existing.BonusIntelligence = Item.BonusIntelligence; - existing.BonusWisdom = Item.BonusWisdom; - existing.BonusEndurance = Item.BonusEndurance; - existing.BonusDexterity = Item.BonusDexterity; - existing.BonusHealth = Item.BonusHealth; - existing.BonusMana = Item.BonusMana; - existing.MinDamage = Item.MinDamage; - existing.MaxDamage = Item.MaxDamage; - existing.AttackRange = Item.AttackRange; - existing.DamageType = Item.DamageType; - existing.Armor = Item.Armor; - existing.MagicResist = Item.MagicResist; - existing.HealAmount = Item.HealAmount; - existing.ManaRestore = Item.ManaRestore; - existing.StaminaRestore = Item.StaminaRestore; - existing.Stackable = Item.Stackable; - existing.MaxStack = Item.MaxStack; - existing.SpritePath = Item.SpritePath; - existing.TintColor = Item.TintColor; - existing.IsEnabled = Item.IsEnabled; - - await _db.SaveChangesAsync(); - - Item = existing; - Message = "Changes saved successfully."; - } - } - catch (Exception ex) - { - Message = $"Error saving item: {ex.Message}"; - IsError = true; - } - - return Page(); - } -} diff --git a/Services/Admin/Pages/Items/Index.cshtml b/Services/Admin/Pages/Items/Index.cshtml index a5a5f68..9b8f700 100644 --- a/Services/Admin/Pages/Items/Index.cshtml +++ b/Services/Admin/Pages/Items/Index.cshtml @@ -1,15 +1,14 @@ @page "/admin/items" -@model VoidScavengers.Admin.Pages.Items.IndexModel +@model Items.IndexModel @{ ViewData["Title"] = "Items"; }
-

Items

-

Manage item definitions

+

Manage item definitions (@Model.ItemCount total)

@@ -19,196 +18,7 @@
- -
-
-
- - -
-
- - -
-
- - -
- - Clear -
-
- - -
- - - - - - - - - - - - - - - @foreach (var item in Model.Items) - { - - - - - - - - - - - } - - @if (!Model.Items.Any()) - { - - - - } - -
IDIconNameTypeRarityStackableEnabledActions
@item.Id - @if (!string.IsNullOrEmpty(item.SpritePath)) - { - @item.Name - } - else - { -
- - - -
- } -
@item.Name@item.Type - @item.Rarity - - @if (item.Stackable) - { - Yes (@item.MaxStack) - } - else - { - No - } - - @if (item.IsEnabled) - { - - - - - Yes - - } - else - { - - - - - No - - } - -
- - - - - - -
-
- No items found. - Create one? -
-
- - - @if (Model.TotalPages > 1) - { -
-

- Showing @((Model.Page - 1) * Model.PageSize + 1) to @Math.Min(Model.Page * Model.PageSize, Model.TotalCount) of @Model.TotalCount items -

-
- @if (Model.Page > 1) - { - Previous - } - Page @Model.Page of @Model.TotalPages - @if (Model.Page < Model.TotalPages) - { - Next - } -
-
- } -
- - - diff --git a/Services/Admin/Pages/Mobs/Index.cshtml.cs b/Services/Admin/Pages/Mobs/Index.cshtml.cs index 038f047..61bea18 100644 --- a/Services/Admin/Pages/Mobs/Index.cshtml.cs +++ b/Services/Admin/Pages/Mobs/Index.cshtml.cs @@ -1,7 +1,7 @@ using Microsoft.EntityFrameworkCore; using Server.Data; -namespace VoidScavengers.Admin.Pages.Mobs; +namespace VoidScavengers.Services.Admin.Pages.Mobs; public class IndexModel : AdminPageModel { diff --git a/Services/Admin/Pages/Players/Index.cshtml b/Services/Admin/Pages/Players/Index.cshtml index 0f9ea65..37795c9 100644 --- a/Services/Admin/Pages/Players/Index.cshtml +++ b/Services/Admin/Pages/Players/Index.cshtml @@ -1,5 +1,5 @@ @page "/admin/players" -@model VoidScavengers.Admin.Pages.Players.IndexModel +@model Players.IndexModel @{ ViewData["Title"] = "Players"; } @@ -7,11 +7,10 @@

Players

-

Manage player accounts

+

Manage player accounts (@Model.PlayerCount total)

-

@Model.PlayerCount registered accounts

-

Full player management coming soon...

+

Player management coming soon...

diff --git a/Services/Admin/Pages/Players/Index.cshtml.cs b/Services/Admin/Pages/Players/Index.cshtml.cs index 2b8a08c..27767e5 100644 --- a/Services/Admin/Pages/Players/Index.cshtml.cs +++ b/Services/Admin/Pages/Players/Index.cshtml.cs @@ -1,7 +1,7 @@ using Microsoft.EntityFrameworkCore; using Server.Data; -namespace VoidScavengers.Admin.Pages.Players; +namespace VoidScavengers.Services.Admin.Pages.Players; public class IndexModel : AdminPageModel { diff --git a/Services/Admin/Pages/Recipes/Index.cshtml b/Services/Admin/Pages/Recipes/Index.cshtml index e7b8329..d1ea246 100644 --- a/Services/Admin/Pages/Recipes/Index.cshtml +++ b/Services/Admin/Pages/Recipes/Index.cshtml @@ -1,5 +1,5 @@ @page "/admin/recipes" -@model VoidScavengers.Admin.Pages.Recipes.IndexModel +@model Recipes.IndexModel @{ ViewData["Title"] = "Recipes"; } @@ -8,7 +8,7 @@
-

@Model.RecipeCount recipes defined

-

Full recipe editor coming soon...

+

Recipe editor coming soon...

diff --git a/Services/Admin/Pages/Recipes/Index.cshtml.cs b/Services/Admin/Pages/Recipes/Index.cshtml.cs index 17c4e67..7f14ba4 100644 --- a/Services/Admin/Pages/Recipes/Index.cshtml.cs +++ b/Services/Admin/Pages/Recipes/Index.cshtml.cs @@ -1,7 +1,7 @@ using Microsoft.EntityFrameworkCore; using Server.Data; -namespace VoidScavengers.Admin.Pages.Recipes; +namespace VoidScavengers.Services.Admin.Pages.Recipes; public class IndexModel : AdminPageModel { diff --git a/Services/Admin/Pages/_ViewImports.cshtml b/Services/Admin/Pages/_ViewImports.cshtml index 712017f..009f46d 100644 --- a/Services/Admin/Pages/_ViewImports.cshtml +++ b/Services/Admin/Pages/_ViewImports.cshtml @@ -1,2 +1,2 @@ -@namespace VoidScavengers.Admin.Pages +@namespace VoidScavengers.Services.Admin.Pages @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers