diff --git a/Pages/CardIndex.razor b/Pages/CardIndex.razor new file mode 100644 index 0000000..618e2f1 --- /dev/null +++ b/Pages/CardIndex.razor @@ -0,0 +1,74 @@ +@page "/card" + +
+ +
+ +
+ @foreach (var card in cards) { +
+
+
+ +
+
+ + +
+
+
+ } +
+
+
+ New
+ + +
+
+
+
+ +
+ @foreach (var card in cards) { + for (var i = 0; i < card.Replicas; i++) { + + + } + } + +
+ + + + +@code { + static List cards = new List(); + + enum cardSizes { + poker, bridge, tarot, square, game, business + } + private static cardSizes size; + + private DeleteConfirmation delete; + private CardEditor editor; + private void createCard() { + var card = new PlayingCard (); + cards.Add(card); + editor?.Edit(card); + } + + private void editCard(PlayingCard card) { + editor?.Edit(card); + } + + private void deleteCard(PlayingCard card) { + this.delete.AskForConfirmation(() => { cards.Remove(card); StateHasChanged(); }); + } +} \ No newline at end of file diff --git a/Pages/Index.razor b/Pages/Index.razor index 13d55ed..fd8142c 100644 --- a/Pages/Index.razor +++ b/Pages/Index.razor @@ -12,14 +12,10 @@
Create Terrain + + +
+ Create Playing Card +
- - -@code { - - private void gotoMini() { - - } - private void gotoTerrain() {} - -} \ No newline at end of file + \ No newline at end of file diff --git a/Pages/MiniIndex.razor b/Pages/MiniIndex.razor index 2454bca..6671bea 100644 --- a/Pages/MiniIndex.razor +++ b/Pages/MiniIndex.razor @@ -1,12 +1,44 @@ @page "/mini" -
- print this page to get your minis . +
+
+ + + + +

all mini's scale to 1

+
+@code { + private PopupModal scaleModal; + private float scaleMultiplier = 1; + private void applyScale() { + foreach (var mini in minis) { + mini.Scale *= scaleMultiplier; + } + } + private void resetScale() { + foreach (var mini in minis) { + mini.Scale = 1; + } + } +} +
@foreach (var mini in minis) { -
+
@mini.Name @if(mini.Replicas > 1) { (x@(mini.Replicas)) } @@ -22,11 +54,17 @@
} -
-
-
- New
- + +
+
+
+

+ New
+ +

+
+
+

+ or multiple minis +

@@ -40,20 +78,22 @@
-
- Confused? Read the complete instructions here. +
+ Confused? Read the complete instructions here.
+ @code { private MiniEditor editor; private DeleteConfirmation delete; + private BulkLoader bulk; - private string baseSelection = "Y"; - private bool printWithBase => baseSelection == "Y"; + private static string baseSelection = "Y"; + private static bool printWithBase => baseSelection == "Y"; public static List minis = new List {}; @@ -70,6 +110,10 @@ editor?.Edit(mini); } + private void bulkAdd(IEnumerable toAdd) { + minis.AddRange(toAdd); + StateHasChanged(); + } private void editMini(Mini mini) { editor?.Edit(mini); diff --git a/Pages/TerrainIndex.razor b/Pages/TerrainIndex.razor index f35df63..922e538 100644 --- a/Pages/TerrainIndex.razor +++ b/Pages/TerrainIndex.razor @@ -1,12 +1,19 @@ @page "/terrain" -
- print this page to get your terrain. +
+
@foreach (var mini in minis) { -
+
@mini.Name @if(mini.Replicas > 1) { (x@(mini.Replicas)) } @@ -21,7 +28,7 @@
} -
+
New
diff --git a/PlayingCard.cs b/PlayingCard.cs new file mode 100644 index 0000000..36dab8a --- /dev/null +++ b/PlayingCard.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; + +namespace PaperMiniMaker { + +public class PlayingCard { + public int Replicas {get; set;} = 1; + public string FrontUrl {get; set;} + public string BackUrl {get; set;} +} + +} \ No newline at end of file diff --git a/Shared/BulkLoader.razor b/Shared/BulkLoader.razor new file mode 100644 index 0000000..31c1769 --- /dev/null +++ b/Shared/BulkLoader.razor @@ -0,0 +1,75 @@ +@inject IJSRuntime js; + +
+
+
+ Bulk Add Minis +
+
+

Select any number of image files below to create miniatures for.

+ +
+
+
+ +
+
+ @if (dataUrls != null && dataUrls.dataUrls != null && dataUrls.dataUrls.Length > 0) { + + } +
+ +
+
+
+ +@code { + + private bool isOpen = false; + private string showModalCss => isOpen ? "w3-show" : "w3-hide"; + + private ElementReference files; + + private BulkResults dataUrls; + + [Parameter] public Action> OnChange {get; set;} + + private class BulkResults { + public string[] dataUrls {get; set;} + public string[] names {get; set;} + } + + private async Task readFileStrings() { + dataUrls = await js.InvokeAsync("BlazorHandleFileSelectMultipleDataUrl", files); + } + + public void Show(bool isOpen) { + this.isOpen = isOpen; + StateHasChanged(); + } + + private void save() { + if (OnChange == null) + return; + + if (dataUrls == null || dataUrls.dataUrls == null) { + OnChange(new Mini[0]); + Show(false); + return; + } + + var minis = new Mini[this.dataUrls.dataUrls.Length]; + for (var i = 0; i < minis.Length; i++) { + minis[i] = new Mini { + Name = i >= 0 && dataUrls.names != null && i < dataUrls.names.Length ? dataUrls.names[i] : "Bulk Mini", + Size = MiniSize.Medium, + FrontArt = new MiniArt { + Url = dataUrls.dataUrls[i] + }, + Replicas = 1, + }; + } + OnChange(minis); + Show(false); + } +} \ No newline at end of file diff --git a/Shared/CardEditor.razor b/Shared/CardEditor.razor new file mode 100644 index 0000000..4f90bb7 --- /dev/null +++ b/Shared/CardEditor.razor @@ -0,0 +1,55 @@ +
+
+
+ Edit Playing Card +
+ @if (card != null) { +
+ + + +
+
+ + +
+ OR +
+ { card.FrontUrl = url; StateHasChanged(); })> + +
 
+ + + +
+ OR +
+ { card.BackUrl = url; StateHasChanged(); })> +
+
+
+
+ +
+ } +
+
+ +@code { + [Parameter] public Action OnChange {get; set;} + private PlayingCard card; + + private bool isOpen = false; + private string showModalCss => isOpen ? "w3-show" : "w3-hide"; + + public void Edit(PlayingCard card) { + this.card = card; + this.isOpen = true; + StateHasChanged(); + } + + public void save() { + OnChange?.Invoke(); + this.isOpen = false; + } +} \ No newline at end of file diff --git a/Shared/MainLayout.razor b/Shared/MainLayout.razor index 4c520ed..f326403 100644 --- a/Shared/MainLayout.razor +++ b/Shared/MainLayout.razor @@ -13,6 +13,9 @@ Terrain + + Card +
@Body diff --git a/Shared/PopupModal.razor b/Shared/PopupModal.razor new file mode 100644 index 0000000..27292c6 --- /dev/null +++ b/Shared/PopupModal.razor @@ -0,0 +1,31 @@ +
+
+
+ @Title Show(false))>x +
+
+ @ChildContent +
+
+ +
+
+
+ +@code { + [Parameter] public string Title {get; set;} + [Parameter] public RenderFragment ChildContent {get; set;} + [Parameter] public Action OnSave {get; set;} + + private bool isOpen = false; + private string showModalCss => isOpen ? "w3-show" : "w3-hide"; + public void Show(bool isOpen) { + this.isOpen = isOpen; + StateHasChanged(); + } + private void save() { + if (OnSave != null) + OnSave(); + Show(false); + } +} \ No newline at end of file diff --git a/wwwroot/assets/card.svg b/wwwroot/assets/card.svg new file mode 100644 index 0000000..8bdc8db --- /dev/null +++ b/wwwroot/assets/card.svg @@ -0,0 +1,158 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wwwroot/assets/printer.svg b/wwwroot/assets/printer.svg new file mode 100644 index 0000000..ebf1ead --- /dev/null +++ b/wwwroot/assets/printer.svg @@ -0,0 +1,108 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/wwwroot/assets/scale.svg b/wwwroot/assets/scale.svg new file mode 100644 index 0000000..28c6399 --- /dev/null +++ b/wwwroot/assets/scale.svg @@ -0,0 +1,72 @@ + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/wwwroot/css/app.css b/wwwroot/css/app.css index a2c9efe..74d2143 100644 --- a/wwwroot/css/app.css +++ b/wwwroot/css/app.css @@ -22,6 +22,11 @@ header { z-index: 10; } +nav { + background-color: #1f1c35; + padding: 4px; +} + footer { background-color: #2E294E; } diff --git a/wwwroot/css/playing-card.css b/wwwroot/css/playing-card.css new file mode 100644 index 0000000..1c30ff0 --- /dev/null +++ b/wwwroot/css/playing-card.css @@ -0,0 +1,37 @@ +.card { + width: 2.5in; + height: 3.5in; + border: 1px solid black; + display: inline-block; + object-fit: fill; +} + +.card.poker { + width: 2.5in !important; + height: 3.5in !important; +} + +.card.bridge { + width: 2.25in !important; + height: 3.5in !important; +} + +.card.tarot { + width: 3.5in !important; + height: 5.75in !important; +} + +.card.square { + width: 3.5in !important; + height: 3.5in !important; +} + +.card.game { + width: 2.2in !important; + height: 3.43in !important; +} + +.card.business { + width: 2in !important; + height: 3.5in !important; +} \ No newline at end of file diff --git a/wwwroot/index.html b/wwwroot/index.html index 66c26b9..4dc71e2 100644 --- a/wwwroot/index.html +++ b/wwwroot/index.html @@ -15,6 +15,7 @@ + diff --git a/wwwroot/js/helpers.js b/wwwroot/js/helpers.js index 52cb1ed..fa2b8ff 100644 --- a/wwwroot/js/helpers.js +++ b/wwwroot/js/helpers.js @@ -89,6 +89,31 @@ async function BlazorHandleFileSelectDataUrl(input) { } } +function removeExtension(filename) { + return filename.substring(0, filename.lastIndexOf('.')) || filename; +} + +async function BlazorHandleFileSelectMultipleDataUrl(input) { + var files = input.files; + if (files.length > 0) { + var data = { + dataUrls: [], + names: [], + }; + for (var i = 0; i < files.length; i++) { + var file = files[i]; + data.dataUrls.push(await BlazorReadFileAsDataUrl(file)); + data.names.push(removeExtension(file.name)); + } + return data; + } else { + return { + dataUrls: [], + names: [], + }; + } +} + async function BlazorReadFileAsDataUrl(file) { return await new Promise((resolve, reject) => { var reader = new FileReader();