Skip to content

Commit

Permalink
Few more items; pages can now set their own title suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
qkmaxware committed Apr 30, 2021
1 parent cba268b commit 94e923f
Show file tree
Hide file tree
Showing 29 changed files with 66 additions and 19 deletions.
1 change: 1 addition & 0 deletions TrekSharp.AdventureTools/Pages/ComputeStardate.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/calculate/stardate"
@inherits Page

<LCARS Title="STARDATE">
<div class="w3-panel typeface">
Expand Down
1 change: 1 addition & 0 deletions TrekSharp.AdventureTools/Pages/ComputeWarp.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@page "/calculate/warpspeed"
@using Qkmaxware.Astro
@inherits Page

<LCARS title="WARP SPEED">
<div class="row">
Expand Down
1 change: 1 addition & 0 deletions TrekSharp.AdventureTools/Pages/CreateBattleGrid.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/new/grid"
@inherits Page

<div class="lcars no-print">
<div class="container">
Expand Down
1 change: 1 addition & 0 deletions TrekSharp.AdventureTools/Pages/CreateCustomData.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/new/custom"
@inherits Page

<LCARS Title="CUSTOM DATA">
<div class="w3-panel typeface">
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/CreateItem.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/new/custom/item"
@inherits AppComponentBase
@inherits Page

<LCARS Title="NEW ITEM">
<div class="w3-panel typeface">
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/CreateNpcType.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@page "/new/custom/npc"
@using Data
@inherits AppComponentBase
@inherits Page

<LCARS Title="NEW NPC TYPE">
<div class="w3-panel typeface">
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/CreatePlayer.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@page "/new/player/lifepath"
@using System.Globalization

@inherits AppComponentBase
@inherits Page
@inject IJSRuntime JsRuntime

<LCARS Title="NEW PLAYER">
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/CreatePlotWriter.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/new/plot/writer"
@inject AppData Data
@inherits Page

<PrintNotification/>

Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/CreateRandomPlayer.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/new/player/random"
@inherits AppComponentBase
@inherits Page

<LCARS Title="RANDOM PLAYER">
<div class="w3-panel typeface">
Expand Down
1 change: 1 addition & 0 deletions TrekSharp.AdventureTools/Pages/CreateShip.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/new/ship"
@inherits Page

<LCARS Title="NEW SHIP">
<div class="w3-panel typeface">
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/CreateSpecies.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/new/custom/species"
@inherits AppComponentBase
@inherits Page

<LCARS Title="NEW SPECIES">
<div class="w3-panel typeface">
Expand Down
1 change: 1 addition & 0 deletions TrekSharp.AdventureTools/Pages/CreateSupport.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/new/support"
@inherits Page

<LCARS Title="NEW SUPPORT CHARACTER">
<div class="w3-panel typeface">
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/"
@inherits AppComponentBase
@inherits Page

<div class="w3-container">

Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/ManageCharacters.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/manage/characters"
@inherits AppComponentBase
@inherits Page
@using Data

<div class="lcars">
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/ManageCustom.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/manage/custom"
@inherits AppComponentBase
@inherits Page

<LCARS Title="CUSTOM SPECIES">
@if (Data.Custom != null && Data.Custom.Species != null && Data.Custom.Species.Definitions != null) {
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/ManageEncounter.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@page "/manage/encounters"
@using System.Globalization
@using Data
@inherits AppComponentBase
@inherits Page

<LCARS Title="SAVED ENCOUNTERS">
<div style="overflow: auto; white-space: nowrap;">
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/ManageExtendedTask.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/manage/task/extended"
@inherits AppComponentBase
@inherits Page

<div class="lcars">
<div class="container">
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/ManageShips.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@page "/manage/ships"
@using Data
@inherits AppComponentBase
@inherits Page

<div class="lcars">
<!-- Player Ships -->
Expand Down
4 changes: 3 additions & 1 deletion TrekSharp.AdventureTools/Pages/ViewCharacterNpcSheet.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/manage/characters/npc/{EncounterId}/{ListId}/{PlayerId}"
@inherits AppComponentBase
@inherits Page

@if (HasCharacter) {
<PrintNotification/>
Expand Down Expand Up @@ -121,6 +121,8 @@
}
public bool HasCharacter => Player != null;

public override string PageTitle => Player?.Name;

private void confirmDelete() {
confirm.Open($"Are you sure you want to delete the character '{this.Player.Name}'?", () => Delete());
}
Expand Down
10 changes: 8 additions & 2 deletions TrekSharp.AdventureTools/Pages/ViewCharacterSheet.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/manage/characters/player/{PlayerId}"
@inherits AppComponentBase
@inherits Page

@if (HasCharacter) {
<PrintNotification/>
Expand Down Expand Up @@ -163,6 +163,8 @@
public PlayerCharacter Player => PlayerIndex >=0 && PlayerIndex < Data.Party.Count ? Data.Party[PlayerIndex] : null;
public bool HasCharacter => Player != null;

public override string PageTitle => Player?.Name;

private void confirmDelete() {
confirm.Open($"Are you sure you want to delete the character '{this.Player.Name}'?", () => Delete());
}
Expand All @@ -188,4 +190,8 @@
milestones.Open(this.Player);
}

}
}

