Jump to content

[1.12.x] Click Through Blocker - NEW DEPENDENCY


linuxgurugamer

Recommended Posts

 Having clicked one too many times on one window, only to have it click on the parts underneath (in the Editor),  or click on an unwanted item in flight, I decided to solve the problem with yet another mod.

Major Release Update, 1.10.5

  • Added Settings page 
  • Added new setting to specify Focus follows Click
  • Added code to have the focus follow the click instead of the mouse, for both editor and flight modes
  • Added initial window to select mode, shows one time only
  • Modified the CBTMonitor to not run in any scene other than the editor
  • Fixed window data not getting cleared properly
  • Removed need to save window rect
  • Reorganized code a bit
  • Removed some unnecessary assignments
  • Added stock settings page to support the FocusFollowsClick mode
  • Removed need to save window rect
  • Reorganized code a bit
  • Removed some unnecessary assignments
  • Added stock settings page to support the FocusFollowsClick mode
  • Added cleanup class to cleanup all input locks after a delay, immediately upon changing scenes
  • Added cleanup delay to settings page

NEW DEPENDENCY

This mod will do nothing by itself, it will need to be used by other mods (see Precise Node for an example)

Mods which use the Click Through Blocker would need to be modified, and this would become a hard dependency for that mod.

The changes are very simple:

Replace all calls to GUILayout.Window with ClickThruBlocker.GUILayoutWindow, the parameters are identical
Replace all calls to GUI.Window with ClickThruBlocker.GUIWindow, the parameters are identical

 

Most important (for mod authors)
All mods using this should add the following line to the AssemblyInfo.cs file:

[assembly: KSPAssemblyDependency("ClickThroughBlocker", 1, 0)]

This will guarantee the load order.  One benefit is that KSP will output a warning and won't load an assembly if it's dependencies aren't met (which may be better than puking out a bunch of exceptions).  The only other real problem with the forced to the top of the sort list method is that technically there's a couple characters before zero ('~', '!', '@', etc.) and dlls directly in GameData come first too.  Of course someone pretty much has to be trying to break things if you have to worry about this particular case.

 

How it works

Each call first calls the original method (ie: ClickThruBlocker.GUILayoutWindow will call GUILayout.Window).  After the call, the position of the mouse is checked to see if it was on top of the window Rect, if it is, it then locks the controls so that clicks don't pass through to any other window.

Usage

  • Add the following to the top of the source:
    • using ClickThroughFix;
  • Replace calls to GUILayout.Window with ClickThruBlocker.GUILayoutWindow
  • Replace calls to GUI.Window with ClickThruBlocker.GUIWindow

Functions - Identical to the GUI and GUILayout versions

  • Rect GUILayoutWindow(int id, Rect screenRect, GUI.WindowFunction func, GUIContent content, GUIStyle style, params GUILayoutOption[] options);
  • Rect GUILayoutWindow(int id, Rect screenRect, GUI.WindowFunction func, Texture image, GUIStyle style, params GUILayoutOption[] options);
  • Rect GUILayoutWindow(int id, Rect screenRect, GUI.WindowFunction func, string text, GUIStyle style, params GUILayoutOption[] options);
  • Rect GUILayoutWindow(int id, Rect screenRect, GUI.WindowFunction func, GUIContent content, params GUILayoutOption[] options);
  • Rect GUILayoutWindow(int id, Rect screenRect, GUI.WindowFunction func, Texture image, params GUILayoutOption[] options);
  • Rect GUILayoutWindow(int id, Rect screenRect, GUI.WindowFunction func, string text, params GUILayoutOption[] options);
  •  
  • Rect GUIWindow(int id, Rect clientRect, WindowFunction func, Texture image, GUIStyle style);
  • Rect GUIWindow(int id, Rect clientRect, WindowFunction func, string text, GUIStyle style);
  • Rect GUIWindow(int id, Rect clientRect, WindowFunction func, GUIContent content);
  • Rect GUIWindow(int id, Rect clientRect, WindowFunction func, Texture image);
  • Rect GUIWindow(int id, Rect clientRect, WindowFunction func, string text);
  • Rect GUIWindow(int id, Rect clientRect, WindowFunction func, GUIContent title, GUIStyle style);

Additional functions

  • bool MouseIsOverWindow(Rect rect)   Returns true if the mouse is over the specified rectangle
     

Download

Available via CKAN

Edited by linuxgurugamer
Link to comment
Share on other sites

Linux, does this behavior affect all/some of the stock/vanilla windows too? If so, you should post an issue to the KSP bug tracker with your implementation so that SQUAD can consider changing the stock handling of the GUI.Window so that the fix gets applied game wide in a future update.

Link to comment
Share on other sites

4 hours ago, Poodmund said:

Linux, does this behavior affect all/some of the stock/vanilla windows too? If so, you should post an issue to the KSP bug tracker with your implementation so that SQUAD can consider changing the stock handling of the GUI.Window so that the fix gets applied game wide in a future update.

It has to be coded in.  I don't think the stock/vanilla windows has the problem.  But it's a unity call, not a KSP call, so I don't think that Squad can replace or change the handling that way.

It's both GUI.Window and GUILayout.Window, my implementation includes replacements for both

I did notify @JPLRepo about it, would be nice if Squad were to include it for mods to use.

I'll post a message to the bug tracker, though

edit:  Bugtracker issue created:  https://bugs.kerbalspaceprogram.com/issues/17286

Edited by linuxgurugamer
Link to comment
Share on other sites

  • 2 weeks later...

New release, 0.1.2

  • Added code to work around stock bug where the editor ignores the lock when the ActionGroup pane is shown

This change was needed to support Action Groups Extended.  Note that this is a bit of a hack, and you will see a blue flash under the mouse in the Action Groups pane when the mouse is over a part

Link to comment
Share on other sites

  • 2 weeks later...

Greetings,

Maybe I just don't get how masters are arranged but I have always downloaded them from your github repo, regardless of mod and used the game data folders from them.  This particular one does not have the necessary game files in the game data folder. That may be by design.. or it may be an omission.

Never mind... I'll just stop doing this and go to the release pages

 

 

Edited by LawnDartLeo
Link to comment
Share on other sites

9 hours ago, LawnDartLeo said:

Never mind... I'll just stop doing this and go to the release pages

That is the correct thing to do, for all mods.  Downloading from anywhere else leaves you the possibility of missing files, etc.  Don't assume that if a GameData folder is there that it will contain everything needed.

Link to comment
Share on other sites

Sorry, but I got an input locking bug.

(I just went to KSP 1.4.1 - last session was 1.4.0)

It happened after I set some radially attached solar panels to be rigid - using latest EER and Click Through Blocker. Or after that, as I went to the Action Groups Editor.

However, "Clear Input Locks" does not work, the part highlighter in VAB is not visible,  I can't select an action in the AG editor, and from there on the log is spammed:

NullReferenceException: Object reference not set to an instance of an object
  at KSP.UI.Screens.EditorActionGroups.ConstructGroupActionList () [0x00000] in <filename unknown>:0 
  at KSP.UI.Screens.EditorActionGroups.ConstructGroupList () [0x00000] in <filename unknown>:0 
  at KSP.UI.Screens.EditorActionGroups.ClearSelection (Boolean reconstruct) [0x00000] in <filename unknown>:0 
  at ClickThroughFix.CBTMonitor.Update () [0x00000] in <filename unknown>:0 
 
(Filename:  Line: -1)

I had to quit KSP because going back to SPC and back into VAB didn't help.

Log:
https://www.dropbox.com/s/p3idq4x7wk0uxzi/2018-03-15_1 KSP.log.7z?dl=1

I'm sorry that again the Gordon comes back with an increasingly borked install - but however the log is "only" 18.7 MB as I quit KSP ... :D
And the other log spamming is the good ol' Contract Configurator - I'm used to it throwing issues since I installed it the first time ...

Edited by Gordon Dry
Link to comment
Share on other sites

45 minutes ago, Gordon Dry said:

Sorry, but I got an input locking bug.

(I just went to KSP 1.4.1 - last session was 1.4.0)

It happened after I set some radially attached solar panels to be rigid - using latest EER and Click Through Blocker. Or after that, as I went to the Action Groups Editor.

However, "Clear Input Locks" does not work, the part highlighter in VAB is not visible,  I can't select an action in the AG editor, and from there on the log is spammed:


NullReferenceException: Object reference not set to an instance of an object
  at KSP.UI.Screens.EditorActionGroups.ConstructGroupActionList () [0x00000] in <filename unknown>:0 
  at KSP.UI.Screens.EditorActionGroups.ConstructGroupList () [0x00000] in <filename unknown>:0 
  at KSP.UI.Screens.EditorActionGroups.ClearSelection (Boolean reconstruct) [0x00000] in <filename unknown>:0 
  at ClickThroughFix.CBTMonitor.Update () [0x00000] in <filename unknown>:0 
 
(Filename:  Line: -1)

I had to quit KSP because going back to SPC and back into VAB didn't help.

Log:
https://www.dropbox.com/s/p3idq4x7wk0uxzi/2018-03-15_1 KSP.log.7z?dl=1

I'm sorry that again the Gordon comes back with an increasingly borked install - but however the log is "only" 18.7 MB as I quit KSP ... :D
And the other log spamming is the good ol' Contract Configurator - I'm used to it throwing issues since I installed it the first time ...

Ok, a series of exact steps to reproduce this is needed, please.

What do you mean by: "set some radially attached solar panels to be rigid"

Please be as specific as you can, EEX is a strange mod internally, since it is really touching the internals of the editor..

I know the line of code, but need to reproduce this.

I will put out a quick update in a few minutes, which might fix this, please try it both ways.

Thanks

 

Link to comment
Share on other sites

Confirmed, without both mods* I got a part highlighter and can fiddle with action groups, as I mentioned in the EEX thread.
 

So, I had a solar panel radially attached, 4x at 45°
After I attached it (them), I opened the EEX menu and chose "All rigid" (no autostruts).

But as both mods* don't work correctly just from the beginning (launching game, loading save, going to VAB, loading craft), it seems not to be an issue because of the panels, or the radially attachment, or the setting it to be rigid.

*EEX and CTB

 

Edit:

I will test CTB 0.1.4 now.

 

Edit:

So well, it somehow works better now.

  • I got part highlighting from scratch.
  • I can edit action groups.

Then I did the test, I opened the log and went to the last line.

  1. Then I set EEX 'All rigid'
  2. No more part highlighting.
  3. 'Clear input locks'
  4. Still no part highlighting.
  5. EEX 'Disable rigid'
  6. 'Clear input locks'
  7. Part highlighting back.
  8. EEX 'All rigid'
  9. No more part highlighting.
  10. 'Clear input locks'
  11. Still no part highlighting.
  12. EEX 'Disable rigid'
  13. 'Clear input locks'
  14. Still no part highlighting.
  15. EEX 'Disable rigid'
  16. 'Clear input locks'
  17. Part highlighting back.

The best is, after all these steps no single line was added to the log!
A little weird, but this time it's not totally borked.

The log:
https://www.dropbox.com/s/1mxx45n9wtza9hk/2018-03-15_3 KSP.log.7z?dl=1

Edited by Gordon Dry
Link to comment
Share on other sites

15 hours ago, Gordon Dry said:

Confirmed, without both mods* I got a part highlighter and can fiddle with action groups, as I mentioned in the EEX thread.
 

So, I had a solar panel radially attached, 4x at 45°
After I attached it (them), I opened the EEX menu and chose "All rigid" (no autostruts).

But as both mods* don't work correctly just from the beginning (launching game, loading save, going to VAB, loading craft), it seems not to be an issue because of the panels, or the radially attachment, or the setting it to be rigid.

*EEX and CTB

 

Edit:

I will test CTB 0.1.4 now.

 

Edit:

So well, it somehow works better now.

  • I got part highlighting from scratch.
  • I can edit action groups.

Then I did the test, I opened the log and went to the last line.

  1. Then I set EEX 'All rigid'
  2. No more part highlighting.
  3. 'Clear input locks'
  4. Still no part highlighting.
  5. EEX 'Disable rigid'
  6. 'Clear input locks'
  7. Part highlighting back.
  8. EEX 'All rigid'
  9. No more part highlighting.
  10. 'Clear input locks'
  11. Still no part highlighting.
  12. EEX 'Disable rigid'
  13. 'Clear input locks'
  14. Still no part highlighting.
  15. EEX 'Disable rigid'
  16. 'Clear input locks'
  17. Part highlighting back.

The best is, after all these steps no single line was added to the log!
A little weird, but this time it's not totally borked.

