mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Android Chat Support
This commit is contained in:
parent
2874c6d7d7
commit
18525ea523
@ -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();
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
|
@ -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 <ctype.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,5 @@ private:
|
||||
UI::ScrollView *scroll_;
|
||||
UI::LinearLayout *chatVert_;
|
||||
UI::ViewGroup *box_;
|
||||
UI::Button *defaultButton_;
|
||||
bool toBottom_;
|
||||
};
|
@ -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") {
|
||||
|
@ -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 \
|
||||
|
Loading…
Reference in New Issue
Block a user