Exemplo n.º 1
0
/** @brief Main in-game rendering routine.
 *
 *  @param b Board configuration to render.
 */
void draw_scene(board_t *b, GLuint fb, int reflections) {
	char temp[80];
	int clock_seconds = 0;
	int clock_minutes = 0;

	glBindFramebuffer(GL_FRAMEBUFFER, fb);

	transition_update();

	gg_dialog_cleanup();

	glDisable(GL_BLEND);
	glDepthFunc(GL_ALWAYS);

	draw_backdrop();

	glEnable(GL_BLEND);
	glDepthFunc(GL_LEQUAL);

	go_3d(get_screen_width(), get_screen_height());

	render_scene_3d(b, fb, reflections);
	mouse_square = find_square(get_true_mouse_x(), get_true_mouse_y());

	glBindFramebuffer(GL_FRAMEBUFFER, fb);
	resize_window(get_screen_width(), get_screen_height());

	glPushMatrix();

	draw_ui_elements();

	// draw_move_list(get_col(COL_WHITE), get_col(COL_YELLOW));
	// draw_capture_list(get_col(COL_WHITE));

	clock_minutes = (((SDL_GetTicks() - get_turn_counter()) / 1000) / 60);
	clock_seconds = ((SDL_GetTicks() - get_turn_counter()) / 1000) - (clock_minutes * 60);
	snprintf(temp, sizeof(temp), "%i:%02i", clock_minutes, clock_seconds);
	/*text_draw_string( 303, 440, temp, 1, &col_black);*/
	glPopMatrix();

	/*if ( get_white_in_check() == TRUE )
		text_draw_string_bouncy( 180, 420, "White is in check!", 1, get_col(COL_WHITE));
	else if ( get_black_in_check() == TRUE )
		text_draw_string_bouncy( 180, 420, "Black is in check!", 1, get_col(COL_WHITE));*/

	gg_dialog_render_all();

	if (get_fading_out()) {
		if (!draw_fade(FADE_OUT))
			set_switch_to_menu(TRUE);
	} else {
		if (get_show_egg())
			draw_sonic_fade(FADE_IN);
		else
			draw_fade(FADE_IN);
	}

	/* Draw mouse cursor.. */
	draw_texture(get_mouse_cursor(), get_mouse_x(), (479 - get_mouse_y() - 32), 32, 32, 1.0f, get_col(COL_WHITE));
}
Exemplo n.º 2
0
void mslider_move_function (event *ev)
{

	float
		mouse_x,
		mouse_y;

	static ui_object
		*obj;

	if (current_object_to_slide)
	{

		mouse_x = get_mouse_x ();

		mouse_y = get_mouse_y ();

		if (mouse_y < get_ui_object_y (current_object_to_slide))
		{

			scroll = max (-1.0f, (get_ui_object_y (current_object_to_slide) - mouse_y) * get_delta_time ());

			set_ui_object_state (current_object_to_slide, UI_OBJECT_STATE_OFF);
		}
		else if (mouse_y > get_ui_object_y (current_object_to_slide) + get_ui_object_y_size (current_object_to_slide))
		{

			scroll = min (1.0f, (get_ui_object_y (current_object_to_slide) + get_ui_object_y_size (current_object_to_slide) - mouse_y) * get_delta_time ());

			set_ui_object_state (current_object_to_slide, UI_OBJECT_STATE_OFF);
		}
		else
		{

			scroll = 0.0;

			obj = check_ui_object_for_selection (current_object_to_slide, mouse_x, mouse_y);

			if (obj)
			{

				set_ui_object_state (obj, UI_OBJECT_STATE_ON);
			}
		}
	}
}
Exemplo n.º 3
0
void menu_file_selector::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
	// lay out extra text
	auto layout = ui().create_layout(container());
	layout.add_text(m_current_directory.c_str());

	// position this extra text
	float x1, y1, x2, y2;
	extra_text_position(origx1, origx2, origy1, top, layout, -1, x1, y1, x2, y2);

	// draw a box
	ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR);

	// take off the borders
	x1 += UI_BOX_LR_BORDER;
	y1 += UI_BOX_TB_BORDER;

	size_t hit_start = 0, hit_span = 0;
	if (is_mouse_hit()
		&& layout.hit_test(get_mouse_x() - x1, get_mouse_y() - y1, hit_start, hit_span)
		&& m_current_directory.substr(hit_start, hit_span) != PATH_SEPARATOR)
	{
		// we're hovering over a directory!  highlight it
		auto target_dir_start = m_current_directory.rfind(PATH_SEPARATOR, hit_start) + 1;
		auto target_dir_end = m_current_directory.find(PATH_SEPARATOR, hit_start + hit_span);
		m_hover_directory = m_current_directory.substr(0, target_dir_end + strlen(PATH_SEPARATOR));

		// highlight the text in question
		rgb_t fgcolor = UI_MOUSEOVER_COLOR;
		rgb_t bgcolor = UI_MOUSEOVER_BG_COLOR;
		layout.restyle(target_dir_start, target_dir_end - target_dir_start, &fgcolor, &bgcolor);
	}
	else
	{
		// we are not hovering over anything
		m_hover_directory.clear();
	}

	// draw the text within it
	layout.emit(container(), x1, y1);
}
 Vector2d get_mouse_pos () { return Vector2d(get_mouse_x (), get_mouse_y()); }
Exemplo n.º 5
0
/*
* BEE::is_mouse_inside() - Return whether the mouse collides with the instance's bounding box
* @instance: the instance to check a collision for
*/
bool BEE::is_mouse_inside(const InstanceData& instance) const {
	SDL_Rect i = {(int)instance.x, (int)instance.y, (int)instance.mask.w, (int)instance.mask.h}; // Create a bounding box based on the instance's CollisionPolygon
	SDL_Rect m = {get_mouse_x(), get_mouse_y(), 0, 0};
	return check_collision(i, m); // Return whether the instance collides with the mouse
}
Exemplo n.º 6
0
bool BEE::is_mouse_inside(InstanceData* instance) {
	SDL_Rect i = {(int)instance->x, (int)instance->y, instance->object->get_mask()->get_subimage_width(), instance->object->get_mask()->get_height()};
	SDL_Rect m = {get_mouse_x(), get_mouse_y(), 0, 0};
	return check_collision(&i, &m);
}