diff --git a/CCharLearn/Client/Program.cs b/CCharLearn/Client/Program.cs
index dc336f6..7dc43b6 100644
--- a/CCharLearn/Client/Program.cs
+++ b/CCharLearn/Client/Program.cs
@@ -10,6 +10,7 @@ namespace CCharLearn
{
public class Program
{
+
public static int CCharsLeft = 0;
public static Action UpdateUiEvent;
diff --git a/CCharLearn/Pages/Index.razor b/CCharLearn/Pages/Index.razor
index 99c2099..07839ad 100644
--- a/CCharLearn/Pages/Index.razor
+++ b/CCharLearn/Pages/Index.razor
@@ -35,14 +35,20 @@
-
+
+
+ Modifiers:
+
+
+
+
-
+
@if (Charecters != null)
{
-
-
+
+
@@ -90,15 +96,27 @@
bool continueDataExists = false;
int continueCharectersLeft = -1;
- private bool isEasyMode;
+ private bool ignoreTone;
- public bool IsEasyMode
+ public bool IgnoreTone
{
- get { return isEasyMode; }
+ get { return ignoreTone; }
set
{
- isEasyMode = value;
- SetEasyMode();
+ ignoreTone = value;
+ SetIgnoreTone();
+ }
+ }
+
+ private bool useChangingFonts;
+
+ public bool UseChangingFonts
+ {
+ get { return useChangingFonts; }
+ set
+ {
+ useChangingFonts = value;
+ SetChangingFonts();
}
}
@@ -153,9 +171,14 @@
StateHasChanged();
}
- async void SetEasyMode()
+ async void SetIgnoreTone()
{
- await localStorage.SetItemAsync("EasyMode", isEasyMode);
+ await localStorage.SetItemAsync("IgnoreTone", ignoreTone);
+ }
+
+ async void SetChangingFonts()
+ {
+ await localStorage.SetItemAsync("ChangingFonts", UseChangingFonts);
}
async Task LoadAllChunksIntoLocalStorage()
@@ -215,9 +238,14 @@
continueCharectersLeft = await localStorage.GetItemAsync("ContinueCharectersLeft");
}
- if (await localStorage.ContainKeyAsync("EasyMode"))
+ if (await localStorage.ContainKeyAsync("IgnoreTone"))
{
- isEasyMode = await localStorage.GetItemAsync("EasyMode");
+ ignoreTone = await localStorage.GetItemAsync("IgnoreTone");
+ }
+
+ if (await localStorage.ContainKeyAsync("ChangingFonts"))
+ {
+ UseChangingFonts = await localStorage.GetItemAsync("ChangingFonts");
}
}
}
\ No newline at end of file
diff --git a/CCharLearn/Pages/Learn.razor b/CCharLearn/Pages/Learn.razor
index a180e2b..3549edd 100644
--- a/CCharLearn/Pages/Learn.razor
+++ b/CCharLearn/Pages/Learn.razor
@@ -42,7 +42,14 @@
@if (!Answers.Any(x => x == null))
{
- @GetDisplayChar()
+ if (useChagingFonts)
+ {
+ @GetDisplayChar()
+ }
+ else
+ {
+ @GetDisplayChar()
+ }
}
@@ -80,7 +87,7 @@
{
Submit
}
- @if (isEasyMode)
+ @if (ignoreTone)
{
• Easy mode enabled
}
@@ -89,12 +96,26 @@
+@*Used to load all fonts into memory instead of loading from http each time*@
+@if (useChagingFonts && !hasLoadedFontsToMemory)
+{
+ @for (int i = 0; i < extraFonts.Length; i++)
+ {
+ i
+ }
+}
+
@code {
bool isSavedLocally = false;
- bool isEasyMode = false;
+ bool ignoreTone = false;
bool selectedCorrect = false;
+ bool useChagingFonts = false;
+ string? currentFont = null;
+ string[] extraFonts = { "HanyiSentyRubber", "mini-jian-caocuyuan", "myoungheihk", "UnboundedSans", "wt064", "XiaolaiSC-Regular", "chinese1", "chinese2" };
+ bool hasLoadedFontsToMemory = false;
+
public Answer[] Answers = new Answer[4];
public void SelectButton(int selectedIndex)
{
@@ -129,9 +150,14 @@
protected override async Task OnInitializedAsync()
{
Program.UpdateUiEvent += OnUiUpdate;
- if (await localStorage.ContainKeyAsync("EasyMode"))
+ if (await localStorage.ContainKeyAsync("IgnoreTone"))
{
- isEasyMode = await localStorage.GetItemAsync("EasyMode");
+ ignoreTone = await localStorage.GetItemAsync("IgnoreTone");
+ }
+
+ if (await localStorage.ContainKeyAsync("ChangingFonts"))
+ {
+ useChagingFonts = await localStorage.GetItemAsync("ChangingFonts");
}
bool continueLast =
@@ -148,13 +174,21 @@
await LoadCharectersFromChunk();
}
- if (isEasyMode)
+ if (ignoreTone)
DontSkipTheseCChar.ForEach(x => x.cchar.pinyin = x.cchar.pinyin.Unidecode());
+ if (useChagingFonts)
+ {
+ ChangeFont();
+ }
+
Program.CCharsLeft = DontSkipTheseCChar.Count;
Program.InvokeUiUpdate();
GenerateQuestion();
+
+ await Task.Delay(100);
+ hasLoadedFontsToMemory = true;
}
async Task LoadCharectersFromChunk()
@@ -234,6 +268,12 @@
navigator.NavigateTo("");
}
+ async void ChangeFont()
+ {
+ int randomIndex = Random.Shared.Next(0, extraFonts.Length);
+ currentFont = extraFonts[randomIndex];
+ }
+
async void Submit()
{
bool isCorrect = Answers.Any(x => x.isCorrect && x.isSelected);
@@ -244,6 +284,7 @@
{
Snackbar.Add($"Definition: {correctCChar.definition}", Severity.Success, config => { config.VisibleStateDuration = 1000; });
increaseCCharStat(GetCorrectCCharStats(), StatType.NumOfCorrects);
+ ChangeFont();
}
else
{
diff --git a/CCharLearn/Pages/Learn.razor.css b/CCharLearn/Pages/Learn.razor.css
new file mode 100644
index 0000000..5f28270
--- /dev/null
+++ b/CCharLearn/Pages/Learn.razor.css
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/CCharLearn/wwwroot/css/app.css b/CCharLearn/wwwroot/css/app.css
index 37dfb60..4a85e01 100644
--- a/CCharLearn/wwwroot/css/app.css
+++ b/CCharLearn/wwwroot/css/app.css
@@ -96,4 +96,46 @@ a, .btn-link {
}
.loading-progress-text:after {
content: var(--blazor-load-percentage-text, "Loading");
- }
\ No newline at end of file
+ }
+
+@font-face {
+ font-family: 'HanyiSentyRubber';
+ src: url(../fonts/HanyiSentyRubber.ttf) format('truetype');
+}
+
+@font-face {
+ font-family: 'mini-jian-caocuyuan';
+ src: url(../fonts/mini-jian-caocuyuan.ttf) format('truetype');
+}
+
+@font-face {
+ font-family: 'myoungheihk';
+ src: url(../fonts/myoungheihk.ttf) format('truetype');
+}
+
+@font-face {
+ font-family: 'UnboundedSans';
+ src: url(../fonts/UnboundedSans.ttf) format('truetype');
+}
+
+@font-face {
+ font-family: 'wt064';
+ src: url(../fonts/wt064.ttf) format('truetype');
+}
+
+@font-face {
+ font-family: 'XiaolaiSC-Regular';
+ src: url(../fonts/XiaolaiSC-Regular.ttf) format('truetype');
+}
+
+/*优设标题黑*/
+@font-face {
+ font-family: 'chinese1';
+ src: url(../fonts/chinese1.ttf) format('truetype');
+}
+
+/*站酷仓耳渔阳体*/
+@font-face {
+ font-family: 'chinese2';
+ src: url(../fonts/chinese2.ttf) format('truetype');
+}
\ No newline at end of file
diff --git a/CCharLearn/wwwroot/fonts/HanyiSentyRubber.ttf b/CCharLearn/wwwroot/fonts/HanyiSentyRubber.ttf
new file mode 100644
index 0000000..df3f929
Binary files /dev/null and b/CCharLearn/wwwroot/fonts/HanyiSentyRubber.ttf differ
diff --git a/CCharLearn/wwwroot/fonts/UnboundedSans.ttf b/CCharLearn/wwwroot/fonts/UnboundedSans.ttf
new file mode 100644
index 0000000..1ed1755
Binary files /dev/null and b/CCharLearn/wwwroot/fonts/UnboundedSans.ttf differ
diff --git a/CCharLearn/wwwroot/fonts/XiaolaiSC-Regular.ttf b/CCharLearn/wwwroot/fonts/XiaolaiSC-Regular.ttf
new file mode 100644
index 0000000..82e28f4
Binary files /dev/null and b/CCharLearn/wwwroot/fonts/XiaolaiSC-Regular.ttf differ
diff --git a/CCharLearn/wwwroot/fonts/chinese1.ttf b/CCharLearn/wwwroot/fonts/chinese1.ttf
new file mode 100644
index 0000000..3729151
Binary files /dev/null and b/CCharLearn/wwwroot/fonts/chinese1.ttf differ
diff --git a/CCharLearn/wwwroot/fonts/chinese2.ttf b/CCharLearn/wwwroot/fonts/chinese2.ttf
new file mode 100644
index 0000000..027535f
Binary files /dev/null and b/CCharLearn/wwwroot/fonts/chinese2.ttf differ
diff --git a/CCharLearn/wwwroot/fonts/mini-jian-caocuyuan.ttf b/CCharLearn/wwwroot/fonts/mini-jian-caocuyuan.ttf
new file mode 100644
index 0000000..8919b7f
Binary files /dev/null and b/CCharLearn/wwwroot/fonts/mini-jian-caocuyuan.ttf differ
diff --git a/CCharLearn/wwwroot/fonts/myoungheihk.ttf b/CCharLearn/wwwroot/fonts/myoungheihk.ttf
new file mode 100644
index 0000000..3483fd9
Binary files /dev/null and b/CCharLearn/wwwroot/fonts/myoungheihk.ttf differ
diff --git a/CCharLearn/wwwroot/fonts/wt064.ttf b/CCharLearn/wwwroot/fonts/wt064.ttf
new file mode 100644
index 0000000..075f994
Binary files /dev/null and b/CCharLearn/wwwroot/fonts/wt064.ttf differ