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
2570f69a
Commit
2570f69a
authored
Mar 07, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ygocore
parent
eaa75dde
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
45 deletions
+67
-45
lib/iduel/window_login.rb
lib/iduel/window_login.rb
+1
-1
lib/ygocore/game.rb
lib/ygocore/game.rb
+66
-44
No files found.
lib/iduel/window_login.rb
View file @
2570f69a
...
@@ -18,7 +18,7 @@ class Window_Login
...
@@ -18,7 +18,7 @@ class Window_Login
@last_clicked
=
Time
.
now
@last_clicked
=
Time
.
now
when
:replay
when
:replay
require
'tk'
require
'tk'
file
=
Tk
.
getOpenFile
file
=
Tk
.
getOpenFile
.
encode
(
"UTF-8"
)
if
!
file
.
empty?
if
!
file
.
empty?
$game
=
Iduel
.
new
$game
=
Iduel
.
new
$game
.
user
=
User
.
new
(
0
)
$game
.
user
=
User
.
new
(
0
)
...
...
lib/ygocore/game.rb
View file @
2570f69a
...
@@ -8,12 +8,16 @@ class Ygocore < Game
...
@@ -8,12 +8,16 @@ class Ygocore < Game
WM_LBUTTONDOWN
=
0x201
WM_LBUTTONDOWN
=
0x201
WM_LBUTTONUP
=
0x202
WM_LBUTTONUP
=
0x202
#WM_KEYDOWN = 0x0100
#WM_KEYUP = 0x0100
VK_CONTROL
=
0x11
VK_CONTROL
=
0x11
VK_A
=
0x41
VK_A
=
0x41
VK_V
=
0x56
VK_V
=
0x56
VK_TAB
=
0x09
VK_TAB
=
0x09
VK_RETURN
=
0x0D
VK_RETURN
=
0x0D
KEYEVENTF_KEYUP
=
0x02
KEYEVENTF_KEYUP
=
0x02
CF_TEXT
=
1
;
GMEM_DDESHARE
=
0x2000
;
def
initialize
def
initialize
super
super
load
File
.
expand_path
(
'event.rb'
,
File
.
dirname
(
__FILE__
))
load
File
.
expand_path
(
'event.rb'
,
File
.
dirname
(
__FILE__
))
...
@@ -29,7 +33,8 @@ class Ygocore < Game
...
@@ -29,7 +33,8 @@ class Ygocore < Game
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
))
end
end
def
watch
(
room
)
def
watch
(
room
)
Widget_Msgbox
.
new
(
"观战"
,
"ygocore不支持加入已经开始游戏的房间"
,
:ok
=>
"确定"
)
#Widget_Msgbox.new("观战", "ygocore不支持加入已经开始游戏的房间", :ok => "确定")
join
(
room
)
end
end
def
join
(
room
)
def
join
(
room
)
return
if
@last_clicked
and
Time
.
now
-
@last_clicked
<
3
#防止重复点击
return
if
@last_clicked
and
Time
.
now
-
@last_clicked
<
3
#防止重复点击
...
@@ -37,15 +42,15 @@ class Ygocore < Game
...
@@ -37,15 +42,15 @@ class Ygocore < Game
Widget_Msgbox
.
new
(
"加入房间"
,
"请指定ygocore主程序位置"
)
Widget_Msgbox
.
new
(
"加入房间"
,
"请指定ygocore主程序位置"
)
$scene
.
draw
$scene
.
draw
require
'tk'
require
'tk'
$config
[
'ygocore'
][
'path'
]
=
Tk
.
getOpenFile
$config
[
'ygocore'
][
'path'
]
=
Tk
.
getOpenFile
.
encode
(
"UTF-8"
)
save_config
save_config
@last_clicked
=
Time
.
now
@last_clicked
=
Time
.
now
end
end
if
$config
[
'ygocore'
][
'path'
]
and
File
.
file?
$config
[
'ygocore'
][
'path'
]
if
$config
[
'ygocore'
][
'path'
]
and
File
.
file?
$config
[
'ygocore'
][
'path'
]
$scene
.
draw
$scene
.
draw
#写入配置文件并运行ygocore
#写入ygocore配置文件
Dir
.
chdir
(
File
.
dirname
(
$config
[
'ygocore'
][
'path'
]))
do
Dir
.
chdir
(
File
.
dirname
(
$config
[
'ygocore'
][
'path'
]))
do
$log
.
debug
(
'当前目录'
){
Dir
.
pwd
.
encode
(
"UTF-8"
)}
system_conf
=
{}
system_conf
=
{}
IO
.
readlines
(
'system.conf'
).
each
do
|
line
|
IO
.
readlines
(
'system.conf'
).
each
do
|
line
|
line
.
force_encoding
"UTF-8"
line
.
force_encoding
"UTF-8"
...
@@ -57,17 +62,24 @@ class Ygocore < Game
...
@@ -57,17 +62,24 @@ class Ygocore < Game
system_conf
[
'lastip'
]
=
Server
system_conf
[
'lastip'
]
=
Server
system_conf
[
'lastport'
]
=
Port
.
to_s
system_conf
[
'lastport'
]
=
Port
.
to_s
open
(
'system.conf'
,
'w'
)
{
|
file
|
file
.
write
system_conf
.
collect
{
|
key
,
value
|
"
#{
key
}
=
#{
value
}
"
}.
join
(
"
\n
"
)}
open
(
'system.conf'
,
'w'
)
{
|
file
|
file
.
write
system_conf
.
collect
{
|
key
,
value
|
"
#{
key
}
=
#{
value
}
"
}.
join
(
"
\n
"
)}
$log
.
debug
(
'ygocore路径'
)
{
$config
[
'ygocore'
][
'path'
]}
#运行ygocore
IO
.
popen
(
"
\"
#{
$config
[
'ygocore'
][
'path'
]
}
\"
"
.
encode
(
"GBK"
))
#执行外部程序....有中文的情况下貌似只能这样了orz
require
'launchy'
end
Launchy
.
open
$config
[
'ygocore'
][
'path'
]
#初始化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'
,
'lstrcpyA'
,
[
'I'
,
'P'
],
'P'
);
@@lstrlen
=
Win32API
.
new
(
'kernel32'
,
'lstrlen'
,
[
'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
hwnd
=
nil
100
.
times
do
100
.
times
do
...
@@ -82,8 +94,19 @@ class Ygocore < Game
...
@@ -82,8 +94,19 @@ class Ygocore < Game
@@SendMessage
.
call
(
hwnd
,
WM_LBUTTONDOWN
,
0
,
MAKELPARAM
(
507
,
242
))
@@SendMessage
.
call
(
hwnd
,
WM_LBUTTONDOWN
,
0
,
MAKELPARAM
(
507
,
242
))
@@SendMessage
.
call
(
hwnd
,
WM_LBUTTONUP
,
0
,
MAKELPARAM
(
507
,
242
))
@@SendMessage
.
call
(
hwnd
,
WM_LBUTTONUP
,
0
,
MAKELPARAM
(
507
,
242
))
sleep
0.3
sleep
0.3
require
'win32/clipboard'
if
@@OpenClipboard
.
Call
(
0
)
!=
0
Win32
::
Clipboard
.
set_data
(
room
.
name
.
encode
(
"GBK"
).
force_encoding
(
"UTF-8"
))
@@EmptyClipboard
.
Call
();
len
=
@@lstrlen
.
Call
(
room
.
name
.
encode
(
"GBK"
));
hmem
=
@@GlobalAlloc
.
Call
(
GMEM_DDESHARE
,
len
+
1
);
pmem
=
@@GlobalLock
.
Call
(
hmem
);
@@lstrcpy
.
Call
(
pmem
,
room
.
name
.
encode
(
"GBK"
));
@@SetClipboardData
.
Call
(
CF_TEXT
,
hmem
);
@@GlobalUnlock
.
Call
(
hmem
);
@@CloseClipboard
.
Call
;
else
return
Widget_Msgbox
.
new
(
"加入房间"
,
'填写房间名失败 请把房间名手动填写到房间密码处'
,
:ok
=>
"确定"
)
end
$log
.
debug
(
'加入房间'
){
room
.
name
}
@@SetForegroundWindow
.
call
(
hwnd
)
@@SetForegroundWindow
.
call
(
hwnd
)
@@SendMessage
.
call
(
hwnd
,
WM_LBUTTONDOWN
,
0
,
MAKELPARAM
(
380
,
500
))
@@SendMessage
.
call
(
hwnd
,
WM_LBUTTONDOWN
,
0
,
MAKELPARAM
(
380
,
500
))
@@SendMessage
.
call
(
hwnd
,
WM_LBUTTONUP
,
0
,
MAKELPARAM
(
380
,
500
))
@@SendMessage
.
call
(
hwnd
,
WM_LBUTTONUP
,
0
,
MAKELPARAM
(
380
,
500
))
...
@@ -98,8 +121,7 @@ class Ygocore < Game
...
@@ -98,8 +121,7 @@ class Ygocore < Game
@@keybd_event
.
call
(
VK_RETURN
,
0
,
0
,
0
)
@@keybd_event
.
call
(
VK_RETURN
,
0
,
0
,
0
)
@@keybd_event
.
call
(
VK_RETURN
,
0
,
KEYEVENTF_KEYUP
,
0
)
@@keybd_event
.
call
(
VK_RETURN
,
0
,
KEYEVENTF_KEYUP
,
0
)
else
else
Widget_Msgbox
.
new
(
"加入房间"
,
'ygocore运行失败'
,
:ok
=>
"确定"
)
return
Widget_Msgbox
.
new
(
"加入房间"
,
'ygocore运行失败'
,
:ok
=>
"确定"
)
end
end
end
end
end
Widget_Msgbox
.
new
(
"加入房间"
,
"已经加入房间"
).
destroy
#仅仅为了消掉正在加入房间的消息框
Widget_Msgbox
.
new
(
"加入房间"
,
"已经加入房间"
).
destroy
#仅仅为了消掉正在加入房间的消息框
...
...
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