Example #1
0
MenuWindow::MenuWindow()
	: m_pos(RATIO_2(Vec2f(20, 25)))
	, m_size(RATIO_2(Vec2f(321, 430)))
	, m_initalOffsetX(-m_size.x)
	, m_fadeDistance(m_size.x + m_pos.x)
	, fAngle(0.f)
	, m_currentPage(NULL)
	, m_background(TextureContainer::LoadUI("graph/interface/menus/menu_console_background"))
	, m_border(TextureContainer::LoadUI("graph/interface/menus/menu_console_background_border"))
{ }
Example #2
0
ButtonWidget::ButtonWidget(const Vec2f & pos, const Vec2f & size, const char * texturePath)
	: Widget()
{
	m_pos = pos;
	m_size = size;
	
	pRef = this; //TODO remove this
	m_id = BUTTON_INVALID; //TODO remove this
	
	m_texture = TextureContainer::Load(texturePath);
	arx_assert(m_texture);
	
	Vec2f scaledPos = RATIO_2(pos);
	Vec2f scaledSize = RATIO_2(m_size);
	m_rect = Rectf(scaledPos, scaledSize.x, scaledSize.y);
}
Example #3
0
	void init() {
		
		{
			std::string szMenuText = getLocalised("system_menus_options_video");
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(0, 0));
			me->clicked = boost::bind(&OptionsMenuPage::onClickedVideo, this);
			me->m_targetMenu = OPTIONS_VIDEO;
			addCenter(me, true);
		}
		
		{
			std::string szMenuText = getLocalised("system_menus_options_audio");
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(0, 0));
			me->m_targetMenu = OPTIONS_AUDIO;
			addCenter(me, true);
		}
		
		{
			std::string szMenuText = getLocalised("system_menus_options_input");
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(0, 0));
			me->m_targetMenu = OPTIONS_INPUT;
			addCenter(me, true);
		}
		
		{
			ButtonWidget * cb = new ButtonWidget(RATIO_2(Vec2i(20, 380)), "graph/interface/menus/back");
			cb->m_targetMenu = MAIN;
			cb->SetShortCut(Keyboard::Key_Escape);
			add(cb);
		}
	}
Example #4
0
	void init() {
		
		{
			std::string szMenuText = getLocalised("system_menus_main_editquest_load");
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(0, 0));
			me->clicked = boost::bind(&ChooseLoadOrSaveMenuPage::onClickLoad, this);
			me->m_targetMenu = EDIT_QUEST_LOAD;
			me->m_savegame = SavegameHandle::Invalid;
			addCenter(me, true);
		}
		
		{
			std::string szMenuText = getLocalised( "system_menus_main_editquest_save");
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(0, 0));
			me->m_targetMenu = EDIT_QUEST_SAVE;
			
			if(!ARXMenu_CanResumeGame()) {
				me->SetCheckOff();
				me->lColor = Color(127, 127, 127);
			}
			addCenter(me, true);
		}
		
		{
			ButtonWidget * cb = new ButtonWidget(RATIO_2(Vec2i(20, 380)), "graph/interface/menus/back");
			cb->m_targetMenu = MAIN;
			cb->SetShortCut(Keyboard::Key_Escape);
			add(cb);
		}
	}
Example #5
0
	void init() {
		
		{
			ButtonWidget * cb = new ButtonWidget(Vec2i(0, 0), "graph/interface/icons/menu_main_save");
			cb->SetCheckOff();
			addCenter(cb, true);
		}
		
		{
			std::string szMenuText = getLocalised("system_menu_editquest_newsavegame", "---");
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0));
			me->m_savegame = SavegameHandle::Invalid;
			me->eState=EDIT;
			me->ePlace=CENTER;
			addCenter(me, true);
		}
		
		HorizontalPanelWidget * pPanel = new HorizontalPanelWidget;
		
		// Delete button
		{
			std::string szMenuText = getLocalised("system_menus_main_editquest_delete");
			TextWidget * me = new TextWidget(BUTTON_MENUEDITQUEST_DELETE, hFontMenu, szMenuText, Vec2i(0, 0));
			me->m_targetMenu = EDIT_QUEST_SAVE;
			me->SetPos(Vec2i(RATIO_X(m_size.x-10)-me->m_rect.width(), RATIO_Y(5)));
			me->lOldColor = me->lColor;
			pPanel->AddElementNoCenterIn(me);
			pDeleteButton = me;
		}
		
		// Save button
		{
			std::string szMenuText = getLocalised("system_menus_main_editquest_save");
			TextWidget * me = new TextWidget(BUTTON_MENUEDITQUEST_SAVE, hFontMenu, szMenuText, Vec2i(0, 0));
			me->m_targetMenu = MAIN;
			me->SetPos(Vec2i(RATIO_X(m_size.x-10)-me->m_rect.width(), RATIO_Y(380)));
			pPanel->AddElementNoCenterIn(me);
		}
		
		// Back button
		{
			ButtonWidget * cb = new ButtonWidget(RATIO_2(Vec2i(20, 380)), "graph/interface/menus/back");
			cb->m_targetMenu = EDIT_QUEST_SAVE;
			cb->SetShortCut(Keyboard::Key_Escape);
			pPanel->AddElementNoCenterIn(cb);
		}
		
		add(pPanel);
	}
Example #6
0
TextWidget::TextWidget(MenuButton id, Font* font, const std::string& text, Vec2f pos)
	: Widget()
{
	m_id = id;

	m_font = font;
	
	Vec2f scaledPos = RATIO_2(pos);
	
	m_rect.left = scaledPos.x;
	m_rect.top = scaledPos.y;
	
	SetText(text);
	
	lColor = Color(232, 204, 142);
	lColorHighlight=lOldColor=Color(255, 255, 255);

	pRef=this;

	bSelected = false;
}
Example #7
0
void ButtonWidget::SetPos(Vec2f pos) {
	
	Vec2f scaledSize = RATIO_2(m_size);
	m_rect = Rectf(pos, scaledSize.x, scaledSize.y);
}
Example #8
0
void MenuWindow::add(MenuPage * page) {
	page->setSize(RATIO_2(Vec2f(292, 395)));
	m_pages.push_back(page);
}
Example #9
0
	void init() {
		
		// Renderer selection
		{
			HorizontalPanelWidget * pc = new HorizontalPanelWidget;
			std::string szMenuText = getLocalised("system_menus_options_video_renderer", "Renderer");
			szMenuText += "  ";
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0));
			me->SetCheckOff();
			pc->AddElement(me);
			CycleTextWidget * slider = new CycleTextWidget;
			slider->valueChanged = boost::bind(&VideoOptionsMenuPage::onChangedRenderer, this, _1, _2);
			
			{
				TextWidget * text = new TextWidget(BUTTON_INVALID, hFontMenu, "Auto-Select", Vec2i(0, 0));
				slider->AddText(text);
				slider->selectLast();
			}
			
	#if ARX_HAVE_SDL1 || ARX_HAVE_SDL2
			{
				TextWidget * text = new TextWidget(BUTTON_INVALID, hFontMenu, "OpenGL", Vec2i(0, 0));
				slider->AddText(text);
				if(config.window.framework == "SDL") {
					slider->selectLast();
				}
			}
	#endif
			
			float fRatio    = (RATIO_X(m_size.x-9) - slider->m_rect.width());
			slider->Move(Vec2i(checked_range_cast<int>(fRatio), 0));
			pc->AddElement(slider);
			addCenter(pc);
		}
		
		{
			std::string szMenuText = getLocalised("system_menus_options_videos_full_screen");
			if(szMenuText.empty()) {
				// TODO once we ship our own amendmends to the loc files a cleaner
				// fix would be to just define system_menus_options_videos_full_screen
				// for the german version there
				szMenuText = getLocalised("system_menus_options_video_full_screen");
			}
			szMenuText += "  ";
			TextWidget * text = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0.f));
			text->SetCheckOff();
			CheckboxWidget * cb = new CheckboxWidget(text);
			cb->stateChanged = boost::bind(&VideoOptionsMenuPage::onChangedFullscreen, this, _1);
			cb->iState = config.video.fullscreen ? 1 : 0;
			addCenter(cb);
			fullscreenCheckbox = cb;
		}
		
		{
			HorizontalPanelWidget * pc = new HorizontalPanelWidget;
			std::string szMenuText = getLocalised("system_menus_options_video_resolution");
			szMenuText += "  ";
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0.f));
			me->SetCheckOff();
			pc->AddElement(me);
			pMenuSliderResol = new CycleTextWidget;
			pMenuSliderResol->valueChanged = boost::bind(&VideoOptionsMenuPage::onChangedResolution, this, _1, _2);
			
			pMenuSliderResol->setEnabled(config.video.fullscreen);
			
			const RenderWindow::DisplayModes & modes = mainApp->getWindow()->getDisplayModes();
			for(size_t i = 0; i != modes.size(); ++i) {
				
				const DisplayMode & mode = modes[i];
				
				// find the aspect ratio
				unsigned a = mode.resolution.x;
				unsigned b = mode.resolution.y;
				while(b != 0) {
					unsigned t = a % b;
					a = b, b = t;
				}
				Vec2i aspect = mode.resolution / Vec2i(a);
				
				std::stringstream ss;
				ss << mode;
				
				if(aspect.x < 100 && aspect.y < 100) {
					if(aspect == Vec2i(8, 5)) {
						aspect = Vec2i(16, 10);
					}
					ss << " (" << aspect.x << ':' << aspect.y << ')';
				}
				
				pMenuSliderResol->AddText(new TextWidget(BUTTON_INVALID, hFontMenu, ss.str()));
				
				if(mode.resolution == config.video.resolution) {
					pMenuSliderResol->selectLast();
				}
			}
			
			pMenuSliderResol->AddText(new TextWidget(BUTTON_INVALID, hFontMenu, AUTO_RESOLUTION_STRING));
			
			if(config.video.resolution == Vec2i_ZERO) {
				pMenuSliderResol->selectLast();
			}
		
			float fRatio    = (RATIO_X(m_size.x-9) - pMenuSliderResol->m_rect.width()); 
		
			pMenuSliderResol->Move(Vec2i(checked_range_cast<int>(fRatio), 0));
			
			pc->AddElement(pMenuSliderResol);
			addCenter(pc);
		}
		
		{
			HorizontalPanelWidget * pc = new HorizontalPanelWidget;
			std::string szMenuText = getLocalised("system_menus_options_detail");
			szMenuText += " ";
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0));
			me->SetCheckOff();
			pc->AddElement(me);
			
			CycleTextWidget * cb = new CycleTextWidget;
			cb->valueChanged = boost::bind(&VideoOptionsMenuPage::onChangedQuality, this, _1, _2);
			szMenuText = getLocalised("system_menus_options_video_texture_low");
			cb->AddText(new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText));
			szMenuText = getLocalised("system_menus_options_video_texture_med");
			cb->AddText(new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText));
			szMenuText = getLocalised("system_menus_options_video_texture_high");
			cb->AddText(new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText));
			cb->setValue(config.video.levelOfDetail);
			
			cb->Move(Vec2i(RATIO_X(m_size.x-9) - cb->m_rect.width(), 0));
			pc->AddElement(cb);
			
			addCenter(pc);
		}
		
		{
			HorizontalPanelWidget * pc = new HorizontalPanelWidget;
			std::string szMenuText = getLocalised("system_menus_options_video_brouillard");
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0.f));
			me->SetCheckOff();
			pc->AddElement(me);
			SliderWidget * sld = new SliderWidget(Vec2i(RATIO_X(200), 0));
			sld->valueChanged = boost::bind(&VideoOptionsMenuPage::onChangedFogDistance, this, _1);
			sld->setValue(config.video.fogDistance);
			pc->AddElement(sld);
			addCenter(pc);
		}
		
		{
			std::string szMenuText = getLocalised("system_menus_options_video_crosshair", "Show Crosshair");
			szMenuText += " ";
			TextWidget * text = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0.f));
			text->SetCheckOff();
			CheckboxWidget * cb = new CheckboxWidget(text);
			cb->stateChanged = boost::bind(&VideoOptionsMenuPage::onChangedCrosshair, this, _1);
			cb->iState = config.video.showCrosshair ? 1 : 0;
			addCenter(cb);
		}
		
		{
			std::string szMenuText = getLocalised("system_menus_options_video_antialiasing", "antialiasing");
			szMenuText += " ";
			TextWidget * text = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0));
			text->SetCheckOff();
			CheckboxWidget * cb = new CheckboxWidget(text);
			cb->stateChanged = boost::bind(&VideoOptionsMenuPage::onChangedAntialiasing, this, _1);
			cb->iState = config.video.antialiasing ? 1 : 0;
			addCenter(cb);
		}
		
		ARX_SetAntiAliasing();
		
		{
			std::string szMenuText = getLocalised("system_menus_options_video_vsync", "VSync");
			szMenuText += " ";
			TextWidget * text = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0));
			text->SetCheckOff();
			CheckboxWidget * cb = new CheckboxWidget(text);
			cb->stateChanged = boost::bind(&VideoOptionsMenuPage::onChangedVsync, this, _1);
			cb->iState = config.video.vsync ? 1 : 0;
			addCenter(cb);
		}
		
		{
			std::string szMenuText = getLocalised("system_menus_options_video_hud_scale", "Scale Hud");
			szMenuText += " ";
			TextWidget * text = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0));
			text->SetCheckOff();
			CheckboxWidget * cb = new CheckboxWidget(text);
			cb->stateChanged = boost::bind(&VideoOptionsMenuPage::onChangedHudScale, this, _1);
			cb->iState = config.video.hudScale ? 1 : 0;
			addCenter(cb);
		}
		
		{
			HorizontalPanelWidget * pc = new HorizontalPanelWidget;
			std::string szMenuText = getLocalised("system_menus_video_apply");
			szMenuText += "   ";
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(240), 0));
			me->clicked = boost::bind(&VideoOptionsMenuPage::onClickedApply, this);
			me->SetPos(Vec2i(RATIO_X(m_size.x-10)-me->m_rect.width(), RATIO_Y(380) + RATIO_Y(40)));
			me->SetCheckOff();
			pc->AddElementNoCenterIn(me);
			pMenuElementApply = me;
			
			ButtonWidget * cb = new ButtonWidget(RATIO_2(Vec2i(20, 420)), "graph/interface/menus/back");
			cb->clicked = boost::bind(&VideoOptionsMenuPage::onClickedBack, this);
			cb->m_targetMenu = OPTIONS;
			cb->SetShortCut(Keyboard::Key_Escape);
			pc->AddElementNoCenterIn(cb);
			
			add(pc);
		}
	}
