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
59e18392
Commit
59e18392
authored
Jul 18, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temp
parent
194e405d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
13 deletions
+55
-13
lib/main.rb
lib/main.rb
+54
-12
lib/update.rb
lib/update.rb
+1
-1
No files found.
lib/main.rb
View file @
59e18392
...
@@ -14,19 +14,55 @@ begin
...
@@ -14,19 +14,55 @@ begin
def
save_config
(
file
=
"config.yml"
)
def
save_config
(
file
=
"config.yml"
)
File
.
open
(
file
,
"w"
)
{
|
file
|
YAML
.
dump
(
$config
,
file
)
}
File
.
open
(
file
,
"w"
)
{
|
file
|
YAML
.
dump
(
$config
,
file
)
}
end
end
def
register_url_protocol
def
register_url_protocol
if
RUBY_PLATFORM
[
"win"
]
||
RUBY_PLATFORM
[
"ming"
]
if
RUBY_PLATFORM
[
"win"
]
||
RUBY_PLATFORM
[
"ming"
]
require
'win32/registry'
require
'win32/registry'
pwd
=
Dir
.
pwd
.
gsub
(
'/'
,
'\\'
)
path
,
command
,
icon
=
assoc_paths
path
=
'"'
+
pwd
+
'\ruby\bin\rubyw.exe" -C"'
+
pwd
+
'" -KU lib/main.rb'
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'mycard'
)
{
|
reg
|
reg
[
'URL Protocol'
]
=
path
.
ljust
path
.
bytesize
}
command
=
path
+
' "%1"'
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'mycard\shell\open\command'
)
{
|
reg
|
reg
[
nil
]
=
command
.
ljust
command
.
bytesize
}
icon
=
'"'
+
pwd
+
'\mycard.exe", 0'
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'mycard\DefaultIcon'
)
{
|
reg
|
reg
[
nil
]
=
icon
.
ljust
icon
.
bytesize
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'mycard'
)
{
|
reg
|
reg
[
'URL Protocol'
]
=
path
.
ljust
path
.
bytesize
unless
(
reg
[
'URL Protocol'
]
==
path
rescue
false
)
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'.ydk'
)
{
|
reg
|
reg
[
nil
]
=
'mycard'
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'mycard\shell\open\command'
)
{
|
reg
|
reg
[
nil
]
=
command
.
ljust
command
.
bytesize
unless
(
reg
[
nil
]
==
command
rescue
false
)
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'.yrp'
)
{
|
reg
|
reg
[
nil
]
=
'mycard'
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'mycard\DefaultIcon'
)
{
|
reg
|
reg
[
nil
]
=
icon
.
ljust
icon
.
bytesize
unless
(
reg
[
nil
]
==
icon
rescue
false
)
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'.deck'
)
{
|
reg
|
reg
[
nil
]
=
'mycard'
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'.ydk'
)
{
|
reg
|
reg
[
nil
]
=
'mycard'
unless
(
reg
[
nil
]
==
'mycard'
rescue
false
)
}
end
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'.yrp'
)
{
|
reg
|
reg
[
nil
]
=
'mycard'
unless
(
reg
[
nil
]
==
'mycard'
rescue
false
)
}
end
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'.deck'
)
{
|
reg
|
reg
[
nil
]
=
'mycard'
unless
(
reg
[
nil
]
==
'mycard'
rescue
false
)
}
def
assoc_paths
pwd
=
Dir
.
pwd
.
gsub
(
'/'
,
'\\'
)
path
=
'"'
+
pwd
+
'\ruby\bin\rubyw.exe" -C"'
+
pwd
+
'" -KU lib/main.rb'
command
=
path
+
' "%1"'
icon
=
'"'
+
pwd
+
'\mycard.exe", 0'
[
path
,
command
,
icon
]
end
def
assoc_need?
return
false
unless
RUBY_PLATFORM
[
"win"
]
||
RUBY_PLATFORM
[
"ming"
]
return
false
if
$config
[
'no_assoc'
]
path
,
command
,
icon
=
assoc_paths
require
'win32/registry'
begin
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
open
(
'mycard'
)
{
|
reg
|
return
true
unless
reg
[
'URL Protocol'
]
==
path
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
open
(
'mycard\shell\open\command'
)
{
|
reg
|
return
true
unless
reg
[
nil
]
==
command
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
open
(
'mycard\DefaultIcon'
)
{
|
reg
|
return
true
unless
reg
[
nil
]
==
icon
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
open
(
'.ydk'
)
{
|
reg
|
return
true
unless
reg
[
nil
]
==
'mycard'
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
open
(
'.yrp'
)
{
|
reg
|
return
true
unless
reg
[
nil
]
==
'mycard'
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
open
(
'.deck'
)
{
|
reg
|
return
true
unless
reg
[
nil
]
==
'mycard'
}
rescue
return
true
end
end
def
request_assoc
require_relative
'widget_msgbox'
Widget_Msgbox
.
new
(
"mycard"
,
"即将进行文件关联, 弹出安全警告请点允许"
,
ok:
"确定"
,
cancel:
"取消"
)
do
|
clicked
|
if
clicked
==
:ok
yield
else
Widget_Msgbox
.
new
(
"mycard"
,
"没有进行关联,要重新关联请删除config.yml"
)
$config
[
'no_assoc'
]
=
true
save_config
end
end
end
end
end
...
@@ -53,6 +89,7 @@ begin
...
@@ -53,6 +89,7 @@ begin
require_relative
'quickstart'
require_relative
'quickstart'
$scene
=
false
$scene
=
false
when
/register_web_protocol/
when
/register_web_protocol/
$assoc_requested
=
true
register_url_protocol
register_url_protocol
$scene
=
false
$scene
=
false
end
end
...
@@ -99,14 +136,19 @@ begin
...
@@ -99,14 +136,19 @@ begin
#初始化标题场景
#初始化标题场景
require_relative
'scene_title'
require_relative
'scene_title'
require_relative
'dialog'
$scene
=
Scene_Title
.
new
$scene
=
Scene_Title
.
new
#自动更新
#自动更新
require_relative
'update'
require_relative
'update'
Update
.
start
Update
.
start
WM
::
set_caption
(
"MyCard v
#{
Update
::
Version
}
"
,
"MyCard"
)
WM
::
set_caption
(
"MyCard v
#{
Update
::
Version
}
"
,
"MyCard"
)
require_relative
'dialog'
if
assoc_need?
register_url_protocol
rescue
Dialog
.
uac
(
"ruby/bin/rubyw.exe"
,
"-KU lib/main.rb register_web_protocol"
)
request_assoc
do
register_url_protocol
rescue
Dialog
.
uac
(
"ruby/bin/rubyw.exe"
,
"-KU lib/main.rb register_web_protocol"
)
end
end
$log
.
info
(
"main"
)
{
"初始化成功"
}
$log
.
info
(
"main"
)
{
"初始化成功"
}
end
end
rescue
Exception
=>
exception
rescue
Exception
=>
exception
...
...
lib/update.rb
View file @
59e18392
...
@@ -2,7 +2,7 @@ require 'open-uri'
...
@@ -2,7 +2,7 @@ require 'open-uri'
require
"fileutils"
require
"fileutils"
require_relative
'card'
require_relative
'card'
module
Update
module
Update
Version
=
'0.7.
0
'
Version
=
'0.7.
2
'
URL
=
"http://card.touhou.cc/mycard/update.json?version=
#{
Version
}
"
URL
=
"http://card.touhou.cc/mycard/update.json?version=
#{
Version
}
"
class
<<
self
class
<<
self
attr_reader
:thumbnails
,
:images
,
:status
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