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

Feature request: Ad-Hoc multiplayer chat support #7451

Closed
lightfirst opened this issue Feb 7, 2015 · 35 comments
Closed

Feature request: Ad-Hoc multiplayer chat support #7451

lightfirst opened this issue Feb 7, 2015 · 35 comments

Comments

@lightfirst
Copy link

when I play Multiplayer, PPSSPP will show some message such as "Network Initialized".
Could PPSSPP show more, show some chatting message.
for example: nickname, ping value, someone join in this lobby, someone left.

@sum2012
Copy link
Collaborator

sum2012 commented Feb 9, 2015

Mark:
The ping value 's sample code is in
http://tangentsoft.net/wskfaq/examples/src/dllping.cpp

@hrydgard
Copy link
Owner

hrydgard commented Feb 9, 2015

@sum2012 , was that posted in the wrong thread?

@lightfirst Yeah, I suppose that could be a good idea, where possible. I'll check and see what can be done soon.

@sum2012
Copy link
Collaborator

sum2012 commented Feb 9, 2015

If someone want to imp icmp,that link should be good ref

@hrydgard
Copy link
Owner

Ah, I missed that he was asking for that.

@lightfirst
Copy link
Author

@hrydgard I try add this code " osm.Show( packet->base.message, 3.0);" to proAdhoc.cpp
It can make PPSSPP show the chat message from JPCSP or PSP. looks like ppsspp also have a chat, but not enable/finished
http://forums.ppsspp.org/showthread.php?tid=14264&page=5

@hrydgard
Copy link
Owner

Ah, I see. Yeah, that doesn't look too hard... I'll put something in after 1.0.1 is finished

@hrydgard hrydgard changed the title could someone add a way to show some chatting message? Feature request: Ad-Hoc multiplayer chat support Feb 10, 2015
@lightfirst
Copy link
Author

1.0.1 is finished, what do you plan to do?
BTW, I try add some code myself:
proAdhoc.cpp


                // Add Incoming Chat to HUD
                -//printf("Receive chat message %s", packet->base.message);
                +// show message from adhocserver
                                    +char *name = (char *)packet->name.data, *blank = ": ", *message = packet->base.message;
                +std::string destination = std::string(name) + std::string(blank) + std::string(message);
                +osm.Show(destination, 3.0f);

                // Add User
                addFriend(packet);

                // Update HUD User Count
                +//show play joined, so we can know who joined, it isn't list player name though
                +char *name = (char *)packet->name.data, *blank = " joined";
                +std::string destination = std::string(name) + std::string(blank);
                +osm.Show(destination, 3.0f);

                // Delete User by IP, should delete by MAC since IP can be shared (behind NAT) isn't?
                deleteFriendByIP(packet->ip);

                // Update HUD User Count
                +// show play left. not work, do I did something long?
                +char *name = (char *)packet->name.data, *blank = " left";
                +std::string destination = std::string(name) + std::string(blank);
                +osm.Show(destination, 3.0f);

