コード例 #1
0
ファイル: MenuCollection.cpp プロジェクト: DeejStar/Jack-Claw
	void closeMenu()
	{
		openedMenus.pop();
		int menu = openedMenus.empty()?0:openedMenus.top();
		
		activeMenu->applyChanges();

		delete activeMenu;
		activeMenu = NULL;

		if( hidePreviouslyOpenedMenus )
		{
			if ( !openedMenus.empty() )
			{
				activeMenu = menuFactory( menu );
				activeMenu->show();
				assert( foreground );
				foreground->Raise();
			}
		}
		else
		{
			activeMenu = openedMenusData.empty()?NULL:openedMenusData.top();
			if (!openedMenusData.empty())
				openedMenusData.pop();

			if( activeMenu ) 
				activeMenu->show();
			assert( foreground );
			foreground->Raise();
		}
	}
コード例 #2
0
ファイル: MenuCollection.cpp プロジェクト: DeejStar/Jack-Claw
	void openMenu( int menu )
	{
		ogui->SetCursorImageState( 0, DH_CURSOR_ARROW );

		if( activeMenu && hidePreviouslyOpenedMenus ) 
		{
			activeMenu->hide();
			delete activeMenu;
		}
		
		if( activeMenu && hidePreviouslyOpenedMenus == false )
		{
			openedMenusData.push( activeMenu );
		}

		if( activeMenu && raiseLowerMenu )
		{
			IMenuBase* temp = activeMenu;
			activeMenu = menuFactory( menu );
			temp->raise();
		}
		else
		{
			activeMenu = menuFactory( menu );
		}
		
		assert( foreground );
		foreground->Raise();
		
		openedMenus.push( menu );
		activeMenu->show();
	}
コード例 #3
0
	void showWindowAt(int x, int y)
	{
		window->MoveTo(x - 5, y - 5);
		window->Show();
		isVisible = true;
		closedAck = false;

		if (game::SimpleOptions::getBool(DH_OPT_B_MENU_AUTOPAUSE))
		{
			// Pause game
			if(!game.isTacticalMode())
			{
				gameWasRunning = true;
				game.gameUI->setPointersChangedFlag(game.singlePlayerNumber);
			}
			else
				gameWasRunning = false;

			game.setTacticalMode(true);
		}

		// TODO: client number
		game::SceneSelection *sel = game.gameUI->getSceneSelection(0);

		clickPosition = VC3(sel->scaledMapX, 
			game.gameMap->getScaledHeightAt(sel->scaledMapX, sel->scaledMapY), 
			sel->scaledMapY);

		if (game::SimpleOptions::getBool(DH_OPT_B_MENU_TWO_CLICK))
		{
			// TODO: correct player...
			if (sel->unit != NULL
				&& sel->unit->visibility.isSeenByPlayer(game.singlePlayerNumber))
			{
				game.gameUI->setUnitHighlight(game.singlePlayerNumber, sel->unit);
			} else {
				game.gameUI->setTerrainHighlight(game.singlePlayerNumber, clickPosition);
			}
			game.gameUI->lockHighlight(game.singlePlayerNumber);
		}
	}
コード例 #4
0
ファイル: MenuCollection.cpp プロジェクト: DeejStar/Jack-Claw
	void changeMenu( int menu )
	{	
		openedMenus.pop();
		delete activeMenu;
		activeMenu = NULL;

		IMenuBase *lower_menu = openedMenusData.empty()?NULL:openedMenusData.top();

		activeMenu = menuFactory( menu );
		
		if(raiseLowerMenu && lower_menu) lower_menu->raise();
		
		assert( foreground );
		foreground->Raise();

		openedMenus.push( menu );
		activeMenu->show();
	}
コード例 #5
0
ファイル: MenuCollection.cpp プロジェクト: DeejStar/Jack-Claw
	bool isVisible() const
	{
		return true;
		if ( activeMenu )	return activeMenu->isVisible();
		else				return background->IsVisible();	
	}
コード例 #6
0
ファイル: MenuCollection.cpp プロジェクト: DeejStar/Jack-Claw
	void show()
	{
		background->Show();
		if( activeMenu ) activeMenu->show();
		foreground->Show();
	}
コード例 #7
0
ファイル: MenuCollection.cpp プロジェクト: DeejStar/Jack-Claw
	void hide()
	{
		background->Hide();
		if( activeMenu ) activeMenu->hide();
		foreground->Hide();
	}
