Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Window_Panel
- #------------------------------------------------------------------------------
- # Esta classe lida com o painel de administração.
- #------------------------------------------------------------------------------
- # Autor: Valentine
- #==============================================================================
- class Window_Panel < Window_Base
- def initialize
- super(adjust_x, adjust_y, 385, 302)
- self.visible = false
- self.closable = true
- self.windowskin = Cache.system('Window2')
- self.title = Vocab::AdmPanel
- #load_maps
- load_items
- create_buttons
- @item_type = 0
- @x = @y = 0
- end
- def adjust_x
- Graphics.width / 2 - 192
- end
- def adjust_y
- Graphics.height / 2 - 176
- end
- =begin
- def load_maps
- @map_ids = []
- @map_names = []
- $data_mapinfos.each do |map_id, map|
- @map_ids << map_id
- @map_names << map.name
- end
- end
- =end
- def load_items
- @items = []
- @items << $data_items.drop(1).map { |item| item.name }
- @items << $data_weapons.drop(1).map { |weapon| weapon.name }
- @items << $data_armors.drop(1).map { |armor| armor.name }
- end
- def create_buttons
- @name_box = Text_Box.new(self, 53, 16, 163, Configs::MAX_CHARACTERS, false, Vocab::SecondaryPanelText)
- @kick_button = Button.new(self, 15, 40, Vocab::Kick, 99) { kick_player }
- @mute_button = Button.new(self, 118, 40, Vocab::Mute, 98) { mute_player }
- @pull_button = Button.new(self, 15, 66, Vocab::Pull, 99) { pull_player }
- @go_button = Button.new(self, 118, 66, Vocab::GoTo, 98) { go_to_player }
- @motd_box = Text_Box.new(self, 15, 110, 145, 120)
- @change_button = Button.new(self, 165, 109, Vocab::Change) { change_motd }
- @days_box = Number_Box.new(self, 53, 152, 61, 5)
- @unban_button = Button.new(self, 118, 151, Vocab::Unban, 98) { unban }
- @ban_account = Button.new(self, 15, 177, Vocab::BanAcc, 98) { ban_account }
- @ban_ip = Button.new(self, 118, 177, Vocab::BanIP, 98) { ban_ip }
- @switch_box = Number_Box.new(self, 39, 222, 45, 4)
- @switch_on = Button.new(self, 89, 221, Vocab::On, 51) { switch_on }
- @switch_off = Button.new(self, 144, 221, Vocab::Off, 72) { switch_off }
- @map_box = Number_Box.new(self, 272, 16, 98, 5)
- #@map_box.text = $game_map.map_id.to_s
- #@map_box = Combo_Box.new(self, 234, 16, 136, @map_names) { refresh }
- @teleport_button = Button.new(self, 234, 150, Vocab::Teleport, 136) { teleport }
- @prev_button = Image_Button.new(self, 271, 194, 'Left') { prev_item_type }
- @next_button = Image_Button.new(self, 347, 194, 'Right') { next_item_type }
- @amount_box = Number_Box.new(self, 314, 244, 56, 5)
- @item_box = Number_Box.new(self, 258, 220, 112, 5)
- #@item_box = Combo_Box.new(self, 234, 220, 136, @items[0])
- @item_button = Button.new(self, 234, 268, Vocab::GiveItem, 136) { give_item }
- @message_box = Text_Box.new(self, 15, 268, 138, 120)
- @send_button = Button.new(self, 158, 267, Vocab::Send, 57) { admin_message }
- disable_buttons
- end
- def disable_buttons
- return if $game_player.admin?
- @kick_button.enable = false
- @change_button.enable = false
- @ban_account.enable = false
- @ban_ip.enable = false
- @unban_button.enable = false
- @switch_on.enable = false
- @switch_off.enable = false
- #@map_box.enable = false
- @teleport_button.enable = false
- @prev_button.enable = false
- @next_button.enable = false
- #@item_box.enable = false
- @item_button.enable = false
- @send_button.enable = false
- end
- def show
- @name_box.clear
- @motd_box.clear
- @days_box.clear
- @switch_box.clear
- @map_box.clear
- @amount_box.clear
- @item_box.clear
- @message_box.clear
- #@map_box.index = $game_map.map_id - 1
- @map_box.text = $game_map.map_id.to_s
- super
- end
- def refresh
- contents.clear
- change_color(system_color)
- draw_text(3, 77, 205, line_height, Vocab::Motd, 1)
- draw_text(3, 119, 205, line_height, Vocab::Banishment, 1)
- draw_text(3, 189, 205, line_height, Vocab::GlobalSwitch, 1)
- draw_text(222, 161, 136, line_height, "#{Vocab::Item}:", 1)
- draw_text(3, 234, 205, line_height, Vocab::AlertMessage, 1)
- change_color(normal_color)
- draw_text(3, 4, 45, line_height, "#{Vocab::Name}:")
- draw_text(3, 139, 200, line_height, "#{Vocab::Days}:")
- draw_text(3, 207, 200, line_height, Vocab::ID)
- draw_text(222, 4, 200, line_height, "#{Vocab::Map}:")
- draw_text(222, 181, 136, line_height, Vocab::ItemType)
- draw_text(222, 207, 136, line_height, Vocab::ID)
- draw_text(222, 231, 136, line_height, "#{Vocab::Amount}:")
- case @item_type
- when 0
- item_type = Vocab::Item
- when 1
- item_type = Vocab.weapon
- when 2
- item_type = Vocab.armor
- when 3
- item_type = Vocab.currency_unit
- end
- draw_text(276, 181, 60, line_height, item_type, 1)
- draw_map
- draw_player_point
- end
- def draw_map
- return unless FileTest.exist?("Graphics/Minimaps/#{@map_box.text}.png")
- bitmap = Cache.minimap(@map_box.text)
- contents.blt(222, 25, bitmap, bitmap.rect)
- end
- def draw_player_point
- rect = Rect.new(142, 0, 16, 16)
- x = [[222 + @x, 222].max, 342].min
- y = [[25 + @y, 25].max, 118].min
- bitmap = Cache.system('Minimap')
- contents.blt(x, y, bitmap, rect)
- end
- def kick_player
- return if @name_box.text.strip.empty?
- $network.send_admin_command(Constants::COMMAND_KICK, @name_box.text)
- end
- def mute_player
- return if @name_box.text.strip.empty?
- $network.send_admin_command(Constants::COMMAND_MUTE, @name_box.text)
- end
- def pull_player
- return if @name_box.text.strip.empty?
- $network.send_admin_command(Constants::COMMAND_PULL, @name_box.text)
- end
- def go_to_player
- return if @name_box.text.strip.empty?
- $network.send_admin_command(Constants::COMMAND_GO, @name_box.text)
- end
- def change_motd
- return if @motd_box.text.strip.empty?
- $network.send_admin_command(Constants::COMMAND_MOTD, @motd_box.text)
- end
- def ban_account
- return if @name_box.text.strip.empty?
- return if @days_box.value == 0
- $network.send_admin_command(Constants::COMMAND_BAN_ACC, @name_box.text, @days_box.value)
- end
- def ban_ip
- return if @name_box.text.strip.empty?
- return if @days_box.value == 0
- $network.send_admin_command(Constants::COMMAND_BAN_IP, @name_box.text, @days_box.value)
- end
- def unban
- return if @name_box.text.strip.empty?
- $network.send_admin_command(Constants::COMMAND_UNBAN, @name_box.text)
- end
- def switch_on
- return if @switch_box.value == 0
- $network.send_admin_command(Constants::COMMAND_SWITCH, @switch_box.text, 1)
- end
- def switch_off
- return if @switch_box.value == 0
- $network.send_admin_command(Constants::COMMAND_SWITCH, @switch_box.text, 0)
- end
- def teleport
- return if @name_box.text.strip.empty?
- x = @x * $game_map.width / 136
- y = @y * $game_map.height / 109
- $network.send_admin_command(Constants::COMMAND_TELEPORT, @name_box.text, @map_box.text.to_i, x, y)
- end
- def prev_item_type
- return if @item_type == 0
- @item_type -= 1
- refresh_item_list
- end
- def next_item_type
- return if @item_type == 3
- @item_type += 1
- refresh_item_list
- end
- def refresh_item_list
- if @item_type < 3
- @item_box.enable = true
- #@item_box.list = @items[@item_type]
- #@item_box.index = 0
- else
- @item_box.enable = false
- end
- refresh
- end
- def give_item
- return if @name_box.text.strip.empty?
- return if @amount_box.value == 0
- $network.send_admin_command(Constants::COMMAND_ITEM + @item_type, @name_box.text, @item_box.text.to_i + 1, @amount_box.value)
- end
- def admin_message
- return if @message_box.text.strip.empty?
- $network.send_admin_command(Constants::COMMAND_MSG, @message_box.text)
- @message_box.clear
- end
- def update
- super
- if Mouse.click?(:L) && in_area?(234, 37, 136, 109)
- @x = Mouse.x - x - 234
- @y = Mouse.y - y - 37
- refresh
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement