void g2Theme::GetCharacter(char character, float* tSrcX, float* tSrcY, float* tSrcWidth, float* tSrcHeight, int* width, int* height, GLuint* textID) { // Calculate the x and y positions // Low nibble is x-axis, high nibble is y axis // Note to self: would it be faster to do a bit-wise manipulation? // sourceX = (character & 0xf0) >> 4 to cast a byte's higher nibble to lower nibble int w, h; GetCharacterSize(character, &w, &h); if(width != NULL) *width = w; if(height != NULL) *height= h; if(tSrcX != NULL) *tSrcX = float((character % 16) * (CharacterMapWidth / 16)) / float(CharacterMapWidth); if(tSrcY != NULL) *tSrcY = float((character / 16) * (CharacterMapHeight / 16)) / float(CharacterMapHeight); if(tSrcWidth != NULL) *tSrcWidth = float(w) / float(CharacterMapWidth); if(tSrcHeight != NULL) *tSrcHeight = float(h) / float(CharacterMapHeight); // Set the texture to the character map if(textID != NULL) *textID = CharacterMapID; }
void CheckBoxObject::SaveToXml(TiXmlElement * elem) { TiXmlElement * str = new TiXmlElement( "String" ); elem->LinkEndChild( str ); str->SetAttribute("value", GetString().c_str()); TiXmlElement * checked = new TiXmlElement( "Checked" ); elem->LinkEndChild( checked ); checked->SetAttribute("value", static_cast<bool>(IsChecked())); TiXmlElement * font = new TiXmlElement( "Font" ); elem->LinkEndChild( font ); font->SetAttribute("value", GetFont().c_str()); TiXmlElement * characterSize = new TiXmlElement( "CharacterSize" ); elem->LinkEndChild( characterSize ); characterSize->SetAttribute("value", GetCharacterSize()); TiXmlElement * backgroundColorElem = new TiXmlElement( "BackgroundColorScheme" ); elem->LinkEndChild( backgroundColorElem ); backgroundColor->SaveToXml(backgroundColorElem); TiXmlElement * borderColorElem = new TiXmlElement( "BorderColorScheme" ); elem->LinkEndChild( borderColorElem ); borderColor->SaveToXml(borderColorElem); TiXmlElement * textColorElem = new TiXmlElement( "TextColorScheme" ); elem->LinkEndChild( textColorElem ); textColor->SaveToXml(textColorElem); TiXmlElement * checkColorElem = new TiXmlElement( "CheckColorScheme" ); elem->LinkEndChild( checkColorElem ); checkColor->SaveToXml(checkColorElem); TiXmlElement * borderWidthElem = new TiXmlElement( "BorderWidth" ); elem->LinkEndChild( borderWidthElem ); borderWidthElem->SetAttribute("value", GetBorderWidth()); TiXmlElement * paddingElem = new TiXmlElement( "Padding" ); elem->LinkEndChild( paddingElem ); paddingElem->SetAttribute("value", GetPadding()); TiXmlElement * boxSizeElem = new TiXmlElement( "BoxSize" ); elem->LinkEndChild( boxSizeElem ); boxSizeElem->SetAttribute("value", GetBoxSize()); TiXmlElement * checkSignSizeElem = new TiXmlElement( "CheckSignSize" ); elem->LinkEndChild( checkSignSizeElem ); checkSignSizeElem->SetAttribute("value", GetCheckSignSize()); }
void CheckBoxObject::UpdateProperties() { //Update BackgroundColor sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId(), "BackgroundColor", backgroundColor->unfocusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":PRELIGHT", "BackgroundColor", backgroundColor->hoveredColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":ACTIVE", "BackgroundColor", backgroundColor->focusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":INSENSITIVE", "BackgroundColor", backgroundColor->disabledColor ); //Update BorderColor sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId(), "BorderColor", borderColor->unfocusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":PRELIGHT", "BorderColor", borderColor->hoveredColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":ACTIVE", "BorderColor", borderColor->focusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":INSENSITIVE", "BorderColor", borderColor->disabledColor ); //Update TextColor sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + "", "Color", textColor->unfocusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":PRELIGHT", "Color", textColor->hoveredColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":ACTIVE", "Color", textColor->focusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":INSENSITIVE", "Color", textColor->disabledColor ); //Update CheckColor sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + "", "CheckColor", checkColor->unfocusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":PRELIGHT", "CheckColor", checkColor->hoveredColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":ACTIVE", "CheckColor", checkColor->focusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":INSENSITIVE", "CheckColor", checkColor->disabledColor ); //Update font size sfg::Context::Get().GetEngine().SetProperty<unsigned int>("CheckButton#" + obj->GetId() + "", "FontSize", GetCharacterSize()); sfg::Context::Get().GetEngine().SetProperty<std::string>("CheckButton#" + obj->GetId(), "FontName", std::string("gdres:") + GetFont()); //Update border width and padding sfg::Context::Get().GetEngine().SetProperty<float>("CheckButton#" + obj->GetId(), "BorderWidth", static_cast<float>(GetBorderWidth())); sfg::Context::Get().GetEngine().SetProperty<float>("CheckButton#" + obj->GetId(), "Padding", static_cast<float>(GetPadding())); sfg::Context::Get().GetEngine().SetProperty<float>("CheckButton#" + obj->GetId(), "BoxSize", static_cast<float>(GetBoxSize())); sfg::Context::Get().GetEngine().SetProperty<float>("CheckButton#" + obj->GetId(), "CheckSize", static_cast<float>(GetCheckSignSize())); }
void CheckBoxObject::GetPropertyForDebugger(unsigned int propertyNb, string & name, string & value) const { if ( propertyNb == 0 ) {name = _("Coché"); if(IsChecked()) value = "yes"; else value = "no";} else if ( propertyNb == 1 ) {name = _("Texte"); value = GetString();} else if ( propertyNb == 2 ) { name = _("Etat"); if(obj->GetState() == sfg::Widget::ACTIVE) value = _("Actif"); else if(obj->GetState() == sfg::Widget::PRELIGHT) value = _("Survolé"); else if(obj->GetState() == sfg::Widget::NORMAL) value = _("Normal"); else if(obj->GetState() == sfg::Widget::INSENSITIVE) value = _("Désactivé"); else value = _("Inconnu"); } else if ( propertyNb == 3 ) {name = _("Taille du texte"); value = ToString<int>(GetCharacterSize());} }
float CFont::GetCharacterSizeDrawing(CharType arg_char) { return GetCharacterSize(arg_char, RenderState->FontStyle, RenderState->BaseCharset, RenderState->Prop, RenderState->Scale.x); }
float CFont::GetCharacterSizeNormal(CharType arg_char) { return GetCharacterSize(arg_char, Details->FontStyle, Details->BaseCharset, Details->Prop, Details->Scale.x); }