Jump to content
samwyze

FPLaunch MOD: Pause and Loading screens...

Recommended Posts

fplaunch 1.2 is in post 8 'exit feature' thread here: http://www.hyperspin-fe.com/forum/showthread.php?t=3062

Great, tnx, will check it.

I saw that FP is not getting focus with this script, which is peculiar since nothing new is applied to FP part of the script. Will compare it with 1.0 and 1.1 versions which focus fine with FP.

I saw in this thread that FP doesn't support putting image over, so different approach will be needed to make FP not exit instantly on ESC

Since FP is getting keys with send you can send anything, Pause for example

Other Esc could also send Pause since it will just get you back in game, and exit - well some kind of flag should be introduced so that enter or 1 in pause mode make FP exit

Share this post


Link to post
Share on other sites
Great, tnx, will check it.

I saw that FP is not getting focus with this script, which is peculiar since nothing new is applied to FP part of the script. Will compare it with 1.0 and 1.1 versions which focus fine with FP.

I saw in this thread that FP doesn't support putting image over, so different approach will be needed to make FP not exit instantly on ESC

Since FP is getting keys with send you can send anything, Pause for example

Other Esc could also send Pause since it will just get you back in game, and exit - well some kind of flag should be introduced so that enter or 1 in pause mode make FP exit

Easy way to 'draw' pause/exit screen in fp would be to take a screenshot using fplaunch, force fp to minimize and draw screenshot with pause overlaid (or exit options). From what I've read so far all of that can be done with ahk scripting, not sure what impact it'd have on resources though, and I know that ahk isn't the best at imaging (flickers a bit, especially when redrawing over a gui element) but all that can be worked around in the long term.

Yea, focus is an issue, I know what to fix, just need to be home to do it. :P

Also just realised that the new version of autohotkey has ansi and unicode builds, for our purposes the older ansi based style is going to be better, as that is the version bbb was using originally, and think that's the same for the HyperSpin ahk script.

Edited by samwyze

Share this post


Link to post
Share on other sites

FP is starting minimized, removed min from the end of launch line, now focus is ok

Share this post


Link to post
Share on other sites
FP is starting minimized, removed min from the end of launch line, now focus is ok

Do you mean FP or VP? Looking at my fplaunch, and the launch line for FP has no min switch?

*EDIT*

Ignore that-was using my current build, not the one on megaupload. Have been updating script and lost track of which file I upped.

Should have the new version up soon :)

Edited by samwyze

Share this post


Link to post
Share on other sites

great

I was thinking about your method to close FP

i think it will not work - you said you will minimize FP and put exit or pause screen on top

but - when FP is minimized screen is still covered with his 3D screen (like in your fplaunch script - it was minimized but still on screen)

any way - sending Pause key to FP on Esc keypress should work fine, only problem is - no way to tell user that he has to press enter after esc to really exit.

maybe if we use same method for VP where we can put message people will get use to it, only if they don't bump on FP table first :)

Share this post


Link to post
Share on other sites
great

I was thinking about your method to close FP

i think it will not work - you said you will minimize FP and put exit or pause screen on top

but - when FP is minimized screen is still covered with his 3D screen (like in your fplaunch script - it was minimized but still on screen)

any way - sending Pause key to FP on Esc keypress should work fine, only problem is - no way to tell user that he has to press enter after esc to really exit.

maybe if we use same method for VP where we can put message people will get use to it, only if they don't bump on FP table first :)

OK, that sounds good, will have to install FP today and have a play. Cheers for the help and input :)

Share this post


Link to post
Share on other sites

Just tried today to send pause on esc.

It looks like send pause is not working, at least not with FP.

I can send esc, i can send even scroll lock, but can't send pause.

The only way i did sent pause to FP is to use Pause key instead of Esc key.

And I use ~Pause instead of Pause - so that key is sent through + some script can be executed that will keep track of what's going on - this way i can configure vp to do whatever and FP will get real pause key for pause. HP can also use pause instead of Esc in its config.

I tried to minimize FP also (Winminimize) but it keeps on runing, because it still has focus.

Will try some more things (like focusing some other window)

Oh and if you have installed FP for the first time - be sure to check slamtilt's mods, for example Dark Knight available at fprelease.

Share this post


Link to post
Share on other sites

Hi,

Could it be possible with AHK to display a small image permanently on top of the table ?

I would like the option of displaying a button card on the bottom left where the instructions are. Could allso be used for instructions.

Only problem could be is that not all tables have the same size apron, but that would be the next challange ;)

Share this post


Link to post
Share on other sites

Nice work here guys. Looking forward to checking out the pause feature.

Share this post


Link to post
Share on other sites

uf, it's been a long ride, but here it is pause key implemented through escape key

as i said fp won't receive pause key with send {Pause} or {vp13sc045} or any other way so one solution was to use Pause as physical key and configure everything around it

but since it is a little awkward and i saw in some older posts that most ipac controllers don't support sending pause i searched on

i found a solution in one post from loafer - in FP you can configure pause key to joystick or mouse button - i choosed right mouse button, so for this script to work you must have mouse or joystick on your cab and pick some button and configure it in fp and then adapt script. If you choose right mouse button script will work out of the box (still you have to configure fp)

what does script do?

it gives you protection form exiting unexpectedly

