-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Can convert support characters to player characters
- Loading branch information
Showing
12 changed files
with
184 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@typeparam T | ||
|
||
<input class="w3-input w3-margin-bottom" list="select_list_@ComponentGuid" placeholder="@Placeholder" @bind=selectedString /> | ||
<datalist id="select_list_@ComponentGuid"> | ||
@if(Items != null) { | ||
foreach (var item in Items) { | ||
<option value="@Stringify(item)"/> | ||
} | ||
} | ||
</datalist> | ||
|
||
@code { | ||
[Parameter] public IEnumerable<T> Items {get; set;} | ||
[Parameter] public string Placeholder {get; set;} | ||
private string selectedString; | ||
public T Selected => Items == null ? default(T) : Items.Where(item => string.Equals(Stringify(item), selectedString, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault(); | ||
|
||
private string ComponentGuid; | ||
|
||
[Parameter] public Func<T, string> Stringify {get; set;} = defaultStringify; | ||
|
||
private static string defaultStringify(T value) { | ||
return value?.ToString(); | ||
} | ||
|
||
protected override void OnInitialized() { | ||
base.OnInitialized(); | ||
ComponentGuid = System.Guid.NewGuid().ToString(); | ||
} | ||
|
||
public void Deselect() { | ||
selectedString = null; | ||
StateHasChanged(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Select @ref=select Placeholder="Talent" Items=talents></Select> | ||
|
||
@code { | ||
|
||
private Select<CharacterTalent> select; | ||
|
||
public CharacterTalent Talent => select?.Selected; | ||
|
||
private List<CharacterTalent> talents; | ||
|
||
[Parameter] public Character Character {get; set;} | ||
|
||
protected override void OnInitialized() { | ||
talents = new Data.RulebookContainer() | ||
.AllRulebooks | ||
.SelectMany(book => book.Value.Talents) | ||
.Where(talent => Character == null || talent.CanBeUsedBy(Character)) | ||
.ToList(); | ||
} | ||
|
||
public void Deselect() { | ||
select?.Deselect(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<div class="row"> | ||
<div class="hbar elbow-left knee-left" style="width: 32px;"></div> | ||
<span class="spacer typeface text-secondary w3-large"> | ||
DELETE | ||
</span> | ||
<div class="hbar row-fill elbow-right knee-right" style="margin-right: 10px;"></div> | ||
</div> | ||
<div class="w3-padding"> | ||
<Select @ref=toDelete Placeholder="Talent" Items=@Character.Talents></Select> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="hbar elbow-left knee-left" style="width: 32px;"></div> | ||
<span class="spacer typeface text-secondary w3-large"> | ||
ADD | ||
</span> | ||
<div class="hbar row-fill elbow-right knee-right" style="margin-right: 10px;"></div> | ||
</div> | ||
<div class="w3-padding"> | ||
<TalentSelect @ref=toAdd Character=@Character></TalentSelect> | ||
</div> | ||
|
||
@code { | ||
private Select<CharacterTalent> toDelete; | ||
private TalentSelect toAdd; | ||
|
||
[Parameter] public PlayableCharacter Character {get; set;} | ||
|
||
public void Swap() { | ||
var delete = toDelete.Selected; | ||
var add = toAdd.Talent; | ||
if (delete != null && add != null) { | ||
Character.Talents.Remove(delete); | ||
Character.Talents.Add(add); | ||
} | ||
} | ||
|
||
public void Deselect() { | ||
toDelete.Deselect(); | ||
toAdd.Deselect(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.