Exemple #1
0
void
draw_screen(void)
{
    draw_view();
    draw_turn();
    draw_stat();
    draw_slot();
    wrefresh(scroll_w);		/* move the cursor */
}
static void
repaint_surfaces(struct weston_output *output, pixman_region32_t *damage)
{
	struct weston_compositor *compositor = output->compositor;
	struct weston_view *view;

	wl_list_for_each_reverse(view, &compositor->view_list, link)
		if (view->plane == &compositor->primary_plane)
			draw_view(view, output, damage);
}
Exemple #3
0
void draw_view(View* view) {
	if (!view) return;

	//inform subviews that we're being redrawn
	//dirtied = 1;

	//fill view with its background color
	draw_rect(view->layer, rect_make(point_zero(), view->frame.size), view->background_color, THICKNESS_FILLED);

	//draw any bmps this view has
	for (int i = 0; i < view->bmps->size; i++) {
		Bmp* bmp = (Bmp*)array_m_lookup(view->bmps, i);
		if (bmp) {
			draw_bmp(view->layer, bmp);
		}
	}
	
	//draw any labels this view has
	for (int i = 0; i < view->labels->size; i++) {
		Label* label = (Label*)array_m_lookup(view->labels, i);
		draw_label(view->layer, label);
	}

	//draw buttons
	for (int i = 0; i < view->buttons->size; i++) {
		Button* button = (Button*)array_m_lookup(view->buttons, i);
		if (button) {
			draw_button(view->layer, button);
		}
	}

	//draw each subview of this view
	for (int i = 0; i < view->subviews->size; i++) {
		View* subview = (View*)array_m_lookup(view->subviews, i);
		draw_view(subview);
		blit_layer(view->layer, subview->layer, rect_make(subview->frame.origin, subview->layer->size), rect_make(point_zero(), subview->layer->size));
	}
	
	view->needs_redraw = 0;
}
Exemple #4
0
Fichier : view.c Projet : bytbox/iv
void view_flush() {
    /* fill the screen with blanks */
    int x,y;
    for(y=0;y<getmaxy(stdscr);y++)
        for(x=0;x<getmaxx(stdscr);x++)
            mvaddch(y,x,' '); /* empty the screen */
    attron(A_BOLD);
    for(y=0;y<getmaxy(stdscr)-1;y++)
        mvaddch(y,0,'~'); /* display blank lines */
    attroff(A_BOLD);
    /* display the message at the bottom of the screen */
    mvaddstr(getmaxy(stdscr)-1,0,displayed_message());
    if(view_layout.hsplit) {
        /* paint a line down the center */
        attrset(A_REVERSE);
        for(y=0;y<getmaxy(stdscr)-1;y++)
            mvaddch(y,view_layout.v1size,'|');
        attrset(A_NORMAL);
        /* display a bottom row with info */
        
        /* buffer 1 info */

        /* buffer 2 info */
    } else if(view_layout.vsplit) {
        /* display a line through the middle */
        attrset(A_REVERSE);

        attrset(A_NORMAL);
    } else {
        /* just draaw the view */
        draw_view(view_layout.active,0,0,getmaxy(stdscr)-1,getmaxx(stdscr));
    }
    /* update and refresh the screen (curses stuff) */
    doupdate();
    refresh();
}
Exemple #5
0
/* the main game function */
static int play_game()
{ 
   ALLEGRO_TIMER *inc_counter;
   int gameover = 0;
   int cyclenum = 0;

   /* init */
   score = 0;

   init_view();
   init_player();
   init_badguys();
   init_bullets();
   init_explode();
   init_message();

   #define TIMER_SPEED  ALLEGRO_BPS_TO_SECS(30*(cyclenum+2))

   inc_counter = al_create_timer(TIMER_SPEED);
   al_start_timer(inc_counter);

   while (!gameover) {

      /* move everyone */
      while ((al_get_timer_count(inc_counter) > 0) && (!gameover)) {
	 update_view();
	 update_bullets();
	 update_explode();
	 update_message();

	 if (update_badguys()) {
	    if (advance_view()) {
	       cyclenum++;
	       al_set_timer_count(inc_counter, 0);
	       lay_attack_wave(TRUE);
	       advance_player(TRUE);
	    }
	    else {
	       lay_attack_wave(FALSE);
	       advance_player(FALSE);
	    }
	 }

	 gameover = update_player();

	 al_set_timer_count(inc_counter, al_get_timer_count(inc_counter)-1);
      }

      /* take a screenshot? */
      if (key[ALLEGRO_KEY_PRINTSCREEN]) {
	 static int ss_count = 0;

	 char fname[80];

	 sprintf(fname, "speed%03d.tga", ++ss_count);

	 al_save_bitmap(fname, al_get_backbuffer(screen));

	 while (key[ALLEGRO_KEY_PRINTSCREEN])
	    poll_input_wait();

	 al_set_timer_count(inc_counter, 0);
      }

      /* toggle fullscreen window */
      if (key[ALLEGRO_KEY_F]) {
         int flags = al_get_display_flags(screen);
         al_set_display_flag(screen, ALLEGRO_FULLSCREEN_WINDOW,
            !(flags & ALLEGRO_FULLSCREEN_WINDOW));

         while (key[ALLEGRO_KEY_F])
            poll_input_wait();
      }

      /* draw everyone */
      draw_view();
   }

   /* cleanup */
   al_destroy_timer(inc_counter);

   shutdown_view();
   shutdown_player();
   shutdown_badguys();
   shutdown_bullets();
   shutdown_explode();
   shutdown_message();

   if (gameover < 0) {
      sfx_ping(1);
      return FALSE;
   }

   return TRUE;
}
Exemple #6
0
bool draw_window(Window* window) {
	if (window->user_backed) {
		return true;
	}

		//blit_layer(window->layer, window->content_view->layer, rect_make(window->content_view->frame.origin, window->layer->size), rect_make(point_zero(), window->content_view->frame.size));
		//return;
	//if window is invisible, don't bother drawing
	if (!window->layer->alpha) return false;

	//if window has a redraw handler, call it
	if (window->redraw_handler) {
		//draw_rect(window->content_view->layer, rect_make(point_zero(), window->content_view->frame.size), window->content_view->background_color, THICKNESS_FILLED);
		event_handler redraw = window->redraw_handler;
		redraw(window, NULL);
		blit_layer(window->layer, window->content_view->layer, rect_make(window->content_view->frame.origin, window->layer->size), rect_make(point_zero(), window->content_view->frame.size));

		window->last_draw_timestamp = time();

		return true;
	}

	//if window doesn't need to be redrawn, no work to do
	if (window->layer->alpha == 1.0 && !window->needs_redraw) {
		return false;
	}

	//dirtied = 1;

	//paint window
	draw_rect(window->layer, rect_make(point_zero(), window->frame.size), window->border_color, window->border_width);

	//only draw a title bar if title_view exists
	if (window->title_view) {
		//update title label of window
		Label* title_label = (Label*)array_m_lookup(window->title_view->labels, 0);
		title_label->text = window->title;
		draw_view(window->title_view);
		blit_layer(window->layer, window->title_view->layer, rect_make(point_zero(), window->layer->size), window->title_view->frame);
		draw_rect(window->layer, window->title_view->frame, color_gray(), 2);
	}

	//only draw the content view if content_view exists
	if (window->content_view) {
		draw_view(window->content_view);

		//if there's a redraw callback, call it
		if (window->redraw_handler) {
			event_handler redraw = window->redraw_handler;
			redraw(window, NULL);
		}

		blit_layer(window->layer, window->content_view->layer, rect_make(window->content_view->frame.origin, window->layer->size), rect_make(point_zero(), window->content_view->frame.size));

		//draw dividing border between window border and other content
		if (window->border_width) {
			//inner border
			draw_rect(window->content_view->layer, rect_make(point_zero(), window->content_view->frame.size), color_gray(), window->border_width);
		}
	}

	//draw window border
	draw_rect(window->layer, rect_make(point_zero(), window->frame.size), color_black(), 1);

	window->needs_redraw = 0;

	window->last_draw_timestamp = time();

	return true;
}
Exemple #7
0
int BEE::Room::draw() {
	sort_instances();

	if (is_background_color_enabled) {
		game->draw_set_color(background_color);
	} else {
		game->draw_set_color(c_white);
	}

	if (is_views_enabled) { // Render different viewports
		if (view_texture->game == NULL) {
			view_texture->game = game;
		}
		if (!game->options->is_debug_enabled) {
			game->render_clear();
		}

		SDL_Rect viewport, viewcoords;
		for (auto& v : views) {
			if (v.second->is_visible) {
				view_current = v.second;

				if (view_current->following != NULL) {
					InstanceData* f = view_current->following;
					if (instances_sorted.find(f) != instances_sorted.end()) {
						SDL_Rect a = {(int)f->x, (int)f->y, f->get_width(), f->get_height()};
						SDL_Rect b = {
							view_current->view_x,
							view_current->view_y,
							view_current->port_width,
							view_current->port_height
						};
						if (a.x < -b.x+view_current->horizontal_border) {
							view_current->view_x = -(a.x - view_current->horizontal_border);
						} else if (a.x+a.w > -b.x+b.w-view_current->horizontal_border) {
							view_current->view_x = b.w - (a.x + a.w + view_current->horizontal_border);
						}
						if (a.y < -b.y+view_current->vertical_border) {
							view_current->view_y = -(a.y - view_current->vertical_border);
						} else if (a.y+a.h > -b.y+b.h-view_current->vertical_border) {
							view_current->view_y = b.h - (a.y + a.h + view_current->vertical_border);
						}
					} else {
						view_current->following = NULL;
					}
				}
				if (view_current->horizontal_speed != 0) {
					view_current->view_x -= view_current->horizontal_speed;
				}
				if (view_current->vertical_speed != 0) {
					view_current->view_y -= view_current->vertical_speed;
				}

				viewport.x = view_current->port_x;
				viewport.y = view_current->port_y;
				viewport.w = view_current->port_width;
				viewport.h = view_current->port_height;
				SDL_RenderSetViewport(game->renderer, &viewport);

				draw_view();
			}
		}
		view_current = NULL;
		viewport = {0, 0, game->get_width(), game->get_height()};
		SDL_RenderSetViewport(game->renderer, &viewport);
	} else {
		if (!game->options->is_debug_enabled) {
			game->render_clear();
		}
		draw_view();
	}

	game->render();

	return 0;
}
Exemple #8
0
	void View_list::update(Core *c){
		layout();
		draw_list();
		draw_view(c);
	}
Exemple #9
0
play()
{
	register struct ship *sp;

	for (;;) {
		switch (sgetch("~\b", (struct ship *)0, 0)) {
		case 'm':
			acceptmove();
			break;
		case 's':
			acceptsignal();
			break;
		case 'g':
			grapungrap();
			break;
		case 'u':
			unfoulplayer();
			break;
		case 'v':
			Signal("%s", (struct ship *)0, version);
			break;
		case 'b':
			acceptboard();
			break;
		case 'f':
			acceptcombat();
			break;
		case 'l':
			loadplayer();
			break;
		case 'c':
			changesail();
			break;
		case 'r':
			repair();
			break;
		case 'B':
			Signal("'Hands to stations!'", (struct ship *)0);
			unboard(ms, ms, 1);	/* cancel DBP's */
			unboard(ms, ms, 0);	/* cancel offense */
			break;
		case '\f':
			centerview();
			blockalarm();
			draw_board();
			draw_screen();
			unblockalarm();
			break;
		case 'L':
			mf->loadL = L_EMPTY;
			mf->loadR = L_EMPTY;
			mf->readyL = R_EMPTY;
			mf->readyR = R_EMPTY;
			Signal("Broadsides unloaded", (struct ship *)0);
			break;
		case 'q':
			Signal("Type 'Q' to quit", (struct ship *)0);
			break;
		case 'Q':
			leave(LEAVE_QUIT);
			break;
		case 'I':
			foreachship(sp)
				if (sp != ms)
					eyeball(sp);
			break;
		case 'i':
			if ((sp = closestenemy(ms, 0, 1)) == 0)
				Signal("No more ships left.");
			else
				eyeball(sp);
			break;
		case 'C':
			centerview();
			blockalarm();
			draw_view();
			unblockalarm();
			break;
		case 'U':
			upview();
			blockalarm();
			draw_view();
			unblockalarm();
			break;
		case 'D':
		case 'N':
			downview();
			blockalarm();
			draw_view();
			unblockalarm();
			break;
		case 'H':
			leftview();
			blockalarm();
			draw_view();
			unblockalarm();
			break;
		case 'J':
			rightview();
			blockalarm();
			draw_view();
			unblockalarm();
			break;
		case 'F':
			lookout();
			break;
		case 'S':
			dont_adjust = !dont_adjust;
			blockalarm();
			draw_turn();
			unblockalarm();
			break;
		}
	}
}
Exemple #10
0
void display()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	switch (style) {
	case 0:
		make_view(4);
		make_projection(4);
		glViewport(width / 2, 0, width / 2, height / 2);
		draw_scene();

		make_view(1);
		make_projection(1);
		glViewport(0, height / 2, width / 2, height / 2);
		draw_scene();
		make_view(1);
		draw_view();

		make_view(2);
		glViewport(width / 2, height / 2, width / 2, height / 2);
		draw_scene();
		make_view(2);
		draw_view();

		make_view(3);
		glViewport(0, 0, width / 2, height / 2);
		draw_scene();
		make_view(3);
		draw_view();
		break;

	case 1:
		make_view(1);
		make_projection(1);
		glViewport(0, 0, width, height);
		draw_scene();
		make_view(1);
		draw_view();
		break;

	case 2:
		make_view(2);
		glViewport(0, 0, width, height);
		draw_scene();
		make_view(2);
		draw_view();
		break;

	case 3:
		make_view(3);
		glViewport(0, 0, width, height);
		draw_scene();
		make_view(3);
		draw_view();
		break;
	case 4:
		glViewport(0, 0, width, height);
		make_view(4);
		make_projection(4);
		draw_scene();
		break;
	}
	/*-------Swap the back buffer to the front --------*/
	glutSwapBuffers();
	return;
}