コード例 #8
0
ファイル: MenuCollection.cpp プロジェクト: DeejStar/Jack-Claw
	MenuCollectionImpl( MenuCollection* self, Ogui* ogui, Game* game, int player ) :
	  self( self ),
	  ogui( ogui ),
	  game( game ),
	  activeMenu( NULL ),
	  backgroundVideo( NULL ),
	  backgroundButton( NULL ),
	  backgroundButtonData( NULL ),
	  logoButton( NULL ),
	  logoVideo( NULL ),
	  videoButton( NULL ),
	  background( NULL ),
	  foreground( NULL ),
	  transparency( 100 ),
	  fadeIn( true ),
		backgroundAlternativeFader( NULL ),
		backgroundAlternativeButton( NULL )
	{
		background = ogui->CreateSimpleWindow(	getLocaleGuiInt( "gui_menu_background_x", 0 ), 
												getLocaleGuiInt( "gui_menu_background_y", 0 ), 
												getLocaleGuiInt( "gui_menu_background_w", 1 ), 
												getLocaleGuiInt( "gui_menu_background_h", 1 ), 
												getLocaleGuiString( "gui_menu_background_img" ) );

		const char *alternatives_str = NULL;
		if(DHLocaleManager::getInstance()->getString(DHLocaleManager::BANK_GUI, "gui_menu_background_alternatives", &alternatives_str))
		{
			int alternatives = atoi(alternatives_str);
			if(alternatives > 0)
			{
				backgroundAlternativeButton = ogui->CreateSimpleImageButton(background,
					getLocaleGuiInt("gui_menu_background_alternatives_x", 0), getLocaleGuiInt("gui_menu_background_alternatives_y", 0),
					getLocaleGuiInt("gui_menu_background_alternatives_w", 0), getLocaleGuiInt("gui_menu_background_alternatives_h", 0),
					NULL, NULL, NULL, NULL, 0, NULL, false);
				backgroundAlternativeButton->SetDisabled(true);

				backgroundAlternativeFader = ogui->CreateSimpleImageButton(background,
					getLocaleGuiInt("gui_menu_background_alternatives_x", 0), getLocaleGuiInt("gui_menu_background_alternatives_y", 0),
					getLocaleGuiInt("gui_menu_background_alternatives_w", 0), getLocaleGuiInt("gui_menu_background_alternatives_h", 0),
					NULL, NULL, NULL, NULL, 0, NULL, false);
				backgroundAlternativeFader->SetDisabled(true);

				backgroundAlternatives.resize(alternatives);
				for(int i = 0; i < alternatives; i++)
				{
					std::string prefix = "gui_menu_background_alt" + boost::lexical_cast<std::string>(i);
					backgroundAlternatives[i].img = ogui->LoadOguiImage( getLocaleGuiString( (prefix+"_img").c_str() ) );
					backgroundAlternatives[i].time = getLocaleGuiInt( (prefix+"_time").c_str() , 0 );
					backgroundAlternatives[i].fade = getLocaleGuiInt( (prefix+"_fade").c_str() , 0 );
				}

				backgroundAlternativeButton->SetDisabledImage(backgroundAlternatives[0].img);
				currentBackgroundAlternative = 0;
				previousBackgroundAlternative = 0;
				lastBackgroundAlternativeSwitch = Timer::getTime();
			}
		}
	
		foreground = ogui->CreateSimpleWindow(	getLocaleGuiInt( "gui_menu_foreground_x", 0 ), 
												getLocaleGuiInt( "gui_menu_foreground_y", 0 ), 
												getLocaleGuiInt( "gui_menu_foreground_w", 1 ), 
												getLocaleGuiInt( "gui_menu_foreground_h", 1 ), 
												getLocaleGuiString( "gui_menu_foreground_img" ) );
		foreground->SetReactMask( 0 );
		
		


		videoButton = ogui->CreateSimpleImageButton( background, 
							getLocaleGuiInt( "gui_menu_video_x", 0 ), getLocaleGuiInt( "gui_menu_video_y", 0 ),
							getLocaleGuiInt( "gui_menu_video_w", 1024 ), getLocaleGuiInt( "gui_menu_video_h", 768 ), NULL, NULL, NULL );
		videoButton->SetDisabled( true );

		backgroundButton = ogui->CreateSimpleImageButton( background, 0, 0, 1024, 768, NULL, NULL, NULL );
		backgroundButton->SetDisabled( true );

		background->Hide();
		foreground->Hide();
		background->SetUnmovable();
		foreground->SetUnmovable();

		ogui->SetCursorImageState( 0, DH_CURSOR_ARROW );

		fonts.big.normal =			ogui->LoadFont( getLocaleGuiString( "gui_menu_font_big" ) );
		fonts.medium.normal =		ogui->LoadFont( getLocaleGuiString( "gui_menu_font_medium" ) );
		fonts.medium.highlighted =	ogui->LoadFont( getLocaleGuiString( "gui_menu_font_medium_high" ) );
		fonts.little.normal =		ogui->LoadFont( getLocaleGuiString( "gui_menu_font_little" ) );
		fonts.little.highlighted =	ogui->LoadFont( getLocaleGuiString( "gui_menu_font_little_high" ) );

		

		background->StartEffect( OGUI_WINDOW_EFFECT_FADEIN, 3000 );
		foreground->StartEffect( OGUI_WINDOW_EFFECT_FADEIN, 3000 );

		if( game->inCombat == false )
			transparencyFadeSpeed = 50.0f;
		else transparencyFadeSpeed = 20.0f;
		
		const int menu_to_be_opened = MenuCollection::MENU_TYPE_MAINMENU;
		openMenu( menu_to_be_opened );
	}
