Ejemplo n.º 1
0
void toggle_fullscreen()
{
	BITMAP *bmp = set_screen(is_windowed_mode());
	if (bmp->w == virt_screen->w)
		destroy_bitmap(bmp);
	else {
		if (bmp->w > virt_screen->w) {
			int h = 400;
			if (in_menu) {
				blit(virt_screen, screen, 0, 384, 0, 464,
							  512, 16);
				h = 384;
			}
			blit(virt_screen, bmp, 0, 0, 64, 0, 512, h);
			curs_x += 8;
		} else {
			blit(virt_screen, bmp, 64, 0, 0, 0, 512, 400);
			curs_x -= 8;
		}
		margin_x = getmargin_x();
		destroy_bitmap(virt_screen);
		virt_screen = bmp;
	}
	refresh_needed = 1;
	refreshscreen();
}
Ejemplo n.º 2
0
void refreshscreen()
{
	int y = 0;
	if (!refresh_needed)
		return;
	if (!is_windowed_mode())
		y = 40;
	acquire_screen();
	blit(virt_screen, screen, 0, 0, 0, y, 8*term_width, 400);
	release_screen();
	refresh_needed = 0;
	memset(blit_rect, 0, 4);
}
Ejemplo n.º 3
0
static int printline(char *line)
{
	int n = strlen(line);
	int c = 0;
	if (line[n-1] == '\n')
		line[--n] = '\0';
	if (n > 64 && is_windowed_mode()) {
		c = line[64];
		line[64] = '\0';
	}
	printstr(line);
	if (!c || curs_y == 24)
		return 0;
	line[64] = c;
	curs_y++;
	printstr(line + 64);
	return 1;
}
Ejemplo n.º 4
0
static void update_mouse_position()
{
  m_x[0] = JI_SCREEN_W * mouse_x / SCREEN_W;
  m_y[0] = JI_SCREEN_H * mouse_y / SCREEN_H;

  if (is_windowed_mode()) {
#ifdef ALLEGRO_WINDOWS
    // This help us (in windows) to get mouse feedback when we capture
    // the mouse but we are outside the window.
    POINT pt;
    RECT rc;

    if (GetCursorPos(&pt) && GetClientRect(win_get_window(), &rc)) {
      MapWindowPoints(win_get_window(), NULL, (LPPOINT)&rc, 2);

      if (!PtInRect(&rc, pt)) {
        // If the mouse is free we can hide the cursor putting the
        // mouse outside the screen (right-bottom corder).
        if (!Manager::getDefault()->getCapture()) {
          if (mouse_cursor) {
            m_x[0] = JI_SCREEN_W + mouse_cursor->getFocus().x;
            m_y[0] = JI_SCREEN_H + mouse_cursor->getFocus().y;
          }
        }
        // If the mouse is captured we can put it in the edges of the
        // screen.
        else {
          pt.x -= rc.left;
          pt.y -= rc.top;

          m_x[0] = JI_SCREEN_W * pt.x / SCREEN_W;
          m_y[0] = JI_SCREEN_H * pt.y / SCREEN_H;

          m_x[0] = MID(0, m_x[0], JI_SCREEN_W-1);
          m_y[0] = MID(0, m_y[0], JI_SCREEN_H-1);
        }
      }
    }
#endif
  }
}
Ejemplo n.º 5
0
int opMenu()
{
     DATAFILE *menu = load_datafile("data\\menu.dat");
 	 BITMAP *buffer = create_bitmap(640,480);
 	 
 	 blit((BITMAP *)menu[1].dat, buffer, 0, 0, 0, 0, MAX_W, MAX_H);
 	 textprintf_centre_ex(buffer, font, 320, 305, makecol(0,30,50),-1, "Para trocar entre o modo fullscreen e janela, aperte ENTER.");
 	 
 	 font = (FONT *)menu[9].dat;
 	 
 	 fade_in(buffer, 10);
 	 
 	 FILE *conf = fopen("config.cdb", "wb");
 	 
 	 if (conf == NULL)
 	 {
        allegro_message("Problema com o arquivo de configuração: config.cdb");
        return 5;
     }
 	 
 	 while (!key[KEY_ESC])
 	 {
        clear(buffer);
        
        blit((BITMAP *)menu[1].dat, buffer, 0, 0, 0, 0, MAX_W, MAX_H);
 	    textprintf_centre_ex(buffer, font, 320, 305, makecol(0,30,50),-1, "Para trocar entre o modo fullscreen e janela, aperte ENTER.");
        
        if (key[KEY_ENTER])
        {
        
           if (is_windowed_mode())
           {
	          if (set_gfx_mode(GFX_AUTODETECT, MAX_W, MAX_H, 0, 0) != 0) {
		         allegro_message(allegro_error);
		         exit(-1);
	          }
	          fade_out(10);
	          unload_datafile(menu);
              destroy_bitmap(buffer);
              
              fprintf(conf, "%d", 2);
              fclose(conf);
     
              return 0;
           }
           else
           {
	          if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, MAX_W, MAX_H, 0, 0) != 0) {
		         allegro_message(allegro_error);
		         exit(-1);
	          }
	          fade_out(10);
	          unload_datafile(menu);
              destroy_bitmap(buffer);
              
              fprintf(conf, "%d", 1);
              fclose(conf);
     
              return 0;
           }
        }
        
        draw_sprite(buffer, (BITMAP *)menu[0].dat, mouse_x, mouse_y);
        
        blit(buffer, screen, 0, 0, 0, 0, MAX_W, MAX_H);
     }
     fade_out(10);
     
     unload_datafile(menu);
     destroy_bitmap(buffer);
     
     return 0;
}