Example #10
0
	void init() {
		
		{
			ButtonWidget * cb = new ButtonWidget(Vec2i(RATIO_X(10), 0), "graph/interface/icons/menu_main_save");
			cb->SetCheckOff();
			addCenter(cb, true);
		}
		
		std::string quicksaveName = getLocalised("system_menus_main_quickloadsave", "Quicksave");
		size_t quicksaveNum = 0;
		
		// Show quicksaves.
		for(size_t i = 0; i < savegames.size(); i++) {
			const SaveGame & save = savegames[i];
			
			if(!save.quicksave) {
				continue;
			}
			
			std::ostringstream text;
			text << quicksaveName << ' ' << ++quicksaveNum << "   " << save.time;
			
			TextWidget * e = new TextWidget(BUTTON_MENUEDITQUEST_SAVEINFO, hFontControls, text.str(), Vec2i(RATIO_X(20), 0.f));
			e->m_targetMenu = EDIT_QUEST_SAVE_CONFIRM;
			e->setColor(Color::grayb(127));
			e->SetCheckOff();
			e->m_savegame = SavegameHandle(i);
			addCenter(e);
		}
		
		// Show regular saves.
		for(size_t i = 0; i < savegames.size(); i++) {
			const SaveGame & save = savegames[i];
			
			if(save.quicksave) {
				continue;
			}
			
			std::string text = save.name +  "   " + save.time;
			
			TextWidget * e = new TextWidget(BUTTON_MENUEDITQUEST_SAVEINFO, hFontControls, text, Vec2i(RATIO_X(20), 0.f));
			e->m_targetMenu = EDIT_QUEST_SAVE_CONFIRM;
			e->m_savegame = SavegameHandle(i);
			addCenter(e);
		}
		
		for(size_t i = savegames.size(); i <= 15; i++) {
			
			std::ostringstream text;
			text << '-' << std::setfill('0') << std::setw(4) << i << '-';
			
			TextWidget * e = new TextWidget(BUTTON_MENUEDITQUEST_SAVEINFO, hFontControls, text.str(), Vec2i(RATIO_X(20), 0));
			e->m_targetMenu = EDIT_QUEST_SAVE_CONFIRM;
			e->m_savegame = SavegameHandle::Invalid;
			addCenter(e);
		}
	
		{
			TextWidget * me01 = new TextWidget(BUTTON_INVALID, hFontControls, " ", Vec2i(RATIO_X(20), 0));
			me01->m_targetMenu = EDIT_QUEST_SAVE_CONFIRM;
			me01->m_savegame = SavegameHandle::Invalid;
			me01->SetCheckOff();
			addCenter(me01);
		}
		
		{
			ButtonWidget * cb = new ButtonWidget(RATIO_2(Vec2i(20, 420)), "graph/interface/menus/back");
			cb->m_targetMenu = EDIT_QUEST;
			cb->SetShortCut(Keyboard::Key_Escape);
			add(cb);
		}
	}
