48#include <guichan/focushandler.hpp>
49#include <guichan/focuslistener.hpp>
63 addFocusListener(
this);
100 setTitleBarHeight(getPadding() + 4);
114 setPadding(std::min<unsigned>(getPadding(), 6));
155 int tab =
mChatTabs->getSelectedTabIndex();
166 int tab =
mChatTabs->getSelectedTabIndex();
177 if (
event.getId() ==
"chatinput")
181 if (!message.empty())
193 mFocusHandler->focusNone();
252 std::string tempNick = nick;
262 std::map<const std::string, ChatTab *> whispers;
265 for (
auto &[
_, tab] : whispers)
277 std::string response;
284 if (!response.empty())
288 response +=
static_cast<Being*
>(actor)->getName();
293 std::string log =
strprintf(
_(
"Present: %s; %d players are present."),
294 response.c_str(), playercount);
303 std::ostringstream timeStr;
304 timeStr <<
"[" << ((((t / 60) / 60) % 24 < 10) ?
"0" :
"")
305 << (
int) (((t / 60) / 60) % 24)
306 <<
":" << (((t / 60) % 60 < 10) ?
"0" :
"")
307 << (
int) ((t / 60) % 60)
334 if (
event.isConsumed())
341 const int dragHeight =
getFocused()->getHeight() +
342 static_cast<int>(getTitleBarHeight());
344 mMoved =
event.getY() < dragHeight;
345 mDragOffsetX =
event.getX();
346 mDragOffsetY =
event.getY();
354 if (
event.isConsumed())
357 if (isMovable() && mMoved)
359 int newX = std::max(0, getX() +
event.getX() - mDragOffsetX);
360 int newY = std::max(0, getY() +
event.getY() - mDragOffsetY);
363 setPosition(newX, newY);
408 const int caretPos =
mChatInput->getCaretPosition();
409 const std::string inputText =
mChatInput->getText();
411 std::ostringstream ss;
412 ss << inputText.substr(0, caretPos) << text <<
" ";
413 ss << inputText.substr(caretPos);
416 mChatInput->setCaretPosition(caretPos + text.length() + 1);
422 std::ostringstream text;
423 text <<
"[" << item <<
"]";
444 const std::string &mes,
Own own)
450 std::string tempNick = nick;
455 if (tempNick == playerName)
501 std::string tempNick = nick;
ActorSpriteManager * actorSpriteManager
const ActorSprites & getAll() const
Returns the whole list of beings.
const std::string & getName() const
Returns the name of the being.
void setPalette(int palette)
void getAutoCompleteList(std::vector< std::string > &list) const override
A tab for the chat window.
void chatLog(std::string line, Own own=BY_SERVER, bool ignoreRecord=false)
Adds a line of text to our message list.
void scroll(int amount)
Scrolls the chat window.
void getAutoCompleteList(std::vector< std::string > &names) const override
void chatInput(const std::string &msg)
Determines whether the message is a command or message, then sends the given message to the game serv...
void clearText()
Clears the text from the tab.
void whisper(const std::string &nick, const std::string &mes, Own own=BY_OTHER)
void clearTab()
Clear the current tab.
void addItemText(const std::string &item)
Called to add item to chat.
ChatInput * mChatInput
Input box for typing chat messages.
TabbedArea * mChatTabs
Tabbed area for holding each channel.
bool isInputFocused() const
Checks whether ChatWindow is Focused or not.
void setVisible(bool visible) override
Override to reset mTmpVisible.
void setRecordingFile(const std::string &msg)
Sets the file being recorded to.
void removeWhisper(const std::string &nick)
~ChatWindow() override
Destructor: used to write back values to the config file.
void addInputText(const std::string &text)
Add the given text to the chat input.
void mouseDragged(gcn::MouseEvent &event) override
bool requestChatFocus()
Request focus for typing chat message.
void scroll(int amount)
Scrolls the chat window.
ItemLinkHandler * mItemLinkHandler
Used for showing item popup on clicking links.
void removeTab(ChatTab *tab)
Remove the given tab from the window.
AutoCompleteLister * mAutoComplete
void nextTab()
Switch to the next tab in order.
ChatTab * addWhisperTab(const std::string &nick, bool switchTo=false)
void action(const gcn::ActionEvent &event) override
Performs action.
void mousePressed(gcn::MouseEvent &event) override
void chatInput(const std::string &msg)
Passes the text to the current tab as input.
void prevTab()
Switch to the previous tab in order.
std::map< const std::string, ChatTab * > mWhispers
Manage whisper tabs.
void resetToDefaultSize() override
Reset the chat window and recorder window attached to it to their default positions.
void addTab(ChatTab *tab)
Add the tab to the window.
ChatTab * getFocused() const
Gets the focused tab.
void event(Event::Channel channel, const Event &event) override
void listen(Event::Channel channel)
int getHeight() const
Returns the logical height of the screen.
int getWidth() const
Returns the logical width of the screen.
LayoutCell & setPadding(int p)
Sets the padding around the cell content.
void afkRespond(ChatTab *tab, const std::string &nick)
virtual void privateMessage(const std::string &recipient, const std::string &text)=0
void setRecordingFile(const std::string &msg)
Sets the file being recorded to.
bool isRecording()
Whether or not the recorder is in use.
void record(const std::string &msg)
Outputs the message to the recorder file.
void registerWindowForReset(Window *window)
Enables the Reset Windows button.
A tabbed area, the same as the guichan tabbed area in 0.8, but extended.
void addTab(gcn::Tab *tab, gcn::Widget *widget) override
Add a tab.
void removeTab(gcn::Tab *tab) override
Override the remove tab function as it's broken in guichan 0.8.
void setSelectedTab(unsigned int index) override
int getNumberOfTabs() const
Return how many tabs have been created.
void setAutoComplete(AutoCompleteLister *lister)
Sets the TextField's source of autocomplete.
void setHistory(TextHistory *history)
Sets the TextField's source of input history.
const Skin & getSkin() const
Returns the Skin used by this window.
virtual void setVisible(bool visible)
Overloads window setVisible by Guichan to allow sticky window handling.
void setDefaultVisible(bool save)
Sets whether the window is visible by default.
void setMinHeight(int height)
Sets the minimum height of the window.
Layout & getLayout()
Gets the layout handler for this window.
void setWindowName(const std::string &name)
Sets the name of the window.
void mouseDragged(gcn::MouseEvent &event) override
Implements window resizing and makes sure the window is not dragged/resized outside of the screen.
virtual void resetToDefaultSize()
Reset the win pos and size to default.
void setResizable(bool resize)
Sets whether or not the window can be resized.
void setSaveVisible(bool save)
Sets whether the window will save it's visibility.
LayoutCell & place(int x, int y, gcn::Widget *, int w=1, int h=1)
Adds a widget to the window and sets it at given cell.
void setShowTitle(bool flag)
Sets flag to show a title or not.
void setDefaultSize()
Set the default win pos and size to the current ones.
void loadWindowState()
Reads the position (and the size for resizable windows) in the configuration based on the given strin...
void mousePressed(gcn::MouseEvent &event) override
Starts window resizing when appropriate.
static int mouseResize
Active resize handles.
void setMinWidth(int width)
Sets the minimum width of the window.
Config config
Global settings (config.xml)
LocalPlayer * local_player
ChatHandler * getChatHandler()
std::string & toLower(std::string &str)
Converts the given string to lower case.
std::string strprintf(char const *format,...)
A safe version of sprintf that returns a std::string of the result.