aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2021-05-28 11:07:52 -0400
committerJon Santmyer <jon@jonsantmyer.com>2021-05-28 11:07:52 -0400
commita0af2c0be21cbba9c9c5d9ea9ffcd7e9d7b74905 (patch)
treebad7b23d96597a167f829b749165b2e352eacff3 /include
parentd3602d5cccf7f6c4a7f975694db2b16db28cdd60 (diff)
downloadpostmodern-a0af2c0be21cbba9c9c5d9ea9ffcd7e9d7b74905.tar.gz
postmodern-a0af2c0be21cbba9c9c5d9ea9ffcd7e9d7b74905.tar.bz2
postmodern-a0af2c0be21cbba9c9c5d9ea9ffcd7e9d7b74905.zip
seperate rendering from game logic, new library boxii
Diffstat (limited to 'include')
-rw-r--r--include/game.h11
-rw-r--r--include/input.h48
-rw-r--r--include/pausescreen.h4
-rw-r--r--include/screen.h8
-rw-r--r--include/testscreen.h12
-rw-r--r--include/textwindow.h25
-rw-r--r--include/titlescreen.h6
-rw-r--r--include/window.h51
8 files changed, 21 insertions, 144 deletions
diff --git a/include/game.h b/include/game.h
index 66a4eb4..4e00bb8 100644
--- a/include/game.h
+++ b/include/game.h
@@ -11,17 +11,12 @@
class Game {
private:
- static int m_width;
- static int m_height;
static bool m_running;
static std::unordered_map<std::string, std::shared_ptr<Screen>> m_screens;
static std::deque<std::weak_ptr<Screen>> m_order;
static bool m_dirty;
- static bool m_rawmode;
- static struct termios m_tosOriginal;
-
static void update();
static void render();
protected:
@@ -35,13 +30,7 @@ public:
static bool popUpto(const std::string &key);
static bool popUptoIncluding(const std::string &key);
- static void enableRawmode();
- static void disableRawmode();
-
static void stop() { m_running = false; }
-
- static int getWidth() { return m_width; }
- static int getHeight() { return m_height; }
};
#endif
diff --git a/include/input.h b/include/input.h
deleted file mode 100644
index f3943d5..0000000
--- a/include/input.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef POSTMODERN_INPUT_H
-#define POSTMODERN_INPUT_H 1
-
-enum class Keycode {
- TERMINATE = 128,
- F1,
- F2,
- F3,
- F4,
- F5,
- F6,
- F7,
- F8,
- F9,
- F10,
- F11,
- F12,
- NUMPAD_HOME,
- NUMPAD_UP,
- NUMPAD_PGUP,
- NUMPAD_LEFT,
- NUMPAD_5,
- NUMPAD_RIGHT,
- NUMPAD_END,
- NUMPAD_DOWN,
- NUMPAD_PGDN,
- HOME,
- UP,
- PGUP,
- LEFT,
- RIGHT,
- END ,
- DOWN,
- PGDOWN,
- INSERT,
- DELETE,
- CTRL_MOD,
- ALT_MOD,
-};
-
-class Input {
-private:
-protected:
-public:
- static int getch();
-};
-
-#endif
diff --git a/include/pausescreen.h b/include/pausescreen.h
index 02d3c4d..c3c1a43 100644
--- a/include/pausescreen.h
+++ b/include/pausescreen.h
@@ -1,7 +1,7 @@
#ifndef POSTMODERN_PAUSESCREEN_H
#define POSTMODERN_PAUSESCREEN_H 1
-#include "textwindow.h"
+#include "boxii/textwindow.h"
#include "screen.h"
class PauseScreen : public Screen {
@@ -13,7 +13,7 @@ private:
SELECTION_COUNT
};
- std::shared_ptr<TextWindow> m_menuWindow;
+ std::shared_ptr<Boxii::TextWindow> m_menuWindow;
int m_selection;
void parseSelection();
diff --git a/include/screen.h b/include/screen.h
index d7de4bb..6896b72 100644
--- a/include/screen.h
+++ b/include/screen.h
@@ -1,7 +1,7 @@
#ifndef POSTMODERN_SCREEN_H
#define POSTMODERN_SCREEN_H 1
-#include "window.h"
+#include "boxii/window.h"
#include <unordered_map>
#include <deque>
@@ -12,13 +12,13 @@ class Screen {
private:
bool m_redraw;
protected:
- std::unordered_map<std::string, std::shared_ptr<Window>> m_windows;
- std::deque<std::weak_ptr<Window>> m_order;
+ std::unordered_map<std::string, std::shared_ptr<Boxii::Window>> m_windows;
+ std::deque<std::weak_ptr<Boxii::Window>> m_order;
public:
Screen() {}
virtual ~Screen() {}
- void addWindow(const std::string &key, std::shared_ptr<Window> value);
+ void addWindow(const std::string &key, std::shared_ptr<Boxii::Window> value);
virtual void update() {}
void render();
diff --git a/include/testscreen.h b/include/testscreen.h
index 6d17760..67d98dc 100644
--- a/include/testscreen.h
+++ b/include/testscreen.h
@@ -1,4 +1,16 @@
#ifndef POSTMODERN_TESTSCREEN_H
#define POSTMODERN_TESTSCREEN_H 1
+#include "screen.h"
+
+class TestScreen : public Screen {
+private:
+protected:
+public:
+ TestScreen();
+ ~TestScreen();
+
+ void update() override;
+};
+
#endif
diff --git a/include/textwindow.h b/include/textwindow.h
deleted file mode 100644
index 00ac3ed..0000000
--- a/include/textwindow.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef POSTMODERN_TEXT_WINDOW_H
-#define POSTMODERN_TEXT_WINDOW_H 1
-
-#include <cstdarg>
-
-#include "window.h"
-
-class TextWindow : public Window
-{
-private:
-protected:
- int m_colorfg;
- int m_colorbg;
-public:
- TextWindow(int x, int y, int width, int height, bool bordered);
- ~TextWindow();
-
- void setfg(int fg) { m_colorfg = fg; }
- void setbg(int bg) { m_colorbg = bg; }
-
- int vprint(const char *fmt, va_list ap);
- int print(const char *fmt, ...);
-};
-
-#endif
diff --git a/include/titlescreen.h b/include/titlescreen.h
index 7d8088a..509ea11 100644
--- a/include/titlescreen.h
+++ b/include/titlescreen.h
@@ -1,7 +1,7 @@
#ifndef POSTMODERN_SCREEN_TITLE_H
#define POSTMODERN_SCREEN_TITLE_H 1
-#include "textwindow.h"
+#include "boxii/textwindow.h"
#include "screen.h"
class TitleScreen : public Screen{
@@ -15,8 +15,8 @@ private:
SELECTION_COUNT
};
- std::shared_ptr<Window> m_graphicWindow;
- std::shared_ptr<TextWindow> m_selectionWindow;
+ std::shared_ptr<Boxii::Window> m_graphicWindow;
+ std::shared_ptr<Boxii::TextWindow> m_selectionWindow;
int m_selection;
diff --git a/include/window.h b/include/window.h
deleted file mode 100644
index 425da0f..0000000
--- a/include/window.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef POSTMODERN_WINDOW_H
-#define POSTMODERN_WINDOW_H 1
-
-struct Cell {
- Cell() : chr(0), fg(0), bg(0) {}
-
- char chr;
- unsigned int fg;
- unsigned int bg;
-
- bool operator==(const Cell &a)
- {
- return a.chr == chr && a.fg == fg && a.bg == bg;
- }
-};
-
-class Window {
-private:
- Cell *m_foreplane;
- Cell *m_backplane;
-protected:
- int m_x;
- int m_y;
- int m_width;
- int m_height;
-
- int m_cursorx;
- int m_cursory;
-
- bool m_bordered;
- bool m_redraw;
-public:
- Window(int x, int y, int width, int height, bool bordered);
- ~Window();
-
- void refresh();
-
- void clear(int fg, int bg);
- void plot(int x, int y, char c, int fg, int bg);
-
- void setRedraw() { m_redraw = true; }
-
- void moveCursor(int x, int y);
- void move(int x, int y);
-
- int getWidth() { return m_width; }
- int getHeight() { return m_height; }
- bool getCenter(int &x, int &y); //Returns if has true center
-};
-
-#endif