Esempio n. 1
0
//
// Draw control
//
void ICTipWindow::DrawSelf(PaintInfo &pi)
{
  // Draw the control
  DrawCtrlBackground(pi, GetTexture());
  DrawCtrlFrame(pi);
  DrawCtrlText(pi);
}
Esempio n. 2
0
//
// ICWindow::DrawSelf
//
// Draw the window
//
void ICWindow::DrawSelf(PaintInfo &pi)
{
  // Redraw the background image
  DrawCtrlBackground(pi, GetTexture());

  // Redraw the frame
  DrawCtrlFrame(pi);
}
  //
  // Draw control
  //
  void PrereqTree::DrawSelf(PaintInfo &pi)
  {
    if (constructor.Alive())
    {
      // Draw all the items
      S32 height = pi.client.Height();
      S32 yoffset = height / 2;
      S32 x = point.x;
      S32 y = point.y;

      // Move the client/window areas up to the top left
      Point<S32> offset(pi.client.p1.x, pi.client.p0.y);

      pi.client -= offset;
      pi.window -= offset;

      x -= 30;
      Point<S32> o(x, y);

      pi.client += o;
      pi.window += o;

      controlState |= STATE_HILITE;
      DrawCtrlBackground(pi, GetTexture());
      DrawCtrlFrame(pi);
      DrawCtrlText(pi, type->GetDesc());
      controlState &= ~STATE_HILITE;

      pi.client -= o;
      pi.window -= o;

      IFace::RenderRectangle(ClipRect(point.x - 30, point.y + yoffset, point.x, point.y + yoffset + 1), Color(1.0f, 1.0f, 1.0f, pi.alphaScale), NULL, pi.alphaScale);
      x -= pi.client.Width();

      S32 savey = y;
      S32 bottom = savey;
      Draw(TRUE, pi, x - 30, y, bottom, type);

      // Draw lines
      if (y > savey)
      {
        IFace::RenderRectangle(ClipRect(x - 25, point.y + yoffset, x, point.y + yoffset + 1), Color(1.0f, 1.0f, 1.0f, pi.alphaScale), NULL, pi.alphaScale);
        IFace::RenderRectangle(ClipRect(x - 25, savey + yoffset, x - 24, bottom + yoffset + 1), Color(1.0f, 1.0f, 1.0f, pi.alphaScale), NULL, pi.alphaScale);
      }
    }
    else
    {
      MarkForDeletion();
    }
  }
  //
  // Draw 
  //
  void PrereqTree::Draw(Bool first, PaintInfo &pi, S32 x, S32 &y, S32 &bottom, UnitObjType *type)
  {
    // Get the prereqs
    for (UnitObjTypeList::Iterator t(&type->GetPrereqs().Get()); *t; t++)
    {
      UnitObjType *type = **t;

      // Only add it if we ...
      // Don't Have It
      if (
        !Prereq::HaveType(team, type) ||
        (first && constructor->MissingUpgrade(type)))
      {
        pi.client += Point<S32>(x, y);
        pi.window += Point<S32>(x, y);

        DrawCtrlBackground(pi, GetTexture());
        DrawCtrlFrame(pi);
        DrawCtrlText(pi, type->GetDesc());

        S32 height = pi.client.Height();
        S32 yoffset = height / 2;

        // Draw horizontal line
        IFace::RenderRectangle(ClipRect(x, y + yoffset, x + 5, y + 1 + yoffset), Color(1.0f, 1.0f, 1.0f, pi.alphaScale), NULL, pi.alphaScale);

        pi.client -= Point<S32>(x, y);
        pi.window -= Point<S32>(x, y);

        bottom = y;

        y += height + 5;
        S32 savey = y;
        S32 bottom = savey;

        // Draw children
        Draw(FALSE, pi, x - 10, y, bottom, type);

        // Draw vertical line (if neccesary)
        if (y > savey)
        {
          IFace::RenderRectangle(ClipRect(x - 5, savey - 5, x - 4, bottom + yoffset + 1), Color(1.0f, 1.0f, 1.0f, pi.alphaScale), NULL, pi.alphaScale);
        }
      }
    }
  }
