Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
mycard
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaoye
mycard
Commits
096e2478
Commit
096e2478
authored
Mar 14, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
版本0.4.2
parent
4fae1f46
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
20 deletions
+30
-20
lib/ygocore/game.rb
lib/ygocore/game.rb
+10
-5
lib/ygocore/scene_lobby.rb
lib/ygocore/scene_lobby.rb
+20
-15
No files found.
lib/ygocore/game.rb
View file @
096e2478
...
@@ -28,10 +28,15 @@ class Ygocore < Game
...
@@ -28,10 +28,15 @@ class Ygocore < Game
file
.
set_encoding
"GBK"
file
.
set_encoding
"GBK"
result
=
file
.
read
.
encode
(
"UTF-8"
)
result
=
file
.
read
.
encode
(
"UTF-8"
)
$log
.
debug
(
'用户登陆传回消息'
){
result
}
$log
.
debug
(
'用户登陆传回消息'
){
result
}
if
result
==
"修改成功"
case
result
when
"修改成功"
connect
connect
@password
=
password
@password
=
password
Game_Event
.
push
Game_Event
::
Login
.
new
(
User
.
new
(
username
.
to_sym
,
username
))
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
else
Game_Event
.
push
Game_Event
::
Error
.
new
(
"登陆"
,
"用户名或密码错误"
)
Game_Event
.
push
Game_Event
::
Error
.
new
(
"登陆"
,
"用户名或密码错误"
)
end
end
...
@@ -42,6 +47,7 @@ class Ygocore < Game
...
@@ -42,6 +47,7 @@ class Ygocore < Game
if
$game
.
password
.
nil?
or
$game
.
password
.
empty?
if
$game
.
password
.
nil?
or
$game
.
password
.
empty?
return
Widget_Msgbox
.
new
(
"建立房间"
,
"必须有账号才能建立房间"
,
:ok
=>
"确定"
)
return
Widget_Msgbox
.
new
(
"建立房间"
,
"必须有账号才能建立房间"
,
:ok
=>
"确定"
)
end
end
return
unless
ygocore_path
room
=
Room
.
new
(
0
,
room_name
)
room
=
Room
.
new
(
0
,
room_name
)
room
.
pvp
=
room_config
[
:pvp
]
room
.
pvp
=
room_config
[
:pvp
]
room
.
match
=
room_config
[
:match
]
room
.
match
=
room_config
[
:match
]
...
@@ -79,15 +85,11 @@ class Ygocore < Game
...
@@ -79,15 +85,11 @@ class Ygocore < Game
info
=
file
.
read
.
encode
(
"UTF-8"
)
info
=
file
.
read
.
encode
(
"UTF-8"
)
Game_Event
.
push
Game_Event
::
AllUsers
.
parse
info
Game_Event
.
push
Game_Event
::
AllUsers
.
parse
info
Game_Event
.
push
Game_Event
::
AllRooms
.
parse
info
Game_Event
.
push
Game_Event
::
AllRooms
.
parse
info
p
block_given?
yield
if
block_given?
yield
if
block_given?
end
end
end
end
end
end
end
end
private
def
connect
end
def
ygocore_path
def
ygocore_path
return
$config
[
'ygocore'
][
'path'
]
if
$config
[
'ygocore'
][
'path'
]
and
File
.
file?
$config
[
'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
#防止重复点击
return
if
@last_clicked
and
Time
.
now
-
@last_clicked
<
3
#防止重复点击
...
@@ -98,6 +100,9 @@ class Ygocore < Game
...
@@ -98,6 +100,9 @@ class Ygocore < Game
save_config
save_config
@last_clicked
=
Time
.
now
@last_clicked
=
Time
.
now
end
end
private
def
connect
end
def
self
.
get_announcements
def
self
.
get_announcements
#公告
#公告
$config
[
'ygocore'
][
'announcements'
]
||=
[
Announcement
.
new
(
"正在读取公告..."
,
nil
,
nil
)]
$config
[
'ygocore'
][
'announcements'
]
||=
[
Announcement
.
new
(
"正在读取公告..."
,
nil
,
nil
)]
...
...
lib/ygocore/scene_lobby.rb
View file @
096e2478
...
@@ -11,6 +11,8 @@ class Scene_Lobby
...
@@ -11,6 +11,8 @@ class Scene_Lobby
CF_UNICODETEXT
=
13
;
CF_UNICODETEXT
=
13
;
GMEM_DDESHARE
=
0x2000
;
GMEM_DDESHARE
=
0x2000
;
def
join
(
room
)
def
join
(
room
)
return
unless
$game
.
ygocore_path
room_name
=
if
room
.
pvp?
and
room
.
match?
room_name
=
if
room
.
pvp?
and
room
.
match?
"PM#"
+
room
.
name
"PM#"
+
room
.
name
elsif
room
.
pvp?
elsif
room
.
pvp?
...
@@ -23,7 +25,7 @@ class Scene_Lobby
...
@@ -23,7 +25,7 @@ class Scene_Lobby
$scene
.
draw
$scene
.
draw
#写入配置文件并运行ygocore
#写入配置文件并运行ygocore
Dir
.
chdir
(
File
.
dirname
(
$
config
[
'ygocore'
][
'path'
]
))
do
Dir
.
chdir
(
File
.
dirname
(
$
game
.
ygocore_path
))
do
$log
.
debug
(
'当前目录'
){
Dir
.
pwd
.
encode
(
"UTF-8"
)}
$log
.
debug
(
'当前目录'
){
Dir
.
pwd
.
encode
(
"UTF-8"
)}
system_conf
=
{}
system_conf
=
{}
begin
begin
...
@@ -49,19 +51,19 @@ class Scene_Lobby
...
@@ -49,19 +51,19 @@ class Scene_Lobby
end
end
#初始化windows API
#初始化windows API
require
'win32api'
require
'win32api'
@@FindWindow
=
Win32API
.
new
(
"user32"
,
"FindWindow"
,
"pp"
,
"l"
)
@@FindWindow
||
=
Win32API
.
new
(
"user32"
,
"FindWindow"
,
"pp"
,
"l"
)
@@SendMessage
=
Win32API
.
new
(
'user32'
,
'SendMessage'
,
[
"L"
,
"L"
,
"L"
,
"L"
],
"L"
)
@@SendMessage
||
=
Win32API
.
new
(
'user32'
,
'SendMessage'
,
[
"L"
,
"L"
,
"L"
,
"L"
],
"L"
)
@@SetForegroundWindow
=
Win32API
.
new
(
'user32'
,
'SetForegroundWindow'
,
'l'
,
'v'
)
@@SetForegroundWindow
||
=
Win32API
.
new
(
'user32'
,
'SetForegroundWindow'
,
'l'
,
'v'
)
@@keybd_event
=
Win32API
.
new
(
'user32'
,
'keybd_event'
,
'llll'
,
'v'
)
@@keybd_event
||
=
Win32API
.
new
(
'user32'
,
'keybd_event'
,
'llll'
,
'v'
)
@@lstrcpy
=
Win32API
.
new
(
'kernel32'
,
'lstrcpyW'
,
[
'I'
,
'P'
],
'P'
);
@@lstrcpy
||
=
Win32API
.
new
(
'kernel32'
,
'lstrcpyW'
,
[
'I'
,
'P'
],
'P'
);
@@lstrlen
=
Win32API
.
new
(
'kernel32'
,
'lstrlenW'
,
[
'P'
],
'I'
);
@@lstrlen
||
=
Win32API
.
new
(
'kernel32'
,
'lstrlenW'
,
[
'P'
],
'I'
);
@@OpenClipboard
=
Win32API
.
new
(
'user32'
,
'OpenClipboard'
,
[
'I'
],
'I'
);
@@OpenClipboard
||
=
Win32API
.
new
(
'user32'
,
'OpenClipboard'
,
[
'I'
],
'I'
);
@@CloseClipboard
=
Win32API
.
new
(
'user32'
,
'CloseClipboard'
,
[],
'I'
);
@@CloseClipboard
||
=
Win32API
.
new
(
'user32'
,
'CloseClipboard'
,
[],
'I'
);
@@EmptyClipboard
=
Win32API
.
new
(
'user32'
,
'EmptyClipboard'
,
[],
'I'
);
@@EmptyClipboard
||
=
Win32API
.
new
(
'user32'
,
'EmptyClipboard'
,
[],
'I'
);
@@SetClipboardData
=
Win32API
.
new
(
'user32'
,
'SetClipboardData'
,
[
'I'
,
'I'
],
'I'
);
@@SetClipboardData
||
=
Win32API
.
new
(
'user32'
,
'SetClipboardData'
,
[
'I'
,
'I'
],
'I'
);
@@GlobalAlloc
=
Win32API
.
new
(
'kernel32'
,
'GlobalAlloc'
,
[
'I'
,
'I'
],
'I'
);
@@GlobalAlloc
||
=
Win32API
.
new
(
'kernel32'
,
'GlobalAlloc'
,
[
'I'
,
'I'
],
'I'
);
@@GlobalLock
=
Win32API
.
new
(
'kernel32'
,
'GlobalLock'
,
[
'I'
],
'I'
);
@@GlobalLock
||
=
Win32API
.
new
(
'kernel32'
,
'GlobalLock'
,
[
'I'
],
'I'
);
@@GlobalUnlock
=
Win32API
.
new
(
'kernel32'
,
'GlobalUnlock'
,
[
'I'
],
'I'
);
@@GlobalUnlock
||
=
Win32API
.
new
(
'kernel32'
,
'GlobalUnlock'
,
[
'I'
],
'I'
);
#获取句柄
#获取句柄
hwnd
=
nil
hwnd
=
nil
50
.
times
do
50
.
times
do
...
@@ -79,7 +81,8 @@ class Scene_Lobby
...
@@ -79,7 +81,8 @@ class Scene_Lobby
if
@@OpenClipboard
.
Call
(
0
)
!=
0
if
@@OpenClipboard
.
Call
(
0
)
!=
0
$log
.
debug
(
'加入房间'
){
room_name
}
$log
.
debug
(
'加入房间'
){
room_name
}
@@EmptyClipboard
.
Call
();
@@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
}
$log
.
debug
(
'房间名长度'
){
len
.
to_s
}
hmem
=
@@GlobalAlloc
.
Call
(
GMEM_DDESHARE
,
len
+
2
);
hmem
=
@@GlobalAlloc
.
Call
(
GMEM_DDESHARE
,
len
+
2
);
pmem
=
@@GlobalLock
.
Call
(
hmem
);
pmem
=
@@GlobalLock
.
Call
(
hmem
);
...
@@ -107,6 +110,8 @@ class Scene_Lobby
...
@@ -107,6 +110,8 @@ class Scene_Lobby
else
else
Widget_Msgbox
.
new
(
"加入房间"
,
'ygocore运行失败'
,
:ok
=>
"确定"
)
Widget_Msgbox
.
new
(
"加入房间"
,
'ygocore运行失败'
,
:ok
=>
"确定"
)
end
end
#这里似乎有个能引起ruby解释器崩溃的故障,但是没法稳定重现。
GC
.
start
end
end
def
MAKELPARAM
(
w1
,
w2
)
def
MAKELPARAM
(
w1
,
w2
)
return
(
w2
<<
16
)
|
w1
return
(
w2
<<
16
)
|
w1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment