From f514b25c79e10d31496d7449aff7f4cb2f744305 Mon Sep 17 00:00:00 2001 From: Ade Novan Date: Tue, 25 Oct 2016 18:35:52 +0800 Subject: [PATCH] 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 87fdcabadf..5301d991b3 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 8504bb162d..2d504e5609 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 32ea47c49e..cf673413ba 100644 --- a/UI/ChatScreen.h +++ b/UI/ChatScreen.h @@ -12,6 +12,9 @@ public: 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 9b1eab79e6..f1f342a1c6 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 4764317960..49a5e5d146 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 a324f42896..90c000f212 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 f105eb9739..5c9ed521c3 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