protected override string

public override string
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/manage/characters/support/{PlayerId}"
@inherits AppComponentBase
@inherits Page

@if (HasCharacter) {
<PrintNotification/>
Expand Down Expand Up @@ -92,6 +92,8 @@
public SupportCharacter Player => PlayerIndex >=0 && PlayerIndex < Data.Supports.Count ? Data.Supports[PlayerIndex] : null;
public bool HasCharacter => Player != null;

public override string PageTitle => Player?.Name;

private void confirmDelete() {
confirm.Open($"Are you sure you want to delete the character '{this.Player.Name}'?", () => Delete());
}
Expand Down
4 changes: 3 additions & 1 deletion TrekSharp.AdventureTools/Pages/ViewNpcShip.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/manage/ships/npc/{EncounterId}/{ListId}/{ShipId}"
@inherits AppComponentBase
@inherits Page

@if (HasShip) {
<PrintNotification/>
Expand Down Expand Up @@ -188,6 +188,8 @@
}
public bool HasShip => Ship != null;

public override string PageTitle => Ship?.Name;

private void confirmDelete() {
confirm.Open($"Are you sure you want to delete the ship '{this.Ship.Name}'?", () => Delete());
}
Expand Down
4 changes: 3 additions & 1 deletion TrekSharp.AdventureTools/Pages/ViewShip.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/manage/ships/vessel/{ShipId}"
@inherits AppComponentBase
@inherits Page

@if (HasShip) {
<PrintNotification/>
Expand Down Expand Up @@ -161,6 +161,8 @@
}
public PlayerVessel Ship => ShipIndex >=0 && ShipIndex < Data.Ships.Count ? Data.Ships[ShipIndex] : null;
public bool HasShip => Ship != null;

public override string PageTitle => Ship?.Name;

private void confirmDelete() {
confirm.Open($"Are you sure you want to delete the ship '{this.Ship.Name}'?", () => Delete());
Expand Down
6 changes: 6 additions & 0 deletions TrekSharp.AdventureTools/Shared/AppComponentBase.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@inject NavigationManager AppNavigationManager;

@code {

protected AppData Data => AppDataService;
protected NavigationManager NavigationManager => AppNavigationManager;
public async Task DownloadJson<T>(string filename, T data) {
Expand All @@ -11,6 +12,11 @@
await JSRuntime.InvokeVoidAsync("BlazorDownloadFile", $"{filename}.json", "text/json", file);
}

protected async Task SetPageTitle(string title) {
Console.WriteLine("Setting Page Title To: " + title);
await JSRuntime.InvokeVoidAsync("BlazorSetPageTitle", title);
}

protected void NavigateHome() {
NavigationManager.NavigateTo(string.Empty);
}
Expand Down
11 changes: 11 additions & 0 deletions TrekSharp.AdventureTools/Shared/Page.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@inherits AppComponentBase

@code {
public virtual string PageTitle => null;

protected override async Task OnAfterRenderAsync(bool firstRender) {
if (firstRender) {
await SetPageTitle(PageTitle);
}
}
}
8 changes: 8 additions & 0 deletions TrekSharp.AdventureTools/wwwroot/js/helpers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
function BlazorSetPageTitle(title) {
if (title && title.length > 0) {
document.title = "TrekSharp - " + title;
} else {
document.title = "TrekSharp";
}
}

function BlazorDownloadFile(filename, contentType, content) {
// Blazor marshall byte[] to a base64 string, so we first need to convert the string (content) to a Uint8Array to create the File
const data = base64DecToArr(content);
Expand Down
1 change: 1 addition & 0 deletions TrekSharp/src/Rulebooks/OperationsDivision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ private OperationsDivision() {}
)
},
Items = new List<Item> {
new Item { Name = "Engineering Tricorder", Size = ItemSize.OneHanded },
new Item { Name = "Micro-Optic Drill", Size = ItemSize.OneHanded },
new Item { Name = "Phaser Drill", Size = ItemSize.TwoHanded },
new Item { Name = "Engineering Tricorder", Size = ItemSize.OneHanded },
Expand Down
1 change: 1 addition & 0 deletions TrekSharp/src/Rulebooks/ScienceDivision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ private ScienceDivision() {}
)
},
Items = new List<Item> {
new Item { Name = "Medical Tricorder", Size = ItemSize.OneHanded },
new Item { Name = "Blood Gas Infuser", Size = ItemSize.TwoHanded },
new Item { Name = "Bone Regenerator", Size = ItemSize.TwoHanded },
new Item { Name = "Blood Gas Infuser", Size = ItemSize.OneHanded },
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp/src/Ships.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public int ShieldsRemaining {
this.UsedShields = Shields - value;
}
}
public int Shields => Systems.Structure + (Talents == null ? 0 : Talents.Select(talent => talent.ShieldModifier).Sum());
public int Shields => Systems.Structure + Departments.Security + (Talents == null ? 0 : Talents.Select(talent => talent.ShieldModifier).Sum());
public int UsedPower;
public int PowerRemaining {
get => Math.Max(0, Power - UsedPower);
Expand Down

0 comments on commit 94e923f

Please sign in to comment.