The-NodeBox-Generator/src/EditorState.hpp

87 lines
1.8 KiB
C++
Raw Permalink Normal View History

2014-05-20 15:15:40 -07:00
#ifndef EDITORSTATE_HPP_INCLUDED
#define EDITORSTATE_HPP_INCLUDED
#include "common.hpp"
2014-04-25 11:46:35 -07:00
#include "Configuration.hpp"
#include "project/project.hpp"
2014-05-20 15:15:40 -07:00
#include "MenuState.hpp"
2013-12-15 09:40:57 -08:00
#define NUMBER_OF_KEYS 252
2015-06-28 08:06:56 -07:00
enum EKeyState
{
2013-12-15 09:40:57 -08:00
EKS_UP = false,
2014-02-14 10:46:12 -08:00
EKS_DOWN = true
2013-12-15 09:40:57 -08:00
};
class Project;
class EditorMode;
class MenuState;
class EditorState
{
public:
2014-04-29 13:48:27 -07:00
EditorState(irr::IrrlichtDevice* dev, Project* proj, Configuration* settings);
2013-12-15 09:40:57 -08:00
// Irrlicht
ITriangleSelector* plane_tri;
2014-04-29 13:48:27 -07:00
IrrlichtDevice* device;
2013-12-15 09:40:57 -08:00
// Project
Project* project;
// Editor
2014-05-15 10:45:04 -07:00
EditorMode* Mode(int id) const
{
if (id < 0 || id >= 5) {
2014-02-14 10:46:12 -08:00
return NULL;
}
2014-04-29 13:48:27 -07:00
return modes[id];
2014-02-14 10:46:12 -08:00
}
2014-05-15 10:45:04 -07:00
EditorMode* Mode() const
{
2014-07-25 11:27:21 -07:00
if (!Mode(currentmode))
std::cerr << "Warning! Null mode returned..." << std::endl;
2014-02-14 10:46:12 -08:00
return Mode(currentmode);
}
2014-05-15 10:45:04 -07:00
2014-02-14 10:46:12 -08:00
void SelectMode(int id);
2015-02-02 10:40:35 -08:00
void AddMode(EditorMode *value);
2014-04-29 13:48:27 -07:00
void CloseEditor() { close_requested = true; }
bool NeedsClose() const { return close_requested; }
2013-12-15 09:40:57 -08:00
// Input
bool mousedown;
2014-07-16 10:17:15 -07:00
vector2di mouse_position;
2015-06-28 08:06:56 -07:00
EKeyState keys[NUMBER_OF_KEYS];
2015-02-02 10:40:35 -08:00
2014-05-20 15:30:52 -07:00
Configuration *settings;
MenuState *menu;
2015-06-28 08:06:56 -07:00
EViewportType getEViewportType(EViewport id);
bool isInstalled;
2013-12-15 09:40:57 -08:00
private:
int currentmode;
2014-05-20 15:30:52 -07:00
EditorMode *modes[5];
2014-04-29 13:48:27 -07:00
int modeCount;
2013-12-15 09:40:57 -08:00
bool close_requested;
};
2014-04-29 13:48:27 -07:00
class EditorMode : public irr::IEventReceiver
2013-12-15 09:40:57 -08:00
{
public:
2014-04-29 13:48:27 -07:00
EditorMode(EditorState* st) : state(st) {}
2013-12-15 09:40:57 -08:00
virtual void load() = 0;
virtual void unload() = 0;
virtual void update(double dtime) = 0;
virtual void draw(irr::video::IVideoDriver* driver) {}
virtual void drawViewport(irr::video::IVideoDriver* driver, EViewport viewport, rect<s32> area) {}
2015-06-28 08:06:56 -07:00
virtual void viewportTick(EViewport window, irr::video::IVideoDriver* driver, rect<s32> offset) = 0;
2013-12-15 09:40:57 -08:00
virtual bool OnEvent(const irr::SEvent &event) = 0;
2014-04-25 11:30:18 -07:00
virtual irr::video::ITexture* icon() = 0;
2014-04-29 13:48:27 -07:00
int id;
EditorState* state;
2013-12-15 09:40:57 -08:00
};
2014-04-29 13:48:27 -07:00
2014-02-12 07:12:06 -08:00
#endif