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

打开网页方式修改,launcher换调用rubyw

parent 520f249d
require 'win32api'
module Dialog
#--------------------------------------------------------------------------
# ● 选择文件对话框
#--------------------------------------------------------------------------
#选择文件对话框
require 'win32api'
GetOpenFileName = Win32API.new("comdlg32.dll", "GetOpenFileNameW", "p", "i")
OFN_EXPLORER = 0x00080000
OFN_PATHMUSTEXIST = 0x00000800
OFN_FILEMUSTEXIST = 0x00001000
OFN_ALLOWMULTISELECT = 0x00000200
OFN_FLAGS = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST |
OFN_ALLOWMULTISELECT
#打开网页
require 'win32ole'
Shell = WIN32OLE.new('Shell.Application')
module_function
def get_open_file(title="选择文件", filter = {"所有文件 (*.*)" => "*.*"})
szFile = (0.chr * 20481).encode("UTF-16LE")
szFileTitle = 0.chr * 2049
szTitle = (title+"\0").encode("UTF-16LE")
szFilter = (filter.flatten.join("\0")+"\0\0").encode("UTF-16LE")
#p szFilter.encode("GBK")
szInitialDir = "\0"
ofn =
......@@ -48,4 +47,7 @@ module Dialog
szFile.delete!("\0".encode("UTF-16LE"))
szFile.encode("UTF-8")
end
def web(url)
Shell.ShellExecute url
end
end
\ No newline at end of file
......@@ -49,7 +49,7 @@ class User
$game.rooms.find{|room|room.include? self}
end
def space
system("start http://www.duelcn.com/home.php?mod=space&uid=#{@id-100000}")
Dialog.web "http://www.duelcn.com/home.php?mod=space&uid=#{@id-100000}"
end
def color
@friend ? [255,0,0] : [0,0,0]
......
......@@ -12,7 +12,7 @@ class Window_Login
$game.login(@username_inputbox.value, @password_inputbox.value)
@last_clicked = Time.now
when :register
system("start #{Iduel::Register_Url}")
Dialog.web Iduel::Register_Url
@last_clicked = Time.now
when :replay
file = Dialog.get_open_file("播放录像", "所有支持的录像 (*.txt;*.htm)" => "*.txt;*.htm", "iDuel的html的录像 (*.htm)" => "*.htm", "文本录像 (*.txt)" => "*.txt")
......
......@@ -62,7 +62,7 @@ class Window_Announcements < Window
end
def clicked
return unless @item
system("start #{@item.url}") if @item.url
Dialog.web @item.url if @item.url
end
def mousemoved(x,y)
if !@focus
......
......@@ -5,7 +5,6 @@ require 'open-uri'
class Ygocore < Game
attr_reader :username
attr_reader :password
attr_reader :irc_users
@@config = YAML.load_file("lib/ygocore/server.yml")
def initialize
super
......@@ -14,10 +13,6 @@ class Ygocore < Game
load 'lib/ygocore/room.rb'
load 'lib/ygocore/scene_lobby.rb'
require 'json'
@irc_users = []
end
def refresh_interval
60
end
def login(username, password)
@username = username
......@@ -40,58 +35,6 @@ class Ygocore < Game
end
end
def user=(user)
super
begin
require 'net/yail'
$log.info('聊天'){user.inspect}
@irc = Net::YAIL.new(
address: 'card.touhou.cc',
username: hexencode(user.id),
nicknames: [hexencode(user.name), hexencode("#{user.name}_#{rand(10000)}"), hexencode("#{user.name}_#{rand(10000)}")])
$log.info('聊天连接')
@irc.on_welcome proc { |event| $log.info('连接聊天服务器成功'); Game_Event.push(Game_Event::Chat.new(ChatMessage.new(User.new(:system, 'system'), '聊天服务器连接成功,聊天功能测试中,可能引发程序崩溃,如果崩得过于频繁请暂时不要使用.', :lobby))); @irc.join('#lobby') }
@irc.hearing_msg {|event|
user = User.new(hexdecode(event.msg.user).to_sym, hexdecode(event.nick))
Game_Event.push Game_Event::Chat.new(ChatMessage.new(user, event.message, event.channel ? event.channel[1,event.channel.size-1].to_sym : user))
}
@irc.heard_namreply{|event|
@irc_users.concat @irc.instance_variable_get(:@nicklist).collect {|user|
User.new(hexdecode(user).to_sym, hexdecode(user))
}
Game_Event.push Game_Event::AllUsers.new(@users|@irc_users)
$log.info('irc用户列表'){user}
}
@irc.heard_join{|event|
user = User.new(hexdecode(event.msg.user).to_sym, hexdecode(event.nick))
Game_Event.push Game_Event::NewUser.new(user)
$log.info('irc用户上线'){user}
}
@irc.heard_quit{|event|
user = User.new(hexdecode(event.msg.user).to_sym, hexdecode(event.nick))
Game_Event.push Game_Event::MissingUser.new(user)
$log.info('irc用户下线'){user}
}
#@irc.hearing_join {}
$log.info('聊天开始监听')
@irc.start_listening
$log.info('聊天加载完毕')
rescue Exception => exception
$log.error('聊天出错'){[exception.inspect, *exception.backtrace].collect{|str|str.encode("UTF-8")}.join("\n")}
Game_Event.push(Game_Event::Chat.new(ChatMessage.new(User.new(:system, 'system'), '连接聊天服务器失败', :lobby)))
end
end
def chat(chatmessage)
$log.info('发送聊天消息'){chatmessage.inspect}
return unless @irc
case chatmessage.channel
when Symbol
@irc.msg "##{chatmessage.channel}", chatmessage.message
when User
@irc.msg hexencode(chatmessage.channel.id), chatmessage.message
end
$log.info('发送聊天消息完毕')
end
def host(room_name, room_config)
room = Room.new(0, room_name)
room.pvp = room_config[:pvp]
......@@ -119,16 +62,11 @@ class Ygocore < Game
@recv.exit if @recv
@recv = nil
end
def exit
(@irc.quit if @irc) rescue nil
@irc = nil
@chat_thread = nil
end
def ygocore_path
"ygocore/gframe.exe"
end
def self.register
system("start #{@@config['register']}")
Dialog.web @@config['register']
end
def server
@@config['server']
......
......@@ -15,7 +15,7 @@ class User
end
def space
if @certified
system("start http://card.touhou.cc/users/#{CGI.escape @id.to_s}")
Dialog.web "http://card.touhou.cc/users/#{CGI.escape @id.to_s}"
else
Widget_Msgbox.new("查看资料", "用户#{@name}没有注册", :ok => "确定")
end
......
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