Skip to content

Commit ee398ee

Browse files
committed
msg_preprocessor: make sure code is compatible to TheXTech
1 parent da811f3 commit ee398ee

File tree

6 files changed

+31
-7
lines changed

6 files changed

+31
-7
lines changed

_common/qt-modules/msg_box_preview/msg_box_preview.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ set(MSG_BOX_PREVIEW_SRC
44
${CMAKE_CURRENT_LIST_DIR}/msg_box_preview.cpp
55
${CMAKE_CURRENT_LIST_DIR}/msg_box_preview.h
66

7-
${CMAKE_CURRENT_LIST_DIR}/msg_macros.cpp
8-
${CMAKE_CURRENT_LIST_DIR}/msg_macros.h
7+
${CMAKE_CURRENT_LIST_DIR}/msg_preprocessor.cpp
8+
${CMAKE_CURRENT_LIST_DIR}/msg_preprocessor.h
99
)

_common/qt-modules/msg_box_preview/msg_box_preview.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <QStack>
66

77
#include "msg_box_preview.h"
8-
#include "msg_macros.h"
8+
#include "msg_preprocessor.h"
99

1010

1111
QString MsgBoxPreview::runPreProcessor()

_common/qt-modules/msg_box_preview/msg_macros.cpp renamed to _common/qt-modules/msg_box_preview/msg_preprocessor.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <cstring>
2121
#include <string>
2222
#include <vector>
23-
#include "msg_macros.h"
23+
#include "msg_preprocessor.h"
2424

2525
#ifndef MOONDUST_UNIT_TEST
2626
static
@@ -287,6 +287,7 @@ static CondLineTail replace_newline(CondCmd cmd)
287287
}
288288
}
289289

290+
290291
void msgMacroProcess(const std::string &in, std::string &ret, int macro_player, int macro_state)
291292
{
292293
struct State
@@ -414,3 +415,11 @@ void msgMacroProcess(const std::string &in, std::string &ret, int macro_player,
414415
}
415416
} while(end < in.size() - 1);
416417
}
418+
419+
420+
void preProcessMessage(std::string &text, int macro_player, int macro_state)
421+
{
422+
std::string ret;
423+
msgMacroProcess(text, ret, macro_player, macro_state);
424+
text = ret;
425+
}

_common/qt-modules/msg_box_preview/msg_macros.h renamed to _common/qt-modules/msg_box_preview/msg_preprocessor.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@
3030
extern bool msgMacroParseTokens(const std::string &line, std::vector<std::string> &tokens);
3131
#endif
3232

33+
/**
34+
* @brief Pre-Process the message (apply conditions, or place player names where is possible)
35+
* @param in Input text to pre-process
36+
* @param out Output of the result
37+
* @param macro_player The player number who triggered this message box, or -1 to heuristically detect somebody.
38+
* @param macro_state The player's state number that is set or -1 to heuristically detect something.
39+
*/
3340
extern void msgMacroProcess(const std::string &in, std::string &out, int macro_player, int macro_state);
3441

42+
/**
43+
* @brief Pre-Process the message (apply conditions, or place player names where is possible)
44+
* @param text Input-Output text to pre-process
45+
* @param playerWho The player number who triggered this message box, or -1 to heuristically detect somebody.
46+
* @param stateWhich The player's state number that is set or -1 to heuristically detect something.
47+
*/
48+
extern void preProcessMessage(std::string &text, int macro_player, int macro_state);
49+
3550
#endif // MSGMACROS_H

test/Editor/msg_macros/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <QtDebug>
33
#include <QVector>
44

5-
#include "msg_macros.h"
5+
#include "msg_preprocessor.h"
66

77
void testTokensList(const std::string &line)
88
{

test/Editor/msg_macros/msg_macros.pro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ DEFINES += MOONDUST_UNIT_TEST
1111
INCLUDEPATH += ../../../_common/qt-modules/msg_box_preview/
1212

1313
HEADERS += \
14-
../../../_common/qt-modules/msg_box_preview/msg_macros.h
14+
../../../_common/qt-modules/msg_box_preview/msg_preprocessor.h
1515

1616
SOURCES += \
1717
main.cpp \
18-
../../../_common/qt-modules/msg_box_preview/msg_macros.cpp
18+
../../../_common/qt-modules/msg_box_preview/msg_preprocessor.cpp

0 commit comments

Comments
 (0)