コード例 #9
0
	void LoadingMessage::renderLoadingMessage()
	{
		assert(storm3d != NULL);
#ifdef LEGACY_FILES
		OguiWindow *win = ogui->CreateSimpleWindow(0,0,1024,768,"Data/GUI/Windows/loadingmsg.tga");
#else
		OguiWindow *win = ogui->CreateSimpleWindow(0,0,1024,768,"data/gui/common/window/loadingmsg.tga");
#endif

#ifdef PROJECT_SURVIVOR
		if(loading_message.empty())
			win->setBackgroundImage(NULL);
#endif
		OguiTextLabel *txt_msg = ogui->CreateTextLabel(win, 0, 768/2, 1024, 32, "");

		txt_msg->SetTextHAlign(OguiButton::TEXT_H_ALIGN_CENTER);
		txt_msg->SetTextVAlign(OguiButton::TEXT_V_ALIGN_MIDDLE);
		if (ui::defaultBigIngameFont == NULL)
			txt_msg->SetFont(ui::defaultFont);
		else
			txt_msg->SetFont(ui::defaultBigIngameFont);
		txt_msg->SetText(loading_message.c_str());

		OguiButton *bar_bg = NULL;
		OguiTextLabel *bar_num = NULL;
		OguiTextLabel *bar_txt = NULL;
		OguiButton *bar = NULL;

		if(loading_bar_value != -1)
		{

			int x = game::getLocaleGuiInt("gui_loadingbar_x",0);
			int y = game::getLocaleGuiInt("gui_loadingbar_y",0);
			int w = game::getLocaleGuiInt("gui_loadingbar_w",0);
			int h = game::getLocaleGuiInt("gui_loadingbar_h",0);
			bar_bg = ogui->CreateSimpleImageButton(win, x, y, w, h, game::getLocaleGuiString("gui_loadingbar_background"), NULL, NULL, 0);
			
			bar = ogui->CreateSimpleImageButton(win, x, y, loading_bar_value * w / 100, h, game::getLocaleGuiString("gui_loadingbar_foreground"), NULL, NULL, 0);

			bar_num = ogui->CreateTextLabel(win, x, y, w, h, "");
			std::string text = int2str(loading_bar_value) + std::string("%");
			bar_num->SetFont(ui::defaultIngameFont);
			bar_num->SetTextHAlign(OguiButton::TEXT_H_ALIGN_CENTER);
			bar_num->SetTextVAlign(OguiButton::TEXT_V_ALIGN_MIDDLE);
			bar_num->SetText(text.c_str());

			bar_txt = ogui->CreateTextLabel(win, x, y, w, h, "");
			bar_txt->SetFont(ui::defaultIngameFont);
			bar_txt->SetTextHAlign(OguiButton::TEXT_H_ALIGN_LEFT);
			bar_txt->SetTextVAlign(OguiButton::TEXT_V_ALIGN_MIDDLE);
			bar_txt->SetText(loading_bar_text.c_str());			
		}

		win->Raise();

		// HACK!
		std::vector<bool> oldValues;
		if(scene->ITTerrain)
		{
			IteratorIM_Set<IStorm3D_Terrain*> it = *(IteratorIM_Set<IStorm3D_Terrain*>*)scene->ITTerrain->Begin();
			while(!it.IsEnd())
			{
				IStorm3D_Terrain *terrain = it.GetCurrent();
				oldValues.push_back(terrain->getRenderer().enableFeature(IStorm3D_TerrainRenderer::RenderTargets, false ));
				it.Next();
			}
		}
		
		ogui->Run(1);
		scene->RenderScene();

		if(scene->ITTerrain)
		{
			unsigned int i = 0;
			IteratorIM_Set<IStorm3D_Terrain*> it = *(IteratorIM_Set<IStorm3D_Terrain*>*)scene->ITTerrain->Begin();
			while(!it.IsEnd() && i < oldValues.size())
			{
				IStorm3D_Terrain *terrain = it.GetCurrent();
				terrain->getRenderer().enableFeature(IStorm3D_TerrainRenderer::RenderTargets, oldValues[i] );
				it.Next();
				i++;
			}
		}


		delete bar;
		delete bar_txt;
		delete bar_num;
		delete bar_bg;
		delete txt_msg;
		delete win;
	}
