示例#1
0
void set_fullscreen(CVideo& video, const bool ison)
{
	_set_fullscreen(ison);

	const std::pair<int,int>& res = resolution();
	if(video.isFullScreen() != ison) {
		const int flags = ison ? FULL_SCREEN : 0;
		int bpp = video.bppForMode(res.first, res.second, flags);

		if(bpp > 0) {
			video.setMode(res.first,res.second,bpp,flags);
			if(disp) {
				disp->redraw_everything();
			}
		} else {
			int tmp_flags = flags;
			std::pair<int,int> tmp_res;
			if(detect_video_settings(video, tmp_res, bpp, tmp_flags)) {
				set_resolution(video, tmp_res.first, tmp_res.second);
			// TODO: see if below line is actually needed, possibly for displays that only support 16 bbp
			} else if(video.modePossible(1024,768,16,flags)) {
				set_resolution(video, 1024, 768);
			} else {
				gui2::show_transient_message(video,"",_("The video mode could not be changed. Your window manager must be set to 16 bits per pixel to run the game in windowed mode. Your display must support 1024x768x16 to run the game full screen."));
			}
			// We reinit color cursors, because SDL on Mac seems to forget the SDL_Cursor
			set_color_cursors(preferences::get("color_cursors", false));
		}
	}
}
示例#2
0
file_dialog::file_dialog(CVideo& video, const std::string& file_path,
		const std::string& title, const std::string& default_file_name,
		bool show_directory_buttons) :
	gui::dialog(video, title, file_path, gui::OK_CANCEL),
	show_directory_buttons_(show_directory_buttons),
	files_list_(nullptr),
	last_selection_(-1),
	last_textbox_text_(),
	chosen_file_(".."),
    autocomplete_(true)
{
	files_list_ = new gui::file_menu(video, file_path);
	const unsigned file_list_height = (video.gety() / 2);
	const unsigned file_list_width = std::min<unsigned>(files_list_->width(), (video.gety() / 4));
	files_list_->set_measurements(file_list_width, file_list_height);
	files_list_->set_max_height(file_list_height);
	set_menu(files_list_);
	default_file_name_ = default_file_name;
	get_message().set_text(format_dirname(files_list_->get_directory()));
	set_textbox(_("File: "), format_filename(file_path), 100);
	if (show_directory_buttons_)
	{
		add_button( new gui::dialog_button(video, _("Delete File"),
					gui::button::TYPE_PRESS, gui::DELETE_ITEM), dialog::BUTTON_EXTRA);
		add_button( new gui::dialog_button(video, _("New Folder"),
					gui::button::TYPE_PRESS, gui::CREATE_ITEM), dialog::BUTTON_EXTRA_LEFT);
	}
}
示例#3
0
bool set_resolution(CVideo& video
		, const unsigned width, const unsigned height)
{
	SDL_Rect rect;
	SDL_GetClipRect(video.getSurface(), &rect);
	if(rect.w == width && rect.h == height) {
		return true;
	}

	const int flags = fullscreen() ? FULL_SCREEN : 0;
	int bpp = video.bppForMode(width, height, flags);

	if(bpp != 0) {
		video.setMode(width, height, bpp, flags);

		if(disp) {
			disp->redraw_everything();
		}

	} else {
        // grzywacz: is this even true?
		gui2::show_transient_message(video,"",_("The video mode could not be changed. Your window manager must be set to 16 bits per pixel to run the game in windowed mode. Your display must support 1024x768x16 to run the game full screen."));
		return false;
	}

	const std::string postfix = fullscreen() ? "resolution" : "windowsize";
	preferences::set('x' + postfix, lexical_cast<std::string>(width));
	preferences::set('y' + postfix, lexical_cast<std::string>(height));

	return true;
}
示例#4
0
文件: intro.cpp 项目: Heark/wesnoth
void the_end(CVideo &video, std::string text, unsigned int duration)
{
	//
	// Some sane defaults.
	//
	if(text.empty())
		text = _("The End");
	if(!duration)
		duration = 3500;

	SDL_Rect area = screen_area();
	sdl::fill_rect(video.getSurface(),&area,0);

	update_whole_screen();
	video.flip();

	const size_t font_size = font::SIZE_XLARGE;

	area = font::text_area(text,font_size);
	area.x = screen_area().w/2 - area.w/2;
	area.y = screen_area().h/2 - area.h/2;

	for(size_t n = 0; n < 255; n += 5) {
		if(n)
			sdl::fill_rect(video.getSurface(),&area,0);

		const SDL_Color col = create_color(n, n, n, n);
		font::draw_text(&video,area,font_size,col,text,area.x,area.y);
		update_rect(area);

		events::pump();
		events::raise_process_event();
		events::raise_draw_event();
		video.flip();
		CVideo::delay(10);
	}

	//
	// Delay after the end of fading.
	// Rounded to multiples of 10.
	//
	unsigned int count = duration/10;
	while(count) {
		events::pump();
		events::raise_process_event();
		events::raise_draw_event();
		video.flip();
		CVideo::delay(10);
		--count;
	}
}
示例#5
0
bool show_video_mode_dialog(CVideo& video)
{
	const resize_lock prevent_resizing;
	// For some reason, this line prevents the dialog from being opened from GUI2...
	//const events::event_context dialog_events_context;

	std::vector<std::pair<int,int> > resolutions
			= video.get_available_resolutions();

	if(resolutions.empty()) {
		gui2::show_transient_message(
				video
				, ""
				, _("There are no alternative video modes available"));

		return false;
	}

	std::vector<std::string> options;
	unsigned current_choice = 0;

	for(size_t k = 0; k < resolutions.size(); ++k) {
		std::pair<int, int> const& res = resolutions[k];

		if (res == video.current_resolution())
			current_choice = static_cast<unsigned>(k);

		std::ostringstream option;
		option << res.first << utils::unicode_multiplication_sign << res.second;
		const int div = boost::math::gcd(res.first, res.second);
		const int ratio[2] = {res.first/div, res.second/div};
		if (ratio[0] <= 10 || ratio[1] <= 10)
			option << " (" << ratio[0] << ':' << ratio[1] << ')';
		options.push_back(option.str());
	}

	gui2::tsimple_item_selector dlg(_("Choose Resolution"), "", options);
	dlg.set_selected_index(current_choice);
	dlg.show(video);

	int choice = dlg.selected_index();

	if(choice == -1 || resolutions[static_cast<size_t>(choice)] == video.current_resolution()) {
		return false;
	}

	video.set_resolution(resolutions[static_cast<size_t>(choice)]);

	return true;
}
示例#6
0
static bool fullscreen(CVideo& video)
{
	video.set_fullscreen(!preferences::fullscreen());


	return true;
}
示例#7
0
void textbox::draw_cursor(int pos, CVideo &video) const
{
	if(show_cursor_ && editable_) {
		SDL_Rect rect = {location().x + pos, location().y, 1, location().h };
		surface const frame_buffer = video.getSurface();
		SDL_FillRect(frame_buffer,&rect,SDL_MapRGB(frame_buffer->format,255,255,255));
	}
}
示例#8
0
void GuiIconCarousel::OnTouchClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger)
{
    if(!controller->data.validPointer)
        return;

    bWasDragging = false;
    selectedGameOnDragStart = getSelectedGame();
    lastPosition.x = controller->data.x;
    lastPosition.y = controller->data.y;

    //! calculate ray origin and direction
    glm::vec3 rayOrigin;
    glm::vec3 rayDir;

    CVideo *video = Application::instance()->getVideo();
    video->screenPosToWorldRay(controller->data.x, controller->data.y, rayOrigin, rayDir);

    glm::vec3 rayDirFrac((rayDir.x != 0.0f) ? (1.0f / rayDir.x) : 0.0f, (rayDir.y != 0.0f) ? (1.0f / rayDir.y) : 0.0f, (rayDir.z != 0.0f) ? (1.0f / rayDir.z) : 0.0f);

    for(u32 i = 0; i < drawOrder.size(); ++i)
    {
        int idx = drawOrder[i];

        if(gameIcons[idx]->checkRayIntersection(rayOrigin, rayDirFrac))
        {
            if(buttonClickSound)
                buttonClickSound->Play();

            setSelectedGame(idx);
            gameSelectionChanged(this, idx);

            //! TODO: change this to a button assigned image
            gameIcons[idx]->setState(STATE_CLICKED);
            gameIcons[idx]->setEffect(EFFECT_SCALE, 4, 125);

            if(selectedGame == idx)
            {
                if(gameLaunchTimer < 30)
                    OnLaunchClick(button, controller, trigger);

                gameLaunchTimer = 0;
            }
        }
    }
}
示例#9
0
bool detect_video_settings(CVideo& video, std::pair<int,int>& resolution, int& bpp, int& video_flags)
{
	video_flags = fullscreen() ? FULL_SCREEN : 0;
	resolution = preferences::resolution();

	int DefaultBPP = 24;
	const SDL_VideoInfo* const video_info = SDL_GetVideoInfo();
	if(video_info != NULL && video_info->vfmt != NULL) {
		DefaultBPP = video_info->vfmt->BitsPerPixel;
	}

	std::cerr << "Checking video mode: " << resolution.first << 'x'
		<< resolution.second << 'x' << DefaultBPP << "...\n";

	typedef std::pair<int, int> res_t;
	std::vector<res_t> res_list;
    if(fullscreen()){
        res_list.push_back(res_t(2560, 1600));
        res_list.push_back(res_t(1920, 1200));
        res_list.push_back(res_t(1920, 1080));
        res_list.push_back(res_t(1680, 1050));
        res_list.push_back(res_t(1440, 900));
        res_list.push_back(res_t(1360, 768));
    }
    res_list.push_back(res_t(1024, 768));


	bpp = video.modePossible(resolution.first, resolution.second,
		DefaultBPP, video_flags, true);

	BOOST_FOREACH(const res_t &res, res_list)
	{
		if (bpp != 0) break;
		std::cerr << "Video mode " << resolution.first << 'x'
			<< resolution.second << 'x' << DefaultBPP
			<< " is not supported; attempting " << res.first
			<< 'x' << res.second << 'x' << DefaultBPP << "...\n";
		resolution = res;
		bpp = video.modePossible(resolution.first, resolution.second,
			DefaultBPP, video_flags);
	}

	preferences::set_resolution(resolution);
	return bpp != 0;
}
示例#10
0
bool tdialog::show(CVideo& video, const unsigned auto_close_time)
{
	if(video.faked() && !show_even_without_video_) {
		if(!allow_plugin_skip_) {
			return false;
		}

		plugins_manager* pm = plugins_manager::get();
		if (pm && pm->any_running())
		{
			plugins_context pc("Dialog");
			pc.set_callback("skip_dialog", [this](config) { retval_ = twindow::OK; }, false);
			pc.set_callback("quit", [](config) {}, false);
			pc.play_slice();
		}

		return false;
	}

	std::unique_ptr<twindow> window(build_window(video));
	assert(window.get());

	post_build(*window);

	window->set_owner(this);

	init_fields(*window);

	pre_show(*window);

	retval_ = window->show(restore_, auto_close_time);

	/*
	 * It can happen that when two clicks follow each other fast that the event
	 * handling code in events.cpp generates a DOUBLE_CLICK_EVENT. For some
	 * reason it can happen that this event gets pushed in the queue when the
	 * window is shown, but processed after the window is closed. This causes
	 * the next window to get this pending event.
	 *
	 * This caused a bug where double clicking in the campaign selection dialog
	 * directly selected a difficulty level and started the campaign. In order
	 * to avoid that problem, filter all pending DOUBLE_CLICK_EVENT events after
	 * the window is closed.
	 */
	SDL_FlushEvent(DOUBLE_CLICK_EVENT);

	finalize_fields(*window, (retval_ == twindow::OK || always_save_fields_));

	post_show(*window);

	// post_show may have updated the windoe retval. Update it here.
	retval_ = window->get_retval();

	return retval_ == twindow::OK;
}
void tnetwork_transmission::wesnothd_dialog(CVideo& video, gui2::tnetwork_transmission::connection_data& conn, const std::string& msg1, const std::string& msg2)
{
	if (video.faked()) {
		while (!conn.finished()) {
			conn.poll();
			SDL_Delay(1);
		}
	}
	else {
		gui2::tnetwork_transmission(conn, msg1, msg2).show(video);
	}
}
示例#12
0
void textbox::draw_cursor(int pos, CVideo &video) const
{
	if(show_cursor_ && editable_ && enabled()) {
		SDL_Rect rect = create_rect(location().x + pos
				, location().y
				, 1
				, location().h);

		surface frame_buffer = video.getSurface();
		sdl_fill_rect(frame_buffer,&rect,SDL_MapRGB(frame_buffer->format,255,255,255));
	}
}
示例#13
0
VideoPtr Video::Create(StreamPtr stream, MessageCallback messageCallback, IAudioDevicePtr audioDevice)
{
	static bool initialized = false;
	if(!initialized)
		av_register_all();

	CVideo* video = new CVideo(messageCallback);

	av_log_set_callback(CVideo::logCb);
	av_log_set_level(AV_LOG_WARNING);

	try {
		video->openFile(stream, audioDevice);
	}

	catch(VideoException e){
		delete video;
		throw e;
	}

	return VideoPtr(video);
}
示例#14
0
static bool fullscreen(CVideo& video)
{
	video.set_fullscreen(!preferences::fullscreen());

#if !SDL_VERSION_ATLEAST(2, 0, 0)
	// Setting to fullscreen doesn't seem to generate a resize event.
	const SDL_Rect& rect = screen_area();

	SDL_Event event;
	event.type = SDL_VIDEORESIZE;
	event.resize.type = SDL_VIDEORESIZE;
	event.resize.w = rect.w;
	event.resize.h = rect.h;

	SDL_PushEvent(&event);
#endif

	return true;
}
示例#15
0
// Helper function to refresh resolution list
static void set_resolution_list(tcombobox& res_list, CVideo& video)
{
	const std::vector<std::pair<int,int> > resolutions = video.get_available_resolutions(true);

	std::vector<std::string> options;
	FOREACH(const AUTO& res, resolutions)
	{
		std::ostringstream option;
		option << res.first << utils::unicode_multiplication_sign << res.second;

		const int div = boost::math::gcd(res.first, res.second);
		const int ratio[2] = {res.first/div, res.second/div};
		if (ratio[0] <= 10 || ratio[1] <= 10) {
			option << " <span color='#777777'>("
				<< ratio[0] << ':' << ratio[1] << ")</span>";
		}

		options.push_back(option.str());
	}
示例#16
0
void tpopup::show(CVideo& video
		, const bool allow_interaction
		, const unsigned /*auto_close_time*/)
{
	if(video.faked()) {
		return;
	}

	hide();

	window_ = build_window(video);

	post_build(video, *window_);

	pre_show(video, *window_);

	if(allow_interaction) {
		window_->show_non_modal();
	} else {
		window_->show_tooltip(/*auto_close_time*/);
	}
}
示例#17
0
文件: help.cpp 项目: Wedge009/wesnoth
/**
 * Open a help dialog using a toplevel other than the default.
 *
 * This allows for complete customization of the contents, although not in a
 * very easy way.
 */
void show_help(CVideo& video, const section &toplevel_sec,
			   const std::string& show_topic,
			   int xloc, int yloc)
{
	const events::event_context dialog_events_context;
	const gui::dialog_manager manager;

	CVideo& screen = video;
	const surface& scr = screen.getSurface();

	const int width  = std::min<int>(font::relative_size(1200), scr->w - font::relative_size(20));
	const int height = std::min<int>(font::relative_size(850), scr->h - font::relative_size(150));
	const int left_padding = font::relative_size(10);
	const int right_padding = font::relative_size(10);
	const int top_padding = font::relative_size(10);
	const int bot_padding = font::relative_size(10);

	// If not both locations were supplied, put the dialog in the middle
	// of the screen.
	if (yloc <= -1 || xloc <= -1) {
		xloc = scr->w / 2 - width / 2;
		yloc = scr->h / 2 - height / 2;
	}
	std::vector<gui::button*> buttons_ptr;
	gui::button close_button_(video, _("Close"));
	buttons_ptr.push_back(&close_button_);

	gui::dialog_frame f(video, _("The Battle for Wesnoth Help"), gui::dialog_frame::default_style,
					 true, &buttons_ptr);
	f.layout(xloc, yloc, width, height);
	f.draw();

    // Find all unit_types that have not been constructed yet and fill in the information
    // needed to create the help topics
	unit_types.build_all(unit_type::HELP_INDEXED);

	if (preferences::encountered_units().size() != size_t(last_num_encountered_units) ||
	    preferences::encountered_terrains().size() != size_t(last_num_encountered_terrains) ||
	    last_debug_state != game_config::debug ||
		last_num_encountered_units < 0) {
		// More units or terrains encountered, update the contents.
		last_num_encountered_units = preferences::encountered_units().size();
		last_num_encountered_terrains = preferences::encountered_terrains().size();
		last_debug_state = game_config::debug;
		generate_contents();
	}
	try {
		help_browser hb(video, toplevel_sec);
		hb.set_location(xloc + left_padding, yloc + top_padding);
		hb.set_width(width - left_padding - right_padding);
		hb.set_height(height - top_padding - bot_padding);
		if (show_topic != "") {
			hb.show_topic(show_topic);
		}
		else {
			hb.show_topic(default_show_topic);
		}
		hb.set_dirty(true);
		events::raise_draw_event();
		CKey key;
		for (;;) {
			events::pump();
			events::raise_process_event();
			f.draw();
			events::raise_draw_event();
			if (key[SDLK_ESCAPE]) {
				// Escape quits from the dialog.
				return;
			}
			for (std::vector<gui::button*>::iterator button_it = buttons_ptr.begin();
				 button_it != buttons_ptr.end(); ++button_it) {
				if ((*button_it)->pressed()) {
					// There is only one button, close.
					return;
				}
			}
			video.flip();
			CVideo::delay(10);
		}
	}
	catch (parse_error& e) {
		std::stringstream msg;
		msg << _("Parse error when parsing help text: ") << "'" << e.message << "'";
		gui2::show_transient_message(video, "", msg.str());
	}
}
void default_map_generator::user_config(CVideo& v)
{
    const events::event_context dialog_events_context;

    CVideo& screen = v;

    const int width = 600;
    const int height = 400;
    const int xpos = screen.getx()/2 - width/2;
    int ypos = screen.gety()/2 - height/2;

    gui::button close_button(screen,_("Close"));
    std::vector<gui::button*> buttons(1,&close_button);

    gui::dialog_frame f(screen,_("Map Generator"),gui::dialog_frame::default_style,true,&buttons);
    f.layout(xpos,ypos,width,height);
    f.draw();

    SDL_Rect dialog_rect = sdl::create_rect(xpos, ypos, width, height);
    surface_restorer dialog_restorer(&screen,dialog_rect);

    const std::string& players_label = _("Players:");
    const std::string& width_label = _("Width:");
    const std::string& height_label = _("Height:");
    const std::string& iterations_label = _("Number of hills:");
    const std::string& hillsize_label = _("Max hill size:");
    const std::string& villages_label = _("Villages:");
    const std::string& castlesize_label = _("Castle size:");
    const std::string& landform_label = _("Landform:");

    SDL_Rect players_rect = font::draw_text(nullptr,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,players_label,0,0);
    SDL_Rect width_rect = font::draw_text(nullptr,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,width_label,0,0);
    SDL_Rect height_rect = font::draw_text(nullptr,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,height_label,0,0);
    SDL_Rect iterations_rect = font::draw_text(nullptr,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,iterations_label,0,0);
    SDL_Rect hillsize_rect = font::draw_text(nullptr,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,hillsize_label,0,0);
    SDL_Rect villages_rect = font::draw_text(nullptr,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,villages_label,0,0);
    SDL_Rect castlesize_rect = font::draw_text(nullptr,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,castlesize_label,0,0);
    SDL_Rect landform_rect = font::draw_text(nullptr,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,landform_label,0,0);

    const int horz_margin = 15;
    const int text_right = xpos + horz_margin +
                           std::max<int>(std::max<int>(std::max<int>(std::max<int>(std::max<int>(std::max<int>(
                                   players_rect.w,width_rect.w),height_rect.w),iterations_rect.w),hillsize_rect.w),villages_rect.w),castlesize_rect.w);

    players_rect.x = text_right - players_rect.w;
    width_rect.x = text_right - width_rect.w;
    height_rect.x = text_right - height_rect.w;
    iterations_rect.x = text_right - iterations_rect.w;
    hillsize_rect.x = text_right - hillsize_rect.w;
    villages_rect.x = text_right - villages_rect.w;
    castlesize_rect.x = text_right - castlesize_rect.w;
    landform_rect.x = text_right - landform_rect.w;

    const int vertical_margin = 20;
    players_rect.y = ypos + vertical_margin*2;
    width_rect.y = players_rect.y + players_rect.h + vertical_margin;
    height_rect.y = width_rect.y + width_rect.h + vertical_margin;
    iterations_rect.y = height_rect.y + height_rect.h + vertical_margin;
    hillsize_rect.y = iterations_rect.y + iterations_rect.h + vertical_margin;
    villages_rect.y = hillsize_rect.y + hillsize_rect.h + vertical_margin;
    castlesize_rect.y = villages_rect.y + iterations_rect.h + vertical_margin;
    landform_rect.y = castlesize_rect.y + villages_rect.h + vertical_margin;

    const int right_space = 150;

    const int slider_left = text_right + 10;
    const int slider_right = xpos + width - horz_margin - right_space;
    SDL_Rect slider_rect = sdl::create_rect(slider_left
                                            , players_rect.y
                                            , slider_right - slider_left
                                            , players_rect.h);

    gui::slider players_slider(screen);
    players_slider.set_location(slider_rect);
    players_slider.set_min(2);
    players_slider.set_max(gamemap::MAX_PLAYERS);
    players_slider.set_value(nplayers_);

    const int min_width = 20;
    const int max_width = 100;
    const int max_height = 100;
    const int extra_size_per_player = 2;

    slider_rect.y = width_rect.y;
    gui::slider width_slider(screen);
    width_slider.set_location(slider_rect);
    width_slider.set_min(min_width+(players_slider.value()-2)*extra_size_per_player);
    width_slider.set_max(max_width);
    width_slider.set_value(width_);

    slider_rect.y = height_rect.y;
    gui::slider height_slider(screen);
    height_slider.set_location(slider_rect);
    height_slider.set_min(min_width+(players_slider.value()-2)*extra_size_per_player);
    height_slider.set_max(max_height);
    height_slider.set_value(height_);

    const int min_iterations = 10;
    const int max_iterations = 3000;

    slider_rect.y = iterations_rect.y;
    gui::slider iterations_slider(screen);
    iterations_slider.set_location(slider_rect);
    iterations_slider.set_min(min_iterations);
    iterations_slider.set_max(max_iterations);
    iterations_slider.set_value(iterations_);

    const int min_hillsize = 1;
    const int max_hillsize = 50;

    slider_rect.y = hillsize_rect.y;
    gui::slider hillsize_slider(screen);
    hillsize_slider.set_location(slider_rect);
    hillsize_slider.set_min(min_hillsize);
    hillsize_slider.set_max(max_hillsize);
    hillsize_slider.set_value(hill_size_);

    const int min_villages = 0;
    const int max_villages = 50;

    slider_rect.y = villages_rect.y;
    gui::slider villages_slider(screen);
    villages_slider.set_location(slider_rect);
    villages_slider.set_min(min_villages);
    villages_slider.set_max(max_villages);
    villages_slider.set_value(nvillages_);

    const int min_castlesize = 2;
    const int max_castlesize = 14;

    slider_rect.y = castlesize_rect.y;
    gui::slider castlesize_slider(screen);
    castlesize_slider.set_location(slider_rect);
    castlesize_slider.set_min(min_castlesize);
    castlesize_slider.set_max(max_castlesize);
    castlesize_slider.set_value(castle_size_);


    const int min_landform = 0;
    const int max_landform = int(max_island);
    slider_rect.y = landform_rect.y;
    gui::slider landform_slider(screen);
    landform_slider.set_location(slider_rect);
    landform_slider.set_min(min_landform);
    landform_slider.set_max(max_landform);
    landform_slider.set_value(island_size_);

    SDL_Rect link_rect = slider_rect;
    link_rect.y = link_rect.y + link_rect.h + vertical_margin;

    gui::button link_castles(screen,_("Roads between castles"),gui::button::TYPE_CHECK);
    link_castles.set_check(link_castles_);
    link_castles.set_location(link_rect);

    SDL_Rect labels_rect = link_rect;
    labels_rect.y = labels_rect.y + labels_rect.h + vertical_margin;

    gui::button show_labels(screen,_("Show labels"),gui::button::TYPE_CHECK);
    show_labels.set_check(show_labels_);
    show_labels.set_location(labels_rect);

    while(true) {
        nplayers_ = players_slider.value();
        width_ = width_slider.value();
        height_ = height_slider.value();
        iterations_ = iterations_slider.value();
        hill_size_ = hillsize_slider.value();
        nvillages_ = villages_slider.value();
        castle_size_ = castlesize_slider.value();
        island_size_ = landform_slider.value();

        dialog_restorer.restore();
        close_button.set_dirty(true);
        if (close_button.pressed())
            break;

        players_slider.set_dirty();
        width_slider.set_dirty();
        height_slider.set_dirty();
        iterations_slider.set_dirty();
        hillsize_slider.set_dirty();
        villages_slider.set_dirty();
        castlesize_slider.set_dirty();
        landform_slider.set_dirty();
        link_castles.set_dirty();
        show_labels.set_dirty();

        width_slider.set_min(min_width+(players_slider.value()-2)*extra_size_per_player);
        height_slider.set_min(min_width+(players_slider.value()-2)*extra_size_per_player);

        f.draw();
        events::raise_process_event();
        events::raise_draw_event();

        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,players_label,players_rect.x,players_rect.y);
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,width_label,width_rect.x,width_rect.y);
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,height_label,height_rect.x,height_rect.y);
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,iterations_label,iterations_rect.x,iterations_rect.y);
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,hillsize_label,hillsize_rect.x,hillsize_rect.y);
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,villages_label,villages_rect.x,villages_rect.y);
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,castlesize_label,castlesize_rect.x,castlesize_rect.y);
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,landform_label,landform_rect.x,landform_rect.y);

        font::draw_text(&screen, screen_area(), font::SIZE_NORMAL,
                        font::NORMAL_COLOR, std::to_string(nplayers_),
                        slider_right + horz_margin, players_rect.y);

        font::draw_text(&screen, screen_area(), font::SIZE_NORMAL,
                        font::NORMAL_COLOR, std::to_string(width_),
                        slider_right + horz_margin, width_rect.y);

        font::draw_text(&screen, screen_area(), font::SIZE_NORMAL,
                        font::NORMAL_COLOR, std::to_string(height_),
                        slider_right+horz_margin,height_rect.y);

        std::stringstream villages_str;
        villages_str << nvillages_ << _("/1000 tiles");
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,villages_str.str(),
                        slider_right+horz_margin,villages_rect.y);

        font::draw_text(&screen, screen_area(), font::SIZE_NORMAL,
                        font::NORMAL_COLOR, std::to_string(castle_size_),
                        slider_right + horz_margin, castlesize_rect.y);

        std::stringstream landform_str;
        landform_str << translation::gettext(island_size_ == 0 ? N_("Inland") : (island_size_ < max_coastal ? N_("Coastal") : N_("Island")));
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,landform_str.str(),
                        slider_right+horz_margin,landform_rect.y);

        update_rect(xpos,ypos,width,height);

        v.flip();
        CVideo::delay(100);
        events::pump();
    }

    link_castles_ = link_castles.checked();
    show_labels_ = show_labels.checked();
}
示例#19
0
//
//  機能     : 画面の更新
//  
//  機能説明 : 
//  
//  返り値   : BOOL
//  
//  備考     : 
//  
BOOL CRsfSimpleForm::UpdateForm() 
{
	/// カレントレコード
	if (theApp.m_lngRsflId <= 0) return FALSE;

	/// 再生中のファイルを停止する
//	PlayStop();

	// StatusBarのクリア
	CMainFrame *pFrame = (CMainFrame*)::AfxGetMainWnd();
	pFrame->SetStatusText(_T(""), 0);
	pFrame->SetStatusText(_T(""), 1);

	// ラジオボタンの参照定義(DDXは扱いにくいので)
	// (クラスメンバーで宣言すると正常に動作しない)
	CButton *rd_rec = (CButton *)GetDlgItem(IDC_RDO_REC);
	CButton *rd_vrec = (CButton *)GetDlgItem(IDC_RDO_VREC);
	CButton *rd_discon = (CButton *)GetDlgItem(IDC_RDO_DISCONNECT);

	/// 初期設定
	m_blAudio = FALSE;
    m_blChat = FALSE;
    m_blVideo = FALSE;
    m_blImg = FALSE;
	m_blBeep = FALSE;
	m_blPrg = FALSE;
	rd_rec->SetCheck(0);
	rd_vrec->SetCheck(0);
	rd_discon->SetCheck(1);

	/// 応答設定テーブルを選択
	CTblRsfl tbl(theApp.m_strDBPath);
	CString strWhere;
	_TCHAR buf[64];
	strWhere.Empty();
	_ltot_s(theApp.m_lngRsflId, buf, sizeof(buf)/sizeof(buf[0]), 10);
	strWhere = strWhere + _T("ID") + _T("=") + buf;
	_ltot_s(RESPBASE_TYPE_SIMPLE, buf, sizeof(buf)/sizeof(buf[0]), 10);
	strWhere = strWhere + _T(" and ") + _T("lngRespType") + _T("=") + buf;
	if (tbl.SelectRec(strWhere) <= 0) {
		return FALSE;
	}

	/// 選択された応答設定RSFをロード
	CTPsetup tps(theApp.m_strDataFolder);
	if (tbl.lngDefaultFlag == 1) {
		m_strSenderId = _T("0");	// default setting
	} else {
		m_strSenderId = tbl.strSenderId;
	}
	tps.SetCallerId(m_strSenderId);
	UST_RSF *pst = tps.LoadRSF();
	if (pst == NULL) return FALSE;

	/// 選択された応答設定RSFを参照
	UST_RSF_RESP *pst_resp;
	for (int i = 0; i < pst->resp_cnt; i++) {
		pst_resp = pst->resp + i;
		//// BEEPのON/OFF
		if (pst_resp->beep > 0) {
			m_blBeep = TRUE;
		}
		switch(pst_resp->type) {
		case RESP_TYPE_PLAY:
			//// 再生内容のON/OFF
			if (pst_resp->play_type & RESP_PLAY_TYPE_AUDIO) {
				m_blAudio = TRUE;
			}
			if (pst_resp->play_type & RESP_PLAY_TYPE_VIDEO) {
				m_blVideo = TRUE;
			}
			if (pst_resp->play_type & RESP_PLAY_TYPE_IMAGE) {
				m_blImg = TRUE;
			}
			if (pst_resp->play_type & RESP_PLAY_TYPE_CHAT) {
				m_blChat = TRUE;
			}
			break;
		//// 録音内容のON/OFF
		case RESP_TYPE_RECORD:
			rd_rec->SetCheck(1);
			rd_vrec->SetCheck(0);
			rd_discon->SetCheck(0);
			break;
		case RESP_TYPE_VRECORD:
			rd_rec->SetCheck(0);
			rd_vrec->SetCheck(1);
			rd_discon->SetCheck(0);
			break;
		case RESP_TYPE_DISCONNECT:
			// 全ての設定で使用されるので、設定すべきことはない
			break;
		//// プログラム連携のON/OFF
		case RESP_TYPE_EXEC:
			m_blPrg = TRUE;
			break;
		default:
			break;
		}
	}

	/// 応答音声ファイルの時間表示
	CString strPlayFile;
	CString strSize;
	CFileSpec fs;
	strSize = _T("[ 00:00 ]");
	strPlayFile = tps.RsfAudioFileName(_T("$"));
	fs.SetFullSpec(strPlayFile);
	if (fs.Exist()) {
		CMainFrame *pFrame = (CMainFrame*)::AfxGetMainWnd();
		CAudio *pAudio = pFrame->m_pAudio;
		pAudio->m_PlayFile = strPlayFile;
		float fTime = pAudio->GetPlaySize();
		if (fTime > 0.0) {
			long lngTime = (long)(fTime+1);
			strSize.Format(_T("[ %02i:%02i ]"), (lngTime/60), (lngTime%60));
		}
	}
	m_lblAudioSize.SetText((LPCTSTR)strSize);

	/// 応答ビデオファイルの時間表示
	strSize = _T("[ 00:00 ]");
	strPlayFile = tps.RsfVideoFileName(_T("$"));
	fs.SetFullSpec(strPlayFile);
	if (fs.Exist()) {
		CMainFrame *pFrame = (CMainFrame*)::AfxGetMainWnd();
		CVideo *pVideo = pFrame->m_pVideo;
		pVideo->SetPlayFile(strPlayFile);
		float fTime = pVideo->GetPlaySize();
		if (fTime > 0.0) {
			long lngTime = (long)(fTime+1);
			strSize.Format(_T("[ %02i:%02i ]"), (lngTime/60), (lngTime%60));
		}
	}
	m_lblVideoSize.SetText((LPCTSTR)strSize);

	/// 画像ファイルのサイズ表示
	strSize = _T("[ 0 Kbytes ]");
	strPlayFile = tps.FindRsfImgFile(_T("$"));
	fs.SetFullSpec(strPlayFile);
	if (fs.Exist()) {
		strSize.Format(_T("[ %d Kbytes ]"), fs.FileSize()/1024);
	}
	m_lblImgSize.SetText((LPCTSTR)strSize);

	/// チャットテキストファイルのサイズ表示
	strSize = _T("[ 0 bytes ]");
	strPlayFile = tps.RsfChatFileName(_T("$"));
	fs.SetFullSpec(strPlayFile);
	if (fs.Exist()) {
		strSize.Format(_T("[ %d bytes ]"), fs.FileSize());
	}
	m_lblChatSize.SetText((LPCTSTR)strSize);

 	/// 連携プログラムコンボボックスを選択
	CString str, strPrgId;
	strPrgId.Format(_T("%d"), pst_resp->exec_id);
	int idx = 0;
	for(int i = 0; i <  m_aryPrgId.GetSize(); i++) {
		str = m_aryPrgId.GetAt(i);
		if (strPrgId == str) {
			idx = i;
			break;
		}
	}
	m_idxPrg = idx;

	/// 連携プログラムCSVファイルが存在しない場合、テンプレートCSVフォルダからコピー
	CString strBinDir, strFile;
	fs.SetFullSpec(FS_APPDIR);
	strBinDir = fs.GetFullSpec() + _T("bin");	// テンプレートCSVフォルダ
	for(int i = 0; i <  m_aryPrgId.GetSize(); i++) {
		strPrgId = m_aryPrgId.GetAt(i);
		strFile = tps.RsfPrgFileName(_T("$$$$"), strPrgId);	// 連携プログラムCSVファイル
		fs.SetFullSpec(strFile);
		if (!fs.Exist()) {
			fs.SetFullSpec(strBinDir + "\\" + strPrgId + ".csv");
			if (fs.Exist()) {
				fs.FileCopy(strFile, FALSE);	// 上書きはしない
			}
		}
	}

	UpdateData(FALSE);	// DDX更新

	return TRUE;
}
示例#20
0
/**
 * Open the help browser, show the variation of the unit matching.
 */
void show_variation_help(CVideo& video, const std::string& unit, const std::string &variation, bool hidden, int xloc, int yloc)
{
	show_help(video, toplevel, hidden_symbol(hidden) + variation_prefix + unit + "_" + variation, xloc, yloc);
	video.flip();
}
示例#21
0
/**
 * Open the help browser, show topic with id show_topic.
 *
 * If show_topic is the empty string, the default topic will be shown.
 */
void show_help(CVideo& video, const std::string& show_topic, int xloc, int yloc)
{
	show_help(video, toplevel, show_topic, xloc, yloc);
	video.flip();
}
示例#22
0
int old_main()
{
	geckoinit = InitGecko();
	use_dvdx = 1;
	
	InitDVD();

	SYS_SetArena1Hi((void *)0x81200000);	// See loader/apploader.c
	CVideo vid;
	
	gprintf("WodeFlow started, running with ios %d\n", IOS_GetVersion());

	bool dipOK = false;
	int ret = 0;
	bool hbc;
	bool wodeOK = false;
		
	// MEM2 usage :
	// 36 MB for general purpose allocations
	// 12 MB for covers (and temporary buffers)
	// adds 15 MB from MEM1 to obtain 27 MB for covers (about 150 HQ covers on screen)
	MEM2_init(36, 12);	// Max ~48

	// Launched through the HBC?
    hbc = *((u32 *) 0x80001804) == 0x53545542 && *((u32 *) 0x80001808) == 0x48415858;

	// Init video
	vid.init();
	
	// Init
	STexture texWait;
	texWait.fromPNG(wait_png, GX_TF_RGB565, ALLOC_MALLOC);
	vid.waitMessage(texWait);
	Sys_Init();
	Sys_ExitToWiiMenu(true);

	Fat_Mount();

	WPAD_Init();
	WPAD_SetDataFormat(0, WPAD_FMT_BTNS_ACC_IR);

	dipOK = Disc_Init() >= 0;
	if (dipOK) {
		u32 status = 0;
		if (WDVD_GetCoverStatus(&status) != 0 || (status & 2) == 0) {
			// WDVD_WaitForDisc();
			
			STexture texWaitForDisc;
			texWaitForDisc.fromPNG(wait_disc_png, GX_TF_RGB565, ALLOC_MALLOC);
			vid.waitMessage(texWaitForDisc);
			texWaitForDisc.data.release();
			do
			{
				WPAD_ScanPads();
				s32 padsState = WPAD_ButtonsDown(0);
				if ((padsState & WPAD_BUTTON_B) != 0)
					break;
				usleep(100 * 1000);
			} while (WDVD_GetCoverStatus(&status) != 0 || (status & 2) == 0);
			if ((status & 2) == 0) return -2;
			
			InitDVD();
		}
	}
	
	wodeOK = WBFS_Init() >= 0;
	vid.waitMessage(texWait);
	texWait.data.release();
	
	MEM2_takeBigOnes(true);
	do
	{
		CMenu menu(vid);
		menu.init(hbc);

		if (!dipOK)
			menu.error(L"Could not initialize DIP module!");
		else if (!wodeOK)
			menu.error(L"Wode not found.");
		else
		{
			ret = menu.main();
		}
		vid.cleanup();
	} while (ret == 1);
	
	LaunchISO(0, 0);
	CloseWode();
	
	Fat_Unmount();
	
	return ret;
};
示例#23
0
/**
 * Open the help browser, show unit with id unit_id.
 *
 * If show_topic is the empty string, the default topic will be shown.
 */
void show_unit_help(CVideo& video, const std::string& show_topic, bool has_variations, bool hidden, int xloc, int yloc)
{
	show_help(video, toplevel,
			  hidden_symbol(hidden) + (has_variations ? ".." : "") + unit_prefix + show_topic, xloc, yloc);
	video.flip();
}
示例#24
0
int main(int argc, char **argv)
{
	set_new_handler(no_memory);
	geckoinit = InitGecko();
	__exception_setreload(5);

	SYS_SetArena1Hi(APPLOADER_START);

	char *gameid = NULL;
	string dolLoc; //(argv[0] != NULL ? argv[0] : "");

	for (int i = 0; i < argc; i++)
	{
		if (argv[i] != NULL && strcasestr(argv[i], "ios=") != NULL && strlen(argv[i]) > 4)
		{
			while(argv[i][0] && !isdigit(argv[i][0])) argv[i]++;
			if (atoi(argv[i]) < 254 && atoi(argv[i]) > 0)
				mainIOS = atoi(argv[i]);
		}
		else if (strlen(argv[i]) == 6)
		{
			gameid = argv[i];
			for (int i=0; i < 5; i++)
				if (!isalnum(gameid[i]))
					gameid = NULL;
		}
	}
	gprintf("Loading cIOS: %d\n", mainIOS);

	ISFS_Initialize();

	// Load Custom IOS
	bool iosOK = loadIOS(mainIOS, false);
	MEM2_init(52);

	u8 mainIOSBase = 0;
	iosOK = iosOK && cIOSInfo::D2X(mainIOS, &mainIOSBase);
	gprintf("Loaded cIOS: %u has base %u\n", mainIOS, mainIOSBase);

	// Init video
	CVideo vid;
	vid.init();
	WIILIGHT_Init();
	vid.waitMessage(0.2f);

	// Init
	Sys_Init();
	Sys_ExitTo(EXIT_TO_HBC);

	int ret = 0;

	do
	{
		Open_Inputs();

		bool deviceAvailable = false;

		u8 timeout = 0;
		while(!deviceAvailable && timeout++ != 20)
		{
			DeviceHandler::Instance()->MountAll();
			sleep(1);

			for(u8 device = SD; device <= USB8; device++)
				if(DeviceHandler::Instance()->IsInserted(device))
					deviceAvailable = true;
		}

		bool dipOK = Disc_Init() >= 0;

		CMenu menu(vid);
		menu.init(dolLoc);
		mainMenu = &menu;
		if(!deviceAvailable)
		{
			menu.error(L"Could not find a device to save configuration files on!");
			break;
		}
		else if(!iosOK)
		{
			menu.error(sfmt("d2x cIOS %i rev6 or later is required", mainIOS));
			break;
		}
		else if(!dipOK)
		{
			menu.error(L"Could not initialize the DIP module!");
			break;
		}
		else
		{
			if (gameid != NULL && strlen(gameid) == 6)
				menu._directlaunch(gameid);
			else
				ret = menu.main();
		}
		vid.cleanup();
		if (bootHB)
		{
			IOS_ReloadIOS(58);
			BootHomebrew();
		}

	} while (ret == 1);

	WifiGecko_Close();

	Nand::Instance()->Disable_Emu();
	Nand::DestroyInstance();

	Sys_Exit();
	return 0;
};
示例#25
0
GameLauncherMenu::GameLauncherMenu(int gameIdx)
    : GuiFrame(0,0)
    , gameIdx(gameIdx)
    , bgImage(500, 500, (GX2Color){0, 0, 0, 255})
    , bgBlur(1280, 720, (GX2Color){0, 0, 0, 255})
    , noCover(Resources::GetFile("noCover.png"), Resources::GetFileSize("noCover.png"))
    , buttonClickSound(Resources::GetSound("settings_click_2.mp3"))
    , quitImageData(Resources::GetImageData("quitButton.png"))
    , quitImage(quitImageData)
    , quitSelectedImageData(Resources::GetImageData("quitButtonSelected.png"))
    , quitSelectedImage(quitSelectedImageData)
    , quitButton(quitImage.getWidth(), quitImage.getHeight())
    , okImageData(Resources::GetImageData("emptyRoundButton.png"))
    , okImage(okImageData)
    , okSelectedImageData(Resources::GetImageData("emptyRoundButtonSelected.png"))
    , okSelectedImage(okSelectedImageData)
    , okButton(okImage.getWidth(), okImage.getHeight())
    , okText("O.K.", 46, glm::vec4(0.1f, 0.1f, 0.1f, 1.0f))
    , titleImageData(Resources::GetImageData("settingsTitle.png"))
    , titleImage(titleImageData)
    , extraSaveText(tr("Extra Save:"), 40, glm::vec4(0.8f, 0.8f, 0.8f, 1.0f))
    , dlcEnableText(tr("Enable DLC Support:"), 40, glm::vec4(0.8f, 0.8f, 0.8f, 1.0f))
    , frameImageData(Resources::GetImageData("gameSettingsFrame.png"))
    , frameImage(frameImageData)
    , touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
    , wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A)
    , buttonATrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_A, true)
    , buttonBTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_B, true)
    , buttonLTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_L, true)
    , buttonRTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_R, true)
    , buttonLeftTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_LEFT | GuiTrigger::STICK_L_LEFT, true)
    , buttonRightTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_RIGHT | GuiTrigger::STICK_L_RIGHT, true)
    , buttonUpTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_UP | GuiTrigger::STICK_L_UP, true)
    , buttonDownTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_DOWN | GuiTrigger::STICK_L_DOWN, true)
    , leftArrowImageData(Resources::GetImageData("leftArrow.png"))
    , rightArrowImageData(Resources::GetImageData("rightArrow.png"))
    , leftArrowImage(leftArrowImageData)
    , rightArrowImage(rightArrowImageData)
    , leftArrowButton(leftArrowImage.getWidth(), leftArrowImage.getHeight())
    , rightArrowButton(rightArrowImage.getWidth(), rightArrowImage.getHeight())
    , DPADButtons(0,0)
    , extraSaveBox(false)
    , dlcEnableBox(false)
    , progresswindow("")
    , pathSelectBox(tr("Update Folder"),NULL)
    , saveModeSelectBox(tr("Save Mode"),NULL)
    , launchModeSelectBox(tr("Launch Mode"),NULL)
    , bgUsedImageDataAsync(NULL)
    , bgNewImageDataAsync(NULL)
    , bgFadingImageDataAsync(NULL)
{
    bFocusChanged = true;
    gamelauncherelementfocus = GamelaunchermenuFocus::OK;

    //Settings up the values for the selectboxes that don't change
    savemode_size = sizeof(ValueGameSaveModes) / sizeof(ValueGameSaveModes[0]);

    saveModeNames[tr("<Settings Default>")] = strfmt("%d", GAME_SAVES_DEFAULT);
    for(int i = 0; i < savemode_size; i++){
        saveModeNames[ValueGameSaveModes[i].name] = strfmt("%d",ValueGameSaveModes[i].value);
    }
    launchmode_size = sizeof(ValueLaunchMode) / sizeof(ValueLaunchMode[0]);
    launchModeNames[tr("<Settings Default>")] = strfmt("%d", LOADIINE_MODE_DEFAULT);
    for(int i = 0; i < launchmode_size; i++){
        launchModeNames[ValueLaunchMode[i].name] = strfmt("%d",ValueLaunchMode[i].value);
    }

    progresswindow.setVisible(false);

    Application::instance()->getMainWindow()->gameLauncherMenuNextClicked.connect(this,&GameLauncherMenu::OnGotHeaderFromMain);

    CVideo * video = Application::instance()->getVideo();
    width = video->getTvWidth()*windowScale;
    height = video->getTvHeight()*windowScale;
    gameLauncherMenuFrame = GuiFrame(width, height);

    bgImage.setSize(width,height);
    frameImage.setScale(windowScale);

    bgBlur.setAlpha(0.85f);
    append(&bgBlur);
    append(&bgImage);
    append(&frameImage);

    titleImage.setScale(windowScale);
    titleText.setColor(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
    titleText.setFontSize(46);
    titleText.setPosition(0, 10);
    titleText.setBlurGlowColor(5.0f, glm::vec4(0.0, 0.0, 0.0f, 1.0f));
    append(&titleImage);
    append(&titleText);

    titleText.setParent(&titleImage);
    titleImage.setAlignment(ALIGN_MIDDLE | ALIGN_TOP);
    quitButton.setImage(&quitImage);
	quitButton.setIconOver(&quitSelectedImage);
    quitButton.setAlignment(ALIGN_BOTTOM | ALIGN_LEFT);
    quitButton.clicked.connect(this, &GameLauncherMenu::OnQuitButtonClick);
    quitButton.setTrigger(&touchTrigger);
    quitButton.setTrigger(&wpadTouchTrigger);
    quitButton.setEffectGrow();
    quitButton.setSoundClick(buttonClickSound);
    quitButton.setScale(windowScale*0.8);
    quitButton.setPosition((1.0/30.0)*width,(1.0/30.0)*width);
    gameLauncherMenuFrame.append(&quitButton);

    okText.setPosition(10, -10);
    okButton.setLabel(&okText);
    okButton.setImage(&okImage);
	okButton.setIconOver(&okSelectedImage);
    okButton.setAlignment(ALIGN_BOTTOM | ALIGN_RIGHT);
    okButton.clicked.connect(this, &GameLauncherMenu::OnOKButtonClick);
    okButton.setTrigger(&touchTrigger);
    okButton.setTrigger(&wpadTouchTrigger);
    okButton.setSoundClick(buttonClickSound);
    okButton.setEffectGrow();
    okButton.setScale(windowScale*0.8);
    okButton.setPosition(-(1.0/30.0)*width,(1.0/30.0)*width);
    gameLauncherMenuFrame.append(&okButton);

    leftArrowButton.setImage(&leftArrowImage);
    leftArrowButton.setEffectGrow();
    leftArrowButton.setPosition(-120, 0);
    leftArrowButton.setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
    leftArrowButton.setTrigger(&touchTrigger);
    leftArrowButton.setTrigger(&wpadTouchTrigger);

    leftArrowButton.setSoundClick(buttonClickSound);
    leftArrowButton.clicked.connect(this, &GameLauncherMenu::OnLeftArrowClick);
    gameLauncherMenuFrame.append(&leftArrowButton);

    rightArrowButton.setImage(&rightArrowImage);
    rightArrowButton.setEffectGrow();
    rightArrowButton.setPosition(120, 0);
    rightArrowButton.setAlignment(ALIGN_RIGHT | ALIGN_MIDDLE);
    rightArrowButton.setTrigger(&touchTrigger);
    rightArrowButton.setTrigger(&wpadTouchTrigger);
    rightArrowButton.setSoundClick(buttonClickSound);
    rightArrowButton.clicked.connect(this, &GameLauncherMenu::OnRightArrowClick);
    gameLauncherMenuFrame.append(&rightArrowButton);

    DPADButtons.setTrigger(&buttonDownTrigger);
    DPADButtons.setTrigger(&buttonATrigger);
    DPADButtons.setTrigger(&buttonBTrigger);
    DPADButtons.setTrigger(&buttonLTrigger);
    DPADButtons.setTrigger(&buttonRTrigger);
    DPADButtons.setTrigger(&buttonLeftTrigger);
    DPADButtons.setTrigger(&buttonRightTrigger);
    DPADButtons.setTrigger(&buttonUpTrigger);

    DPADButtons.clicked.connect(this, &GameLauncherMenu::OnDPADClick);
    gameLauncherMenuFrame.append(&DPADButtons);

    f32 buttonscale = 3.8f/3.0f;

    extraSaveBox.setTrigger(&touchTrigger);
    extraSaveBox.setTrigger(&wpadTouchTrigger);
    extraSaveBox.setSoundClick(buttonClickSound);
    extraSaveBox.valueChanged.connect(this, &GameLauncherMenu::OnExtraSaveValueChanged);

    gameLauncherMenuFrame.append(&extraSaveBox);

    dlcEnableBox.setTrigger(&touchTrigger);
    dlcEnableBox.setTrigger(&wpadTouchTrigger);
    dlcEnableBox.setSoundClick(buttonClickSound);
    dlcEnableBox.valueChanged.connect(this, &GameLauncherMenu::OnDLCEnableValueChanged);

    gameLauncherMenuFrame.append(&dlcEnableBox);

    f32 xpos = 0.11f;
    f32 yOffset = -(0.3 * height);

    dlcEnableBox.setScale(buttonscale*windowScale);
    saveModeSelectBox.setScale(buttonscale*windowScale);
    launchModeSelectBox.setScale(buttonscale*windowScale);
    extraSaveBox.setScale(buttonscale*windowScale);
    extraSaveText.setScale(buttonscale*windowScale);
    dlcEnableText.setScale(buttonscale*windowScale);
    pathSelectBox.setScale(buttonscale* windowScale);

    dlcEnableBox.setPosition(xpos*width + (saveModeSelectBox.getTopValueWidth()*saveModeSelectBox.getScale() /2.0) - (dlcEnableBox.getWidth()*dlcEnableBox.getScale()/2.0), yOffset);
    dlcEnableText.setPosition(xpos*width - (saveModeSelectBox.getTopValueWidth()*saveModeSelectBox.getScale() /2.0)+ (dlcEnableText.getTextWidth()/2.0), yOffset);
    yOffset += saveModeSelectBox.getTopValueHeight() * saveModeSelectBox.getScale();

    saveModeSelectBox.setPosition(xpos*width, yOffset);
    yOffset += saveModeSelectBox.getTopValueHeight() * saveModeSelectBox.getScale();

    launchModeSelectBox.setPosition(xpos*width, yOffset);
    yOffset += saveModeSelectBox.getTopValueHeight() * saveModeSelectBox.getScale() * 1.2f;

    extraSaveBox.setPosition(xpos*width + (saveModeSelectBox.getTopValueWidth()*saveModeSelectBox.getScale() /2.0) - (extraSaveBox.getWidth()*extraSaveBox.getScale()/2.0), yOffset);

    extraSaveText.setPosition(xpos*width - (saveModeSelectBox.getTopValueWidth()*saveModeSelectBox.getScale() /2.0)+ (extraSaveText.getTextWidth()/2.0), yOffset);
    yOffset += saveModeSelectBox.getTopValueHeight() * saveModeSelectBox.getScale() * 1.2f;

    pathSelectBox.setPosition(xpos*width, yOffset);
    yOffset += saveModeSelectBox.getTopValueHeight() * saveModeSelectBox.getScale() * 1.2f;

    pathSelectBox.showhide.connect(this, &GameLauncherMenu::OnSelectBoxShowHide);
    launchModeSelectBox.showhide.connect(this, &GameLauncherMenu::OnSelectBoxShowHide),
    saveModeSelectBox.showhide.connect(this, &GameLauncherMenu::OnSelectBoxShowHide);

    pathSelectBox.valueChanged.connect(this, &GameLauncherMenu::OnSelectBoxValueChanged);
    launchModeSelectBox.valueChanged.connect(this, &GameLauncherMenu::OnSelectBoxValueChanged),
    saveModeSelectBox.valueChanged.connect(this, &GameLauncherMenu::OnSelectBoxValueChanged);

    gameLauncherMenuFrame.append(&dlcEnableText);
    gameLauncherMenuFrame.append(&extraSaveText);
    gameLauncherMenuFrame.append(&saveModeSelectBox);
    gameLauncherMenuFrame.append(&pathSelectBox);
    gameLauncherMenuFrame.append(&launchModeSelectBox);

    selectBoxes.push_back(&pathSelectBox);
    selectBoxes.push_back(&launchModeSelectBox);
    selectBoxes.push_back(&saveModeSelectBox);

    append(&gameLauncherMenuFrame);
    append(&progresswindow);

    focusElements[GamelaunchermenuFocus::ExtraSave] = &extraSaveBox;
    focusElements[GamelaunchermenuFocus::EnableDLC] = &dlcEnableBox;
    focusElements[GamelaunchermenuFocus::Quit] = &quitButton;
    focusElements[GamelaunchermenuFocus::UpdatePath] = &pathSelectBox;
    focusElements[GamelaunchermenuFocus::SaveMethod] = &saveModeSelectBox;
    focusElements[GamelaunchermenuFocus::LaunchMethod] = &launchModeSelectBox;
    focusElements[GamelaunchermenuFocus::OK] = &okButton;

    setHeader(GameList::instance()->at(gameIdx));
}
示例#26
0
//--------------------------------------------------------------------
// Función:    CParticles::Update
// Creador:    Nacho (AMD)
// Fecha:      Wednesday  14/02/2007  19:48:41
//--------------------------------------------------------------------
void CParticles::Update(float dt, CLevel* pTheLevel, CSound* pSoundPlayer)
{	
	CVideo * pVideo = CVideo::GetSingleton();

	m_fAngType3 += (240.0f * dt);
	m_fAngType3 = MAT_NormalizarAngulo360(m_fAngType3);

	CBall* pBall = pTheLevel->GetBall();
	CSmoke* pSmoke = pTheLevel->GetSmoke();

	VECTOR3 vecBallPos = pBall->GetPosition();
	VECTOR2 vecBallVel = pBall->GetVelocity();
	float fBallRadius = pBall->GetRadius();

	sceGuEnable(GU_BLEND);
	sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
	sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);

	ENEMY* pEnemies = pTheLevel->GetEnemies();
	int iNumEnemies = pTheLevel->GetNumEnemies();
	
	///--- TIPO 0: Disparo amarillo
	//////////////////////////////////////////////////////////////////////

	pVideo->EnableTexture(m_pTexture[0]);

	for (int i=0; i<MAX_PARTICLES; i++)
	{
		if (m_pParticleArray[0][i].enable)
		{			
			m_pParticleArray[0][i].timeStamp += dt;

			if (m_pParticleArray[0][i].timeStamp >= 5.0f)
			{
				m_pParticleArray[0][i].enable = false;
				m_pParticleArray[0][i].next = m_iFreeSlot[0];
				m_iFreeSlot[0] = i;

				continue;
			}

			m_pParticleArray[0][i].pos.x += m_pParticleArray[0][i].vel.x * dt;
			m_pParticleArray[0][i].pos.y += m_pParticleArray[0][i].vel.y * dt;


			stCollisionData data;

			data.radius = 1.0f;
			data.x = m_pParticleArray[0][i].pos.x;
			data.y = m_pParticleArray[0][i].pos.y;
			data.velX = m_pParticleArray[0][i].vel.x;
			data.velY = m_pParticleArray[0][i].vel.y;

			if (pTheLevel->TestCollision(&data, false))
			{		
				m_pParticleArray[0][i].pos.x = data.x;
				m_pParticleArray[0][i].pos.y = data.y;
				m_pParticleArray[0][i].vel.x = data.velX;
				m_pParticleArray[0][i].vel.y = data.velY;
			}

			for (int a=0; a<iNumEnemies; a++)
			{
				if (pEnemies[a].active)
				{					
					///--- sierra
					///--- rebota
					if ((pEnemies[a].type == 0) || (pEnemies[a].type == 3))
					{
						VECTOR3 vDis;
						VECTOR3 vTemp = {m_pParticleArray[0][i].pos.x, m_pParticleArray[0][i].pos.y, 4.0f};
						VECTOR3 vTemp2 = {pEnemies[a].posX + 4.0f, pEnemies[a].posY + 4.0f, 4.0f};

						MAT_VectorSubtract(&vDis, &vTemp2, &vTemp);

						float length = MAT_VectorQuadraticLength(&vDis);

						if (length < 6.25f)
						{
							m_pParticleArray[0][i].enable = false;
							m_pParticleArray[0][i].next = m_iFreeSlot[0];
							m_iFreeSlot[0] = i;

							pSmoke->AddExplosion(vTemp2, 20.0f, true);

							pEnemies[a].active = false;

							pSoundPlayer->Play(SOUND_ENE_EXPLO);

							break;
						}
					}
					///--- dirigidos
					///--- rectos
					else if ((pEnemies[a].type == 1) || (pEnemies[a].type == 2))
					{	
						VECTOR3 vTemp = {0};

						if (pEnemies[a].rot==0)
						{
							vTemp.x = pEnemies[a].posX+2.0f;
							vTemp.y = pEnemies[a].posY+4.0f;
						}						
						else if (pEnemies[a].rot==3)
						{
							vTemp.x = pEnemies[a].posX+4.0f;
							vTemp.y = pEnemies[a].posY+2.0f;
						}
						else if (pEnemies[a].rot==2)
						{
							vTemp.x = pEnemies[a].posX+6.0f;
							vTemp.y = pEnemies[a].posY+4.0f;
						}
						else if (pEnemies[a].rot==1)
						{
							vTemp.x = pEnemies[a].posX+4.0f;
							vTemp.y = pEnemies[a].posY+6.0f;						
						}	

						vTemp.z = 4.0f;

						VECTOR3 vDis;
						VECTOR3 vTemp2 = {m_pParticleArray[0][i].pos.x, m_pParticleArray[0][i].pos.y, 4.0f};
						
						MAT_VectorSubtract(&vDis, &vTemp, &vTemp2);

						float disx = vecBallPos.x - m_pParticleArray[0][i].pos.x,;

						float length = MAT_VectorQuadraticLength(&vDis);

						if (length < 6.0f)
						{
							m_pParticleArray[0][i].enable = false;
							m_pParticleArray[0][i].next = m_iFreeSlot[0];
							m_iFreeSlot[0] = i;

							pSmoke->AddExplosion(vTemp, 20.0f, true);

							pEnemies[a].active = false;

							pSoundPlayer->Play(SOUND_ENE_EXPLO);

							int pan = 127;

							if (disx < 0.0f)
							{
								if (disx < -32.0f)
								{
									pan = 255;
								}
								else
								{
									pan = MAT_Clamp(128 + (int)(((-disx) / 32.0f) * 127.0f), 128, 255);									
								}
							}
							else

							{
								if (disx > 32.0f)
								{
									pan = 0;
								}
								else
								{ 
									pan = MAT_Clamp((int)(127.0f - ((disx / 32.0f) * 127.0f)), 0, 127);
								}
							}

							pSoundPlayer->Play(SOUND_ENE_EXPLO, pan);

							break;
						}						
					}				
				}
			}

			if (!m_pParticleArray[0][i].enable)
				continue;

			///--- render

			sceGumMatrixMode(GU_MODEL);
			sceGumLoadIdentity();
			{
				VECTOR3 pos =  { m_pParticleArray[0][i].pos.x -1.0f,
					-(m_pParticleArray[0][i].pos.y + 1.0f), 4.0f };
				VECTOR3 scale = { 2.0f, 2.0f, 2.0f };
				sceGumTranslate(&pos);
				sceGumScale(&scale);			
			}			

			if (m_pParticleArray[0][i].timeStamp >= 4.0f)
			{
				int alpha = (int)MAT_Clampf((5.0f - m_pParticleArray[0][i].timeStamp) * 255.0f, 0.0f, 255.0f);

				sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);

				sceGuAmbientColor(COLOR_ARGB(alpha, 255, 255, 255));

				m_pQuad->Render();

				sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, COLOR_ARGB(alpha, alpha, alpha, alpha), 0xffffffff);

				m_pQuad->Render();

				sceGuAmbientColor(0xffffffff);
			}
			else
			{
				sceGuAmbientColor(0xffffffff);

				m_pQuad->Render();

				sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0xffffffff, 0xffffffff);

				m_pQuad->Render();
			}

			sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);			
		}
