Example #1
0
/*** Performs some checks on what user has enterred ***/
void check_tab(struct Gadget *str)
{
	UBYTE *buf = GetSI(str)->Buffer, *start;

	for(start=buf; *buf; buf++)
		if(*buf < '0' || *buf > '9')
		{
			/* Wrong char, avert user */
			GetSI(str)->BufferPos = buf-start;
			DisplayBeep(NULL);
			ActivateGadget(str, Wnd, NULL);
			break;
		}
}
static void ScrollPlayfield(int dx, int dy)
{
  int x1 = mScrollX_last / TILEX - 2;
  int y1 = mScrollY_last / TILEY - 2;
  int x2 = mScrollX_last / TILEX + (SCR_FIELDX - 1) + 2;
  int y2 = mScrollY_last / TILEY + (SCR_FIELDY - 1) + 2;
  int x, y;

  BlitBitmap(bitmap_db_field_sp, bitmap_db_field_sp,
             TILEX * (dx == -1),
             TILEY * (dy == -1),
             (MAX_BUF_XSIZE * TILEX) - TILEX * (dx != 0),
             (MAX_BUF_YSIZE * TILEY) - TILEY * (dy != 0),
             TILEX * (dx == 1),
             TILEY * (dy == 1));

  /* when scrolling the whole playfield, do not redraw single tiles */
  for (x = 0; x < MAX_BUF_XSIZE; x++)
    for (y = 0; y < MAX_BUF_YSIZE; y++)
      redraw[x][y] = FALSE;
  redraw_tiles = 0;

  DrawFrameIfNeeded();

  for (y = DisplayMinY; y <= DisplayMaxY; y++)
  {
    for (x = DisplayMinX; x <= DisplayMaxX; x++)
    {
      if (x >= x1 && x <= x2 && y >= y1 && y <= y2)
      {
	int sx = x - x1;
	int sy = y - y1;
	int tsi = GetSI(x, y);
	long id = ((PlayField16[tsi]) |
		   (PlayField8[tsi] << 16) |
		   (DisPlayField[tsi] << 24));

	if ((dx == -1 && x == x2) ||
	    (dx == +1 && x == x1) ||
	    (dy == -1 && y == y2) ||
	    (dy == +1 && y == y1))
	{
	  DrawFieldNoAnimated(x, y);
	  DrawFieldAnimated(x, y);
	}

	ScreenBuffer[sx][sy] = id;
      }
    }
  }
}
void UpdatePlayfield(boolean force_redraw)
{
  int x, y;
#if 1
  int num_redrawn = 0;
#endif

  for (y = DisplayMinY; y <= DisplayMaxY; y++)
  {
    for (x = DisplayMinX; x <= DisplayMaxX; x++)
    {
      int element = LowByte(PlayField16[GetSI(x, y)]);
      int graphic = GfxGraphic[x][y];
      int sync_frame = GfxFrame[x][y];
      boolean redraw = force_redraw;

#if 0
      redraw = TRUE;	// !!! TEST ONLY -- ALWAYS REDRAW !!!
#endif

      if (graphic < 0)
      {
	GfxGraphicLast[x][y] = GfxGraphic[x][y];

	continue;
      }

      if (element != GfxElementLast[x][y] &&
	  graphic == GfxGraphicLast[x][y])
      {
	/* element changed, but not graphic => disable updating graphic */

	GfxElementLast[x][y] = element;
	GfxGraphicLast[x][y] = GfxGraphic[x][y] = -1;

	continue;
      }

      if (graphic != GfxGraphicLast[x][y])			// new graphic
      {
	redraw = TRUE;

	GfxElementLast[x][y] = element;
	GfxGraphicLast[x][y] = GfxGraphic[x][y];
	sync_frame = GfxFrame[x][y] = 0;
      }
      else if (isNextAnimationFrame_SP(graphic, sync_frame))	// new frame
      {
	redraw = TRUE;
      }

      if (redraw)
      {
	int sx = x * StretchWidth;
	int sy = y * StretchWidth;

#if 0
	printf("::: REDRAW (%d, %d): %d, %d\n", x, y, graphic, sync_frame);
#endif

	DDSpriteBuffer_BltImg(sx, sy, graphic, sync_frame);

#if 1
	num_redrawn++;
#endif
      }
    }
  }

#if 0
  printf("::: FRAME %d: %d redrawn\n", FrameCounter, num_redrawn);
#endif
}
Example #4
0
void MainWindow::SetTrafficInformation() {
    // Эта функция создана для расчёта траффика
    // Во-первых, она устанавливает значения траффика в окне
    // Во-вторых, подсчитывает среднюю скорость
    // В-третьих, в будущем будет писать в логи траффик за сеанс
    // В-четвертых, будет рисовать граффики, или не будет, не знаю пока...
    ////////////////////////////////////////////////////////////////////
    // Считаем траффик
    ////////////////////////////////////////////////////////////////////
    QString Temp;
    QTableWidgetItem *item = 0;
    QString a;
    int s=0, len=0;
    ////////////////////////////////////////////////////////////////////
    // Вызываем функции
    ////////////////////////////////////////////////////////////////////
    GetSI(0); // Входящий траффик
    GetSI(1); // Исходящий траффик

    GetSI(2); // Входящая скорость
    GetSI(3); // Исходящая скорость

    GetSI(4); // Входящая максимальная скорость
    GetSI(5); // Исходящая максимальная скорость
    ////////////////////////////////////////////////////////////////////


    ////////////////////////////////////////////////////////////////////
    // 0
    ////////////////////////////////////////////////////////////////////
    a = QString("%1").arg(GlobalTrafficInFloat);
    s = a.lastIndexOf(".");
    len = a.length()-2;
    if(s <= len) { len = a.lastIndexOf(".")+3; a = a.mid(0, len); }
    a.append(" ");
    a.append(InSI);
    item = new QTableWidgetItem(a);
    ui->TrafficTable->setItem(0,0,item);
    a.clear();
    ////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////
    // 1
    ////////////////////////////////////////////////////////////////////
    a = QString("%1").arg(GlobalTrafficOutFloat);
    s = a.lastIndexOf(".");
    len = a.length()-2;
    if(s <= len) { len = a.lastIndexOf(".")+3; a = a.mid(0, len); }
    a.append(" ");
    a.append(OutSI);
    item = new QTableWidgetItem(a);
    ui->TrafficTable->setItem(0,1,item);
    a.clear();
    ////////////////////////////////////////////////////////////////////


    ////////////////////////////////////////////////////////////////////
    // 2
    ////////////////////////////////////////////////////////////////////
    a = QString("%1").arg(GlobalTrafficInSpeed);
    s = a.lastIndexOf(".");
    len = a.length()-2;
    if(s <= len) { len = a.lastIndexOf(".")+3; a = a.mid(0, len); }
    a.append(" ");
    a.append(InSISpeed);
    a.append(tr("/S"));
    item = new QTableWidgetItem(a);
    ui->TrafficTable->setItem(1,0,item);
    a.clear();
    ////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////
    // 3
    ////////////////////////////////////////////////////////////////////
    a = QString("%1").arg(GlobalTrafficOutSpeed);
    s = a.lastIndexOf(".");
    len = a.length()-2;
    if(s <= len) { len = a.lastIndexOf(".")+3; a = a.mid(0, len); }
    a.append(" ");
    a.append(OutSISpeed);
    a.append(tr("/S"));
    item = new QTableWidgetItem(a);
    ui->TrafficTable->setItem(1,1,item);
    a.clear();
    ////////////////////////////////////////////////////////////////////


    ////////////////////////////////////////////////////////////////////
    // 4
    ////////////////////////////////////////////////////////////////////
    a = QString("%1").arg(GlobalTrafficInMaxSpeed);
    s = a.lastIndexOf(".");
    len = a.length()-2;
    if(s <= len) { len = a.lastIndexOf(".")+3; a = a.mid(0, len); }
    a.append(" ");
    a.append(InSIMaxSSpeed);
    a.append(tr("/S"));
    item = new QTableWidgetItem(a);
    ui->TrafficTable->setItem(2,0,item);
    a.clear();
    ////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////
    // 5
    ////////////////////////////////////////////////////////////////////
    a = QString("%1").arg(GlobalTrafficOutMaxSpeed);
    s = a.lastIndexOf(".");
    len = a.length()-2;
    if(s <= len) { len = a.lastIndexOf(".")+3; a = a.mid(0, len); }
    a.append(" ");
    a.append(OutSIMaxSpeed);
    a.append(tr("/S"));
    item = new QTableWidgetItem(a);
    ui->TrafficTable->setItem(2,1,item);
    a.clear();
    ////////////////////////////////////////////////////////////////////



    ////////////////////////////////////////////////////////////////////
    // Конец этой функции
    ////////////////////////////////////////////////////////////////////
}