summaryrefslogtreecommitdiff
path: root/lib/nes/app/graphics
diff options
context:
space:
mode:
authorHannes Schulze <haschu0103@outlook.de>2025-02-06 18:24:59 +0100
committerHannes Schulze <haschu0103@outlook.de>2025-02-06 18:24:59 +0100
commitd060e3a50c987d10799ccc739bdbf9d7d7a13c10 (patch)
tree4b5585383ada85608b57bcf76e5828817962fddf /lib/nes/app/graphics
parentdbed1c0fa5599b1b96c221b89b10f1e350351645 (diff)
implement settings
Diffstat (limited to 'lib/nes/app/graphics')
-rw-r--r--lib/nes/app/graphics/renderer.cc16
-rw-r--r--lib/nes/app/graphics/renderer.hh7
-rw-r--r--lib/nes/app/graphics/tiles/CMakeLists.txt7
-rw-r--r--lib/nes/app/graphics/tiles/symbol_at.pngbin0 -> 156 bytes
-rw-r--r--lib/nes/app/graphics/tiles/symbol_backslash.pngbin0 -> 133 bytes
-rw-r--r--lib/nes/app/graphics/tiles/symbol_brace_close.pngbin0 -> 148 bytes
-rw-r--r--lib/nes/app/graphics/tiles/symbol_brace_open.pngbin0 -> 147 bytes
-rw-r--r--lib/nes/app/graphics/tiles/symbol_hat.pngbin0 -> 142 bytes
-rw-r--r--lib/nes/app/graphics/tiles/symbol_pipe.pngbin0 -> 141 bytes
-rw-r--r--lib/nes/app/graphics/tiles/symbol_underscore.pngbin0 -> 136 bytes
10 files changed, 22 insertions, 8 deletions
diff --git a/lib/nes/app/graphics/renderer.cc b/lib/nes/app/graphics/renderer.cc
index 564125b..4f0d562 100644
--- a/lib/nes/app/graphics/renderer.cc
+++ b/lib/nes/app/graphics/renderer.cc
@@ -64,7 +64,7 @@ namespace nes::app
}
auto renderer::render_text(
- i32 x, i32 const y, std::string_view const str, color const c, text_attributes const attributes) -> void
+ i32 x, i32 const y, std::string_view const str, color const c, text_attributes const attributes) -> u32
{
// Enforce max length
char buffer[width];
@@ -121,9 +121,10 @@ namespace nes::app
// Draw the text
for (auto i = u32{ 0 }; i < length; ++i)
{
- auto const character = static_cast<u32>(buffer[i]);
- render_mask_tile(x + static_cast<i32>(i), y, resolve_character(character), c);
+ render_mask_tile(x + static_cast<i32>(i), y, resolve_character(buffer[i]), c);
}
+
+ return length;
}
auto renderer::render_rect(i32 const x, i32 const y, u32 const width, u32 const height, color const c) -> void
@@ -217,7 +218,7 @@ namespace nes::app
return rgb::from_hex(0x000000);
}
- auto renderer::resolve_character(u32 const c) const -> mask_tile
+ auto renderer::resolve_character(char const c) const -> mask_tile
{
switch (c)
{
@@ -260,6 +261,10 @@ namespace nes::app
case '9': return tiles::digit_9;
case '&': return tiles::symbol_ampersand;
case '\'': return tiles::symbol_apostrophe;
+ case '@': return tiles::symbol_at;
+ case '\\': return tiles::symbol_backslash;
+ case '{': return tiles::symbol_brace_open;
+ case '}': return tiles::symbol_brace_close;
case '[': return tiles::symbol_bracket_open;
case ']': return tiles::symbol_bracket_close;
case ':': return tiles::symbol_colon;
@@ -269,18 +274,21 @@ namespace nes::app
case '!': return tiles::symbol_exclamation_mark;
case '>': return tiles::symbol_greater;
case '#': return tiles::symbol_hashtag;
+ case '^': return tiles::symbol_hat;
case '<': return tiles::symbol_less;
case '-': return tiles::symbol_minus;
case '(': return tiles::symbol_paren_open;
case ')': return tiles::symbol_paren_close;
case '%': return tiles::symbol_percent;
case '.': return tiles::symbol_period;
+ case '|': return tiles::symbol_pipe;
case '+': return tiles::symbol_plus;
case '?': return tiles::symbol_question_mark;
case '"': return tiles::symbol_quotation_mark;
case ';': return tiles::symbol_semicolon;
case '/': return tiles::symbol_slash;
case '*': return tiles::symbol_star;
+ case '_': return tiles::symbol_underscore;
default: return tiles::symbol_unknown;
}
}
diff --git a/lib/nes/app/graphics/renderer.hh b/lib/nes/app/graphics/renderer.hh
index d4d7cc4..2e24ad3 100644
--- a/lib/nes/app/graphics/renderer.hh
+++ b/lib/nes/app/graphics/renderer.hh
@@ -46,7 +46,7 @@ namespace nes::app
/// Render an image at the given tile coordinates.
auto render_image(i32 x, i32 y, image_view) -> void;
/// Render a string of text at the given tile coordinates (one tile per character).
- auto render_text(i32 x, i32 y, std::string_view, color, text_attributes = text_attributes{}) -> void;
+ auto render_text(i32 x, i32 y, std::string_view, color, text_attributes = text_attributes{}) -> u32;
template<typename... Args>
auto render_text_format(
@@ -55,8 +55,7 @@ namespace nes::app
{
string_buffer<width> buffer{};
buffer.append_format(fmt, args...);
- render_text(x, y, buffer.get_result(), c, attrs);
- return static_cast<u32>(buffer.get_result().length());
+ return render_text(x, y, buffer.get_result(), c, attrs);
}
template<typename... Args>
@@ -75,6 +74,6 @@ namespace nes::app
private:
auto resolve_color(color) const -> rgb;
- auto resolve_character(u32) const -> mask_tile;
+ auto resolve_character(char) const -> mask_tile;
};
} // namespace nes::app \ No newline at end of file
diff --git a/lib/nes/app/graphics/tiles/CMakeLists.txt b/lib/nes/app/graphics/tiles/CMakeLists.txt
index eced5ca..5dced68 100644
--- a/lib/nes/app/graphics/tiles/CMakeLists.txt
+++ b/lib/nes/app/graphics/tiles/CMakeLists.txt
@@ -40,6 +40,10 @@ nes_generate_tiles(
digit_8.png
digit_9.png
symbol_ampersand.png
+ symbol_at.png
+ symbol_backslash.png
+ symbol_brace_open.png
+ symbol_brace_close.png
symbol_apostrophe.png
symbol_bracket_open.png
symbol_bracket_close.png
@@ -50,18 +54,21 @@ nes_generate_tiles(
symbol_exclamation_mark.png
symbol_greater.png
symbol_hashtag.png
+ symbol_hat.png
symbol_less.png
symbol_minus.png
symbol_paren_open.png
symbol_paren_close.png
symbol_percent.png
symbol_period.png
+ symbol_pipe.png
symbol_plus.png
symbol_question_mark.png
symbol_quotation_mark.png
symbol_semicolon.png
symbol_slash.png
symbol_star.png
+ symbol_underscore.png
symbol_unknown.png)
nes_generate_tiles(
diff --git a/lib/nes/app/graphics/tiles/symbol_at.png b/lib/nes/app/graphics/tiles/symbol_at.png
new file mode 100644
index 0000000..e399054
--- /dev/null
+++ b/lib/nes/app/graphics/tiles/symbol_at.png
Binary files differ
diff --git a/lib/nes/app/graphics/tiles/symbol_backslash.png b/lib/nes/app/graphics/tiles/symbol_backslash.png
new file mode 100644
index 0000000..8d98ef0
--- /dev/null
+++ b/lib/nes/app/graphics/tiles/symbol_backslash.png
Binary files differ
diff --git a/lib/nes/app/graphics/tiles/symbol_brace_close.png b/lib/nes/app/graphics/tiles/symbol_brace_close.png
new file mode 100644
index 0000000..bb24228
--- /dev/null
+++ b/lib/nes/app/graphics/tiles/symbol_brace_close.png
Binary files differ
diff --git a/lib/nes/app/graphics/tiles/symbol_brace_open.png b/lib/nes/app/graphics/tiles/symbol_brace_open.png
new file mode 100644
index 0000000..32bdb99
--- /dev/null
+++ b/lib/nes/app/graphics/tiles/symbol_brace_open.png
Binary files differ
diff --git a/lib/nes/app/graphics/tiles/symbol_hat.png b/lib/nes/app/graphics/tiles/symbol_hat.png
new file mode 100644
index 0000000..ab21714
--- /dev/null
+++ b/lib/nes/app/graphics/tiles/symbol_hat.png
Binary files differ
diff --git a/lib/nes/app/graphics/tiles/symbol_pipe.png b/lib/nes/app/graphics/tiles/symbol_pipe.png
new file mode 100644
index 0000000..9db3443
--- /dev/null
+++ b/lib/nes/app/graphics/tiles/symbol_pipe.png
Binary files differ
diff --git a/lib/nes/app/graphics/tiles/symbol_underscore.png b/lib/nes/app/graphics/tiles/symbol_underscore.png
new file mode 100644
index 0000000..1823c95
--- /dev/null
+++ b/lib/nes/app/graphics/tiles/symbol_underscore.png
Binary files differ