示例#27
0
/**
 * Show credits with list of contributors.
 *
 * Names of people are shown scrolling up like in movie-credits.\n
 * Uses map from wesnoth or campaign as background.
 */
void show_about(CVideo &video, const std::string &campaign)
{
	boost::scoped_ptr<cursor::setter> cur(new cursor::setter(cursor::WAIT));
	surface& screen = video.getSurface();
	if (screen == nullptr) return;

	// If the title is multi-line, we need to split it accordingly or we
	// get slight scrolling glitches in the credits screen.
	std::vector<std::string> text = about::get_text(campaign, true);

	SDL_Rect screen_rect = sdl::create_rect(0, 0, screen->w, screen->h);

	const surface_restorer restorer(&video, screen_rect);

	cur.reset();

	std::vector<std::string> image_list;
	if(campaign.size() && !images[campaign].empty()){
		image_list = utils::parenthetical_split(images[campaign], ',');
	} else{
		image_list = utils::parenthetical_split(images_default, ',');
	}

	surface map_image, map_image_scaled;

	if(!image_list.empty()) {
		map_image = image::get_image(image_list[0]);
	} else {
		image_list.push_back("");
	}

	if(!map_image){
        image_list[0]=game_config::images::game_title_background;
		map_image=image::get_image(image_list[0]);
	}

	gui::button close(video,_("Close"));
	close.set_location((screen->w/2)-(close.width()/2), screen->h - 30);

	const int def_size = font::SIZE_XLARGE;
	const SDL_Color def_color = font::NORMAL_COLOR;

	//substitute in the correct control characters for '+' and '-'
	std::string before_header(2, ' ');
	before_header[0] = font::LARGE_TEXT;
	for(unsigned i = 0; i < text.size(); ++i) {
		std::string &s = text[i];
		if (s.empty()) continue;
		char &first = s[0];
		if (first == '-')
			first = font::SMALL_TEXT;
		else if (first == '+') {
			first = font::LARGE_TEXT;
			text.insert(text.begin() + i, before_header);
			++i;
		}
	}
	text.insert(text.begin(), 10, before_header);

	int startline = 0;

	//TODO: use values proportional to screen ?
	// distance from top of map image to top of scrolling text
	const int top_margin = 60;
	// distance from bottom of scrolling text to bottom of map image
	const int bottom_margin = 40;
	// distance from left of scrolling text to the frame border
	const int text_left_padding = screen->w/32;

	int offset = 0;
	bool is_new_line = true;

	int first_line_height = 0;

	SDL_Rect frame_area;

	// we use a dialog to contains the text. Strange idea but at least the style
	// will be consistent with the titlescreen
	gui::dialog_frame f(video, "", gui::dialog_frame::titlescreen_style, false);

	// the text area's dimensions
	SDL_Rect text_rect = { 0, 0, 0, 0 };
	// we'll retain a copy to prevent SDL_blit to change its w and h
	SDL_Rect text_rect_blit;

	surface text_surf;

	CKey key;
	bool last_escape;

	int image_count = 0;
	int scroll_speed = 4;	// scroll_speed*50 = speed of scroll in pixel per second

	// Initially redraw all
	bool redraw_mapimage = true;
	bool update_dimensions = true;
	int max_text_width = 0;

	do {
		last_escape = key[SDLK_ESCAPE] != 0;

		// check to see if background image has changed
		if(text.size() && (image_count <
				((startline * static_cast<int>(image_list.size())) /
				static_cast<int>(text.size())))){

			image_count++;
			surface temp=image::get_image(image_list[image_count]);
			map_image=temp?temp:map_image;
			redraw_mapimage = true;
		}

		if (update_dimensions) {
			// rescale the background
			map_image_scaled = scale_surface(map_image, screen->w, screen->h);
			screen_rect = sdl::create_rect(0, 0, screen->w, screen->h);
			redraw_mapimage = true;

			// update the frame
			frame_area = sdl::create_rect(
						  screen->w * 3 / 32
						, top_margin
						, screen->w * 13 / 16
						, screen->h - top_margin - bottom_margin);

			text_rect = f.layout(frame_area).interior;

			// update the text area
			text_rect.x += text_left_padding;
			text_rect.w -= text_left_padding;
			text_rect_blit = text_rect;

			text_surf = create_compatible_surface(screen, text_rect.w, text_rect.h);
			SDL_SetAlpha(text_surf, SDL_RLEACCEL, SDL_ALPHA_OPAQUE);

			// relocate the close button
			close.set_location((screen->w/2)-(close.width()/2), screen->h - 30);

			update_dimensions = false;
		}

		if (redraw_mapimage) {
			// draw map to screen, thus erasing all text
			sdl_blit(map_image_scaled, nullptr, screen, nullptr);
			update_rect(screen_rect);

			// redraw the dialog
			f.draw_background();
			f.draw_border();
			// cache the dialog background (alpha blending + blurred map)
			sdl_blit(screen, &text_rect, text_surf, nullptr);
			redraw_mapimage = false;
		} else {
			// redraw the saved part of the dialog where text scrolled
			// thus erasing all text
			SDL_Rect modified = sdl::create_rect(0, 0, max_text_width, text_rect.h);
			sdl_blit(text_surf, &modified, screen, &text_rect_blit);
			update_rect(text_rect);
		}

		int y = text_rect.y - offset;
		int line = startline;
		max_text_width = 0;

		{
			// clip to keep text into the frame (thus the new code block)
			clip_rect_setter set_clip_rect(screen, &text_rect);

			const int line_spacing = 5;
			do {
				// draw the text (with ellipsis if needed)
				// update the max_text_width for future cleaning
				int w = font::draw_text(&video, text_rect, def_size, def_color,
										text[line], text_rect.x, y).w;
				max_text_width = std::max<int>(max_text_width, w);
				// since the real drawing on screen is clipped,
				// we do a dummy one to get the height of the not clipped line.
				// (each time because special format characters may change it)
				const int line_height = font::draw_text(nullptr, text_rect, def_size, def_color,
										text[line], 0,0).h;

				if(is_new_line) {
					is_new_line = false;
					first_line_height = line_height + line_spacing;
				}
				line++;
				if(size_t(line) > text.size()-1)
					line = 0;
				y += line_height + line_spacing;
			} while(y < text_rect.y + text_rect.h);
		}

		// performs the actual scrolling
		offset += scroll_speed;
		if (offset>=first_line_height) {
			offset -= first_line_height;
			is_new_line = true;
			startline++;
			if(size_t(startline) == text.size()){
				startline = 0;
				image_count = -1;
			}
		}

		// handle events
		if (key[SDLK_UP] && scroll_speed < 20) {
			++scroll_speed;
		}
		if (key[SDLK_DOWN] && scroll_speed > 0) {
			--scroll_speed;
		}
		if (screen->w != screen_rect.w || screen->h != screen_rect.h) {
			update_dimensions = true;
		}

		events::pump();
		events::raise_process_event();
		events::raise_draw_event();

		// flip screen and wait, so the text does not scroll too fast
		video.flip();
		CVideo::delay(20);

	} while(!close.pressed() && (last_escape || !key[SDLK_ESCAPE]));
}
示例#28
0
/**
 * Open the help browser, show terrain with id terrain_id.
 *
 * If show_topic is the empty string, the default topic will be shown.
 */
void show_terrain_help(CVideo& video, const std::string& show_topic, bool hidden, int xloc, int yloc)
{
	show_help(video, toplevel, hidden_symbol(hidden) + terrain_prefix + show_topic, xloc, yloc);
	video.flip();
}