Advertisement
djvj

Untitled

Apr 4th, 2015
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 99.71 KB | None | 0 0
  1. MCRC=C8A44421
  2. MVersion=1.0.9
  3.  
  4. BezelGUI(){
  5. Global
  6. if (bezelEnabled = "true"){
  7. Log("BezelGUI - Started")
  8. ; creating GUi elements and pointers
  9. ; Bezel_GUI1 - Background
  10. ; Bezel_GUI2 - Overlay
  11. ; Bezel_GUI3 - Bezel Image
  12. ; Bezel_GUI4 - Instruction Card
  13. ; Bezel_GUI5 - Instruction Card Left Menu Background
  14. ; Bezel_GUI6 - Instruction Card Left Menu List
  15. ; Bezel_GUI7 - Instruction Card Right Menu Background
  16. ; Bezel_GUI8 - Instruction Card Right Menu List
  17. ;initializing gdi plus
  18. If !pToken
  19. pToken := Gdip_Startup()
  20. Loop, 8 {
  21. If (a_index = 1) {
  22. Gui, Bezel_GUI%A_Index%: +Disabled -Caption +E0x80000 +OwnDialogs +LastFound +ToolWindow
  23. } Else {
  24. OwnerGUI := A_Index - 1
  25. Gui, Bezel_GUI%A_Index%: +OwnerBezel_GUI%OwnerGUI% +Disabled -Caption +E0x80000 +OwnDialogs +LastFound +ToolWindow +AlwaysOnTop
  26. }
  27. Gui, Bezel_GUI%A_Index%: Margin,0,0
  28. Gui, Bezel_GUI%A_Index%: Show,, BezelLayer%A_Index%
  29. Bezel_hwnd%A_Index% := WinExist()
  30. Bezel_hbm%A_Index% := CreateDIBSection(A_ScreenWidth, A_ScreenHeight)
  31. Bezel_hdc%A_Index% := CreateCompatibleDC()
  32. Bezel_obm%A_Index% := SelectObject(Bezel_hdc%A_Index%, Bezel_hbm%A_Index%)
  33. Bezel_G%A_Index% := Gdip_GraphicsFromhdc(Bezel_hdc%A_Index%)
  34. Gdip_SetSmoothingMode(Bezel_G%A_Index%, 4)
  35. }
  36. Log("BezelGUI - Ended")
  37. }
  38. }
  39.  
  40. BezelStart(Mode="",parent="",angle="",rom=""){
  41. Global
  42. if (bezelEnabled = "true"){
  43. Log("BezelStart - Started")
  44. ;Defining Bezel Mode
  45. if !Mode
  46. bezelMode = Normal
  47. else if (Mode = "fixResMode")
  48. bezelMode = fixResMode
  49. else if (Mode = "layout")
  50. bezelLayoutFile = %rom%
  51. else if RegExMatch(Mode, "^\d+$")
  52. bezelMode = MultiScreens
  53. else
  54. Log("Invalid Bezel mode defined on the module.",3)
  55. ;Choosing to use layout files or normal bezel
  56. if bezelLayoutFile
  57. {
  58. If !FileExist( emuPath . "\artwork\" . bezelLayoutFile . ".zip") and !FileExist( emuPath . "\artwork\" . parent . ".zip")
  59. {
  60. Log("Bezel - Layout mode selected but no MAME or MESS layout file found. Using HyperLaunch Bezel normal mode instead.",1)
  61. bezelMode = Normal
  62. bezelLayoutFile =
  63. } else {
  64. Log("Bezel - MAME or MESS layout file (" . emuPath . "\artwork\" . bezelLayoutFile . ".zip" . " or " . emuPath . "\artwork\" . parent . ".zip" . ") already exists. Bezel addon will exit without doing any change to the emulator launch.",1)
  65. useBezels := " -use_bezels"
  66. Return
  67. }
  68. }
  69. Log("Bezel - Bezel mode " . bezelMode . " selected.",4)
  70. ;Check for old modules error
  71. IfWinNotExist, BezelLayer1
  72. ScriptError("You have an old incompatible module version.`n`r`n`rUpdate your modules before running HyperLaunch again!!!")
  73. ; -------------- Read ini options and define default values
  74. Bezel_GlobalFile := A_ScriptDir . "\Settings\Global Bezel.ini"
  75. Bezel_SystemFile := A_ScriptDir . "\Settings\" . systemName . "\Bezel.ini"
  76. Bezel_RomFile := A_ScriptDir . "\Settings\" . systemName . "\" . dbname . "\Bezel.ini"
  77. if (RIni_Read("bezelGlobalRini",Bezel_GlobalFile) = -11)
  78. RIni_Create("bezelGlobalRini")
  79. if (RIni_Read("bezelSystemRini",Bezel_SystemFile) = -11)
  80. RIni_Create("bezelSystemRini")
  81. if (RIni_Read("BezelRomRini",Bezel_RomFile) = -11)
  82. RIni_Create("BezelRomRini")
  83. ;[Settings]
  84. bezelFileExtensions := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Settings", "Bezel_Supported_Image_Files","png|gif|tif|bmp|jpg")
  85. ;[Bezel Change]
  86. bezelChangeDur := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Bezel Change", "Bezel_Transition_Duration","500")
  87. bezelSaveSelected := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini","Bezel Change","Bezel_Save_Selected","false")
  88. extraFullScreenBezel := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini","Bezel Change","Extra_FullScreen_Bezel","false")
  89. ;[Background]
  90. bezelBackgroundChangeDur := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Background", "Background_Change_Timer","0") ; 0 if disabled, number if you want the bezel background to change automatically at each x miliseconds
  91. bezelBackgroundTransition := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Background", "Background_Transition_Animation","fade") ; none or fade
  92. bezelBackgroundTransitionDur := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Background", "Background_Transition_Duration","500") ; determines the duration of fade bezel background transition
  93. bezelUseBackgrounds := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Background", "Use_Backgrounds","false") ; determines the duration of fade bezel background transition
  94. ;[Bezel Change Keys]
  95. nextBezelKey := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Bezel Change Keys", "Next_Bezel_Key", "")
  96. previousBezelKey := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Bezel Change Keys", "Previous_Bezel_Key","")
  97. If (bezelICEnabled = "true") {
  98. ;[Instruction Cards General Settings]
  99. positionIC := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards General Settings", "IC_Positions","topLeft|topRight|bottomLeft|bottomRight|topCenter|leftCenter|rightCenter|bottomCenter") ; (1-8 positions) can be topLeft|topRight|bottomLeft|bottomRight|topCenter|leftCenter|rightCenter|bottomCenter
  100. animationIC := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards General Settings", "IC_Transition_Animation","fade") ; can be none, fade, slideIn, slideOutandIn
  101. ICChangeDur := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards General Settings", "IC_Transition_Duration","500")
  102. enableICChangeSound := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards General Settings", "IC_Enable_Transition_Sound","true") ; It searches for sound files named ICslideIn.mp3, ICslideOut.mp3, ICFadeOut.mp3, ICFadeIn.mp3 or ICChange.mp3 on the default global, default system and rom bezel folders to be played while changing the ICs
  103. ICScaleFactor := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards General Settings", "IC_Scale_Factor","ScreenHeight") ;you can choose between a number (1 to keep the original image size), or the words: ScreenHeight, ScreenWidth, HalfScreenHeight, HalfScreenWidth, OneThirdScreenHeight and OneThirdScreenWidth in order to resize the image in relation to the screen size. The default value is ScreenHeight that will work better in any resolution with a two ICs option (also the default one).
  104. ICSaveSelected := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini","Instruction Cards General Settings","IC_Save_Selected","false")
  105. ;[Instruction Cards Menu]
  106. leftMenuPositionsIC := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Menu", "IC_Left_Menu_Positions","topLeft|leftCenter|bottomLeft|bottomCenter") ; (1-8 positions) can be topLeft|topRight|bottomLeft|bottomRight|topCenter|leftCenter|rightCenter|bottomCenter
  107. ICleftMenuListItems := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Menu", "IC_Left_Menu_Number_of_List_Items","7")
  108. rightMenuPositionsIC := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Menu", "IC_Right_Menu_Positions","topRight|rightCenter|bottomRight|topCenter") ; (1-8 positions) can be topLeft|topRight|bottomLeft|bottomRight|topCenter|leftCenter|rightCenter|bottomCenter
  109. ICrightMenuListItems := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Menu", "IC_Right_Menu_Number_of_List_Items","7")
  110. ;[Instruction Cards Visibility]
  111. displayICOnStartup := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Visibility", "IC_Display_Card_on_Startup","false")
  112. ICRandomSlideShowTimer := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Visibility", "IC_Random_Slide_Show_Timer","0")
  113. toogleICVisibilityKey := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Visibility", "IC_Toggle_Visibility_Key","")
  114. ;[Instruction Cards Keys Change Mode 1]
  115. leftICMenuKey := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 1", "IC_Left_Menu_Key","")
  116. rightICMenuKey := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 1", "IC_Right_Menu_Key","")
  117. ;[Instruction Cards Keys Change Mode 2]
  118. changeActiveICKey := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 2", "IC_Change_Active_Instruction_Card_Key","")
  119. previousICKey := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 2", "IC_Previous_Instruction_Card_Key","")
  120. nextICKey := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 2", "IC_Next_Instruction_Card_Key","")
  121. ;[Instruction Cards Keys Change Mode 3]
  122. previousIC1Key := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 3", "IC_1_Previous_Key","")
  123. previousIC2Key := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 3", "IC_2_Previous_Key","")
  124. previousIC3Key := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 3", "IC_3_Previous_Key","")
  125. previousIC4Key := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 3", "IC_4_Previous_Key","")
  126. previousIC5Key := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 3", "IC_5_Previous_Key","")
  127. previousIC6Key := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 3", "IC_6_Previous_Key","")
  128. previousIC7Key := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 3", "IC_7_Previous_Key","")
  129. previousIC8Key := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 3", "IC_8_Previous_Key","")
  130. nextIC1Key := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 3", "IC_1_Next_Key","")
  131. nextIC2Key := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 3", "IC_2_Next_Key","")
  132. nextIC3Key := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 3", "IC_3_Next_Key","")
  133. nextIC4Key := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 3", "IC_4_Next_Key","")
  134. nextIC5Key := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 3", "IC_5_Next_Key","")
  135. nextIC6Key := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 3", "IC_6_Next_Key","")
  136. nextIC7Key := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 3", "IC_7_Next_Key","")
  137. nextIC8Key := RIniBezelLoadVar("bezelGlobalRini","bezelSystemRini", "BezelRomRini", "Instruction Cards Keys Change Mode 3", "IC_8_Next_Key","")
  138. }
  139. ; Saving values to ini file
  140. RIni_Write("bezelGlobalRini",Bezel_GlobalFile,"`r`n",1,1,1)
  141. IfNotExist, % A_ScriptDir . "\Settings\" . systemName
  142. FileCreateDir, % A_ScriptDir . "\Settings\" . systemName
  143. RIni_Write("bezelSystemRini",Bezel_SystemFile,"`r`n",1,1,1)
  144. ;logging all Bezel Options
  145. Log("Bezel variable values: " . BezelVarLog,5)
  146. ; -------------- End of Read ini options and define default values
  147. ;Loading Bezel parameters and images
  148. ;Checking if game is vertical oriented
  149. if (angle != 180 && ((angle=90) or (angle=270) or (angle))) {
  150. vertical := "true"
  151. Log("Bezel - Assuming that game has vertical orientation. Bezel will search on the extra folder Vertical in order to find assets.",4)
  152. } else
  153. Log("Bezel - Assuming that game has horizontal orientation.",4)
  154. ;Read Bezel Image
  155. if (bezelMode = "MultiScreens"){
  156. bezelNumberOfScreens := mode
  157. bezelPath := BezelFilesPath("Bezel [" . bezelNumberOfScreens . "S]",bezelFileExtensions)
  158. } else {
  159. bezelPath := BezelFilesPath("Bezel",bezelFileExtensions,true)
  160. }
  161. ;-----Loading Image Files into ARRAYs for bezel/background/overlay/instruction card
  162. If bezelPath
  163. {
  164. bezelCheckPosTimeout = 5000
  165. ;Setting bezel aleatory choosed file
  166. bezelImagesList := []
  167. if (bezelMode = "MultiScreens")
  168. {
  169. Loop, Parse, bezelFileExtensions,|
  170. Loop, % bezelPath . "\Bezel [" . bezelNumberOfScreens . "S]*." . A_LoopField
  171. bezelImagesList.Insert(A_LoopFileFullPath)
  172. } else {
  173. Loop, Parse, bezelFileExtensions,|
  174. Loop, % bezelPath . "\Bezel*." . A_LoopField
  175. if !RegExMatch(A_LoopFileName, "i)\[[0-9]+S\]")
  176. bezelImagesList.Insert(A_LoopFileFullPath)
  177. }
  178. if (bezelSaveSelected="true"){
  179. Random, initialRndmBezel, 1, % bezelImagesList.MaxIndex()
  180. bezelSelectedIndex := RIni_GetKeyValue("BezelRomRini","Bezel Change","Initial_Bezel_Index")
  181. RndmBezel := if (bezelSelectedIndex = -2) or (bezelSelectedIndex = -3) ? initialRndmBezel : bezelSelectedIndex
  182. } else
  183. Random, RndmBezel, 1, % bezelImagesList.MaxIndex()
  184. bezelImageFile := bezelImagesList[RndmBezel]
  185. Log("Bezel - Loading Bezel image: " . bezelImageFile,1)
  186. ;Setting background aleatory choosed file
  187. bezelBackgroundsList := []
  188. SplitPath, bezelImageFile, bezelImageFileName
  189. If FileExist(bezelPath . "\Background" . SubStr(bezelImageFileName,6)) {
  190. bezelBackgroundsList.Insert(bezelPath . "\Background" . SubStr(bezelImageFileName,6))
  191. bezelBackgroundfile := % bezelPath . "\Background" . SubStr(bezelImageFileName,6)
  192. Log("Bezel - Loading Background image with the same name of the bezel image: " . bezelBackgroundFile,1)
  193. } Else {
  194. bezelBackgroundPath := BezelFilesPath("Background",bezelFileExtensions,false,if (bezelUseBackgrounds="true") ? true : false)
  195. if (bezelBackgroundPath)
  196. { bezelBackgroundfileList := []
  197. Loop, Parse, bezelFileExtensions,|
  198. Loop, % bezelBackgroundPath . "\" . "Background*." . A_LoopField
  199. bezelBackgroundfileList.Insert(A_LoopFileFullPath)
  200. Random, RndBezelBackground, 1, % bezelBackgroundfileList.MaxIndex()
  201. bezelBackgroundfile := bezelBackgroundfileList[RndBezelBackground]
  202. Log("Bezel - Loading Background image: " . bezelBackgroundFile,1)
  203. }
  204. }
  205. ;Setting overlay aleatory choosed file (only searches overlays at the bezel.png folder)
  206. bezelOverlaysList := []
  207. If FileExist(bezelPath . "\Overlay" . SubStr(bezelImageFileName,6)) {
  208. bezelOverlaysList.Insert(bezelPath . "\Overlay" . SubStr(bezelImageFileName,6))
  209. bezelOverlayFile := % bezelPath . "\Overlay" . SubStr(bezelImageFileName,6)
  210. Log("Bezel - Loading Overlay image with the same name of the bezel image: " . bezelOverlayFile,1)
  211. } Else {
  212. if (bezelMode = "MultiScreens")
  213. {
  214. Loop, Parse, bezelFileExtensions,|
  215. Loop, % bezelPath . "\Overlay [" . bezelNumberOfScreens . "S]*." . A_LoopField
  216. bezelOverlaysList.Insert(A_LoopFileFullPath)
  217. } else {
  218. Loop, Parse, bezelFileExtensions,|
  219. Loop, % bezelPath . "\Overlay*." . A_LoopField
  220. if !RegExMatch(A_LoopFileName, "i)\[[0-9]+S\]")
  221. bezelOverlaysList.Insert(A_LoopFileFullPath)
  222. }
  223. Random, RndmBezelOverlay, 1, % bezelOverlaysList.MaxIndex()
  224. bezelOverlayFile := bezelOverlaysList[RndmBezelOverlay]
  225. If FileExist(bezelOverlayFile)
  226. Log("Bezel - Loading Overlay image: " . bezelOverlayFile,1)
  227. }
  228. }
  229. if (extraFullScreenBezel = "true"){
  230. Log("Adding extra fullscreen fake bezel image",1)
  231. if !bezelPath
  232. {
  233. bezelImagesList := []
  234. bezelPath := "fakeFullScreenBezel"
  235. RndmBezel := 1
  236. bezelImageFile := "fakeFullScreenBezel"
  237. }
  238. bezelImagesList.Insert("fakeFullScreenBezel")
  239. }
  240. If (bezelICEnabled = "true") {
  241. ;Loading bezel instruction card files
  242. bezelICPath := BezelFilesPath("Instruction Card",bezelFileExtensions)
  243. if bezelICPath
  244. {
  245. ;Acquiring screen info for dealing with rotated menu drawings
  246. Gdip_Alt_GetRotatedDimensions(A_ScreenWidth, A_ScreenHeight, screenRotationAngle, baseScreenWidth, baseScreenHeight)
  247. Gdip_GetRotatedTranslation(baseScreenWidth, baseScreenHeight, screenRotationAngle, xTranslation, yTranslation)
  248. xTranslation:=round(xTranslation), yTranslation:=round(yTranslation)
  249. Loop, 5 {
  250. CurrentGUI := a_index + 3
  251. Gdip_TranslateWorldTransform(Bezel_G%CurrentGUI%, xTranslation, yTranslation)
  252. Gdip_RotateWorldTransform(Bezel_G%CurrentGUI%, screenRotationAngle)
  253. }
  254. ;List of available IC images
  255. bezelICImageList := []
  256. Loop, Parse, bezelFileExtensions,|
  257. Loop, %bezelICPath%\Instruction Card*.%A_LoopField%
  258. bezelICImageList.Insert(A_LoopFileFullPath)
  259. Loop, % bezelICImageList.MaxIndex()
  260. ICLogFilesList := ICLogFilesList . "`r`n`t`t`t`t`t" . bezelICImageList[a_index]
  261. Log("Bezel - Instruction Card images found: " . ICLogFilesList,4)
  262. ;IC Position Array
  263. listofPosibleICPositions = topLeft,topRight,bottomLeft,bottomRight,topCenter,leftCenter,rightCenter,bottomCenter
  264. listofPossibleICScale = HalfScreenHeight|HalfScreenWidth|OneThirdScreenHeight|OneThirdScreenWidth|ScreenHeight|ScreenWidth
  265. StringSplit, positionICArray, positionIC, |,
  266. ;IC Array
  267. defaultICScaleFactor := ICScaleFactor
  268. bezelICArray := [] ;bezelICArray[screenICPositionIndex, ICimageIndex, Attribute]
  269. activeIC := 1
  270. selectedICimage := []
  271. prevselectedICimage := []
  272. selectedRightMenuItem := []
  273. selectedLeftMenuItem := []
  274. maxICimage := []
  275. currentImage := 0
  276. loop, 8
  277. {
  278. currentImage := 0
  279. currentICPositionIndex := a_index
  280. Loop, % bezelICImageList.MaxIndex()
  281. {
  282. currentBezelICFileName := bezelICImageList[a_index]
  283. SplitPath, currentBezelICFileName, , , , currentPureFileName
  284. postionNotDefined := false
  285. if currentPureFileName not contains %listofPosibleICPositions%
  286. postionNotDefined := true
  287. if ( ( (positionICArray%currentICPositionIndex%) and (InStr(currentPureFileName,positionICArray%currentICPositionIndex%)) ) or (postionNotDefined = true) )
  288. {
  289. currentImage++
  290. bezelICArray[currentICPositionIndex,currentImage,1] := currentBezelICFileName ; path to instruction card image
  291. bezelICArray[currentICPositionIndex,currentImage,2] := Gdip_CreateBitmapFromFile(currentBezelICFileName) ;bitmap pointer
  292. ;image size
  293. ICScaleFactor := defaultICScaleFactor
  294. Loop, parse, listofPossibleICScale,|,
  295. {
  296. if InStr(currentPureFileName,A_LoopField)
  297. {
  298. ICScaleFactor := A_LoopField
  299. Log("ICScaleFactor set by instruction card file name: " . ICScaleFactor,5)
  300. break
  301. }
  302. }
  303. if (ICScaleFactor="ScreenHeight")
  304. ICScaleFactor := baseScreenHeight/Gdip_GetImageHeight(bezelICArray[currentICPositionIndex,currentImage,2])
  305. else if (ICScaleFactor="ScreenWidth")
  306. ICScaleFactor := baseScreenWidth/Gdip_GetImageWidth(bezelICArray[currentICPositionIndex,currentImage,2])
  307. else if (ICScaleFactor="HalfScreenHeight")
  308. ICScaleFactor := baseScreenHeight/2/Gdip_GetImageHeight(bezelICArray[currentICPositionIndex,currentImage,2])
  309. else if (ICScaleFactor="HalfScreenWidth")
  310. ICScaleFactor := baseScreenWidth/2/Gdip_GetImageWidth(bezelICArray[currentICPositionIndex,currentImage,2])
  311. else if (ICScaleFactor="OneThirdScreenHeight")
  312. ICScaleFactor := baseScreenHeight/3/Gdip_GetImageHeight(bezelICArray[currentICPositionIndex,currentImage,2])
  313. else if (ICScaleFactor="OneThirdScreenWidth")
  314. ICScaleFactor := baseScreenWidth/3/Gdip_GetImageWidth(bezelICArray[currentICPositionIndex,currentImage,2])
  315. else
  316. ICScaleFactor := ICScaleFactor
  317. bezelICArray[currentICPositionIndex,currentImage,3] := round(Gdip_GetImageWidth(bezelICArray[currentICPositionIndex,currentImage,2])*ICScaleFactor) ; width of instruction card image
  318. bezelICArray[currentICPositionIndex,currentImage,4] := round(Gdip_GetImageHeight(bezelICArray[currentICPositionIndex,currentImage,2])*ICScaleFactor) ; height of instruction card image
  319. ;clean name
  320. StringTrimLeft, currentLabel, currentPureFileName,16
  321. replace := {"topLeft":"","topRight":"","bottomLeft":"","bottomRight":"","topCenter":"","leftCenter":"","rightCenter":"","bottomCenter":""} ; Removing place strings from name
  322. For what, with in replace
  323. if InStr(currentLabel,what)
  324. StringReplace, currentLabel, currentLabel, %what%, %with%, All
  325. replace := {"HalfScreenHeight":"","HalfScreenWidth":"","OneThirdScreenHeight":"","OneThirdScreenWidth":"","ScreenHeight":"","ScreenWidth":""} ; Removing scale factor from name
  326. For what, with in replace
  327. if InStr(currentLabel,what)
  328. StringReplace, currentLabel, currentLabel, %what%, %with%, All
  329. currentLabel:=RegExReplace(currentLabel,"\(.*\)","") ; remove anything inside parentesis
  330. currentLabel:=RegExReplace(currentLabel,"^\s*","") ; remove leading
  331. currentLabel:=RegExReplace(currentLabel,"\s*$","") ; remove trailing
  332. bezelICArray[currentICPositionIndex,currentImage,5] := currentLabel ;clean Name
  333. }
  334. }
  335. bezelICArray[currentICPositionIndex,0,5] := "None"
  336. selectedICimage[currentICPositionIndex] := 0
  337. prevselectedICimage[currentICPositionIndex] := 0
  338. selectedRightMenuItem[currentICPositionIndex] := 0
  339. selectedLeftMenuItem[currentICPositionIndex] := 0
  340. maxICimage[currentICPositionIndex] := currentImage
  341. currentImage := 0
  342. ICVisibilityOn := true
  343. }
  344. if enableICChangeSound
  345. {
  346. currentPath := BezelFilesPath("ICslideIn","mp3")
  347. if currentPath
  348. slideInICSound := currentPath . "\ICslideIn.mp3"
  349. currentPath := BezelFilesPath("ICslideOut","mp3")
  350. if currentPath
  351. slideOutICSound := currentPath . "\ICslideOut.mp3"
  352. currentPath := BezelFilesPath("ICFadeOut","mp3")
  353. if currentPath
  354. fadeOutICSound := currentPath . "\ICFadeOut.mp3"
  355. currentPath := BezelFilesPath("ICFadeIn","mp3")
  356. if currentPath
  357. fadeOutICSound := currentPath . "\ICFadeIn.mp3"
  358. currentPath := BezelFilesPath("ICChange","mp3")
  359. if currentPath
  360. changeICSound := currentPath . "\ICChange.mp3"
  361. }
  362. ;initializing IC menus
  363. StringReplace, leftMenuPositionsIC, leftMenuPositionsIC,|,`,, all
  364. StringReplace, rightMenuPositionsIC, rightMenuPositionsIC,|,`,, all
  365. loop, 8
  366. {
  367. if positionICArray%a_index% in %leftMenuPositionsIC%
  368. {
  369. if bezelICArray[a_index,1,1]
  370. {
  371. leftMenuActiveIC := a_index
  372. break
  373. }
  374. }
  375. }
  376. loop, 8
  377. {
  378. if positionICArray%a_index% in %rightMenuPositionsIC%
  379. {
  380. if bezelICArray[a_index,1,1]
  381. {
  382. rightMenuActiveIC := a_index
  383. break
  384. }
  385. }
  386. }
  387. ;loading menu parameters
  388. menuSelectedItem := []
  389. loop, 2
  390. {
  391. if (a_index=1)
  392. currentICMenu := "Left"
  393. else
  394. currentICMenu := "Right"
  395. bezelIC%currentICMenu%MenuList := []
  396. bezelICMenuPath := BezelFilesPath("IC Menu " . currentICMenu, bezelFileExtensions)
  397. If !bezelICMenuPath {
  398. Log("Bezel - No bezelICMenuPath found for " . currentICMenu,2)
  399. Continue
  400. }
  401. Loop, Parse, bezelFileExtensions,|
  402. Loop, % bezelICMenuPath . "\IC Menu " . currentICMenu . "*." . A_LoopField
  403. bezelIC%currentICMenu%MenuList.Insert(A_LoopFileFullPath)
  404. Random, RndmbezelICMenu, 1, % bezelIC%currentICMenu%MenuList.MaxIndex()
  405. ;File and bitmap pointers
  406. bezelIC%currentICMenu%MenuFile := bezelIC%currentICMenu%MenuList[RndmbezelICMenu]
  407. bezelIC%currentICMenu%MenuBitmap := Gdip_CreateBitmapFromFile(bezelIC%currentICMenu%MenuFile)
  408. Gdip_GetImageDimensions(bezelIC%currentICMenu%MenuBitmap, bezelIC%currentICMenu%MenuBitmapW, bezelIC%currentICMenu%MenuBitmapH)
  409. ;Ini appearance options
  410. currentICMenuFile := bezelIC%currentICMenu%MenuList[RndmbezelICMenu]
  411. SplitPath, currentICMenuFile,,,,ICMenuFileNameNoExt
  412. BezelICMenuIniFile := bezelICMenuPath . "\" . ICMenuFileNameNoExt . ".ini"
  413. Log("currentICMenu: " . currentICMenu . " || bezelFileExtensions: " . bezelFileExtensions . " || bezelICMenuPath: " . bezelICMenuPath . " || ICMenuFileNameNoExt: " . ICMenuFileNameNoExt . " || BezelICMenuIniFile: " . BezelICMenuIniFile,3)
  414. if (RIni_Read("bezelICRini" . currentICMenu,BezelICMenuIniFile) = -11)
  415. RIni_Create("bezelICRini" . currentICMenu)
  416. IC%currentICMenu%MenuListTextFont := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Font","Bebas Neue")
  417. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Font",IC%currentICMenu%MenuListTextFont) ; set value if ini not found
  418. IC%currentICMenu%MenuListTextAlignment := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Alignment","Center")
  419. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Alignment",IC%currentICMenu%MenuListTextAlignment) ; set value if ini not found
  420. IC%currentICMenu%MenuListTextSize := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Text_Size","50")
  421. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Text_Size",IC%currentICMenu%MenuListTextSize) ; set value if ini not found
  422. IC%currentICMenu%MenuListDisabledTextSize := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Disabled_Text_Size","30")
  423. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Disabled_Text_Size",IC%currentICMenu%MenuListDisabledTextSize) ; set value if ini not found
  424. IC%currentICMenu%MenuListTextColor := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Selected_Text_Color","FF000000")
  425. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Selected_Text_Color",IC%currentICMenu%MenuListTextColor) ; set value if ini not found
  426. IC%currentICMenu%MenuListDisabledTextColor := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Disabled_Text_Color","FFCCCCCC")
  427. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Disabled_Text_Color",IC%currentICMenu%MenuListDisabledTextColor) ; set value if ini not found
  428. IC%currentICMenu%MenuListCurrentTextColor := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Current_Text_Color","FFFF00FF")
  429. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Current_Text_Color",IC%currentICMenu%MenuListCurrentTextColor) ; set value if ini not found
  430. IC%currentICMenu%MenuListX := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Top_X_position","20")
  431. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Top_X_position",IC%currentICMenu%MenuListX) ; set value if ini not found
  432. IC%currentICMenu%MenuListY := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Top_Y_position","20")
  433. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Top_Y_position",IC%currentICMenu%MenuListY) ; set value if ini not found
  434. IC%currentICMenu%MenuListWidth := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Width","260")
  435. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Width",IC%currentICMenu%MenuListWidth) ; set value if ini not found
  436. IC%currentICMenu%MenuListHeight := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Height","360")
  437. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card List Settings","Height",IC%currentICMenu%MenuListHeight) ; set value if ini not found
  438. IC%currentICMenu%MenuPositionTextFont := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card Screen Position Text Settings","Font","Bebas Neue")
  439. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card Screen Position Text Settings","Font",IC%currentICMenu%MenuPositionTextFont) ; set value if ini not found
  440. IC%currentICMenu%MenuPositionTextAlignment := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card Screen Position Text Settings","Alignment","Right")
  441. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card Screen Position Text Settings","Alignment",IC%currentICMenu%MenuPositionTextAlignment) ; set value if ini not found
  442. IC%currentICMenu%MenuPositionTextSize := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card Screen Position Text Settings","Text_Size","20")
  443. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card Screen Position Text Settings","Text_Size",IC%currentICMenu%MenuPositionTextSize) ; set value if ini not found
  444. IC%currentICMenu%MenuPositionTextColor := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card Screen Position Text Settings","Text_Color","FFFFFFFF")
  445. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card Screen Position Text Settings","Text_Color",IC%currentICMenu%MenuPositionTextColor) ; set value if ini not found
  446. IC%currentICMenu%MenuPositionTextX := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card Screen Position Text Settings","Top_X_position",0)
  447. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card Screen Position Text Settings","Top_X_position",IC%currentICMenu%MenuPositionTextX) ; set value if ini not found
  448. IC%currentICMenu%MenuPositionTextY := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card Screen Position Text Settings","Top_Y_position",bezelIC%currentICMenu%MenuBitmapH-IC%currentICMenu%MenuPositionTextSize)
  449. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card Screen Position Text Settings","Top_Y_position",IC%currentICMenu%MenuPositionTextY) ; set value if ini not found
  450. IC%currentICMenu%MenuPositionTextWidth := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card Screen Position Text Settings","Width",bezelIC%currentICMenu%MenuBitmapW)
  451. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card Screen Position Text Settings","Width",IC%currentICMenu%MenuPositionTextWidth) ; set value if ini not found
  452. IC%currentICMenu%MenuPositionTextHeight := RIni_GetKeyValue("bezelICRini" . currentICMenu,"Instruction Card Screen Position Text Settings","Height",IC%currentICMenu%MenuPositionTextSize)
  453. RIni_SetKeyValue("bezelICRini" . currentICMenu,"Instruction Card Screen Position Text Settings","Height",IC%currentICMenu%MenuPositionTextHeight) ; set value if ini not found
  454. ; Saving values to ini file
  455. RIni_Write("bezelICRini" . currentICMenu,BezelICMenuIniFile,"`r`n",1,1,1)
  456. ;Resizing Menu items
  457. XBaseRes := 1920, YBaseRes := 1080
  458. if (((A_screenWidth < A_screenHeight) and ((screenRotationAngle=0) or (screenRotationAngle=180))) or ((A_screenWidth > A_screenHeight) and ((screenRotationAngle=90) or (screenRotationAngle=270))))
  459. XBaseRes := 1080, YBaseRes := 1920
  460. ICMenuScreenScallingFactor := baseScreenHeight/YBaseRes
  461. OptionScale(IC%currentICMenu%MenuListX, ICMenuScreenScallingFactor)
  462. OptionScale(IC%currentICMenu%MenuListY, ICMenuScreenScallingFactor)
  463. OptionScale(IC%currentICMenu%MenuListWidth, ICMenuScreenScallingFactor)
  464. OptionScale(IC%currentICMenu%MenuListHeight, ICMenuScreenScallingFactor)
  465. OptionScale(IC%currentICMenu%MenuListTextSize, ICMenuScreenScallingFactor)
  466. OptionScale(IC%currentICMenu%MenuListDisabledTextSize, ICMenuScreenScallingFactor)
  467. OptionScale(IC%currentICMenu%MenuPositionTextX, ICMenuScreenScallingFactor)
  468. OptionScale(IC%currentICMenu%MenuPositionTextY, ICMenuScreenScallingFactor)
  469. OptionScale(IC%currentICMenu%MenuPositionTextWidth, ICMenuScreenScallingFactor)
  470. OptionScale(IC%currentICMenu%MenuPositionTextHeight, ICMenuScreenScallingFactor)
  471. OptionScale(bezelIC%currentICMenu%MenuBitmapW, ICMenuScreenScallingFactor)
  472. OptionScale(bezelIC%currentICMenu%MenuBitmapH, ICMenuScreenScallingFactor)
  473. }
  474. pGraphUpd(Bezel_G4,baseScreenWidth,baseScreenHeight)
  475. pGraphUpd(Bezel_G5,bezelICLeftMenuBitmapW,bezelICLeftMenuBitmapH)
  476. pGraphUpd(Bezel_G6,ICLeftMenuListWidth,ICLeftMenuListTextSize)
  477. pGraphUpd(Bezel_G7,bezelICRightMenuBitmapW,bezelICRightMenuBitmapH)
  478. pGraphUpd(Bezel_G8,ICRightMenuListWidth,ICRightMenuListTextSize)
  479. }
  480. }
  481. If bezelPath
  482. {
  483. ;Setting ini file with bezel coordinates and reading its values
  484. if (bezelImageFile = "fakeFullScreenBezel"){
  485. bezelScreenX := 0
  486. bezelScreenY := 0
  487. bezelScreenWidth := A_ScreenWidth
  488. bezelScreenHeight := A_ScreenHeight
  489. origbezelImageW := A_ScreenWidth
  490. origbezelImageH := A_ScreenHeight
  491. bezelOrigIniScreenX1 := 0
  492. bezelOrigIniScreenY1 := 0
  493. bezelOrigIniScreenX2 := A_ScreenWidth
  494. bezelOrigIniScreenY2 := A_ScreenHeight
  495. } else {
  496. ReadBezelIniFile()
  497. bezelScreenX1 := bezelOrigIniScreenX1
  498. bezelScreenY1 := bezelOrigIniScreenY1
  499. bezelScreenX2 := bezelOrigIniScreenX2
  500. bezelScreenY2 := bezelOrigIniScreenY2
  501. ; creating bitmap pointers
  502. bezelBitmap := Gdip_CreateBitmapFromFile(bezelImageFile)
  503. Gdip_GetImageDimensions(bezelBitmap, origbezelImageW, origbezelImageH)
  504. bezelImageW := origbezelImageW
  505. bezelImageH := origbezelImageH
  506. ; calculating BezelCoordinates
  507. if (bezelMode = "Normal")
  508. BezelCoordinates("Normal")
  509. else if (bezelMode = "MultiScreens")
  510. BezelCoordinates("MultiScreens")
  511. }
  512. if bezelBackgroundFile
  513. bezelBackgroundBitmap := Gdip_CreateBitmapFromFile(bezelBackgroundFile)
  514. if bezelOverlayFile
  515. bezelOverlayBitmap := Gdip_CreateBitmapFromFile(bezelOverlayFile)
  516. ; Updating GUI 1 - Background - with image
  517. If bezelBackgroundFile
  518. {
  519. Gdip_DrawImage(Bezel_G1, bezelBackgroundBitmap, 0, 0,A_ScreenWidth+1,A_ScreenHeight+1)
  520. UpdateLayeredWindow(Bezel_hwnd1, Bezel_hdc1,0,0, A_ScreenWidth, A_ScreenHeight)
  521. Gui, Bezel_GUI1: Show, na
  522. Log("Bezel - Background Screen Position: BezelImage left=" . 0 . " top=" . 0 . " right=" . A_ScreenWidth . " bottom=" . A_ScreenHeight ,5)
  523. }
  524. }
  525. If (bezelPath) or (bezelICPath)
  526. {
  527. ;force windowed mode
  528. if !disableForceFullscreen
  529. Fullscreen := false
  530. }
  531. Log("BezelStart - Ended")
  532. }
  533. Return
  534. }
  535.  
  536. BezelDraw(){
  537. Global
  538. if (bezelEnabled = "true"){
  539. Log("BezelDraw - Started")
  540. ;------------ bezelMode bezelLayoutFile
  541. if bezelLayoutFile
  542. return
  543. If bezelPath
  544. {
  545. ;------------ bezelMode MultiScreens
  546. if (bezelMode = "MultiScreens") {
  547. ; Disable windows components
  548. ; Going to the label on the module to enable or disable emulator window manipulation codes to hide windows components, ...
  549. var := "BezelLabel"
  550. If IsLabel(var)
  551. gosub, %var%
  552. loop, %bezelNumberOfScreens%
  553. {
  554. currentScreen := a_index
  555. If !disableHideTitleBarScreen%currentScreen%
  556. WinSet, Style, -0xC00000, % "ahk_id " . Screen%currentScreen%ID
  557. If !disableHideToggleMenuScreen%currentScreen%
  558. ToggleMenu(Screen%a_index%ID)
  559. If !disableHideBorderScreen%currentScreen%
  560. WinSet, Style, -0xC40000, % "ahk_id " . Screen%currentScreen%ID
  561. ;Moving emulator Window to predefined bezel position
  562. screenPositionLogList := screenPositionLogList . "`r`n`t`t`t`t`tScreen " . currentScreen . ": left=" . bezelScreen%currentScreen%X1 . " top=" . bezelScreen%currentScreen%Y1 . " right=" . (bezelScreen%currentScreen%X1+bezelScreen%currentScreen%W) . " bottom=" . (bezelScreen%currentScreen%Y1+bezelScreen%currentScreen%H)
  563. If !disableWinMove
  564. WinMove, % "ahk_id " . Screen%currentScreen%ID, , % bezelScreen%currentScreen%X1, % bezelScreen%currentScreen%Y1, % bezelScreen%currentScreen%W, % bezelScreen%currentScreen%H
  565. }
  566. If !disableWinMove
  567. {
  568. ;check if windows moved
  569. sleep, 200
  570. loop, %bezelNumberOfScreens%
  571. {
  572. currentScreen := a_index
  573. X:="" , Y:="" , W:="" , H:=""
  574. timeout := A_TickCount
  575. loop
  576. {
  577. sleep, 50
  578. WinGetPos, X, Y, W, H, % "ahk_id " . Screen%currentScreen%ID
  579. if (X=bezelScreen%currentScreen%X1) and (Y=bezelScreen%currentScreen%Y1) and (W=bezelScreen%currentScreen%W) and (H=bezelScreen%currentScreen%H)
  580. break
  581. if(timeout < A_TickCount - bezelCheckPosTimeout) {
  582. Log("Screen " . currentScreen . " did not moved to correct bezel position. Timeout enabled.",5)
  583. break
  584. }
  585. sleep, 50
  586. WinMove, % "ahk_id " . Screen%currentScreen%ID, , % bezelScreen%currentScreen%X1, % bezelScreen%currentScreen%Y1, % bezelScreen%currentScreen%W, % bezelScreen%currentScreen%H
  587. }
  588. }
  589. }
  590. ;------------ bezelMode Normal
  591. } else if (bezelMode = "Normal") {
  592. WinGet emulatorID, ID, A
  593. ;BezelCoordinates("Normal")
  594. Log("Bezel - Bezel Screen Offset: left=" . bezelLeftOffset . " top=" . bezelTopOffset . " right=" . bezelRightOffset . " bottom=" . bezelBottomOffset ,1)
  595. ; Going to the label on the module to enable or disable emulator window manipulation codes to hide windows components, ...
  596. var := "BezelLabel"
  597. If IsLabel(var)
  598. gosub, %var%
  599. ; list of windows manipulation options that can be enabled/disabled on the BezelLabel (they are enable as default)
  600. If !disableHideTitleBar
  601. WinSet, Style, -0xC00000, A
  602. If !disableHideToggleMenu
  603. ToggleMenu(emulatorID)
  604. If !disableHideBorder
  605. WinSet, Style, -0xC40000, A
  606. ;Moving emulator Window to predefined bezel window
  607. If !disableWinMove
  608. {
  609. bezelScreenX := round(bezelScreenX) , bezelScreenY := round(bezelScreenY), bezelScreenWidth := round(bezelScreenWidth) , bezelScreenHeight := round(bezelScreenHeight)
  610. WinMove, ahk_id %emulatorID%, , %bezelScreenX%, %bezelScreenY%, %bezelScreenWidth%, %bezelScreenHeight%
  611. ; check if window moved
  612. X:="" , Y:="" , W:="" , H:=""
  613. timeout := A_TickCount
  614. sleep, 200
  615. loop
  616. {
  617. sleep, 50
  618. WinGetPos, X, Y, W, H, ahk_id %emulatorID%
  619. if (X=bezelScreenX) and (Y=bezelScreenY) and (W=bezelScreenWidth) and (H=bezelScreenHeight)
  620. break
  621. if(timeout < A_TickCount - bezelCheckPosTimeout)
  622. break
  623. sleep, 50
  624. WinMove, ahk_id %emulatorID%, , %bezelScreenX%, %bezelScreenY%, %bezelScreenWidth%, %bezelScreenHeight%
  625. }
  626. }
  627. ;------------ bezelMode fixResMode
  628. } else if (bezelMode = "fixResMode") { ; Define coordinates for emulators that does not support custom made resolutions.
  629. WinGet emulatorID, ID, A
  630. Log("Bezel - Emulator does not support custom made resolution. Game screen will be centered at the emulator resolution and the bezel png will be drawn around it. The bezel image will be croped if its resolution is bigger them the screen resolution.",1)
  631. X:="" , Y:="" , W:="" , H:=""
  632. timeout := A_TickCount
  633. loop
  634. {
  635. sleep, 50
  636. WinGetPos, bezelScreenX, bezelScreenY, bezelScreenWidth, bezelScreenHeight, A
  637. if bezelScreenX and bezelScreenY and bezelScreenWidth and bezelScreenHeight
  638. break
  639. if(timeout < A_TickCount - bezelCheckPosTimeout)
  640. break
  641. }
  642. Log("Bezel - Emulator Screen Position: left=" . bezelScreenX . " top=" . bezelScreenY . " width=" . bezelScreenWidth . " height=" . bezelScreenHeight ,5)
  643. BezelCoordinates("fixResMode")
  644. Log("Bezel - Screen Offset: left=" . bezelLeftOffset . " top=" . bezelTopOffset . " right=" . bezelRightOffset . " bottom=" . bezelBottomOffset ,1)
  645. ; Going to the label on the module to enable or disable emulator window manipulation codes to hide windows components, ...
  646. var := "BezelLabel"
  647. If IsLabel(var)
  648. gosub, %var%
  649. ; list of windows manipulation options that can be enabled/disabled on the BezelLabel (they are enable as default)
  650. If !disableHideTitleBar
  651. WinSet, Style, -0xC00000, A
  652. If !disableHideToggleMenu
  653. ToggleMenu(emulatorID)
  654. If !disableHideBorder
  655. WinSet, Style, -0xC40000, A
  656. ;Moving emulator Window to predefined bezel window
  657. If !disableWinMove
  658. {
  659. bezelScreenX := round(bezelScreenX) , bezelScreenY := round(bezelScreenY)
  660. WinMove, ahk_id %emulatorID%, , %bezelScreenX%, %bezelScreenY%
  661. ; check if window moved
  662. X:="" , Y:=""
  663. timeout := A_TickCount
  664. sleep, 200
  665. loop
  666. {
  667. sleep, 50
  668. WinGetPos, X, Y, , , ahk_id %emulatorID%
  669. if (X=bezelScreenX) and (Y=bezelScreenY)
  670. break
  671. if(timeout < A_TickCount - bezelCheckPosTimeout)
  672. break
  673. sleep, 50
  674. WinMove, ahk_id %emulatorID%, , %bezelScreenX%, %bezelScreenY%
  675. }
  676. }
  677. }
  678. ;Drawing Bezel GUI
  679. if !(bezelImageFile = "fakeFullScreenBezel"){
  680. Gdip_DrawImage(Bezel_G3, bezelBitmap, bezelImageX, bezelImageY,bezelImageW,bezelImageH)
  681. if !bezelLoaded
  682. UpdateLayeredWindow(Bezel_hwnd3, Bezel_hdc3,0,0, A_ScreenWidth, A_ScreenHeight)
  683. Log("Bezel - Bezel Image Screen Position: BezelImage left=" . bezelImageX . " top=" . bezelImageY . " right=" . (bezelImageX+bezelImageW) . " bottom=" . (bezelImageY+bezelImageH) ,5)
  684. if (bezelMode = "MultiScreens")
  685. Log("Bezel - Game Screen Position:" . screenPositionLogList, 4)
  686. else
  687. Log("Bezel - Game Screen Position: BezelImage left=" . bezelScreenX . " top=" . bezelScreenY . " right=" . (bezelScreenX+bezelScreenWidth) . " bottom=" . (bezelScreenY+bezelScreenHeight) ,5)
  688. }
  689. ;Drawing Overlay Image above screen
  690. If bezelOverlayFile
  691. {
  692. if (bezelMode = "MultiScreens") {
  693. loop, %bezelNumberOfScreens%
  694. Gdip_DrawImage(Bezel_G2, bezelOverlayBitmap, bezelScreen%A_Index%X1, bezelScreen%A_Index%Y1,bezelScreen%A_Index%W,bezelScreen%A_Index%H)
  695. if !bezelLoaded
  696. UpdateLayeredWindow(Bezel_hwnd2, Bezel_hdc2,0,0, A_ScreenWidth, A_ScreenHeight)
  697. } else {
  698. Gdip_DrawImage(Bezel_G2, bezelOverlayBitmap, 0, 0,bezelScreenWidth,bezelScreenHeight)
  699. if !bezelLoaded
  700. UpdateLayeredWindow(Bezel_hwnd2, Bezel_hdc2,bezelScreenX,bezelScreenY, bezelScreenWidth, bezelScreenHeight)
  701. Log("Bezel - Overlay Screen Position: BezelImage left=" . bezelScreenX . " top=" . bezelScreenY . " right=" . (bezelScreenX+bezelScreenWidth) . " bottom=" . (bezelScreenY+bezelScreenHeight) ,5)
  702. }
  703. }
  704. if !bezelLoaded
  705. {
  706. ;Initializing Instruction Cards Keys
  707. gosub, EnableBezelKeys
  708. ;Initializing bezel change
  709. if (bezelImagesList.MaxIndex() > 1) {
  710. if nextBezelKey
  711. {
  712. nextBezelKey := xHotKeyVarEdit(nextBezelKey,"nextBezelKey","~","Add")
  713. XHotKeywrapper(nextBezelKey,"nextBezel")
  714. }
  715. if previousBezelKey
  716. {
  717. previousBezelKey := xHotKeyVarEdit(previousBezelKey,"previousBezelKey","~","Add")
  718. XHotKeywrapper(previousBezelKey,"previousBezel")
  719. }
  720. }
  721. ;Creating bezel background timer
  722. if (bezelBackgroundsList.MaxIndex() > 1)
  723. if bezelBackgroundChangeDur
  724. settimer, BezelBackgroundTimer, %bezelBackgroundChangeDur%
  725. }
  726. }
  727. if bezelICPath
  728. {
  729. if ((ICSaveSelected="true") and (FileExist(Bezel_RomFile))) {
  730. loop, 8
  731. if maxICimage[a_index]
  732. {
  733. selectedIndex := RIni_GetKeyValue("BezelRomRini","Instruction Cards","Initial_Card_" . a_index . "_Index")
  734. selectedICimage[a_index] := if (selectedIndex = -2) or (selectedIndex = -3) ? 1 : selectedIndex
  735. }
  736. }
  737. if (displayICOnStartup = "true") {
  738. loop, 8
  739. {
  740. if !(selectedICimage[a_index])
  741. selectedICimage[a_index] := 1
  742. if maxICimage[a_index]
  743. {
  744. DrawIC()
  745. }
  746. }
  747. } else if (displayICOnStartup = "Random") {
  748. gosub, randomICChange
  749. }
  750. if %ICRandomSlideShowTimer%
  751. SetTimer, randomICChange, %ICRandomSlideShowTimer%
  752. }
  753. bezelLoaded := true
  754. Log("BezelDraw - Ended")
  755. }
  756. Return
  757. }
  758.  
  759. BezelExit(){
  760. Global
  761. if (bezelEnabled = "true"){
  762. Log("BezelExit - Started")
  763. ;Deleting pointers and destroying GUis
  764. loop, 8 {
  765. SelectObject(Bezel_hdc%A_Index%, Bezel_obm%A_Index%)
  766. DeleteObject(Bezel_hbm%A_Index%)
  767. DeleteDC(Bezel_hdc%A_Index%)
  768. Gdip_DeleteGraphics(Bezel_G%A_Index%)
  769. Gui, Bezel_GUI%A_Index%: Destroy
  770. }
  771. If bezelPath
  772. {
  773. log("Bezel - Removing bezel image components to exit HyperLaunch.",1)
  774. if bezelBitmap
  775. Gdip_DisposeImage(bezelBitmap)
  776. if bezelBackgroundFile
  777. Gdip_DisposeImage(bezelBackgroundBitmap)
  778. if bezelOverlayFile
  779. Gdip_DisposeImage(bezelOverlayBitmap)
  780. if BezelBackgroundChangeLoaded
  781. Gdip_DisposeImage(preRndmBezelBackground)
  782. if bezelICPath
  783. {
  784. loop, 8
  785. {
  786. currentICPositionIndex := a_index
  787. loop, %numberofICImages%
  788. {
  789. if bezelICArray[currentICPositionIndex,a_index,2]
  790. Gdip_DisposeImage(bezelICArray[currentICPositionIndex,a_index,2])
  791. }
  792. }
  793. }
  794. if (bezelSaveSelected="true") {
  795. RIni_SetKeyValue("BezelRomRini","Bezel Change","Initial_Bezel_Index",RndmBezel)
  796. updateBezel_RomFile := true
  797. }
  798. }
  799. if bezelICPath
  800. {
  801. if (ICSaveSelected="true"){
  802. Loop, 8
  803. RIni_SetKeyValue("BezelRomRini","Instruction Cards","Initial_Card_" . a_index . "_Index",selectedICimage[a_index])
  804. updateBezel_RomFile := true
  805. }
  806. }
  807. if updateBezel_RomFile
  808. {
  809. SplitPath, Bezel_RomFile, , Bezel_RomFilePath
  810. FileCreateDir, % Bezel_RomFilePath
  811. RIni_Write("BezelRomRini",Bezel_RomFile,"`r`n",1,1,1)
  812. }
  813. Log("BezelExit - Ended")
  814. }
  815. Return
  816. }
  817.  
  818.  
  819. ReadBezelIniFile(){
  820. Global
  821. StringTrimRight, bezelIniFile, bezelImageFile, 4
  822. bezelIniFile := bezelIniFile . ".ini"
  823. If !FileExist(bezelIniFile)
  824. Log("Bezel - Bezel Ini file not found. Creating the file " . bezelIniFile . " with full screen coordinates. You should edit the ini file to enter the coordinates in pixels of the screen emulator location on the bezel image.",2)
  825. bezelOrigIniScreenX1 := IniReadCheck(bezelIniFile, "General", "Bezel Screen Top Left X Coordinate", 0)
  826. bezelOrigIniScreenY1 := IniReadCheck(bezelIniFile, "General", "Bezel Screen Top Left Y Coordinate", 0)
  827. bezelOrigIniScreenX2 := IniReadCheck(bezelIniFile, "General", "Bezel Screen Bottom Right X Coordinate", A_ScreenWidth)
  828. bezelOrigIniScreenY2 := IniReadCheck(bezelIniFile, "General", "Bezel Screen Bottom Right Y Coordinate", A_ScreenHeight)
  829. Log("Bezel - Bezel ini file found. Defined screen positions: X1=" . bezelOrigIniScreenX1 . " Y1=" . bezelOrigIniScreenY1 . " X2=" . bezelOrigIniScreenX2 . " Y2=" . bezelOrigIniScreenY2 ,5)
  830. ;reading additional screens info
  831. if (bezelMode = "MultiScreens") {
  832. loop, % bezelNumberOfScreens-1
  833. {
  834. currentScreen := a_index+1
  835. bezelScreen%currentScreen%X1 := IniReadCheck(bezelIniFile, "General", "Bezel Screen " . currentScreen . " Top Left X Coordinate", 0)
  836. bezelScreen%currentScreen%Y1 := IniReadCheck(bezelIniFile, "General", "Bezel Screen " . currentScreen . " Top Left Y Coordinate", 0)
  837. bezelScreen%currentScreen%X2 := IniReadCheck(bezelIniFile, "General", "Bezel Screen " . currentScreen . " Bottom Right X Coordinate", 0)
  838. bezelScreen%currentScreen%Y2 := IniReadCheck(bezelIniFile, "General", "Bezel Screen " . currentScreen . " Bottom Right Y Coordinate", 0)
  839. }
  840. }
  841. return
  842. }
  843.  
  844. BezelCoordinates(CoordinatesMode){
  845. Global
  846. if (CoordinatesMode = "Normal"){
  847. ; Resizing bezel transparent area to the screen resolution (image is stretched to Center screen, keeping aspect)
  848. widthMaxPerc := ( A_ScreenWidth / bezelImageW ) ; get the percentage needed to maximise the image so the higher dimension reaches the screen's edge
  849. heightMaxPerc := ( A_ScreenHeight / bezelImageH )
  850. scaleFactor := If (widthMaxPerc < heightMaxPerc) ? widthMaxPerc : heightMaxPerc
  851. bezelImageW := Round(bezelImageW * scaleFactor)
  852. bezelImageH := Round(bezelImageH * scaleFactor)
  853. bezelImageX := Round( ( A_ScreenWidth - bezelImageW ) // 2 )
  854. bezelImageY := Round( ( A_ScreenHeight - bezelImageH ) // 2 )
  855. ; Defining emulator position
  856. bezelScreenX := Round ( bezelImageX + (bezelScreenX1 * scaleFactor) )
  857. bezelScreenY := Round ( bezelImageY + (bezelScreenY1 * scaleFactor) )
  858. bezelScreenWidth := Round( (bezelScreenX2-bezelScreenX1)* scaleFactor )
  859. bezelScreenHeight := Round( (bezelScreenY2-bezelScreenY1)* scaleFactor )
  860. ; Applying offsets to correctly place the emulator if the emulator has extra window components
  861. bezelScreenX := if bezelLeftOffset ? bezelScreenX - bezelLeftOffset : bezelScreenX
  862. bezelScreenY := if bezelTopOffset ? bezelScreenY - bezelTopOffset : bezelScreenY
  863. bezelScreenWidth := if bezelRightOffset ? ( if bezelLeftOffset ? bezelScreenWidth + bezelRightOffset + bezelLeftOffset : bezelScreenWidth + bezelRightOffset ) : ( if bezelLeftOffset ? bezelScreenWidth + bezelLeftOffset : bezelScreenWidth )
  864. bezelScreenHeight := if bezelTopOffset ? ( if bezelBottomOffset ? bezelScreenHeight + bezelTopOffset + bezelBottomOffset : bezelScreenHeight + bezelTopOffset ) : ( if bezelBottomOffset ? bezelScreenHeight + bezelBottomOffset : bezelScreenHeight )
  865. bezelScreenX := round(bezelScreenX) , bezelScreenY := round(bezelScreenY), bezelScreenWidth := round(bezelScreenWidth) , bezelScreenHeight := round(bezelScreenHeight)
  866. } else if (CoordinatesMode = "MultiScreens") {
  867. ; Resizing bezel transparent area to the screen resolution (image is stretched to Center screen, keeping aspect)
  868. widthMaxPerc := ( A_ScreenWidth / bezelImageW ) ; get the percentage needed to maximise the image so the higher dimension reaches the screen's edge
  869. heightMaxPerc := ( A_ScreenHeight / bezelImageH )
  870. scaleFactor := If (widthMaxPerc < heightMaxPerc) ? widthMaxPerc : heightMaxPerc
  871. bezelImageW := Round(bezelImageW * scaleFactor)
  872. bezelImageH := Round(bezelImageH * scaleFactor)
  873. bezelImageX := Round( ( A_ScreenWidth - bezelImageW ) // 2 )
  874. bezelImageY := Round( ( A_ScreenHeight - bezelImageH ) // 2 )
  875. ; Defining emulator position
  876. bezelScreen1X1 := bezelScreenX1
  877. bezelScreen1Y1 := bezelScreenY1
  878. bezelScreen1X2 := bezelScreenX2
  879. bezelScreen1Y2 := bezelScreenY2
  880. loop, %bezelNumberOfScreens%
  881. {
  882. bezelScreen%a_index%W := Round((bezelScreen%a_index%X2-bezelScreen%a_index%X1)*scaleFactor)
  883. bezelScreen%a_index%H := Round((bezelScreen%a_index%Y2-bezelScreen%a_index%Y1)*scaleFactor)
  884. bezelScreen%a_index%X1 := Round(bezelImageX+bezelScreen%a_index%X1*scaleFactor)
  885. bezelScreen%a_index%Y1 := Round(bezelImageY+bezelScreen%a_index%Y1*scaleFactor)
  886. ; Applying offsets to correctly place the emulator if the emulator has extra window components
  887. bezelScreen%a_index%X1 := if bezelLeftOffsetScreen%a_index% ? bezelScreen%a_index%X1 - bezelLeftOffsetScreen%a_index% : bezelScreen%a_index%X1
  888. bezelScreen%a_index%Y1 := if bezelTopOffsetScreen%a_index% ? bezelScreen%a_index%Y1 - bezelTopOffsetScreen%a_index% : bezelScreen%a_index%Y1
  889. bezelScreen%a_index%W := if bezelRightOffsetScreen%a_index% ? ( if bezelLeftOffsetScreen%a_index% ? bezelScreen%a_index%W + bezelRightOffsetScreen%a_index% + bezelLeftOffsetScreen%a_index% : bezelScreen%a_index%W + bezelRightOffsetScreen%a_index% ) : ( if bezelLeftOffsetScreen%a_index% ? bezelScreen%a_index%W + bezelLeftOffsetScreen%a_index% : bezelScreen%a_index%W )
  890. bezelScreen%a_index%H := if bezelTopOffsetScreen%a_index% ? ( if bezelBottomOffsetScreen%a_index% ? bezelScreen%a_index%H + bezelTopOffsetScreen%a_index% + bezelBottomOffsetScreen%a_index% : bezelScreen%a_index%H + bezelTopOffsetScreen%a_index% ) : ( if bezelBottomOffsetScreen%a_index% ? bezelScreen%a_index%H + bezelBottomOffsetScreen%a_index% : bezelScreen%a_index%H )
  891. bezelScreen%a_index%X1 := round(bezelScreen%a_index%X1) , bezelScreen%a_index%Y1 := round(bezelScreen%a_index%Y1), bezelScreen%a_index%W := round(bezelScreen%a_index%W) , bezelScreen%a_index%H := round(bezelScreen%a_index%H)
  892. log("Emulator Screen " . a_index . " position on bezel: X=" . bezelScreen%a_index%X1 . " Y=" . bezelScreen%a_index%Y1 . " W=" . bezelScreen%a_index%W . " H=" . bezelScreen%a_index%H ,5)
  893. }
  894. } else if (CoordinatesMode = "fixResMode") {
  895. bezelScreenWidth := if bezelRightOffset ? ( if bezelLeftOffset ? bezelScreenWidth - bezelRightOffset - bezelLeftOffset : bezelScreenWidth - bezelRightOffset ) : ( if bezelLeftOffset ? bezelScreenWidth - bezelLeftOffset : bezelScreenWidth )
  896. bezelScreenHeight := if bezelTopOffset ? ( if bezelBottomOffset ? bezelScreenHeight - bezelTopOffset - bezelBottomOffset : bezelScreenHeight - bezelTopOffset ) : ( if bezelBottomOffset ? bezelScreenHeight - bezelBottomOffset : bezelScreenHeight )
  897. bezelScreenX:= Round((A_ScreenWidth-bezelScreenWidth)/2)
  898. bezelScreenY:= Round((A_ScreenHeight-bezelScreenHeight)/2)
  899. bezelScreenX := if bezelLeftOffset ? bezelScreenX - bezelLeftOffset : bezelScreenX
  900. bezelScreenY := if bezelTopOffset ? bezelScreenY - bezelTopOffset : bezelScreenY
  901. xScaleFactor := (bezelScreenWidth)/(bezelScreenX2-bezelScreenX1)
  902. yScaleFactor := (bezelScreenHeight)/(bezelScreenY2-bezelScreenY1)
  903. bezelImageW := Round(bezelImageW * xScaleFactor)
  904. bezelImageH := Round(bezelImageH * yScaleFactor)
  905. bezelImageX := Round( (A_ScreenWidth-(bezelScreenX2-bezelScreenX1)*xScaleFactor)//2-bezelScreenX1*xScaleFactor )
  906. bezelImageY := Round( (A_ScreenHeight-(bezelScreenY2-bezelScreenY1)*yScaleFactor)//2-bezelScreenY1*yScaleFactor )
  907. }
  908. Return
  909. }
  910.  
  911. BezelFilesPath(filename,fileextension,excludeScreens=false,useBkgdPath=false)
  912. {
  913. Global HLMediaPath, systemName, dbName, vertical
  914. Global dbCloneOf
  915. bezelpath1 := HLMediaPath . "\Bezels\" . systemName . "\" . dbName
  916. If dbCloneOf
  917. bezelpath2 := HLMediaPath . "\Bezels\" . systemName . "\" . dbCloneOf
  918. If (useBkgdPath){
  919. bezelpath3 := HLMediaPath . "\Backgrounds\" . systemName . "\" . dbName
  920. If dbCloneOf
  921. bezelpath4 := HLMediaPath . "\Backgrounds\" . systemName . "\" . dbCloneOf
  922. }
  923. If (vertical = "true")
  924. bezelpath5 := HLMediaPath . "\Bezels\" . systemName . "\_Default\Vertical"
  925. Else
  926. bezelpath6 := HLMediaPath . "\Bezels\" . systemName . "\_Default\Horizontal"
  927. bezelpath7 := HLMediaPath . "\Bezels\" . systemName . "\_Default"
  928. If (useBkgdPath){
  929. If (vertical = "true")
  930. bezelpath8 := HLMediaPath . "\Backgrounds\" . systemName . "\_Default\Vertical"
  931. else
  932. bezelpath9 := HLMediaPath . "\Backgrounds\" . systemName . "\_Default\Horizontal"
  933. bezelpath10 := HLMediaPath . "\Backgrounds\" . systemName . "\_Default"
  934. }
  935. If (vertical = "true")
  936. bezelpath11 := HLMediaPath . "\Bezels\_Default\Vertical"
  937. Else
  938. bezelpath12 := HLMediaPath . "\Bezels\_Default\Horizontal"
  939. bezelpath13 := HLMediaPath . "\Bezels\_Default"
  940. If (useBkgdPath){
  941. If (vertical = "true")
  942. bezelpath14 := HLMediaPath . "\Backgrounds\_Default\Vertical"
  943. else
  944. bezelpath15 := HLMediaPath . "\Backgrounds\_Default\Horizontal"
  945. bezelpath16 := HLMediaPath . "\Backgrounds\_Default"
  946. }
  947. Loop, 16 {
  948. If bezelpath%a_index%
  949. {
  950. Log("Bezel - Looking for " . filename . " in: " . bezelpath%A_Index%,4)
  951. currentbezelpathNumber := a_index
  952. Loop, Parse, fileextension,|
  953. {
  954. Loop % bezelpath%currentbezelpathNumber% . "\" . filename . "*." . A_LoopField
  955. {
  956. If excludeScreens
  957. {
  958. If !RegExMatch(A_LoopFileName, "i)\[[0-9]+S\]")
  959. {
  960. Log("Bezel - Found " . filename . " art in folder: " . bezelpath%currentbezelpathNumber%,4)
  961. bezelPathFound := bezelpath%currentbezelpathNumber%
  962. break
  963. }
  964. } Else {
  965. Log("Bezel - Found " . filename . " art in folder: " . bezelpath%currentbezelpathNumber%,4)
  966. bezelPathFound := bezelpath%currentbezelpathNumber%
  967. break
  968. }
  969. }
  970. }
  971. If bezelPathFound
  972. break
  973. }
  974. }
  975. If !bezelPathFound
  976. log("Bezel - Bezels are enabled, however none of the " . filename . " files, with extensions " . fileextension . " exist on the bezel folders.",2)
  977. Return bezelPathFound
  978. }
  979.  
  980.  
  981. ;Function to load ini values
  982. RIniBezelLoadVar(gRIniVar,sRIniVar,rRIniVar,gsec,gkey,gdefaultvalue="",ssec=0,skey=0,sdefaultvalue="use_global",rdefaultvalue="use_global") {
  983. Global
  984. if not ssec
  985. ssec := gsec
  986. if not skey
  987. skey := gkey
  988. X1 := RIni_GetKeyValue(gRIniVar,gsec,gkey)
  989. X1 := If (X1 = -2) or (X1 = -3) ? gdefaultvalue : X1
  990. X2 := RIni_GetKeyValue(sRIniVar,ssec,skey)
  991. X2 := If (X2 = -2) or (X2 = -3) ? sdefaultvalue : X2
  992. X3 := RIni_GetKeyValue(rRIniVar,ssec,skey)
  993. X3 := If (X3 = -2) or (X3 = -3) ? rdefaultvalue : X3
  994. X4 := (If (X3 = "use_global") ? (If (X2 = "use_global") ? (X1) : (X2)) : (X3))
  995. RIni_SetKeyValue(gRIniVar,gsec,gkey,X1)
  996. RIni_SetKeyValue(sRIniVar,ssec,skey,X2)
  997. RIni_SetKeyValue(rRIniVar,ssec,skey,X3)
  998. BezelVarLog .= "`r`n`t`t`t`t`t" . "[" . gsec . "] " . gkey . " = " . X4
  999. Return X4
  1000. }
  1001.  
  1002.  
  1003. ; Bezel Change Code
  1004. BezelBackgroundTimer:
  1005. BezelBackgroundChangeLoaded := true
  1006. preRndmBezelBackground := RndmBezelBackground
  1007. RndmBezelBackground := RndmBezelBackground + 1
  1008. if (RndmBezelBackground > bezelBackgroundsList.MaxIndex())
  1009. RndmBezelBackground := 1
  1010. prebezelBackgroundfile := bezelBackgroundsList[preRndmBezelBackground]
  1011. bezelBackgroundfile := bezelBackgroundsList[RndmBezelBackground]
  1012. prebezelBackgroundBitmap := Gdip_CreateBitmapFromFile(prebezelBackgroundfile)
  1013. bezelBackgroundBitmap := Gdip_CreateBitmapFromFile(bezelBackgroundFile)
  1014. if (bezelBackgroundTransition="fade"){
  1015. ;fade in
  1016. startTime := A_TickCount
  1017. Loop {
  1018. Gdip_GraphicsClear(Bezel_G1)
  1019. t := if ((TimeElapsed := A_TickCount-startTime) < bezelBackgroundTransitionDur) ? ((timeElapsed/bezelBackgroundTransitionDur)) : 1
  1020. Gdip_DrawImage(Bezel_G1, prebezelBackgroundBitmap, 0, 0,A_ScreenWidth,A_ScreenHeight)
  1021. Gdip_DrawImage(Bezel_G1, bezelBackgroundBitmap, 0, 0,A_ScreenWidth,A_ScreenHeight,"","","","",t)
  1022. UpdateLayeredWindow(Bezel_hwnd1, Bezel_hdc1,0,0, A_ScreenWidth, A_ScreenHeight)
  1023. If (t >= 1)
  1024. Break
  1025. }
  1026. } else {
  1027. Gdip_GraphicsClear(Bezel_G1)
  1028. Gdip_DrawImage(Bezel_G1, bezelBackgroundBitmap, 0, 0,A_ScreenWidth,A_ScreenHeight)
  1029. UpdateLayeredWindow(Bezel_hwnd1, Bezel_hdc1,0,0, A_ScreenWidth, A_ScreenHeight)
  1030. }
  1031. return
  1032.  
  1033.  
  1034. NextBezel:
  1035. PreviousBezel:
  1036. if bezelPath
  1037. {
  1038. if bezelLayoutFile
  1039. return
  1040. if (A_ThisLabel="NextBezel") {
  1041. RndmBezel := RndmBezel + 1
  1042. if (RndmBezel > bezelImagesList.MaxIndex()){
  1043. RndmBezel := 1
  1044. }
  1045. } else if (A_ThisLabel="PreviousBezel") {
  1046. RndmBezel := RndmBezel - 1
  1047. if (RndmBezel < 1){
  1048. RndmBezel := bezelImagesList.MaxIndex()
  1049. }
  1050. }
  1051. ;fade out
  1052. startTime := A_TickCount
  1053. Loop {
  1054. t := if ((TimeElapsed := A_TickCount-startTime) < bezelChangeDur) ? (255*(1-(timeElapsed/bezelChangeDur))) : 0
  1055. If bezelOverlayFile
  1056. {
  1057. if (bezelMode = "MultiScreens") {
  1058. Gdip_GraphicsClear(Bezel_G2)
  1059. loop, %bezelNumberOfScreens%
  1060. Gdip_DrawImage(Bezel_G2, bezelOverlayBitmap, bezelScreen%A_Index%X1, bezelScreen%A_Index%Y1,bezelScreen%A_Index%W,bezelScreen%A_Index%H)
  1061. UpdateLayeredWindow(Bezel_hwnd2, Bezel_hdc2,0,0, A_ScreenWidth, A_ScreenHeight,t)
  1062. } else {
  1063. Gdip_GraphicsClear(Bezel_G2)
  1064. Gdip_DrawImage(Bezel_G2, bezelOverlayBitmap, 0, 0,bezelScreenWidth,bezelScreenHeight)
  1065. UpdateLayeredWindow(Bezel_hwnd2, Bezel_hdc2,bezelScreenX,bezelScreenY, bezelScreenWidth, bezelScreenHeight,t)
  1066. }
  1067. }
  1068. Gdip_GraphicsClear(Bezel_G3)
  1069. if (bezelImageFile = "fakeFullScreenBezel"){
  1070. Gdip_DrawImage(Bezel_G3, bezelBitmap, bezelImageX, bezelImageY,bezelImageW,bezelImageH)
  1071. UpdateLayeredWindow(Bezel_hwnd3, Bezel_hdc3,0,0, A_ScreenWidth, A_ScreenHeight,t)
  1072. }
  1073. WinSet, Transparent, %t%, ahk_id %emulatorID%
  1074. If (t <= 0)
  1075. Break
  1076. }
  1077. prevbezelImageW := origbezelImageW
  1078. prevbezelImageH := origbezelImageH
  1079. prevbezelOrigIniScreenX1 := bezelOrigIniScreenX1
  1080. prevbezelOrigIniScreenY1 := bezelOrigIniScreenY1
  1081. prevbezelOrigIniScreenX2 := bezelOrigIniScreenX2
  1082. prevbezelOrigIniScreenY2 := bezelOrigIniScreenY2
  1083. bezelImageFile := bezelImagesList[RndmBezel]
  1084. bezelBitmap := Gdip_CreateBitmapFromFile(bezelImageFile)
  1085. Gdip_GetImageDimensions(bezelBitmap, origbezelImageW, origbezelImageH)
  1086. ReadBezelIniFile()
  1087. WinActivate, ahk_id %emulatorID%
  1088. Gdip_GraphicsClear(Bezel_G2)
  1089. Gdip_GraphicsClear(Bezel_G3)
  1090. if ((prevbezelImageW=origbezelImageW) and (prevbezelImageH = origbezelImageH) and (prevbezelOrigIniScreenX1 = bezelOrigIniScreenX1) and (prevbezelOrigIniScreenY1 = bezelOrigIniScreenY1) and (prevbezelOrigIniScreenX2 = bezelOrigIniScreenX2) and (prevbezelOrigIniScreenY2 = bezelOrigIniScreenY2) ) { ;just replace bezel image
  1091. if !(bezelImageFile = "fakeFullScreenBezel")
  1092. Gdip_DrawImage(Bezel_G3, bezelBitmap, bezelImageX, bezelImageY,bezelImageW,bezelImageH)
  1093. ;Drawing Overlay Image above screen
  1094. If bezelOverlayFile
  1095. if (bezelMode = "MultiScreens")
  1096. Gdip_DrawImage(Bezel_G2, bezelOverlayBitmap, bezelScreen%A_Index%X1, bezelScreen%A_Index%Y1,bezelScreen%A_Index%W,bezelScreen%A_Index%H)
  1097. else
  1098. Gdip_DrawImage(Bezel_G2, bezelOverlayBitmap, 0, 0,bezelScreenWidth,bezelScreenHeight)
  1099. } else { ; recalculate everything bezel related
  1100. bezelImageW := origbezelImageW
  1101. bezelImageH := origbezelImageH
  1102. bezelScreenX1 := bezelOrigIniScreenX1
  1103. bezelScreenY1 := bezelOrigIniScreenY1
  1104. bezelScreenX2 := bezelOrigIniScreenX2
  1105. bezelScreenY2 := bezelOrigIniScreenY2
  1106. ToggleMenu(emulatorID)
  1107. if (bezelMode = "Normal")
  1108. BezelCoordinates("Normal")
  1109. BezelDraw()
  1110. }
  1111. ;fade in
  1112. startTime := A_TickCount
  1113. Loop {
  1114. t := if ((TimeElapsed := A_TickCount-startTime) < bezelChangeDur) ? (255*(timeElapsed/bezelChangeDur)) : 255
  1115. If bezelOverlayFile
  1116. {
  1117. if (bezelMode = "MultiScreens") {
  1118. Gdip_GraphicsClear(Bezel_G2)
  1119. loop, %bezelNumberOfScreens%
  1120. Gdip_DrawImage(Bezel_G2, bezelOverlayBitmap, bezelScreen%A_Index%X1, bezelScreen%A_Index%Y1,bezelScreen%A_Index%W,bezelScreen%A_Index%H)
  1121. UpdateLayeredWindow(Bezel_hwnd2, Bezel_hdc2,0,0, A_ScreenWidth, A_ScreenHeight,t)
  1122. } else {
  1123. Gdip_GraphicsClear(Bezel_G2)
  1124. Gdip_DrawImage(Bezel_G2, bezelOverlayBitmap, 0, 0,bezelScreenWidth,bezelScreenHeight)
  1125. UpdateLayeredWindow(Bezel_hwnd2, Bezel_hdc2,bezelScreenX,bezelScreenY, bezelScreenWidth, bezelScreenHeight,t)
  1126. }
  1127. }
  1128. Gdip_GraphicsClear(Bezel_G3)
  1129. if !(bezelImageFile = "fakeFullScreenBezel")
  1130. Gdip_DrawImage(Bezel_G3, bezelBitmap, bezelImageX, bezelImageY,bezelImageW,bezelImageH)
  1131. UpdateLayeredWindow(Bezel_hwnd3, Bezel_hdc3,0,0, A_ScreenWidth, A_ScreenHeight,t)
  1132. WinSet, Transparent, %t%, ahk_id %emulatorID%
  1133. If (t >= 255)
  1134. Break
  1135. }
  1136. }
  1137. return
  1138.  
  1139.  
  1140. ;Instruction Cards Code
  1141. toogleICVisibility:
  1142. if ICVisibilityOn
  1143. {
  1144. gosub, DisableBezelKeys
  1145. if ICRightMenuDraw
  1146. gosub, DisableICRightMenuKeys
  1147. if ICLeftMenuDraw
  1148. gosub, DisableICLeftMenuKeys
  1149. XHotKeywrapper(toogleICVisibilityKey,"toogleICVisibility", "ON")
  1150. startTime := A_TickCount
  1151. Loop {
  1152. t := if ((TimeElapsed := A_TickCount-startTime) < ICChangeDur) ? ((1-(timeElapsed/ICChangeDur))) : 0
  1153. Alt_UpdateLayeredWindow(Bezel_hwnd4, Bezel_hdc4,0,0, baseScreenWidth, baseScreenHeight, round(255*t))
  1154. If (t <= 0){
  1155. Alt_UpdateLayeredWindow(Bezel_hwnd4, Bezel_hdc4,0,0, baseScreenWidth, baseScreenHeight, 0)
  1156. Break
  1157. }
  1158. }
  1159. ICVisibilityOn := false
  1160. } else {
  1161. gosub, EnableBezelKeys
  1162. if ICRightMenuDraw
  1163. gosub, EnableICRightMenuKeys
  1164. if ICLeftMenuDraw
  1165. gosub, EnableICLeftMenuKeys
  1166. startTime := A_TickCount
  1167. Loop {
  1168. t := if ((TimeElapsed := A_TickCount-startTime) < ICChangeDur) ? ((timeElapsed/ICChangeDur)) : 1
  1169. Alt_UpdateLayeredWindow(Bezel_hwnd4, Bezel_hdc4,0,0, baseScreenWidth, baseScreenHeight, round(255*t))
  1170. If (t >= 1){
  1171. Alt_UpdateLayeredWindow(Bezel_hwnd4, Bezel_hdc4,0,0, baseScreenWidth, baseScreenHeight)
  1172. Break
  1173. }
  1174. }
  1175. ICVisibilityOn := true
  1176. }
  1177. return
  1178.  
  1179.  
  1180. nextIC1:
  1181. nextIC2:
  1182. nextIC3:
  1183. nextIC4:
  1184. nextIC5:
  1185. nextIC6:
  1186. nextIC7:
  1187. nextIC8:
  1188. previousIC1:
  1189. previousIC2:
  1190. previousIC3:
  1191. previousIC4:
  1192. previousIC5:
  1193. previousIC6:
  1194. previousIC7:
  1195. previousIC8:
  1196. if %ICRandomSlideShowTimer%
  1197. {
  1198. SetTimer, randomICChange, off
  1199. ICRandomSlideShowTimer := 0
  1200. Return
  1201. }
  1202. StringTrimRight, currentICChange, A_ThisLabel, 1
  1203. StringRight, currentICChangeKeyPressed, A_ThisLabel, 1
  1204. activeIC := 0
  1205. ICindex := 0
  1206. loop, 8
  1207. {
  1208. if bezelICArray[a_index,1,1]
  1209. ICindex++
  1210. if (ICindex = currentICChangeKeyPressed)
  1211. {
  1212. activeIC := a_index
  1213. break
  1214. }
  1215. }
  1216. if (currentICChange="nextIC"){
  1217. gosub, nextIC
  1218. } else {
  1219. gosub, previousIC
  1220. }
  1221. return
  1222.  
  1223. nextIC:
  1224. previousIC:
  1225. if %ICRandomSlideShowTimer%
  1226. {
  1227. SetTimer, randomICChange, off
  1228. ICRandomSlideShowTimer := 0
  1229. Return
  1230. }
  1231. prevSelectedICimage[activeIC] := selectedICimage[activeIC]
  1232. if (A_ThisLabel="nextIC") {
  1233. selectedICimage[activeIC] := selectedICimage[activeIC] + 1
  1234. if (selectedICimage[activeIC] > maxICimage[activeIC]){
  1235. selectedICimage[activeIC] := 0
  1236. }
  1237. } else {
  1238. selectedICimage[activeIC] := selectedICimage[activeIC] - 1
  1239. if (selectedICimage[activeIC] < 0){
  1240. selectedICimage[activeIC] := maxICimage[activeIC]
  1241. }
  1242. }
  1243. DrawIC()
  1244. return
  1245.  
  1246.  
  1247. changeActiveIC:
  1248. if %ICRandomSlideShowTimer%
  1249. {
  1250. SetTimer, randomICChange, off
  1251. ICRandomSlideShowTimer := 0
  1252. Return
  1253. }
  1254. loop, 8
  1255. {
  1256. activeIC++
  1257. if (activeIC > 8)
  1258. activeIC := 1
  1259. if bezelICArray[activeIC,1,1]
  1260. break
  1261. }
  1262. if selectedICimage[activeIC]
  1263. {
  1264. ;grow effect
  1265. GrowSize := 1
  1266. While GrowSize <= 10 {
  1267. Gdip_GraphicsClear(Bezel_G4)
  1268. loop, 8
  1269. {
  1270. if (a_index = activeIC) {
  1271. ICposition(a_index,selectedICimage[a_index])
  1272. Gdip_Alt_DrawImage(Bezel_G4, bezelICArray[a_index,selectedICimage[a_index],2], ICPositionArray[1]-GrowSize, ICPositionArray[2]-GrowSize, bezelICArray[a_index,selectedICimage[a_index],3]+2*GrowSize, bezelICArray[a_index,selectedICimage[a_index],4]+2*GrowSize)
  1273. } else {
  1274. if bezelICArray[a_index,selectedICimage[a_index],1]
  1275. {
  1276. ICposition(a_index,selectedICimage[a_index])
  1277. Gdip_Alt_DrawImage(Bezel_G4, bezelICArray[a_index,selectedICimage[a_index],2], ICPositionArray[1], ICPositionArray[2], bezelICArray[a_index,selectedICimage[a_index],3], bezelICArray[a_index,selectedICimage[a_index],4])
  1278. }
  1279. }
  1280. }
  1281. Alt_UpdateLayeredWindow(Bezel_hwnd4, Bezel_hdc4,0,0, baseScreenWidth, baseScreenHeight)
  1282. GrowSize++
  1283. }
  1284. ;reset
  1285. Gdip_GraphicsClear(Bezel_G4)
  1286. loop, 8
  1287. {
  1288. if bezelICArray[a_index,selectedICimage[a_index],1]
  1289. {
  1290. ICposition(a_index,selectedICimage[a_index])
  1291. Gdip_Alt_DrawImage(Bezel_G4, bezelICArray[a_index,selectedICimage[a_index],2], ICPositionArray[1], ICPositionArray[2], bezelICArray[a_index,selectedICimage[a_index],3], bezelICArray[a_index,selectedICimage[a_index],4])
  1292. }
  1293. }
  1294. Alt_UpdateLayeredWindow(Bezel_hwnd4, Bezel_hdc4,0,0, baseScreenWidth, baseScreenHeight)
  1295. }
  1296. return
  1297.  
  1298.  
  1299. DrawIC(){
  1300. Global
  1301. if (animationIC="none"){
  1302. Gdip_GraphicsClear(Bezel_G4)
  1303. if changeICSound
  1304. SoundPlay, %changeICSound%
  1305. loop, 8
  1306. {
  1307. if bezelICArray[a_index,selectedICimage[a_index],1]
  1308. {
  1309. ICposition(a_index,selectedICimage[a_index])
  1310. Gdip_Alt_DrawImage(Bezel_G4, bezelICArray[a_index,selectedICimage[a_index],2], ICPositionArray[1], ICPositionArray[2], bezelICArray[a_index,selectedICimage[a_index],3], bezelICArray[a_index,selectedICimage[a_index],4])
  1311. }
  1312. }
  1313. Alt_UpdateLayeredWindow(Bezel_hwnd4, Bezel_hdc4,0,0, baseScreenWidth, baseScreenHeight)
  1314. } else if (animationIC="fade"){
  1315. ;fade out
  1316. if prevSelectedICimage[activeIC]
  1317. {
  1318. if fadeOutICSound
  1319. SoundPlay, %fadeOutICSound%
  1320. startTime := A_TickCount
  1321. Loop {
  1322. Gdip_GraphicsClear(Bezel_G4)
  1323. t := if ((TimeElapsed := A_TickCount-startTime) < ICChangeDur) ? ((1-(timeElapsed/ICChangeDur))) : 0
  1324. loop, 8
  1325. {
  1326. if (activeIC = a_index) {
  1327. ICposition(a_index,prevselectedICimage[a_index])
  1328. Gdip_Alt_DrawImage(Bezel_G4, bezelICArray[a_index,prevselectedICimage[a_index],2], ICPositionArray[1], ICPositionArray[2], bezelICArray[a_index,prevselectedICimage[a_index],3], bezelICArray[a_index,prevselectedICimage[a_index],4],"","","","",t)
  1329. } else {
  1330. if bezelICArray[a_index,selectedICimage[a_index],1]
  1331. {
  1332. ICposition(a_index,selectedICimage[a_index])
  1333. Gdip_Alt_DrawImage(Bezel_G4, bezelICArray[a_index,selectedICimage[a_index],2], ICPositionArray[1], ICPositionArray[2], bezelICArray[a_index,selectedICimage[a_index],3], bezelICArray[a_index,selectedICimage[a_index],4])
  1334. }
  1335. }
  1336. }
  1337. Alt_UpdateLayeredWindow(Bezel_hwnd4, Bezel_hdc4,0,0, baseScreenWidth, baseScreenHeight)
  1338. If (t <= 0)
  1339. Break
  1340. }
  1341. }
  1342. ;fade in
  1343. if fadeInICSound
  1344. SoundPlay, %fadeInICSound%
  1345. startTime := A_TickCount
  1346. Loop {
  1347. Gdip_GraphicsClear(Bezel_G4)
  1348. t := if ((TimeElapsed := A_TickCount-startTime) < ICChangeDur) ? ((timeElapsed/ICChangeDur)) : 1
  1349. loop, 8
  1350. {
  1351. if (activeIC = a_index) {
  1352. ICposition(a_index,selectedICimage[a_index])
  1353. Gdip_Alt_DrawImage(Bezel_G4, bezelICArray[a_index,selectedICimage[a_index],2], ICPositionArray[1], ICPositionArray[2], bezelICArray[a_index,selectedICimage[a_index],3], bezelICArray[a_index,selectedICimage[a_index],4],"","","","",t)
  1354. } else {
  1355. if bezelICArray[a_index,selectedICimage[a_index],1]
  1356. {
  1357. ICposition(a_index,selectedICimage[a_index])
  1358. Gdip_Alt_DrawImage(Bezel_G4, bezelICArray[a_index,selectedICimage[a_index],2], ICPositionArray[1], ICPositionArray[2], bezelICArray[a_index,selectedICimage[a_index],3], bezelICArray[a_index,selectedICimage[a_index],4])
  1359. }
  1360. }
  1361. }
  1362. Alt_UpdateLayeredWindow(Bezel_hwnd4, Bezel_hdc4,0,0, baseScreenWidth, baseScreenHeight)
  1363. If (t >= 1)
  1364. Break
  1365. }
  1366. } else if (animationIC="slideOutandIn"){
  1367. ; slide out
  1368. if prevSelectedICimage[activeIC]
  1369. {
  1370. if slideOutICSound
  1371. SoundPlay, %slideOutICSound%
  1372. startTime := A_TickCount
  1373. Loop {
  1374. Gdip_GraphicsClear(Bezel_G4)
  1375. t := if ((TimeElapsed := A_TickCount-startTime) < ICChangeDur) ? ((timeElapsed/ICChangeDur)) : 1
  1376. loop, 8
  1377. {
  1378. if (activeIC = a_index) {
  1379. ICposition(a_index,prevselectedICimage[a_index],t)
  1380. Gdip_Alt_DrawImage(Bezel_G4, bezelICArray[a_index,prevselectedICimage[a_index],2], ICPositionArray[1], ICPositionArray[2], bezelICArray[a_index,prevselectedICimage[a_index],3], bezelICArray[a_index,prevselectedICimage[a_index],4])
  1381. } else {
  1382. if bezelICArray[a_index,selectedICimage[a_index],1]
  1383. {
  1384. ICposition(a_index,selectedICimage[a_index])
  1385. Gdip_Alt_DrawImage(Bezel_G4, bezelICArray[a_index,selectedICimage[a_index],2], ICPositionArray[1], ICPositionArray[2], bezelICArray[a_index,selectedICimage[a_index],3], bezelICArray[a_index,selectedICimage[a_index],4])
  1386. }
  1387. }
  1388. }
  1389. Alt_UpdateLayeredWindow(Bezel_hwnd4, Bezel_hdc4,0,0, baseScreenWidth, baseScreenHeight)
  1390. If (t >= 1)
  1391. Break
  1392. }
  1393. }
  1394. ; slide in
  1395. if slideInICSound
  1396. SoundPlay, %slideInICSound%
  1397. startTime := A_TickCount
  1398. Loop {
  1399. Gdip_GraphicsClear(Bezel_G4)
  1400. t := if ((TimeElapsed := A_TickCount-startTime) < ICChangeDur) ? ((1-(timeElapsed/ICChangeDur))) : 0
  1401. loop, 8
  1402. {
  1403. if (a_index = activeIC) {
  1404. ICposition(a_index,selectedICimage[a_index],t)
  1405. Gdip_Alt_DrawImage(Bezel_G4, bezelICArray[a_index,selectedICimage[a_index],2], ICPositionArray[1], ICPositionArray[2], bezelICArray[a_index,selectedICimage[a_index],3], bezelICArray[a_index,selectedICimage[a_index],4])
  1406. } else {
  1407. if bezelICArray[a_index,selectedICimage[a_index],1]
  1408. {
  1409. ICposition(a_index,selectedICimage[a_index])
  1410. Gdip_Alt_DrawImage(Bezel_G4, bezelICArray[a_index,selectedICimage[a_index],2], ICPositionArray[1], ICPositionArray[2], bezelICArray[a_index,selectedICimage[a_index],3], bezelICArray[a_index,selectedICimage[a_index],4])
  1411. }
  1412. }
  1413. }
  1414. Alt_UpdateLayeredWindow(Bezel_hwnd4, Bezel_hdc4,0,0, baseScreenWidth, baseScreenHeight)
  1415. If (t <= 0)
  1416. Break
  1417. }
  1418. } else if (animationIC="slideIn"){
  1419. ; slide in
  1420. if slideInICSound
  1421. SoundPlay, %slideInICSound%
  1422. startTime := A_TickCount
  1423. Loop {
  1424. Gdip_GraphicsClear(Bezel_G4)
  1425. t := if ((TimeElapsed := A_TickCount-startTime) < ICChangeDur) ? ((1-(timeElapsed/ICChangeDur))) : 0
  1426. loop, 8
  1427. {
  1428. if (a_index = activeIC) {
  1429. ICposition(a_index,selectedICimage[a_index],t)
  1430. Gdip_Alt_DrawImage(Bezel_G4, bezelICArray[a_index,selectedICimage[a_index],2], ICPositionArray[1], ICPositionArray[2], bezelICArray[a_index,selectedICimage[a_index],3], bezelICArray[a_index,selectedICimage[a_index],4])
  1431. } else {
  1432. if bezelICArray[a_index,selectedICimage[a_index],1]
  1433. {
  1434. ICposition(a_index,selectedICimage[a_index])
  1435. Gdip_Alt_DrawImage(Bezel_G4, bezelICArray[a_index,selectedICimage[a_index],2], ICPositionArray[1], ICPositionArray[2], bezelICArray[a_index,selectedICimage[a_index],3], bezelICArray[a_index,selectedICimage[a_index],4])
  1436. }
  1437. }
  1438. }
  1439. Alt_UpdateLayeredWindow(Bezel_hwnd4, Bezel_hdc4,0,0, baseScreenWidth, baseScreenHeight)
  1440. If (t <= 0)
  1441. Break
  1442. }
  1443. }
  1444. return
  1445. }
  1446.  
  1447. ICposition(ICSelectedIndex,ICImageSelectedIndex, step = "0"){
  1448. Global
  1449. if not ICPositionArray
  1450. ICPositionArray := []
  1451. if (positionICArray%ICSelectedIndex% = "topLeft") {
  1452. ICPositionArray[1] := round( 0 - step*bezelICArray[ICSelectedIndex,ICImageSelectedIndex,3] )
  1453. ICPositionArray[2] := 0
  1454. } else if (positionICArray%ICSelectedIndex% = "topRight") {
  1455. ICPositionArray[1] := round( baseScreenWidth - bezelICArray[ICSelectedIndex,ICImageSelectedIndex,3] + step*bezelICArray[ICSelectedIndex,ICImageSelectedIndex,3] )
  1456. ICPositionArray[2] := 0
  1457. } else if (positionICArray%ICSelectedIndex% = "bottomLeft") {
  1458. ICPositionArray[1] := round( 0 - step*bezelICArray[ICSelectedIndex,ICImageSelectedIndex,3] )
  1459. ICPositionArray[2] := round( baseScreenHeight - bezelICArray[ICSelectedIndex,ICImageSelectedIndex,4] )
  1460. } else if (positionICArray%ICSelectedIndex% = "bottomRight") {
  1461. ICPositionArray[1] := round( baseScreenWidth - bezelICArray[ICSelectedIndex,ICImageSelectedIndex,3] + step*bezelICArray[ICSelectedIndex,ICImageSelectedIndex,3] )
  1462. ICPositionArray[2] := round( baseScreenHeight - bezelICArray[ICSelectedIndex,ICImageSelectedIndex,4] )
  1463. } else if (positionICArray%ICSelectedIndex% = "topCenter") {
  1464. ICPositionArray[1] := round( baseScreenWidth//2 - bezelICArray[ICSelectedIndex,ICImageSelectedIndex,3]//2 )
  1465. ICPositionArray[2] := round( 0 - step*bezelICArray[ICSelectedIndex,ICImageSelectedIndex,4] )
  1466. } else if (positionICArray%ICSelectedIndex% = "leftCenter") {
  1467. ICPositionArray[1] := round( 0 - step*bezelICArray[ICSelectedIndex,ICImageSelectedIndex,3] )
  1468. ICPositionArray[2] := round( ( baseScreenHeight - bezelICArray[ICSelectedIndex,ICImageSelectedIndex,4] ) // 2 )
  1469. } else if (positionICArray%ICSelectedIndex% = "rightCenter") {
  1470. ICPositionArray[1] := round( ( baseScreenWidth - bezelICArray[ICSelectedIndex,ICImageSelectedIndex,3] ) + step*bezelICArray[ICSelectedIndex,ICImageSelectedIndex,3] )
  1471. ICPositionArray[2] := round( ( baseScreenHeight - bezelICArray[ICSelectedIndex,ICImageSelectedIndex,4] ) // 2 )
  1472. } else { ; bottomCenter
  1473. ICPositionArray[1] := round( ( baseScreenWidth - bezelICArray[ICSelectedIndex,ICImageSelectedIndex,3] ) // 2 )
  1474. ICPositionArray[2] := round( baseScreenHeight - bezelICArray[ICSelectedIndex,ICImageSelectedIndex,4] + step*bezelICArray[ICSelectedIndex,ICImageSelectedIndex,4] )
  1475. }
  1476. return ICPositionArray
  1477. }
  1478.  
  1479.  
  1480. ;IC Menu code
  1481.  
  1482. rightICMenu:
  1483. leftICMenu:
  1484. if %ICRandomSlideShowTimer%
  1485. {
  1486. SetTimer, randomICChange, off
  1487. ICRandomSlideShowTimer := 0
  1488. }
  1489. if (A_ThisLabel="rightICMenu") {
  1490. if ICRightMenuDraw
  1491. {
  1492. gosub, DisableICRightMenuKeys
  1493. SetTimer, UpdatecurrentRightICScrollingText, off
  1494. Gdip_GraphicsClear(Bezel_G7)
  1495. Gdip_GraphicsClear(Bezel_G8)
  1496. Alt_UpdateLayeredWindow(Bezel_hwnd7, Bezel_hdc7, baseScreenWidth-bezelICRightMenuBitmapW, (baseScreenHeight-bezelICRightMenuBitmapH)//2, bezelICRightMenuBitmapW, bezelICRightMenuBitmapH)
  1497. Alt_UpdateLayeredWindow(Bezel_hwnd8, Bezel_hdc8, baseScreenWidth-ICMenuListX-ICMenuListWidth, (baseScreenHeight-bezelICLeftMenuBitmapH)//2+ICMenuListY+ICMenuListHeight//2-ICMenuListTextSize//2, ICMenuListWidth, ICMenuListTextSize)
  1498. ICRightMenuDraw := false
  1499. } else {
  1500. DrawICMenu("right")
  1501. gosub, EnableICRightMenuKeys
  1502. ICRightMenuDraw := true
  1503. }
  1504. } else {
  1505. if ICLeftMenuDraw
  1506. {
  1507. gosub, DisableICLeftMenuKeys
  1508. SetTimer, UpdatecurrentLeftICScrollingText, off
  1509. Gdip_GraphicsClear(Bezel_G5)
  1510. Gdip_GraphicsClear(Bezel_G6)
  1511. Alt_UpdateLayeredWindow(Bezel_hwnd5, Bezel_hdc5, 0, (baseScreenHeight-bezelICLeftMenuBitmapH)//2, bezelICLeftMenuBitmapW, bezelICLeftMenuBitmapH)
  1512. Alt_UpdateLayeredWindow(Bezel_hwnd6, Bezel_hdc6, ICMenuListX, (baseScreenHeight-bezelICLeftMenuBitmapH)//2+ICMenuListY+ICMenuListHeight//2-ICMenuListTextSize//2, ICMenuListWidth, ICMenuListTextSize)
  1513. ICLeftMenuDraw := false
  1514. } else {
  1515. DrawICMenu("left")
  1516. gosub, EnableICLeftMenuKeys
  1517. ICLeftMenuDraw := true
  1518. }
  1519. }
  1520. return
  1521.  
  1522. rightICMenuUp:
  1523. rightICMenuDown:
  1524. rightICMenuLeft:
  1525. rightICMenuRight:
  1526. leftICMenuUp:
  1527. leftICMenuDown:
  1528. leftICMenuLeft:
  1529. leftICMenuRight:
  1530. if InStr(A_ThisLabel,"MenuUp"){
  1531. if InStr(A_ThisLabel,"rightIC"){
  1532. selectedRightMenuItem[rightMenuActiveIC] := selectedRightMenuItem[rightMenuActiveIC] + 1
  1533. if (selectedRightMenuItem[rightMenuActiveIC] > maxICimage[rightMenuActiveIC])
  1534. selectedRightMenuItem[rightMenuActiveIC] := 0
  1535. } else { ;left
  1536. selectedLeftMenuItem[leftMenuActiveIC] := selectedLeftMenuItem[leftMenuActiveIC] + 1
  1537. if (selectedLeftMenuItem[leftMenuActiveIC] > maxICimage[leftMenuActiveIC])
  1538. selectedLeftMenuItem[leftMenuActiveIC] := 0
  1539. }
  1540. } else if InStr(A_ThisLabel,"MenuDown"){
  1541. if InStr(A_ThisLabel,"rightIC"){
  1542. selectedRightMenuItem[rightMenuActiveIC] := selectedRightMenuItem[rightMenuActiveIC] - 1
  1543. if (selectedRightMenuItem[rightMenuActiveIC] < 0)
  1544. selectedRightMenuItem[rightMenuActiveIC] := maxICimage[rightMenuActiveIC]
  1545. } else { ;left
  1546. selectedLeftMenuItem[leftMenuActiveIC] := selectedLeftMenuItem[leftMenuActiveIC] - 1
  1547. if (selectedLeftMenuItem[leftMenuActiveIC] < 0)
  1548. selectedLeftMenuItem[leftMenuActiveIC] := maxICimage[leftMenuActiveIC]
  1549. }
  1550. } else if InStr(A_ThisLabel,"MenuLeft"){ ;left key
  1551. if InStr(A_ThisLabel,"rightIC"){ ;right menu
  1552. loop, 8
  1553. {
  1554. rightMenuActiveIC--
  1555. if (rightMenuActiveIC < 1)
  1556. rightMenuActiveIC := 8
  1557. if bezelICArray[rightMenuActiveIC,1,1]
  1558. if positionICArray%rightMenuActiveIC% in %rightMenuPositionsIC%
  1559. break
  1560. }
  1561. } else { ;left menu key
  1562. loop, 8
  1563. {
  1564. leftMenuActiveIC--
  1565. if (leftMenuActiveIC < 1)
  1566. leftMenuActiveIC := 8
  1567. if bezelICArray[leftMenuActiveIC,1,1]
  1568. if positionICArray%leftMenuActiveIC% in %leftMenuPositionsIC%
  1569. break
  1570. }
  1571. }
  1572. } else { ;Right key
  1573. if InStr(A_ThisLabel,"rightIC"){ ;right menu
  1574. loop, 8
  1575. {
  1576. rightMenuActiveIC++
  1577. if (rightMenuActiveIC > 8)
  1578. rightMenuActiveIC := 1
  1579. if bezelICArray[rightMenuActiveIC,1,1]
  1580. if positionICArray%rightMenuActiveIC% in %rightMenuPositionsIC%
  1581. break
  1582. }
  1583. } else { ;left menu key
  1584. loop, 8
  1585. {
  1586. leftMenuActiveIC++
  1587. if (leftMenuActiveIC > 8)
  1588. leftMenuActiveIC := 1
  1589. if bezelICArray[leftMenuActiveIC,1,1]
  1590. if positionICArray%leftMenuActiveIC% in %leftMenuPositionsIC%
  1591. break
  1592. }
  1593. }
  1594. }
  1595. if InStr(A_ThisLabel,"rightIC")
  1596. DrawICMenu("right")
  1597. else ; left
  1598. DrawICMenu("left")
  1599. Return
  1600.  
  1601.  
  1602. rightICMenuSelect:
  1603. leftICMenuSelect:
  1604. if InStr(A_ThisLabel,"rightIC"){
  1605. activeIC := rightMenuActiveIC
  1606. selectedICimage[activeIC] := selectedRightMenuItem[rightMenuActiveIC]
  1607. DrawIC()
  1608. DrawICMenu("right")
  1609. } else { ; left
  1610. activeIC := leftMenuActiveIC
  1611. selectedICimage[activeIC] := selectedLeftMenuItem[leftMenuActiveIC]
  1612. DrawIC()
  1613. DrawICMenu("left")
  1614. }
  1615. Return
  1616.  
  1617.  
  1618. DrawICMenu(side){
  1619. Global
  1620. ;Initializing parameters
  1621. ICMenuListTextFont := IC%side%MenuListTextFont
  1622. ICMenuListTextAlignment := IC%side%MenuListTextAlignment
  1623. ICMenuListTextSize := IC%side%MenuListTextSize
  1624. ICMenuListTextColor := IC%side%MenuListTextColor
  1625. ICMenuListDisabledTextColor := IC%side%MenuListDisabledTextColor
  1626. ICMenuListCurrentTextColor := IC%side%MenuListCurrentTextColor
  1627. ICMenuListDisabledTextSize := IC%side%MenuListDisabledTextSize
  1628. ICMenuListItems := IC%side%MenuListItems
  1629. ICMenuListX := IC%side%MenuListX
  1630. ICMenuListY := IC%side%MenuListY
  1631. ICMenuListWidth := IC%side%MenuListWidth
  1632. ICMenuListHeight := IC%side%MenuListHeight
  1633. ICMenuPositionTextFont := IC%side%MenuPositionTextFont
  1634. ICMenuPositionTextSize := IC%side%MenuPositionTextSize
  1635. ICMenuPositionTextColor := IC%side%MenuPositionTextColor
  1636. ICMenuPositionTextX := IC%side%MenuPositionTextX
  1637. ICMenuPositionTextY := IC%side%MenuPositionTextY
  1638. ICMenuPositionTextWidth := IC%side%MenuPositionTextWidth
  1639. ICMenuPositionTextHeight := IC%side%MenuPositionTextHeight
  1640. ICMenuPositionTextAlignment := IC%side%MenuPositionTextAlignment
  1641. VDistBtwICNames := ICMenuListHeight//(ICMenuListItems+1)
  1642. menuActiveIC := %side%MenuActiveIC
  1643. menuSelectedItem[menuActiveIC] := if selected%side%MenuItem[menuActiveIC] ? selected%side%MenuItem[menuActiveIC] : 0
  1644. ;Drawing Menu Image
  1645. if (side="left"){
  1646. Gdip_GraphicsClear(Bezel_G5)
  1647. Gdip_GraphicsClear(Bezel_G6)
  1648. Gdip_Alt_DrawImage(Bezel_G5, bezelICLeftMenuBitmap, 0, 0, bezelICLeftMenuBitmapW, bezelICLeftMenuBitmapH)
  1649. Gdip_Alt_TextToGraphics(Bezel_G5, positionICArray%leftMenuActiveIC%, "x" . ICMenuPositionTextX . " y" . ICMenuPositionTextY . " " . ICMenuPositionTextAlignment . " c" . ICMenuPositionTextColor . " r4 s" . ICMenuPositionTextSize . " normal", ICMenuPositionTextFont, ICMenuPositionTextWidth, ICMenuPositionTextHeight)
  1650. } else {
  1651. Gdip_GraphicsClear(Bezel_G7)
  1652. Gdip_GraphicsClear(Bezel_G8)
  1653. Gdip_Alt_DrawImage(Bezel_G7, bezelICRightMenuBitmap, 0, 0, bezelICRightMenuBitmapW, bezelICRightMenuBitmapH)
  1654. Gdip_Alt_TextToGraphics(Bezel_G7, positionICArray%rightMenuActiveIC%, "x" . ICMenuPositionTextX . " y" . ICMenuPositionTextY . " " . ICMenuPositionTextAlignment . " c" . ICMenuPositionTextColor . " r4 s" . ICMenuPositionTextSize . " normal", ICMenuPositionTextFont, ICMenuPositionTextWidth, ICMenuPositionTextHeight)
  1655. }
  1656. ;Drawing IC List
  1657. bottomtext := menuSelectedItem[menuActiveIC]
  1658. topText := menuSelectedItem[menuActiveIC]
  1659. Loop, % ICMenuListItems//2+1
  1660. {
  1661. If (a_index=1)
  1662. {
  1663. currentSelectedColor%side% := if (menuSelectedItem[menuActiveIC] = selectedICimage[menuActiveIC]) ? ICMenuListCurrentTextColor : ICMenuListTextColor
  1664. currentSelectedLabel%side% := bezelICArray[menuActiveIC,menuSelectedItem[menuActiveIC],5]
  1665. MeasureCurrentSelectedIC := MeasureText(currentSelectedLabel%side%, "Left r4 s" . ICMenuListTextSize . " bold",ICMenuListTextFont)
  1666. if (MeasureCurrentSelectedIC <= ICMenuListWidth) {
  1667. TextOptions := "x0 y0 " . ICMenuListTextAlignment . " c" . currentSelectedColor%side% . " r4 s" . ICMenuListTextSize . " bold"
  1668. if (side="left") {
  1669. SetTimer, UpdatecurrentLeftICScrollingText, off
  1670. Gdip_GraphicsClear(Bezel_G6)
  1671. Gdip_Alt_TextToGraphics(Bezel_G6, currentSelectedLabel%side%, TextOptions, ICMenuListTextFont, ICMenuListWidth, ICMenuListTextSize)
  1672. } else {
  1673. SetTimer, UpdatecurrentRightICScrollingText, off
  1674. Gdip_GraphicsClear(Bezel_G8)
  1675. Gdip_Alt_TextToGraphics(Bezel_G8, currentSelectedLabel%side%, TextOptions, ICMenuListTextFont, ICMenuListWidth, ICMenuListTextSize)
  1676. }
  1677. } else {
  1678. if (side="left"){
  1679. initLeftPixels := 0
  1680. xLeft := 0
  1681. SetTimer, UpdatecurrentLeftICScrollingText, 20
  1682. } else {
  1683. initRightPixels := 0
  1684. xRight := 0
  1685. SetTimer, UpdatecurrentRightICScrollingText, 20
  1686. }
  1687. }
  1688. } Else {
  1689. bottomtext++
  1690. bottomtext := If (bottomtext > maxICimage[menuActiveIC]) ? 0 : bottomtext
  1691. currentColor := if (bottomtext = selectedICimage[menuActiveIC]) ? ICMenuListCurrentTextColor : ICMenuListDisabledTextColor
  1692. currentLabel := bezelICArray[menuActiveIC,bottomtext,5]
  1693. TextOptions := "x" . ICMenuListX . " y" . ICMenuListY+ICMenuListHeight//2-(a_index-1)*(VDistBtwICNames)-ICMenuListDisabledTextSize//2 . " " . ICMenuListTextAlignment . " c" . currentColor . " r4 s" . ICMenuListDisabledTextSize . " normal"
  1694. if (side="left"){
  1695. Gdip_Alt_TextToGraphics(Bezel_G5, currentLabel, TextOptions, ICMenuListTextFont, ICMenuListWidth, ICMenuListDisabledTextSize)
  1696. } else {
  1697. Gdip_Alt_TextToGraphics(Bezel_G7, currentLabel, TextOptions, ICMenuListTextFont, ICMenuListWidth, ICMenuListDisabledTextSize)
  1698. }
  1699. topText--
  1700. topText := If (topText < 0) ? maxICimage[menuActiveIC] : topText
  1701. currentColor := if (topText = selectedICimage[menuActiveIC]) ? ICMenuListCurrentTextColor : ICMenuListDisabledTextColor
  1702. currentLabel := bezelICArray[menuActiveIC,topText,5]
  1703. TextOptions := "x" . ICMenuListX . " y" . ICMenuListY+ICMenuListHeight//2+(a_index-1)*(VDistBtwICNames)-ICMenuListDisabledTextSize//2 . " " . ICMenuListTextAlignment . " c" . currentColor . " r4 s" . ICMenuListDisabledTextSize . " normal"
  1704. if (side="left"){
  1705. Gdip_Alt_TextToGraphics(Bezel_G5, currentLabel, TextOptions, ICMenuListTextFont, ICMenuListWidth, ICMenuListDisabledTextSize)
  1706. } else {
  1707. Gdip_Alt_TextToGraphics(Bezel_G7, currentLabel, TextOptions, ICMenuListTextFont, ICMenuListWidth, ICMenuListDisabledTextSize)
  1708. }
  1709. }
  1710. }
  1711. if (side="left"){
  1712. Alt_UpdateLayeredWindow(Bezel_hwnd5, Bezel_hdc5, 0, (baseScreenHeight-bezelICLeftMenuBitmapH)//2, bezelICLeftMenuBitmapW, bezelICLeftMenuBitmapH)
  1713. Alt_UpdateLayeredWindow(Bezel_hwnd6, Bezel_hdc6, ICMenuListX, (baseScreenHeight-bezelICLeftMenuBitmapH)//2+ICMenuListY+ICMenuListHeight//2-(ICMenuListTextSize)//2, ICMenuListWidth, ICMenuListTextSize)
  1714. } else {
  1715. Alt_UpdateLayeredWindow(Bezel_hwnd7, Bezel_hdc7, baseScreenWidth-bezelICRightMenuBitmapW, (baseScreenHeight-bezelICRightMenuBitmapH)//2, bezelICRightMenuBitmapW, bezelICRightMenuBitmapH)
  1716. Alt_UpdateLayeredWindow(Bezel_hwnd8, Bezel_hdc8, baseScreenWidth-bezelICRightMenuBitmapW+ICMenuListX, (baseScreenHeight-bezelICLeftMenuBitmapH)//2+ICMenuListY+ICMenuListHeight//2-(ICMenuListTextSize)//2, ICMenuListWidth, ICMenuListTextSize)
  1717. }
  1718. Return
  1719. }
  1720.  
  1721. UpdatecurrentLeftICScrollingText: ;Updating scrolling IC name
  1722. Options = y0 c%currentSelectedColorLeft% r4 s%ICMenuListTextSize% bold
  1723. scrollingVelocity := 2
  1724. xLeft := (-xLeft >= E3) ? initLeftPixels : xLeft-scrollingVelocity
  1725. initLeftPixels := ICLeftMenuListWidth
  1726. Gdip_GraphicsClear(Bezel_G6)
  1727. E := Gdip_Alt_TextToGraphics(Bezel_G6, currentSelectedLabelLeft, "x" xLeft " " Options, ICMenuListTextFont, (xLeft < 0) ? ICLeftMenuListWidth-xLeft : ICLeftMenuListWidth, ICMenuListTextSize)
  1728. StringSplit, E, E, |
  1729. Alt_UpdateLayeredWindow(Bezel_hwnd6, Bezel_hdc6, ICMenuListX, (baseScreenHeight-bezelICLeftMenuBitmapH)//2+ICMenuListY+ICMenuListHeight//2-(ICMenuListTextSize)//2, ICMenuListWidth, ICMenuListTextSize)
  1730. return
  1731.  
  1732. UpdatecurrentRightICScrollingText: ;Updating scrolling IC name
  1733. Options = y0 c%currentSelectedColorRight% r4 s%ICMenuListTextSize% bold
  1734. scrollingVelocity := 2
  1735. xRight := (-xRight >= E3) ? initRightPixels : xRight-scrollingVelocity
  1736. initRightPixels := ICRightMenuListWidth
  1737. Gdip_GraphicsClear(Bezel_G8)
  1738. E := Gdip_Alt_TextToGraphics(Bezel_G8, currentSelectedLabelRight, "x" xRight " " Options, ICMenuListTextFont, (xRight < 0) ? ICRightMenuListWidth-xRight : ICRightMenuListWidth, ICMenuListTextSize)
  1739. StringSplit, E, E, |
  1740. Alt_UpdateLayeredWindow(Bezel_hwnd8, Bezel_hdc8, baseScreenWidth-bezelICRightMenuBitmapW+ICMenuListX, (baseScreenHeight-bezelICLeftMenuBitmapH)//2+ICMenuListY+ICMenuListHeight//2-(ICMenuListTextSize)//2, ICMenuListWidth, ICMenuListTextSize)
  1741. Return
  1742.  
  1743.  
  1744.  
  1745. randomICChange:
  1746. loop, 8
  1747. {
  1748. if maxICimage[a_index]
  1749. {
  1750. activeIC := a_index
  1751. Random, ICImage, 1, % maxICimage[activeIC]
  1752. selectedICimage[activeIC] := ICImage
  1753. DrawIC()
  1754. }
  1755. }
  1756. Return
  1757.  
  1758.  
  1759. EnableBezelKeys:
  1760. if bezelICPath
  1761. {
  1762. if toogleICVisibilityKey
  1763. XHotKeywrapper(toogleICVisibilityKey,"toogleICVisibility", "ON")
  1764. if nextICKey
  1765. XHotKeywrapper(nextICKey,"nextIC", "ON")
  1766. if previousICKey
  1767. XHotKeywrapper(previousICKey,"previousIC", "ON")
  1768. if changeActiveICKey
  1769. XHotKeywrapper(changeActiveICKey,"changeActiveIC", "ON")
  1770. loop, 8
  1771. {
  1772. if nextIC%a_index%Key
  1773. XHotKeywrapper(nextIC%a_index%Key,"nextIC" . A_Index, "ON")
  1774. if previousIC%a_index%Key
  1775. XHotKeywrapper(previousIC%a_index%Key,"previousIC" . A_Index, "ON")
  1776. }
  1777. if leftICMenuKey
  1778. XHotKeywrapper(leftICMenuKey,"leftICMenu", "ON")
  1779. if rightICMenuKey
  1780. XHotKeywrapper(rightICMenuKey,"rightICMenu", "ON")
  1781. }
  1782. if (bezelImagesList.MaxIndex() > 1) {
  1783. if nextBezelKey
  1784. XHotKeywrapper(nextBezelKey,"nextBezel", "ON")
  1785. if previousBezelKey
  1786. XHotKeywrapper(previousBezelKey,"previousBezel", "ON")
  1787. }
  1788. Log("Bezel Keys Enabled",5)
  1789. Return
  1790.  
  1791.  
  1792. DisableBezelKeys:
  1793. if bezelICPath
  1794. {
  1795. if toogleICVisibilityKey
  1796. XHotKeywrapper(toogleICVisibilityKey,"toogleICVisibility", "OFF")
  1797. if nextICKey
  1798. XHotKeywrapper(nextICKey,"nextIC", "OFF")
  1799. if previousICKey
  1800. XHotKeywrapper(previousICKey,"previousIC", "OFF")
  1801. if changeActiveICKey
  1802. XHotKeywrapper(changeActiveICKey,"changeActiveIC", "OFF")
  1803. loop, 8
  1804. {
  1805. if nextIC%a_index%Key
  1806. XHotKeywrapper(nextIC%a_index%Key,"nextIC" . A_Index, "OFF")
  1807. if previousIC%a_index%Key
  1808. XHotKeywrapper(previousIC%a_index%Key,"previousIC" . A_Index, "OFF")
  1809. }
  1810. if leftICMenuKey
  1811. XHotKeywrapper(leftICMenuKey,"leftICMenu", "OFF")
  1812. if rightICMenuKey
  1813. XHotKeywrapper(rightICMenuKey,"rightICMenu", "OFF")
  1814. }
  1815. if (bezelImagesList.MaxIndex() > 1) {
  1816. if nextBezelKey
  1817. XHotKeywrapper(nextBezelKey,"nextBezel", "OFF")
  1818. if previousBezelKey
  1819. XHotKeywrapper(previousBezelKey,"previousBezel", "OFF")
  1820. }
  1821. Log("Bezel Keys Disabled",5)
  1822. Return
  1823.  
  1824. EnableICRightMenuKeys:
  1825. XHotKeywrapper(navP2SelectKey,"rightICMenuSelect","ON")
  1826. XHotKeywrapper(navP2LeftKey,"rightICMenuLeft","ON")
  1827. XHotKeywrapper(navP2RightKey,"rightICMenuRight","ON")
  1828. XHotKeywrapper(navP2UpKey,"rightICMenuUp","ON")
  1829. XHotKeywrapper(navP2DownKey,"rightICMenuDown","ON")
  1830. return
  1831.  
  1832. DisableICRightMenuKeys:
  1833. XHotKeywrapper(navP2SelectKey,"rightICMenuSelect","OFF")
  1834. XHotKeywrapper(navP2LeftKey,"rightICMenuLeft","OFF")
  1835. XHotKeywrapper(navP2RightKey,"rightICMenuRight","OFF")
  1836. XHotKeywrapper(navP2UpKey,"rightICMenuUp","OFF")
  1837. XHotKeywrapper(navP2DownKey,"rightICMenuDown","OFF")
  1838. return
  1839.  
  1840. EnableICLeftMenuKeys:
  1841. XHotKeywrapper(navSelectKey,"leftICMenuSelect","ON")
  1842. XHotKeywrapper(navLeftKey,"leftICMenuLeft","ON")
  1843. XHotKeywrapper(navRightKey,"leftICMenuRight","ON")
  1844. XHotKeywrapper(navUpKey,"leftICMenuUp","ON")
  1845. XHotKeywrapper(navDownKey,"leftICMenuDown","ON")
  1846. return
  1847.  
  1848. DisableICLeftMenuKeys:
  1849. XHotKeywrapper(navSelectKey,"leftICMenuSelect","OFF")
  1850. XHotKeywrapper(navLeftKey,"leftICMenuLeft","OFF")
  1851. XHotKeywrapper(navRightKey,"leftICMenuRight","OFF")
  1852. XHotKeywrapper(navUpKey,"leftICMenuUp","OFF")
  1853. XHotKeywrapper(navDownKey,"leftICMenuDown","OFF")
  1854. return
  1855.  
  1856.  
  1857. ExtraFixedResBezelGUI(){
  1858. Global bezelEnabled, extraFixedRes_Bezel_hbm, extraFixedRes_Bezel_hdc, extraFixedRes_Bezel_hwnd, extraFixedRes_Bezel_G
  1859. if (bezelEnabled = "true"){
  1860. ;Gui, extraFixedRes_Bezel_GUI: +OwnerBezel_GUI8 +Disabled -Caption +E0x80000 +OwnDialogs +LastFound +ToolWindow +AlwaysOnTop
  1861. Gui, extraFixedRes_Bezel_GUI: +Disabled -Caption +E0x80000 +OwnDialogs +LastFound +ToolWindow +AlwaysOnTop
  1862. Gui, extraFixedRes_Bezel_GUI: Margin,0,0
  1863. Gui, extraFixedRes_Bezel_GUI: Show,, BezelLayer9
  1864. extraFixedRes_Bezel_hwnd := WinExist()
  1865. extraFixedRes_Bezel_hbm := CreateDIBSection(A_ScreenWidth, A_ScreenHeight)
  1866. extraFixedRes_Bezel_hdc := CreateCompatibleDC()
  1867. extraFixedRes_Bezel_obm := SelectObject(extraFixedRes_Bezel_hdc, extraFixedRes_Bezel_hbm)
  1868. extraFixedRes_Bezel_G := Gdip_GraphicsFromhdc(extraFixedRes_Bezel_hdc)
  1869. Gdip_SetSmoothingMode(extraFixedRes_Bezel_G, 4)
  1870. }
  1871. }
  1872.  
  1873.  
  1874. ExtraFixedResBezelDraw(extraFixedResScreenID, filePreffix="VMU", extraFixedResPosition="TopRight",extraFixedResBezelScreenWidth=80,extraFixedResBezelScreenHeight=60,extraFixedResBezelRightOffset=0,extraFixedResBezelLeftOffset=0,extraFixedResBezelTopOffset=0,extraFixedResBezelBottomOffset=0){
  1875. Global bezelEnabled, bezelPath, extraFixedRes_Bezel_hbm, extraFixedRes_Bezel_hdc, extraFixedRes_Bezel_hwnd, extraFixedRes_Bezel_G, bezelFileExtensions
  1876. if ((bezelEnabled = "true") and (bezelPath)){
  1877. ;Check for extraFixedRes bezel file:
  1878. extraFixedResBezelPath := BezelFilesPath(filePreffix . " Bezel",bezelFileExtensions)
  1879. If extraFixedResBezelPath
  1880. { ;Setting bezel aleatory choosed file
  1881. extraFixedResbezelImagesList := []
  1882. Loop, Parse, bezelFileExtensions,|
  1883. Loop, % extraFixedResBezelPath . "\" . filePreffix . " Bezel*." . A_LoopField
  1884. if !RegExMatch(A_LoopFileName, "i)\[[0-9]+S\]")
  1885. extraFixedResBezelImagesList.Insert(A_LoopFileFullPath)
  1886. Random, RndmextraFixedResBezel, 1, % extraFixedResBezelImagesList.MaxIndex()
  1887. extraFixedResBezelImageFile := extraFixedResBezelImagesList[RndmextraFixedResBezel]
  1888. SplitPath, extraFixedResBezelImageFile, extraFixedResBezelImageFileName, extraFixedResBezelImageDir,,extraFixedResBezelImageFileNameNoExt
  1889. Log("Bezel - Loading extraFixedRes Bezel image: " . extraFixedResBezelImageFile,1)
  1890. ;Setting overlay aleatory choosed file (only searches overlays at the bezel.png folder)
  1891. If FileExist(extraFixedResBezelPath . "\" . filePreffix . " Overlay" . SubStr(extraFixedResBezelImageFileName,StrLen(filePreffix)+7)) {
  1892. extraFixedResBezelOverlaysList := []
  1893. extraFixedResBezelOverlaysList.Insert(extraFixedResBezelPath . "\" . filePreffix . " Overlay" . SubStr(extraFixedResBezelImageFileName,StrLen(filePreffix)+7))
  1894. extraFixedResBezelOverlayFile := % extraFixedResBezelPath . "\" . filePreffix . " Overlay" . SubStr(extraFixedResBezelImageFileName,StrLen(filePreffix)+7)
  1895. extraFixedResBezelOverlayBitmap := Gdip_CreateBitmapFromFile(extraFixedResBezelOverlayFile)
  1896. Log("Bezel - Loading extraFixedRes Overlay image with the same name of the extraFixedRes bezel image: " . extraFixedResBezelOverlayFile,1)
  1897. }
  1898. ;Read extraFixedRes Bezel ini coordinates
  1899. extraFixedResBezelScreenX1 := IniReadCheck(extraFixedResBezelImageDir . "\" . extraFixedResBezelImageFileNameNoExt . ".ini", "General", "Bezel Screen Top Left X Coordinate", 0)
  1900. extraFixedResBezelScreenY1 := IniReadCheck(extraFixedResBezelImageDir . "\" . extraFixedResBezelImageFileNameNoExt . ".ini", "General", "Bezel Screen Top Left Y Coordinate", 0)
  1901. extraFixedResBezelScreenX2 := IniReadCheck(extraFixedResBezelImageDir . "\" . extraFixedResBezelImageFileNameNoExt . ".ini", "General", "Bezel Screen Bottom Right X Coordinate", 150)
  1902. extraFixedResBezelScreenY2 := IniReadCheck(extraFixedResBezelImageDir . "\" . extraFixedResBezelImageFileNameNoExt . ".ini", "General", "Bezel Screen Bottom Right Y Coordinate", 100)
  1903. ; creating bitmap pointers
  1904. extraFixedResBezelBitmap := Gdip_CreateBitmapFromFile(extraFixedResBezelImageFile)
  1905. Gdip_GetImageDimensions(extraFixedResBezelBitmap, extraFixedResBezelImageW, extraFixedResBezelImageH)
  1906. xScaleFactor := (extraFixedResBezelScreenWidth)/(extraFixedResBezelScreenX2-extraFixedResBezelScreenX1)
  1907. yScaleFactor := (extraFixedResBezelScreenHeight)/(extraFixedResBezelScreenY2-extraFixedResBezelScreenY1)
  1908. extraFixedResBezelImageW := Round(extraFixedResBezelImageW * xScaleFactor)
  1909. extraFixedResBezelImageH := Round(extraFixedResBezelImageH * yScaleFactor)
  1910. if (extraFixedResPosition="TopRight")
  1911. extraFixedResBezelImageX := A_ScreenWidth - extraFixedResBezelImageW , extraFixedResBezelImageY := 0
  1912. else if (extraFixedResPosition="TopCenter")
  1913. extraFixedResBezelImageX := (A_ScreenWidth - extraFixedResBezelImageW)//2 , extraFixedResBezelImageY := 0
  1914. else if (extraFixedResPosition="TopLeft")
  1915. extraFixedResBezelImageX := 0 , extraFixedResBezelImageY := 0
  1916. else if (extraFixedResPosition="LeftCenter")
  1917. extraFixedResBezelImageX := 0 , extraFixedResBezelImageY := (A_ScreenHeight - extraFixedResBezelImageH)//2
  1918. else if (extraFixedResPosition="BottomRight")
  1919. extraFixedResBezelImageX := A_ScreenWidth - extraFixedResBezelImageW , extraFixedResBezelImageY := A_ScreenHeight - extraFixedResBezelImageH
  1920. else if (extraFixedResPosition="BottomCenter")
  1921. extraFixedResBezelImageX := (A_ScreenWidth - extraFixedResBezelImageW)//2 , extraFixedResBezelImageY := A_ScreenHeight - extraFixedResBezelImageH
  1922. else if (extraFixedResPosition="BottomLeft")
  1923. extraFixedResBezelImageX := 0 , extraFixedResBezelImageY := A_ScreenHeight - extraFixedResBezelImageH
  1924. else ; Right Center
  1925. extraFixedResBezelImageX := A_ScreenWidth - extraFixedResBezelImageW , extraFixedResBezelImageY := (A_ScreenHeight - extraFixedResBezelImageH)//2
  1926. extraFixedResBezelScreenX := extraFixedResBezelImageX + Round(extraFixedResBezelScreenX1*xScaleFactor)
  1927. extraFixedResBezelScreenY := extraFixedResBezelImageY + Round(extraFixedResBezelScreenY1*yScaleFactor)
  1928. ; Applying offsets to correctly place the emulator if the emulator has extra window components
  1929. extraFixedResBezelScreenX := if extraFixedResBezelLeftOffset ? extraFixedResBezelScreenX - extraFixedResBezelLeftOffset : extraFixedResBezelScreenX
  1930. extraFixedResBezelScreenY := if extraFixedResBezelTopOffset ? extraFixedResBezelScreenY - extraFixedResBezelTopOffset : extraFixedResBezelScreenY
  1931. ; check if window moved (maximun 5 seconds)
  1932. X:="" , Y:="" , timeout := A_TickCount
  1933. sleep, 200
  1934. loop
  1935. {
  1936. sleep, 50
  1937. WinGetPos, X, Y, , , ahk_id %extraFixedResScreenID%
  1938. if (X=extraFixedResBezelScreenX) and (Y=extraFixedResBezelScreenY)
  1939. break
  1940. if(timeout < A_TickCount - 5000)
  1941. break
  1942. sleep, 50
  1943. WinMove, ahk_id %extraFixedResScreenID%, , %extraFixedResBezelScreenX%, %extraFixedResBezelScreenY%
  1944. }
  1945. ;Drawing extraFixedRes Bezel GUI
  1946. Gdip_DrawImage(extraFixedRes_Bezel_G, extraFixedResBezelBitmap, extraFixedResBezelImageX, extraFixedResBezelImageY,extraFixedResBezelImageW,extraFixedResBezelImageH)
  1947. Log("Bezel - extraFixedRes Bezel Image Screen Position: left=" . extraFixedResBezelImageX . " top=" . extraFixedResBezelImageY . " right=" . (extraFixedResBezelImageX+extraFixedResBezelImageW) . " bottom=" . (extraFixedResBezelImageY+extraFixedResBezelImageH) ,5)
  1948. ;Drawing Overlay Image above screen
  1949. If (extraFixedResBezelOverlayFile)
  1950. { Gdip_DrawImage(extraFixedRes_Bezel_G, extraFixedResBezelOverlayBitmap, extraFixedResBezelImageX+Round(extraFixedResBezelScreenX1*xScaleFactor), extraFixedResBezelImageY+Round(extraFixedResBezelScreenY1*yScaleFactor) ,extraFixedResBezelScreenWidth,extraFixedResBezelScreenHeight)
  1951. Log("Bezel - extraFixedRes Overlay Screen Position: left=" . extraFixedResBezelImageX+Round(extraFixedResBezelScreenX1*xScaleFactor) . " top=" . extraFixedResBezelImageY+Round(extraFixedResBezelScreenY1*yScaleFactor) . " right=" . extraFixedResBezelImageX+(Round(extraFixedResBezelScreenX1*xScaleFactor)+extraFixedResBezelScreenWidth) . " bottom=" . extraFixedResBezelImageY+Round(extraFixedResBezelScreenY1*yScaleFactor)+extraFixedResBezelScreenHeight ,5)
  1952. }
  1953. UpdateLayeredWindow(extraFixedRes_Bezel_hwnd, extraFixedRes_Bezel_hdc,0,0, A_ScreenWidth, A_ScreenHeight)
  1954. }
  1955. Log("BezelDraw - Ended")
  1956. }
  1957. Return
  1958. }
  1959.  
  1960. ExtraFixedResBezelExit(){
  1961. Global bezelEnabled, extraFixedResBezelPath, extraFixedRes_Bezel_hbm, extraFixedRes_Bezel_obm, extraFixedRes_Bezel_hdc, extraFixedRes_Bezel_hwnd, extraFixedRes_Bezel_G, extraFixedResBezelImageFile, extraFixedResBezelBitmap, extraFixedResBezelOverlayFile, extraFixedResBezelOverlayBitmap
  1962. if (bezelEnabled = "true"){
  1963. SelectObject(extraFixedRes_Bezel_hdc, extraFixedRes_Bezel_obm)
  1964. DeleteObject(extraFixedRes_Bezel_hbm)
  1965. DeleteDC(extraFixedRes_Bezel_hdc)
  1966. Gdip_DeleteGraphics(extraFixedRes_Bezel_G)
  1967. Gui, extraFixedRes_Bezel_GUI: Destroy
  1968. If extraFixedResBezelPath
  1969. { if extraFixedResBezelImageFile
  1970. Gdip_DisposeImage(extraFixedResBezelBitmap)
  1971. if extraFixedResBezelOverlayFile
  1972. Gdip_DisposeImage(extraFixedResBezelOverlayBitmap)
  1973. }
  1974. }
  1975. Return
  1976. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement