From d62c139ee0d0d7e9363392810329135a19c3cddb Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 12 Mar 2019 20:02:43 +0200 Subject: [PATCH 1/7] Changed: Parse html style attribute --HG-- branch : develop --- code/nel/include/nel/gui/group_html.h | 5 +++ code/nel/include/nel/gui/libwww.h | 8 ++++ code/nel/src/gui/group_html.cpp | 60 ++++++++++++++++++++------- code/nel/src/gui/libwww.cpp | 11 +++++ 4 files changed, 68 insertions(+), 16 deletions(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 7820cbd6a..8b296f114 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -105,6 +105,7 @@ namespace NLGUI Height=-1; MaxWidth=-1; MaxHeight=-1; + BackgroundColor=NLMISC::CRGBA::Black; } uint FontSize; uint FontWeight; @@ -119,6 +120,7 @@ namespace NLGUI sint32 Height; sint32 MaxWidth; sint32 MaxHeight; + NLMISC::CRGBA BackgroundColor; }; // ImageDownload system @@ -345,6 +347,9 @@ namespace NLGUI // Get Home URL virtual std::string home(); + // Clear style stack and restore default style + void resetCssStyle(); + // Parse style html tag TStyle parseStyle(const std::string &str_styles); diff --git a/code/nel/include/nel/gui/libwww.h b/code/nel/include/nel/gui/libwww.h index 9c6579f1f..112cae7d7 100644 --- a/code/nel/include/nel/gui/libwww.h +++ b/code/nel/include/nel/gui/libwww.h @@ -49,6 +49,14 @@ namespace NLGUI #undef HTML_ATTR #define HTML_ATTR(t,a) MY_HTML_##t##_##a + enum + { + HTML_ATTR(HTML,DIR) = 0, + HTML_ATTR(HTML,LANG), + HTML_ATTR(HTML,VERSION), + HTML_ATTR(HTML,STYLE), + }; + enum { HTML_ATTR(A,ACCESSKEY) = 0, diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 92431a3aa..7b81ef746 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -1489,6 +1489,13 @@ namespace NLGUI // Paragraph ? switch(element_number) { + case HTML_HTML: + if (present[MY_HTML_HTML_STYLE] && value[MY_HTML_HTML_STYLE]) + getStyleParams(value[MY_HTML_HTML_STYLE], _StyleDefault); + + _Style = _StyleDefault; + setBackgroundColor(_Style.BackgroundColor); + break; case HTML_HEAD: _ReadingHeadTag = !_IgnoreHeadTag; _IgnoreHeadTag = true; @@ -1708,18 +1715,22 @@ namespace NLGUI break; case HTML_BODY: { - if (present[HTML_BODY_BGCOLOR] && value[HTML_BODY_BGCOLOR]) - { - CRGBA bgColor; - if (scanHTMLColor(value[HTML_BODY_BGCOLOR], bgColor)) - setBackgroundColor (bgColor); - } - + pushStyle(); + string style; if (present[HTML_BODY_STYLE] && value[HTML_BODY_STYLE]) style = value[HTML_BODY_STYLE]; - - + + if (!style.empty()) + getStyleParams(style, _Style); + + CRGBA bgColor = _Style.BackgroundColor; + if (present[HTML_BODY_BGCOLOR] && value[HTML_BODY_BGCOLOR]) + scanHTMLColor(value[HTML_BODY_BGCOLOR], bgColor); + + if (bgColor != _Style.BackgroundColor) + setBackgroundColor(bgColor); + if (!style.empty()) { TStyle styles = parseStyle(style); @@ -1743,10 +1754,6 @@ namespace NLGUI image = image.substr(4, image.size()-5); setBackground (image, scale, repeat); } - - // set default text style from - getStyleParams(style, _StyleDefault); - _Style = _StyleDefault; } } break; @@ -2737,6 +2744,9 @@ namespace NLGUI case HTML_HEAD: _ReadingHeadTag = false; break; + case HTML_BODY: + popStyle(); + break; case HTML_FONT: popStyle(); break; @@ -4915,9 +4925,7 @@ namespace NLGUI _IgnoreBaseUrlTag = false; // reset style - _StyleDefault = CStyleParams(); - _Style = _StyleDefault; - _StyleParams.clear(); + resetCssStyle(); // TR @@ -6252,6 +6260,18 @@ namespace NLGUI return uri.toString(); } + // *************************************************************************** + void CGroupHTML::resetCssStyle() + { + _StyleDefault = CStyleParams(); + _StyleDefault.TextColor = TextColor; + _StyleDefault.FontSize = TextFontSize; + _StyleDefault.BackgroundColor = BgColor; + + _Style = _StyleDefault; + _StyleParams.clear(); + } + // *************************************************************************** // CGroupHTML::CStyleParams style; // style.FontSize; // font-size: 10px; @@ -6485,6 +6505,14 @@ namespace NLGUI if (fromString(it->second, b)) style.GlobalColor = b; } + else + if (it->first == "background-color") + { + if (it->second == "inherit") + style.BackgroundColor = current.backgroundColor; + else + scanHTMLColor(it->second.c_str(), style.BackgroundColor); + } } } diff --git a/code/nel/src/gui/libwww.cpp b/code/nel/src/gui/libwww.cpp index f00a92749..bb32fd5b6 100644 --- a/code/nel/src/gui/libwww.cpp +++ b/code/nel/src/gui/libwww.cpp @@ -47,6 +47,15 @@ namespace NLGUI #undef HTML_ATTR #define HTML_ATTR(a,b) { (char*) #b } + HTAttr html_attr[] = + { + HTML_ATTR(HTML,DIR), + HTML_ATTR(HTML,LANG), + HTML_ATTR(HTML,VERSION), + HTML_ATTR(HTML,STYLE), + { 0 } + }; + HTAttr a_attr[] = { HTML_ATTR(A,ACCESSKEY), @@ -469,6 +478,8 @@ namespace NLGUI // Change the HTML DTD SGML_dtd *HTML_DTD = HTML_dtd (); + HTML_DTD->tags[HTML_HTML].attributes = html_attr; + HTML_DTD->tags[HTML_HTML].number_of_attributes = sizeof(html_attr) / sizeof(HTAttr) - 1; HTML_DTD->tags[HTML_TABLE].attributes = table_attr; HTML_DTD->tags[HTML_TABLE].number_of_attributes = sizeof(table_attr) / sizeof(HTAttr) - 1; HTML_DTD->tags[HTML_TR].attributes = tr_attr; From b6d3ff8323c17a5c7b382fad601ccd75e244552a Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 12 Mar 2019 20:03:34 +0200 Subject: [PATCH 2/7] Changed: Parse css pt/em/rem size values --HG-- branch : develop --- code/nel/include/nel/gui/libwww.h | 3 + code/nel/src/gui/group_html.cpp | 96 +++++++++++++++++++++++++++---- code/nel/src/gui/libwww.cpp | 31 ++++++++++ 3 files changed, 118 insertions(+), 12 deletions(-) diff --git a/code/nel/include/nel/gui/libwww.h b/code/nel/include/nel/gui/libwww.h index 112cae7d7..84eeb01e9 100644 --- a/code/nel/include/nel/gui/libwww.h +++ b/code/nel/include/nel/gui/libwww.h @@ -280,6 +280,9 @@ namespace NLGUI #undef HTML_ATTR // *************************************************************************** + // Read a CSS length value, return true if one of supported units '%, rem, em, px, pt' + // On failure: 'value' and 'unit' values are undefined + bool getCssLength (float &value, std::string &unit, const std::string &str); // Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false bool getPercentage (sint32 &width, float &percent, const char *str); diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 7b81ef746..514bccf15 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -1851,10 +1851,11 @@ namespace NLGUI // Get the string name if (present[MY_HTML_IMG_SRC] && value[MY_HTML_IMG_SRC]) { - CStyleParams style; float tmpf; - std::string id; + CStyleParams style; + style.FontSize = _Style.FontSize; + if (present[MY_HTML_IMG_ID] && value[MY_HTML_IMG_ID]) id = value[MY_HTML_IMG_ID]; @@ -2190,6 +2191,7 @@ namespace NLGUI if (!(_Forms.empty())) { CStyleParams style; + style.FontSize = _Style.FontSize; // A select box string name; @@ -2699,6 +2701,7 @@ namespace NLGUI if (sep) { CStyleParams style; + style.FontSize = _Style.FontSize; style.TextColor = CRGBA(120, 120, 120, 255); style.Height = 0; style.Width = 0; @@ -6291,22 +6294,39 @@ namespace NLGUI float tmpf; TStyle styles = parseStyle(styleString); TStyle::iterator it; + + // first pass: get font-size for 'em' sizes for (it=styles.begin(); it != styles.end(); ++it) { if (it->first == "font-size") { if (it->second == "inherit") + { style.FontSize = current.FontSize; + } else { - float tmp; - sint size = 0; - getPercentage (size, tmp, it->second.c_str()); - if (size > 0) - style.FontSize = size; + std::string unit; + if (getCssLength(tmpf, unit, it->second.c_str())) + { + if (unit == "rem") + style.FontSize = _StyleDefault.FontSize * tmpf; + else if (unit == "em") + style.FontSize = current.FontSize * tmpf; + else if (unit == "pt") + style.FontSize = tmpf / 0.75f; + else if (unit == "%") + style.FontSize = current.FontSize * tmpf / 100.f; + else + style.FontSize = tmpf; + } } } - else + } + + // second pass: rest of style + for (it=styles.begin(); it != styles.end(); ++it) + { if (it->first == "font-style") { if (it->second == "inherit") @@ -6485,16 +6505,68 @@ namespace NLGUI } else if (it->first == "width") - getPercentage(style.Width, tmpf, it->second.c_str()); + { + std::string unit; + if (getCssLength(tmpf, unit, it->second.c_str())) + { + if (unit == "rem") + style.Width = tmpf * _StyleDefault.FontSize; + else if (unit == "em") + style.Width = tmpf * style.FontSize; + else if (unit == "pt") + style.FontSize = tmpf / 0.75f; + else + style.Width = tmpf; + } + } else if (it->first == "height") - getPercentage(style.Height, tmpf, it->second.c_str()); + { + std::string unit; + if (getCssLength(tmpf, unit, it->second.c_str())) + { + if (unit == "rem") + style.Height = tmpf * _StyleDefault.FontSize; + else if (unit == "em") + style.Height = tmpf * style.FontSize; + else if (unit == "pt") + style.FontSize = tmpf / 0.75f; + else + style.Height = tmpf; + } + } else if (it->first == "max-width") - getPercentage(style.MaxWidth, tmpf, it->second.c_str()); + { + std::string unit; + if (getCssLength(tmpf, unit, it->second.c_str())) + { + if (unit == "rem") + style.MaxWidth = tmpf * _StyleDefault.FontSize; + else if (unit == "em") + style.MaxWidth = tmpf * style.FontSize; + else if (unit == "pt") + style.FontSize = tmpf / 0.75f; + else + style.MaxWidth = tmpf; + } + } else if (it->first == "max-height") - getPercentage(style.MaxHeight, tmpf, it->second.c_str()); + { + std::string unit; + if (getCssLength(tmpf, unit, it->second.c_str())) + { + if (unit == "rem") + style.MaxHeight = tmpf * _StyleDefault.FontSize; + else if (unit == "em") + style.MaxHeight = tmpf * style.FontSize; + else if (unit == "pt") + style.FontSize = tmpf / 0.75f; + else + style.MaxHeight = tmpf; + } + } else if (it->first == "-ryzom-modulate-color") { diff --git a/code/nel/src/gui/libwww.cpp b/code/nel/src/gui/libwww.cpp index bb32fd5b6..ca8920b14 100644 --- a/code/nel/src/gui/libwww.cpp +++ b/code/nel/src/gui/libwww.cpp @@ -293,6 +293,37 @@ namespace NLGUI }; // *************************************************************************** + bool getCssLength (float &value, std::string &unit, const std::string &str) + { + std::string::size_type pos = 0; + std::string::size_type len = str.size(); + if (len == 1 && str[0] == '.') + { + return false; + } + + while(pos < len) + { + bool isNumeric = (str[pos] >= '0' && str[pos] <= '9') + || (pos == 0 && str[pos] == '.') + || (pos > 0 && str[pos] == '.' && str[pos-1] >= '0' && str[pos-1] <= '9'); + if (!isNumeric) + { + break; + } + + pos++; + } + + unit = toLower(str.substr(pos)); + if (unit == "%" || unit == "rem" || unit == "em" || unit == "px" || unit == "pt") + { + std::string tmpstr = str.substr(0, pos); + return fromString(tmpstr, value); + } + + return false; + } // Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false bool getPercentage (sint32 &width, float &percent, const char *str) From 69f73ba28ba18ccfbdcca954fd06c9988c20f13b Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 14 Mar 2019 14:57:55 +0200 Subject: [PATCH 3/7] Changed: Add hmin attribute to text button --HG-- branch : develop --- code/nel/include/nel/gui/ctrl_text_button.h | 8 +++++-- code/nel/src/gui/ctrl_text_button.cpp | 26 ++++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/code/nel/include/nel/gui/ctrl_text_button.h b/code/nel/include/nel/gui/ctrl_text_button.h index 69898639d..367e527f8 100644 --- a/code/nel/include/nel/gui/ctrl_text_button.h +++ b/code/nel/include/nel/gui/ctrl_text_button.h @@ -111,6 +111,9 @@ namespace NLGUI sint32 getWMin() const { return _WMin; } void setWMin( sint32 wmin ) { _WMin = wmin; } + sint32 getHMin() const { return _HMin; } + void setHMin( sint32 hmin ) { _HMin = hmin; } + // Compute Size according to bitmap and Text (Ensure as big as possible button) sint32 getWMax() const; @@ -122,6 +125,7 @@ namespace NLGUI REFLECT_SINT32("text_x", getTextX, setTextX) REFLECT_SINT32("wmargin", getWMargin, setWMargin) REFLECT_SINT32("wmin", getWMin, setWMin) + REFLECT_SINT32("hmin", getHMin, setHMin) REFLECT_LUA_METHOD("getViewText", luaGetViewText) REFLECT_EXPORT_END @@ -151,8 +155,8 @@ namespace NLGUI sint32 _BmpLeftW, _BmpMiddleW, _BmpRightW, _BmpH; // Value to add to TextW to get button W. sint32 _WMargin; - // Min W Value - sint32 _WMin; + // Min W, H Value + sint32 _WMin, _HMin; sint32 _TextY; sint32 _TextX; THotSpot _TextPosRef; diff --git a/code/nel/src/gui/ctrl_text_button.cpp b/code/nel/src/gui/ctrl_text_button.cpp index 6e1fab26e..9775b1b07 100644 --- a/code/nel/src/gui/ctrl_text_button.cpp +++ b/code/nel/src/gui/ctrl_text_button.cpp @@ -46,6 +46,7 @@ namespace NLGUI _BmpLeftW= _BmpMiddleW= _BmpRightW= _BmpH= 0; _WMargin= 0; _WMin= 0; + _HMin= 0; _TextX= 0; _TextY= 0; _Setuped= false; @@ -124,6 +125,11 @@ namespace NLGUI return toString( _WMin ); } else + if( name == "hmin" ) + { + return toString( _HMin ); + } + else if( name == "hardtext" ) { if( _ViewText != NULL ) @@ -296,6 +302,14 @@ namespace NLGUI return; } else + if( name == "hmin" ) + { + sint32 i; + if( fromString( value, i ) ) + _HMin = i; + return; + } + else if( name == "hardtext" ) { if( _ViewText != NULL ) @@ -469,6 +483,7 @@ namespace NLGUI xmlNewProp( node, BAD_CAST "wmargin", BAD_CAST toString( _WMargin ).c_str() ); xmlNewProp( node, BAD_CAST "wmin", BAD_CAST toString( _WMin ).c_str() ); + xmlNewProp( node, BAD_CAST "hmin", BAD_CAST toString( _HMin ).c_str() ); xmlNewProp( node, BAD_CAST "hardtext", BAD_CAST _ViewText->getText().toString().c_str() ); xmlNewProp( node, BAD_CAST "text_y", BAD_CAST toString( _TextY ).c_str() ); xmlNewProp( node, BAD_CAST "text_x", BAD_CAST toString( _TextX ).c_str() ); @@ -519,7 +534,6 @@ namespace NLGUI return false; } - // *** Read Textures. prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_normal" ); if (prop) @@ -604,6 +618,15 @@ namespace NLGUI // _WMin is at least the size of All W Bitmaps _WMin= max(_WMin, _BmpLeftW + _BmpMiddleW + _BmpRightW); + // hmin + _HMin= 0; + prop = (char*) xmlGetProp( cur, (xmlChar*)"hmin" ); + if (prop) + { + fromString((const char *) prop, _HMin); + } + _HMin= max(_HMin, _BmpH); + // TextY _TextY= 0; prop = (char*) xmlGetProp( cur, (xmlChar*)"text_y" ); @@ -900,6 +923,7 @@ namespace NLGUI if (!(_SizeRef & 2)) { _H= max(_BmpH, _ViewText->getH()); + _H= max(_H, _HMin); } CViewBase::updateCoords(); From 64e54f24c1d923c074e1cc4f3442a82543827c63 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 14 Mar 2019 22:59:33 +0200 Subject: [PATCH 4/7] Changed: Form element styling --HG-- branch : develop --- code/nel/include/nel/gui/ctrl_text_button.h | 7 + code/nel/include/nel/gui/dbgroup_combo_box.h | 1 + code/nel/include/nel/gui/group_html.h | 8 ++ code/nel/include/nel/gui/group_menu.h | 3 + code/nel/src/gui/ctrl_text_button.cpp | 37 ++++++ code/nel/src/gui/dbgroup_combo_box.cpp | 9 ++ code/nel/src/gui/group_html.cpp | 133 ++++++++++++++++--- code/nel/src/gui/group_menu.cpp | 6 + 8 files changed, 188 insertions(+), 16 deletions(-) diff --git a/code/nel/include/nel/gui/ctrl_text_button.h b/code/nel/include/nel/gui/ctrl_text_button.h index 367e527f8..e88ec81e1 100644 --- a/code/nel/include/nel/gui/ctrl_text_button.h +++ b/code/nel/include/nel/gui/ctrl_text_button.h @@ -117,6 +117,13 @@ namespace NLGUI // Compute Size according to bitmap and Text (Ensure as big as possible button) sint32 getWMax() const; + // Set texture directly without _l.tga, _m.tga, _r.tga convention + // Texture size is only read from normal textures + // If updateHeight == false, then _BmpH will keep its value + void setTexture(const std::string &l, const std::string &m, const std::string &r, bool updateHeight = true); + void setTexturePushed(const std::string &l, const std::string &m, const std::string &r); + void setTextureOver(const std::string &l, const std::string &m, const std::string &r); + int luaGetViewText(CLuaState &ls); REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton) diff --git a/code/nel/include/nel/gui/dbgroup_combo_box.h b/code/nel/include/nel/gui/dbgroup_combo_box.h index 87e6d758a..723afbdc0 100644 --- a/code/nel/include/nel/gui/dbgroup_combo_box.h +++ b/code/nel/include/nel/gui/dbgroup_combo_box.h @@ -85,6 +85,7 @@ namespace NLGUI // view text void setViewText(const ucstring & text); ucstring getViewText() const; + CViewText *getViewText(); void setTexture(uint i, const ucstring &texture); diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 8b296f114..71d7b9ff0 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -33,6 +33,7 @@ typedef std::map TStyle; namespace NLGUI { class CCtrlButton; + class CCtrlTextButton; class CCtrlScroll; class CGroupList; class CGroupMenu; @@ -105,7 +106,9 @@ namespace NLGUI Height=-1; MaxWidth=-1; MaxHeight=-1; + BorderWidth=1; BackgroundColor=NLMISC::CRGBA::Black; + BackgroundColorOver=NLMISC::CRGBA::Black; } uint FontSize; uint FontWeight; @@ -120,7 +123,9 @@ namespace NLGUI sint32 Height; sint32 MaxWidth; sint32 MaxHeight; + sint32 BorderWidth; NLMISC::CRGBA BackgroundColor; + NLMISC::CRGBA BackgroundColorOver; }; // ImageDownload system @@ -857,6 +862,9 @@ namespace NLGUI void setImage(CViewBase *view, const std::string &file, const TImageType type); void setImageSize(CViewBase *view, const CStyleParams &style = CStyleParams()); + void setTextButtonStyle(CCtrlTextButton *ctrlButton, const CStyleParams &style); + void setTextStyle(CViewText *pVT, const CStyleParams &style); + // BnpDownload system void initBnpDownload(); void checkBnpDownload(); diff --git a/code/nel/include/nel/gui/group_menu.h b/code/nel/include/nel/gui/group_menu.h index d4f940088..cfe91f7f9 100644 --- a/code/nel/include/nel/gui/group_menu.h +++ b/code/nel/include/nel/gui/group_menu.h @@ -351,6 +351,9 @@ namespace NLGUI void setMinW(sint32 minW); void setMinH(sint32 minH); + // change fontsize for new menu items + void setFontSize(uint32 fontSize); + // Gray a line on the RootMenu void setGrayedLine(uint line, bool g); diff --git a/code/nel/src/gui/ctrl_text_button.cpp b/code/nel/src/gui/ctrl_text_button.cpp index 9775b1b07..d10dfa0c9 100644 --- a/code/nel/src/gui/ctrl_text_button.cpp +++ b/code/nel/src/gui/ctrl_text_button.cpp @@ -728,6 +728,43 @@ namespace NLGUI return true; } + // *************************************************************************** + void CCtrlTextButton::setTexture(const std::string &l, const std::string &m, const std::string &r, bool updateHeight) + { + nlctassert(NumTexture==3); + _TextureIdNormal[0].setTexture(l.c_str()); + _TextureIdNormal[1].setTexture(m.c_str()); + _TextureIdNormal[2].setTexture(r.c_str()); + + sint32 newH; + + // Compute Bmp Sizes + CViewRenderer &rVR = *CViewRenderer::getInstance(); + rVR.getTextureSizeFromId(_TextureIdNormal[0], _BmpLeftW, newH); + rVR.getTextureSizeFromId(_TextureIdNormal[1], _BmpMiddleW, newH); + rVR.getTextureSizeFromId(_TextureIdNormal[2], _BmpRightW, newH); + + if (updateHeight) _BmpH = newH; + } + + // *************************************************************************** + void CCtrlTextButton::setTexturePushed(const std::string &l, const std::string &m, const std::string &r) + { + nlctassert(NumTexture==3); + _TextureIdPushed[0].setTexture(l.c_str()); + _TextureIdPushed[1].setTexture(m.c_str()); + _TextureIdPushed[2].setTexture(r.c_str()); + } + + // *************************************************************************** + void CCtrlTextButton::setTextureOver(const std::string &l, const std::string &m, const std::string &r) + { + nlctassert(NumTexture==3); + _TextureIdOver[0].setTexture(l.c_str()); + _TextureIdOver[1].setTexture(m.c_str()); + _TextureIdOver[2].setTexture(r.c_str()); + } + // *************************************************************************** void CCtrlTextButton::draw () { diff --git a/code/nel/src/gui/dbgroup_combo_box.cpp b/code/nel/src/gui/dbgroup_combo_box.cpp index 2afd8c570..5893c0b72 100644 --- a/code/nel/src/gui/dbgroup_combo_box.cpp +++ b/code/nel/src/gui/dbgroup_combo_box.cpp @@ -473,6 +473,12 @@ namespace NLGUI return _ViewText->getText(); } + // *************************************************************************** + CViewText *CDBGroupComboBox::getViewText() + { + return _ViewText; + } + // *************************************************************************** std::string CDBGroupComboBox::getSelectionText() const { @@ -633,6 +639,9 @@ namespace NLGUI { nlassert(groupMenu); + if (_ViewText) + groupMenu->setFontSize(_ViewText->getFontSize()); + // Setup the menu with combo action. groupMenu->reset(); for(uint i=0; i treating it like "display: inline-block;" + if (style.Width > 0) ctrlButton->setWMin(_Style.Width); + if (style.Height > 0) ctrlButton->setHMin(_Style.Height); + + CViewText *pVT = ctrlButton->getViewText(); + if (pVT) + { + setTextStyle(pVT, _Style); + } + + if (_Style.BackgroundColor.A > 0) + { + if (_Style.BackgroundColorOver.A == 0) + _Style.BackgroundColorOver = _Style.BackgroundColor; + + ctrlButton->setColor(_Style.BackgroundColor); + ctrlButton->setColorOver(_Style.BackgroundColorOver); + ctrlButton->setTexture("", "blank.tga", "", false); + ctrlButton->setTextureOver("", "blank.tga", ""); + ctrlButton->setProperty("force_text_over", "true"); + } + else if (_Style.BackgroundColorOver.A > 0) + { + ctrlButton->setColorOver(_Style.BackgroundColorOver); + ctrlButton->setProperty("force_text_over", "true"); + ctrlButton->setTextureOver("blank.tga", "blank.tga", "blank.tga"); + } + } + + void CGroupHTML::setTextStyle(CViewText *pVT, const CStyleParams &style) + { + if (pVT) + { + pVT->setFontSize(style.FontSize); + pVT->setColor(style.TextColor); + pVT->setColor(style.TextColor); + pVT->setFontName(style.FontFamily); + pVT->setFontSize(style.FontSize); + pVT->setEmbolden(style.FontWeight >= FONT_WEIGHT_BOLD); + pVT->setOblique(style.FontOblique); + pVT->setUnderlined(style.Underlined); + pVT->setStrikeThrough(style.StrikeThrough); + if (style.TextShadow.Enabled) + { + pVT->setShadow(true); + pVT->setShadowColor(style.TextShadow.Color); + pVT->setShadowOutline(style.TextShadow.Outline); + pVT->setShadowOffset(style.TextShadow.X, style.TextShadow.Y); + } + } + } + // Get an url and return the local filename with the path where the url image should be string CGroupHTML::localImageName(const string &url) { @@ -1556,6 +1610,10 @@ namespace NLGUI _Style.TextColor = LinkColor; _Style.Underlined = true; _Style.GlobalColor = LinkColorGlobalColor; + _Style.BackgroundColor.A = 0; + _Style.BackgroundColorOver.A = 0; + _Style.Width = -1; + _Style.Height = -1; if (present[HTML_A_STYLE] && value[HTML_A_STYLE]) getStyleParams(value[HTML_A_STYLE], _Style); @@ -1956,6 +2014,13 @@ namespace NLGUI _Style.FontSize = TextFontSize; _Style.FontWeight = FONT_WEIGHT_NORMAL; _Style.FontOblique = false; + _Style.TextShadow = STextShadow(true); + _Style.Width = -1; + _Style.Height = -1; + // by default background texture is transparent, + // using alpha value to decide if to change it to 'blank.tga' for coloring + _Style.BackgroundColor.A = 0; + _Style.BackgroundColorOver.A = 0; // Global color flag if (present[MY_HTML_INPUT_GLOBAL_COLOR]) @@ -2058,6 +2123,8 @@ namespace NLGUI } ctrlButton->setText(ucstring::makeFromUtf8(text)); + + setTextButtonStyle(ctrlButton, _Style); } getParagraph()->addChild (buttonGroup); paragraphChange (); @@ -2226,6 +2293,7 @@ namespace NLGUI sb->setMinH(style.Height); sb->setMaxVisibleLine(size); + sb->setFontSize(style.FontSize); } entry.SelectBox = sb; @@ -2234,6 +2302,14 @@ namespace NLGUI { CDBGroupComboBox *cb = addComboBox(DefaultFormSelectGroup, name.c_str()); entry.ComboBox = cb; + + if (cb) + { + // create view text + cb->updateCoords(); + if (cb->getViewText()) + setTextStyle(cb->getViewText(), style); + } } _Forms.back().Entries.push_back (entry); } @@ -2460,6 +2536,9 @@ namespace NLGUI _Style.FontOblique = false; _Style.FontSize = TextFontSize; _Style.TextShadow = STextShadow(true); + _Style.Width = -1; + _Style.Height = -1; + _Style.BackgroundColor.A = 0; if (present[MY_HTML_TEXTAREA_STYLE] && value[MY_HTML_TEXTAREA_STYLE]) getStyleParams(value[MY_HTML_TEXTAREA_STYLE], _Style); @@ -4494,6 +4573,8 @@ namespace NLGUI // Translate the tooltip ctrlButton->setDefaultContextHelp(ucstring::makeFromUtf8(getLinkTitle())); ctrlButton->setText(tmpStr); + + setTextButtonStyle(ctrlButton, _Style); } getParagraph()->addChild (buttonGroup); paragraphChange (); @@ -4516,23 +4597,10 @@ namespace NLGUI } } newLink->setText(tmpStr); - newLink->setColor(_Style.TextColor); - newLink->setFontName(_Style.FontFamily); - newLink->setFontSize(_Style.FontSize); - newLink->setEmbolden(embolden); - newLink->setOblique(_Style.FontOblique); - newLink->setUnderlined(_Style.Underlined); - newLink->setStrikeThrough(_Style.StrikeThrough); newLink->setMultiLineSpace((uint)((float)(_Style.FontSize)*LineSpaceFontFactor)); newLink->setMultiLine(true); newLink->setModulateGlobalColor(_Style.GlobalColor); - if (_Style.TextShadow.Enabled) - { - newLink->setShadow(true); - newLink->setShadowColor(_Style.TextShadow.Color); - newLink->setShadowOutline(_Style.TextShadow.Outline); - newLink->setShadowOffset(_Style.TextShadow.X, _Style.TextShadow.Y); - } + setTextStyle(newLink, _Style); // newLink->setLineAtBottom (true); registerAnchor(newLink); @@ -4638,6 +4706,10 @@ namespace NLGUI _CurrentViewLink = NULL; { + // override cols/rows values from style + if (_Style.Width > 0) cols = _Style.Width / _Style.FontSize; + if (_Style.Height > 0) rows = _Style.Height / _Style.FontSize; + // Not added ? std::vector > templateParams; templateParams.push_back (std::pair ("w", toString (cols*_Style.FontSize))); @@ -4675,7 +4747,18 @@ namespace NLGUI // Set the content CGroupEditBox *eb = dynamic_cast(textArea->getGroup("eb")); if (eb) + { eb->setInputString(decodeHTMLEntities(content)); + if (_Style.BackgroundColor.A > 0) + { + CViewBitmap *bg = dynamic_cast(eb->getView("bg")); + if (bg) + { + bg->setTexture("blank.tga"); + bg->setColor(_Style.BackgroundColor); + } + } + } textArea->invalidateCoords(); getParagraph()->addChild (textArea); @@ -6327,6 +6410,16 @@ namespace NLGUI // second pass: rest of style for (it=styles.begin(); it != styles.end(); ++it) { + if (it->first == "border") + { + sint32 b; + if (it->second == "none") + style.BorderWidth = 0; + else + if (fromString(it->second, b)) + style.BorderWidth = b; + } + else if (it->first == "font-style") { if (it->second == "inherit") @@ -6581,10 +6674,18 @@ namespace NLGUI if (it->first == "background-color") { if (it->second == "inherit") - style.BackgroundColor = current.backgroundColor; + style.BackgroundColor = current.BackgroundColor; else scanHTMLColor(it->second.c_str(), style.BackgroundColor); } + else + if (it->first == "-ryzom-background-color-over") + { + if (it->second == "inherit") + style.BackgroundColorOver = current.BackgroundColorOver; + else + scanHTMLColor(it->second.c_str(), style.BackgroundColorOver); + } } } diff --git a/code/nel/src/gui/group_menu.cpp b/code/nel/src/gui/group_menu.cpp index 7d002cfd6..d8b3452ed 100644 --- a/code/nel/src/gui/group_menu.cpp +++ b/code/nel/src/gui/group_menu.cpp @@ -2561,6 +2561,12 @@ namespace NLGUI } } + // ------------------------------------------------------------------------------------------------ + void CGroupMenu::setFontSize(uint fontSize) + { + _FontSize = fontSize; + } + // ------------------------------------------------------------------------------------------------ uint CGroupMenu::getNumLine() const { From dafd8cf7f7beceab7cce63a389c40b4d4fe1ab60 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Fri, 15 Mar 2019 15:41:02 +0200 Subject: [PATCH 5/7] Changed: Add font inherit style rule --HG-- branch : develop --- code/nel/src/gui/group_html.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index d36747a8d..783861f45 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -6381,6 +6381,17 @@ namespace NLGUI // first pass: get font-size for 'em' sizes for (it=styles.begin(); it != styles.end(); ++it) { + if (it->first == "font") + { + if (it->second == "inherit") + { + style.FontSize = current.FontSize; + style.FontFamily = current.FontFamily; + style.FontWeight = current.FontWeight; + style.FontOblique = current.FontOblique; + } + } + else if (it->first == "font-size") { if (it->second == "inherit") From 24767a86dfc26ed4e55e3b7f2cf4f91a58c7508e Mon Sep 17 00:00:00 2001 From: Nimetu Date: Fri, 15 Mar 2019 15:41:02 +0200 Subject: [PATCH 6/7] Fixed: CSS inherit rules --HG-- branch : develop --- code/nel/include/nel/gui/group_html.h | 2 +- code/nel/src/gui/group_html.cpp | 73 +++++++++++++-------------- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 71d7b9ff0..20584b04e 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -796,7 +796,7 @@ namespace NLGUI static TGroupHtmlByUIDMap _GroupHtmlByUID; // read style attribute - void getStyleParams(const std::string &styleString, CStyleParams &style, bool inherit = true); + void getStyleParams(const std::string &styleString, CStyleParams &style, const CStyleParams ¤t); void applyCssMinMax(sint32 &width, sint32 &height, sint32 minw=0, sint32 minh=0, sint32 maxw=0, sint32 maxh=0); // load and render local html file (from bnp for example) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 783861f45..2b4786a79 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -1545,7 +1545,7 @@ namespace NLGUI { case HTML_HTML: if (present[MY_HTML_HTML_STYLE] && value[MY_HTML_HTML_STYLE]) - getStyleParams(value[MY_HTML_HTML_STYLE], _StyleDefault); + getStyleParams(value[MY_HTML_HTML_STYLE], _StyleDefault, _StyleDefault); _Style = _StyleDefault; setBackgroundColor(_Style.BackgroundColor); @@ -1616,7 +1616,7 @@ namespace NLGUI _Style.Height = -1; if (present[HTML_A_STYLE] && value[HTML_A_STYLE]) - getStyleParams(value[HTML_A_STYLE], _Style); + getStyleParams(value[HTML_A_STYLE], _Style, _StyleParams.back()); _A.push_back(true); _Link.push_back (""); @@ -1669,7 +1669,7 @@ namespace NLGUI style = value[MY_HTML_DIV_STYLE]; if (!style.empty()) - getStyleParams(style, _Style); + getStyleParams(style, _Style, _StyleParams.back()); // use generic template system if (_TrustedDomain && !instClass.empty() && instClass == "ryzom-ui-grouptemplate") @@ -1780,7 +1780,7 @@ namespace NLGUI style = value[HTML_BODY_STYLE]; if (!style.empty()) - getStyleParams(style, _Style); + getStyleParams(style, _Style, _StyleParams.back()); CRGBA bgColor = _Style.BackgroundColor; if (present[HTML_BODY_BGCOLOR] && value[HTML_BODY_BGCOLOR]) @@ -1841,7 +1841,7 @@ namespace NLGUI _Style.TextColor = H1Color; _Style.GlobalColor = H1ColorGlobalColor; if (present[MY_HTML_H1_STYLE] && value[MY_HTML_H1_STYLE]) - getStyleParams(value[MY_HTML_H1_STYLE], _Style); + getStyleParams(value[MY_HTML_H1_STYLE], _Style, _StyleParams.back()); } break; case HTML_H2: @@ -1853,7 +1853,7 @@ namespace NLGUI _Style.TextColor = H2Color; _Style.GlobalColor = H2ColorGlobalColor; if (present[MY_HTML_H2_STYLE] && value[MY_HTML_H2_STYLE]) - getStyleParams(value[MY_HTML_H2_STYLE], _Style); + getStyleParams(value[MY_HTML_H2_STYLE], _Style, _StyleParams.back()); } break; case HTML_H3: @@ -1865,7 +1865,7 @@ namespace NLGUI _Style.TextColor = H3Color; _Style.GlobalColor = H3ColorGlobalColor; if (present[MY_HTML_H3_STYLE] && value[MY_HTML_H3_STYLE]) - getStyleParams(value[MY_HTML_H3_STYLE], _Style); + getStyleParams(value[MY_HTML_H3_STYLE], _Style, _StyleParams.back()); } break; case HTML_H4: @@ -1877,7 +1877,7 @@ namespace NLGUI _Style.TextColor = H4Color; _Style.GlobalColor = H4ColorGlobalColor; if (present[MY_HTML_H4_STYLE] && value[MY_HTML_H4_STYLE]) - getStyleParams(value[MY_HTML_H4_STYLE], _Style); + getStyleParams(value[MY_HTML_H4_STYLE], _Style, _StyleParams.back()); } break; case HTML_H5: @@ -1889,7 +1889,7 @@ namespace NLGUI _Style.TextColor = H5Color; _Style.GlobalColor = H5ColorGlobalColor; if (present[MY_HTML_H5_STYLE] && value[MY_HTML_H5_STYLE]) - getStyleParams(value[MY_HTML_H5_STYLE], _Style); + getStyleParams(value[MY_HTML_H5_STYLE], _Style, _StyleParams.back()); } break; case HTML_H6: @@ -1901,7 +1901,7 @@ namespace NLGUI _Style.TextColor = H6Color; _Style.GlobalColor = H6ColorGlobalColor; if (present[MY_HTML_H6_STYLE] && value[MY_HTML_H6_STYLE]) - getStyleParams(value[MY_HTML_H6_STYLE], _Style); + getStyleParams(value[MY_HTML_H6_STYLE], _Style, _StyleParams.back()); } break; case HTML_IMG: @@ -1928,7 +1928,7 @@ namespace NLGUI // width, height from inline css if (present[MY_HTML_IMG_STYLE] && value[MY_HTML_IMG_STYLE]) - getStyleParams(value[MY_HTML_IMG_STYLE], style); + getStyleParams(value[MY_HTML_IMG_STYLE], style, _Style); // Tooltip const char *tooltip = NULL; @@ -2032,7 +2032,7 @@ namespace NLGUI tooltip = value[MY_HTML_INPUT_ALT]; if (present[MY_HTML_INPUT_STYLE] && value[MY_HTML_INPUT_STYLE]) - getStyleParams(value[MY_HTML_INPUT_STYLE], _Style); + getStyleParams(value[MY_HTML_INPUT_STYLE], _Style, _StyleParams.back()); string type = toLower(value[MY_HTML_INPUT_TYPE]); if (type == "image") @@ -2258,7 +2258,6 @@ namespace NLGUI if (!(_Forms.empty())) { CStyleParams style; - style.FontSize = _Style.FontSize; // A select box string name; @@ -2272,7 +2271,7 @@ namespace NLGUI if (present[HTML_SELECT_MULTIPLE] && value[HTML_SELECT_MULTIPLE]) multiple = true; if (present[HTML_SELECT_STYLE] && value[HTML_SELECT_STYLE]) - getStyleParams(value[HTML_SELECT_STYLE], style); + getStyleParams(value[HTML_SELECT_STYLE], style, _Style); CGroupHTML::CForm::CEntry entry; entry.Name = name; @@ -2356,7 +2355,7 @@ namespace NLGUI pushStyle(); if (present[HTML_LI_STYLE] && value[HTML_LI_STYLE]) - getStyleParams(value[HTML_LI_STYLE], _Style); + getStyleParams(value[HTML_LI_STYLE], _Style, _StyleParams.back()); ucstring str; str.fromUtf8(_UL.back().getListMarkerText()); @@ -2379,7 +2378,7 @@ namespace NLGUI newParagraph(PBeginSpace); pushStyle(); if (present[MY_HTML_P_STYLE] && value[MY_HTML_P_STYLE]) - getStyleParams(value[MY_HTML_P_STYLE], _Style); + getStyleParams(value[MY_HTML_P_STYLE], _Style, _StyleParams.back()); } break; case HTML_PRE: @@ -2388,7 +2387,7 @@ namespace NLGUI _Style.FontFamily = "monospace"; if (present[HTML_PRE_STYLE] && value[HTML_PRE_STYLE]) - getStyleParams(value[HTML_PRE_STYLE], _Style); + getStyleParams(value[HTML_PRE_STYLE], _Style, _StyleParams.back()); _PRE.push_back(true); @@ -2416,7 +2415,7 @@ namespace NLGUI if (present[MY_HTML_TABLE_CELLPADDING] && value[MY_HTML_TABLE_CELLPADDING]) fromString(value[MY_HTML_TABLE_CELLPADDING], table->CellPadding); if (present[MY_HTML_TABLE_STYLE] && value[MY_HTML_TABLE_STYLE]) - getStyleParams(value[MY_HTML_TABLE_STYLE], _Style); + getStyleParams(value[MY_HTML_TABLE_STYLE], _Style, _StyleParams.back()); table->setMarginLeft(getIndent()); addHtmlGroup (table, 0); @@ -2446,7 +2445,7 @@ namespace NLGUI } if (present[MY_HTML_TD_STYLE] && value[MY_HTML_TD_STYLE]) - getStyleParams(value[MY_HTML_TD_STYLE], _Style); + getStyleParams(value[MY_HTML_TD_STYLE], _Style, _StyleParams.back()); CGroupTable *table = getTable(); if (table) @@ -2541,7 +2540,7 @@ namespace NLGUI _Style.BackgroundColor.A = 0; if (present[MY_HTML_TEXTAREA_STYLE] && value[MY_HTML_TEXTAREA_STYLE]) - getStyleParams(value[MY_HTML_TEXTAREA_STYLE], _Style); + getStyleParams(value[MY_HTML_TEXTAREA_STYLE], _Style, _StyleParams.back()); // Got one form ? if (!(_Forms.empty())) @@ -2597,7 +2596,7 @@ namespace NLGUI pushStyle(); if (present[MY_HTML_TR_STYLE] && value[MY_HTML_TR_STYLE]) - getStyleParams(value[MY_HTML_TR_STYLE], _Style); + getStyleParams(value[MY_HTML_TR_STYLE], _Style, _StyleParams.back()); } break; case HTML_UL: @@ -2614,7 +2613,7 @@ namespace NLGUI pushStyle(); if (present[HTML_UL_STYLE] && value[HTML_UL_STYLE]) - getStyleParams(value[HTML_UL_STYLE], _Style); + getStyleParams(value[HTML_UL_STYLE], _Style, _StyleParams.back()); break; case HTML_OBJECT: _ObjectType.clear(); @@ -2637,7 +2636,7 @@ namespace NLGUI pushStyle(); if (present[MY_HTML_SPAN_STYLE] && value[MY_HTML_SPAN_STYLE]) - getStyleParams(value[MY_HTML_SPAN_STYLE], _Style); + getStyleParams(value[MY_HTML_SPAN_STYLE], _Style, _StyleParams.back()); } break; case HTML_DEL: @@ -2681,7 +2680,7 @@ namespace NLGUI endParagraph(); pushStyle(); if (present[HTML_GEN_STYLE] && value[HTML_GEN_STYLE]) - getStyleParams(value[HTML_GEN_STYLE], _Style); + getStyleParams(value[HTML_GEN_STYLE], _Style, _StyleParams.back()); } break; case HTML_DT: @@ -2704,7 +2703,7 @@ namespace NLGUI pushStyle(); _Style.FontWeight = FONT_WEIGHT_BOLD; if (present[HTML_GEN_STYLE] && value[HTML_GEN_STYLE]) - getStyleParams(value[HTML_GEN_STYLE], _Style); + getStyleParams(value[HTML_GEN_STYLE], _Style, _StyleParams.back()); if (!_LI) { @@ -2739,7 +2738,7 @@ namespace NLGUI pushStyle(); if (present[HTML_GEN_STYLE] && value[HTML_GEN_STYLE]) - getStyleParams(value[HTML_GEN_STYLE], _Style); + getStyleParams(value[HTML_GEN_STYLE], _Style, _StyleParams.back()); if (!_LI) { @@ -2763,7 +2762,7 @@ namespace NLGUI if (present[HTML_OL_TYPE] && value[HTML_OL_TYPE]) type = value[HTML_OL_TYPE]; if (present[HTML_OL_STYLE] && value[HTML_OL_STYLE]) - getStyleParams(value[HTML_OL_STYLE], _Style); + getStyleParams(value[HTML_OL_STYLE], _Style, _StyleParams.back()); _UL.push_back(HTMLOListElement(start, type)); // if LI is already present @@ -2786,7 +2785,7 @@ namespace NLGUI style.Width = 0; if (present[HTML_HR_STYLE] && value[HTML_HR_STYLE]) - getStyleParams(value[HTML_HR_STYLE], style); + getStyleParams(value[HTML_HR_STYLE], style, _Style); CViewBitmap *bitmap = dynamic_cast(sep->getView("hr")); if (bitmap) @@ -6364,16 +6363,8 @@ namespace NLGUI // style.TextColor; // color: #ABCDEF; // style.Underlined; // text-decoration: underline; text-decoration-line: underline; // style.StrikeThrough; // text-decoration: line-through; text-decoration-line: line-through; - void CGroupHTML::getStyleParams(const std::string &styleString, CStyleParams &style, bool inherit) + void CGroupHTML::getStyleParams(const std::string &styleString, CStyleParams &style, const CStyleParams ¤t) { - const CStyleParams current = _Style; - - if (inherit) - { - style.Underlined = current.Underlined; - style.StrikeThrough = current.StrikeThrough; - } - float tmpf; TStyle styles = parseStyle(styleString); TStyle::iterator it; @@ -6698,6 +6689,14 @@ namespace NLGUI scanHTMLColor(it->second.c_str(), style.BackgroundColorOver); } } + + // if outer element has underline set, then inner element cannot remove it + if (current.Underlined) + style.Underlined = current.Underlined; + + // if outer element has line-through set, then inner element cannot remove it + if (current.StrikeThrough) + style.StrikeThrough = current.StrikeThrough; } // *************************************************************************** From eee4684b0c7db1beb204eb50abce27d5412763a7 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Fri, 15 Mar 2019 15:41:02 +0200 Subject: [PATCH 7/7] Fixed: Invalid window mode switch in some cases. --HG-- branch : develop --- code/ryzom/client/src/init.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index b653127f4..d80cfda00 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -1096,23 +1096,21 @@ void prelogInit() UDriver::CMode mode; - bool forceWindowed1024x768 = true; - if (Driver->getCurrentScreenMode(mode)) { - // if screen mode lower than 1024x768, use same mode in fullscreen - if (mode.Width <= 1024 && mode.Height <= 768) + // use current mode if its smaller than 1024x768 + // mode should be windowed already, but incase its not, use the mode as is + if (mode.Windowed && (mode.Width > 1024 && mode.Height > 768)) { - mode.Windowed = false; - forceWindowed1024x768 = false; + mode.Width = 1024; + mode.Height = 768; } } - - if (forceWindowed1024x768) + else { - mode.Width = 1024; - mode.Height = 768; - mode.Windowed = true; + mode.Width = 1024; + mode.Height = 768; + mode.Windowed = true; } // Disable Hardware Vertex Program.