From 10e874cefd887807a3553d7db6d67482689c83d8 Mon Sep 17 00:00:00 2001 From: Ade Novan Date: Fri, 21 Oct 2016 18:35:54 +0800 Subject: [PATCH 01/26] PPSSPP early chat feature rebranched --- Core/HLE/proAdhoc.cpp | 66 +++++++++++++++++++--- Core/HLE/proAdhoc.h | 9 +++ UI/ChatScreen.cpp | 124 ++++++++++++++++++++++++++++++++++++++++++ UI/ChatScreen.h | 21 +++++++ UI/EmuScreen.cpp | 13 +++++ UI/EmuScreen.h | 1 + UI/UI.vcxproj | 2 + UI/UI.vcxproj.filters | 6 ++ 8 files changed, 233 insertions(+), 9 deletions(-) create mode 100644 UI/ChatScreen.cpp create mode 100644 UI/ChatScreen.h diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index a7e154348a4c..6288189ebd34 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -55,6 +55,11 @@ std::recursive_mutex peerlock; SceNetAdhocPdpStat * pdp[255]; SceNetAdhocPtpStat * ptp[255]; uint32_t localip; +std::vector chatLog; +ChatMenu* ch; +std::string name = ""; +std::string incoming = ""; +std::string message = ""; int isLocalMAC(const SceNetEtherAddr * addr) { SceNetEtherAddr saddr; @@ -981,6 +986,35 @@ void freeFriendsRecursive(SceNetAdhocctlPeerInfo * node) { free(node); } +void setChatPointer(ChatMenu* chatmenu) { + //set chatscreen instance + ch = chatmenu; +} + +void sendChat(std::string chatString) { + SceNetAdhocctlChatPacketC2S chat; + chat.base.opcode = OPCODE_CHAT; + //Send Chat Messages need to check network inited and already connected to server or not + //if (friendFinderRunning) + //{ + // Send Chat to Server + //maximum char allowed is 64 character for compability with original server (pro.coldbird.net) + message = chatString.substr(0, 57); // 64 return chat variable corrupted is it out of memory? + strcpy(chat.message, message.c_str()); + NOTICE_LOG(SCENET, "Send %s to Adhoc Server", chat.message); + int chatResult = send(metasocket, (const char *)&chat, sizeof(chat), 0); + //need to check if send success or not before appending to chat screen + name = g_Config.sNickName.c_str(); + chatLog.push_back(name.substr(0, 8) + ": " + chat.message); + //} +} + + +std::vector getChatLog() { + // this log used by chat screen + return chatLog; +} + int friendFinder(){ // Receive Buffer int rxpos = 0; @@ -1024,13 +1058,6 @@ int friendFinder(){ }*/ } - // Send Chat Messages - //while(popFromOutbox(chat.message)) - //{ - // // Send Chat to Server - // sceNetInetSend(metasocket, (const char *)&chat, sizeof(chat), 0); - //} - // Wait for Incoming Data int received = recv(metasocket, (char *)(rx + rxpos), sizeof(rx) - rxpos, 0); @@ -1084,7 +1111,19 @@ int friendFinder(){ // Add Incoming Chat to HUD //printf("Receive chat message %s", packet->base.message); - DEBUG_LOG(SCENET, "Received chat message %s", packet->base.message); + NOTICE_LOG(SCENET, "Received chat message %s", packet->base.message); + incoming = ""; + name = (char *)packet->name.data; + incoming.append(name.substr(0, 8)); + incoming.append(": "); + incoming.append((char *)packet->base.message); + chatLog.push_back(incoming); + //im new to pointer btw :( doesn't know its safe or not this should update the chat screen when data coming + if (ch) { + ch->UpdateChat(); + } + // Move RX Buffer + memmove(rx, rx + sizeof(SceNetAdhocctlChatPacketS2C), sizeof(rx) - sizeof(SceNetAdhocctlChatPacketS2C)); // Move RX Buffer memmove(rx, rx + sizeof(SceNetAdhocctlChatPacketS2C), sizeof(rx) - sizeof(SceNetAdhocctlChatPacketS2C)); @@ -1107,7 +1146,16 @@ int friendFinder(){ // Add User addFriend(packet); - + incoming = ""; + incoming.append((char *)packet->name.data); + incoming.append(" Joined "); + //do we need ip? + //joined.append((char *)packet->ip); + chatLog.push_back(incoming); + //im new to pointer btw :( doesn't know its safe or not this should update the chat screen when data coming + if (ch) { + ch->UpdateChat(); + } // Update HUD User Count #ifdef LOCALHOST_AS_PEER setUserCount(getActivePeerCount()); diff --git a/Core/HLE/proAdhoc.h b/Core/HLE/proAdhoc.h index 6573dd892009..2ec7861203ee 100644 --- a/Core/HLE/proAdhoc.h +++ b/Core/HLE/proAdhoc.h @@ -33,6 +33,7 @@ #include "Core/HLE/sceKernel.h" #include "Core/HLE/sceKernelMutex.h" #include "Core/HLE/sceUtility.h" +#include "UI/ChatScreen.h" class PointerWrap; @@ -842,6 +843,14 @@ SceNetAdhocMatchingMemberInternal* addMember(SceNetAdhocMatchingContext * contex */ void addFriend(SceNetAdhocctlConnectPacketS2C * packet); +/** +* Send chat or get that +* @param std::string ChatString +*/ +void setChatPointer(ChatMenu* chatmenu); +void sendChat(std::string chatString); +std::vector getChatLog(); + /* * Find a Peer/Friend by MAC address */ diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp new file mode 100644 index 000000000000..b34c705c4c3e --- /dev/null +++ b/UI/ChatScreen.cpp @@ -0,0 +1,124 @@ +#include "ui/ui_context.h" +#include "ui/view.h" +#include "ui/viewgroup.h" +#include "ui/ui.h" +#include "ChatScreen.h" +#include "Core/Config.h" +#include "Core/System.h" +#include "Common/LogManager.h" +#include "Core/HLE/proAdhoc.h" + +void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { + using namespace UI; + //tried to give instance to proAdhoc not working + //setChatPointer(this); + LinearLayout *outer = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, 400)); + scroll_ = outer->Add(new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(PopupWidth(), FILL_PARENT, 1.0f))); + chatVert_ = scroll_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(PopupWidth(), WRAP_CONTENT))); + chatVert_->SetSpacing(0); + LinearLayout *bottom = outer->Add(new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, WRAP_CONTENT))); + chatEdit_ = bottom->Add(new TextEdit("", "Chat Here", new LinearLayoutParams(1.0))); + chatEdit_->OnEnter.Handle(this, &ChatMenu::OnSubmit); + bottom->Add(new Button("Send"))->OnClick.Handle(this, &ChatMenu::OnSubmit); + parent->Add(outer); + UpdateChat(); +} + +void ChatMenu::CreateViews() { + using namespace UI; + + UIContext &dc = *screenManager()->getUIContext(); + + AnchorLayout *anchor = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); + anchor->Overflow(false); + root_ = anchor; + + float yres = screenManager()->getUIContext()->GetBounds().h; + + box_ = new LinearLayout(ORIENT_VERTICAL, + new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, 280, NONE, NONE, 250, true)); + + root_->Add(box_); + box_->SetBG(UI::Drawable(0x66303030)); + box_->SetHasDropShadow(false); + + View *title = new PopupHeader("Chat"); + box_->Add(title); + + CreatePopupContents(box_); + root_->SetDefaultFocusView(box_); +} + +void ChatMenu::dialogFinished(const Screen *dialog, DialogResult result) { + UpdateUIState(UISTATE_INGAME); + // Close when a subscreen got closed. + // TODO: a bug in screenmanager causes this not to work here. + // screenManager()->finishDialog(this, DR_OK); +} + +UI::EventReturn ChatMenu::OnSubmit(UI::EventParams &e) { + std::string chat = chatEdit_->GetText(); + NOTICE_LOG(HLE, "Chat Send to socket: %s", chat.c_str()); + chatEdit_->SetText(""); + chatEdit_->SetFocus(); + sendChat(chat); + UpdateChat(); + return UI::EVENT_DONE; +} + +std::vector Split(const std::string& str, int splitLength) +{ + int NumSubstrings = str.length() / splitLength; + std::vector ret; + + // TODO sub string in white space + for (auto i = 0; i < NumSubstrings; i++) + { + ret.push_back(str.substr(i * splitLength, splitLength)); + } + + // If there are leftover characters, create a shorter item at the end. + if (str.length() % splitLength != 0) + { + ret.push_back(str.substr(splitLength * NumSubstrings)); + } + + + return ret; +} + +void ChatMenu::UpdateChat() { + using namespace UI; + if (chatVert_ != NULL) { + chatVert_->Clear(); + std::vector chatLog = getChatLog(); + for (auto i : chatLog) { + if (i.length() > 30) { + //split long text + std::vector splitted = Split(i, 32); + for (auto j : splitted) { + TextView *v = chatVert_->Add(new TextView(j, FLAG_DYNAMIC_ASCII, false, new LayoutParams(PopupWidth(), WRAP_CONTENT))); + uint32_t color = 0xFFFFFF; + v->SetTextColor(0xFF000000 | color); + } + } + else { + TextView *v = chatVert_->Add(new TextView(i, FLAG_DYNAMIC_ASCII, false, new LayoutParams(PopupWidth(), WRAP_CONTENT))); + uint32_t color = 0xFFFFFF; + v->SetTextColor(0xFF000000 | color); + } + } + scroll_->ScrollToBottom(); + } +} + +bool ChatMenu::touch(const TouchInput &touch) { + if (!box_ || (touch.flags & TOUCH_DOWN) == 0 || touch.id != 0) { + return UIDialogScreen::touch(touch); + } + + if (!box_->GetBounds().Contains(touch.x, touch.y)) + screenManager()->finishDialog(this, DR_BACK); + + return UIDialogScreen::touch(touch); +} \ No newline at end of file diff --git a/UI/ChatScreen.h b/UI/ChatScreen.h new file mode 100644 index 000000000000..c9c72c47ac9c --- /dev/null +++ b/UI/ChatScreen.h @@ -0,0 +1,21 @@ +#pragma once +#include "file/file_util.h" +#include "ui/ui_screen.h" + +class ChatMenu : public PopupScreen { +public: + ChatMenu() : PopupScreen("Chat") {} + void CreatePopupContents(UI::ViewGroup *parent) override; + void CreateViews() override; + void dialogFinished(const Screen *dialog, DialogResult result) override; + bool touch(const TouchInput &touch) override; + void UpdateChat(); +private: + UI::EventReturn OnSubmit(UI::EventParams &e); + UI::TextEdit *chatEdit_; + UI::ScrollView *scroll_; + UI::LinearLayout *chatVert_; + UI::ViewGroup *box_; + UI::Button *defaultButton_; + bool toBottom_; +}; \ No newline at end of file diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 0e496cf6443a..f7b65203eeb3 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -54,6 +54,7 @@ #include "Core/SaveState.h" #include "Core/MIPS/MIPS.h" #include "Core/HLE/__sceAudio.h" +#include "Core/HLE/proAdhoc.h" #include "UI/ui_atlas.h" #include "UI/BackgroundAudio.h" @@ -70,6 +71,7 @@ #include "UI/GameSettingsScreen.h" #include "UI/InstallZipScreen.h" #include "UI/ProfilerDraw.h" +#include "UI/ChatScreen.h" #if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) #include "Windows/MainWindow.h" @@ -776,6 +778,8 @@ void EmuScreen::CreateViews() { if (g_Config.bShowDeveloperMenu) { root_->Add(new Button("DevMenu"))->OnClick.Handle(this, &EmuScreen::OnDevTools); } + // TODO add options in networking menu checkbox enable chat + root_->Add(new Button("Chat", new AnchorLayoutParams(50, NONE, NONE, 50, true)))->OnClick.Handle(this, &EmuScreen::OnChat); saveStatePreview_ = new AsyncImageFileView("", IS_FIXED, nullptr, new AnchorLayoutParams(bounds.centerX(), 100, NONE, NONE, true)); saveStatePreview_->SetFixedSize(160, 90); saveStatePreview_->SetColor(0x90FFFFFF); @@ -794,7 +798,16 @@ UI::EventReturn EmuScreen::OnDevTools(UI::EventParams ¶ms) { return UI::EVENT_DONE; } +UI::EventReturn EmuScreen::OnChat(UI::EventParams ¶ms) { + releaseButtons(); + ChatMenu* ch = new ChatMenu(); + setChatPointer(ch); + screenManager()->push(ch); + return UI::EVENT_DONE; +} + void EmuScreen::update() { + if (bootPending_) bootGame(gamePath_); diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index 3f103513b71c..2057f6835b29 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -52,6 +52,7 @@ class EmuScreen : public UIScreen { protected: void CreateViews() override; UI::EventReturn OnDevTools(UI::EventParams ¶ms); + UI::EventReturn OnChat(UI::EventParams ¶ms); private: void bootGame(const std::string &filename); diff --git a/UI/UI.vcxproj b/UI/UI.vcxproj index 06f979c86b51..2438e316ff44 100644 --- a/UI/UI.vcxproj +++ b/UI/UI.vcxproj @@ -20,6 +20,7 @@ + @@ -51,6 +52,7 @@ + diff --git a/UI/UI.vcxproj.filters b/UI/UI.vcxproj.filters index 8332d1176212..ed59a4c614ea 100644 --- a/UI/UI.vcxproj.filters +++ b/UI/UI.vcxproj.filters @@ -70,6 +70,9 @@ Screens + + Screens + @@ -141,6 +144,9 @@ Screens + + Screens + From bd2342ad597fd2ecafe012959abc17031b14f782 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Fri, 21 Oct 2016 20:40:11 +0800 Subject: [PATCH 02/26] Enable chat box --- Core/Config.cpp | 1 + Core/Config.h | 1 + UI/EmuScreen.cpp | 4 ++-- UI/GameSettingsScreen.cpp | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 347a91f8ba85..c2b6ebdfc98f 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -708,6 +708,7 @@ static ConfigSetting controlSettings[] = { static ConfigSetting networkSettings[] = { ConfigSetting("EnableWlan", &g_Config.bEnableWlan, false, true, true), ConfigSetting("EnableAdhocServer", &g_Config.bEnableAdhocServer, false, true, true), + ConfigSetting("EnableNetworkChat", &g_Config.bEnableNetworkChat, false, true, true), ConfigSetting(false), }; diff --git a/Core/Config.h b/Core/Config.h index 383629fd8858..381a1b954bb2 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -424,6 +424,7 @@ struct Config { bool bEnableAdhocServer; int iWlanAdhocChannel; bool bWlanPowerSave; + bool bEnableNetworkChat; int iPSPModel; int iFirmwareVersion; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index f7b65203eeb3..13ecd468b31f 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -778,8 +778,8 @@ void EmuScreen::CreateViews() { if (g_Config.bShowDeveloperMenu) { root_->Add(new Button("DevMenu"))->OnClick.Handle(this, &EmuScreen::OnDevTools); } - // TODO add options in networking menu checkbox enable chat - root_->Add(new Button("Chat", new AnchorLayoutParams(50, NONE, NONE, 50, true)))->OnClick.Handle(this, &EmuScreen::OnChat); + if (g_Config.bEnableNetworkChat) + root_->Add(new Button("Chat", new AnchorLayoutParams(50, NONE, NONE, 50, true)))->OnClick.Handle(this, &EmuScreen::OnChat); saveStatePreview_ = new AsyncImageFileView("", IS_FIXED, nullptr, new AnchorLayoutParams(bounds.centerX(), 100, NONE, NONE, true)); saveStatePreview_->SetFixedSize(160, 90); saveStatePreview_->SetColor(0x90FFFFFF); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 03c8f8a21a87..a933bbe077d6 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -619,6 +619,7 @@ void GameSettingsScreen::CreateViews() { networkingSettings->Add(new CheckBox(&g_Config.bEnableAdhocServer, n->T("Enable built-in PRO Adhoc Server", "Enable built-in PRO Adhoc Server"))); networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sMACAddress, n->T("Change Mac Address"), nullptr))->OnClick.Handle(this, &GameSettingsScreen::OnChangeMacAddress); networkingSettings->Add(new PopupSliderChoice(&g_Config.iPortOffset, 0, 60000, n->T("Port offset", "Port offset(0 = PSP compatibility)"), 100, screenManager())); + networkingSettings->Add(new CheckBox(&g_Config.bEnableNetworkChat, n->T("Enable network chat", "Enable network chat"))); ViewGroup *toolsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); toolsScroll->SetTag("GameSettingsTools"); From 08a1cc70755160d900397b90f0daddd450c09c7f Mon Sep 17 00:00:00 2001 From: sum2012 Date: Fri, 21 Oct 2016 21:12:57 +0800 Subject: [PATCH 03/26] Add translation --- UI/ChatScreen.cpp | 9 ++++++--- UI/EmuScreen.cpp | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index b34c705c4c3e..da588a791444 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -7,19 +7,21 @@ #include "Core/System.h" #include "Common/LogManager.h" #include "Core/HLE/proAdhoc.h" +#include "i18n/i18n.h" void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { using namespace UI; //tried to give instance to proAdhoc not working //setChatPointer(this); + I18NCategory *n = GetI18NCategory("Networking"); LinearLayout *outer = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, 400)); scroll_ = outer->Add(new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(PopupWidth(), FILL_PARENT, 1.0f))); chatVert_ = scroll_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(PopupWidth(), WRAP_CONTENT))); chatVert_->SetSpacing(0); LinearLayout *bottom = outer->Add(new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, WRAP_CONTENT))); - chatEdit_ = bottom->Add(new TextEdit("", "Chat Here", new LinearLayoutParams(1.0))); + chatEdit_ = bottom->Add(new TextEdit("", n->T("Chat Here"), new LinearLayoutParams(1.0))); chatEdit_->OnEnter.Handle(this, &ChatMenu::OnSubmit); - bottom->Add(new Button("Send"))->OnClick.Handle(this, &ChatMenu::OnSubmit); + bottom->Add(new Button(n->T("Send")))->OnClick.Handle(this, &ChatMenu::OnSubmit); parent->Add(outer); UpdateChat(); } @@ -27,6 +29,7 @@ void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { void ChatMenu::CreateViews() { using namespace UI; + I18NCategory *n = GetI18NCategory("Networking"); UIContext &dc = *screenManager()->getUIContext(); AnchorLayout *anchor = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); @@ -42,7 +45,7 @@ void ChatMenu::CreateViews() { box_->SetBG(UI::Drawable(0x66303030)); box_->SetHasDropShadow(false); - View *title = new PopupHeader("Chat"); + View *title = new PopupHeader(n->T("Chat")); box_->Add(title); CreatePopupContents(box_); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 13ecd468b31f..ed2e2e1941d6 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -772,6 +772,7 @@ void EmuScreen::processAxis(const AxisInput &axis, int direction) { void EmuScreen::CreateViews() { using namespace UI; + I18NCategory *sc = GetI18NCategory("Screen"); const Bounds &bounds = screenManager()->getUIContext()->GetBounds(); InitPadLayout(bounds.w, bounds.h); root_ = CreatePadLayout(bounds.w, bounds.h, &pauseTrigger_); @@ -779,7 +780,7 @@ void EmuScreen::CreateViews() { root_->Add(new Button("DevMenu"))->OnClick.Handle(this, &EmuScreen::OnDevTools); } if (g_Config.bEnableNetworkChat) - root_->Add(new Button("Chat", new AnchorLayoutParams(50, NONE, NONE, 50, true)))->OnClick.Handle(this, &EmuScreen::OnChat); + root_->Add(new Button(sc->T("Chat"), new AnchorLayoutParams(50, NONE, NONE, 50, true)))->OnClick.Handle(this, &EmuScreen::OnChat); saveStatePreview_ = new AsyncImageFileView("", IS_FIXED, nullptr, new AnchorLayoutParams(bounds.centerX(), 100, NONE, NONE, true)); saveStatePreview_->SetFixedSize(160, 90); saveStatePreview_->SetColor(0x90FFFFFF); From 07b1d8b845dc729500ec83242df5bb31b5c65956 Mon Sep 17 00:00:00 2001 From: Ade Novan Date: Sun, 23 Oct 2016 00:06:07 +0800 Subject: [PATCH 04/26] pointer fix random crash & better substring logic --- Core/HLE/proAdhoc.cpp | 31 ++++++++++++--------- Core/HLE/proAdhoc.h | 2 +- UI/ChatScreen.cpp | 64 ++++++++++++++++++++++++++++--------------- UI/ChatScreen.h | 1 + UI/EmuScreen.cpp | 6 ++-- 5 files changed, 65 insertions(+), 39 deletions(-) diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index 6288189ebd34..c8a8459d588a 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -56,7 +56,7 @@ SceNetAdhocPdpStat * pdp[255]; SceNetAdhocPtpStat * ptp[255]; uint32_t localip; std::vector chatLog; -ChatMenu* ch; +ChatMenu * ch; std::string name = ""; std::string incoming = ""; std::string message = ""; @@ -986,7 +986,8 @@ void freeFriendsRecursive(SceNetAdhocctlPeerInfo * node) { free(node); } -void setChatPointer(ChatMenu* chatmenu) { +//@params chatmenu pass NULL on Hide , and pass ChatMenu On Create (EmuScreen.cpp) +void setChatPointer(ChatMenu * chatmenu) { //set chatscreen instance ch = chatmenu; } @@ -994,24 +995,28 @@ void setChatPointer(ChatMenu* chatmenu) { void sendChat(std::string chatString) { SceNetAdhocctlChatPacketC2S chat; chat.base.opcode = OPCODE_CHAT; - //Send Chat Messages need to check network inited and already connected to server or not - //if (friendFinderRunning) + //TODO check network inited, check send success or not, chatlog.pushback error on failed send, pushback error on not connected + //if (friendFinderRunning) //need to check network inited and already connected to server or not is this correct? //{ - // Send Chat to Server - //maximum char allowed is 64 character for compability with original server (pro.coldbird.net) - message = chatString.substr(0, 57); // 64 return chat variable corrupted is it out of memory? - strcpy(chat.message, message.c_str()); - NOTICE_LOG(SCENET, "Send %s to Adhoc Server", chat.message); - int chatResult = send(metasocket, (const char *)&chat, sizeof(chat), 0); - //need to check if send success or not before appending to chat screen - name = g_Config.sNickName.c_str(); - chatLog.push_back(name.substr(0, 8) + ": " + chat.message); + // Send Chat to Server + //maximum char allowed is 64 character for compability with original server (pro.coldbird.net) + message = chatString.substr(0, 60); // 64 return chat variable corrupted is it out of memory? + strcpy(chat.message, message.c_str()); + //Send Chat Messages + int chatResult = send(metasocket, (const char *)&chat, sizeof(chat), 0); + NOTICE_LOG(SCENET, "Send %s to Adhoc Server", chat.message); + name = g_Config.sNickName.c_str(); + chatLog.push_back(name.substr(0, 8) + ": " + chat.message); //} } std::vector getChatLog() { // this log used by chat screen + if (chatLog.size() > 50) { + //erase the first 40 element limit the chatlog size + chatLog.erase(chatLog.begin(), chatLog.begin() + 40); + } return chatLog; } diff --git a/Core/HLE/proAdhoc.h b/Core/HLE/proAdhoc.h index 2ec7861203ee..5247f56b76ff 100644 --- a/Core/HLE/proAdhoc.h +++ b/Core/HLE/proAdhoc.h @@ -847,7 +847,7 @@ void addFriend(SceNetAdhocctlConnectPacketS2C * packet); * Send chat or get that * @param std::string ChatString */ -void setChatPointer(ChatMenu* chatmenu); +void setChatPointer(ChatMenu * chatmenu); void sendChat(std::string chatString); std::vector getChatLog(); diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index da588a791444..47a2ded09eb8 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -8,20 +8,19 @@ #include "Common/LogManager.h" #include "Core/HLE/proAdhoc.h" #include "i18n/i18n.h" +#include void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { using namespace UI; - //tried to give instance to proAdhoc not working - //setChatPointer(this); I18NCategory *n = GetI18NCategory("Networking"); - LinearLayout *outer = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, 400)); - scroll_ = outer->Add(new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(PopupWidth(), FILL_PARENT, 1.0f))); - chatVert_ = scroll_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(PopupWidth(), WRAP_CONTENT))); - chatVert_->SetSpacing(0); + LinearLayout *outer = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT,400)); + scroll_ = outer->Add(new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0))); LinearLayout *bottom = outer->Add(new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, WRAP_CONTENT))); chatEdit_ = bottom->Add(new TextEdit("", n->T("Chat Here"), new LinearLayoutParams(1.0))); chatEdit_->OnEnter.Handle(this, &ChatMenu::OnSubmit); bottom->Add(new Button(n->T("Send")))->OnClick.Handle(this, &ChatMenu::OnSubmit); + chatVert_ = scroll_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT))); + chatVert_->SetSpacing(0); parent->Add(outer); UpdateChat(); } @@ -69,36 +68,47 @@ UI::EventReturn ChatMenu::OnSubmit(UI::EventParams &e) { return UI::EVENT_DONE; } -std::vector Split(const std::string& str, int splitLength) +std::vector Split(const std::string& str) { - int NumSubstrings = str.length() / splitLength; std::vector ret; - - // TODO sub string in white space - for (auto i = 0; i < NumSubstrings; i++) - { - ret.push_back(str.substr(i * splitLength, splitLength)); + int counter = 0; + int firstSentenceEnd = 0; + int secondSentenceEnd = 0; + NOTICE_LOG(HLE, "Splitted %s %i", str.c_str(),str.size()); + for (auto i = 0; i 35) { + secondSentenceEnd = i; + } + } } - // If there are leftover characters, create a shorter item at the end. - if (str.length() % splitLength != 0) - { - ret.push_back(str.substr(splitLength * NumSubstrings)); + if (firstSentenceEnd == 0) { + firstSentenceEnd = 35; + } + + if(secondSentenceEnd == 0){ + secondSentenceEnd = str.length(); } - + ret.push_back(str.substr(0, firstSentenceEnd)); + ret.push_back(str.substr(firstSentenceEnd, secondSentenceEnd)); return ret; } void ChatMenu::UpdateChat() { using namespace UI; if (chatVert_ != NULL) { - chatVert_->Clear(); + chatVert_->Clear(); //read Access violation is proadhoc.cpp use NULL_->Clear() pointer? std::vector chatLog = getChatLog(); for (auto i : chatLog) { if (i.length() > 30) { //split long text - std::vector splitted = Split(i, 32); + std::vector splitted = Split(i); for (auto j : splitted) { TextView *v = chatVert_->Add(new TextView(j, FLAG_DYNAMIC_ASCII, false, new LayoutParams(PopupWidth(), WRAP_CONTENT))); uint32_t color = 0xFFFFFF; @@ -111,7 +121,7 @@ void ChatMenu::UpdateChat() { v->SetTextColor(0xFF000000 | color); } } - scroll_->ScrollToBottom(); + toBottom_ = true; } } @@ -120,8 +130,18 @@ bool ChatMenu::touch(const TouchInput &touch) { return UIDialogScreen::touch(touch); } - if (!box_->GetBounds().Contains(touch.x, touch.y)) + if (!box_->GetBounds().Contains(touch.x, touch.y)){ screenManager()->finishDialog(this, DR_BACK); + setChatPointer(NULL); //fix the random crash + } return UIDialogScreen::touch(touch); +} + +void ChatMenu::update(InputState &input) { + if (toBottom_) { + toBottom_ = false; + scroll_->ScrollToBottom(); + } + PopupScreen::update(input); } \ No newline at end of file diff --git a/UI/ChatScreen.h b/UI/ChatScreen.h index c9c72c47ac9c..d12de148e8c2 100644 --- a/UI/ChatScreen.h +++ b/UI/ChatScreen.h @@ -9,6 +9,7 @@ class ChatMenu : public PopupScreen { void CreateViews() override; void dialogFinished(const Screen *dialog, DialogResult result) override; bool touch(const TouchInput &touch) override; + void update(InputState &input) override; void UpdateChat(); private: UI::EventReturn OnSubmit(UI::EventParams &e); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index ed2e2e1941d6..13a32b8aab75 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -87,7 +87,6 @@ AVIDump avi; static bool frameStep_; static int lastNumFlips; static bool startDumping; - static void __EmuScreenVblank() { I18NCategory *sy = GetI18NCategory("System"); @@ -779,8 +778,9 @@ void EmuScreen::CreateViews() { if (g_Config.bShowDeveloperMenu) { root_->Add(new Button("DevMenu"))->OnClick.Handle(this, &EmuScreen::OnDevTools); } - if (g_Config.bEnableNetworkChat) + if (g_Config.bEnableNetworkChat) { root_->Add(new Button(sc->T("Chat"), new AnchorLayoutParams(50, NONE, NONE, 50, true)))->OnClick.Handle(this, &EmuScreen::OnChat); + } saveStatePreview_ = new AsyncImageFileView("", IS_FIXED, nullptr, new AnchorLayoutParams(bounds.centerX(), 100, NONE, NONE, true)); saveStatePreview_->SetFixedSize(160, 90); saveStatePreview_->SetColor(0x90FFFFFF); @@ -801,7 +801,7 @@ UI::EventReturn EmuScreen::OnDevTools(UI::EventParams ¶ms) { UI::EventReturn EmuScreen::OnChat(UI::EventParams ¶ms) { releaseButtons(); - ChatMenu* ch = new ChatMenu(); + ChatMenu * ch = new ChatMenu(); // memory leak or not? setChatPointer(ch); screenManager()->push(ch); return UI::EVENT_DONE; From 2874c6d7d73c0faf3040d3451a66f993b8103630 Mon Sep 17 00:00:00 2001 From: Ade Novan Date: Sun, 23 Oct 2016 02:44:28 +0800 Subject: [PATCH 05/26] Oops it still random crashed destructor do the fix well --- UI/ChatScreen.cpp | 10 +++++++--- UI/ChatScreen.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 47a2ded09eb8..2264e45e2618 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -110,13 +110,13 @@ void ChatMenu::UpdateChat() { //split long text std::vector splitted = Split(i); for (auto j : splitted) { - TextView *v = chatVert_->Add(new TextView(j, FLAG_DYNAMIC_ASCII, false, new LayoutParams(PopupWidth(), WRAP_CONTENT))); + TextView *v = chatVert_->Add(new TextView(j, FLAG_DYNAMIC_ASCII, false)); uint32_t color = 0xFFFFFF; v->SetTextColor(0xFF000000 | color); } } else { - TextView *v = chatVert_->Add(new TextView(i, FLAG_DYNAMIC_ASCII, false, new LayoutParams(PopupWidth(), WRAP_CONTENT))); + TextView *v = chatVert_->Add(new TextView(i, FLAG_DYNAMIC_ASCII, false)); uint32_t color = 0xFFFFFF; v->SetTextColor(0xFF000000 | color); } @@ -144,4 +144,8 @@ void ChatMenu::update(InputState &input) { scroll_->ScrollToBottom(); } PopupScreen::update(input); -} \ No newline at end of file +} + +ChatMenu::~ChatMenu() { + setChatPointer(NULL); +} diff --git a/UI/ChatScreen.h b/UI/ChatScreen.h index d12de148e8c2..47fb684f13dc 100644 --- a/UI/ChatScreen.h +++ b/UI/ChatScreen.h @@ -5,6 +5,7 @@ class ChatMenu : public PopupScreen { public: ChatMenu() : PopupScreen("Chat") {} + ~ChatMenu(); void CreatePopupContents(UI::ViewGroup *parent) override; void CreateViews() override; void dialogFinished(const Screen *dialog, DialogResult result) override; From 18525ea523024f1cf0cc80972b0a8df1408c3733 Mon Sep 17 00:00:00 2001 From: Ade Novan Date: Mon, 24 Oct 2016 01:49:12 +0800 Subject: [PATCH 06/26] Android Chat Support --- Core/HLE/proAdhoc.cpp | 7 ++++++- UI/ChatScreen.cpp | 14 ++++++++++++-- UI/ChatScreen.h | 1 - UI/NativeApp.cpp | 3 +++ android/jni/Android.mk | 1 + 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index c8a8459d588a..4289bdcc56a8 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -999,14 +999,19 @@ void sendChat(std::string chatString) { //if (friendFinderRunning) //need to check network inited and already connected to server or not is this correct? //{ // Send Chat to Server + if (!chatString.empty()) { //maximum char allowed is 64 character for compability with original server (pro.coldbird.net) message = chatString.substr(0, 60); // 64 return chat variable corrupted is it out of memory? strcpy(chat.message, message.c_str()); //Send Chat Messages int chatResult = send(metasocket, (const char *)&chat, sizeof(chat), 0); - NOTICE_LOG(SCENET, "Send %s to Adhoc Server", chat.message); + NOTICE_LOG(SCENET, "Send Chat %s to Adhoc Server", chat.message); name = g_Config.sNickName.c_str(); chatLog.push_back(name.substr(0, 8) + ": " + chat.message); + if (ch) { + ch->UpdateChat(); + } + } //} } diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 2264e45e2618..d42b4887e9c4 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -4,21 +4,28 @@ #include "ui/ui.h" #include "ChatScreen.h" #include "Core/Config.h" +#include "Core/Host.h" #include "Core/System.h" #include "Common/LogManager.h" #include "Core/HLE/proAdhoc.h" #include "i18n/i18n.h" #include + void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { using namespace UI; I18NCategory *n = GetI18NCategory("Networking"); LinearLayout *outer = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT,400)); scroll_ = outer->Add(new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0))); LinearLayout *bottom = outer->Add(new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, WRAP_CONTENT))); + +#if defined(_WIN32) || defined(USING_QT_UI) chatEdit_ = bottom->Add(new TextEdit("", n->T("Chat Here"), new LinearLayoutParams(1.0))); chatEdit_->OnEnter.Handle(this, &ChatMenu::OnSubmit); bottom->Add(new Button(n->T("Send")))->OnClick.Handle(this, &ChatMenu::OnSubmit); +#elif defined(__ANDROID__) + bottom->Add(new Button(n->T("Chat Here"),new LayoutParams(FILL_PARENT, WRAP_CONTENT)))->OnClick.Handle(this, &ChatMenu::OnSubmit); +#endif chatVert_ = scroll_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT))); chatVert_->SetSpacing(0); parent->Add(outer); @@ -59,12 +66,15 @@ void ChatMenu::dialogFinished(const Screen *dialog, DialogResult result) { } UI::EventReturn ChatMenu::OnSubmit(UI::EventParams &e) { +#if defined(_WIN32) || defined(USING_QT_UI) std::string chat = chatEdit_->GetText(); - NOTICE_LOG(HLE, "Chat Send to socket: %s", chat.c_str()); chatEdit_->SetText(""); chatEdit_->SetFocus(); sendChat(chat); - UpdateChat(); +#elif defined(__ANDROID__) + scroll_->ScrollToBottom(); + System_SendMessage("inputbox", "Chat:"); +#endif return UI::EVENT_DONE; } diff --git a/UI/ChatScreen.h b/UI/ChatScreen.h index 47fb684f13dc..32ea47c49e01 100644 --- a/UI/ChatScreen.h +++ b/UI/ChatScreen.h @@ -18,6 +18,5 @@ class ChatMenu : public PopupScreen { UI::ScrollView *scroll_; UI::LinearLayout *chatVert_; UI::ViewGroup *box_; - UI::Button *defaultButton_; bool toBottom_; }; \ No newline at end of file diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 0f293b883161..d5753010168c 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -80,6 +80,7 @@ #include "Core/System.h" #include "Core/HLE/__sceAudio.h" #include "Core/HLE/sceCtrl.h" +#include "Core/HLE/proAdhoc.h" #include "Core/Util/GameManager.h" #include "Core/Util/AudioFormat.h" #include "GPU/GPUInterface.h" @@ -857,6 +858,8 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) { g_Config.proAdhocServer = setString; if (inputboxValue[0] == "nickname") g_Config.sNickName = setString; + if (inputboxValue[0] == "Chat") + sendChat(setString); inputboxValue.clear(); } if (msg == "bgImage_updated") { diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 58242a452797..5df2ca432665 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -398,6 +398,7 @@ LOCAL_SRC_FILES := \ $(SRC)/android/jni/native_audio.cpp \ $(SRC)/android/jni/native-audio-so.cpp \ $(SRC)/UI/BackgroundAudio.cpp \ + $(SRC)/UI/ChatScreen.cpp\ $(SRC)/UI/DevScreens.cpp \ $(SRC)/UI/DisplayLayoutEditor.cpp \ $(SRC)/UI/DisplayLayoutScreen.cpp \ From 5187b9f118bc8806c5ef89da4aa1ee9fb4e044ca Mon Sep 17 00:00:00 2001 From: Ade Novan Date: Mon, 24 Oct 2016 15:29:17 +0800 Subject: [PATCH 07/26] Add New Chat Counter --- Core/Config.h | 1 + Core/HLE/proAdhoc.cpp | 5 +++++ UI/ChatScreen.cpp | 1 + UI/EmuScreen.cpp | 3 ++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Core/Config.h b/Core/Config.h index 381a1b954bb2..bc65c531cb9b 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -425,6 +425,7 @@ struct Config { int iWlanAdhocChannel; bool bWlanPowerSave; bool bEnableNetworkChat; + int iNewChat; int iPSPModel; int iFirmwareVersion; diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index 4289bdcc56a8..87fdcabadf5f 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -1132,6 +1132,11 @@ int friendFinder(){ if (ch) { ch->UpdateChat(); } + else { + if (g_Config.iNewChat < 50) { + g_Config.iNewChat += 1; + } + } // Move RX Buffer memmove(rx, rx + sizeof(SceNetAdhocctlChatPacketS2C), sizeof(rx) - sizeof(SceNetAdhocctlChatPacketS2C)); diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index d42b4887e9c4..8504bb162df6 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -56,6 +56,7 @@ void ChatMenu::CreateViews() { CreatePopupContents(box_); root_->SetDefaultFocusView(box_); + g_Config.iNewChat = 0; } void ChatMenu::dialogFinished(const Screen *dialog, DialogResult result) { diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 13a32b8aab75..9b1eab79e6a9 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -779,7 +779,8 @@ void EmuScreen::CreateViews() { root_->Add(new Button("DevMenu"))->OnClick.Handle(this, &EmuScreen::OnDevTools); } if (g_Config.bEnableNetworkChat) { - root_->Add(new Button(sc->T("Chat"), new AnchorLayoutParams(50, NONE, NONE, 50, true)))->OnClick.Handle(this, &EmuScreen::OnChat); + //root_->Add(new Button(sc->T("Chat"), new AnchorLayoutParams(50, NONE, NONE, 50, true)))->OnClick.Handle(this, &EmuScreen::OnChat); + root_->Add(new ChoiceWithValueDisplay(&g_Config.iNewChat, sc->T("Chat"), new AnchorLayoutParams(130,WRAP_CONTENT,80, NONE, NONE, 50, true)))->OnClick.Handle(this, &EmuScreen::OnChat); } saveStatePreview_ = new AsyncImageFileView("", IS_FIXED, nullptr, new AnchorLayoutParams(bounds.centerX(), 100, NONE, NONE, true)); saveStatePreview_->SetFixedSize(160, 90); From f514b25c79e10d31496d7449aff7f4cb2f744305 Mon Sep 17 00:00:00 2001 From: Ade Novan Date: Tue, 25 Oct 2016 18:35:52 +0800 Subject: [PATCH 08/26] Windows CTRL + C Hotkey --- Core/HLE/proAdhoc.cpp | 16 +++++++++------- UI/ChatScreen.cpp | 20 ++++++++++++++------ UI/ChatScreen.h | 3 +++ UI/EmuScreen.cpp | 5 +++++ Windows/MainWindowMenu.cpp | 7 ++++++- Windows/ppsspp.rc | 2 ++ Windows/resource.h | 2 ++ 7 files changed, 41 insertions(+), 14 deletions(-) diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index 87fdcabadf5f..5301d991b3e8 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -996,14 +996,14 @@ void sendChat(std::string chatString) { SceNetAdhocctlChatPacketC2S chat; chat.base.opcode = OPCODE_CHAT; //TODO check network inited, check send success or not, chatlog.pushback error on failed send, pushback error on not connected - //if (friendFinderRunning) //need to check network inited and already connected to server or not is this correct? - //{ + if (friendFinderRunning) + { // Send Chat to Server if (!chatString.empty()) { //maximum char allowed is 64 character for compability with original server (pro.coldbird.net) message = chatString.substr(0, 60); // 64 return chat variable corrupted is it out of memory? strcpy(chat.message, message.c_str()); - //Send Chat Messages + //Send Chat Messages int chatResult = send(metasocket, (const char *)&chat, sizeof(chat), 0); NOTICE_LOG(SCENET, "Send Chat %s to Adhoc Server", chat.message); name = g_Config.sNickName.c_str(); @@ -1012,7 +1012,12 @@ void sendChat(std::string chatString) { ch->UpdateChat(); } } - //} + }else { + chatLog.push_back("You're in Offline Mode, go to lobby or online hall"); // use this or osm better? + if (ch) { + ch->UpdateChat(); + } + } } @@ -1140,9 +1145,6 @@ int friendFinder(){ // Move RX Buffer memmove(rx, rx + sizeof(SceNetAdhocctlChatPacketS2C), sizeof(rx) - sizeof(SceNetAdhocctlChatPacketS2C)); - // Move RX Buffer - memmove(rx, rx + sizeof(SceNetAdhocctlChatPacketS2C), sizeof(rx) - sizeof(SceNetAdhocctlChatPacketS2C)); - // Fix RX Buffer Length rxpos -= sizeof(SceNetAdhocctlChatPacketS2C); } diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 8504bb162df6..2d504e560971 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -29,7 +29,6 @@ void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { chatVert_ = scroll_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT))); chatVert_->SetSpacing(0); parent->Add(outer); - UpdateChat(); } void ChatMenu::CreateViews() { @@ -56,6 +55,7 @@ void ChatMenu::CreateViews() { CreatePopupContents(box_); root_->SetDefaultFocusView(box_); + this->UpdateChat(); g_Config.iNewChat = 0; } @@ -73,7 +73,6 @@ UI::EventReturn ChatMenu::OnSubmit(UI::EventParams &e) { chatEdit_->SetFocus(); sendChat(chat); #elif defined(__ANDROID__) - scroll_->ScrollToBottom(); System_SendMessage("inputbox", "Chat:"); #endif return UI::EVENT_DONE; @@ -132,7 +131,7 @@ void ChatMenu::UpdateChat() { v->SetTextColor(0xFF000000 | color); } } - toBottom_ = true; + this->ScrollChat(); } } @@ -150,11 +149,20 @@ bool ChatMenu::touch(const TouchInput &touch) { } void ChatMenu::update(InputState &input) { - if (toBottom_) { - toBottom_ = false; + PopupScreen::update(input); + this->ScrollChat(); +} + +void ChatMenu::sendMessage(const char *message, const char *value) { + // Always call the base class method first to handle the most common messages. + PopupScreen::sendMessage(message, value); + this->ScrollChat(); +} + +void ChatMenu::ScrollChat() { + if (scroll_) { scroll_->ScrollToBottom(); } - PopupScreen::update(input); } ChatMenu::~ChatMenu() { diff --git a/UI/ChatScreen.h b/UI/ChatScreen.h index 32ea47c49e01..cf673413ba50 100644 --- a/UI/ChatScreen.h +++ b/UI/ChatScreen.h @@ -12,6 +12,9 @@ class ChatMenu : public PopupScreen { bool touch(const TouchInput &touch) override; void update(InputState &input) override; void UpdateChat(); + void ScrollChat(); +protected: + virtual void sendMessage(const char *message, const char *value); private: UI::EventReturn OnSubmit(UI::EventParams &e); UI::TextEdit *chatEdit_; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 9b1eab79e6a9..f1f342a1c6ee 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -371,6 +371,11 @@ void EmuScreen::sendMessage(const char *message, const char *value) { } else { gstate_c.skipDrawReason &= ~SKIPDRAW_WINDOW_MINIMIZED; } + } else if (!strcmp(message, "chat screen")) { + releaseButtons(); + ChatMenu * ch = new ChatMenu(); + setChatPointer(ch); + screenManager()->push(ch); } } diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index 47643179603a..49a5e5d146b1 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -344,6 +344,7 @@ namespace MainWindow { TranslateMenuItem(menu, ID_OPTIONS_SHOWFPS); TranslateMenuItem(menu, ID_EMULATION_SOUND); TranslateMenuItem(menu, ID_EMULATION_CHEATS, L"\tCtrl+T"); + TranslateMenuItem(menu, ID_EMULATION_CHAT, L"\tCtrl+C"); // Help menu: it's translated in CreateHelpMenu. CreateHelpMenu(menu); @@ -648,7 +649,11 @@ namespace MainWindow { g_Config.bEnableCheats = !g_Config.bEnableCheats; osm.ShowOnOff(gr->T("Cheats"), g_Config.bEnableCheats); break; - + case ID_EMULATION_CHAT: + if (GetUIState() == UISTATE_INGAME) { + NativeMessageReceived("chat screen", ""); + } + break; case ID_FILE_LOADSTATEFILE: if (W32Util::BrowseForFileName(true, hWnd, L"Load state", 0, L"Save States (*.ppst)\0*.ppst\0All files\0*.*\0\0", L"ppst", fn)) { SetCursor(LoadCursor(0, IDC_WAIT)); diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index a324f4289637..90c000f212a3 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -68,6 +68,7 @@ BEGIN "W", ID_EMULATION_STOP, VIRTKEY, CONTROL, NOINVERT "B", ID_EMULATION_RESET, VIRTKEY, CONTROL, NOINVERT "T", ID_EMULATION_CHEATS, VIRTKEY, CONTROL, NOINVERT + "C", ID_EMULATION_CHAT, VIRTKEY, CONTROL, NOINVERT "D", ID_DEBUG_DISASSEMBLY, VIRTKEY, CONTROL, NOINVERT "G", ID_DEBUG_GEDEBUGGER, VIRTKEY, CONTROL, NOINVERT "L", ID_DEBUG_LOG, VIRTKEY, CONTROL, NOINVERT @@ -559,6 +560,7 @@ BEGIN MENUITEM "Enable Sound", ID_EMULATION_SOUND, CHECKED MENUITEM SEPARATOR MENUITEM "Enable Cheats", ID_EMULATION_CHEATS + MENUITEM "Enable Chat", ID_EMULATION_CHAT END END diff --git a/Windows/resource.h b/Windows/resource.h index f105eb973993..5c9ed521c332 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -334,6 +334,8 @@ #define ID_FILE_DUMPAUDIO 40167 #define ID_HELP_GITHUB 40168 #define IDC_GEDBG_RECORD 40169 +#define ID_EMULATION_CHAT 40168 + // Dummy option to let the buffered rendering hotkey cycle through all the options. #define ID_OPTIONS_BUFFEREDRENDERINGDUMMY 40500 From 20b289c8eaa2e035fc901e8cacb27f30396d7beb Mon Sep 17 00:00:00 2001 From: Ade Novan Date: Tue, 25 Oct 2016 18:42:51 +0800 Subject: [PATCH 09/26] cmake buildfix --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83f56c3aa12a..c9763768171e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -757,6 +757,7 @@ list(APPEND NativeAppSource android/jni/TestRunner.cpp UI/NativeApp.cpp UI/BackgroundAudio.cpp + UI/ChatScreen.cpp UI/DevScreens.cpp UI/DisplayLayoutEditor.cpp UI/DisplayLayoutScreen.cpp From 766373e15955f90fcce701a8c0be873534191855 Mon Sep 17 00:00:00 2001 From: Ade Novan Date: Thu, 27 Oct 2016 05:21:07 +0800 Subject: [PATCH 10/26] pointer and scroll fix --- Core/HLE/proAdhoc.cpp | 18 ++++++++---------- UI/ChatScreen.cpp | 28 ++++++++-------------------- UI/ChatScreen.h | 5 +---- 3 files changed, 17 insertions(+), 34 deletions(-) diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index 5301d991b3e8..0ec147e81734 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -986,10 +986,12 @@ void freeFriendsRecursive(SceNetAdhocctlPeerInfo * node) { free(node); } -//@params chatmenu pass NULL on Hide , and pass ChatMenu On Create (EmuScreen.cpp) +//@params chatmenu pass NULL on destroy, and pass ChatMenu On Create (EmuScreen.cpp) void setChatPointer(ChatMenu * chatmenu) { - //set chatscreen instance - ch = chatmenu; + if (chatmenu != NULL) { + delete ch; + } + ch = chatmenu; //setChatPointer } void sendChat(std::string chatString) { @@ -1012,8 +1014,9 @@ void sendChat(std::string chatString) { ch->UpdateChat(); } } - }else { - chatLog.push_back("You're in Offline Mode, go to lobby or online hall"); // use this or osm better? + } + else { + chatLog.push_back("You're in Offline Mode, go to lobby or online hall"); //need translation if (ch) { ch->UpdateChat(); } @@ -1120,12 +1123,7 @@ int friendFinder(){ if (rxpos >= (int)sizeof(SceNetAdhocctlChatPacketS2C)) { // Cast Packet SceNetAdhocctlChatPacketS2C * packet = (SceNetAdhocctlChatPacketS2C *)rx; - - // Fix for Idiots that try to troll the "ME" Nametag - if (strcasecmp((char *)packet->name.data, "ME") == 0) strcpy((char *)packet->name.data, "NOT ME"); - // Add Incoming Chat to HUD - //printf("Receive chat message %s", packet->base.message); NOTICE_LOG(SCENET, "Received chat message %s", packet->base.message); incoming = ""; name = (char *)packet->name.data; diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 2d504e560971..d3c6b6e69727 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -55,15 +55,12 @@ void ChatMenu::CreateViews() { CreatePopupContents(box_); root_->SetDefaultFocusView(box_); - this->UpdateChat(); + UpdateChat(); g_Config.iNewChat = 0; } void ChatMenu::dialogFinished(const Screen *dialog, DialogResult result) { UpdateUIState(UISTATE_INGAME); - // Close when a subscreen got closed. - // TODO: a bug in screenmanager causes this not to work here. - // screenManager()->finishDialog(this, DR_OK); } UI::EventReturn ChatMenu::OnSubmit(UI::EventParams &e) { @@ -84,7 +81,7 @@ std::vector Split(const std::string& str) int counter = 0; int firstSentenceEnd = 0; int secondSentenceEnd = 0; - NOTICE_LOG(HLE, "Splitted %s %i", str.c_str(),str.size()); + //NOTICE_LOG(HLE, "Splitted %s %i", str.c_str(),str.size()); for (auto i = 0; iSetTextColor(0xFF000000 | color); } } - this->ScrollChat(); + toBottom_ = true; } } @@ -142,29 +139,20 @@ bool ChatMenu::touch(const TouchInput &touch) { if (!box_->GetBounds().Contains(touch.x, touch.y)){ screenManager()->finishDialog(this, DR_BACK); - setChatPointer(NULL); //fix the random crash } return UIDialogScreen::touch(touch); } -void ChatMenu::update(InputState &input) { - PopupScreen::update(input); - this->ScrollChat(); -} - -void ChatMenu::sendMessage(const char *message, const char *value) { - // Always call the base class method first to handle the most common messages. - PopupScreen::sendMessage(message, value); - this->ScrollChat(); -} - -void ChatMenu::ScrollChat() { - if (scroll_) { +void ChatMenu::postRender() { + if (scroll_ && toBottom_) { scroll_->ScrollToBottom(); + toBottom_ = false; } } ChatMenu::~ChatMenu() { setChatPointer(NULL); + scroll_ = NULL; + chatVert_ = NULL; } diff --git a/UI/ChatScreen.h b/UI/ChatScreen.h index cf673413ba50..035624648c93 100644 --- a/UI/ChatScreen.h +++ b/UI/ChatScreen.h @@ -10,11 +10,8 @@ class ChatMenu : public PopupScreen { 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 UpdateChat(); - void ScrollChat(); -protected: - virtual void sendMessage(const char *message, const char *value); private: UI::EventReturn OnSubmit(UI::EventParams &e); UI::TextEdit *chatEdit_; From 6b390188680f263c76feb243c04a65df040769ef Mon Sep 17 00:00:00 2001 From: Ade Novan Date: Thu, 27 Oct 2016 17:06:58 +0800 Subject: [PATCH 11/26] Android chat empty after : fix --- UI/ChatScreen.h | 2 +- UI/NativeApp.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/UI/ChatScreen.h b/UI/ChatScreen.h index 035624648c93..c377f1fdcde7 100644 --- a/UI/ChatScreen.h +++ b/UI/ChatScreen.h @@ -11,7 +11,7 @@ class ChatMenu : public PopupScreen { void dialogFinished(const Screen *dialog, DialogResult result) override; bool touch(const TouchInput &touch) override; void postRender() override; - void UpdateChat(); + virtual void UpdateChat(); private: UI::EventReturn OnSubmit(UI::EventParams &e); UI::TextEdit *chatEdit_; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index d5753010168c..d50fd6451be1 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -858,8 +858,16 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) { g_Config.proAdhocServer = setString; if (inputboxValue[0] == "nickname") g_Config.sNickName = setString; - if (inputboxValue[0] == "Chat") - sendChat(setString); + if (inputboxValue[0] == "Chat") { + if (inputboxValue.size() > 2) + { + std::string chatString = value; + chatString.erase(0, 5); + sendChat(chatString); + } else { + sendChat(setString); + } + } inputboxValue.clear(); } if (msg == "bgImage_updated") { From e17b57d9cb7a2762be77d6a3c079877dbfa06546 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Thu, 27 Oct 2016 21:40:19 +0800 Subject: [PATCH 12/26] Add support OSK for windows --- UI/ChatScreen.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index d3c6b6e69727..66b2febac66b 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -10,6 +10,7 @@ #include "Core/HLE/proAdhoc.h" #include "i18n/i18n.h" #include +#include "util/text/utf8.h" void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { @@ -21,6 +22,16 @@ void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { #if defined(_WIN32) || defined(USING_QT_UI) chatEdit_ = bottom->Add(new TextEdit("", n->T("Chat Here"), new LinearLayoutParams(1.0))); + if (g_Config.bBypassOSKWithKeyboard && !g_Config.bFullScreen) + { + std::wstring titleText = ConvertUTF8ToWString(n->T("Chat")); + std::wstring defaultText = ConvertUTF8ToWString(n->T("Chat Here")); + std::wstring inputChars; + if (System_InputBoxGetWString(titleText.c_str(), defaultText, inputChars)) { + chatEdit_->SetText(ConvertWStringToUTF8(inputChars)); + } + } + chatEdit_->OnEnter.Handle(this, &ChatMenu::OnSubmit); bottom->Add(new Button(n->T("Send")))->OnClick.Handle(this, &ChatMenu::OnSubmit); #elif defined(__ANDROID__) From fae863310c13dcbcdca774db80cab5b138c1fca9 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Fri, 28 Oct 2016 05:11:05 +0800 Subject: [PATCH 13/26] Build fix for Linux QT --- UI/ChatScreen.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 66b2febac66b..11c283e64d4c 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -22,6 +22,7 @@ void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { #if defined(_WIN32) || defined(USING_QT_UI) chatEdit_ = bottom->Add(new TextEdit("", n->T("Chat Here"), new LinearLayoutParams(1.0))); +#if defined(USING_WIN_UI) if (g_Config.bBypassOSKWithKeyboard && !g_Config.bFullScreen) { std::wstring titleText = ConvertUTF8ToWString(n->T("Chat")); @@ -31,6 +32,7 @@ void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { chatEdit_->SetText(ConvertWStringToUTF8(inputChars)); } } +#endif chatEdit_->OnEnter.Handle(this, &ChatMenu::OnSubmit); bottom->Add(new Button(n->T("Send")))->OnClick.Handle(this, &ChatMenu::OnSubmit); From 1241d53a8a0f6e10e824d9aa636161e8c4354612 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Fri, 28 Oct 2016 06:46:31 +0800 Subject: [PATCH 14/26] Add translation of "You're in Offline Mode" --- Core/HLE/proAdhoc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index 0ec147e81734..f82351128a26 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -996,6 +996,7 @@ void setChatPointer(ChatMenu * chatmenu) { void sendChat(std::string chatString) { SceNetAdhocctlChatPacketC2S chat; + I18NCategory *n = GetI18NCategory("Networking"); chat.base.opcode = OPCODE_CHAT; //TODO check network inited, check send success or not, chatlog.pushback error on failed send, pushback error on not connected if (friendFinderRunning) @@ -1016,7 +1017,7 @@ void sendChat(std::string chatString) { } } else { - chatLog.push_back("You're in Offline Mode, go to lobby or online hall"); //need translation + chatLog.push_back(n->T("You're in Offline Mode, go to lobby or online hall")); if (ch) { ch->UpdateChat(); } From 6121dce9e138da7fc0e9d3a7efca7fc98ac8cd56 Mon Sep 17 00:00:00 2001 From: Ade Novan Date: Mon, 31 Oct 2016 22:22:57 +0800 Subject: [PATCH 15/26] remove pointer and using update() should fix random crash (thanks Uknown) --- Core/Config.h | 1 - Core/HLE/proAdhoc.cpp | 33 +++++++++++++-------------------- Core/HLE/proAdhoc.h | 5 +++-- UI/ChatScreen.cpp | 15 +++++++++++---- UI/ChatScreen.h | 3 ++- UI/EmuScreen.cpp | 10 +++------- 6 files changed, 32 insertions(+), 35 deletions(-) diff --git a/Core/Config.h b/Core/Config.h index bc65c531cb9b..381a1b954bb2 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -425,7 +425,6 @@ struct Config { int iWlanAdhocChannel; bool bWlanPowerSave; bool bEnableNetworkChat; - int iNewChat; int iPSPModel; int iFirmwareVersion; diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index f82351128a26..fdd31c39b0ec 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -56,10 +56,12 @@ SceNetAdhocPdpStat * pdp[255]; SceNetAdhocPtpStat * ptp[255]; uint32_t localip; std::vector chatLog; -ChatMenu * ch; std::string name = ""; std::string incoming = ""; std::string message = ""; +bool chatScreenVisible = false; +bool updateChatScreen = false; +int newChat = 0; int isLocalMAC(const SceNetEtherAddr * addr) { SceNetEtherAddr saddr; @@ -986,14 +988,6 @@ void freeFriendsRecursive(SceNetAdhocctlPeerInfo * node) { free(node); } -//@params chatmenu pass NULL on destroy, and pass ChatMenu On Create (EmuScreen.cpp) -void setChatPointer(ChatMenu * chatmenu) { - if (chatmenu != NULL) { - delete ch; - } - ch = chatmenu; //setChatPointer -} - void sendChat(std::string chatString) { SceNetAdhocctlChatPacketC2S chat; I18NCategory *n = GetI18NCategory("Networking"); @@ -1011,20 +1005,19 @@ void sendChat(std::string chatString) { NOTICE_LOG(SCENET, "Send Chat %s to Adhoc Server", chat.message); name = g_Config.sNickName.c_str(); chatLog.push_back(name.substr(0, 8) + ": " + chat.message); - if (ch) { - ch->UpdateChat(); + if (chatScreenVisible) { + updateChatScreen = true; } } } else { chatLog.push_back(n->T("You're in Offline Mode, go to lobby or online hall")); - if (ch) { - ch->UpdateChat(); + if (chatScreenVisible) { + updateChatScreen = true; } } } - std::vector getChatLog() { // this log used by chat screen if (chatLog.size() > 50) { @@ -1133,12 +1126,12 @@ int friendFinder(){ incoming.append((char *)packet->base.message); chatLog.push_back(incoming); //im new to pointer btw :( doesn't know its safe or not this should update the chat screen when data coming - if (ch) { - ch->UpdateChat(); + if (chatScreenVisible) { + updateChatScreen = true; } else { - if (g_Config.iNewChat < 50) { - g_Config.iNewChat += 1; + if (newChat < 50) { + newChat += 1; } } // Move RX Buffer @@ -1169,8 +1162,8 @@ int friendFinder(){ //joined.append((char *)packet->ip); chatLog.push_back(incoming); //im new to pointer btw :( doesn't know its safe or not this should update the chat screen when data coming - if (ch) { - ch->UpdateChat(); + if (chatScreenVisible) { + updateChatScreen = true; } // Update HUD User Count #ifdef LOCALHOST_AS_PEER diff --git a/Core/HLE/proAdhoc.h b/Core/HLE/proAdhoc.h index 5247f56b76ff..6d83e793b216 100644 --- a/Core/HLE/proAdhoc.h +++ b/Core/HLE/proAdhoc.h @@ -33,7 +33,6 @@ #include "Core/HLE/sceKernel.h" #include "Core/HLE/sceKernelMutex.h" #include "Core/HLE/sceUtility.h" -#include "UI/ChatScreen.h" class PointerWrap; @@ -847,9 +846,11 @@ void addFriend(SceNetAdhocctlConnectPacketS2C * packet); * Send chat or get that * @param std::string ChatString */ -void setChatPointer(ChatMenu * chatmenu); void sendChat(std::string chatString); std::vector getChatLog(); +extern bool chatScreenVisible; +extern bool updateChatScreen; +extern int newChat; /* * Find a Peer/Friend by MAC address diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 11c283e64d4c..1bbf7ceed5a7 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -69,7 +69,8 @@ void ChatMenu::CreateViews() { CreatePopupContents(box_); root_->SetDefaultFocusView(box_); UpdateChat(); - g_Config.iNewChat = 0; + chatScreenVisible = true; + newChat = 0; } void ChatMenu::dialogFinished(const Screen *dialog, DialogResult result) { @@ -142,6 +143,7 @@ void ChatMenu::UpdateChat() { } } toBottom_ = true; + updateChatScreen = false; } } @@ -157,6 +159,13 @@ bool ChatMenu::touch(const TouchInput &touch) { return UIDialogScreen::touch(touch); } +void ChatMenu::update(InputState &input) { + PopupScreen::update(input); + if (updateChatScreen) { + UpdateChat(); + } +} + void ChatMenu::postRender() { if (scroll_ && toBottom_) { scroll_->ScrollToBottom(); @@ -165,7 +174,5 @@ void ChatMenu::postRender() { } ChatMenu::~ChatMenu() { - setChatPointer(NULL); - scroll_ = NULL; - chatVert_ = NULL; + chatScreenVisible = false; } diff --git a/UI/ChatScreen.h b/UI/ChatScreen.h index c377f1fdcde7..701643aabbed 100644 --- a/UI/ChatScreen.h +++ b/UI/ChatScreen.h @@ -10,8 +10,9 @@ class ChatMenu : public PopupScreen { 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; - virtual void UpdateChat(); + void UpdateChat(); private: UI::EventReturn OnSubmit(UI::EventParams &e); UI::TextEdit *chatEdit_; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index f1f342a1c6ee..5ffec9aff053 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -373,9 +373,7 @@ void EmuScreen::sendMessage(const char *message, const char *value) { } } else if (!strcmp(message, "chat screen")) { releaseButtons(); - ChatMenu * ch = new ChatMenu(); - setChatPointer(ch); - screenManager()->push(ch); + screenManager()->push(new ChatMenu()); } } @@ -785,7 +783,7 @@ void EmuScreen::CreateViews() { } if (g_Config.bEnableNetworkChat) { //root_->Add(new Button(sc->T("Chat"), new AnchorLayoutParams(50, NONE, NONE, 50, true)))->OnClick.Handle(this, &EmuScreen::OnChat); - root_->Add(new ChoiceWithValueDisplay(&g_Config.iNewChat, sc->T("Chat"), new AnchorLayoutParams(130,WRAP_CONTENT,80, NONE, NONE, 50, true)))->OnClick.Handle(this, &EmuScreen::OnChat); + root_->Add(new ChoiceWithValueDisplay(&newChat, sc->T("Chat"), new AnchorLayoutParams(130,WRAP_CONTENT,80, NONE, NONE, 50, true)))->OnClick.Handle(this, &EmuScreen::OnChat); } saveStatePreview_ = new AsyncImageFileView("", IS_FIXED, nullptr, new AnchorLayoutParams(bounds.centerX(), 100, NONE, NONE, true)); saveStatePreview_->SetFixedSize(160, 90); @@ -807,9 +805,7 @@ UI::EventReturn EmuScreen::OnDevTools(UI::EventParams ¶ms) { UI::EventReturn EmuScreen::OnChat(UI::EventParams ¶ms) { releaseButtons(); - ChatMenu * ch = new ChatMenu(); // memory leak or not? - setChatPointer(ch); - screenManager()->push(ch); + screenManager()->push(new ChatMenu()); return UI::EVENT_DONE; } From 624d1cd82f6018a859e39b10b1b9b460d50d3671 Mon Sep 17 00:00:00 2001 From: Ade Novan Date: Mon, 5 Dec 2016 11:04:31 +0800 Subject: [PATCH 16/26] chat screen & chat button position and hide ui on show chat --- Core/Config.cpp | 3 ++- Core/Config.h | 16 +++++++++++++++- UI/ChatScreen.cpp | 34 +++++++++++++++++++++++++++++---- UI/EmuScreen.cpp | 40 +++++++++++++++++++++++++++++++++++++-- UI/GameSettingsScreen.cpp | 5 ++++- 5 files changed, 89 insertions(+), 9 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index c2b6ebdfc98f..8170cd5069e5 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -709,7 +709,8 @@ static ConfigSetting networkSettings[] = { ConfigSetting("EnableWlan", &g_Config.bEnableWlan, false, true, true), ConfigSetting("EnableAdhocServer", &g_Config.bEnableAdhocServer, false, true, true), ConfigSetting("EnableNetworkChat", &g_Config.bEnableNetworkChat, false, true, true), - + ConfigSetting("ChatButtonPosition",&g_Config.iChatButtonPosition,BOTTOM_LEFT,true,true), + ConfigSetting("ChatScreenPosition",&g_Config.iChatScreenPosition,BOTTOM_LEFT,true,true), ConfigSetting(false), }; diff --git a/Core/Config.h b/Core/Config.h index 381a1b954bb2..f2fbe11a42e3 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -77,6 +77,17 @@ enum IOTimingMethods { IOTIMING_REALISTIC = 2, }; +enum ChatPositions { + BOTTOM_LEFT = 0, + BOTTOM_CENTER = 1, + BOTOM_RIGHT = 2, + TOP_LEFT = 3, + TOP_CENTER = 4, + TOP_RIGHT = 5, + CENTER_LEFT = 6, + CENTER_RIGHT = 7, +}; + namespace http { class Download; class Downloader; @@ -425,7 +436,10 @@ struct Config { int iWlanAdhocChannel; bool bWlanPowerSave; bool bEnableNetworkChat; - + //for chat position , moveable buttons is better than this + int iChatButtonPosition; + int iChatScreenPosition; + int iPSPModel; int iFirmwareVersion; // TODO: Make this work with your platform, too! diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 1bbf7ceed5a7..9f22d6f342b9 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -23,17 +23,18 @@ void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { #if defined(_WIN32) || defined(USING_QT_UI) chatEdit_ = bottom->Add(new TextEdit("", n->T("Chat Here"), new LinearLayoutParams(1.0))); #if defined(USING_WIN_UI) + //freeze the ui when using ctrl + C hotkey need workaround if (g_Config.bBypassOSKWithKeyboard && !g_Config.bFullScreen) { std::wstring titleText = ConvertUTF8ToWString(n->T("Chat")); std::wstring defaultText = ConvertUTF8ToWString(n->T("Chat Here")); std::wstring inputChars; if (System_InputBoxGetWString(titleText.c_str(), defaultText, inputChars)) { - chatEdit_->SetText(ConvertWStringToUTF8(inputChars)); + //chatEdit_->SetText(ConvertWStringToUTF8(inputChars)); + sendChat(ConvertWStringToUTF8(inputChars)); } } #endif - chatEdit_->OnEnter.Handle(this, &ChatMenu::OnSubmit); bottom->Add(new Button(n->T("Send")))->OnClick.Handle(this, &ChatMenu::OnSubmit); #elif defined(__ANDROID__) @@ -56,8 +57,26 @@ void ChatMenu::CreateViews() { float yres = screenManager()->getUIContext()->GetBounds().h; - box_ = new LinearLayout(ORIENT_VERTICAL, - new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, 280, NONE, NONE, 250, true)); + switch (g_Config.iChatScreenPosition) { + case 0: + box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, 280, NONE, NONE, 250, true)); + break; + case 1: + box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, dc.GetBounds().centerX(), NONE, NONE, 250, true)); + break; + case 2: + box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, NONE, NONE, 280, 250, true)); + break; + case 3: + box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, 280, 250, NONE, NONE, true)); + break; + case 4: + box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, dc.GetBounds().centerX(), 250, NONE, NONE, true)); + break; + case 5: + box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, NONE, 250, 280, NONE, true)); + break; + } root_->Add(box_); box_->SetBG(UI::Drawable(0x66303030)); @@ -67,7 +86,14 @@ void ChatMenu::CreateViews() { box_->Add(title); 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; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 5ffec9aff053..f532ea6f4f74 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -84,6 +84,8 @@ AVIDump avi; #endif +UI::ChoiceWithValueDisplay *chatButtons; + static bool frameStep_; static int lastNumFlips; static bool startDumping; @@ -373,6 +375,10 @@ void EmuScreen::sendMessage(const char *message, const char *value) { } } else if (!strcmp(message, "chat screen")) { releaseButtons(); + //temporary workaround for hotkey its freeze the ui when open using hotkey and native keyboard is enable + if (g_Config.bBypassOSKWithKeyboard) osm.Show("Disable windows native keyboard options to use ctrl + c hotkey", 2.0f); + else + chatButtons->SetVisibility(UI::V_GONE); screenManager()->push(new ChatMenu()); } } @@ -782,8 +788,36 @@ void EmuScreen::CreateViews() { root_->Add(new Button("DevMenu"))->OnClick.Handle(this, &EmuScreen::OnDevTools); } if (g_Config.bEnableNetworkChat) { - //root_->Add(new Button(sc->T("Chat"), new AnchorLayoutParams(50, NONE, NONE, 50, true)))->OnClick.Handle(this, &EmuScreen::OnChat); - root_->Add(new ChoiceWithValueDisplay(&newChat, sc->T("Chat"), new AnchorLayoutParams(130,WRAP_CONTENT,80, NONE, NONE, 50, true)))->OnClick.Handle(this, &EmuScreen::OnChat); + switch (g_Config.iChatButtonPosition) { + case 0: + chatButtons = new ChoiceWithValueDisplay(&newChat, sc->T("Chat"), new AnchorLayoutParams(130, WRAP_CONTENT, 80, NONE, NONE, 50, true)); + break; + case 1: + chatButtons = new ChoiceWithValueDisplay(&newChat, sc->T("Chat"), new AnchorLayoutParams(130, WRAP_CONTENT, bounds.centerX(), NONE, NONE, 50, true)); + break; + case 2: + chatButtons = new ChoiceWithValueDisplay(&newChat, sc->T("Chat"), new AnchorLayoutParams(130, WRAP_CONTENT, NONE, NONE, 80, 50, true)); + break; + case 3: + chatButtons = new ChoiceWithValueDisplay(&newChat, sc->T("Chat"), new AnchorLayoutParams(130, WRAP_CONTENT, 80, 50, NONE, NONE, true)); + case 4: + chatButtons = new ChoiceWithValueDisplay(&newChat, sc->T("Chat"), new AnchorLayoutParams(130, WRAP_CONTENT, bounds.centerX(), 50, NONE, NONE, true)); + break; + case 5: + chatButtons = new ChoiceWithValueDisplay(&newChat, sc->T("Chat"), new AnchorLayoutParams(130, WRAP_CONTENT, NONE, 50, 80, NONE, true)); + break; + case 6: + chatButtons = new ChoiceWithValueDisplay(&newChat, sc->T("Chat"), new AnchorLayoutParams(130, WRAP_CONTENT, 80, bounds.centerY(), NONE, NONE, true)); + break; + case 7: + chatButtons = new ChoiceWithValueDisplay(&newChat, sc->T("Chat"), new AnchorLayoutParams(130, WRAP_CONTENT, NONE, bounds.centerY(), 80, NONE, true)); + break; + default: + chatButtons = new ChoiceWithValueDisplay(&newChat, sc->T("Chat"), new AnchorLayoutParams(130, WRAP_CONTENT, 80, NONE, NONE, 50, true)); + break; + } + + root_->Add(chatButtons)->OnClick.Handle(this, &EmuScreen::OnChat); } saveStatePreview_ = new AsyncImageFileView("", IS_FIXED, nullptr, new AnchorLayoutParams(bounds.centerX(), 100, NONE, NONE, true)); saveStatePreview_->SetFixedSize(160, 90); @@ -805,6 +839,7 @@ UI::EventReturn EmuScreen::OnDevTools(UI::EventParams ¶ms) { UI::EventReturn EmuScreen::OnChat(UI::EventParams ¶ms) { releaseButtons(); + if(chatButtons->GetVisibility() == UI::V_VISIBLE) chatButtons->SetVisibility(UI::V_GONE); screenManager()->push(new ChatMenu()); return UI::EVENT_DONE; } @@ -898,6 +933,7 @@ void EmuScreen::update() { } } } + } void EmuScreen::checkPowerDown() { diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index a933bbe077d6..fe1d74c1108e 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -620,7 +620,10 @@ void GameSettingsScreen::CreateViews() { networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sMACAddress, n->T("Change Mac Address"), nullptr))->OnClick.Handle(this, &GameSettingsScreen::OnChangeMacAddress); networkingSettings->Add(new PopupSliderChoice(&g_Config.iPortOffset, 0, 60000, n->T("Port offset", "Port offset(0 = PSP compatibility)"), 100, screenManager())); networkingSettings->Add(new CheckBox(&g_Config.bEnableNetworkChat, n->T("Enable network chat", "Enable network chat"))); - + static const char *chatButtonPositions[] = { "Bottom Left", "Bottom Center","Bottom Right","Top Left","Top Center", "Top Right","Center Left","Center Right" }; + networkingSettings->Add(new PopupMultiChoice(&g_Config.iChatButtonPosition, n->T("Chat Button Position"), chatButtonPositions, 0, ARRAY_SIZE(chatButtonPositions), "Chat Button Position", screenManager())); + static const char *chatScreenPositions[] = { "Bottom Left", "Bottom Center","Bottom Right","Top Left","Top Center", "Top Right" }; + networkingSettings->Add(new PopupMultiChoice(&g_Config.iChatScreenPosition, n->T("Chat Screen Position"), chatScreenPositions, 0, ARRAY_SIZE(chatScreenPositions), "Chat Screen Position", screenManager())); ViewGroup *toolsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); toolsScroll->SetTag("GameSettingsTools"); LinearLayout *tools = new LinearLayout(ORIENT_VERTICAL); From 6706698d213a74f4b33a2f9dc2c0d9ace88df917 Mon Sep 17 00:00:00 2001 From: Ade Novan Date: Mon, 5 Dec 2016 11:21:44 +0800 Subject: [PATCH 17/26] build fix --- UI/EmuScreen.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index f532ea6f4f74..a4625932974e 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -375,11 +375,18 @@ void EmuScreen::sendMessage(const char *message, const char *value) { } } else if (!strcmp(message, "chat screen")) { releaseButtons(); - //temporary workaround for hotkey its freeze the ui when open using hotkey and native keyboard is enable - if (g_Config.bBypassOSKWithKeyboard) osm.Show("Disable windows native keyboard options to use ctrl + c hotkey", 2.0f); - else +#if defined(USING_WIN_UI) + //temporary workaround for hotkey its freeze the ui when open chat screen using hotkey and native keyboard is enable + if (g_Config.bBypassOSKWithKeyboard) { + osm.Show("Disable windows native keyboard options to use ctrl + c hotkey", 2.0f); + } else { + chatButtons->SetVisibility(UI::V_GONE); + screenManager()->push(new ChatMenu()); + } +#else chatButtons->SetVisibility(UI::V_GONE); screenManager()->push(new ChatMenu()); +#endif } } From 97a4d6424f8c1d20a543c74e4fc492cf0fb2859d Mon Sep 17 00:00:00 2001 From: Gde Made Novan Priambhada Date: Thu, 8 Jun 2017 02:18:45 +0800 Subject: [PATCH 18/26] Rebased and fix the update scroll --- UI/ChatScreen.cpp | 29 +++++++++++++++++------------ UI/ChatScreen.h | 5 ++--- UI/EmuScreen.cpp | 11 ++++++++--- Windows/resource.h | 2 +- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 9f22d6f342b9..888a29503223 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 701643aabbed..2d07d439fffe 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 a4625932974e..aaabc47959c7 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 5c9ed521c332..f38f5ba43fd7 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. From 8ec2d50c28d9adb449dfa1ec0ec466d587c4851d Mon Sep 17 00:00:00 2001 From: Gde Made Novan Priambhada Date: Thu, 8 Jun 2017 02:26:49 +0800 Subject: [PATCH 19/26] Add virtual key for opening chat --- Common/KeyMap.cpp | 1 + Common/KeyMap.h | 1 + UI/EmuScreen.cpp | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/Common/KeyMap.cpp b/Common/KeyMap.cpp index 44a90043a47b..335e78d021d2 100644 --- a/Common/KeyMap.cpp +++ b/Common/KeyMap.cpp @@ -661,6 +661,7 @@ const KeyMap_IntStrPair psp_button_names[] = { {VIRTKEY_AXIS_RIGHT_Y_MIN, "RightAn.Down"}, {VIRTKEY_AXIS_RIGHT_X_MIN, "RightAn.Left"}, {VIRTKEY_AXIS_RIGHT_X_MAX, "RightAn.Right"}, + {VIRTKEY_OPENCHAT, "OpenChat" }, {VIRTKEY_AXIS_SWAP, "AxisSwap"}, {VIRTKEY_DEVMENU, "DevMenu"}, diff --git a/Common/KeyMap.h b/Common/KeyMap.h index 334b5a53f959..06b1246b8632 100644 --- a/Common/KeyMap.h +++ b/Common/KeyMap.h @@ -51,6 +51,7 @@ enum { VIRTKEY_AXIS_SWAP = 0x10012, VIRTKEY_DEVMENU = 0x10013, VIRTKEY_FRAME_ADVANCE = 0x10014, + VIRTKEY_OPENCHAT = 0x10015, VIRTKEY_LAST, VIRTKEY_COUNT = VIRTKEY_LAST - VIRTKEY_FIRST }; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index aaabc47959c7..bbc804b5e3b6 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -462,6 +462,14 @@ void EmuScreen::onVKeyDown(int virtualKeyCode) { } break; + case VIRTKEY_OPENCHAT: + if (g_Config.bEnableNetworkChat) { + releaseButtons(); + chatButtons->SetVisibility(UI::V_GONE); + screenManager()->push(new ChatMenu()); + } + break; + case VIRTKEY_AXIS_SWAP: KeyMap::SwapAxis(); break; From f5d56872cec7f1ab75713c589ba58232e5cb8181 Mon Sep 17 00:00:00 2001 From: Gde Made Novan Priambhada Date: Thu, 6 Jul 2017 21:43:39 +0800 Subject: [PATCH 20/26] Quick Chat --- Core/Config.cpp | 5 ++ Core/Config.h | 9 ++- UI/ChatScreen.cpp | 36 ++++++++++- UI/ChatScreen.h | 5 ++ UI/GameSettingsScreen.cpp | 127 ++++++++++++++++++++++++++++++++++++++ UI/GameSettingsScreen.h | 5 ++ UI/NativeApp.cpp | 10 +++ 7 files changed, 195 insertions(+), 2 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 8170cd5069e5..a3f8d99a04e9 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -711,6 +711,11 @@ static ConfigSetting networkSettings[] = { ConfigSetting("EnableNetworkChat", &g_Config.bEnableNetworkChat, false, true, true), ConfigSetting("ChatButtonPosition",&g_Config.iChatButtonPosition,BOTTOM_LEFT,true,true), ConfigSetting("ChatScreenPosition",&g_Config.iChatScreenPosition,BOTTOM_LEFT,true,true), + ConfigSetting("QuickChat1", &g_Config.sQuickChat0, "Quick Chat 1", true, true), + ConfigSetting("QuickChat2", &g_Config.sQuickChat1, "Quick Chat 2", true, true), + ConfigSetting("QuickChat3", &g_Config.sQuickChat2, "Quick Chat 3", true, true), + ConfigSetting("QuickChat4", &g_Config.sQuickChat3, "Quick Chat 4", true, true), + ConfigSetting("QuickChat5", &g_Config.sQuickChat4, "Quick Chat 5", true, true), ConfigSetting(false), }; diff --git a/Core/Config.h b/Core/Config.h index f2fbe11a42e3..deeaa682c7c9 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -439,7 +439,14 @@ struct Config { //for chat position , moveable buttons is better than this int iChatButtonPosition; int iChatScreenPosition; - + + bool bEnableQuickChat; + std::string sQuickChat0; + std::string sQuickChat1; + std::string sQuickChat2; + std::string sQuickChat3; + std::string sQuickChat4; + int iPSPModel; int iFirmwareVersion; // TODO: Make this work with your platform, too! diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 888a29503223..29d5b647b6ac 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -19,7 +19,6 @@ void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { LinearLayout *outer = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT,400)); scroll_ = outer->Add(new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0))); LinearLayout *bottom = outer->Add(new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, WRAP_CONTENT))); - #if defined(_WIN32) || defined(USING_QT_UI) chatEdit_ = bottom->Add(new TextEdit("", n->T("Chat Here"), new LinearLayoutParams(1.0))); #if defined(USING_WIN_UI) @@ -40,6 +39,15 @@ void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { #elif defined(__ANDROID__) bottom->Add(new Button(n->T("Chat Here"),new LayoutParams(FILL_PARENT, WRAP_CONTENT)))->OnClick.Handle(this, &ChatMenu::OnSubmit); #endif + + if (g_Config.bEnableQuickChat) { + LinearLayout *quickChat = outer->Add(new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, WRAP_CONTENT))); + quickChat->Add(new Button(n->T("1"), new LinearLayoutParams(1.0)))->OnClick.Handle(this, &ChatMenu::OnQuickChat1); + quickChat->Add(new Button(n->T("2"), new LinearLayoutParams(1.0)))->OnClick.Handle(this, &ChatMenu::OnQuickChat2); + quickChat->Add(new Button(n->T("3"), new LinearLayoutParams(1.0)))->OnClick.Handle(this, &ChatMenu::OnQuickChat3); + quickChat->Add(new Button(n->T("4"), new LinearLayoutParams(1.0)))->OnClick.Handle(this, &ChatMenu::OnQuickChat4); + quickChat->Add(new Button(n->T("5"), new LinearLayoutParams(1.0)))->OnClick.Handle(this, &ChatMenu::OnQuickChat5); + } chatVert_ = scroll_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT))); chatVert_->SetSpacing(0); parent->Add(outer); @@ -116,6 +124,32 @@ UI::EventReturn ChatMenu::OnSubmit(UI::EventParams &e) { return UI::EVENT_DONE; } + +UI::EventReturn ChatMenu::OnQuickChat1(UI::EventParams &e) { + sendChat(g_Config.sQuickChat0); + return UI::EVENT_DONE; +} + +UI::EventReturn ChatMenu::OnQuickChat2(UI::EventParams &e) { + sendChat(g_Config.sQuickChat1); + return UI::EVENT_DONE; +} + +UI::EventReturn ChatMenu::OnQuickChat3(UI::EventParams &e) { + sendChat(g_Config.sQuickChat2); + return UI::EVENT_DONE; +} + +UI::EventReturn ChatMenu::OnQuickChat4(UI::EventParams &e) { + sendChat(g_Config.sQuickChat3); + return UI::EVENT_DONE; +} + +UI::EventReturn ChatMenu::OnQuickChat5(UI::EventParams &e) { + sendChat(g_Config.sQuickChat4); + 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 diff --git a/UI/ChatScreen.h b/UI/ChatScreen.h index 2d07d439fffe..c99297a5245e 100644 --- a/UI/ChatScreen.h +++ b/UI/ChatScreen.h @@ -14,6 +14,11 @@ class ChatMenu : public PopupScreen { void UpdateChat(); private: UI::EventReturn OnSubmit(UI::EventParams &e); + UI::EventReturn OnQuickChat1(UI::EventParams &e); + UI::EventReturn OnQuickChat2(UI::EventParams &e); + UI::EventReturn OnQuickChat3(UI::EventParams &e); + UI::EventReturn OnQuickChat4(UI::EventParams &e); + UI::EventReturn OnQuickChat5(UI::EventParams &e); UI::TextEdit *chatEdit_; UI::ScrollView *scroll_; UI::LinearLayout *chatVert_; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index fe1d74c1108e..9b7e5cb6cec3 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -624,6 +624,53 @@ void GameSettingsScreen::CreateViews() { networkingSettings->Add(new PopupMultiChoice(&g_Config.iChatButtonPosition, n->T("Chat Button Position"), chatButtonPositions, 0, ARRAY_SIZE(chatButtonPositions), "Chat Button Position", screenManager())); static const char *chatScreenPositions[] = { "Bottom Left", "Bottom Center","Bottom Right","Top Left","Top Center", "Top Right" }; networkingSettings->Add(new PopupMultiChoice(&g_Config.iChatScreenPosition, n->T("Chat Screen Position"), chatScreenPositions, 0, ARRAY_SIZE(chatScreenPositions), "Chat Screen Position", screenManager())); + + networkingSettings->Add(new ItemHeader(co->T("QuickChat", "Quick Chat"))); + networkingSettings->Add(new CheckBox(&g_Config.bEnableQuickChat, co->T("QuickChat", "Enable Quick Chat"))); +#if !defined(MOBILE_DEVICE) && !defined(USING_QT_UI) // TODO: Add all platforms where KEY_CHAR support is added + PopupTextInputChoice *qc1 = networkingSettings->Add(new PopupTextInputChoice(&g_Config.sQuickChat0, sy->T("Quick Chat 1"), "", 32, screenManager())); + qc1->SetEnabledPtr(&g_Config.bEnableQuickChat); + PopupTextInputChoice *qc2 = networkingSettings->Add(new PopupTextInputChoice(&g_Config.sQuickChat1, sy->T("Quick Chat 2"), "", 32, screenManager())); + qc2->SetEnabledPtr(&g_Config.bEnableQuickChat); + PopupTextInputChoice *qc3 = networkingSettings->Add(new PopupTextInputChoice(&g_Config.sQuickChat2, sy->T("Quick Chat 3"), "", 32, screenManager())); + qc3->SetEnabledPtr(&g_Config.bEnableQuickChat); + PopupTextInputChoice *qc4 = networkingSettings->Add(new PopupTextInputChoice(&g_Config.sQuickChat3, sy->T("Quick Chat 4"), "", 32, screenManager())); + qc4->SetEnabledPtr(&g_Config.bEnableQuickChat); + PopupTextInputChoice *qc5 = networkingSettings->Add(new PopupTextInputChoice(&g_Config.sQuickChat4, sy->T("Quick Chat 5"), "", 32, screenManager())); + qc5->SetEnabledPtr(&g_Config.bEnableQuickChat); +#elif defined(USING_QT_UI) + Choice *qc1 = networkingSettings->Add(new Choice(sy->T("Quick Chat 1"))); + qc1->SetEnabledPtr(&g_Config.bEnableQuickChat); + qc1->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat0); + Choice *qc2 = networkingSettings->Add(new Choice(sy->T("Quick Chat 2"))); + qc2->SetEnabledPtr(&g_Config.bEnableQuickChat); + qc2->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat1); + Choice *qc3 = networkingSettings->Add(new Choice(sy->T("Quick Chat 3"))); + qc3->SetEnabledPtr(&g_Config.bEnableQuickChat); + qc3->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat2); + Choice *qc4 = networkingSettings->Add(new Choice(sy->T("Quick Chat 4"))); + qc4->SetEnabledPtr(&g_Config.bEnableQuickChat); + qc4->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat3); + Choice *qc5 = networkingSettings->Add(new Choice(sy->T("Quick Chat 5"))); + qc5->SetEnabledPtr(&g_Config.bEnableQuickChat); + qc5->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat4); +#elif defined(__ANDROID__) + ChoiceWithValueDisplay *qc1 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sNickName, sy->T("Quick Chat 1"), nullptr)); + qc1->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat0); + qc1->SetEnabledPtr(&g_Config.bEnableQuickChat); + ChoiceWithValueDisplay *qc2 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sNickName, sy->T("Quick Chat 2"), nullptr)); + qc2->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat1); + qc2->SetEnabledPtr(&g_Config.bEnableQuickChat); + ChoiceWithValueDisplay *qc3 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sNickName, sy->T("Quick Chat 3"), nullptr)); + qc3->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat2); + qc3->SetEnabledPtr(&g_Config.bEnableQuickChat); + ChoiceWithValueDisplay *qc4 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sNickName, sy->T("Quick Chat 4"), nullptr)); + qc4->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat3); + qc4->SetEnabledPtr(&g_Config.bEnableQuickChat); + ChoiceWithValueDisplay *qc5 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sNickName, sy->T("Quick Chat 5"), nullptr)); + qc5->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat4); + qc5->SetEnabledPtr(&g_Config.bEnableQuickChat); +#endif ViewGroup *toolsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); toolsScroll->SetTag("GameSettingsTools"); LinearLayout *tools = new LinearLayout(ORIENT_VERTICAL); @@ -1096,6 +1143,86 @@ UI::EventReturn GameSettingsScreen::OnRenderingBackend(UI::EventParams &e) { return UI::EVENT_DONE; } +UI::EventReturn GameSettingsScreen::OnChangeQuickChat0(UI::EventParams &e) { +#if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) + const size_t chat_len = 64; + + char chat[chat_len]; + memset(chat, 0, sizeof(chat)); + + if (System_InputBoxGetString("Enter Quick Chat 1", g_Config.sQuickChat0.c_str(), chat, chat_len)) { + g_Config.sQuickChat0 = chat; + } +#elif defined(__ANDROID__) + System_SendMessage("inputbox", ("quickchat0:" + g_Config.).c_str()); +#endif + return UI::EVENT_DONE; +} + +UI::EventReturn GameSettingsScreen::OnChangeQuickChat1(UI::EventParams &e) { +#if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) + const size_t chat_len = 64; + + char chat[chat_len]; + memset(chat, 0, sizeof(chat)); + + if (System_InputBoxGetString("Enter Quick Chat 2", g_Config.sQuickChat1.c_str(), chat, chat_len)) { + g_Config.sQuickChat1 = chat; + } +#elif defined(__ANDROID__) + System_SendMessage("inputbox", ("quickchat1:" + g_Config.).c_str()); +#endif + return UI::EVENT_DONE; +} + +UI::EventReturn GameSettingsScreen::OnChangeQuickChat2(UI::EventParams &e) { +#if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) + const size_t chat_len = 64; + + char chat[chat_len]; + memset(chat, 0, sizeof(chat)); + + if (System_InputBoxGetString("Enter Quick Chat 3", g_Config.sQuickChat2.c_str(), chat, chat_len)) { + g_Config.sQuickChat2 = chat; + } +#elif defined(__ANDROID__) + System_SendMessage("inputbox", ("quickchat2:" + g_Config.).c_str()); +#endif + return UI::EVENT_DONE; +} + +UI::EventReturn GameSettingsScreen::OnChangeQuickChat3(UI::EventParams &e) { +#if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) + const size_t chat_len = 64; + + char chat[chat_len]; + memset(chat, 0, sizeof(chat)); + + if (System_InputBoxGetString("Enter Quick Chat 4", g_Config.sQuickChat3.c_str(), chat, chat_len)) { + g_Config.sQuickChat3 = chat; + } +#elif defined(__ANDROID__) + System_SendMessage("inputbox", ("quickchat3:" + g_Config.).c_str()); +#endif + return UI::EVENT_DONE; +} + +UI::EventReturn GameSettingsScreen::OnChangeQuickChat4(UI::EventParams &e) { +#if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) + const size_t chat_len = 64; + + char chat[chat_len]; + memset(chat, 0, sizeof(chat)); + + if (System_InputBoxGetString("Enter Quick Chat 5", g_Config.sQuickChat4.c_str(), chat, chat_len)) { + g_Config.sQuickChat4 = chat; + } +#elif defined(__ANDROID__) + System_SendMessage("inputbox", ("quickchat4:" + g_Config.).c_str()); +#endif + return UI::EVENT_DONE; +} + UI::EventReturn GameSettingsScreen::OnChangeNickname(UI::EventParams &e) { #if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) const size_t name_len = 256; diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index cb17a1ce2fd4..e6965d1e3c17 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -76,6 +76,11 @@ class GameSettingsScreen : public UIDialogScreenWithGameBackground { UI::EventReturn OnPostProcShaderChange(UI::EventParams &e); UI::EventReturn OnDeveloperTools(UI::EventParams &e); UI::EventReturn OnRemoteISO(UI::EventParams &e); + UI::EventReturn OnChangeQuickChat0(UI::EventParams &e); + UI::EventReturn OnChangeQuickChat1(UI::EventParams &e); + UI::EventReturn OnChangeQuickChat2(UI::EventParams &e); + UI::EventReturn OnChangeQuickChat3(UI::EventParams &e); + UI::EventReturn OnChangeQuickChat4(UI::EventParams &e); UI::EventReturn OnChangeNickname(UI::EventParams &e); UI::EventReturn OnChangeproAdhocServerAddress(UI::EventParams &e); UI::EventReturn OnChangeMacAddress(UI::EventParams &e); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index d50fd6451be1..6ca0a73db9e0 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -856,6 +856,16 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) { std::string setString = inputboxValue.size() > 1 ? inputboxValue[1] : ""; if (inputboxValue[0] == "IP") g_Config.proAdhocServer = setString; + if (inputboxValue[0] == "quickchat0") + g_Config.sQuickChat0 = setString; + if (inputboxValue[0] == "quickchat1") + g_Config.sQuickChat1 = setString; + if (inputboxValue[0] == "quickchat2") + g_Config.sQuickChat2 = setString; + if (inputboxValue[0] == "quickchat3") + g_Config.sQuickChat3 = setString; + if (inputboxValue[0] == "quickchat4") + g_Config.sQuickChat4 = setString; if (inputboxValue[0] == "nickname") g_Config.sNickName = setString; if (inputboxValue[0] == "Chat") { From 4420719a860d97d17eed4e7c869d3bf1e0a42979 Mon Sep 17 00:00:00 2001 From: Gde Made Novan Priambhada Date: Sat, 8 Jul 2017 18:08:33 +0800 Subject: [PATCH 21/26] Bug fix --- Core/Config.cpp | 1 + UI/ChatScreen.cpp | 80 ++++++++++++++++++++++++--------------- UI/ChatScreen.h | 4 +- UI/EmuScreen.cpp | 15 +++++--- UI/EmuScreen.h | 2 +- UI/GameSettingsScreen.cpp | 20 +++++----- android/ab.cmd | 2 +- 7 files changed, 74 insertions(+), 50 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index a3f8d99a04e9..49ba96f07e92 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -711,6 +711,7 @@ static ConfigSetting networkSettings[] = { ConfigSetting("EnableNetworkChat", &g_Config.bEnableNetworkChat, false, true, true), ConfigSetting("ChatButtonPosition",&g_Config.iChatButtonPosition,BOTTOM_LEFT,true,true), ConfigSetting("ChatScreenPosition",&g_Config.iChatScreenPosition,BOTTOM_LEFT,true,true), + ConfigSetting("EnableQuickChat", &g_Config.bEnableQuickChat, true, true, true), ConfigSetting("QuickChat1", &g_Config.sQuickChat0, "Quick Chat 1", true, true), ConfigSetting("QuickChat2", &g_Config.sQuickChat1, "Quick Chat 2", true, true), ConfigSetting("QuickChat3", &g_Config.sQuickChat2, "Quick Chat 3", true, true), diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 29d5b647b6ac..817aff9d707c 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -88,7 +88,7 @@ void ChatMenu::CreateViews() { } root_->Add(box_); - box_->SetBG(UI::Drawable(0x66303030)); + box_->SetBG(UI::Drawable(0x99303030)); box_->SetHasDropShadow(false); View *title = new PopupHeader(n->T("Chat")); @@ -96,15 +96,18 @@ void ChatMenu::CreateViews() { CreatePopupContents(box_); #if defined(_WIN32) || defined(USING_QT_UI) + UI::EnableFocusMovement(true); root_->SetDefaultFocusView(box_); box_->SubviewFocused(chatEdit_); root_->SetFocus(); #else - root_->SetDefaultFocusView(box_); + //root_->SetDefaultFocusView(box_); + //box_->SubviewFocused(scroll_); + //root_->SetFocus(); #endif chatScreenVisible = true; newChat = 0; - UI::EnableFocusMovement(true); + UpdateChat(); } @@ -162,28 +165,25 @@ std::vector Split(const std::string& str) int counter = 0; int firstSentenceEnd = 0; int secondSentenceEnd = 0; + int spliton = 45; + for (auto i = 0; i 35) { - secondSentenceEnd = i; + else if (i > spliton) { + firstSentenceEnd = spliton; } } } if (firstSentenceEnd == 0) { - firstSentenceEnd = 35; + firstSentenceEnd = spliton; } - - if(secondSentenceEnd == 0){ - secondSentenceEnd = str.length(); - } - ret.push_back(str.substr(0, firstSentenceEnd)); - ret.push_back(str.substr(firstSentenceEnd, secondSentenceEnd)); + ret.push_back(str.substr(firstSentenceEnd)); return ret; } @@ -194,22 +194,42 @@ void ChatMenu::UpdateChat() { std::vector chatLog = getChatLog(); for (auto i : chatLog) { //split long text - if (i.length() > 30) { - std::vector splitted = Split(i); - for (auto j : splitted) { - TextView *v = chatVert_->Add(new TextView(j, FLAG_DYNAMIC_ASCII, false)); - uint32_t color = 0xFFFFFF; - v->SetTextColor(0xFF000000 | color); - } + uint32_t namecolor = 0xF6B629; + uint32_t textcolor = 0xFFFFFF; + uint32_t infocolor = 0x35D8FD; + + std::string name = g_Config.sNickName.c_str(); + std::string displayname = i.substr(0, i.find(':')); + std::string chattext = i.substr(displayname.length()); + + if (name.substr(0, 8) == displayname) { + namecolor = 0x3539E5; + } + + if (i[displayname.length()] != ':') { + TextView *v = chatVert_->Add(new TextView(i, FLAG_DYNAMIC_ASCII, true)); + v->SetTextColor(0xFF000000 | infocolor); } else { - TextView *v = chatVert_->Add(new TextView(i, FLAG_DYNAMIC_ASCII, false)); - uint32_t color = 0xFFFFFF; - v->SetTextColor(0xFF000000 | color); + LinearLayout *line = chatVert_->Add(new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, FILL_PARENT))); + TextView *nameView = line->Add(new TextView(displayname, FLAG_DYNAMIC_ASCII, true)); + nameView->SetTextColor(0xFF000000 | namecolor); + if (chattext.length() > 45) { + std::vector splitted = Split(chattext); + std::string one = splitted[0]; + std::string two = splitted[1]; + TextView *oneview = line->Add(new TextView(one, FLAG_DYNAMIC_ASCII, true)); + oneview->SetTextColor(0xFF000000 | textcolor); + TextView *twoview = chatVert_->Add(new TextView(two, FLAG_DYNAMIC_ASCII, true)); + twoview->SetTextColor(0xFF000000 | textcolor); + } + else { + TextView *chatView = line->Add(new TextView(chattext, FLAG_DYNAMIC_ASCII, true)); + chatView->SetTextColor(0xFF000000 | textcolor); + } } } toBottom_ = true; - updateChatScreen = false; } } @@ -227,14 +247,14 @@ bool ChatMenu::touch(const TouchInput &touch) { void ChatMenu::update() { PopupScreen::update(); + if (scroll_ && toBottom_) { + toBottom_ = false; + scroll_->ScrollToBottom(); + } + if (updateChatScreen) { UpdateChat(); - } - else { - if (scroll_ && toBottom_) { - toBottom_ = false; - scroll_->ScrollToBottom(); - } + updateChatScreen = false; } } diff --git a/UI/ChatScreen.h b/UI/ChatScreen.h index c99297a5245e..ecb6d1546e3a 100644 --- a/UI/ChatScreen.h +++ b/UI/ChatScreen.h @@ -4,7 +4,7 @@ class ChatMenu : public PopupScreen { public: - ChatMenu() : PopupScreen("Chat") , toBottom_(false) {} + ChatMenu() : PopupScreen("Chat") , toBottom_(true) {} ~ChatMenu(); void CreatePopupContents(UI::ViewGroup *parent) override; void CreateViews() override; @@ -12,6 +12,7 @@ class ChatMenu : public PopupScreen { bool touch(const TouchInput &touch) override; void update() override; void UpdateChat(); + bool toBottom_; private: UI::EventReturn OnSubmit(UI::EventParams &e); UI::EventReturn OnQuickChat1(UI::EventParams &e); @@ -23,5 +24,4 @@ class ChatMenu : public PopupScreen { UI::ScrollView *scroll_; UI::LinearLayout *chatVert_; UI::ViewGroup *box_; - bool toBottom_; }; \ No newline at end of file diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index bbc804b5e3b6..34f5089bfd95 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -129,6 +129,7 @@ EmuScreen::EmuScreen(const std::string &filename) startDumping = false; OnDevMenu.Handle(this, &EmuScreen::OnDevTools); + OnChatMenu.Handle(this, &EmuScreen::OnChat); } void EmuScreen::bootGame(const std::string &filename) { @@ -381,14 +382,16 @@ void EmuScreen::sendMessage(const char *message, const char *value) { 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()); + releaseButtons(); + UI::EventParams e{}; + OnChatMenu.Trigger(e); } } #else if (g_Config.bEnableNetworkChat) { - chatButtons->SetVisibility(UI::V_GONE); - screenManager()->push(new ChatMenu()); + releaseButtons(); + UI::EventParams e{}; + OnChatMenu.Trigger(e); } #endif } @@ -465,8 +468,8 @@ void EmuScreen::onVKeyDown(int virtualKeyCode) { case VIRTKEY_OPENCHAT: if (g_Config.bEnableNetworkChat) { releaseButtons(); - chatButtons->SetVisibility(UI::V_GONE); - screenManager()->push(new ChatMenu()); + UI::EventParams e{}; + OnChatMenu.Trigger(e); } break; diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index 2057f6835b29..4fe120c96c04 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -71,7 +71,7 @@ class EmuScreen : public UIScreen { void checkPowerDown(); UI::Event OnDevMenu; - + UI::Event OnChatMenu; bool bootPending_; std::string gamePath_; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 9b7e5cb6cec3..deb06ec15e91 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -655,19 +655,19 @@ void GameSettingsScreen::CreateViews() { qc5->SetEnabledPtr(&g_Config.bEnableQuickChat); qc5->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat4); #elif defined(__ANDROID__) - ChoiceWithValueDisplay *qc1 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sNickName, sy->T("Quick Chat 1"), nullptr)); + ChoiceWithValueDisplay *qc1 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sQuickChat0, sy->T("Quick Chat 1"), nullptr)); qc1->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat0); qc1->SetEnabledPtr(&g_Config.bEnableQuickChat); - ChoiceWithValueDisplay *qc2 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sNickName, sy->T("Quick Chat 2"), nullptr)); + ChoiceWithValueDisplay *qc2 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sQuickChat1, sy->T("Quick Chat 2"), nullptr)); qc2->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat1); qc2->SetEnabledPtr(&g_Config.bEnableQuickChat); - ChoiceWithValueDisplay *qc3 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sNickName, sy->T("Quick Chat 3"), nullptr)); + ChoiceWithValueDisplay *qc3 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sQuickChat2, sy->T("Quick Chat 3"), nullptr)); qc3->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat2); qc3->SetEnabledPtr(&g_Config.bEnableQuickChat); - ChoiceWithValueDisplay *qc4 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sNickName, sy->T("Quick Chat 4"), nullptr)); + ChoiceWithValueDisplay *qc4 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sQuickChat3, sy->T("Quick Chat 4"), nullptr)); qc4->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat3); qc4->SetEnabledPtr(&g_Config.bEnableQuickChat); - ChoiceWithValueDisplay *qc5 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sNickName, sy->T("Quick Chat 5"), nullptr)); + ChoiceWithValueDisplay *qc5 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sQuickChat4, sy->T("Quick Chat 5"), nullptr)); qc5->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat4); qc5->SetEnabledPtr(&g_Config.bEnableQuickChat); #endif @@ -1154,7 +1154,7 @@ UI::EventReturn GameSettingsScreen::OnChangeQuickChat0(UI::EventParams &e) { g_Config.sQuickChat0 = chat; } #elif defined(__ANDROID__) - System_SendMessage("inputbox", ("quickchat0:" + g_Config.).c_str()); + System_SendMessage("inputbox", ("quickchat0:" + g_Config.sQuickChat0).c_str()); #endif return UI::EVENT_DONE; } @@ -1170,7 +1170,7 @@ UI::EventReturn GameSettingsScreen::OnChangeQuickChat1(UI::EventParams &e) { g_Config.sQuickChat1 = chat; } #elif defined(__ANDROID__) - System_SendMessage("inputbox", ("quickchat1:" + g_Config.).c_str()); + System_SendMessage("inputbox", ("quickchat1:" + g_Config.sQuickChat1).c_str()); #endif return UI::EVENT_DONE; } @@ -1186,7 +1186,7 @@ UI::EventReturn GameSettingsScreen::OnChangeQuickChat2(UI::EventParams &e) { g_Config.sQuickChat2 = chat; } #elif defined(__ANDROID__) - System_SendMessage("inputbox", ("quickchat2:" + g_Config.).c_str()); + System_SendMessage("inputbox", ("quickchat2:" + g_Config.sQuickChat2).c_str()); #endif return UI::EVENT_DONE; } @@ -1202,7 +1202,7 @@ UI::EventReturn GameSettingsScreen::OnChangeQuickChat3(UI::EventParams &e) { g_Config.sQuickChat3 = chat; } #elif defined(__ANDROID__) - System_SendMessage("inputbox", ("quickchat3:" + g_Config.).c_str()); + System_SendMessage("inputbox", ("quickchat3:" + g_Config.sQuickChat3).c_str()); #endif return UI::EVENT_DONE; } @@ -1218,7 +1218,7 @@ UI::EventReturn GameSettingsScreen::OnChangeQuickChat4(UI::EventParams &e) { g_Config.sQuickChat4 = chat; } #elif defined(__ANDROID__) - System_SendMessage("inputbox", ("quickchat4:" + g_Config.).c_str()); + System_SendMessage("inputbox", ("quickchat4:" + g_Config.sQuickChat4).c_str()); #endif return UI::EVENT_DONE; } diff --git a/android/ab.cmd b/android/ab.cmd index 6befeb03b341..c2506530a973 100644 --- a/android/ab.cmd +++ b/android/ab.cmd @@ -5,6 +5,6 @@ copy ..\assets\langregion.ini assets\langregion.ini copy ..\assets\compat.ini assets\compat.ini copy ..\assets\Roboto-Condensed.ttf assets\Roboto-Condensed.ttf copy ..\assets\*.png assets\ -SET NDK=C:\AndroidNDK +SET NDK=D:\Android\NDK SET NDK_MODULE_PATH=..\ext;..\ext\native\ext %NDK%/ndk-build -j9 %* From f236ea1fc9f11aaebc063c0bcf4610a91744cb3f Mon Sep 17 00:00:00 2001 From: Gde Made Novan Priambhada Date: Wed, 9 Aug 2017 04:19:28 +0800 Subject: [PATCH 22/26] group chat options and set enabled ptr --- UI/ChatScreen.cpp | 2 +- UI/GameSettingsScreen.cpp | 9 ++++++--- android/ab.cmd | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 817aff9d707c..a8619780ed40 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -35,9 +35,9 @@ void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { } #endif chatEdit_->OnEnter.Handle(this, &ChatMenu::OnSubmit); - bottom->Add(new Button(n->T("Send")))->OnClick.Handle(this, &ChatMenu::OnSubmit); #elif defined(__ANDROID__) bottom->Add(new Button(n->T("Chat Here"),new LayoutParams(FILL_PARENT, WRAP_CONTENT)))->OnClick.Handle(this, &ChatMenu::OnSubmit); + bottom->Add(new Button(n->T("Send")))->OnClick.Handle(this, &ChatMenu::OnSubmit); #endif if (g_Config.bEnableQuickChat) { diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index deb06ec15e91..2813fae774db 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -619,12 +619,14 @@ void GameSettingsScreen::CreateViews() { networkingSettings->Add(new CheckBox(&g_Config.bEnableAdhocServer, n->T("Enable built-in PRO Adhoc Server", "Enable built-in PRO Adhoc Server"))); networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sMACAddress, n->T("Change Mac Address"), nullptr))->OnClick.Handle(this, &GameSettingsScreen::OnChangeMacAddress); networkingSettings->Add(new PopupSliderChoice(&g_Config.iPortOffset, 0, 60000, n->T("Port offset", "Port offset(0 = PSP compatibility)"), 100, screenManager())); + + + networkingSettings->Add(new ItemHeader(ms->T("Chat"))); networkingSettings->Add(new CheckBox(&g_Config.bEnableNetworkChat, n->T("Enable network chat", "Enable network chat"))); static const char *chatButtonPositions[] = { "Bottom Left", "Bottom Center","Bottom Right","Top Left","Top Center", "Top Right","Center Left","Center Right" }; - networkingSettings->Add(new PopupMultiChoice(&g_Config.iChatButtonPosition, n->T("Chat Button Position"), chatButtonPositions, 0, ARRAY_SIZE(chatButtonPositions), "Chat Button Position", screenManager())); + networkingSettings->Add(new PopupMultiChoice(&g_Config.iChatButtonPosition, n->T("Chat Button Position"), chatButtonPositions, 0, ARRAY_SIZE(chatButtonPositions), "Chat Button Position", screenManager()))->SetEnabledPtr(&g_Config.bEnableNetworkChat); static const char *chatScreenPositions[] = { "Bottom Left", "Bottom Center","Bottom Right","Top Left","Top Center", "Top Right" }; - networkingSettings->Add(new PopupMultiChoice(&g_Config.iChatScreenPosition, n->T("Chat Screen Position"), chatScreenPositions, 0, ARRAY_SIZE(chatScreenPositions), "Chat Screen Position", screenManager())); - + networkingSettings->Add(new PopupMultiChoice(&g_Config.iChatScreenPosition, n->T("Chat Screen Position"), chatScreenPositions, 0, ARRAY_SIZE(chatScreenPositions), "Chat Screen Position", screenManager()))->SetEnabledPtr(&g_Config.bEnableNetworkChat); networkingSettings->Add(new ItemHeader(co->T("QuickChat", "Quick Chat"))); networkingSettings->Add(new CheckBox(&g_Config.bEnableQuickChat, co->T("QuickChat", "Enable Quick Chat"))); #if !defined(MOBILE_DEVICE) && !defined(USING_QT_UI) // TODO: Add all platforms where KEY_CHAR support is added @@ -671,6 +673,7 @@ void GameSettingsScreen::CreateViews() { qc5->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat4); qc5->SetEnabledPtr(&g_Config.bEnableQuickChat); #endif + ViewGroup *toolsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); toolsScroll->SetTag("GameSettingsTools"); LinearLayout *tools = new LinearLayout(ORIENT_VERTICAL); diff --git a/android/ab.cmd b/android/ab.cmd index c2506530a973..b176024cf94d 100644 --- a/android/ab.cmd +++ b/android/ab.cmd @@ -5,6 +5,6 @@ copy ..\assets\langregion.ini assets\langregion.ini copy ..\assets\compat.ini assets\compat.ini copy ..\assets\Roboto-Condensed.ttf assets\Roboto-Condensed.ttf copy ..\assets\*.png assets\ -SET NDK=D:\Android\NDK +SET NDK=C:\Android\NDK SET NDK_MODULE_PATH=..\ext;..\ext\native\ext %NDK%/ndk-build -j9 %* From 5382efd44efa9689aa92d7f8af0d60e478e803de Mon Sep 17 00:00:00 2001 From: Ade Novan Date: Wed, 9 Aug 2017 06:04:34 +0800 Subject: [PATCH 23/26] Update ab.cmd --- android/ab.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/ab.cmd b/android/ab.cmd index b176024cf94d..6befeb03b341 100644 --- a/android/ab.cmd +++ b/android/ab.cmd @@ -5,6 +5,6 @@ copy ..\assets\langregion.ini assets\langregion.ini copy ..\assets\compat.ini assets\compat.ini copy ..\assets\Roboto-Condensed.ttf assets\Roboto-Condensed.ttf copy ..\assets\*.png assets\ -SET NDK=C:\Android\NDK +SET NDK=C:\AndroidNDK SET NDK_MODULE_PATH=..\ext;..\ext\native\ext %NDK%/ndk-build -j9 %* From 93b59afed5d1b8c58ca23f141a53fdc365c3cc84 Mon Sep 17 00:00:00 2001 From: ANR2ME Date: Tue, 3 Mar 2020 00:23:12 +0700 Subject: [PATCH 24/26] Fix building errors --- Core/HLE/proAdhoc.cpp | 2 +- UI/ChatScreen.cpp | 4 ++-- UI/EmuScreen.cpp | 5 +---- UI/GameSettingsScreen.cpp | 10 +++++----- android/jni/Android.mk | 2 +- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index 9069798448fc..c24ea7a140fa 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -990,7 +990,7 @@ void freeFriendsRecursive(SceNetAdhocctlPeerInfo * node) { void sendChat(std::string chatString) { SceNetAdhocctlChatPacketC2S chat; - I18NCategory *n = GetI18NCategory("Networking"); + auto n = GetI18NCategory("Networking"); chat.base.opcode = OPCODE_CHAT; //TODO check network inited, check send success or not, chatlog.pushback error on failed send, pushback error on not connected if (friendFinderRunning) diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index a8619780ed40..0f3dae16fe4a 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -15,7 +15,7 @@ void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { using namespace UI; - I18NCategory *n = GetI18NCategory("Networking"); + auto n = GetI18NCategory("Networking"); LinearLayout *outer = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT,400)); scroll_ = outer->Add(new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0))); LinearLayout *bottom = outer->Add(new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, WRAP_CONTENT))); @@ -56,7 +56,7 @@ void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { void ChatMenu::CreateViews() { using namespace UI; - I18NCategory *n = GetI18NCategory("Networking"); + auto n = GetI18NCategory("Networking"); UIContext &dc = *screenManager()->getUIContext(); AnchorLayout *anchor = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 5929ad523e91..8c5abb02b9d8 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -444,21 +444,19 @@ void EmuScreen::sendMessage(const char *message, const char *value) { gstate_c.skipDrawReason &= ~SKIPDRAW_WINDOW_MINIMIZED; } } else if (!strcmp(message, "chat screen")) { - releaseButtons(); + #if defined(USING_WIN_UI) //temporary workaround for hotkey its freeze the ui when open chat screen using hotkey and native keyboard is enable if (g_Config.bBypassOSKWithKeyboard) { osm.Show("Disable windows native keyboard options to use ctrl + c hotkey", 2.0f); } else { if (g_Config.bEnableNetworkChat) { - releaseButtons(); UI::EventParams e{}; OnChatMenu.Trigger(e); } } #else if (g_Config.bEnableNetworkChat) { - releaseButtons(); UI::EventParams e{}; OnChatMenu.Trigger(e); } @@ -555,7 +553,6 @@ void EmuScreen::onVKeyDown(int virtualKeyCode) { case VIRTKEY_OPENCHAT: if (g_Config.bEnableNetworkChat) { - releaseButtons(); UI::EventParams e{}; OnChatMenu.Trigger(e); } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 9d35e4c0387e..db5e4443e409 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -708,19 +708,19 @@ void GameSettingsScreen::CreateViews() { qc5->SetEnabledPtr(&g_Config.bEnableQuickChat); qc5->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat4); #elif defined(__ANDROID__) - ChoiceWithValueDisplay *qc1 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sQuickChat0, sy->T("Quick Chat 1"), nullptr)); + ChoiceWithValueDisplay *qc1 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sQuickChat0, sy->T("Quick Chat 1"), (const char *)nullptr)); qc1->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat0); qc1->SetEnabledPtr(&g_Config.bEnableQuickChat); - ChoiceWithValueDisplay *qc2 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sQuickChat1, sy->T("Quick Chat 2"), nullptr)); + ChoiceWithValueDisplay *qc2 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sQuickChat1, sy->T("Quick Chat 2"), (const char *)nullptr)); qc2->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat1); qc2->SetEnabledPtr(&g_Config.bEnableQuickChat); - ChoiceWithValueDisplay *qc3 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sQuickChat2, sy->T("Quick Chat 3"), nullptr)); + ChoiceWithValueDisplay *qc3 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sQuickChat2, sy->T("Quick Chat 3"), (const char *)nullptr)); qc3->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat2); qc3->SetEnabledPtr(&g_Config.bEnableQuickChat); - ChoiceWithValueDisplay *qc4 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sQuickChat3, sy->T("Quick Chat 4"), nullptr)); + ChoiceWithValueDisplay *qc4 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sQuickChat3, sy->T("Quick Chat 4"), (const char *)nullptr)); qc4->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat3); qc4->SetEnabledPtr(&g_Config.bEnableQuickChat); - ChoiceWithValueDisplay *qc5 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sQuickChat4, sy->T("Quick Chat 5"), nullptr)); + ChoiceWithValueDisplay *qc5 = networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sQuickChat4, sy->T("Quick Chat 5"), (const char *)nullptr)); qc5->OnClick.Handle(this, &GameSettingsScreen::OnChangeQuickChat4); qc5->SetEnabledPtr(&g_Config.bEnableQuickChat); #endif diff --git a/android/jni/Android.mk b/android/jni/Android.mk index f6fd2c74d237..d334324cf82d 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -494,7 +494,7 @@ LOCAL_SRC_FILES := \ $(SRC)/android/jni/native-audio-so.cpp \ $(SRC)/UI/BackgroundAudio.cpp \ $(SRC)/UI/DiscordIntegration.cpp \ - $(SRC)/UI/ChatScreen.cpp\ + $(SRC)/UI/ChatScreen.cpp \ $(SRC)/UI/DevScreens.cpp \ $(SRC)/UI/DisplayLayoutEditor.cpp \ $(SRC)/UI/DisplayLayoutScreen.cpp \ From 394194f4002333830209cc60af03481fa9a14aa3 Mon Sep 17 00:00:00 2001 From: ANR2ME Date: Tue, 3 Mar 2020 00:59:20 +0700 Subject: [PATCH 25/26] Fix chat color formatting --- UI/ChatScreen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 0f3dae16fe4a..ddcf259c86f1 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -194,16 +194,16 @@ void ChatMenu::UpdateChat() { std::vector chatLog = getChatLog(); for (auto i : chatLog) { //split long text - uint32_t namecolor = 0xF6B629; + uint32_t namecolor = 0x29B6F6; uint32_t textcolor = 0xFFFFFF; - uint32_t infocolor = 0x35D8FD; + uint32_t infocolor = 0xFDD835; std::string name = g_Config.sNickName.c_str(); std::string displayname = i.substr(0, i.find(':')); std::string chattext = i.substr(displayname.length()); if (name.substr(0, 8) == displayname) { - namecolor = 0x3539E5; + namecolor = 0xE53935; } if (i[displayname.length()] != ':') { From dc4df7d769d8894c73d443fa9b07f2c5689b4503 Mon Sep 17 00:00:00 2001 From: ANR2ME Date: Tue, 3 Mar 2020 01:52:31 +0700 Subject: [PATCH 26/26] Tweaked chatbox a little bit --- UI/ChatScreen.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index ddcf259c86f1..f7873b65a3ca 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -66,24 +66,24 @@ 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 + // the chat screen size is still static 280x240 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)); + box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, 280, NONE, NONE, 240, true)); break; case 1: - box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, dc.GetBounds().centerX(), NONE, NONE, 250, true)); + box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, dc.GetBounds().centerX(), NONE, NONE, 240, true)); break; case 2: - box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, NONE, NONE, 280, 250, true)); + box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, NONE, NONE, 280, 240, true)); break; case 3: - box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, 280, 250, NONE, NONE, true)); + box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, 280, 240, NONE, NONE, true)); break; case 4: - box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, dc.GetBounds().centerX(), 250, NONE, NONE, true)); + box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, dc.GetBounds().centerX(), 240, NONE, NONE, true)); break; case 5: - box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, NONE, 250, 280, NONE, true)); + box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, NONE, 240, 280, NONE, true)); break; } @@ -167,7 +167,7 @@ std::vector Split(const std::string& str) int secondSentenceEnd = 0; int spliton = 45; - for (auto i = 0; i