This commit is contained in:
Gde Made Novan Priambhada committed 2017-08-09 03:50:31 +08:00
1 parent f5d56872ce
commit 4420719a86
7 files changed
+74 -50

No files matched your search

+1
View File
@@ -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),
+50 -30
View File
@@ -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<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;
}
@@ -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;
}
}
@@ -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;
}
}
+2 -2
View File
@@ -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 @@ public:
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 @@ private:
UI::ScrollView *scroll_;
UI::LinearLayout *chatVert_;
UI::ViewGroup *box_;
bool toBottom_;
};
+9 -6
View File
@@ -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;
+1 -1
View File
@@ -71,7 +71,7 @@ private:
void checkPowerDown();
UI::Event OnDevMenu;
UI::Event OnChatMenu;
bool bootPending_;
std::string gamePath_;
+10 -10
View File
@@ -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;
}
+1 -1
View File
@@ -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 %*