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
21f382e2
Commit
21f382e2
authored
Mar 18, 2012
by
zh99998
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去掉Tk库,输入法改为夏娜版,get_open_file改为windows API
parent
940f2b07
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
386 additions
and
59 deletions
+386
-59
lib/dialog.rb
lib/dialog.rb
+51
-0
lib/game_event.rb
lib/game_event.rb
+1
-2
lib/iduel/window_login.rb
lib/iduel/window_login.rb
+2
-2
lib/main.rb
lib/main.rb
+3
-0
lib/ogginfo.rb
lib/ogginfo.rb
+1
-1
lib/scene.rb
lib/scene.rb
+11
-2
lib/scene_lobby.rb
lib/scene_lobby.rb
+2
-0
lib/scene_login.rb
lib/scene_login.rb
+0
-1
lib/widget_inputbox.rb
lib/widget_inputbox.rb
+239
-28
lib/window_chat.rb
lib/window_chat.rb
+6
-2
lib/window_gameselect.rb
lib/window_gameselect.rb
+1
-0
lib/window_host.rb
lib/window_host.rb
+12
-1
lib/window_lobbybuttons.rb
lib/window_lobbybuttons.rb
+4
-1
lib/window_login.rb
lib/window_login.rb
+22
-2
lib/ygocore/event.rb
lib/ygocore/event.rb
+20
-9
lib/ygocore/game.rb
lib/ygocore/game.rb
+5
-3
lib/ygocore/scene_lobby.rb
lib/ygocore/scene_lobby.rb
+2
-1
lib/ygocore/server.yml
lib/ygocore/server.yml
+4
-4
No files found.
lib/dialog.rb
0 → 100644
View file @
21f382e2
require
'win32api'
module
Dialog
#--------------------------------------------------------------------------
# ● 选择文件对话框
#--------------------------------------------------------------------------
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
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
=
[
76
,
# lStructSize L
0
,
# hwndOwner L
0
,
# hInstance L
szFilter
,
# lpstrFilter L
0
,
# lpstrCustomFilter L
0
,
# nMaxCustFilter L
1
,
# nFilterIndex L
szFile
,
# lpstrFile L
szFile
.
size
-
1
,
# nMaxFile L
szFileTitle
,
# lpstrFileTitle L
szFileTitle
.
size
-
1
,
# nMaxFileTitle L
szInitialDir
,
# lpstrInitialDir L
szTitle
,
# lpstrTitle L
OFN_FLAGS
,
# Flags L
0
,
# nFileOffset S
0
,
# nFileExtension S
0
,
# lpstrDefExt L
0
,
# lCustData L
0
,
# lpfnHook L
0
# lpTemplateName L
].
pack
(
"LLLPLLLPLPLPPLS2L4"
)
Dir
.
chdir
{
GetOpenFileName
.
call
(
ofn
)}
szFile
.
delete!
(
"
\0
"
.
encode
(
"UTF-16LE"
))
szFile
.
encode
(
"UTF-8"
)
end
end
\ No newline at end of file
lib/game_event.rb
View file @
21f382e2
...
...
@@ -138,8 +138,7 @@ class Game_Event
@title
=
title
@message
=
message
@fatal
=
fatal
p
@title
,
@title
.
encoding
,
@message
,
@message
.
encoding
,
caller
.
to_s
.
encoding
$log
.
error
(
@fatal
?
"致命错误"
:
"一般错误"
){
"
#{
@title
}
:
#{
@message
.
encode
(
"UTF-8"
)
}
#{
caller
}
"
}
$log
.
error
(
@fatal
?
"致命错误"
:
"一般错误"
){
"
#{
@title
}
:
#{
@message
}
#{
caller
}
"
}
end
end
class
Unknown
<
Error
...
...
lib/iduel/window_login.rb
View file @
21f382e2
...
...
@@ -16,8 +16,8 @@ class Window_Login
Launchy
.
open
(
Iduel
::
Register_Url
)
@last_clicked
=
Time
.
now
when
:replay
require
'tk
'
file
=
Tk
.
getOpenFile
.
encode
(
"UTF-8
"
)
require
_relative
'../dialog
'
file
=
Dialog
.
get_open_file
(
"播放战报"
,
"所有支持的战报 (*.txt;*.htm)"
=>
"*.txt;*.htm"
,
"iDuel的html的战报 (*.htm)"
=>
"*.htm"
,
"文本战报 (*.txt)"
=>
"*.txt
"
)
if
!
file
.
empty?
$game
=
Iduel
.
new
$game
.
user
=
User
.
new
(
0
)
...
...
lib/main.rb
View file @
21f382e2
...
...
@@ -38,6 +38,9 @@ begin
#初始化SDL
require
'sdl'
include
SDL
SDL
::
Event
::
APPMOUSEFOCUS
=
1
SDL
::
Event
::
APPINPUTFOCUS
=
2
SDL
::
Event
::
APPACTIVE
=
4
SDL
.
putenv
(
"SDL_VIDEO_CENTERED=1"
);
SDL
.
init
(
INIT_VIDEO
|
INIT_AUDIO
)
WM
::
set_caption
(
"MyCard"
,
"MyCard"
)
...
...
lib/ogginfo.rb
View file @
21f382e2
...
...
@@ -31,7 +31,7 @@
# see http://www.xiph.org/ogg/vorbis/docs.html for documentation on vorbis format
# http://www.xiph.org/ogg/vorbis/doc/v-comment.html
require
"iconv"
#
require "iconv"
# Raised on any kind of error related to ruby-ogginfo
class
OggInfoError
<
StandardError
;
end
...
...
lib/scene.rb
View file @
21f382e2
...
...
@@ -8,6 +8,7 @@ require_relative 'fpstimer'
require_relative
'game'
require_relative
'window_bgm'
require_relative
'ogginfo'
require_relative
'widget_inputbox'
class
Scene
attr_reader
:windows
attr_reader
:background
...
...
@@ -106,6 +107,9 @@ class Scene
when
5
@active_window
.
scroll_down
if
@active_window
end
if
!
@active_window
.
is_a?
Widget_InputBox
Widget_InputBox
.
focus
=
false
end
when
Event
::
MouseButtonUp
case
event
.
button
when
Mouse
::
BUTTON_LEFT
...
...
@@ -117,12 +121,16 @@ class Scene
when
Key
::
F12
$scene
=
Scene_Title
.
new
else
#$log.
debug
('unhandled event'){event.inspect}
#$log.
info
('unhandled event'){event.inspect}
end
when
Event
::
Quit
$scene
=
nil
when
Event
::
Active
if
(
event
.
state
&
Event
::
APPINPUTFOCUS
)
!=
0
Widget_InputBox
.
focus
=
event
.
gain
end
else
#$log.
debug
('unhandled event'){event.inspect}
#$log.
info
('unhandled event'){event.inspect}
end
end
def
handle_game
(
event
)
...
...
@@ -143,6 +151,7 @@ class Scene
# ● 结束处理
#--------------------------------------------------------------------------
def
terminate
self
.
windows
.
each
{
|
window
|
window
.
destroy
}
end
def
update_active_window
(
x
,
y
)
self
.
windows
.
reverse
.
each
do
|
window
|
...
...
lib/scene_lobby.rb
View file @
21f382e2
...
...
@@ -86,6 +86,8 @@ class Scene_Lobby < Scene
$scene
=
Scene_Duel
.
new
(
room
)
end
def
update
@chat_window
.
update
@host_window
.
update
if
@count
>=
600
$game
.
refresh
@count
=
0
...
...
lib/scene_login.rb
View file @
21f382e2
...
...
@@ -18,7 +18,6 @@ class Scene_Login < Scene
super
end
def
update
#@announcements_window.update
@gameselect_window
.
update
super
end
...
...
lib/widget_inputbox.rb
View file @
21f382e2
#输入法by夏娜
require
'dl'
require
'dl/import'
module
RM_IME
extend
DL
::
Importer
Dir
.
chdir
(
'ruby/bin'
){
dlload
'RMIME.dll'
}
extern
'void _init(long, int, int)'
extern
'void _update(int, int)'
extern
'void _dispose()'
extern
'void _get_text(char*)'
extern
'void _back(char*)'
module
RM_INPUT
extend
DL
::
Importer
dlload
'user32.dll'
extern
'int GetAsyncKeyState(int)'
extern
'long FindWindow(char*, char*)'
ENTER
=
0x0D
ESC
=
0x1B
TAB
=
0x09
UP
=
0x26
DOWN
=
0x28
LEFT
=
0x25
RIGHT
=
0x27
Key_Hash
=
{}
Key_Repeat
=
{}
module_function
#----------------------------------------------------------------------
# ● 按下判断
#----------------------------------------------------------------------
def
press?
(
rkey
)
return
GetAsyncKeyState
(
rkey
)
!=
0
end
#----------------------------------------------------------------------
# ● 重复按下判断
#----------------------------------------------------------------------
def
repeat?
(
rkey
)
result
=
GetAsyncKeyState
(
rkey
)
if
result
!=
0
if
Key_Repeat
[
rkey
].
nil?
Key_Repeat
[
rkey
]
=
0
return
true
end
Key_Repeat
[
rkey
]
+=
1
else
Key_Repeat
[
rkey
]
=
nil
Key_Hash
[
rkey
]
=
0
end
if
!
Key_Repeat
[
rkey
].
nil?
and
Key_Repeat
[
rkey
]
>
4
Key_Repeat
[
rkey
]
=
0
return
true
else
return
false
end
end
#----------------------------------------------------------------------
# ● 击键判断
#----------------------------------------------------------------------
def
trigger?
(
rkey
)
result
=
GetAsyncKeyState
(
rkey
)
if
Key_Hash
[
rkey
]
==
1
and
result
!=
0
return
false
end
if
result
!=
0
Key_Hash
[
rkey
]
=
1
return
true
else
Key_Hash
[
rkey
]
=
0
return
false
end
end
end
HWND
=
RM_INPUT
.
FindWindow
(
'SDL_app'
,
WM
.
caption
[
0
])
module_function
def
init
return
if
@active
_init
(
HWND
,
0
,
0
)
@x
=
0
@y
=
0
@active
=
true
$log
.
info
(
'输入法'
){
'开启'
}
end
def
set
(
x
,
y
)
@x
=
x
@y
=
y
end
def
text
buf
=
0
.
chr
*
1024
_get_text
(
buf
)
buf
.
force_encoding
(
"UTF-8"
)
buf
.
delete!
(
"
\0
"
)
end
def
update
_update
(
@x
,
@y
)
buf
=
[
0
,
0
].
pack
(
"LL"
)
_back
(
buf
)
buf
=
buf
.
unpack
(
"LL"
)
@backspace
=
buf
[
0
]
==
1
@delete
=
buf
[
1
]
==
1
end
def
dispose
return
if
!
@active
_dispose
$log
.
info
(
'输入法'
){
'关闭'
}
@active
=
false
end
def
active?
@active
end
def
backspace?
@backspace
end
def
delete?
@delete
end
def
left?
RM_INPUT
.
repeat?
(
RM_INPUT
::
LEFT
)
end
def
right?
RM_INPUT
.
repeat?
(
RM_INPUT
::
RIGHT
)
end
def
tab?
RM_INPUT
.
trigger?
(
RM_INPUT
::
TAB
)
end
def
enter?
RM_INPUT
.
trigger?
(
RM_INPUT
::
ENTER
)
end
def
esc?
RM_INPUT
.
trigger?
(
RM_INPUT
::
ESC
)
end
end
class
Widget_InputBox
<
Window
attr_reader
:value
,
:proc
attr_accessor
:type
require
'tk'
Root
=
TkRoot
.
new
{
withdraw
overrideredirect
true
attributes
:topmost
,
true
}
Entry
=
TkEntry
.
new
(
Root
){
font
TkFont
.
new
"family"
=>
'WenQuanYi Micro Hei'
,
"size"
=>
15
validate
:focusout
validatecommand
{
Widget_InputBox
.
determine
}
bind
(
'Key-Return'
){
self
.
value
=
""
if
@@active
.
proc
.
call
(
get
.
encode
(
"UTF-8"
))
if
@@active
.
proc
;
true
}
#两个if的解释:当存在proc时,call那个proc,如果执行结果为真就清空value
pack
}
Thread
.
new
{
Tk
.
mainloop
}
attr_reader
:value
attr_reader
:index
@@active
=
nil
@@cursor
=
nil
@@focus
=
true
def
initialize
(
x
,
y
,
width
,
height
,
z
=
300
,
&
proc
)
super
(
x
,
y
,
width
,
height
,
z
)
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
20
)
@proc
=
proc
@value
=
""
@type
=
:text
@index
=
0
@count
=
0
@char_pos
=
[
2
]
end
def
value
=
(
value
)
return
if
@value
==
value
@value
=
value
@char_pos
.
replace
[
2
]
@value
.
each_char
do
|
char
|
@char_pos
<<
@char_pos
.
last
+
@font
.
text_size
(
@type
==
:password
?
'*'
:
char
)[
0
]
end
if
@index
>
value
.
size
self
.
index
=
value
.
size
end
refresh
end
def
index
=
(
index
)
if
index
>
@value
.
size
index
=
@value
.
size
elsif
index
<
0
index
=
0
end
return
if
@index
==
index
@index
=
index
@count
=
0
@@cursor
.
visible
=
true
@@cursor
.
x
=
@x
+
@char_pos
[
@index
]
RM_IME
.
set
(
@@cursor
.
x
,
@@cursor
.
y
)
end
def
refresh
clear
@font
.
draw_blended_utf8
(
@contents
,
@type
==
:password
?
'*'
*
@value
.
size
:
@value
,
2
,
0
,
0x00
,
0x00
,
0x00
)
unless
@value
.
empty?
end
def
clicked
Entry
.
value
=
@value
Entry
.
show
@type
==
:password
?
'*'
:
nil
Entry
.
focus
:force
Entry
.
width
@width
Root
.
geometry
"
#{
@width
}
x
#{
@height
}
+
#{
@x
+
TkWinfo
.
pointerx
(
Root
)
-
Mouse
.
state
[
0
]
}
+
#{
@y
+
TkWinfo
.
pointery
(
Root
)
-
Mouse
.
state
[
1
]
}
"
#根据鼠标位置来确定游戏窗口的相对位置,点击的瞬间鼠标移动了的话会有误差
Root
.
deiconify
@@active
=
self
#TODO:存在线程安全问题
RM_IME
.
init
@@active
=
self
@@focus
=
true
unless
@@cursor
and
!
@@cursor
.
destroyed?
@@cursor
=
Window
.
new
(
0
,
0
,
2
,
@height
-
4
,
301
)
@@cursor
.
contents
.
fill_rect
(
0
,
0
,
@@cursor
.
width
,
@@cursor
.
height
,
0xFF000000
)
end
@@cursor
.
y
=
@y
+
2
mouse_x
=
Mouse
.
state
[
0
]
-
@x
@index
=
nil
#强制重置
if
mouse_x
<
0
or
@value
.
empty?
self
.
index
=
0
else
@char_pos
.
each_with_index
do
|
x
,
index
|
if
x
>
mouse_x
return
self
.
index
=
index
-
1
end
end
self
.
index
=
@value
.
size
end
end
def
clear
(
x
=
0
,
y
=
0
,
width
=
@width
,
height
=
@height
)
@contents
.
fill_rect
(
x
,
y
,
width
,
height
,
0x110000FF
)
@contents
.
fill_rect
(
x
+
2
,
y
+
2
,
width
-
4
,
height
-
4
,
0xFFFFFFFF
)
end
def
update
#puts "UPDATE:" + self.to_s
return
unless
self
==
@@active
and
@@focus
if
@count
>=
40
@count
=
0
@@cursor
.
visible
=
!
@@cursor
.
visible
else
@count
+=
1
end
RM_IME
.
update
new_value
=
self
.
value
.
dup
new_index
=
self
.
index
text
=
RM_IME
.
text
if
!
text
.
empty?
new_value
.
insert
(
@index
,
text
)
new_index
+=
text
.
size
end
if
RM_IME
.
backspace?
and
@index
>
0
new_value
.
slice!
(
@index
-
1
,
1
)
new_index
-=
1
end
if
RM_IME
.
delete?
and
@index
<
@value
.
size
new_value
.
slice!
(
@index
,
1
)
end
if
RM_IME
.
left?
new_index
-=
1
end
if
RM_IME
.
right?
new_index
+=
1
end
self
.
value
=
new_value
self
.
index
=
new_index
if
@proc
if
RM_IME
.
esc?
self
.
value
=
''
if
@proc
.
call
:ESC
end
if
RM_IME
.
tab?
self
.
value
=
''
if
@proc
.
call
:TAB
end
if
RM_IME
.
enter?
self
.
value
=
''
if
@proc
.
call
:ENTER
end
end
end
def
self
.
determine
@@active
.
value
=
Entry
.
get
.
encode
(
"UTF-8"
);
Root
.
withdraw
(
true
);
@@active
.
refresh
;
true
def
destroy
if
@@active
==
self
Widget_InputBox
.
focus
=
false
end
super
end
end
def
self
.
focus
=
(
focus
)
@@focus
=
focus
if
!
@@focus
RM_IME
.
dispose
@@cursor
.
destroy
if
@@cursor
end
end
end
\ No newline at end of file
lib/window_chat.rb
View file @
21f382e2
...
...
@@ -21,11 +21,12 @@ class Window_Chat < Window_Scrollable
@background
.
fill_rect
(
0
,
0
,
@background
.
w
,
@background
.
h
,
0xFFb2cefe
)
@background
.
put
(
@chat_background
,
0
,
31
-
4
)
@tab
=
Surface
.
load
"graphics/system/tab.png"
@chat_input
=
Widget_InputBox
.
new
(
@x
+
8
,
@y
+
@height
-
24
-
10
,
@width
-
14
,
24
)
do
|
message
|
chatmessage
=
ChatMessage
.
new
(
$game
.
user
,
messag
e
,
@channel
)
@chat_input
=
Widget_InputBox
.
new
(
@x
+
8
,
@y
+
@height
-
24
-
10
,
@width
-
14
,
24
)
do
|
key
|
chatmessage
=
ChatMessage
.
new
(
$game
.
user
,
@chat_input
.
valu
e
,
@channel
)
$game
.
chat
chatmessage
Game_Event
.
push
Game_Event
::
Chat
.
new
(
chatmessage
)
end
@chat_input
.
refresh
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
14
)
@scrollbar
=
Widget_ScrollBar
.
new
(
self
,
@x
+
@width
-
20
-
8
,
@y
+
31
+
3
,
@height
-
68
)
@page_size
=
(
@height
-
68
)
/
WLH
...
...
@@ -160,4 +161,7 @@ class Window_Chat < Window_Scrollable
def
scroll_down
self
.
scroll
+=
1
end
def
update
@chat_input
.
update
end
end
\ No newline at end of file
lib/window_gameselect.rb
View file @
21f382e2
...
...
@@ -66,6 +66,7 @@ class Window_GameSelect < Window_List
refresh
end
def
update
@login_window
.
update
if
@login_window
@announcements_window
.
update
if
@announcements_window
end
#def lostfocus
...
...
lib/window_host.rb
View file @
21f382e2
...
...
@@ -9,7 +9,15 @@ class Window_Host < Window
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
16
)
@title_color
=
[
0xFF
,
0xFF
,
0xFF
]
@color
=
[
0x04
,
0x47
,
0x7c
]
@roomname_inputbox
=
Widget_InputBox
.
new
(
@x
+
96
,
@y
+
41
,
165
,
WLH
){
clicked
;
false
}
@roomname_inputbox
=
Widget_InputBox
.
new
(
@x
+
96
,
@y
+
41
,
165
,
WLH
)
do
|
key
|
case
key
when
:ENTER
clicked
false
when
:ESC
true
end
end
default_name
=
$game
.
user
.
name
1
.
upto
(
1000
)
do
|
i
|
if
$game
.
rooms
.
all?
{
|
room
|
room
.
name
!=
i
.
to_s
}
...
...
@@ -72,4 +80,7 @@ class Window_Host < Window
@match
.
destroy
super
end
def
update
@roomname_inputbox
.
update
end
end
\ No newline at end of file
lib/window_lobbybuttons.rb
View file @
21f382e2
...
...
@@ -18,6 +18,9 @@ class Window_LobbyButtons < Window_List
self
.
index
=
nil
end
def
clicked
Window_Host
.
new
(
300
,
200
)
@host_window
=
Window_Host
.
new
(
300
,
200
)
end
def
update
@host_window
.
update
if
@host_window
and
!
@host_window
.
destroyed?
end
end
lib/window_login.rb
View file @
21f382e2
...
...
@@ -7,9 +7,29 @@ class Window_Login < Window
@password
=
password
@button
=
Surface
.
load
(
"graphics/login/button.png"
)
super
(
x
,
y
,
597
,
338
)
@username_inputbox
=
Widget_InputBox
.
new
(
@x
+
192
,
@y
+
80
,
165
,
WLH
){
|
text
|
@username_inputbox
.
value
=
text
;
@password_inputbox
.
clicked
;
false
}
@username_inputbox
=
Widget_InputBox
.
new
(
@x
+
192
,
@y
+
80
,
165
,
WLH
)
do
|
key
|
case
key
when
:TAB
,
:ENTER
@password_inputbox
.
clicked
false
when
:ESC
true
end
end
@username
&&
!
@username
.
empty?
?
@username_inputbox
.
value
=
@username
:
@username_inputbox
.
refresh
@password_inputbox
=
Widget_InputBox
.
new
(
@x
+
192
,
@y
+
125
,
165
,
WLH
){
|
text
|
Widget_InputBox
.
determine
;
self
.
index
=
:login
;
clicked
;
false
}
@password_inputbox
=
Widget_InputBox
.
new
(
@x
+
192
,
@y
+
125
,
165
,
WLH
)
do
|
key
|
case
key
when
:TAB
self
.
index
=
:login
false
when
:ENTER
self
.
index
=
:login
self
.
clicked
false
when
:ESC
true
end
end
@password_inputbox
.
type
=
:password
@password
&&
!
@password
.
empty?
?
@password_inputbox
.
value
=
@password
:
@password_inputbox
.
refresh
@color
=
[
255
,
255
,
255
]
...
...
lib/ygocore/event.rb
View file @
21f382e2
class
Game_Event
User_Filter
=
/\[(\d+),
<font color="(?:blue|gray)">(.+?)(\(未认证\)|)<\/font>
\]/
Room_Filter
=
/\[(\d+),(.+?),(wait|start)
#{
User_Filter
}
+?
\]/
User_Filter
=
/\[(\d+),
(.+?)
\]/
Room_Filter
=
/\[(\d+),(.+?),(wait|start)
(
#{
User_Filter
}
+?)
\]/
#User_Filter = /<li>(:::观战:|===决斗1=|===决斗2=)<font color="(?:blue|gray)">(.+?)(\(未认证\)|)<\/font>;<\/li>/
#Room_Filter = /<div style="width:300px; height:150px; border:1px #ececec solid; float:left;padding:5px; margin:5px;">房间名称:(.+?)(<font color="d28311" title="竞技场模式">\[竞\]<\/font>|) (<font color=(?:\")?red(?:\")?>决斗已开始!<\/font>|<font color=(?:\")?blue(?:\")?>等待<\/font>)<font size="1">\(ID:(\d+)\)<\/font>#{User_Filter}+?<\/div>/
class
AllRooms
<
Game_Event
def
self
.
parse
(
info
)
@rooms
=
[]
info
.
scan
(
Room_Filter
)
do
|
id
,
name
,
status
|
info
.
scan
(
Room_Filter
)
do
|
id
,
name
,
status
,
users
|
#p id, name, status, users, '------------'
player1
=
player2
=
nil
$&
.
scan
(
User_Filter
)
do
|
player
,
name
,
certified
|
users
.
scan
(
User_Filter
)
do
|
player
,
name
|
if
name
=~
/^<font color="(?:blue|gray)">(.+?)<\/font>$/
name
=
$1
end
if
name
=~
/^(.+?)\(未认证\)$/
name
=
$1
certified
=
false
else
certified
=
true
end
if
player
[
"1"
]
player1
=
User
.
new
(
name
.
to_sym
,
name
,
certified
.
empty?
)
player1
=
User
.
new
(
name
.
to_sym
,
name
,
certified
)
elsif
player
[
"2"
]
player2
=
User
.
new
(
name
.
to_sym
,
name
,
certified
.
empty?
)
player2
=
User
.
new
(
name
.
to_sym
,
name
,
certified
)
end
end
room
=
Room
.
new
(
id
.
to_i
,
name
,
player1
,
player2
,
false
,
[
0
,
0
,
0
])
room
.
status
=
status
.
to_sym
room
.
name
=~
/^(P)?(M)?\#?(.*)$/
room
.
name
=~
/^(P)?(M)?\#?(.*)
(?:<font color="d28311" title="竞技场模式">[竞]<\/font>)?
$/
room
.
name
=
$3
room
.
pvp
=
!!
$1
room
.
match
=
!!
$2
...
...
@@ -33,8 +43,9 @@ class Game_Event
class
AllUsers
<
Game_Event
def
self
.
parse
(
info
)
@users
=
[]
info
.
scan
(
User_Filter
)
do
|
player
,
name
,
certified
|
@users
<<
User
.
new
(
name
.
to_sym
,
name
,
certified
.
empty?
)
$game
.
rooms
.
each
do
|
room
|
@users
<<
room
.
player1
if
room
.
player1
@users
<<
room
.
player2
if
room
.
player2
end
self
.
new
@users
end
...
...
lib/ygocore/game.rb
View file @
21f382e2
...
...
@@ -76,13 +76,15 @@ class Ygocore < Game
end
end
def
refresh
$log
.
info
(
'刷新大厅信息'
){
'开始'
}
Thread
.
new
do
begin
open
(
"
#{
@@config
[
'api'
]
}
?operation=getroom"
)
do
|
file
|
file
.
set_encoding
(
"GBK"
)
info
=
file
.
read
.
encode
(
"UTF-8"
)
Game_Event
.
push
Game_Event
::
AllUsers
.
parse
info
$log
.
info
(
'刷新大厅信息'
){
'完成'
}
Game_Event
.
push
Game_Event
::
AllRooms
.
parse
info
Game_Event
.
push
Game_Event
::
AllUsers
.
parse
info
yield
if
block_given?
end
end
...
...
@@ -93,8 +95,8 @@ class Ygocore < Game
return
if
@last_clicked
and
Time
.
now
-
@last_clicked
<
3
#防止重复点击
msgbox
=
Widget_Msgbox
.
new
(
"加入房间"
,
"请指定ygocore主程序位置"
)
$scene
.
draw
require
'tk
'
$config
[
'ygocore'
][
'path'
]
=
Tk
.
getOpenFile
.
encode
(
"UTF-8
"
)
require
_relative
'../dialog
'
$config
[
'ygocore'
][
'path'
]
=
Dialog
.
get_open_file
(
"请指定ygocore主程序位置"
,
"ygocore主程序 (gframe.exe)"
=>
"gframe.exe
"
)
save_config
msgbox
.
destroy
@last_clicked
=
Time
.
now
...
...
lib/ygocore/scene_lobby.rb
View file @
21f382e2
...
...
@@ -11,7 +11,8 @@ class Scene_Lobby
GMEM_DDESHARE
=
0x2000
;
def
join
(
room
)
path
=
$game
.
ygocore_path
return
Widget_Msgbox
.
destroy
unless
path
Widget_Msgbox
.
new
(
"加入房间"
,
"正在启动ygocore"
)
room_name
=
if
room
.
pvp?
and
room
.
match?
"PM#"
+
room
.
name
elsif
room
.
pvp?
...
...
lib/ygocore/server.yml
View file @
21f382e2
register
:
http://
sh.convnet.net:7955/regist.html
api
:
http://
sh.convnet.net
:7922/
index
:
http://
sh.convnet.net:7922
/
server
:
221.226.68.62
register
:
http://
card.touhou.cc/register
api
:
http://
140.113.242.66
:7922/
index
:
http://
card.touhou.cc
/
server
:
140.113.242.66
port
:
7911
\ No newline at end of file
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