コード例 #1
0
ファイル: front_torture.c プロジェクト: ommmmmmm/keeperfx
TbBool fronttorture_draw(void)
{
  struct TbSprite *spr;
  const int img_width = 640;
  const int img_height = 480;
  int w,h,i;
  int spx,spy;
  // Only 8bpp supported for now
  if (LbGraphicsScreenBPP() != 8)
    return false;
  int units_per_px;
  units_per_px = min(units_per_pixel,units_per_pixel_min*16/10);
  w = img_width * units_per_px / 16;
  h = img_height * units_per_px / 16;
  // Starting point coords
  spx = (LbScreenWidth() - w) >> 1;
  spy = (LbScreenHeight() - h) >> 1;
  copy_raw8_image_buffer(lbDisplay.WScreen,LbGraphicsScreenWidth(),LbGraphicsScreenHeight(),
      w,h,spx,spy,torture_background,img_width,img_height);

  for (i=0; i < torture_doors_available; i++)
  {
    if (i == torture_door_selected)
    {
      spr = &doors[i].sprites[torture_sprite_frame];
    } else
    {
      spr = &doors[i].sprites[1];
    }
    LbSpriteDrawResized(spx + doors[i].pos_spr_x*units_per_px/16, spy + doors[i].pos_spr_y*units_per_px/16, units_per_px, spr);
  }
  return true;
}
コード例 #2
0
ファイル: gui_draw.c プロジェクト: ommmmmmm/keeperfx
TbBool frontmenu_copy_background_at(const struct TbRect *bkgnd_area, int units_per_px)
{
    int img_width, img_height;
    img_width = 640;
    img_height = 480;
    const unsigned char *srcbuf = frontend_background;
    // Only 8bpp supported for now
    if (LbGraphicsScreenBPP() != 8)
        return false;
    // Do the drawing
    copy_raw8_image_buffer(lbDisplay.WScreen,LbGraphicsScreenWidth(),LbGraphicsScreenHeight(),
        img_width*units_per_px/16,img_height*units_per_px/16,bkgnd_area->left,bkgnd_area->top,srcbuf,img_width,img_height);
    // Burning candle flames
    return true;
}
コード例 #3
0
ファイル: bflib_mouse.cpp プロジェクト: joaocc/keeperfx-git
TbResult LbMouseSetup(struct TbSprite *pointerSprite)
{
  TbResult ret;
  long x,y;
  if (lbMouseInstalled)
    LbMouseSuspend();
  y = (lbDisplay.MouseWindowHeight + lbDisplay.MouseWindowY) / 2;
  x = (lbDisplay.MouseWindowWidth + lbDisplay.MouseWindowX) / 2;
  pointerHandler.Install();
  lbMouseOffline = true;
  lbMouseInstalled = true;
  LbMouseSetWindow(0,0,LbGraphicsScreenWidth(),LbGraphicsScreenHeight());
  ret = Lb_SUCCESS;
  if (LbMouseSetPosition(x,y) != Lb_SUCCESS)
    ret = Lb_FAIL;
  if (LbMouseChangeSprite(pointerSprite) != Lb_SUCCESS)
    ret = Lb_FAIL;
  lbMouseInstalled = (ret == Lb_SUCCESS);
  lbMouseOffline = false;
  return ret;
}
コード例 #4
0
ファイル: gui_draw.c プロジェクト: ommmmmmm/keeperfx
/** Draws a string on GUI button.
 *  Note that the source text buffer may be damaged by this function.
 * @param gbtn Button to draw text on.
 * @param base_width Width of the button before scaling.
 * @param text Text to be displayed.
 */
void draw_button_string(struct GuiButton *gbtn, int base_width, const char *text)
{
    unsigned long flgmem;
    static unsigned char cursor_type = 0;
    static char dtext[TEXT_BUFFER_LENGTH];
    flgmem = lbDisplay.DrawFlags;
    long cursor_pos = -1;
    LbStringCopy(dtext,text,TEXT_BUFFER_LENGTH);
    if ((gbtn->button_type == LbBtnType_EditBox) && (gbtn == input_button))
    {
        cursor_type++;
        if ((cursor_type & 0x02) == 0)
          cursor_pos = input_field_pos;
        LbLocTextStringConcat(dtext, " ", TEXT_BUFFER_LENGTH);
        lbDisplay.DrawColour = LbTextGetFontFaceColor();
        lbDisplayEx.ShadowColour = LbTextGetFontBackColor();
    }
    LbTextSetJustifyWindow(gbtn->scr_pos_x, gbtn->scr_pos_y, gbtn->width);
    LbTextSetClipWindow(gbtn->scr_pos_x, gbtn->scr_pos_y, gbtn->width, gbtn->height);
    lbDisplay.DrawFlags = Lb_TEXT_HALIGN_CENTER;// | Lb_TEXT_UNDERLNSHADOW;
    if (cursor_pos >= 0) {
        // Mind the order, 'cause inserting makes positions shift
        LbLocTextStringInsert(dtext, "\x0B", cursor_pos+1, TEXT_BUFFER_LENGTH);
        LbLocTextStringInsert(dtext, "\x0B", cursor_pos, TEXT_BUFFER_LENGTH);
    }
    int units_per_px;
    units_per_px = (gbtn->width * 16 + base_width/2) / base_width;
    int tx_units_per_px;
    tx_units_per_px = units_per_px*22/LbTextLineHeight();
    unsigned long w,h;
    w = 4 * units_per_px / 16;
    h = (gbtn->height - text_string_height(tx_units_per_px, dtext))/2 - 3*units_per_px/16;
    LbTextDrawResized(w, h, tx_units_per_px, dtext);
    LbTextSetJustifyWindow(0, 0, LbGraphicsScreenWidth());
    LbTextSetClipWindow(0/pixel_size, 0/pixel_size, MyScreenWidth/pixel_size, MyScreenHeight/pixel_size);
    LbTextSetWindow(0/pixel_size, 0/pixel_size, MyScreenWidth/pixel_size, MyScreenHeight/pixel_size);
    lbDisplay.DrawFlags = flgmem;
}