Ejemplo n.º 1
0
		void CharacterSelectScreen::reloadIcons(const SmashData&smashData)
		{
			autoIconLayoutMgr.clear();
			
			for(unsigned int i=0; i<icons.size(); i++)
			{
				delete icons.get(i);
			}
			icons.clear();
			
			ArrayList<CharacterInfo>& characters = smashData.getModuleData()->getCharacterLoader()->getCharacters();
			unsigned int total = characters.size();
			double approx_cols = Math::sqrt((3.0*((double)total))/2.0);
			double approx_rows = approx_cols*(2.0/3.0);
			unsigned int cols = (unsigned int)Math::round(approx_cols);
			unsigned int rows = (unsigned int)Math::round(approx_rows);
			if((cols*rows) < total)
			{
				cols = (unsigned int)Math::ceil(approx_cols);
				if((cols*rows) < total)
				{
					rows = (unsigned int)Math::ceil(approx_rows);
				}
			}
			
			double frameoffset_y = getElement()->getAutoLayoutManager().get(getHeaderbarElement()).bottom*1.1;
			
			RectD bounds(0.1, frameoffset_y, 0.9, 0.6);
			double bounds_w = bounds.right - bounds.left;
			double bounds_h = bounds.bottom - bounds.top;
			
			double icon_width = bounds_w/((double)cols);
			double icon_height = bounds_h/((double)rows);
			
			AssetManager* loaderAssetManager = smashData.getModuleData()->getCharacterLoader()->getAssetManager();
			for(unsigned int i=0; i<characters.size(); i++)
			{
				CharacterInfo& info = characters.get(i);
				CharacterIcon* icon = new CharacterIcon(info, 0, 0, loaderAssetManager);
				unsigned int col = i%cols;
				unsigned int row = i/cols;
				double icon_left = bounds.left+(((double)col)*icon_width);
				double icon_top = bounds.top+(((double)row)*icon_height);
				autoIconLayoutMgr.add(RectD(icon_left, icon_top, icon_left+icon_width, icon_top+icon_height), icon);
				icons.add(icon);
			}
		}
Ejemplo n.º 2
0
		CharacterSelectScreen::CharacterSelectScreen(const SmashData&smashData, Rules*ruleData) : SmashBros::Menu::BaseMenuScreen(smashData)
		{
			RectangleD frame = getFrame();
			autoIconLayoutMgr.setFrame(RectangleD(0,0,frame.width,frame.height));
			autoPanelLayoutMgr.setFrame(RectangleD(0,0,frame.width,frame.height));
			
			rules = ruleData;
			characterLoader = smashData.getModuleData()->getCharacterLoader();
			readyToFightBanner = new ReadyToFightBanner(this, 0, 0, smashData.getMenuData()->getAssetManager());
			getElement()->getAutoLayoutManager().add(RectD(0, 0.5, 1.0, 0.7), readyToFightBanner);
		}
		void StageSelectScreen::reloadIcons(const SmashData&smashData)
		{
			for(size_t i=0; i<icons.size(); i++)
			{
				delete icons.get(i);
			}
			icons.clear();
			
			ArrayList<StageInfo>& stages = smashData.getModuleData()->getStageLoader()->getStages();
			
			RectD bounds(0.3, 0.2, 0.9, 0.9);
			double bounds_w = bounds.right - bounds.left;
			double bounds_h = bounds.bottom - bounds.top;
			
			unsigned int cols = 6;
			unsigned int rows = 6;
			double icon_width = bounds_w / (double)cols;
			double icon_height = bounds_h / (double)rows;
			
			AssetManager* loaderAssetManager = smashData.getModuleData()->getStageLoader()->getAssetManager();
			for(size_t i=0; i<stages.size(); i++)
			{
				StageInfo& info = stages.get(i);
				StageIcon* icon = new StageIcon(info, 0, 0, loaderAssetManager);
				unsigned int col = (unsigned int)(i%cols);
				unsigned int row = (unsigned int)(i/cols);
				double icon_left = bounds.left+(((double)col)*icon_width);
				double icon_top = bounds.top+(((double)row)*icon_height);
				icon->autoLayoutMgr.setRule(LAYOUTRULE_LEFT, icon_left, LAYOUTVALUE_RATIO);
				icon->autoLayoutMgr.setRule(LAYOUTRULE_TOP, icon_top, LAYOUTVALUE_RATIO);
				icon->autoLayoutMgr.setRule(LAYOUTRULE_RIGHT, icon_left+icon_width, LAYOUTVALUE_RATIO);
				icon->autoLayoutMgr.setRule(LAYOUTRULE_BOTTOM, icon_top+icon_height, LAYOUTVALUE_RATIO);
				icons.add(icon);
				addItem(icon);
			}
		}
		void StageSelectScreen::reloadPreview(const SmashData&smashData)
		{
			if(preview != nullptr)
			{
				preview->removeFromParentElement();
				delete preview;
				preview = nullptr;
			}
			
			preview = new StagePreview(smashData.getModuleData()->getStageLoader()->getAssetManager());
			preview->setLayoutRule(LAYOUTRULE_LEFT, 0.05, LAYOUTVALUE_RATIO);
			preview->setLayoutRule(LAYOUTRULE_TOP, 0.20, LAYOUTVALUE_RATIO);
			preview->setLayoutRule(LAYOUTRULE_RIGHT, 0.25, LAYOUTVALUE_RATIO);
			preview->setLayoutRule(LAYOUTRULE_BOTTOM, 0.90, LAYOUTVALUE_RATIO);
			getElement()->addChildElement(preview);
		}