예제 #1
0
Skin::Skin(const std::string &filename, Graphics::Renderer *renderer, float scale) :
	m_renderer(renderer),
	m_scale(scale)
{
	IniConfig cfg;
	// set defaults
	cfg.SetInt("ButtonMinInnerSize", 16);
	cfg.SetFloat("ListAlphaNormal", 0.0);
	cfg.SetFloat("ListAlphaHover", 0.4);
	cfg.SetFloat("ListAlphaSelect", 0.6);
	// load
	cfg.Read(FileSystem::gameDataFiles, filename);

	m_texture.Reset(Graphics::TextureBuilder::UI(cfg.String("TextureFile")).GetOrCreateTexture(m_renderer, "ui"));

	Graphics::MaterialDescriptor desc;
	desc.textures = 1;
	m_material.Reset(m_renderer->CreateMaterial(desc));
	m_material->texture0 = m_texture.Get();
	m_material->diffuse = Color::WHITE;

	m_backgroundNormal        = LoadBorderedRectElement(cfg.String("BackgroundNormal"));
	m_backgroundActive        = LoadBorderedRectElement(cfg.String("BackgroundActive"));

	m_buttonDisabled          = LoadBorderedRectElement(cfg.String("ButtonDisabled"));
	m_buttonNormal            = LoadBorderedRectElement(cfg.String("ButtonNormal"));
	m_buttonHover             = LoadBorderedRectElement(cfg.String("ButtonHover"));
	m_buttonActive            = LoadBorderedRectElement(cfg.String("ButtonActive"));

	m_smallButtonDisabled     = LoadRectElement(cfg.String("SmallButtonDisabled"));
	m_smallButtonNormal       = LoadRectElement(cfg.String("SmallButtonNormal"));
	m_smallButtonHover        = LoadRectElement(cfg.String("SmallButtonHover"));
	m_smallButtonActive       = LoadRectElement(cfg.String("SmallButtonActive"));

	m_checkboxDisabled        = LoadRectElement(cfg.String("CheckboxDisabled"));
	m_checkboxNormal          = LoadRectElement(cfg.String("CheckboxNormal"));
	m_checkboxHover           = LoadRectElement(cfg.String("CheckboxHover"));
	m_checkboxActive          = LoadRectElement(cfg.String("CheckboxActive"));
	m_checkboxCheckedDisabled = LoadRectElement(cfg.String("CheckboxCheckedDisabled"));
	m_checkboxCheckedNormal   = LoadRectElement(cfg.String("CheckboxCheckedNormal"));
	m_checkboxCheckedHover    = LoadRectElement(cfg.String("CheckboxCheckedHover"));
	m_checkboxCheckedActive   = LoadRectElement(cfg.String("CheckboxCheckedActive"));

	m_sliderVerticalGutter         = LoadEdgedRectElement(cfg.String("SliderVerticalGutter"));
	m_sliderHorizontalGutter       = LoadEdgedRectElement(cfg.String("SliderHorizontalGutter"));
	m_sliderVerticalButtonNormal   = LoadRectElement(cfg.String("SliderVerticalButtonNormal"));
	m_sliderVerticalButtonHover    = LoadRectElement(cfg.String("SliderVerticalButtonHover"));
	m_sliderVerticalButtonActive   = LoadRectElement(cfg.String("SliderVerticalButtonActive"));
	m_sliderHorizontalButtonNormal = LoadRectElement(cfg.String("SliderHorizontalButtonNormal"));
	m_sliderHorizontalButtonHover  = LoadRectElement(cfg.String("SliderHorizontalButtonHover"));
	m_sliderHorizontalButtonActive = LoadRectElement(cfg.String("SliderHorizontalButtonActive"));

	m_buttonMinInnerSize      = cfg.Int("ButtonMinInnerSize");

	m_listAlphaNormal = cfg.Float("ListAlphaNormal");
	m_listAlphaSelect = cfg.Float("ListAlphaSelect");
	m_listAlphaHover  = cfg.Float("ListAlphaHover");
}
예제 #2
0
파일: Skin.cpp 프로젝트: AmesianX/pioneer
Skin::Skin(const std::string &filename, Graphics::Renderer *renderer, float scale) :
	m_renderer(renderer),
	m_scale(scale)
{
	IniConfig cfg;
	// set defaults
	cfg.SetInt("ButtonMinInnerSize", 16);
	cfg.SetFloat("AlphaNormal", 0.0);
	cfg.SetFloat("AlphaHover", 0.4);
	cfg.SetFloat("AlphaSelect", 0.6);
	// load
	cfg.Read(FileSystem::gameDataFiles, filename);

	m_texture.Reset(Graphics::TextureBuilder::UI(cfg.String("TextureFile")).GetOrCreateTexture(m_renderer, "ui"));

	Graphics::MaterialDescriptor desc;
	desc.textures = 1;
	m_textureMaterial.Reset(m_renderer->CreateMaterial(desc));
	m_textureMaterial->texture0 = m_texture.Get();
	m_textureMaterial->diffuse = Color::WHITE;

	desc.textures = 0;
	m_colorMaterial.Reset(m_renderer->CreateMaterial(desc));

	Graphics::RenderStateDesc rsd;
	rsd.blendMode = Graphics::BLEND_ALPHA;
	rsd.depthWrite = false;
	rsd.depthTest = false;
	m_alphaBlendState = m_renderer->CreateRenderState(rsd);

	rsd.blendMode = Graphics::BLEND_SET_ALPHA;
	m_alphaSetState = m_renderer->CreateRenderState(rsd);

	rsd.blendMode = Graphics::BLEND_DEST_ALPHA;
	m_alphaMaskState = m_renderer->CreateRenderState(rsd);

	m_backgroundNormal        = LoadBorderedRectElement(cfg.String("BackgroundNormal"));
	m_backgroundActive        = LoadBorderedRectElement(cfg.String("BackgroundActive"));

	m_buttonDisabled          = LoadBorderedRectElement(cfg.String("ButtonDisabled"));
	m_buttonNormal            = LoadBorderedRectElement(cfg.String("ButtonNormal"));
	m_buttonHover             = LoadBorderedRectElement(cfg.String("ButtonHover"));
	m_buttonActive            = LoadBorderedRectElement(cfg.String("ButtonActive"));

	m_smallButtonDisabled     = LoadRectElement(cfg.String("SmallButtonDisabled"));
	m_smallButtonNormal       = LoadRectElement(cfg.String("SmallButtonNormal"));
	m_smallButtonHover        = LoadRectElement(cfg.String("SmallButtonHover"));
	m_smallButtonActive       = LoadRectElement(cfg.String("SmallButtonActive"));

	m_checkboxDisabled        = LoadRectElement(cfg.String("CheckboxDisabled"));
	m_checkboxNormal          = LoadRectElement(cfg.String("CheckboxNormal"));
	m_checkboxHover           = LoadRectElement(cfg.String("CheckboxHover"));
	m_checkboxActive          = LoadRectElement(cfg.String("CheckboxActive"));
	m_checkboxCheckedDisabled = LoadRectElement(cfg.String("CheckboxCheckedDisabled"));
	m_checkboxCheckedNormal   = LoadRectElement(cfg.String("CheckboxCheckedNormal"));
	m_checkboxCheckedHover    = LoadRectElement(cfg.String("CheckboxCheckedHover"));
	m_checkboxCheckedActive   = LoadRectElement(cfg.String("CheckboxCheckedActive"));

	m_sliderVerticalGutter         = LoadEdgedRectElement(cfg.String("SliderVerticalGutter"));
	m_sliderHorizontalGutter       = LoadEdgedRectElement(cfg.String("SliderHorizontalGutter"));
	m_sliderVerticalButtonNormal   = LoadRectElement(cfg.String("SliderVerticalButtonNormal"));
	m_sliderVerticalButtonHover    = LoadRectElement(cfg.String("SliderVerticalButtonHover"));
	m_sliderVerticalButtonActive   = LoadRectElement(cfg.String("SliderVerticalButtonActive"));
	m_sliderHorizontalButtonNormal = LoadRectElement(cfg.String("SliderHorizontalButtonNormal"));
	m_sliderHorizontalButtonHover  = LoadRectElement(cfg.String("SliderHorizontalButtonHover"));
	m_sliderHorizontalButtonActive = LoadRectElement(cfg.String("SliderHorizontalButtonActive"));

	m_gaugeBackground = LoadEdgedRectElement(cfg.String("GaugeBackground"));
	m_gaugeMask = LoadEdgedRectElement(cfg.String("GaugeMask"));
	m_gaugeFillNormal = LoadRectElement(cfg.String("GaugeFillNormal"));
	m_gaugeFillWarning = LoadRectElement(cfg.String("GaugeFillWarning"));
	m_gaugeFillCritical = LoadRectElement(cfg.String("GaugeFillCritical"));

	m_buttonMinInnerSize      = cfg.Int("ButtonMinInnerSize");

	m_alphaNormal = cfg.Float("AlphaNormal");
	m_alphaSelect = cfg.Float("AlphaSelect");
	m_alphaHover  = cfg.Float("AlphaHover");
}