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
Copy server invite code to the clipboard automatically #9739
Conversation
I'm +1 to this feature, but not how it's hidden from anyone who hasn't seen this PR. 😃 Personally I would prefer a |
Setting clipboard data is "destructive" in the sense that it clears out whatever the user may have already had in their clipboard, which the user may have deemed valuable. Also, as @2TallTyler mentions, how would anyone even know that this happened so that they could actually make use of it? I think adding an explicit button would be a better design, even if it's more work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to make a button for copying the code, that makes it clear that clicking this button will replace the user's clipboard contents.
Don't silently overwrite the user's clipboard.
I've added a 'copy to clipboard' button to GUI |
Please, don't care too much about this. Perhaps my opinion will be parochial and overly conservative for you, but... |
The invite code is for players to join their friends' games without having to list the game publicly. See #9434. But the value of this approach has nothing to do with this PR, which simply aims to make it easier to share the invite code. |
I thought invite code was a way to join servers behind NAT? It looks pretty
important to me.
…On Mon, 13 Dec 2021, 07:40 Tyler Trahan, ***@***.***> wrote:
The invite code is for players to join their friends' games without having
to list the game publicly. See #9434
<#9434>. But the value of this
approach has nothing to do with this PR, which simply aims to make it
easier to share the invite code.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#9739 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABF5QC7V5SPPQWFVIUECP3UQWBOJANCNFSM5JXZVA6A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
@LC-Zorg That's why the invite code is important: It's the easy way to let others join your private game. |
Ok, I don't use it and I don't think it will be any different in the future for me, but I can understand there is a need for some to hide the server. However, I think there are at least one maybe two significant issues with this feature that make its functionality significantly limited, and in its current form, at least from my point of view, it is more problematic than useful. It is independent of this PR, so I will write about it elsewhere. (#9746) (#9747) If I understand the code correctly, this copy button is in the client list window in the server settings field. If so, I think there is no problem and it is a good solution. :) Previously, I thought this might be for the server list window, and that wouldn't be good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like others I am generally +1 to this feature, but I don't understand the current implementation
Why is set_clipboard_text
stored at all? Why not just call SDL_SetClipboardText
directly in VideoDriver::SetClipboardContents
?
Because it must be called from the SDL main thread, not from the game
thread.
…On Wed, 5 Jan 2022, 14:42 Charles Pigott, ***@***.***> wrote:
***@***.**** commented on this pull request.
Like others I am generally +1 to this feature, but I don't understand the
current implementation
Why is set_clipboard_text stored at all? Why not just call
SDL_SetClipboardText directly in VideoDriver::SetClipboardContents ?
—
Reply to this email directly, view it on GitHub
<#9739 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABF5QCBBUU5LUBGP5H7ROLUUQ4D5ANCNFSM5JXZVA6A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When actually squashing/merging, maybe note that it is SDL2 for now?
One tricky thing from the user's point of view is that is a button that does nothing (unless they use SDL2). That might be considered buggy behaviour, so does that make this patch bugged?
And what would be the best way to remedy this? Implementing it for the other platforms as well in this PR? Or ship it buggy and hope the maintainers fix those bugs? Or introduce some manner where the UI can ask the video driver whether it supports writing to the clipboard and then disable the button when the video driver doesn't support it?
Isn't SDL2 used for all release binaries that are published to openttd.org? |
SDL2 is used only on linux builds. |
Eh okay. SDL2 is designed to abstract away Linux/Windows/MacOS differences,
it seems counter-intuitive that OpenTTD is not using this feature.
Well, we can copypaste SDL2 implementation at least.
https://github.com/libsdl-org/SDL/blob/main/src/video/windows/SDL_windowsclipboard.c#L51
https://github.com/libsdl-org/SDL/blob/main/src/video/cocoa/SDL_cocoaclipboard.m#L29
…On Fri, 4 Feb 2022, 22:44 Loïc Guilloux, ***@***.***> wrote:
SDL2 is used only on linux builds.
—
Reply to this email directly, view it on GitHub
<#9739 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABF5QF34FJXL2FY6W6CXL3UZQ3ERANCNFSM5JXZVA6A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I don't see a point shipping a build with a button that doesn't work for the majority of users. (I imagine Linux will be more prevalent among OpenTTD users than the average, but W3 Schools says it's used by about 4.3% of users.) |
Yes, releasing the feature only for Linux makes little sense.
I'm not using Windows or MacOS, I can only point to SDL2 clipboard
implementation. Someone else will need to fill in the missing code in this
patch.
…On Sat, 5 Feb 2022, 00:04 Tyler Trahan, ***@***.***> wrote:
I don't see a point shipping a build with a button that doesn't work for
the majority of users. (I imagine Linux will be more prevalent among
OpenTTD users than the average, but W3 Schools says it's used by
<https://www.w3schools.com/browsers/browsers_os.asp> about 4.3% of users.)
—
Reply to this email directly, view it on GitHub
<#9739 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABF5QASQZBHDAC5F4CKLP3UZREN3ANCNFSM5JXZVA6A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I was about to say that the Win32 and Cocoa video drivers also support setting the clipboard, but I was mixing that up with the getting clipboard function, which is implemented in the OS code and not video driver. OpenTTD/src/os/windows/win32.cpp Lines 511 to 531 in 7f0efbe
OpenTTD/src/os/macosx/macos.mm Lines 191 to 206 in 7f0efbe
Lines 271 to 289 in 7f0efbe
I think it would make the most sense to move this code to the video driver (because the concept of a clipboard is usually quite tightly bound to the "exterior" windowing system used), and then of course implement setting the clipboard for all platforms as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues with this at all, but it needs to support more than just SDL2 before being merged
As @pelya posted on TT-Forums a month ago, he will likely not be working on this any time in the near future. |
This is a great feature but the PR can't be merged without supporting all OSs. Since @pelya has indicated that he's not willing/able to add that support, I'm closing the PR. Feel free to reopen if you disagree or have code that makes it work for other OSs. 🙂 |
Motivation / Problem
When you create a server, you need to type the server invite code into email/chat letter by letter to send it to friends.
Description
With this patch, the invite code is copied to the clipboard automatically when the server registers with the masterserver.
Limitations
I am too lazy to add 'Copy to clipboard' button to the server info dialog, this is good enough for me.
This code works only with SDL2, other video backends will ignore the clipboard for now.
Checklist for review