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
syntax_j
mycard
Commits
5a87a77c
Commit
5a87a77c
authored
Jun 03, 2012
by
zh99998
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0.6.6 URL protocol
parent
709a9dbb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
225 additions
and
237 deletions
+225
-237
.gitignore
.gitignore
+1
-0
Rakefile
Rakefile
+64
-68
lib/main.rb
lib/main.rb
+126
-129
lib/quickstart.rb
lib/quickstart.rb
+33
-39
lib/update.rb
lib/update.rb
+1
-1
No files found.
.gitignore
View file @
5a87a77c
/nbproject/
/.idea/
/ruby/
/pkg/
/config.yml
...
...
Rakefile
View file @
5a87a77c
#encoding: UTF-8
require
'rubygems'
require
'rake'
require
'rake/clean'
require
'rubygems/package_task'
require
'rdoc/task'
#require 'rake/testtask'
Windows
=
RUBY_PLATFORM
[
"mingw"
]
||
RUBY_PLATFORM
[
"mswin"
]
if
Windows
STDOUT
.
set_encoding
"GBK"
,
"UTF-8"
STDERR
.
set_encoding
"GBK"
,
"UTF-8"
end
#在windows上UTF-8脚本编码环境中 Dir.glob无法列出中文目录下的文件 所以自己写个递归
def
list
(
path
)
result
=
[]
Dir
.
foreach
(
path
)
do
|
file
|
next
if
file
==
"."
or
file
==
".."
result
<<
"
#{
path
}
/
#{
file
}
"
result
.
concat
list
(
result
.
last
)
if
File
.
directory?
result
.
last
end
result
end
spec
=
Gem
::
Specification
.
new
do
|
s
|
s
.
name
=
'mycard'
s
.
version
=
'0.6.4'
s
.
extra_rdoc_files
=
[
'README.txt'
,
'LICENSE.txt'
]
s
.
summary
=
'a card game'
s
.
description
=
s
.
summary
s
.
author
=
'zh99998'
s
.
email
=
'zh99998@gmail.com'
s
.
homepage
=
'http://card.touhou,cc'
# s.executables = ['your_executable_here']
s
.
files
=
%w(LICENSE.txt README.txt replay)
%w{lib audio data fonts graphics ygocore}
.
each
{
|
dir
|
s
.
files
.
concat
list
(
dir
)}
if
Windows
s
.
files
+=
%w(mycard.exe)
+
list
(
"ruby"
)
else
s
.
files
+=
%w(install.sh)
end
s
.
require_path
=
"lib"
#s.bindir = "bin"
end
Gem
::
PackageTask
.
new
(
spec
)
do
|
p
|
p
.
gem_spec
=
spec
if
Windows
p
.
need_zip
=
true
p
.
zip_command
=
'../7z.exe a'
def
p
.
zip_file
"
#{
package_name
}
-win32.7z"
end
else
p
.
need_tar
=
true
end
end
Rake
::
RDocTask
.
new
do
|
rdoc
|
files
=
[
'README.txt'
,
'LICENSE.txt'
,
'lib/**/*.rb'
]
rdoc
.
rdoc_files
.
add
(
files
)
rdoc
.
main
=
"README.txt"
# page to start on
rdoc
.
title
=
"Mycard Docs"
rdoc
.
rdoc_dir
=
'doc/rdoc'
# rdoc output folder
rdoc
.
options
<<
'--line-numbers'
end
CLOBBER
.
include
%w(error-程序出错请到论坛反馈.txt log.log profile.log config.yml doc ygocore/pics)
+
list
(
'replay'
)
+
list
(
'ygocore/replay'
)
+
list
(
'.'
).
keep_if
{
|
file
|
File
.
basename
(
file
)
==
"Thumbs.db"
}
+
list
(
"graphics/avatars"
).
keep_if
{
|
file
|
File
.
basename
(
file
)
=~
/.*_(?:small|middle|large)\.png/
}
+
list
(
"ygocore/deck"
).
keep_if
{
|
file
|
File
.
basename
(
file
)
!=
'sample.ydk'
}
#encoding: UTF-8
require
'rubygems'
require
'rake'
require
'rake/clean'
require
'rubygems/package_task'
require
'rdoc/task'
#require 'rake/testtask'
Windows
=
RUBY_PLATFORM
[
"mingw"
]
||
RUBY_PLATFORM
[
"mswin"
]
#在windows上UTF-8脚本编码环境中 Dir.glob无法列出中文目录下的文件 所以自己写个递归
def
list
(
path
)
result
=
[]
Dir
.
foreach
(
path
)
do
|
file
|
next
if
file
==
"."
or
file
==
".."
result
<<
"
#{
path
}
/
#{
file
}
"
result
.
concat
list
(
result
.
last
)
if
File
.
directory?
result
.
last
end
result
end
spec
=
Gem
::
Specification
.
new
do
|
s
|
s
.
name
=
'mycard'
s
.
version
=
'0.6.6'
s
.
extra_rdoc_files
=
[
'README.txt'
,
'LICENSE.txt'
]
s
.
summary
=
'a card game'
s
.
description
=
s
.
summary
s
.
author
=
'zh99998'
s
.
email
=
'zh99998@gmail.com'
s
.
homepage
=
'http://card.touhou,cc'
# s.executables = ['your_executable_here']
s
.
files
=
%w(LICENSE.txt README.txt replay)
%w{lib audio data fonts graphics ygocore}
.
each
{
|
dir
|
s
.
files
.
concat
list
(
dir
)}
if
Windows
s
.
files
+=
%w(mycard.exe)
+
list
(
"ruby"
)
else
s
.
files
+=
%w(install.sh)
end
s
.
require_path
=
"lib"
#s.bindir = "bin"
end
Gem
::
PackageTask
.
new
(
spec
)
do
|
p
|
p
.
gem_spec
=
spec
if
Windows
p
.
need_zip
=
true
p
.
zip_command
=
'../7z.exe a'
def
p
.
zip_file
"
#{
package_name
}
-win32.7z"
end
else
p
.
need_tar
=
true
end
end
Rake
::
RDocTask
.
new
do
|
rdoc
|
files
=
[
'README.txt'
,
'LICENSE.txt'
,
'lib/**/*.rb'
]
rdoc
.
rdoc_files
.
add
(
files
)
rdoc
.
main
=
"README.txt"
# page to start on
rdoc
.
title
=
"Mycard Docs"
rdoc
.
rdoc_dir
=
'doc/rdoc'
# rdoc output folder
rdoc
.
options
<<
'--line-numbers'
end
CLOBBER
.
include
%w(error-程序出错请到论坛反馈.txt log.log profile.log config.yml doc ygocore/pics)
+
list
(
'replay'
)
+
list
(
'ygocore/replay'
)
+
list
(
'.'
).
keep_if
{
|
file
|
File
.
basename
(
file
)
==
"Thumbs.db"
}
+
list
(
"graphics/avatars"
).
keep_if
{
|
file
|
File
.
basename
(
file
)
=~
/.*_(?:small|middle|large)\.png/
}
+
list
(
"ygocore/deck"
).
keep_if
{
|
file
|
File
.
basename
(
file
)
!=
'sample.ydk'
}
lib/main.rb
View file @
5a87a77c
#!/usr/bin/env ruby
p
ARGV
STDIN
.
gets
begin
#定义全局方法
def
load_config
(
file
=
"config.yml"
)
require
'yaml'
$config
=
YAML
.
load_file
(
"config.yml"
)
rescue
{}
$config
=
{}
unless
$config
.
is_a?
Hash
$config
[
'bgm'
]
=
true
if
$config
[
'bgm'
].
nil?
$config
[
'screen'
]
||=
{}
$config
[
'screen'
][
'width'
]
||=
1024
$config
[
'screen'
][
'height'
]
||=
768
end
def
save_config
(
file
=
"config.yml"
)
File
.
open
(
file
,
"w"
){
|
file
|
YAML
.
dump
(
$config
,
file
)}
end
def
register_url_protocol
if
RUBY_PLATFORM
[
"win"
]
||
RUBY_PLATFORM
[
"ming"
]
require
'win32/registry'
pwd
=
Dir
.
pwd
.
gsub
(
'/'
,
'\\'
)
path
=
'"'
+
pwd
+
'\ruby\bin\ruby.exe" -C"'
+
pwd
+
'" -KU lib/main.rb'
command
=
path
+
' "%1"'
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'mycard'
){
|
reg
|
reg
[
'URL Protocol'
]
=
path
unless
(
reg
[
'URL Protocol'
]
==
path
rescue
false
)}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'mycard\shell\open\command'
){
|
reg
|
reg
[
nil
]
=
command
unless
(
reg
[
nil
]
==
command
rescue
false
)}
end
end
Thread
.
abort_on_exception
=
true
require_relative
'announcement'
#读取配置文件
load_config
save_config
#读取命令行参数
log
=
"log.log"
log_level
=
"INFO"
profile
=
nil
ARGV
.
each
do
|
arg
|
p
arg
STDIN
.
gets
case
arg
.
dup
.
force_encoding
(
"UTF-8"
)
when
/--log=(.*)/
log
.
replace
$1
when
/--log-level=(.*)/
log_level
.
replace
$1
when
/--profile=(.*)/
profile
=
$1
when
/mycard:.*/
require_relative
'quickstart'
$scene
=
false
when
/register_web_protocol/
register_url_protocol
$scene
=
false
end
end
unless
$scene
==
false
#初始化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"
)
WM
::
icon
=
Surface
.
load
(
"graphics/system/icon.gif"
)
$screen
=
Screen
.
open
(
$config
[
'screen'
][
'width'
],
$config
[
'screen'
][
'height'
],
0
,
HWSURFACE
|
(
$config
[
'screen'
][
'fullscreen'
]
?
FULLSCREEN
:
0
))
Mixer
.
open
(
Mixer
::
DEFAULT_FREQUENCY
,
Mixer
::
DEFAULT_FORMAT
,
Mixer
::
DEFAULT_CHANNELS
,
1024
)
Mixer
.
set_volume_music
(
60
)
TTF
.
init
Thread
.
abort_on_exception
=
true
#初始化日志
require
'logger'
if
log
==
"STDOUT"
#调试用
log
=
STDOUT
STDOUT
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
if
RUBY_PLATFORM
[
"win"
]
||
RUBY_PLATFORM
[
"ming"
]
end
$log
=
Logger
.
new
(
log
)
$log
.
level
=
Logger
.
const_get
log_level
#性能分析
if
profile
if
profile
==
"STDOUT"
profile
=
STDOUT
else
profile
=
open
(
profile
,
'w'
)
end
require
'profiler'
RubyVM
::
InstructionSequence
.
compile_option
=
{
:trace_instruction
=>
true
,
:specialized_instruction
=>
false
}
Profiler__
::
start_profile
end
#初始化标题场景
require_relative
'scene_title'
$scene
=
Scene_Title
.
new
#自动更新
require_relative
'update'
Update
.
start
WM
::
set_caption
(
"MyCard v
#{
Update
::
Version
}
"
,
"MyCard"
)
require_relative
'dialog'
register_url_protocol
rescue
Dialog
.
uac
(
"ruby/bin/rubyw.exe"
,
"-KU lib/main.rb register_web_protocol"
)
$log
.
info
(
"main"
){
"初始化成功"
}
end
rescue
Exception
=>
exception
open
(
'error-程序出错请到论坛反馈.txt'
,
'w'
){
|
f
|
f
.
write
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)}
$scene
=
false
end
#主循环
begin
$scene
.
main
while
$scene
rescue
Exception
=>
exception
exception
.
backtrace
.
each
{
|
backtrace
|
break
if
backtrace
=~
/^(.*)\.rb:\d+:in `.*'"$/
}
#由于脚本是从main.rb开始执行的,总会有个能匹配成功的文件
$log
.
fatal
(
$1
){[
exception
.
inspect
,
*
exception
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)}.
join
(
"
\n
"
)}
$game
.
exit
if
$game
require_relative
'scene_error'
$scene
=
Scene_Error
.
new
retry
ensure
if
profile
Profiler__
::
print_profile
(
profile
)
profile
.
close
end
$log
.
close
rescue
nil
#!/usr/bin/env ruby
begin
#定义全局方法
def
load_config
(
file
=
"config.yml"
)
require
'yaml'
$config
=
YAML
.
load_file
(
"config.yml"
)
rescue
{}
$config
=
{}
unless
$config
.
is_a?
Hash
$config
[
'bgm'
]
=
true
if
$config
[
'bgm'
].
nil?
$config
[
'screen'
]
||=
{}
$config
[
'screen'
][
'width'
]
||=
1024
$config
[
'screen'
][
'height'
]
||=
768
end
def
save_config
(
file
=
"config.yml"
)
File
.
open
(
file
,
"w"
){
|
file
|
YAML
.
dump
(
$config
,
file
)}
end
def
register_url_protocol
if
RUBY_PLATFORM
[
"win"
]
||
RUBY_PLATFORM
[
"ming"
]
require
'win32/registry'
pwd
=
Dir
.
pwd
.
gsub
(
'/'
,
'\\'
)
path
=
'"'
+
pwd
+
'\ruby\bin\rubyw.exe" -C"'
+
pwd
+
'" -KU lib/main.rb'
command
=
path
+
' "%1"'
path
.
replace
path
.
ljust
path
.
bytesize
command
.
replace
command
.
ljust
command
.
bytesize
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'mycard'
){
|
reg
|
reg
[
'URL Protocol'
]
=
path
unless
(
reg
[
'URL Protocol'
]
==
path
rescue
false
)}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'mycard\shell\open\command'
){
|
reg
|
reg
[
nil
]
=
command
unless
(
reg
[
nil
]
==
command
rescue
false
)}
end
end
Thread
.
abort_on_exception
=
true
require_relative
'announcement'
#读取配置文件
load_config
save_config
#读取命令行参数
log
=
"log.log"
log_level
=
"INFO"
profile
=
nil
ARGV
.
each
do
|
arg
|
case
arg
.
dup
.
force_encoding
(
"UTF-8"
)
when
/--log=(.*)/
log
.
replace
$1
when
/--log-level=(.*)/
log_level
.
replace
$1
when
/--profile=(.*)/
profile
=
$1
when
/mycard:.*/
require_relative
'quickstart'
$scene
=
false
when
/register_web_protocol/
register_url_protocol
$scene
=
false
end
end
unless
$scene
==
false
#初始化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"
)
WM
::
icon
=
Surface
.
load
(
"graphics/system/icon.gif"
)
$screen
=
Screen
.
open
(
$config
[
'screen'
][
'width'
],
$config
[
'screen'
][
'height'
],
0
,
HWSURFACE
|
(
$config
[
'screen'
][
'fullscreen'
]
?
FULLSCREEN
:
0
))
Mixer
.
open
(
Mixer
::
DEFAULT_FREQUENCY
,
Mixer
::
DEFAULT_FORMAT
,
Mixer
::
DEFAULT_CHANNELS
,
1024
)
Mixer
.
set_volume_music
(
60
)
TTF
.
init
Thread
.
abort_on_exception
=
true
#初始化日志
require
'logger'
if
log
==
"STDOUT"
#调试用
log
=
STDOUT
end
$log
=
Logger
.
new
(
log
)
$log
.
level
=
Logger
.
const_get
log_level
#性能分析
if
profile
if
profile
==
"STDOUT"
profile
=
STDOUT
else
profile
=
open
(
profile
,
'w'
)
end
require
'profiler'
RubyVM
::
InstructionSequence
.
compile_option
=
{
:trace_instruction
=>
true
,
:specialized_instruction
=>
false
}
Profiler__
::
start_profile
end
#初始化标题场景
require_relative
'scene_title'
$scene
=
Scene_Title
.
new
#自动更新
require_relative
'update'
Update
.
start
WM
::
set_caption
(
"MyCard v
#{
Update
::
Version
}
"
,
"MyCard"
)
require_relative
'dialog'
register_url_protocol
rescue
Dialog
.
uac
(
"ruby/bin/rubyw.exe"
,
"-KU lib/main.rb register_web_protocol"
)
$log
.
info
(
"main"
){
"初始化成功"
}
end
rescue
Exception
=>
exception
open
(
'error-程序出错请到论坛反馈.txt'
,
'w'
){
|
f
|
f
.
write
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)}
$scene
=
false
end
#主循环
begin
$scene
.
main
while
$scene
rescue
Exception
=>
exception
exception
.
backtrace
.
each
{
|
backtrace
|
break
if
backtrace
=~
/^(.*)\.rb:\d+:in `.*'"$/
}
#由于脚本是从main.rb开始执行的,总会有个能匹配成功的文件
$log
.
fatal
(
$1
){[
exception
.
inspect
,
*
exception
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)}.
join
(
"
\n
"
)}
$game
.
exit
if
$game
require_relative
'scene_error'
$scene
=
Scene_Error
.
new
retry
ensure
if
profile
Profiler__
::
print_profile
(
profile
)
profile
.
close
end
$log
.
close
rescue
nil
end
\ No newline at end of file
lib/quickstart.rb
View file @
5a87a77c
require_relative
'game'
require_relative
'user'
require_relative
'room'
require_relative
'ygocore/game'
$game
=
Ygocore
.
new
p
1
STDIN
.
gets
uri
=
URI
.
unescape
URI
.
unescape
ARGV
.
first
[
9
,
ARGV
.
first
.
size
-
9
]
p
uri
STDIN
.
gets
case
uri
when
/^(.*\.yrp)$/
require
'open-uri'
open
(
"http://"
+
URI
.
escape
(
$1
),
'rb'
)
{
|
src
|
Dir
.
mkdir
(
"replay"
)
unless
File
.
directory?
(
"replay"
)
open
(
'replay/'
+
File
.
basename
(
$1
),
'wb'
){
|
dest
|
dest
.
write
src
.
read
}
}
Ygocore
.
replay
(
'replay/'
+
File
.
basename
(
$1
),
true
)
when
/^(.*\.ydk)$/
require
'open-uri'
open
(
"http://"
+
URI
.
escape
(
$1
),
'rb'
)
{
|
src
|
Dir
.
mkdir
(
'ygocore/deck'
)
unless
File
.
directory?
(
"ygocore/deck"
)
open
(
'ygocore/deck/'
+
File
.
basename
(
$1
),
'wb'
){
|
dest
|
dest
.
write
src
.
read
}
}
Ygocore
.
run_ygocore
(
File
.
basename
(
$1
,
'.ydk'
),
true
)
when
/^(?:(.*)\:(.*)\@)?(.*)\:(\d+)\/(.*)$/
p
$1
STDIN
.
gets
require
'uri'
$game
.
user
=
User
.
new
(
$1
.
to_sym
,
$1
)
if
$1
$game
.
password
=
$2
if
$2
$game
.
server
=
$3
$game
.
port
=
$4
.
to_i
Ygocore
.
run_ygocore
Room
.
new
(
0
,
$5
),
true
require_relative
'game'
require_relative
'user'
require_relative
'room'
require_relative
'ygocore/game'
$game
=
Ygocore
.
new
uri
=
URI
.
unescape
URI
.
unescape
ARGV
.
first
[
9
,
ARGV
.
first
.
size
-
9
]
case
uri
when
/^(.*\.yrp)$/
require
'open-uri'
open
(
"http://"
+
URI
.
escape
(
$1
),
'rb'
)
{
|
src
|
Dir
.
mkdir
(
"replay"
)
unless
File
.
directory?
(
"replay"
)
open
(
'replay/'
+
File
.
basename
(
$1
),
'wb'
){
|
dest
|
dest
.
write
src
.
read
}
}
Ygocore
.
replay
(
'replay/'
+
File
.
basename
(
$1
),
true
)
when
/^(.*\.ydk)$/
require
'open-uri'
open
(
"http://"
+
URI
.
escape
(
$1
),
'rb'
)
{
|
src
|
Dir
.
mkdir
(
'ygocore/deck'
)
unless
File
.
directory?
(
"ygocore/deck"
)
open
(
'ygocore/deck/'
+
File
.
basename
(
$1
),
'wb'
){
|
dest
|
dest
.
write
src
.
read
}
}
Ygocore
.
run_ygocore
(
File
.
basename
(
$1
,
'.ydk'
),
true
)
when
/^(?:(.*)\:(.*)\@)?(.*)\:(\d+)\/(.*)$/
require
'uri'
$game
.
user
=
User
.
new
(
$1
.
to_sym
,
$1
)
if
$1
$game
.
password
=
$2
if
$2
$game
.
server
=
$3
$game
.
port
=
$4
.
to_i
Ygocore
.
run_ygocore
Room
.
new
(
0
,
$5
),
true
end
\ No newline at end of file
lib/update.rb
View file @
5a87a77c
...
...
@@ -2,7 +2,7 @@ require 'open-uri'
require
"fileutils"
require_relative
'card'
module
Update
Version
=
'0.6.
4
'
Version
=
'0.6.
6
'
URL
=
"http://card.touhou.cc/mycard/update.json?version=
#{
Version
}
"
class
<<
self
attr_reader
:thumbnails
,
:images
,
:status
...
...
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