Skip to content

Commit

Permalink
Loading JSON or Raw characters now redirects to character sheet autom…
Browse files Browse the repository at this point in the history
…atically; Player characters can have bios
  • Loading branch information
qkmaxware committed May 25, 2021
1 parent 0c33698 commit 9352985
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 18 deletions.
5 changes: 4 additions & 1 deletion TrekSharp.AdventureTools/Pages/CreatePlayerMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@
}
private void onCharacterLoaded(PlayerCharacter character) {
this.Data.Party.Add(character);
this.NavigateToPlayerCharacter(character);
}

RawPlayerCharacterCreator raw;
private void openRawImporter() {
raw?.Open();
}
private void onRawImport() {}
private void onRawImport(PlayerCharacter character) {
this.NavigateToPlayerCharacter(character);
}
}
6 changes: 3 additions & 3 deletions TrekSharp.AdventureTools/Pages/CreateShipMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
}
private void onShipLoaded(PlayerVessel vessel) {
this.Data.Ships.Add(vessel);
this.StateHasChanged();
this.NavigateToPlayerVessel(vessel);
}

private RawShipCreator raw;
private void openRawImporter() {
raw?.Open();
}
private void onRawShipLoaded() {
this.StateHasChanged();
private void onRawShipLoaded(PlayerVessel vessel) {
this.NavigateToPlayerVessel(vessel);
}


Expand Down
21 changes: 21 additions & 0 deletions TrekSharp.AdventureTools/Pages/ViewCharacterSheet.razor
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
</div>
</LCARS>

<!-- Talents -->
@if (Player.Talents != null && Player.Talents.Count > 0) {
<div class="pagebreak"></div>
<LCARS PrintBorders=true>
Expand Down Expand Up @@ -107,6 +108,26 @@
</div>
</LCARS>
}

<!-- BIO -->
<div class="pagebreak"></div>
<LCARS PrintBorders=true>
<div class="row-fill">
<div class="w3-row w3-padding">
<div class="row w3-margin-bottom row-fill">
<div class="hbar elbow-left knee-left" style="width: 32px;"></div>
<div class="typeface" style="margin-left: 10px; margin-right: 10px;">
BIO
</div>
<div class="hbar row-fill elbow-right knee-right"></div>
</div>
</div>
<div class="row-fill w3-margin-left w3-margin-right">
<textarea class="text-primary border-primary no-print" @bind=Player.Bio style="width: 100%; resize: vertical; background-color: inherit; min-height: 120px;"></textarea>
<div class="print" style="white-space: pre-wrap;">@Player.Bio</div>
</div>
</div>
</LCARS>
</div>


Expand Down
5 changes: 4 additions & 1 deletion TrekSharp.AdventureTools/Shared/AppComponentBase.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
protected AppData Data => AppDataService;
protected NavigationManager NavigationManager => AppNavigationManager;
public async Task DownloadJson<T>(string filename, T data) {
var json = System.Text.Json.JsonSerializer.Serialize(data);
await DownloadJson(filename, data, typeof(T));
}
public async Task DownloadJson(string filename, object data, Type t) {
var json = System.Text.Json.JsonSerializer.Serialize(data, t);
byte[] file = System.Text.Encoding.UTF8.GetBytes(json);
await JSRuntime.InvokeVoidAsync("BlazorDownloadFile", $"{filename}.json", "text/json", file);
}
Expand Down
10 changes: 1 addition & 9 deletions TrekSharp.AdventureTools/Shared/CharacterEditorPopoutTab.razor
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,7 @@

public async Task Export() {
if (HasCharacter) {
if (this.Character is PlayerCharacter pc) {
await this.DownloadJson<PlayerCharacter>($"{pc.Name}.character", pc);
} else if (this.Character is SupportCharacter sc) {
await this.DownloadJson<SupportCharacter>($"{sc.Name}.character", sc);
} else if (this.Character is NpcCharacter npc) {
await this.DownloadJson<NpcCharacter>($"{npc.Name}.character", npc);
} else {
await this.DownloadJson<Character>($"{Character.Name}.character", Character);
}
await this.DownloadJson($"{this.Character.Name}.character", this.Character, this.Character.GetType());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
@code {
Popup popup;

[Parameter] public Action OnImport {get; set;}
[Parameter] public Action<PlayerCharacter> OnImport {get; set;}

private PlayerCharacter character;

Expand All @@ -296,7 +296,7 @@
private void Confirm() {
if (character != null) {
Data.Party.Add(character);
OnImport?.Invoke();
OnImport?.Invoke(character);
}
popup.Close();
}
Expand Down
4 changes: 2 additions & 2 deletions TrekSharp.AdventureTools/Shared/RawShipCreator.razor
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
@code {
Popup popup;

[Parameter] public Action OnImport {get; set;}
[Parameter] public Action<PlayerVessel> OnImport {get; set;}

private PlayerVessel ship;

Expand All @@ -293,7 +293,7 @@
private void Confirm() {
if (ship != null) {
Data.Ships.Add(ship);
OnImport?.Invoke();
OnImport?.Invoke(ship);
}
popup.Close();
}
Expand Down
1 change: 1 addition & 0 deletions TrekSharp/src/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class Character {
public List<string> Values {get; set;}

public Avatar Avatar {get; set;} = null;
public string Bio {get; set;} = null;

public virtual int TotalStress => Attributes.Fitness + Disciplines.Security + BonusStress;
public virtual int BonusStress {get;} = 0;
Expand Down

0 comments on commit 9352985

Please sign in to comment.