コード例 #10
0
	void initVideos()
	{
		
		bool video_enabled = GameOptionManager::getInstance()->getOptionByName( "menu_video_enabled" )? GameOptionManager::getInstance()->getOptionByName( "menu_video_enabled" )->getBooleanValue() : true;

		if( video_enabled && game->inCombat && videoDisabledDuringGame )
			video_enabled = false;

		sfx::SoundMixer *mixer = game->gameUI->getSoundMixer();
		IStorm3D_StreamBuilder *builder = 0;
		if(mixer)
			builder = mixer->getStreamBuilder();

		if( video_enabled )
			backgroundVideo = ogui->LoadOguiVideo( getLocaleGuiString( "gui_menu_video_video" ), builder );
		
		if( backgroundVideo == NULL )
		{
			// background->setBackgroundImage( );
			backgroundVideo = ogui->LoadOguiImage( getLocaleGuiString( "gui_menu_video_image" ) );
		}

#ifdef PROJECT_SHADOWGROUNDS
		float normal_aspect = (background->GetSizeX() * ogui->GetScaleX()) / (float)(background->GetSizeY() * ogui->GetScaleY());

		float video_aspect = (float)atof( getLocaleGuiString("gui_menu_video_video_aspect") );

		float texcoord_multiplier = (video_aspect / normal_aspect);
		float texcoord_offset = (1.0f - texcoord_multiplier) * 0.5f;

		float xm = 0.0f, ym = 0.0f;
		OguiStormImage* bv = (OguiStormImage*)backgroundVideo;
		if (bv->video != NULL)
		{
			bv->video->getTextureCoords(xm, ym);
			if(texcoord_multiplier > 1.0f)
			{
				videoButton->SetRepeat(xm, texcoord_multiplier * ym);
				videoButton->SetScroll(0.0f, texcoord_offset);
			}
		}
#endif

		videoButton->SetDisabledImage( backgroundVideo );

		{
			bool playLogoVideo = GameOptionManager::getInstance()->getOptionByName( "menu_logo_video_enabled" )? GameOptionManager::getInstance()->getOptionByName( "menu_logo_video_enabled" )->getBooleanValue() : true;
			OguiButton* button;
			button = ogui->CreateSimpleImageButton( foreground, 
													getLocaleGuiInt( "gui_menu_logo_x", 0 ), 
													getLocaleGuiInt( "gui_menu_logo_y", 0 ),
													getLocaleGuiInt( "gui_menu_logo_w", 1 ),
													getLocaleGuiInt( "gui_menu_logo_h", 1 ), 
													NULL, NULL, NULL, 0 );

			if( ( video_enabled || playLogoVideoAlways ) && playLogoVideo )
				logoVideo = ogui->LoadOguiVideo( getLocaleGuiString( "gui_menu_logo_video" ), builder );
			
			if( logoVideo == NULL ) 
				logoVideo = ogui->LoadOguiImage( getLocaleGuiString( "gui_menu_logo_img" ) );

#ifdef PROJECT_SHADOWGROUNDS
			normal_aspect = (button->GetSizeX() * ogui->GetScaleX()) / (float)(button->GetSizeY() * ogui->GetScaleY());
			video_aspect = (float)atof( getLocaleGuiString("gui_menu_logo_video_aspect") );

			texcoord_multiplier = (video_aspect / normal_aspect);
			texcoord_offset = (1.0f - texcoord_multiplier) * 0.5f;

			OguiStormImage* lv = (OguiStormImage*)logoVideo;
			if (lv->video != NULL)
			{
				lv->video->getTextureCoords(xm, ym);
				if(texcoord_multiplier > 1.0f)
				{
					button->SetRepeat(xm, texcoord_multiplier * ym);
					button->SetScroll(0.0f, texcoord_offset);
				}
			}
#endif

			button->SetDisabled( true );
			button->SetDisabledImage( logoVideo );

			logoButton = button;
		}
	}