Repository navigation
Docs for devs
Virus Rpi edited this page Dec 12, 2023
·
23 revisions
- Create new class that inherits from Window
1.1. Create the methods update_window() that returns Bitarray2D
1.2. Create method handle_key_down(KeyPress keypress)
- Add a new MenuOption to MainMenuWindow.cpp and change size of options vector
- Implement all the functions you need
- To get screen size you can do
#include "constant/Constants.h"and then use SCREEN_HEIGHT and SCREEN_WIDTH - To get time since boot do
#include "utils/Utils.h"and then useUtils::us_since_boot() - To check for a key press use
keypress.key_calculator == Chars::KEY_MAP.at("1")(you can also usekeypress.key_raworkeypress.key_keyboard) - To check if alpha or shift is activated use
keypress.alphaorkeypress.shift
Disclaimer: If the headline is italic the section is AI generated
You can create a Bitset2D with the following methods:
-
Bitset2D()for dynamic size and a starting size of 0, 0 -
Bitset2D(uint32_t width, uint32_t height, bool value)to initialize with a specific size and a default value -
Bitset2D(uint32_t width, const DynamicBitset& other)to initialize with a width. The height and values are copied from the dynamic bit set -
Bitset2D(uint32_t width, uint32_t height, const std::vector<std::vector<uint8_t>>& plane)same as above but height also specific -
Bitset2D(const Bitset2D& other)copies the bit set passed in (height, width, values)
Methods:
-
.at(uint32_t index)to get the value at an index in the dynamic bit set -
.width()to get the width of the bit set -
.height()to get the height of the bit set -
.get_bit(uint32_t coord_x, uint32_t coord_y)to get the bit at a specific x and y coordinate -
.copy(uint32_t x_start, uint32_t y_start, uint32_t width, uint32_t height, Bitset2D& destination)copies a section of a bit set into another -
.put_chars(uint32_t coord_x, uint32_t coord_y, const std::map<KEY, Bitset2D>& font, KEY_SET text, bool resize_if_needed)to but a character on a specific coordinate with the option to extend the bit set if needed -
.set(uint32_t coord_x, uint32_t coord_y, const Bitset2D& other, bool resize_if_needed)inserts a bit set into another at a coordinate with the option to extend the bit set if needed -
.set_column(uint32_t coord_x, const DynamicBitset& other)replaces a column in the bit set with a dynamic bit set -
.set_bit(uint32_t coord_x, uint32_t coord_y, bool value)to set a value of one pixel at a coordinate -
.erase_x(uint32_t coord_x)to remove a column at a specific x coordinate -
.erase_y(uint32_t coord_y)to remove a row at a specific y coordinate -
.pop_back_x()to remove the last column in the bit set -
.clear()to clear the bit set -
.push_back(const DynamicBitset& other)to add a dynamic bit set to the end of the bit set -
.push_front(const DynamicBitset& other)to add a dynamic bit set to the beginning of the bit set -
.extend_right(const Bitset2D& other)to extend the bit set to the right with another bit set -
.extend_right(uint32_t length, bool value)to extend the bit set to the right with a specific length and value -
.extend_down(const Bitset2D& other)to extend the bit set downwards with another bit set -
.extend_down(uint32_t length, bool value)to extend the bit set downwards with a specific length and value -
.extend_left(const Bitset2D& other)to extend the bit set to the left with another bit set -
.extend_left(uint32_t length, bool value)to extend the bit set to the left with a specific length and value -
.extend_up(const Bitset2D& other)to extend the bit set upwards with another bit set -
.extend_up(uint32_t length, bool value)to extend the bit set upwards with a specific length and value -
.to_string()to convert the bit set to a string -
.to_string_formatted()to convert the bit set to a formatted string
Behavior with operators:
-
Bitset2D::operator[](uint32_t index)to get the dynamic bit set at an index in the 2D bit set -
Bitset2D::operator==(const Bitset2D& other)to check if two 2D bit sets are equal -
Bitset2D::operator!=(const Bitset2D& other)to check if two 2D bit sets are not equal -
Bitset2D::operator=(const Bitset2D& other)to assign one 2D bit set to another -
Bitset2D::operator+(const Bitset2D& other)to concatenate two 2D bit sets
You can create a DynamicBitset with the following methods:
-
DynamicBitset()for dynamic size and a starting size of 0 -
DynamicBitset(uint32_t count, bool value)to initialize with a specific size and a default value -
DynamicBitset(uint32_t count, std::vector<uint8_t> values)to initialize with a specific size and values from a vector of bytes -
DynamicBitset(uint32_t count, std::vector<bool> values)to initialize with a specific size and values from a vector of booleans -
DynamicBitset(const DynamicBitset& other)copies the bit set passed in (size, values)
Methods:
-
.at(uint32_t index)to get the value at an index in the dynamic bit set -
.size()to get the size of the bit set -
.get_bytes()to get the bytes of the bit set -
.copy(uint32_t start, uint32_t width)copies a section of a bit set -
.set(uint32_t index, bool value)to set a value of one bit at an index -
.set(uint32_t index, const DynamicBitset& other)inserts a bit set into another at an index -
.insert(uint32_t index, bool bit)to insert a bit at a specific index -
.insert(uint32_t index, const DynamicBitset& bits)to insert a bit set at a specific index -
.erase(uint32_t index)to remove a bit at a specific index -
.clear()to clear the bit set -
.push_back(bool bit)to add a bit to the end of the bit set -
.push_front(bool bit)to add a bit to the beginning of the bit set -
.pop_back()to remove the last bit in the bit set -
.pop_front()to remove the first bit in the bit set -
.extend(const DynamicBitset& other)to extend the bit set with another bit set -
.extend(uint32_t length, bool value)to extend the bit set with a specific length and value -
.extend_left(const DynamicBitset& other)to extend the bit set to the left with another bit set -
.extend_left(uint32_t length, bool value)to extend the bit set to the left with a specific length and value -
.to_string()to convert the bit set to a string -
.to_string_formatted(uint32_t bytes_per_line)to convert the bit set to a formatted string
Behavior with operators:
-
DynamicBitset::operator[](uint32_t i)to get the bit at an index in the dynamic bit set -
DynamicBitset::operator==(const DynamicBitset& other)to check if two dynamic bit sets are equal -
DynamicBitset::operator!=(const DynamicBitset& other)to check if two dynamic bit sets are not equal -
DynamicBitset::operator=(const DynamicBitset& other)to assign one dynamic bit set to another -
DynamicBitset::operator+(const DynamicBitset& other)to concatenate two dynamic bit sets
The Window class is used to manage the window of the application. It provides methods to update the window, get the render canvas, add graphics to the window, clear the window, clear symbols, change symbols, scroll left and right, and handle key down and up events.
You can create a Window with the following methods:
-
Window()to initialize the window
Methods:
-
.update_window()to update the window and return the render canvas -
.get_render_canvas()to get the render canvas of the window -
.add_to_window(const Bitset2D& graphic, int corner_x, int corner_y)to add a graphic to the window at a specific corner -
.clear_window()to clear the window -
.clear_symbols()to clear the symbols -
.change_symbol(std::string symbol, bool state)to change the state of a symbol -
.scroll_left()to scroll the window to the left -
.scroll_right()to scroll the window to the right -
.handle_key_down(KeyPress keypress)to handle the key down event -
.handle_key_up(KeyPress keypress)to handle the key up event -
.got_focus()to handle the event when the window got focus -
.lost_focus()to handle the event when the window lost focus