Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat feature based on Adenovan's Rechat branch #12667

Merged
merged 27 commits into from
Mar 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
10e874c
PPSSPP early chat feature rebranched
adenovan Oct 21, 2016
bd2342a
Enable chat box
sum2012 Oct 21, 2016
08a1cc7
Add translation
sum2012 Oct 21, 2016
07b1d8b
pointer fix random crash & better substring logic
adenovan Oct 22, 2016
2874c6d
Oops it still random crashed destructor do the fix well
adenovan Oct 22, 2016
18525ea
Android Chat Support
adenovan Oct 23, 2016
5187b9f
Add New Chat Counter
adenovan Oct 24, 2016
f514b25
Windows CTRL + C Hotkey
adenovan Oct 25, 2016
20b289c
cmake buildfix
adenovan Oct 25, 2016
766373e
pointer and scroll fix
adenovan Oct 26, 2016
6b39018
Android chat empty after : fix
adenovan Oct 27, 2016
e17b57d
Add support OSK for windows
sum2012 Oct 27, 2016
fae8633
Build fix for Linux QT
sum2012 Oct 27, 2016
1241d53
Add translation of "You're in Offline Mode"
sum2012 Oct 27, 2016
6121dce
remove pointer and using update() should fix random crash (thanks Ukn…
adenovan Oct 31, 2016
624d1cd
chat screen & chat button position and hide ui on show chat
adenovan Dec 5, 2016
6706698
build fix
adenovan Dec 5, 2016
97a4d64
Rebased and fix the update scroll
adenovan Jun 7, 2017
8ec2d50
Add virtual key for opening chat
adenovan Jun 7, 2017
f5d5687
Quick Chat
adenovan Jul 6, 2017
4420719
Bug fix
adenovan Jul 8, 2017
f236ea1
group chat options and set enabled ptr
adenovan Aug 8, 2017
5382efd
Update ab.cmd
adenovan Aug 8, 2017
142e609
Merge branch 'rechat' of https://github.com/adenovan/amultios-ppsspp …
anr2me Mar 2, 2020
93b59af
Fix building errors
anr2me Mar 2, 2020
394194f
Fix chat color formatting
anr2me Mar 2, 2020
dc4df7d
Tweaked chatbox a little bit
anr2me Mar 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Bug fix
  • Loading branch information
adenovan committed Aug 8, 2017
commit 4420719a860d97d17eed4e7c869d3bf1e0a42979
1 change: 1 addition & 0 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
80 changes: 50 additions & 30 deletions UI/ChatScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,26 @@ 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"));
box_->Add(title);

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();
}

Expand Down Expand Up @@ -162,28 +165,25 @@ std::vector<std::string> Split(const std::string& str)
int counter = 0;
int firstSentenceEnd = 0;
int secondSentenceEnd = 0;
int spliton = 45;

for (auto i = 0; i<str.length(); i++) {
if (isspace(str[i])) {
if (i < 35) {
if (i < spliton) {
if(str[i-1]!=':')
firstSentenceEnd = i+1;
}
else if (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;
}

Expand All @@ -194,22 +194,42 @@ void ChatMenu::UpdateChat() {
std::vector<std::string> chatLog = getChatLog();
for (auto i : chatLog) {
//split long text
if (i.length() > 30) {
std::vector<std::string> 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<std::string> 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;
}
}

Expand All @@ -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;
}
}

Expand Down
4 changes: 2 additions & 2 deletions UI/ChatScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

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;
void dialogFinished(const Screen *dialog, DialogResult result) override;
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);
Expand All @@ -23,5 +24,4 @@ class ChatMenu : public PopupScreen {
UI::ScrollView *scroll_;
UI::LinearLayout *chatVert_;
UI::ViewGroup *box_;
bool toBottom_;
};
15 changes: 9 additions & 6 deletions UI/EmuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion UI/EmuScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class EmuScreen : public UIScreen {
void checkPowerDown();

UI::Event OnDevMenu;

UI::Event OnChatMenu;
bool bootPending_;
std::string gamePath_;

Expand Down
20 changes: 10 additions & 10 deletions UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion android/ab.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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 %*