Merging Mods, Collaborating

Discuss Daggerfall Unity and Daggerfall Tools for Unity.
Post Reply
User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Merging Mods, Collaborating

Post by Interkarma »

Nystul wrote:had to make minor changes to the BaseScreenComponent class in update() function to make OnMouseDown event behave like I would expect it.
What I would expect is that the event is fired repeatedly as long as the left mouse button is pressed (it was behaving basically like a simple mouseclick event - just fired on first mouse button down)
that way I was able to implement drag and drop easily in the automap script which would otherwise be tedious...
Do you agree with my opinion?
No, sorry. That isn't how input events work. This is how you should be using the event.
  1. You handle the OnMouseDown event. Set a flag called called something like mouseDown.
  2. You handle the OnMouseUp event. Clear mouseDown flag.
  3. In your Update(), do something like: if (mouseDown) { // do stuff }
My UI events work just like similar systems (e.g. WinForms) in that events are fired only at the beginning or end of an action. Continuously firing an event every frame isn't how this kind of system works.

Edit: If you ever do feel changes are needed to the core files to support your work, please email me first to discuss before putting it into code. :)

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: Merging Mods, Collaborating

Post by Nystul »

Interkarma wrote: No, sorry. That isn't how input events work. This is how you should be using the event.
  1. You handle the OnMouseDown event. Set a flag called called something like mouseDown.
  2. You handle the OnMouseUp event. Clear mouseDown flag.
  3. In your Update(), do something like: if (mouseDown) { // do stuff }
My UI events work just like similar systems (e.g. WinForms) in that events are fired only at the beginning or end of an action. Continuously firing an event every frame isn't how this kind of system works.
so what is the difference between OnMouseDown and OnMouseClick then?

A further thing that is unclear to me is how I can then implement drag and drop without getting an updated position... I mean of course I could try to do it in a the update function and get the mouse position there. but this is kind of feeling a bit wrong - since you always learn in books to abstract/seperate behavior.
Interkarma wrote: Edit: If you ever do feel changes are needed to the core files to support your work, please email me first to discuss before putting it into code. :)
This is why I asked in the first place ;)
I am working in a separate branch where I try out stuff - so no harm was hopefully done ;)

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Merging Mods, Collaborating

Post by Interkarma »

Nystul wrote: so what is the difference between OnMouseDown and OnMouseClick then?
The current implementation of OnMouseClick is a placeholder. It will eventually work more like a standard forms click, like so:
  • OnMouseClick event should only fire when mouse button completes a full click-release on control.
  • If user clicks, then drags mouse away from control before releasing, then OnMouseClick will not fire.
That's why similar event systems in WinForms, etc. differentiate between a click event and mouse down/up events. I've just not properly implemented the full behaviour yet.

There are a few other spots as well (like proper key-repeat in UI) that need more work. What I'm doing now is just getting things rapidly to a working state then iterating back over them when I have time.
Nystul wrote: This is why I asked in the first place ;)
Cheers. :)

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Merging Mods, Collaborating

Post by Interkarma »

Nystul wrote: A further thing that is unclear to me is how I can then implement drag and drop without getting an updated position... I mean of course I could try to do it in a the update function and get the mouse position there. but this is kind of feeling a bit wrong - since you always learn in books to abstract/seperate behavior.
In forms, drag-drop is event-based as well. There's an event for when user drops object A onto control B. I doubt I will be implementing this event, as I can't think of anywhere in Daggerfall that uses drag-drop.

What objects exactly are you drag-dropping? I might be able to offer some guidance.

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: Merging Mods, Collaborating

Post by Nystul »

working on drag and drop to meet your description ;)

update:
ah but it seems like there is still the bug interfering the new implementation as well:

mouse up is always fired immediatly after mousedown even if i still hold the mouse down.
reason is this line:

Code: Select all

bool leftMouseDown = Input.GetMouseButtonDown(0);
from description of Input.GetMouseButtonDown:
Returns true during the frame the user pressed the given mouse button.

I think the correct method to call should be:

Code: Select all

bool leftMouseDown = Input.GetMouseButton(0):
description Input.GetMouseButton:
Returns whether the given mouse button is held down.

I admit the name of the functions is confusing and even contradicting

update2:
yes changing this and drag and drop works like expected, implemented it following your suggestions

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Merging Mods, Collaborating

Post by Interkarma »

Thanks for the bug report. GetMouseButtonDown() is definitely the correct option for what I need it for (click handling). But you are right I need to be using GetMouseButton() for up/down sampling. I've split these out now and pushed fix to git. The events should work as intended now.

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: Merging Mods, Collaborating

Post by Nystul »

Interkarma wrote:Thanks for the bug report. GetMouseButtonDown() is definitely the correct option for what I need it for (click handling). But you are right I need to be using GetMouseButton() for up/down sampling. I've split these out now and pushed fix to git. The events should work as intended now.
thanks! will integrate your fix into my working branch :D <3

CyberWilhelm
Posts: 17
Joined: Mon Oct 19, 2015 6:57 pm

Re: Merging Mods, Collaborating

Post by CyberWilhelm »

Submitted my first pull request! This is my first time doing anything in Git, so I made it something teeny-tiny, but hopefully useful.

Basically I just make sure the texture repeat mode on video textures is set to Clamp instead of the default Repeat. I was noticing the emperor's head and the torch from the intro movie bleeding over to the other part of the frame when showing off the game to my friend the other day.

Let me know if I got the procedure right in Git/GitHub. I figured this was more useful than just submitting a bug report. :)

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Merging Mods, Collaborating

Post by Interkarma »

Good fix, pull request has been merged now. Thank you! :)

ifkopifko
Posts: 195
Joined: Thu Apr 02, 2015 9:03 am

Re: Merging Mods, Collaborating

Post by ifkopifko »

Hey there everyone. I would have a quick question so that I would no mess something up... :D

When my current cotribution to the project is finished (changes merged with Interkarma's master), should I just delete my current forked repository (ifkopifko/daggerfall-unity)? So in the future, if/when I'll see an opportunity to help with something, I would create a new fork?

Or do I misunderstand something. Thanks for any advice...

Post Reply