Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4858 in orxonox.OLD for orxonox/trunk/src/lib/graphics/render2D


Ignore:
Timestamp:
Jul 14, 2005, 12:43:39 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: loadParam functions implemented

Location:
orxonox/trunk/src/lib/graphics/render2D
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/render2D/element_2d.cc

    r4856 r4858  
    2121#include "graphics_engine.h"
    2222#include "p_node.h"
     23#include "load_param.h"
     24#include "tinyxml.h"
     25#include "class_list.h"
    2326
    2427using namespace std;
     
    4447
    4548
     49/**
     50 * initializes a Element2D
     51 */
    4652void Element2D::init()
    4753{
     
    5258
    5359  Render2D::getInstance()->registerElement2D(this);
     60}
     61
     62/**
     63 * Loads the Parameters of an Element2D from...
     64 * @param root The XML-element to load from
     65 */
     66void Element2D::loadParams(const TiXmlElement* root)
     67{
     68  LoadParam<Element2D>(root, "alignment", this, &Element2D::setAlignment)
     69      .describe("loads the alignment: (either: center, left, right or screen-center)");
     70
     71  LoadParam<Element2D>(root, "layer", this, &Element2D::setLayer)
     72      .describe("loads the layer onto which to project: (either: top, medium, bottom, below-all)");
     73
     74  LoadParam<Element2D>(root, "bind-node", this, &Element2D::setBindNode)
     75      .describe("sets a node, this 2D-Element should be shown upon (name of the node)");
     76
     77  LoadParam<Element2D>(root, "2d-position", this, &Element2D::setPosition2D)
     78      .describe("the _relative_ position (away from alignment) this 2d-element shows");
     79
     80//  LoadParam<Element2D>(root, "visibility", this, &Element2D::setVisibility)
     81//      .describe("if the Element is visible or not");
     82}
     83
     84/**
     85 * sets the alignment of the 2D-element in form of a String
     86 * @param alignment the alignment @see loadParams
     87*/
     88void Element2D::setAlignment(const char* alignment)
     89{
     90  if (!strcmp(alignment, "center"))
     91    this->setAlignment(E2D_ALIGN_CENTER);
     92  else if (!strcmp(alignment, "left"))
     93    this->setAlignment(E2D_ALIGN_LEFT);
     94  else if (!strcmp(alignment, "right"))
     95    this->setAlignment(E2D_ALIGN_RIGHT);
     96  else if (!strcmp(alignment, "screen-center"))
     97    this->setAlignment(E2D_ALIGN_SCREEN_CENTER);
     98}
     99
     100/**
     101 * sets the layer onto which this 2D-element is projected to.
     102 * @param layer the layer @see loadParams
     103 */
     104void Element2D::setLayer(const char* layer)
     105{
     106  if (!strcmp(layer, "top"))
     107    this->setLayer(E2D_TOP);
     108  else if (!strcmp(layer, "medium"))
     109    this->setLayer(E2D_MEDIUM);
     110  else if (!strcmp(layer, "bottom"))
     111    this->setLayer(E2D_BOTTOM);
     112  else if (!strcmp(layer, "below-all"))
     113    this->setLayer(E2D_BELOW_ALL);
     114}
     115
     116
     117/**
     118 * sets a node, this 2D-Element should be shown upon
     119 * @param bindNode the name of the Node (should be existing)
     120 */
     121void Element2D::setBindNode(const char* bindNode)
     122{
     123  const PNode* tmpBindNode = dynamic_cast<const PNode*>(ClassList::getObject(bindNode, CL_PARENT_NODE));
     124  if (tmpBindNode != NULL)
     125    this->bindNode = tmpBindNode;
    54126}
    55127
  • orxonox/trunk/src/lib/graphics/render2D/element_2d.h

    r4856 r4858  
    1111// FORWARD DECLARATION
    1212class PNode;
     13class TiXmlElement;
    1314
    1415//!< An enumerator defining the Depth of a 2D-element.
     
    4849    virtual ~Element2D();
    4950
     51    void init();
     52    void loadParams(const TiXmlElement* root);
     53
    5054    /** @param xCoord the xCoordinate @param yCoord the y-Coordinate. These coordinates are Relative */
    5155    inline void setPosition2D(int xCoord, int yCoord) { this->relPos2D[0] = xCoord; this->relPos2D[1] = yCoord; };
     
    5458    /** @param alignment the new Alignment of the 2D-Element */
    5559    inline void setAlignment(E2D_ALIGNMENT alignment) { this->alignment = alignment; };
     60    void setAlignment(const char* alignment);
    5661    /** @param layer the Layer this is drawn on */
    5762    inline void setLayer(E2DLayer layer) { this->layer = layer; };
     63    void setLayer(const char* layer);
    5864    /** @param visible true if the Element should be visible false otherwise (will not be rendered) */
    5965    inline void setVisibility(bool visible) { this->visible = visible; };
    6066    /** @param bindNode the Node this 2D-element should follow. if NULL the Element will not follow anything */
    6167    inline void setBindNode(const PNode* bindNode) { this->bindNode = bindNode; };
     68    void setBindNode(const char* bindNode);
    6269
    6370    /** @returns the visibility state */
    6471    inline bool isVisible() { return this->visible; };
    6572
    66     void positioning();
    6773    virtual void tick(float dt);
    6874    virtual void draw() const = NULL;
    6975
    70   private:
    71     void init();
     76  protected:
     77    void positioning();
    7278
    7379  protected:
Note: See TracChangeset for help on using the changeset viewer.