Exemplo n.º 1
0
adv_error advance_ui_init(struct advance_ui_context* context, adv_conf* cfg_context)
{
	context->state.ui_extra_flag = 0;
	context->state.ui_message_flag = 0;
	context->state.ui_help_flag = 0;
	context->state.ui_menu_map = 0;
	context->state.ui_osd_flag = 0;
	context->state.ui_scroll_flag = 0;
	context->state.ui_scroll_begin = 0;
	context->state.ui_scroll_end = 0;
	context->state.ui_direct_text_flag = 0;
	context->state.ui_direct_slow_flag = 0;
	context->state.ui_direct_fast_flag = 0;
	context->state.ui_font = 0;
	context->state.ui_font_oriented = 0;
	context->state.buffer_def = color_def_make_rgb_from_sizelenpos(4, 8, 16, 8, 8, 8, 0); /* BGRA */
	context->state.color_map.def = 0; /* invalidate the color map */

	conf_bool_register_default(cfg_context, "debug_speedmark", 0);
	conf_string_register_multi(cfg_context, "ui_helptag");
	conf_string_register_default(cfg_context, "ui_helpimage", "auto");
	conf_string_register_default(cfg_context, "ui_font", "auto");
	conf_string_register_default(cfg_context, "ui_fontsize", "auto");
	conf_string_register_default(cfg_context, "ui_color[interface]", "000000 ffffff");
	conf_string_register_default(cfg_context, "ui_color[tag]", "247ef0 ffffff");
	conf_string_register_default(cfg_context, "ui_color[select]", "000000 afffff");
	conf_string_register_default(cfg_context, "ui_color[help_p1]", "000000 ffff00");
	conf_string_register_default(cfg_context, "ui_color[help_p2]", "000000 00ff00");
	conf_string_register_default(cfg_context, "ui_color[help_p3]", "000000 ff0000");
	conf_string_register_default(cfg_context, "ui_color[help_p4]", "000000 00ffff");
	conf_string_register_default(cfg_context, "ui_color[help_other]", "000000 808080");
	conf_float_register_limit_default(cfg_context, "ui_translucency", 0, 1, 0.80);

	return 0;
}
Exemplo n.º 2
0
/**
 * Make an arbitrary RGB format definition from a shiftmask specification.
 * \param bytes_per_pixel Bytes per pixel.
 * \param red_mask, green_mask, blue_mask Bit mask.
 * \param red_shift, green_shift, blue_shift Shift.
 */
adv_color_def color_def_make_rgb_from_sizeshiftmask(unsigned bytes_per_pixel, int red_shift, unsigned red_mask, int green_shift, unsigned green_mask, int blue_shift, unsigned blue_mask)
{
    unsigned red_len = rgb_len_get_from_mask(red_mask);
    unsigned green_len = rgb_len_get_from_mask(green_mask);
    unsigned blue_len = rgb_len_get_from_mask(blue_mask);
    unsigned red_pos = 8 + red_shift - red_len;
    unsigned green_pos = 8 + green_shift - green_len;
    unsigned blue_pos = 8 + blue_shift - blue_len;

    return color_def_make_rgb_from_sizelenpos(bytes_per_pixel, red_len, red_pos, green_len, green_pos, blue_len, blue_pos);
}
Exemplo n.º 3
0
/**
 * Make an arbitrary color format definition from the specified index type.
 */
