summaryrefslogtreecommitdiffstats
path: root/src/CompositeChat.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/CompositeChat.h')
-rw-r--r--src/CompositeChat.h119
1 files changed, 25 insertions, 94 deletions
diff --git a/src/CompositeChat.h b/src/CompositeChat.h
index b52b76bc5..78c8e0c9b 100644
--- a/src/CompositeChat.h
+++ b/src/CompositeChat.h
@@ -34,126 +34,68 @@ class cCompositeChat
public:
// tolua_end
- enum ePartType
- {
- ptText,
- ptClientTranslated,
- ptUrl,
- ptRunCommand,
- ptSuggestCommand,
- ptShowAchievement,
- } ;
-
-
- class cBasePart
+ struct BasePart
{
- public:
- ePartType m_PartType;
- AString m_Text;
- AString m_Style;
- AString m_AdditionalStyleData;
-
- cBasePart(ePartType a_PartType, const AString & a_Text, const AString & a_Style = "");
-
- // Force a virtual destructor in descendants
- virtual ~cBasePart() {}
+ AString Text;
+ AString Style;
+ AString AdditionalStyleData;
} ;
- class cTextPart:
- public cBasePart
+ struct TextPart:
+ public BasePart
{
- using Super = cBasePart;
-
- public:
-
- cTextPart(const AString & a_Text, const AString & a_Style = "");
} ;
- class cClientTranslatedPart:
- public cBasePart
+ struct ClientTranslatedPart:
+ public BasePart
{
- using Super = cBasePart;
-
- public:
-
- AStringVector m_Parameters;
-
- cClientTranslatedPart(const AString & a_TranslationID, const AStringVector & a_Parameters, const AString & a_Style = "");
+ AStringVector Parameters;
} ;
- class cUrlPart:
- public cBasePart
+ struct UrlPart:
+ public BasePart
{
- using Super = cBasePart;
-
- public:
-
- AString m_Url;
-
- cUrlPart(const AString & a_Text, const AString & a_Url, const AString & a_Style = "");
+ AString Url;
} ;
- class cCommandPart:
- public cBasePart
+ struct CommandPart:
+ public BasePart
{
- using Super = cBasePart;
-
- public:
-
- AString m_Command;
-
- cCommandPart(ePartType a_PartType, const AString & a_Text, const AString & a_Command, const AString & a_Style = "");
+ AString Command;
} ;
- class cRunCommandPart:
- public cCommandPart
+ struct RunCommandPart:
+ public CommandPart
{
- using Super = cCommandPart;
-
- public:
-
- cRunCommandPart(const AString & a_Text, const AString & a_Command, const AString & a_Style = "");
} ;
- class cSuggestCommandPart:
- public cCommandPart
+ struct SuggestCommandPart:
+ public CommandPart
{
- using Super = cCommandPart;
-
- public:
-
- cSuggestCommandPart(const AString & a_Text, const AString & a_Command, const AString & a_Style = "");
} ;
- class cShowAchievementPart:
- public cBasePart
+ struct ShowAchievementPart:
+ public BasePart
{
- using Super = cBasePart;
-
- public:
-
- AString m_PlayerName;
- cShowAchievementPart(const AString & a_PlayerName, const AString & a_Achievement, const AString & a_Style = "");
+ AString PlayerName;
} ;
- /** the parts have to be allocated with new else the part specific parts are not saved (only the cBasePart members). */
- using cParts = std::vector<std::unique_ptr<cBasePart>>;
/** Creates a new empty chat message.
Exported manually due to the other overload needing a manual export. */
@@ -165,14 +107,6 @@ public:
Exported manually due to ToLua++ generating extra output parameter. */
cCompositeChat(const AString & a_ParseText, eMessageType a_MessageType = mtCustom);
- cCompositeChat(cCompositeChat && a_Other) = default;
-
- /** Copy constructor is explicitly deleted because m_Parts is not copyable. */
- cCompositeChat(cCompositeChat & a_Other) = delete;
- cCompositeChat(const cCompositeChat & a_Other) = delete;
-
- ~cCompositeChat(); // tolua_export
-
// The following are exported in ManualBindings in order to support chaining - they return "self" in Lua (#755)
/** Removes all parts from the object. */
@@ -231,7 +165,7 @@ public:
// tolua_end
- const cParts & GetParts(void) const { return m_Parts; }
+ const auto & GetParts(void) const { return m_Parts; }
/** Converts the MessageType to a LogLevel value.
Used by the logging bindings when logging a cCompositeChat object. */
@@ -241,8 +175,9 @@ public:
void AddChatPartStyle(Json::Value & a_Value, const AString & a_PartStyle) const;
protected:
+
/** All the parts that */
- cParts m_Parts;
+ std::vector<std::variant<TextPart, ClientTranslatedPart, UrlPart, RunCommandPart, SuggestCommandPart, ShowAchievementPart>> m_Parts;
/** The message type, as indicated by prefixes. */
eMessageType m_MessageType;
@@ -255,7 +190,3 @@ protected:
If the style already contains something that a_AddStyle overrides, it is erased first. */
void AddStyle(AString & a_Style, const AString & a_AddStyle);
} ; // tolua_export
-
-
-
-