stylet 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.travis.yml +4 -0
  4. data/.yardopts +2 -0
  5. data/Gemfile +16 -0
  6. data/README.org +19 -0
  7. data/Rakefile +17 -0
  8. data/bin/setup +63 -0
  9. data/bin/stylet +8 -0
  10. data/examples/.ruby-version +1 -0
  11. data/examples/00100_lib_hello_world.rb +8 -0
  12. data/examples/00110_lib_sge_check.rb +6 -0
  13. data/examples/00120_lib_/343/202/254/343/203/263/343/203/236/345/200/244/343/201/256/345/244/211/346/233/264.rb +22 -0
  14. data/examples/00130_lib_window_title.rb +8 -0
  15. data/examples/00140_lib_callbacks.rb +8 -0
  16. data/examples/00150_lib_vector.rb +5 -0
  17. data/examples/00160_lib_run.rb +4 -0
  18. data/examples/00170_lib_frame.rb +4 -0
  19. data/examples/00180_lib_config/347/242/272/350/252/215.rb +7 -0
  20. data/examples/00190_lib_/343/201/231/343/201/271/343/201/246/345/220/214/343/201/230/343/202/252/343/203/226/343/202/270/343/202/247/343/202/257/343/203/210.rb +10 -0
  21. data/examples/00200_lib_/343/203/254/343/202/267/343/203/274/343/203/220/343/203/274/343/202/222/347/234/201/347/225/245/343/201/231/343/202/213/346/226/271/346/263/225/343/201/256/343/203/206/343/202/271/343/203/210.rb +28 -0
  22. data/examples/00210_lib_delegators.rb +7 -0
  23. data/examples/00220_lib_template_method.rb +13 -0
  24. data/examples/00230_lib_/350/203/214/346/231/257/347/224/273/345/203/217/350/241/250/347/244/272.rb +9 -0
  25. data/examples/00240_lib_/350/203/214/346/231/257/347/224/273/345/203/217/343/202/222/346/232/227/343/201/2171_/351/273/222/343/201/256/344/270/212/343/201/253/350/203/214/346/231/257.rb +18 -0
  26. data/examples/00250_lib_/350/203/214/346/231/257/347/224/273/345/203/217/343/202/222/346/232/227/343/201/2172_/350/203/214/346/231/257/343/201/256/344/270/212/343/201/253/351/273/222.rb +17 -0
  27. data/examples/00260_lib_/350/203/214/346/231/257/347/224/273/345/203/217/343/202/222/346/232/227/343/201/2173_/350/203/214/346/231/257/343/201/256/344/270/212/343/201/253/351/273/222_/347/224/273/351/235/242/343/202/265/343/202/244/343/202/272/343/203/225/343/202/243/343/203/203/343/203/210_/351/207/215/343/201/204.rb +27 -0
  28. data/examples/00270_lib_/350/203/214/346/231/257/347/224/273/345/203/217/343/202/222/346/232/227/343/201/2173_/350/203/214/346/231/257/343/201/256/344/270/212/343/201/253/351/273/222_/347/224/273/351/235/242/343/202/265/343/202/244/343/202/272/343/203/225/343/202/243/343/203/203/343/203/210_/351/253/230/351/200/237/345/214/226.rb +44 -0
  29. data/examples/00280_lib_/347/211/271/345/256/232/343/201/256/343/202/250/343/203/252/343/202/242/343/201/240/343/201/221/345/276/220/343/200/205/343/201/253/346/266/210/343/201/231.rb +26 -0
  30. data/examples/00290_lib_/350/203/214/346/231/257/350/211/262/345/244/211/346/233/264.rb +5 -0
  31. data/examples/00300_lib_/343/202/255/343/203/243/343/203/251/343/202/257/343/202/277/347/224/273/345/203/217/343/202/222/350/241/250/347/244/272/343/201/231/343/202/213/344/276/213.rb +17 -0
  32. data/examples/00310_lib_/343/202/255/343/203/243/343/203/251/343/202/257/343/202/277/347/224/273/345/203/217/343/201/256/343/202/242/343/203/213/343/203/241/343/203/274/343/202/267/343/203/247/343/203/263.rb +18 -0
  33. data/examples/00320_lib_/343/202/255/343/203/243/343/203/251/343/202/257/343/202/277/346/213/241/345/244/247/347/270/256/345/260/217/345/233/236/350/273/242.rb +21 -0
  34. data/examples/00330_joystick.rb +5 -0
  35. data/examples/00340_joystick_PS3/343/202/242/343/203/212/343/203/255/343/202/260/343/203/254/343/203/220/343/203/274/343/201/256/345/213/225/343/201/215/343/201/214/345/206/205/351/203/250/343/201/247/343/201/257/345/233/233/350/247/222.rb +30 -0
  36. data/examples/00350_joystick_PS3/343/202/242/343/203/212/343/203/255/343/202/260/343/203/254/343/203/220/343/203/274/343/201/256/350/252/277/346/225/264/346/270/210/343/201/277/343/203/231/343/202/257/343/203/210/343/203/253.rb +12 -0
  37. data/examples/00360_lib_mouse.rb +5 -0
  38. data/examples/00370_lib_input.rb +29 -0
  39. data/examples/00380_lib_vputs_align.rb +8 -0
  40. data/examples/00390_/343/203/225/343/202/251/343/203/263/343/203/210/344/270/200/350/246/247.rb +15 -0
  41. data/examples/00400_lib_draw_circle.rb +8 -0
  42. data/examples/00410_SDL/343/201/256draw_rect/343/201/2571/343/203/224/343/202/257/343/202/273/343/203/253/344/275/231/345/210/206/343/201/253/346/217/217/347/224/273/343/201/225/343/202/214/343/202/213/343/201/256/343/201/247/346/263/250/346/204/217.rb +7 -0
  43. data/examples/00420_circle_on_circle.rb +10 -0
  44. data/examples/00430_rotate.rb +16 -0
  45. data/examples/00440_draw_triangle.rb +7 -0
  46. data/examples/00450_parabora_triangle.rb +37 -0
  47. data/examples/00460_ice_hockey.rb +88 -0
  48. data/examples/00470_collision_block_vs_block.rb +120 -0
  49. data/examples/00480_simple_circle_controll.rb +37 -0
  50. data/examples/00490_/347/255/211/351/200/237/347/247/273/345/213/225_uniform_velocity_rain.rb +51 -0
  51. data/examples/00500_/345/212/240/351/200/237/346/224/276/347/211/251/347/267/232_parabora_volcano.rb +94 -0
  52. data/examples/00510_3d.rb +53 -0
  53. data/examples/00520_/343/203/210/343/203/253/343/203/215/343/201/256/343/203/241/343/203/213/343/203/245/343/203/274/351/242/250/343/201/256/345/213/225/343/201/215.rb +77 -0
  54. data/examples/00530_curve_2/346/254/241/343/203/231/343/202/270/343/202/247/346/233/262/347/267/232/343/201/250/347/233/264/347/267/232/343/201/250/343/201/256/344/272/244/347/202/271.rb +43 -0
  55. data/examples/00540_curve_3/346/254/241/343/203/231/343/202/270/343/202/247/346/233/262/347/267/232.rb +40 -0
  56. data/examples/00550_curve_N/346/254/241/343/203/231/343/202/270/343/202/247/346/233/262/347/267/232.rb +92 -0
  57. data/examples/00560_curve_/343/202/271/343/203/227/343/203/251/343/202/244/343/203/263/346/233/262/347/267/232.rb +113 -0
  58. data/examples/00570_/345/206/206/351/201/213/345/213/225_circle_jet_coaster.rb +52 -0
  59. data/examples/00580_/345/206/206/343/202/222/346/212/274/343/201/231/343/201/262/343/201/243/343/201/261/343/202/213_collision_circle_vs_circle_push_or_pull.rb +56 -0
  60. data/examples/00590_/350/212/213/350/231/253/343/202/264/343/203/240/347/264/220/343/203/207/343/203/242_collision_demo_circle_worm.rb +104 -0
  61. data/examples/00600_/346/214/257/343/202/212/345/255/220_swing.rb +145 -0
  62. data/examples/00610_/345/206/205/347/251/215/343/201/250/345/244/226/347/251/215_inner_product.rb +36 -0
  63. data/examples/00620_/346/263/225/347/267/232/343/203/231/343/202/257/343/203/210/343/203/253.rb +23 -0
  64. data/examples/00630_/345/206/206/343/201/250/345/206/206/343/201/256/345/217/215/345/260/204_collision_reflect_circle_vs_circle.rb +222 -0
  65. data/examples/00640_/347/202/271/343/201/250/347/267/232/345/210/206/343/201/256/344/272/244/345/267/256/345/210/244/345/256/232_collision_ray_circle_vs_line.rb +261 -0
  66. data/examples/00650_/345/206/206/343/201/250/347/202/271/343/201/256/345/217/215/345/260/204_collision_circle_vs_dot.rb +36 -0
  67. data/examples/00660_/345/206/206/343/201/250/345/206/206/343/201/250/347/267/232/345/210/206/343/201/256/345/217/215/345/260/204/343/203/207/343/203/242_collision_demo.rb +305 -0
  68. data/examples/00670_/343/203/251/343/202/244/343/203/225/343/202/262/343/203/274/343/203/240.rb +86 -0
  69. data/examples/00680_2/347/202/271/343/202/222/351/200/232/343/202/213/347/233/264/347/267/232/343/201/256/346/226/271/347/250/213/345/274/217.rb +81 -0
  70. data/examples/00690_/343/203/222/343/203/253/343/203/231/343/203/253/343/203/210/346/233/262/347/267/232.rb +77 -0
  71. data/examples/00700_/343/202/263/343/203/203/343/203/233/346/233/262/347/267/232.rb +79 -0
  72. data/examples/00710_/343/202/267/343/202/260/343/203/242/343/202/244/343/203/211/346/233/262/347/267/232.rb +40 -0
  73. data/examples/00720_/343/202/267/343/203/200/346/244/215/347/211/251.rb +44 -0
  74. data/examples/00730_/343/202/257/343/203/252/343/203/225/343/202/251/343/203/274/343/203/211/343/202/242/343/203/210/343/203/251/343/202/257/343/202/277_/345/237/272/346/234/254.rb +29 -0
  75. data/examples/00740_/343/202/257/343/203/252/343/203/225/343/202/251/343/203/274/343/203/211/343/202/242/343/203/210/343/203/251/343/202/257/343/202/277_/346/224/271/350/211/257_/350/211/262/344/273/230/343/201/215.rb +68 -0
  76. data/examples/00750_/343/202/257/343/203/252/343/203/225/343/202/251/343/203/274/343/203/211/343/202/242/343/203/210/343/203/251/343/202/257/343/202/277_/343/203/211/343/203/274/343/203/212/343/203/204/345/236/213.rb +44 -0
  77. data/examples/00760_/347/201/253/350/212/261.rb +42 -0
  78. data/examples/00770_atan/343/201/247atan2/343/202/222/346/233/270/343/201/217.rb +26 -0
  79. data/examples/00780_/346/250/231/346/272/226/343/203/251/343/202/244/343/203/226/343/203/251/343/203/252/343/201/256atan2_sin_cos/343/202/222/344/275/277/343/201/206.rb +15 -0
  80. data/examples/00790_/350/247/222/345/272/246/343/201/250/343/203/251/343/202/270/343/202/242/343/203/263/343/201/256/347/233/270/344/272/222/345/244/211/346/217/233.rb +22 -0
  81. data/examples/00800_/347/220/203/343/201/214/347/233/264/347/267/232/347/232/204/343/201/253/345/213/225/343/201/204/343/201/246/343/201/204/343/202/213/343/201/240/343/201/221/343/201/247/345/233/236/350/273/242/343/201/227/343/201/246/343/201/204/343/202/213/343/202/210/343/201/206/343/201/253/350/246/213/343/201/210/343/202/213.rb +27 -0
  82. data/examples/00810_/343/202/267/343/203/237/343/203/245/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263_/350/273/212.rb +75 -0
  83. data/examples/00820_/343/202/267/343/203/237/343/203/245/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263_/346/210/246/350/273/212.rb +90 -0
  84. data/examples/00830_/350/247/222/345/272/246/345/267/256.rb +36 -0
  85. data/examples/00840_/346/224/276/347/211/251/347/267/232/343/201/247/347/213/231/346/222/203_/346/231/202/351/226/223/345/233/272/345/256/232.rb +61 -0
  86. data/examples/00850_/346/224/276/347/211/251/347/267/232/343/201/247/347/213/231/346/222/203_/350/247/222/345/272/246/345/233/272/345/256/232.rb +84 -0
  87. data/examples/00860_/346/224/276/347/211/251/347/267/232/343/201/247/347/213/231/346/222/203_/351/200/237/345/272/246/345/233/272/345/256/232.rb +66 -0
  88. data/examples/00870_/350/247/222/345/272/246/350/243/234/346/255/243_/345/212/240/351/200/237/343/203/237/343/202/265/343/202/244/343/203/253.rb +60 -0
  89. data/examples/00880_/345/210/235/351/200/237/343/201/214/351/200/237/343/201/204/343/203/237/343/202/265/343/202/244/343/203/253.rb +51 -0
  90. data/examples/00890_/346/255/243/350/246/217/344/271/261/346/225/260/343/201/250/346/250/231/346/272/226/345/201/217/345/267/256/343/201/256/345/217/257/350/246/226/345/214/226.rb +72 -0
  91. data/examples/00900_/345/220/221/345/277/203/345/212/233/343/201/247/345/233/236/350/273/242/343/200/220/350/247/222/345/272/2460/345/272/246/343/201/213/343/202/211/343/200/221.rb +23 -0
  92. data/examples/00910_/345/220/221/345/277/203/345/212/233/343/201/247/345/233/236/350/273/242/343/200/220/344/273/273/346/204/217/343/201/256/350/247/222/345/272/246/343/201/213/343/202/211/343/200/221.rb +33 -0
  93. data/examples/00920_/343/203/236/343/203/252/343/202/252/343/203/226/343/203/251/343/202/266/343/203/274/343/202/272/351/242/250/343/201/253/347/224/273/351/235/242/344/270/241/347/253/257/343/201/214/347/271/213/343/201/243/343/201/246/343/201/204/343/202/213/344/276/213.rb +29 -0
  94. data/examples/00930_/345/212/271/346/236/234/351/237/263.rb +17 -0
  95. data/examples/00940_/343/203/236/343/203/203/343/203/227/343/203/201/343/203/203/343/203/227/343/201/256/343/203/236/343/203/203/343/203/227/351/205/215/347/275/256.rb +71 -0
  96. data/examples/00950_/343/203/236/343/203/203/343/203/227/343/203/201/343/203/203/343/203/227/343/201/256/350/241/250/347/244/272/344/276/213.rb +28 -0
  97. data/examples/00960_/343/203/236/343/203/203/343/203/227/343/203/201/343/203/203/343/203/227/343/201/250/345/215/230/344/270/200/347/224/273/345/203/217/343/201/256/351/201/225/343/201/204/343/202/222/345/220/270/345/217/216/343/201/231/343/202/213/344/276/213.rb +47 -0
  98. data/examples/00970_observer_/343/201/235/343/201/2561_/347/233/264/346/216/245.rb +28 -0
  99. data/examples/00980_observer_/343/201/235/343/201/2562_/346/231/256/351/200/232/343/201/253Singleton/347/211/210.rb +30 -0
  100. data/examples/00990_observer_/343/201/235/343/201/2563_SimpleDelegator/347/211/210.rb +28 -0
  101. data/examples/01000_observer_/343/201/235/343/201/2564_/351/200/206/343/201/253/343/203/253/343/203/274/343/203/227/344/270/273/345/260/216.rb +28 -0
  102. data/examples/01010_observer_/343/201/235/343/201/2565_/343/201/204/343/202/215/343/202/223/343/201/252/346/211/200/343/201/213/343/202/211/345/221/274/343/202/223/343/201/247/343/201/204/343/202/213/343/201/221/343/201/251Singleton/343/201/252/343/201/256/343/201/247/345/256/211/345/205/250.rb +37 -0
  103. data/examples/01020_observer_/343/201/235/343/201/2566_/343/201/204/343/202/215/343/202/223/343/201/252/346/211/200/343/201/213/343/202/211/345/221/274/343/201/266/345/240/264/345/220/210callbacks/343/202/222/344/275/277/343/202/217/343/201/252/343/201/204/343/202/210/343/201/206/343/201/253.rb +30 -0
  104. data/examples/01030_observer_/343/201/235/343/201/2567_/343/202/250/343/203/225/343/202/247/343/202/257/343/203/210/343/202/277/343/202/271/343/202/257/343/202/222/345/233/236/343/201/231/344/276/213.rb +57 -0
  105. data/examples/01040_/343/203/236/343/202/246/343/202/271/343/201/256/344/275/215/347/275/256/343/201/253/343/203/224/343/202/257/343/202/273/343/203/253/343/202/222/346/211/223/343/201/244.rb +18 -0
  106. data/examples/01050_/343/203/224/343/202/257/343/202/273/343/203/253/345/205/250/344/275/223/343/202/222/346/233/270/343/201/215/350/276/274/343/202/200.rb +27 -0
  107. data/examples/01060_effect_/347/224/273/345/203/217/343/201/256/343/202/263/343/203/263/343/203/234/343/203/252/343/203/245/343/203/274/343/203/210/346/263/225/343/201/253/343/202/210/343/202/213/343/202/250/343/203/225/343/202/247/343/202/257/343/203/210/345/207/246/347/220/206.rb +116 -0
  108. data/examples/01070_effect_FF7/343/201/256/346/210/246/351/227/230/343/201/253/345/205/245/343/202/213/343/201/250/343/201/215/343/201/256/343/202/250/343/203/225/343/202/247/343/202/257/343/203/210.rb +33 -0
  109. data/examples/01080_effect_/350/203/214/346/231/257/343/202/222/347/267/251/343/201/217/346/266/210/343/201/227/343/201/246/343/201/204/343/201/217/343/201/250/343/202/271/343/203/240/343/203/274/343/202/272/343/201/253/343/201/252/343/202/213.rb +16 -0
  110. data/examples/01090_/347/224/273/345/203/217/343/201/256/343/202/257/343/203/255/343/202/271/343/203/225/343/202/247/343/203/274/343/203/211.rb +37 -0
  111. data/examples/01100_/343/202/271/343/202/257/343/203/252/343/203/274/343/203/263/346/203/205/345/240/261.rb +8 -0
  112. data/examples/01110_lib_contrib_menu.rb +19 -0
  113. data/examples/01120_/351/233/233/345/236/213_2P/345/257/276/346/210/246/351/242/250STG.rb +109 -0
  114. data/examples/01130_/351/233/233/345/236/213_/346/210/246/350/273/212/345/257/276/346/210/246.rb +396 -0
  115. data/examples/01140_/351/233/233/345/236/213_2P/345/257/276/346/210/246.rb +60 -0
  116. data/examples/01150_/351/233/233/345/236/213_/343/202/271/343/203/274/343/203/221/343/203/274/343/203/236/343/203/252/343/202/252/351/242/250/343/202/242/343/202/257/343/202/267/343/203/247/343/203/263.rb +1251 -0
  117. data/examples/01160_2D/343/202/242/343/203/225/343/202/243/343/203/263/345/244/211/346/217/233.rb +40 -0
  118. data/examples/01170_stackprof.rb +10 -0
  119. data/examples/01180_sdl_/343/202/242/343/203/253/343/203/225/343/202/241/343/203/226/343/203/254/343/203/263/343/203/207/343/202/243/343/203/263/343/202/260/343/201/247/351/207/215/343/201/255/345/220/210/343/201/233/345/241/227/343/202/212/346/275/260/343/201/227.rb +11 -0
  120. data/examples/01190_/343/203/221/343/203/274/343/203/206/343/202/243/343/202/257/343/203/253/345/220/214/345/243/253/343/201/247/344/270/255/345/244/256/343/201/253/345/220/221/343/201/213/343/201/206.rb +79 -0
  121. data/examples/01200_lib_OpenGL.rb +55 -0
  122. data/examples/bezier.rb +202 -0
  123. data/examples/cursor.rb +50 -0
  124. data/examples/helper.rb +38 -0
  125. data/examples/lifegame_patterns.rb +102 -0
  126. data/examples/movable_point.rb +64 -0
  127. data/examples/mtx33.rb +294 -0
  128. data/examples/setup.rb +5 -0
  129. data/examples/stage_infos.rb +1 -0
  130. data/examples/start.sh +2 -0
  131. data/examples/test_all.rb +5 -0
  132. data/examples/testgl.rb +228 -0
  133. data/examples/trash/__0060_shooting2.rb +37 -0
  134. data/examples/trash/__0090_collision_circle1.rb +50 -0
  135. data/examples/trash/__0125_circle_collision.rb +103 -0
  136. data/examples/trash/__0130_circle_collision2.rb +60 -0
  137. data/examples/trash/__0270_circle_cycle_shift.rb +29 -0
  138. data/examples/trash/__bullet_algos.rb +224 -0
  139. data/examples/trash/gunship.rb +39 -0
  140. data/examples//343/203/227/343/203/255/343/202/270/343/202/247/343/202/257/343/202/277/343/203/274/343/201/253/350/241/250/347/244/272/343/201/231/343/202/213/343/201/250/343/201/215.sh +2 -0
  141. data/lib/stylet.rb +1 -0
  142. data/lib/stylet/application_memory_record.rb +33 -0
  143. data/lib/stylet/audio.rb +455 -0
  144. data/lib/stylet/axis_support.rb +62 -0
  145. data/lib/stylet/base.rb +76 -0
  146. data/lib/stylet/callbacks.rb +62 -0
  147. data/lib/stylet/cli.rb +54 -0
  148. data/lib/stylet/collision_support.rb +56 -0
  149. data/lib/stylet/config.rb +39 -0
  150. data/lib/stylet/contrib/menu.rb +508 -0
  151. data/lib/stylet/contrib/shared_pad.rb +32 -0
  152. data/lib/stylet/contrib/sprity.rb +149 -0
  153. data/lib/stylet/core.rb +118 -0
  154. data/lib/stylet/cpu_stat.rb +58 -0
  155. data/lib/stylet/delegators.rb +54 -0
  156. data/lib/stylet/draw.rb +256 -0
  157. data/lib/stylet/draw_support/arrow.rb +56 -0
  158. data/lib/stylet/draw_support/circle.rb +63 -0
  159. data/lib/stylet/draw_support/polygon.rb +22 -0
  160. data/lib/stylet/font.rb +172 -0
  161. data/lib/stylet/fps_adjust.rb +23 -0
  162. data/lib/stylet/fps_stat.rb +41 -0
  163. data/lib/stylet/input.rb +8 -0
  164. data/lib/stylet/input/base.rb +105 -0
  165. data/lib/stylet/input/hardware_bindings.rb +65 -0
  166. data/lib/stylet/input/key_one.rb +162 -0
  167. data/lib/stylet/input/support.rb +72 -0
  168. data/lib/stylet/joystick.rb +31 -0
  169. data/lib/stylet/joystick_adapter.rb +130 -0
  170. data/lib/stylet/joystick_adapters/buffalo_snes_adapter.rb +47 -0
  171. data/lib/stylet/joystick_adapters/elecom_usb_pad_adapter.rb +30 -0
  172. data/lib/stylet/joystick_adapters/hori_rap_v3_sa_adapter.rb +46 -0
  173. data/lib/stylet/joystick_adapters/ps3_standard_adapter.rb +40 -0
  174. data/lib/stylet/joystick_adapters/unknown_adapter.rb +13 -0
  175. data/lib/stylet/keyboard.rb +15 -0
  176. data/lib/stylet/logger.rb +12 -0
  177. data/lib/stylet/mouse.rb +58 -0
  178. data/lib/stylet/palette.rb +17 -0
  179. data/lib/stylet/rect.rb +113 -0
  180. data/lib/stylet/shortcut.rb +8 -0
  181. data/lib/stylet/state.rb +87 -0
  182. data/lib/stylet/stylet.rb +44 -0
  183. data/lib/stylet/system_pause.rb +24 -0
  184. data/lib/stylet/version.rb +3 -0
  185. data/log/.gitkeep +0 -0
  186. data/stylet.gemspec +31 -0
  187. data/test/test_helper.rb +6 -0
  188. data/test/test_input_base.rb +12 -0
  189. data/test/test_input_key_one.rb +43 -0
  190. data/test/test_input_support.rb +47 -0
  191. data/test/test_sample.rb +13 -0
  192. data/test/test_state.rb +26 -0
  193. data/tips.org +16 -0
  194. metadata +391 -0
@@ -0,0 +1,62 @@
1
+ #
2
+ # レバーの状態から方向を返す便利メソッド
3
+ #
4
+
5
+ module Stylet
6
+ module AxisSupport
7
+ extend self
8
+
9
+ # レバーの状態から8方向の番号インデックスに変換
10
+ # [U]
11
+ # 6
12
+ # 5 7
13
+ # [L]4 0[R]
14
+ # 3 1
15
+ # 2
16
+ # [D]
17
+ def axis_angle_index(axis)
18
+ case
19
+ when axis.up.press?
20
+ case
21
+ when axis.right.press?
22
+ 7
23
+ when axis.left.press?
24
+ 5
25
+ else
26
+ 6
27
+ end
28
+ when axis.down.press?
29
+ case
30
+ when axis.right.press?
31
+ 1
32
+ when axis.left.press?
33
+ 3
34
+ else
35
+ 2
36
+ end
37
+ when axis.right.press?
38
+ 0
39
+ when axis.left.press?
40
+ 4
41
+ end
42
+ end
43
+
44
+ # 8方向レバーの状態から一周を1.0としたときの方向を返す
45
+ # [U]
46
+ # 0.750
47
+ # 0.625 0.875
48
+ # [L] 0.500 0.000 [R]
49
+ # 0.375 0.125
50
+ # 0.250
51
+ # [D]
52
+ def axis_angle(axis)
53
+ if dir = axis_angle_index(axis)
54
+ 1.0 * dir / 8
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ if $0 == __FILE__
61
+ require_relative "../stylet"
62
+ end
@@ -0,0 +1,76 @@
1
+ # 数学系汎用
2
+ pp $LOAD_PATH
3
+ exit
4
+ require 'stylet_support'
5
+
6
+ # gem
7
+ require 'sdl'
8
+ require 'active_support/concern' # ActiveSupport::Concern
9
+ require 'active_support/core_ext/module/concerning' # concerning
10
+ require "active_support/core_ext/hash/keys" # assert_valid_keys
11
+ require "active_support/core_ext/array/wrap" # Array.wrap
12
+ require 'active_support/callbacks'
13
+
14
+ # ruby library
15
+ require 'pp'
16
+ require 'singleton'
17
+ require 'pathname'
18
+
19
+ require 'stylet/config'
20
+
21
+ # 汎用ライブラリ
22
+ require_relative 'application_memory_record'
23
+ require_relative 'palette'
24
+ require_relative 'fps_adjust'
25
+ require_relative 'fps_stat'
26
+ require_relative 'cpu_stat'
27
+ require_relative 'logger'
28
+ require_relative 'rect'
29
+ require_relative 'collision_support'
30
+
31
+ # 描画系
32
+ require_relative 'core'
33
+ require_relative 'callbacks'
34
+ require_relative 'system_pause'
35
+ require_relative 'cli'
36
+ require_relative 'draw'
37
+ require_relative 'font'
38
+ require_relative 'shortcut'
39
+
40
+ # 描画サポート
41
+ require_relative 'draw_support/circle'
42
+ require_relative 'draw_support/polygon'
43
+ require_relative 'draw_support/arrow'
44
+
45
+ # 入力系
46
+ require_relative 'joystick'
47
+ require_relative 'keyboard'
48
+ require_relative 'mouse'
49
+
50
+ # オーディオ系
51
+ require_relative 'audio'
52
+
53
+ # その他
54
+ require_relative 'delegators'
55
+
56
+ module Stylet
57
+ class Base
58
+ include Core
59
+ include Callbacks
60
+ include Draw
61
+ include DeprecateBackground
62
+ include DrawSupport
63
+ include Font
64
+ include Joystick
65
+ include Keyboard
66
+ include Mouse
67
+ include Pause
68
+ include ClOptions
69
+ include Shortcut
70
+ include Delegators
71
+ end
72
+ end
73
+
74
+ if $0 == __FILE__
75
+ Stylet::Base.run
76
+ end
@@ -0,0 +1,62 @@
1
+ require 'active_support/callbacks'
2
+ require 'active_model/callbacks'
3
+
4
+ module Stylet
5
+ module Callbacks
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ extend ActiveModel::Callbacks
10
+ define_model_callbacks :setup, :update, :main_loop
11
+ end
12
+
13
+ class_methods do
14
+ def setup(*args, &block)
15
+ set_callback(:setup, *args, &block)
16
+ end
17
+
18
+ def update(*args, &block)
19
+ set_callback(:update, *args, &block)
20
+ end
21
+ end
22
+
23
+ def setup
24
+ run_callbacks(:setup) { super }
25
+ end
26
+
27
+ def update
28
+ run_callbacks(:update) { super }
29
+ end
30
+
31
+ def main_loop(&block)
32
+ run_callbacks(:main_loop) { super(&block) }
33
+ end
34
+ end
35
+ end
36
+
37
+ if $0 == __FILE__
38
+ require_relative "../stylet"
39
+
40
+ # 方法1
41
+ Stylet::Base.setup { @a = "A" }
42
+ Stylet::Base.update { vputs @a }
43
+ Stylet::Base.run
44
+
45
+ # 方法2
46
+ module Stylet
47
+ class Base
48
+ setup { @b = "B" }
49
+ update { vputs @b }
50
+ run
51
+ end
52
+ end
53
+
54
+ # 方法3 (他の方法のあとに呼ぶとだめなのはなぜ?)
55
+ # Stylet::Base.reset_callbacks(:setup)
56
+ # Stylet::Base.reset_callbacks(:update)
57
+ class A < Stylet::Base
58
+ setup { @c = "C" }
59
+ update { vputs @c }
60
+ run
61
+ end
62
+ end
@@ -0,0 +1,54 @@
1
+ #
2
+ # コマンドライン対応
3
+ #
4
+ # サンプルプログラムを連続実行して動作確認
5
+ # rsdl foo.rb bar.rb --shutdown=60
6
+
7
+ require "optparse"
8
+
9
+ module Stylet
10
+ module ClOptions
11
+ def self.oparser
12
+ @oparser ||= OptionParser.new do |oparser|
13
+ oparser.on("--fps=INTEGER", Integer) {|v| Stylet.config.fps = v }
14
+ oparser.on("--shutdown=INTEGER", Integer) {|v| Stylet.config.shutdown = v }
15
+ oparser.on("-f", "--full-screen", TrueClass) {|v| Stylet.config.full_screen = v }
16
+ oparser.on("-p", "--production", TrueClass) {|v| Stylet.production = v }
17
+ oparser.on("-s", "--screen-size=SIZE", String) {|v| Stylet.config.screen_size = [*v.scan(/\d+/).collect(&:to_i)] }
18
+ oparser.on("-c", "--color-depth=DEPTH", Integer) {|v| Stylet.config.color_depth = v }
19
+ oparser.on("-m", "--mute-mute", TrueClass) {|v| Stylet.config.mute_music = v }
20
+ oparser.on("-M", "--mute", TrueClass) {|v| Stylet.config.mute = v }
21
+ oparser.on("-i", "--hide-mouse", TrueClass) {|v| Stylet.config.hide_mouse = v }
22
+ end
23
+ end
24
+
25
+ concerning :Base do
26
+ def initialize
27
+ super if defined? super
28
+ return if Stylet.config.optparse_skip || ENV["STYLET_OPTPARSE_SKIP"]
29
+ ClOptions.oparser.order!(ARGV)
30
+ end
31
+ end
32
+
33
+ concerning :Shutdown do
34
+ def update
35
+ super if defined? super
36
+ if Stylet.config.shutdown && frame_counter >= Stylet.config.shutdown
37
+ throw :exit, :break
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ if $0 == __FILE__
45
+ $LOAD_PATH << ".."
46
+ require "stylet"
47
+ ARGV << "--shutdown=3600"
48
+ ARGV << "--screen-size=800x600"
49
+ ARGV << "--full-screen"
50
+ ARGV << "--production"
51
+ Stylet.run do
52
+ vputs Stylet.config
53
+ end
54
+ end
@@ -0,0 +1,56 @@
1
+ module Stylet
2
+ module CollisionSupport
3
+ extend self
4
+
5
+ # +--- -r ---+
6
+ # | | |
7
+ # -r -- p0 -- r のなかに p1 の点が含まれているか?
8
+ # | | |
9
+ # +---- r ---+
10
+ def squire_collision?(p0, p1, options = {})
11
+ ((p0.x - options[:radius])..(p0.x + options[:radius])).include?(p1.x) &&
12
+ ((p0.y - options[:radius])..(p0.y + options[:radius])).include?(p1.y)
13
+ end
14
+
15
+ # 領域rectの中に点pが含まれているか?
16
+ def rect_in?(rect, p)
17
+ (rect.min_x <= p.x && p.x <= rect.max_x) &&
18
+ (rect.min_y <= p.y && p.y <= rect.max_y)
19
+ end
20
+
21
+ # 領域rectの中に点pが含まていない?
22
+ def rect_out?(rect, p)
23
+ !rect_in?(rect, p)
24
+ end
25
+
26
+ # 長方形aと長方形bの一部が接触しているか?
27
+ def rect_collision2?(a, b)
28
+ # めりこみサイズを4辺について調べる
29
+ _l = a.max_xi - b.min_xi # A|B
30
+ _r = b.max_xi - a.min_xi # B|A
31
+ _u = a.max_yi - b.min_yi # A/B
32
+ _d = b.max_yi - a.min_yi # B/A
33
+
34
+ if true &&
35
+ _l >= 1 && # A|B
36
+ _r >= 1 && # B|A
37
+ _u >= 1 && # A/B
38
+ _d >= 1 && # B/A
39
+ true
40
+ true
41
+ end
42
+ end
43
+
44
+ # 長方形aのなかにbが含まれているか?
45
+ def rect_include?(a, b)
46
+ if true &&
47
+ a.min_xi <= b.min_xi &&
48
+ b.max_xi <= a.max_xi &&
49
+ a.min_yi <= b.min_yi &&
50
+ b.max_yi <= a.max_yi &&
51
+ true
52
+ true
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,39 @@
1
+ require "active_support/configurable"
2
+
3
+ module Stylet
4
+ include ActiveSupport::Configurable
5
+
6
+ config_accessor :production
7
+
8
+ # Screen
9
+ config.screen_size = [640, 480]
10
+ config.fps = nil
11
+ config.full_screen = false
12
+ config.color_depth = 16
13
+ config.screen_flags = SDL::HWSURFACE | SDL::DOUBLEBUF | SDL::HWACCEL | SDL::RESIZABLE
14
+ # config.screen_flags = SDL::HWSURFACE | SDL::DOUBLEBUF | SDL::HWACCEL | SDL::RESIZABLE # SDL::NOFRAME
15
+ # config.screen_flags = SDL::HWSURFACE | SDL::DOUBLEBUF | SDL::HWACCEL | SDL::RESIZABLE | SDL::SRCALPHA
16
+ config.background_image = nil # "background.bmp"
17
+
18
+ # Font
19
+ config.system_font_key = :ipag_mona
20
+ config.font_list = [
21
+ {:key => :ipag_mona, :path => "ipag-mona.ttf", :bold => false, :font_size => 14},
22
+ # {:key => :font_large, :path => "LiberationMono-Bold.ttf", :bold => true, :font_size => 24},
23
+ # {:key => :coda, :path => "Coda-Regular.ttf", :bold => false, :font_size => 14},
24
+ ]
25
+
26
+ # Mouse
27
+ config.hide_mouse = false
28
+
29
+ # Audio
30
+ config.sound_freq = 22050 # 44100 # SDLのデフォルトは 22050
31
+ config.mute_music = false
32
+ config.mute = false
33
+
34
+ # etc.
35
+ config.production = false
36
+ config.production_keys = [SDL::Key::K0] # [SDL::Key::RETURN]
37
+ config.pause_keys = [SDL::Key::SPACE]
38
+ config.optparse_skip = false
39
+ end
@@ -0,0 +1,508 @@
1
+ require "stylet"
2
+ require_relative "shared_pad"
3
+
4
+ module Stylet
5
+ module Menu
6
+ module Core
7
+ extend ActiveSupport::Concern
8
+
9
+ include Stylet::Delegators
10
+
11
+ attr_accessor :parent, :bar, :display_height, :select_buttons, :cancel_buttons, :line_format, :close_hook, :input, :elements, :every_command_all
12
+ attr_reader :state, :children
13
+
14
+ def initialize(**params)
15
+ super() if defined? super
16
+
17
+ {
18
+ :parent => nil,
19
+ :name => nil,
20
+ :elements => [],
21
+ :select_buttons => [:btA, :btD],
22
+ :cancel_buttons => [:btB, :btC],
23
+ :scroll_margin => nil,
24
+ :bar => "─" * 40,
25
+ :display_height => 20,
26
+ :line_format => " %{cursor}%{name} %{value}",
27
+ :close_hook => nil,
28
+ :input => Input::SharedPad.new,
29
+ :aroundable => false,
30
+ :cursor => 0,
31
+ :every_command_all => nil,
32
+ }.merge(params).each {|k, v| instance_variable_set("@#{k}", v) }
33
+
34
+ @window_cursor = @cursor
35
+ @state = State.new(:boot)
36
+ @children = []
37
+ end
38
+
39
+ def chain(params)
40
+ notify(:menu_chain)
41
+
42
+ params = params.dup
43
+ menu_class = params.delete(:menu_class) || self.class
44
+ @children << menu_class.new({:name => current[:name], :parent => self}.merge(params))
45
+ @state.jump_to :ms_sleep
46
+ end
47
+
48
+ def update
49
+ super if defined? super
50
+ unless @parent
51
+ @input.key_bit_update_all
52
+ @input.key_counter_update_all
53
+ end
54
+ @state.loop_in { send @state.key }
55
+ end
56
+
57
+ def root
58
+ if @parent
59
+ @parent.root
60
+ else
61
+ self
62
+ end
63
+ end
64
+
65
+ def force_close
66
+ throw :exit, :break
67
+ end
68
+
69
+ def close_trigger?
70
+ root.cancel_buttons.any? {|e|root.input.button.send(e).trigger?} || Stylet::Base.active_frame.key_down?(SDL::Key::BACKSPACE)
71
+ end
72
+
73
+ def diff_val
74
+ case e = Input::Support.preference_key(root.input.axis.right, root.input.axis.left)
75
+ when root.input.axis.right
76
+ e.repeat
77
+ when root.input.axis.left
78
+ e.repeat * -1
79
+ else
80
+ 0
81
+ end
82
+ end
83
+
84
+ begin
85
+ private
86
+
87
+ def boot
88
+ bgm_if_possible
89
+ @state.jump_to :ms_alive
90
+ end
91
+
92
+ def ms_sleep
93
+ @children.each(&:update)
94
+ end
95
+
96
+ def ms_restart
97
+ if @state.start?
98
+ bgm_if_possible
99
+ notify(:menu_back)
100
+ end
101
+ @state.jump_to :ms_alive
102
+ end
103
+
104
+ def ms_alive
105
+ cursor_update
106
+ if @state.counter > 1 # サブメニューを開いた瞬間や戻ってきたときに最初の項目を押させないため
107
+ close_check
108
+ all_run
109
+ current_run
110
+ end
111
+ current_value_change
112
+ window_cursor_update
113
+ render
114
+ end
115
+
116
+ def render
117
+ # unless @bar
118
+ # vputs
119
+ # end
120
+ if menu_name
121
+ rendar_bar
122
+ vputs menu_name
123
+ end
124
+ rendar_bar
125
+ @elements.slice(@window_cursor, @display_height).each {|element| element_display(element) }
126
+ rendar_bar
127
+
128
+ if current
129
+ if s = current[:desc]
130
+ if s.respond_to?(:call)
131
+ s = s.call
132
+ end
133
+ vputs s
134
+ end
135
+ end
136
+ end
137
+
138
+ def menu_name
139
+ if @name.respond_to?(:call)
140
+ @name.call
141
+ else
142
+ @name
143
+ end
144
+ end
145
+
146
+ def element_display(element)
147
+ vputs line_format % {
148
+ :cursor => element_cursor(element),
149
+ :name => element_name(element),
150
+ :value => element_value(element),
151
+ }
152
+ end
153
+
154
+ def element_cursor(element)
155
+ if element == current
156
+ "〉"
157
+ else
158
+ " "
159
+ end
160
+ end
161
+
162
+ def element_name(element)
163
+ name = element[:name]
164
+ if name.respond_to?(:call)
165
+ name = name.call
166
+ end
167
+ if element == current
168
+ if menu_type?
169
+ name = "#{name}/"
170
+ end
171
+ if command_type?
172
+ name = "#{name} => OK ?"
173
+ end
174
+ else
175
+ name = "#{name}"
176
+ end
177
+ name
178
+ end
179
+
180
+ def element_value(element)
181
+ if element[:value]
182
+ value = element[:value].call
183
+ if element == current
184
+ if left_right_type?
185
+ value = "< #{value} >"
186
+ end
187
+ end
188
+ value
189
+ end
190
+ end
191
+
192
+ def all_run
193
+ if @every_command_all
194
+ @every_command_all.call(self)
195
+ end
196
+ @elements.each do |elem|
197
+ if command = elem[:every_call]
198
+ command.call(self)
199
+ end
200
+ end
201
+ end
202
+
203
+ def current_run
204
+ return unless current
205
+ current.assert_valid_keys *[
206
+ :name,
207
+ :desc,
208
+ :menu,
209
+ :simple_command,
210
+ :se_command,
211
+ :safe_command,
212
+ :change,
213
+ :change_with_self,
214
+ :change_with_se,
215
+ :value,
216
+ :every_call,
217
+ :call_if_current,
218
+ :cursor_in,
219
+ :cursor_out,
220
+ ]
221
+
222
+ if command = current[:call_if_current]
223
+ command.call(self)
224
+ end
225
+
226
+ if current_run_trigger?
227
+ if menu = current[:menu]
228
+ if menu.respond_to?(:call)
229
+ menu = menu.call
230
+ end
231
+ chain(menu)
232
+ end
233
+ if command = current[:simple_command]
234
+ if command.respond_to?(:call)
235
+ command.call(self)
236
+ else
237
+ send(command)
238
+ end
239
+ end
240
+ if command = current[:se_command]
241
+ notify(:menu_select)
242
+ command.call(self)
243
+ end
244
+ if command = current[:safe_command]
245
+ safe_command_around { command.call(self) }
246
+ end
247
+ end
248
+ end
249
+
250
+ def cursor_update
251
+ if v = Stylet::Input::Support.preference_key(root.input.axis.up, root.input.axis.down)
252
+ if v.repeat >= 1
253
+ d = 0
254
+ if v == root.input.axis.up
255
+ if @aroundable || @cursor > 0
256
+ d = -1
257
+ end
258
+ else
259
+ if @aroundable || @cursor < @elements.size - 1
260
+ d = 1
261
+ end
262
+ end
263
+ if d != 0
264
+ c = (@cursor + d).modulo(@elements.size)
265
+ if c != @cursor
266
+ before = current
267
+ @cursor = c
268
+ notify(:menu_cursor)
269
+
270
+ if m = before[:cursor_out]
271
+ if m.respond_to?(:call)
272
+ m.call(self)
273
+ end
274
+ end
275
+ if m = current[:cursor_in]
276
+ if m.respond_to?(:call)
277
+ m.call(self)
278
+ end
279
+ end
280
+ end
281
+ end
282
+ end
283
+ end
284
+ end
285
+
286
+ def rendar_bar
287
+ if @bar
288
+ vputs @bar
289
+ end
290
+ end
291
+
292
+ def close_check
293
+ if close_trigger?
294
+ close_and_parent_restart
295
+ end
296
+ end
297
+
298
+ def window_cursor_update
299
+ d = scroll_margin - (@cursor - @window_cursor)
300
+ if d >= 1
301
+ @window_cursor -= d
302
+ end
303
+ d = (@cursor - @window_cursor) - (@display_height - scroll_margin - 1)
304
+ if d >= 1
305
+ @window_cursor += d
306
+ end
307
+ @window_cursor = Stylet::Chore.clamp(@window_cursor, window_range)
308
+ end
309
+
310
+ def window_range
311
+ max = @elements.size - @display_height
312
+ if max < 0
313
+ max = 0
314
+ end
315
+ 0..max
316
+ end
317
+
318
+ def current
319
+ unless @elements.empty?
320
+ @elements.fetch(@cursor)
321
+ end
322
+ end
323
+
324
+ def scroll_margin
325
+ @scroll_margin || (@display_height / 3)
326
+ end
327
+
328
+ def close_and_parent_restart
329
+ if parent
330
+ if @close_hook
331
+ @close_hook.call(self)
332
+ end
333
+ parent.children.delete(self)
334
+ parent.state.jump_to :ms_restart
335
+ end
336
+ end
337
+
338
+ def notify(key)
339
+ end
340
+
341
+ def bgm_if_possible
342
+ end
343
+
344
+ def current_value_change
345
+ if current
346
+ if diff_val.nonzero?
347
+ if current[:change]
348
+ current[:change].call(diff_val)
349
+ end
350
+ if current[:change_with_self]
351
+ current[:change_with_self].call(self)
352
+ end
353
+ if current[:change_with_se]
354
+ current[:change_with_se].call(diff_val)
355
+ notify(:menu_select)
356
+ end
357
+ end
358
+ end
359
+ end
360
+
361
+ def current_run_trigger?
362
+ root.select_buttons.any? {|e|root.input.button.send(e).trigger?} || Stylet::Base.active_frame.key_down?(SDL::Key::RETURN)
363
+ end
364
+
365
+ def safe_command_around
366
+ Stylet::Audio.halt
367
+ notify(:menu_select)
368
+ yield
369
+ Stylet::Audio.halt
370
+ bgm_if_possible
371
+
372
+ # yield内でBキャンセルしたときにこのメニューもBキャンセルが反応してしまう。
373
+ # この対策としてメニューをリスタートさせる。
374
+ # リスタートすることで2フレーム間Bキャンセルを回避できる。
375
+ @state.jump_to :ms_restart
376
+ end
377
+
378
+ def left_right_type?
379
+ what_type?("change")
380
+ end
381
+
382
+ def menu_type?
383
+ what_type?("menu")
384
+ end
385
+
386
+ def command_type?
387
+ what_type?("command")
388
+ end
389
+
390
+ def what_type?(s)
391
+ current.keys.any? { |e| e.to_s.include?(s) }
392
+ end
393
+ end
394
+ end
395
+
396
+ module Soundable
397
+ extend ActiveSupport::Concern
398
+
399
+ def initialize(*)
400
+ super if defined? super
401
+
402
+ Stylet::SE.load("#{__dir__}/../../../assets/audios/pc_puyo_puyo_fever/SE/039CURSOR.WAV", volume: 0.5, key: :menu_cursor)
403
+ Stylet::SE.load("#{__dir__}/../../../assets/audios/pc_puyo_puyo_fever/SE/036DECIDE.WAV", volume: 0.5, key: :menu_select)
404
+ Stylet::SE.load("#{__dir__}/../../../assets/audios/pc_puyo_puyo_fever/SE/037CANCEL.WAV", volume: 0.5, key: :menu_back)
405
+ Stylet::SE.load("#{__dir__}/../../../assets/audios/pc_puyo_puyo_fever/SE/036DECIDE.WAV", volume: 0.5, key: :menu_chain)
406
+ end
407
+
408
+ def notify(key)
409
+ Stylet::SE[key].play
410
+ end
411
+
412
+ def bgm_if_possible
413
+ unless Stylet::Music.play?
414
+ Stylet::Music.play("#{__dir__}/../../../assets/audios/pc_puyo_puyo_fever/BGM/01_MENU.ogg")
415
+ end
416
+ end
417
+ end
418
+
419
+ class Simple
420
+ include Core
421
+ end
422
+
423
+ class Basic
424
+ include Core
425
+ include Soundable
426
+ end
427
+ end
428
+
429
+ if $0 == __FILE__
430
+ class SampleWindow < SimpleDelegator
431
+ def initialize
432
+ super(Stylet::Base.active_frame)
433
+ @c = 0
434
+ end
435
+
436
+ def counter_loop
437
+ main_loop do |_|
438
+ if @c >= 60
439
+ break
440
+ end
441
+ vputs "#{self.class.name}: #{@c}"
442
+ @c += 1
443
+ end
444
+ end
445
+ end
446
+
447
+ #--------------------------------------------------------------------------------
448
+ # 例1
449
+ #--------------------------------------------------------------------------------
450
+
451
+ if true
452
+ class App1 < SimpleDelegator
453
+ def initialize
454
+ super(Stylet::Base.active_frame)
455
+
456
+ if false
457
+ @menu = Stylet::Menu::Basic.new
458
+ else
459
+ @test_var = 0
460
+ @menu = Stylet::Menu::Basic.new(elements: [
461
+ {name: "モード", safe_command: proc {}, :value => proc { @test_var }, :change => proc {|v| @test_var += v }, :desc => proc { "説明" }},
462
+
463
+ {name: "実行", safe_command: proc { SampleWindow.new.counter_loop }},
464
+ {
465
+ name: "サブメニュー",
466
+ simple_command: proc {|s|
467
+ s.chain(name: "sub menu", elements: [
468
+ {name: "実行", safe_command: proc { SampleWindow.new.counter_loop }},
469
+ {name: "A", safe_command: proc { p 1 }},
470
+ {name: "B", safe_command: proc { p 2 }},
471
+ {name: "閉じる", simple_command: :close_and_parent_restart },
472
+ ])
473
+ },
474
+ },
475
+ {name: "サブメニュー2", simple_command: proc {|s| s.chain(name: "[サブメニュー2]", elements: 50.times.collect {|i|{:name => "項目#{i}"}})}},
476
+ {name: "サブメニュー3", menu: {name: "[サブメニュー3]", elements: 50.times.collect {|i|{:name => "項目#{i}"}}}},
477
+ {:name => "閉じる", simple_command: :close_and_parent_restart },
478
+ ])
479
+ end
480
+ end
481
+
482
+ def counter_loop
483
+ main_loop {|_| @menu.update }
484
+ end
485
+ end
486
+
487
+ App1.new.counter_loop
488
+ end
489
+
490
+ #--------------------------------------------------------------------------------
491
+ # 例2
492
+ #--------------------------------------------------------------------------------
493
+
494
+ if false
495
+ # この例でもいいけど update コールバックが Singleton のインスタンスに結び付いてしまうのため
496
+ # SampleWindow クラスでも update が実行されてしまう
497
+ class App2 < Stylet::Base
498
+ setup do
499
+ @menu = Stylet::Menu::Basic.new(elements: [{name: "RUN", safe_command: proc { SampleWindow.new.counter_loop }}])
500
+ end
501
+ update do
502
+ @menu.update
503
+ end
504
+ run
505
+ end
506
+ end
507
+ end
508
+ end