actually esc brings pause and hi scores in fp, and pause menu in vp (normally esc key)

another esc takes you back to game or if you press 1 (start) during pause you exit the game

it is totally consistent in vp and fp

additionally i've put saving of fp table position on exit which you can remove if you have all positions saved

don't forget to compile

feel free to test, report errors, complain, suggest, ask, ...

samwyze it is still draft so there is no your loading and pause screen yet (esc screens are not needed any more)

here is the code:

/** 
* FPLaunch Version 1.11 by blur
* Esc key does not exit - Esc is actually pause
* Esc Esc returns you to the game
* Esc 1 exits
* FP saves table position (can be removed when all tables are saved)
* Based on Autohotkey script 1.10 by BadBoyBill  [email protected]
* CursorHide by Lazlo
* 
* If you are reading this and do not have autohotkey you can get it
* @ http://www.autohotkey.com/download/
* If you would like to modify this script and share it thats OK, but
* see if your modification is something that we would like to add
* to the official version.   
*
* Refer to the autohotkey documentation for the keyoboard keylist
* 
* If this script does not support your favorite emulator
* then please request support @ http://www.hyperspin-fe.com/forum   
*
* Supports Future Pinball and Visual Pinball
*
*/

#SingleInstance force      ;Prevent multiple instances
#InstallKeybdHook
SetTitleMatchMode, 2

;------------------------------------------------------------------------------;
;                                 MAIN SETTINGS                                ;
;------------------------------------------------------------------------------;
; Pause = vk13sc045


;[uNIVERSAL HOTKEYS]            ;SEPERATE MULTIPLE KEYS WITH &(ampersand) up to 2 keys.
exitScriptKey   = q & s         ;Secret hotkey(s) to exit script if needed
                               ;Not to be confused with exit emulator keys

exitEmulatorKey = Esc	        ;This key/key combo will close any emulators
                               ;that do not have normal closing methods.

exitEmulatorKey2 = ~1	        ;This key/key combo will close any emulators
                               ;that do not have normal closing methods.

toggleCursorKey = t             ;hotkey(s) to show or hide cursor if needed
                               ;when hideCursor below is true

;[MOUSE CURSOR]
hideCursor      = true          ;Automatically hide cursor during script
                               ;WARNING: Make sure ALL your emu's are running fine

;[WINDOWS]
hideDesktop     = true         ;Attempts to hide desktop with black screen, might help
                               ;on some emu's for hiding launching windows.

hideTaskbar     = true          ;Hide the windows taskbar when running emu's.
                               ;WARNING: Make sure ALL your emu's are running fine
                               ;         before setting this to true as a precaution.*






/*
   *:If for some weird reason the script hangs follow these steps to get back to normal.
     1. If an emulator hangs up or cant load your game then first try to exit the emu
        by pressing your Emulator exit hotkey above.
     2. If your emu exited but your mouse cursor is gone use your cursor toggle hotkey.   
     3. Next try to exit the script by pressing your Exit Script Hotkey above. This 
        will also bring back your cursor and taskbar is they are set to true.
*/







;*******************************************************************************
;*                  EDIT BELOW THIS POINT AT YOUR OWN RISK                     *
;*******************************************************************************   

;------------------------------------------------------------------------------;
;                       GET PARAMATERS AND SET HOTKEYS                         ;
;------------------------------------------------------------------------------;

;CHECKING FOR 2 PARAMS, IF NOT THEN EXIT
if 0 < 2
{
   MsgBox Usage: FPLaunch.ahk/exe "System Name" "Rom Name"
   ExitApp
}

systemName = %1%
tableName = %2%





Hotkey, %exitScriptKey%, ExitScript

if (hideCursor = "true")
{
 MouseMove %A_ScreenWidth%,%A_ScreenHeight%
 Hotkey, %toggleCursorKey%, ToggleCursor
 SystemCursor("Off")
}
if (hideTaskbar = "true")
{
 WinHide ahk_class Shell_TrayWnd
 WinHide Start ahk_class Button
}

if (hideDesktop = "true")
{
 Gui, Color, 000000
 Gui +AlwaysOnTop -Caption +ToolWindow
 Gui, Show, x0 y0 W%A_ScreenWidth% H%A_ScreenHeight%, BlackScreen
}

WinClose, cmd.exe
;------------------------------------------------------------------------------;
;                              GET AND CHECK PATHS                             ;
;------------------------------------------------------------------------------;
GoSub, CheckINI
IniRead, iniEmuPath, %A_ScriptDir%\Settings\Settings.ini, %systemName%, Path
emuPath := GetFullName(iniEmuPath)
IniRead, iniTablePath, %A_ScriptDir%\Settings\Settings.ini, %systemName%, Table_Path
tablePath := GetFullName(iniTablePath)
IniRead, executable, %A_ScriptDir%\Settings\Settings.ini, %systemName%, Exe

romExtension =
GoSub, CheckPaths

;------------------------------------------------------------------------------;
;                                  RUN SYSTEM                                  ;
;------------------------------------------------------------------------------;