Esempio n. 5
0
//
// ICListBox::DrawSelf
//
void ICListBox::DrawSelf(PaintInfo &pi)
{
    // Sync vars with actual item count
    if (count != container->children.GetCount())
    {
        UpdateRange(FALSE);
    }

    // Reposition all controls
    if (reposition)
    {
        reposition = FALSE;

        SetupCellSize();
        UpdateRange(FALSE);
    }

    // Redraw background
    DrawCtrlBackground(pi, GetTexture());

    // Redraw frame
    DrawCtrlFrame(pi);
}
Esempio n. 6
0
//
// ICWindowTitle::DrawSelf
//
void ICWindowTitle::DrawSelf(PaintInfo &pi)
{
  DrawCtrlBackground(pi, GetTexture());
  DrawCtrlFrame(pi);
  DrawCtrlText(pi);
}
    //
    // TransferList::Item::DrawSelf
    //
    // DrawSelf
    //
    void TransferList::Item::DrawSelf(PaintInfo &pi)
    {
      // Fill the background
      DrawCtrlBackground(pi, GetTexture());

      // Draw the frame
      DrawCtrlFrame(pi);

      if (!pi.font)
      {
        return;
      }

      CH buff[128];
      const CH *ch;

      // Draw the name of the file
      ch = Utils::Ansi2Unicode(offer->path.str);
      pi.font->Draw
      (
        pi.client.p0.x + transferList.offsetFile.x,
        pi.client.p0.y + transferList.offsetFile.y, 
        ch, 
        Utils::Strlen(ch),
        pi.colors->fg[ColorIndex()],
        &pi.client
      );

      Network::Player *player = Network::GetPlayers().Find(offer->who);
      if (player)
      {
        Utils::Sprintf(buff, 128, L"%s %s", offer->from ? L"From" : L"To", Utils::Ansi2Unicode(player->GetName()));
        ch = buff;
        pi.font->Draw
        (
          pi.client.p0.x + transferList.offsetPlayer.x,
          pi.client.p0.y + transferList.offsetPlayer.y, 
          ch, 
          Utils::Strlen(ch),
          pi.colors->fg[ColorIndex()],
          &pi.client
        );
      }

      ch = Utils::Ansi2Unicode(offer->path.str);
      pi.font->Draw
      (
        pi.client.p0.x + transferList.offsetFile.x,
        pi.client.p0.y + transferList.offsetFile.y, 
        ch, 
        Utils::Strlen(ch),
        pi.colors->fg[ColorIndex()],
        &pi.client
      );

      U32 state;
      U32 remaining;
      U32 rate;

      offer->transfer.Progress(state, remaining, rate);

      switch (state)
      {
        case StyxNet::TransferState::Transferring:
          break;

        default:
          remaining = offer->size;
          rate = 0;
          break;
      }

      U32 transferred = offer->size - remaining;

      // Draw the amount transferred
      if (transferred < 1000)
      {
        Utils::Sprintf(buff, 128, L"%.1fB", F32(transferred));
      }
      else if (transferred < 1000000)
      {
        Utils::Sprintf(buff, 128, L"%.1fkB", F32(transferred) / 1000.0f);
      }
      else
      {
        Utils::Sprintf(buff, 128, L"%.1fMB", F32(transferred) / 1000000.0f);
      }
      ch = buff;
      pi.font->Draw
      (
        pi.client.p0.x + transferList.offsetTransferred.x,
        pi.client.p0.y + transferList.offsetTransferred.y, 
        ch, 
        Utils::Strlen(ch),
        pi.colors->fg[ColorIndex()],
        &pi.client
      );

      // Draw the rate
      if (rate < 1000)
      {
        Utils::Sprintf(buff, 128, L"%.1fB/s", F32(rate));
      }
      else if (rate < 1000000)
      {
        Utils::Sprintf(buff, 128, L"%.1fkB/s", F32(rate) / 1000.0f);
      }
      else
      {
        Utils::Sprintf(buff, 128, L"%.1fMB/s", F32(rate) / 1000000.0f);
      }
      pi.font->Draw
      (
        pi.client.p0.x + transferList.offsetRate.x,
        pi.client.p0.y + transferList.offsetRate.y, 
        ch, 
        Utils::Strlen(ch),
        pi.colors->fg[ColorIndex()],
        &pi.client
      );

      // Draw the ETA
      if (rate)
      {
        S32 eta = remaining / rate;
        Utils::Sprintf(buff, 128, L"%d:%02d", eta / 60, eta % 60);
      }
      else
      {
        ch = L"?:??";
      }
      pi.font->Draw
      (
        pi.client.p0.x + transferList.offsetETA.x,
        pi.client.p0.y + transferList.offsetETA.y, 
        ch, 
        Utils::Strlen(ch),
        pi.colors->fg[ColorIndex()],
        &pi.client
      );

      // Draw a progress bar
      ClipRect c
      (
        pi.client.p0.x + transferList.offsetProgress.x, pi.client.p0.y + transferList.offsetProgress.y,
        pi.client.p1.x - transferList.offsetProgress.x, pi.client.p0.y + transferList.offsetProgress.y + transferList.heightProgress
      );

      IFace::RenderRectangle
      (
        c,
        Color(0.0f, 0.0f, 0.0f, pi.alphaScale), 
        NULL, 
        pi.alphaScale
      );

      IFace::RenderGradient
      (
        ClipRect
        (
          c.p0.x, c.p0.y,
          c.p1.x - (c.Width() * remaining / offer->size), c.p1.y
        ), 
        Color(0.2f, 1.0f, 1.0f, pi.alphaScale), 
        Color(0.1f, 0.5f, 0.5f, pi.alphaScale)
      );

    }
Esempio n. 8
0
//
// Draw this control
//
void Power::DrawSelf(PaintInfo &pi)
{
    DrawCtrlBackground(pi, GetTexture());
    DrawCtrlFrame(pi);

    // Get the display team
    Team *team = Team::GetDisplayTeam();

    if (team)
    {
        // Get this teams power
        const ::Power::Team &power = team->GetPower();

        U32 available = power.GetAvailable();
        U32 availableDay = power.GetAvailableDay();
        U32 availableNight = power.GetAvailableNight();
        U32 consumed = power.GetConsumed();

        // Get the maximum
        U32 max = 0;
        max = Max(max, available);
        max = Max(max, availableDay);
        max = Max(max, availableNight);
        max = Max(max, consumed);

        // What the available height
        U32 height = pi.client.Height();
        ASSERT(height > 0)

        // How many notches are required to display this max (round up)
        div_t d = div(max, notchValue);
        U32 numNotches = d.quot + (d.rem ? 1 : 0);

        // How many pixels can we assign to each notch
        U32 notchPixels = numNotches ? Min(notchPixelMax, height / numNotches) : notchPixelMax;

        // Reduce notch pixels to the nearest power of two
        U32 mask = 0x10000000;
        do
        {
            if (mask & notchPixels)
            {
                notchPixels = mask;
                break;
            }
        }
        while (mask >>= 1);

        // We now have the number of pixels per notch, which also gives the ratio of pixels/units

        // Draw background
        IFace::RenderRectangle(
            pi.client,
            Color(0.0f, 0.0f, 0.0f),
            NULL,
            pi.alphaScale);

        // Display the available power
        IFace::RenderRectangle(
            ClipRect(
                pi.client.p0.x, pi.client.p1.y - notchPixels * available / notchValue,
                pi.client.p1.x, pi.client.p1.y),
            power.GetColor(),
            NULL,
            pi.alphaScale);

        // Display the day night difference
        IFace::RenderRectangle(
            ClipRect(
                pi.client.p0.x, pi.client.p1.y - notchPixels * availableDay / notchValue,
                pi.client.p1.x, pi.client.p1.y - notchPixels * availableNight / notchValue),
            Color(1.0f, 1.0f, 1.0f, 0.4f),
            NULL,
            pi.alphaScale);

        // Display the current power
        IFace::RenderRectangle(
            ClipRect(
                pi.client.p0.x, pi.client.p1.y - notchPixels * consumed / notchValue,
                pi.client.p1.x, pi.client.p1.y - notchPixels * consumed / notchValue + 1),
            Color(1.0f, 1.0f, 1.0f),
            NULL,
            pi.alphaScale);


        if (notchPixels > notchPixelMin)
        {
            // Draw the notches
            S32 y = pi.client.p1.y;
            while (y >= pi.client.p0.y)
            {
                IFace::RenderRectangle(
                    ClipRect(
                        pi.client.p0.x, y,
                        pi.client.p0.x + notchWidth, y + 1),
                    Color(1.0f, 1.0f, 1.0f),
                    NULL,
                    pi.alphaScale);

                IFace::RenderRectangle(
                    ClipRect(
                        pi.client.p1.x - notchWidth, y,
                        pi.client.p1.x, y + 1),
                    Color(1.0f, 1.0f, 1.0f),
                    NULL,
                    pi.alphaScale);

                y -= notchPixels;
            }

        }

    }

}
Esempio n. 9
0
//
// ICTicker::DrawSelf
//
// Draw the control
//
void ICTicker::DrawSelf(PaintInfo &pi)
{
  // Draw background
  DrawCtrlBackground(pi, GetTexture());

  // Draw frame
  DrawCtrlFrame(pi);

  // If there is a font then draw the control's text
  if (pi.font)
  {
    // Is there any text to be drawn
    if (currentMessage)
    {
      Color c = pi.colors->fg[ColorIndex()];
      c.a = U8(alpha);

      // Display the text
      pi.font->Draw
      (
        pi.client.p0.x + offsetX, 
        pi.client.p0.y + offsetY, 
        currentMessage->text, 
        currentMessage->length, 
        c,
        &pi.client
      );

      // Calcalate the width of the text
      //int width = pi.font->Width(currentMessage->text, currentMessage->length);
      
      switch (currentMessage->direction)
      {
        /*
        case DIR_LEFT:
          // Pause in the middle
          if (counter && offsetX <= ((pi.client.Width() - width) / 2))
          {
            counter--;
            break;
          }
           
          offsetX -= speed;
          if (offsetX < -width)
          {
            NextMessage();
          }
          break;

        case DIR_RIGHT:
          // Pause in the middle
          if (counter && offsetX >= ((pi.client.Width() - width) / 2))
          {
            counter--;
            break;
          }

          offsetX += speed;
          if (offsetX > pi.client.Width())
          {
            NextMessage();
          }
          break;

        case DIR_UP:
          // Pause in the middle
          if (counter && offsetY <= ((pi.client.Height() - S32(pi.font->Height())) / 2))
          {
            counter--;
            break;
          }

          offsetY -= speed;
          if (offsetY < -pi.font->Height())
          {
            NextMessage();
          }
          break;

        case DIR_DOWN:
          // Pause in the middle
          if (counter && offsetY >= ((pi.client.Height() - S32(pi.font->Height())) / 2))
          {
            counter--;
            break;
          }

          offsetY += speed;
          if (offsetY > pi.client.Height())
          {
            NextMessage();
          }
          break;
      */
        case DIR_ALPHA:
        default:
        {
          // Pause in the middle
          if (counter && alpha >= 255)
          {
            counter--;
            alphaDir = -S32(speed);
            break;
          }

          alpha += alphaDir;
          if (alpha > 255)
          {
            alpha = 255;
          }

          if (alpha <= 0)
          {
            NextMessage();
          }
          break;
        }
      }
    }
  }
}