mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-13 07:57:58 +00:00
- made DBrokenLines serializable.
This commit is contained in:
parent
23aff98e90
commit
aa69d63a65
2 changed files with 25 additions and 13 deletions
|
@ -45,6 +45,7 @@
|
||||||
|
|
||||||
#include "gstrings.h"
|
#include "gstrings.h"
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
|
#include "serializer.h"
|
||||||
|
|
||||||
int ListGetInt(VMVa_List &tags);
|
int ListGetInt(VMVa_List &tags);
|
||||||
|
|
||||||
|
@ -345,7 +346,7 @@ static void breakit (FBrokenLines *line, FFont *font, const uint8_t *start, cons
|
||||||
line->Width = font->StringWidth (line->Text);
|
line->Width = font->StringWidth (line->Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *string, bool preservecolor, unsigned int *count)
|
TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *string, bool preservecolor)
|
||||||
{
|
{
|
||||||
TArray<FBrokenLines> Lines(128);
|
TArray<FBrokenLines> Lines(128);
|
||||||
|
|
||||||
|
@ -451,28 +452,40 @@ TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str
|
||||||
return Lines;
|
return Lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
void V_FreeBrokenLines (FBrokenLines *lines)
|
FSerializer &Serialize(FSerializer &arc, const char *key, FBrokenLines& g, FBrokenLines *def)
|
||||||
{
|
{
|
||||||
if (lines)
|
if (arc.BeginObject(key))
|
||||||
{
|
{
|
||||||
delete[] lines;
|
arc("text", g.Text)
|
||||||
|
("width", g.Width)
|
||||||
|
.EndObject();
|
||||||
}
|
}
|
||||||
|
return arc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DBrokenLines : public DObject
|
class DBrokenLines : public DObject
|
||||||
{
|
{
|
||||||
DECLARE_ABSTRACT_CLASS(DBrokenLines, DObject)
|
DECLARE_CLASS(DBrokenLines, DObject)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TArray<FBrokenLines> mBroken;
|
TArray<FBrokenLines> mBroken;
|
||||||
|
|
||||||
|
DBrokenLines() = default;
|
||||||
|
|
||||||
DBrokenLines(TArray<FBrokenLines> &broken)
|
DBrokenLines(TArray<FBrokenLines> &broken)
|
||||||
{
|
{
|
||||||
mBroken = std::move(broken);
|
mBroken = std::move(broken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Serialize(FSerializer &arc) override
|
||||||
|
{
|
||||||
|
arc("lines", mBroken);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_CLASS(DBrokenLines, true, false);
|
IMPLEMENT_CLASS(DBrokenLines, false, false);
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(DBrokenLines, Count)
|
DEFINE_ACTION_FUNCTION(DBrokenLines, Count)
|
||||||
{
|
{
|
||||||
|
@ -500,7 +513,6 @@ DEFINE_ACTION_FUNCTION(FFont, BreakLines)
|
||||||
PARAM_STRING(text);
|
PARAM_STRING(text);
|
||||||
PARAM_INT(maxwidth);
|
PARAM_INT(maxwidth);
|
||||||
|
|
||||||
unsigned int count;
|
auto broken = V_BreakLines(self, maxwidth, text, true);
|
||||||
TArray<FBrokenLines> broken = V_BreakLines(self, maxwidth, text, true, &count);
|
|
||||||
ACTION_RETURN_OBJECT(Create<DBrokenLines>(broken));
|
ACTION_RETURN_OBJECT(Create<DBrokenLines>(broken));
|
||||||
}
|
}
|
||||||
|
|
10
src/v_text.h
10
src/v_text.h
|
@ -79,11 +79,11 @@ struct FBrokenLines
|
||||||
#define TEXTCOLOR_CHAT "\034*"
|
#define TEXTCOLOR_CHAT "\034*"
|
||||||
#define TEXTCOLOR_TEAMCHAT "\034!"
|
#define TEXTCOLOR_TEAMCHAT "\034!"
|
||||||
|
|
||||||
TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str, bool preservecolor = false, unsigned int *count = nullptr);
|
TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str, bool preservecolor = false);
|
||||||
inline TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const char *str, bool preservecolor = false, unsigned int *count = nullptr)
|
inline TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const char *str, bool preservecolor = false)
|
||||||
{ return V_BreakLines (font, maxwidth, (const uint8_t *)str, preservecolor, count); }
|
{ return V_BreakLines (font, maxwidth, (const uint8_t *)str, preservecolor); }
|
||||||
inline TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const FString &str, bool preservecolor = false, unsigned int *count = nullptr)
|
inline TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const FString &str, bool preservecolor = false)
|
||||||
{ return V_BreakLines (font, maxwidth, (const uint8_t *)str.GetChars(), preservecolor, count); }
|
{ return V_BreakLines (font, maxwidth, (const uint8_t *)str.GetChars(), preservecolor); }
|
||||||
|
|
||||||
int GetCharFromString(const uint8_t *&string);
|
int GetCharFromString(const uint8_t *&string);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue