[REL] Hide the UI to prevent sticky mouse down [DISCONTINUED]

Discussion in 'Mod Discussions' started by cola_colin, July 28, 2013.

  1. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Hey guys,

    Today I was pretty annoyed by the fact that mouse up events are lost when the mouse is above a UI Element. I've tried to fix this and the best thing I came up with is this mod.
    It hides the whole UI while the mouse is moved around with the left mouse button or the middle mouse button pressed.
    This prevents the mouse from being stuck and gives you a nice view of the planet while scrolling around.

    Please note that it is highly recommended to use a fake fullscreen script or you might still get a stuck mouse, due to leaving the windows completely.

    Download: http://www.nanodesu.info/stuff/pa/mods/mouseSwitch.zip

    To install unpack and read the readme.txt
    Since 51853 making selectionboxes is no longer sticky. Scrolling around using the middle mouse should also be fixed -there is code that is supposed to handle it-, but it seems it is not fully completed. The changes made in 51853 introduce a new way of handling input I do not fully understand, so to make to get mouseswitch to work for middle mouse only you need to edit PA/media/ui/alpha/live_game/live_game.js around line 1105 you will find something that looks like this:

    Code:
    $holodeck.mousedown(function(mdevent) {
    			
                var holodeck = api.Holodeck.get(this);
    
    You need to add 3 lines so it looks like this:

    Code:
    $holodeck.mousedown(function(mdevent) {
    			
    
    			if (mdevent.button === 1) {
    				return;
    			}
    			
                var holodeck = api.Holodeck.get(this);
    
    With this change the mouseswitch will keep working for the middle mouse only, which is fine since left mouse is no longer a problem.
  2. sneakyness

    sneakyness Member

    Messages:
    106
    Likes Received:
    5
    Re: [REL] Hide the UI to prevent sticky mouse down

    This is great!

    <ocd>I noticed you used tabs instead of spaces, and also your indentation was a level off. There also aren't any comments around the changes at lines 363 and 518, and none in the HTML file. I guess what I'm getting at is that it's important to remain consistent, with both the coding style of the files you're changing, and yourself :D

    Does mouseDown do anything as a variable? I see it being set to false, but otherwise that's it. I removed it. I also renamed the mouseSwitch variable to hideForMiddleMouse and changed a bit of other formatting for consistency.

    I'm not sure what you're trying to do with the middle mouse down event, but I found that, for whatever reason, this is the only code that actually returns the correct event.which value for middle mouse.
    Code:
    $(document).on('click', function(event) {
                console.log(event.which);
            });
    I put some serious time into fixing the sticking for windowed players, but it seems like it's a combination of coherent not being passed the mouseenter/mouseleave events from the application wrapper, knockout's wonky (bad) interpretation of mouse events, and the way the HTML is structured/styled.

    I also added the visibility modifier to the rest of the UI elements (where sensible) and added a custom knockout binding to quickly fade most of the UI in and out. It's disabled on elements where rapid interaction is required, as bubbling can occur and dequeuing the animation requires more effort elsewhere and wouldn't fix the interaction requirement.

    Weirdness aside, this really makes the game feel a lot more "finished". I can't wait to actually play with it (I haven't yet)

    I'm attaching the live_game_alpha.js/html files that I'm playing with currently. I didn't want to push any of my choices on you, so I'm leaving it up to you to do your own 'pull request' here. I did email Uber about Github, so hopefully we hear good things soon.

    :mrgreen: </ocd>

    On the upside, you can now fade the UI out and then get the mouse 'stuck' on purpose to take better screenshots. It's a feature, not a bug, I swear!!!

    Edit: would you mind hosting the mod as an attachment to your post, instead of externally? Some users might not be comfortable with downloading/consuming code from an external source.

    Attached Files:

  3. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Re: [REL] Hide the UI to prevent sticky mouse down

    I am detecting middle mouse from the mouse move event, because it is indeed not processed by mouse down.
    And yes, the mod was in dire need of a code clean up, mouseDown was a remnant of an old concept I threw away at some point, but I was happy with it working and it hopefully is only a temporary solution after all. That I am not consistent with any code style is a result of the fact that I usually don't work with javascript and I am already happy when notepad++ at least shows a bit of syntax coloring. No idea what kind of IDE would be used for this.
  4. sneakyness

    sneakyness Member

    Messages:
    106
    Likes Received:
    5
    Re: [REL] Hide the UI to prevent sticky mouse down

    If you use the code from my post it should do exactly what you need. I wasn't sure what your intent was so I couldn't really finish whatever you had in mind.

    I have no idea why coherent is so weird with mouse events. It's not following any known behavior pattern, and it certainly isn't following the standard. I haven't seen anything in coherent's docs that indicate why things are this way. I suspect if I knew, I wouldn't need their product :lol: Regardless, every time something like this comes up, we're going to have to essentially brute force various attempts until we have our own "polyfill" of sorts.

    A polyfill is basically a means of making things the way they should be. They are the pothole fillers of this lovely tech ghetto known as the web.

    Don't worry about not being a JS dev, I'll whip you into shape yet :twisted:

    I use sublime text two most of the time.
  5. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Re: [REL] Hide the UI to prevent sticky mouse down

    There is not further intended, my intended was to hide the UI and that was working after all.
    Detecting the middle mouse only on mouse move isn't a problem as it is moved around when used anyway. I'll incorporate your changes later this day and also try to move as many changes as possible to it's own file.
  6. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Re: [REL] Hide the UI to prevent sticky mouse down

    Put most of the extra code in an extra js file, using your cleanup. However personally I dont like the fade effect, so I threw it out.
    Updated files in the OP.
  7. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Re: [REL] Hide the UI to prevent sticky mouse down [51531]

    updated again, it now uses the current UI mod system.
    download and read the readme, it should be able to survive patching now. Or at least have a chance of surviving it, ofc if Uber changes too much it will break.
  8. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Re: [REL] Hide the UI to prevent sticky mouse down [51531]

    51853 breaks handling of mouse events for mods it seems. At least I can't figure out how they work anymore.

    I've found this so far:

    - This mod will only hide anything when you push the mouse down above an UI element. However in that case you won't be able to scroll around.
    - Selection boxes are not sticky anymore in 51853, middle mouse still is.
    - opening the console fixes it all, all mouse events are handled as expected, as long as the console is open.

    So can anyone tell me why i.e.

    Code:
    $(document).mousedown(function(event) {
    
    });
    
    Does only capture mouse down while over some UI element? Why did this change?
    How do I get mouse events now? I've also tried things like $('#page') or $('body') to no avail, even though $('body') is used by the game itself. EDIT: the game's listeners show the same problems.

    I have no idea why this doesnt work anymore :/
  9. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    So Uber seems to be introducing some kind of new input handling system, that I fail to understand. See the first post for introductions of how to fix mouseswitch for 51853. Sorry I can't provide a UI-System mod for this.
  10. masterdigital

    masterdigital Uber Alumni

    Messages:
    438
    Likes Received:
    833
    We are moving a lot of ui logic out c++ into js. In the long term, this will be great for the modding... in the short term things are a little buggy.
  11. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    A lot of it looks like it will be very useful once it is fully working and I understand it.
    I can't wait :)
  12. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    Great! I'll include in the modpack.

    You say to use a fullscreen script. is game companion good enough? I notice I still see the border at the bottom for example.
  13. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    I have no idea, I use my own. Try it out ;)
  14. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
  15. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    I am happy to announce that this mod is discontinued as of 52168. It's all fixed :)
  16. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    yay! and thanks for helping us along the way!

Share This Page