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
7f4e6bb8
Commit
7f4e6bb8
authored
Dec 28, 2011
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登陆
parent
f5f28430
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
83 additions
and
90 deletions
+83
-90
lib/iduel/game.rb
lib/iduel/game.rb
+7
-5
lib/iduel/game.yml
lib/iduel/game.yml
+1
-1
lib/iduel/window_login.rb
lib/iduel/window_login.rb
+14
-0
lib/nbx/game.rb
lib/nbx/game.rb
+3
-2
lib/nbx/window_login.rb
lib/nbx/window_login.rb
+8
-0
lib/scene_login.rb
lib/scene_login.rb
+9
-25
lib/scene_login_nbx.rb
lib/scene_login_nbx.rb
+0
-31
lib/window_gameselect.rb
lib/window_gameselect.rb
+33
-2
lib/window_login.rb
lib/window_login.rb
+8
-24
No files found.
lib/iduel/game.rb
View file @
7f4e6bb8
#encoding: UTF-8
#encoding: UTF-8
load
File
.
expand_path
(
'window_login.rb'
,
File
.
dirname
(
__FILE__
))
class
Iduel
<
Game
class
Iduel
<
Game
Version
=
"20110131"
Version
=
"20110131"
Server
=
"iduel.ocgsoft.cn"
Server
=
"iduel.ocgsoft.cn"
Register_Url
=
'http://www.duelcn.com/member.php?mod=join_id'
Port
=
38522
Port
=
38522
RS
=
"¢"
RS
=
"¢"
attr_accessor
:session
attr_accessor
:session
attr_accessor
:key
attr_accessor
:key
def
initialize
def
initialize
super
super
require
'digest/md5'
require
'digest/md5'
require_relative
'action'
load
File
.
expand_path
(
'action.rb'
,
File
.
dirname
(
__FILE__
))
require_relative
'event'
load
File
.
expand_path
(
'event.rb'
,
File
.
dirname
(
__FILE__
))
require_relative
'user'
load
File
.
expand_path
(
'user.rb'
,
File
.
dirname
(
__FILE__
))
require_relative
'replay'
load
File
.
expand_path
(
'replay.rb'
,
File
.
dirname
(
__FILE__
))
end
end
def
connect
def
connect
require
'socket'
require
'socket'
...
@@ -36,6 +37,7 @@ class Iduel < Game
...
@@ -36,6 +37,7 @@ class Iduel < Game
$log
.
error
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
$log
.
error
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
end
end
end
end
def
login
(
username
,
password
)
def
login
(
username
,
password
)
connect
connect
md5
=
Digest
::
MD5
.
hexdigest
(
password
)
md5
=
Digest
::
MD5
.
hexdigest
(
password
)
...
...
lib/iduel/game.yml
View file @
7f4e6bb8
name
:
iduel
name
:
iduel
\ No newline at end of file
lib/iduel/window_login.rb
0 → 100644
View file @
7f4e6bb8
#encoding: UTF-8
class
Window_Login
def
clicked
case
@index
when
:login
$game
=
Iduel
.
new
$game
.
login
(
@username_inputbox
.
value
,
@password_inputbox
.
value
)
Widget_Msgbox
.
new
(
"iduel"
,
"正在登陆"
)
when
:register
require
'launchy'
Launchy
.
open
(
Iduel
::
Register_Url
)
end
end
end
lib/nbx/game.rb
View file @
7f4e6bb8
#encoding: UTF-8
#encoding: UTF-8
load
File
.
expand_path
(
'window_login.rb'
,
File
.
dirname
(
__FILE__
))
class
NBX
<
Game
class
NBX
<
Game
Version
=
"20090622"
Version
=
"20090622"
Port
=
2583
Port
=
2583
...
@@ -8,8 +9,8 @@ class NBX < Game
...
@@ -8,8 +9,8 @@ class NBX < Game
require
'socket'
require
'socket'
require
'digest/md5'
require
'digest/md5'
require
'open-uri'
require
'open-uri'
require_relative
'action'
load
File
.
expand_path
(
'action.rb'
,
File
.
dirname
(
__FILE__
))
require_relative
'event'
load
File
.
expand_path
(
'event.rb'
,
File
.
dirname
(
__FILE__
))
@conn_hall
=
UDPSocket
.
new
@conn_hall
=
UDPSocket
.
new
@conn_hall
.
setsockopt
(
Socket
::
SOL_SOCKET
,
Socket
::
SO_BROADCAST
,
true
)
@conn_hall
.
setsockopt
(
Socket
::
SOL_SOCKET
,
Socket
::
SO_BROADCAST
,
true
)
...
...
lib/nbx/window_login.rb
0 → 100644
View file @
7f4e6bb8
#encoding: UTF-8
class
Window_Login
def
initialize
(
*
args
)
$game
=
NBX
.
new
username
=
$config
[
'username'
]
&&
!
$config
[
'username'
].
empty?
?
$config
[
'username'
]
:
$_ENV
[
'username'
]
$game
.
login
username
end
end
lib/scene_login.rb
View file @
7f4e6bb8
...
@@ -6,34 +6,19 @@
...
@@ -6,34 +6,19 @@
#==============================================================================
#==============================================================================
require_relative
'window_gameselect'
require_relative
'window_gameselect'
require_relative
'window_login'
require_relative
'window_login'
require
'game'
class
Scene_Login
<
Scene
class
Scene_Login
<
Scene
Vocab_Logging
=
"Logging"
Vocab_Logging
=
"Logging"
def
start
def
start
#@font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 24)
#if $config["autologin"]
# @username = $config["username"]
# @password = $config["password"]
# login
#end
@background
=
Surface
.
load
(
"graphics/login/background.png"
)
@background
=
Surface
.
load
(
"graphics/login/background.png"
)
@gameselect_window
=
Window_GameSelect
.
new
(
117
,
269
)
@gameselect_window
=
Window_GameSelect
.
new
(
117
,
269
,
$config
[
"game"
])
@login_window
=
Window_Login
.
new
(
316
,
316
,
$config
[
"username"
],
$config
[
"password"
])
end
end
def
login
def
update
#@font.draw_blended_utf8($screen, Vocab_Logging, 0,0,255,0,255)
while
event
=
Game_Event
.
poll
require_relative
'game'
handle_game
(
event
)
require_relative
'iduel/iduel'
end
require_relative
'widget_msgbox'
super
Widget_Msgbox
.
new
(
"iduel"
,
"正在登陆"
)
end
$game
=
Iduel
.
new
$game
.
login
(
@username
,
@password
)
end
#def update
#while event = Game_Event.poll
# handle_game(event)
#end
#super
#end
def
handle_game
(
event
)
def
handle_game
(
event
)
case
event
case
event
when
Game_Event
::
Login
when
Game_Event
::
Login
...
@@ -45,5 +30,4 @@ class Scene_Login < Scene
...
@@ -45,5 +30,4 @@ class Scene_Login < Scene
$log
.
debug
event
$log
.
debug
event
end
end
end
end
end
end
\ No newline at end of file
lib/scene_login_nbx.rb
deleted
100644 → 0
View file @
f5f28430
#==============================================================================
# ■ Scene_Login
#------------------------------------------------------------------------------
# login
#==============================================================================
class
Scene_Login_NBX
<
Scene
Vocab_Logging
=
"Logging"
def
start
require_relative
'nbx/nbx'
$game
=
NBX
.
new
login
end
def
login
username
=
$config
[
'username'
]
&&
!
$config
[
'username'
].
empty?
?
$config
[
'username'
]
:
$_ENV
[
'username'
]
$game
.
login
username
end
def
update
while
event
=
Game_Event
.
poll
handle_game
(
event
)
end
super
end
def
handle_game
(
event
)
case
event
when
Game_Event
::
Login
require_relative
'scene_hall'
$scene
=
Scene_Hall
.
new
end
end
end
lib/window_gameselect.rb
View file @
7f4e6bb8
#encoding: UTF-8
#encoding: UTF-8
class
Window_GameSelect
<
Window_List
class
Window_GameSelect
<
Window_List
WLH
=
56
WLH
=
56
def
initialize
(
x
,
y
)
def
initialize
(
x
,
y
,
game_name
=
nil
)
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
24
)
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
24
)
@color
=
[
255
,
255
,
255
]
@color
=
[
255
,
255
,
255
]
@game_color
=
[
47
,
156
,
192
]
@game_color
=
[
47
,
156
,
192
]
...
@@ -10,6 +10,8 @@ class Window_GameSelect < Window_List
...
@@ -10,6 +10,8 @@ class Window_GameSelect < Window_List
Dir
.
glob
(
'lib/**/game.yml'
)
do
|
file
|
Dir
.
glob
(
'lib/**/game.yml'
)
do
|
file
|
game
=
YAML
.
load_file
(
file
)
game
=
YAML
.
load_file
(
file
)
if
game
.
is_a?
(
Hash
)
&&
game
[
"name"
]
if
game
.
is_a?
(
Hash
)
&&
game
[
"name"
]
game
[
'file'
]
||=
'game.rb'
game
[
'file'
]
=
File
.
expand_path
(
game
[
'file'
],
File
.
dirname
(
file
))
@list
<<
game
@list
<<
game
else
else
$log
.
warn
"
#{
game
.
inspect
}
读取失败(
#{
file
}
)"
$log
.
warn
"
#{
game
.
inspect
}
读取失败(
#{
file
}
)"
...
@@ -20,11 +22,22 @@ class Window_GameSelect < Window_List
...
@@ -20,11 +22,22 @@ class Window_GameSelect < Window_List
@button
=
Surface
.
load
(
"graphics/login/game_background.png"
)
@button
=
Surface
.
load
(
"graphics/login/game_background.png"
)
#@button.set_alpha(RLEACCEL,255)
#@button.set_alpha(RLEACCEL,255)
self
.
list
=
@list
self
.
list
=
@list
self
.
index
=
@list
.
find_index
{
|
game
|
game
[
"name"
]
==
game_name
}
||
0
clicked
refresh
end
end
def
draw_item
(
index
,
status
=
0
)
def
draw_item
(
index
,
status
=
0
)
Surface
.
blit
(
@button
,
0
,
0
,
@button
.
w
,
@button
.
h
,
@contents
,
0
,
WLH
*
index
)
case
status
when
0
Surface
.
blit
(
@button
,
0
,
0
,
@button
.
w
,
@button
.
h
,
@contents
,
0
,
WLH
*
index
)
when
1
2
.
times
{
Surface
.
blit
(
@button
,
0
,
0
,
@button
.
w
,
@button
.
h
,
@contents
,
0
,
WLH
*
index
)}
#我自重
end
draw_stroked_text
(
@list
[
index
][
"name"
],
24
,
WLH
*
index
+
14
,
2
)
draw_stroked_text
(
@list
[
index
][
"name"
],
24
,
WLH
*
index
+
14
,
2
)
end
end
def
item_rect
(
index
)
[
0
,
WLH
*
index
,
@button
.
w
,
@button
.
h
]
end
def
draw_stroked_text
(
text
,
x
,
y
,
size
=
1
)
def
draw_stroked_text
(
text
,
x
,
y
,
size
=
1
)
[[
x
-
size
,
y
-
size
],
[
x
-
size
,
y
],
[
x
-
size
,
y
+
size
],
[[
x
-
size
,
y
-
size
],
[
x
-
size
,
y
],
[
x
-
size
,
y
+
size
],
[
x
,
y
-
size
],
[
x
,
y
+
size
],
[
x
,
y
-
size
],
[
x
,
y
+
size
],
...
@@ -32,4 +45,22 @@ class Window_GameSelect < Window_List
...
@@ -32,4 +45,22 @@ class Window_GameSelect < Window_List
].
each
{
|
pos
|
@font
.
draw_blended_utf8
(
@contents
,
text
,
pos
[
0
],
pos
[
1
],
*
@game_stroke_color
)}
].
each
{
|
pos
|
@font
.
draw_blended_utf8
(
@contents
,
text
,
pos
[
0
],
pos
[
1
],
*
@game_stroke_color
)}
@font
.
draw_blended_utf8
(
@contents
,
text
,
x
,
y
,
*
@game_color
)
@font
.
draw_blended_utf8
(
@contents
,
text
,
x
,
y
,
*
@game_color
)
end
end
def
mousemoved
(
x
,
y
)
self
.
index
=
(
y
-
@y
)
/
WLH
end
def
index
=
(
index
)
return
if
@index
==
index
or
index
.
nil?
if
@index
clear
(
*
item_rect
(
@index
))
draw_item
(
@index
,
0
)
end
@index
=
index
clear
(
*
item_rect
(
@index
))
draw_item
(
@index
,
1
)
end
def
clicked
load
@list
[
@index
][
"file"
]
#TODO: load的这种架构微蛋疼,一时想不到更好的方案
@login_window
.
destroy
if
@login_window
@login_window
=
Window_Login
.
new
(
316
,
316
,
$config
[
"username"
],
$config
[
"password"
])
end
end
end
lib/window_login.rb
View file @
7f4e6bb8
#encoding: UTF-8
#encoding: UTF-8
require_relative
'widget_inputbox'
require_relative
'widget_inputbox'
require_relative
'widget_msgbox'
class
Window_Login
<
Window
class
Window_Login
<
Window
def
initialize
(
x
,
y
,
username
=
nil
,
password
=
nil
)
def
initialize
(
x
,
y
,
username
=
nil
,
password
=
nil
)
@username
=
username
@username
=
username
...
@@ -7,16 +8,14 @@ class Window_Login < Window
...
@@ -7,16 +8,14 @@ class Window_Login < Window
@button
=
Surface
.
load
(
"graphics/login/button.png"
)
@button
=
Surface
.
load
(
"graphics/login/button.png"
)
super
(
x
,
y
,
597
,
338
)
super
(
x
,
y
,
597
,
338
)
@username_inputbox
=
Widget_InputBox
.
new
(
@x
+
192
,
@y
+
80
,
165
,
WLH
)
@username_inputbox
=
Widget_InputBox
.
new
(
@x
+
192
,
@y
+
80
,
165
,
WLH
)
@username_inputbox
.
value
=
@username
@username_inputbox
.
value
=
@username
if
@username
@password_inputbox
=
Widget_InputBox
.
new
(
@x
+
192
,
@y
+
125
,
165
,
WLH
)
@password_inputbox
=
Widget_InputBox
.
new
(
@x
+
192
,
@y
+
125
,
165
,
WLH
)
@password_inputbox
.
type
=
:password
@password_inputbox
.
type
=
:password
@password_inputbox
.
value
=
@password
@password_inputbox
.
value
=
@password
if
@password
@color
=
[
255
,
255
,
255
]
@color
=
[
255
,
255
,
255
]
@color_stroke
=
[
0
,
0
,
0
]
@color_stroke
=
[
0
,
0
,
0
]
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
16
)
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
16
)
@font_button
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
18
)
@font_button
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
18
)
draw_stroked_text
(
"用户名"
,
105
,
80
+
2
,
1
)
draw_stroked_text
(
"密码"
,
105
,
125
+
2
,
1
)
#@font.draw_blended_utf8(@contents, text, 105,80, *@game_color)
#@font.draw_blended_utf8(@contents, text, 105,80, *@game_color)
@items
=
{
@items
=
{
#:username => [192,80,165,WLH],
#:username => [192,80,165,WLH],
...
@@ -28,7 +27,7 @@ class Window_Login < Window
...
@@ -28,7 +27,7 @@ class Window_Login < Window
:login
=>
"登陆"
,
:login
=>
"登陆"
,
:register
=>
"注册"
:register
=>
"注册"
}
}
self
.
index
=
nil
#
self.index = nil
refresh
refresh
end
end
def
draw_stroked_text
(
text
,
x
,
y
,
size
=
1
,
font
=
@font
)
def
draw_stroked_text
(
text
,
x
,
y
,
size
=
1
,
font
=
@font
)
...
@@ -41,33 +40,18 @@ class Window_Login < Window
...
@@ -41,33 +40,18 @@ class Window_Login < Window
def
refresh
def
refresh
clear
clear
@items
.
each_pair
{
|
index
,
rect
|
draw_item
(
index
,
rect
)}
@items
.
each_pair
{
|
index
,
rect
|
draw_item
(
index
,
rect
)}
draw_stroked_text
(
"用户名"
,
105
,
80
+
2
,
1
)
draw_stroked_text
(
"密码"
,
105
,
125
+
2
,
1
)
end
end
def
draw_item
(
index
,
rect
,
status
=
0
)
def
draw_item
(
index
,
rect
,
status
=
0
)
Surface
.
blit
(
@button
,
0
,
0
,
rect
[
2
],
rect
[
3
],
@contents
,
rect
[
0
],
rect
[
1
])
Surface
.
blit
(
@button
,
0
,
0
,
rect
[
2
],
rect
[
3
],
@contents
,
rect
[
0
],
rect
[
1
])
draw_stroked_text
(
@items_text
[
index
],
rect
[
0
]
+
20
,
rect
[
1
]
+
9
,
1
,
@font_button
)
draw_stroked_text
(
@items_text
[
index
],
rect
[
0
]
+
20
,
rect
[
1
]
+
9
,
1
,
@font_button
)
end
end
def
mousemoved
(
x
,
y
)
def
mousemoved
(
x
,
y
)
@items
.
each_pair
{
|
index
,
rect
|
@items
.
each_pair
{
|
index
,
rect
|
return
self
.
index
=
index
if
(
x
-
@x
>=
rect
[
0
]
and
x
-
@x
<
rect
[
0
]
+
rect
[
2
]
and
y
-
@y
>=
rect
[
1
]
and
y
-
@y
<
rect
[
1
]
+
rect
[
3
])}
#p index, x >= rect[0] and x < rect[0]+rect[2] and y >= rect[1] and y < rect[1]+rect[3]
#p x,y,rect[0], rect[0]+rect[2], rect[1], rect[1]+rect[3]
p
@x
+
x
>=
rect
[
0
]
and
@x
+
x
<
rect
[
0
]
+
rect
[
2
]
and
@y
+
y
>=
rect
[
1
]
and
@y
+
y
<
rect
[
1
]
+
rect
[
3
]
return
self
.
index
=
index
if
true
#@x+x >= rect[0] and @x+x < rect[0]+rect[2] and @y+y >= rect[1] and @y+y < rect[1]+rect[3]
}
end
end
def
index
=
(
index
)
def
index
=
(
index
)
#return if @index == index
return
if
@index
==
index
p
index
@index
=
index
@index
=
index
end
end
def
clicked
case
@index
when
:login
$game
=
Iduel
.
new
$game
.
login
(
@username_inputbox
.
value
,
@password_inputbox
.
value
)
when
:register
require
'launchy'
Launchy
.
open
(
"http://google.com"
)
end
end
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