-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Implement dropShadow property which shows where widget will drop #1501
Conversation
While dragging a clone of the widget is added to target holders to show where that widget will be dropped to.
PR-SERVER-BOT: You can play around with it here: https://test.virtualtabletop.io/PR-1501/pr-test (or any other room on that server) After merging, a backup will be available at |
Doesn't work when dragging a pile handle. |
A couple of other things
|
I added this to the cardDefaults thinking it might work:
But that just makes the pile drag handle the target instead of the holder. So the pile drag handle turns gray. |
Yeah, this is because it currently does a shallow clone, so only the dragged widget (i.e. pile handle) is shown. This is an easy fix - and I can implement that other feature I've wanted - the recursive clone option. |
Yeah, I could see an argument for making this a property of the holder rather than the widget. It's slightly harder technically since I'll need to do an ancestor check but not that hard. I'd be curious to hear what others think.
Also something we could "fix" if we wanted - avoid counting the shadow widget in the pile count.
I was able to style it via the global css, see the widget id Note that to disable the filter you have to set filter to |
* Recursive clone to support complex structures. * Use id of shadow widget to not fail if something else deletes it. * Clone top child in presence of piles.
@96LawDawg I made a few changes around some of the things you brought up. Dragging a pile will now clone the top-most child in the pile rather than the pile handle. Also piles don't count the shadow widget anymore. The clone code now also supports recursion and is shared with the clone function. Let me know what you think :-). |
Do you know about the existing clone function that's also used by the JSON editor command? I didn't look at yours in detail yet but at a glance it seems like duplicated functionality. |
Do the shadow widgets get synced to state (all players see); if so, what happens with the clones if a client get disconnected in the middle of a dragging operation? |
Yep, I'm aware, I've shared the code in the latest update of the PR. Update: Oh, not the clone function, the editor command. I'll have to take a look. |
Yes, I think this is the best way to make sure it behaves the same as dropping the widget and ensure that everything stays in sync.
It stays. I'll look into how to detect drags still in process vs disconnected users and clean it up appropriately. |
Well, if you didn't feel fully welcomed to VTT yet, now you are. Because piles are hard. And your improvement is great and works as expected when a pile already exists. BUT, it doesn't work when first making a pile. Demo: Put 1 card into a holder that does piles. Then drag and hover over that holder. You get a pile indicator of 1 before there is a pile. |
Haha thanks! I think what I really want is a property similar to |
And done! That was pretty simple and builds on the existing pile code rather than needing to modify it 😀 |
We probably want the shadow widget to have a property that indicates which widget it is a shadow of. Not sure how it should be cleaned up. IIRC we have some code in timer.js that has another client adopt a running timer if the client that had been running the timer disconnects; if so, something similar should happen here. |
Another option is we could just clean it up the next time someone drags the widget, since that would also be the point at which we clean up the dragging property right? |
That's true. As long as the client that starts the new drag finds the old shadow copies rather than creating new ones, it should work fine. I'm still not sure that I think the shadow elements should be widgets, but I understand that it makes some things easier to process them as widgets. A couple of years ago, we started down the process of making piles no longer be widgets, but eventually decided it wasn't worth it. |
Done in latest patch.
I know it's tempting not to create widgets for this, and I really tried to go this route initialy but there were going to be many issues that would be really hard to solve properly if it's not a widget. The state would be inconsistent if the widget isn't actually added to the holder during the drag. I.e. My client needs to produce a layout with the widget in the holder and if I have a different layout than you then it can lead to further inconsistencies. Not to mention there are many setups where the widget will run a routine to position new elements. I initially tried putting the actual widget in the holder then it will break things like transitions #1423 and we'd still need to sync a drag copy of the widget for other people to see me dragging it anyways. I think it's kind of nice how it works that you can see the same state and we can both position drag elements within holders in parallel. |
All that is really needed for sync is for other clients to know that the widget is being dragged (which they already do) - each client could create the shadow element for widgets being dragged independently. Still I understand that using an actual widget makes a whole bunch of things about the shadow element easier to accomplish. |
That works for the simple cases, but if placing the shadow widget in the holder invokes routines you would invoke those routines on each client which would could result in strange unexpected results (e.g. if you had a counter it would be invoked by each player in the session). My intention with just having a simple property is that we could still explore other ways of accomplishing the shadow while still supporting the high level developer intent that we should have a shadow element showing where the widget will go. |
If the shadow element were not a widget, it wouldn't trigger any routines. One concern I have is that by using shadow widgets, routines may be triggered that the game designer does not intend to be triggered until the widget is dropped. If dropShadow is a holder property instead of a widget property (would not support a shadow outside holders, but I don't think that would change the visual effect unless the widget has partial transparency) the holder could create the shadow element as part of its own rendering. Not sure how that delta call should work though. |
Yeah, it would be awesome to get this feature part of more games. +1 to trying to do this.
changeRoutines on the pile should be fine with the current PR because the shadow widget is not allowed to be part of piles (in order to avoid incorrect pile counts): https://github.com/ArnoldSmith86/virtualtabletop/pull/1501/files#diff-cda5cc45823227e11eaa23e3e718a50f300e3fa6183280043e48e4e55b78024dR2239 . That said I expect they're also extremely uncommon on piles anyways and it makes the code pattern more generic if I don't differentiate piles from other stuff. |
…t on server-side.
I tested each of the public library games which was auto-modified by the file updater and as far as I can tell the added dropShadows does not affect the gameplay adversely in any of them. In most of them it is useful except for Rummy Tiles where the shadow isn't visible because it shows directly behind the widget anyways. Can someone explain the remaining testcafe failure? How does the edit test know that after adding some widgets they must have a particular id? (i.e. in this case |
The ID is generated randomly, but for TestCafe, all randomness is not so random (see |
Yeah that makes sense. Do you have a way to figure out what the ids have become? Every time I try to run the tests locally it times out waiting for the browser and the test failure on the run here doesn't say anything about what ids were created. I suppose I could add some logging.
|
It's possible to use the non-random random function in a proper browser and do all the clicks. |
Does TestCafé also fail with Chrome/Chromium? You should also be able to use it on gitpod.io: https://gitpod.io/#https://github.com/flackr/virtualtabletop/tree/drop-shadow , https://github.com/ArnoldSmith86/virtualtabletop/wiki/TestCaf%C3%A9#running-tests-in-gitpod . |
Instructions needed to be updated after #1362 I was able to install noVNC with |
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.
Code looks fine to me but it's complex enough that it'll probably break a thing or two. 🤷♂️
See if my two comments warrant a change and then merge.
https://test.virtualtabletop.io/PR-1501/pr-test
While dragging a widget with the dropShadow property set, a clone of the widget is added to the current hover target to show where that widget will be dropped to visually.
Proposed wiki update:
dropShadowOwner
. When a shadow is created, the value will be theplayerName
. The clone will activate enterRoutine and leaveRoutine, so you may need to counteract that by using IF statements filtering out the clone looking for non-null values. The css of the shadow can be modified using.dragging-shadow
.