Beispiel #1
0
void PictureDecorator::drawBorder(Picture &dstpic, const Rect& rectangle, const int offset, bool useAlpha)
{
  // pics are: 0TopLeft, 1Top, 2TopRight, 3Right, 4BottomRight, 5Bottom, 6BottomLeft, 7Left
  // draws horizontal borders
  const Picture& topborder = Picture::load( ResourceGroup::panelBackground, offset+1);
  const int sw = topborder.getWidth();
  const int sh = topborder.getHeight();
  const Picture& bottomBorder = Picture::load( ResourceGroup::panelBackground, offset+5);
  for (int i = 0; i<(rectangle.getWidth()/sw-1); ++i)
  {
     dstpic.draw( topborder, rectangle.UpperLeftCorner + Point( sw+sw*i, 0 ), useAlpha);
     dstpic.draw( bottomBorder, rectangle.UpperLeftCorner + Point( sw+sw*i, rectangle.getHeight()-sh ), useAlpha );
  }

  // draws vertical borders
  const Picture& leftborder = Picture::load( ResourceGroup::panelBackground, offset+7);
  const Picture& rightborder = Picture::load( ResourceGroup::panelBackground, offset+3);
  for (int i = 0; i<(rectangle.getHeight()/sh-1); ++i)
  {
     dstpic.draw( leftborder, rectangle.UpperLeftCorner + Point( 0, sh+sh*i ), useAlpha );
     dstpic.draw( rightborder, rectangle.UpperLeftCorner + Point( rectangle.getWidth()-sw, sh+sh*i ), useAlpha );
  }

  // topLeft corner
  dstpic.draw( Picture::load( ResourceGroup::panelBackground, offset+0), rectangle.UpperLeftCorner, useAlpha);
  // topRight corner
  dstpic.draw(Picture::load( ResourceGroup::panelBackground, offset+2), rectangle.getRight()-sw, rectangle.getTop(), useAlpha );
  // bottomLeft corner
  dstpic.draw(Picture::load( ResourceGroup::panelBackground, offset+6), rectangle.getLeft(), rectangle.getBottom()-sh, useAlpha);
  // bottomRight corner
  dstpic.draw(Picture::load( ResourceGroup::panelBackground, offset+4), rectangle.getRight()-16, rectangle.getBottom()-sh, useAlpha);
}
Beispiel #2
0
void PictureDecorator::drawBorder( Picture &dstpic, const Rect& rectangle, 
                                   int tp, int bp, int lp, int rp, 
                                   int pCount, int hCount,
                                   int ltc, int lbc, int rtc, int rbc, bool useAlpha )
{
  // draws horizontal borders
  Size size = Picture::load( ResourceGroup::panelBackground, tp ).getSize();
  const int sw = size.getWidth();
  const int sh = size.getHeight();
  for (int i = 0; i<(rectangle.getWidth()/size.getWidth()-1); ++i)
  {
    Point offset = rectangle.UpperLeftCorner + Point( sw+sw*i, 0 );
    dstpic.draw( Picture::load( ResourceGroup::panelBackground, tp+i%pCount), offset, useAlpha );      // top border
    dstpic.draw( Picture::load( ResourceGroup::panelBackground, bp+i%pCount), offset + Point( 0, rectangle.getHeight()-sh ), useAlpha );      // bottom border
  }

  // draws vertical borders
  for (int i = 0; i<(rectangle.getHeight()/size.getHeight()-1); ++i)
  {
    Point offset = rectangle.UpperLeftCorner + Point( 0, sh+sh*i );
    dstpic.draw( Picture::load( ResourceGroup::panelBackground, lp+hCount*(i%pCount)), offset, useAlpha );      // left border
    dstpic.draw( Picture::load( ResourceGroup::panelBackground, rp+hCount*(i%pCount)), offset + Point( rectangle.getWidth()-sw, 0 ), useAlpha );      // right border
  }

  dstpic.draw( Picture::load( ResourceGroup::panelBackground, ltc), rectangle.UpperLeftCorner );    // left-top corner
  dstpic.draw( Picture::load( ResourceGroup::panelBackground, lbc), Point( rectangle.getLeft(), rectangle.getBottom()-sh ), useAlpha );    // left-bottom corner
  dstpic.draw( Picture::load( ResourceGroup::panelBackground, rtc ), Point( rectangle.getRight() - sw, rectangle.getTop() ), useAlpha );     // right-top corner
  dstpic.draw( Picture::load( ResourceGroup::panelBackground, rbc), rectangle.LowerRightCorner - Point( sw, sh ), useAlpha );    // right-bottom corner
}
void PictureBank::createResources()
{
  Picture& originalPic = getPicture( ResourceGroup::utilitya, 34 );
  setPicture( std::string( ResourceGroup::waterbuildings ) + "_00001.png", *originalPic.getSurface() );

  Picture* fullReservoir = originalPic.createCopy(); //mem leak on destroy picloader
  fullReservoir->draw( getPicture( ResourceGroup::utilitya, 35 ), 47, 37 );
  setPicture( std::string( ResourceGroup::waterbuildings ) + "_00002.png", *fullReservoir->getSurface() );

  Picture& emptyFontainOrig = getPicture( ResourceGroup::utilitya, 10 );
  setPicture( std::string( ResourceGroup::waterbuildings ) + "_00003.png", *emptyFontainOrig.getSurface() );

  Picture* fullFontain = emptyFontainOrig.createCopy();  //mem leak on destroy picloader
  fullFontain->draw( getPicture( ResourceGroup::utilitya, 11 ), 12, 25 );
  setPicture( std::string( ResourceGroup::waterbuildings) + "_00004.png", *fullFontain->getSurface() );
}
Beispiel #4
0
void PictureDecorator::drawPanel( Picture &dstpic, const Rect& rectangle, int picId, bool useAlpha )
{
  // left side
  dstpic.draw( Picture::load( ResourceGroup::panelBackground, picId), rectangle.UpperLeftCorner );

  // draws the inside
  const Picture& centerPic = Picture::load( ResourceGroup::panelBackground, picId+1);
  for (int i = 0; i<(rectangle.getWidth()/16-1); ++i)
  {
    dstpic.draw( centerPic, rectangle.UpperLeftCorner + Point( 16+16*i, 0 ), useAlpha );
  }

  // right side
  dstpic.draw( Picture::load( ResourceGroup::panelBackground, picId+2), 
               rectangle.UpperLeftCorner + Point( rectangle.getWidth()-16, 0) );
}
static void android_graphics_Picture_draw(JNIEnv* env, jobject, jlong canvasHandle,
                                          jlong pictureHandle) {
    Canvas* canvas = reinterpret_cast<Canvas*>(canvasHandle);
    Picture* picture = reinterpret_cast<Picture*>(pictureHandle);
    SkASSERT(canvas);
    SkASSERT(picture);
    picture->draw(canvas);
}
Beispiel #6
0
void PictureDecorator::drawFrame(Picture &dstpic, const Rect& rectangle, const int picId, bool useAlpha)
{
   // pics are: 0TopLeft, 1Top, 2TopRight, 3Left, 4Center, 5Right, 6BottomLeft, 7Bottom, 8BottomRight

   // draws the inside of the box
  const Picture& bg = Picture::load( ResourceGroup::panelBackground, picId+4);
  const int sw = bg.getWidth();
  const int sh = bg.getHeight();
  for (int j = 0; j<(rectangle.getHeight()/sh-1); ++j)
  {
     for (int i = 0; i<(rectangle.getWidth()/sw-1); ++i)
     {
        dstpic.draw( bg, rectangle.UpperLeftCorner + Point( sw+sw*i, sh+sh*j ), useAlpha );
     }
  }

  // draws horizontal borders
  const Picture& topBorder = Picture::load( ResourceGroup::panelBackground, picId+1);
  const Picture& bottomBorder = Picture::load( ResourceGroup::panelBackground, picId+7);
  for (int i = 0; i<(rectangle.getWidth()/sw-1); ++i)
  {
     dstpic.draw( topBorder, rectangle.UpperLeftCorner + Point( sw+sw*i, 0 ), useAlpha);
     dstpic.draw( bottomBorder, rectangle.UpperLeftCorner + Point( sw+sw*i, rectangle.getHeight()-sh ), useAlpha );
  }

  // draws vertical borders
  const Picture& leftBorder = Picture::load( ResourceGroup::panelBackground, picId+3);
  const Picture& rightBorder = Picture::load( ResourceGroup::panelBackground, picId+5);
  for (int i = 0; i<(rectangle.getHeight()/sh-1); ++i)
  {
     dstpic.draw( leftBorder, rectangle.UpperLeftCorner + Point( 0, sh+sh*i ), useAlpha );
     dstpic.draw( rightBorder, rectangle.UpperLeftCorner + Point( rectangle.getWidth()-sw, sh+sh*i ), useAlpha );
  }

  // topLeft corner
  dstpic.draw(Picture::load( ResourceGroup::panelBackground, picId+0), rectangle.UpperLeftCorner, useAlpha );
  // topRight corner
  dstpic.draw(Picture::load( ResourceGroup::panelBackground, picId+2), Point( rectangle.getRight()-sh, rectangle.getTop() ), useAlpha );
  // bottomLeft corner
  dstpic.draw(Picture::load( ResourceGroup::panelBackground, picId+6), Point( rectangle.getLeft(), rectangle.getBottom() - sh ), useAlpha );
  // bottomRight corner
  dstpic.draw(Picture::load( ResourceGroup::panelBackground, picId+8), rectangle.LowerRightCorner - Point( 16, 16 ), useAlpha );
}
Beispiel #7
0
void PictureDecorator::drawArea(Picture &dstpic, const Rect& rectangle, int picId, int picCount, int offset, bool useAlpha)
{
  for (int j = 0; j<(rectangle.getHeight()/16+1); ++j)
  {
    for (int i = 0; i<(rectangle.getWidth()/16+1); ++i)
    {
      // use some clipping to remove the right and bottom areas
      const Picture &srcpic = Picture::load( ResourceGroup::panelBackground, picId + (i%picCount) + offset*(j%picCount) );

      int dx = 16*i;
      int dy = 16*j;
      int sw = std::min(16, rectangle.getWidth()-dx);
      int sh = std::min(16, rectangle.getHeight()-dy);

      dstpic.draw( srcpic, Rect( 0, 0, sw, sh), rectangle.UpperLeftCorner + Point( dx, dy ) );
    }
  }
}
Beispiel #8
0
void Font::draw(Picture& dstpic, const std::string &text, const int dx, const int dy, bool useAlpha )
{
  if( !_d->ttfFont || !dstpic.isValid() )
    return;

  SDL_Surface* sText = TTF_RenderUTF8_Blended( _d->ttfFont, text.c_str(), _d->color );
  if( sText && useAlpha )
  {
    SDL_SetAlpha( sText, 0, 0 );
  }

  if( sText )
  {
    Picture pic;
    pic.init( sText, Point( 0, 0 ) );
    dstpic.draw( pic, dx, dy);
  }

  SDL_FreeSurface( sText );
}       
Beispiel #9
0
/*********************************************************
 *                          draw                         *
 *********************************************************/
