summaryrefslogtreecommitdiff
path: root/mm/2s2h/DeveloperTools/MessageViewer.h
blob: 5e271040c8b45653664f49facb554e27ffccc0a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once

#include "z64.h"

#ifdef __cplusplus
#include <ship/window/gui/GuiWindow.h>
#include <unordered_map>

extern "C" {
#endif

/**
 * \brief Displays a vanilla message in a text box on screen.
 * \param tableId Unused (reserved for future use)
 * \param textId The textId corresponding to the message to display
 * \param language Unused (reserved for future use)
 */
void MessageDebug_StartTextBox(const char* tableId, uint16_t textId, uint8_t language);

/**
 * \brief Displays a custom message using Custom Message Syntax.
 * \param customMessage A string using Custom Message Syntax.
 */
void MessageDebug_DisplayCustomMessage(const char* customMessage);

#ifdef __cplusplus
}

class MessageViewerWindow : public Ship::GuiWindow {
  public:
    using GuiWindow::GuiWindow;

    void InitElement() override;
    void DrawElement() override;
    void UpdateElement() override;

    ~MessageViewerWindow() override;

  private:
    void DisplayExistingMessage() const;
    void DisplayCustomMessage() const;
    void LoadMessageToEditor();
    bool ParseTextIdFromBuffer(uint16_t& outTextId);

    static constexpr uint16_t MAX_STRING_SIZE = 1024;
    static constexpr int HEXADECIMAL = 0;
    static constexpr int DECIMAL = 1;

    char* mTextIdBuf;
    uint16_t mTextId;
    int mTextIdBase = HEXADECIMAL;
    char* mCustomMessageBuf;
    std::string mCustomMessageString;
    bool mDisplayExistingMessageClicked = false;
    bool mDisplayCustomMessageClicked = false;
    bool mLoadMessageClicked = false;
};

#endif // __cplusplus