Advertisement
nio_kasgami

mod for map display (from Tankentai ultima Demo)

Feb 27th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.45 KB | None | 0 0
  1. #==============================================================================
  2. # ■ Window_MapName
  3. #------------------------------------------------------------------------------
  4. #  マップ名を表示するウィンドウです。
  5. #==============================================================================
  6.  
  7.  
  8.  module Ul01
  9.    Window_width = 250
  10.    Back_color1 = Color.new(100, 200, 100, 192)
  11.    Back_color2 = Color.new(200, 200, 200, 0)
  12.    Map_Name_Position = [100,10]
  13.    Map_Name_Font = [ "AR ESSENCE" ]
  14.    Map_Name_Font_Bold = false
  15.    Map_Name_Font_Italic = true
  16.    
  17.  end
  18.  
  19. class Window_MapName < Window_Base
  20.  
  21.   attr_accessor :back_color1
  22.   attr_accessor :back_color2
  23.  
  24.   #--------------------------------------------------------------------------
  25.   # ● オブジェクト初期化
  26.   #--------------------------------------------------------------------------
  27.   def initialize
  28.     super( window_x,window_y,window_width, fitting_height(1))
  29.     self.opacity = 0
  30.     self.contents_opacity = 0
  31.     setting
  32.     @show_count = 0
  33.     refresh
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # ● ウィンドウ幅の取得
  37.   #--------------------------------------------------------------------------
  38.   def setting
  39.     self.contents.font.name = Ul01::Map_Name_Font
  40.     self.contents.font.size = 30
  41.     self.contents.font.bold = Ul01::Map_Name_Font_Bold
  42.     self.contents.font.italic = Ul01::Map_Name_Font_Italic
  43.   end
  44.  
  45.   def window_width
  46.     return Ul01::Window_width
  47.   end
  48.  
  49.   def window_x
  50.     return Ul01::Map_Name_Position[0]
  51.   end
  52.  
  53.   def window_y
  54.     return Ul01::Map_Name_Position[1]
  55.   end
  56.  
  57.   #--------------------------------------------------------------------------
  58.   # ● フレーム更新
  59.   #--------------------------------------------------------------------------
  60.   def update
  61.     super
  62.     if @show_count > 0 && $game_map.name_display
  63.       update_fadein
  64.       @show_count -= 1
  65.     else
  66.       update_fadeout
  67.     end
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # ● フェードインの更新
  71.   #--------------------------------------------------------------------------
  72.   def update_fadein
  73.     self.contents_opacity += 16
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ● フェードアウトの更新
  77.   #--------------------------------------------------------------------------
  78.   def update_fadeout
  79.     self.contents_opacity -= 16
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # ● ウィンドウを開く
  83.   #--------------------------------------------------------------------------
  84.   def open
  85.     refresh
  86.     @show_count = 150
  87.     self.contents_opacity = 0
  88.     self
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # ● ウィンドウを閉じる
  92.   #--------------------------------------------------------------------------
  93.   def close
  94.     @show_count = 0
  95.     self
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ● リフレッシュ
  99.   #--------------------------------------------------------------------------
  100.   def refresh
  101.     contents.clear
  102.     unless $game_map.display_name.empty?
  103.       @map = "#{$data_mapinfos[$game_map.map_id].name}"
  104.       #@map2 = "#{$game_map.display_name}"
  105.       draw_background(contents.rect)
  106.       draw_text(contents.rect,@map, 0)
  107.       #draw_text(contents.rect,@map2, 2)
  108.     end
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # ● 背景の描画
  112.   #--------------------------------------------------------------------------
  113.   def draw_background(rect)
  114.     temp_rect = rect.clone
  115.     temp_rect.width /= 2
  116.     contents.gradient_fill_rect(temp_rect, back_color2, back_color1)
  117.     temp_rect.x = temp_rect.width
  118.     contents.gradient_fill_rect(temp_rect, back_color1, back_color2)
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● 背景色 1 の取得
  122.   #--------------------------------------------------------------------------
  123.   def back_color1
  124.     return Ul01::Back_color1
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ● 背景色 2 の取得
  128.   #--------------------------------------------------------------------------
  129.   def back_color2
  130.     return Ul01::Back_color2
  131.   end
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement