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
43a04a2a
Commit
43a04a2a
authored
Feb 28, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
公告滚动
parent
fa9b2490
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
9 deletions
+65
-9
lib/announcement.rb
lib/announcement.rb
+10
-0
lib/chatmessage.rb
lib/chatmessage.rb
+1
-0
lib/iduel/game.rb
lib/iduel/game.rb
+9
-4
lib/main.rb
lib/main.rb
+1
-0
lib/window_announcements.rb
lib/window_announcements.rb
+44
-5
No files found.
lib/announcement.rb
0 → 100644
View file @
43a04a2a
class
Announcement
attr_accessor
:title
attr_accessor
:url
attr_accessor
:time
def
initialize
(
title
,
url
,
time
=
nil
)
@title
=
title
@url
=
url
@time
=
time
end
end
lib/chatmessage.rb
View file @
43a04a2a
#encoding: UTF-8
class
ChatMessage
attr_accessor
:user
,
:message
,
:channel
,
:time
def
initialize
(
user
,
message
,
channel
=
:lobby
,
time
=
Time
.
now
)
...
...
lib/iduel/game.rb
View file @
43a04a2a
...
...
@@ -121,14 +121,19 @@ class Iduel < Game
(
@conn
.
write
info
)
rescue
Game_Event
.
push
Game_Event
::
Error
.
new
(
$!
.
class
.
to_s
,
$!
.
message
)
end
#公告
$config
[
'iDuel'
][
'announcements'
]
||=
{
"正在读取公告..."
=>
nil
}
$config
[
'iDuel'
][
'announcements'
]
||=
[
Announcement
.
new
(
"正在读取公告..."
,
nil
,
nil
)]
Thread
.
new
do
begin
open
(
'http://www.duelcn.com/topic-Announce.html'
)
do
|
file
|
file
.
set_encoding
"GBK"
announcements
=
{}
file
.
read
.
scan
(
/<li><em>.*?<\/em><a href="(.*?)" title="(.*?)" target="_blank">.*?<\/a><\/li>/
).
each
do
|
url
,
title
|
announcements
[
title
.
encode
(
"UTF-8"
)]
=
"http://www.duelcn.com/
#{
url
}
"
announcements
=
[]
file
.
read
.
scan
(
/<li><em>(.*?)<\/em><a href="(.*?)" title="(.*?)" target="_blank">.*?<\/a><\/li>/
).
each
do
|
time
,
url
,
title
|
if
time
=~
/(\d+)-(\d+)-(\d+)/
time
=
Time
.
new
(
$1
,
$2
,
$3
)
else
time
=
nil
end
announcements
<<
Announcement
.
new
(
title
.
encode
(
"UTF-8"
),
"http://www.duelcn.com/
#{
url
}
"
,
time
)
end
$config
[
'iDuel'
][
'announcements'
].
replace
announcements
save_config
...
...
lib/main.rb
View file @
43a04a2a
...
...
@@ -14,6 +14,7 @@ begin
File
.
open
(
file
,
"w"
){
|
file
|
YAML
.
dump
(
$config
,
file
)}
end
require_relative
'announcement'
#读取配置文件
load_config
save_config
...
...
lib/window_announcements.rb
View file @
43a04a2a
class
Window_Announcements
<
Window
def
initialize
(
x
,
y
,
width
,
height
)
super
(
x
,
y
,
width
,
height
)
@index
=
0
@count
=
0
@items
=
$config
[
$config
[
'game'
]][
'announcements'
]
@last_item
=
@item
=
@items
.
first
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
18
)
@color
=
[
44
,
64
,
78
]
@
last_announcement
=
@items
.
first
@
transforming
=
nil
refresh
end
def
refresh
clear
@font
.
draw_blended_utf8
(
@contents
,
@items
.
first
[
0
],
0
,
0
,
*
@color
)
@index
=
0
if
!
@items
[
@index
]
if
@transforming
@font
.
draw_blended_utf8
(
@contents
,
@last_item
.
title
,
0
,
-
@transforming
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
@item
.
title
,
0
,
-
@transforming
+
24
,
*
@color
)
else
@font
.
draw_blended_utf8
(
@contents
,
@item
.
title
,
0
,
0
,
*
@color
)
end
end
def
update
if
@
items
.
first
!=
@last_announcement
if
@
transforming
refresh
@last_announcement
=
@items
.
first
if
@transforming
>=
24
@transforming
=
nil
@last_item
=
@item
else
@transforming
+=
1
end
else
if
@last_item
!=
@item
@transforming
=
0
end
end
if
@item
!=
@items
[
@index
]
@index
=
0
@count
=
0
@item
=
@items
[
@index
]
end
if
@focus
@count
=
0
else
@count
+=
1
end
if
@count
>=
120
@index
=
(
@index
+
1
)
%
@items
.
size
@count
=
0
@item
=
@items
[
@index
]
end
super
end
def
clicked
require
'launchy'
Launchy
.
open
(
@items
.
first
[
1
])
if
@items
.
first
[
1
]
Launchy
.
open
(
@item
.
url
)
if
@item
.
url
end
def
mousemoved
(
x
,
y
)
@focus
=
true
end
def
lostfocus
(
active_window
=
nil
)
@focus
=
false
end
end
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