Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

orxonox/trunk: loadParam functions implemented

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.