SHARE
TWEET

Video 1

a guest Jan 20th, 2018 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================#
  2. # Version 0.3 #
  3. # RPG Maker XP Flash Player #
  4. # #
  5. # Author: ????? Updated by: Dark_Wolf_Warrior/Dahrkael #
  6. # # Peaverin: Adapt to Essentials + tutorial(optional credits)
  7. # How to Use: #
  8. # 1. Create the folder Graphics/Flash and insert there the movies.
  9. # #
  10. # 2. If you want to play a flash at any moment insert: #
  11. # $flash.play("file.swf", button)
  12. # file= the name of the flash to be played
  13. # button= 0(the player can't skip the flash by pressing enter)
  14. # button= 1(the player can skip the flash by prssing enter)
  15. # FOR EXAMPLE: I add a flash called Heya to the flash folder.
  16. # # Then, in a event I call the script:
  17. # # $flash.play("Heya.swf", 0)
  18. # # By this way the flash Heya will be played and you won't be
  19. # # able to skip it by pressing enter.
  20. # Interactive flashes requires RGSS knownledge to make they work #
  21. # #
  22. # Original Keyb module by HoundNinja #
  23. # #
  24. #==============================================================================#
  25.  
  26.  
  27.  
  28. class String
  29.  
  30. CP_ACP = 0
  31. CP_UTF8 = 65001
  32.  
  33. def u2s
  34. m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")
  35. w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")
  36.  
  37. len = m2w.call(CP_UTF8, 0, self, -1, nil, 0)
  38. buf = "\0" * (len*2)
  39. m2w.call(CP_UTF8, 0, self, -1, buf, buf.size/2)
  40.  
  41. len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil)
  42. ret = "\0" * len
  43. w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil)
  44.  
  45. return ret
  46. end
  47.  
  48. def s2u
  49. m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")
  50. w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")
  51.  
  52. len = m2w.call(CP_ACP, 0, self, -1, nil, 0);
  53. buf = "\0" * (len*2)
  54. m2w.call(CP_ACP, 0, self, -1, buf, buf.size/2);
  55.  
  56. len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
  57. ret = "\0" * len
  58. w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);
  59.  
  60. return ret
  61. end
  62.  
  63. def s2u!
  64. self[0, length] = s2u
  65. end
  66.  
  67. def u2s!
  68. self[0, length] = u2s
  69. end
  70.  
  71. end
  72.  
  73. class Bitmap
  74.  
  75. RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  76. RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
  77.  
  78. def address
  79. buffer, ad = "xxxx", object_id * 2 + 16
  80. RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 8
  81. RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 16
  82. RtlMoveMemory_pi.call(buffer, ad, 4); return buffer.unpack("L")[0]
  83. end
  84.  
  85. end
  86.  
  87. class RMFlash
  88.  
  89. API_NEW   = Win32API.new("RMFlash", "_new", "piil", "l")
  90. API_UPDATE   = Win32API.new("RMFlash", "_update", "l", "v")
  91. API_FREE   = Win32API.new("RMFlash", "_free", "l", "v")
  92. API_PLAYING = Win32API.new("RMFlash", "_is_playing", "l", "i")
  93. API_PAUSE   = Win32API.new("RMFlash", "_pause", "l", "v")
  94. API_RESUME   = Win32API.new("RMFlash", "_resume", "l", "v")
  95. API_BACK   = Win32API.new("RMFlash", "_back", "l", "v")
  96. API_REWIND   = Win32API.new("RMFlash", "_rewind", "l", "v")
  97. API_FORWARD   = Win32API.new("RMFlash", "_forward", "l", "v")
  98. API_CURFRAME   = Win32API.new("RMFlash", "_cur_frame", "l", "i")
  99. API_TOTALFRAME  = Win32API.new("RMFlash", "_total_frames", "l", "i")
  100. API_GOTOFRAME   = Win32API.new("RMFlash", "_goto_frame", "li", "v")
  101. API_GETLOOP   = Win32API.new("RMFlash", "_get_loop", "l", "i")
  102. API_SETLOOP   = Win32API.new("RMFlash", "_set_loop", "li", "v")
  103. API_CLEARALL   = Win32API.new("RMFlash", "_clear_all", "v", "v")
  104. API_VALID = Win32API.new("RMFlash", "_valid", "l", "i")
  105. API_SENDMSG = Win32API.new("RMFlash", "_send_message", "liii", "l")
  106.  
  107. CUR_PATH = Dir.pwd
  108.  
  109. def self.get_version
  110.  
  111. end
  112.  
  113. def self.clear_all
  114. API_CLEARALL.call
  115. end
  116.  
  117. def self.load(name, width, height, v = nil)
  118. new("#{CUR_PATH}/Graphics/Flash/Untitled.swf".u2s, width, height, v)
  119. end
  120.  
  121. attr_reader :valid
  122.  
  123. def initialize(flash_name, flash_width, flash_height, viewport = nil)
  124. @sprite = Sprite.new(viewport)
  125. @sprite.bitmap = Bitmap.new(flash_width, flash_height)
  126. @value = API_NEW.call(flash_name, flash_width, flash_height, @sprite.bitmap.address)
  127. @loop = API_GETLOOP.call(@value) > 0
  128. @valid = API_VALID.call(@value) > 0
  129. end
  130.  
  131. def viewport
  132. @sprite.viewport
  133. end
  134.  
  135. def update
  136. API_UPDATE.call(@value)
  137. end
  138.  
  139. def dispose
  140. API_FREE.call(@sprite.bitmap.address)
  141. end
  142.  
  143. def playing?
  144. API_PLAYING.call(@value) > 0
  145. end
  146.  
  147. def pause
  148. API_PAUSE.call(@value)
  149. end
  150.  
  151. def resume
  152. API_RESUME.call(@value)
  153. end
  154.  
  155. def back
  156. API_BACK.call(@value)
  157. end
  158.  
  159. def rewind
  160. API_REWIND.call(@value)
  161. end
  162.  
  163. def forward
  164. API_FORWARD.call(@value)
  165. end
  166.  
  167. def current_frame
  168. API_CURFRAME.call(@value)
  169. end
  170.  
  171. def total_frames
  172. API_TOTALFRAME.call(@value)
  173. end
  174.  
  175. def goto_frame(goal_frame)
  176. API_GOTOFRAME.call(@value, goal_frame)
  177. end
  178.  
  179. def x
  180. @sprite.x
  181. end
  182.  
  183. def x=(v)
  184. @sprite.x = v
  185. end
  186.  
  187. def y
  188. @sprite.y
  189. end
  190.  
  191. def y=(v)
  192. @sprite.y = v
  193. end
  194.  
  195. def z
  196. @sprite.z
  197. end
  198.  
  199. def z=(v)
  200. @sprite.z = v
  201. end
  202.  
  203. def width
  204. @sprite.bitmap.width
  205. end
  206.  
  207. def height
  208. @sprite.bitmap.height
  209. end
  210.  
  211. def loop?
  212. @loop
  213. end
  214.  
  215. def loop=(v)
  216. if @loop != v
  217. @loop = v
  218. API_SETLOOP.call(@value, v)
  219. end
  220. end
  221.  
  222. def msg_to_flash(msg, wParam, lParam)
  223. return API_SENDMSG.call(@value, msg, wParam, lParam)
  224. end
  225.  
  226. # ?
  227. WM_MOUSEMOVE = 0x0200
  228.  
  229. def make_long(a, b)
  230. return (a & 0xffff ) | (b & 0xffff) << 16
  231. end
  232.  
  233. def on_mouse_move(x, y)
  234. return msg_to_flash(WM_MOUSEMOVE, 0, make_long(x, y))
  235. end
  236.  
  237. end
  238.  
  239. module Kernel
  240.  
  241. alias origin_exit exit unless method_defined? :exit
  242.  
  243. def exit(*args)
  244. RMFlash.clear_all
  245. origin_exit(*args)
  246. end
  247.  
  248. end
  249.  
  250. module Keyb
  251. $keys = {}
  252. $keys["Enter"] = 0x0D
  253. GetKeyState = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
  254. module_function
  255. def trigger(rkey)
  256. GetKeyState.call(rkey) & 0x01 == 1
  257. end
  258. end
  259.  
  260. class Play
  261.  
  262. def play(filename, button)
  263. fondo = Sprite.new
  264. fondo.bitmap = Bitmap.new(512, 384)
  265. fondo.bitmap.fill_rect(0, 0, 512, 384, Color.new(0,0,0,255))
  266. fls = RMFlash.load(filename, 512, 384)
  267. fls.loop = 1
  268. fls.z = 999999
  269. @button = button
  270. @fr = Graphics.frame_rate
  271. Graphics.frame_rate = 40
  272.  
  273. while true
  274. Graphics.update
  275. #Input.update
  276. fls.update
  277. break if @button == 1 and Keyb.trigger($keys["Enter"])
  278. break if !fls.playing?
  279. end
  280. fls.dispose
  281. Graphics.frame_rate = @fr
  282. fondo.dispose
  283. end
  284. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top