Exemple #1
0
int
clip_WREOPEN(ClipMachine * ClipMachineMemory)
{
   int top, left, bottom, right;

   int erase, i;

   ClipWindow *wp = 0;

   _clip_fullscreen(ClipMachineMemory);
   if (ClipMachineMemory->argc < 4)
      return EG_ARG;

   top = _clip_parni(ClipMachineMemory, 1);
   left = _clip_parni(ClipMachineMemory, 2);
   bottom = _clip_parni(ClipMachineMemory, 3);
   right = _clip_parni(ClipMachineMemory, 4);
   erase = _clip_parl(ClipMachineMemory, 5);

   if (top > bottom || left > right)
      return EG_ARG;

   //save_window(ClipMachineMemory, ClipMachineMemory->windows + ClipMachineMemory->wnum);
   wp = ClipMachineMemory->windows + ClipMachineMemory->wnum;

   wp->ClipRect_rect_of_ClipWindow.top_of_ClipRect = top;
   wp->ClipRect_rect_of_ClipWindow.bottom_of_ClipRect = bottom;
   wp->ClipRect_rect_of_ClipWindow.left_of_ClipRect = left;
   wp->ClipRect_rect_of_ClipWindow.right_of_ClipRect = right;
   wp->ClipRect_format_of_ClipWindow = wp->ClipRect_rect_of_ClipWindow;

   ClipMachineMemory->screen->y = 0;
   ClipMachineMemory->screen->x = 0;
   adjust_cursor(ClipMachineMemory);

   if (erase)
   {
      int attr = _clip_colorSelect(ClipMachineMemory);

      int j;

      char fill = *((char *) _clip_fetch_item(ClipMachineMemory, HASH_setclearb));

      Screen *sp = ClipMachineMemory->screen;

      bottom -= top;
      top = 0;
      right -= left;
      left = 0;
      clip_region(ClipMachineMemory, &top, &left, &bottom, &right, 2, -1);
      for (i = top; i <= bottom; ++i)
      {
	 sp->touched[i] = 1;
	 for (j = left; j <= right; ++j)
	 {
	    sp->chars[i][j] = fill;
	    sp->colors[i][j] = attr;
	    sp->attrs[i][j] = 0;
	 }
      }
      draw_shadow(ClipMachineMemory, wp);
      sync_mp(ClipMachineMemory);
   }

   _clip_retni(ClipMachineMemory, wp->no_of_ClipWindow);

   return 0;
}
Exemple #2
0
int singleplayer_process_input (struct state *st, struct ui *ui, char c) {
  int cursi = ui->cursor.i;
  int cursj = ui->cursor.j;
  switch (c) {
    case 'q': case 'Q':
      return 1;
    case 'f':
      st->prev_speed = st->speed;
      st->speed = faster(st->speed);
      break;
    case 's':
      st->prev_speed = st->speed;
      st->speed = slower(st->speed);
      break;
    case 'p':
      if (st->speed == sp_pause)
        st->speed = st->prev_speed;
      else {
        st->prev_speed = st->speed;
        st->speed = sp_pause;
      }
      break;
    case 'h': case K_LEFT:
      cursi--;
      break;
    case 'l': case K_RIGHT:
      cursi++;
      break;
    case 'k': case K_UP:
      cursj--;
      if (cursj % 2 == 1)
        cursi++;
      break;
    case 'j': case K_DOWN:
      cursj++;
      if (cursj % 2 == 0)
        cursi--;
      break;
    case ' ':
      if (st->fg[st->controlled].flag[ui->cursor.i][ui->cursor.j] == 0)
        add_flag (&st->grid, &st->fg[st->controlled], ui->cursor.i, ui->cursor.j, FLAG_POWER);
      else
        remove_flag (&st->grid, &st->fg[st->controlled], ui->cursor.i, ui->cursor.j, FLAG_POWER);
      break;
    case 'x':
      remove_flags_with_prob (&st->grid, &st->fg[st->controlled], 1.0);
      break;
    case 'c':
      remove_flags_with_prob (&st->grid, &st->fg[st->controlled], 0.5);
      break;
    case 'r':
    case 'v':
      build (&st->grid, &st->country[st->controlled], st->controlled, ui->cursor.i, ui->cursor.j);
      break;
    
    case ESCAPE:
    case 91:
      break;
  }
  
  adjust_cursor(st, ui, cursi, cursj);

  return 0;
}