Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Scene_Map
- def call_menu
- $game_temp.menu_calling = false
- $game_player.straighten
- $game_map.update
- pbCallMenu2
- end
- end
- class Menu2
- def update;end
- def initialize
- @selected_item = 0
- @items = []
- @bagCmd = addCmd(["bag","Mochila","openBag"])
- @partyCmd = addCmd(["pokeball","Equipo","openParty"])
- @trainerCmd = addCmd(["trainer","Mochila","openTrainerCard"])
- @saveCmd = addCmd(["save","Mochila","openSave"])
- @optionsCmd = addCmd(["options","Opciones","openOptions"])
- @debugCmd = addCmd(["debug","Mochila","pbDebugMenu"]) if $DEBUG
- @exitCmd = addCmd(["exit","Mochila","exitMenu"])
- @icon_width = 66
- @icon_height = 66
- @n_icons = 4 #iconos por fila
- @spacing_x = 20 #espacio en x entre los iconos
- @spacing_y = 20 #espacio en y entre los iconos
- @menu_width = @n_icons*(@icon_width+@spacing_x)-@spacing_x
- @menu_height = (@items.length/@n_icons.to_f).ceil*(@icon_height+@spacing_y)-@spacing_y
- @x_margin = (Graphics.width-@menu_width)/2 #separación entre los iconos y el borde izquiero de la pantalla
- @y_margin = (Graphics.height-@menu_height)/2 #separación entre los iconos y el borde superior de la pantalla
- @exit = false
- end
- def pbStartScene # CARGA LAS COSAS
- @sprites={}
- @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport.z=99999
- @sprites["bg"]=Sprite.new(@viewport)
- @sprites["bg"].bitmap=RPG::Cache.picture("menu/menubg")
- #@totalElements = 7
- radius = 100
- counter = 0
- for item in @items
- @sprites["item_#{counter}"] = Sprite.new(@viewport)
- @sprites["item_#{counter}"].bitmap=RPG::Cache.picture("menu/"+item[0])
- @sprites["item_#{counter}"].x=@x_margin + ((@icon_width+@spacing_x) * (counter%@n_icons))
- @sprites["item_#{counter}"].y=@y_margin + ((@icon_height+@spacing_y) * (counter/@n_icons))
- counter += 1
- end
- @sprites["selector"]=Sprite.new(@viewport)
- @sprites["selector"].bitmap=RPG::Cache.picture("menu/menu_selection")
- redrawSelector
- @sprites["selector"].z=99999
- pbSEPlay("menu")
- end
- def pbEndScene # CUANDO TERMINA...
- pbDisposeSpriteHash(@sprites)
- @viewport.dispose if @viewport
- end
- def redrawSelector
- @sprites["selector"].x=@x_margin + ((@icon_width+@spacing_x) * (@selected_item%@n_icons))
- @sprites["selector"].y=@y_margin + ((@icon_height+@spacing_y) * (@selected_item/@n_icons))
- end
- def addCmd(item)
- return @items.push(item).length-1
- end
- def pbUpdate
- @xcount=999
- @posible1=0
- @posible2=0
- @posible3=0
- loop do
- Input.update
- ################### FUNCIONES AQUÍ #######
- if Input.trigger?(Input::RIGHT)
- @selected_item+=1
- end
- if Input.trigger?(Input::LEFT)
- @selected_item-=1
- end
- if Input.trigger?(Input::UP)
- @selected_item-=@n_icons
- if(@selected_item < 0)
- @selected_item = 0
- end
- end
- if Input.trigger?(Input::DOWN)
- @selected_item+=@n_icons
- if(@selected_item > @items.length-1)
- @selected_item = @items.length-1
- end
- end
- if (@selected_item < 0)
- @selected_item = @items.length-1
- end
- if (@selected_item >= @items.length)
- @selected_item=0
- end
- if Input.trigger?(Input::C)
- send(@items[@selected_item][2])
- end
- break if Input.trigger?(Input::B) # CIERRA EL MENÚ
- break if @exit
- redrawSelector
- Graphics.update
- end # loop
- end # update
- end # Cierra la class
- ###################################################
- def pbCallMenu2
- scene=Menu2.new
- scene.pbStartScene
- scene.pbUpdate
- scene.pbEndScene
- end
- def exitMenu
- @exit = true
- end
- def openOptions
- if defined?(PokemonOptionScene) == 'constant' && PokemonOptionScene.class == Class
- scene=PokemonOptionScene.new
- screen=PokemonOption.new(scene)
- pbFadeOutIn(99999) { screen.pbStartScreen(true) }
- else
- pbFadeOutIn(99999){
- scene = PokemonOption_Scene.new
- screen = PokemonOptionScreen.new(scene)
- screen.pbStartScreen(true)
- }
- end
- end
- def openBag
- item=0
- scene=PokemonBag_Scene.new
- screen=PokemonBagScreen.new(scene,$PokemonBag)
- pbFadeOutIn(99999) {
- item=screen.pbStartScreen
- if item>0
- pbEndScene
- else
- #@scene.pbRefresh
- end
- }
- if item>0
- Kernel.pbUseKeyItemInField(item)
- exitMenu #Corrección 01-11-2018
- return
- end
- end
- def openParty
- if defined?(PokemonScreen_Scene) == 'constant' && PokemonScreen_Scene.class == Class
- if Input.trigger?(Input::C)
- sscene=PokemonScreen_Scene.new
- sscreen=PokemonScreen.new(sscene,$Trainer.party)
- hiddenmove=nil
- pbFadeOutIn(99999) {
- hiddenmove=sscreen.pbPokemonScreen
- if hiddenmove
- pbEndScene
- else
- #@scene.pbRefresh
- end
- }
- if hiddenmove
- Kernel.pbUseHiddenMove(hiddenmove[0],hiddenmove[1])
- exitMenu #Corrección 01-11-2018
- return
- end
- end
- else
- if Input.trigger?(Input::C)
- sscene=PokemonParty_Scene.new
- sscreen=PokemonPartyScreen.new(sscene,$Trainer.party)
- hiddenmove=nil
- pbFadeOutIn(99999) {
- hiddenmove=sscreen.pbPokemonScreen
- if hiddenmove
- pbEndScene
- else
- #@scene.pbRefresh
- end
- }
- if hiddenmove
- Kernel.pbUseHiddenMove(hiddenmove[0],hiddenmove[1])
- exitMenu #Corrección 01-11-2018
- return
- end
- end
- end
- end
- def openTrainerCard
- if defined?(PokemonTrainerCardScene) == 'constant' && PokemonTrainerCardScene.class == Class
- scene=PokemonTrainerCardScene.new
- screen=PokemonTrainerCard.new(scene)
- pbFadeOutIn(99999) {
- screen.pbStartScreen
- }
- else
- scene=PokemonTrainerCard_Scene.new
- screen=PokemonTrainerCardScreen.new(scene)
- pbFadeOutIn(99999) {
- screen.pbStartScreen
- }
- end
- end
- def openSave
- if defined?(PokemonSaveScene) == 'constant' && PokemonSaveScene.class == Class
- scene=PokemonSaveScene.new
- screen=PokemonSave.new(scene)
- if screen.pbSaveScreen
- endscene=false
- @exit = true
- #break
- end
- else
- scene=PokemonSave_Scene.new
- screen=PokemonSaveScreen.new(scene)
- if screen.pbSaveScreen
- endscene=false
- @exit = true
- #break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement