WinAPI - calling SHBrowseForFolder from RGSS

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I'm working on a script where I need to allow the user to select a folder on their system.


This WinAPI will apparently do the job, but I find it incredibly hard to follow - it seems to need you to call a different function (API?) both before and after SHBrowseForFolder, and I have no idea about the arguments/structures required.


Is anyone able to get this up and working, or aware of an alternative I could use instead?


http://msdn.microsoft.com/en-us/library/bb762115(v=vs.85).aspx
 

cremnophobia

Veteran
Veteran
Joined
Dec 10, 2013
Messages
216
Reaction score
97
Primarily Uses
Ruby has a Dir class. I think writing a new scene instead of calling this function is a good alternative (especially because it would look like the rest of the game). You can use Window_Help and Window_Command (commands are the directories). Do you need something else?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I know about the Dir class. I did consider writing a new class that would handle it all and avoid the API. But this is just a single task that I need for a (possibly) rather large and complex script. I don't really want to spend that much time implementing something that would mimic the behaviour.


Maybe for now I'll just put the full path in variables and when I release the script I'll tell people they'll have to change it to whatever they want to use.


Not elegant, but it'll let me move on to the REAL script that I'm trying to develop.


Oh - it's a development script, not something players will ever see, so it doesn't need to look like the rest of the game. :)


I did see a reference to a require wins which is apparently a Ruby script/tool/plugin/whatever, but it requires installing and I can't really ask people to do that just to use the script. Maybe it's not as difficult as I think?
 
Last edited by a moderator:

cremnophobia

Veteran
Veteran
Joined
Dec 10, 2013
Messages
216
Reaction score
97
Primarily Uses
I see. It's definitely possible to use this function, but it's also not something that should be written in Ruby. But I'll take a look at it. Any restrictions on the RGSS version (RGSS3 only would make things easier)?
 

Edit: The following code needs some serious cleanup, but should work in every version.

Edit 2: Removed old version. Click here to get the current one.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
OMG I love you soooooo much right now!!!!


Thank you - it works perfectly!


I will be sharing my script with the community when it's done and will include this snippet (with credit to you, naturally). If you think it needs a cleanup and would like to do that before I release it, go for it, then just post back the new version. Otherwise, it works, and that's all that really matters to me, so I'm also happy to include it as-is.


Also, I AM using RGSS3, but my script might also work for VX and XP - I'll have to test them out when I'm done. Is there anything in the above that you think might cause issues in older makers?


Another question ... is there a way to make it start in the working folder by default?
 
Last edited by a moderator:

cremnophobia

Veteran
Veteran
Joined
Dec 10, 2013
Messages
216
Reaction score
97
Primarily Uses
If you think it needs a cleanup and would like to do that before I release it, go for it
I've cleaned it up.

Is there anything in the above that you think might cause issues in older makers?
No, I don't think so. As I've said before, it should work with XP and VX. If it doesn't, then I'll fix it.

Another question ... is there a way to make it start in the working folder by default?
Yes, there is, but the RGSS doesn't have a way to create callback functions. So the actual answer is no.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Thank you for that.


I just do this?


folder_name = BrowseForFolder.select('Choose your folder')
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:

Forum statistics

Threads
105,854
Messages
1,017,004
Members
137,562
Latest member
tamedeathman
Top