Skip to content

Commit 553fbc3

Browse files
committed
added a version option in the settings
1 parent f0a33ad commit 553fbc3

File tree

3 files changed

+43
-29
lines changed

3 files changed

+43
-29
lines changed

ui/menu.hpp

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ namespace menu {
7575
data(args)
7676
{}
7777

78-
template <typename Font, typename FrameBuffer, uint32_t BufferSize>
79-
void draw(FrameBuffer& fb, const klib::vector2u& offset, const uint32_t selected, char option[Count][BufferSize],
80-
const klib::graphics::color foreground, const klib::graphics::color background, const bool hidden[Count] = {})
78+
template <typename Font, typename FrameBuffer>
79+
void draw(FrameBuffer& fb, const klib::vector2u& offset, const uint32_t selected, const char** option,
80+
const klib::graphics::color foreground, const klib::graphics::color background, const bool* hidden)
8181
{
8282
uint32_t onscreen_index = 0;
8383
uint32_t hidden_by_scroll = 0;
@@ -127,29 +127,32 @@ namespace menu {
127127
// move the onscreen index
128128
onscreen_index++;
129129

130-
// // check if we need to show a option for the current item
131-
// if (option == nullptr || option[i] == nullptr) {
132-
// // skip if we dont have one
133-
// continue;
134-
// }
135-
136-
// // get the length of the option string
137-
// const uint32_t len = klib::string::strlen(option[i]);
138-
139-
// // check if the string has any length
140-
// if (!len) {
141-
// continue;
142-
// }
143-
144-
// // write the value to the display
145-
// writer.draw(
146-
// fb, option[i],
147-
// klib::vector2i{
148-
// static_cast<int32_t>(Width - line_boarder_pixels + (len * 8)),
149-
// static_cast<int32_t>(3 + position_index * line_boarder_pixels)
150-
// } - offset.cast<int32_t>(),
151-
// col_foreground, klib::graphics::transparent
152-
// );
130+
// check if we need to show a option for the current item
131+
if (option == nullptr || option[i] == nullptr) {
132+
// skip if we dont have one
133+
continue;
134+
}
135+
136+
// get the length of the option string
137+
const uint32_t len = klib::string::strnlen(option[i], sizeof(string));
138+
139+
// check if the string has any length
140+
if (!len || (len == sizeof(string))) {
141+
continue;
142+
}
143+
144+
// write the value to the display
145+
Font::template draw(
146+
fb, option[i],
147+
klib::vector2i{
148+
static_cast<int32_t>(Width - (line_boarder_pixels + (Font::font::width * len))),
149+
static_cast<int32_t>(
150+
boarder_pixels + (boarder_pixels / 2) +
151+
(position_index * line_pixels)
152+
)
153+
} - offset.cast<int32_t>(),
154+
col_foreground, klib::graphics::transparent
155+
);
153156
}
154157

155158
// check if we need to clear parts of the screen

ui/settings.hpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include <klib/graphics/bitmap.hpp>
44

5+
#include <version.hpp>
6+
57
#include "menu.hpp"
68
#include "screen.hpp"
79

@@ -16,6 +18,7 @@ namespace menu {
1618
time,
1719
calibration,
1820
mouse,
21+
version,
1922

2023
// should always be at the end
2124
count
@@ -32,6 +35,7 @@ namespace menu {
3235
"set time",
3336
"set cal",
3437
"usb jiggler",
38+
"version",
3539
};
3640

3741
// menu that can draw all the labels
@@ -90,14 +94,17 @@ namespace menu {
9094
// clear the background black
9195
frame_buffer.clear(klib::graphics::black);
9296

93-
// array with all the options
94-
char buffer[label_count][sizeof(labels[0])] = {};
97+
// create a array with nullptrs
98+
const char* ptr[label_count] = {};
99+
100+
// set the version to the version string
101+
ptr[static_cast<uint8_t>(item::version)] = version;
95102

96103
// update the labels
97104
options.template draw<typename screen_base::large_text>(
98105
frame_buffer,
99106
offset, static_cast<uint8_t>(selection),
100-
buffer, klib::graphics::grey,
107+
ptr, klib::graphics::grey,
101108
klib::graphics::white, {}
102109
);
103110
}

version.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#pragma once
2+
3+
// Current version
4+
constexpr static char version[] = "0.1";

0 commit comments

Comments
 (0)