Commit 096e2478 authored by 神楽坂玲奈's avatar 神楽坂玲奈

版本0.4.2

parent 4fae1f46
......@@ -28,10 +28,15 @@ class Ygocore < Game
file.set_encoding "GBK"
result = file.read.encode("UTF-8")
$log.debug('用户登陆传回消息'){result}
if result == "修改成功"
case result
when "修改成功"
connect
@password = password
Game_Event.push Game_Event::Login.new(User.new(username.to_sym, username))
when "用户注册禁止"
connect
@password = password
Widget_Msgbox.new("登陆", "验证关闭,加房连接断开请自行检查密码", :ok => "确定"){Game_Event.push Game_Event::Login.new(User.new(username.to_sym, username))}
else
Game_Event.push Game_Event::Error.new("登陆", "用户名或密码错误")
end
......@@ -42,6 +47,7 @@ class Ygocore < Game
if $game.password.nil? or $game.password.empty?
return Widget_Msgbox.new("建立房间", "必须有账号才能建立房间", :ok => "确定")
end
return unless ygocore_path
room = Room.new(0, room_name)
room.pvp = room_config[:pvp]
room.match = room_config[:match]
......@@ -79,15 +85,11 @@ class Ygocore < Game
info = file.read.encode("UTF-8")
Game_Event.push Game_Event::AllUsers.parse info
Game_Event.push Game_Event::AllRooms.parse info
p block_given?
yield if block_given?
end
end
end
end
private
def connect
end
def ygocore_path
return $config['ygocore']['path'] if $config['ygocore']['path'] and File.file? $config['ygocore']['path']
return if @last_clicked and Time.now - @last_clicked < 3 #防止重复点击
......@@ -98,6 +100,9 @@ class Ygocore < Game
save_config
@last_clicked = Time.now
end
private
def connect
end
def self.get_announcements
#公告
$config['ygocore']['announcements'] ||= [Announcement.new("正在读取公告...", nil, nil)]
......
......@@ -11,6 +11,8 @@ class Scene_Lobby
CF_UNICODETEXT = 13;
GMEM_DDESHARE = 0x2000;
def join(room)
return unless $game.ygocore_path
room_name = if room.pvp? and room.match?
"PM#" + room.name
elsif room.pvp?
......@@ -23,7 +25,7 @@ class Scene_Lobby
$scene.draw
#写入配置文件并运行ygocore
Dir.chdir(File.dirname($config['ygocore']['path'])) do
Dir.chdir(File.dirname($game.ygocore_path)) do
$log.debug('当前目录'){Dir.pwd.encode("UTF-8")}
system_conf = {}
begin
......@@ -49,19 +51,19 @@ class Scene_Lobby
end
#初始化windows API
require 'win32api'
@@FindWindow = Win32API.new("user32","FindWindow","pp","l")
@@SendMessage = Win32API.new('user32', 'SendMessage', ["L", "L", "L", "L"], "L")
@@SetForegroundWindow = Win32API.new('user32', 'SetForegroundWindow', 'l', 'v')
@@keybd_event = Win32API.new('user32', 'keybd_event', 'llll', 'v')
@@lstrcpy = Win32API.new('kernel32', 'lstrcpyW', ['I', 'P'], 'P');
@@lstrlen = Win32API.new('kernel32', 'lstrlenW', ['P'], 'I');
@@OpenClipboard = Win32API.new('user32', 'OpenClipboard', ['I'], 'I');
@@CloseClipboard = Win32API.new('user32', 'CloseClipboard', [], 'I');
@@EmptyClipboard = Win32API.new('user32', 'EmptyClipboard', [], 'I');
@@SetClipboardData = Win32API.new('user32', 'SetClipboardData', ['I', 'I'], 'I');
@@GlobalAlloc = Win32API.new('kernel32', 'GlobalAlloc', ['I','I'], 'I');
@@GlobalLock = Win32API.new('kernel32', 'GlobalLock', ['I'], 'I');
@@GlobalUnlock = Win32API.new('kernel32', 'GlobalUnlock', ['I'], 'I');
@@FindWindow ||= Win32API.new("user32","FindWindow","pp","l")
@@SendMessage ||= Win32API.new('user32', 'SendMessage', ["L", "L", "L", "L"], "L")
@@SetForegroundWindow ||= Win32API.new('user32', 'SetForegroundWindow', 'l', 'v')
@@keybd_event ||= Win32API.new('user32', 'keybd_event', 'llll', 'v')
@@lstrcpy ||= Win32API.new('kernel32', 'lstrcpyW', ['I', 'P'], 'P');
@@lstrlen ||= Win32API.new('kernel32', 'lstrlenW', ['P'], 'I');
@@OpenClipboard ||= Win32API.new('user32', 'OpenClipboard', ['I'], 'I');
@@CloseClipboard ||= Win32API.new('user32', 'CloseClipboard', [], 'I');
@@EmptyClipboard ||= Win32API.new('user32', 'EmptyClipboard', [], 'I');
@@SetClipboardData ||= Win32API.new('user32', 'SetClipboardData', ['I', 'I'], 'I');
@@GlobalAlloc ||= Win32API.new('kernel32', 'GlobalAlloc', ['I','I'], 'I');
@@GlobalLock ||= Win32API.new('kernel32', 'GlobalLock', ['I'], 'I');
@@GlobalUnlock ||= Win32API.new('kernel32', 'GlobalUnlock', ['I'], 'I');
#获取句柄
hwnd = nil
50.times do
......@@ -79,7 +81,8 @@ class Scene_Lobby
if @@OpenClipboard.Call(0) != 0
$log.debug('加入房间'){room_name}
@@EmptyClipboard.Call();
len=room_name.encode("UTF-16LE").bytesize
p len = room_name.encode("UTF-16LE").bytesize
#p len=@@lstrlen.call(room_name.encode("UTF-16LE"))#
$log.debug('房间名长度'){len.to_s}
hmem = @@GlobalAlloc.Call(GMEM_DDESHARE, len+2);
pmem = @@GlobalLock.Call(hmem);
......@@ -107,6 +110,8 @@ class Scene_Lobby
else
Widget_Msgbox.new("加入房间", 'ygocore运行失败', :ok => "确定")
end
#这里似乎有个能引起ruby解释器崩溃的故障,但是没法稳定重现。
GC.start
end
def MAKELPARAM(w1,w2)
return (w2<<16) | w1
......
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