gamesmame

Untitled

Mar 25th, 2023
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 44.59 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. /* Atari 2600 theme v10.3.2
  3. _______ _______ _______ ______ ___ _______ ___ _______ _______
  4. | _ || || _ || _ | | | | || | | _ || _ |
  5. | |_| ||_ _|| |_| || | || | | |____ || |___ | | | || | | |
  6. | | | | | || |_||_ | | ____| || _ || | | || | | |
  7. | | | | | || __ || | | ______|| | | || |_| || |_| |
  8. | _ | | | | _ || | | || | | |_____ | |_| || || |
  9. |__| |__| |___| |__| |__||___| |_||___| |_______||_______||_______||_______|
  10.  
  11. Design, Code and Art by Yaron2019
  12.  
  13. 'coordinates table for different screen aspects' code adapted from nevato theme
  14. Letters and 'System games count' code adapted from pcca theme */
  15. ////////////////////////////////////////////////////////////////////////////////////////////////////////
  16.  
  17. local orderx = 0;
  18. local divider = "----"
  19.  
  20. class UserConfig {
  21. </ label="Enable startup animations", help="Enable system animation when layout starts", options="Yes,No", order=orderx++ /> enable_ini_anim="Yes";
  22. </ label="Startup animation transition time",
  23. help="animation time in ms",
  24. options="500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000",
  25. order=orderx++
  26. />ini_anim_trans_ms="1000";
  27. </ label="Enable background scanlines", help="Show scanline effect on background image", options="None,Light,Medium,Dark", order=orderx++ /> enable_scanline="None";
  28. </ label= divider, help=" ", options = " ", order=orderx++ /> paramxx1 = " "
  29.  
  30. </ label="Type of wheel", help="Select round wheel or vertical wheel", options="Round,Vertical", order=orderx++ /> wheel_type="Round";
  31. </ label="Size of wheel logos", help="Use smaller or larger wheel logos", options="Smaller,Larger", order=orderx++ /> wheel_logo_size="Larger";
  32. </ label="Preserve wheel logo's aspect ratio", help="Preserve the original aspect ratio of the wheel logos, great for vertical wheel mode", options="Yes,No", order=orderx++ /> wheel_logo_aspect="No";
  33. </ label="Enable wheel logos mipmap", help="Mipmap reduces aliasing artifacts (jagged edges) for high resolution wheel logos", options="Yes,No", order=orderx++ /> wheel_logo_mipmap="No";
  34. </ label="Adjust wheel position", help="Adjust wheel position closer to or further from the right side of the screen", options="Adjust Left,Adjust Right", order=orderx++ /> wheel_poisition="Adjust Left";
  35. </ label="Enable semitransparent wheel", help="Semitransparent or fully opaque wheel logos", options="Yes,No", order=orderx++ /> wheel_semi_t="No";
  36. </ label="Number of wheel slots",
  37. help="Number of slots in the wheel",
  38. options="4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80",
  39. order=orderx++
  40. />wheels="10";
  41. </ label="Wheel transition time",
  42. help="Time in milliseconds for wheel spin",
  43. options="1,25,50,75,100,125,150,175,200",
  44. order=orderx++
  45. />transition_ms="25";
  46. </ label="Enable wheel fadeout", help="Enable wheel fadeout", options="No,Completely,Partially", order=orderx++ /> wheel_fadeout="Partially";
  47. </ label="Fade wheel time", help="Fade wheel time", options="500,1000,2000,3000", order=orderx++ /> wheel_fade_ms="500";
  48. </ label = "Delay time",
  49. help = "The time (in milliseconds) it takes to start hiding the wheel and pointer",
  50. options = "500,750,1000,1250,1500,1750,2000,2250,2500,2750,3000",
  51. order = orderx++
  52. /> set_ms_delay = "1250";
  53. </ label="Enable wheel pulse", help="Animate a pulse of the current wheel logo - will pulse only once if wheel fadeout is enabled", options="No,Once,Loop", order=orderx++ /> wheel_pulse="Once";
  54. </ label="Enable wheel background", help="Show wheel background texture", options="Yes,No", order=orderx++ /> enable_wl_bg="No";
  55. </ label="Enable wheel sounds", help="Play sounds when navigating games wheel", options="No,Random,Click", order=orderx++ /> enable_random_sound="Random";
  56. </ label="Show wheel pointer", help="Show animated wheel pointer", options="Yes,No", order=orderx++ /> enable_pointer="Yes";
  57. </ label="Enable Letters",
  58. help="Show graphical letters on the screen when pressing the wheel's 'Next Letter' or 'Previous Letter' hotkeys set in the Controls menu.\n 'System Display Name' option will seek the letters in a folder identical to the current system display name (attract/letters/mame for example).",
  59. options="No,Default,By System Display Name", order=orderx++ /> letters_type="Default";
  60. </ label= divider, help=" ", options = " ", order=orderx++ /> paramxx2 = " "
  61.  
  62. </ label="Enable CRT scanlines", help="Show CRT scanlines", options="None,Light,Medium,Dark", order=orderx++ /> enable_crt_scanline="Medium";
  63. </ label="Enable CRT bloom shader effect", help="Creates a bloom effect for the snap video, if device is able to run GLSL shaders", options="Yes,No", order=orderx++ /> enable_bloom="Yes";
  64. </ label="Mute game snap videos", help="Mute game snap videos", options="Yes,No", order=orderx++ /> mute_videos="No";
  65. </ label= divider, help=" ", options = " ", order=orderx++ /> paramxx3 = " "
  66.  
  67. </ label="Show game box art", help="Shows the current game box art if available", options="Yes,No", order=orderx++ /> enable_gboxart="Yes";
  68. </ label="Show game cart art", help="Shows the current game cart art if available", options="Yes,No", order=orderx++ /> enable_gcartart="Yes";
  69. </ label= divider, help=" ", options = " ", order=orderx++ /> paramxx4 = " "
  70.  
  71. </ label="Show game information", help="Show game info", options="No,Info,Info and Enumerate", order=orderx++ /> enable_gameinfo="Info and Enumerate";
  72. </ label="Game name", help="Show game title only or manufacturer and game title. If there is no manufacturer name in the romlist, only the game title will be shown.",
  73. options="Title Only,Manufacturer and Title", order=orderx++ /> enable_game_manu="Title Only";
  74. </ label="Enable random text colors", help="Enable game info random text colors", options="Yes,No", order=orderx++ /> enable_colors="No";
  75. </ label="Enable text frame", help="Show frame to make game info text standout ", options="Yes,No", order=orderx++ /> enable_frame="Yes";
  76. </ label= divider, help=" ", options = " ", order=orderx++ /> paramxx5 = " "
  77.  
  78. </ label="Mark favourite games", help="Mark favourite games with an icon to the left of the wheel logo or at the bottom with the game info", options="No,Left of Wheel,With Game Info", order=orderx++ /> enable_favstar="With Game Info";
  79. </ label= divider, help=" ", options = " ", order=orderx++ /> paramxx6= " "
  80.  
  81. </ label="Search key", help="Choose the key to initiate a search", options="Custom1,Custom2,Custom3,Custom4,Custom5,Custom6", order=orderx++ /> user_search_key="Custom1";
  82. </ label="Search box size", help="Choose size of the search box", options="Small,Large", order=orderx++ /> user_search_boxsize="Small";
  83. </ label= divider, help=" ", options = " ", order=orderx++ /> paramxx7 = " "
  84. }
  85.  
  86.  
  87. local my_config = fe.get_config();
  88. fe.layout.font="SF Atarian System";
  89.  
  90.  
  91. // modules
  92. fe.load_module( "animate" );
  93. fe.load_module( "fade" );
  94. fe.load_module("file");
  95. fe.load_module("file-format");
  96. fe.load_module("gtc");
  97. fe.load_module("gtc-kb");
  98. fe.load_module("gtc-pas");
  99.  
  100. local ini_anim_time;
  101. try { ini_anim_time = my_config["ini_anim_trans_ms"].tointeger(); } catch ( e ) { }
  102.  
  103. // initialize wheel delay time
  104. my_delay <- 0;
  105. try {my_delay = my_config["set_ms_delay"].tointeger();} catch(e) {}
  106. my_play <- my_delay;
  107.  
  108. // Letters ini
  109. local rtime = 0;
  110. local glob_time = 0;
  111. local glob_delay;
  112. try { glob_delay = my_config["set_ms_delay"].tointeger(); } catch ( e ) { }
  113. if ( glob_delay > 750 )
  114. glob_delay = 750;
  115.  
  116. //coordinates table for different screen aspects -- Start
  117. local settings = {
  118. "default": {
  119. //16x9 is default
  120. aspectDepend = {
  121. res_x = 2133,
  122. res_y = 1200,
  123. maskFactor = 1.9}
  124. },
  125. "16x10": {
  126. aspectDepend = {
  127. res_x = 1920,
  128. res_y = 1200,
  129. maskFactor = 1.9}
  130. },
  131. "16x9": {
  132. aspectDepend = {
  133. res_x = 1920,
  134. res_y = 1080,
  135. maskFactor = 1.9}
  136. },
  137. "4x3": {
  138. aspectDepend = {
  139. res_x = 1600,
  140. res_y = 1200,
  141. maskFactor = 1.6}
  142. }
  143. "5x4": {
  144. aspectDepend = {
  145. res_x = 1500,
  146. res_y = 1200,
  147. maskFactor = 1.6}
  148. }
  149. }
  150.  
  151. local aspect = fe.layout.width / fe.layout.height.tofloat();
  152. local aspect_name = "";
  153. switch( aspect.tostring() )
  154. {
  155. case "1.77865": //for 1366x768 screen
  156. case "1.77778": //for any other 16x9 resolution
  157. aspect_name = "16x9";
  158. break;
  159. case "1.6":
  160. aspect_name = "16x10";
  161. break;
  162. case "1.33333":
  163. aspect_name = "4x3";
  164. break;
  165. case "1.25":
  166. aspect_name = "5x4";
  167. break;
  168. case "0.75":
  169. aspect_name = "3x4";
  170. break;
  171. }
  172. print("Attract-Mode Version: " + FeVersion + "\n" + "Screen aspect ratio: "+aspect_name+"\n" + "Resolution: "+ScreenWidth+"x"+ScreenHeight+"\n" + "Shader GLSL available: "+ShadersAvailable+"\n" + "OS: "+OS+"\n");
  173.  
  174. function Setting( id, name )
  175. {
  176. if ( aspect_name in settings && id in settings[aspect_name] && name in settings[aspect_name][id] )
  177. {
  178. ::print("\tusing settings[" + aspect_name + "][" + id + "][" + name + "] : " + settings[aspect_name][id][name] + "\n" );
  179. return settings[aspect_name][id][name];
  180. } else if ( aspect_name in settings == false )
  181. {
  182. ::print("\tsettings[" + aspect_name + "] does not exist\n");
  183. } else if ( name in settings[aspect_name][id] == false )
  184. {
  185. ::print("\tsettings[" + aspect_name + "][" + id + "][" + name + "] does not exist\n");
  186. }
  187. ::print("\t\tusing default value: " + settings["default"][id][name] + "\n" );
  188. return settings["default"][id][name];
  189. }
  190.  
  191. fe.layout.width = Setting("aspectDepend", "res_x");
  192. fe.layout.height = Setting("aspectDepend", "res_y");
  193.  
  194. local flx = fe.layout.width;
  195. local fly = fe.layout.height;
  196. local flw = fe.layout.width;
  197. local flh = fe.layout.height;
  198.  
  199. local mask_factor = Setting("aspectDepend", "maskFactor");
  200.  
  201. //coordinates table for different screen aspects -- End
  202.  
  203.  
  204. /////////////////////////////////////////////////////////////////////////////////
  205. // load background art
  206. local bg = FadeArt( "bkg", 0, 0, flw, flh );
  207. bg.zorder = -15;
  208.  
  209. //scanline effect overlay for background art
  210. local bg_scanline;
  211. if ( my_config["enable_scanline"] != "None" )
  212. {
  213. local scanlines = FeConfigDirectory+"gtc-common/art/scanlines_1920.png"
  214. if (ScreenWidth < 1920)
  215. scanlines = FeConfigDirectory+"gtc-common/art/scanlines_720.png"
  216.  
  217. bg_scanline = fe.add_image( scanlines, 0, 0, flw, flh );
  218. bg_scanline.preserve_aspect_ratio = false;
  219.  
  220. if ( my_config["enable_scanline"] == "Light" )
  221. bg_scanline.alpha = 30;
  222. else if ( my_config["enable_scanline"] == "Medium" )
  223. bg_scanline.alpha = 80;
  224. else if ( my_config["enable_scanline"] == "Dark" )
  225. bg_scanline.alpha = 150;
  226.  
  227. bg_scanline.zorder = -14;
  228. }
  229.  
  230.  
  231. /////////////////////////////////////////////////////////////////////////////////
  232. // Video snap and static
  233.  
  234. // static effect if no snap video available
  235. local snapbg = fe.add_image(FeConfigDirectory+"gtc-common/videos/static.mp4", flx*0.057, fly*0.22, flw*0.3, flh*0.4);
  236. snapbg.zorder = -13;
  237.  
  238. if ( my_config["enable_ini_anim"] == "Yes" )
  239. {
  240. // animate static effect entry when layout starts
  241. local move_transition1 = {when = Transition.StartLayout, property = "x", start = flx*-1.36, end = flx*0.057, tween = "cubic", time = ini_anim_time}
  242. animation.add( PropertyAnimation( snapbg, move_transition1 ) );
  243. }
  244.  
  245. // add current game snap video
  246. local snap = fe.add_artwork("snap", flx*0.057, fly*0.22, flw*0.3, flh*0.4);
  247. snap.trigger = Transition.EndNavigation;
  248. snap.preserve_aspect_ratio = false;
  249. snap.zorder = -12;
  250.  
  251. if ( my_config["mute_videos"] == "Yes" )
  252. snap.video_flags = Vid.NoAudio;
  253.  
  254. if ( my_config["enable_ini_anim"] == "Yes" )
  255. {
  256. // animate snap entry when layout starts
  257. local move_transition1 = {when = Transition.StartLayout, property = "x", start = flx*-1.36, end = flx*0.057, tween = "cubic", time = ini_anim_time}
  258. animation.add( PropertyAnimation( snap, move_transition1 ) );
  259. }
  260.  
  261. // bloom shader
  262. if ( my_config["enable_bloom"] == "Yes" && ShadersAvailable == 1)
  263. {
  264. local sh = fe.add_shader( Shader.Fragment, "bloom_shader.frag" );
  265. sh.set_texture_param("bgl_RenderedTexture");
  266. snap.shader = sh;
  267. }
  268.  
  269.  
  270. /////////////////////////////////////////////////////////////////////////////////
  271. // crt scanline
  272. local scanline;
  273. if ( my_config["enable_crt_scanline"] != "None" )
  274. {
  275. local scanlines = FeConfigDirectory+"gtc-common/art/scanlines_1920.png"
  276. if (ScreenWidth < 1920)
  277. scanlines = FeConfigDirectory+"gtc-common/art/scanlines_640.png"
  278.  
  279. scanline = fe.add_image( scanlines, flx*0.057, fly*0.22, flw*0.3, flh*0.5 );
  280. scanline.preserve_aspect_ratio = false;
  281.  
  282. if ( my_config["enable_crt_scanline"] == "Light" )
  283. scanline.alpha = 30;
  284. else if ( my_config["enable_crt_scanline"] == "Medium" )
  285. scanline.alpha = 60;
  286. else if ( my_config["enable_crt_scanline"] == "Dark" )
  287. scanline.alpha = 150;
  288.  
  289. scanline.zorder = -11;
  290.  
  291. if ( my_config["enable_ini_anim"] == "Yes" )
  292. {
  293. // animate crt scanline when layout starts
  294. local move_transition1 = {when = Transition.StartLayout, property = "x", start = flx*-1.36, end = flx*0.057, tween = "cubic",time = ini_anim_time}
  295. animation.add( PropertyAnimation( scanline, move_transition1 ) );
  296. }
  297. }
  298.  
  299.  
  300. /////////////////////////////////////////////////////////////////////////////////
  301. // art images
  302. local logo_y = fly*-1.5;
  303. local space_inv_x = flx*1.1;
  304. if ( my_config["enable_ini_anim"] == "No" )
  305. {
  306. logo_y = 0;
  307. space_inv_x = 0;
  308. }
  309.  
  310. local tv = fe.add_image( "tv.png", 0, 0, flw, flh );
  311. tv.zorder = -10;
  312. if ( my_config["enable_ini_anim"] == "Yes" )
  313. {
  314. local move_transition1 = {when = Transition.StartLayout, property = "x", start = flx*-1.45, end = flx*0.0, tween = "cubic", time = ini_anim_time}
  315. animation.add( PropertyAnimation( tv, move_transition1 ) );
  316. }
  317.  
  318. if ( my_config["enable_ini_anim"] == "Yes" )
  319. {
  320. local space_invader = PanAndScanImage( "space_invader.png", 0, 0, flw, flh);
  321. space_invader.trigger = Transition.EndNavigation;
  322. space_invader.preserve_aspect_ratio = false;
  323. space_invader.set_fit_or_fill("fill");
  324. space_invader.set_anchor(::Anchor.Left);
  325. space_invader.set_zoom(0, 0);
  326. space_invader.set_animate(::AnimateType.HorizBounce, 1, 1)
  327. space_invader.set_randomize_on_transition(false);
  328. space_invader.set_start_scale(1.0);
  329. space_invader.zorder = -9;
  330.  
  331. local move_transition1 = {
  332. when = Transition.StartLayout,
  333. property = "x",
  334. start = flx*1.5,
  335. end = flx*0.0,
  336. tween = "quart",
  337. time = ini_anim_time
  338. }
  339. animation.add( PropertyAnimation( space_invader, move_transition1 ) );
  340. }
  341. else
  342. {
  343. local space_invader = fe.add_image( "space_invader.png", 0, 0, flw, flh );
  344. space_invader.zorder = -9;
  345. }
  346.  
  347. local logo = fe.add_image( "logo.png", 0, logo_y, flw, flh );
  348. logo.zorder = -8;
  349. if ( my_config["enable_ini_anim"] == "Yes" )
  350. {
  351. local start_transition1 = {when = Transition.StartLayout, property = "y", start = fly*-2, end = fly*0, tween = "circle", time = ini_anim_time+800}
  352. animation.add( PropertyAnimation( logo, start_transition1 ) );
  353. }
  354.  
  355. local console = fe.add_image( "console.png", 0, 0, flw, flh );
  356. console.zorder = -7;
  357. if ( my_config["enable_ini_anim"] == "Yes" )
  358. {
  359. local move_transition1 = {when = Transition.StartLayout, property = "y", start = fly*1, end = fly*0, tween = "cubic", time = ini_anim_time}
  360. animation.add( PropertyAnimation( console, move_transition1 ) );
  361. }
  362.  
  363.  
  364. //////////////////////////////////////////////////////////////////////////////////////////////////
  365. //Cartart
  366. if ( my_config["enable_gcartart"] == "Yes" )
  367. {
  368. local x = 0.322;
  369. local y = 0.57;
  370. local w = 0.12;
  371. local h = 0.18;
  372.  
  373. if (aspect_name == "16x10")
  374. {
  375. x = 0.327;
  376. y = 0.57;
  377. w = 0.11
  378. h = 0.17
  379. }
  380.  
  381. local cartart = fe.add_artwork("cartart", flx*x, fly*-2.1, flw*w, flh*h );
  382. cartart.trigger = Transition.EndNavigation;
  383. cartart.preserve_aspect_ratio = true;
  384. cartart.mipmap = true;
  385.  
  386. local start_transition1 = {when = Transition.StartLayout, property = "y", start = fly*-2.1, end = fly*y, tween = "cubic", delay = ini_anim_time*0.5, time = ini_anim_time+500}
  387. animation.add( PropertyAnimation( cartart, start_transition1 ) );
  388.  
  389. function cartart_transition( ttype, var, ttime )
  390. {
  391. if ( ttype == Transition.EndNavigation )
  392. cartart.alpha = 255;
  393.  
  394. if ( ttype == Transition.ToNewSelection )
  395. cartart.alpha = 0;
  396.  
  397. return false;
  398. }
  399. fe.add_transition_callback( "cartart_transition" );
  400.  
  401. local move_transition1 = {when = Transition.EndNavigation, property = "y", start = fly*-2.1, end = fly*y, tween = "cubic", time = ini_anim_time+500}
  402. animation.add( PropertyAnimation( cartart, move_transition1 ) );
  403. }
  404.  
  405.  
  406. //////////////////////////////////////////////////////////////////////////////////////////////////
  407. // console cover
  408. local console_cover = fe.add_image( "console_cover.png", 0, 0, flw, flh );
  409. if ( my_config["enable_ini_anim"] == "Yes" )
  410. {
  411. // animate console_cover image when layout starts
  412. local move_transition1 = {when = Transition.StartLayout, property = "y", start = fly*1, end = fly*0, tween = "cubic", time = ini_anim_time}
  413. animation.add( PropertyAnimation( console_cover, move_transition1 ) );
  414. }
  415.  
  416.  
  417. /////////////////////////////////////////////////////////////////////////////////
  418. // wheel background
  419. local wheel_art;
  420. local wheel_art_alpha=255;
  421. if ( my_config["enable_wl_bg"] == "Yes" )
  422. {
  423. // Large is default
  424. local round_x = 0;
  425. local round_w = flw;
  426. local vertical_x = flx*0.1;
  427. local vertical_w = flw*0.8;
  428.  
  429. if ( my_config["wheel_poisition"] == "Adjust Right" )
  430. {
  431. if ( my_config["wheel_logo_size"] == "Larger" )
  432. {
  433. round_x = flx*0.05;
  434. vertical_x = flx*0.17;
  435. }
  436. else //smaller
  437. {
  438. round_x = flx*0.27;
  439. round_w = flw*0.75;
  440. vertical_x = flx*0.23;
  441. vertical_w = flw*0.71;
  442. }
  443. }
  444. if ( my_config["wheel_poisition"] == "Adjust Left" )
  445. {
  446. if ( my_config["wheel_logo_size"] == "Larger" )
  447. {
  448. round_x = flx*0;
  449. vertical_x = flx*0.13;
  450. }
  451. else //smaller
  452. {
  453. round_x = flx*0.2;
  454. round_w = flw*0.77;
  455. vertical_x = flx*0.2;
  456. vertical_w = flw*0.7;
  457. }
  458. }
  459.  
  460. if ( my_config["wheel_type"] == "Round" )
  461. wheel_art = fe.add_image( FeConfigDirectory+"gtc-common/art/wheel_art.png", round_x, 0, round_w, flh );
  462. else
  463. wheel_art = fe.add_image( FeConfigDirectory+"gtc-common/art/wheel_vert.png", vertical_x, 0, vertical_w, flh );
  464. }
  465.  
  466.  
  467. /////////////////////////////////////////////////////////////////////////////////
  468. // Pointers
  469. local pointer;
  470.  
  471. if ( my_config["enable_pointer"] == "Yes")
  472. {
  473. local start_x = 0.91;
  474. local end_x = 0.87;
  475.  
  476. if ( my_config["wheel_poisition"] == "Adjust Right" )
  477. {
  478. start_x = 0.915;
  479. end_x = 0.89;
  480. }
  481.  
  482. pointer = fe.add_image("pointers/default.png", flx*start_x, fly*0.34, flw*0.2, flh*0.35);
  483. pointer.preserve_aspect_ratio = true;
  484.  
  485. local movex_cfg = { when = Transition.ToNewSelection, property = "x", start = flx*end_x, end = pointer.x, time = 200 }
  486. animation.add( PropertyAnimation( pointer, movex_cfg ) );
  487. }
  488.  
  489.  
  490. /////////////////////////////////////////////////////////////////////////////////
  491. // Wheels
  492. fe.load_module( "conveyor" );
  493.  
  494. local wheel_count;
  495. try { wheel_count = my_config["wheels"].tointeger(); } catch ( e ) { }
  496.  
  497. local _partially = 30;
  498. local _alpha;
  499. local wheel_x;
  500. local wheel_y;
  501. local wheel_w;
  502. local wheel_a;
  503. local wheel_h;
  504. local wheel_r;
  505. local num_arts;
  506.  
  507. // Round wheel
  508. if ( my_config["wheel_type"] == "Round" )
  509. {
  510. if ( my_config["wheel_poisition"] == "Adjust Left" )
  511. {
  512. if ( my_config["wheel_logo_size"] == "Larger" )
  513. wheel_x = [ flx*0.80, flx*0.795, flx*0.756, flx*0.725, flx*0.70, flx*0.68, flx*0.63, flx*0.68, flx*0.70, flx*0.725, flx*0.756, flx*0.76, ];
  514. else //smaller
  515. wheel_x = [ flx*0.85, flx*0.850, flx*0.801, flx*0.775, flx*0.75, flx*0.73, flx*0.68, flx*0.73, flx*0.75, flx*0.775, flx*0.8006, flx*0.81, ];
  516. }
  517. else //adjust right
  518. {
  519. if ( my_config["wheel_logo_size"] == "Larger" )
  520. wheel_x = [ flx*0.85, flx*0.845, flx*0.806, flx*0.775, flx*0.75, flx*0.730, flx*0.68, flx*0.73, flx*0.75, flx*0.775, flx*0.806, flx*0.81, ];
  521. else //smaller
  522. wheel_x = [ flx*0.90, flx*0.895, flx*0.856, flx*0.825, flx*0.80, flx*0.780, flx*0.73, flx*0.78, flx*0.80, flx*0.825, flx*0.856, flx*0.86, ];
  523. }
  524. wheel_y = [ -fly*0.22, -fly*0.105, fly*0.0, fly*0.105, fly*0.215, fly*0.325, fly*0.436, fly*0.61, fly*0.72 fly*0.83, fly*0.935, fly*0.99, ];
  525. if ( my_config["wheel_logo_size"] == "Larger" )
  526. wheel_w = [ flw*0.18, flw*0.18, flw*0.18, flw*0.18, flw*0.18, flw*0.18, flw*0.28, flw*0.18, flw*0.18, flw*0.18, flw*0.18, flw*0.18, ];
  527. else //smaller
  528. wheel_w = [ flw*0.12, flw*0.12, flw*0.12, flw*0.12, flw*0.12, flw*0.12, flw*0.19, flw*0.12, flw*0.12, flw*0.12, flw*0.12, flw*0.12, ];
  529. if ( my_config["wheel_semi_t"] == "Yes" )
  530. wheel_a = [ 80, 80, 80, 80, 80, 80, 255, 80, 80, 80, 80, 80, ];
  531. else
  532. wheel_a = [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, ];
  533. wheel_h = [ flh*0.11, flh*0.11, flh*0.11, flh*0.11, flh*0.11, flh*0.11, flh*0.168, flh*0.11, flh*0.11, flh*0.11, flh*0.11, flh*0.11, ];
  534. wheel_r = [ 30, 25, 20, 15, 10, 5, 0, -10, -15, -20, -25, -30, ];
  535. }
  536. else // Vertical wheel
  537. {
  538. if ( my_config["wheel_poisition"] == "Adjust Left" )
  539. {
  540. if ( my_config["wheel_logo_size"] == "Larger" )
  541. wheel_x = [ flx*0.72, flx*0.72, flx*0.72, flx*0.72, flx*0.72, flx*0.72, flx*0.685, flx*0.72, flx*0.72, flx*0.72, flx*0.72, flx*0.72, ];
  542. else //smaller
  543. wheel_x = [ flx*0.74, flx*0.74, flx*0.74, flx*0.74, flx*0.74, flx*0.74, flx*0.70, flx*0.74, flx*0.74, flx*0.74, flx*0.74, flx*0.74, ];
  544. }
  545. else //adjust right
  546. {
  547. if ( my_config["wheel_logo_size"] == "Larger" )
  548. wheel_x = [ flx*0.76, flx*0.76, flx*0.76, flx*0.76, flx*0.76, flx*0.76, flx*0.725, flx*0.76, flx*0.76, flx*0.76, flx*0.76, flx*0.76, ];
  549. else //smaller
  550. wheel_x = [ flx*0.78, flx*0.78, flx*0.78, flx*0.78, flx*0.78, flx*0.78, flx*0.74, flx*0.78, flx*0.78, flx*0.78, flx*0.78, flx*0.78, ];
  551. }
  552. wheel_y = [ -fly*0.22, -fly*0.105, fly*0.0, fly*0.105, fly*0.215, fly*0.325, fly*0.436, fly*0.61, fly*0.72 fly*0.83, fly*0.935, fly*0.99, ];
  553. if ( my_config["wheel_logo_size"] == "Larger" )
  554. wheel_w = [ flw*0.18, flw*0.18, flw*0.18, flw*0.18, flw*0.18, flw*0.18, flw*0.25, flw*0.18, flw*0.18, flw*0.18, flw*0.18, flw*0.18, ];
  555. else //smaller
  556. wheel_w = [ flw*0.12, flw*0.12, flw*0.12, flw*0.12, flw*0.12, flw*0.12, flw*0.19, flw*0.12, flw*0.12, flw*0.12, flw*0.12, flw*0.12, ];
  557.  
  558. if ( my_config["wheel_semi_t"] == "Yes" )
  559. wheel_a = [ 80, 80, 80, 80, 150, 150, 255, 150, 150, 80, 80, 80, ];
  560. else
  561. wheel_a = [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, ];
  562. wheel_h = [ flh*0.11, flh*0.11, flh*0.11, flh*0.11, flh*0.11, flh*0.11, flh*0.15, flh*0.11, flh*0.11, flh*0.11, flh*0.11, flh*0.11, ];
  563. wheel_r = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ];
  564. }
  565. num_arts = wheel_count;
  566.  
  567. class WheelEntry extends ConveyorSlot
  568. {
  569. constructor()
  570. {
  571. base.constructor( ::fe.add_artwork( "wheel" ) );
  572. }
  573.  
  574. function on_progress( progress, var )
  575. {
  576. local p = progress / 0.1;
  577. local slot = p.tointeger();
  578. p -= slot;
  579.  
  580. slot++;
  581.  
  582. if ( slot < 0 ) slot=0;
  583. if ( slot >=10 ) slot=10;
  584.  
  585. m_obj.x = wheel_x[slot] + p * ( wheel_x[slot+1] - wheel_x[slot] );
  586. m_obj.y = wheel_y[slot] + p * ( wheel_y[slot+1] - wheel_y[slot] );
  587. m_obj.width = wheel_w[slot] + p * ( wheel_w[slot+1] - wheel_w[slot] );
  588. m_obj.height = wheel_h[slot] + p * ( wheel_h[slot+1] - wheel_h[slot] );
  589. m_obj.rotation = wheel_r[slot] + p * ( wheel_r[slot+1] - wheel_r[slot] );
  590. m_obj.alpha = wheel_a[slot] + p * ( wheel_a[slot+1] - wheel_a[slot] );
  591. if ( my_config["wheel_logo_mipmap"] == "Yes" )
  592. m_obj.mipmap = true;
  593. if ( my_config["wheel_logo_aspect"] == "Yes" )
  594. m_obj.preserve_aspect_ratio=true;
  595. }
  596. };
  597.  
  598. local wheel_entries = [];
  599. for ( local i=0; i<num_arts/2; i++ )
  600. wheel_entries.push( WheelEntry() );
  601.  
  602. local remaining = num_arts - wheel_entries.len();
  603.  
  604. // we do it this way so that the last wheelentry created is the middle one showing the current
  605. // selection (putting it at the top of the draw order)
  606. for ( local i=0; i<remaining; i++ )
  607. wheel_entries.insert( num_arts/2, WheelEntry() );
  608.  
  609. local conveyor = Conveyor();
  610. conveyor.set_slots( wheel_entries );
  611. try { conveyor.transition_ms = my_config["transition_ms"].tointeger(); } catch ( e ) { }
  612.  
  613.  
  614. // Favourite games marker
  615. function FavStar()
  616. {
  617. if (fe.game_info( Info.Favourite ) == "1") return FeConfigDirectory+"gtc-common/art/fav.png";
  618. }
  619.  
  620. local favourite_marker;
  621. if ( my_config["enable_favstar"] == "Left of Wheel" )
  622. {
  623. local x;
  624. local y;
  625. local wh;
  626.  
  627. if (conveyor.m_objs.len() > 0)
  628. {
  629. local art = wheel_entries[conveyor.m_objs.len()/2].m_obj;
  630. x = art.x-(flw*0.042);
  631. y = art.y+(flh*0.038);
  632. wh = flw*0.04;
  633. }
  634.  
  635. favourite_marker = fe.add_image("[!FavStar]",x, y, wh, wh );
  636.  
  637. if ( my_config["wheel_logo_mipmap"] == "Yes" )
  638. favourite_marker.mipmap = true;
  639. }
  640.  
  641. //Wheel fading code starts here
  642. if ( my_config["wheel_fadeout"] != "No" )
  643. {
  644. first_tick <- 0;
  645. stop_fading <- true;
  646. wheel_fade_ms <- 0;
  647. try { wheel_fade_ms = my_config["wheel_fade_ms"].tointeger(); } catch ( e ) { }
  648.  
  649. if ( wheel_fade_ms > 0 )
  650. {
  651. function wheel_fade_transition( ttype, var, ttime )
  652. {
  653. if ( ttype == Transition.ToNewSelection || ttype == Transition.ToNewList )
  654. {
  655. first_tick = -1;
  656. my_delay = fe.layout.time;
  657. if ( my_config["enable_pointer"] != "No")
  658. pointer.alpha = 255;
  659. if (my_config["enable_wl_bg"] != "No")
  660. wheel_art.alpha = wheel_art_alpha;
  661. if ( my_config["enable_favstar"] != "No" )
  662. {
  663. if (fe.game_info( Info.Favourite, var ) == "1")
  664. favourite_marker.alpha = 255;
  665. }
  666. }
  667. return false;
  668. }
  669. fe.add_transition_callback( "wheel_fade_transition" );
  670.  
  671. function wheel_alpha( ttime )
  672. {
  673. local _elapsed = 0;
  674.  
  675. if (first_tick == -1)
  676. stop_fading = false;
  677.  
  678. // handle wheel alpha after keyboard search
  679. if (first_tick > 0)
  680. _elapsed = ttime - first_tick;
  681.  
  682. if (_elapsed < wheel_fade_ms)
  683. {
  684. local count = conveyor.m_objs.len();
  685.  
  686. for (local i=0; i < count; i++)
  687. {
  688. if (i == count/2)
  689. conveyor.m_objs[i].alpha = 255;
  690. else
  691. {
  692. if ( my_config["wheel_semi_t"] == "Yes" )
  693. conveyor.m_objs[i].alpha = 80;
  694. else
  695. conveyor.m_objs[i].alpha = 255;
  696. }
  697. }
  698. }
  699.  
  700. // Wheel fading
  701. if ( !stop_fading && ttime - my_delay >= my_play )
  702. {
  703. local elapsed = 0;
  704.  
  705. if (first_tick > 0)
  706. elapsed = ttime - first_tick;
  707.  
  708. local count = conveyor.m_objs.len();
  709.  
  710. for (local i=0; i < count; i++)
  711. {
  712. if ( elapsed > wheel_fade_ms)
  713. {
  714. if ( my_config["wheel_fadeout"] == "Partially" )
  715. conveyor.m_objs[i].alpha = _partially;
  716. else
  717. conveyor.m_objs[i].alpha = 0;
  718. }
  719. else
  720. {
  721. if (i == count/2)
  722. {
  723. _alpha = (255 * (wheel_fade_ms - elapsed)) / wheel_fade_ms;
  724. if (_alpha < _partially && my_config["wheel_fadeout"] == "Partially")
  725. _alpha = _partially;
  726. conveyor.m_objs[i].alpha = _alpha;
  727. }
  728. else
  729. {
  730. local _start_alpha = 79;
  731. if ( my_config["wheel_semi_t"] == "No" )
  732. _start_alpha = 254;
  733. _alpha = (_start_alpha * (wheel_fade_ms - elapsed)) / wheel_fade_ms;
  734. if (_alpha < _partially && my_config["wheel_fadeout"] == "Partially")
  735. _alpha = _partially;
  736. conveyor.m_objs[i].alpha = _alpha;
  737. }
  738.  
  739. if ( my_config["enable_pointer"] != "No")
  740. {
  741. _alpha = (255 * (wheel_fade_ms - elapsed)) / wheel_fade_ms;
  742. if (_alpha < _partially && my_config["wheel_fadeout"] == "Partially")
  743. _alpha = _partially;
  744. pointer.alpha = _alpha;
  745. }
  746.  
  747. if (my_config["enable_wl_bg"] != "No")
  748. {
  749. _alpha = (wheel_art_alpha * (wheel_fade_ms - elapsed)) / wheel_fade_ms;
  750. if (_alpha < _partially && my_config["wheel_fadeout"] == "Partially")
  751. _alpha = _partially;
  752. wheel_art.alpha = _alpha;
  753. }
  754.  
  755. if ( my_config["enable_favstar"] == "Left of Wheel" )
  756. {
  757. _alpha = (255 * (wheel_fade_ms - elapsed)) / wheel_fade_ms;
  758. if (_alpha < _partially && my_config["wheel_fadeout"] == "Partially")
  759. _alpha = _partially;
  760. favourite_marker.alpha = _alpha;
  761. }
  762. }
  763. }
  764.  
  765. if ( elapsed > wheel_fade_ms)
  766. {
  767. //So we don't keep doing the loop above when all values have 0 alpha
  768. stop_fading = true;
  769. }
  770.  
  771. if (first_tick == -1)
  772. first_tick = ttime;
  773. }
  774. }
  775. fe.add_ticks_callback( "wheel_alpha" );
  776. }
  777. }
  778.  
  779. // pulse current wheel logo
  780. if( my_config["wheel_pulse"] != "No" )
  781. {
  782. local _loop = false;
  783. if( my_config["wheel_pulse"] == "Loop")
  784. _loop = true;
  785.  
  786. local art = wheel_entries[wheel_count/2].m_obj;
  787. local art_pulse = fe.add_artwork( "wheel", art.x,art.y,art.width,art.height );
  788. art.zorder = 1
  789. if( my_config["wheel_logo_aspect"] == "Yes" )
  790. art_pulse.preserve_aspect_ratio = true;
  791.  
  792. local _time = 3000;
  793.  
  794. local art_scale = { when = Transition.StartLayout, property = "scale", start = 1.0, end = 1.2, time = _time, loop = _loop }
  795. local alpha_cfg = { when = Transition.StartLayout, property = "alpha", start = 150, end = 0, time = _time, loop = _loop }
  796. animation.add( PropertyAnimation( art_pulse, art_scale ) );
  797. animation.add( PropertyAnimation( art_pulse, alpha_cfg ) );
  798.  
  799. function pulse_transition( ttype, var, ttime )
  800. {
  801. if( ttype == Transition.ToNewSelection )
  802. {
  803. // turn off StartLayout pulse animation when ToNewSelection begins
  804. if( alpha_cfg.loop == true )
  805. {
  806. alpha_cfg.start = 0;
  807. alpha_cfg.loop = false;
  808. art_scale.loop = false;
  809. }
  810. art_pulse.alpha = 0;
  811. }
  812. return false;
  813. }
  814. fe.add_transition_callback( "pulse_transition" );
  815.  
  816. local art_scale2 = { when = Transition.ToNewSelection, property = "scale", start = 1.0, end = 1.2, time = _time, loop = _loop }
  817. local alpha_cfg2 = { when = Transition.ToNewSelection, property = "alpha", start = 150, end = 0, time = _time, loop = _loop }
  818. animation.add( PropertyAnimation( art_pulse, art_scale2 ) );
  819. animation.add( PropertyAnimation( art_pulse, alpha_cfg2 ) );
  820.  
  821. function stop_pulse( ttime )
  822. {
  823. // if there is fadeout, pulse once only
  824. if( conveyor.m_objs[wheel_count/2].m_obj.alpha == 0 || conveyor.m_objs[wheel_count/2].m_obj.alpha == _partially )
  825. {
  826. alpha_cfg.loop = false;
  827. alpha_cfg2.loop = false;
  828. }
  829. else // if no fadeout pulse loop
  830. {
  831. alpha_cfg.loop = true;
  832. alpha_cfg2.loop = true;
  833.  
  834. if( my_config["wheel_pulse"] == "Once" )
  835. {
  836. alpha_cfg.loop = false;
  837. alpha_cfg2.loop = false;
  838. }
  839. }
  840. }
  841. fe.add_ticks_callback( "stop_pulse" );
  842. }
  843.  
  844.  
  845. /////////////////////////////////////////////////////////////////////////////////
  846. // Play sound when transitioning to next / previous game on wheel
  847. //
  848. // Use an array that is loaded outside and only updated inside the transition_callback function
  849. // in order to prevent a memory leak by calling fe.add_sound() within that function
  850.  
  851. local random_num;
  852. local sound_name="";
  853. local Wheelclick = [];
  854. local i;
  855. for ( i=0; i<20; i++)
  856. Wheelclick.push(fe.add_sound(sound_name));
  857.  
  858. local sid = 0;
  859.  
  860. function sound_transitions(ttype, var, ttime)
  861. {
  862. if (my_config["enable_random_sound"] != "No")
  863. {
  864. if (my_config["enable_random_sound"] == "Random")
  865. {
  866. random_num = floor(((rand() % 1000 ) / 1000.0) * (322 - (1 - 1)) + 1);
  867. sound_name = FeConfigDirectory+"gtc-common/sounds/GS"+random_num+".mp3";
  868. }
  869.  
  870. if (my_config["enable_random_sound"] == "Click")
  871. sound_name = FeConfigDirectory+"gtc-common/sounds/click.mp3";
  872.  
  873. switch(ttype)
  874. {
  875. case Transition.StartLayout:
  876. case Transition.EndNavigation:
  877. sid++; // next cell in the array
  878. if (sid > 19) //if reached end of the array go to the beginning
  879. sid = 0;
  880. Wheelclick[sid].file_name = sound_name;
  881. Wheelclick[sid].playing = true;
  882. break;
  883. }
  884. return false;
  885. }
  886. }
  887. fe.add_transition_callback("sound_transitions");
  888.  
  889.  
  890. /////////////////////////////////////////////////////////////////////////////////
  891. //Boxart - when wheel is visible and boxart is enabled
  892. if ( my_config["enable_gboxart"] == "Yes" )
  893. {
  894. // if whhel_fadeout != No
  895. local from_side = 2; //enter from left
  896. local y = 0.43;
  897. local x = 0.68;
  898. local w = 0.2;
  899. local h = 0.5;
  900.  
  901. if (my_config["wheel_fadeout"] == "No")
  902. {
  903. from_side = 2; //animate from right
  904. x = 0.463;
  905. y = 0.24;
  906. w = 0.17;
  907. h = 0.48;
  908.  
  909. if ( my_config["wheel_poisition"] == "Adjust Right" )
  910. {
  911. w = 0.18;
  912. y = 0.25;
  913. }
  914. }
  915.  
  916. local boxart = fe.add_artwork("boxart", flx*x, fly*y, flw*w, flh*h );
  917. boxart.trigger = Transition.EndNavigation;
  918. boxart.preserve_aspect_ratio = true;
  919.  
  920. if( my_config["wheel_fadeout"] == "No" )
  921. boxart.zorder = -8;
  922.  
  923. local start_transition1 = {when = Transition.StartLayout, property = "x", start = flx*from_side, end = flx*x, time = my_delay+200}
  924. animation.add( PropertyAnimation( boxart, start_transition1 ) );
  925.  
  926. function boxart_transition( ttype, var, ttime )
  927. {
  928. if ( ttype == Transition.EndNavigation )
  929. boxart.alpha = 255;
  930.  
  931. if ( ttype == Transition.ToNewSelection )
  932. boxart.alpha = 0;
  933.  
  934. return false;
  935. }
  936. fe.add_transition_callback( "boxart_transition" );
  937.  
  938. local move_transition1 = {when = Transition.EndNavigation, property = "x", start = flx*from_side, end = flx*x, time = my_delay+200}
  939. animation.add( PropertyAnimation( boxart, move_transition1 ) );
  940. }
  941.  
  942.  
  943. /////////////////////////////////////////////////////////////////////////////////
  944. // Game info background frame
  945. if ( my_config["enable_frame"] == "Yes" )
  946. {
  947. local frame = fe.add_image( FeConfigDirectory+"gtc-common/art/frame.png", 0, fly*0.94, flw, flh*0.06 );
  948. frame.alpha = 255;
  949.  
  950. if ( my_config["enable_ini_anim"] == "Yes" )
  951. {
  952. local start_transition1 = { when = Transition.StartLayout, property = "y", start = fly*2, end = fly*0.94, time = ini_anim_time }
  953. animation.add( PropertyAnimation( frame, start_transition1 ) );
  954. }
  955. }
  956.  
  957.  
  958. /////////////////////////////////////////////////////////////////////////////////
  959. // Favourite marker for "With Game Info" setting, separated from "Left to Wheel"
  960. // to avoid zorder issues
  961. if ( my_config["enable_favstar"] == "With Game Info" )
  962. {
  963. local x = flx*0.07;
  964. local y = fly*0.95;
  965. local wh = flw*0.022;
  966.  
  967. favourite_marker = fe.add_image("[!FavStar]",x, y, wh, wh );
  968. favourite_marker.mipmap = true;
  969.  
  970. if ( my_config["enable_ini_anim"] == "No" )
  971. {
  972. // fade in if startup animation is set to No
  973. local alpha_cfg = { when = Transition.StartLayout, property = "alpha", start = 0, end = 255, time = (ini_anim_time*2) }
  974. animation.add( PropertyAnimation( favourite_marker, alpha_cfg ) );
  975. }
  976. if ( my_config["enable_ini_anim"] == "Yes" )
  977. {
  978. // animate with game info
  979. local move_transition_year = { when = Transition.StartLayout, property = "x", start = flx*-2, end = x, time = (ini_anim_time+350) }
  980. animation.add( PropertyAnimation( favourite_marker, move_transition_year ) );
  981. }
  982. }
  983.  
  984.  
  985. /////////////////////////////////////////////////////////////////////////////////
  986. // Game info
  987. function Manufacturer_Name( ioffset )
  988. {
  989. local name = fe.game_info( Info.Manufacturer, ioffset );
  990. if (name.len() > 0)
  991. {
  992. name = split( name, "(" )[0]; // shorten the manufacturer name when one of the followig characters exist
  993. name = split( name, "[" )[0];
  994. name = split( name, "/" )[0];
  995. name = split( name, "," )[0];
  996. name = split( name, "?" )[0];
  997.  
  998. name = strip( name ); // remove white-space-only from the beginning or end of the manufacturer name
  999. }
  1000. return name;
  1001. }
  1002.  
  1003. if ( my_config["enable_gameinfo"] != "No" )
  1004. {
  1005. local year = "";
  1006. local year_b = ""; //black shadow
  1007. local title = "";
  1008. local title_b = ""; //black shadow
  1009. local filter = "";
  1010. local filter_b = ""; //black shadow
  1011. local x_year_b = flx*0.009;
  1012. local x_year = flx*0.01;
  1013. local x_title_b = flx*0.109;
  1014. local x_title = flx*0.11;
  1015. local x_filter_b = flx*0.589;
  1016. local x_filter = flx*0.59;
  1017. local font_size = flh*0.0325;
  1018.  
  1019.  
  1020. // Year
  1021. year_b = fe.add_text("[Year]", x_year_b, fly*0.916, flw*0.4, flh*0.1);
  1022. year = fe.add_text("[Year]", x_year, fly*0.916, flw*0.4, flh*0.1);
  1023.  
  1024. year_b.align = Align.Left;
  1025. year_b.charsize = font_size;
  1026. year_b.set_rgb(0, 0, 0);
  1027.  
  1028. year.align = Align.Left;
  1029. year.charsize = font_size;
  1030. year.set_rgb(255, 255, 255);
  1031.  
  1032. // Title
  1033. if ( my_config["enable_game_manu"] == "Title Only" )
  1034. {
  1035. title_b = fe.add_text("[Title]", x_title_b, fly*0.916, flw*0.6, flh*0.1);
  1036. title = fe.add_text("[Title]", x_title, fly*0.916, flw*0.6, flh*0.1);
  1037. }
  1038. else
  1039. {
  1040. function formatted_text()
  1041. {
  1042. local m = Manufacturer_Name(0);
  1043. local t = "[Title]";
  1044.  
  1045. if (( m.len() > 0 ) && ( t.len() > 0 ))
  1046. return m + ", " + t;
  1047.  
  1048. return t;
  1049. }
  1050. title_b = fe.add_text("[!formatted_text]", x_title_b, fly*0.916, flw*0.6, flh*0.1);
  1051. title = fe.add_text("[!formatted_text]", x_title, fly*0.916, flw*0.6, flh*0.1);
  1052. }
  1053. title_b.align = Align.Left;
  1054. title_b.charsize = font_size;
  1055. title_b.set_rgb(0, 0, 0);
  1056.  
  1057. title.align = Align.Left;
  1058. title.charsize = font_size;
  1059. title.set_rgb(255, 255, 255);
  1060.  
  1061. // enumerate game list
  1062. if ( my_config["enable_gameinfo"] == "Info and Enumerate" )
  1063. {
  1064. // Current game out of total number of games
  1065. filter_b = fe.add_text( "Game: [ListEntry]/[ListSize]", x_filter_b, fly*0.917, flw*0.4, flh*0.1 );
  1066. filter = fe.add_text( "Game: [ListEntry]/[ListSize]", x_filter, fly*0.917, flw*0.4, flh*0.1 );
  1067.  
  1068. filter_b.align = Align.Right;
  1069. filter_b.charsize = font_size-4;
  1070. filter_b.set_rgb(0, 0, 0);
  1071.  
  1072. filter.align = Align.Right;
  1073. filter.charsize = font_size-4;
  1074. filter.set_rgb(255, 255, 255);
  1075. }
  1076.  
  1077. // Random color for info text
  1078. if ( my_config["enable_colors"] == "Yes" )
  1079. {
  1080. function brightrand() {
  1081. return 255-(rand()/255);
  1082. }
  1083.  
  1084. local red, green, blue;
  1085.  
  1086. // Color Transitions
  1087. fe.add_transition_callback( "color_transitions" );
  1088. function color_transitions( ttype, var, ttime ) {
  1089. switch ( ttype )
  1090. {
  1091. case Transition.StartLayout:
  1092. case Transition.ToNewSelection:
  1093. red = brightrand();
  1094. green = brightrand();
  1095. blue = brightrand();
  1096. if(year!="")
  1097. year.set_rgb(red,green,blue);
  1098. if(title!="")
  1099. title.set_rgb(red,green,blue);
  1100. if(filter!="")
  1101. filter.set_rgb(red,green,blue);
  1102. break;
  1103. }
  1104. return false;
  1105. }
  1106. }
  1107.  
  1108. // fade in game info if the startup animation is disabled
  1109. if ( my_config["enable_ini_anim"] == "No" )
  1110. {
  1111. // fade in year
  1112. local alpha_cfg = {when = Transition.StartLayout, property = "alpha", start = 0, end = 255, time = (ini_anim_time*2)}
  1113. animation.add( PropertyAnimation( year, alpha_cfg ) );
  1114.  
  1115. local alpha_cfg = {when = Transition.StartLayout, property = "alpha", start = 0, end = 255, time = (ini_anim_time*2)}
  1116. animation.add( PropertyAnimation( year_b, alpha_cfg ) );
  1117.  
  1118. // fade in title
  1119. local alpha_cfg = {when = Transition.StartLayout, property = "alpha", start = 0, end = 255, time = (ini_anim_time*2)}
  1120. animation.add( PropertyAnimation( title, alpha_cfg ) );
  1121.  
  1122. local alpha_cfg = {when = Transition.StartLayout, property = "alpha", start = 0, end = 255, time = (ini_anim_time*2)}
  1123. animation.add( PropertyAnimation( title_b, alpha_cfg ) );
  1124.  
  1125. // fade in filter
  1126. if ( my_config["enable_gameinfo"] == "Info and Enumerate" )
  1127. {
  1128. // animate title
  1129. local alpha_cfg = {when = Transition.StartLayout, property = "alpha", start = 0, end = 255, time = (ini_anim_time*2)}
  1130. animation.add( PropertyAnimation( filter, alpha_cfg ) );
  1131.  
  1132. local alpha_cfg = {when = Transition.StartLayout, property = "alpha", start = 0, end = 255, time = (ini_anim_time*2)}
  1133. animation.add( PropertyAnimation( filter_b, alpha_cfg ) );
  1134. }
  1135. }
  1136.  
  1137. // animate game info
  1138. if ( my_config["enable_ini_anim"] == "Yes" )
  1139. {
  1140. // animate year
  1141. local move_transition_year = {when = Transition.StartLayout, property = "x", start = flx*-2, end = x_year, time = (ini_anim_time+350)}
  1142. animation.add( PropertyAnimation( year, move_transition_year ) );
  1143.  
  1144. local move_transition_year_b = {when = Transition.StartLayout, property = "x", start = flx*-2, end = x_year_b, time = (ini_anim_time+350)}
  1145. animation.add( PropertyAnimation( year_b, move_transition_year_b ) );
  1146.  
  1147. // animate title
  1148. local move_transition_title = {when = Transition.StartLayout, property = "x", start = flx*-2, end = x_title, time = (ini_anim_time+350)}
  1149. animation.add( PropertyAnimation( title, move_transition_title ) );
  1150.  
  1151. local move_transition_title_b = {when = Transition.StartLayout, property = "x", start = flx*-2, end = x_title_b, time = (ini_anim_time+350)}
  1152. animation.add( PropertyAnimation( title_b, move_transition_title_b ) );
  1153.  
  1154. if ( my_config["enable_gameinfo"] == "Info and Enumerate" )
  1155. {
  1156. // animate filter
  1157. local move_transition_title = {when = Transition.StartLayout, property = "x", start = flx*2, end = x_filter, time = (ini_anim_time+350)}
  1158. animation.add( PropertyAnimation( filter, move_transition_title ) );
  1159.  
  1160. local move_transition_title_b = {when = Transition.StartLayout, property = "x", start = flx*2, end = x_filter_b, time = (ini_anim_time+350)}
  1161. animation.add( PropertyAnimation( filter_b, move_transition_title_b ) );
  1162. }
  1163. }
  1164. }
  1165.  
  1166.  
  1167. /////////////////////////////////////////////////////////////////////////////////
  1168. // Letters
  1169. local trigger_letter = false;
  1170. local letter_x = 0.5;
  1171. if ( my_config["wheel_poisition"] == "Adjust Right" )
  1172. letter_x = 0.55;
  1173.  
  1174. local letters = fe.add_image("", flw * letter_x - (flw*0.140 * 0.5), flh * 0.5 - (flh*0.280 * 0.5), flw*0.140, flh*0.280);
  1175.  
  1176. fe.add_transition_callback( "letter_transition" );
  1177. function letter_transition( ttype, var, ttime )
  1178. {
  1179. if (ttype == Transition.ToNewList)
  1180. rtime = glob_time;
  1181. }
  1182.  
  1183. fe.add_ticks_callback( "letter_tick" );
  1184. function letter_tick( ttime )
  1185. {
  1186. glob_time = ttime;
  1187.  
  1188. if(glob_time - rtime > glob_delay)
  1189. letters.visible = false; // hide letter search if present
  1190.  
  1191. if(trigger_letter == true)
  1192. {
  1193. local firstl = fe.game_info(Info.Title);
  1194.  
  1195. if (my_config["letters_type"] != "No")
  1196. {
  1197. if (my_config["letters_type"] == "Default")
  1198. letters.file_name = FeConfigDirectory + "gtc-common/letters/default/" + firstl.slice(0,1).tolower() + ".png";
  1199. else //by system display name
  1200. letters.file_name = FeConfigDirectory + "gtc-common/letters/" + fe.displays[fe.list.display_index].name + "/" + firstl.slice(0,1).tolower() + ".png";
  1201.  
  1202. letters.visible = true;
  1203. }
  1204. trigger_letter = false;
  1205. }
  1206. }
  1207.  
  1208. fe.add_signal_handler(this, "on_signal")
  1209. function on_signal(str)
  1210. {
  1211. switch( str )
  1212. {
  1213. case "next_letter":
  1214. case "prev_letter":
  1215. rtime = glob_time;
  1216. trigger_letter = true;
  1217. break;
  1218. }
  1219.  
  1220. return false;
  1221. }
  1222.  
  1223.  
  1224. /////////////////////////////////////////////////////////////////////////////////
  1225. // Search
  1226. local search_surface = fe.add_surface(fe.layout.width *1.12 , fe.layout.height * 1.6)
  1227. KeyboardSearch(search_surface)
  1228. .keys_pos([ 0.05, 0.45, 0.9, 0.4 ])
  1229. .search_key( my_config["user_search_key"].tolower() )
  1230. .mode( "show_results" )
  1231. .text_font("BebasNeue Bold")
  1232. .bg_color(0,0,0,210)
  1233. .text_color(0,255,0)
  1234. .keys_selected_color(0,255,0)
  1235. .init()
  1236.  
  1237. if (my_config["user_search_boxsize"] == "Large")
  1238. search_surface.set_pos(0, 0, flw, flh); // Large center
  1239. else
  1240. search_surface.set_pos(flx*0.15, fly*0.23, flw*0.680, flh*0.58); // Small center
  1241.  
  1242.  
  1243. /////////////////////////////////////////////////////////////////////////////////
  1244. // System games count
  1245. main_infos <- {};
  1246. if( !file_exist(FeConfigDirectory + "gtc.stats") )
  1247. {
  1248. fe.overlay.splash_message ("Counting games, please wait...")
  1249. print("Created the gtc.stats file!\n");
  1250. refresh_stats();
  1251. }
  1252. main_infos <- LoadStats();
  1253.  
  1254. function system_stats( ttype, var, ttime )
  1255. {
  1256. local curr_sys;
  1257. if ( ttype == Transition.StartLayout)
  1258. {
  1259. curr_sys = fe.list.name;
  1260.  
  1261. if( fe.filters[fe.list.filter_index].name.tolower() == "all" ) //make sure default filter ("all") is on so all games are counted
  1262. {
  1263. if( main_infos.rawin(curr_sys) ) //check if system exists
  1264. {
  1265. if(fe.list.size != main_infos[curr_sys].cnt) //if count is wrong, update it with current system list size
  1266. {
  1267. main_infos[curr_sys].cnt = fe.list.size;
  1268. SaveStats(main_infos);
  1269. print("Updated number of games for " + curr_sys + "\n");
  1270. }
  1271. }
  1272. else //if system is new and does not exist in the gtc.stats file, create new entry and count
  1273. {
  1274. main_infos <- refresh_stats(curr_sys);
  1275. print("Created new entry for " + curr_sys + " and counted games for it" + "\n");
  1276. }
  1277. }
  1278. }
  1279. return false;
  1280. }
  1281. fe.add_transition_callback( "system_stats" );
  1282.  
Add Comment
Please, Sign In to add comment