adv_color_def color_def_make_from_index(unsigned index)
{
    switch (index) {
    case MODE_FLAGS_INDEX_PALETTE8 :
        return color_def_make_palette_from_size(1);
    case MODE_FLAGS_INDEX_BGR8 :
        return color_def_make_rgb_from_sizelenpos(1, 3, 5, 3, 2, 2, 0);
    case MODE_FLAGS_INDEX_BGR15 :
        return color_def_make_rgb_from_sizelenpos(2, 5, 10, 5, 5, 5, 0);
    case MODE_FLAGS_INDEX_BGR16 :
        return color_def_make_rgb_from_sizelenpos(2, 5, 11, 6, 5, 5, 0);
    case MODE_FLAGS_INDEX_BGR24 :
        return color_def_make_rgb_from_sizelenpos(3, 8, 16, 8, 8, 8, 0);
    case MODE_FLAGS_INDEX_BGR32 :
        return color_def_make_rgb_from_sizelenpos(4, 8, 16, 8, 8, 8, 0);
    case MODE_FLAGS_INDEX_YUY2 :
        return color_def_make(adv_color_type_yuy2);
    default :
        return color_def_make(adv_color_type_unknown);
    }
}
Exemplo n.º 4
0
adv_color_def fb_color_def(void)
{
	assert(fb_is_active() && fb_mode_is_active());

	switch (fb_state.index) {
	case MODE_FLAGS_INDEX_BGR15 :
	case MODE_FLAGS_INDEX_BGR16 :
	case MODE_FLAGS_INDEX_BGR24 :
	case MODE_FLAGS_INDEX_BGR32 :
		return color_def_make_rgb_from_sizelenpos(
			fb_state.bytes_per_pixel,
			fb_state.varinfo.red.length, fb_state.varinfo.red.offset,
			fb_state.varinfo.green.length, fb_state.varinfo.green.offset,
			fb_state.varinfo.blue.length, fb_state.varinfo.blue.offset
		);
	default:
		return color_def_make_from_index(fb_state.index);
	}
}
Exemplo n.º 5
0
adv_error advance_ui_inner_init(struct advance_ui_context* context, adv_conf* cfg_context)
{
	adv_conf_iterator k;
	adv_color_def def;

	context->state.ui_font = 0;
	context->state.ui_font_oriented = 0;

	if (strcmp(context->config.ui_font_buffer, "auto") != 0) {
		/* try reading the font, the real font is loaded later */
		adv_font* font;
		adv_fz* f;

		const char* file = file_config_file_home(context->config.ui_font_buffer);

		log_std(("emu:ui: font '%s'\n", file));

		f = fzopen(file, "rb");
		if (!f) {
			target_err("Error opening the font %s\n", file);
			return -1;
		}

		font = adv_font_load(f, 16, 16);
		if (!font) {
			target_err("Error reading the font %s\n%s\n", file, error_get());
			return -1;
		}

		adv_font_free(font);

		fzclose(f);
	}

	def = color_def_make_rgb_from_sizelenpos(3, 8, 0, 8, 8, 8, 16);

	if (strcmp(context->config.help_image_buffer, "auto") == 0) {
		adv_fz* f;
		unsigned i;

		log_std(("emu:ui: helpimage auto\n"));

		f = fzopenmemory(HELPIMAGE, HELPIMAGE_SIZE);

		context->state.help_image = adv_bitmap_load_png_rgb(f, def);
		if (!context->state.help_image) {
			target_err("Error reading the internal help image\n");
			return -1;
		}

		fzclose(f);

		log_std(("emu:ui: helptag auto\n"));
		i = 0;
		while (HELPTAG[i]) {
			char* d = strdup(HELPTAG[i]);

			log_std(("emu:ui: helptag '%s'\n", d));

			if (advance_ui_parse_help(context, d) != 0) {
				free(d);
				target_err("Invalid 'ui_helptag' option.\n%s\n", error_get());
				return -1;
			}

			free(d);

			++i;
		}
	} else {
		if (strcmp(context->config.help_image_buffer, "none") != 0) {
			adv_fz* f;
			const char* file = file_config_file_home(context->config.help_image_buffer);

			log_std(("emu:ui: helpimage '%s'\n", file));

			f = fzopen(file, "rb");
			if (!f) {
				target_err("Error opening the help image %s\n", file);
				return -1;
			}

			context->state.help_image = adv_bitmap_load_png_rgb(f, def);
			if (!context->state.help_image) {
				target_err("Error reading the help image %s\n%s\n", file, error_get());
				return -1;
			}

			fzclose(f);
		} else {
			context->state.help_image = 0;
		}

		log_std(("emu:ui: helptag start\n"));
		for (conf_iterator_begin(&k, cfg_context, "ui_helptag"); !conf_iterator_is_end(&k); conf_iterator_next(&k)) {
			char* d = strdup(conf_iterator_string_get(&k));

			log_std(("emu:ui: helptag '%s'\n", d));

			if (advance_ui_parse_help(context, d) != 0) {
				free(d);
				target_err("Invalid 'ui_helptag' option.\n%s\n", error_get());
				return -1;
			}

			free(d);
		}
	}

	return 0;
}