Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merged with shua

  • Loading branch information...
commit 2a539160305f2db8bbe0a7c7a9ced5808c6542fe 2 parents 98205ae + 518cd64
Sven-Hendrik Haase authored
Showing with 2,033 additions and 7,059 deletions.
  1. +9 −2 INSTALL
  2. +1 −1  data/scripts/root.xml
  3. +1 −1  src/game/level.cpp
  4. +0 −1  src/game/trigger.hpp
  5. +15 −11 src/gfx/root.cpp
  6. +0 −242 src/gui/brush.cpp
  7. +0 −99 src/gui/brush.hpp
  8. +0 −70 src/gui/button.cpp
  9. +0 −64 src/gui/button.hpp
  10. +0 −64 src/gui/check_box.cpp
  11. +0 −45 src/gui/check_box.hpp
  12. +0 −148 src/gui/console.cpp
  13. +0 −58 src/gui/console.hpp
  14. +0 −109 src/gui/drop_down_menu.cpp
  15. +0 −71 src/gui/drop_down_menu.hpp
  16. +0 −215 src/gui/file_dialog.cpp
  17. +0 −72 src/gui/file_dialog.hpp
  18. +29 −72 src/gui/gui_disp.cpp
  19. +11 −10 src/gui/gui_disp.hpp
  20. +0 −140 src/gui/layout.cpp
  21. +0 −185 src/gui/layout.hpp
  22. +0 −45 src/gui/mouse.cpp
  23. +0 −44 src/gui/mouse.hpp
  24. +0 −32 src/gui/mouse_button.hpp
  25. +0 −250 src/gui/panel.cpp
  26. +0 −67 src/gui/panel.hpp
  27. +0 −176 src/gui/scrollable_panel.cpp
  28. +0 −61 src/gui/scrollable_panel.hpp
  29. +0 −100 src/gui/scrollbar.cpp
  30. +0 −70 src/gui/scrollbar.hpp
  31. +0 −262 src/gui/sheet.cpp
  32. +0 −193 src/gui/sheet.hpp
  33. +0 −112 src/gui/skin.cpp
  34. +0 −66 src/gui/skin.hpp
  35. +0 −37 src/gui/skin_pre.hpp
  36. +0 −313 src/gui/text.cpp
  37. +0 −133 src/gui/text.hpp
  38. +0 −167 src/gui/text_box.cpp
  39. +0 −55 src/gui/text_box.hpp
  40. +0 −521 src/gui/widget.cpp
  41. +0 −498 src/gui/widget.hpp
  42. +0 −32 src/gui/widget_types.hpp
  43. +0 −134 src/gui/window.cpp
  44. +0 −76 src/gui/window.hpp
  45. +2 −2 src/main.cpp
  46. +1 −1  src/script/bindings.cpp
  47. +2 −2 src/script/bindings_editor.cpp
  48. +1 −1  src/script/bindings_game.cpp
  49. +9 −7 src/script/bindings_gui.cpp
  50. +2 −2 src/script/bindings_play.cpp
  51. +1,135 −1,135 src/states/editor.cpp
  52. +303 −301 src/states/editor.hpp
  53. +36 −10 src/states/main_menu.cpp
  54. +14 −12 src/states/main_menu.hpp
  55. +348 −348 src/states/play.cpp
  56. +114 −114 src/states/play.hpp