The log:
https://www.dropbox.com/s/1mxx45n9wtza9hk/2018-03-15_3 KSP.log.7z?dl=1

This will be helpful, thanks.

will work on it tomorrow, very late here now

Link to comment
Share on other sites

3 hours ago, <noname> said:

Ubuntu 16.04, KSP 1.4.1

Mouse cursor disappears. Can still click stuff that is highlighted, just can't see the cursor. Have to restart the game to get my cursor back. Removed this mod and cursor returns to normal.

Mod list :

Kerbal Alarm Clock, Precise Node, ClickThroughBlocker,  Kerbal Engineer, Squad Expansion, Diazo(Landing Height), [x]Science!

I noticed this bug after I installed KAC, precise node, and click through blocker all together. Not sure if it is a conflict with KAC or something else.


Drop by the KAC thread, I think it's a KAC problem.

Link to comment
Share on other sites

  • 2 weeks later...

So I'm posting here mainly because I am not sure where else to post about this issue. There's a chance it's not this mod causing the problem. Or even a mod at all, as I remember a similar issue being in KSP vanilla a long time ago. But I can't seem to find much support via googling things so I figured I'd start here and see if anyone has knowledge that can help and if not, that's fine, I can keep troubleshooting on my own.

It's the problem where, after a certain amount of time (uncertain how long or what conditions cause it), I can no longer click on anything in map view with left click. I can't click on orbit lines to create manuevers. I can't click on planets/other ships to hit the "set as target" or "focus view" buttons. I can't double click things to focus view on them. Save/loading doesn't work. Going to main menu and back doesn't work. I have to fully restart the game to be able to click on things in the map view again.

The even weirder part is I didn't experience this bug at all until a day or two ago. And none of the new mods that I had downloaded had anything to do with the map view, at least from my perspective.. I think all I got was the gravity turn mod, and some of the near future mods by nertea.

 

As far as mods that impact map view, I've got Click Through Blocker, KAC, Precise Maneuver (I am suspect about this, but have no idea how it could cause the bug)

Here's a full list of my mods (is image form bad? I didn't know of another way to get a list of them without writing each one out by hand) https://imgur.com/a/MULx5

Here's my KSP log file.  https://www.dropbox.com/s/wz7tt5sbmdqonr2/KSP.log?dl=0 Although I will say that during the last play session, I had removed precise maneuver, downloaded precise node, and didn't experience the bug (though I didn't play for that long, so who knows). But man was that annoying, because every time I would click on the buttons to change stuff in precise node, it was "clicking through" to the map, so it was constantly untargeting whatever planet I had targeted because it thought I was double clicking on nothing. I will say that I've gotten used to the functionality on precise maneuver.

The main reason I'm posting here is that the bug has to do with mouse clicks not happening. And so I wondered if it had to do with click through blocker somehow blocking all the clicks on the map. But like I said, this is a new bug. I've been playing ksp for two weeks since 1.4.1 and the bug just started a day or two ago. And I've had pretty much all of those mods the whole time. 

Edited by Crixomix
Link to comment
Share on other sites

Now that you say it, I can remember that I had a non-working left click on map, too. In the last one or 2 weeks. I think I switched vehicles with HayStack and then it was good to go, again. I didn't had time to investigate it further.
Precise Maneuver once had a bug where in a special situation you were not able to create maneuver nodes anymore on orbits. But the rest of left clicks were working. I reported how to reproduce that and it got fixed.
So all information I can deliver for now, that it happened to me, too. Not much, but we will see.

Link to comment
Share on other sites

  • 2 weeks later...

LGG, I'm not sure if it's CTB that's the culprit, or this has always been like this.  

I have a series a contracts that require something to go to or happen at a variety of target vessels.  I am using Contract Configurator and some of the packs.   In map view, the target vessels has a slight diamond shaped colored icon over/around it, indicating it is the target.  It is very difficult to click the vessel, as the icon seems to block the mouse from seeing the vessel.  You can still click it by having the pointer just on the edge of it, as the vessel icon is slightly bigger than the target icon. 

If it is CTB doing this, if possible, adding something to allow that particular instance to be clicked through would be nice.  Even if you just add some sort of call that other mods can use to temporarily disable it.  It would be on the other mods to implement it, but seeing how CTB is becoming one of the back bone mods, it should be readily accepted. 

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...