void Menu::draw(int pos)
{
   Font fnt;
   Options opt;
   fnt.defineFont(opt.getDefaultFont(), 10);
   fnt.defineFontAlign(Font::ALIGN_LEFT);
   fnt.defineFontStyle(Font::STYLE_NORMAL);

   /* Define Coordinates */
   int x1 = x;
   int x2 = x1 + (maxCharac)*(fnt.getIncCP()+1)+4; 
   int y1 = y;
   int y2 = (((int)list.size()-numPictures) * ITEM_HEIGHT) + 
                                         y1 + 5; /* bizarre from DOS version */
   
   /* Verify Sides */
   if(x2 > wWidth-1)
   {
      x1 = (wWidth-1) - (x2 - x1);
      x2 = wWidth-1;
      x = x1;
   }
   if(y2 > wHeight-1)
   {
      y1 = (wHeight-1) - (y2 - y1);
      y2 = wHeight-1;
      y = y1;
   }

   /* Draw the Menu */
   color_Set(colors.colorMenu.R, colors.colorMenu.G,
             colors.colorMenu.B, colors.colorMenu.A);
   rectangle_Fill(wSurface,x1+1,y1+1,x2-1,y2-1);
   color_Set(colors.colorCont[2].R, colors.colorCont[2].G,
             colors.colorCont[2].B, colors.colorCont[2].A);
   rectangle_Oval(wSurface,x1,y1,x2,y2,colors.colorCont[1].R,
                  colors.colorCont[1].G, colors.colorCont[1].B,
                  colors.colorCont[1].A);
      /*itens*/  
   int xa = x1+4;
   int ya = y1+3;
   int med = (ITEM_HEIGHT - 10) / 2;
   GuiObject* item;

   std::list<GuiObject*>::iterator it;
   for(it=list.begin(); it != list.end(); it++)
   {
      item = (*it);
      /* Treat Pictures */
      if(item->type == Farso::OBJECT_PICTURE)
      {
         Picture* pic = (Picture*)item;
         pic->setCoordinate(xa, ya+med+1, xa+10, ya+10+med+1);
         pic->draw();
         /* The next text will be translated right */
         xa = x1+15;
      }
      /* treat Texts */
      else if(item->type == Farso::OBJECT_TEXT_BOX)
      {
         color_Set(colors.colorText.R,
               colors.colorText.G,
               colors.colorText.B,
               colors.colorText.A);

         /* Menu Texts */
         if (item->getText().compare("-"))
         {
            if (item->isAvailable()) 
            {
               fnt.write(wSurface,xa,ya+med,item->getText());
            }
            else
            {
               color_Set(colors.colorCont[2].R, colors.colorCont[2].G,
                     colors.colorCont[2].B, colors.colorCont[2].A);
               fnt.write(wSurface,xa+1,ya+med+1,item->getText());
               color_Set(colors.colorCont[1].R, colors.colorCont[1].G,
                     colors.colorCont[1].B, colors.colorCont[1].A);
               fnt.write(wSurface,xa,ya+med,item->getText());
            }
         } 

         /* Menu Separators */
         else 
         {
            color_Set(colors.colorCont[1].R, colors.colorCont[1].G,
                  colors.colorCont[1].B, colors.colorCont[1].A);
            rectangle_2Colors(wSurface,xa-2,ya+6,x2-2,ya+7,
                  colors.colorCont[0].R,
                  colors.colorCont[0].G,colors.colorCont[0].B,
                  colors.colorCont[0].A);
         }
         xa = x1+4;
         ya += ITEM_HEIGHT;
      }
   }
  
}