Jump to content
Unfortunately we had to take download section back offline temporarily. We should have it working normally soon.

FPLaunch MOD: Pause and Loading screens...


samwyze

Recommended Posts

I had a lots of freezes with 1.28 and 1.29, 1.291 and 1.292.

But it is complete freeze, "rendering table" progress bar stops and i have to logoff or kill everything with task manager.

But I have it already solved in 1.293 which is on the way.

By the way - loading screen and pause screen now work in FP also, exit321 functionality for FP is still on the way.

And VP has short press on esc - Pause - long press Exit321 - feature implemented!

Probably FP will have it also :)

Link to comment
Share on other sites

Hi´ya Blur!

Don´t know if any have mentioned this or even experienced it, but somethimes 1 out of 3 maybe the table loads and then get stuck in the loading phase.

You can see the dmd from the table but the hyperpin loading overlay dosen´t move to show the actual table beneath until you quick press ESC / EXIT.

Then it goes away! Not so hard to get around though. Mostly annoying! :(

Link to comment
Share on other sites

gstav - this could be the same case from reko which should be fixed in 293

njay - there are two different looking final versions right now 1.13 without loading and pause screens and 1.292 with loading and pause screens

sounds great, can't wait. current version works good for me except this one table. the only other issue I could think of is loosing focus in FP if i exit from FP back to HP as soon as FP table loads. No issues if I play a table or wait few seconds.

Link to comment
Share on other sites

Thanx Blur! Great to hear, as sometime you can´t quick press the exit button to make it go away. But you have to se the 1-2-3 seq first and then reload the table! :D *damn*

edit:

I´m running the Ledwiz board so I start my hyperpin with the HPLedControl file. And I think this is based on FPLaunch Version 1.25, so that may be my problem right there.

Regards!

Edited by gstav
Link to comment
Share on other sites

By the way - loading screen and pause screen now work in FP also, exit321 functionality for FP is still on the way.

And VP has short press on esc - Pause - long press Exit321 - feature implemented!

Probably FP will have it also :)

OK, FP has all the functionalities - loading screen, pause screen AND exit321 screen and short press pause, long press exit321.

I only have to correct some minor bugs, put together some bits and pieces and the script is done.

Major PITA with FP was that you can't draw partial image over it, that image will blink shortly and then disappear. To solve this i've been drawing black screen and then exit and pause screen, but then i changed black screen with screenshot of the game. So now when esc or pause is pressed in fp printscreen is executed and then pause and esc screens are drawn over that.

Another PITA was that with FP logical key state was not working ok. I had to check for physical key state to see if key is pressed down or not.

Number of lines has come from ~300 to ~950.

Link to comment
Share on other sites

There is no any "really new" features in version 293 (like screenshots going directly to media directory or automatic screen positioning in fp arcaderender mode or no-nag screen in vp) but now all features from vp are implemented in fp also. And now it is easy to build anything on that.

Some new thingies are:

- short press on esc is pause, long press is exit321 screen

- esc and pause can be used with any modifier, shift for example - this means that you can hold flipper up with left shift - and then press pause or esc and you will get pause. This was not possible before, it was necessary to release shift and then press pause or esc.

- you can have useexitscreen and useexitaspause both set to true, and both options will work in both programs (remember long press, short press)

- usepausekey option is independent of other options so you can have pause even if xou don't use exit screen, or exit as pause

- magic key "alt-F4" is introduced - this key closes vp player or fp player, unhides vp/fp editor, activates it, shows cursor and taskbar and suspends all hot keys until you run play table again. When you run table hotkeys are reenabled and cursor and taskbar are hidden.

Hot keys are suspended because every esc while you edit table would invoke exit321 or pause screen. This way you can quickly edit table or change settings in vp/fp.

If you don't press play in editor but press alt-f4 again (closing the editor) - you'll have to close autohotkey manually from the tray - because ahk will wait for vp/fp player to show up.

- saving of fp table position is implemented only if nedded (if you used scroll lock during game), just like in version 1.13.

Edited by blur
Link to comment
Share on other sites

Here is fplaunch.ahk.

Just put it in file and recompile to get exe.

/**
* FPLaunch MOD Version 1.293
* Modified by dumpster.monkey (samwyze) & blur 
* Based on original FPLaunch 1.2 by 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 or Enter exits, Esc and then Esc again takes you back to the game
* Includes support for Pause in VP and FP by blur
*   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 position (scrolllock) on exit by blur
* 
* All images are to be placed in %HyperPinDir%\Media\HyperPin\Images 
*
* These settings are automatically added to your settings.ini
* file in the %HyperPinDir%\Settings folder on first start:
*   [FPLaunch]
*   exitScriptKey    = q & s
*   exitEmulatorKey  = Esc
*   toggleCursorKey  = t
*   pauseVPinball 	  = p
*   hideCursor       = true
*   hideDesktop      = true
*   hideTaskbar      = true
*   useExitScreen    = true
*   usePauseKey      = true
*   useLoadScreen    = true
*   fadespeed        = 25
*   useExitAsPause   = true
*   exitEmulatorKey2 = 1
*   exitEmulatorKey3 = Enter
*   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.
DetectHiddenWindows on

;*******************************************************************************
;*                  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,exitEmulatorKey3,pauseFPKey,saveFPTables
Loop, parse, iniKeys, `,
  {
     IniRead, %A_LoopField%, %hyperini%, FPLaunch, %A_LoopField%
  }

romExtension =
GoSub, CheckPaths

loadspeed := fadespeed * 10

Hotkey, %exitScriptKey%, ExitScript

If  (useLoadScreen = "true") {
ProgBar = 0
gui, 99:add,picture,hwndloadpic, %A_ScriptDir%\Media\HyperPin\Images\Loading.png
controlgetpos,,,wLoad,hLoad,,ahk_id %loadpic%
gui, 99: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)
}  
If  (usePauseKey = "true") {
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))
}
If  (useExitScreen = "true") {
Exiting = 0
Exit =
gui, 97:add,picture,hwndexitpic, %A_ScriptDir%\Media\HyperPin\Images\Exit_1.png
controlgetpos,,,wExit,hExit,,ahk_id %exitpic%
gui, 97: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))
}

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

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



;**********************************FUTURE PINBALL***********************************
if (systemName = "Future Pinball" && (executable = "Future Pinball.exe"))
 {
   if (useExitScreen = "true")
	Hotkey, $*%exitEmulatorKey%, ExitScreen
   else if (useExitAsPause = "true")
	Hotkey, $*%exitEmulatorKey%, PauseFP
else
	Hotkey, $*%exitEmulatorKey%, CloseFP

If  (usePauseKey = "true") {
	Hotkey, $*%pauseVPinball%, PauseFP
	Hotkey, $*Pause, PauseFP
}

Hotkey, $~!F4, ShowFP

Hotkey, $ScrollLock, SetSaveFPNeeded

if (saveFPTables = "true")
	Run, "%emuPath%\%executable%" /open "%tablePath%\%tableName%.fpt" /play /arcaderender,,Min UseErrorLevel
else
	Run, "%emuPath%\%executable%" /open "%tablePath%\%tableName%.fpt" /play /Exit /arcaderender,,Min UseErrorLevel

If (useLoadScreen   = "true") ;Draw the loading Gui with wrapped Progress bar
	Gosub CreateLoadScreen
   Else {
	WinWait, ahk_class FuturePinball
	WinHide, ahk_class FuturePinball
}
WinWait, ahk_class FuturePinballOpenGL
WinActivate, ahk_class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
   Gui, destroy   
   Process, WaitClose, Future Pinball.exe
}
;**********************************VISUAL PINBALL***********************************
else if (systemName = "Visual Pinball" && (executable = "VPinball.exe"))
 {
  ;--------------------------------------------------------------
  ;------     check if an active backglass shall be started -----
  ;--------------------------------------------------------------
StringRight, ending, tableName, 3
if (ending = "B2S")
{
	Run, %tablePath%%tableName%.exe, %tablePath%
	sleep 200
}

   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

If  (useExitScreen = "true")
	Hotkey, *%exitEmulatorKey%, ExitScreen
Else If (useExitAsPause = "true")
	Hotkey, *%exitEmulatorKey%, PauseVP
Else
	Hotkey, *%exitEmulatorKey%, CloseVP

If  (usePauseKey = "true") {
	Hotkey, $*%pauseVPinball%, pauseVP
	Hotkey, $*Pause, PauseVP
}

Hotkey, $~!F4, ShowVP

If (useLoadScreen   = "true") ;Draw the loading Gui with wrapped Progress bar
	Gosub CreateLoadScreen
   Else {
	WinWait, ahk_class VPinball
	WinHide, ahk_class VPinball
}
WinWait, Visual Pinball Player,, DMD ;Wait for vp to be Ready before killing Gui blackScreen
WinActivate, Visual Pinball Player,, DMD        
WinWaitActive, Visual Pinball Player,, DMD        
   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, %xecutable%
return

PauseFP:
if (Paused = 0) {
Paused = 1
Gosub CreateBlackScreen
Gosub CreatePauseScreen
WinHide, ahk_class FuturePinballOpenGL
WinActivate, ahk_class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
Send {%pauseFPKey%}
Hotkey, $%exitEmulatorKey2%, CloseFP
Hotkey, $%exitEmulatorKey2%, On
Hotkey, $%exitEmulatorKey3%, CloseFP
Hotkey, $%exitEmulatorKey3%, On
} else {
Paused = 0
Hotkey, $%exitEmulatorKey2%, Off
Hotkey, $%exitEmulatorKey3%, Off
WinActivate, ahk_class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
Send {%pauseFPKey%}
WinShow, ahk_class FuturePinballOpenGL
Gui 1: Destroy
Gui 5: Destroy
}
return

pauseVP:
If (Paused = 0) {
Paused = 1
Gosub CreatePauseScreen
Hotkey, $%exitEmulatorKey2%, CloseVP
Hotkey, $%exitEmulatorKey2%, On
Hotkey, $%exitEmulatorKey3%, CloseVP
Hotkey, $%exitEmulatorKey3%, On
} Else {
Paused = 0
Gui, Destroy
WinActivate, Visual Pinball Player,, DMD
Hotkey, $%exitEmulatorKey2%, Off
Hotkey, $%exitEmulatorKey3%, Off
}
return

ShowFP:
if (Paused = 1) {
Paused = 0
Gui 1: Destroy
Gui 5: Destroy
Hotkey, $%exitEmulatorKey2%, Off
Hotkey, $%exitEmulatorKey3%, Off
}
WinWaitClose, ahk_class FuturePinballOpenGL
WinShow, ahk_class FuturePinball
WinRestore, ahk_class FuturePinball
WinActivate, ahk_class FuturePinball
WinWaitActive, ahk_class FuturePinball
SystemCursor("On")
WinShow, ahk_class Shell_TrayWnd
WinShow, Start ahk_class Button
Suspend, On
WinWait, ahk_class FuturePinballOpenGL
Suspend, Off
SystemCursor("Off")
WinHide, ahk_class Shell_TrayWnd
WinHide, Start ahk_class Button
return

ShowVP:
if (Paused = 1) {
Paused = 0
Gui, Destroy
WinActivate, Visual Pinball Player,, DMD
WinClose, ahk_class VPPlayer
Hotkey, $%exitEmulatorKey2%, Off
Hotkey, $%exitEmulatorKey3%, Off
}
WinWaitClose, ahk_class VPPlayer
WinShow, ahk_class VPinball
WinRestore, ahk_class FuturePinball
WinActivate, ahk_class VPinball
WinWaitActive, ahk_class VPinball
SystemCursor("On")
WinShow ahk_class Shell_TrayWnd
WinShow Start ahk_class Button
Suspend, On
WinWait, ahk_class VPPlayer
Suspend, Off
SystemCursor("Off")
WinHide, ahk_class Shell_TrayWnd
WinHide, Start ahk_class Button
return

SetSaveFPNeeded:
saveFPNeeded = true
Send {ScrollLock}
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
WinHide, ahk_class FuturePinball
WinActivate, ahk_class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
Send {Esc}
WinWaitClose, ahk_class FuturePinballOpenGL
; saving fp table position, black screen hides fp window
if (saveFPTables = "true") and (saveFPNeeded = "true") {
; we already have gui 1 and gui 5 on screen from pause
WinActivate, ahk_class FuturePinball
WinWaitActive, ahk_class FuturePinball
WinMenuSelectItem, ahk_class FuturePinball,,File,Save
;WinHide, ahk_class FuturePinball
Sleep, 2000
}
WinClose, ahk_class FuturePinball
GoSub, ExitScript
return

CloseVP:
 Hotkey, %exitScriptKey%, Off
 ; --------------------------------------------------------------
 ; --- Close the animated backglass -----------------------
 ; --------------------------------------------------------------
 if (ending = "B2S")
 {
WinKill, Form1
 }
 ;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

CreateLoadScreen:
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
	}
	if (systemName = "Visual Pinball") {
		IfWinExist, Visual Pinball Player,, DMD  ;Check if visual pinball is Ready
		{
			IfWinActive, Visual Pinball Player,, DMD ;Check if visual pinball is Ready
			{
				WinActivate, ahk_class TBackglass
				WinActivate, ahk_class MAME
				WinActivate, ahk_class VPPlayer
				Break
			}
		}
	} else {
		IfWinExist, ahk_class FuturePinballOpenGL ;Check if visual pinball is Ready
           {
			IfWinActive, ahk_class FuturePinballOpenGL ;Check if visual pinball is Ready
			{
				Break
			}
		}
	}
}
Return

CreateBlackScreen:
CaptureScreen(3)
Gui 5: Color, 000000
Gui 5: Margin, 0, 0
Gui 5: Add, Picture, W%A_ScreenWidth% H%A_ScreenHeight% vScreenPic, screen.bmp
Gui 5: +AlwaysOnTop -Caption +ToolWindow
Gui 5: Show, x0 y0 W%A_ScreenWidth% H%A_ScreenHeight%, BlackScreen
Return

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

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, w%wLoad% h%hLoad%, %picDir%%ExitPic%
       Gui %A_Index%: +AlwaysOnTop -Caption +Lastfound
       Gui %A_Index%: Show, AutoSize Center Hide
	WinSet, TransColor, EEAA99
  }
Return

ExitScreen:
LoopVal = 0
Loop {  
	GetKeyState, state, %exitEmulatorKey%, P
	if state = D
	{
           if (loopVal = 10) {
			if (Paused = 1) {
				if (systemName = "Future Pinball")
					GoSub PauseFP
				else
					GoSub PauseVP
			}
			Gosub CreateExitScreen
			if (systemName = "Future Pinball")
				GoSub CreateBlackScreen
	        Gui, 3:Show
		} else if loopVal = 40
		    Gui, 2:Show
		else if loopVal = 70
		    Gui, 1:Show
           Sleep,  %fadespeed%
		if (loopVal = 100) {
	        if (systemName = "Visual Pinball") {
				GoSub, CloseVP
				Loop, 4
					Gui, %A_Index%: Destroy
			} else if (systemName = "Future Pinball") {
				Loop, 5
					Gui, %A_Index%: Destroy
				GoSub, CloseFP
			}
			break
           }
	} else {
		if (LoopVal < 10 && useExitAsPause = "true") {
	        if (systemName = "Visual Pinball")
				GoSub, PauseVP
			else if (systemName = "Future Pinball")
				GoSub, PauseFP
		} else {
			Loop, 5
				Gui, %A_Index%: Destroy
			WinActivate, Visual Pinball Player,, DMD
			WinActivate, ahk_class FuturePinballOpenGL
		}
        	Transvalue = 0
		LoopVal = 0
 		break
       }
    LoopVal += 1
   }
Return

ExitScript:
Loop, 5
Gui, %A_Index%: Destroy
Process, Exist, HyperPin.exe
PID := errorLevel
if (hideTaskbar = "true") {
 WinShow ahk_class Shell_TrayWnd
 WinShow Start ahk_class Button
}
if (PID) {
 WinActivate, ahk_pid %PID%
 ;WinWaitActive, ahk_pid %PID%
}
if (hideCursor = "true")
 SystemCursor("On")
;to debug script uncomment the pause
;Pause
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
   }
 If (exitScriptKey = "ERROR") or (useExitAsPause = "ERROR") or (exitEmulatorKey3 = "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, Enter, %hyperini%, FPLaunch, exitEmulatorKey3
 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    = true
usePauseKey      = true
useLoadScreen    = true
fadespeed        = 25
useExitAsPause   = true
exitEmulatorKey2 = 1
exitEmulatorKey3 = Enter
pauseFPKey       = RButton
saveFPTables     = true

return

/* CaptureScreen(aRect, bCursor, sFileTo, nQuality)
 By Sean - Taken from Forum page:    http://www.autohotkey.com/forum/topic18146.html
1) If the optional parameter bCursor is True, captures the cursor too.
2) If the optional parameter sFileTo is 0, set the image to Clipboard.
  If it is omitted or "", saves to screen.bmp in the script folder,
  otherwise to sFileTo which can be BMP/JPG/PNG/GIF/TIF.
3) The optional parameter nQuality is applicable only when sFileTo is JPG. Set it to the desired quality level of the resulting JPG, an integer between 0 - 100.
4) If aRect is 0/1/2/3, captures the entire desktop/active window/active client area/active monitor.
5) aRect can be comma delimited sequence of coordinates, e.g., "Left, Top, Right, Bottom" or "Left, Top, Right, Bottom, Width_Zoomed, Height_Zoomed".
  In this case, only that portion of the rectangle will be captured. Additionally, in the latter case, zoomed to the new width/height, Width_Zoomed/Height_Zoomed.

Example:
CaptureScreen(0)
CaptureScreen(1)
CaptureScreen(2)
CaptureScreen(3)
CaptureScreen("100, 100, 200, 200")
CaptureScreen("100, 100, 200, 200, 400, 400")   ; Zoomed
*/

