diff --git a/src/include/invscreen.h b/src/include/invscreen.h new file mode 100644 index 0000000000000000000000000000000000000000..cd6b267ac4ebb04faaaa77515f2a71284f1b6735 --- /dev/null +++ b/src/include/invscreen.h @@ -0,0 +1,16 @@ +#pragma once +#include "uistate.h" +#include "playerchar.h" +#include "../libtcod/include/libtcod.hpp" +#include "playstate.h" +#include "level.h" + +class InvScreen : public UIState { + public: + InvScreen(PlayerChar*, Level*); + void draw(TCODConsole*); + UIState* handleInput(TCOD_key_t); + private: + PlayerChar* player; + Level* level; +}; diff --git a/src/invscreen.cpp b/src/invscreen.cpp new file mode 100644 index 0000000000000000000000000000000000000000..93df1fb1d36d2b1473cf45612e69c0d8ceb1a2a5 --- /dev/null +++ b/src/invscreen.cpp @@ -0,0 +1,23 @@ +#include "include/invscreen.h" +#include "include/playerchar.h" +#include "include/playstate.h" +#include "libtcod/include/libtcod.hpp" + +InvScreen::InvScreen(PlayerChar* player, Level* level) + : player(player) + , level(level) +{} + +UIState* InvScreen::handleInput(TCOD_key_t key) { + if (key.vk == TCODK_ESCAPE) { + return new PlayState(player, level); + } + return this; +} + +void InvScreen::draw(TCODConsole* con) { + int y = 0; + for (auto item : player->getInventory()) { + con->print(0, y, item.first->getName().c_str()); + } +} diff --git a/src/playstate.cpp b/src/playstate.cpp index 21005457ead9d876c4ddcdf7267069484d0ea4ba..0455f8517287d721a42feb30ef5dd729710cac27 100644 --- a/src/playstate.cpp +++ b/src/playstate.cpp @@ -3,6 +3,7 @@ #include "include/playerchar.h" #include "include/level.h" #include "include/ripscreen.h" +#include "include/invscreen.h" #include "libtcod/include/libtcod.hpp" #include <iostream> #include <string> @@ -160,6 +161,9 @@ UIState* PlayState::handleInput(TCOD_key_t key) { prompt = new QuitPrompt(player, level); return this; } + if (key.c == 'i') { + return new InvScreen(player, level); + } //Arrow controls auto newPos = player->getLocation().copy(); if (key.vk == TCODK_UP) {