| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2016-7-23 |
| 在线时间 | 66 小时 |
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 66 小时
- 注册时间
- 2014-4-15
- 回帖
- 16
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
- #==============================================================================
- # Window Chat
- #==============================================================================
- class Window_Chat < Window_Base
-
- def initialize
- super(285, (Graphics.height-(WLH*4+32)-WLH), 250, (WLH*4+32))
- @scroll_bar = ScrollBar.new(self)
- $windows << self
- @size = 0
- create_buttons
- end
-
- def create_buttons
- @guild_button = Button.new(self, 2, -WLH+4, "公会") { talk(0); @textbox.text = ""; @textbox.text += "@"; @textbox.active = true ;$聊天[$聊天宽度,0]="@";$聊天宽度 += 1;}
- @guild_button.tip_text = ["公会聊天(绿色)"]
- @friends_button = Button.new(self, @guild_button.x+@guild_button.width+2, -WLH+4, "好友") { talk(1); @textbox.text = ""; @textbox.text += "#"; @textbox.active = true ;$聊天[$聊天宽度,0]="#";$聊天宽度 += 1;}
- @friends_button.tip_text = ["好友聊天(蓝色)"]
- @whisper_button = Button.new(self, @friends_button.x+@friends_button.width+2, -WLH+4, "私聊") { talk(2); @textbox.text = ""; @textbox.text += "/#{$game_temp.last_whisper} "; @textbox.active = true;$聊天[$聊天宽度,0]="/";$聊天宽度 += 1; }
- @whisper_button.tip_text = ["私聊聊天(蓝色)"]
- @all_button = Button.new(self, @whisper_button.x+@whisper_button.width+2, -WLH+4, "世界") { talk(3); @textbox.text = ""; @textbox.text += "!"; @textbox.active = true ;$聊天[$聊天宽度,0]="!";$聊天宽度 += 1;}
- @all_button.tip_text = ["世界聊天(粉红色)"]
- @normal_button = Button.new(self, @all_button.x+@all_button.width+2, -WLH+4, "正常") { talk(4); @textbox.text = ""; @textbox.active = true}
- @normal_button.tip_text = ["正常聊天"]
- @textbox = TextBox.new(self, 2, self.height, self.width-55, 25) { write }
- Button.new(self, @textbox.width+4, self.height, "发送") { write }
- end
-
- def update
- super
- #--------------------------------------------------------------------------
- $Ltf.active = self.active
- @textbox.text = $聊天
- # 输入窗口刷新
- $Ltf.update
- #--------------------------------------------------------------------------
-
- refresh if @size != $game_temp.chat_text.size
- end
-
- def refresh
- @textbox.active = self.active
- self.contents.clear
- scroll_down
- y = 0
- for text in $game_temp.chat_text
- if text[0] =~ /<Admin>/
- self.contents.font.color = Color.admin
- elsif text[0] =~ /<GM>/
- self.contents.font.color = Color.gm
- elsif text[0] =~ /@(.*)/
- next if @friend_talk or @whisper_talk or @all_talk
- next unless $1.to_i == $actor.guild
- self.contents.font.color = Color.guild
- elsif text[0] =~ /#(.*)/
- next if @guild_talk or @whisper_talk or @all_talk
- next unless Network.friends.include?($1) or $actor.name == $1
- self.contents.font.color = Color.friend
- elsif text[0] =~ /\/(.*) (.*)/
- next if @guild_talk or @friend_talk or @all_talk
- next unless $1 == $actor.name or $2 == $actor.name
- $game_temp.last_whisper = $1
- self.contents.font.color = Color.whisper
- elsif text[0] =~ /!/
- next if @guild_talk or @friend_talk or @whisper_talk
- self.contents.font.color = Color.all
- else
- self.contents.font.color = normal_color
- end
- self.contents.draw_text(0, y, contents.width, WLH, text[1])
- y += WLH
- end
- @size = $game_temp.chat_text.size
- end
-
- def talk(x)
- @guild_talk = (x == 0)
- @friend_talk = (x == 1)
- @whisper_talk = (x == 2)
- @all_talk = (x == 3)
- refresh
- end
-
- def write
- return if @textbox.text.to_s.nil? or @textbox.text.to_s == ""
- for i in Network.chat_filter
- loop do
- @textbox.text.gsub!(/#{i}/i, "")
- break if @textbox.text.casecmp(i) != 0
- end
- end
- mesage_commands
- message_balloon
- return if @textbox.text.nil? or @textbox.text == ""
- text = @textbox.text.delete(@textbox.text[0,1]).to_s
- if @textbox.text[0,1] == "@" and $actor.guild > 0
- Network.send_chat("@#{$actor.guild}", "#{$actor.name}: #{text}", 1)
- elsif @textbox.text[0,1] == "#"
- Network.send_chat("##{$actor.name}", "#{$actor.name}: #{text}", 1)
- elsif @textbox.text[0,1] == "/"
- t = @textbox.text.split(" ")
- Network.send_chat("#{t[0]} #{$actor.name}", "#{$actor.name}: #{t[1]}", 1)
- elsif @textbox.text[0,1] == "!"
- Network.send_chat("!", "#{$actor.name}: #{text}", 1)
- elsif Network.hierarchy == 2
- Network.send_chat("<Admin>", "#{$actor.name}: #{@textbox.text.to_s}")
- elsif Network.hierarchy == 1
- Network.send_chat("<GM>", "#{$actor.name}: #{@textbox.text.to_s}")
- else
- Network.send_chat("", "#{$actor.name}: #{@textbox.text.to_s}")
- end
- @textbox.text = ""
- $聊天= ""
- end
-
- def mesage_commands
- return if Network.hierarchy <= 0
- if @textbox.text.include?("/kick")
- data = @textbox.text.split(' ')
- unless data[1].nil? or data[1] == ""
- Network.gm_commands(0, data[1].to_s)
- end
- @textbox.text = ""
- $聊天= ""
- end
- if @textbox.text.include?("/suspend")
- data = @textbox.text.split(' ')
- unless data[1].nil? or data[1] == ""
- Network.gm_commands(1, data[1].to_s)
- end
- @textbox.text = ""
- $聊天= ""
- end
- if @textbox.text.include?("/ban")
- data = @textbox.text.split(' ')
- unless data[1].nil? or data[1] == ""
- Network.gm_commands(2, data[1].to_s)
- end
- @textbox.text = ""
- $聊天= ""
- end
- end
-
- def message_balloon
- return if @textbox.text[0,1] == "@"
- return if @textbox.text[0,1] == "!"
- return if @textbox.text[0,1] == "#"
- return if @textbox.text[0,1] == "/"
- $game_player.message1 = @textbox.text[0, 13].to_s
- $game_player.message2 = @textbox.text[13, 99].to_s
- $game_player.message_duration = 240
- Network.socket.send("<update>@message1 = '#{$game_player.message1}';@message2 = '#{$game_player.message2}'</update>\n")
- end
-
- def scroll_down
- if $game_temp.chat_text.size >= 15
- $game_temp.chat_text -= $game_temp.chat_text.values_at(0...14)
- self.oy = 0
- create_contents
- end
- if self.contents.height < ($game_temp.chat_text.size*WLH)
- self.oy += (($game_temp.chat_text.size*WLH) - self.contents.height)
- self.contents.dispose
- self.contents = Bitmap.new(self.width-32, ($game_temp.chat_text.size*WLH))
- end
- end
-
- end
复制代码 |
|