Author Topic: C# AGILE  (Read 87643 times)

0 Members and 1 Guest are viewing this topic.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #180 on: November 13, 2022, 06:42:17 PM »
Setting the root folder to RootFolder "MyComputer" is supposed to do that. Since adding that I have not noticed it not scrolling to the selected folder. The only thing that I can think of is that it is not loading its config file or the lastBrowsePath value is null or invalid. When it happens is MyComputer selected? I am curious as to the hack you devised.

By "My Computer" do you mean "This PC"? That is the name of the top level node in the tree for me, which I assume is the same thing. Yeah, searching that online a bit, it sounds like it was renamed a few years back, and its the same thing. So given that, then yes, "This PC" is always at the top of the tree of nodes, regardless of whether the scroll down happens or doesn't happen, and in both cases the preselected game folder is highlighted. What I mean is that even though the selected folder is always highlighted, it is sometimes not visible as it is outside the area currently shown, due to it not having scrolled down. It has the feel of a timing issue, e.g. perhaps the scroll bit sometimes kicks in before the selection has been fully applied, but that is just a wild guess. No idea what the code for that component looks like.

The hack I devised is simply to issue a couple of key strokes in code. For example, the down key followed by the up key caused it to scroll down to the selected folder, and the net effect is that it is still selected. The down key would actually move one item down in the list of folders, and the up key would move back up one item, thus taking it back to where it started. This is really hacky, but seems to work for me. But if no one else is seeing this, then maybe it isn't an urgent thing to fix.

I like the idea of skipping the CP questions. Gold Rush v3 (Software Farm version) has no copy check questions, which is why I always use it when I play the game. What about making skipping optional? Skipping the age questions in LSL would be nice as well. I don't remember if LSL1 has different "dirtyness" levels based on how well you do with the age questions the way some later games in the series.

Yeah, the way I'm implementing the patches, it would be trivial to wrap it with a new preference setting.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #181 on: November 13, 2022, 06:55:17 PM »
As to the folder browser scroll to selected, I found this: https://social.msdn.microsoft.com/Forums/windows/en-US/6df8e181-750e-4e14-b707-96ff5c6f43c4/set-folderbrowserdialog-focus-on-treeview-on-the-selected-folder-in-c-winform?forum=csharpgeneral

None of the answers mentioned directly on that page fix the issue, but one of the links to stackoverflow from that page is where I got the "issue key strokes" approach from. They use different keys from what I am using though, as the keys they suggested didn't work in my case. That makes me think that perhaps the keys that work for me won't work for others, which makes the whole thing seem even more hacky. I even tried some of the very involved approaches mentioned on stackoverflow, involving a lot of code, and those didn't work either. Only the keystroke hack is working for me so far.

Offline Collector

Re: C# AGI Interpreter
« Reply #182 on: November 13, 2022, 07:36:54 PM »
Yes, it used to be called "My Computer" since the days of Win9x. The statement for this folder is still "Environment.SpecialFolder.MyComputer". Desktop is at the topmost, but if that is used as root it never scrolls. If the selected folder is highlighted simply hitting enter will load that folder, even if not visible.

I'd say implement your hack. If we find a better solution later it can always be changed.
KQII Remake Pic

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #183 on: November 13, 2022, 11:17:19 PM »
I'd say implement your hack. If we find a better solution later it can always be changed.

Okay, I have just done that. There was a little more to it than simply sending the keys. It needs to be done in a new async task. Without that, it doesn't work, but with it run in an async task, it appears to work every time. I haven't been able to see it fail after making this change. It is a variation of this stackoverflow answer:

https://stackoverflow.com/questions/6942150/why-folderbrowserdialog-dialog-does-not-scroll-to-selected-folder#answer-72376104

Just hoping that it doesn't break it for other people.

@vafada and @Collector, would you both be able to try that out to confirm that it still works for you?

Offline vafada

Re: C# AGI Interpreter
« Reply #184 on: November 14, 2022, 12:13:32 PM »
Its not consistent... sometimes i can see the selected folder... sometimes i need to scroll

Offline Collector

Re: C# AGI Interpreter
« Reply #185 on: November 14, 2022, 12:58:11 PM »
Ditto.
KQII Remake Pic

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #186 on: November 14, 2022, 01:48:06 PM »
And to confirm, was it like that already for both of you before that change?

Offline vafada

Re: C# AGI Interpreter
« Reply #187 on: November 14, 2022, 01:59:41 PM »
And to confirm, was it like that already for both of you before that change?

