summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Credits.md3
-rw-r--r--assets/fonts/coolvetica.ttf (renamed from assets/coolvetica.ttf)bin67464 -> 67464 bytes
-rw-r--r--assets/fonts/monofont.ttfbin0 -> 33896 bytes
-rw-r--r--src/resources/resources.c5
-rw-r--r--src/resources/resources.h1
-rw-r--r--src/scenes/puzzleScene.c6
-rw-r--r--src/ui_elements/TextEditor.c8
-rw-r--r--src/ui_elements/UI.h1
8 files changed, 21 insertions, 3 deletions
diff --git a/Credits.md b/Credits.md
index e4acceb..ade38fb 100644
--- a/Credits.md
+++ b/Credits.md
@@ -1,6 +1,9 @@
+# ASSETS ORIGINS
+
## FONTS
All the fonts were downloaded from https://www.1001freefonts.com
- https://www.1001freefonts.com/coolvetica.font
+- https://www.1001freefonts.com/monofonto.font
## COLORS
- https://www.color-hex.com/color-palette/1072336
diff --git a/assets/coolvetica.ttf b/assets/fonts/coolvetica.ttf
index 16d39c1..16d39c1 100644
--- a/assets/coolvetica.ttf
+++ b/assets/fonts/coolvetica.ttf
Binary files differ
diff --git a/assets/fonts/monofont.ttf b/assets/fonts/monofont.ttf
new file mode 100644
index 0000000..6bb4c32
--- /dev/null
+++ b/assets/fonts/monofont.ttf
Binary files differ
diff --git a/src/resources/resources.c b/src/resources/resources.c
index b8a292e..e82b6e0 100644
--- a/src/resources/resources.c
+++ b/src/resources/resources.c
@@ -3,12 +3,15 @@
#include <raylib.h>
Font MainFont;
+Font MonoFont;
void LoadResources() {
- MainFont = LoadFontEx("assets/coolvetica.ttf", 100, NULL, 0);
+ MainFont = LoadFontEx("assets/fonts/coolvetica.ttf", 100, NULL, 0);
+ MonoFont = LoadFontEx("assets/fonts/monofont.ttf", 100, NULL, 0);
}
Font *GetMainFont() { return &MainFont; }
+Font *GetMonoFont() { return &MonoFont; }
void DrawStripe(int start_step, int end_step, Color color) {
int height = GetScreenHeight();
diff --git a/src/resources/resources.h b/src/resources/resources.h
index c53da99..e6efc25 100644
--- a/src/resources/resources.h
+++ b/src/resources/resources.h
@@ -18,5 +18,6 @@ static const Color COLORSCHEME_WHITE = { 233, 225, 185, 255 };
void LoadResources();
Font *GetMainFont();
+Font *GetMonoFont();
#endif // RESOURCES_H
diff --git a/src/scenes/puzzleScene.c b/src/scenes/puzzleScene.c
index 8824a09..d49b530 100644
--- a/src/scenes/puzzleScene.c
+++ b/src/scenes/puzzleScene.c
@@ -67,6 +67,10 @@ bool drawPuzzleScene(void *self) {
DrawPuzzleName(data->PuzzlePtr->Name);
Rectangle body = GetBodyRect();
+ DrawRecBordered(body, WHITE, COLORSCHEME_ORANGE, BORDER);
+ DrawTextArea(data->EditorInfo, body, GetMonoFont(), 20, 2, &data->editor_scroll);
+ return true;
+
Rectangle pane1, pane2;
GetPanesSplit(&pane1, &pane2, body, 0.5, 0.4);
DrawRecBordered(pane1, WHITE, COLORSCHEME_ORANGE, BORDER);
@@ -74,7 +78,7 @@ bool drawPuzzleScene(void *self) {
DrawTextInRec(pane1, data->PuzzlePtr->Description,
GetMainFont(), 20, COLORSCHEME_BROWN, 3, &data->scroll);
- DrawTextArea(data->EditorInfo, pane2, GetMainFont(), 20, 2, &data->editor_scroll);
+ DrawTextArea(data->EditorInfo, pane2, GetMonoFont(), 20, 2, &data->editor_scroll);
return true;
}
diff --git a/src/ui_elements/TextEditor.c b/src/ui_elements/TextEditor.c
index ebc8671..fa85443 100644
--- a/src/ui_elements/TextEditor.c
+++ b/src/ui_elements/TextEditor.c
@@ -68,11 +68,13 @@ bool AddSpaceDetermined(TextNode *base, size_t additional_space) {
void AppendTextToNode(TextNode *base, char *new_text) {
if (base == NULL || new_text == NULL) return;
size_t len = strlen(base->text);
+ size_t new_len = strlen(new_text);
/// >= and not > because it needs a \0
- if (len + strlen(new_text) >= base->cap) {
+ if (len + new_len >= base->cap) {
if (!AddSpace(base)) return;
}
strcpy(base->text + len, new_text);
+ base->len += new_len;
}
TextArea *CreateTextArea() {
@@ -367,6 +369,10 @@ void HandleKeyboard(TextArea *ta) {
if (IsKeyPressedFix(KEY_RIGHT)) MoveCursorRight(ta);
if (IsKeyPressedFix(KEY_DOWN)) MoveCursorDown(ta);
if (IsKeyPressedFix(KEY_UP)) MoveCursorUp(ta);
+ if (IsKeyPressedFix(KEY_TAB)) {
+ for (int i = 0; i < TAB_WIDTH; i++)
+ InsertChar(ta, ' ');
+ };
if (IsKeyPressedFix(KEY_HOME)) MoveCursorHome(ta);
if (IsKeyPressedFix(KEY_END)) MoveCursorEnd(ta);
diff --git a/src/ui_elements/UI.h b/src/ui_elements/UI.h
index 779290f..eaf17e8 100644
--- a/src/ui_elements/UI.h
+++ b/src/ui_elements/UI.h
@@ -5,6 +5,7 @@
#define UI_ELEMENTS_H
static const float SCROLL_SENC = 10;
+static const float TAB_WIDTH = 4;
void DrawRecBordered(Rectangle rec, Color bg, Color border_color, int border_width);
void DrawTextInRec(Rectangle rec, char *text, Font *font, int height, Color color, float padding, int *scroll);