2024-02-25 14:46:47 +00:00
|
|
|
#pragma once
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
#include "StarPane.hpp"
|
|
|
|
#include "StarChatTypes.hpp"
|
|
|
|
|
|
|
|
namespace Star {
|
|
|
|
|
|
|
|
STAR_CLASS(UniverseClient);
|
|
|
|
STAR_CLASS(TextBoxWidget);
|
|
|
|
STAR_CLASS(LabelWidget);
|
|
|
|
STAR_CLASS(ButtonWidget);
|
|
|
|
STAR_CLASS(ImageStretchWidget);
|
|
|
|
STAR_CLASS(CanvasWidget);
|
|
|
|
STAR_CLASS(Chat);
|
|
|
|
|
|
|
|
class Chat : public Pane {
|
|
|
|
public:
|
|
|
|
Chat(UniverseClientPtr client);
|
|
|
|
|
|
|
|
void startChat();
|
|
|
|
void startCommand();
|
|
|
|
bool hasFocus() const override;
|
|
|
|
virtual bool sendEvent(InputEvent const& event) override;
|
|
|
|
void stopChat();
|
|
|
|
virtual void renderImpl() override;
|
|
|
|
virtual void hide() override;
|
|
|
|
|
2023-07-20 14:58:49 +00:00
|
|
|
virtual void update(float dt) override;
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
void addLine(String const& text, bool showPane = true);
|
|
|
|
void addMessages(List<ChatReceivedMessage> const& messages, bool showPane = true);
|
|
|
|
void addHistory(String const& chat);
|
2024-04-23 21:44:53 +00:00
|
|
|
void clear(size_t count = std::numeric_limits<size_t>::max());
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
String currentChat() const;
|
2024-04-21 20:07:59 +00:00
|
|
|
bool setCurrentChat(String const& chat, bool moveCursor = false);
|
2023-06-20 04:33:09 +00:00
|
|
|
void clearCurrentChat();
|
|
|
|
|
|
|
|
ChatSendMode sendMode() const;
|
|
|
|
|
|
|
|
void incrementIndex();
|
|
|
|
void decrementIndex();
|
|
|
|
|
|
|
|
float visible() const;
|
|
|
|
|
|
|
|
void scrollUp();
|
|
|
|
void scrollDown();
|
|
|
|
void scrollBottom();
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct LogMessage {
|
|
|
|
MessageContext::Mode mode;
|
|
|
|
String portrait;
|
|
|
|
String text;
|
|
|
|
};
|
|
|
|
|
|
|
|
void updateBottomButton();
|
|
|
|
|
|
|
|
UniverseClientPtr m_client;
|
|
|
|
|
|
|
|
TextBoxWidgetPtr m_textBox;
|
|
|
|
LabelWidgetPtr m_say;
|
|
|
|
ButtonWidgetPtr m_bottomButton;
|
|
|
|
ButtonWidgetPtr m_upButton;
|
|
|
|
Deque<String> m_chatHistory;
|
|
|
|
unsigned m_chatPrevIndex;
|
|
|
|
int64_t m_timeChatLastActive;
|
|
|
|
float m_chatVisTime;
|
|
|
|
float m_fadeRate;
|
2024-04-21 20:07:59 +00:00
|
|
|
TextStyle m_chatTextStyle;
|
2023-06-20 04:33:09 +00:00
|
|
|
unsigned m_chatHistoryLimit;
|
|
|
|
int m_historyOffset;
|
2024-04-23 21:44:53 +00:00
|
|
|
String m_chatFormatString;
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
CanvasWidgetPtr m_chatLog;
|
2023-06-20 14:59:41 +00:00
|
|
|
Vec2I m_chatLogPadding;
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
ImageStretchWidgetPtr m_background;
|
|
|
|
int m_defaultHeight;
|
|
|
|
int m_bodyHeight;
|
|
|
|
int m_expandedBodyHeight;
|
|
|
|
bool m_expanded;
|
|
|
|
|
|
|
|
void updateSize();
|
|
|
|
|
|
|
|
Vec2I m_portraitTextOffset;
|
|
|
|
Vec2I m_portraitImageOffset;
|
|
|
|
float m_portraitScale;
|
|
|
|
int m_portraitVerticalMargin;
|
|
|
|
String m_portraitBackground;
|
|
|
|
|
|
|
|
Map<MessageContext::Mode, String> m_colorCodes;
|
|
|
|
Deque<LogMessage> m_receivedMessages;
|
|
|
|
|
|
|
|
Set<MessageContext::Mode> m_modeFilter;
|
|
|
|
ChatSendMode m_sendMode;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|