Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Aaron's "GameInfo" for MAME


  • Please log in to reply
2 replies to this topic
aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
Introducing:

GameInfo version 0.9.0.0b
(plugs into 3Darcade main folder, may even work with other frontends!)

Posted Image
The above screen (with your current game's info) pops up over
your open MAME game's screen when you press an assigned key.

It's very frustrating whenever I find new buttons in MAME games I've played lots of times and I never had any clue they were there. Then I thought it would also be nice to see everything about the game in one place, easily and quickly. I looked around for an easy way to get information about buttons etc in MAME games... and found a few hopeful leads but they turned out to be quite complicated systems and not exactly what I had in mind. The basic idea was to find something that gathers button labels and game information and displays them on a screen, using a trigger key to activate it.

(YouTube video here will show configuration and use once I build it)

I decided to build my own a few weeks ago, and I took it over the top a little, but I'm very much liking what this is so far.

In a nutshell, GameInfo.exe gathers information about the game you are currently playing. It looks into almost all available extra DAT and INI files available for MAME... namely these:

Hiscore.dat - reads this file to check compatibility with current game
History.dat - reads this file and gets current game's history and facts
Story.dat - reads this file and gets the current submitted MAME high scores list
Catver.ini - reads this file and gets the current game's category (format: 1943=Shooter / Flying Vertical)
Controls.ini - reads this file and gets button information and labels
cabinets - (image folder) If this exists in main 3Darcade folder, its images are displayed
cpanel - (image folder) If this exists in main 3Darcade folder, its images are displayed

It makes use of the files in the list above ONLY if they already exist in the User's main 3Darcade folder, but even if they are not there you will see information parsed from MAME.EXE.
The above files are freely available from the web... I could turn the above filenames into links which take the User to their parent websites where they can download the files, but most MAME users know what the above files are.

I thought I would also make it very very easy to use:

INSTRUCTIONS:

- compile GameInfo.ahk into GameInfo.exe
- drag and drop GameInfo.exe into your frontend's main folder

- run GameInfo.exe, you will be prompted to choose your MAME.EXE file(s)
(must be in same folder, not a subfolder... you may choose multiple MAME.EXE files)

- enter a key when prompted... this will be the key that activates the GameInfo.exe screen while playing game.
...the system is configured! A matching .BAT file has been created beside each MAME.EXE you chose.

- go into your frontend's configuration utility (tested working with 3Darcade so far) and edit it to point at the matching .BAT file instead of your regular MAME.EXE file. In 3Darcade this is done by manually replacing .EXE with .BAT in the file-selection box where it asks you to choose your emulator file. It has to be entered manually because that particular selection box will not let us choose anything other than EXE files, and in this case the .BAT file is needed.

My AutoHotkey.net account still does not exist, so I have no place to host the EXE.

I built this with AHK_L, so I'm not sure if AHK basic will run it.

Here is the code:
/*
 * * * Compile_AHK SETTINGS BEGIN * * *

[AHK2EXE]
Exe_File=%In_Dir%\GameInfo.exe
No_UPX=1
[VERSION]
Set_Version_Info=1
Company_Name=Bewza Software Group
File_Description=GameInfo
File_Version=0.9.0.0
Inc_File_Version=0
Internal_Name=GameInfo
Legal_Copyright=2012 Aaron Bewza
Original_Filename=GameInfo
Product_Name=GameInfo
Product_Version=0.9.0.0
[ICONS]
Icon_1=%In_Dir%\utilities\icon.ico

* * * Compile_AHK SETTINGS END * * *
*/

; ==============================================================
; ******* "GameInfo" (by Aaron Bewza, started July 2012) *******
; ==============================================================

/*
Description: An easy-to-use information screen for 3Darcade/Mame.
	- User-assignable hotkey toggles information.
	- User can select multiple MAME.EXE versions (I use seven versions)

GameInfo.exe must be in main 3Darcade folder, where the following files can be found and used:
	Catver.ini - gets category of current game (make sure to use the one in this format: RomName=Category)
	Hiscore.dat - reads and determines if current game is supported
	History.dat - gets history and facts about current game
;	Story.dat - gets current submitted MAME high scores for current game

GameInfo.exe makes use of images in the following folders if they exist in main 3Darcade folder:
	cpanels
	cabinets

Any MAME.EXE files chosen must also be in the main 3Darcade folder.
If not, there are path issues and this program will not operate correctly.

Future plans:
	- Make it possible to choose Mame executables that are not in the main 3Darcade program directory
	- Parse chosen game's CFG file to check for custom button and joystick mappings made by the User.
	- Add the ability to parse 'Command.dat' as this could plug nicely into this system.
		...a folder of arrow images would be required, it could be created inside the GameInfoData folder.
	- Build separate script to parse TwinGalaxies.com for official MAME high score records
		...it could call the game info with the HTML address, then parse the source code
		and place its data into an INI file inside the GameInfoData folder.
*/

#SingleInstance force ; New instances of this program will replace any existing running instances.
#LTrim ; Keeps MsgBox and FileAppend text aligned to the left, removes any leading spaces.
#NoTrayIcon ; May potentially interfere with User's window focus.
#MaxMem, 2000 ; Limits program to 2gb of memory.
SendMode Input ; Makes it possible to send keystrokes to game's window.
SetTitleMatchMode, 2 ; Window titles must partially match.
SetWorkingDir, %A_ScriptDir% ; Sets working directory in the same folder as this program.
DetectHiddenWindows, On ; Even if windows are hidden, they are detected.

BuiltBy = Aaron Bewza
Company = Bewza Software Group ; My son Enger is a genius. Look for this name in the near future :)
VerNumber = 0.9.0.0b ; Currently beta status.
BuildDate = August 16 2012

RomName = %1% ; The variable name for the currently running game (already sent from .BAT file)
ConfigFile = GameInfoData\`_config.ini ; Creates variable for config.ini file.
IfNotExist, %ConfigFile% ; If configuration file does not exist...
	GoSub, CreateMainConfigFile ; ...one is created with this subroutine.
GoSub, XmlProcess ; Reads chosen game's data from the mame executable and assigns information to variables.
WinActivate, %1% ; Makes sure the current game's window stays active, as this script is also launched.
TextControlsWidth:=A_ScreenWidth-350 ; 350px from the right side of screen (w674 on a 1024x768 monitor).
ControlsPicX:= A_ScreenWidth-650 ; 650px from the right side of screen. (x374 on a 1024x768 monitor).
CabinetPicX:= A_ScreenWidth-320 ; 320px from the right side of screen. (x704 on a 1024x768 monitor).
GameInfoRows:=36-GameInfoHeaderRows ; 36 rows at font-size 12 fits a 1024x768 screen, header rows are subtracted to get number of remaining available rows.

CenterTopImage = cpanel\%1%.png ; Assigns 'cpanel' folder as source of images for the top center of screen.
IfNotExist, %CenterTopImage% ; If this is not present in User's main arcade folder...
	CenterTopImage = marquees\%1%.png ; ...marquee images are used instead.

RightSideImage = cabinets\%1%.png ; Assigns 'cabinets' folder as source of images for the right side of screen.
IfNotExist, %RightSideImage% ; If this is not present in User's main arcade folder...
	RightSideImage = snap\%1%.png ; ... snaps are used instead (too many title screens have been made into marquees).
IfNotExist, %RightSideImage% ; If there is no corresponding snap for the chosen game...
	RightSideImage = titles\%1%.png ; ... titles are used. If none of these images exist, the text area uses the available space to display its contents. 

Gui, Color, 000000 ; Black, of course.
Gui, Add, Picture, x%ControlsPicX% y10 w300 h-1, %CenterTopImage% ; Displays picture of chosen game's actual control panel.
Gui, Add, Picture, x%CabinetPicX% y10 w320 h-1, %RightSideImage% ; Displays picture of chosen game's cabinet.
Gui, Font, c9F9F9F s12 ; Header information font size.
Gui, Add, Text, cFFFFFF x10 y10 r%GameInfoHeaderRows% +BackgroundTrans vControlsGuiHeader
Gui, Add, Edit, x10 y+20 r%GameInfoRows% -VScroll +ReadOnly +BackgroundTrans vControlsGui
Gui, Show, Hide x0 y0 w%A_ScreenWidth% h%A_ScreenHeight%, ControlsViewer
Gui, -Caption ; The rest of the GUI is built and displayed when User presses hotkey.
IniRead, HotKey, %ConfigFile%, ChosenHotKey, CurrentHotkey ; Reads main configuration file for assigned HotKey.
If HotKey = ERROR  ; If variable contains ErrorLevel message, Hotkey was not listed in the INI file...
	GoSub, ChooseHotkeyGui ; ...so the User is prompted to choose one.
HotKey, %HotKey%, InfoScreen, On ; Assigns the retrieved HotKey to run the 'InfoScreen' (subroutine directly below) when pressed:
SetTimer, DetectMameWindow, 500 ; Checks for open mame window every half second, exits script if mame is not running.
Return

; --------------------------------------------------------------------------------------------------------->>
; ------ This assigned HotKey toggles the information screen, User chooses it during configuration -------->>
; --------------------------------------------------------------------------------------------------------->>
InfoScreen:
	SoundPlay, dummys\shot.wav
	OnOff := !OnOff
	If OnOff
		{
		If ChosenGameName = ; If the chosen game does not exist then script exits after it checks a second time...
			{
			Sleep, 1000 ; Waits one second.
			If ChosenGameName = ; If it is still empty...
				ExitApp ; ...script exits (should never happen if all is well).
			}
		GuiControl, Text, ControlsGuiHeader, %GameInfoHeader% ; Top text control's entire contents (larger font size).
		GuiControl, Move, ControlsGuiHeader, w%TextControlsWidth% +BackgroundTrans ; Widens this text control.
		GuiControl, Text, ControlsGui, %GameInfo% ; Information text control's entire contents (smaller font size).
		IfNotExist, %RightSideImage% ; If cabinet or title screen picture does not exists...
			TextControlsWidth := A_ScreenWidth-20 ; ...text control is adjusted to be the width of the screen minus 20px for a margin.
		GuiControl, Move, ControlsGui, w%TextControlsWidth% +BackgroundTrans ; Widens this text control.
		Gui, Show ; Window is shown now that it contains information.
		Send, {PGUP 3} ; Sends 'Page Up' three times, moves the caret up inside the edit control (unhighlights the text).
		WinHide, ahk_class ImlWinBackdropClass ; Hides the 3Darcade window.
		Winset, Top,, ControlsViewer ; Sets ControlsViewer window to be topmost.
		WinActivate, ControlsViewer ; Activates ControlsViewer window (if it wasn't already).
		}
	If !OnOff
		{
		WinRestore, %1% ; Restores game window.
		Gui, Hide ; Hides GameInfo window.
		}
Return

; --------------------------------------------------------------------------------------------------------->>
; ---------- Processes XML information from chosen game and retrieves all sorts of data ------------------->>
; --------------------------------------------------------------------------------------------------------->>
XmlProcess: ; Determines which mame executable parses the XML data for the chosen game
	Sleep 500 ; Waits half a second for the mame executable to open.
	TempGameXmlFile = %A_Temp%\TempXml.txt ; Sets location of temporary file, contains all XML data for chosen game
	GameIniFile = GameInfoData\%1%.ini ; Sets location of permanent INI file, will store INI version of XML data parsed from mame executable.
	IfExist, %GameIniFile% ; If INI file already exists, it is parsed for information as it is much smaller
		{
		IniRead, ChosenGameName, %GameIniFile%, controls, ChosenGameName, %A_Space%
		IniRead, Year, %GameIniFile%, controls, Year, %A_Space%
		IniRead, Manufacturer, %GameIniFile%, controls, Manufacturer, %A_Space%
		IniRead, PlayersTotal, %GameIniFile%, controls, PlayersTotal, %A_Space%
		IniRead, NumButtons, %GameIniFile%, controls, NumButtons, %A_Space%
		IniRead, ControlsType, %GameIniFile%, controls, ControlsType, %A_Space%
		IniRead, JoystickType, %GameIniFile%, controls, JoystickType, %A_Space%
		IniRead, HighScoreSupport, %GameIniFile%, controls, HighScoreSupport, %A_Space%
		}
	IfNotExist, %GameIniFile% ; If INI file does not exist, current game's XML is parsed from mame executable and processed to create INI.
		{ ; Beginning of "IfNotExist, %GameIniFile%" loop
		RunWait, %comspec% /c %RunningMame% %1% "-listxml" > "%TempGameXmlFile%",, Hide ; Uses mame executable to parse XML information about the current game
		FileRead, CurrentGameXml, %TempGameXmlFile% ; Reads XML data into variable from temporary file
		FileDelete, %TempGameXmlFile% ; Temporary file is deleted afterwards.
		; ------------------------------------------->>
		; --- First section of XML, to discard: ----->>
		; ------------------------------------------->>
		DiscardThisSectionBegin = `<`?xml ; --- Removes the following section -------------->>
		DiscardThisSectionEnd = `]`>
		DiscardThisSection := StrX( CurrentGameXml, DiscardThisSectionBegin, 1, 0, DiscardThisSectionEnd, 1, 0 ) ; Target data section to be deleted from XML data.
		StringReplace, CurrentGameXml, CurrentGameXml, %DiscardThisSection% ; ------------<<
		; ------------------------------------------->>
		; --- Game Name: ---------------------------->>
		; ------------------------------------------->>
		ChosenGameNameBegin = `<description`>
		ChosenGameNameEnd = `<`/description`>
		ChosenGameName := StrX( CurrentGameXml, ChosenGameNameBegin, 1, 13, ChosenGameNameEnd, 1, 14 ) ; Gets game name from inside description tags
		IfInString, ChosenGameName, `(
			{
			StringGetPos, BracketPosition, ChosenGameName, `( ; If there is a bracket then there is extra info which needs to be removed.
			StringLeft, ChosenGameName, ChosenGameName, %BracketPosition% ; Retrieves the game name from the left side of the left bracket
			}
		; ------------------------------------------->>
		; --- Year: --------------------------------->>
		; ------------------------------------------->>
		YearBegin = `<year`>
		YearEnd = `<`/year`>
		Year := StrX( CurrentGameXml, YearBegin, 1, 6, YearEnd, 1, 7 ) ; Gets year from inside 'year' tags	
		; ------------------------------------------->>
		; --- Manufacturer: ------------------------->>
		; ------------------------------------------->>
		ManufacturerBegin = `<manufacturer`>
		ManufacturerEnd = `<`/manufacturer`>
		Manufacturer := StrX( CurrentGameXml, ManufacturerBegin, 1, 14, ManufacturerEnd, 1, 15 ) ; Gets manufacturer from inside manufacturer tags
		IfInString, Manufacturer, `(
			{
			StringGetPos, BracketPosition, Manufacturer, `( ; If there is a bracket then there is extra info which needs to be removed.
			StringLeft, Manufacturer, Manufacturer, %BracketPosition% ; Retrieves the manufacturer name from the left side of the left bracket
			Manufacturer = %Manufacturer% ; Makes sure any remaining leading or trailing spaces are removed.
			}
		; --- Controls Section, --------------------->>
		; --- contains "Players Total"--------------->>
		; --- and "Number of Buttons" data----------->>
		ControlsTypeSectionBegin = `<input ; Gets the chunk of XML containing needed data about players and controls
		ControlsTypeSectionEnd = `<`/input`>
		ControlsTypeSection := StrX( CurrentGameXml, ControlsTypeSectionBegin, 1, 0, ControlsTypeSectionEnd, 1, 0 ) ; Gets input XML
		; ------------------------------------------->>
		; --- Players Total: ------------------------>>
		; ------------------------------------------->>
		PlayersTotalBegin = `<input players=`"
		PlayersTotalEnd = `"
		PlayersTotal := StrX( ControlsTypeSection, PlayersTotalBegin, 1, 16, PlayersTotalEnd, 1, 1 ) ; Gets amount of players
		PlayersTotalIni = %PlayersTotal% ; Places number into variable for INI file before it is processed for display.
		; ------------------------------------------->>
		; --- Number of Buttons --------------------->>
		; ------------------------------------------->>
		NumButtonsBegin = buttons`=`"
		NumButtonsEnd = `"
		NumButtons := StrX( ControlsTypeSection, NumButtonsBegin, 1, 9, NumButtonsEnd, 1, 1 ) ; Gets number of buttons
		NumButtonsIni = %NumButtons% ; Places number into variable for INI file before it is processed for display.
		; ------------------------------------------->>
		; --- Controls Type: ------------------------>>
		; ------------------------------------------->>
		ControlsTypeBegin = `<control type`=`"
		ControlsTypeEnd = `"
		n = 1
		KeyNumber = 1
		Loop ; Looks for multiple "ControlsType" entries and gathers data from them all.
			{
			CurrentControlsType := StrX( ControlsTypeSection, ControlsTypeBegin, n, 15, ControlsTypeEnd, n, 1, n )
			If CurrentControlsType = ; If no more control types are found...
				Break ; Loop is broken
			ControlsType%KeyNumber% = `, %CurrentControlsType% ; Adds a comma/space to the information (ControlType1's comma will be removed after all the data is retrieved).
			n:=n+1
			KeyNumber:=KeyNumber+1
			}
		StringReplace, ControlsType1, ControlsType1, `, ; Removes the comma from ControlType1, as it is the first data listed.
		If ControlsType1 = joy
			ControlsType1 = Joystick
		If ControlsType1 = doublejoy
			ControlsType1 = Dual Joysticks
		
		ControlsType = %ControlsType1%%ControlsType2%%ControlsType3%%ControlsType4%%ControlsType5%%ControlsType6%%ControlsType7%%ControlsType8%%ControlsType9%%ControlsType10%%ControlsType11%%ControlsType12%
		StringUpper, ControlsType, ControlsType, T ; Converts "ControlsType" into "title" format.
		ControlsTypeIni = %ControlsType% ; Keeps a copy of the data for the INI file
		
		JoystickTypeBegin = ways`=`"
		JoystickTypeEnd = `"
		JoystickType := StrX( ControlsTypeSection, JoystickTypeBegin, 1, 6, JoystickTypeEnd, 1, 1 ) ; Gets joystick directional type
		If JoystickType = vertical2
			JoystickType = Vertical 2
		JoystickTypeIni = %JoystickType% ; Places JoystickType into variable for INI file before it is processed for display.
		
		; ----------------------------------------------------------------------------------------------------->>
		; ----- Checks for State Save support with the current game's parsed XML data ------------------------->>
		; ----------------------------------------------------------------------------------------------------->>
		If HighScoreSupport = ; If nothing was retrieved from the current game's INI file:
			{ ; Beginning of "If HighScoreSupport" loop
			DriverStatusSectionBegin = `<driver status`= ; Gets the section of XML containing data about State Save support.
			DriverStatusSectionEnd = `/`>
			DriverStatusSection := StrX( CurrentGameXml, DriverStatusSectionBegin, 1, 0, DriverStatusSectionEnd, 1, 0 ) ; Gets driver status section in which State Save support is indicated.

			SaveStateSupportBegin = savestate`=`" ; Gets the State Save support information.
			SaveStateSupportEnd = `"
			SaveStateSupport := StrX( DriverStatusSection, SaveStateSupportBegin, 1, 11, SaveStateSupportEnd, 1, 1 ) ; Gets information about state saves.

			If SaveStateSupport = supported
				SaveStateSupport = State Save support ; Text which shows when there is State Save compatibility, shown from the parsed Mame executable. Period added to separate it from previous data
			If SaveStateSupport = unsupported
				SaveStateSupport= ; This variable is cleared if there is no State Save compatibility, shown from the parsed Mame executable.
			; ------------------------------------------------------------------------------------------------->>
			; ----- Checks for high score support in Hiscore.dat ---------------------------------------------->>
			; ------------------------------------------------------------------------------------------------->>
			HiScoreDatFile = hiscore.dat
			IfExist, %HiScoreDatFile% ; If Hiscore.dat exists in User's main folder:
				{
				FileRead, HiScoreDatFileContents, %HiScoreDatFile%
				IfInString, HiScoreDatFileContents, %1%`: ; If the current game's Rom name is in Hiscore.dat with a semicolon after it...
					HiScoreSupport = `, Hiscore`.dat support ; ...there is support for high score saving with this method.
				IfInString, HiScoreDatFileContents, `;%1%`: ; But if it starts with ';', the game's Rom name has been commented out (probably not a working entry).
					HiScoreSupport = ; Variable is cleared.
				IfNotInString, HiScoreDatFileContents, %1%`:
					HiScoreSupport = ; Variable is cleared.
				}
			; ------------------------------------------------------------------------------------------------->>
			; ----- Checks for the existence of Nvram files --------------------------------------------------->>
			; ------------------------------------------------------------------------------------------------->>
			IfExist, nvram\%1%.nv ; If Nvram file exists (Mame v0.0144 and older):
				NvramFilesExist = `, Nvram file exists ; The .NV file alone is looked for first as it is the older of two choices.
			IfExist, nvram\%1% ; If Nvram folder exists (Mame v0.0145 and newer):
				NvramFilesExist = `, Nvram folder exists ; The newer Nvram folder is looked for second, will take precedence over older .NV file.
			IfNotExist, nvram\%1% ; If Nvram folder does not exist...
				{
				IfNotExist, nvram\%1%.nv ; ...the older .NV file is looked for. If it is also not here...
				NvramFilesExist = ; ...variable is cleared.
				}
			; ------------------------------------------------------------------------------------------------->>
			; --- Combines %HiScoreSupport% and %SaveStateSupport% into one variable: %HighScoreSupport% ------>>
			; ------------------------------------------------------------------------------------------------->>
			HighScoreSupport = %SaveStateSupport%%HiScoreSupport%%NvramFilesExist% ; Combines these two variables, the presence of both indicates User can usually delete the matching state save file.
			If HighScoreSupport = `, Hiscore`.dat support ; If hiscore.dat is in use by itself...
				HighScoreSupport = Hiscore`.dat support ; ...comma is removed from beginning of string.
			If HighScoreSupport = `, Hiscore`.dat support`, Nvram file exists ; If hiscore.dat in use and there are Nvram files...
				HighScoreSupport = Hiscore`.dat support`, Nvram file exists ; ...comma is removed from beginning of string.
			If HighScoreSupport = `, Hiscore`.dat support`, Nvram folder exists ; If hiscore.dat in use and there are Nvram files...
				HighScoreSupport = Hiscore`.dat support`, Nvram folder exists ; ...comma is removed from beginning of string.
			If HighScoreSupport = `, Nvram file exists ; If only Nvram file(s) are detected...
				HighScoreSupport = Nvram file exists ; ...comma is removed from beginning of string.
			If HighScoreSupport = `, Nvram folder exists ; If only Nvram file(s) are detected...
				HighScoreSupport = Nvram folder exists ; ...comma is removed from beginning of string.
			If HighScoreSupport = ; If game uses none of the above...
				HighScoreSupport = No high score support ; No high score support is reported.
			} ; End of "If HighScoreSupport" loop
		} ; End of "IfNotExist, %GameIniFile%" loop

; --------------------------------------------------------------------------------------------------------->>
; ----------- Retrieves more data from "history.dat" if it exists in same directory as script ------------->>
; --------------------------------------------------------------------------------------------------------->>
	HistoryDatFile = history.dat
	IfExist, %HistoryDatFile% ; If this file is in User's arcade folder, it is parsed for more information about controls and buttons.
		{
		FileRead, HistoryDatFileContents, %HistoryDatFile%
		
		HistoryDatSectionBegin = `$info`=%1%`, ; Starts looking where running game's Rom name is found in 'history.dat'.
		IfNotInString, HistoryDatFileContents, `$info`=%1%`, ; If the main header is not immediately followed by the running game's Rom name...
			HistoryDatSectionBegin = `,%1%`, ; ...it might be farther along that same line, separated by commas.
		HistoryDatSectionEnd = `$end ; This is where the entire section ends.
		HistoryDatSection := StrX( HistoryDatFileContents, HistoryDatSectionBegin, 1, 0, HistoryDatSectionEnd, 1, 0 ) ; Gets section with all game info in it.
		HistoryDatInfoBegin = `$bio ; This is where the beginning of the text to display is found.
		HistoryDatInfoEnd = `$end ; It goes right to the end of the entire section as well.
		HistoryDatInfo := StrX( HistoryDatSection, HistoryDatInfoBegin, 1, 4, HistoryDatInfoEnd, 1, 0 ) ; Gets target data section with info text for display.
		Loop, parse, HistoryDatInfo, `n
			{
			IfInString, A_LoopField, `(c`) ; Looks for "(c)" (which is in title's line only) and removes line.
				{
				StringReplace, HistoryDatInfo, HistoryDatInfo, %A_LoopField%
				Break
				}
			}
		; ----------------------------------------------------------------------------------------------------->>
		; --- Removes the following two sections ("Technical" and "Sources" are not User-friendly) ------------>>
		; ----------------------------------------------------------------------------------------------------->>
		DiscardThisSectionBegin = `- TECHNICAL `-
		DiscardThisSectionEnd = `- TRIVIA `-
		DiscardThisSection := StrX( HistoryDatInfo, DiscardThisSectionBegin, 1, 0, DiscardThisSectionEnd, 1, 0 ) ; Target data section to be excluded from display.
		StringReplace, HistoryDatInfo, HistoryDatInfo, %DiscardThisSection%

		DiscardThisSectionBegin = `- Sources `-
		DiscardThisSectionEnd = `$end
		DiscardThisSection := StrX( HistoryDatInfo, DiscardThisSectionBegin, 1, 0, DiscardThisSectionEnd, 1, 4 ) ; Target data section to be excluded from display.
		StringReplace, HistoryDatInfo, HistoryDatInfo, %DiscardThisSection%
		; -----------------------------------------------------------------------------------------------------<<
		; -----------------------------------------------------------------------------------------------------<<
		; -----------------------------------------------------------------------------------------------------<<
		
		StringReplace, HistoryDatInfo, HistoryDatInfo, `$end ; "$end" needs to be removed after the data has been retrieved.
;		/*
		StringReplace, HistoryDatInfo, HistoryDatInfo, `n`r`n`r`n`r`n`r,, All ; Removes quadruple line-breaks.
		StringReplace, HistoryDatInfo, HistoryDatInfo, `n`r`n`r`n`r,, All ; Removes triple line-breaks.
		StringReplace, HistoryDatInfo, HistoryDatInfo, `n`r`n`r,, All ; Removes double line-breaks.
		StringReplace, HistoryDatInfo, HistoryDatInfo, `n`r,, All ; Removes line-breaks.
		StringReplace, HistoryDatInfo, HistoryDatInfo, `n`n`n`n`n,, All ; Removes quintuple line-breaks.
		StringReplace, HistoryDatInfo, HistoryDatInfo, `n`n`n`n,, All ; Removes quadruple line-breaks.
		StringReplace, HistoryDatInfo, HistoryDatInfo, `n`n`n,, All ; Removes triple line-breaks.
		StringReplace, HistoryDatInfo, HistoryDatInfo, `n`n,, All ; Removes double line-breaks.
;		*/
		}

; --------------------------------------------------------------------------------------------------------->>
; ----------- Retrieves more data from "catver.ini" if it exists in same directory as script -------------->>
; --------------------------------------------------------------------------------------------------------->>
	CatVerIniFile = catver.ini
	IfExist, %CatVerIniFile% ; If this file is in User's arcade folder, it is parsed for more information about controls and buttons.
		{
		IniRead, Category, %CatVerIniFile%, Category, %1%, %A_Space% ; Retrieves game category.
		StringReplace, Category, Category, Amer`., American, All ; Converts abbreviated form of "American".
		StringReplace, Category, Category, `&, and, All ; Converts ampersand to literal 'and'.
		Category = `n%Category% ; Adds a line break before the data.
		If Category = `n ; If only this data is in this variable, there was no real data to retrieve...
			Category = ; ...and the variable is cleared entirely.
		
		IniRead, VerAdded, %CatVerIniFile%, VerAdded, %1%, %A_Space% ; Retrieves version of Mame first supported the game.
		StringReplace, VerAdded, VerAdded, `., 0`., All ; Adds '0' to the reported number so it matches with current mame version number.
		VerAdded = `(added v%VerAdded%`) ; Adds a period to separate the data from other data.
		If VerAdded = `(added v`) ; If only this data is in this variable, there was no real data to retrieve...
			VerAdded =  ; ...and the variable is cleared entirely, except for the period which is added to "CurrentMameReported" info.
		}
			
; --------------------------------------------------------------------------------------------------------->>
; ----------- Retrieves more data from "controls.ini" if it exists in same directory as script ------------>>
; --------------------------------------------------------------------------------------------------------->>
	ControlsIniFile = controls.ini
	IfExist, %ControlsIniFile% ; If this file is in User's arcade folder, it is parsed for more information about controls and buttons.
		{ ; Beginning of "IfExist" loop
		IniRead, Alternating, %ControlsIniFile%, %1%, Alternating, %A_Space%
		If Alternating = 0 ; If this says '0'...
			PlayMode = Simultaneous ; Players can play simultaneously.
		If Alternating = 1
			PlayMode = Alternating
		IniRead, MiscDetails, %ControlsIniFile%, %1%, miscDetails, %A_Space%
		StringReplace, MiscDetails, MiscDetails, OTHER`:,, All ; Removes this if it exists.
;		/*
		StringReplace, MiscDetails, MiscDetails, `n`r`n`r`n`r`n`r,, All ; Removes quadruple line-breaks.
		StringReplace, MiscDetails, MiscDetails, `n`r`n`r`n`r,, All ; Removes triple line-breaks.
		StringReplace, MiscDetails, MiscDetails, `n`r`n`r,, All ; Removes double line-breaks.
		StringReplace, MiscDetails, MiscDetails, `n`r,, All ; Removes line-breaks.
		StringReplace, MiscDetails, MiscDetails, `n`n`n`n`n,, All ; Removes quintuple line-breaks.
		StringReplace, MiscDetails, MiscDetails, `n`n`n`n,, All ; Removes quadruple line-breaks.
		StringReplace, MiscDetails, MiscDetails, `n`n`n,, All ; Removes triple line-breaks.
		StringReplace, MiscDetails, MiscDetails, `n`n,, All ; Removes double line-breaks.
;		*/
		If MiscDetails != ; If there is data here...
			MiscDetails = `n%MiscDetails%`n`n ; Adds a line-break before and two line-breaks after, to separate data for better readability.
		If MiscDetails = ; If this variable is empty...
			MiscDetails = `n`n ; Adds two line-breaks to separate the rest of the data from the previous data, for better readability.
		; ----------------------------------------------------------------------------------------------------->>
		; --- Retrieves button label and joystick information ------------------------------------------------->>
		; ----------------------------------------------------------------------------------------------------->>
		n=1 ; Starts the below loop at 1 (Player 1 button 1).
		Loop
			{
			CurrentButtonLabel = P1_BUTTON%n% ; Places button label into 'CurrentButtonLabel' variable.
			IniRead, ThisButtonLabel, %ControlsIniFile%, %1%, %CurrentButtonLabel%, %A_Space%
			If ThisButtonLabel = ; If there is no information in this variable...
				Break ; ... loop is ended.
			P1Button%n% = Button %n% `- %ThisButtonLabel%`n ; Makes the information readable.
			n:=n+1 ; Adds 1 to 'n' and loops again.
			}
		} ; End of "IfExist" loop
	If PlayersTotal = 1 ; If 1 player is detected...
		PlayersTotalDisplay = `n1 Player`n ; ...singular context is used and "Simultaneous" or "Alternating" is not included in description.
	If PlayersTotal > 1 ; If more than 1 player is detected...
		PlayersTotalDisplay = `n%PlayersTotal% Players %PlayMode%`n ; ...plural context is used and "Simultaneous" or "Alternating" is included in description.

	If NumButtons = 1 ; If there is one button...
		NumButtonsDisplay = `, 1 Button ; ...singular context is displayed
	If NumButtons > 1 ; If there is more than one button...
		NumButtonsDisplay = `, %NumButtons% Buttons ; ...plural context is displayed
	
	If JoystickType !=
		JoystickType = %JoystickType%`-way ; If joystick entries have directional properties attached, they are shown.
	ControlsType = %JoystickType% %ControlsType%%NumButtonsDisplay% ; "JoystickType" and "ControlsType" + comma are also used in case they exist
	If ControlsType = %NumButtonsDisplay% ; But if there are no controls listed, and only buttons...
		{
		StringReplace, NumButtonsDisplay, NumButtonsDisplay, `, ; Removes the comma from the beginning of buttons data as it is the only info displayed.
		ControlsType = %NumButtonsDisplay% ; ...everything is pruned out of "ControlsType" variable except for buttons.
		}

	If RomName != ; If the Rom name is retrieved...
		RomName = Rom Name`: %1%`n ; ...it is wrapped with descriptive tag and a line break.

/* This section is redundant at the moment... until I figure out a way to parse TwinGalaxies.com
; --------------------------------------------------------------------------------------------------------->>
; ----------- Retrieves more data from "story.dat" if it exists in same directory as script --------------->>
; --------------------------------------------------------------------------------------------------------->>
	StoryDatIniFile = story.dat
	IfExist, %StoryDatIniFile% ; If this file is in User's arcade folder, it is parsed for high score records.
		{
		FileRead, StoryDatContents, %StoryDatIniFile% ; Reads Story.dat into a variable for parsing.
		StoryDatEntryBegin = `$info`=%1% ; This is where the beginning of the section to parse is found, at the current game name.
		StoryDatEntryEnd = `$end ; Ends here.
		StoryDatEntrySection := StrX( StoryDatContents, StoryDatEntryBegin, 1, 0, StoryDatEntryEnd, 1, 0 ) ; Gets target data section.
		DiscardThisSectionBegin = `! MAMESCORE INSTRUCTIONS `! ; Anything in this section is French and well, I'm not French so it can go away. No offense to French people in France.
		DiscardThisSectionEnd = `$end ; Ends here.
		DiscardThisSection := StrX( StoryDatEntrySection, DiscardThisSectionBegin, 1, 0, DiscardThisSectionEnd, 1, 0 ) ; Gets target data section.
		StringReplace, StoryDatEntrySection, StoryDatEntrySection, %DiscardThisSection% ; Tosses the data.
		StoryDatInfoBegin = `$story ; This is where the beginning of the text to display is found.
		StoryDatInfoEnd = `$end ; Ends here.
		StoryDatInfoSection := StrX( StoryDatEntrySection, StoryDatInfoBegin, 1, 8, StoryDatInfoEnd, 1, 4 ) ; Gets target data with info text for display.
		StoryDatInfoSection = %StoryDatInfoSection% ; Removes any leading or trailing spaces.
		StringUpper, StoryDatInfoSection, StoryDatInfoSection, T ; Converts the data to "title" format for readability.
		StringReplace, StoryDatInfoSection, StoryDatInfoSection, MAMESCORE Records `:, MAME high score records as of ; Changes this for readability.
		StringReplace, StoryDatInfoSection, StoryDatInfoSection, `_`_`_`_, `_, All ; Removes all underscores from between listed players' names and their score entries ---->>
		StringReplace, StoryDatInfoSection, StoryDatInfoSection, `_`_`_, `_, All
		StringReplace, StoryDatInfoSection, StoryDatInfoSection, `_`_, `_, All
		StringReplace, StoryDatInfoSection, StoryDatInfoSection, `_`_, `_, All
		StringReplace, StoryDatInfoSection, StoryDatInfoSection, `_, %A_Space%`-%A_Space%, All ; Replaces the last underscores with "space dash space" ---------------------<<
		StringReplace, StoryDatInfoSection, StoryDatInfoSection, `., `,, All ; Replaces any periods with commas, for score readability.
;		/*
		StringReplace, StoryDatInfoSection, StoryDatInfoSection, `n`r`n`r`n`r`n`r,, All ; Removes quadruple line-breaks.
		StringReplace, StoryDatInfoSection, StoryDatInfoSection, `n`r`n`r`n`r,, All ; Removes triple line-breaks.
		StringReplace, StoryDatInfoSection, StoryDatInfoSection, `n`r`n`r,, All ; Removes double line-breaks.
		StringReplace, StoryDatInfoSection, StoryDatInfoSection, `n`r,, All ; Removes line-breaks.
		StringReplace, StoryDatInfoSection, StoryDatInfoSection, `n`n`n`n`n`n,, All ; Removes sextuple line-breaks.
		StringReplace, StoryDatInfoSection, StoryDatInfoSection, `n`n`n`n`n,, All ; Removes quintuple line-breaks.
		StringReplace, StoryDatInfoSection, StoryDatInfoSection, `n`n`n`n,, All ; Removes quadruple line-breaks.
		StringReplace, StoryDatInfoSection, StoryDatInfoSection, `n`n`n,, All ; Removes triple line-breaks.
		StringReplace, StoryDatInfoSection, StoryDatInfoSection, `n`n,, All ; Removes double line-breaks.
;		*/
		}
End of redundant high score section
*/

; --------------------------------------------------------------------------------------------------------->>
; ---------- Sums up all the variables' data into two variables: "GameInfoHeader" and "GameInfo" ---------->>
; --------------------------------------------------------------------------------------------------------->>
	GeneralInfo = %ChosenGameName%%Category%%PlayersTotalDisplay%%ControlsType%`n`n
	ButtonsInfo = %P1Button1%%P1Button2%%P1Button3%%P1Button4%%P1Button5%%P1Button6%%P1Button7%%P1Button8%%P1Button9%%P1Button10%%P1Button11%%P1Button12%%P1Button13%%P1Button14%%P1Button15%%P1Button16%
	StringUpper, ButtonsInfo, ButtonsInfo, T ; Converts the data to "title" format.
	
	FileGetVersion, RunningMameFileVersion, %RunningMame% ; Gets file version number of current Mame executable.
	RunningMame = Mame v%RunningMameFileVersion% %VerAdded% ; Combines currently running Mame executable version number and the version it was added.
	If RunningMame = Mame v %VerAdded% ; If 'RunningMame' variable is empty...
		{
		StringReplace, VerAdded, VerAdded, `( ; ...left-side bracket is removed from 'VerAdded'.
		StringReplace, VerAdded, VerAdded, `) ; ...right-side bracket is removed from 'VerAdded'.
		StringReplace, VerAdded, VerAdded, added, Added ; ...this word is capitalized.
		RunningMame = %VerAdded%
		}
		
	GameInfoHeader = %GeneralInfo%%ButtonsInfo% ; Combines this information into 'GameInfoHeader' variable... will have larger display text.
	GameInfo = %RomName%%Year% %Manufacturer%`n%RunningMame%`n%HighScoreSupport%`n%MiscDetails%%HistoryDatInfo%%StoryDatInfoSection% ; Combines this information into 'GameInfo' variable (%StoryDatInfoSection% is currently redundant).

	StringReplace, GameInfoHeader, GameInfoHeader, `&, and, All ; Replaces ampersands with the word 'and'.
	StringReplace, GameInfoHeader, GameInfoHeader, –, %A_Space%-%A_Space%, All ; Replaces these weird things with ' - '.
	StringReplace, GameInfoHeader, GameInfoHeader, –, %A_Space%-%A_Space%, All ; Replaces these weird things with ' - '.
	StringReplace, GameInfoHeader, GameInfoHeader, ’, ', All ; Replaces these weird things with apostrophes.
	StringReplace, GameInfoHeader, GameInfoHeader, ’, ', All ; Replaces these weird things with apostrophes.
	StringReplace, GameInfoHeader, GameInfoHeader, Â,, All ; Removes these weird things.
	StringReplace, GameInfoHeader, GameInfoHeader, ´, ', All ; Replaces these weird things with apostrophes.
	StringReplace, GameInfoHeader, GameInfoHeader, Â,, All ; Removes these weird things.
	StringReplace, GameInfoHeader, GameInfoHeader, %A_Space%%A_Space%, %A_Space%, All ; Changes double-spaces into singles.
	StringReplace, GameInfoHeader, GameInfoHeader, %A_Tab%, %A_Space%, All ; Replaces any tabbed spaces with regular spaces.
	StringReplace, GameInfo, GameInfo, andlt`;,, All ; Replaces these with nothing. I'm assuming they are some kind of apostrophes. In any case they show up as nonsense.
	StringReplace, GameInfo, GameInfo, andgt`;,, All ; Same as these ones.
	
	StringReplace, GameInfo, GameInfo, `&, and, All ; Replaces ampersands with the word 'and'.
	StringReplace, GameInfo, GameInfo, –, %A_Space%`-%A_Space%, All ; Replaces these weird things with ' - '.
	StringReplace, GameInfo, GameInfo, –, %A_Space%-%A_Space%, All ; Replaces these weird things with ' - '.
	StringReplace, GameInfo, GameInfo, ’, ', All ; Replaces these weird things with apostrophes.
	StringReplace, GameInfo, GameInfo, ’, ', All ; Replaces these weird things with apostrophes.
	StringReplace, GameInfo, GameInfo, Â,, All ; Removes these weird things.
	StringReplace, GameInfo, GameInfo, ´, ', All ; Replaces these weird things with apostrophes.
	StringReplace, GameInfo, GameInfo, Â,, All ; Removes these weird things.
	StringReplace, GameInfo, GameInfo, %A_Space%%A_Space%, %A_Space%, All ; Changes double-spaces into singles.
	StringReplace, GameInfo, GameInfo, %A_Tab%, %A_Space%, All ; Replaces any tabbed spaces with regular spaces.
	StringReplace, GameInfo, GameInfo, `n`r`n`r`n`r`n`r, `n`n, All ; Removes quadruple line-breaks.
	StringReplace, GameInfo, GameInfo, `n`r`n`r`n`r, `n`n, All ; Replaces triple line-breaks with doubles.
	StringReplace, GameInfo, GameInfo, `n`r, `n, All ; Replaces singular line-breaks with regular singles.
	StringReplace, GameInfo, GameInfo, `n`n`n`n`n, `n`n, All ; Replaces quintuple line-breaks with doubles.
	StringReplace, GameInfo, GameInfo, `n`n`n`n, `n`n, All ; Replaces quadruple line-breaks with doubles.
	StringReplace, GameInfo, GameInfo, `n`n`n, `n`n, All ; Replaces triple line-breaks with doubles.
	StringReplace, GameInfo, GameInfo, andlt`;,, All ; Replaces these with nothing. I'm assuming they are some kind of apostrophes. In any case they show up as nonsense.
	StringReplace, GameInfo, GameInfo, andgt`;,, All ; Same as these ones.

	Loop, Parse, GameInfoHeader, `n, `r ; Counts the rows of data in 'GameInfoHeader'.
		GameInfoHeaderRows = %A_Index% ; Assigns that number to 'GameInfoHeaderRows'.
	If GameInfoHeaderRows < 1 ; If no rows are found...
		GameInfoHeaderRows = 1 ; ...adds one row so something is reported.
	
	Loop, Parse, GameInfo, `n, `r ; Counts the rows of data in 'GameInfo'.
		GameInfoRows = %A_Index% ; Assigns that number to 'GameInfoRows'.
	If GameInfoRows < 1 ; If no rows are found...
		GameInfoRows = 1 ; ...adds one row so something is reported.
; --------------------------------------------------------------------------------------------------------->>
; ------------ If INI file for current game does not exist, it is created here ---------------------------->>
; --------------------------------------------------------------------------------------------------------->>
	IfNotExist, %GameIniFile%
		{
		If ChosenGameName != ; If this variable contains information...
			IniWrite, %ChosenGameName%, %GameIniFile%, controls, ChosenGameName ; It is written to INI file.
		If Year !=
			IniWrite, %Year%, %GameIniFile%, controls, Year
		If Manufacturer !=
			IniWrite, %Manufacturer%, %GameIniFile%, controls, Manufacturer
		If PlayersTotalIni !=
			IniWrite, %PlayersTotalIni%, %GameIniFile%, controls, PlayersTotal
		If NumButtonsIni !=
			IniWrite, %NumButtonsIni%, %GameIniFile%, controls, NumButtons
		If ControlsTypeIni !=
			IniWrite, %ControlsTypeIni%, %GameIniFile%, controls, ControlsType
		If JoystickTypeIni !=
			IniWrite, %JoystickTypeIni%, %GameIniFile%, controls, JoystickType
		If ControlsTypeIni !=
			IniWrite, %HighScoreSupport%, %GameIniFile%, controls, HighScoreSupport
		}
Return

; --------------------------------------------------------------------------------------------------------->>
; If User has not configured this system, the next section configures Mame executables and .BAT files ----->>
; --------------------------------------------------------------------------------------------------------->>
CreateMainConfigFile:
	IfNotExist, GameInfoData ; If there is no GameInfoData folder in User's arcade folder...
		FileCreateDir, GameInfoData ; one is created.
	MsgBox,1,,
		(
		You will now be prompted to choose your Mame executable`(s`)`.
		You may choose multiple files`.`.`. as many versions as you wish`.
		I personally use 7 differently named Mame`.exe files`. There is no limit`.`n
		Your Mame executables MUST be in the main 3Darcade folder, the same
		location as GameInfo`.exe `(Hiscore`.dat would be there if present`)`.
		If so, move the Mame.exe file`(s`) and change the paths in its INI file`.
		)
	IfMsgBox, Cancel ; If User cancels...
		GoSub, UserDidNotChoose ; Message shown if User does not choose any Mame executables.
	
	n=1 ; Starts loop at 1
	Loop
		{ ; Start of "MameExe%n%" loop ------------------------>>
		ChosenMameVersion = MameExe%n%
		FileSelectFile, ChosenMameVersion, 1, %A_WorkingDir%, Please select your MAME`.EXE file`(s`)`:, *.exe
		If ErrorLevel = 1
			{
			If n = 1 ; If n equals 1, it is the loop's first pass which means User has not chosen anything.
				GoSub, UserDidNotChoose ; Message shown if User does not choose any Mame executables.
			If n > 1 ; If 'n' is greater than 1, at least one MAME.EXE has been chosen.
				{
				GoSub, ChooseHotkeyGui ; Prompts User to choose a toggle key to view game information, then finishes.
				Break ; Loop is broken.
				}
			}
		SplitPath, ChosenMameVersion, ChosenMameVersionExt,,, ChosenMameVersionNoExt ; Splits off filename and extension from full path.
		GoSub, BuildCurrentBatFile ; Builds the batch files which run the system.
		
; --- Creates INI file that indicates system has already been configured ----->>
		IniWrite, %ChosenMameVersionExt%, %ConfigFile%, ChosenMameExe, MameExeVersion%n% ; Writes chosen Mame executables to the INI file in 'ChosenMameExe' section, 'MameExeVersion%n%' key.
		MsgBox, 4,, %ChosenMameVersionExt% was successfully assigned`.`nWould you like to select another Mame`.exe file`?
		IfMsgBox, Yes
			n:=n+1 ; Adds 1 to the number 'n' and loops again.
		IfMsgBox, No
			{
			GoSub, ChooseHotkeyGui ; Prompts User to choose a toggle key to view game information, then finishes.
			Break ; Loop is broken.
			}
		} ; End of "MameExe%n%" loop --------------------------<<
	IniWrite, %HotKey%, %ConfigFile%, ChosenHotKey, CurrentHotkey ; Adds User's chosen HotKey to the main INI file in 'ChosenHotKey' section, 'CurrentHotkey' key.
Return

; --------------------------------------------------------------------------------------------------------->>
; ----- Reads 'GameInfoData\config.ini' and creates batch files at which User can point 3DArcade ---------->>
; --------------------------------------------------------------------------------------------------------->>
BatchFileBuilder:
	n=1 ; Starts loop at 1
	Loop ; Reads config.ini entries for mame.exe files User has chosen previously.
		{
		IniRead, ChosenMameVersion, %ConfigFile%, ChosenMameExeFiles, MameExeVersion%n%, %A_Space%
		If ChosenMameVersion = ; If there is no data in this variable...
			Break ; ...loop is broken.
		SplitPath, ChosenMameVersion, ChosenMameVersionExt,,, ChosenMameVersionNoExt ; Splits off filename and extension from full path.
		GoSub, BuildCurrentBatFile ; Builds the .BAT launcher file which runs this script and the chosen game.
		n:=n+1 ; Adds 1 to the number 'n' and loops again.
		}
Return ; 'BatchFileBuilder' and 'BuildCurrentBatFile' work together if system is not configured --->>
BuildCurrentBatFile: ; ------------------------------------------------------------------------------------<<
	IfExist, GameInfo.ahk ; If User is using AHK script...
		ScriptExtension = ahk ; ...batch files are made with .ahk extension (for using the AHK script).
	IfExist, GameInfo.exe ; If User is using EXE script...
		ScriptExtension = exe ; ...batch files are made with .exe extension (for using the compiled EXE... takes precedence over GameInfo.ahk).
	FileDelete, %ChosenMameVersionNoExt%.bat ; Deletes any existing .BAT file of the same name (If User deletes "GameInfoData\_config.ini" and reconfigures).
	FileAppend, ; Creates a batch file which User can point 3DArcade at. Substitutes as the chosen emulator and matches existing mame.exe filenames.
		(
		`@echo off
		Set RunningMame`=%ChosenMameVersionExt%
		start GameInfo`.%ScriptExtension% `"`%1`"
		%ChosenMameVersionExt% `"`%1`"
		exit`n
		`# Built By`: %BuiltBy%
		`# Company`: %Company%
		`# Version`: %VerNumber%
		`# Build Date`: %BuildDate%
		), %ChosenMameVersionNoExt%.bat ; "%1" is the game name's variable which 3DArcade sends to the .BAT file.
Return

; --------------------------------------------------------------------------------------------------------->>
; ----- 'ChooseHotkey' prompts User to choose a key which will display the information screen ------------->>
; --------------------------------------------------------------------------------------------------------->>
ChooseHotkeyGui: ; Window which allows User to type a hotkey.
	InputBox, HotKey, Select Key, Please select the key to use`nfor viewing game information`:,, 200 ;, Height, X, Y
	If ErrorLevel ; If User presses Cancel or closes InputBox:
		{
		MsgBox, No key chosen. You must choose a key.
		GoTo, ChooseHotkeyGui ; Begins this sequence again.
		}
	If HotKey = ; If User entered nothing but pressed OK...
		{
		MsgBox, No key chosen. You must choose a key.
		GoTo, ChooseHotkeyGui ; Begins this sequence again.
		}
	StringLen, HotKeyLength, HotKey ; Gets the number of characters in HotKey variable.
	If HotKeyLength > 1 ; If there is more than one character:
		{
		MsgBox, You can only choose a single letter or number. ; User is prompted to choose a regular letter or number.
		GoTo, ChooseHotkeyGui
		}
	If Hotkey is number
		LetterOrNumber = number
	If HotKey is alpha
		LetterOrNumber = letter
	If HotKey is not number
		{
		If HotKey is not alpha
			{
			MsgBox, You can only choose regular letters and numbers. ; User is prompted to choose a regular letter or number.
			GoTo, ChooseHotkeyGui
			}
		}
	StringUpper, HotKey, Hotkey, T ; If chosen key is a letter, it is capitalized for display.
	MsgBox, ; Message shown if User successfully chooses one or more Mame executables.
		(
		One or more Mame executables have been successfully chosen`!`n
		A `.BAT file has been created beside your Mame executable`(s`)`.
		After you are finished, point your system to the `.BAT file`(s`)
		instead of the `.EXE file`(s`)`. In 3DArcade, this is done by
		opening `"config`.bat`" and choosing your regular `.EXE file`.
		Then replace `.EXE with `.BAT in the text entry field on the
		top of the file selection box`. Your system should think
		the `.BAT file is the actual Mame`.exe emulator`.`n
		You have chosen the %LetterOrNumber% `'%HotKey%`' as the key used to view game info`.
		At any time while playing a game, press `'%HotKey%`' and wait
		a few seconds for the game information to be gathered and
		displayed`. It seems to do this more quickly and efficiently
		if the game is paused before pressing `'%HotKey%`'`.
		)
	HotKey = `~%HotKey%  ; The '~' modifier is added so the key's regular function is not affected.
	IniWrite, %HotKey%, %ConfigFile%, ChosenHotKey, CurrentHotkey ; Adds User's chosen HotKey to the main INI file in 'ChosenHotKey' section, 'CurrentHotkey' key.
Return

; --------------------------------------------------------------------------------------------------------->>
; ----------- Message shown if User does not choose any Mame executables ---------------------------------->>
; --------------------------------------------------------------------------------------------------------->>
UserDidNotChoose:
	MsgBox, You did not select any mame executables`.`nRun this program again when you are ready`.
	ExitApp ; Script exits and INI file is not written (if loop was simply broken the INI would be created).
Return

; --------------------------------------------------------------------------------------------------------->>
; --- Every 1/2 second this runs. If the current game window does not exist, script exits ----------------->>
; --------------------------------------------------------------------------------------------------------->>
DetectMameWindow:
	IfWinNotExist, %1%
		ExitApp
Return

; --------------------------------------------------------------------------------------------------------->>
; --------- StrX (by Skan) allows XML and HTML data files to be parsed ------------------------------------>>
; --------------------------------------------------------------------------------------------------------->>
StrX(H,BS="",BO=0,BT=1,ES="",EO=0,ET=1,ByRef N="")
	{
	Return SubStr(H,P:=(((Z:=StrLen(ES))+(X:=StrLen(H))+StrLen(BS)-Z-X)?((T:=InStr(H,BS,0,((BO
	<0)?(1):(BO))))?(T+BT):(X+1)):(1)),(N:=P+((Z)?((T:=InStr(H,ES,0,((EO)?(P+1):(0))))?(T-P+Z
	+(0-ET)):(X+P)):(X)))-P) ; v1.0-196c 21-Nov-2009 www.autohotkey.com/forum/topic51354.html
	}
Return



aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
Oh no! I did not notice the subforums... this should be in the gaming threads. I accidentally posted in the wrong area :( sorry about that. How do I fix this?

aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
Thank you SKAN for moving the post... and also for your StrX function, this script mainly relies on it :)

I've been trying to capture the screen in a video to show it in operation but with ZDsoft screen recorder
i am only getting the top left corner of the screen. I have to find something else to do this with.