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

log

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