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

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

parent 520f249d
require 'win32api'
module Dialog module Dialog
#-------------------------------------------------------------------------- #选择文件对话框
# ● 选择文件对话框 require 'win32api'
#--------------------------------------------------------------------------
GetOpenFileName = Win32API.new("comdlg32.dll", "GetOpenFileNameW", "p", "i") GetOpenFileName = Win32API.new("comdlg32.dll", "GetOpenFileNameW", "p", "i")
OFN_EXPLORER = 0x00080000 OFN_EXPLORER = 0x00080000
OFN_PATHMUSTEXIST = 0x00000800 OFN_PATHMUSTEXIST = 0x00000800
OFN_FILEMUSTEXIST = 0x00001000 OFN_FILEMUSTEXIST = 0x00001000
OFN_ALLOWMULTISELECT = 0x00000200 OFN_ALLOWMULTISELECT = 0x00000200
OFN_FLAGS = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_FLAGS = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST |
OFN_ALLOWMULTISELECT OFN_ALLOWMULTISELECT
#打开网页
require 'win32ole'
Shell = WIN32OLE.new('Shell.Application')
module_function module_function
def get_open_file(title="选择文件", filter = {"所有文件 (*.*)" => "*.*"}) def get_open_file(title="选择文件", filter = {"所有文件 (*.*)" => "*.*"})
szFile = (0.chr * 20481).encode("UTF-16LE") szFile = (0.chr * 20481).encode("UTF-16LE")
szFileTitle = 0.chr * 2049 szFileTitle = 0.chr * 2049
szTitle = (title+"\0").encode("UTF-16LE") szTitle = (title+"\0").encode("UTF-16LE")
szFilter = (filter.flatten.join("\0")+"\0\0").encode("UTF-16LE") szFilter = (filter.flatten.join("\0")+"\0\0").encode("UTF-16LE")
#p szFilter.encode("GBK")
szInitialDir = "\0" szInitialDir = "\0"
ofn = ofn =
...@@ -48,4 +47,7 @@ module Dialog ...@@ -48,4 +47,7 @@ module Dialog
szFile.delete!("\0".encode("UTF-16LE")) szFile.delete!("\0".encode("UTF-16LE"))
szFile.encode("UTF-8") szFile.encode("UTF-8")
end end
def web(url)
Shell.ShellExecute url
end
end end
\ No newline at end of file
...@@ -49,7 +49,7 @@ class User ...@@ -49,7 +49,7 @@ class User
$game.rooms.find{|room|room.include? self} $game.rooms.find{|room|room.include? self}
end end
def space 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 end
def color def color
@friend ? [255,0,0] : [0,0,0] @friend ? [255,0,0] : [0,0,0]
......
...@@ -12,7 +12,7 @@ class Window_Login ...@@ -12,7 +12,7 @@ class Window_Login
$game.login(@username_inputbox.value, @password_inputbox.value) $game.login(@username_inputbox.value, @password_inputbox.value)
@last_clicked = Time.now @last_clicked = Time.now
when :register when :register
system("start #{Iduel::Register_Url}") Dialog.web Iduel::Register_Url
@last_clicked = Time.now @last_clicked = Time.now
when :replay when :replay
file = Dialog.get_open_file("播放录像", "所有支持的录像 (*.txt;*.htm)" => "*.txt;*.htm", "iDuel的html的录像 (*.htm)" => "*.htm", "文本录像 (*.txt)" => "*.txt") file = Dialog.get_open_file("播放录像", "所有支持的录像 (*.txt;*.htm)" => "*.txt;*.htm", "iDuel的html的录像 (*.htm)" => "*.htm", "文本录像 (*.txt)" => "*.txt")
......
...@@ -62,7 +62,7 @@ class Window_Announcements < Window ...@@ -62,7 +62,7 @@ class Window_Announcements < Window
end end
def clicked def clicked
return unless @item return unless @item
system("start #{@item.url}") if @item.url Dialog.web @item.url if @item.url
end end
def mousemoved(x,y) def mousemoved(x,y)
if !@focus if !@focus
......
...@@ -5,7 +5,6 @@ require 'open-uri' ...@@ -5,7 +5,6 @@ require 'open-uri'
class Ygocore < Game class Ygocore < Game
attr_reader :username attr_reader :username
attr_reader :password attr_reader :password
attr_reader :irc_users
@@config = YAML.load_file("lib/ygocore/server.yml") @@config = YAML.load_file("lib/ygocore/server.yml")
def initialize def initialize
super super
...@@ -14,10 +13,6 @@ class Ygocore < Game ...@@ -14,10 +13,6 @@ class Ygocore < Game
load 'lib/ygocore/room.rb' load 'lib/ygocore/room.rb'
load 'lib/ygocore/scene_lobby.rb' load 'lib/ygocore/scene_lobby.rb'
require 'json' require 'json'
@irc_users = []
end
def refresh_interval
60
end end
def login(username, password) def login(username, password)
@username = username @username = username
...@@ -40,58 +35,6 @@ class Ygocore < Game ...@@ -40,58 +35,6 @@ class Ygocore < Game
end end
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) def host(room_name, room_config)
room = Room.new(0, room_name) room = Room.new(0, room_name)
room.pvp = room_config[:pvp] room.pvp = room_config[:pvp]
...@@ -119,16 +62,11 @@ class Ygocore < Game ...@@ -119,16 +62,11 @@ class Ygocore < Game
@recv.exit if @recv @recv.exit if @recv
@recv = nil @recv = nil
end end
def exit
(@irc.quit if @irc) rescue nil
@irc = nil
@chat_thread = nil
end
def ygocore_path def ygocore_path
"ygocore/gframe.exe" "ygocore/gframe.exe"
end end
def self.register def self.register
system("start #{@@config['register']}") Dialog.web @@config['register']
end end
def server def server
@@config['server'] @@config['server']
...@@ -252,4 +190,4 @@ class Ygocore < Game ...@@ -252,4 +190,4 @@ class Ygocore < Game
end end
end end
get_announcements get_announcements
end end
\ No newline at end of file
...@@ -15,7 +15,7 @@ class User ...@@ -15,7 +15,7 @@ class User
end end
def space def space
if @certified 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 else
Widget_Msgbox.new("查看资料", "用户#{@name}没有注册", :ok => "确定") Widget_Msgbox.new("查看资料", "用户#{@name}没有注册", :ok => "确定")
end 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