diff options
author | Cara Salter <cara@devcara.com> | 2023-01-07 23:24:04 -0500 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2023-01-07 23:24:04 -0500 |
commit | 36d4f4741cd2559362de7e64820ca4b29b022121 (patch) | |
tree | 172537aa08f946e2a6dc65bc4bec40985f6e1f95 /src/frame.hpp | |
download | cpp-rl-36d4f4741cd2559362de7e64820ca4b29b022121.tar.gz cpp-rl-36d4f4741cd2559362de7e64820ca4b29b022121.zip |
Diffstat (limited to 'src/frame.hpp')
-rw-r--r-- | src/frame.hpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/frame.hpp b/src/frame.hpp new file mode 100644 index 0000000..378619e --- /dev/null +++ b/src/frame.hpp @@ -0,0 +1,76 @@ +/* + * ===================================================================================== + * + * Filename: frame.hpp + * + * Description: Abstractions around NCurses windows + * + * Version: 1.0 + * Created: 01/07/2023 09:55:52 PM + * Revision: none + * Compiler: gcc + * + * Author: Cara Salter (muirrum), cara@devcara.com + * Organization: + * + * ===================================================================================== + */ + +#pragma once + +#include <ncurses.h> + +#include "mob.hpp" + +class Frame { + // dimensions + int _height, _width; + // Position + int _row, _col; + // FALSE when root window and TRUE for a subwindow + bool _has_super; + // Pointer to an ncurses window + WINDOW* _w; + // The super-window, if exists + WINDOW* _super; + + public: + // Init with no parent + Frame(int nr_rows, int nr_cols, int row_0, int col_0); + // Init with parent window + Frame(Frame &super, int nr_rows, int nr_cols, int row_0, int col_0); + ~Frame(); + + // Get window type + bool has_super(); + + WINDOW* win(); + WINDOW *super(); + + // Get height of window + int height(); + int width(); + int row(); + int col(); + + void refresh(); + void move(int r, int c); + + // Fill a window with numbers, for debugging + // Will look like this: + // 0 | 1 + // ----- + // 2 | 3 + void fill_window(); + + void move_window(int r, int c); + + void erase(Mob &x); + // Add a mob to the window + void place_mob(Mob &x); + void place_mob(Mob &x, int row_0, int col_0); + // Center viewport around mob + void center(Mob &x); + + void gen_Perlin(const unsigned int &seed); +}; |