Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- *** SCRIPT CREADO POR NEWOLD, FEBRERO-MARZO 2011, TRIPLE TRIAD 1.0 ***
- =end
- class CardsMenu
- # ---------------------------------------------------------------------------
- def initialize
- $deck['backupresolution'][0] = Graphics.width
- $deck['backupresolution'][1] = Graphics.height
- Graphics.resize_screen(640, 480)
- # *******************************************************
- # INICIO CONFIGURACIÓN
- # *******************************************************
- # Imagenes ...............................................
- # ........................................................
- # Ruta que contiene las cartas del juegos
- @foldercards = "CardsGame/cards/"
- # Ruta imagen de fondo
- @backgroundimage = "CardsGame/background/fondo2"
- # Ruta imagen indicadores Ventanas 1 y 2
- @indicatorsimage = "CardsGame/cursor/indicador4"
- # Ruta imagen indicadores Ventana 4
- @indicatorsimage2 = "CardsGame/cursor/indicador5"
- # Ruta Imagen del cursor
- @cursorbitmap = "CardsGame/cursor/1"
- # Ruta Imagen del selector en la ventana 2 (Ventana de cartas)
- @selectorcardsbitmap = "CardsGame/cursor/menu_cards_selector"
- # Ruta imagen de ventana 1
- @win1image = "CardsGame/background/cardsmenu_win1"
- # Ruta imagen de ventana 2
- @win2image = "CardsGame/background/cardsmenu_win2"
- # Ruta imagen de ventana 3
- @win3image = "CardsGame/background/cardsmenu_win3"
- # Ruta imagen de ventana 4
- @win4image = "CardsGame/background/cardsmenu_win4"
- # Ruta imágenes barra desplazamiento ventana 4
- @win4barbottom = "CardsGame/background/barbotton" # Parte Inferior
- @win4bartop = "CardsGame/background/bartop" # Parte superior
- # Ruta imagen carta desconocida
- @nocardimage = "CardsGame/cards/carta_no_encontrada"
- # Ruta icono miniestrella (Se muestra al lado de las categorías completas)
- @ministar = "CardsGame/icons/ministar"
- # Sonidos ...............................................
- # ........................................................
- # Sonido que se produce al mover el cursor
- @soundcursor = "CardsGame/sound/cursor1"
- # Sonido que se produce al cancelar
- @soundcancel = "CardsGame/sound/fx4"
- # Textos ...............................................
- # ........................................................
- @textos = [
- ["Página","de","Categoría completada al"],
- ["Nombre","Categoría","Carta única","Cartas en posesión",
- "Atributo","Ninguno","Carta","Atk"],
- ["Usa las teclas de dirección para cambiar las categorías / páginas",
- "L y R : Cambia la página actual Direcciones : Moverse por el panel"],
- ["Colección completada al","Tu baraja tiene","carta"]
- ]
- # *******************************************************
- # FIN CONFIGURACIÓN
- # *******************************************************
- end
- # ---------------------------------------------------------------------------
- def main
- @exit = false
- @index1 = 0
- @index2 = 0
- @page1 = 0
- @page2 = 0
- @maxitemspage1 = 10
- @maxitemspage2 = 12
- @cardsnumber = {}
- @maxpag2 = {}
- @data0 = {}
- @data1 = getdatawin1
- @data2 = getdatawin2
- @maxpage1 = @data1.size / @maxitemspage1
- if @data1[(@maxpage1 * @maxitemspage1)] == nil and (@maxpage1 - 1) >= 0
- @maxpage1 -= 1
- end
- @fondo = Sprite.new
- @fondo.bitmap = Bitmap.new(@backgroundimage)
- @fondo.opacity = 0
- @cursor = Sprite.new
- @cursor.bitmap = Bitmap.new(@cursorbitmap)
- @cursor.z = 2000
- @cursor.visible = false
- cursor_ini
- @selector = Sprite.new
- @selector.opacity = 110
- @selector.blend_type = 2
- @selector.z = 2000
- @selector.visible = false
- @selector_win2 = Sprite.new
- @selector_win2.bitmap = Bitmap.new(@selectorcardsbitmap)
- @selector_win2.z = 249
- @selector_win2.visible = false
- indicators = Bitmap.new(@indicatorsimage2)
- @indicatorwin4top = Sprite.new
- @indicatorwin4top.bitmap = Bitmap.new(10,10)
- @indicatorwin4top.bitmap.blt(0,0,indicators,Rect.new(0,0,10,10))
- @indicatorwin4top.x = 220
- @indicatorwin4top.y = 249
- @indicatorwin4top.z = 10000
- @indicatorwin4top.visible = false
- @indicatorwin4bottom = Sprite.new
- @indicatorwin4bottom.bitmap = Bitmap.new(10,10)
- @indicatorwin4bottom.bitmap.blt(0,0,indicators,Rect.new(0,10,10,10))
- @indicatorwin4bottom.x = 220
- @indicatorwin4bottom.y = 388
- @indicatorwin4bottom.z = 10000
- @indicatorwin4bottom.visible = false
- # ----------------------------------------------
- # Animación del Cursor
- # ----------------------------------------------
- @aniglobal = [-1,-1,0,0,0,0,0,1,1,1,0,0,0,-1]
- @aniglobal.concat(@aniglobal.reverse)
- @anicursor = 0
- # ----------------------------------------------
- viewport1 = Viewport.new(15,23,200,434)
- @win1 = Sprite.new(viewport1)
- @win1.bitmap = Bitmap.new(@win1image)
- @win1.x = -200
- @win1.y = 0
- viewport2 = Viewport.new(204,23,420,434)
- @win2 = Sprite.new(viewport2)
- @win2.bitmap = Bitmap.new(@win2image)
- @win2.x = 428
- @win2.y = 0
- viewport3 = Viewport.new(106,140,428,260)
- viewport3.z = 250
- @win3 = Sprite.new(viewport3)
- @win3.x = 412
- @win3.y = 0
- @win3.z = 250
- @win3.visible = false
- viewport4 = Viewport.new(113,250,233,145)
- viewport4.z = 251
- @win4 = Sprite.new(viewport4)
- @win4.x = 0
- @win4.y = -233
- @win4.z = 251
- @win4.visible = false
- @datawin1bitmap = Sprite.new(viewport1)
- @datawin1bitmap.bitmap = Bitmap.new(192,434)
- @datawin1bitmap.x = -200
- @datawin1bitmap.y = 0
- @datawin2bitmap = Sprite.new(viewport2)
- @datawin2bitmap.bitmap = Bitmap.new(412,434)
- @datawin2bitmap.x = 420
- @datawin2bitmap.y = 0
- viewport5 = Viewport.new(113,255,233,135)
- viewport5.z = 2000
- @datawin4bitmap = Sprite.new(viewport5)
- @datawin4bitmap.x = 0
- @datawin4bitmap.oy = 233
- @previewimas = {}
- # ----------------------------------------------
- drawcontentwin1
- drawcontentwin2
- drawwin1selection
- drawnumberpage
- @numberpageima.visible = false
- # ----------------------------------------------
- @helpwindow = Sprite.new
- @helpwindow.bitmap = Bitmap.new(640,22)
- @helpwindow.bitmap.font.size = 18
- @helpwindow2 = Sprite.new
- @helpwindow2.bitmap = Bitmap.new(640,22)
- @helpwindow2.bitmap.font.size = 18
- @helpwindow2.y = 452
- # ----------------------------------------------
- @datawin1bitmap.opacity = 255
- @datawin2bitmap.opacity = 255
- for i in 0...10
- @win1.x += 20
- @datawin1bitmap.x += 20
- @win2.x -= 42
- @datawin2bitmap.x -= 42
- @fondo.opacity += 25
- Graphics.update
- end
- # ----------------------------------------------
- @cursor.visible = true
- @numberpageima.visible = true
- @win = 1
- @global_frame = 0
- @indicator_frame = 0
- animatepages
- updatehelpwindow
- updatehelpwindow2
- n = 0
- # ----------------------------------------------
- Graphics.transition(20)
- loop do
- @global_frame += 1
- Graphics.update
- Input.update
- animatecursor
- animatestars if @global_frame % 2 == 0
- fadeindatawinbitmap
- if @global_frame == 10
- @global_frame = 0
- @indicator_frame == 0 ? @indicator_frame = 1 : @indicator_frame = 0
- animatepages
- end
- n += 1
- if n == 300
- n = 0
- Graphics.frame_reset
- end
- case @win
- when 1
- update_win1
- when 2
- update_win2
- when 3
- update_win3
- refresh_indicators_win4
- refresh_cardpreview_opacity
- end
- if @exit
- $scene = Scene_Map.new
- break
- end
- #break if @exit
- end
- dispose
- Input.update
- Graphics.resize_screen($deck['backupresolution'][0], $deck['backupresolution'][1])
- end
- # ---------------------------------------------------------------------------
- def updatehelpwindow
- @helpwindow.bitmap.clear
- case @win
- when 1
- text = @textos[2][0]
- when 2
- text = @textos[2][1]
- else
- text = ''
- end
- data_pos = [[0,-1],[0,2]]
- color1 = Color.new(51,52,1,255)
- color2 = Color.new(252,255,2,255)
- @helpwindow.bitmap.font.color = color1
- for i in 0...data_pos.size
- x = 25 + data_pos[i][0]
- y = 2 + data_pos[i][1]
- @helpwindow.bitmap.draw_text(x,y,600,22,text)
- end
- @helpwindow.bitmap.font.color = color2
- @helpwindow.bitmap.draw_text(25,2,600,22,text)
- end
- # ---------------------------------------------------------------------------
- def updatehelpwindow2
- data_pos = [[0,-1],[0,2]]
- color1 = Color.new(51,52,1,255)
- color2 = Color.new(252,255,2,255)
- text1 = sprintf('%.2f', checkplayercollection) # Porcentaje de colección
- text2 = checkplayercards # Total cartas
- s = (text2 != 1 ? 's' : '') # plural
- text3 = @textos[3][0] # Categoría completada al
- text4 = @textos[3][1] # Tu baraja tiene...
- text5 = @textos[3][2] # carta...
- text = "#{text4} #{text2} #{text5}#{s} #{text3} #{text1}%"
- @helpwindow2.bitmap.font.color = color1
- for i in 0...data_pos.size
- x = 25 + data_pos[i][0]
- y = 2 + data_pos[i][1]
- @helpwindow2.bitmap.draw_text(x,y,600,22,text,1)
- end
- @helpwindow2.bitmap.font.color = color2
- @helpwindow2.bitmap.draw_text(25,2,600,22,text,1)
- end
- # ---------------------------------------------------------------------------
- def checkplayercollection
- # Devuelve el Porcentaje completado de la colección de cartas
- total_cards = Newold::CARDS::Cards.size
- player_cards = 0.0
- for i in 0...$deck['player'].size
- next if $deck['player'][i] == nil or $deck['player'][i] == []
- player_cards += 1
- end
- return (player_cards / total_cards) * 100
- end
- # ---------------------------------------------------------------------------
- def checkplayercards
- # Devuelve el Total de cartas poseidas por el jugador
- totalcards = 0
- $deck['player'].each do |cards|
- if cards != nil and cards != []
- cards.each do |card|
- totalcards += 1
- end
- end
- end
- return totalcards
- end
- # ---------------------------------------------------------------------------
- def getdatawin1
- data = Newold::CARDS::Cards
- categorias = []
- for i in 0...data.size
- item = data[i]
- cat = item[6]
- categorias.push(cat) if !categorias.include?(cat)
- @cardsnumber[cat] = [] if @cardsnumber[cat] == nil
- @cardsnumber[cat].push(i)
- if @maxpag2[cat] != nil
- @maxpag2[cat] += 1
- else
- @maxpag2[cat] = 1
- end
- end
- @maxpag2.each do |key,value|
- @maxpag2[key] = value - 1
- end
- return categorias.sort
- end
- # ---------------------------------------------------------------------------
- def getdatawin2
- data = $deck['player']
- cartas = {}
- data.each do |item|
- next if item == nil
- next if item.size == 0
- cat = item[0][9]
- imaname = item[0][7]
- cartas[cat] = [] if cartas[cat] == nil
- cartas[cat].push(imaname) if !cartas.include?(imaname)
- if @data0[imaname] == nil
- @data0[imaname] = []
- end
- @data0[imaname].push(item)
- end
- return cartas
- end
- # ---------------------------------------------------------------------------
- def drawcontentwin1
- if @stars == nil
- @stars = []
- end
- @stars.each do |star|
- if star.is_a?(Array)
- if star[0].is_a?(Sprite)
- star[0].dispose
- end
- end
- end
- @stars = []
- @datawin1bitmap.bitmap.clear
- index = @index1 + (@page1 * @maxitemspage1)
- x = 15
- y = 5
- data_pos = [[-1,0],[1,0],[0,1],[0,-1],[0,2]]
- color1 = Color.new(255,255,255,255)
- color2 = Color.new(0,0,0,255)
- for i in index...index + @maxitemspage1
- return if i >= @data1.size
- cat = @data1[i]
- if @data2[cat] != nil
- complete_cards = (@data2[cat].size > @maxpag2[cat] ? true : false)
- if complete_cards
- star = Sprite.new
- star.z = 10
- star.x = 180
- star.y = y + 23
- @stars[i] = [star,0]
- end
- end
- @datawin1bitmap.bitmap.font.color = color2
- for z in 0...data_pos.size
- x1 = x + data_pos[z][0]
- y1 = y + data_pos[z][1]
- @datawin1bitmap.bitmap.draw_text(x1,y1,150,22,@data1[i])
- end
- @datawin1bitmap.bitmap.font.color = color1
- @datawin1bitmap.bitmap.draw_text(x,y,150,22,@data1[i])
- y += 24
- end
- @datawin1bitmap.opacity = 0
- end
- # ---------------------------------------------------------------------------
- def drawwin1selection
- index0 = @index1 + (@page1 * @maxitemspage1)
- x = 15
- y = 5 + (@index1 * 24)
- rect = Rect.new(x,y,172,24)
- color1 = Color.new(0,0,0,0)
- color2 = Color.new(58,204,202,255)
- color3 = Color.new(255,255,255,255)
- color4 = Color.new(0,0,0,255)
- data_pos = [[-1,0],[1,0],[0,1],[0,-1],[0,2]]
- if @last_index != nil
- y2 = 5 + (@last_index * 24)
- rect2 = Rect.new(x,y2,160,24)
- @datawin1bitmap.bitmap.fill_rect(rect2,color1)
- @datawin1bitmap.bitmap.font.color = color4
- index1 = @last_index + (@page1 * @maxitemspage1)
- for z in 0...data_pos.size
- x1 = x + data_pos[z][0]
- y1 = y2 + data_pos[z][1]
- @datawin1bitmap.bitmap.draw_text(x1,y1,152,22,@data1[index1])
- end
- @datawin1bitmap.bitmap.font.color = color3
- @datawin1bitmap.bitmap.draw_text(x,y2,152,22,@data1[index1])
- end
- @datawin1bitmap.bitmap.fill_rect(rect,color1)
- @datawin1bitmap.bitmap.font.color = color4
- for i in 0...data_pos.size
- x1 = x + data_pos[i][0] + 7
- y1 = y + data_pos[i][1]
- @datawin1bitmap.bitmap.draw_text(x1,y1,152,22,@data1[index0].to_s)
- end
- @datawin1bitmap.bitmap.font.color = color2
- @datawin1bitmap.bitmap.draw_text(x+7,y,152,22,@data1[index0].to_s)
- end
- # ---------------------------------------------------------------------------
- def drawcontentwin2
- @datawin2bitmap.bitmap.clear
- index0 = @index1 + (@page1 * @maxitemspage1)
- cat = @data1[index0]
- return if index0 >= @data1.size
- index = @index2# + (@page2 * @maxitemspage2)
- nocard = Bitmap.new(@nocardimage)
- y = 0
- x = 0
- imagedata = @data2[cat]
- imagedata = [] if imagedata == nil
- for i in index...index + @maxitemspage2
- return if i > @maxpag2[cat]
- if x == 4
- x = 0
- y += 1
- end
- if i < imagedata.size
- if @previewimas["#{@foldercards}#{imagedata[i]}"] == nil
- im = Bitmap.new("#{@foldercards}#{imagedata[i]}")
- @previewimas["#{@foldercards}#{imagedata[i]}"] = im
- else
- im = @previewimas["#{@foldercards}#{imagedata[i]}"]
- end
- ima = Bitmap.new(91,128)
- ima.stretch_blt(ima.rect,im,Rect.new(16,25,91,128))
- @datawin2bitmap.bitmap.blt(21+(x*98),7+(y*133),ima,ima.rect)
- else
- @datawin2bitmap.bitmap.blt(21+(x*98),7+(y*133),nocard,nocard.rect)
- end
- x += 1
- end
- @datawin2bitmap.opacity = 0
- end
- # ---------------------------------------------------------------------------
- def drawwin3
- #$deck['elementallist']
- @index3 = 0
- index = @index1 + (@page1 * @maxitemspage1)
- cat = @data1[index]
- data = @data0[@data2[cat][@index2]][0]
- cards_number = data.size
- drawcontentwin3(data[@index3],cards_number)
- @nodrawinwin4 = []
- drawcontentwin4(data)
- drawbarwin4(cards_number)
- @maxitemwin4 = cards_number
- @win3.visible = true
- @win4.visible = true
- @darkcontent = Sprite.new
- @darkcontent.bitmap = Bitmap.new(640,480)
- @darkcontent.bitmap.fill_rect(0,0,640,480,Color.new(0,0,0,160))
- @darkcontent.opacity = 30
- @darkcontent.z = 200
- viewport = Viewport.new(352,148,177,250)
- viewport.z = 252
- @previewimage = Sprite.new(viewport)
- @previewimage.bitmap = Bitmap.new(177,250)
- @previewimage.x = 410
- draw_card_preview(data[@index3])
- @previewimage.z = 252
- for i in 0...5
- @win3.x -= 82
- @previewimage.x -= 82
- @darkcontent.opacity += 15
- Graphics.update
- end
- viewport = Viewport.new(352,148,177,250)
- viewport.z = 251
- @backuppreviewimage = Sprite.new(viewport)
- @backuppreviewimage.z = 251
- @win3.x = 0
- @datawin4bitmap.oy = 0 + @datawin4bitmap.bitmap.height
- mod_y = @datawin4bitmap.oy / 10
- for i in 0...10
- @win4.y += 23
- @datawin4bitmap.oy -= mod_y
- @darkcontent.opacity += 15
- Graphics.update
- end
- @datawin4bitmap.oy = 0
- @win4.y = 0
- @barbottom.visible = true
- @bartop.visible = true
- end
- # ---------------------------------------------------------------------------
- def drawcontentwin3(data,cards_number)
- data_pos = [[1,0],[-1,0],[0,1],[0,-1],[0,2]]
- color1 = Color.new(255,255,255,255)
- color2 = Color.new(0,0,0,255)
- color3 = Color.new(58,204,202,255)
- color4 = Color.new(209,19,151,255)
- color5 = Color.new(204,134,58,255)
- color6 = Color.new(213,9,9,255)
- color7 = Color.new(219,224,24,255)
- @win3.bitmap = Bitmap.new(@win3image)
- @win3.bitmap.font.size = 19
- text1 = "#{@textos[1][0]}: " # nombre
- text2 = "#{@textos[1][1]}: " # categoría
- text3 = "#{@textos[1][2]}" # carta única
- text4 = "#{@textos[1][3]} (" # Cartas en posesión
- text5 = "#{@textos[1][4]}: " # atributo
- text6 = "#{@textos[1][5]}" # palabra ninguno
- name = data[1]
- cat = data[9]
- uniq = data[4]
- iconelement = Bitmap.new(20,18)
- if $deck['elementallist'][data[2]] != nil
- textelement = $deck['elementallist'][data[2]][1]
- ima = Bitmap.new($deck['elementallist'][data[2]][0])
- iconelement.stretch_blt(iconelement.rect,ima,ima.rect)
- else
- textelement = text6
- end
- # -----------------------------------------------------------
- @win3.bitmap.font.color = color2
- for i in 0...data_pos.size
- x = data_pos[i][0]
- y = data_pos[i][1]
- # -----------------------------------------------------------
- @win3.bitmap.draw_text(x+8,y+8,88,20,text1)
- @win3.bitmap.draw_text(x+8,y+28,88,20,text2)
- @win3.bitmap.draw_text(x+8,y+48,88,20,text5)
- @win3.bitmap.draw_text(x+8,y+88,230,20,"#{text4}#{cards_number})")
- # -----------------------------------------------------------
- @win3.bitmap.draw_text(x+92,y+8,153,20,name)
- @win3.bitmap.draw_text(x+92,y+28,153,20,cat)
- if textelement != text6
- @win3.bitmap.draw_text(x+115,y+48,153,20,textelement)
- else
- @win3.bitmap.draw_text(x+92,y+48,153,20,textelement)
- end
- # -----------------------------------------------------------
- @win3.bitmap.draw_text(x+8,y+68,230,20,text3) if uniq == 1
- end
- # -----------------------------------------------------------
- @win3.bitmap.font.color = color1
- @win3.bitmap.draw_text(8,8,88,20,text1)
- @win3.bitmap.draw_text(8,28,88,20,text2)
- @win3.bitmap.draw_text(8,48,88,20,text5)
- @win3.bitmap.draw_text(8,88,230,20,text4)
- w = @win3.bitmap.text_size(text4).width
- @win3.bitmap.font.color = color5
- @win3.bitmap.draw_text(8+w,88,230,20,"#{cards_number}")
- w2 = @win3.bitmap.text_size("#{cards_number}").width
- @win3.bitmap.font.color = color1
- @win3.bitmap.draw_text(8+w+w2,88,230,20,"):")
- # -----------------------------------------------------------
- @win3.bitmap.font.color = color6
- @win3.bitmap.draw_text(92,8,153,20,name)
- @win3.bitmap.font.color = color3
- @win3.bitmap.draw_text(92,28,153,20,cat)
- @win3.bitmap.font.color = color7
- if textelement != text6
- @win3.bitmap.blt(91,50,iconelement,iconelement.rect)
- @win3.bitmap.draw_text(115,48,153,20,textelement)
- else
- @win3.bitmap.draw_text(92,48,153,20,textelement)
- end
- # -----------------------------------------------------------
- @win3.bitmap.font.color = color4
- @win3.bitmap.draw_text(8,68,230,20,text3) if uniq == 1
- # -----------------------------------------------------------
- end
- # ---------------------------------------------------------------------------
- def drawcontentwin4(data,limit1 = -1,limit2 = -1)
- data_pos = [[1,0],[0,2],[0,1],[-1,0],[0,-1]]
- color1 = Color.new(255,255,255,255)
- color2 = Color.new(0,0,0,255)
- color3 = Color.new(204,134,58,255)
- x = 5
- y = 0
- text1 = @textos[1][6]
- text2 = @textos[1][7]
- cnt = 0
- if limit1 == -1
- @win4.bitmap = Bitmap.new(@win4image)
- w = 233
- h = 18 + (data.size * 22)
- @datawin4bitmap.bitmap = Bitmap.new(w,h)
- @datawin4bitmap.bitmap.font.size = 18
- else
- for i in limit1..limit2
- next if @nodrawinwin4.include?(i)
- x1 = x
- y1 = y + (i * 22)
- @datawin4bitmap.bitmap.fill_rect(x1,y1,233,22,Color.new(0,0,0,0))
- end
- end
- for i in 0...data.size
- if limit1 != -1
- if i < limit1
- y += 22
- next
- end
- break if i > limit2
- end
- if @nodrawinwin4.include?(i)
- y += 22
- next
- end
- break if cnt > 6 and limit1 == -1
- @nodrawinwin4.push(i)
- cnt += 1
- atk = data[i][3]
- id = i + 1
- @datawin4bitmap.bitmap.font.color = color2
- for i in 0...data_pos.size
- x1 = x + data_pos[i][0]
- y1 = y + data_pos[i][1]
- text = "#{text1} #{id}: "
- @datawin4bitmap.bitmap.draw_text(x1,y1,100,22,text)
- w = @datawin4bitmap.bitmap.text_size(text).width
- text = "(#{text2} - #{atk[0]}/#{atk[1]}/#{atk[2]}/#{atk[3]})"
- @datawin4bitmap.bitmap.draw_text(x1+w,y1,141,22,text)
- end
- text = "#{text1} #{id}: "
- @datawin4bitmap.bitmap.font.color = color3
- @datawin4bitmap.bitmap.draw_text(x,y,100,22,text)
- w = @datawin4bitmap.bitmap.text_size(text).width
- text = "(#{text2} - #{atk[0]}/#{atk[1]}/#{atk[2]}/#{atk[3]})"
- @datawin4bitmap.bitmap.font.color = color1
- @datawin4bitmap.bitmap.draw_text(x+w,y,141,22,text)
- y += 22
- end
- end
- # ---------------------------------------------------------------------------
- def drawbarwin4(size)
- real_size = size - 6
- if real_size > 0
- h_top = 137 - (4 * real_size)
- h_top = 6 if h_top < 6
- else
- h_top = 137
- end
- @barbottom = Sprite.new
- @barbottom.bitmap = Bitmap.new(@win4barbottom)
- @barbottom.x = 333
- @barbottom.y = 252
- @barbottom.z = 10000
- @barbottom.visible = false
- top = Bitmap.new(@win4bartop)
- @bartop = Sprite.new
- @bartop.bitmap = Bitmap.new(7,h_top)
- @bartop.bitmap.stretch_blt(@bartop.bitmap.rect,top,top.rect)
- @bartop.x = 334
- @bartop.y = 253
- @bartop.z = 10000
- @bartop.visible = false
- end
- # ---------------------------------------------------------------------------
- def draw_card_preview(data)
- # --------------------------------------------------------------
- if @backuppreviewimage != nil
- @backuppreviewimage.bitmap = @previewimage.bitmap.dup
- opacity = 110
- else
- opacity = 255
- end
- # --------------------------------------------------------------
- atks = data[3]
- pos = data[8]
- im = @previewimas["#{@foldercards}#{data[7]}"]
- ima = Bitmap.new(177,250)
- ima.blt(0,0,im,Rect.new(931,37,177,250))
- @previewimage.bitmap.blt(0,0,ima,ima.rect)
- # Añadir los valores de ataque a la carta seleccionada
- # ------------------------------------------------------------------------
- pos_mod = [[1,0],[-1,0],[0,1],[0,-1],[2,0],[-2,0],[0,2],[0,-2]]
- atk_arr = (atks[0] == 10 ? "A" : atks[0])
- atk_izq = (atks[1] == 10 ? "A" : atks[1])
- atk_der = (atks[2] == 10 ? "A" : atks[2])
- atk_aba = (atks[3] == 10 ? "A" : atks[3])
- case pos
- when 0 # Arriba Izquierda
- x = -6
- y = 10
- when 1 # Arriba Derecha
- x = 99
- y = 10
- when 2 # Inferior Izquierda
- x = -6
- y = 137
- when 3 # Inferior Derecha
- x = 99
- y = 137
- end
- @previewimage.bitmap.font.color = Color.new(0,0,0,255)
- for i in 0...pos_mod.size
- x1 = x + pos_mod[i][0]
- y1 = y + pos_mod[i][1]
- @previewimage.bitmap.font.size = 36
- # Posición Ataque Arriba
- @previewimage.bitmap.draw_text(x1,y1,80,40,"#{atk_arr}",1)
- # Posición Ataque Izquierda / Derecha
- @previewimage.bitmap.draw_text(x1,y1+28,80,40,"#{atk_izq} #{atk_der}",1)
- # Posición Ataque Abajo
- @previewimage.bitmap.draw_text(x1,y1+56,80,40,"#{atk_aba}",1)
- end
- @previewimage.bitmap.font.color = Color.new(255,255,255,255)
- @previewimage.bitmap.font.size = 36
- # Posición Ataque Arriba
- @previewimage.bitmap.draw_text(x,y,80,40,"#{atk_arr}",1)
- # Posición Ataque Izquierda / Derecha
- @previewimage.bitmap.draw_text(x,y+28,80,40,"#{atk_izq} #{atk_der}",1)
- # Posición Ataque Abajo
- @previewimage.bitmap.draw_text(x,y+56,80,40,"#{atk_aba}",1)
- @previewimage.opacity = opacity
- # ------------------------------------------------------------------------
- end
- # ---------------------------------------------------------------------------
- def drawnumberpage
- if @numberpageima != nil
- @numberpageima.bitmap.clear
- else
- @numberpageima = Sprite.new
- @numberpageima.bitmap = Bitmap.new(640,26)
- @numberpageima.bitmap.font.size = 20
- @numberpageima.x = 0
- @numberpageima.y = 429
- @numberpageima.z = 10
- end
- data_pos = [[1,0],[0,2],[0,1],[-1,0],[0,-1]]
- color1 = Color.new(0,0,0,255)
- color2 = Color.new(219,158,12,255)
- texto1 = @textos[0][0] # Página...
- texto2 = @textos[0][1] # De...
- texto3 = @textos[0][2] # Categoría completada al...
- n1 = @page1 + 1
- n2 = @page2 + 1
- maxn1 = @maxpage1 + 1
- index = @index1 + (@page1 * @maxitemspage1)
- cat = @data1[index]
- maxn2 = (@maxpag2[cat] / @maxitemspage2) + 1
- if maxn1 > 1
- text1 = "#{texto1} #{n1} #{texto2} #{maxn1}"
- else
- text1 = "#{texto1} #{n1}"
- end
- if maxn2 > 1
- text2 = "#{texto1} #{n2} #{texto2} #{maxn2}"
- else
- text2 = "#{texto1} #{n2}"
- end
- if @data2[cat] != nil
- perc = (@data2[cat].size / (@maxpag2[cat]+1.0)) * 100
- perc2 = perc
- perc = sprintf('%.2f', perc)
- perc = 100 if perc == '100.00'
- else
- perc = 0
- end
- text3 = "(#{texto3} #{perc}%)"
- @maxitemspage2
- @numberpageima.bitmap.font.color = color1
- for i in 0...data_pos.size
- x = -6 + data_pos[i][0]
- y = 3 + data_pos[i][1]
- @numberpageima.bitmap.draw_text(x,y,179,22,text1,2)
- @numberpageima.bitmap.draw_text(x,y,593,22,text2,2)
- @numberpageima.bitmap.draw_text(x+256,y,230,22,text3,0)
- end
- @numberpageima.bitmap.font.color = color2
- @numberpageima.bitmap.draw_text(-6,3,179,22,text1,2)
- @numberpageima.bitmap.draw_text(-6,3,593,22,text2,2)
- @numberpageima.bitmap.draw_text(250,3,230,22,text3,0)
- end
- # ---------------------------------------------------------------------------
- def hidewin3
- mod_y = @datawin4bitmap.bitmap.height / 5
- @barbottom.dispose
- @bartop.dispose
- @indicatorwin4top.visible = false
- @indicatorwin4bottom.visible = false
- @backuppreviewimage.viewport.dispose
- @backuppreviewimage.dispose
- @backuppreviewimage = nil
- for i in 0...10
- @win4.y -= 23
- @datawin4bitmap.oy += 23 + mod_y
- @darkcontent.opacity -= 15
- Graphics.update
- end
- @win4.y = -233
- for i in 0...5
- @win3.x += 82
- @previewimage.x += 82
- @darkcontent.opacity -= 15
- Graphics.update
- end
- @darkcontent.dispose
- @previewimage.viewport.dispose
- @previewimage.dispose
- @win3.x = 412
- @win3.visible = false
- @win4.visible = false
- end
- # ---------------------------------------------------------------------------
- def animatecursor
- return if @fase == 2
- @anicursor = 0 if @anicursor == @aniglobal.size
- @cursor.x += @aniglobal[@anicursor]
- @indicatorwin4top.y -= @aniglobal[@anicursor]
- @indicatorwin4bottom.y += @aniglobal[@anicursor]
- @anicursor += 1
- # Animar selector
- case @aniglobal[@anicursor]
- when -1:
- @selector.opacity -= 10
- @selector_win2.opacity -= 25 if rand(2) % 2 == 0
- when 1:
- @selector.opacity += 10
- @selector_win2.opacity += 25 if rand(2) % 2 == 0
- end
- end
- # ---------------------------------------------------------------------------
- def animatestars
- bitmap = Bitmap.new(@ministar)
- for i in 0...@stars.size
- next if @stars[i] == nil
- x = @stars[i][1] * 22
- @stars[i][0].bitmap = Bitmap.new(22,22)
- @stars[i][0].bitmap.blt(0,0,bitmap,Rect.new(x,0,22,22))
- @stars[i][1] += 1
- @stars[i][1] = 0 if @stars[i][1] == 14
- end
- end
- # ---------------------------------------------------------------------------
- def fadeindatawinbitmap
- @datawin1bitmap.opacity += 20
- @datawin2bitmap.opacity += 20
- end
- # ---------------------------------------------------------------------------
- def animatepages
- sum = (@indicator_frame == 1 ? 3 : -3)
- ima = Bitmap.new(@indicatorsimage)
- if @maxpage1 > 0
- if @indicator1a == nil
- @indicator1a = Sprite.new
- @indicator1a.bitmap = Bitmap.new(25,23)
- @indicator1a.y = 430
- @indicator1a.x = 22
- @indicator1a.z = 100
- @indicator1b = Sprite.new
- @indicator1b.bitmap = Bitmap.new(25,23)
- @indicator1b.y = 430
- @indicator1b.x = 176
- @indicator1b.z = 100
- end
- @indicator1a.bitmap.clear
- @indicator1b.bitmap.clear
- @indicator1a.bitmap.blt(0,0,ima,Rect.new(0+(@indicator_frame*25),0,25,23))
- @indicator1b.bitmap.blt(0,0,ima,Rect.new(0+(@indicator_frame*25),23,25,23))
- @indicator1a.x += sum
- @indicator1b.x -= sum
- end
- index = @index1 + (@page1 * @maxitemspage1)
- cat = @data1[index]
- maxn = (@maxpag2[cat] / @maxitemspage2) + 1
- if maxn > 1
- if @indicator2a == nil
- @indicator2a = Sprite.new
- @indicator2a.bitmap = Bitmap.new(25,23)
- @indicator2a.y = 430
- @indicator2a.x = 220
- @indicator2a.z = 100
- @indicator2b = Sprite.new
- @indicator2b.bitmap = Bitmap.new(25,23)
- @indicator2b.y = 430
- @indicator2b.x = 592
- @indicator2b.z = 100
- end
- @indicator2a.bitmap.clear
- @indicator2b.bitmap.clear
- frame = (@indicator_frame == 1 ? 0 : 1)
- @indicator2a.bitmap.blt(0,0,ima,Rect.new(0+(frame*25),0,25,23))
- @indicator2b.bitmap.blt(0,0,ima,Rect.new(0+(frame*25),23,25,23))
- @indicator2a.x += sum
- @indicator2b.x -= sum
- else
- if @indicator2a != nil
- @indicator2a.bitmap.clear
- @indicator2b.bitmap.clear
- @indicator2a.x += sum
- @indicator2b.x -= sum
- end
- end
- end
- # ---------------------------------------------------------------------------
- def cursor_ini
- @cursor.x = 3
- @cursor.y = 32
- end
- # ---------------------------------------------------------------------------
- def refresh_indicators_win4
- if @win == 3
- @indicatorwin4top.visible = (@datawin4bitmap.oy > 0 ? true : false)
- if @datawin4bitmap.bitmap.height - @datawin4bitmap.oy > 150
- @indicatorwin4bottom.visible = true
- else
- @indicatorwin4bottom.visible = false
- end
- if @indicatorwin4top.y > 253
- @indicatorwin4top.y = 249
- end
- if @indicatorwin4bottom.y < 384
- @indicatorwin4bottom.y = 388
- end
- else
- @indicatorwin4top.visible = false
- @indicatorwin4bottom.visible = false
- end
- end
- # ---------------------------------------------------------------------------
- def refresh_cardpreview_opacity
- if !@previewimage.disposed?
- @previewimage.opacity += 5
- end
- end
- # ---------------------------------------------------------------------------
- def update_win1
- # ***********************************************************
- # Update para la ventana 1
- # ***********************************************************
- # Botones de acción
- if Input.trigger?(Input::C) # Activar ventana 2
- Audio.se_play(@soundcursor,85)
- x_final = 216
- y_final = 50
- modx = (x_final - @cursor.x) / 4
- mody = (y_final - @cursor.y) / 4
- for i in 0...4
- @cursor.x += modx
- @cursor.y += mody
- Graphics.update
- end
- @cursor.x = x_final
- @cursor.y = y_final
- Graphics.update
- @anicursor = 0
- @index2 = 0 + (12 * @page2)
- @win = 2
- index = @index1 + (@page1 * @maxitemspage1)
- cat = @data1[index]
- if @data2[cat] != nil
- if @data2[cat][@index2] == nil
- @selector_win2.visible = false
- else
- @selector_win2.visible = true
- end
- else
- @selector_win2.visible = false
- end
- @selector_win2.x = @cursor.x + 10
- @selector_win2.y = @cursor.y - 20
- updatehelpwindow
- return
- end
- if Input.trigger?(Input::B) # Salir del menú
- @exit = true
- @cursor.visible = false
- @numberpageima.visible = false
- for i in 0...@stars.size
- next if @stars[i] == nil
- @stars[i][0].visible = false
- end
- Audio.se_play(@soundcancel,85)
- if @indicator1a != nil
- @indicator1a.visible = false
- @indicator1b.visible = false
- end
- if @indicator2a != nil
- @indicator2a.visible = false
- @indicator2b.visible = false
- end
- @helpwindow2.visible = false
- for i in 0...10
- @win1.x -= 20
- @datawin1bitmap.x -= 20
- @win2.x += 42
- @datawin2bitmap.x += 42
- @fondo.opacity -= 25
- @helpwindow.opacity -= 25
- Graphics.update
- end
- return
- end
- # Direcciones / Movimiento del cursor
- if Input.repeat?(Input::DOWN)
- Audio.se_play(@soundcursor,85)
- index0 = @index1 + 1 + (@page1 * @maxitemspage1)
- @last_index = @index1
- if @index1 < @data1.size - 1 and @index1 < @maxitemspage1 - 1 and
- @data1[index0] != nil
- @index1 += 1
- @cursor.y += 24
- elsif @index1 == @maxitemspage1 - 1 or @data1[index0] == nil
- cursor_ini
- @index1 = 0
- end
- @page2 = 0
- @index2 = 0
- drawcontentwin2
- drawwin1selection
- drawnumberpage
- return
- end
- if Input.repeat?(Input::UP)
- Audio.se_play(@soundcursor,85)
- @last_index = @index1
- if @index1 > 0
- @index1 -= 1
- @cursor.y -= 24
- elsif @index1 == 0
- index0 = @index1 + 1 + (@page1 * @maxitemspage1)
- while @index1 < @maxitemspage1 - 1 and @data1[index0] != nil
- @index1 += 1
- @cursor.y += 24
- index0 = @index1 + 1 + (@page1 * @maxitemspage1)
- end
- end
- @page2 = 0
- @index2 = 0
- drawcontentwin2
- drawwin1selection
- drawnumberpage
- return
- end
- if Input.trigger?(Input::LEFT) or Input.trigger?(Input::Y) or
- Input.trigger?(Input::L)
- return if @maxpage1 <= 0
- Audio.se_play(@soundcursor,85)
- cursor_ini
- @last_index = nil
- @page1 -= 1
- @page1 = @maxpage1 if @page1 < 0
- @index1 = 0
- drawcontentwin1
- drawcontentwin2
- drawwin1selection
- @page2 = 0
- @index2 = 0
- drawnumberpage
- return
- end
- if Input.trigger?(Input::RIGHT) or Input.trigger?(Input::Z) or
- Input.trigger?(Input::R)
- return if @maxpage1 <= 0
- Audio.se_play(@soundcursor,85)
- cursor_ini
- @last_index = nil
- @page1 += 1
- @page1 = 0 if @page1 > @maxpage1
- @index1 = 0
- drawcontentwin1
- drawcontentwin2
- drawwin1selection
- @page2 = 0
- @index2 = 0
- drawnumberpage
- return
- end
- end
- # ---------------------------------------------------------------------------
- def update_win2
- # ***********************************************************
- # Update para la ventana 2
- # ***********************************************************
- # Botones de acción
- if Input.trigger?(Input::C)
- index = @index1 + (@page1 * @maxitemspage1)
- cat = @data1[index]
- if @data2[cat] != nil
- return if @data2[cat][@index2] == nil
- @cursor.visible = false
- @backupcursorx = @cursor.x
- @backupcursory = @cursor.y
- @backupanicursor = @anicursor
- @anicursor = 0
- @cursor.x = 88
- @cursor.y = 262
- Audio.se_play(@soundcursor,85)
- if @indicator1a != nil
- @indicator1a.visible = false
- @indicator1b.visible = false
- end
- if @indicator2a != nil
- @indicator2a.visible = false
- @indicator2b.visible = false
- end
- drawwin3
- @win = 3
- @cursor.visible = true
- updatehelpwindow
- end
- return
- end
- if Input.trigger?(Input::B)
- x_final = 3
- y_final = 32 + (@index1 * 24)
- modx = (x_final - @cursor.x) / 4
- mody = (y_final - @cursor.y) / 4
- @selector_win2.visible = false
- Audio.se_play(@soundcancel,85)
- for i in 0...4
- @cursor.x += modx
- @cursor.y += mody
- Graphics.update
- end
- @cursor.x = x_final
- @cursor.y = y_final
- Graphics.update
- @win = 1
- @anicursor = 0
- @index2 = 0 + (@page2 * 12)
- updatehelpwindow
- return
- end
- # Direcciones / Movimiento del cursor
- x = y = 0
- if Input.repeat?(Input::DOWN)
- y = 133
- @index2 += 4
- end
- if Input.repeat?(Input::UP)
- y = -133
- @index2 -= 4
- end
- if Input.repeat?(Input::RIGHT)
- x = 98
- @index2 += 1
- end
- if Input.repeat?(Input::LEFT)
- Audio.se_play(@soundcursor,85)
- x = -98
- @index2 -= 1
- end
- if x != 0 or y != 0
- Audio.se_play(@soundcursor,85)
- for i in @anicursor...@aniglobal.size
- @cursor.x += @aniglobal[i]
- end
- @cursor.x += x
- @cursor.y += y
- @anicursor = 0
- if @cursor.x > 600
- @cursor.x = 216
- @cursor.y += 133
- end
- if @cursor.x < 200
- @cursor.x = 216 + (98*3)
- @cursor.y -= 133
- end
- if @cursor.y > 316
- @cursor.y = 50
- @index2 -= 12
- end
- if @cursor.y < 50
- @cursor.y = 316
- @index2 += 12
- end
- if @index2 < 0 + (@page2 * 12)
- @index2 = 0 + (@page2 * 12)
- elsif @index2 > 11 + (@page2 * 12)
- @index2 = 11 + (@page2 * 12)
- end
- @selector_win2.x = @cursor.x + 10
- @selector_win2.y = @cursor.y - 20
- @selector_win2.opacity = 255
- index = @index1 + (@page1 * @maxitemspage1)
- cat = @data1[index]
- if @data2[cat] != nil
- if @data2[cat][@index2] == nil
- @selector_win2.visible = false
- else
- @selector_win2.visible = true
- end
- else
- @selector_win2.visible = false
- end
- return
- end
- # Alternar entre páginas
- if Input.trigger?(Input::Y) or Input.trigger?(Input::L)
- index = @index1 + (@page1 * @maxitemspage1)
- cat = @data1[index]
- maxn = (@maxpag2[cat] / @maxitemspage2) + 1
- return if maxn <= 1
- Audio.se_play(@soundcursor,85)
- @cursor.x = 216
- @cursor.y = 50
- @anicursor = 0
- @page2 -= 1
- @page2 = (@maxpag2[cat] / @maxitemspage2) if @page2 < 0
- @index2 = 0 + (@page2 * 12)
- drawcontentwin2
- @selector_win2.x = @cursor.x + 10
- @selector_win2.y = @cursor.y - 20
- @selector_win2.opacity = 255
- index = @index1 + (@page1 * @maxitemspage1)
- cat = @data1[index]
- if @data2[cat] != nil
- if @data2[cat][@index2] == nil
- @selector_win2.visible = false
- else
- @selector_win2.visible = true
- end
- else
- @selector_win2.visible = false
- end
- drawnumberpage
- return
- end
- if Input.trigger?(Input::Z) or Input.trigger?(Input::R)
- index = @index1 + (@page1 * @maxitemspage1)
- cat = @data1[index]
- maxn = (@maxpag2[cat] / @maxitemspage2) + 1
- return if maxn <= 1
- Audio.se_play(@soundcursor,85)
- @cursor.x = 216
- @cursor.y = 50
- @anicursor = 0
- @page2 += 1
- @page2 = 0 if @page2 > (@maxpag2[cat] / @maxitemspage2)
- @index2 = 0 + (@page2 * 12)
- drawcontentwin2
- @selector_win2.x = @cursor.x + 10
- @selector_win2.y = @cursor.y - 20
- @selector_win2.opacity = 255
- index = @index1 + (@page1 * @maxitemspage1)
- cat = @data1[index]
- if @data2[cat] != nil
- if @data2[cat][@index2] == nil
- @selector_win2.visible = false
- else
- @selector_win2.visible = true
- end
- else
- @selector_win2.visible = false
- end
- drawnumberpage
- return
- end
- end
- # ---------------------------------------------------------------------------
- def update_win3
- # ***********************************************************
- # Update para la ventana 3
- # ***********************************************************
- # Botones de acción
- if Input.trigger?(Input::B)
- Audio.se_play(@soundcancel,85)
- @cursor.visible = false
- hidewin3
- if @indicator1a != nil
- @indicator1a.visible = true
- @indicator1b.visible = true
- end
- if @indicator2a != nil
- @indicator2a.visible = true
- @indicator2b.visible = true
- end
- @cursor.visible = true
- @cursor.x = @backupcursorx
- @cursor.y = @backupcursory
- @anicursor = @backupanicursor
- @win = 2
- updatehelpwindow
- end
- # Direcciones / Movimiento del cursor
- if Input.repeat?(Input::DOWN) or Input.press?(Input::Z)
- if Input.press?(Input::Z)
- n = 6
- limit1 = (@index3+6) - 5
- limit2 = (@index3+7)
- else
- n = 1
- limit1 = @index3+1
- limit2 = @index3+5
- end
- playsound = true
- for i in 0...n
- if @cursor.y < 372 and (@index3+1) < @maxitemwin4
- Audio.se_play(@soundcursor,85) if playsound
- @cursor.y += 22
- @index3 += 1
- elsif (@index3+1) < @maxitemwin4
- Audio.se_play(@soundcursor,85) if playsound
- @datawin4bitmap.oy += 22
- real_desplace = (137 - @bartop.bitmap.height)
- desplace = real_desplace.to_f / (@maxitemwin4-6)
- move_bar = 253 + (desplace * (@index3-4))
- @bartop.y = move_bar
- @index3 += 1
- end
- playsound = false
- end
- index = @index1 + (@page1 * @maxitemspage1)
- cat = @data1[index]
- data = @data0[@data2[cat][@index2]][0]
- drawcontentwin4(data,limit1,limit2)
- draw_card_preview(data[@index3])
- return
- end
- if Input.repeat?(Input::UP) or Input.press?(Input::Y)
- if Input.press?(Input::Y)
- n = 6
- else
- n = 1
- end
- playsound = true
- for i in 0...n
- if @cursor.y > 262 and @index3 > 0
- Audio.se_play(@soundcursor,85) if playsound
- @cursor.y -= 22
- @index3 -= 1
- elsif @index3 > 0
- Audio.se_play(@soundcursor,85) if playsound
- @datawin4bitmap.oy -= 22
- real_desplace = (137 - @bartop.bitmap.height)
- desplace = real_desplace.to_f / (@maxitemwin4-6)
- move_bar = 253 + (desplace * (@index3-1))
- @bartop.y = move_bar
- @index3 -= 1
- end
- playsound = false
- end
- index = @index1 + (@page1 * @maxitemspage1)
- cat = @data1[index]
- data = @data0[@data2[cat][@index2]][0]
- draw_card_preview(data[@index3])
- return
- end
- end
- # ---------------------------------------------------------------------------
- def dispose
- @fondo.dispose
- @cursor.dispose
- @helpwindow.dispose
- @helpwindow2
- @selector_win2.dispose
- @win1.viewport.dispose
- @win1.dispose
- @win2.viewport.dispose
- @win2.dispose
- @win3.viewport.dispose
- @win3.dispose
- @win4.viewport.dispose
- @win4.dispose
- @indicator1a.dispose if @indicator1a != nil
- @indicator1b.dispose if @indicator1b != nil
- @indicator2a.dispose if @indicator2a != nil
- @indicator2b.dispose if @indicator2b != nil
- @datawin1bitmap.dispose
- @datawin2bitmap.dispose
- @datawin4bitmap.dispose
- @indicatorwin4top.dispose
- @indicatorwin4bottom.dispose
- @numberpageima.dispose
- for i in 0...@stars.size
- next if @stars[i] == nil
- @stars[i][0].dispose
- end
- end
- # ---------------------------------------------------------------------------
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement