Дополнение для Полоса Энергии
Автор: Я (Денис Кузнецов)
Версия: 1.0 от 13.04.15
Тип: Добавляющий возможности

Зависимости:
Глобальные Настройки: минимальная версия 1.2
Полоса энергии: минимальная версия 1.43

Данное дополнение позволяет настроить скрипт Полоса Энергии

Спойлер Код:
Код:
=begin
###############################################################################
#                                                                             #
#          						Аддон к Восстанавливающаяся полоса                      #
#                                                                             #
###############################################################################	
	
Автор: Денис Кузнецов (http://vk.com/id8137201)
=end

$Extended_Settings_Command_List.push({ :command_name => "Энергия", :command_symbol => :den_kyz_energy_bar_settings_command_symbol, 
		:method => :den_kyz_energy_bar_settings_method, :enabled => true, :author => "Денис Кузнецов", :version => 1.0, :date => "13.04.15", 
		:description => "Настройка скрипта\n"Восстанавливающаяся полоса"" })

class Extended_Settings_Scene < Scene_Base
	
	def den_kyz_energy_bar_settings_method
		SceneManager.call(Energy_Bar_Settings_Scene) if $imported["DenKyz_EnergyBar"]
	end
	
end # class Extended_Settings_Scene < Scene_Base

class Energy_Bar_Settings_Scene < Scene_Base
	
	def start
		super
		create_command_window
		create_info_window
		create_process_window
	end
	
	def create_energy_bar_window
		
		$ENERGY_BAR_ARRAY.push({ :text => "Тест", :max => 250, :now => 175, :use_speed => 0, :restore_speed => 0,
				:color => rand(33), :inverse => false, :event => [], 
				:event_ok => false, :button => -1, :auto => false })
		
		@create_energy_bar_window = Energy_Bar_Window.new
		@create_energy_bar_window.z = 200
	end
	
	def create_command_window
		@create_command_window = Energy_Bar_Settings_Command_Window.new
		@create_command_window.set_handler(:cancel, method(:return_scene))
		@create_command_window.set_handler(:activate_process_window, method(:activate_process_window))
	end
	
	def create_info_window
		@create_info_window = Energy_Bar_Settings_Info_Window.new(@create_command_window)
		@create_additional_info_window = Energy_Bar_Settings_Additional_Info_Window.new
	end
	
	def create_process_window
		@create_process_window = Energy_Bar_Settings_Process_Window.new(@create_command_window)
		@create_process_window.set_handler(:cancel, method(:deactivate_process_window))
		@create_process_window.set_handler(:window_settings_ok, method(:deactivate_process_window))
		@create_process_window.deactivate
		@create_process_window.cursor_rect.empty
	end
	
	def activate_process_window
		return @create_command_window.activate if $ENERGY_BAR_ARRAY.empty? && @create_command_window.index == 1
		@create_command_window.deactivate
		@create_process_window.refresh
		@create_process_window.activate
		
		###
		if @create_command_window.index == 0
			create_energy_bar_window if @create_energy_bar_window == nil
		end
		###
		
	end
	
	def deactivate_process_window
		@create_command_window.activate
		@create_process_window.select(0)
		@create_process_window.deactivate
		@create_process_window.refresh
		@create_process_window.cursor_rect.empty
		
		###
		if @create_command_window.index == 0 && !@create_energy_bar_window.nil?
			if $ENERGY_BAR_ARRAY.size > 1
				$ENERGY_BAR_ARRAY[-1] = nil
			else
				$ENERGY_BAR_ARRAY[0] = nil
			end
			$ENERGY_BAR_ARRAY.compact!
			@create_energy_bar_window.dispose
			@create_energy_bar_window = nil
		end
		###
		
	end
	
	def update
		super
		if @last_command_window_index != @create_command_window.index
			@last_command_window_index = @create_command_window.index
			@create_process_window.refresh
			@create_process_window.cursor_rect.empty
		end
	end
	
end # class Energy_Bar_Settings_Scene < Scene_Base

class Energy_Bar_Settings_Command_Window < Window_HorzCommand
	
	def initialize
		super(0, 48)
	end
	
	def col_max
		3
	end
	
	def window_width
		Graphics.width
	end
	
	def make_command_list
		add_command("Настройка окна", :activate_process_window)
		add_command("Настройка полос", :activate_process_window)
		add_command("Другие настройки", :activate_process_window)
	end
	
	def cursor_down(wrap = false)
		process_ok
	end
	
end # class Energy_Bar_Settings_Command_Window < Window_HorzCommand

class Energy_Bar_Settings_Info_Window < Window_Base
	
	def initialize(command_window)
		@command_window = command_window
		super(0, 0, Graphics.width, 48)
	end
	
	def update
		super
		contents.clear
		case @command_window.index
		when 0
			draw_text(0, 0, contents_width, contents_height, "Настройте положение окна на экране", 1)
		when 1
			draw_text(0, 0, contents_width, contents_height, "Управляйте своими полосами", 1)
		when 2
			draw_text(0, 0, contents_width, contents_height, "Настройте остальные параметры", 1)
		end
	end
	
end # class Energy_Bar_Settings_Info_Window < Window_Base

class Energy_Bar_Settings_Additional_Info_Window < Window_Base
	
	def initialize
		super(0, Graphics.height - 48, Graphics.width, 48)
		self.arrows_visible = false
		@text_index = 0
		@text_info = ["Изменяйте параметры стрелками влево/вправо", "Используйте след./пред. стр. для изменения параметров", "Спасибо, что используете мой скрипт"]
		draw_text(0, 0, contents_width, contents_height, @text_info[@text_index], 1)
	end
	
	def draw_info_text
		contents.clear
			draw_text(0, 0, contents_width, contents_height, @text_info[@text_index], 1)
	end
	
	def update
		if Graphics.frame_count % 10 == 0
			self.oy += 1
		end
		if self.oy == 24
			@text_index += 1
			@text_index %= @text_info.size
			draw_info_text
			self.oy = -24
		end
	end
	
end # class Energy_Bar_Settings_Additional_Info_Window < Window_Base

class Energy_Bar_Settings_Process_Window < Window_Command
	
	def initialize(command_window)
		@command_window = command_window
		@energy_bar_index = 0
		super(0, 48 * 2)
	end
	
	def alignment
		1
	end
	
	def window_width
		Graphics.width
	end
	
	def window_height
		Graphics.height - 48 * 3
	end
	
	def item_rect(index)
		rect = Rect.new
		
		rect.height = item_height
		rect.width = contents_width / 2
		rect.x = rect.width + index % col_max * (item_width + spacing)
		rect.y = index / col_max * item_height
		
		if @command_window.index == 1
			if index == 0
				rect.width = item_width
				rect.x = index % col_max * (item_width + spacing)
				rect.y = item_height + index / col_max * item_height
			else
				rect.width = contents_width / 2
				rect.x = rect.width + index % col_max * (item_width + spacing)
				rect.y = item_height + index / col_max * item_height
			end
		end
		
		rect
	end
	
	def draw_energy_bar_color(index)
		rect = item_rect(index)
		rect.x += 2
		rect.y += 2
		rect.width -= 4
		rect.height -= 4
		contents.fill_rect(rect, text_color($ENERGY_BAR_ARRAY[@energy_bar_index][:color]))
	end
	
	def draw_item(index)
		return draw_energy_bar_color(index) if index == 5
		change_color(normal_color, command_enabled?(index))
		draw_text(item_rect_for_text(index), command_name(index), alignment)
	end
	
	def make_command_list
		case @command_window.index
		when 0
			add_command($ENERGY_BAR_WINDOW_X.to_s, :window_settings_ok)
			add_command($ENERGY_BAR_WINDOW_Y.to_s, :window_settings_ok)
			add_command($ENERGY_BAR_WINDOW_WIDTH.to_s, :window_settings_ok)
		when 1
			if $ENERGY_BAR_ARRAY.size > @energy_bar_index
				add_command($ENERGY_BAR_ARRAY[@energy_bar_index][:text], :window_settings_ok)
				add_command($ENERGY_BAR_ARRAY[@energy_bar_index][:now].to_s, :window_settings_ok)
				add_command($ENERGY_BAR_ARRAY[@energy_bar_index][:max].to_s, :window_settings_ok)
				add_command($ENERGY_BAR_ARRAY[@energy_bar_index][:use_speed].to_s, :window_settings_ok)
				add_command($ENERGY_BAR_ARRAY[@energy_bar_index][:restore_speed].to_s, :window_settings_ok)
				add_command($ENERGY_BAR_ARRAY[@energy_bar_index][:color].to_i.to_s, :sym)
				add_command($ENERGY_BAR_ARRAY[@energy_bar_index][:inverse] ? "Да" : "Нет", :window_settings_ok)
				for i in 0..Energy_Bar_Settings::ENERGY_BAR_EVENTS.size - 1
					break if $ENERGY_BAR_ARRAY[@energy_bar_index][:event] == Energy_Bar_Settings::ENERGY_BAR_EVENTS[i]
				end
				add_command(i.to_s, :window_settings_ok)
				add_command($ENERGY_BAR_ARRAY[@energy_bar_index][:auto] ? "Использовать" : "Восстанавливать", :window_settings_ok) if !$ENERGY_BAR_ARRAY[@energy_bar_index][:button].is_a?(Symbol)
			end
		when 2
			add_command($ENERGY_BAR_MESSAGE_STOP ? "Да" : "Нет", :window_settings_ok)
			add_command($ENERGY_BAR_SPEED.to_s, :window_settings_ok)
			add_command($USE_ENERGY_BAR_WINDOW_PERCENT ? "Да" : "Нет", :window_settings_ok)
			add_command($USE_MINIMAL_ENERGY_BAR_STYLE ? "Да" : "Нет", :window_settings_ok)
		end
	end
	
	def refresh
		super
		case @command_window.index
		when 0
			
			mas = ["X:", "Y:", "Ширина:"]
			for i in 0..mas.size - 1
				draw_text(0, item_height * i, contents_width / 2, item_height,  mas[i], 1)
			end
			
		when 1
			if $ENERGY_BAR_ARRAY.empty?
				draw_text(0, 0, contents_width, contents_height, "У Вас нет еще полос", 1)
			else
				draw_text(0, 0, contents_width, item_height, "Выберите полосу (" + (@energy_bar_index + 1).to_s + "/" + ($ENERGY_BAR_ARRAY.size).to_s + ")", 1)
				
				mas = ["Текущее значение:", "Максимальное значение:", "Использование:", "Восстановление:", "Цвет:", "Инвертирование:", "Событие:", "Статус:"]
				for i in 0..mas.size - 1
					break if i == mas.size - 1 && $ENERGY_BAR_ARRAY[@energy_bar_index][:button].is_a?(Symbol)
					draw_text(0, item_height * (i + 2), contents_width / 2, item_height,  mas[i], 1)
				end
				
			end
		when 2
			
			mas = ["Пауза при сообщениях:", "Скорость полосы:", "Показывать проценты:", "Минимальный стиль:"]
			for i in 0..mas.size - 1
				draw_text(0, item_height * i, contents_width / 2, item_height,  mas[i], 1)
			end
			
		end
	end
	
	def cursor_right(wrap = false)
		case @command_window.index
		when 0
			case index
			when 0
				$ENERGY_BAR_WINDOW_X += 1
			when 1
				$ENERGY_BAR_WINDOW_Y += 1
			when 2
				$ENERGY_BAR_WINDOW_WIDTH += 1
			end
		when 1
			case index
			when 0
				@energy_bar_index += 1 
				@energy_bar_index = @energy_bar_index % $ENERGY_BAR_ARRAY.size
			when 1
				$ENERGY_BAR_ARRAY[@energy_bar_index][:now] += 0.125
				$ENERGY_BAR_ARRAY[@energy_bar_index][:now] = $ENERGY_BAR_ARRAY[@energy_bar_index][:max] if $ENERGY_BAR_ARRAY[@energy_bar_index][:now] >= $ENERGY_BAR_ARRAY[@energy_bar_index][:max]
			when 2
				$ENERGY_BAR_ARRAY[@energy_bar_index][:max] += 0.125
			when 3
				$ENERGY_BAR_ARRAY[@energy_bar_index][:use_speed] += 0.125
				$ENERGY_BAR_ARRAY[@energy_bar_index][:use_speed] = $ENERGY_BAR_ARRAY[@energy_bar_index][:max] if $ENERGY_BAR_ARRAY[@energy_bar_index][:use_speed] >= $ENERGY_BAR_ARRAY[@energy_bar_index][:max]
			when 4
				$ENERGY_BAR_ARRAY[@energy_bar_index][:restore_speed] += 0.125
				$ENERGY_BAR_ARRAY[@energy_bar_index][:restore_speed] = $ENERGY_BAR_ARRAY[@energy_bar_index][:max] if $ENERGY_BAR_ARRAY[@energy_bar_index][:restore_speed] >= $ENERGY_BAR_ARRAY[@energy_bar_index][:max]
			when 5
				$ENERGY_BAR_ARRAY[@energy_bar_index][:color] += 1
				$ENERGY_BAR_ARRAY[@energy_bar_index][:color] = $ENERGY_BAR_ARRAY[@energy_bar_index][:color] % 32 # 32 цвета всего
			when 6
				$ENERGY_BAR_ARRAY[@energy_bar_index][:inverse] = !$ENERGY_BAR_ARRAY[@energy_bar_index][:inverse]
			when 7
				for i in 0..Energy_Bar_Settings::ENERGY_BAR_EVENTS.size - 1
					break if $ENERGY_BAR_ARRAY[@energy_bar_index][:event] == Energy_Bar_Settings::ENERGY_BAR_EVENTS[i]
				end
				$ENERGY_BAR_ARRAY[@energy_bar_index][:event] = Energy_Bar_Settings::ENERGY_BAR_EVENTS[(i + 1) % (Energy_Bar_Settings::ENERGY_BAR_EVENTS.size)]
			when 8
				$ENERGY_BAR_ARRAY[@energy_bar_index][:auto] = !$ENERGY_BAR_ARRAY[@energy_bar_index][:auto]	
			end
		when 2
			case index
			when 0
				$ENERGY_BAR_MESSAGE_STOP = !$ENERGY_BAR_MESSAGE_STOP
			when 1
				$ENERGY_BAR_SPEED += 1
				$ENERGY_BAR_SPEED = [2, $ENERGY_BAR_SPEED % 31].max
			when 2
				$USE_ENERGY_BAR_WINDOW_PERCENT = !$USE_ENERGY_BAR_WINDOW_PERCENT
			when 3
				$USE_MINIMAL_ENERGY_BAR_STYLE = !$USE_MINIMAL_ENERGY_BAR_STYLE
			end
		end
		refresh
	end
	
	def cursor_left(wrap = false)
		case @command_window.index
		when 0
			case index
			when 0
				$ENERGY_BAR_WINDOW_X -= 1
				$ENERGY_BAR_WINDOW_X = 0 if $ENERGY_BAR_WINDOW_X < 0
			when 1
				$ENERGY_BAR_WINDOW_Y -= 1
				$ENERGY_BAR_WINDOW_Y = 0 if $ENERGY_BAR_WINDOW_Y < 0
			when 2
				$ENERGY_BAR_WINDOW_WIDTH -= 1
				$ENERGY_BAR_WINDOW_WIDTH = 0 if $ENERGY_BAR_WINDOW_WIDTH < 0
			end
		when 1
			case index
			when 0
				@energy_bar_index -= 1 
				@energy_bar_index = @energy_bar_index % $ENERGY_BAR_ARRAY.size
			when 1
				$ENERGY_BAR_ARRAY[@energy_bar_index][:now] -= 0.125
				$ENERGY_BAR_ARRAY[@energy_bar_index][:now] = 0 if $ENERGY_BAR_ARRAY[@energy_bar_index][:now] <= 0
			when 2
				$ENERGY_BAR_ARRAY[@energy_bar_index][:max] -= 0.125
				$ENERGY_BAR_ARRAY[@energy_bar_index][:max] = 1 if $ENERGY_BAR_ARRAY[@energy_bar_index][:max] <= 1
				$ENERGY_BAR_ARRAY[@energy_bar_index][:now] = $ENERGY_BAR_ARRAY[@energy_bar_index][:max] if $ENERGY_BAR_ARRAY[@energy_bar_index][:now] >= $ENERGY_BAR_ARRAY[@energy_bar_index][:max]
			when 3
				$ENERGY_BAR_ARRAY[@energy_bar_index][:use_speed] -= 0.125
				$ENERGY_BAR_ARRAY[@energy_bar_index][:use_speed] = 0 if $ENERGY_BAR_ARRAY[@energy_bar_index][:use_speed] <= 0
			when 4
				$ENERGY_BAR_ARRAY[@energy_bar_index][:restore_speed] -= 0.125
				$ENERGY_BAR_ARRAY[@energy_bar_index][:restore_speed] = 0 if $ENERGY_BAR_ARRAY[@energy_bar_index][:restore_speed] <= 0
			when 5
				$ENERGY_BAR_ARRAY[@energy_bar_index][:color] -= 1
				$ENERGY_BAR_ARRAY[@energy_bar_index][:color] = $ENERGY_BAR_ARRAY[@energy_bar_index][:color] % 32 # 32 цвета всего
			when 6
				$ENERGY_BAR_ARRAY[@energy_bar_index][:inverse] = !$ENERGY_BAR_ARRAY[@energy_bar_index][:inverse]
			when 7
				for i in 0..Energy_Bar_Settings::ENERGY_BAR_EVENTS.size - 1
					break if $ENERGY_BAR_ARRAY[@energy_bar_index][:event] == Energy_Bar_Settings::ENERGY_BAR_EVENTS[i]
				end
				$ENERGY_BAR_ARRAY[@energy_bar_index][:event] = Energy_Bar_Settings::ENERGY_BAR_EVENTS[(i - 1) % (Energy_Bar_Settings::ENERGY_BAR_EVENTS.size)]
			when 8
				$ENERGY_BAR_ARRAY[@energy_bar_index][:auto] = !$ENERGY_BAR_ARRAY[@energy_bar_index][:auto]
			end
		when 2
			case index
			when 0
				$ENERGY_BAR_MESSAGE_STOP = !$ENERGY_BAR_MESSAGE_STOP
			when 1
				$ENERGY_BAR_SPEED -= 1
				$ENERGY_BAR_SPEED = 30 if $ENERGY_BAR_SPEED < 2
			when 2
				$USE_ENERGY_BAR_WINDOW_PERCENT = !$USE_ENERGY_BAR_WINDOW_PERCENT
			when 3
				$USE_MINIMAL_ENERGY_BAR_STYLE = !$USE_MINIMAL_ENERGY_BAR_STYLE
			end
		end
		refresh
	end
	
	def cursor_pagedown
		10.times do cursor_right end
	end
	
	def cursor_pageup
		10.times do cursor_left end
	end
	
end # class Energy_Bar_Settings_Process_Window < Window_Command