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
fa2343a2
Commit
fa2343a2
authored
Feb 19, 2013
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
announcements
parent
e0b8d20a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
46 deletions
+50
-46
lib/update.rb
lib/update.rb
+33
-28
lib/window_announcements.rb
lib/window_announcements.rb
+3
-3
lib/ygocore/game.rb
lib/ygocore/game.rb
+14
-15
No files found.
lib/update.rb
View file @
fa2343a2
...
...
@@ -2,7 +2,7 @@
require
"fileutils"
require_relative
'card'
module
Update
Version
=
'0.9.
3
'
Version
=
'0.9.
4
'
URL
=
"http://my-card.in/mycard/update.json?version=
#{
Version
}
"
class
<<
self
attr_reader
:thumbnails
,
:images
,
:status
...
...
@@ -129,12 +129,15 @@ module Update
require
'net/http/pipeline'
@thumbnails_left
=
@thumbnails
.
size
@images_left
=
@images
.
size
threads
=
1
.
times
.
collect
do
threads
=
5
.
times
.
collect
do
thread
=
Thread
.
new
do
Net
::
HTTP
.
start
uri
.
host
,
uri
.
port
do
|
http
|
http
.
pipelining
=
true
begin
list
=
@thumbnails
ids
=
[]
while
!
@thumbnails
.
empty?
ids
=
@thumbnails
.
pop
(
100
)
ids
.
replace
@thumbnails
.
pop
(
100
)
reqs
=
ids
.
reverse
.
collect
{
|
id
|
Net
::
HTTP
::
Get
.
new
image_req
.
gsub
(
':id'
,
id
.
to_s
)
}
http
.
pipeline
reqs
do
|
res
|
@status
.
replace
"正在下载缩略卡图 (剩余
#{
@thumbnails_left
}
张)"
...
...
@@ -142,13 +145,13 @@ module Update
id
=
ids
.
pop
next
if
File
.
file?
"ygocore/pics/thumbnail/
#{
id
}
.jpg"
content
=
res
.
body
open
(
"ygocore/pics/thumbnail/
#{
id
}
.jpg"
,
'wb'
)
do
|
local
|
local
.
write
content
open
(
"ygocore/pics/thumbnail/
#{
id
}
.jpg"
,
'wb'
)
{
|
local
|
local
.
write
content
}
end
end
rescue
$log
.
error
(
'下载缩略卡图'
)
{
[
$!
.
inspect
,
*
$!
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
end
list
=
@images_reqs
ids
=
[]
while
!
@images_reqs
.
empty?
ids
=
@images_reqs
.
pop
(
100
)
ids
.
replace
@images_reqs
.
pop
(
100
)
reqs
=
ids
.
reverse
.
collect
{
|
id
|
Net
::
HTTP
::
Get
.
new
thumbnail_req
.
gsub
(
':id'
,
id
.
to_s
)
}
http
.
pipeline
reqs
do
|
res
|
@status
.
replace
"正在下载完整卡图 (剩余
#{
@images_left
}
张)"
...
...
@@ -156,12 +159,14 @@ module Update
id
=
ids
.
pop
next
if
File
.
file?
"ygocore/pics/
#{
id
}
.jpg"
content
=
res
.
body
open
(
"ygocore/pics/
#{
id
}
.jpg"
,
'wb'
)
do
|
local
|
local
.
write
content
open
(
"ygocore/pics/
#{
id
}
.jpg"
,
'wb'
)
{
|
local
|
local
.
write
content
}
end
end
rescue
$log
.
error
(
'卡图下载'
)
{
[
$!
.
inspect
,
*
$!
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
list
.
concat
ids
end
end
rescue
$log
.
error
(
'下载完整卡图'
)
{
[
$!
.
inspect
,
*
$!
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
end
end
rescue
$log
.
error
(
'下载完整卡图出错'
)
{
[
$!
.
inspect
,
*
$!
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
end
thread
.
priority
=
-
1
thread
...
...
lib/window_announcements.rb
View file @
fa2343a2
...
...
@@ -18,14 +18,14 @@ class Window_Announcements < Window
if
@transforming
and
@last_item
@font
.
style
=
TTF
::
STYLE_NORMAL
@font
.
draw_blended_utf8
(
@contents
,
@last_item
.
title
,
0
,
-
@transforming
,
*
@color
)
@time_font
.
draw_blended_utf8
(
@contents
,
@last_item
.
time
.
strftime
(
'%Y-%m-%d'
),
3
00
,
-
@transforming
+
4
,
*
@time_color
)
if
@last_item
.
time
@time_font
.
draw_blended_utf8
(
@contents
,
@last_item
.
time
.
strftime
(
'%Y-%m-%d'
),
5
00
,
-
@transforming
+
4
,
*
@time_color
)
if
@last_item
.
time
@font
.
style
=
TTF
::
STYLE_UNDERLINE
if
@focus
@font
.
draw_blended_utf8
(
@contents
,
@item
.
title
,
0
,
-
@transforming
+
24
,
*
@color
)
@time_font
.
draw_blended_utf8
(
@contents
,
@item
.
time
.
strftime
(
'%Y-%m-%d'
),
3
00
,
-
@transforming
+
24
+
4
,
*
@time_color
)
if
@item
.
time
@time_font
.
draw_blended_utf8
(
@contents
,
@item
.
time
.
strftime
(
'%Y-%m-%d'
),
5
00
,
-
@transforming
+
24
+
4
,
*
@time_color
)
if
@item
.
time
else
@font
.
style
=
@focus
?
TTF
::
STYLE_UNDERLINE
:
TTF
::
STYLE_NORMAL
@font
.
draw_blended_utf8
(
@contents
,
@item
.
title
,
0
,
0
,
*
@color
)
@time_font
.
draw_blended_utf8
(
@contents
,
@item
.
time
.
strftime
(
'%Y-%m-%d'
),
3
00
,
4
,
*
@time_color
)
if
@item
.
time
@time_font
.
draw_blended_utf8
(
@contents
,
@item
.
time
.
strftime
(
'%Y-%m-%d'
),
5
00
,
4
,
*
@time_color
)
if
@item
.
time
end
end
def
update
...
...
lib/ygocore/game.rb
View file @
fa2343a2
...
...
@@ -5,6 +5,8 @@ require 'em-http'
require
'websocket'
require
'open-uri'
require
'yaml'
require
'json'
require
'date'
class
Ygocore
<
Game
attr_reader
:username
attr_accessor
:password
...
...
@@ -357,21 +359,18 @@ class Ygocore < Game
#公告
$config
[
'ygocore'
]
||=
{}
$config
[
'ygocore'
][
'announcements'
]
||=
[
Announcement
.
new
(
"开放注册"
,
nil
,
nil
)]
#Thread.new do
# begin
# open(@@config['api']) do |file|
# file.set_encoding "GBK"
# announcements = []
# file.read.encode("UTF-8").scan(/<div style="color:red" >公告:(.*?)<\/div>/).each do |title, others|
# announcements << Announcement.new(title, @@config['index'], nil)
# end
# $config['ygocore']['announcements'].replace announcements
# Config.save
# end
# rescue Exception => exception
# $log.error('公告读取失败') { [exception.inspect, *exception.backtrace].collect { |str| str.encode("UTF-8") }.join("\n") }
# end
#end
Thread
.
new
do
begin
open
(
'http://my-card.in/announcements.json'
)
do
|
file
|
$config
[
'ygocore'
][
'announcements'
].
replace
JSON
.
parse
(
file
.
read
).
collect
{
|
announcement
|
Announcement
.
new
(
announcement
[
'title'
],
announcement
[
'url'
],
Date
.
parse
(
announcement
[
'created_at'
]))
}
Config
.
save
end
rescue
Exception
=>
exception
$log
.
error
(
'公告读取失败'
)
{
[
exception
.
inspect
,
*
exception
.
backtrace
].
collect
{
|
str
|
str
.
encode
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
end
end
end
#module Client
...
...
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