Class: UI::DexWinMap

Inherits:
SpriteStack show all
Defined in:
scripts/01450 Systems/00101 Dex/00002 UI/01400 Dex UIs.rb

Overview

Dex sprite that show the Pokemon location

Constant Summary collapse

MAP_ICON =

Filename of the World Map Icon

'344'

Constants inherited from SpriteStack

SpriteStack::NO_INITIAL_IMAGE

Instance Attribute Summary

Attributes inherited from SpriteStack

#animated, #data, #moving, #stack, #viewport, #x, #y

Instance Method Summary collapse

Methods inherited from SpriteStack

#[], #add_background, #add_line, #add_text, #anime, #anime_delta_set, #dispose, #each, #execute_anime, #move, #move_to, #opacity, #opacity=, #push, #push_sprite, #set_origin, #set_position, #simple_mouse_in?, #size, #stop_animation, #translate_mouse_coords, #update, #update_animation, #update_position, #visible, #visible=, #with_cache, #with_font, #with_surface, #z, #z=

Constructor Details

#initialize(viewport, display_controls = true) ⇒ DexWinMap

Create a new dex win sprite



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'scripts/01450 Systems/00101 Dex/00002 UI/01400 Dex UIs.rb', line 137

def initialize(viewport, display_controls = true)
  # Create the sprite stack at coordinate 0, 0 using the RPG::Cache.pokedex as image source
  super(viewport, 0, 0, default_cache: :pokedex)

  @pkm_icon  = add_sprite(28, 123, NO_INITIAL_IMAGE, type: PokemonIconSprite)
  @item_icon = add_sprite(13, 106, NO_INITIAL_IMAGE)
  @location  = add_text(10, 18, 132, 16, ext_text(9000, 19), 1, color: 10)
  @region    = add_text(150, 0, 150, 24, 'REGION', 2, color: 10)
  if display_controls
    add_sprite(40, 221, NO_INITIAL_IMAGE, :Y, type: KeyShortcut)
    add_text(60, 221, 140, 16, ext_text(9000, 32), color: 10) # Next worldmap
    add_sprite(190, 221, NO_INITIAL_IMAGE, :X, type: KeyShortcut)
    add_text(210, 221, 140, 16, ext_text(9000, 33), color: 10) # Zoom
  end

  # Set region text in bold
  @region.bold = true
end

Instance Method Details

#data=(pokemon)

Change the data and the state

Parameters:

  • pokemon (PFM::Pokemon, :map)

    if set to map, we'll be showing the map icon



158
159
160
161
162
163
164
165
166
167
168
# File 'scripts/01450 Systems/00101 Dex/00002 UI/01400 Dex UIs.rb', line 158

def data=(pokemon)
  if pokemon == :map
    @pkm_icon.visible = false
    @item_icon.visible = true
    @item_icon.set_bitmap(MAP_ICON, :icon)
  elsif pokemon.is_a? PFM::Pokemon
    @pkm_icon.visible = true
    @item_icon.visible = false
    super(pokemon)
  end
end

#set_location(place, color = 10)

Set the location name

Parameters:

  • place (String)

    the name to display

  • color (Integer) (defaults to: 10)

    the color code



173
174
175
176
# File 'scripts/01450 Systems/00101 Dex/00002 UI/01400 Dex UIs.rb', line 173

def set_location(place, color = 10)
  @location.multiline_text = place
  @location.load_color color
end

#set_region(place, color = 10)

Set the region name

Parameters:

  • place (String)

    the name to display

  • color (Integer) (defaults to: 10)

    the color code



181
182
183
184
# File 'scripts/01450 Systems/00101 Dex/00002 UI/01400 Dex UIs.rb', line 181

def set_region(place, color = 10)
  @region.multiline_text = place.upcase
  @location.load_color color
end