/* Convert(sFileFr, sFileTo, nQuality)
Convert("C:\image.bmp", "C:\image.jpg")
Convert("C:\image.bmp", "C:\image.jpg", 95)
Convert(0, "C:\clip.png")   ; Save the bitmap in the clipboard to sFileTo if sFileFr is "" or 0.
*/


CaptureScreen(aRect = 0, bCursor = False, sFile = "", nQuality = "")
{
If	!aRect
{
	SysGet, nL, 76
	SysGet, nT, 77
	SysGet, nW, 78
	SysGet, nH, 79
}
Else If	aRect = 1
	WinGetPos, nL, nT, nW, nH, A
Else If	aRect = 2
{
	WinGet, hWnd, ID, A
	VarSetCapacity(rt, 16, 0)
	DllCall("GetClientRect" , "Uint", hWnd, "Uint", &rt)
	DllCall("ClientToScreen", "Uint", hWnd, "Uint", &rt)
	nL := NumGet(rt, 0, "int")
	nT := NumGet(rt, 4, "int")
	nW := NumGet(rt, 8)
	nH := NumGet(rt,12)
}
Else If	aRect = 3
{
	VarSetCapacity(mi, 40, 0)
	DllCall("GetCursorPos", "int64P", pt)
	DllCall("GetMonitorInfo", "Uint", DllCall("MonitorFromPoint", "int64", pt, "Uint", 2), "Uint", NumPut(40,mi)-4)
	nL := NumGet(mi, 4, "int")
	nT := NumGet(mi, 8, "int")
	nW := NumGet(mi,12, "int") - nL
	nH := NumGet(mi,16, "int") - nT
}
Else
{
	StringSplit, rt, aRect, `,, %A_Space%%A_Tab%
	nL := rt1
	nT := rt2
	nW := rt3 - rt1
	nH := rt4 - rt2
	znW := rt5
	znH := rt6
}

mDC := DllCall("CreateCompatibleDC", "Uint", 0)
hBM := CreateDIBSection(mDC, nW, nH)
oBM := DllCall("SelectObject", "Uint", mDC, "Uint", hBM)
hDC := DllCall("GetDC", "Uint", 0)
DllCall("BitBlt", "Uint", mDC, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", hDC, "int", nL, "int", nT, "Uint", 0x40000000 | 0x00CC0020)
DllCall("ReleaseDC", "Uint", 0, "Uint", hDC)
If	bCursor
	CaptureCursor(mDC, nL, nT)
DllCall("SelectObject", "Uint", mDC, "Uint", oBM)
DllCall("DeleteDC", "Uint", mDC)
If	znW && znH
	hBM := Zoomer(hBM, nW, nH, znW, znH)
If	sFile = 0
	SetClipboardData(hBM)
Else	Convert(hBM, sFile, nQuality), DllCall("DeleteObject", "Uint", hBM)
}

CaptureCursor(hDC, nL, nT)
{
VarSetCapacity(mi, 20, 0), mi := Chr(20)
DllCall("GetCursorInfo", "Uint", &mi)
bShow   := NumGet(mi, 4)
hCursor := NumGet(mi, 8)
xCursor := NumGet(mi,12)
yCursor := NumGet(mi,16)

If	bShow && hCursor:=DllCall("CopyIcon", "Uint", hCursor)
{
VarSetCapacity(ni, 20, 0)
DllCall("GetIconInfo", "Uint", hCursor, "Uint", ∋)
bIcon    := NumGet(ni, 0)
xHotspot := NumGet(ni, 4)
yHotspot := NumGet(ni, 8)
hBMMask  := NumGet(ni,12)
hBMColor := NumGet(ni,16)

DllCall("DrawIcon", "Uint", hDC, "int", xCursor - xHotspot - nL, "int", yCursor - yHotspot - nT, "Uint", hCursor)
DllCall("DestroyIcon", "Uint", hCursor)
If	hBMMask
DllCall("DeleteObject", "Uint", hBMMask)
If	hBMColor
DllCall("DeleteObject", "Uint", hBMColor)
}
}

Zoomer(hBM, nW, nH, znW, znH)
{
mDC1 := DllCall("CreateCompatibleDC", "Uint", 0)
mDC2 := DllCall("CreateCompatibleDC", "Uint", 0)
zhBM := CreateDIBSection(mDC2, znW, znH)
oBM1 := DllCall("SelectObject", "Uint", mDC1, "Uint",  hBM)
oBM2 := DllCall("SelectObject", "Uint", mDC2, "Uint", zhBM)
DllCall("SetStretchBltMode", "Uint", mDC2, "int", 4)
DllCall("StretchBlt", "Uint", mDC2, "int", 0, "int", 0, "int", znW, "int", znH, "Uint", mDC1, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", 0x00CC0020)
DllCall("SelectObject", "Uint", mDC1, "Uint", oBM1)
DllCall("SelectObject", "Uint", mDC2, "Uint", oBM2)
DllCall("DeleteDC", "Uint", mDC1)
DllCall("DeleteDC", "Uint", mDC2)
DllCall("DeleteObject", "Uint", hBM)
Return	zhBM
}

Convert(sFileFr = "", sFileTo = "", nQuality = "")
{
If	sFileTo  =
	sFileTo := A_ScriptDir . "\screen.bmp"
SplitPath, sFileTo, , sDirTo, sExtTo, sNameTo

If Not	hGdiPlus := DllCall("LoadLibrary", "str", "gdiplus.dll")
	Return	sFileFr+0 ? SaveHBITMAPToFile(sFileFr, sDirTo . "\" . sNameTo . ".bmp") : ""
VarSetCapacity(si, 16, 0), si := Chr(1)
DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "Uint", &si, "Uint", 0)

If	!sFileFr
{
	DllCall("OpenClipboard", "Uint", 0)
	If	 DllCall("IsClipboardFormatAvailable", "Uint", 2) && (hBM:=DllCall("GetClipboardData", "Uint", 2))
	DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", hBM, "Uint", 0, "UintP", pImage)
	DllCall("CloseClipboard")
}
Else If	sFileFr Is Integer
	DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", sFileFr, "Uint", 0, "UintP", pImage)
Else	DllCall("gdiplus\GdipLoadImageFromFile", "Uint", Unicode4Ansi(wFileFr,sFileFr), "UintP", pImage)

DllCall("gdiplus\GdipGetImageEncodersSize", "UintP", nCount, "UintP", nSize)
VarSetCapacity(ci,nSize,0)
DllCall("gdiplus\GdipGetImageEncoders", "Uint", nCount, "Uint", nSize, "Uint", &ci)
Loop, %	nCount
	If	InStr(Ansi4Unicode(NumGet(ci,76*(A_Index-1)+44)), "." . sExtTo)
	{
		pCodec := &ci+76*(A_Index-1)
		Break
	}
If	InStr(".JPG.JPEG.JPE.JFIF", "." . sExtTo) && nQuality<>"" && pImage && pCodec
{
DllCall("gdiplus\GdipGetEncoderParameterListSize", "Uint", pImage, "Uint", pCodec, "UintP", nSize)
VarSetCapacity(pi,nSize,0)
DllCall("gdiplus\GdipGetEncoderParameterList", "Uint", pImage, "Uint", pCodec, "Uint", nSize, "Uint", π)
Loop, %	NumGet(pi)
	If	NumGet(pi,28*(A_Index-1)+20)=1 && NumGet(pi,28*(A_Index-1)+24)=6
	{
		pParam := π+28*(A_Index-1)
		NumPut(nQuality,NumGet(NumPut(4,NumPut(1,pParam+0)+20)))
		Break
	}
}

If	pImage
	pCodec	? DllCall("gdiplus\GdipSaveImageToFile", "Uint", pImage, "Uint", Unicode4Ansi(wFileTo,sFileTo), "Uint", pCodec, "Uint", pParam) : DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "Uint", pImage, "UintP", hBitmap, "Uint", 0) . SetClipboardData(hBitmap), DllCall("gdiplus\GdipDisposeImage", "Uint", pImage)

DllCall("gdiplus\GdiplusShutdown" , "Uint", pToken)
DllCall("FreeLibrary", "Uint", hGdiPlus)
}

CreateDIBSection(hDC, nW, nH, bpp = 32, ByRef pBits = "")
{
NumPut(VarSetCapacity(bi, 40, 0), bi)
NumPut(nW, bi, 4)
NumPut(nH, bi, 8)
NumPut(bpp, NumPut(1, bi, 12, "UShort"), 0, "Ushort")
NumPut(0,  bi,16)
Return	DllCall("gdi32\CreateDIBSection", "Uint", hDC, "Uint", &bi, "Uint", 0, "UintP", pBits, "Uint", 0, "Uint", 0)
}

SaveHBITMAPToFile(hBitmap, sFile)
{
DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi)
hFile:=	DllCall("CreateFile", "Uint", &sFile, "Uint", 0x40000000, "Uint", 0, "Uint", 0, "Uint", 2, "Uint", 0, "Uint", 0)
DllCall("WriteFile", "Uint", hFile, "int64P", 0x4D42|14+40+NumGet(oi,44)<<16, "Uint", 6, "UintP", 0, "Uint", 0)
DllCall("WriteFile", "Uint", hFile, "int64P", 54<<32, "Uint", 8, "UintP", 0, "Uint", 0)
DllCall("WriteFile", "Uint", hFile, "Uint", &oi+24, "Uint", 40, "UintP", 0, "Uint", 0)
DllCall("WriteFile", "Uint", hFile, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44), "UintP", 0, "Uint", 0)
DllCall("CloseHandle", "Uint", hFile)
}

SetClipboardData(hBitmap)
{
DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi)
hDIB :=	DllCall("GlobalAlloc", "Uint", 2, "Uint", 40+NumGet(oi,44))
pDIB :=	DllCall("GlobalLock", "Uint", hDIB)
DllCall("RtlMoveMemory", "Uint", pDIB, "Uint", &oi+24, "Uint", 40)
DllCall("RtlMoveMemory", "Uint", pDIB+40, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44))
DllCall("GlobalUnlock", "Uint", hDIB)
DllCall("DeleteObject", "Uint", hBitmap)
DllCall("OpenClipboard", "Uint", 0)
DllCall("EmptyClipboard")
DllCall("SetClipboardData", "Uint", 8, "Uint", hDIB)
DllCall("CloseClipboard")
}

Unicode4Ansi(ByRef wString, sString)
{
nSize := DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0)
VarSetCapacity(wString, nSize * 2)
DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize)
Return	&wString
}

Ansi4Unicode(pString)
{
nSize := DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int",  0, "Uint", 0, "Uint", 0)
VarSetCapacity(sString, nSize)
DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nSize, "Uint", 0, "Uint", 0)
Return	sString
}

Link to comment
Share on other sites

Thanks Blur for all your work on this. It is a great addition to the cab! All of the documented features are working for me. I have run across a couple of things that I would put on a wish list for tweaking.

Under FP

When I pause the screen flashes black then shows the blue "Pause" image for a 1/2 second then back to the table and then pulls up the Pause High Score screen. The delay in pausing allows for the ball to drain if it is in the lower half of the playfield. Not sure if there is any way to make the pause more instantaneous like in VP.

Accidental bump of exit button causes the screen to flash black for a second then back to the table. Results in possible ball drain when ball is in lower half of playfield.

Rendering table progress bar moves really fast.

When exiting table shows my desktop for a second before HyperPin comes up.

Under VP

About 20% of the time my taskbar stays on top of HyperPin.

Here are my settings incase your interested.

[FPLaunch]

exitScriptKey=q & s

exitEmulatorKey=e

toggleCursorKey=t

pauseVPinball=g

hideCursor=true

hideDesktop=true

hideTaskbar=true

useExitScreen=true

usePauseKey=true

useLoadScreen=true

fadespeed=15

UseExitAsPause=true

exitEmulatorKey2=1

pauseFPKey=RButton

saveFPTables=true

exitEmulatorKey3=Enter

Again thanks for this great addition to HyperPin.

Link to comment
Share on other sites

Will check this out.

For pause in fp i do this:

- capture screenshot to disk

- then screenshot is drawn on top of fp

- then over screenshot - blue pause screen is drawn

- then fp window which is now in background is made invisible (hidden)

- then i bring this fp window to front (it is still invisible, but now has focus)

- then i send pause (RButton) to fp

it is a lot of work so ball can escape, but you should not see anything except blue pause screen

What os do you have? maybe hiding doesn't work on some os's

Same problem with hiding could be with taskbar. Is there some special situation when taskbar pops up?

Edited by blur
Link to comment
Share on other sites

Using Windows 7 - 64bit. Yeah, on FP I see a lot of screen flashing during the pause routine. I only see the blue pause screen for about 1/2 a second then it ends on the actual FP Pause screen showing the high scores. That is the desirable end screen for me so I can easily see the high scores. Ideally it would go to that screen instantaneously which I believe is how it performed in the previous version. I am not sure if there is another way to see the high scores in FP unless you pause it.

I entered and exited a lot of VP games trying to determine a pattern when my task bar stays on top of Hyperpin but I was not able to find anything. I would hold the exit button extra long thinking that was it but nope. Now if I set my task bar to hide then it never stays on top but when I pause and exit the table I can see the task bars hidden edge. If I don't have the task bar set to hide then when I pause and exit the table I don't see any part of the taskbar but then like I said about 20% of the time it will showup on top of Hyperpin.

I am replacing the motherboard, cpu, and video card this weekend. Maybe I will get lucky and this mildly annoying issues will go away. :)

I can appreciate your challenges on implementing all this stuff though and I applaud what you have accomplished. It is great!

Link to comment
Share on other sites

tnx blitz!

yeah it was so in last fp - pause would just send RButton and game will pause immediately - so no blinking and no ball movement in the background

maybe i can make separate options for pause screen in vp and fp, so you can just disable pause screen in fp and have old behavior

the other route would be to find out just why hiding doesn't work in win7 and fixing it

this would then solve taskbar hiding also

best regards, tnx for extensive testing!

Link to comment
Share on other sites

Will check this out.

For pause in fp i do this:

- capture screenshot to disk

- then screenshot is drawn on top of fp

- then over screenshot - blue pause screen is drawn

- then fp window which is now in background is made invisible (hidden)

- then i bring this fp window to front (it is still invisible, but now has focus)

- then i send pause (RButton) to fp

...Yeah, on FP I see a lot of screen flashing during the pause routine. I only see the blue pause screen for about 1/2 a second then it ends on the actual FP Pause screen showing the high scores. That is the desirable end screen for me so I can easily see the high scores...

@blur, if FP users want to see high scores how about changing order that screenshot is taken, so send a pause to fp, take the screenshot now that it's paused,then overlay the blue pause gfx-unsure if this needs repositioning so that high scores are visible.

It would be nice to have the high score but still keep the blue paused gfx so that it is more visually uniform.

@blitz17, unfortunately the flickering issues are related to the way ahk handles gfx, don't forget ahk is a scripting language. This could be overcome by using an external library to handle the gfx but would require the user to download yet another item (don't think it's allowed to be 'bundled'), and blur or myself would need to rewrite alot of the scipt.

What do you think blur, is it worth moving to gdi+ (better image routines,less or even no flicker) and gpf (allows overlays on d3d 8 and d3d 9)?

Link to comment
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
×
×
  • Create New...