97 lines
2.2 KiB
C++
97 lines
2.2 KiB
C++
#ifndef SPARROWSHELL_H
|
|
#define SPARROWSHELL_H
|
|
|
|
#include <list>
|
|
|
|
#include "glm/vec2.hpp"
|
|
|
|
#include "scene/scenetree.h"
|
|
#include "scene/graphicalcontainernode.h"
|
|
|
|
#include "scene/gui/guinode.h"
|
|
#include "scene/gui/callback.h"
|
|
|
|
#include "sparrowshell/shellbuffer.h"
|
|
#include "sparrowshell/shellscrollbar.h"
|
|
|
|
#include "SparrowInput/keybindings.h"
|
|
|
|
class Input;
|
|
class TextInputNode;
|
|
class ShellBuffer;
|
|
class BackGroundNode;
|
|
class ScriptNode;
|
|
|
|
namespace sf {
|
|
class Window;
|
|
}
|
|
|
|
class SparrowShell : public GUINode
|
|
{
|
|
private:
|
|
class InputCallBack : public CallBack{
|
|
SparrowShell* m_shell;
|
|
TextInputNode* m_text_input_node;
|
|
public:
|
|
InputCallBack(SparrowShell* shell,TextInputNode* textinput);
|
|
virtual void exec();
|
|
};
|
|
|
|
class AutocompletionCallBack : public CallBack{
|
|
SparrowShell* m_shell;
|
|
TextInputNode* m_text_input_node;
|
|
public:
|
|
AutocompletionCallBack(SparrowShell* shell,TextInputNode* textinput);
|
|
virtual void exec();
|
|
};
|
|
|
|
glm::vec2 m_dimension;
|
|
bool m_shellEnabled = false;
|
|
|
|
BackGroundNode* m_background;
|
|
ShellBuffer* m_buffer;
|
|
ShellScrollBar* m_scrollbar;
|
|
ScriptNode * m_script;
|
|
|
|
glm::vec3 m_text_color;
|
|
TextInputNode* m_input_node;
|
|
|
|
int m_move_cursor_left;
|
|
int m_move_cursor_right;
|
|
std::string m_previous_context;
|
|
|
|
// std::vector<int> m_inputActions;
|
|
|
|
// enum ShellAction {MOVE_CURSOR_LEFT,MOVE_CURSOR_RIGHT,HISTORY_PREVIOUS,HISTORY_NEXT};
|
|
|
|
public:
|
|
static const unsigned int BUFFER_MAX_LENGTH;
|
|
static const unsigned int BUFFER_DISPLAYED_LINES;
|
|
static const unsigned int SCROLLBAR_PIXEL_WIDTH;
|
|
static const float SHELL_DEPTH;
|
|
static const float DEFAULT_FONT_SIZE;
|
|
|
|
SparrowShell(sf::Window*);
|
|
|
|
void update();
|
|
void scrollUp();
|
|
void scrollDown();
|
|
|
|
void toggleShell();
|
|
void out(std::string str);
|
|
void out(std::string str, glm::vec3 color);
|
|
|
|
glm::vec2 getDimension(){return m_dimension;}
|
|
|
|
unsigned int getIndex(){return m_buffer->getIndex();}
|
|
ShellBuffer* getBuffer(){return m_buffer;}
|
|
ScriptNode* getScript(){return m_script;}
|
|
|
|
void setInputs(int cursor_left, int cursor_right, int history_up, int history_down);
|
|
|
|
bool isEnabled(){return m_shellEnabled;}
|
|
|
|
void clear();
|
|
};
|
|
#endif // SPARROWSHELL_H
|