Commit b33ab42f authored by 神楽坂玲奈's avatar 神楽坂玲奈

log

parent 7678d09f
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class Action class Action
attr_accessor :from_player, :msg attr_accessor :from_player, :msg
attr_accessor :id attr_accessor :id
def initialize(from_player=true, msg=nil) def initialize(from_player=true, msg=nil)
@id = @@id @id = @@id
@from_player = from_player @from_player = from_player
@msg = msg @msg = msg
......
...@@ -115,14 +115,12 @@ class Game_Event ...@@ -115,14 +115,12 @@ class Game_Event
#"Q" #"Q"
#"273,1,zh99998(201448),zh99997(201629)" #"273,1,zh99998(201448),zh99997(201629)"
class Watch class Watch
attr_reader :room
def self.parse(info) def self.parse(info)
id, name = info.split(",", 2) id, name = info.split(",", 2)
self.new Room.new(id.to_i, name) self.new Room.new(id.to_i, name)
end end
end end
class Action class Action
attr_reader :action
def self.parse(info) def self.parse(info)
info =~ /(.*)▊▊▊.*?$/m info =~ /(.*)▊▊▊.*?$/m
info = $1 info = $1
...@@ -133,8 +131,6 @@ class Game_Event ...@@ -133,8 +131,6 @@ class Game_Event
class Leave class Leave
end end
class Chat class Chat
attr_reader :user, :content
alias old_initialize initialize
def self.parse(info) def self.parse(info)
user, content = info.split(",", 2) user, content = info.split(",", 2)
user = user == "System" ? User.new(100000, "iDuel管理中心") : User.parse(user) user = user == "System" ? User.new(100000, "iDuel管理中心") : User.parse(user)
...@@ -142,7 +138,6 @@ class Game_Event ...@@ -142,7 +138,6 @@ class Game_Event
end end
end end
class Error class Error
attr_reader :title, :message
def self.parse(info) def self.parse(info)
title, message = case info.to_i title, message = case info.to_i
when 0x00 when 0x00
......
...@@ -26,14 +26,14 @@ class Iduel < Game ...@@ -26,14 +26,14 @@ class Iduel < Game
recv @conn.gets(RS) while @conn recv @conn.gets(RS) while @conn
rescue => exception rescue => exception
Game_Event.push Game_Event::Error.new(exception.class.to_s, exception.message) Game_Event.push Game_Event::Error.new(exception.class.to_s, exception.message)
$log.warn ([exception.inspect] + exception.backtrace).join("\n") $log.error [exception.inspect, *exception.backtrace].join("\n")
ensure ensure
self.exit self.exit
end end
end end
rescue => exception rescue => exception
Game_Event.push Game_Event::Error.new(exception.class.to_s, exception.message) Game_Event.push Game_Event::Error.new(exception.class.to_s, exception.message)
$log.warn ([exception.inspect] + exception.backtrace).join("\n") $log.error [exception.inspect, *exception.backtrace].join("\n")
end end
end end
def login(username, password) def login(username, password)
......
#!/usr/bin/env ruby #!/usr/bin/env ruby
#encoding: UTF-8 #encoding: UTF-8
begin begin
#切换工作目录
Dir.chdir(File.expand_path("..", File.dirname(__FILE__)))
#读取配置文件 #读取配置文件
require 'yaml' require 'yaml'
$config = YAML.load_file("config.yml") rescue YAML.load_file("data/config_default.yml") $config = YAML.load_file("config.yml") rescue YAML.load_file("data/config_default.yml")
...@@ -24,11 +22,15 @@ begin ...@@ -24,11 +22,15 @@ begin
#初始化日志 #初始化日志
require 'logger' require 'logger'
$log = Logger.new(STDOUT) #调试用,发布时改为log.log并删掉下面那句 if true #调试用,由于将$DEBUG设成true时tk库会输出一大坨奇怪的东西,所以这里不能使用$DEBUG
STDOUT.set_encoding "GBK", "UTF-8", :invalid => :replace, :undef => :replace if RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"] STDOUT.set_encoding "GBK", "UTF-8", :invalid => :replace, :undef => :replace if RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"]
$log = Logger.new(STDOUT)
else
$log = Logger.new("log.log")
end
$log.info("main"){"初始化成功"} $log.info("main"){"初始化成功"}
rescue Exception => exception rescue Exception => exception
open('error-程序出错请到论坛反馈.txt', 'w'){|f|f.write ([exception.inspect] + exception.backtrace).join("\n")} open('error-程序出错请到论坛反馈.txt', 'w'){|f|f.write [exception.inspect, *exception.backtrace].join("\n")}
exit(1) exit(1)
end end
...@@ -37,7 +39,7 @@ begin ...@@ -37,7 +39,7 @@ begin
$scene.main while $scene $scene.main while $scene
rescue Exception => exception rescue Exception => exception
exception.backtrace.each{|backtrace|break if backtrace =~ /^(.*)\.rb:\d+:in `.*'"$/} #由于脚本是从main.rb开始执行的,总会有个能匹配成功的文件 exception.backtrace.each{|backtrace|break if backtrace =~ /^(.*)\.rb:\d+:in `.*'"$/} #由于脚本是从main.rb开始执行的,总会有个能匹配成功的文件
$log.fatal($1){([exception.inspect] + exception.backtrace).join("\n")} $log.fatal($1){[exception.inspect, *exception.backtrace].join("\n")}
require_relative 'scene_error' require_relative 'scene_error'
$scene = Scene_Error.new $scene = Scene_Error.new
retry retry
......
...@@ -11,6 +11,12 @@ class Scene ...@@ -11,6 +11,12 @@ class Scene
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# ● 主处理 # ● 主处理
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
def initialize
@background = nil
@windows = []
@active_window = nil
@font = TTF.open('fonts/WenQuanYi Micro Hei.ttf', 16)
end
def main def main
start start
while $scene == self while $scene == self
...@@ -30,10 +36,6 @@ class Scene ...@@ -30,10 +36,6 @@ class Scene
end end
terminate terminate
end end
def initialize
@windows = []
@font = TTF.open('fonts/WenQuanYi Micro Hei.ttf', 16)
end
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# ● 开始处理 # ● 开始处理
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
......
...@@ -10,7 +10,7 @@ class Scene_Hall < Scene ...@@ -10,7 +10,7 @@ class Scene_Hall < Scene
require_relative 'window_userinfo' require_relative 'window_userinfo'
require_relative 'window_roomlist' require_relative 'window_roomlist'
require_relative 'window_chat' require_relative 'window_chat'
def start def start
$game.refresh $game.refresh
@background = Surface.load "graphics/hall/background.png" @background = Surface.load "graphics/hall/background.png"
Surface.blit(@background,0,0,0,0,$screen,0,0) Surface.blit(@background,0,0,0,0,$screen,0,0)
......
...@@ -10,9 +10,7 @@ class Widget_ScrollBar < Window ...@@ -10,9 +10,7 @@ class Widget_ScrollBar < Window
@back = Surface.load('graphics/hall/scroll_background.png') @back = Surface.load('graphics/hall/scroll_background.png')
@bar = Surface.load('graphics/hall/scroll.png') @bar = Surface.load('graphics/hall/scroll.png')
@contents.fill_rect(0,0,@width, @height, 0xFFFFFFFF) @contents.fill_rect(0,0,@width, @height, 0xFFFFFFFF)
@background.fill_rect(0,0,@width, @height, 0xFFFFFFFF)
Surface.transform_draw(@back,@contents,0,1,@contents.h.to_f/@back.h,0,0,0,0,0) Surface.transform_draw(@back,@contents,0,1,@contents.h.to_f/@back.h,0,0,0,0,0)
Surface.transform_draw(@back,@background,0,1,@contents.h.to_f/@back.h,0,0,0,0,0)
refresh refresh
end end
def index=(index) def index=(index)
......
...@@ -10,20 +10,13 @@ class Window ...@@ -10,20 +10,13 @@ class Window
@visible = true @visible = true
@angle = 0 @angle = 0
@viewport = [0, 0, @width, @height] @viewport = [0, 0, @width, @height]
@destroyed = false
amask = 0xff000000 amask = 0xff000000
rmask = 0x00ff0000 rmask = 0x00ff0000
gmask = 0x0000ff00 gmask = 0x0000ff00
bmask = 0x000000ff bmask = 0x000000ff
#@background ||= Surface.new(SWSURFACE, @width, @height, 32, rmask, gmask, bmask, amask)
@contents ||= Surface.new(SWSURFACE, @width, @height, 32, rmask, gmask, bmask, amask)
unless @background
@background = Surface.new(SWSURFACE, @width, @height, 32, rmask, gmask, bmask, amask)
#@background.fill_rect(0,0,@width,@height,0x66000000)
end
unless @contents
@contents = Surface.new(SWSURFACE, @width, @height, 32, rmask, gmask, bmask, amask)
#@contents.fill_rect(0,0,@width,@height,0x66000000)
end
#按Z坐标插入 #按Z坐标插入
unless $scene.windows.each_with_index do |window, index| unless $scene.windows.each_with_index do |window, index|
if window.z > @z if window.z > @z
......
...@@ -9,8 +9,9 @@ class Window_List < Window ...@@ -9,8 +9,9 @@ class Window_List < Window
attr_reader :list attr_reader :list
attr_reader :index attr_reader :index
def initialize(x, y, width, height, z=200) def initialize(x, y, width, height, z=200)
@list ||= []
@index ||= nil
super(x,y,width, height,z) super(x,y,width, height,z)
@list = [] unless @list
@o_index = 0 @o_index = 0
@item_max = 0 @item_max = 0
@column_max = 1 @column_max = 1
...@@ -43,12 +44,9 @@ class Window_List < Window ...@@ -43,12 +44,9 @@ class Window_List < Window
@height = @item_max * self.class::WLH @height = @item_max * self.class::WLH
refresh refresh
end end
def refresh def refresh
clear clear
@item_max.times {|index|draw_item(index, index==@index ? 1 : 0)}
@item_max.times do |index|
draw_item(index, index==@index ? 1 : 0)
end
end end
def cursor_up def cursor_up
self.index = @index ? (@index - @column_max) % [@list.size, @item_max].min : 0 self.index = @index ? (@index - @column_max) % [@list.size, @item_max].min : 0
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#============================================================================== #==============================================================================
class Window_UserInfo < Window class Window_UserInfo < Window
def initialize(x, y, user) def initialize(x, y, user)
@avatar_boarder = Surface.load "graphics/hall/avatar_boader.png" @avatar_boarder = Surface.load "graphics/hall/avatar_boader.png"
super(x,y,240,144) super(x,y,240,144)
@font = TTF.open('fonts/WenQuanYi Micro Hei.ttf', 16) @font = TTF.open('fonts/WenQuanYi Micro Hei.ttf', 16)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment