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
68841d6b
Commit
68841d6b
authored
Jun 06, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
卡组编辑强化 增加导出OS格式卡组
parent
36a6f898
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
408 additions
and
222 deletions
+408
-222
graphics/system/deck_buttons.png
graphics/system/deck_buttons.png
+0
-0
lib/dialog.rb
lib/dialog.rb
+73
-55
lib/game.rb
lib/game.rb
+44
-42
lib/window.rb
lib/window.rb
+92
-92
lib/window_deck.rb
lib/window_deck.rb
+199
-0
lib/ygocore/game.rb
lib/ygocore/game.rb
+0
-33
No files found.
graphics/system/deck_buttons.png
0 → 100644
View file @
68841d6b
This diff was suppressed by a .gitattributes entry.
lib/dialog.rb
View file @
68841d6b
module
Dialog
#选择文件对话框
require
'win32api'
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
#打开网页
require
'win32ole'
Shell
=
WIN32OLE
.
new
(
'Shell.Application'
)
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"
)
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
def
web
(
url
)
Shell
.
ShellExecute
url
end
def
uac
(
command
,
*
args
)
Shell
.
ShellExecute
File
.
expand_path
(
command
),
args
.
join
(
' '
),
Dir
.
pwd
,
"runas"
end
module
Dialog
#选择文件对话框
require
'win32api'
GetOpenFileName
=
Win32API
.
new
(
"comdlg32.dll"
,
"GetOpenFileNameW"
,
"p"
,
"i"
)
GetSaveFileName
=
Win32API
.
new
(
"comdlg32.dll"
,
"GetSaveFileNameW"
,
"p"
,
"i"
)
OFN_EXPLORER
=
0x00080000
OFN_PATHMUSTEXIST
=
0x00000800
OFN_FILEMUSTEXIST
=
0x00001000
OFN_ALLOWMULTISELECT
=
0x00000200
OFN_FLAGS
=
OFN_EXPLORER
|
OFN_PATHMUSTEXIST
|
OFN_FILEMUSTEXIST
|
OFN_ALLOWMULTISELECT
#打开网页
require
'win32ole'
Shell
=
WIN32OLE
.
new
(
'Shell.Application'
)
module_function
def
get_open_file
(
title
=
"选择文件"
,
filter
=
{
"所有文件 (*.*)"
=>
"*.*"
},
save
=
nil
)
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"
)
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
{
if
save
GetSaveFileName
.
call
(
ofn
)
else
GetOpenFileName
.
call
(
ofn
)
end
}
szFile
.
delete!
(
"
\0
"
.
encode
(
"UTF-16LE"
))
result
=
szFile
.
encode
(
"UTF-8"
)
if
!
result
.
empty?
and
save
.
is_a?
Array
ext
=
save
[
ofn
.
unpack
(
"LLLPLLLPLPLPPLS2L4"
)[
6
]
-
1
]
if
result
[
-
ext
.
size
,
ext
.
size
].
downcase
!=
ext
.
downcase
result
<<
ext
end
end
result
end
def
web
(
url
)
Shell
.
ShellExecute
url
end
def
uac
(
command
,
*
args
)
Shell
.
ShellExecute
File
.
expand_path
(
command
),
args
.
join
(
' '
),
Dir
.
pwd
,
"runas"
end
end
\ No newline at end of file
lib/game.rb
View file @
68841d6b
#游戏适配器的抽象类
require_relative
'game_event'
require_relative
'action'
require_relative
'user'
require_relative
'room'
class
Game
attr_reader
:users
,
:rooms
attr_accessor
:user
,
:room
,
:player_field
,
:opponent_field
,
:turn
,
:turn_player
,
:phase
def
initialize
@users
=
[]
@rooms
=
[]
end
def
login
(
username
,
password
=
nil
)
end
def
refresh
end
def
host
(
room_name
,
room_config
)
end
def
join
(
room
)
end
def
watch
(
room
)
end
def
leave
end
def
action
(
action
)
end
def
chat
(
chatmessage
)
end
def
exit
$scene
=
Scene_Login
.
new
if
$scene
end
def
watching?
@room
and
@room
.
include?
@user
end
def
self
.
deck_edit
end
def
refresh_interval
5
end
end
#游戏适配器的抽象类
require_relative
'game_event'
require_relative
'action'
require_relative
'user'
require_relative
'room'
class
Game
attr_reader
:users
,
:rooms
attr_accessor
:user
,
:room
,
:player_field
,
:opponent_field
,
:turn
,
:turn_player
,
:phase
def
initialize
@users
=
[]
@rooms
=
[]
end
def
login
(
username
,
password
=
nil
)
end
def
refresh
end
def
host
(
room_name
,
room_config
)
end
def
join
(
room
)
end
def
watch
(
room
)
end
def
leave
end
def
action
(
action
)
end
def
chat
(
chatmessage
)
end
def
exit
$scene
=
Scene_Login
.
new
if
$scene
end
def
watching?
@room
and
@room
.
include?
@user
end
def
self
.
deck_edit
require_relative
'window_deck'
@deck_window
=
Window_Deck
.
new
end
def
refresh_interval
5
end
end
lib/window.rb
View file @
68841d6b
class
Window
WLH
=
24
attr_accessor
:x
,
:y
,
:width
,
:height
,
:z
,
:contents
,
:visible
,
:viewport
,
:background
alias
visible?
visible
def
initialize
(
x
,
y
,
width
,
height
,
z
=
200
)
@x
=
x
@y
=
y
@z
=
z
@width
=
width
@height
=
height
@visible
=
true
#@angle = 0
@viewport
=
[
0
,
0
,
@width
,
@height
]
@destroyed
=
false
amask
=
0xff000000
rmask
=
0x00ff0000
gmask
=
0x0000ff00
bmask
=
0x000000ff
#@background ||= Surface.new(SWSURFACE, @width, @height, 32, rmask, gmask, bmask, amask)
@contents
||=
Surface
.
new
(
SWSURFACE
,
@width
,
@height
,
32
,
rmask
,
gmask
,
bmask
,
amask
)
#按Z坐标插入
unless
$scene
.
windows
.
each_with_index
do
|
window
,
index
|
if
window
.
z
>
@z
$scene
.
windows
.
insert
(
index
,
self
)
break
true
end
end
==
true
$scene
.
windows
<<
self
end
end
def
draw_stroked_text
(
text
,
x
,
y
,
size
=
1
,
font
=
@font
,
color
=
@color
,
color_stroke
=
@color_stroke
)
[[
x
-
size
,
y
-
size
],
[
x
-
size
,
y
],
[
x
-
size
,
y
+
size
],
[
x
,
y
-
size
],
[
x
,
y
+
size
],
[
x
+
size
,
y
-
size
],
[
x
+
size
,
y
],
[
x
+
size
,
y
+
size
],
].
each
{
|
pos
|
font
.
draw_blended_utf8
(
@contents
,
text
,
pos
[
0
],
pos
[
1
],
*
color
)}
font
.
draw_blended_utf8
(
@contents
,
text
,
x
,
y
,
*
color_stroke
)
end
def
include?
(
x
,
y
)
x
>=
@x
&&
x
<
@x
+
@width
&&
y
>=
@y
&&
y
<
@y
+
@height
end
def
destroy
@destroyed
=
true
@contents
.
destroy
if
@contents
$scene
.
windows
.
delete
self
if
$scene
end
def
destroyed?
@destroyed
end
def
draw
(
screen
)
return
unless
self
.
contents
&&
self
.
visible?
&&
!
self
.
destroyed?
Surface
.
blit
(
self
.
contents
,
*
self
.
viewport
,
screen
,
self
.
x
,
self
.
y
)
end
def
clear
(
x
=
0
,
y
=
0
,
width
=
@width
,
height
=
@height
)
if
@background
Surface
.
blit
(
@background
,
x
,
y
,
width
,
height
,
@contents
,
x
,
y
)
elsif
$scene
and
$scene
.
background
Surface
.
blit
(
$scene
.
background
,
@x
+
x
,
@y
+
y
,
width
,
height
,
@contents
,
x
,
y
)
else
@contents
.
fill_rect
(
x
,
y
,
width
,
height
,
0xFF000000
)
end
end
def
update
#子类定义
end
def
refresh
#子类定义
end
def
mousemoved
(
x
,
y
)
#子类定义
end
def
clicked
#子类定义
end
def
mouseleftbuttonup
#子类定义
end
def
lostfocus
(
active_window
=
nil
)
#子类定义
end
def
cursor_up
(
wrap
=
false
)
#子类定义
end
def
cursor_down
(
wrap
=
false
)
#子类定义
end
def
scroll_up
cursor_up
end
def
scroll_down
cursor_down
end
class
Window
WLH
=
24
attr_accessor
:x
,
:y
,
:width
,
:height
,
:z
,
:contents
,
:visible
,
:viewport
,
:background
alias
visible?
visible
def
initialize
(
x
,
y
,
width
,
height
,
z
=
200
)
@x
=
x
@y
=
y
@z
=
z
@width
=
width
@height
=
height
@visible
=
true
#@angle = 0
@viewport
=
[
0
,
0
,
@width
,
@height
]
@destroyed
=
false
amask
=
0xff000000
rmask
=
0x00ff0000
gmask
=
0x0000ff00
bmask
=
0x000000ff
#@background ||= Surface.new(SWSURFACE, @width, @height, 32, rmask, gmask, bmask, amask)
@contents
||=
Surface
.
new
(
SWSURFACE
,
@width
,
@height
,
32
,
rmask
,
gmask
,
bmask
,
amask
)
#按Z坐标插入
unless
$scene
.
windows
.
each_with_index
do
|
window
,
index
|
if
window
.
z
>
@z
$scene
.
windows
.
insert
(
index
,
self
)
break
true
end
end
==
true
$scene
.
windows
<<
self
end
end
def
draw_stroked_text
(
text
,
x
,
y
,
size
=
1
,
font
=
@font
,
color
=
@color
,
color_stroke
=
@color_stroke
)
[[
x
-
size
,
y
-
size
],
[
x
-
size
,
y
],
[
x
-
size
,
y
+
size
],
[
x
,
y
-
size
],
[
x
,
y
+
size
],
[
x
+
size
,
y
-
size
],
[
x
+
size
,
y
],
[
x
+
size
,
y
+
size
],
].
each
{
|
pos
|
font
.
draw_blended_utf8
(
@contents
,
text
,
pos
[
0
],
pos
[
1
],
*
color
)}
font
.
draw_blended_utf8
(
@contents
,
text
,
x
,
y
,
*
color_stroke
)
end
def
include?
(
x
,
y
)
x
>=
@x
&&
x
<
@x
+
@width
&&
y
>=
@y
&&
y
<
@y
+
@height
end
def
destroy
@destroyed
=
true
@contents
.
destroy
if
@contents
$scene
.
windows
.
delete
self
if
$scene
end
def
destroyed?
@destroyed
end
def
draw
(
screen
)
return
unless
self
.
contents
&&
self
.
visible?
&&
!
self
.
destroyed?
Surface
.
blit
(
self
.
contents
,
*
self
.
viewport
,
screen
,
self
.
x
,
self
.
y
)
end
def
clear
(
x
=
0
,
y
=
0
,
width
=
@width
,
height
=
@height
)
if
@background
Surface
.
blit
(
@background
,
x
,
y
,
width
,
height
,
@contents
,
x
,
y
)
elsif
$scene
and
$scene
.
background
Surface
.
blit
(
$scene
.
background
,
@x
+
x
,
@y
+
y
,
width
,
height
,
@contents
,
x
,
y
)
else
@contents
.
fill_rect
(
x
,
y
,
width
,
height
,
0xFF000000
)
end
end
def
update
#子类定义
end
def
refresh
#子类定义
end
def
mousemoved
(
x
,
y
)
#子类定义
end
def
clicked
#子类定义
end
def
mouseleftbuttonup
#子类定义
end
def
lostfocus
(
active_window
=
nil
)
#子类定义
end
def
cursor_up
(
wrap
=
false
)
#子类定义
end
def
cursor_down
(
wrap
=
false
)
#子类定义
end
def
scroll_up
cursor_up
end
def
scroll_down
cursor_down
end
end
\ No newline at end of file
lib/window_deck.rb
0 → 100644
View file @
68841d6b
class
Window_Deck
<
Window
attr_reader
:index
def
initialize
@items
=
Dir
.
glob
(
"ygocore/deck/*.ydk"
)[
0
,
10
]
@background
=
Surface
.
load
(
@items
.
size
>
4
?
'graphics/lobby/host.png'
:
'graphics/system/msgbox.png'
).
display_format
super
((
1024
-
@background
.
w
)
/
2
,
230
,
@background
.
w
,
@background
.
h
,
300
)
@items_button
=
Surface
.
load
(
"graphics/system/deck_buttons.png"
)
@items_buttons
=
{
edit:
"编辑"
,
delete:
"删除"
,
export:
"导出"
}
button_y
=
@height
-
36
@button
=
Surface
.
load
(
"graphics/system/button.png"
)
@buttons
=
{
import:
"导入"
,
edit:
"编辑"
,
close:
"关闭"
}
space
=
(
@width
-
@buttons
.
size
*
@button
.
w
/
3
)
/
(
@buttons
.
size
+
1
)
@buttons_pos
=
{}
@buttons
.
each_with_index
do
|
button
,
index
|
@buttons_pos
[
button
[
0
]]
=
[(
space
+
@button
.
w
/
3
)
*
index
+
space
,
button_y
,
@button
.
w
/
3
,
@button
.
h
]
end
@font
=
TTF
.
open
(
"fonts/wqy-microhei.ttc"
,
16
)
@title_color
=
[
0xFF
,
0xFF
,
0xFF
]
@color
=
[
0x04
,
0x47
,
0x7c
]
refresh
end
def
refresh
clear
@font
.
draw_blended_utf8
(
@contents
,
"卡组编辑"
,
(
@width
-
@font
.
text_size
(
"卡组编辑"
)[
0
])
/
2
,
2
,
*
@title_color
)
@items
=
Dir
.
glob
(
"ygocore/deck/*.ydk"
)[
0
,
10
]
@background
=
Surface
.
load
(
@items
.
size
>
4
?
'graphics/lobby/host.png'
:
'graphics/system/msgbox.png'
).
display_format
@height
=
@background
.
h
@items
.
each_with_index
do
|
deck
,
index
|
@font
.
draw_blended_utf8
(
@contents
,
File
.
basename
(
deck
,
".ydk"
),
16
,
28
+
WLH
*
index
,
*
@color
)
end
@items
.
size
.
times
do
|
index
|
@items_buttons
.
each_key
do
|
key
|
draw_item
([
index
,
key
],
self
.
index
==
[
index
,
key
]
?
1
:
0
)
end
end
@buttons
.
each_key
do
|
index
|
draw_item
(
index
,
self
.
index
==
index
?
1
:
0
)
end
end
def
draw_item
(
index
,
status
=
0
)
x
,
y
=
item_rect
(
index
)
if
index
.
is_a?
Array
Surface
.
blit
(
@items_button
,
status
*
@items_button
.
w
/
3
,
@items_buttons
.
keys
.
index
(
index
[
1
])
*
@items_button
.
h
/
3
,
@items_button
.
w
/
3
,
@items_button
.
h
/
3
,
@contents
,
x
,
y
)
else
Surface
.
blit
(
@button
,
@button
.
w
/
3
*
status
,
0
,
@button
.
w
/
3
,
@button
.
h
,
@contents
,
x
,
y
)
text_size
=
@font
.
text_size
(
@buttons
[
index
])
@font
.
draw_blended_utf8
(
@contents
,
@buttons
[
index
],
x
+
(
@button
.
w
/
3
-
text_size
[
0
])
/
2
,
y
+
(
@button
.
h
-
text_size
[
1
])
/
2
,
0xFF
,
0xFF
,
0xFF
)
end
end
def
mousemoved
(
x
,
y
)
new_index
=
nil
line
=
(
y
-
@y
-
28
)
/
WLH
if
line
.
between?
(
0
,
@items
.
size
-
1
)
i
=
(
x
-
@x
-
(
@width
-
@items_buttons
.
size
*
@items_button
.
w
/
3
))
/
(
@items_button
.
w
/
3
)
if
i
>=
0
new_index
=
[
line
,
@items_buttons
.
keys
[
i
]]
end
else
@buttons_pos
.
each_key
do
|
index
|
if
(
x
-
@x
).
between?
(
@buttons_pos
[
index
][
0
],
@buttons_pos
[
index
][
0
]
+
@buttons_pos
[
index
][
2
])
and
(
y
-
@y
).
between?
(
@buttons_pos
[
index
][
1
],
@buttons_pos
[
index
][
1
]
+
@buttons_pos
[
index
][
3
])
new_index
=
index
break
end
end
end
self
.
index
=
new_index
end
def
item_rect
(
index
)
if
index
.
is_a?
Array
[
@width
-
(
@items_button
.
w
/
3
)
*
(
@items_buttons
.
keys
.
reverse
.
index
(
index
[
1
])
+
1
),
28
+
WLH
*
index
[
0
],
@items_button
.
w
/
3
,
@items_button
.
h
/
3
]
else
@buttons_pos
[
index
]
end
end
def
index
=
(
index
)
return
if
index
==
@index
if
@index
clear
(
*
item_rect
(
@index
))
draw_item
(
@index
,
0
)
end
@index
=
index
if
@index
clear
(
*
item_rect
(
@index
))
draw_item
(
@index
,
1
)
end
end
def
clicked
case
self
.
index
when
:import
import
refresh
when
:edit
Ygocore
.
run_ygocore
(
:deck
)
when
:close
destroy
when
Array
case
index
[
1
]
when
:edit
Ygocore
.
run_ygocore
(
@items
[
index
[
0
]])
when
:delete
require_relative
'widget_msgbox'
Widget_Msgbox
.
new
(
"删除卡组"
,
"确定要删除卡组
#{
File
.
basename
(
@items
[
index
[
0
]],
'.ydk'
)
}
吗"
,
buttons
=
{
ok:
"确定"
,
cancel:
"取消"
})
do
|
clicked
|
if
clicked
==
:ok
File
.
delete
@items
[
index
[
0
]]
refresh
end
end
when
:export
export
end
end
end
def
import
file
=
Dialog
.
get_open_file
(
"导入卡组"
,
"所有支持的卡组 (*.ydk;*.txt;*.deck)"
=>
"*.ydk;*.txt;*.deck"
,
"ygocore卡组 (*.ydk)"
=>
"*.ydk"
,
"OcgSoft卡组 (*.txt;*.deck)"
=>
"*.txt;*.deck"
)
if
!
file
.
empty?
#fix for stdlib File.extname
file
=~
/(\.deck|\.txt|\.ydk)$/i
extname
=
$1
Dir
.
mkdir
"ygocore/deck"
unless
File
.
directory?
(
"ygocore/deck"
)
open
(
"ygocore/deck/
#{
File
.
basename
(
file
,
extname
)
+
".ydk"
}
"
,
'w'
)
do
|
dest
|
if
file
=~
/(\.deck|\.txt)$/i
deck
=
Deck
.
load
(
file
)
dest
.
puts
(
"#main"
)
deck
.
main
.
each
{
|
card
|
dest
.
puts
card
.
number
}
dest
.
puts
(
"#extra"
)
deck
.
extra
.
each
{
|
card
|
dest
.
puts
card
.
number
}
dest
.
puts
(
"!side"
)
deck
.
side
.
each
{
|
card
|
dest
.
puts
card
.
number
}
else
open
(
file
)
do
|
src
|
dest
.
write
src
.
read
end
end
end
rescue
(
$log
.
error
(
$!
.
inspect
)
{
$!
.
backtrace
.
inspect
};
Widget_Msgbox
.
new
(
"导入卡组"
,
"导入卡组失败"
,
:ok
=>
"确定"
))
end
end
def
export
require_relative
'dialog'
file
=
Dialog
.
get_open_file
(
"导出卡组"
,
{
"ygocore卡组 (*.ydk)"
=>
"*.ydk"
,
"OcgSoft卡组 (*.txt)"
=>
"*.txt"
},
[
".ydk"
,
".txt"
])
if
!
file
.
empty?
@items
[
index
[
0
]]
open
(
@items
[
index
[
0
]])
do
|
src
|
if
file
=~
/.txt$/i
main
=
[]
extra
=
[]
side
=
[]
now_side
=
false
src
.
readlines
.
each
do
|
line
|
line
.
chomp!
if
line
[
0
,
1
]
==
"#"
next
elsif
line
[
0
,
5
]
==
"!side"
now_side
=
true
else
card
=
Card
.
find
(
"number = '
#{
line
.
rjust
(
8
,
'0'
)
}
'"
)[
0
]
next
if
card
.
nil?
if
now_side
side
<<
card
elsif
card
.
extra?
extra
<<
card
else
main
<<
card
end
end
end
open
(
file
,
'w:GBK'
)
do
|
dest
|
main
.
each
{
|
card
|
dest
.
puts
"[
#{
card
.
name
}
]##"
}
dest
.
puts
"####"
side
.
each
{
|
card
|
dest
.
puts
"[
#{
card
.
name
}
]##"
}
dest
.
puts
"===="
extra
.
each
{
|
card
|
dest
.
puts
"[
#{
card
.
name
}
]##"
}
end
else
open
(
file
,
'w'
)
do
|
dest
|
dest
.
write
src
.
read
end
end
end
end
end
end
\ No newline at end of file
lib/ygocore/game.rb
View file @
68841d6b
...
...
@@ -186,39 +186,6 @@ class Ygocore < Game
Widget_Msgbox
.
destroy
rescue
nil
end
def
self
.
deck_edit
Widget_Msgbox
.
new
(
"编辑卡组"
,
"
\"
导入
\"
导入已有卡组,
\"
编辑
\"
启动ygocore"
,
:import
=>
"导入"
,
:edit
=>
"编辑"
)
do
|
button
|
case
button
when
:import
file
=
Dialog
.
get_open_file
(
"导入卡组"
,
"所有支持的卡组 (*.txt;*.deck;*.ydk)"
=>
"*.ydk;*.txt;*.deck"
,
"OcgSoft卡组 (*.txt;*.deck)"
=>
"*.txt;*.deck"
,
"ygocore卡组 (*.ydk)"
=>
"*.ydk"
)
if
!
file
.
empty?
#fix for stdlib File.extname
file
=~
/(\.deck|\.txt|\.ydk)$/i
extname
=
$1
Dir
.
mkdir
"ygocore/deck"
unless
File
.
directory?
(
"ygocore/deck"
)
open
(
"ygocore/deck/
#{
File
.
basename
(
file
,
extname
)
+
".ydk"
}
"
,
'w'
)
do
|
dest
|
if
file
=~
/(\.deck|\.txt)$/i
deck
=
Deck
.
load
(
file
)
dest
.
puts
(
"#main"
)
deck
.
main
.
each
{
|
card
|
dest
.
puts
card
.
number
}
dest
.
puts
(
"#extra"
)
deck
.
extra
.
each
{
|
card
|
dest
.
puts
card
.
number
}
dest
.
pust
(
"!side"
)
deck
.
side
.
each
{
|
card
|
dest
.
puts
card
.
number
}
else
open
(
file
)
do
|
src
|
dest
.
write
src
.
read
end
end
end
rescue
Widget_Msgbox
.
new
(
"导入卡组"
,
"导入卡组失败"
,
:ok
=>
"确定"
)
Ygocore
.
run_ygocore
(
File
.
basename
(
file
,
extname
))
end
when
:edit
Ygocore
.
run_ygocore
(
:deck
)
end
end
end
def
self
.
replay
(
file
,
skip_image_downloading
=
false
)
require
'fileutils'
FileUtils
.
mv
Dir
.
glob
(
'ygocore/replay/*.yrp'
),
'replay/'
...
...
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