;**********************************FUTURE PINBALL***********************************
if (systemName = "Future Pinball" && (executable = "Future Pinball.exe"))
{	
inPause = false
   Hotkey, $%exitEmulatorKey%, PauseFP
   Hotkey, $%exitEmulatorKey2%, ExitFP

;    Run, "%emuPath%\%executable%" /open "%tablePath%\%tableName%.fpt" /play /exit /arcaderender,,UseErrorLevel
; /exit is removed to enable saving of table position on exit
   Run, "%emuPath%\%executable%" /open "%tablePath%\%tableName%.fpt" /play /arcaderender,,UseErrorLevel
   WinWait, ahk_class FuturePinball
   WinHide, ahk_class FuturePinball
   Gui, destroy
   Process, WaitClose, Future Pinball.exe
}

else if (systemName = "Visual Pinball" && (executable = "VPinball.exe"))
{
inPause = false
   Hotkey, $%exitEmulatorKey%, PauseVP
   Hotkey, $%exitEmulatorKey2%, ExitVP

   Run, "%emuPath%\%executable%" /play -"%tablePath%%tableName%.vpt",,UseErrorLevel
   WinWait, ahk_class VPinball
   WinHide, ahk_class VPinball
   WinWait, ahk_Class VPPlayer
   Gui, destroy
   Process, WaitClose, VPinball.exe
}

else
{
   MsgBox,48,Error,%systemName% is an invalid System Name or %executable% isnt supported yet,6
}

;------------------------------------------------------------------------------;
;                WHEN EMULATOR FINISHES OR IF LAUNCH EXE FAILS                 ;
;------------------------------------------------------------------------------;
;************PROBABLY DO NOT NEED TO EDIT THIS AREA*************

if (ErrorLevel = "ERROR")
{
 MsgBox,48,Error,Failed to run executable check your paths,6
}
Goto ExitScript ; Exits script and returns to frontend


;------------------------------------------------------------------------------;
;                                KILL COMMANDS                                 ;
;------------------------------------------------------------------------------;
;************PROBABLY DO NOT NEED TO EDIT THIS AREA*************

CloseProcess:
Hotkey, %exitScriptKey%, Off
Process, Close, %executable%
Process, WaitClose, %Executable%
return

PauseFP:
if (inPause = "false")
inPause = true
else
inPause = false
Send {RButton}
return

ExitFP:
if (inPause = "true")
Goto CloseFP
;else
;	Send {1}
return

CloseFP:
;Future Pinball must be closed this way instead of killing process or it wil not save your last game information.i.e score/credtis
Send {Esc}
;Saving FP table position
Sleep, 10
WinShow, ahk_class FuturePinball
WinMenuSelectItem, ahk_class FuturePinball,,File,Save
Sleep, 10
WinClose, ahk_class FuturePinball

return

PauseVP:
if (inPause = "false")
inPause = true
else
inPause = false
if (inPause = "true")
Send {Esc}
else
Send {Enter}
return

ExitVP:
if (inPause = "true")
Goto CloseVP
;else
;	Send {1}
return

CloseVP:
Hotkey, %exitScriptKey%, Off
;Visual Pinball must be closed this way instead of killing process or it wil not save your last game information.i.e score/credtis
DetectHiddenWindows, on ;Or next line will not work
WinHide, ahk_class VPinball ;This line fixes where the VP Window flashes real quick when closing the window for a cleaner exit
WinClose, ahk_class VPinball

return

ExitScript:
Gui, destroy
Process, Exist, HyperPin.exe
if (hideTaskbar)
 ;WinShow ahk_class Shell_TrayWnd
 ;WinShow Start ahk_class Button

PID := errorLevel
if (PID)
{
 ;WinActivate, ahk_pid %PID%
 ;WinWaitActive, ahk_pid %PID%
}
if (hideCursor)
 SystemCursor("On")
ExitApp


OnExit, ExitScript
return


;------------------------------------------------------------------------------;
;                                 REST OF SCRIPT                               ;
;------------------------------------------------------------------------------;
;************PROBABLY DO NOT NEED TO EDIT THIS AREA*************



