Advertisement
warriortimmy

Menu Module

Mar 12th, 2011
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 44.97 KB | None | 0 0
  1. =begin
  2.  
  3.   *** SCRIPT CREADO POR NEWOLD, FEBRERO-MARZO 2011, TRIPLE TRIAD 1.0 ***
  4.  
  5. =end
  6.  
  7. class CardsMenu
  8.   # ---------------------------------------------------------------------------
  9.   def initialize
  10.     $deck['backupresolution'][0] = Graphics.width
  11.     $deck['backupresolution'][1] = Graphics.height
  12.     Graphics.resize_screen(640, 480)
  13.     # *******************************************************
  14.     # INICIO CONFIGURACIÓN
  15.     # *******************************************************
  16.    
  17.     # Imagenes ...............................................
  18.     # ........................................................
  19.     # Ruta que contiene las cartas del juegos
  20.     @foldercards = "CardsGame/cards/"
  21.     # Ruta imagen de fondo
  22.     @backgroundimage = "CardsGame/background/fondo2"
  23.     # Ruta imagen indicadores Ventanas 1 y 2
  24.     @indicatorsimage = "CardsGame/cursor/indicador4"
  25.     # Ruta imagen indicadores Ventana 4
  26.     @indicatorsimage2 = "CardsGame/cursor/indicador5"
  27.     # Ruta Imagen del cursor
  28.     @cursorbitmap = "CardsGame/cursor/1"
  29.     # Ruta Imagen del selector en la ventana 2 (Ventana de cartas)
  30.     @selectorcardsbitmap = "CardsGame/cursor/menu_cards_selector"
  31.     # Ruta imagen de ventana 1
  32.     @win1image = "CardsGame/background/cardsmenu_win1"
  33.     # Ruta imagen de ventana 2
  34.     @win2image = "CardsGame/background/cardsmenu_win2"
  35.     # Ruta imagen de ventana 3
  36.     @win3image = "CardsGame/background/cardsmenu_win3"
  37.     # Ruta imagen de ventana 4
  38.     @win4image = "CardsGame/background/cardsmenu_win4"
  39.     # Ruta imágenes barra desplazamiento ventana 4
  40.     @win4barbottom = "CardsGame/background/barbotton" # Parte Inferior
  41.     @win4bartop = "CardsGame/background/bartop" # Parte superior
  42.     # Ruta imagen carta desconocida
  43.     @nocardimage = "CardsGame/cards/carta_no_encontrada"
  44.     # Ruta icono miniestrella (Se muestra al lado de las categorías completas)
  45.     @ministar = "CardsGame/icons/ministar"
  46.  
  47.     # Sonidos ...............................................
  48.     # ........................................................
  49.     # Sonido que se produce al mover el cursor
  50.     @soundcursor = "CardsGame/sound/cursor1"
  51.     # Sonido que se produce al cancelar
  52.     @soundcancel = "CardsGame/sound/fx4"
  53.    
  54.     # Textos ...............................................
  55.     # ........................................................
  56.     @textos = [
  57.       ["Página","de","Categoría completada al"],
  58.       ["Nombre","Categoría","Carta única","Cartas en posesión",
  59.        "Atributo","Ninguno","Carta","Atk"],
  60.       ["Usa las teclas de dirección para cambiar las categorías / páginas",
  61.        "L y R : Cambia la página actual   Direcciones : Moverse por el panel"],
  62.       ["Colección completada al","Tu baraja tiene","carta"]
  63.     ]
  64.    
  65.     # *******************************************************
  66.     # FIN CONFIGURACIÓN
  67.     # *******************************************************
  68.   end
  69.   # ---------------------------------------------------------------------------
  70.   def main
  71.     @exit = false
  72.     @index1 = 0
  73.     @index2 = 0
  74.     @page1 = 0
  75.     @page2 = 0
  76.     @maxitemspage1 = 10
  77.     @maxitemspage2 = 12
  78.     @cardsnumber = {}
  79.     @maxpag2 = {}
  80.     @data0 = {}
  81.     @data1 = getdatawin1
  82.     @data2 = getdatawin2
  83.     @maxpage1 = @data1.size / @maxitemspage1
  84.     if @data1[(@maxpage1 * @maxitemspage1)] == nil and (@maxpage1 - 1) >= 0
  85.       @maxpage1 -= 1
  86.     end
  87.     @fondo = Sprite.new
  88.     @fondo.bitmap = Bitmap.new(@backgroundimage)
  89.     @fondo.opacity = 0
  90.     @cursor = Sprite.new
  91.     @cursor.bitmap = Bitmap.new(@cursorbitmap)
  92.     @cursor.z = 2000
  93.     @cursor.visible = false
  94.     cursor_ini
  95.     @selector = Sprite.new
  96.     @selector.opacity = 110
  97.     @selector.blend_type = 2
  98.     @selector.z = 2000
  99.     @selector.visible = false
  100.     @selector_win2 = Sprite.new
  101.     @selector_win2.bitmap = Bitmap.new(@selectorcardsbitmap)
  102.     @selector_win2.z = 249
  103.     @selector_win2.visible = false
  104.     indicators = Bitmap.new(@indicatorsimage2)
  105.     @indicatorwin4top = Sprite.new
  106.     @indicatorwin4top.bitmap = Bitmap.new(10,10)
  107.     @indicatorwin4top.bitmap.blt(0,0,indicators,Rect.new(0,0,10,10))
  108.     @indicatorwin4top.x = 220
  109.     @indicatorwin4top.y = 249
  110.     @indicatorwin4top.z = 10000
  111.     @indicatorwin4top.visible = false
  112.     @indicatorwin4bottom = Sprite.new
  113.     @indicatorwin4bottom.bitmap = Bitmap.new(10,10)
  114.     @indicatorwin4bottom.bitmap.blt(0,0,indicators,Rect.new(0,10,10,10))
  115.     @indicatorwin4bottom.x = 220
  116.     @indicatorwin4bottom.y = 388
  117.     @indicatorwin4bottom.z = 10000
  118.     @indicatorwin4bottom.visible = false
  119.    
  120.     # ----------------------------------------------
  121.     # Animación del Cursor
  122.     # ----------------------------------------------
  123.     @aniglobal = [-1,-1,0,0,0,0,0,1,1,1,0,0,0,-1]
  124.     @aniglobal.concat(@aniglobal.reverse)
  125.     @anicursor = 0
  126.     # ----------------------------------------------
  127.     viewport1 = Viewport.new(15,23,200,434)
  128.     @win1 = Sprite.new(viewport1)
  129.     @win1.bitmap = Bitmap.new(@win1image)
  130.     @win1.x = -200
  131.     @win1.y = 0
  132.     viewport2 = Viewport.new(204,23,420,434)
  133.     @win2 = Sprite.new(viewport2)
  134.     @win2.bitmap = Bitmap.new(@win2image)
  135.     @win2.x = 428
  136.     @win2.y = 0
  137.     viewport3 = Viewport.new(106,140,428,260)
  138.     viewport3.z = 250
  139.     @win3 = Sprite.new(viewport3)
  140.     @win3.x = 412
  141.     @win3.y = 0
  142.     @win3.z = 250
  143.     @win3.visible = false
  144.     viewport4 = Viewport.new(113,250,233,145)
  145.     viewport4.z = 251
  146.     @win4 = Sprite.new(viewport4)
  147.     @win4.x = 0
  148.     @win4.y = -233
  149.     @win4.z = 251
  150.     @win4.visible = false
  151.     @datawin1bitmap = Sprite.new(viewport1)
  152.     @datawin1bitmap.bitmap = Bitmap.new(192,434)
  153.     @datawin1bitmap.x = -200
  154.     @datawin1bitmap.y = 0
  155.     @datawin2bitmap = Sprite.new(viewport2)
  156.     @datawin2bitmap.bitmap = Bitmap.new(412,434)
  157.     @datawin2bitmap.x = 420
  158.     @datawin2bitmap.y = 0
  159.     viewport5 = Viewport.new(113,255,233,135)
  160.     viewport5.z = 2000
  161.     @datawin4bitmap = Sprite.new(viewport5)
  162.     @datawin4bitmap.x = 0
  163.     @datawin4bitmap.oy = 233
  164.     @previewimas = {}
  165.     # ----------------------------------------------
  166.     drawcontentwin1
  167.     drawcontentwin2
  168.     drawwin1selection
  169.     drawnumberpage
  170.     @numberpageima.visible = false
  171.     # ----------------------------------------------
  172.     @helpwindow = Sprite.new
  173.     @helpwindow.bitmap = Bitmap.new(640,22)
  174.     @helpwindow.bitmap.font.size = 18
  175.     @helpwindow2 = Sprite.new
  176.     @helpwindow2.bitmap = Bitmap.new(640,22)
  177.     @helpwindow2.bitmap.font.size = 18
  178.     @helpwindow2.y = 452
  179.     # ----------------------------------------------
  180.     @datawin1bitmap.opacity = 255
  181.     @datawin2bitmap.opacity = 255
  182.     for i in 0...10
  183.       @win1.x += 20
  184.       @datawin1bitmap.x += 20
  185.       @win2.x -= 42
  186.       @datawin2bitmap.x -= 42
  187.       @fondo.opacity += 25
  188.       Graphics.update
  189.     end
  190.     # ----------------------------------------------
  191.     @cursor.visible = true
  192.     @numberpageima.visible = true
  193.     @win = 1
  194.     @global_frame = 0
  195.     @indicator_frame = 0
  196.     animatepages
  197.     updatehelpwindow
  198.     updatehelpwindow2
  199.     n = 0
  200.     # ----------------------------------------------
  201.     Graphics.transition(20)
  202.     loop do
  203.       @global_frame += 1
  204.       Graphics.update
  205.       Input.update
  206.       animatecursor
  207.       animatestars if @global_frame % 2 == 0
  208.       fadeindatawinbitmap
  209.       if @global_frame == 10
  210.         @global_frame = 0
  211.         @indicator_frame == 0 ? @indicator_frame = 1 : @indicator_frame = 0
  212.         animatepages
  213.       end
  214.       n += 1
  215.       if n == 300
  216.         n = 0
  217.         Graphics.frame_reset
  218.       end
  219.       case @win
  220.       when 1
  221.         update_win1
  222.       when 2
  223.         update_win2
  224.       when 3
  225.         update_win3
  226.         refresh_indicators_win4
  227.         refresh_cardpreview_opacity
  228.       end
  229.       if @exit
  230.         $scene = Scene_Map.new
  231.         break
  232.       end
  233.       #break if @exit
  234.     end
  235.     dispose
  236.     Input.update
  237.     Graphics.resize_screen($deck['backupresolution'][0], $deck['backupresolution'][1])
  238.   end
  239.   # ---------------------------------------------------------------------------
  240.   def updatehelpwindow
  241.     @helpwindow.bitmap.clear
  242.     case @win
  243.     when 1
  244.       text = @textos[2][0]
  245.     when 2
  246.       text = @textos[2][1]
  247.     else
  248.       text = ''
  249.     end
  250.     data_pos = [[0,-1],[0,2]]
  251.     color1 = Color.new(51,52,1,255)
  252.     color2 = Color.new(252,255,2,255)
  253.     @helpwindow.bitmap.font.color = color1
  254.     for i in 0...data_pos.size
  255.       x = 25 + data_pos[i][0]
  256.       y = 2 + data_pos[i][1]
  257.       @helpwindow.bitmap.draw_text(x,y,600,22,text)
  258.     end
  259.     @helpwindow.bitmap.font.color = color2
  260.     @helpwindow.bitmap.draw_text(25,2,600,22,text)
  261.   end
  262.   # ---------------------------------------------------------------------------
  263.   def updatehelpwindow2
  264.     data_pos = [[0,-1],[0,2]]
  265.     color1 = Color.new(51,52,1,255)
  266.     color2 = Color.new(252,255,2,255)
  267.     text1 = sprintf('%.2f', checkplayercollection) # Porcentaje de colección
  268.     text2 = checkplayercards # Total cartas
  269.     s = (text2 != 1 ? 's' : '') # plural
  270.     text3 = @textos[3][0] # Categoría completada al
  271.     text4 = @textos[3][1] # Tu baraja tiene...
  272.     text5 = @textos[3][2] # carta...
  273.     text = "#{text4} #{text2} #{text5}#{s}      #{text3} #{text1}%"
  274.     @helpwindow2.bitmap.font.color = color1
  275.     for i in 0...data_pos.size
  276.       x = 25 + data_pos[i][0]
  277.       y = 2 + data_pos[i][1]
  278.       @helpwindow2.bitmap.draw_text(x,y,600,22,text,1)
  279.     end
  280.     @helpwindow2.bitmap.font.color = color2
  281.     @helpwindow2.bitmap.draw_text(25,2,600,22,text,1)
  282.   end
  283.   # ---------------------------------------------------------------------------
  284.   def checkplayercollection
  285.     # Devuelve el Porcentaje completado de la colección de cartas
  286.     total_cards = Newold::CARDS::Cards.size
  287.     player_cards = 0.0
  288.     for i in 0...$deck['player'].size
  289.       next if $deck['player'][i] == nil or $deck['player'][i] == []
  290.       player_cards += 1
  291.     end
  292.     return (player_cards / total_cards) * 100
  293.   end
  294.   # ---------------------------------------------------------------------------
  295.   def checkplayercards
  296.     # Devuelve el Total de cartas poseidas por el jugador
  297.     totalcards = 0
  298.     $deck['player'].each do |cards|
  299.       if cards != nil and cards != []
  300.         cards.each do |card|
  301.           totalcards += 1
  302.         end
  303.       end
  304.     end
  305.     return totalcards
  306.   end
  307.   # ---------------------------------------------------------------------------
  308.   def getdatawin1
  309.     data = Newold::CARDS::Cards
  310.     categorias = []
  311.     for i in 0...data.size
  312.       item = data[i]
  313.       cat = item[6]
  314.       categorias.push(cat) if !categorias.include?(cat)
  315.       @cardsnumber[cat] = [] if @cardsnumber[cat] == nil
  316.       @cardsnumber[cat].push(i)
  317.       if @maxpag2[cat] != nil
  318.         @maxpag2[cat] += 1
  319.       else
  320.         @maxpag2[cat] = 1
  321.       end
  322.     end
  323.     @maxpag2.each do |key,value|
  324.       @maxpag2[key] = value - 1
  325.     end
  326.     return categorias.sort
  327.   end
  328.   # ---------------------------------------------------------------------------
  329.   def getdatawin2
  330.     data = $deck['player']
  331.     cartas = {}
  332.     data.each do |item|
  333.       next if item == nil
  334.       next if item.size == 0
  335.       cat = item[0][9]
  336.       imaname = item[0][7]
  337.       cartas[cat] = [] if cartas[cat] == nil
  338.       cartas[cat].push(imaname) if !cartas.include?(imaname)
  339.       if @data0[imaname] == nil
  340.         @data0[imaname] = []
  341.       end
  342.       @data0[imaname].push(item)
  343.     end
  344.     return cartas
  345.   end
  346.   # ---------------------------------------------------------------------------
  347.   def drawcontentwin1
  348.     if @stars == nil
  349.       @stars = []
  350.     end
  351.     @stars.each do |star|
  352.       if star.is_a?(Array)
  353.         if star[0].is_a?(Sprite)
  354.           star[0].dispose
  355.         end
  356.       end
  357.     end
  358.     @stars = []
  359.     @datawin1bitmap.bitmap.clear
  360.     index = @index1 + (@page1 * @maxitemspage1)
  361.     x = 15
  362.     y = 5
  363.     data_pos = [[-1,0],[1,0],[0,1],[0,-1],[0,2]]
  364.     color1 = Color.new(255,255,255,255)
  365.     color2 = Color.new(0,0,0,255)
  366.     for i in index...index + @maxitemspage1
  367.       return if i >= @data1.size
  368.       cat = @data1[i]
  369.       if @data2[cat] != nil
  370.         complete_cards = (@data2[cat].size > @maxpag2[cat] ? true : false)
  371.         if complete_cards
  372.           star = Sprite.new
  373.           star.z = 10
  374.           star.x = 180
  375.           star.y = y + 23
  376.           @stars[i] = [star,0]
  377.         end
  378.       end
  379.       @datawin1bitmap.bitmap.font.color = color2
  380.       for z in 0...data_pos.size
  381.         x1 = x + data_pos[z][0]
  382.         y1 = y + data_pos[z][1]
  383.         @datawin1bitmap.bitmap.draw_text(x1,y1,150,22,@data1[i])
  384.       end
  385.       @datawin1bitmap.bitmap.font.color = color1
  386.       @datawin1bitmap.bitmap.draw_text(x,y,150,22,@data1[i])
  387.       y += 24
  388.     end
  389.     @datawin1bitmap.opacity = 0
  390.   end
  391.   # ---------------------------------------------------------------------------
  392.   def drawwin1selection
  393.     index0 = @index1 + (@page1 * @maxitemspage1)
  394.     x = 15
  395.     y = 5 + (@index1 * 24)
  396.     rect = Rect.new(x,y,172,24)
  397.     color1 = Color.new(0,0,0,0)
  398.     color2 = Color.new(58,204,202,255)
  399.     color3 = Color.new(255,255,255,255)
  400.     color4 = Color.new(0,0,0,255)
  401.     data_pos = [[-1,0],[1,0],[0,1],[0,-1],[0,2]]
  402.     if @last_index != nil
  403.       y2 = 5 + (@last_index * 24)
  404.       rect2 = Rect.new(x,y2,160,24)
  405.       @datawin1bitmap.bitmap.fill_rect(rect2,color1)
  406.       @datawin1bitmap.bitmap.font.color = color4
  407.       index1 = @last_index + (@page1 * @maxitemspage1)
  408.       for z in 0...data_pos.size
  409.         x1 = x + data_pos[z][0]
  410.         y1 = y2 + data_pos[z][1]
  411.         @datawin1bitmap.bitmap.draw_text(x1,y1,152,22,@data1[index1])
  412.       end
  413.       @datawin1bitmap.bitmap.font.color = color3
  414.       @datawin1bitmap.bitmap.draw_text(x,y2,152,22,@data1[index1])
  415.     end
  416.     @datawin1bitmap.bitmap.fill_rect(rect,color1)
  417.     @datawin1bitmap.bitmap.font.color = color4
  418.     for i in 0...data_pos.size
  419.       x1 = x + data_pos[i][0] + 7
  420.       y1 = y + data_pos[i][1]
  421.       @datawin1bitmap.bitmap.draw_text(x1,y1,152,22,@data1[index0].to_s)
  422.     end
  423.     @datawin1bitmap.bitmap.font.color = color2
  424.     @datawin1bitmap.bitmap.draw_text(x+7,y,152,22,@data1[index0].to_s)
  425.   end
  426.   # ---------------------------------------------------------------------------
  427.   def drawcontentwin2
  428.     @datawin2bitmap.bitmap.clear
  429.     index0 = @index1 + (@page1 * @maxitemspage1)
  430.     cat = @data1[index0]
  431.     return if index0 >= @data1.size
  432.     index = @index2# + (@page2 * @maxitemspage2)
  433.     nocard = Bitmap.new(@nocardimage)
  434.     y = 0
  435.     x = 0
  436.     imagedata = @data2[cat]
  437.     imagedata = [] if imagedata == nil
  438.     for i in index...index + @maxitemspage2
  439.       return if i > @maxpag2[cat]
  440.       if x == 4
  441.         x = 0
  442.         y += 1
  443.       end
  444.       if i < imagedata.size
  445.         if @previewimas["#{@foldercards}#{imagedata[i]}"] == nil
  446.           im = Bitmap.new("#{@foldercards}#{imagedata[i]}")
  447.           @previewimas["#{@foldercards}#{imagedata[i]}"] = im
  448.         else
  449.           im = @previewimas["#{@foldercards}#{imagedata[i]}"]
  450.         end
  451.         ima = Bitmap.new(91,128)
  452.         ima.stretch_blt(ima.rect,im,Rect.new(16,25,91,128))
  453.         @datawin2bitmap.bitmap.blt(21+(x*98),7+(y*133),ima,ima.rect)
  454.       else
  455.         @datawin2bitmap.bitmap.blt(21+(x*98),7+(y*133),nocard,nocard.rect)
  456.       end
  457.       x += 1
  458.     end
  459.     @datawin2bitmap.opacity = 0
  460.   end
  461.   # ---------------------------------------------------------------------------
  462.   def drawwin3
  463.     #$deck['elementallist']
  464.     @index3 = 0
  465.     index = @index1 + (@page1 * @maxitemspage1)
  466.     cat = @data1[index]
  467.     data = @data0[@data2[cat][@index2]][0]
  468.     cards_number = data.size
  469.     drawcontentwin3(data[@index3],cards_number)
  470.     @nodrawinwin4 = []
  471.     drawcontentwin4(data)
  472.     drawbarwin4(cards_number)
  473.     @maxitemwin4 = cards_number
  474.     @win3.visible = true
  475.     @win4.visible = true
  476.     @darkcontent = Sprite.new
  477.     @darkcontent.bitmap = Bitmap.new(640,480)
  478.     @darkcontent.bitmap.fill_rect(0,0,640,480,Color.new(0,0,0,160))
  479.     @darkcontent.opacity = 30
  480.     @darkcontent.z = 200
  481.     viewport = Viewport.new(352,148,177,250)
  482.     viewport.z = 252
  483.     @previewimage = Sprite.new(viewport)
  484.     @previewimage.bitmap = Bitmap.new(177,250)
  485.     @previewimage.x = 410
  486.     draw_card_preview(data[@index3])
  487.     @previewimage.z = 252
  488.     for i in 0...5
  489.       @win3.x -= 82
  490.       @previewimage.x -= 82
  491.       @darkcontent.opacity += 15
  492.       Graphics.update
  493.     end
  494.     viewport = Viewport.new(352,148,177,250)
  495.     viewport.z = 251
  496.     @backuppreviewimage = Sprite.new(viewport)
  497.     @backuppreviewimage.z = 251
  498.     @win3.x = 0
  499.     @datawin4bitmap.oy = 0 + @datawin4bitmap.bitmap.height
  500.     mod_y = @datawin4bitmap.oy / 10
  501.     for i in 0...10
  502.       @win4.y += 23
  503.       @datawin4bitmap.oy -= mod_y
  504.       @darkcontent.opacity += 15
  505.       Graphics.update
  506.     end
  507.     @datawin4bitmap.oy = 0
  508.     @win4.y = 0
  509.     @barbottom.visible = true
  510.     @bartop.visible = true
  511.   end
  512.   # ---------------------------------------------------------------------------
  513.   def drawcontentwin3(data,cards_number)
  514.     data_pos = [[1,0],[-1,0],[0,1],[0,-1],[0,2]]
  515.     color1 = Color.new(255,255,255,255)
  516.     color2 = Color.new(0,0,0,255)
  517.     color3 = Color.new(58,204,202,255)
  518.     color4 = Color.new(209,19,151,255)
  519.     color5 = Color.new(204,134,58,255)
  520.     color6 = Color.new(213,9,9,255)
  521.     color7 = Color.new(219,224,24,255)
  522.     @win3.bitmap = Bitmap.new(@win3image)
  523.     @win3.bitmap.font.size = 19
  524.     text1 = "#{@textos[1][0]}: " # nombre
  525.     text2 = "#{@textos[1][1]}: " # categoría
  526.     text3 = "#{@textos[1][2]}" # carta única
  527.     text4 = "#{@textos[1][3]} (" # Cartas en posesión
  528.     text5 = "#{@textos[1][4]}: " # atributo
  529.     text6 = "#{@textos[1][5]}" # palabra ninguno
  530.     name = data[1]
  531.     cat = data[9]
  532.     uniq = data[4]
  533.     iconelement = Bitmap.new(20,18)
  534.     if $deck['elementallist'][data[2]] != nil
  535.       textelement = $deck['elementallist'][data[2]][1]
  536.       ima = Bitmap.new($deck['elementallist'][data[2]][0])
  537.       iconelement.stretch_blt(iconelement.rect,ima,ima.rect)
  538.     else
  539.       textelement = text6
  540.     end
  541.     # -----------------------------------------------------------
  542.     @win3.bitmap.font.color = color2
  543.     for i in 0...data_pos.size
  544.       x = data_pos[i][0]
  545.       y = data_pos[i][1]
  546.       # -----------------------------------------------------------
  547.       @win3.bitmap.draw_text(x+8,y+8,88,20,text1)
  548.       @win3.bitmap.draw_text(x+8,y+28,88,20,text2)
  549.       @win3.bitmap.draw_text(x+8,y+48,88,20,text5)
  550.       @win3.bitmap.draw_text(x+8,y+88,230,20,"#{text4}#{cards_number})")
  551.       # -----------------------------------------------------------
  552.       @win3.bitmap.draw_text(x+92,y+8,153,20,name)
  553.       @win3.bitmap.draw_text(x+92,y+28,153,20,cat)
  554.       if textelement != text6
  555.         @win3.bitmap.draw_text(x+115,y+48,153,20,textelement)
  556.       else
  557.         @win3.bitmap.draw_text(x+92,y+48,153,20,textelement)
  558.       end
  559.       # -----------------------------------------------------------
  560.       @win3.bitmap.draw_text(x+8,y+68,230,20,text3) if uniq == 1
  561.     end
  562.     # -----------------------------------------------------------
  563.     @win3.bitmap.font.color = color1
  564.     @win3.bitmap.draw_text(8,8,88,20,text1)
  565.     @win3.bitmap.draw_text(8,28,88,20,text2)
  566.     @win3.bitmap.draw_text(8,48,88,20,text5)
  567.     @win3.bitmap.draw_text(8,88,230,20,text4)
  568.     w = @win3.bitmap.text_size(text4).width
  569.     @win3.bitmap.font.color = color5
  570.     @win3.bitmap.draw_text(8+w,88,230,20,"#{cards_number}")
  571.     w2 = @win3.bitmap.text_size("#{cards_number}").width
  572.     @win3.bitmap.font.color = color1
  573.     @win3.bitmap.draw_text(8+w+w2,88,230,20,"):")
  574.     # -----------------------------------------------------------
  575.     @win3.bitmap.font.color = color6
  576.     @win3.bitmap.draw_text(92,8,153,20,name)
  577.     @win3.bitmap.font.color = color3
  578.     @win3.bitmap.draw_text(92,28,153,20,cat)
  579.     @win3.bitmap.font.color = color7
  580.     if textelement != text6
  581.       @win3.bitmap.blt(91,50,iconelement,iconelement.rect)
  582.       @win3.bitmap.draw_text(115,48,153,20,textelement)
  583.     else
  584.       @win3.bitmap.draw_text(92,48,153,20,textelement)
  585.     end
  586.     # -----------------------------------------------------------
  587.     @win3.bitmap.font.color = color4
  588.     @win3.bitmap.draw_text(8,68,230,20,text3) if uniq == 1
  589.     # -----------------------------------------------------------
  590.   end
  591.   # ---------------------------------------------------------------------------
  592.   def drawcontentwin4(data,limit1 = -1,limit2 = -1)
  593.     data_pos = [[1,0],[0,2],[0,1],[-1,0],[0,-1]]
  594.     color1 = Color.new(255,255,255,255)
  595.     color2 = Color.new(0,0,0,255)
  596.     color3 = Color.new(204,134,58,255)
  597.    
  598.     x = 5
  599.     y = 0
  600.     text1 = @textos[1][6]
  601.     text2 = @textos[1][7]
  602.     cnt = 0
  603.    
  604.     if limit1 == -1
  605.       @win4.bitmap = Bitmap.new(@win4image)
  606.       w = 233
  607.       h = 18 + (data.size * 22)
  608.       @datawin4bitmap.bitmap = Bitmap.new(w,h)
  609.       @datawin4bitmap.bitmap.font.size = 18
  610.     else
  611.       for i in limit1..limit2
  612.         next if @nodrawinwin4.include?(i)
  613.         x1 = x
  614.         y1 = y + (i * 22)
  615.         @datawin4bitmap.bitmap.fill_rect(x1,y1,233,22,Color.new(0,0,0,0))
  616.       end
  617.     end
  618.  
  619.     for i in 0...data.size
  620.       if limit1 != -1
  621.         if i < limit1
  622.           y += 22
  623.           next
  624.         end
  625.         break if i > limit2
  626.       end
  627.       if @nodrawinwin4.include?(i)
  628.         y += 22
  629.         next
  630.       end
  631.       break if cnt > 6 and limit1 == -1
  632.       @nodrawinwin4.push(i)
  633.       cnt += 1
  634.       atk = data[i][3]
  635.       id = i + 1
  636.       @datawin4bitmap.bitmap.font.color = color2
  637.       for i in 0...data_pos.size
  638.         x1 = x + data_pos[i][0]
  639.         y1 = y + data_pos[i][1]
  640.         text = "#{text1} #{id}: "
  641.         @datawin4bitmap.bitmap.draw_text(x1,y1,100,22,text)
  642.         w = @datawin4bitmap.bitmap.text_size(text).width
  643.         text = "(#{text2} - #{atk[0]}/#{atk[1]}/#{atk[2]}/#{atk[3]})"
  644.         @datawin4bitmap.bitmap.draw_text(x1+w,y1,141,22,text)
  645.       end
  646.       text = "#{text1} #{id}: "
  647.       @datawin4bitmap.bitmap.font.color = color3
  648.       @datawin4bitmap.bitmap.draw_text(x,y,100,22,text)
  649.       w = @datawin4bitmap.bitmap.text_size(text).width
  650.       text = "(#{text2} - #{atk[0]}/#{atk[1]}/#{atk[2]}/#{atk[3]})"
  651.       @datawin4bitmap.bitmap.font.color = color1
  652.       @datawin4bitmap.bitmap.draw_text(x+w,y,141,22,text)
  653.       y += 22
  654.     end
  655.   end
  656.   # ---------------------------------------------------------------------------
  657.   def drawbarwin4(size)
  658.     real_size = size - 6
  659.     if real_size > 0
  660.       h_top = 137 - (4 * real_size)
  661.       h_top = 6 if h_top < 6
  662.     else
  663.       h_top = 137
  664.     end
  665.     @barbottom = Sprite.new
  666.     @barbottom.bitmap = Bitmap.new(@win4barbottom)
  667.     @barbottom.x = 333
  668.     @barbottom.y = 252
  669.     @barbottom.z = 10000
  670.     @barbottom.visible = false
  671.     top = Bitmap.new(@win4bartop)
  672.     @bartop = Sprite.new
  673.     @bartop.bitmap = Bitmap.new(7,h_top)
  674.     @bartop.bitmap.stretch_blt(@bartop.bitmap.rect,top,top.rect)
  675.     @bartop.x = 334
  676.     @bartop.y = 253
  677.     @bartop.z = 10000
  678.     @bartop.visible = false
  679.   end
  680.   # ---------------------------------------------------------------------------
  681.   def draw_card_preview(data)
  682.     # --------------------------------------------------------------
  683.     if @backuppreviewimage != nil
  684.       @backuppreviewimage.bitmap = @previewimage.bitmap.dup
  685.       opacity = 110
  686.     else
  687.       opacity = 255
  688.     end
  689.     # --------------------------------------------------------------
  690.     atks = data[3]
  691.     pos = data[8]
  692.     im = @previewimas["#{@foldercards}#{data[7]}"]
  693.     ima = Bitmap.new(177,250)
  694.     ima.blt(0,0,im,Rect.new(931,37,177,250))
  695.     @previewimage.bitmap.blt(0,0,ima,ima.rect)
  696.     # Añadir los valores de ataque a la carta seleccionada
  697.     # ------------------------------------------------------------------------
  698.     pos_mod = [[1,0],[-1,0],[0,1],[0,-1],[2,0],[-2,0],[0,2],[0,-2]]
  699.     atk_arr = (atks[0] == 10 ? "A" : atks[0])
  700.     atk_izq = (atks[1] == 10 ? "A" : atks[1])
  701.     atk_der = (atks[2] == 10 ? "A" : atks[2])
  702.     atk_aba = (atks[3] == 10 ? "A" : atks[3])
  703.     case pos
  704.     when 0 # Arriba Izquierda
  705.       x = -6
  706.       y = 10
  707.     when 1 # Arriba Derecha
  708.       x = 99
  709.       y = 10
  710.     when 2 # Inferior Izquierda
  711.       x = -6
  712.       y = 137
  713.     when 3 # Inferior Derecha
  714.       x = 99
  715.       y = 137
  716.     end
  717.     @previewimage.bitmap.font.color = Color.new(0,0,0,255)
  718.     for i in 0...pos_mod.size
  719.       x1 = x + pos_mod[i][0]
  720.       y1 = y + pos_mod[i][1]
  721.       @previewimage.bitmap.font.size = 36
  722.       # Posición Ataque Arriba
  723.       @previewimage.bitmap.draw_text(x1,y1,80,40,"#{atk_arr}",1)
  724.       # Posición Ataque Izquierda / Derecha
  725.       @previewimage.bitmap.draw_text(x1,y1+28,80,40,"#{atk_izq} #{atk_der}",1)
  726.       # Posición Ataque Abajo
  727.       @previewimage.bitmap.draw_text(x1,y1+56,80,40,"#{atk_aba}",1)
  728.     end
  729.     @previewimage.bitmap.font.color = Color.new(255,255,255,255)
  730.     @previewimage.bitmap.font.size = 36
  731.     # Posición Ataque Arriba
  732.     @previewimage.bitmap.draw_text(x,y,80,40,"#{atk_arr}",1)
  733.     # Posición Ataque Izquierda / Derecha
  734.     @previewimage.bitmap.draw_text(x,y+28,80,40,"#{atk_izq} #{atk_der}",1)
  735.     # Posición Ataque Abajo
  736.     @previewimage.bitmap.draw_text(x,y+56,80,40,"#{atk_aba}",1)
  737.     @previewimage.opacity = opacity
  738.     # ------------------------------------------------------------------------
  739.   end
  740.   # ---------------------------------------------------------------------------
  741.   def drawnumberpage
  742.     if @numberpageima != nil
  743.       @numberpageima.bitmap.clear
  744.     else
  745.       @numberpageima = Sprite.new
  746.       @numberpageima.bitmap = Bitmap.new(640,26)
  747.       @numberpageima.bitmap.font.size = 20
  748.       @numberpageima.x = 0
  749.       @numberpageima.y = 429
  750.       @numberpageima.z = 10
  751.     end
  752.     data_pos = [[1,0],[0,2],[0,1],[-1,0],[0,-1]]
  753.     color1 = Color.new(0,0,0,255)
  754.     color2 = Color.new(219,158,12,255)
  755.     texto1 = @textos[0][0] # Página...
  756.     texto2 = @textos[0][1] # De...
  757.     texto3 = @textos[0][2] # Categoría completada al...
  758.     n1 = @page1 + 1
  759.     n2 = @page2 + 1
  760.     maxn1 = @maxpage1 + 1
  761.     index = @index1 + (@page1 * @maxitemspage1)
  762.     cat = @data1[index]
  763.     maxn2 = (@maxpag2[cat] / @maxitemspage2) + 1
  764.     if maxn1 > 1
  765.       text1 = "#{texto1} #{n1} #{texto2} #{maxn1}"
  766.     else
  767.       text1 = "#{texto1} #{n1}"
  768.     end
  769.     if maxn2 > 1
  770.       text2 = "#{texto1} #{n2} #{texto2} #{maxn2}"
  771.     else
  772.       text2 = "#{texto1} #{n2}"
  773.     end
  774.     if @data2[cat] != nil
  775.       perc = (@data2[cat].size / (@maxpag2[cat]+1.0)) * 100
  776.       perc2 = perc
  777.       perc = sprintf('%.2f', perc)
  778.       perc = 100 if perc == '100.00'
  779.     else
  780.       perc = 0
  781.     end
  782.     text3 = "(#{texto3} #{perc}%)"
  783.     @maxitemspage2
  784.     @numberpageima.bitmap.font.color = color1
  785.     for i in 0...data_pos.size
  786.       x = -6 + data_pos[i][0]
  787.       y = 3 + data_pos[i][1]
  788.       @numberpageima.bitmap.draw_text(x,y,179,22,text1,2)
  789.       @numberpageima.bitmap.draw_text(x,y,593,22,text2,2)
  790.       @numberpageima.bitmap.draw_text(x+256,y,230,22,text3,0)
  791.     end
  792.     @numberpageima.bitmap.font.color = color2
  793.     @numberpageima.bitmap.draw_text(-6,3,179,22,text1,2)
  794.     @numberpageima.bitmap.draw_text(-6,3,593,22,text2,2)
  795.     @numberpageima.bitmap.draw_text(250,3,230,22,text3,0)
  796.   end
  797.   # ---------------------------------------------------------------------------
  798.   def hidewin3
  799.     mod_y = @datawin4bitmap.bitmap.height / 5
  800.     @barbottom.dispose
  801.     @bartop.dispose
  802.     @indicatorwin4top.visible = false
  803.     @indicatorwin4bottom.visible = false
  804.     @backuppreviewimage.viewport.dispose
  805.     @backuppreviewimage.dispose
  806.     @backuppreviewimage = nil
  807.     for i in 0...10
  808.       @win4.y -= 23
  809.       @datawin4bitmap.oy += 23 + mod_y
  810.       @darkcontent.opacity -= 15
  811.       Graphics.update
  812.     end
  813.     @win4.y = -233
  814.     for i in 0...5
  815.       @win3.x += 82
  816.       @previewimage.x += 82
  817.       @darkcontent.opacity -= 15
  818.       Graphics.update
  819.     end
  820.     @darkcontent.dispose
  821.     @previewimage.viewport.dispose
  822.     @previewimage.dispose
  823.     @win3.x = 412
  824.     @win3.visible = false
  825.     @win4.visible = false
  826.   end
  827.   # ---------------------------------------------------------------------------
  828.   def animatecursor
  829.     return if @fase == 2
  830.     @anicursor = 0 if @anicursor == @aniglobal.size
  831.     @cursor.x += @aniglobal[@anicursor]
  832.     @indicatorwin4top.y -= @aniglobal[@anicursor]
  833.     @indicatorwin4bottom.y += @aniglobal[@anicursor]
  834.     @anicursor += 1
  835.     # Animar selector
  836.     case @aniglobal[@anicursor]
  837.     when -1:
  838.       @selector.opacity -= 10
  839.       @selector_win2.opacity -= 25 if rand(2) % 2 == 0
  840.     when 1:
  841.       @selector.opacity += 10
  842.       @selector_win2.opacity += 25 if rand(2) % 2 == 0
  843.     end
  844.   end
  845.   # ---------------------------------------------------------------------------
  846.   def animatestars
  847.     bitmap = Bitmap.new(@ministar)
  848.     for i in 0...@stars.size
  849.       next if @stars[i] == nil
  850.       x = @stars[i][1] * 22
  851.       @stars[i][0].bitmap = Bitmap.new(22,22)
  852.       @stars[i][0].bitmap.blt(0,0,bitmap,Rect.new(x,0,22,22))
  853.       @stars[i][1] += 1
  854.       @stars[i][1] = 0 if @stars[i][1] == 14
  855.     end
  856.   end
  857.   # ---------------------------------------------------------------------------
  858.   def fadeindatawinbitmap
  859.     @datawin1bitmap.opacity += 20
  860.     @datawin2bitmap.opacity += 20
  861.   end
  862.   # ---------------------------------------------------------------------------
  863.   def animatepages
  864.     sum = (@indicator_frame == 1 ? 3 : -3)
  865.     ima = Bitmap.new(@indicatorsimage)
  866.     if @maxpage1 > 0
  867.       if @indicator1a == nil
  868.         @indicator1a = Sprite.new
  869.         @indicator1a.bitmap = Bitmap.new(25,23)
  870.         @indicator1a.y = 430
  871.         @indicator1a.x = 22
  872.         @indicator1a.z = 100
  873.         @indicator1b = Sprite.new
  874.         @indicator1b.bitmap = Bitmap.new(25,23)
  875.         @indicator1b.y = 430
  876.         @indicator1b.x = 176
  877.         @indicator1b.z = 100
  878.       end
  879.       @indicator1a.bitmap.clear
  880.       @indicator1b.bitmap.clear
  881.       @indicator1a.bitmap.blt(0,0,ima,Rect.new(0+(@indicator_frame*25),0,25,23))
  882.       @indicator1b.bitmap.blt(0,0,ima,Rect.new(0+(@indicator_frame*25),23,25,23))
  883.       @indicator1a.x += sum
  884.       @indicator1b.x -= sum
  885.     end
  886.     index = @index1 + (@page1 * @maxitemspage1)
  887.     cat = @data1[index]
  888.     maxn = (@maxpag2[cat] / @maxitemspage2) + 1
  889.     if maxn > 1
  890.       if @indicator2a == nil
  891.         @indicator2a = Sprite.new
  892.         @indicator2a.bitmap = Bitmap.new(25,23)
  893.         @indicator2a.y = 430
  894.         @indicator2a.x = 220
  895.         @indicator2a.z = 100
  896.         @indicator2b = Sprite.new
  897.         @indicator2b.bitmap = Bitmap.new(25,23)
  898.         @indicator2b.y = 430
  899.         @indicator2b.x = 592
  900.         @indicator2b.z = 100
  901.       end
  902.       @indicator2a.bitmap.clear
  903.       @indicator2b.bitmap.clear
  904.       frame = (@indicator_frame == 1 ? 0 : 1)
  905.       @indicator2a.bitmap.blt(0,0,ima,Rect.new(0+(frame*25),0,25,23))
  906.       @indicator2b.bitmap.blt(0,0,ima,Rect.new(0+(frame*25),23,25,23))
  907.       @indicator2a.x += sum
  908.       @indicator2b.x -= sum
  909.     else
  910.       if @indicator2a != nil
  911.         @indicator2a.bitmap.clear
  912.         @indicator2b.bitmap.clear
  913.         @indicator2a.x += sum
  914.         @indicator2b.x -= sum
  915.       end
  916.     end
  917.   end
  918.   # ---------------------------------------------------------------------------
  919.   def cursor_ini
  920.     @cursor.x = 3
  921.     @cursor.y = 32
  922.   end
  923.   # ---------------------------------------------------------------------------
  924.   def refresh_indicators_win4
  925.     if @win == 3
  926.       @indicatorwin4top.visible = (@datawin4bitmap.oy > 0 ? true : false)
  927.       if @datawin4bitmap.bitmap.height - @datawin4bitmap.oy > 150
  928.         @indicatorwin4bottom.visible = true
  929.       else
  930.         @indicatorwin4bottom.visible = false
  931.       end
  932.       if @indicatorwin4top.y > 253
  933.         @indicatorwin4top.y = 249
  934.       end
  935.       if @indicatorwin4bottom.y < 384
  936.         @indicatorwin4bottom.y = 388
  937.       end
  938.     else
  939.       @indicatorwin4top.visible = false
  940.       @indicatorwin4bottom.visible = false
  941.     end
  942.   end
  943.   # ---------------------------------------------------------------------------
  944.   def refresh_cardpreview_opacity
  945.     if !@previewimage.disposed?
  946.       @previewimage.opacity += 5
  947.     end
  948.   end
  949.   # ---------------------------------------------------------------------------      
  950.   def update_win1
  951.     # ***********************************************************
  952.     # Update para la ventana 1
  953.     # ***********************************************************
  954.     # Botones de acción
  955.     if Input.trigger?(Input::C) # Activar ventana 2
  956.       Audio.se_play(@soundcursor,85)
  957.       x_final = 216
  958.       y_final = 50
  959.       modx = (x_final - @cursor.x) / 4
  960.       mody = (y_final - @cursor.y) / 4
  961.       for i in 0...4
  962.         @cursor.x += modx
  963.         @cursor.y += mody
  964.         Graphics.update
  965.       end
  966.       @cursor.x = x_final
  967.       @cursor.y = y_final
  968.       Graphics.update
  969.       @anicursor = 0
  970.       @index2 = 0 + (12 * @page2)
  971.       @win = 2
  972.       index = @index1 + (@page1 * @maxitemspage1)
  973.       cat = @data1[index]
  974.       if @data2[cat] != nil
  975.         if @data2[cat][@index2] == nil
  976.           @selector_win2.visible = false
  977.         else
  978.           @selector_win2.visible = true
  979.         end
  980.       else
  981.         @selector_win2.visible = false
  982.       end
  983.       @selector_win2.x = @cursor.x + 10
  984.       @selector_win2.y = @cursor.y - 20
  985.       updatehelpwindow
  986.       return
  987.     end
  988.     if Input.trigger?(Input::B) # Salir del menú
  989.       @exit = true
  990.       @cursor.visible = false
  991.       @numberpageima.visible = false
  992.       for i in 0...@stars.size
  993.         next if @stars[i] == nil
  994.         @stars[i][0].visible = false
  995.       end
  996.       Audio.se_play(@soundcancel,85)
  997.       if @indicator1a != nil
  998.         @indicator1a.visible = false
  999.         @indicator1b.visible = false
  1000.       end
  1001.       if @indicator2a != nil
  1002.         @indicator2a.visible = false
  1003.         @indicator2b.visible = false
  1004.       end
  1005.       @helpwindow2.visible = false
  1006.       for i in 0...10
  1007.         @win1.x -= 20
  1008.         @datawin1bitmap.x -= 20
  1009.         @win2.x += 42
  1010.         @datawin2bitmap.x += 42
  1011.         @fondo.opacity -= 25
  1012.         @helpwindow.opacity -= 25
  1013.         Graphics.update
  1014.       end
  1015.       return
  1016.     end
  1017.     # Direcciones / Movimiento del cursor
  1018.     if Input.repeat?(Input::DOWN)
  1019.       Audio.se_play(@soundcursor,85)
  1020.       index0 = @index1 + 1 + (@page1 * @maxitemspage1)
  1021.       @last_index = @index1
  1022.       if @index1 < @data1.size - 1 and @index1 < @maxitemspage1 - 1 and
  1023.         @data1[index0] != nil
  1024.         @index1 += 1
  1025.         @cursor.y += 24
  1026.       elsif @index1 == @maxitemspage1 - 1 or @data1[index0] == nil
  1027.         cursor_ini
  1028.         @index1 = 0
  1029.       end
  1030.       @page2 = 0
  1031.       @index2 = 0
  1032.       drawcontentwin2
  1033.       drawwin1selection
  1034.       drawnumberpage
  1035.       return
  1036.     end
  1037.     if Input.repeat?(Input::UP)
  1038.       Audio.se_play(@soundcursor,85)
  1039.       @last_index = @index1
  1040.       if @index1 > 0
  1041.         @index1 -= 1
  1042.         @cursor.y -= 24
  1043.       elsif @index1 == 0
  1044.         index0 = @index1 + 1 + (@page1 * @maxitemspage1)
  1045.         while @index1 < @maxitemspage1 - 1 and @data1[index0] != nil
  1046.           @index1 += 1
  1047.           @cursor.y += 24
  1048.           index0 = @index1 + 1 + (@page1 * @maxitemspage1)
  1049.         end
  1050.       end
  1051.       @page2 = 0
  1052.       @index2 = 0
  1053.       drawcontentwin2
  1054.       drawwin1selection
  1055.       drawnumberpage
  1056.       return
  1057.     end
  1058.     if Input.trigger?(Input::LEFT) or Input.trigger?(Input::Y) or
  1059.       Input.trigger?(Input::L)
  1060.       return if @maxpage1 <= 0
  1061.       Audio.se_play(@soundcursor,85)
  1062.       cursor_ini
  1063.       @last_index = nil
  1064.       @page1 -= 1
  1065.       @page1 = @maxpage1 if @page1 < 0
  1066.       @index1 = 0
  1067.       drawcontentwin1
  1068.       drawcontentwin2
  1069.       drawwin1selection
  1070.       @page2 = 0
  1071.       @index2 = 0
  1072.       drawnumberpage
  1073.       return
  1074.     end
  1075.     if Input.trigger?(Input::RIGHT) or Input.trigger?(Input::Z) or
  1076.       Input.trigger?(Input::R)
  1077.       return if @maxpage1 <= 0
  1078.       Audio.se_play(@soundcursor,85)
  1079.       cursor_ini
  1080.       @last_index = nil
  1081.       @page1 += 1
  1082.       @page1 = 0 if @page1 > @maxpage1
  1083.       @index1 = 0
  1084.       drawcontentwin1
  1085.       drawcontentwin2
  1086.       drawwin1selection
  1087.       @page2 = 0
  1088.       @index2 = 0
  1089.       drawnumberpage
  1090.       return
  1091.     end
  1092.   end
  1093.   # ---------------------------------------------------------------------------
  1094.   def update_win2
  1095.     # ***********************************************************
  1096.     # Update para la ventana 2
  1097.     # ***********************************************************
  1098.     # Botones de acción
  1099.     if Input.trigger?(Input::C)
  1100.       index = @index1 + (@page1 * @maxitemspage1)
  1101.       cat = @data1[index]
  1102.       if @data2[cat] != nil
  1103.         return if @data2[cat][@index2] == nil
  1104.         @cursor.visible = false
  1105.         @backupcursorx   = @cursor.x
  1106.         @backupcursory   = @cursor.y
  1107.         @backupanicursor = @anicursor
  1108.         @anicursor = 0
  1109.         @cursor.x = 88
  1110.         @cursor.y = 262
  1111.         Audio.se_play(@soundcursor,85)
  1112.         if @indicator1a != nil
  1113.           @indicator1a.visible = false
  1114.           @indicator1b.visible = false
  1115.         end
  1116.         if @indicator2a != nil
  1117.           @indicator2a.visible = false
  1118.           @indicator2b.visible = false
  1119.         end
  1120.         drawwin3
  1121.         @win = 3
  1122.         @cursor.visible = true
  1123.         updatehelpwindow
  1124.       end
  1125.       return
  1126.     end
  1127.     if Input.trigger?(Input::B)
  1128.       x_final = 3
  1129.       y_final = 32 + (@index1 * 24)
  1130.       modx = (x_final - @cursor.x) / 4
  1131.       mody = (y_final - @cursor.y) / 4
  1132.       @selector_win2.visible = false
  1133.       Audio.se_play(@soundcancel,85)
  1134.       for i in 0...4
  1135.         @cursor.x += modx
  1136.         @cursor.y += mody
  1137.         Graphics.update
  1138.       end
  1139.       @cursor.x = x_final
  1140.       @cursor.y = y_final
  1141.       Graphics.update
  1142.       @win = 1
  1143.       @anicursor = 0
  1144.       @index2 = 0 + (@page2 * 12)
  1145.       updatehelpwindow
  1146.       return
  1147.     end
  1148.     # Direcciones / Movimiento del cursor
  1149.     x = y = 0
  1150.     if Input.repeat?(Input::DOWN)
  1151.       y = 133
  1152.       @index2 += 4
  1153.     end
  1154.     if Input.repeat?(Input::UP)
  1155.       y = -133
  1156.       @index2 -= 4
  1157.     end
  1158.     if Input.repeat?(Input::RIGHT)
  1159.       x = 98
  1160.       @index2 += 1
  1161.     end
  1162.     if Input.repeat?(Input::LEFT)
  1163.       Audio.se_play(@soundcursor,85)
  1164.       x = -98
  1165.       @index2 -= 1
  1166.     end
  1167.     if x != 0 or y != 0
  1168.       Audio.se_play(@soundcursor,85)
  1169.       for i in @anicursor...@aniglobal.size
  1170.         @cursor.x += @aniglobal[i]
  1171.       end
  1172.       @cursor.x += x
  1173.       @cursor.y += y
  1174.       @anicursor = 0
  1175.       if @cursor.x > 600
  1176.         @cursor.x = 216
  1177.         @cursor.y += 133
  1178.       end
  1179.       if @cursor.x < 200
  1180.         @cursor.x = 216 + (98*3)
  1181.         @cursor.y -= 133
  1182.       end
  1183.       if @cursor.y > 316
  1184.        @cursor.y = 50
  1185.        @index2 -= 12
  1186.       end
  1187.       if @cursor.y < 50
  1188.         @cursor.y = 316
  1189.         @index2 += 12
  1190.       end
  1191.       if @index2 < 0 + (@page2 * 12)
  1192.         @index2 = 0 + (@page2 * 12)
  1193.       elsif @index2 > 11 + (@page2 * 12)
  1194.         @index2 = 11 + (@page2 * 12)
  1195.       end
  1196.       @selector_win2.x = @cursor.x + 10
  1197.       @selector_win2.y = @cursor.y - 20
  1198.       @selector_win2.opacity = 255
  1199.       index = @index1 + (@page1 * @maxitemspage1)
  1200.       cat = @data1[index]
  1201.       if @data2[cat] != nil
  1202.         if @data2[cat][@index2] == nil
  1203.           @selector_win2.visible = false
  1204.         else
  1205.           @selector_win2.visible = true
  1206.         end
  1207.       else
  1208.         @selector_win2.visible = false
  1209.       end
  1210.       return
  1211.     end
  1212.     # Alternar entre páginas
  1213.     if Input.trigger?(Input::Y) or Input.trigger?(Input::L)
  1214.       index = @index1 + (@page1 * @maxitemspage1)
  1215.       cat = @data1[index]
  1216.       maxn = (@maxpag2[cat] / @maxitemspage2) + 1
  1217.       return if maxn <= 1
  1218.       Audio.se_play(@soundcursor,85)
  1219.       @cursor.x = 216
  1220.       @cursor.y = 50
  1221.       @anicursor = 0
  1222.       @page2 -= 1
  1223.       @page2 = (@maxpag2[cat] / @maxitemspage2) if @page2 < 0
  1224.       @index2 = 0 + (@page2 * 12)
  1225.       drawcontentwin2
  1226.       @selector_win2.x = @cursor.x + 10
  1227.       @selector_win2.y = @cursor.y - 20
  1228.       @selector_win2.opacity = 255
  1229.       index = @index1 + (@page1 * @maxitemspage1)
  1230.       cat = @data1[index]
  1231.       if @data2[cat] != nil
  1232.         if @data2[cat][@index2] == nil
  1233.           @selector_win2.visible = false
  1234.         else
  1235.           @selector_win2.visible = true
  1236.         end
  1237.       else
  1238.         @selector_win2.visible = false
  1239.       end
  1240.       drawnumberpage
  1241.       return
  1242.     end
  1243.     if Input.trigger?(Input::Z) or Input.trigger?(Input::R)
  1244.       index = @index1 + (@page1 * @maxitemspage1)
  1245.       cat = @data1[index]
  1246.       maxn = (@maxpag2[cat] / @maxitemspage2) + 1
  1247.       return if maxn <= 1
  1248.       Audio.se_play(@soundcursor,85)
  1249.       @cursor.x = 216
  1250.       @cursor.y = 50
  1251.       @anicursor = 0
  1252.       @page2 += 1
  1253.       @page2 = 0 if @page2 > (@maxpag2[cat] / @maxitemspage2)
  1254.       @index2 = 0 + (@page2 * 12)
  1255.       drawcontentwin2
  1256.       @selector_win2.x = @cursor.x + 10
  1257.       @selector_win2.y = @cursor.y - 20
  1258.       @selector_win2.opacity = 255
  1259.       index = @index1 + (@page1 * @maxitemspage1)
  1260.       cat = @data1[index]
  1261.       if @data2[cat] != nil
  1262.         if @data2[cat][@index2] == nil
  1263.           @selector_win2.visible = false
  1264.         else
  1265.           @selector_win2.visible = true
  1266.         end
  1267.       else
  1268.         @selector_win2.visible = false
  1269.       end
  1270.       drawnumberpage
  1271.       return
  1272.     end
  1273.   end
  1274.   # ---------------------------------------------------------------------------
  1275.   def update_win3
  1276.     # ***********************************************************
  1277.     # Update para la ventana 3
  1278.     # ***********************************************************
  1279.     # Botones de acción
  1280.     if Input.trigger?(Input::B)
  1281.       Audio.se_play(@soundcancel,85)
  1282.       @cursor.visible = false
  1283.       hidewin3
  1284.       if @indicator1a != nil
  1285.         @indicator1a.visible = true
  1286.         @indicator1b.visible = true
  1287.       end
  1288.       if @indicator2a != nil
  1289.         @indicator2a.visible = true
  1290.         @indicator2b.visible = true
  1291.       end
  1292.       @cursor.visible = true
  1293.       @cursor.x = @backupcursorx
  1294.       @cursor.y = @backupcursory
  1295.       @anicursor = @backupanicursor
  1296.       @win = 2
  1297.       updatehelpwindow
  1298.     end
  1299.     # Direcciones / Movimiento del cursor
  1300.     if Input.repeat?(Input::DOWN) or Input.press?(Input::Z)
  1301.       if Input.press?(Input::Z)
  1302.         n = 6
  1303.         limit1 = (@index3+6) - 5
  1304.         limit2 = (@index3+7)
  1305.       else
  1306.         n = 1
  1307.         limit1 = @index3+1
  1308.         limit2 = @index3+5
  1309.       end
  1310.       playsound = true
  1311.       for i in 0...n
  1312.         if @cursor.y < 372 and (@index3+1) < @maxitemwin4
  1313.           Audio.se_play(@soundcursor,85) if playsound
  1314.           @cursor.y += 22
  1315.           @index3 += 1
  1316.         elsif (@index3+1) < @maxitemwin4
  1317.           Audio.se_play(@soundcursor,85) if playsound
  1318.           @datawin4bitmap.oy += 22
  1319.           real_desplace =  (137 - @bartop.bitmap.height)
  1320.           desplace = real_desplace.to_f / (@maxitemwin4-6)
  1321.           move_bar = 253 + (desplace * (@index3-4))
  1322.           @bartop.y = move_bar
  1323.           @index3 += 1
  1324.         end
  1325.         playsound = false
  1326.       end
  1327.       index = @index1 + (@page1 * @maxitemspage1)
  1328.       cat = @data1[index]
  1329.       data = @data0[@data2[cat][@index2]][0]
  1330.       drawcontentwin4(data,limit1,limit2)
  1331.       draw_card_preview(data[@index3])
  1332.       return
  1333.     end
  1334.     if Input.repeat?(Input::UP) or Input.press?(Input::Y)
  1335.       if Input.press?(Input::Y)
  1336.         n = 6
  1337.       else
  1338.         n = 1
  1339.       end
  1340.       playsound = true
  1341.       for i in 0...n
  1342.         if @cursor.y > 262 and @index3 > 0
  1343.           Audio.se_play(@soundcursor,85) if playsound
  1344.           @cursor.y -= 22
  1345.           @index3 -= 1
  1346.         elsif @index3 > 0
  1347.           Audio.se_play(@soundcursor,85) if playsound
  1348.           @datawin4bitmap.oy -= 22
  1349.           real_desplace =  (137 - @bartop.bitmap.height)
  1350.           desplace = real_desplace.to_f / (@maxitemwin4-6)
  1351.           move_bar = 253 + (desplace * (@index3-1))
  1352.           @bartop.y = move_bar
  1353.           @index3 -= 1
  1354.         end
  1355.         playsound = false
  1356.       end
  1357.       index = @index1 + (@page1 * @maxitemspage1)
  1358.       cat = @data1[index]
  1359.       data = @data0[@data2[cat][@index2]][0]
  1360.       draw_card_preview(data[@index3])
  1361.       return
  1362.     end
  1363.   end
  1364.   # ---------------------------------------------------------------------------
  1365.   def dispose
  1366.     @fondo.dispose
  1367.     @cursor.dispose
  1368.     @helpwindow.dispose
  1369.     @helpwindow2
  1370.     @selector_win2.dispose
  1371.     @win1.viewport.dispose
  1372.     @win1.dispose
  1373.     @win2.viewport.dispose
  1374.     @win2.dispose
  1375.     @win3.viewport.dispose
  1376.     @win3.dispose
  1377.     @win4.viewport.dispose
  1378.     @win4.dispose
  1379.     @indicator1a.dispose if @indicator1a != nil
  1380.     @indicator1b.dispose if @indicator1b != nil
  1381.     @indicator2a.dispose if @indicator2a != nil
  1382.     @indicator2b.dispose if @indicator2b != nil
  1383.     @datawin1bitmap.dispose
  1384.     @datawin2bitmap.dispose
  1385.     @datawin4bitmap.dispose
  1386.     @indicatorwin4top.dispose
  1387.     @indicatorwin4bottom.dispose
  1388.     @numberpageima.dispose
  1389.     for i in 0...@stars.size
  1390.       next if @stars[i] == nil
  1391.       @stars[i][0].dispose
  1392.     end
  1393.   end
  1394.   # ---------------------------------------------------------------------------
  1395. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement