Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Vocab
- AlchemyCraft = "Создать"
- AlchemyCancel = "Отмена"
- AlchemyNoItem = "Нет предмета"
- AlchemyUnknownCombo = "Комбинация %d: ???"
- Alchemy
- end
- class RPG::Item
- def initialize
- super
- make_combos
- end
- def make_combos
- @combos ||= []
- if self.key?
- notes = self.note.split(/\n/)
- notes.each do |line|
- if line=~/<Alchemy Combo/i
- id = line.match(/<Alchemy Combo Item:[\s]*(\d+)*>/i)[1]
- @combos.push {
- :id => id,
- :known => false
- }
- end
- end
- end
- end
- def key?
- return true if self.itype_id == 2
- false
- end
- def combos
- make_combos if @combos.nil?
- @combos
- end
- def combo_known?(index)
- @knowns
- end
- end
- class Window_Regi < Window_Selectable
- def initialize
- x, y, width, height = 0, 0, 272, 216
- super(x, y, width, height)
- @item = nil
- self.index = -1
- redraw
- @max_combos = 0
- end
- def redraw
- self.contents.clear
- draw_item_icon
- draw_name
- draw_desc
- draw_combos
- end
- def draw_item_icon
- rect = Rect.new(0,0,48,48)
- inner_rect = Rect.new(1,1,46,46)
- contents.fill_rect(rect,Color.new(255,255,255))
- contents.fill_rect(inner_rect,Color.new(255,255,255,0))
- return if @item.nil?
- draw_icon $data_items[ @item ].icon_index, 12, 12
- end
- def draw_name
- rect = Rect.new( 64,0, self.contents.width-32, self.line_height )
- if @item.nil?
- draw_text(rect, Vocab::AlchemyNoItem)
- else
- draw_text(rect, $data_items[ @item ].name)
- end
- end
- def draw_desc
- unless @item.nil?
- draw_text_ex( 0, 48, $data_items[ @item ].description )
- end
- end
- def draw_combos
- unless @item.nil?
- if $data_items[ @item ].key?
- @max_combos = $data_items[ @item ].combos.size
- for index in 0...@max_combos
- combo = $data_items[ @item ].combos[ index ]
- rect = Rect.new(
- 16,
- 96+index*line_height,
- contents.width-16,
- line_height
- )
- rect_rect = Rect.new(
- 0,
- 96+index*line_height+line_height/2-2,
- 4,
- 4
- )
- contents.fill_rect( rect_rect, Color.new(255,255,255) )
- draw_text(rect, $data_items[ combo[ :id ].to_i ].name)
- end
- end
- end
- end
- def item=(id)
- id = nil if id == 0
- @item = id
- redraw
- end
- def update_cursor
- if @index == -1
- cursor_rect.set(0, 0, contents.width, contents.height)
- elsif @index == 0
- cursor_rect.set(0, 0, contents.width, 48)
- else
- if @max_combos > 0
- cursor_rect.set(96+@index*line_height,contents.width,line_height)
- else
- @index = 0
- end
- end
- end
- end
- class Window_Confirm < Window_Command
- def initialize
- x, y, width, height = (Graphics.width-272)/2, Graphics.height - 48, 272, 48
- super(x, y)
- self.width = width
- self.height = height
- self.create_contents
- self.draw_all_items
- self.index = 0
- end
- def col_max
- 2
- end
- def make_command_list
- add_command Vocab::AlchemyCraft, :craft
- add_command Vocab::AlchemyCancel, :cancel
- end
- def alignment
- 1
- end
- end
- class Window_RegiList < Window_Command
- def initialize
- x, y ,width, height = 0,0, 272, 160
- super(x,y)
- self.width = width
- self.height = height
- self.create_contents
- self.draw_all_items
- end
- def make_command_list
- end
- end
- class Scene_Alchemy < Scene_MenuBase
- def start
- super
- create_floating_windows
- create_options
- @index = 0
- end
- def create_floating_windows
- @floating_windows = []
- @abscissa = [ 0, Graphics.width - 272, 0, Graphics.width - 272 ]
- @ordinate = [ 0,0,216,216 ]
- for index in 0...4
- @floating_windows[ index ] = Window_Regi.new
- @floating_windows[ index ].x = @abscissa[ index ]
- @floating_windows[ index ].y = @ordinate[ index ]
- @floating_windows[ index ].set_handler(:ok, method(:on_input_ok))
- end
- @floating_windows[ 0 ].activate
- @floating_windows[ 0 ].item = 52
- end
- def create_options
- @options_window = Window_Confirm.new
- @options_window.deactivate
- end
- def update
- super
- case @index
- when 0,1,2,3
- @floating_windows[ @index ].update
- when 4
- @options_window.update
- end
- end
- def on_input_ok
- if [0,1,2,3].include? @index
- @floating_windows[ @index ].activate
- @floating_windows[ @index ].index = 0
- else
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement