Advertisement
Guest User

Untitled

a guest
Sep 19th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.57 KB | None | 0 0
  1. #==============================================================================
  2. # ** Game_System
  3. #------------------------------------------------------------------------------
  4. # This class handles data surrounding the system. Backround music, etc.
  5. # is managed here as well. Refer to "$game_system" for the instance of
  6. # this class.
  7. #==============================================================================
  8.  
  9. class Game_System
  10. attr_reader :map_interpreter # map event interpreter
  11. attr_reader :battle_interpreter # battle event interpreter
  12. attr_accessor :timer # timer
  13. attr_accessor :timer_working # timer working flag
  14. attr_accessor :save_disabled # save forbidden
  15. attr_accessor :menu_disabled # menu forbidden
  16. attr_accessor :encounter_disabled # encounter forbidden
  17. attr_accessor :message_position # text option: positioning
  18. attr_accessor :message_frame # text option: window frame
  19. attr_accessor :save_count # save count
  20. attr_accessor :magic_number # magic number
  21. attr_accessor :autoscroll_x_speed
  22. attr_accessor :autoscroll_y_speed
  23. attr_accessor :bgm_position
  24.  
  25. def initialize
  26. if $RPGVX
  27. @map_interpreter = Game_Interpreter.new(0, true)
  28. @battle_interpreter = Game_Interpreter.new(0, false)
  29. else
  30. @map_interpreter = Interpreter.new(0, true)
  31. @battle_interpreter = Interpreter.new(0, false)
  32. end
  33. @timer = 0
  34. @timer_working = false
  35. @save_disabled = false
  36. @menu_disabled = false
  37. @encounter_disabled = false
  38. @message_position = 2
  39. @message_frame = 0
  40. @save_count = 0
  41. @magic_number = 0
  42. @autoscroll_x_speed = 0
  43. @autoscroll_y_speed = 0
  44. @bgm_position=0
  45. @bgs_position=0
  46. end
  47.  
  48. def bgm_play(bgm)
  49. bgm_play_internal(bgm,0)
  50. end
  51.  
  52. def bgm_play_internal2(name,volume,pitch,position) #VOLUME
  53. volume=$PokemonSystem.volume if $PokemonSystem #VOLUME
  54. begin #VOLUME
  55. Audio.bgm_play(name,volume,pitch,position)
  56. rescue ArgumentError
  57. Audio.bgm_play(name,volume,pitch)
  58. end
  59. end
  60.  
  61. def bgm_play_internal(bgm,position) # :nodoc:
  62. if !@bgm_paused
  63. @bgm_position=position
  64. end
  65. @playing_bgm = bgm==nil ? nil : bgm.clone
  66. if bgm != nil and bgm.name != ""
  67. if FileTest.audio_exist?("Audio/BGM/"+ bgm.name)
  68. bgm_play_internal2("Audio/BGM/" + bgm.name, bgm.volume, bgm.pitch,
  69. @bgm_position) if !@defaultBGM
  70. end
  71. else
  72. if !@bgm_paused
  73. @bgm_position=position
  74. end
  75. @playing_bgm=nil
  76. Audio.bgm_stop if !@defaultBGM
  77. end
  78. if @defaultBGM
  79. bgm_play_internal2("Audio/BGM/"+@defaultBGM.name,
  80. @defaultBGM.volume,@defaultBGM.pitch,@bgm_position)
  81. end
  82. Graphics.frame_reset
  83. end
  84.  
  85. def bgm_pause(fadetime=0.0) # :nodoc:
  86. pos=Audio.bgm_position rescue 0
  87. if fadetime>0.0
  88. self.bgm_fade(fadetime)
  89. end
  90. @bgm_position=pos
  91. @bgm_paused=true
  92. end
  93.  
  94. def bgs_pause(fadetime=0.0) # :nodoc:
  95. if fadetime>0.0
  96. self.bgs_fade(fadetime)
  97. else
  98. self.bgs_stop
  99. end
  100. @bgs_paused=true
  101. end
  102.  
  103. def bgm_unpause; # :nodoc:
  104. @bgm_position=0; @bgm_paused=false;
  105. end
  106.  
  107. def bgs_unpause; # :nodoc:
  108. @bgs_paused=false
  109. end
  110.  
  111. def bgm_resume(bgm) # :nodoc:
  112. if @bgm_paused
  113. self.bgm_play_internal(bgm,@bgm_position)
  114. @bgm_position=0
  115. @bgm_paused=false
  116. end
  117. end
  118.  
  119. def bgs_resume(bgs) # :nodoc:
  120. if @bgs_paused
  121. self.bgs_play(bgs)
  122. @bgs_paused=false
  123. end
  124. end
  125.  
  126. def bgm_stop # :nodoc:
  127. if !@bgm_paused
  128. @bgm_position=0
  129. end
  130. @playing_bgm = nil
  131. Audio.bgm_stop if !@defaultBGM
  132. end
  133.  
  134. def bgm_fade(time) # :nodoc:
  135. if !@bgm_paused
  136. @bgm_position=0
  137. end
  138. @playing_bgm = nil
  139. Audio.bgm_fade((time * 1000).floor) if !@defaultBGM
  140. end
  141.  
  142. # Returns an RPG::AudioFile object for the currently playing background music
  143. def getPlayingBGM
  144. return @playing_bgm ? @playing_bgm.clone : nil
  145. end
  146.  
  147. # Saves the currently playing background music for later playback.
  148. def bgm_memorize
  149. @memorized_bgm = @playing_bgm
  150. end
  151.  
  152. # Plays the currently memorized background music
  153. def bgm_restore
  154. bgm_play(@memorized_bgm)
  155. end
  156.  
  157. def bgs_play(bgs)
  158. $PokemonSystem.soundvolume=100 if !$PokemonSystem.soundvolume #VOLUME
  159. volume=$PokemonSystem.soundvolume #VOLUME
  160. @playing_bgs = bgs==nil ? nil : bgs.clone
  161. if bgs != nil and bgs.name != ""
  162. if FileTest.audio_exist?("Audio/BGS/"+ bgs.name)
  163. Audio.bgs_play("Audio/BGS/" + bgs.name, volume, bgs.pitch) #VOLUME
  164. end
  165. else
  166. @bgs_position=0
  167. @playing_bgs=nil
  168. Audio.bgs_stop
  169. end
  170. Graphics.frame_reset
  171. end
  172.  
  173. def bgs_fade(time)
  174. @bgs_position=0
  175. @playing_bgs = nil
  176. Audio.bgs_fade((time * 1000).floor)
  177. end
  178.  
  179. def bgs_stop
  180. @bgs_position=0
  181. @playing_bgs = nil
  182. Audio.bgs_stop
  183. end
  184.  
  185. def getPlayingBGS
  186. return @playing_bgs ? @playing_bgs.clone : nil
  187. end
  188.  
  189. def bgs_memorize
  190. @memorized_bgs = @playing_bgs
  191. end
  192.  
  193. def bgs_restore
  194. bgs_play(@memorized_bgs)
  195. end
  196.  
  197. def setDefaultBGM(bgm,volume=80,pitch=100)
  198. volume=$PokemonSystem.volume if $PokemonSystem #VOLUME
  199. if bgm.is_a?(String)
  200. bgm=RPG::AudioFile.new(bgm,volume,pitch)
  201. end
  202. if bgm != nil and bgm.name != ""
  203. @defaultBGM=nil
  204. self.bgm_play(bgm)
  205. @defaultBGM=bgm.clone
  206. else
  207. @defaultBGM=nil
  208. self.bgm_play(@playing_bgm)
  209. end
  210. end
  211.  
  212. def me_play(me)
  213. $PokemonSystem.soundvolume=100 if !$PokemonSystem.soundvolume #VOLUME
  214. volume=$PokemonSystem.soundvolume #VOLUME
  215.  
  216. if me.is_a?(String)
  217. me=RPG::AudioFile.new(me)
  218. end
  219. if me != nil and me.name != ""
  220. if FileTest.audio_exist?("Audio/ME/"+me.name)
  221. Audio.me_play("Audio/ME/" + me.name, volume, me.pitch) #VOLUME
  222. end
  223. else
  224. Audio.me_stop
  225. end
  226. Graphics.frame_reset
  227. end
  228.  
  229. def se_play(se)
  230. $PokemonSystem.soundvolume=100 if !$PokemonSystem.soundvolume #VOLUME
  231. volume=$PokemonSystem.soundvolume #VOLUME
  232. if se.is_a?(String)
  233. se=RPG::AudioFile.new(se)
  234. end
  235. if se != nil and se.name != ""
  236. if FileTest.audio_exist?("Audio/SE/"+ se.name)
  237. Audio.se_play("Audio/SE/" + se.name, volume, se.pitch) #VOLUME
  238. end
  239. end
  240. end
  241.  
  242. def se_stop
  243. Audio.se_stop
  244. end
  245.  
  246. def playing_bgm
  247. return @playing_bgm
  248. end
  249.  
  250. def playing_bgs
  251. return @playing_bgs
  252. end
  253.  
  254. def windowskin_name
  255. if @windowskin_name == nil
  256. return $data_system.windowskin_name
  257. else
  258. return @windowskin_name
  259. end
  260. end
  261.  
  262. def windowskin_name=(windowskin_name)
  263. @windowskin_name = windowskin_name
  264. end
  265.  
  266. def battle_bgm
  267. if @battle_bgm == nil
  268. return $data_system.battle_bgm
  269. else
  270. return @battle_bgm
  271. end
  272. end
  273.  
  274. def battle_bgm=(battle_bgm)
  275. @battle_bgm = battle_bgm
  276. end
  277.  
  278. def battle_end_me
  279. if @battle_end_me == nil
  280. return $data_system.battle_end_me
  281. else
  282. return @battle_end_me
  283. end
  284. end
  285.  
  286. def battle_end_me=(battle_end_me)
  287. @battle_end_me = battle_end_me
  288. end
  289.  
  290. def update
  291. if @timer_working and @timer > 0
  292. @timer -= 1
  293. end
  294. if Input.trigger?(Input::F5) && pbCurrentEventCommentInput(1,"Cut Scene")
  295. event=@map_interpreter.get_character(0)
  296. @map_interpreter.pbSetSelfSwitch(event.id,"A",true)
  297. @map_interpreter.command_end
  298. event.start
  299. end
  300. end
  301. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement