2021-03-27 12:38:34 +01:00
|
|
|
/* Copyright (C) 2021 Wildfire Games.
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDED_GUITEXT
|
|
|
|
#define INCLUDED_GUITEXT
|
|
|
|
|
|
|
|
#include "gui/CGUISprite.h"
|
2019-10-02 11:44:00 +02:00
|
|
|
#include "gui/SettingTypes/CGUIColor.h"
|
|
|
|
#include "gui/SettingTypes/EAlign.h"
|
2021-03-30 23:14:36 +02:00
|
|
|
#include "maths/Rect.h"
|
2021-03-27 17:08:06 +01:00
|
|
|
#include "maths/Size2D.h"
|
2021-03-28 23:55:13 +02:00
|
|
|
#include "maths/Vector2D.h"
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
#include "ps/CStrIntern.h"
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <list>
|
|
|
|
#include <vector>
|
|
|
|
|
2019-08-29 11:07:29 +02:00
|
|
|
class CGUI;
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
class CGUIString;
|
2019-10-01 14:46:55 +02:00
|
|
|
class IGUIObject;
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
struct SGenerateTextImage;
|
2019-10-01 14:46:55 +02:00
|
|
|
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
using SGenerateTextImages = std::array<std::vector<SGenerateTextImage>, 2>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An CGUIText object is a parsed string, divided into
|
|
|
|
* text-rendering components. Each component, being a
|
|
|
|
* call to the Renderer. For instance, if you by tags
|
|
|
|
* change the color, then the GUI will have to make
|
|
|
|
* individual calls saying it want that color on the
|
|
|
|
* text.
|
|
|
|
*
|
|
|
|
* For instance:
|
|
|
|
* "Hello [b]there[/b] bunny!"
|
|
|
|
*
|
|
|
|
* That without word-wrapping would mean 3 components.
|
|
|
|
* i.e. 3 calls to CRenderer. One drawing "Hello",
|
|
|
|
* one drawing "there" in bold, and one drawing "bunny!".
|
|
|
|
*/
|
|
|
|
class CGUIText
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* A sprite call to the CRenderer
|
|
|
|
*/
|
|
|
|
struct SSpriteCall
|
|
|
|
{
|
|
|
|
// The CGUISpriteInstance makes this uncopyable to avoid invalidating its draw cache
|
|
|
|
NONCOPYABLE(SSpriteCall);
|
|
|
|
MOVABLE(SSpriteCall);
|
|
|
|
|
2021-03-27 12:38:34 +01:00
|
|
|
SSpriteCall() {}
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Size and position of sprite
|
|
|
|
*/
|
|
|
|
CRect m_Area;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sprite from global GUI sprite database.
|
|
|
|
*/
|
|
|
|
CGUISpriteInstance m_Sprite;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tooltip text
|
|
|
|
*/
|
|
|
|
CStrW m_Tooltip;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tooltip style
|
|
|
|
*/
|
|
|
|
CStrW m_TooltipStyle;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A text call to the CRenderer
|
|
|
|
*/
|
|
|
|
struct STextCall
|
|
|
|
{
|
|
|
|
NONCOPYABLE(STextCall);
|
|
|
|
MOVABLE(STextCall);
|
|
|
|
|
|
|
|
STextCall() :
|
|
|
|
m_UseCustomColor(false),
|
|
|
|
m_Bold(false), m_Italic(false), m_Underlined(false),
|
2019-09-23 01:28:25 +02:00
|
|
|
m_pSpriteCall(nullptr) {}
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Position
|
|
|
|
*/
|
2021-03-28 23:55:13 +02:00
|
|
|
CVector2D m_Pos;
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Size
|
|
|
|
*/
|
2021-03-27 17:08:06 +01:00
|
|
|
CSize2D m_Size;
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The string that is suppose to be rendered.
|
|
|
|
*/
|
|
|
|
CStrW m_String;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Use custom color? If true then m_Color is used,
|
|
|
|
* else the color inputted will be used.
|
|
|
|
*/
|
|
|
|
bool m_UseCustomColor;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Color setup
|
|
|
|
*/
|
|
|
|
CGUIColor m_Color;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Font name
|
|
|
|
*/
|
|
|
|
CStrIntern m_Font;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Settings
|
|
|
|
*/
|
|
|
|
bool m_Bold, m_Italic, m_Underlined;
|
|
|
|
|
|
|
|
/**
|
2019-09-23 01:28:25 +02:00
|
|
|
* *IF* an icon, then this is not nullptr.
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
*/
|
|
|
|
std::list<SSpriteCall>::pointer m_pSpriteCall;
|
|
|
|
};
|
|
|
|
|
|
|
|
// The SSpriteCall CGUISpriteInstance makes this uncopyable to avoid invalidating its draw cache.
|
|
|
|
// Also take advantage of exchanging the containers directly with move semantics.
|
|
|
|
NONCOPYABLE(CGUIText);
|
|
|
|
MOVABLE(CGUIText);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates empty text.
|
|
|
|
*/
|
|
|
|
CGUIText() = default;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a CGUIText object from the inputted string.
|
|
|
|
* The function will break down the string and its
|
|
|
|
* tags to calculate exactly which rendering queries
|
|
|
|
* will be sent to the Renderer. Also, horizontal alignment
|
|
|
|
* is taken into acount in this method but NOT vertical alignment.
|
|
|
|
*
|
|
|
|
* @param Text Text to generate CGUIText object from
|
|
|
|
* @param Font Default font, notice both Default color and default font
|
|
|
|
* can be changed by tags.
|
|
|
|
* @param Width Width, 0 if no word-wrapping.
|
|
|
|
* @param BufferZone space between text and edge, and space between text and images.
|
|
|
|
* @param pObject Optional parameter for error output. Used *only* if error parsing fails,
|
|
|
|
* and we need to be able to output which object the error occurred in to aid the user.
|
|
|
|
*/
|
2019-09-28 13:46:06 +02:00
|
|
|
CGUIText(const CGUI& pGUI, const CGUIString& string, const CStrW& FontW, const float Width, const float BufferZone, const IGUIObject* pObject);
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw this CGUIText object
|
|
|
|
*/
|
2021-03-28 23:55:13 +02:00
|
|
|
void Draw(CGUI& pGUI, const CGUIColor& DefaultColor, const CVector2D& pos, const float z, const CRect& clipping) const;
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
|
2021-03-27 17:08:06 +01:00
|
|
|
const CSize2D& GetSize() const { return m_Size; }
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
|
|
|
|
const std::list<SSpriteCall>& GetSpriteCalls() const { return m_SpriteCalls; }
|
|
|
|
|
|
|
|
const std::vector<STextCall>& GetTextCalls() const { return m_TextCalls; }
|
|
|
|
|
|
|
|
// Helper functions of the constructor
|
|
|
|
bool ProcessLine(
|
2019-08-21 12:12:33 +02:00
|
|
|
const CGUI& pGUI,
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
const CGUIString& string,
|
|
|
|
const CStrIntern& Font,
|
|
|
|
const IGUIObject* pObject,
|
|
|
|
const SGenerateTextImages& Images,
|
|
|
|
const EAlign align,
|
|
|
|
const float prelim_line_height,
|
|
|
|
const float Width,
|
|
|
|
const float BufferZone,
|
|
|
|
bool& FirstLine,
|
|
|
|
float& x,
|
|
|
|
float& y,
|
|
|
|
int& i,
|
|
|
|
int& from);
|
|
|
|
|
|
|
|
void SetupSpriteCalls(
|
2019-08-21 12:12:33 +02:00
|
|
|
const CGUI& pGUI,
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
const std::array<std::vector<CStr>, 2>& FeedbackImages,
|
|
|
|
const float y,
|
|
|
|
const float Width,
|
|
|
|
const float BufferZone,
|
|
|
|
const int i,
|
|
|
|
const int pos_last_img,
|
|
|
|
SGenerateTextImages& Images);
|
|
|
|
|
|
|
|
float GetLineOffset(
|
|
|
|
const EAlign align,
|
|
|
|
const float width_range_from,
|
|
|
|
const float width_range_to,
|
2021-03-27 17:08:06 +01:00
|
|
|
const CSize2D& line_size) const;
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
|
|
|
|
void ComputeLineRange(
|
|
|
|
const SGenerateTextImages& Images,
|
|
|
|
const float y,
|
|
|
|
const float Width,
|
|
|
|
const float prelim_line_height,
|
|
|
|
float& width_range_from,
|
|
|
|
float& width_range_to) const;
|
|
|
|
|
|
|
|
void ComputeLineSize(
|
2019-08-21 12:12:33 +02:00
|
|
|
const CGUI& pGUI,
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
const CGUIString& string,
|
|
|
|
const CStrIntern& Font,
|
|
|
|
const bool FirstLine,
|
|
|
|
const float Width,
|
|
|
|
const float width_range_to,
|
|
|
|
const int i,
|
|
|
|
const int temp_from,
|
|
|
|
float& x,
|
2021-03-27 17:08:06 +01:00
|
|
|
CSize2D& line_size) const;
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
|
|
|
|
bool AssembleCalls(
|
2019-08-21 12:12:33 +02:00
|
|
|
const CGUI& pGUI,
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
const CGUIString& string,
|
|
|
|
const CStrIntern& Font,
|
|
|
|
const IGUIObject* pObject,
|
|
|
|
const bool FirstLine,
|
|
|
|
const float Width,
|
|
|
|
const float width_range_to,
|
|
|
|
const float dx,
|
|
|
|
const float y,
|
|
|
|
const int temp_from,
|
|
|
|
const int i,
|
|
|
|
float& x,
|
|
|
|
int& from);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List of TextCalls, for instance "Hello", "there!"
|
|
|
|
*/
|
|
|
|
std::vector<STextCall> m_TextCalls;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List of sprites, or "icons" that should be rendered
|
|
|
|
* along with the text.
|
|
|
|
*/
|
|
|
|
std::list<SSpriteCall> m_SpriteCalls; // list for consistent mem addresses
|
|
|
|
// so that we can point to elements.
|
|
|
|
/**
|
|
|
|
* Width and height of the whole output, used when setting up
|
|
|
|
* scrollbars and such.
|
|
|
|
*/
|
2021-03-27 17:08:06 +01:00
|
|
|
CSize2D m_Size;
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SGenerateTextImage
|
|
|
|
{
|
|
|
|
// The image's starting location in Y
|
|
|
|
float m_YFrom;
|
|
|
|
|
|
|
|
// The image's end location in Y
|
|
|
|
float m_YTo;
|
|
|
|
|
|
|
|
// The image width in other words
|
|
|
|
float m_Indentation;
|
|
|
|
|
|
|
|
void SetupSpriteCall(
|
|
|
|
const bool Left, CGUIText::SSpriteCall& SpriteCall, const float width, const float y,
|
2021-03-27 17:08:06 +01:00
|
|
|
const CSize2D& Size, const CStr& TextureName, const float BufferZone);
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDED_GUITEXT
|