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
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
load
File
.
expand_path
(
'window_login.rb'
,
File
.
dirname
(
__FILE__
))
class
Iduel
<
Game
Version
=
"20110131"
Server
=
"iduel.ocgsoft.cn"
Register_Url
=
'http://www.duelcn.com/member.php?mod=join_id'
Port
=
38522
RS
=
"¢"
attr_accessor
:session
attr_accessor
:key
def
initialize
super
require
'digest/md5'
require_relative
'action'
require_relative
'event'
require_relative
'user'
require_relative
'replay'
load
File
.
expand_path
(
'action.rb'
,
File
.
dirname
(
__FILE__
))
load
File
.
expand_path
(
'event.rb'
,
File
.
dirname
(
__FILE__
))
load
File
.
expand_path
(
'user.rb'
,
File
.
dirname
(
__FILE__
))
load
File
.
expand_path
(
'replay.rb'
,
File
.
dirname
(
__FILE__
))
end
def
connect
require
'socket'
...
...
@@ -36,6 +37,7 @@ class Iduel < Game
$log
.
error
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
end
end
def
login
(
username
,
password
)
connect
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
load
File
.
expand_path
(
'window_login.rb'
,
File
.
dirname
(
__FILE__
))
class
NBX
<
Game
Version
=
"20090622"
Port
=
2583
...
...
@@ -8,8 +9,8 @@ class NBX < Game
require
'socket'
require
'digest/md5'
require
'open-uri'
require_relative
'action'
require_relative
'event'
load
File
.
expand_path
(
'action.rb'
,
File
.
dirname
(
__FILE__
))
load
File
.
expand_path
(
'event.rb'
,
File
.
dirname
(
__FILE__
))
@conn_hall
=
UDPSocket
.
new
@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 @@
#==============================================================================
require_relative
'window_gameselect'
require_relative
'window_login'
require
'game'
class
Scene_Login
<
Scene
Vocab_Logging
=
"Logging"
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"
)
@gameselect_window
=
Window_GameSelect
.
new
(
117
,
269
)
@login_window
=
Window_Login
.
new
(
316
,
316
,
$config
[
"username"
],
$config
[
"password"
])
@gameselect_window
=
Window_GameSelect
.
new
(
117
,
269
,
$config
[
"game"
])
end
def
login
#@font.draw_blended_utf8($screen, Vocab_Logging, 0,0,255,0,255)
require_relative
'game'
require_relative
'iduel/iduel'
require_relative
'widget_msgbox'
Widget_Msgbox
.
new
(
"iduel"
,
"正在登陆"
)
$game
=
Iduel
.
new
$game
.
login
(
@username
,
@password
)
end
#def update
#while event = Game_Event.poll
# handle_game(event)
#end
#super
#end
def
update
while
event
=
Game_Event
.
poll
handle_game
(
event
)
end
super
end
def
handle_game
(
event
)
case
event
when
Game_Event
::
Login
...
...
@@ -45,5 +30,4 @@ class Scene_Login < Scene
$log
.
debug
event
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
class
Window_GameSelect
<
Window_List
WLH
=
56
def
initialize
(
x
,
y
)
def
initialize
(
x
,
y
,
game_name
=
nil
)
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
24
)
@color
=
[
255
,
255
,
255
]
@game_color
=
[
47
,
156
,
192
]
...
...
@@ -10,6 +10,8 @@ class Window_GameSelect < Window_List
Dir
.
glob
(
'lib/**/game.yml'
)
do
|
file
|
game
=
YAML
.
load_file
(
file
)
if
game
.
is_a?
(
Hash
)
&&
game
[
"name"
]
game
[
'file'
]
||=
'game.rb'
game
[
'file'
]
=
File
.
expand_path
(
game
[
'file'
],
File
.
dirname
(
file
))
@list
<<
game
else
$log
.
warn
"
#{
game
.
inspect
}
读取失败(
#{
file
}
)"
...
...
@@ -20,11 +22,22 @@ class Window_GameSelect < Window_List
@button
=
Surface
.
load
(
"graphics/login/game_background.png"
)
#@button.set_alpha(RLEACCEL,255)
self
.
list
=
@list
self
.
index
=
@list
.
find_index
{
|
game
|
game
[
"name"
]
==
game_name
}
||
0
clicked
refresh
end
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
)
end
def
item_rect
(
index
)
[
0
,
WLH
*
index
,
@button
.
w
,
@button
.
h
]
end
def
draw_stroked_text
(
text
,
x
,
y
,
size
=
1
)
[[
x
-
size
,
y
-
size
],
[
x
-
size
,
y
],
[
x
-
size
,
y
+
size
],
[
x
,
y
-
size
],
[
x
,
y
+
size
],
...
...
@@ -32,4 +45,22 @@ class Window_GameSelect < Window_List
].
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
)
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
lib/window_login.rb
View file @
7f4e6bb8
#encoding: UTF-8
require_relative
'widget_inputbox'
require_relative
'widget_msgbox'
class
Window_Login
<
Window
def
initialize
(
x
,
y
,
username
=
nil
,
password
=
nil
)
@username
=
username
...
...
@@ -7,16 +8,14 @@ class Window_Login < Window
@button
=
Surface
.
load
(
"graphics/login/button.png"
)
super
(
x
,
y
,
597
,
338
)
@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
.
type
=
:password
@password_inputbox
.
value
=
@password
@password_inputbox
.
value
=
@password
if
@password
@color
=
[
255
,
255
,
255
]
@color_stroke
=
[
0
,
0
,
0
]
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
16
)
@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)
@items
=
{
#:username => [192,80,165,WLH],
...
...
@@ -28,7 +27,7 @@ class Window_Login < Window
:login
=>
"登陆"
,
:register
=>
"注册"
}
self
.
index
=
nil
#
self.index = nil
refresh
end
def
draw_stroked_text
(
text
,
x
,
y
,
size
=
1
,
font
=
@font
)
...
...
@@ -41,33 +40,18 @@ class Window_Login < Window
def
refresh
clear
@items
.
each_pair
{
|
index
,
rect
|
draw_item
(
index
,
rect
)}
draw_stroked_text
(
"用户名"
,
105
,
80
+
2
,
1
)
draw_stroked_text
(
"密码"
,
105
,
125
+
2
,
1
)
end
def
draw_item
(
index
,
rect
,
status
=
0
)
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
)
end
def
mousemoved
(
x
,
y
)
@items
.
each_pair
{
|
index
,
rect
|
#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]
}
@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
])}
end
def
index
=
(
index
)
#return if @index == index
p
index
return
if
@index
==
index
@index
=
index
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
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