proAdhoc.h
typedef struct {
SceNetAdhocctlPacketBase base;
uint32_t ip;
+SceNetAdhocctlNickname name;


any one can finished Send Chat Messages?
// Send Chat Messages
//while(popFromOutbox(chat.message))
//{
// // Send Chat to Server
// sceNetInetSend(metasocket, (const char *)&chat, sizeof(chat), 0);
//}

@NgJinXiang14
Copy link

Does this feature is done?I hope it can add to android because when i use openvpn to play with other player,we cant chat and cant use app such as facebook messager to chat because we cant use internet when connect to vpn.

@adenovan
Copy link
Contributor

adenovan commented Oct 15, 2016

sorry for bothering you @hrydgard , im trying to implement this chat feature but have many questions in my mind.

  1. Can ppsspp make a chat screen without pausing the core, something that not like pause screen, i see the debug log if we pausing the emulator with esc key. the log is stopped that means the core game is paused too right?
  2. is it possible to build something like osm but instead of a text only its display chat screen that contains chat data from proadhoc.cpp and and contains textbox to send chat to the server, something like this?
    chat
  3. Can android On screen touch used as toogle to hide or show the chat screen? like chat button on the image. android will call keyboard fullscreen if want to input something, an example like input nickname in system settings. so it will be a problem or not for the core to keep running?
  4. for windows user that map game key to keyboard can we use the keyboard to input text and focused to textbox in chat screen, when core is still running?

thats a lot of question and im not sure what file to look for build an overlay screen on ppsspp, also i never had a GUI Programming in C++ this the first time but i really enjoy to learn something new :D.

Edit
Here is the part when im stuck tried to implement this. a Text box in top of emu screen and can send text message in top of it, if someone can tell me how to do that it will be a great help. for the rest of code an client server chat implementation should be easy because atpro have a working sample code.
image

@adenovan
Copy link
Contributor

adenovan commented Oct 19, 2016

i manage to create the GUI and send the text to server and this is so far the progress @hrydgard , is it good enough?

screenshot 112

To Do Next :
-display the chat into screen (its easy)
-add shortcut key (or map key in controller) as a toogle to display or hide the chat screen on windows ( didn't know how to do that)
-add options enable chat on networking(lazy to implement).

@hrydgard
Copy link
Owner

Sorry for not responding above, I got the message when busy then forgot.

Looks like a good start, keep at it :) As you found out it's very possible to add UI on top of the game by adding it in EmuScreen.

@adenovan
Copy link
Contributor

@hrydgard ah no problem, i learn a lot by not having the answer :D , basic chat is working i think , need a friend to test the chat, but we have GUI problem on Textview and TextEdit, TextEdit need to auto scroll right when the character exceed the Text Edit Width. and the TextView need a dynamic height so a long text exceed the width of textview not be a problem. here is the sample issues can we fix it?
screenshot 118

im trying to use the layout params wrap content for the textview but it still not working

void ChatMenu::UpdateChat() {
using namespace UI;
chatVert_->Clear();
std::vectorstd::string chatLog = getChatLog();
for (auto i : chatLog) {
TextView *v = chatVert_->Add(new TextView(i, FLAG_DYNAMIC_ASCII, false,
new LayoutParams(PopupWidth(), WRAP_CONTENT)));
uint32_t color = 0xFFFFFF;
v->SetTextColor(0xFF000000 | color);
}
toBottom_ = true;
}
`

@adenovan
Copy link
Contributor

@hrydgard it's done, need a options enable chat and better substring logic (on whitespace). should i make a pull request now? or just commit it on my branch? @sum2012 can you help add the options on the networking part and correct my substr logic ?
image

@sum2012
Copy link
Collaborator

sum2012 commented Oct 21, 2016

@adenovan where is your code in your branch ?

@adenovan
Copy link
Contributor

@sum2012 adenovan@d254a8d

@sum2012
Copy link
Collaborator

sum2012 commented Oct 21, 2016

@adenovan recently, we have moved the lang folder,maybe you need re-fork the source again.
I cannot test your code because of conflict
1

@sum2012
Copy link
Collaborator

sum2012 commented Oct 21, 2016

I try to ignore the conflict,build error

10>Core.lib(proAdhoc.obj) : error LNK2019: unresolved external symbol "public: void __cdecl ChatMenu::UpdateChat(void)" (?UpdateChat@ChatMenu@@QEAAXXZ) referenced in function "int __cdecl friendFinder(void)" (?friendFinder@@yahxz)
10>UI.lib(EmuScreen.obj) : error LNK2001: unresolved external symbol "public: virtual void __cdecl ChatMenu::CreatePopupContents(class UI::ViewGroup *)" (?CreatePopupContents@ChatMenu@@UEAAXPEAVViewGroup@UI@@@z)
10>UI.lib(EmuScreen.obj) : error LNK2001: unresolved external symbol "public: virtual void __cdecl ChatMenu::CreateViews(void)" (?CreateViews@ChatMenu@@UEAAXXZ)
10>UI.lib(EmuScreen.obj) : error LNK2001: unresolved external symbol "public: virtual void __cdecl ChatMenu::dialogFinished(class Screen const *,enum DialogResult)" (?dialogFinished@ChatMenu@@UEAAXPEBVScreen@@W4DialogResult@@@z)
10>UI.lib(EmuScreen.obj) : error LNK2001: unresolved external symbol "public: virtual bool __cdecl ChatMenu::touch(struct TouchInput const &)" (?touch@ChatMenu@@UEAA_NAEBUTouchInput@@@z)
10>..\PPSSPPWindows64.exe : fatal error LNK1120: 5 unresolved externals

@adenovan
Copy link
Contributor

@sum2012 ok wait will do rebranch now

@adenovan
Copy link
Contributor

@sum2012 done adenovan@b3db60b

@sum2012
Copy link
Collaborator

sum2012 commented Oct 21, 2016

@adenovan Well done,I test two computer chat okay.
2

@sum2012
Copy link
Collaborator

sum2012 commented Oct 21, 2016

@adenovan
1:Do you mean that I need to add option of "Chat" button visable or not ?
2:For substr , I don't know it.

@adenovan
Copy link
Contributor

adenovan commented Oct 21, 2016

@sum2012 ok just help me with add options to enable and disable the chat buttons

its looks like good enough, but it still have random crash on chatScreen pointer. i give a chatscreen instance to proAdhoc.cpp , on EmuScreen.cpp , sometimes its crashed when joined message coming without opening the chat feature, sometimes its not. try to reproduce the issues but didn't get it.

improvement we can make for future :

  • Different chat color for send and receive
  • Auto scroll TextEdit to the right when typing long text
  • hide chat button when ChatScreen displayed
  • Add shortcut key alt+c or add map keys options in ppsspp control to display the chatScreen
  • Substring character on white space before 30 n character . so it will look better (ChatScreen.cpp TODO) .
  • Maybe change the packet headers for chat [64] character but it will make a problem missing text after 64 character in original server (coldbird.server)
  • the chatscreen size is different on different resolution (need to fix this) but im not good with math
  • Limit the chatlog vector size to 50 chat only, if the chatLog is long enough or hold many of string i think it will cause a problem or performance drop

@sum2012
Copy link
Collaborator

sum2012 commented Oct 21, 2016

@adenovan I have made a pull request in adenovan#1

@adenovan
Copy link
Contributor

@sum2012 ok sum merged thanks for the translation and the options, im trying to build on android now and test the chatScreen on mobile device

@sum2012
Copy link
Collaborator

sum2012 commented Oct 21, 2016

It is possable to make OSK for android
see https://github.com/hrydgard/ppsspp/blob/master/UI/GameSettingsScreen.cpp#L981
I need to sleep now and torromow need to go to work,

@adenovan
Copy link
Contributor

@sum2012 yeah will do it now, thanks for the info.

@adenovan
Copy link
Contributor

found the random crash error, how to produce, showchat > join room > hide chat > showchat > join room (crashed).

tried to guess it maybe proAdhoc.cpp not updating the pointer, i already check null pointer on every call to chat screen on proAdhoc.cpp but its still crashed.
https://github.com/adenovan/ppsspp/blob/rechat/UI/EmuScreen.cpp#L786

this line get Acess violation reading location
https://github.com/adenovan/ppsspp/blob/rechat/UI/ChatScreen.cpp#L96

on release build sometimes write location sometimes read location
screenshot 123
screenshot 124

what i tried

  • making chatMenu class singleton (crashed with heap when opened the chat screen first time)

not tried yet

  • extern chatMenu like osm but not sure it will works.

@sum2012
Copy link
Collaborator

sum2012 commented Oct 21, 2016

how to join room 2 times without leave room ?

showchat > join room > hide chat > showchat > join room

@adenovan
Copy link
Contributor

I tried it with monster hunter game. It will crash if somone inside the guildhall and give joined message with second times chatlog instance. The main problem is Updating the chat from proadhoc.cpp. Ah my bad im leaving the room actually. Here is the flow, join room > showchat (new chatscreen1 ) > hidechat > leave room > showchat (new chatscreen2) > join room (crashed). Looks like when joining proadhoc.cpp chatmenu instance pointing to chatscreen1 address. Or maybe update chat is still in middle of loop and the address changed. Ah im really new to this C++ pointer and addressing. Not much I can do about this

@sum2012
Copy link
Collaborator

sum2012 commented Oct 22, 2016

Compile error in Android
1

@adenovan
Copy link
Contributor

@sum2012 its not added to android make yet. im still working in random crash issues and make a fix just a hour ago :) , right now i am still testing with my buddy over the internet :). will post the result tommorow if not encountering a crash again its ready for pull request. you can check the changes on my branch.

@adenovan
Copy link
Contributor

adenovan commented Oct 22, 2016

@hrydgard can i add more asset to ppsspp? its a sound asset to used when chat coming and the chatscreen is not visible so user know there is a chat coming from other player. is there any sample code to play sound asset in ppsspp? what is the best file format for that? aac,mp3,wav?

still uploading a online gameplay video now https://youtu.be/Cj00RmIg6oI , so far so good there is no random crash again in 2 hours of gameplay

@domnicap
Copy link

I'm looking the game so on ,where can we download it?

@unknownbrackets
Copy link
Collaborator

I think some degree of chat support is now available. Is this issue / feature request fixed?

-[Unknown]

@hrydgard hrydgard added this to the v1.10.0 milestone Mar 15, 2020
@hrydgard
Copy link
Owner

Yeah let's close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants