Exemplo n.º 1
0
void BTPrint::draw(BTBackgroundAndScreen &d, int x, int y, ObjectSerializer *pc)
{
 int xMult, yMult;
 SDL_Rect dst;
 d.getDisplay()->getMultiplier(xMult, yMult);
 dst.x = (x + position.x) * xMult;
 dst.y = (y + position.y) * yMult;
 dst.w = position.w * xMult;
 dst.h = position.h * yMult;
 d.drawFont(text, dst, d.getColor(color), (BTAlignment::alignment)align);
}
Exemplo n.º 2
0
void BTStatBlock::draw(BTBackgroundAndScreen &d, int x, int y, ObjectSerializer *pc)
{
 int xMult, yMult;
 SDL_Rect dst;
 std::string color("black");
 d.getDisplay()->getMultiplier(xMult, yMult);
 dst.x = (x + position.x) * xMult;
 dst.y = (y + position.y) * yMult;
 dst.w = position.w * xMult;
 dst.h = position.h * yMult;
 XMLAction *state = pc->find(attribute, NULL);
 if (state)
 {
  switch(state->getType())
  {
   case XMLTYPE_BOOL:
    if (*(reinterpret_cast<bool*>(state->object)))
     d.drawFont("true", dst, d.getColor(color), (BTAlignment::alignment)align);
    else
     d.drawFont("false", dst, d.getColor(color), (BTAlignment::alignment)align);
    break;
   case XMLTYPE_INT:
    if (compare.attribute != "")
    {
     XMLAction *cmpState = pc->find(compare.attribute.c_str(), NULL);
     if ((cmpState) && (cmpState->getType() == XMLTYPE_INT))
     {
      int curVal = *(reinterpret_cast<int*>(state->object));
      int maxVal = *(reinterpret_cast<int*>(cmpState->object));
      if (maxVal == curVal)
       color = compare.full;
      else if (curVal < (maxVal / 2))
       color = compare.half;
     }
    }
    if (state->data)
    {
     d.drawFont(reinterpret_cast<ValueLookup*>(state->data)->getName(*(reinterpret_cast<int*>(state->object))).c_str(), dst, d.getColor(color), (BTAlignment::alignment)align);
    }
    else
    {
     int val = *(reinterpret_cast<int*>(state->object)) + modifier;
     if (negate)
      val *= -1;
     if ((maxValue != -1) && (maxValue < val))
     {
      d.drawFont(overflow, dst, d.getColor(color), (BTAlignment::alignment)align);
     }
     else
     {
      char tmp[40];
      snprintf(tmp, 40, "%d", val);
      d.drawFont(tmp, dst, d.getColor(color), (BTAlignment::alignment)align);
     }
    }
    break;
   case XMLTYPE_UINT:
   {
/*    char tmp[40];
    snprintf(tmp, 40, "%u", *(reinterpret_cast<unsigned int*>(state->object)));
    line.back() += tmp;*/
    break;
   }
   case XMLTYPE_STRING:
    d.drawFont(*(reinterpret_cast<char**>(state->object)), dst, d.getColor(color), (BTAlignment::alignment)align);
    break;
   case XMLTYPE_BITFIELD:
   default:
    break;
  }
 }
}