SystemCursor(OnOff=1)   ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
{
   static AndMask, XorMask, $, h_cursor
       ,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
       , b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13   ; blank cursors
       , h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13   ; handles of default cursors
   if (OnOff = "Init" or OnOff = "I" or $ = "")       ; init when requested or at first call
   {
       $ = h                                          ; active default cursors
       VarSetCapacity( h_cursor,4444, 1 )
       VarSetCapacity( AndMask, 32*4, 0xFF )
       VarSetCapacity( XorMask, 32*4, 0 )
       system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650
       StringSplit c, system_cursors, `,
       Loop %c0%
       {
           h_cursor   := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
           h%A_Index% := DllCall( "CopyImage",  "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
           b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0
               , "int",32, "int",32, "uint",&AndMask, "uint",&XorMask )
       }
   }
   if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
       $ = b  ; use blank cursors
   else
       $ = h  ; use the saved cursors

   Loop %c0%
   {
       h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
       DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
   }
}
ToggleCursor:
 SystemCursor("Toggle")
return

IniRead(Filename, Section, Key, Default = "") { 
  FileRead, text, *t %Filename% 
  text = `n%text%`n 
  StringTrimLeft, text, text, InStr(text, "`n[" . Section . "]`n") 
  Loop, 8 { 
     sp := sp . " " 
     StringReplace, text, text, %Key%%sp%=, %Key%= 
     If ErrorLevel 
        Break 
  } 
  start := InStr(text, "`n" . Key . "=") 
  If !start 
     Return, Default 
  start += StrLen(Key) + 2 
  StringMid, Value, text, start, InStr(text, "`n", false, start) - start 
  Return, Value 
}

;Get Full Path from Relative Path
GetFullName( fn ) {
  static buf, i
  if !i
     i := VarSetCapacity(buf, 512)
  DllCall("GetFullPathNameA", "str", fn, "uint", 512, "str", buf, "str*", 0)
  return buf
}

CheckINI:
 IfNotExist, %A_ScriptDir%\HyperPin.exe
 {
   MsgBox,48,Error, Must be in same directory as HyperPin.exe,6
   Goto ExitScript 
 }
 IfNotExist, %A_ScriptDir%\Settings\Settings.ini
 {
   MsgBox,48,Error,Cannot Find %A_ScriptDir%\Settings\Settings.ini,6
   Goto ExitScript 
 }
return

CheckPaths:
 romFound = 
 StringRight, emuPathBackSlash, EmuPath, 1
 StringRight, tablePathBackSlash, TablePath, 1

 If (emuPathBackSlash != "\" || tablePathBackSlash != "\")
 {
   MsgBox,48,Error, Make sure your paths contains a backslash on the end ,6
   Goto ExitScript
 }
 If (executable = "") 
 {
   MsgBox,48,Error, Missing executable in Settings.ini ,6
   Goto ExitScript  
 }
 If (tablePath = "") 
 {
   MsgBox,48,Error, Missing rom path in Settings.ini ,6
   Goto ExitScript  
 }
 If (emuPath = "") 
 {
   MsgBox,48,Error, Missing emulator path in Settings.ini ,6
   Goto ExitScript  
 }
 IfNotExist, %EmuPath%%Executable%
 {
   MsgBox,48,Error,Cannot Find %EmuPath%%Executable%,6
   Goto ExitScript 
 }
return

Edited by blur

Share this post


Link to post
Share on other sites

Great work blur, keen to have a read of your script and incorporate, still haven't had any decent time on the pc to play with fp. It's summer holidays over here so spending as much time with the lads as I can :)

In the mean time think I got the focus issues sorted, so should be more consistent across multi pc's. Also moved config settings to the hyperpin settings file so we don't have to recompile when altering keys etc... First post updated to reflect this.

Next I'd like to make a gui for the settings.ini

(and have fplaunch add default section and keys to ini if they don't exist, save the user typing them in manually.) - DONE

After that I'll knuckle into FP, although you might be finished on that side of things by then!

@pixelmagic: It should be possible so long as the overlay doesn't grab focus

@Rawd: You might want to download the new version, several fixes to do with window focus issues included :o

Edited by samwyze

Share this post


Link to post
Share on other sites

btw, is there a scaling effect on the loading and exit png when displayed? these images are a bit washed out/pixelated. pause image looks nice and clean.

Share this post


Link to post
Share on other sites
btw, is there a scaling effect on the loading and exit png when displayed? these images are a bit washed out/pixelated. pause image looks nice and clean.

They should all scale the same, they were created as a single pdf, then certain layers were exported to pngs. Off the top off my head the scale routines should be identical in the ahk. Perhaps best would be for me to replace the crappy low-res graphics with higher res ones. Think they're currently optimized around 1280x800 as thats what my lappy runs at, but I suppose those of you with full scale cabs outnumber us low spec users!

Share this post


Link to post
Share on other sites

I just tried version 1.28 and VP is working great but Future Pinball launchs ok but doesnt exit back to hyperpin, nor does it display the exiting 3 2 1 menu.

Also does this script support hyper DMD native?

Share this post


Link to post
Share on other sites
I just tried version 1.28 and VP is working great but Future Pinball launchs ok but doesnt exit back to hyperpin, nor does it display the exiting 3 2 1 menu.

Also does this script support hyper DMD native?

The new exit/pause/loading screens are only for visual pinball at this stage.

It shouldn't be affecting future pinballs exit routine as this hasn't been altered? Perhaps Blur could have a look at 1.28's Future Pinball compatibility for me as I have yet to install and play with it. :P

It 'SHOULD' support hyper_DMD but is lacking the script lines to start/close it, these need to be added yourself. How are people using hyper_DMD? Do you use it to show instructions while browsing tables or are you using it instead of each tables unique DMD? I'll add ahk code and an ini key to use it in the next update, but I'd like to know how most people use it first. :)

Share this post


Link to post
Share on other sites

to be honest, I dont know how I am going to use HyperDMD. I just set it up but I didnt try adding it to your script. I figured I would just try your fplaunch.

There is definatly an issue with Future Pinball I hope blur can test it or maybe you can install Future Pinball. Shouldnt take more then 5 mins to install and set it up to launch table FS. I can give you a table thats already sized 1080p if u need.

Share this post


Link to post
Share on other sites

sam i will put fp features in your 1.28 and make 1.29, is it ok?

just be sure you don't add something in parallel.

what do you think - would you like this "exit - 1" way of exiting in VP also, of course i would try put in your pause window instead of sending Esc (esc key gives unrotated! window which is unprofesional)

Share this post


Link to post
Share on other sites

It's comming right now :) Enjoy :)

Here is the code, uses same images, so just have to save it as fplaunch.ahk and compile

Esc or P (both of them work) are used for pausing, 1 while in pause will get you out of FP and VP just the same. VP is using this big nice blue pause screen, FP shows hiscores while paused.

Happy new year to you all :)

/**
* FPLaunch MOD Version 1.29
* Modified by dumpster.monkey (samwyze) & blur 
* Based on original FPLaunch 1.2 BadBoyBill
* Includes modified pause code from ManoWars Nuevo FPLaunch 1.2
* Includes exit png's based on jpg's from BBB's 'exit feature' thread
* Includes support for Exit key acting as a Pause in VP and FP by blur
*   Esc and then 1 exits, Esc and then Esc again takes you back to the game
*   For pause to work in FP you have to assign one mouse or gamepad
*   button to pause in FP, this script is using right mouse button (RButton)
* Includes support for saving FP table positions on exit by blur
* 
* All images to be placed in %HyperPinDir%\Media\HyperPin\Images 
*
* There will be a slight slow-down on first launch while default
* values are written to the settings.ini file. To avoid this you
* can manually add the following section and keys to your settings.ini
* file in the %HyperPinDir%\Settings folder:
*   [FPLaunch]
*   exitScriptKey    = q & s
*   exitEmulatorKey  = Esc
*   toggleCursorKey  = t
*   pauseVPinball 	  = p
*   hideCursor       = true
*   hideDesktop      = true
*   hideTaskbar      = true
*   useExitScreen    = false
*   usePauseKey      = true
*   useLoadScreen    = true
*   fadespeed        = 25
*   useExitAsPause   = true
*   exitEmulatorKey2 = ~1
*   pauseFPKey       = RButton
*   saveFPTables     = true
*
* NOTE: This is a wip and is by no means complete or optimized
* Feel free to disect, mod, clean, optimize, distribute or delete!
* 
* Autohotkey script by BadBoyBill  [email protected]
* CursorHide by Lazlo
* 
* If you are reading this and do not have autohotkey you can get it
* @ http://www.autohotkey.com/download/
* If you would like to modify this script and share it thats OK, but
* see if your modification is something that we would like to add
* to the official version.   
*
* Refer to the autohotkey documentation for the keyoboard keylist
* 
* If this script does not support your favorite emulator
* then please request support @ http://www.hyperspin-fe.com/forum   
*
* Supports Future Pinball and Visual Pinball
*
*/
#SingleInstance force      ;Prevent Multiple instances
#InstallKeybdHook
SetTitleMatchMode 2        ;Use relaxed title matching
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
;*******************************************************************************
;*                  EDIT BELOW THIS POINT AT YOUR OWN RISK                     *
;*******************************************************************************

;------------------------------------------------------------------------------;
;                       GET PARAMATERS AND SET HOTKEYS                         ;
;------------------------------------------------------------------------------;

;CHECKING FOR 2 PARAMS, IF NOT THEN EXIT
If 0 < 2
 {
   MsgBox Usage: FPLaunch.ahk/exe "System Name" "Rom Name"
   ExitApp
 }

systemName = %1%
tableName = %2%
hyperini = %A_ScriptDir%\Settings\Settings.ini
picDir = %A_ScriptDir%\Media\HyperPin\Images\

;------------------------------------------------------------------------------;
;                              GET AND CHECK PATHS                             ;
;------------------------------------------------------------------------------;
Gosub, CheckINI
IniRead, iniEmuPath, %hyperini%, %systemName%, Path
emuPath := GetFullName(iniEmuPath)
IniRead, iniTablePath, %hyperini%, %systemName%, Table_Path
tablePath := GetFullName(iniTablePath)
IniRead, executable, %hyperini%, %systemName%, Exe

iniKeys = exitScriptKey,exitEmulatorKey,hideCursor,toggleCursorKey,hideDesktop,hideTaskbar
,useExitScreen,usePauseKey,pauseVPinball,useLoadScreen,fadespeed
,useExitAsPause,exitEmulatorKey2,pauseFPKey,saveFPTables
Loop, parse, iniKeys, `,
  {
     IniRead, %A_LoopField%, %hyperini%, FPLaunch, %A_LoopField%
  }

loadspeed := fadespeed * 10

romExtension =
Gosub, CheckInis

If  (useexitScreen = "true" && (systemName = "Visual Pinball"))
 {
   Exiting = 0
   Exit =
gui, 99:add,picture,hwndexitpic, %A_ScriptDir%\Media\HyperPin\Images\Exit_1.png
controlgetpos,,,wExit,hExit,,ahk_id %exitpic%
gui, 99:destroy
wExit := Round(wExit*A_ScreenWidth/1280)
xExit := Round(A_ScreenWidth/2-(wExit/2))
hExit := Round(hExit*A_ScreenHeight/800)
yExit := Round(A_ScreenHeight/2-(hExit/2))
Hotkey, %exitEmulatorKey%, exitScreen
 }
Else if (useExitAsPause = "true")
 {
Paused = 0
   Hotkey, $%exitEmulatorKey%, PauseVP
   Hotkey, $%exitEmulatorKey2%, ExitVP
 }
Else
   Hotkey, $%exitEmulatorKey%, CloseVP

If  (usePauseKey = "true" && systemName = ("Visual Pinball"))
{
   Paused = 0
   PausePic =
gui, 98:add,picture,hwndpausepic, %picDir%\Media\HyperPin\Images\Pause.png
controlgetpos,,,wPause,hPause,,ahk_id %pausepic%
gui, 98:destroy
wPause := Round(wPause*A_ScreenWidth/1280)
xPause := Round(A_ScreenWidth/2-(wPause/2))
hPause := Round(hPause*A_ScreenHeight/800)
yPause := Round(A_ScreenHeight/2-(hPause/2))
   Hotkey, %pauseVPinball%, pauseVP
 }

If  (useLoadScreen = "true" && (systemName = "Visual Pinball"))
 {
   ProgBar = 0
gui, 97:add,picture,hwndloadpic, %A_ScriptDir%\Media\HyperPin\Images\Loading.png
controlgetpos,,,wLoad,hLoad,,ahk_id %loadpic%
gui, 97:destroy	
   wLoad := Round(wLoad*A_ScreenWidth/1280)
xLoad := Round(A_ScreenWidth/2-(wLoad/2))
hLoad := Round(hLoad*A_ScreenHeight/800)
yLoad := Round(A_ScreenHeight/2-(hLoad/2))
wLoadProgress := Round(20*A_ScreenWidth/1280)
xLoadProgress := Round(145*A_ScreenWidth/1280)
hLoadProgress := Round(194*A_ScreenHeight/800)
yLoadProgress := Round(288*A_ScreenHeight/800)
 }  

Hotkey, %exitScriptKey%, exitScript

If (hideCursor = "true")
 {
   MouseMove %A_ScreenWidth%,%A_ScreenHeight%
   Hotkey, %toggleCursorKey%, ToggleCursor
   SystemCursor("Off")
 }
If (hideTaskbar = "true")
 {
   WinHide ahk_class Shell_TrayWnd
   WinHide Start ahk_class Button
 }
If (hideDesktop = "true")
 {
   Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
   Gui, Color, 000000
   Gui, Show, x0 y0 W%A_ScreenWidth% H%A_ScreenHeight%, blackScreen
 }

WinClose, cmd.exe

;------------------------------------------------------------------------------;
;                                  RUN SYSTEM                                  ;
;------------------------------------------------------------------------------;


;**********************************FUTURE PINBALL***********************************
If (systemName = "Future Pinball" && (executable = "Future Pinball.exe"))
 {
   if (useExitAsPause = "true") {
	Paused = 0
	Hotkey, $%exitEmulatorKey%, PauseFP
	Hotkey, $%exitEmulatorKey2%, ExitFP
	Hotkey, $%pauseVPinball%, PauseFP
} else
	Hotkey, $%exitEmulatorKey%, CloseFP
if (saveFPTables = "true")
	Run, "%emuPath%\%executable%" /open "%tablePath%\%tableName%.fpt" /play /arcaderender,,UseErrorLevel
else
	Run, "%emuPath%\%executable%" /open "%tablePath%\%tableName%.fpt" /play /Exit /arcaderender,,UseErrorLevel
   WinWait, ahk_class FuturePinball
   WinHide, ahk_class FuturePinball
   Gui, Destroy
   Process, WaitClose, Future Pinball.exe
 }

Else If (systemName = "Visual Pinball" && (executable = "VPinball.exe"))
 {
   Run, "%emuPath%\%executable%" /play -"%tablePath%%tableName%.vpt",, Min UseErrorLevel ;Run Minimized
   ;was the best way I could hide the vp editor and play loading screens as WinHide didn't seem to find them
   DetectHiddenWindows on
If (useLoadScreen   = "true") ;Draw the loading Gui with wrapped Progress bar
     {
	Gui, Destroy ; kill Gui blackScreen
       Gui, Color, EEAA99
       Gui, Margin, 0, 0
       Gui, Add, Picture, h%hLoad% w%wLoad% vLoadPic, %picDir%loading.png
	Gui, Add, Progress, x%xLoadProgress% y%yLoadProgress% w%wLoadProgress% h%hLoadProgress% -smooth 0x8 c0C32A5 vLoading vertical BackgroundFFFFFF 
       Gui +AlwaysOnTop -Caption +Lastfound
       Gui, Show, AutoSize Center, loadScreen
	WinSet, TransColor, EEAA99
	Loop
         {
           ProgBar += 1
           If ProgBar = %loadspeed%
             {
               GuiControl,, Loading, 1
               ProgBar = 0
             }
		IfWinExist, Visual Pinball Player,, DMD ;Check if visual pinball is Ready
             {
		    IfWinExist, ahk_class WindowsForms10.Window.8.app.0.378734a
		      {
			   WinMinimize, ahk_class VPinball
			   WinActivate, ahk_class WindowsForms10.Window.8.app.0.378734a
			   WinActivate, Visual Pinball Player,, DMD
			   WinWaitActive, Visual Pinball Player,,,DMD
			   WinHide, HyperPin
			   Break
                 }
		    IfWinExist, ahk_class MAME
		      {
			   WinMinimize, ahk_class VPinball
			   WinActivate, ahk_class MAME
			   WinActivate, Visual Pinball Player,, DMD
			   WinWaitActive, Visual Pinball Player,,,DMD
			   WinHide, HyperPin
			   Break
                 }
		  }
         }
     }
   Else
     {
		WinWait, Visual Pinball Player,, DMD ;Wait for vp to be Ready before killing Gui blackScreen
	WinHide, ahk_class VPinball
	WinActivate, Visual Pinball Player,, DMD        
  }
   Gui, Destroy
DetectHiddenWindows off
Process, WaitClose, VPinball.exe
}
Else
 {
   MsgBox,48,Error,%systemName% is an invalid System Name or %executable% isnt supported yet,6
 }

;------------------------------------------------------------------------------;
;                WHEN EMULATOR FINISHES OR IF LAUNCH EXE FAILS                 ;
;------------------------------------------------------------------------------;
;************PROBABLY DO NOT NEED TO EDIT THIS AREA*************

If (ErrorLevel = "Error")
 {
   MsgBox,48,Error,Failed to Run executable Check your paths,6
 }
Goto exitScript ; Exits script and Returns to frontend


;------------------------------------------------------------------------------;
;                                KILL COMMANDS                                 ;
;------------------------------------------------------------------------------;
;************PROBABLY DO NOT NEED TO EDIT THIS AREA*************

CloseProcess:
 Hotkey, %exitScriptKey%, Off
 Process, Close, %executable%
 Process, WaitClose, %Executable%
Return

PauseFP:
if (Paused = 0)
Paused = 1
else
Paused = 0
Send {%pauseFPKey%}
return

ExitFP:
if (Paused = 1)
Goto CloseFP
return

CloseFP:
 ;Future Pinball must be closed this way instead of killing process or it wil not save your last game information.i.e score/credtis
 Send {Escape}
 if (saveFPTables = "true") {
Sleep, 10
WinShow, ahk_class FuturePinball
WinMenuSelectItem, ahk_class FuturePinball,,File,Save
Sleep, 10
WinClose, ahk_class FuturePinball
 }
 Gosub, exitScript
Return

CloseVP:
 Hotkey, %exitScriptKey%, Off
 ;Visual Pinball must be closed this way instead of killing process or it wil not save your last game information.i.e score/credtis
 DetectHiddenWindows on ;Or next line will not work
 Gui, Destroy
 WinRestore, HyperPin
 WinHide, ahk_class VPinball ;This line fixes where the VP Window Flashes real quick when closing the window for a cleaner Exit
 WinClose, ahk_class VPinball
 Gosub, exitScript
Return

exitScript:
 Gui, Destroy
 Process, Exist, HyperPin.exe
 If (hideTaskbar)
     PID := ErrorLevel
 If (PID)
   {
     WinActivate, ahk_pid %PID%
     WinWaitActive, ahk_pid %PID%
   }
 If (hideCursor)
     SystemCursor("On")
 ExitApp

CreateexitScreen:
	Gui, Destroy
Loop, 4
  {
    ExitPic = Exit_%A_Index%.png
    Gui %A_Index%: Color, EEAA99
       Gui %A_Index%: Margin, 0, 0
       Gui %A_Index%: Add, Picture, AltSubmit BackgroundTrans x0 y0 w%wExit% h%hExit%, %picDir%%ExitPic%
       Gui %A_Index%: +Lastfound
       Gui %A_Index%: Show, AutoSize Center Hide
	WinSet, TransColor, EEAA99
	Winset, Transparent , 0
	Gui %A_Index%: -Caption
  }
Return

exitScreen:
Gosub CreateexitScreen
Loop, 4
{
     GuiNum := 5 - A_Index
  Gui %GuiNum%:Show
}
LoopVal = 0
   Gui, 4:+Lastfound 
   Winset, Transparent, 255
Transvalue = 0
Loop
     {  
	  GetKeyState, state, Esc
	  If state = D
	    {		  
             If LoopVal = 5
	      {
	        Gui, 3:+LastFound
	        Transvalue = 0
	      }
		  Else If LoopVal = 35
		  { 
		    Gui, 2:+LastFound
		    Transvalue = 0
		  }
		  Else If LoopVal = 60
		  { 
		    Gui, 1:+LastFound
		    Transvalue = 0
		  }
    		  If LoopVal > 5
		   {
		    If LoopVal < 90
		     Transvalue+=10   
		    Winset, Transparent, %Transvalue%
		   }
             Sleep,  %fadespeed%
		  If LoopVal = 90
		  {
	        If(systemName = "Visual Pinball")
                {
                  Gosub, CloseVP
                }
              Loop, 4
	        {
	          Gui, %A_Index%: Destroy
	        }
 	       Break
             }
	    }
      Else
           {
	      Loop, 4
		  {
	        Gui, %A_Index%: Destroy
		  }
        	  Transvalue = 0
		  LoopVal = 0
		  WinActivate, Visual Pinball Player,, DMD
 		  Break
           }
    LoopVal += 1
     }
Return

CreatePauseScreen:
   Gui, Destroy
   Gui, Color, EEAA99
   Gui, Margin, 0, 0
   Gui, Add, Picture, h%hPause% w-1 vPausePic, %picDir%Pause.png
   Gui +AlwaysOnTop -Caption +Lastfound
   Gui, Show, Hide, pauseScreen
WinSet, TransColor, EEAA99
Return

pauseVP:
 Gosub CreatePauseScreen
 If (Paused = 0)
   {
     Gui, Show
     Winactivate
  Paused = 1
   }
 Else
   {
     Gui, Hide
     WinActivate, Visual Pinball Player,, DMD
     Paused = 0
   }
Return

ExitVP:
if (Paused = 1)
Goto CloseVP
return

OnExit, exitScript
Return

;------------------------------------------------------------------------------;
;                                 REST OF SCRIPT                               ;
;------------------------------------------------------------------------------;
;************PROBABLY DO NOT NEED TO EDIT THIS AREA*************

SystemCursor(OnOff=1)   ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
 {
   static AndMask, XorMask, $, h_cursor
           ,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
           , b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13   ; blank cursors
           , h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13   ; handles of default cursors
   If (OnOff = "Init" or OnOff = "I" or $ = "")       ; init when requested or at First call
     {
       $ = h 
       VarSetCapacity( h_cursor,4444, 1 )
       VarSetCapacity( AndMask, 32*4, 0xFF )
       VarSetCapacity( XorMask, 32*4, 0 )
       system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650
       StringSplit c, system_cursors, `,
       Loop %c0%
         {
           h_cursor   := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
           h%A_Index% := DllCall( "CopyImage",  "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
           b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0
                   , "int",32, "int",32, "uint",&AndMask, "uint",&XorMask )
         }
     }
   If (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
      $ = b  ; use blank cursors
   Else
      $ = h  ; use the saved cursors
         Loop %c0%
           {
             h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
             DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
           }
 }
