Advertisement
djvj

Untitled

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