diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 9f22d6f342..888a295032 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -58,6 +58,7 @@ void ChatMenu::CreateViews() { float yres = screenManager()->getUIContext()->GetBounds().h; switch (g_Config.iChatScreenPosition) { + // the chat screen size is still static 280,250 need a dynamic size based on device resolution case 0: box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, 280, NONE, NONE, 250, true)); break; @@ -87,16 +88,16 @@ void ChatMenu::CreateViews() { CreatePopupContents(box_); #if defined(_WIN32) || defined(USING_QT_UI) - //not work yet for tywald requests cant set the focus to chat edit after chat opened root_->SetDefaultFocusView(box_); box_->SubviewFocused(chatEdit_); root_->SetFocus(); #else root_->SetDefaultFocusView(box_); #endif - UpdateChat(); chatScreenVisible = true; newChat = 0; + UI::EnableFocusMovement(true); + UpdateChat(); } void ChatMenu::dialogFinished(const Screen *dialog, DialogResult result) { @@ -115,13 +116,18 @@ UI::EventReturn ChatMenu::OnSubmit(UI::EventParams &e) { return UI::EVENT_DONE; } +/* + maximum chat length in one message from server is only 64 character + need to split the chat to fit the static chat screen size + if the chat screen size become dynamic from device resolution + we need to change split function logic also. +*/ std::vector Split(const std::string& str) { std::vector ret; int counter = 0; int firstSentenceEnd = 0; int secondSentenceEnd = 0; - //NOTICE_LOG(HLE, "Splitted %s %i", str.c_str(),str.size()); for (auto i = 0; iClear(); //read Access violation is proadhoc.cpp use NULL_->Clear() pointer? std::vector chatLog = getChatLog(); for (auto i : chatLog) { + //split long text if (i.length() > 30) { - //split long text std::vector splitted = Split(i); for (auto j : splitted) { TextView *v = chatVert_->Add(new TextView(j, FLAG_DYNAMIC_ASCII, false)); @@ -185,17 +191,16 @@ bool ChatMenu::touch(const TouchInput &touch) { return UIDialogScreen::touch(touch); } -void ChatMenu::update(InputState &input) { - PopupScreen::update(input); +void ChatMenu::update() { + PopupScreen::update(); if (updateChatScreen) { UpdateChat(); } -} - -void ChatMenu::postRender() { - if (scroll_ && toBottom_) { - scroll_->ScrollToBottom(); - toBottom_ = false; + else { + if (scroll_ && toBottom_) { + toBottom_ = false; + scroll_->ScrollToBottom(); + } } } diff --git a/UI/ChatScreen.h b/UI/ChatScreen.h index 701643aabb..2d07d439ff 100644 --- a/UI/ChatScreen.h +++ b/UI/ChatScreen.h @@ -4,14 +4,13 @@ class ChatMenu : public PopupScreen { public: - ChatMenu() : PopupScreen("Chat") {} + ChatMenu() : PopupScreen("Chat") , toBottom_(false) {} ~ChatMenu(); void CreatePopupContents(UI::ViewGroup *parent) override; void CreateViews() override; void dialogFinished(const Screen *dialog, DialogResult result) override; bool touch(const TouchInput &touch) override; - void update(InputState &input) override; - void postRender() override; + void update() override; void UpdateChat(); private: UI::EventReturn OnSubmit(UI::EventParams &e); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index a462593297..aaabc47959 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -380,12 +380,16 @@ void EmuScreen::sendMessage(const char *message, const char *value) { if (g_Config.bBypassOSKWithKeyboard) { osm.Show("Disable windows native keyboard options to use ctrl + c hotkey", 2.0f); } else { + if (g_Config.bEnableNetworkChat) { + chatButtons->SetVisibility(UI::V_GONE); + screenManager()->push(new ChatMenu()); + } + } +#else + if (g_Config.bEnableNetworkChat) { chatButtons->SetVisibility(UI::V_GONE); screenManager()->push(new ChatMenu()); } -#else - chatButtons->SetVisibility(UI::V_GONE); - screenManager()->push(new ChatMenu()); #endif } } @@ -807,6 +811,7 @@ void EmuScreen::CreateViews() { break; case 3: chatButtons = new ChoiceWithValueDisplay(&newChat, sc->T("Chat"), new AnchorLayoutParams(130, WRAP_CONTENT, 80, 50, NONE, NONE, true)); + break; case 4: chatButtons = new ChoiceWithValueDisplay(&newChat, sc->T("Chat"), new AnchorLayoutParams(130, WRAP_CONTENT, bounds.centerX(), 50, NONE, NONE, true)); break; diff --git a/Windows/resource.h b/Windows/resource.h index 5c9ed521c3..f38f5ba43f 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -334,7 +334,7 @@ #define ID_FILE_DUMPAUDIO 40167 #define ID_HELP_GITHUB 40168 #define IDC_GEDBG_RECORD 40169 -#define ID_EMULATION_CHAT 40168 +#define ID_EMULATION_CHAT 40170 // Dummy option to let the buffered rendering hotkey cycle through all the options.