If you are not using RL User Functions then you can ignore all this and go back to play some games, on the other hand if you are using User Functions make sure you read all of it to avoid starting to post that your User Functions are broken right after the next RL update is out.
Continuing with our update to make RL more class based and at the same time compatible with the upcoming AHKv2 there will be some important changes made to the User Functions feature that will require user manual intervention after the RL update that will be out shortly.
It's a very simple fix, so no one should have trouble with it as long as they read this info.
Make sure you only do this AFTER the next RL update, if you do this right now it will only break your User Functions.
Right now there are 2 User Function files:
Lib\User Functions.ahk
Lib\User Functions Init.ahk
You'll need to move and rename the User Functions.ahk file to "Lib\User Functions\Global.ahk".
If your User Functions Init.ahk file has no content you can delete it as it's no longer needed. If it has content you'll need to move it to the Global.ahk file which I will explain later.
This file is now class based so you will need to edit it in a text editor. Let's say your current User Functions.ahk file is currently:
Edit the file so it will now look like:
As you can see it's pretty simple, you just need to add the class line at the top of the file, make sure you add the closing bracket at the end of the file and the function names are slightly different. If in doubt you can check the sample file that will be in the update to ensure you have the function names right.
If you also have content in your User Functions Init.ahk file you'll need to copy the content from that file and add it to a function called InitUserFeatures in Global.ahk, so it will look like:
After that you can delete the old Init file. And that's it after following these steps you are done. If you have any issues getting it to work just post your old files here and we will help you out converting them.
This is all that's needed in order to update your files.
But, this isn't all of it! We also made User Functions a lot more flexible now and instead of using a single ahk file for every single system you can break it into separate files named after each system, emulator or even game. This will help you keep your code clean instead of having a bunch of if conditions inside your global script file. This is completely optional, if you want to keep everything stuffed in a single file you can still do it.
The new file structure will be:
Lib\User Functions\Global.ahk (This script is run for any game/system)
Lib\User Functions\%SystemName%.ahk (This script is run for this particular system only)
Lib\User Functions\Emulator\%EmulatorName%.ahk (This script is run for this particular emulator only, regardless of the system)
Lib\User Functions\%SystemName%\Emulators\%EmulatorName%.ahk (This script is run for this particular emulator and system only)
Lib\User Functions\%SystemName%\%RomName%.ahk (This script is run for this particular game and system only)
They will be run in the same order as listed above.
So you'll have a lot of flexibility on how you can organize your code. Every file should use the exact same function names, there will be a sample folder included in the update so it should be fairly simple to follow it.
There are some specific functions in the %RomName%.ahk these will be mostly useful with PCLauncher as it will allow you to run custom code if you want to emable/disable fullscreen for a game through RLUI settings or if the game needs some specific handling code in order for bezels to work properly. Those new functions are:
SetFullscreenPostLaunch
SetFullscreenPreLaunch
HaltGame
RestoreGame
They are also commented on the sample files so you can understand the purpose of each of them.
This should cover everything new regarding User Functions, if you have any doubts ask away.
And make sure you read all this BEFORE updating!
Continuing with our update to make RL more class based and at the same time compatible with the upcoming AHKv2 there will be some important changes made to the User Functions feature that will require user manual intervention after the RL update that will be out shortly.
It's a very simple fix, so no one should have trouble with it as long as they read this info.
Make sure you only do this AFTER the next RL update, if you do this right now it will only break your User Functions.
Right now there are 2 User Function files:
Lib\User Functions.ahk
Lib\User Functions Init.ahk
You'll need to move and rename the User Functions.ahk file to "Lib\User Functions\Global.ahk".
If your User Functions Init.ahk file has no content you can delete it as it's no longer needed. If it has content you'll need to move it to the Global.ahk file which I will explain later.
This file is now class based so you will need to edit it in a text editor. Let's say your current User Functions.ahk file is currently:
Code:
; Use this function to define any code you want to run in every module on start
StartGlobalUserFeatures(){
Log("StartGlobalUserFeatures - Starting")
; INSERT CODE HERE
Log("StartGlobalUserFeatures - Ending")
}
; Use this function to define any code you may need to stop or clean up in every module on exit
StopGlobalUserFeatures(){
Log("StopGlobalUserFeatures - Starting")
; INSERT CODE HERE
Log("StopGlobalUserFeatures - Ending")
}
Edit the file so it will now look like:
Code:
class GlobalUserFunction extends UserFunction {
; Use this function to define any code you want to run in every module on start
StartUserFeatures() {
Global RLLog,dbName,systemName
RLLog.Info(A_ThisFunc . " - Starting")
; INSERT CODE HERE
RLLog.Info(A_ThisFunc . " - Ending")
}
; Use this function to define any code you may need to stop or clean up in every module on exit
StopUserFeatures() {
Global RLLog,dbName,systemName
RLLog.Info(A_ThisFunc . " - Starting")
; INSERT CODE HERE
RLLog.Info(A_ThisFunc . " - Ending")
}
}
As you can see it's pretty simple, you just need to add the class line at the top of the file, make sure you add the closing bracket at the end of the file and the function names are slightly different. If in doubt you can check the sample file that will be in the update to ensure you have the function names right.
If you also have content in your User Functions Init.ahk file you'll need to copy the content from that file and add it to a function called InitUserFeatures in Global.ahk, so it will look like:
Code:
; Use this function to define any code you want to run on initialization
InitUserFeatures() {
Global RLLog,dbName,systemName
RLLog.Info(A_ThisFunc . " - Starting")
; PASTE YOUR User Functions Init.ahk HERE
RLLog.Info(A_ThisFunc . " - Ending")
}
After that you can delete the old Init file. And that's it after following these steps you are done. If you have any issues getting it to work just post your old files here and we will help you out converting them.
This is all that's needed in order to update your files.
But, this isn't all of it! We also made User Functions a lot more flexible now and instead of using a single ahk file for every single system you can break it into separate files named after each system, emulator or even game. This will help you keep your code clean instead of having a bunch of if conditions inside your global script file. This is completely optional, if you want to keep everything stuffed in a single file you can still do it.
The new file structure will be:
Lib\User Functions\Global.ahk (This script is run for any game/system)
Lib\User Functions\%SystemName%.ahk (This script is run for this particular system only)
Lib\User Functions\Emulator\%EmulatorName%.ahk (This script is run for this particular emulator only, regardless of the system)
Lib\User Functions\%SystemName%\Emulators\%EmulatorName%.ahk (This script is run for this particular emulator and system only)
Lib\User Functions\%SystemName%\%RomName%.ahk (This script is run for this particular game and system only)
They will be run in the same order as listed above.
So you'll have a lot of flexibility on how you can organize your code. Every file should use the exact same function names, there will be a sample folder included in the update so it should be fairly simple to follow it.
There are some specific functions in the %RomName%.ahk these will be mostly useful with PCLauncher as it will allow you to run custom code if you want to emable/disable fullscreen for a game through RLUI settings or if the game needs some specific handling code in order for bezels to work properly. Those new functions are:
SetFullscreenPostLaunch
SetFullscreenPreLaunch
HaltGame
RestoreGame
They are also commented on the sample files so you can understand the purpose of each of them.
This should cover everything new regarding User Functions, if you have any doubts ask away.
And make sure you read all this BEFORE updating!