From 3256a3ec461cde4a5e2f8a5b038f346570bc3197 Mon Sep 17 00:00:00 2001 From: Gaerzi Date: Sun, 5 Mar 2017 20:42:36 +0100 Subject: [PATCH] Add support for colourise/tint translation like SLADE 3's. --- parse.c | 18 +++++++++++++++++- pcode.h | 2 ++ token.c | 3 +++ token.h | 1 + 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/parse.c b/parse.c index e59304e..9a0c046 100644 --- a/parse.c +++ b/parse.c @@ -2526,10 +2526,12 @@ static void LeadingHudMessage(void) // arglist: arg | arglist arg // arg: range = replacement // range: exp : exp -// replacement: palrep | colorrep +// replacement: palrep | colorrep | desatrep | colouriserep | tintrep // palrep: exp : exp // colorrep: [exp,exp,exp]:[exp,exp,exp] // desatrep: %colorrep +// colouriserep: #[exp,exp,exp] +// tintrep: @exp[exp,exp,exp] //========================================================================== static void LeadingCreateTranslation(void) @@ -2556,6 +2558,18 @@ static void LeadingCreateTranslation(void) translationcode = PCD_TRANSLATIONRANGE3; TK_NextTokenMustBe(TK_LBRACKET, ERR_MISSING_LBRACKET); } + else if (tk_Token == TK_NUMBERSIGN) + { + translationcode = PCD_TRANSLATIONRANGE4; + TK_NextTokenMustBe(TK_LBRACKET, ERR_MISSING_LBRACKET); + } + else if (tk_Token == TK_ATSIGN) + { + translationcode = PCD_TRANSLATIONRANGE5; + TK_NextToken(); + EvalExpression(); + TK_TokenMustBe(TK_LBRACKET, ERR_MISSING_LBRACKET); + } else { translationcode = PCD_TRANSLATIONRANGE2; @@ -2581,6 +2595,8 @@ static void LeadingCreateTranslation(void) } TK_NextToken(); } + if (translationcode == PCD_TRANSLATIONRANGE4 || translationcode == PCD_TRANSLATIONRANGE5) + break; if(j == 2) { TK_TokenMustBe(TK_COLON, ERR_MISSING_COLON); diff --git a/pcode.h b/pcode.h index 5cceb6c..8c10ec3 100644 --- a/pcode.h +++ b/pcode.h @@ -448,6 +448,8 @@ typedef enum PCD_STRCPYTOSCRIPTCHRANGE, PCD_LSPEC5EX, PCD_LSPEC5EXRESULT, + PCD_TRANSLATIONRANGE4, + PCD_TRANSLATIONRANGE5, PCODE_COMMAND_COUNT } pcd_t; diff --git a/token.c b/token.c index 0e5cd1e..3b43366 100644 --- a/token.c +++ b/token.c @@ -1342,6 +1342,9 @@ static void ProcessSpecialToken(void) case '#': tk_Token = TK_NUMBERSIGN; break; + case '@': + tk_Token = TK_ATSIGN; + break; case '^': if(Chr == '=') { diff --git a/token.h b/token.h index 617e066..c3cb20f 100644 --- a/token.h +++ b/token.h @@ -136,6 +136,7 @@ typedef enum TK_ENDREGION, // 'endregion' [mxd] TK_KILL, // 'kill' [JM] TK_REOPEN, // 'reopen' [Nash] + TK_ATSIGN, // '@' } tokenType_t; // PUBLIC FUNCTION PROTOTYPES ----------------------------------------------