ToggleCursor:
 SystemCursor("Toggle")
Return

;Get Full Path from Relative Path
GetFullName( fn ) {
   static buf, i
   If !i
      i := VarSetCapacity(buf, 512)
   DllCall("GetFullPathNameA", "str", fn, "uint", 512, "str", buf, "str*", 0)
   Return buf
 }

CheckINI:
 IfNotExist, %A_ScriptDir%\HyperPin.exe
   {
     MsgBox,48,Error, Must be in same directory as HyperPin.exe,6
     Goto exitScript
   }
 IfNotExist, %A_ScriptDir%\Settings\Settings.ini
   {
     MsgBox,48,Error,Cannot Find %A_ScriptDir%\Settings\Settings.ini,6
     Goto exitScript
   }
Return

CheckInis:
 romFound =
 StringRight, emuPathBackSlash, EmuPath, 1
 StringRight, tablePathBackSlash, TablePath, 1

 If (emuPathBackSlash != "\" || tablePathBackSlash != "\")
   {
     MsgBox,48,Error, Make sure your paths Contains a backslash on the end ,6
     Goto exitScript
   }
 If (executable = "")
   {
     MsgBox,48,Error, Missing executable in Settings.ini ,6
     Goto exitScript
   }
 If (tablePath = "")
   {
     MsgBox,48,Error, Missing rom path in Settings.ini ,6
     Goto exitScript
   }
 If (emuPath = "")
   {
     MsgBox,48,Error, Missing emulator path in Settings.ini ,6
     Goto exitScript
   }
 If (exitScriptKey = "ERROR") or (useExitAsPause = "ERROR")
   Gosub addIni
 IfNotExist, %EmuPath%%Executable%
   {
     MsgBox,48,Error,Cannot Find %EmuPath%%Executable%,6
     Goto exitScript
   }
Return

addIni:
 IniWrite, q & s, %hyperini%, FPLaunch, exitScriptKey
 IniWrite, Esc, %hyperini%, FPLaunch, exitEmulatorKey
 IniWrite, t, %hyperini%, FPLaunch, toggleCursorKey
 IniWrite, p, %hyperini%, FPLaunch, pauseVPinball
 IniWrite, true, %hyperini%, FPLaunch, hideCursor
 IniWrite, true, %hyperini%, FPLaunch, hideDesktop
 IniWrite, true, %hyperini%, FPLaunch, hideTaskbar
 IniWrite, false, %hyperini%, FPLaunch, useExitScreen
 IniWrite, true, %hyperini%, FPLaunch, usePauseKey
 IniWrite, true, %hyperini%, FPLaunch, useLoadScreen
 IniWrite, 25, %hyperini%, FPLaunch, fadespeed
 IniWrite, true, %hyperini%, FPLaunch, UseExitAsPause
 IniWrite, ~1, %hyperini%, FPLaunch, exitEmulatorKey2
 IniWrite, RButton, %hyperini%, FPLaunch, pauseFPKey
 IniWrite, true, %hyperini%, FPLaunch, saveFPTables
exitScriptKey    = q & s
exitEmulatorKey  = Esc
toggleCursorKey  = t
pauseVPinball 	 = p
hideCursor       = true
hideDesktop      = true
hideTaskbar      = true
useExitScreen    = false
usePauseKey      = true
useLoadScreen    = true
fadespeed        = 25
useExitAsPause   = true
exitEmulatorKey2 = ~1
pauseFPKey       = RButton
saveFPTables     = true

Return

Share this post


Link to post
Share on other sites

getting an error saying Make sure your paths Contains a backslash on the end

1.28 I dont get this error when launching fp or vp

Edited by bent98

Share this post


Link to post
Share on other sites

be sure to use basic version of autohotkey when compiling

advanced L version gives this error

i will put compiled exe in a while

Share this post


Link to post
Share on other sites

Thanks I'll just wait for the .exe I don't feel I am smart enough to compile this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×