I cannot comment on this... when using AGILE.. I never use the folder browser window... i always used command line arguements

Offline Collector

Re: C# AGI Interpreter
« Reply #188 on: November 14, 2022, 02:11:31 PM »
I hadn't noticed it before since most of what I was checking was more GUI things. Just hitting the enter key as soon as the dialog shows opens the selected folder. So it probably was not scrolling at time and I never noticed. I should try the TAB, TAB, RIGHT combination to see if it as inconsistent as DOWN, UP.
KQII Remake Pic

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #189 on: November 14, 2022, 03:43:57 PM »
Yeah, I was going to suggest that you try that. I'm on Windows 11 btw. I could try it on Windows 10 to see how that behaves for me.

Offline Collector

Re: C# AGI Interpreter
« Reply #190 on: November 14, 2022, 04:33:35 PM »
It is inconsistent with that for me as well. It seems that what has focus when the dialog appears varies. If the focus is on the OK or Cancel buttons these sendkey commands seem to just send the focus back and forth between the buttons and not the treeview. Might need to roll our own browser dialog to set the focus where it needs to be.
KQII Remake Pic

Offline Collector

Re: C# AGI Interpreter
« Reply #191 on: November 14, 2022, 07:08:08 PM »
OK, I just made a folder browser dialog using gong-shell and it works perfectly, but is far too slow.

There may be other controls that are faster.
KQII Remake Pic

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #192 on: November 14, 2022, 07:35:52 PM »
It seems that what has focus when the dialog appears varies. If the focus is on the OK or Cancel buttons these sendkey commands seem to just send the focus back and forth between the buttons and not the treeview.

Perhaps an even uglier hack would be to do a key sequence like this:

Code: [Select]
        private void ScrollSelectedPathIntoView()
        {
            System.Threading.Tasks.Task.Run(() =>
            {
                SendKeys.SendWait("{TAB}");
                SendKeys.SendWait("{DOWN}");
                SendKeys.SendWait("{UP}");
                SendKeys.SendWait("{TAB}");
                SendKeys.SendWait("{DOWN}");
                SendKeys.SendWait("{UP}");
                SendKeys.SendWait("{TAB}");
                SendKeys.SendWait("{DOWN}");
                SendKeys.SendWait("{UP}");
            });
        }

Since there are only three things to TAB between, then it would in theory not matter which one starts off with the focus, since it would tab to each and do a down/up.

That still works for me, Does it work for you when you change it to the above @Collector and @vafada?


Offline lance.ewing

Re: C# AGI Interpreter
« Reply #193 on: November 14, 2022, 10:04:07 PM »
Failing that, then I think this option might be working for me:

https://stackoverflow.com/questions/6942150/why-folderbrowserdialog-dialog-does-not-scroll-to-selected-folder#answer-15440926

I thought I had tried this previously, but perhaps not, as it seems to be working consistently now.

I basically just copied the code into a new class called FolderBrowserLauncher, then launch the standard FolderBrowserDialog using that FolderBrowserLauncher class, using the ShowFolderBrowser method in that class. The purpose of that FolderBrowserLauncher class is to locate the treeview and send it a message that will make it scroll down. There are some comments that perhaps the slight delay needs to be longer, e.g. if it is a slower computer, but so far it seems to be working for me.

This FolderBrowserLauncher class, from that stackoverflow answer, also uses the sendkeys approach as a fallback, but I've set a breakpoint on that and it isn't hitting it, so the main solution seems to be working for me.

If I try the FolderBrowserDialog directly, I'm getting it scrolling down about 50% of the time, e.g. 5 out of 10 attempts. But calling it through the FolderBrowserLauncher class, it is 100%.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #194 on: November 14, 2022, 10:27:15 PM »
Okay, I think I am going to push that to the github repo.

I tried it over and over again, and eventually I did get it to fail to scroll, so I increased the interval of the Timer from 10 to 50ms, tried again, and saw another occurrence after a while, so increased it to 100ms, and now I think it isn't happening at all; at least for me. Sometimes, when the dialog hasn't scrolled down itself, it is possible to see it scroll down due to the workaround, but given it is after 100ms, it isn't really noticeable unless you're looking for it.

As I say, I've pushed the change, so let me know how it works for you.

Changes can be seen here:

https://github.com/lanceewing/agile/commit/4048dc5526b27fdfd884d04e54f804f2859f5570


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.06 seconds with 22 queries.