Example #11
0
	void init() {
		
		{
			ButtonWidget * cb = new ButtonWidget(Vec2i(0, 0), "graph/interface/icons/menu_main_load");
			cb->SetCheckOff();
			addCenter(cb, true);
		}
		
		std::string quicksaveName = getLocalised("system_menus_main_quickloadsave", "Quicksave");
		
		// TODO make this list scrollable
		// TODO align the date part to the right!
		
		{
		size_t quicksaveNum = 0;
		
		// Show quicksaves.
		for(size_t i = 0; i < savegames.size(); i++) {
			const SaveGame & save = savegames[i];
			
			if(!save.quicksave) {
				continue;
			}
			
			std::ostringstream text;
			text << quicksaveName << ' ' << ++quicksaveNum << "   " << save.time;
			
			TextWidget * e = new TextWidget(BUTTON_MENUEDITQUEST_LOAD, hFontControls, text.str(), Vec2i(RATIO_X(20), 0));
			e->m_savegame = SavegameHandle(i);
			addCenter(e);
		}
		
		// Show regular saves.
		for(size_t i = 0; i < savegames.size(); i++) {
			const SaveGame & save = savegames[i];
			
			if(save.quicksave) {
				continue;
			}
			
			std::string text = save.name +  "   " + save.time;
			
			TextWidget * e = new TextWidget(BUTTON_MENUEDITQUEST_LOAD, hFontControls, text, Vec2i(RATIO_X(20), 0));
			e->m_savegame = SavegameHandle(i);
			addCenter(e);
		}
		
		{
			TextWidget * confirm = new TextWidget(BUTTON_INVALID, hFontControls, " ", Vec2i(RATIO_X(20), 0));
			confirm->m_targetMenu = EDIT_QUEST_SAVE_CONFIRM;
			confirm->SetCheckOff();
			confirm->m_savegame = SavegameHandle::Invalid;
			addCenter(confirm);
		}
		
		// Delete button
		{
			std::string szMenuText = getLocalised("system_menus_main_editquest_delete");
			szMenuText += "   ";
			TextWidget * me = new TextWidget(BUTTON_MENUEDITQUEST_DELETE_CONFIRM, hFontMenu, szMenuText, Vec2i(0, 0));
			me->m_targetMenu = EDIT_QUEST_LOAD;
			me->SetPos(Vec2i(RATIO_X(m_size.x-10)-me->m_rect.width(), RATIO_Y(42)));
			me->SetCheckOff();
			me->lOldColor = me->lColor;
			me->lColor = Color::grayb(127);
			add(me);
			pDeleteConfirm = me;
		}
		
		// Load button
		{
			std::string szMenuText = getLocalised("system_menus_main_editquest_load");
			szMenuText += "   ";
			TextWidget * me = new TextWidget(BUTTON_MENUEDITQUEST_LOAD_CONFIRM, hFontMenu, szMenuText, Vec2i(0, 0));
			me->m_targetMenu = MAIN;
			me->SetPos(Vec2i(RATIO_X(m_size.x-10)-me->m_rect.width(), RATIO_Y(380) + RATIO_Y(40)));
			me->SetCheckOff();
			me->lOldColor = me->lColor;
			me->lColor = Color::grayb(127);
			add(me);
			pLoadConfirm = me;
		}
		
		// Back button
		{
			ButtonWidget * cb = new ButtonWidget(RATIO_2(Vec2i(20, 420)), "graph/interface/menus/back");
			cb->clicked = boost::bind(&LoadMenuPage::onClickBack, this);
			cb->m_targetMenu = EDIT_QUEST;
			cb->SetShortCut(Keyboard::Key_Escape);
			add(cb);
		}
		}
	}