11 INSTALL
View
@@ -2,8 +2,15 @@ Pseudoform INSTALL
============================
To install the game, just extract it to somewhere and run
-Linux: ./pseudoform_linux.sh
-Windows: pseudoform_win.bat
+Linux:
+cmake .
+make
+./pseudoform_linux.sh
+
+Windows:
+run cmake in root dir
+run make in root dir
+pseudoform_win.bat
Except for working 3D drivers, no dependencies should be required in either case.
Please excuse the improper installation as of now.
2  data/scripts/root.xml
View
@@ -1,5 +1,5 @@
<renderer lib="ogl"
- plugins="/usr/local/lib/OGRE/"
+ plugins="/usr/lib/OGRE/"
width="1024"
height="768"
fullscreen="0"
2  src/game/level.cpp
View
@@ -16,7 +16,7 @@
#include "script/bindings.hpp"
#include "script/script.hpp"
-#include "gui/sheet.hpp"
+//#include "gui/sheet.hpp"
#include "level.hpp"
#include "types.hpp"
1  src/game/trigger.hpp
View
@@ -11,7 +11,6 @@
#include <list>
-// TODO: include script.hpp
#include "script/script.hpp"
#include "generic_prop.hpp"
26 src/gfx/root.cpp
View
@@ -25,6 +25,8 @@
#include "log.hpp"
#include "fs_ops.hpp"
+#include <boost/filesystem.hpp>
+
#include "txml/txml.hpp"
namespace engine
@@ -91,22 +93,22 @@ namespace engine
}
else
{
- #ifdef _DEBUG
- _root->loadPlugin(plugins + "RenderSystem_GL_d");
- #else
+ //#ifdef _DEBUG
+ //_root->loadPlugin(plugins + "RenderSystem_GL_d");
+ //#else
_root->loadPlugin(plugins + "RenderSystem_GL");
- #endif
+ //#endif
renderLib = RL_OGL;
}
// Load CG shader manager and particle manager
- #ifdef _DEBUG
- _root->loadPlugin(plugins + "Plugin_CgProgramManager_d");
- _root->loadPlugin(plugins + "Plugin_ParticleFX_d");
- #else
+ //#ifdef _DEBUG
+ //_root->loadPlugin(plugins + "Plugin_CgProgramManager_d");
+ //_root->loadPlugin(plugins + "Plugin_ParticleFX_d");
+ //#else
_root->loadPlugin(plugins + "Plugin_CgProgramManager");
_root->loadPlugin(plugins + "Plugin_ParticleFX");
- #endif
+ //#endif
// Get full list of available renderers
const Ogre::RenderSystemList& availRenderers = _root->getAvailableRenderers();
@@ -177,8 +179,10 @@ namespace engine
// Manage project resources
Ogre::ResourceGroupManager &rgm = Ogre::ResourceGroupManager::getSingleton();
- rgm.addResourceLocation(engine::DATA_DIR, "FileSystem", "data", true);
- rgm.initialiseResourceGroup("data");
+ rgm.addResourceLocation(engine::DATA_DIR, "FileSystem", "General", true);
+ rgm.addResourceLocation(engine::DATA_DIR + "/media", "FileSystem", "General", true);
+ rgm.addResourceLocation(engine::DATA_DIR + "/media/MyGUI_Media", "FileSystem", "General", true);
+ rgm.initialiseResourceGroup("General");
Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(16);
Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_ANISOTROPIC);
242 src/gui/brush.cpp
View
@@ -1,242 +0,0 @@
- /*
- * Copyright (c) 2008-2010 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#include <OgreRenderSystem.h>
-#include <OgreManualObject.h>
-#include <OgreSceneManager.h>
-#include <OgreRoot.h>
-
-#include "brush.hpp"
-#include "log.hpp"
-
-#include "gfx/utils.hpp"
-#include "gfx/render_lib.hpp"
-
-namespace engine
-{
- namespace gui
- {
- idGen brush::_idGen;
-
- brush::brush():
- _rs(Ogre::Root::getSingleton().getRenderSystem()),
- _pass(NULL),
- _selectPass(NULL),
- _pressPass(NULL),
- _noBlendPass(NULL),
- _quad(NULL)
- {
- _pass = gfx::getPass("gui_mat", 0, 0, true);
- _selectPass = gfx::getPass("gui_mat", 0, 1, true);
- _pressPass = gfx::getPass("gui_mat", 0, 2, true);
- _noBlendPass = gfx::getPass("gui_mat", 0, 3, true);
-
- if (!_pass || !_selectPass || !_pressPass || !_noBlendPass)
- {
- log("gui_mat unavailable, GUI rendering will be disabled");
- }
-
- // Just get some scene manager, doesn't matter which
- Ogre::SceneManagerEnumerator::SceneManagerIterator sceneIter =
- Ogre::Root::getSingleton().getSceneManagerIterator();
- assert(sceneIter.hasMoreElements());
-
- Ogre::SceneManager *sceneMgr = sceneIter.peekNextValue();
-
- _quad = sceneMgr->createManualObject(_idGen("brush") + "::_quad");
-
- _quad->clear();
- _quad->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST);
- {
- // top-right
- _quad->position(vec3(1, 1, 0));
- _quad->textureCoord(vec2(1, 0));
-
- // bottom-right
- _quad->position(vec3(1, -1, 0));
- _quad->textureCoord(vec2(1, 1));
-
- // bottom-left
- _quad->position(vec3(-1, -1, 0));
- _quad->textureCoord(vec2(0, 1));
-
- // top-left
- _quad->position(vec3(-1, 1, 0));
- _quad->textureCoord(vec2(0, 0));
-
- // Vertices are clockwise, make them anticlockwise
- _quad->quad(3, 2, 1, 0);
- }
- _quad->end();
- }
-
- brush::~brush()
- {
- if (_quad)
- _quad->_getManager()->destroyManualObject(_quad);
- _quad = NULL;
- _rs = NULL;
- }
-
-// void brush::prepareForUse() const
-// {
-// assert(_rs);
-//
-// _rs->unbindGpuProgram(Ogre::GPT_FRAGMENT_PROGRAM);
-// _rs->unbindGpuProgram(Ogre::GPT_VERTEX_PROGRAM);
-//
-// _rs->_setWorldMatrix(mat4::IDENTITY);
-// _rs->_setViewMatrix(mat4::IDENTITY);
-// _rs->_setProjectionMatrix(mat4::IDENTITY);
-//
-// _rs->setLightingEnabled(false);
-// _rs->_setDepthBias(false);
-// _rs->_setDepthBufferCheckEnabled(false);
-// _rs->_setDepthBufferWriteEnabled(false);
-// _rs->_setColourBufferWriteEnabled(true, true, true, true);
-// _rs->_setFog(Ogre::FOG_NONE);
-// _rs->_setPolygonMode(Ogre::PM_SOLID);
-// _rs->_setSceneBlending(Ogre::SBF_SOURCE_ALPHA, Ogre::SBF_ONE_MINUS_SOURCE_ALPHA);
-// _rs->_setTextureCoordSet(0, 0);
-// _rs->_setTextureUnitFiltering(0, Ogre::FO_NONE, Ogre::FO_NONE, Ogre::FO_NONE);
-// }
-
-// void brush::texture(const string &name) const
-// {
-//// assert(_rs);
-// if (!_pass)
-// return;
-//
-//// _rs->_setTexture(0, true, name);
-// _pass->getTextureUnitState(0)->setTextureName(name);
-// }
-
- void brush::render(Ogre::Viewport *vp, const vec4 &rect, const effect &e) const
- {
- if (_texture.empty())
- return;
-
- Ogre::Pass *pass = NULL;
-
- switch (e)
- {
- case E_NONE:
- pass = _pass;
- break;
-
- case E_SELECT:
- pass = _selectPass;
- break;
-
- case E_PRESS:
- pass = _pressPass;
- break;
-
- case E_NO_BLEND:
- pass = _noBlendPass;
- break;
- }
-
- if (!pass)
- return;
-
- pass->getTextureUnitState(0)->setTextureName(_texture);
-// if (!_pass)
-// _pass = gfx::getPass("gui_mat", 0, 0, true);
-// if (!_pass)
-// return;
-
- _quad->_getManager()->_setPass(pass, true, false);
-
- vec4 r = rect;
- {
- // If not relative, make it relative and cache it
- float w = 1.0 / vp->getActualWidth();
- float h = 1.0 / vp->getActualHeight();
-
- // Scale XY to [0..2], ZW to [0..1]
- r *= vec4(w * 2, h * 2, w, h);
-
- // Move XY to [-1..1] and add [0..1] WH to XY
- r += vec4(-1 + r.z, -1 + r.w, 0, 0);
-
- // Negate Y because 0 is at bottom
- r.y *= -1;
- }
-
- Ogre::RenderOperation rop;
- _quad->getSection(0)->getRenderOperation(rop);
-
- _rs->_setViewport(vp); // Render to said viewport
-
- // Scale to dimensions
- mat4 mat(mat4::getScale(r.z, r.w, 1));
-
- // Translate by XY
- mat = mat4::getTrans(r.x, r.y, 0) * mat;
-
- // Translate by half-texel offsets if necessary
- if (gfx::renderLib == gfx::RL_D3D)
- {
- // Get [-1..1] offsets
- float ox = 1.0 / vp->getTarget()->getWidth();
- float oy = 1.0 / vp->getTarget()->getHeight();
-
- // Subtract from quad position
- mat = mat4::getTrans(-ox, oy, 0) * mat;
- // (using a positive Y offset because Y goes up
- // in this space)
- }
-
- // Flip if needed for GL render targets
- if (vp->getTarget()->requiresTextureFlipping())
- mat = mat4::getScale(1, -1, 1) * mat;
-
- Ogre::GpuProgramParametersSharedPtr vertParams = pass->getVertexProgramParameters();
-
- if (vertParams->_findNamedConstantDefinition("mat"))
- vertParams->setNamedConstant("mat", mat);
-
- if (vertParams->_findNamedConstantDefinition("invSize"))
- {
- Ogre::TexturePtr tex = gfx::getTexture(_texture);
- if (tex.get())
- {
- vec4 v(1.0 / tex->getWidth(), 1.0 / tex->getHeight(), 1, 1);
- vertParams->setNamedConstant("invSize", v);
- }
- }
-
- // TODO: !!!!!!
- //_rs->bindGpuProgramParameters(Ogre::GPT_VERTEX_PROGRAM, vertParams);
-
- Ogre::GpuProgramParametersSharedPtr fragParams = pass->getFragmentProgramParameters();
-
- if (fragParams->_findNamedConstantDefinition("alpha"))
- fragParams->setNamedConstant("alpha", _alpha);
-
- if (fragParams->_findNamedConstantDefinition("colour"))
- fragParams->setNamedConstant("colour", _colour);
-
- if (fragParams->_findNamedConstantDefinition("invSize"))
- {
- Ogre::TexturePtr tex = gfx::getTexture(_texture);
- if (tex.get())
- {
- vec4 v(1.0 / tex->getWidth(), 1.0 / tex->getHeight(), 1, 1);
- fragParams->setNamedConstant("invSize", v);
- }
- }
-
- // TODO: !!!!!!
- //_rs->bindGpuProgramParameters(Ogre::GPT_FRAGMENT_PROGRAM, fragParams);
-
- _rs->_beginFrame();
- _rs->_render(rop);
- _rs->_endFrame();
- }
- }
-}
99 src/gui/brush.hpp
View
@@ -1,99 +0,0 @@
- /*
- * Copyright (c) 2008-2010 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-/*
- * Update list:
- * date
- * comments
- */
-
-#ifndef BRUSH_HPP_INCLUDED
-#define BRUSH_HPP_INCLUDED
-
-#include "pre_ogre.hpp"
-
-#include "types.hpp"
-#include "id.hpp"
-
-namespace engine
-{
- namespace gui
- {
- /**
- * Gui brush object
- */
- class brush
- {
- private:
- /// Render system
- Ogre::RenderSystem *_rs;
-
- /// Passes for different states
- Ogre::Pass *_pass, *_selectPass, *_pressPass, *_noBlendPass;
-
- /// Quad for brush
- Ogre::ManualObject *_quad;
-
- /// Brush texture name
- string _texture;
-
- /// Opacity of brush
- float _alpha;
-
- /// Brush color
- colour _colour;
-
- /// Map of brushes names
- static idGen _idGen;
-
- public:
- /**
- * Constructor
- */
- brush();
-
- /**
- * Destructor
- */
- ~brush();
-
- /**
- * Set texture for the brush
- * @param str name of texture from resources
- */
- void texture(const string &str) { _texture = str; }
-
- /**
- * Set opacity of brush
- * @param a brush opacity from 0.0 to 1.0(full opacity)
- */
- void alpha(float a) { _alpha = a; }
-
- /**
- * Brush color
- * @param c color to use
- */
- void colourMult(const ::engine::colour &c) { _colour = c; }
-
- /// Different kinds of effects for brush
- enum effect
- {
- E_NONE, E_SELECT, E_PRESS, E_NO_BLEND
- };
-
- /**
- * Render brush quad
- * @param vp viewport to render in
- * @param rect vector4 - 4 coordinates of rectangle to use brush in
- * @param e use some effect for brush quad
- */
- void render(Ogre::Viewport *vp, const vec4 &rect, const effect &e = E_NONE) const;
- };
- }
-}
-
-
-#endif // BRUSH_HPP_INCLUDED
70 src/gui/button.cpp
View
@@ -1,70 +0,0 @@
- /*
- * Copyright (c) 2008-2010 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#include "button.hpp"
-#include "text.hpp"
-
-namespace engine
-{
- namespace gui
- {
- button::button(const string &name, bool internal):
- panel(name, internal),
- _text(new text(_name + "::_text", true))
- {
- update
-// ("texture", string("gui/back_med.png"))
- ("size", vec2(96, 32))
- ("draggable", false);
-
- child(_text)
- ("text", string("<text>"))
- ("colour", colour::White)
- ("clickable", true)
- .callback("onClick", boost::bind(&button::_clickText, this, _1));
-// ("selectParent", true);
- }
-
- button::~button()
- {
- }
-
- string button::getSkinType() const
- {
- return "button";
- }
-
- void button::_clickText(const event &e)
- {
- _fireCallback("onClick", e.misc);
- }
-
- boost::any button::attrib(const string &name) const
- {
- if (name == "text") return _text->attrib("text");
-
- else return panel::attrib(name);
-
- return boost::any();
- }
-
- widget &button::update(const string &name, const boost::any &val)
- {
- if (name == "text") _text->update("text", val);
-
- else return panel::update(name, val);
-
- return *this;
- }
-
- void button::tick(real dt)
- {
- panel::tick(dt);
- _text->update
- ("position", size * vec2(0.5, 0.5) - _text->size * vec2(0.5, 0.5));
- }
- }
-}
64 src/gui/button.hpp
View
@@ -1,64 +0,0 @@
- /*
- * Copyright (c) 2008-2009 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#ifndef BUTTON_HPP_INCLUDED
-#define BUTTON_HPP_INCLUDED
-
-#include "panel.hpp"
-#include "text.hpp"
-
-namespace engine
-{
- namespace gui
- {
- /**
- * Button widget
- */
- class button;
-
- /// Shared pointer for the button
- typedef boost::shared_ptr<button> buttonPtr;
-
- class button: public panel
- {
- protected:
- /// Button label text
- textPtr _text;
-
- /**
- * Click event
- * @param e called event additional data
- */
- void _clickText(const event &e);
-
- public:
- /**
- * Constructor
- */
- button(const string &name, bool internal = false);
-
- /**
- * Destructor
- */
- ~button();
-
- /**
- * Update button from global application cycle
- */
- void tick(real dt);
-
- /**
- * Get current object type
- */
- string getSkinType() const;
-
- widget &update(const string &name, const boost::any &val);
- boost::any attrib(const string &name) const;
- };
- }
-}
-
-#endif // BUTTON_HPP_INCLUDED
64 src/gui/check_box.cpp
View
@@ -1,64 +0,0 @@
- /*
- * Copyright (c) 2008-2009 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#include "check_box.hpp"
-#include "safe_any.hpp"
-
-namespace engine
-{
- namespace gui
- {
-
- checkBox::checkBox(const string &name, bool internal):
- panel(name, internal),
- _check(new panel("check", true))
- {
- _interfaces.push_back(WIDGET_CHECK_BOX);
-
- size = vec2(16, 16);
- draggable = false;
- decorate = true;
-
- addChild(_check);
- _check->textureName("checkbox_tix.png");
- _check->fitTextureSize();
- _check->visible = false;
- _check->selectParent = true;
- _check->decorate = false;
- _check->draggable = false;
- }
-
- checkBox::~checkBox()
- {
- }
-
- string checkBox::getSkinType() const
- {
- return "checkBox";
- }
-
- bool checkBox::checked() const
- {
- return _check->visible;
- }
-
- void checkBox::checked(bool b)
- {
- _check->visible = b;
- }
-
- void checkBox::mouseUp(const vec2 &p, mouseButton b)
- {
- if (b == MB_LEFT)
- {
- _check->visible = !_check->visible;
- _fireCallback("onCheck", _check->visible);
- }
- }
-
- }
-
-}
45 src/gui/check_box.hpp
View
@@ -1,45 +0,0 @@
- /*
- * Copyright (c) 2008-2009 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#ifndef CHECK_BOX_HPP_INCLUDED
-#define CHECK_BOX_HPP_INCLUDED
-
-#include "panel.hpp"
-#include "text.hpp"
-
-namespace engine
-{
-
- namespace gui
- {
-
- class checkBox;
- typedef boost::shared_ptr<checkBox> checkBoxPtr;
-
- class checkBox: public panel
- {
- protected:
-
- panelPtr _check;
-
- public:
-
- checkBox(const string &name, bool internal = false);
- ~checkBox();
-
- string getSkinType() const;
-
- void checked(bool b);
- bool checked() const;
-
- void mouseUp(const vec2 &p, mouseButton b);
- };
-
- }
-
-}
-
-#endif // CHECK_BOX_HPP_INCLUDED
148 src/gui/console.cpp
View
@@ -1,148 +0,0 @@
- /*
- * Copyright (c) 2008-2009 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#include <boost/foreach.hpp>
-#include <boost/bind.hpp>
-#include <boost/lexical_cast.hpp>
-
-#include <OgreLogManager.h>
-
-#include "console.hpp"
-#include "safe_any.hpp"
-
-namespace engine
-{
- namespace gui
- {
-
- console::console(const string &name, bool internal):
- window(name, internal),
- _curLine(_lines.end()),
- _input(new textBox("input", true)),
- _listeningToLog(false)
- {
- _interfaces.push_back(WIDGET_CONSOLE);
-
- addChild(_input);
- _input->adjustSize(vec2(size.x, 1));
- _input->setCallback("onEnter", boost::bind(&console::_enterInput, this, _1));
- _input->setCallback("onSpecialKey", boost::bind(&console::_inputUpDown, this, _1));
- _input->obeyOffset = false;
- _input->draggable = false;
- _input->clippable = false;
- }
-
- console::~console()
- {
- if (_listeningToLog)
- listenToLog(false); // just in case
- }
-
- void console::messageLogged(const string &str, Ogre::LogMessageLevel lvl, bool maskDebug, const string &name)
- {
- switch (lvl)
- {
- case Ogre::LML_TRIVIAL:
- addLine(str);
- break;
-
- case Ogre::LML_NORMAL:
- addLine(str, colour(0, 0, 0));
- break;
-
- case Ogre::LML_CRITICAL:
- addLine(str, colour(1, 0, 0));
- break;
- }
- }
-
- void console::listenToLog(bool b)
- {
- _listeningToLog = b;
- if (!b)
- Ogre::LogManager::getSingleton().getLog(LOG_NAME)->removeListener(this);
- else
- Ogre::LogManager::getSingleton().getLog(LOG_NAME)->addListener(this);
- }
-
- void console::addLine(const string &str, const colour &c)
- {
- textPtr t(new text("line" + boost::lexical_cast<string>(_lines.size())));
- addChild(t);
-
- float y = 0;
- if (!_lines.empty())
- // use actualSize() since the size variable might not be updated yet
- // if the text is not yet rendered
- y = _lines.back()->position.y + _lines.back()->actualSize().y;
-
- t->setText(str);
- // if no lines, then at 0 Y, but otherwise, at the previous line Y + prev. line height
- t->position = vec2(0, y);
- t->draggable = false;
- t->selectParent = true;
-
- _lines.push_back(t);
-
- // reset our current line
- _curLine = _lines.end(); --_curLine;
- }
-
- void console::clear()
- {
- BOOST_FOREACH(textPtr &i, _lines)
- {
- removeChild(i->name());
- }
- _lines.clear();
- }
-
- void console::_enterInput(const event &e)
- {
- string str = SAFE_ANY_CAST(string, e.misc);
- addLine(str, colour::White);
- // raise an event of our own
- _fireCallback("onEnter", str);
- // clear input
- _input->clear();
- }
-
- void console::_inputUpDown(const event &e)
- {
- if (_curLine == _lines.end())
- return;
-
- specialKey k = SAFE_ANY_CAST(specialKey, e.misc);
-
- if (k == SK_UP && _curLine != _lines.begin())
- {
- --_curLine;
- _input->setText((*_curLine)->getText());
- }
- else if (k == SK_DOWN)
- {
- if (++_curLine != _lines.end())
- _input->setText((*_curLine)->getText());
- else
- _input->clear();
- }
- }
-
- void console::tick(real dt)
- {
- window::tick(dt);
-
- float height = rect().w;
- if (_xScrollbar->visible)
- height += _xScrollbar->rect().w;
-
- _input->adjustSize(vec2(size.x, 1));
- _input->position = vec2(0, height);
- }
-
- }
-
-}
58 src/gui/console.hpp
View
@@ -1,58 +0,0 @@
- /*
- * Copyright (c) 2008-2009 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#ifndef CONSOLE_HPP_INCLUDED
-#define CONSOLE_HPP_INCLUDED
-
-#include <list>
-
-#include <OgreLog.h>
-
-#include "window.hpp"
-#include "text_box.hpp"
-#include "text.hpp"
-
-namespace engine
-{
- namespace gui
- {
-
- class console: public window, public Ogre::LogListener
- {
- protected:
-
- typedef std::list<textPtr> lineList;
- lineList _lines;
- lineList::iterator _curLine;
-
-// scrollablePanelPtr _linesPanel;
- textBoxPtr _input;
-
- bool _listeningToLog;
-
- void _enterInput(const event &e);
- void _inputUpDown(const event &e);
-
- public:
-
- void listenToLog(bool b);
- // as an Ogre::LogListener
- void messageLogged(const string &str, Ogre::LogMessageLevel lvl, bool maskDebug, const string &name);
-
- void addLine(const string &str, const colour &c = colour::Black);
- void clear();
-
- console(const string &name, bool internal = false);
- ~console();
-
- void tick(real dt);
- };
-
- }
-}
-
-
-#endif // CONSOLE_HPP_INCLUDED
109 src/gui/drop_down_menu.cpp
View
@@ -1,109 +0,0 @@
- /*
- * Copyright (c) 2008-2009 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#include <cmath>
-#include <numeric>
-
-#include <boost/foreach.hpp>
-#include <boost/bind.hpp>
-#include <boost/any.hpp>
-
-#include "drop_down_menu.hpp"
-#include "safe_any.hpp"
-#include "layout.hpp"
-
-namespace engine
-{
-
-
- namespace gui
- {
-
- string dropDownMenuChoices::getSkinType() const
- {
- return "dropDownMenu";
- }
-
- dropDownMenu::dropDownMenu(const string &name, bool internal):
- panel(name, internal),
- _selection(new text("selection", true)),
- _choices(new dropDownMenuChoices("choices", true))
- {
- _interfaces.push_back(WIDGET_DROP_DOWN_MENU);
-
- addChild(_selection);
- _selection->selectParent = true;
-
- addChild(_choices);
- _choices->clippable = false;
- _choices->obeyOffset = false;
- _choices->draggable = false;
- _choices->selectParent = true;
- _choices->visible = false;
-
- _choices->setLayout(layoutPtr(new verticalLayout()));
- }
-
- dropDownMenu::~dropDownMenu()
- {
- }
-
- void dropDownMenu::tick(real dt)
- {
- panel::tick(dt);
-
- _choices->position = vec2(0, rect().w);
- _choices->size = vec2(size.x, 256);
- _choices->visible = active;
- }
-
- void dropDownMenu::_select(const event &e)
- {
-// string text = SAFE_ANY_CAST(string, e.caller.attrib("text"));
-//
-// _selection->setText(text);
-//
-// _fireCallback("onSelect", text);
- }
-
- string dropDownMenu::getSkinType() const
- {
- return "dropDownMenu";
- }
-
- void dropDownMenu::addChoice(const string &str)
- {
- layoutPtr lay = _choices->getLayout();
- assert(lay);
-
- textPtr choice(new text("choice" + boost::lexical_cast<string>(lay->numItems())));
- _choices->addChild(choice);
- lay->addWidget(choice);
-
- choice->setText(str);
- choice->selectParent = false;
- choice->draggable = false;
- choice->clickable = true;
- choice->setCallback("onClick", boost::bind(&dropDownMenu::_select, this, _1));
- }
-
- void dropDownMenu::adjustSize(const vec2 &v)
- {
- // x == pixels, y == y * text height
- size = v * vec2(1, _selection->info('X').h);
- }
-
- void dropDownMenu::mouseUp(const vec2 &p, mouseButton b)
- {
- panel::mouseUp(p, b);
-
- active = !active;
- }
-
- }
-
-}
-
71 src/gui/drop_down_menu.hpp
View
@@ -1,71 +0,0 @@
- /*
- * Copyright (c) 2008-2009 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#ifndef DROP_DOWN_MENU_HPP_INCLUDED
-#define DROP_DOWN_MENU_HPP_INCLUDED
-
-#include "scrollable_panel.hpp"
-#include "text.hpp"
-
-namespace engine
-{
-
-
- namespace gui
- {
-
- class dropDownMenuChoices: public scrollablePanel
- {
- public:
-
- dropDownMenuChoices(const string &name, bool internal = false):
- scrollablePanel(name, internal)
- {
- }
- ~dropDownMenuChoices()
- {
- }
-
- string getSkinType() const;
-
- };
-
- class dropDownMenu: public panel
- {
- protected:
-
- textPtr _selection;
-
- scrollablePanelPtr _choices;
-
-// unsigned _numChoices;
-
- void _select(const event &e);
-
- public:
-
- dropDownMenu(const string &name, bool internal = false);
- ~dropDownMenu();
-
- void addChoice(const string &str);
- void adjustSize(const vec2 &v);
-
- void tick(real dt);
-
- void mouseUp(const vec2 &p, mouseButton b);
-
- string getSkinType() const;
-
- };
-
- typedef boost::shared_ptr<dropDownMenu> dropDownMenuPtr;
-
- }
-
-
-}
-
-#endif // DROP_DOWN_MENU_HPP_INCLUDED
215 src/gui/file_dialog.cpp
View
@@ -1,215 +0,0 @@
- /*
- * Copyright (c) 2008-2009 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#include <boost/foreach.hpp>
-#include <boost/bind.hpp>
-#include <boost/filesystem.hpp>
-#include <boost/lexical_cast.hpp>
-
-#include "file_dialog.hpp"
-#include "safe_any.hpp"
-#include "data_dir.hpp"
-
-namespace fs = boost::filesystem;
-
-namespace engine
-{
- namespace gui
- {
-
- fileDialog::fileDialog(const string &name):
- window(name),
- _input(new textBox("input", true)),
- _go(new button("go", true)),
- relativeToDataDir(true)
- {
- _interfaces.push_back(WIDGET_FILE_DIALOG);
-
- addChild(_input);
- _input->adjustSize(vec2(size.x, 1));
- _input->setCallback("onEnter", boost::bind(&fileDialog::_enterInput, this, _1));
- _input->obeyOffset = false;
- _input->draggable = false;
- _input->clippable = false;
-
- addChild(_go);
- _go->obeyOffset = false;
- _go->clippable = false;
- _go->draggable = false;
- _go->setText("go");
- _go->setCallback("onClick", boost::bind(&fileDialog::_clickGo, this, _1));
-
- title("file dialog");
-
- _exploreDir(DATA_DIR);
- }
-
- fileDialog::~fileDialog()
- {
- }
-
- void fileDialog::_clearDirs()
- {
- BOOST_FOREACH(dir &i, _dirs)
- {
- removeChild(i.icon->name());
- removeChild(i.text->name());
- }
- _dirs.clear();
- _selection.reset();
- }
-
- void fileDialog::_exploreDir(const string &str)
- {
- fs::path path(str);
-
- if (!fs::is_directory(path))
- return;
-
- _currentDir = str;
-
- _clearDirs();
-
- // create parent-directory object
- {
- panelPtr icon(new panel("_dirs0_icon"));
- addChild(icon);
- icon->textureName("gui/directory.png");
- icon->position = vec2(0, 0);
- icon->fitTextureSize();
- icon->draggable = false;
- icon->decorate = false;
- icon->clickable = false;
-
- textPtr t(new text("_dirs0"));
- addChild(t);
- t->setText("../");
- t->position = vec2(icon->size.x + 4, 0);
- t->draggable = false;
- t->clickable = true;
- t->misc = path.branch_path().string();
- t->setCallback("onMouseDown", boost::bind(&fileDialog::_clickDir, this, _1));
- t->setCallback("onDoubleClick", boost::bind(&fileDialog::_doubleClickDir, this, _1));
-
- _dirs.push_back(dir(icon, t));
- }
-
- for (fs::directory_iterator i(path), end; i != end; ++i)
- {
- bool isDir = fs::is_directory(*i);
-
- string idx = boost::lexical_cast<string>(_dirs.size());
-
- panelPtr icon(new panel("_dirs" + idx + "_icon"));
- addChild(icon);
- icon->textureName(isDir ? string("gui/directory.png") : string("gui/file.png"));
- icon->position = vec2(0, _dirs.size() * _input->size.y);
- icon->fitTextureSize();
- icon->draggable = false;
- icon->decorate = false;
- icon->clickable = false;
-
- textPtr t(new text("_dirs" + idx));
- addChild(t);
- t->setText(i->path().leaf() + (isDir ? "/" : ""));
- t->position = vec2(icon->size.x + 4, _dirs.size() * _input->size.y);
- t->draggable = false;
- t->clickable = true;
- t->misc = i->path().string();
- t->setCallback("onMouseDown", boost::bind(&fileDialog::_clickDir, this, _1));
- t->setCallback("onDoubleClick", boost::bind(&fileDialog::_doubleClickDir, this, _1));
-
- _dirs.push_back(dir(icon, t));
- }
- }
-
- void fileDialog::_clickDir(const event &e)
- {
- _selection = e.caller.smartPtr();
-
- string str = SAFE_ANY_CAST(string, e.caller.misc);
- // we only want the leaf, not the full path
- // (which is in the misc data)
- _input->setText(fs::path(str).leaf());
- }
-
- void fileDialog::_doubleClickDir(const event &e)
- {
- string str = SAFE_ANY_CAST(string, e.caller.misc);
-
- // we don't use _confirm() here because the misc data
- // is already the full directory, not just the current
- // name relative to the current directory
- if (fs::is_directory(str))
- {
- _exploreDir(str);
- _input->clear();
- }
- else
- {
- _fireConfirmCallback(str);
- }
- }
-
- void fileDialog::_enterInput(const event &e)
- {
- string str = SAFE_ANY_CAST(string, e.misc);
- _confirm(str);
- }
-
- void fileDialog::_clickGo(const event &e)
- {
- string str = SAFE_ANY_CAST(string, _input->getText());
- _confirm(str);
- }
-
- void fileDialog::_confirm(const string &str)
- {
- if (str.empty())
- return;
-
- if (fs::is_directory(fs::path(_currentDir) / fs::path(str)))
- {
- _exploreDir((fs::path(_currentDir) / fs::path(str)).string());
- _input->clear();
- }
- else
- {
- string final = (fs::path(_currentDir) / fs::path(str)).string();
- _fireConfirmCallback(final);
- }
- }
-
- void fileDialog::_fireConfirmCallback(const string &str)
- {
- if (relativeToDataDir)
- {
- // gotta cut off the data directory from it
- _fireCallback("onConfirm", str.substr(DATA_DIR.size()));
- }
- else
- {
- _fireCallback("onConfirm", str);
- }
- }
-
- void fileDialog::tick(real dt)
- {
- window::tick(dt);
-
- vec4 r = rect();
-
- _input->adjustSize(vec2(size.x - _go->size.x, 1));
- _input->position = vec2(0, r.w);
-
- vec4 ir = _input->rect();
-
- _go->position = vec2(ir.z, r.w);
- }
-
- }
-
-}
72 src/gui/file_dialog.hpp
View
@@ -1,72 +0,0 @@
- /*
- * Copyright (c) 2008-2009 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#ifndef FILE_DIALOG_HPP_INCLUDED
-#define FILE_DIALOG_HPP_INCLUDED
-
-#include <list>
-
-#include <OgreLog.h>
-
-#include "window.hpp"
-#include "text_box.hpp"
-#include "text.hpp"
-#include "button.hpp"
-
-namespace engine
-{
- namespace gui
- {
-
- class fileDialog: public window
- {
- protected:
-
- struct dir
- {
- panelPtr icon;
- textPtr text;
-
- dir(const panelPtr &icon, const textPtr &t):
- icon(icon), text(t) {}
- };
-
- typedef std::list<dir> dirList;
- dirList _dirs;
- widgetPtr _selection;
-
- string _currentDir;
-
- textBoxPtr _input;
- buttonPtr _go;
-
- void _clearDirs();
- void _exploreDir(const string &str);
-
- void _enterInput(const event &e);
- void _clickGo(const event &e);
- void _clickDir(const event &e);
- void _doubleClickDir(const event &e);
- void _confirm(const string &str);
- void _fireConfirmCallback(const string &str);
-
- public:
-
- bool relativeToDataDir;
-
- fileDialog(const string &name);
- ~fileDialog();
-
- void setDir(const string &str);
-
- void tick(real dt);
- };
-
- }
-}
-
-
-#endif // FILE_DIALOG_HPP_INCLUDED
101 src/gui/gui_disp.cpp
View
@@ -6,101 +6,58 @@
#include "gui_disp.hpp"
#include "types.hpp"
-#include "mouse_button.hpp"
-
namespace engine
{
namespace gui
{
- bool guiDisp::keyPressed(const OIS::KeyEvent &e)
- {
- if (!_dispatchSheet)
- return true;
-
- switch (e.key)
- {
- case OIS::KC_RETURN:
- _dispatchSheet->keyDown(SK_ENTER);
- break;
-
- case OIS::KC_BACK:
- _dispatchSheet->keyDown(SK_BACKSPACE);
- break;
-
- case OIS::KC_LEFT:
- _dispatchSheet->keyDown(SK_LEFT);
- break;
- case OIS::KC_RIGHT:
- _dispatchSheet->keyDown(SK_RIGHT);
- break;
-
- case OIS::KC_UP:
- _dispatchSheet->keyDown(SK_UP);
- break;
-
- case OIS::KC_DOWN:
- _dispatchSheet->keyDown(SK_DOWN);
- break;
+ void guiDisp::initGUI(Ogre::RenderWindow *renderWindow, Ogre::SceneManager *sceneMgr)
+ {
+ mPlatform = new MyGUI::OgrePlatform();
+ // Don't forget to send "data", it's the name of resource stream
+ // to load in. Default is 'General'.
+ mPlatform->initialise(renderWindow, sceneMgr);
+ mPlatform->getRenderManagerPtr()->setActiveViewport(1);
+
+ mGUI = new MyGUI::Gui();
+ mGUI->initialise();
+ }
- default:
- _dispatchSheet->keyDown(e.text);
- break;
- }
+ guiDisp::~guiDisp()
+ {
+ /*
+ mGUI->shutdown();
+ delete mGUI;
+ mGUI = 0;
+
+ mPlatform->shutdown();
+ delete mPlatform;
+ mPlatform = 0;*/
+ }
- return true;
+ bool guiDisp::keyPressed(const OIS::KeyEvent &e)
+ {
+ return mGUI->injectKeyPress(MyGUI::KeyCode::Enum(e.key), e.text);
}
bool guiDisp::keyReleased(const OIS::KeyEvent &e)
{
- if (!_dispatchSheet)
- return true;
-
- return true;
+ return mGUI->injectKeyRelease(MyGUI::KeyCode::Enum(e.key));
}
bool guiDisp::mouseMoved(const OIS::MouseEvent &e)
{
-// if (!_gui.mouseVisible())
-// return true;
- if (!_dispatchSheet)
- return true;
-
- _dispatchSheet->mouseMove(vec2(e.state.X.rel, e.state.Y.rel));
- if (int(e.state.Z.rel))
- _dispatchSheet->mouseScroll(e.state.Z.rel * -0.25);
-
- //_gui._mgr->injectMousePosition(e.state.X.abs, e.state.Y.abs);
- //_gui._mgr->injectMouseMove(e.state.X.rel, e.state.Y.rel);
-
- return true;
+ return mGUI->injectMouseMove(e.state.X.abs, e.state.Y.abs, e.state.Z.abs);
}
bool guiDisp::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
{
-// if (!_gui.mouseVisible())
-// return true;
- if (!_dispatchSheet)
- return true;
-
- _dispatchSheet->mouseDown(mouseButton(id));
- //_gui._mgr->injectMouseButtonDown(QuickGUI::MouseButtonID(id));
-
- return true;
+ return mGUI->injectMousePress(e.state.X.abs, e.state.Y.abs, MyGUI::MouseButton::Enum(id));
}
bool guiDisp::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
{
-// if (!_gui.mouseVisible())
-// return true;
- if (!_dispatchSheet)
- return true;
-
- _dispatchSheet->mouseUp(mouseButton(id));
-
- //_gui._mgr->injectMouseButtonUp(QuickGUI::MouseButtonID(id));
-
- return true;
+ return mGUI->injectMouseRelease(e.state.X.abs, e.state.Y.abs, MyGUI::MouseButton::Enum(id));
}
}
}
21 src/gui/gui_disp.hpp
View
@@ -4,19 +4,15 @@
* For conditions of distribution and use, see copyright notice in COPYING
*/
-/*
- * Update list:
- * date
- * comments
- */
-
#ifndef GUI_DISP_HPP_INCLUDED
#define GUI_DISP_HPP_INCLUDED
#include <OIS/OISKeyboard.h>
#include <OIS/OISMouse.h>
-#include "sheet.hpp"
+#include "MyGUI.h"
+#include "MyGUI_OgrePlatform.h"
+#include "MyGUI_OgreRenderManager.h"
namespace engine
{
@@ -25,11 +21,16 @@ namespace engine
class guiDisp: public OIS::KeyListener, public OIS::MouseListener
{
protected:
- // TODO: comment this
- sheetPtr _dispatchSheet;
+ MyGUI::Gui *mGUI;
+ MyGUI::OgrePlatform *mPlatform;
public:
/**
+ * @brief Configure gui system
+ */
+ virtual void initGUI(Ogre::RenderWindow *renderWindow, Ogre::SceneManager *sceneMgr);
+
+ /**
* Constructor
*/
guiDisp() {}
@@ -37,7 +38,7 @@ namespace engine
/**
* Destructor
*/
- virtual ~guiDisp() {}
+ virtual ~guiDisp();
/**
* Event key pressed
140 src/gui/layout.cpp
View
@@ -1,140 +0,0 @@
- /*
- * Copyright (c) 2008-2010 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#include "layout.hpp"
-#include "widget.hpp"
-
-namespace engine
-{
- namespace gui
- {
- widgetLayoutItem::widgetLayoutItem(const widgetPtr &w):
- _widget(w)
- {
- assert(_widget);
- }
-
- vec2 widgetLayoutItem::size() const
- {
- vec4 r = _widget->rect();
- return vec2(r.z, r.w);
- }
-
- void widgetLayoutItem::size(const vec2 &v)
- {
- // Apply new size
- _widget->sizeWithSkin(v);
- }
-
- vec2 widgetLayoutItem::pos() const
- {
- return _widget->position;
- }
-
- void widgetLayoutItem::pos(const vec2 &v)
- {
- _widget->position = v;
- }
-
- layout::layout(float pad):
- padding(pad)
- {
- }
-
- layout::~layout()
- {
- }
-
- vec2 layout::size() const
- {
- // Go through all items in the layour
- // and calculate their joined size
- vec2 ret(0, 0);
- BOOST_FOREACH(const layoutItemPtr &i, _items)
- {
- vec2 r = i->pos() + i->size();
- ret.x = std::max<float>(ret.x, r.x);
- ret.y = std::max<float>(ret.y, r.y);
- }
- return ret;
- }
-
- void layout::addWidget(const boost::shared_ptr<widget> &w)
- {
- if (!w)
- {
- //log("Tried to add null widget to layout");
- //log("Can't add empty widget into the layout");
- return;
- }
- _items.push_back(layoutItemPtr(new widgetLayoutItem(w)));
- }
-
- void layout::addLayout(const layoutPtr &lay)
- {
- _items.push_back(layoutItemPtr(new layoutLayoutItem(lay)));
- }
-
- layoutLayoutItem::layoutLayoutItem(const layoutPtr &lay):
- _layout(lay)
- {
- assert(_layout);
- }
-
- vec2 layoutLayoutItem::size() const
- {
- return _layout->size();
- }
-
- void layoutLayoutItem::size(const vec2 &v)
- {
- }
-
- vec2 layoutLayoutItem::pos() const
- {
- return vec2(0, 0);
- }
-
- void layoutLayoutItem::pos(const vec2 &v)
- {
- }
-
- void layoutLayoutItem::tick(real dt)
- {
- _layout->tick(dt);
- }
-
- void verticalLayout::tick(real dt)
- {
- vec2 p(padding, padding);
-
- BOOST_FOREACH(layoutItemPtr &i, _items)
- {
- i->pos(p);
-
- // Set new vertical pozition for items
- p.y += i->size().y + padding;
- }
- }
-
- void horizontalLayout::tick(real dt)
- {
- vec2 p(padding, padding);
-
- BOOST_FOREACH(layoutItemPtr &i, _items)
- {
- i->pos(p);
-
- // Set new horizontal pozition for items
- p.x += i->size().x + padding;
- }
- }
- }
-}
-
-
-
-
185 src/gui/layout.hpp
View
@@ -1,185 +0,0 @@
- /*
- * Copyright (c) 2008-2010 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#ifndef LAYOUT_HPP_INCLUDED
-#define LAYOUT_HPP_INCLUDED
-
-#include <boost/shared_ptr.hpp>
-
-//#include "widget.hpp"
-#include "types.hpp"
-
-namespace engine
-{
- namespace gui
- {
- class widget;
-
- /**
- * \brief Layout unit
- *
- * Inner object of the layout
- */
- class layoutItem
- {
- public:
- /**
- * Destructor
- */
- virtual ~layoutItem() {}
-
- /**
- * Get layout size
- */
-
- virtual vec2 size() const = 0;
- /**
- * Set layout size
- * @param v layout size
- */
- virtual void size(const vec2 &v) = 0;
-
- /**
- * Get layout position
- */
- virtual vec2 pos() const = 0;
-
- /**
- * Set layout position
- * @param v new layout position
- */
- virtual void pos(const vec2 &v) = 0;
-
- /**
- * Update layout from global application cycle
- */
- virtual void tick(real dt) {}
- };
-
- /// Shared pointer for the layout item
- typedef boost::shared_ptr<layoutItem> layoutItemPtr;
-
- /// List of items for layout
- typedef std::vector<layoutItemPtr> layoutItemList;
-
- /**
- * Widget-based layout item object
- */
- class widgetLayoutItem: public layoutItem
- {
- private:
- /// Item will use this widget
- boost::shared_ptr<widget> _widget;
-
- public:
- /**
- * Constructor
- */
- widgetLayoutItem(const boost::shared_ptr<widget> &w);
-
- vec2 size() const;
- void size(const vec2 &v);
-
- vec2 pos() const;
- void pos(const vec2 &v);
- };
-
- /**
- * Layout system
- */
- class layout;
-
- /// Shared pointer for the layout system
- typedef boost::shared_ptr<layout> layoutPtr;
-
- class layout
- {
- protected:
- /// List of items in layout object
- layoutItemList _items;
-
- public:
- /**
- * Get number of items in layout
- */
- const layoutItemList::size_type numItems() const
- {
- return _items.size();
- }
-
- /// Layout-items padding from parent border
- float padding;
-
- /**
- * Constructor
- * @param pad default items padding
- */
- layout(float pad = 4);
-
- /**
- * Destructor
- */
- virtual ~layout();
-
- /**
- * Add own widget into the layout
- * @param w shared pointer for the widget to add in
- */
- void addWidget(const boost::shared_ptr<widget> &w);
-
- /**
- * Add another layout into the layout
- * @param lay link to the pointer of another layout
- */
- void addLayout(const layoutPtr &lay);
-
- vec2 size() const;
-
- virtual void tick(real dt) = 0;
- };
-
- // TODO
- class layoutLayoutItem: public layoutItem
- {
- private:
-
- layoutPtr _layout;
-
- public:
-
- layoutLayoutItem(const layoutPtr &lay);
-
- vec2 size() const;
- void size(const vec2 &v);
-
- vec2 pos() const;
- void pos(const vec2 &v);
-
- void tick(real dt);
- };
-
- /**
- * \breif Layout with vertical-stacked items
- */
- class verticalLayout: public layout
- {
- public:
- void tick(real dt);
- };
-
- /**
- * \breif Layout with horizontal-stacked items
- */
- class horizontalLayout: public layout
- {
- public:
-
- void tick(real dt);
- };
- }
-}
-
-#endif // LAYOUT_HPP_INCLUDED
45 src/gui/mouse.cpp
View
@@ -1,45 +0,0 @@
- /*
- * Copyright (c) 2008-2010 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-/*
- * Update list:
- * date
- * comments
- */
-
-#include <OgrePass.h>
-#include <OgreViewport.h>
-
-#include "mouse.hpp"
-
-namespace engine
-{
- namespace gui
- {
- mouse::mouse(const string &name):
- panel(name)
- {
- (*this)
- ("texture", string("gui/mouse.png"))
- ("autoSize");
- }
-
- mouse::~mouse()
- {
- }
-
- // TODO: Remove rendering cursor by hands
-
-// void mouse::_renderThis(Ogre::Viewport *vp)
-// {
-// // render directly, no caching here
-// _pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
-// _pass->getTextureUnitState(0)->setTextureName(_textureName);
-// _quad->render(_pass, vp);
-// }
-
- }
-}
44 src/gui/mouse.hpp
View
@@ -1,44 +0,0 @@
- /*
- * Copyright (c) 2008-2010 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-/*
- * Update list:
- * date
- * comments
- */
-
-#ifndef MOUSE_HPP_INCLUDED
-#define MOUSE_HPP_INCLUDED
-
-#include "panel.hpp"
-
-namespace engine
-{
- namespace gui
- {
- /**
- * This class represents mouse widget (cursor)
- */
- class mouse: public panel
- {
- public:
- /**
- * Constructor
- */
- mouse(const string &name);
-
- /**
- * Destructor
- */
- ~mouse();
-
- // TODO: Remove if not needed
- //void _renderThis(Ogre::Viewport *vp);
- };
- }
-}
-
-#endif // MOUSE_HPP_INCLUDED
32 src/gui/mouse_button.hpp
View
@@ -1,32 +0,0 @@
- /*
- * Copyright (c) 2008-2010 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#ifndef MOUSE_BUTTON_HPP_INCLUDED
-#define MOUSE_BUTTON_HPP_INCLUDED
-
-namespace engine
-{
- namespace gui
- {
- /// List of available mouse buttons
- enum mouseButton
- {
- MB_LEFT,
- // what kind of fucking idiot used a #define for this?
- // ^ :D max
- #undef MB_RIGHT
- MB_RIGHT,
- MB_MIDDLE,
- MB_AUX0,
- MB_AUX1,
- MB_AUX2,
- MB_AUX3,
- MB_AUX4
- };
- }
-}
-
-#endif // MOUSE_BUTTON_HPP_INCLUDED
250 src/gui/panel.cpp
View
@@ -1,250 +0,0 @@
- /*
- * Copyright (c) 2008-2010 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-/*
- * Update list:
- * date
- */
-
-#include <boost/foreach.hpp>
-
-#include <OgrePass.h>
-#include <OgreTextureUnitState.h>
-#include <OgreTexture.h>
-#include <OgreTextureManager.h>
-
-#include "panel.hpp"
-#include "safe_any.hpp"
-#include "brush.hpp"
-#include "skin.hpp"
-
-#include "gfx/utils.hpp"
-
-namespace engine
-{
-
- namespace gui
- {
-
- panel::panel(const string &name, bool internal):
- widget(name, internal)
- {
- }
-
- panel::~panel()
- {
- }
-
- string panel::getSkinType() const
- {
- return "panel";
- }
-
- void panel::_renderThis(Ogre::Viewport *vp)
- {
- widget::_renderThis(vp);
-
- brush *bru = getBrush();
- assert(bru);
-
- bru->alpha(derivedAlpha());
- bru->colourMult(_colour);
-
- vec2 dp = derivedPosition();
-
- if (decorate)
- {
- if (skin *s = getSkin())
- {
- const string TYPE = getSkinType();
-
- const skin::piece &tl = s->getPiece(TYPE, A_TL);
- const skin::piece &tr = s->getPiece(TYPE, A_TR);
- const skin::piece &t = s->getPiece(TYPE, A_T);
-
- float topSize = std::max(std::max(tl.size.y, tr.size.y), t.size.y);
-
- const skin::piece &bl = s->getPiece(TYPE, A_BL);
- const skin::piece &br = s->getPiece(TYPE, A_BR);
- const skin::piece &b = s->getPiece(TYPE, A_B);
-
- const skin::piece &l = s->getPiece(TYPE, A_L);
- const skin::piece &r = s->getPiece(TYPE, A_R);
-
- float leftSize = std::max(std::max(tl.size.x, bl.size.x), l.size.x);
-
- const skin::piece &mi = s->getPiece(TYPE, A_MI);
-
- if (!tl.tex.empty())
- {
- bru->texture(tl.tex);
- bru->render(vp, vec4(dp.x, dp.y, tl.size.x, tl.size.y));
- }
-
- if (!tr.tex.empty())
- {
- bru->texture(tr.tex);
- bru->render(vp, vec4(dp.x + size.x + leftSize, dp.y, tr.size.x, tr.size.x));
- }
-
- if (!t.tex.empty())
- {
- bru->texture(t.tex);
- bru->render(vp, vec4(dp.x + leftSize, dp.y, size.x, t.size.y));
- }
-
- if (!bl.tex.empty())
- {
- bru->texture(bl.tex);
- bru->render(vp, vec4(dp.x, dp.y + size.y + topSize, bl.size.x, bl.size.y));
- }
-
- if (!br.tex.empty())
- {
- bru->texture(br.tex);
- bru->render(vp, vec4(dp.x + size.x + leftSize, dp.y + size.y + topSize, br.size.x, br.size.x));
- }
-
- if (!b.tex.empty())
- {
- bru->texture(b.tex);
- bru->render(vp, vec4(dp.x + leftSize, dp.y + size.y + topSize, size.x, b.size.y));
- }
-
- if (!l.tex.empty())
- {
- bru->texture(l.tex);
- bru->render(vp, vec4(dp.x, dp.y + topSize, l.size.x, size.y));
- }
-
- if (!r.tex.empty())
- {
- bru->texture(r.tex);
- bru->render(vp, vec4(dp.x + size.x + leftSize, dp.y + topSize, r.size.x, size.y));
- }
-
- if (!mi.tex.empty())
- {
- bru->texture(mi.tex);
- bru->render(vp, vec4(dp.x + leftSize, dp.y + topSize, size.x, size.y));
- }
- }
- }
-
- if (_textureName.empty())
- return;
-
- string texName = _textureName;
- if (skin *s = getSkin())
- texName = s->getTexture(texName);
-
- Ogre::TexturePtr tex = gfx::getTexture(texName);
- if (!tex.get())
- {
- _textureName.clear();
- return;
- }
-
-// if (!b)
-// {
-// _textureName.clear();
-// log("widget " + _name + " has no brush");
-// }
-
- vec4 dcr = derivedChildrenRect();
-
- bru->texture(texName);
-
- if (clickable && _mouseDown)
- bru->render(vp, dcr, brush::E_PRESS);
- else
- {
- if (blend)
- bru->render(vp, dcr);
- else
- bru->render(vp, dcr, brush::E_NO_BLEND);
-
- // if the mouse is over us and we're not fading
- if (clickable && _mouseOver && derivedVisible())
- {
- bru->render(vp, dcr, brush::E_SELECT);
- }
- }
- }
-
- vec2 panel::skinOffset(const align_t &a) const
- {
- if (decorate)
- {
- if (skin *s = getSkin())
- {
- const string TYPE = getSkinType();
-
- const skin::piece &tl = s->getPiece(TYPE, A_TL);
- const skin::piece &tr = s->getPiece(TYPE, A_TR);
- const skin::piece &t = s->getPiece(TYPE, A_T);
-
- float topSize = std::max(std::max(tl.size.y, tr.size.y), t.size.y);
-
- const skin::piece &bl = s->getPiece(TYPE, A_BL);
- const skin::piece &br = s->getPiece(TYPE, A_BR);
- const skin::piece &b = s->getPiece(TYPE, A_B);
-
- const skin::piece &l = s->getPiece(TYPE, A_L);
- const skin::piece &r = s->getPiece(TYPE, A_R);
-
- float leftSize = std::max(std::max(tl.size.x, bl.size.x), l.size.x);
-
- float rightSize = std::max(std::max(tr.size.x, br.size.x), r.size.x);
-
- float bottomSize = std::max(std::max(bl.size.y, br.size.y), b.size.y);
-
-// const skin::piece &p = s->getPiece(getSkinType(), a);
-// return p.size;
- if (a == A_TL) return vec2(leftSize, topSize);
- else if (a == A_T) return vec2(0, topSize);
- else if (a == A_TR) return vec2(rightSize, topSize);
- else if (a == A_R) return vec2(rightSize, 0);
- else if (a == A_BR) return vec2(rightSize, bottomSize);
- else if (a == A_B) return vec2(0, bottomSize);
- else if (a == A_BL) return vec2(leftSize, bottomSize);
- else if (a == A_L) return vec2(leftSize, 0);
- else if (a == A_MI) return vec2(0, 0);
- }
- }
- return vec2(0, 0);
- }
-
- boost::any panel::attrib(const string &name) const
- {
- if (name == "texture" || name == "textureName") return _textureName;
- else return widget::attrib(name);
- return boost::any();
- }
-
- widget &panel::update(const string &name, const boost::any &val)
- {
- //using boost::any_cast;
- if (name == "texture" || name == "textureName") _textureName = SAFE_ANY_CAST(string, val);
- else if (name == "autoSize" && !_textureName.empty())
- {
- string texName = _textureName;
- if (skin *s = getSkin())
- texName = s->getTexture(texName);
-
- Ogre::TexturePtr tex = gfx::getTexture(texName);
- if (tex.get())
- {
- update
- ("size", vec2(tex->getWidth(), tex->getHeight()));
- }
- }
- else return widget::update(name, val);
-
- return *this;
- }
- }
-}
67 src/gui/panel.hpp
View
@@ -1,67 +0,0 @@
- /*
- * Copyright (c) 2008-2010 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#ifndef PANEL_HPP_INCLUDED
-#define PANEL_HPP_INCLUDED
-
-#include "pre_ogre.hpp"
-#include "widget.hpp"
-#include "types.hpp"
-
-namespace engine
-{
- namespace gui
- {
- // TODO: Comment panel class
- class panel;
-
- /// Base type for shared pointer onto panel object
- typedef boost::shared_ptr<panel> panelPtr;
-
- class panel: public widget
- {
- protected:
- /// Name of texture to use with this panel
- string _textureName;
-
- /// Render this current object manually
- virtual void _renderThis(Ogre::Viewport *vp);
-
- public:
- /**
- * Constructor
- */
- panel(const string &name, bool internal = false);
-
- /**
- * Destructor
- */
- virtual ~panel();
-
- // TODO: comment this
- virtual vec2 skinOffset(const align_t &a = A_TL) const;
-
- /**
- * Get the type of current object
- */
- virtual string getSkinType() const;
-
- /**
- * Update given attribute name of current object
- * @param name attribute name to work with
- */
- virtual widget &update(const string &name, const boost::any &val);
-
- /**
- * Get additional attribute for given object name
- * @name attribute to get
- */
- virtual boost::any attrib(const string &name) const;
- };
- }
-}
-
-#endif // PANEL_HPP_INCLUDED
176 src/gui/scrollable_panel.cpp
View
@@ -1,176 +0,0 @@
- /*
- * Copyright (c) 2008-2009 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#include <cmath>
-#include <numeric>
-
-#include <boost/foreach.hpp>
-#include <boost/bind.hpp>
-#include <boost/any.hpp>
-
-#include "scrollable_panel.hpp"
-#include "safe_any.hpp"
-
-namespace engine
-{
-
-
- namespace gui
- {
-
- scrollablePanel::scrollablePanel(const string &name, bool internal):
- panel(name, internal),
- _xScrollbar(new scrollbar("xScrollbar", true)),
- _yScrollbar(new scrollbar("yScrollbar", true)),
- _childrenRect(0, 0, 1, 1),
- _childrenOffset(0, 0),
- _smoothOffset(0, 0)
- {
- _interfaces.push_back(WIDGET_SCROLLABLE_PANEL);
-
- addChild(_xScrollbar);
- _xScrollbar->visible = false;
- _xScrollbar->obeyOffset = false;
- _xScrollbar->clippable = false;
- _xScrollbar->decorate = true;
- _xScrollbar->setCallback("onScroll", boost::bind(&scrollablePanel::_scroll, this, _1));
-
- addChild(_yScrollbar);
- _yScrollbar->visible = false;
- _yScrollbar->obeyOffset = false;
- _yScrollbar->clippable = false;
- _yScrollbar->decorate = true;
- _yScrollbar->setCallback("onScroll", boost::bind(&scrollablePanel::_scroll, this, _1));
- }
-
- scrollablePanel::~scrollablePanel()
- {
- }
-
- void scrollablePanel::_scroll(const event &e)
- {
- bool vert = (&e.caller == _yScrollbar.get());
-
- float a = (vert ? _childrenRect.y : _childrenRect.x);
- float b = (vert ? _childrenRect.w - size.y : _childrenRect.z - size.x);
-
- if (b < a)
- b = a; // make sure right/bottom >= left/top
- float f = SAFE_ANY_CAST(float, e.misc);
-
- if (vert)
- _childrenOffset.y = a + (b - a) * f;
- else
- _childrenOffset.x = a + (b - a) * f;
- }
-
- void scrollablePanel::tick(real dt)
- {
- _calcChildrenRect();
- _limitChildrenOffset();
- _updateScrollbars();
-
- const float SMOOTH_SPEED = 8;
- _smoothOffset += (_childrenOffset - _smoothOffset) * dt * SMOOTH_SPEED;
-
- panel::tick(dt);
- }
-
- void scrollablePanel::_limitChildrenOffset()
- {
- // limit left
- if (_childrenOffset.x < _childrenRect.x)
- _childrenOffset.x = _childrenRect.x;
- // limit top
- if (_childrenOffset.y < _childrenRect.y)
- _childrenOffset.y = _childrenRect.y;
-
- // limit right (only up to right - width of scrollablePanel)
- if (_childrenOffset.x > _childrenRect.z - size.x)
- _childrenOffset.x = _childrenRect.z - size.x;
-
- // limit bottom (only up to bottom - height of scrollablePanel)
- if (_childrenOffset.y > _childrenRect.w - size.y)
- _childrenOffset.y = _childrenRect.w - size.y;
- }
-
- void scrollablePanel::_updateScrollbars()
- {
- _xScrollbar->visible = _childrenRect.x < 0 || _childrenRect.z > size.x;
- _xScrollbar->percent(_xScrollbar->percent());
-
- _yScrollbar->visible = _childrenRect.y < 0 || _childrenRect.w > size.y;
- _yScrollbar->percent(_yScrollbar->percent());
-
- /*
- we originally get the children offset from the scrollbar as so:
-
- a + (b - a)x = c
-
- when we break it down to get the reverse (percent), we get:
-
- x(b - a) + a = c
- x(b - a) = c - a
- x = c - a
- -----
- b - a
-
- c = _childrenOffset
- x = percent
- a = _childrenRect.xy
- b = _childrenRect.zw - size.xy
-
- */
- float x = (_childrenOffset.x - _childrenRect.x) / (_childrenRect.z - size.x - _childrenRect.x);
- float y = (_childrenOffset.y - _childrenRect.y) / (_childrenRect.w - size.y - _childrenRect.y);
-
- _xScrollbar->percent(x);
- _yScrollbar->percent(y);
-
- vec4 r = rect();
- vec2 s = _xScrollbar->getDragger()->size; // assume _yScrollbar has same size
- _xScrollbar->points(vec2(0, r.w), vec2(size.x - s.x, r.w));
-
- //! iffy issue here because windows usually don't have a A_T skin part
- //! so we get an ugly offset that doesn't match up >.<
- //! so we need to account for this crap :(
- float offset = _yScrollbar->skinOffset(A_T).y - skinOffset(A_T).y;
- _yScrollbar->points(vec2(r.z, 0), vec2(r.z, size.y - s.y - offset));
- }
-
- void scrollablePanel::_calcChildrenRect()
- {
- _childrenRect = vec4(0, 0, size.x, size.y);
- if (_children.empty())
- return;
-
- BOOST_FOREACH(const widgetMap::value_type &i, _children)
- {
- if (!i.second->obeyOffset)
- continue;
-
- vec4 r = i.second->rect();
-
- vec2 p(r.x, r.y), s(r.z, r.w);
-
- _childrenRect.x = std::min(p.x, _childrenRect.x);
- _childrenRect.y = std::min(p.y, _childrenRect.y);
- _childrenRect.z = std::max(p.x + s.x, _childrenRect.z);
- _childrenRect.w = std::max(p.y + s.y, _childrenRect.w);
- }
- }
-
-// void scrollablePanel::scroll(const vec2 &v)
-// {
-// // simulate dragging
-// if (_xScrollbar->visible) _xScrollbar->update("drag", vec2(v.x, 0));
-// if (_yScrollbar->visible) _yScrollbar->update("drag", vec2(0, v.y));
-// }
-
- }
-
-}
-
61 src/gui/scrollable_panel.hpp
View
@@ -1,61 +0,0 @@
- /*
- * Copyright (c) 2008-2009 Agop 'nullsquared' Shirinian and Sven-Hendrik 'Svenstaro' Haase
- * This file is part of Pseudoform (Pseudoform project at http://www.pseudoform.org).
- * For conditions of distribution and use, see copyright notice in COPYING
- */
-
-#ifndef SCROLLABLE_PANEL_HPP_INCLUDED
-#define SCROLLABLE_PANEL_HPP_INCLUDED
-
-#include "panel.hpp"
-#include "scrollbar.hpp"
-
-namespace engine
-{
-
-
- namespace gui
- {
-
- class scrollablePanel: public panel
- {
- protected:
-
- scrollbarPtr _xScrollbar, _yScrollbar;
- vec4 _childrenRect;
- vec2 _childrenOffset;
- vec2 _smoothOffset;
-
- void _calcChildrenRect();
- void _updateScrollbars();
- void _limitChildrenOffset();
-
- void _scroll(const event &e);
-
- public:
-
- virtual vec2 childrenOffset() const
- {
-// _calcChildrenRect();
-// _limitChildrenOffset();
-// return -_childrenOffset; // this is added, but we need it to be subtracted
- return panel::childrenOffset() + -_smoothOffset;
- }
-
- scrollablePanel(const string &name, bool internal = false);
- virtual ~scrollablePanel();
-
- virtual void tick(real dt);
-
-// virtual void scroll(const vec2 &v);
-
- };