Advertisement
TechSkylander1518

Tristantine Dex Display

Dec 15th, 2022
1,057
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.04 KB | None | 0 0
  1. module TristantineDisplay
  2.   PANEL_WIDTH = 176
  3.   PANEL_HEIGHT = 240
  4.  
  5.   BACKGROUND = Color.new(200,191,231)
  6.   BORDER = Color.new(0,0,0)
  7.  
  8.   CENTER_BORDER = Color.new(195,195,195)
  9.   CENTER_BG = Color.new(248,248,248)
  10.  
  11.   TEXT_BASE_COLOR = Color.new(248,248,248)
  12.   TEXT_SHADOW_COLOR = Color.new(128,120,112)
  13.  
  14.   FONT_NAME = MessageConfig::SMALL_FONT_NAME
  15.   FONT_SIZE = MessageConfig::SMALL_FONT_SIZE
  16.   FONT_Y_OFFSET = MessageConfig::FONT_Y_OFFSET
  17.  
  18.   ROW_LENGTH = 6 #Number of Pokemon displayed per row
  19.   PANEL_GAP_X = 2
  20.   PANEL_GAP_Y = 2
  21.  
  22.   TYPE_COLORS = [
  23.   #Light,Main,Dark
  24.   [Color.new(216,216,192),Color.new(168,168,120),Color.new(112,88,72)],  #Normal
  25.   [Color.new(240,128,48),Color.new(192,48,40),Color.new(72,64,56)],      #Fighting
  26.   [Color.new(200,192,248),Color.new(168,144,240),Color.new(112,88,152)], #Flying
  27.   [Color.new(216,128,184),Color.new(160,64,160),Color.new(72,56,80)],    #Poison
  28.   [Color.new(248,248,120),Color.new(224,192,104),Color.new(136,104,48)], #Ground
  29.   [Color.new(224,192,104),Color.new(184,160,56),Color.new(136,104,48)],  #Rock
  30.   [Color.new(216,224,48),Color.new(168,184,32),Color.new(120,144,16)],   #Bug
  31.   [Color.new(168,144,240),Color.new(112,88,152),Color.new(72,56,80)],    #Ghost
  32.   [Color.new(216,216,192),Color.new(184,184,208),Color.new(128,120,112)],#Steel
  33.   [Color.new(112,200,176),Color.new(104,160,144),Color.new(32,104,96)],  #???
  34.   [Color.new(248,208,48),Color.new(240,128,48),Color.new(192,48,40)],    #Fire
  35.   [Color.new(152,216,216),Color.new(104,144,240),Color.new(128,120,112)],#Water
  36.   [Color.new(192,248,96),Color.new(120,200,80),Color.new(88,128,64)],    #Grass
  37.   [Color.new(248,248,120),Color.new(248,208,48),Color.new(184,160,56)],  #Electric
  38.   [Color.new(248,192,176),Color.new(248,88,136),Color.new(144,96,96)],   #Psychic
  39.   [Color.new(208,248,232),Color.new(152,216,216),Color.new(144,144,160)],#Ice
  40.   [Color.new(184,160,248),Color.new(112,56,248),Color.new(72,56,144)],   #Dragon
  41.   [Color.new(168,168,120),Color.new(112,88,72),Color.new(72,64,56)],     #Dark
  42.   [Color.new(248,216,224),Color.new(240,168,176),Color.new(168,120,136)],#Fairy
  43.  
  44.   ]
  45.  
  46.   def self.pbFakedexPanel(species,regiondex)
  47.     species = GameData::Species.get(species)
  48.     monotype = (species.types.length == 1)
  49.     type = species.types[0]
  50.     type2 = species.types[1] if !monotype
  51.     type_number = GameData::Type.get(type).icon_position
  52.     colors = TYPE_COLORS[type_number]
  53.     color_light = colors[0]
  54.     color_main = colors[1]
  55.     color_dark = colors[2]
  56.     base = Bitmap.new(PANEL_WIDTH,PANEL_HEIGHT)
  57.     base.fill_rect(0, 0, base.width, base.height, BACKGROUND)
  58.     base.fill_rect(2, 0, base.width - 4 , base.height, BORDER)
  59.     base.fill_rect(0, 2, base.width , base.height - 4, BORDER)
  60.     base.fill_rect(2, 2, base.width - 4, base.height - 4, color_light)
  61.     base.fill_rect(4, 4, base.width - 6, base.height - 6, color_dark)
  62.     base.fill_rect(4, 4, base.width - 8, base.height - 8, color_main)
  63.     base.fill_rect(4, 22, 168, 168, BORDER)
  64.     base.fill_rect(6, 24, 164, 164, CENTER_BORDER)
  65.     base.fill_rect(8, 26, 160, 160, CENTER_BG)
  66.    
  67.     shadow = Bitmap.new(GameData::Species.shadow_filename(species))
  68.     shadow_x = (base.width/2) - (shadow.width/2)
  69.     shadow_y = 182 - shadow.height
  70.     shadow_rect = Rect.new(0,0,shadow.width,shadow.height)
  71.     base.blt(shadow_x, shadow_y, shadow, shadow_rect)
  72.     sprite = Bitmap.new(GameData::Species.front_sprite_filename(species.id))
  73.     metrics = GameData::SpeciesMetrics.get_species_form(species.id,0)
  74.     sprite_x = (base.width/2) - (sprite.width/2)
  75.     sprite_x += (metrics.front_sprite[0] * 2)
  76.     sprite_y = 14
  77.     sprite_y += metrics.front_sprite[1] * 2
  78.     sprite_rect = Rect.new(0,0,sprite.width,sprite.height)
  79.     base.blt(sprite_x, sprite_y, sprite, sprite_rect)
  80.    
  81.     base.font.name = FONT_NAME
  82.     base.font.size = FONT_SIZE
  83.     base.text_offset_y = FONT_Y_OFFSET
  84.     nationalDexList = [:NONE]
  85.     dexnum = regiondex.index(species.species) + 1
  86.     dexnum = sprintf("%03d", dexnum)
  87.     textpos = [
  88.     [dexnum, 8, 6, 0, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR],
  89.     ["#{species.real_name.upcase}", 172, 6, 1, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR],
  90.     ]
  91.     pbDrawTextPositions(base,textpos)
  92.     typebitmap    = AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
  93.     type_number = GameData::Type.get(type).icon_position
  94.     type_rect = Rect.new(0, type_number * 28, 64, 28)
  95.     type_x = (monotype) ? 56 : 18
  96.     if type2
  97.       type2_number = GameData::Type.get(type2).icon_position
  98.       type2_rect = Rect.new(0, type2_number * 28, 64, 28)
  99.       type2_x = 94
  100.     end
  101.     base.fill_rect(type_x, 198, 64, 32, CENTER_BG)
  102.     base.fill_rect(type_x - 2, 200, 68, 28, CENTER_BG)
  103.     base.blt(type_x, 200, typebitmap.bitmap, type_rect)
  104.     if type2
  105.       base.fill_rect(type2_x, 198, 64, 32, CENTER_BG)
  106.       base.fill_rect(type2_x - 2, 200, 68, 28, CENTER_BG)
  107.       base.blt(type2_x, 200, typebitmap.bitmap, type2_rect)
  108.     end
  109.     return base
  110.   end
  111.  
  112.   def self.pbFullFakedex(region=-1)
  113.     regionalSpecies = pbAllRegionalSpecies(region)
  114.     if !regionalSpecies || regionalSpecies.length == 0
  115.       # If no Regional Dex specified, use the National Pokédex
  116.       regionalSpecies = []
  117.       GameData::Species.each_species { |s| regionalSpecies.push(s.id) }
  118.     end
  119.     columns = (regionalSpecies.length/ROW_LENGTH)
  120.     columns += 1 if !((regionalSpecies.length%ROW_LENGTH) == 0)
  121.     fullwidth = (PANEL_WIDTH + PANEL_GAP_X) * ROW_LENGTH
  122.     fullheight = (PANEL_HEIGHT + PANEL_GAP_Y) * columns
  123.     fullbase = Bitmap.new(fullwidth,fullheight)
  124.     fullbase.fill_rect(0, 0, fullbase.width, fullbase.height, BACKGROUND)
  125.     for i in 0...regionalSpecies.length
  126.       s = regionalSpecies[i]
  127.       newbitmap = self.pbFakedexPanel(s,regionalSpecies)
  128.       newrect = Rect.new(0,0,newbitmap.width,newbitmap.height)
  129.       newx = (i%ROW_LENGTH)*(PANEL_WIDTH + PANEL_GAP_X)
  130.       newy = (i/ROW_LENGTH)*(PANEL_HEIGHT + PANEL_GAP_Y)
  131.       fullbase.blt(newx, newy, newbitmap, newrect)
  132.     end
  133.     fullbase.to_file("Graphics/Pictures/DexDisplay.png")
  134.   end
  135.  
  136. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement