mirror of
https://github.com/ArnoldSmith86/virtualtabletop.git
synced 2026-03-02 22:57:02 -05:00
BasicWidget does not show text of active face #685
Labels
No labels
PCIO compatibility
Validator
automated testing
bug
documentation
duplicate
editor
enhancement
enhancement
library
library
maintenance
needs legacy server
pile related
reported client crash
routine operations
user interface
widget properties
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/virtualtabletop#685
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ArnoldSmith86 on GitHub (Mar 2, 2023).
Wow. Fun times. Turns out that setting
activeFacein a basic widget does not copy the properties from the face to the widget. Never did.It copies it to
this.statewhich is basically the "actual JSON" of the widget saved inside the Widget object. That is never sent to the server but it is what all the editors will show you and once you save, it will be sent to the server (and the JSON editor saves automatically).You can test this yourself. Add this widget to a new room:
You would expect it to show
X. It does. Click it. You expect it to showB. It does. Reload the room and it showsXagain. This happens sincegithub.com/ArnoldSmith86/virtualtabletop@f922834c2f.Now try this:
Works just fine. You see the image of the active face. And you can use the state API (
https://virtualtabletop.io/state/<room>) to check that the propertyimageof the widget does not change.The problem is in this piece of code:
super.applyDeltaToDOM(delta);applies the actualimageproperty to the widget.this.applyDelta(face);applies theimageandtextproperties of the active face to the widget.setText(this.domElement, delta.text);applies the actualtextproperty to the widget.I'm pretty sure that the fix is to replace
setText(this.domElement, delta.text);bysetText(this.domElement, this.get('text'));becausethis.get('text')actually returns thetextproperty of the active face (soGETshould as well). But after this roller coaster, I'll have to ponder about the meaning of life for a second before opening a PR.This also means that I'll revisit https://github.com/ArnoldSmith86/virtualtabletop/pull/536. We can probably just do what that PR does without changing game behavior. That PR contains the fix since https://github.com/ArnoldSmith86/virtualtabletop/pull/536/commits/e319a30b537c5316463c68fd5ddc54731f3503dd...
@robartsd commented on GitHub (Mar 2, 2023):
So if it is only the editor that is copying to the widget, this should be fixed in the editor (as well as your proposed fix for text).
I think changing away from a face leaves the property set by the face in the state unless it was also set on the face being changed to. This would mean if a property is only set on one face, after seeing that face, the property would remain in state; but a client joining later would not have the property in state. Anything that causes different clients to have a different idea of the shared state is clearly a bug; but I'm not sure how we should fix this.
@ArnoldSmith86 commented on GitHub (Mar 3, 2023):
Didn't you fix that in #536?