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
cafaae12
Commit
cafaae12
authored
Jan 12, 2012
by
zh99998
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
滚动条
parent
c89feb3c
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
185 additions
and
121 deletions
+185
-121
lib/fpstimer.rb
lib/fpstimer.rb
+1
-1
lib/game_event.rb
lib/game_event.rb
+2
-1
lib/main.rb
lib/main.rb
+2
-1
lib/scene.rb
lib/scene.rb
+2
-2
lib/scene_duel.rb
lib/scene_duel.rb
+3
-6
lib/scene_hall.rb
lib/scene_hall.rb
+5
-5
lib/widget_scrollbar.rb
lib/widget_scrollbar.rb
+27
-10
lib/window.rb
lib/window.rb
+8
-2
lib/window_action.rb
lib/window_action.rb
+15
-15
lib/window_chat.rb
lib/window_chat.rb
+1
-1
lib/window_field.rb
lib/window_field.rb
+4
-4
lib/window_gameselect.rb
lib/window_gameselect.rb
+7
-7
lib/window_list.rb
lib/window_list.rb
+17
-21
lib/window_phases.rb
lib/window_phases.rb
+5
-3
lib/window_roomchat.rb
lib/window_roomchat.rb
+1
-1
lib/window_roomlist.rb
lib/window_roomlist.rb
+18
-21
lib/window_scrollable.rb
lib/window_scrollable.rb
+49
-0
lib/window_title.rb
lib/window_title.rb
+1
-2
lib/window_user.rb
lib/window_user.rb
+5
-5
lib/window_userlist.rb
lib/window_userlist.rb
+12
-13
No files found.
lib/fpstimer.rb
View file @
cafaae12
...
...
@@ -44,7 +44,7 @@ class FPSTimer
private
def
wait
(
nxt
)
print
"-"
# 加了这货tk输入框不卡,原因不明=.=
#
print "-"# 加了这货tk输入框不卡,原因不明=.=
sleeptime
=
nxt
-
get_ticks
sleep
(
sleeptime
)
if
sleeptime
>
0
end
...
...
lib/game_event.rb
View file @
cafaae12
...
...
@@ -130,7 +130,8 @@ class Game_Event
@title
=
title
@message
=
message
@fatal
=
fatal
$log
.
error
(
@title
){
@message
}
$log
.
error
(
@fatal
?
"致命错误"
:
"一般错误"
){
"
#{
@title
}
:
#{
@message
}
"
}
$log
.
debug
caller
end
end
class
Unknown
<
Error
...
...
lib/main.rb
View file @
cafaae12
#!/usr/bin/env ruby
#encoding: UTF-8
GC
.
disable
begin
#读取配置文件
require
'yaml'
...
...
@@ -53,5 +53,6 @@ rescue Exception => exception
$scene
=
Scene_Error
.
new
retry
ensure
#(Thread.list-[Thread.main]).each{|t|t.exit} #消灭其他
$log
.
close
end
\ No newline at end of file
lib/scene.rb
View file @
cafaae12
...
...
@@ -83,9 +83,9 @@ class Scene
update_active_window
(
event
.
x
,
event
.
y
)
@active_window
.
clicked
if
@active_window
when
4
@active_window
.
cursor
_up
if
@active_window
@active_window
.
scroll
_up
if
@active_window
when
5
@active_window
.
cursor
_down
if
@active_window
@active_window
.
scroll
_down
if
@active_window
end
when
Event
::
KeyDown
case
event
.
sym
...
...
lib/scene_duel.rb
View file @
cafaae12
...
...
@@ -80,17 +80,14 @@ class Scene_Duel < Scene
end
def
handle
(
event
)
case
event
when
Event
::
MouseButton
Up
when
Event
::
MouseButton
Down
case
event
.
button
when
Mouse
::
BUTTON_LEFT
if
@phases_window
.
include?
event
.
x
,
event
.
y
@phases_window
.
mousemoved
event
.
x
,
event
.
y
change_phase
(
Window_Phases
::
Phases
[
@phases_window
.
index
])
end
when
Mouse
::
BUTTON_RIGHT
if
@player_field_window
.
action_window
@player_field_window
.
action_window
.
next
end
else
super
end
when
Event
::
KeyDown
case
event
.
sym
...
...
lib/scene_hall.rb
View file @
cafaae12
...
...
@@ -46,12 +46,12 @@ class Scene_Hall < Scene
$game
.
join
'localhost'
@joinroom_msgbox
=
Widget_Msgbox
.
new
(
"加入房间"
,
"正在加入房间"
)
when
Key
::
F5
if
@roomlist
.
list
and
room
=
@roomlist
.
list
.
find
{
|
room
|
room
.
player1
==
$game
.
user
or
room
.
player2
==
$game
.
user
}
if
@roomlist
.
items
and
room
=
@roomlist
.
items
.
find
{
|
room
|
room
.
player1
==
$game
.
user
or
room
.
player2
==
$game
.
user
}
$game
.
qroom
room
end
$game
.
refresh
when
Key
::
F12
if
@roomlist
.
list
and
room
=
@roomlist
.
list
.
find
{
|
room
|
room
.
player1
==
$game
.
user
or
room
.
player2
==
$game
.
user
}
if
@roomlist
.
items
and
room
=
@roomlist
.
items
.
find
{
|
room
|
room
.
player1
==
$game
.
user
or
room
.
player2
==
$game
.
user
}
$game
.
qroom
room
end
$game
.
exit
...
...
@@ -75,9 +75,9 @@ class Scene_Hall < Scene
def
handle_game
(
event
)
case
event
when
Game_Event
::
AllUsers
@userlist
.
list
=
$game
.
users
@userlist
.
items
=
$game
.
users
when
Game_Event
::
AllRooms
@roomlist
.
list
=
$game
.
rooms
@roomlist
.
items
=
$game
.
rooms
when
Game_Event
::
Join
require_relative
'scene_duel'
$scene
=
Scene_Duel
.
new
(
event
.
room
,
Deck
.
load
(
"test1.TXT"
))
...
...
@@ -103,7 +103,7 @@ class Scene_Hall < Scene
def
determine
case
@active_window
when
@roomlist
return
unless
@roomlist
.
index
and
room
=
@roomlist
.
list
[
@roomlist
.
index
]
return
unless
@roomlist
.
index
and
room
=
@roomlist
.
items
[
@roomlist
.
index
]
if
room
.
full?
$game
.
watch
room
@joinroom_msgbox
=
Widget_Msgbox
.
new
(
"加入房间"
,
"正在加入观战"
)
...
...
lib/widget_scrollbar.rb
View file @
cafaae12
# To change this template, choose Tools | Templates
# and open the template in the editor.
class
Widget_ScrollBar
<
Window
def
initialize
(
x
,
y
,
height
,
max
)
attr_reader
:scroll
,
:scroll_max
def
initialize
(
parent_window
,
x
,
y
,
height
)
super
(
x
,
y
,
20
,
height
,
400
)
@
max
=
max
@
parent_window
=
parent_window
@up_button
=
Surface
.
load
(
'graphics/hall/scroll_up.png'
)
@down_button
=
Surface
.
load
(
'graphics/hall/scroll_down.png'
)
@back
=
Surface
.
load
(
'graphics/hall/scroll_background.png'
)
@bar
=
Surface
.
load
(
'graphics/hall/scroll.png'
)
@contents
.
fill_rect
(
0
,
0
,
@width
,
@height
,
0xFFFFFFFF
)
@scroll
||=
0
@scroll_max
||=
0
Surface
.
transform_draw
(
@back
,
@contents
,
0
,
1
,
@contents
.
h
.
to_f
/
@back
.
h
,
0
,
0
,
0
,
0
,
0
)
refresh
end
...
...
@@ -42,12 +42,14 @@ class Widget_ScrollBar < Window
when
:up
Surface
.
blit
(
@up_button
,
status
*
20
,
0
,
20
,
20
,
@contents
,
0
,
0
)
when
:scroll
Surface
.
blit
(
@bar
,
status
*
20
,
0
,
20
,
24
,
@contents
,
0
,
20
)
return
if
@scroll_max
.
zero?
Surface
.
blit
(
@bar
,
status
*
20
,
0
,
20
,
24
,
@contents
,
0
,
20
+
(
@height
-
40
-
24
)
*
@scroll
/
(
@scroll_max
))
when
:down
Surface
.
blit
(
@down_button
,
status
*
20
,
0
,
20
,
20
,
@contents
,
0
,
@height
-
20
)
end
end
def
refresh
clear
[
:up
,
:scroll
,
:down
].
each
do
|
index
|
draw_item
(
index
,
@index
==
index
?
1
:
0
)
end
...
...
@@ -63,9 +65,24 @@ class Widget_ScrollBar < Window
end
end
def
clicked
p
@index
#case index
#when :up
#end
case
@index
when
:up
@parent_window
.
scroll
-=
1
when
:down
@parent_window
.
scroll
+=
1
end
end
def
scroll
=
(
scroll
)
return
unless
scroll
and
scroll
.
between?
(
0
,
@scroll_max
)
@scroll
=
scroll
refresh
end
def
scroll_max
=
(
scroll_max
)
return
unless
scroll_max
and
scroll_max
!=
@scroll_max
and
scroll_max
>=
0
@scroll_max
=
scroll_max
if
@scroll
>=
@scroll_max
@scroll
=
@scroll_max
end
refresh
end
end
lib/window.rb
View file @
cafaae12
...
...
@@ -74,10 +74,16 @@ class Window
def
lostfocus
(
active_window
=
nil
)
#子类定义
end
def
cursor_up
def
cursor_up
(
wrap
=
false
)
#子类定义
end
def
cursor_down
def
cursor_down
(
wrap
=
false
)
#子类定义
end
def
scroll_up
cursor_up
end
def
scroll_down
cursor_down
end
end
\ No newline at end of file
lib/window_action.rb
View file @
cafaae12
...
...
@@ -3,7 +3,7 @@ class Window_Action < Window_List
Color
=
[
0xFF
,
0xFF
,
0xFF
]
Color_Disabled
=
[
0x66
,
0x66
,
0x66
]
Color_Selected
=
[
0xFF
,
0xFF
,
0x00
]
def
initialize
#,
list,list_available=Array.new(list
.size, true))
def
initialize
#,
items,items_available=Array.new(items
.size, true))
super
(
0
,
0
,
123
,
20
*
WLH
,
300
)
#@skin = Surface.load 'graphics/field/action.png'
@up
=
Surface
.
load
(
'graphics/field/action_up.png'
)
...
...
@@ -17,13 +17,13 @@ class Window_Action < Window_List
@font
=
TTF
.
open
(
'fonts/WenQuanYi Micro Hei.ttf'
,
16
)
@visible
=
false
end
def
list
=
(
list
)
if
list
@
list
=
list
.
keys
@
list_available
=
list
.
values
@height
=
@viewport
[
3
]
=
@
list
.
size
*
WLH
+
15
*
2
@item_max
=
@
list
.
size
@index
=
@
list
_available
.
find_index
(
true
)
||
0
def
items
=
(
items
)
if
items
@
items
=
items
.
keys
@
items_available
=
items
.
values
@height
=
@viewport
[
3
]
=
@
items
.
size
*
WLH
+
15
*
2
@item_max
=
@
items
.
size
@index
=
@
items
_available
.
find_index
(
true
)
||
0
refresh
@visible
=
true
else
...
...
@@ -32,7 +32,7 @@ class Window_Action < Window_List
end
def
clear
(
x
=
0
,
y
=
0
,
width
=
@width
,
height
=
@height
)
@contents
.
put
(
@up
,
0
,
0
)
Surface
.
transform_draw
(
@middle
,
@contents
,
0
,
1
,(
@
list
.
size
*
WLH
+
20
).
to_f
/
@middle
.
h
,
0
,
0
,
0
,
15
,
Surface
::
TRANSFORM_SAFE
)
#+那里,我不知道为什么需要这么做,但是如果不+ 内容和底边会有一点空白
Surface
.
transform_draw
(
@middle
,
@contents
,
0
,
1
,(
@
items
.
size
*
WLH
+
20
).
to_f
/
@middle
.
h
,
0
,
0
,
0
,
15
,
Surface
::
TRANSFORM_SAFE
)
#+那里,我不知道为什么需要这么做,但是如果不+ 内容和底边会有一点空白
@contents
.
put
(
@down
,
0
,
@height
-
15
)
end
def
index
=
(
index
)
...
...
@@ -44,19 +44,19 @@ class Window_Action < Window_List
def
draw_item
(
index
,
status
=
0
)
case
status
when
0
color
=
@
list
_available
[
index
]
?
Color
:
Color_Disabled
@font
.
draw_blended_utf8
(
@contents
,
@
list
[
index
]
,
(
@width
-
16
*
6
)
/
2
,
index
*
WLH
+
15
,
*
color
)
color
=
@
items
_available
[
index
]
?
Color
:
Color_Disabled
@font
.
draw_blended_utf8
(
@contents
,
@
items
[
index
]
,
(
@width
-
16
*
6
)
/
2
,
index
*
WLH
+
15
,
*
color
)
when
1
@font
.
draw_blended_utf8
(
@contents
,
@
list
[
index
]
,
(
@width
-
16
*
6
)
/
2
,
index
*
WLH
+
15
,
*
Color_Selected
)
@font
.
draw_blended_utf8
(
@contents
,
@
items
[
index
]
,
(
@width
-
16
*
6
)
/
2
,
index
*
WLH
+
15
,
*
Color_Selected
)
end
end
def
next
if
index
=
@
list_available
[
@index
.
next
...
@list
.
size
].
find_index
(
true
)
if
index
=
@
items_available
[
@index
.
next
...
@items
.
size
].
find_index
(
true
)
self
.
index
=
index
+
@index
.
next
elsif
index
=
@
list
_available
[
0
..
@index
].
find_index
(
true
)
elsif
index
=
@
items
_available
[
0
..
@index
].
find_index
(
true
)
self
.
index
=
index
else
self
.
index
=
(
@index
+
1
)
%
@
list
.
size
self
.
index
=
(
@index
+
1
)
%
@
items
.
size
end
end
def
mousemoved
(
x
,
y
)
...
...
lib/window_chat.rb
View file @
cafaae12
...
...
@@ -13,7 +13,7 @@ class Window_Chat < Window
super
(
x
,
y
,
width
,
height
)
@chat_input
=
Widget_InputBox
.
new
(
416
,
723
,
586
,
24
){
|
text
|
$game
.
chat
text
;
add
(
$game
.
user
,
text
)}
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
16
)
@scroll
=
Widget_ScrollBar
.
new
(
@x
+
@width
-
20
,
@y
,
@height
,
0
)
@scroll
=
Widget_ScrollBar
.
new
(
self
,
@x
+
@width
-
20
,
@y
,
@height
)
@list
=
[]
end
def
add
(
user
,
content
)
...
...
lib/window_field.rb
View file @
cafaae12
...
...
@@ -102,7 +102,7 @@ class Window_Field < Window
end
if
index
.
nil?
or
!
@items
.
has_key?
(
index
)
or
(
index
==
:deck
and
@field
.
deck
.
empty?
)
or
(
index
==
:removed
and
@field
.
removed
.
empty?
)
or
(
index
==
:extra
and
@field
.
extra
.
empty?
)
or
(
index
==
:graveyard
and
@field
.
graveyard
.
empty?
)
@index
=
nil
@action_window
.
list
=
nil
if
@action_window
@action_window
.
items
=
nil
if
@action_window
else
@index
=
index
draw_item
(
@index
,
1
)
...
...
@@ -185,7 +185,7 @@ class Window_Field < Window
}
end
if
@action_window
@action_window
.
list
=
@action_names
@action_window
.
items
=
@action_names
@action_window
.
x
=
@x
+
@items
[
@index
][
0
]
-
(
@action_window
.
width
-
@items
[
@index
][
2
])
/
2
@action_window
.
y
=
@y
+
@items
[
@index
][
1
]
-
@action_window
.
height
end
...
...
@@ -206,10 +206,10 @@ class Window_Field < Window
@action_window
.
cursor_down
if
@action_window
end
def
cursor_left
#self.index = @index ? (@index - 1) % [@
list
.size, @item_max].min : 0
#self.index = @index ? (@index - 1) % [@
items
.size, @item_max].min : 0
end
def
cursor_right
#self.index = @index ? (@index + 1) % [@
list
.size, @item_max].min : 0
#self.index = @index ? (@index + 1) % [@
items
.size, @item_max].min : 0
end
def
lostfocus
(
active_window
=
nil
)
if
active_window
!=
@action_window
...
...
lib/window_gameselect.rb
View file @
cafaae12
...
...
@@ -6,29 +6,29 @@ class Window_GameSelect < Window_List
@color
=
[
255
,
255
,
255
]
@game_color
=
[
47
,
156
,
192
]
@game_stroke_color
=
[
0xFF
,
0xFF
,
0xFF
]
@
list
=
[]
@
items
=
[]
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
@
items
<<
game
else
$log
.
warn
"
#{
game
.
inspect
}
读取失败(
#{
file
}
)"
end
end
super
(
x
,
y
,
160
,
@
list
.
size
*
WLH
)
super
(
x
,
y
,
160
,
@
items
.
size
*
WLH
)
clear
@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
self
.
items
=
@items
self
.
index
=
@
items
.
find_index
{
|
game
|
game
[
"name"
]
==
game_name
}
||
0
clicked
refresh
end
def
draw_item
(
index
,
status
=
0
)
Surface
.
blit
(
@button
,
@button
.
w
/
3
*
status
,
0
,
@button
.
w
/
3
,
@button
.
h
,
@contents
,
0
,
WLH
*
index
)
draw_stroked_text
(
@
list
[
index
][
"name"
],
24
,
WLH
*
index
+
14
,
2
)
draw_stroked_text
(
@
items
[
index
][
"name"
],
24
,
WLH
*
index
+
14
,
2
)
end
def
item_rect
(
index
)
[
0
,
WLH
*
index
,
@button
.
w
,
@button
.
h
]
...
...
@@ -54,7 +54,7 @@ class Window_GameSelect < Window_List
draw_item
(
@index
,
1
)
end
def
clicked
load
@
list
[
@index
][
"file"
]
#TODO: load的这种架构微蛋疼,一时想不到更好的方案
load
@
items
[
@index
][
"file"
]
#TODO: load的这种架构微蛋疼,一时想不到更好的方案
@login_window
.
destroy
if
@login_window
@login_window
=
Window_Login
.
new
(
316
,
316
,
$config
[
"username"
],
$config
[
"password"
])
end
...
...
lib/window_list.rb
View file @
cafaae12
#encoding: UTF-8
#==============================================================================
# ■ Window_Room
List
# ■ Window_Room
items
#------------------------------------------------------------------------------
# 大厅内房间列表
#==============================================================================
require_relative
'window'
class
Window_List
<
Window
attr_reader
:
list
attr_reader
:
items
attr_reader
:index
def
initialize
(
x
,
y
,
width
,
height
,
z
=
200
)
@
list
||=
[]
@
items
||=
[]
@index
||=
nil
super
(
x
,
y
,
width
,
height
,
z
)
@o_index
=
0
@item_max
=
0
@column_max
=
1
end
def
index
=
(
index
)
index
=
nil
if
index
<
0
or
index
>=
@item
_max
if
index
index
=
nil
if
index
<
0
or
index
>=
@item
s
.
size
if
index
return
if
index
==
@index
if
@index
clear
(
*
item_rect
(
@index
))
draw_item
(
@index
,
0
)
draw_item
(
@index
,
0
)
if
@items
[
@index
]
end
if
index
.
nil?
or
index
<
0
or
index
>=
@item
_max
if
index
.
nil?
or
index
<
0
or
index
>=
@item
s
.
size
@index
=
nil
else
@index
=
index
...
...
@@ -37,30 +34,29 @@ class Window_List < Window
#子类定义
end
def
item_rect
(
index
)
[
0
,
@
index
*
self
.
class
::
WLH
,
@width
,
self
.
class
::
WLH
]
[
0
,
index
*
self
.
class
::
WLH
,
@width
,
self
.
class
::
WLH
]
end
def
list
=
(
list
)
@list
=
list
@item_max
=
@list
.
size
def
items
=
(
items
)
@items
=
items
refresh
end
def
refresh
clear
@item
_max
.
times
{
|
index
|
draw_item
(
index
,
index
==
@index
?
1
:
0
)}
@item
s
.
each_index
{
|
index
|
draw_item
(
index
,
index
==
@index
?
1
:
0
)}
end
def
cursor_up
self
.
index
=
@index
?
(
@index
-
@column_max
)
%
[
@
list
.
size
,
@item_max
].
min
:
0
def
cursor_up
(
wrap
=
false
)
self
.
index
=
@index
?
(
@index
-
@column_max
)
%
[
@
items
.
size
,
@items
.
size
].
min
:
0
end
def
cursor_down
def
cursor_down
(
wrap
=
false
)
#if @index
self
.
index
=
@index
?
((
@index
+
@column_max
)
%
[
@
list
.
size
,
@item_max
].
min
)
:
0
#p @index, @index + @column_max, [@
list.size, @item_max].min, (@index + @column_max) % [@list.size, @item_max].min, @index ? ((@index + @column_max) % [@list.size, @item_max
].min) : 0
self
.
index
=
@index
?
((
@index
+
@column_max
)
%
[
@
items
.
size
,
@items
.
size
].
min
)
:
0
#p @index, @index + @column_max, [@
items.size, @items.size].min, (@index + @column_max) % [@items.size, @items.size].min, @index ? ((@index + @column_max) % [@items.size, @items.size
].min) : 0
end
def
cursor_left
self
.
index
=
@index
?
(
@index
-
1
)
%
[
@
list
.
size
,
@item_max
].
min
:
0
self
.
index
=
@index
?
(
@index
-
1
)
%
[
@
items
.
size
,
@items
.
size
].
min
:
0
end
def
cursor_right
self
.
index
=
@index
?
(
@index
+
1
)
%
[
@
list
.
size
,
@item_max
].
min
:
0
self
.
index
=
@index
?
(
@index
+
1
)
%
[
@
items
.
size
,
@items
.
size
].
min
:
0
end
def
mousemoved
(
x
,
y
)
#子类定义
...
...
lib/window_phases.rb
View file @
cafaae12
class
Window_Phases
<
Window_List
WLH
=
81
#其实是列宽
Phases
=
[
:DP
,
:SP
,
:M1
,
:BP
,
:M2
,
:EP
]
def
initialize
(
x
,
y
)
@phases_player
=
Surface
.
load
(
'graphics/system/phases_player.png'
)
@phases_player
.
set_alpha
(
RLEACCEL
,
255
)
@phases_opponent
=
Surface
.
load
(
'graphics/system/phases_opponent.png'
)
@phases_opponent
.
set_alpha
(
RLEACCEL
,
255
)
super
(
x
,
y
,
5
*
WLH
+
@phases_player
.
w
/
3
,
@phases_player
.
h
/
6
)
@
column_max
=
@item_max
=
6
@
items
=
[
:DP
,
:SP
,
:M1
,
:BP
,
:M2
,
:EP
]
self
.
player
=
true
end
def
player
=
(
player
)
...
...
@@ -17,7 +16,7 @@ class Window_Phases < Window_List
refresh
end
def
phase
=
(
phase
)
phase
=
Phase
s
.
index
(
phase
)
unless
(
0
..
5
).
include?
phase
phase
=
@item
s
.
index
(
phase
)
unless
(
0
..
5
).
include?
phase
return
if
phase
==
@phase
@index
=
@phase
@phase
=
phase
...
...
@@ -36,4 +35,7 @@ class Window_Phases < Window_List
def
clear
(
x
=
0
,
y
=
0
,
width
=
@width
,
height
=
@height
)
@contents
.
fill_rect
(
x
,
y
,
width
,
height
,
0x00000000
)
end
def
clicked
$scene
.
change_phase
(
@items
[
@index
])
end
end
\ No newline at end of file
lib/window_roomchat.rb
View file @
cafaae12
...
...
@@ -18,7 +18,7 @@ class Window_RoomChat < Window
end
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
14
)
@contents
.
fill_rect
(
0
,
0
,
@width
,
@height
,
0x99FFFFFF
)
@scroll
=
Widget_ScrollBar
.
new
(
@x
+
@width
-
20
,
@y
,
@height
,
0
)
@scroll
=
Widget_ScrollBar
.
new
(
self
,
@x
+
@width
-
20
,
@y
,
@height
)
@list
=
[]
$chat_window
=
self
end
...
...
lib/window_roomlist.rb
View file @
cafaae12
#encoding: UTF-8
#==============================================================================
# ■ Window_Room
List
# ■ Window_Room
items
#------------------------------------------------------------------------------
# 大厅内房间列表
#==============================================================================
class
Window_RoomList
<
Window_
List
attr_reader
:
list
require_relative
'window_scrollable'
class
Window_RoomList
<
Window_
Scrollable
attr_reader
:
items
WLH
=
48
def
initialize
(
x
,
y
,
list
)
def
initialize
(
x
,
y
,
items
)
@button
=
Surface
.
load
(
'graphics/hall/room.png'
)
@button
.
set_alpha
(
RLEACCEL
,
255
)
#@background = Surface.load 'graphics/hall/room
list
.png'
#@contents = Surface.load 'graphics/hall/room
list
.png'
#@background = Surface.load 'graphics/hall/room
items
.png'
#@contents = Surface.load 'graphics/hall/room
items
.png'
super
(
x
,
y
,
@button
.
w
/
3
,
48
*
10
)
@item_max
=
0
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
16
)
@color
=
[
0x03
,
0x11
,
0x22
]
@scroll
=
Widget_ScrollBar
.
new
(
@x
+
@width
,
@y
,
@height
,
0
)
self
.
list
=
list
@old_x
=
@old_y
=
-
1
@scrolling
=
Widget_ScrollBar
.
new
(
self
,
@x
+
@width
,
@y
,
@height
)
self
.
items
=
items
end
def
draw_item
(
index
,
status
=
0
)
room
=
@list
[
index
]
Surface
.
blit
(
@button
,
@width
*
status
,
room
.
full?
?
WLH
:
0
,
@width
,
WLH
,
@contents
,
0
,
WLH
*
index
)
@font
.
draw_blended_utf8
(
@contents
,
"R-
#{
room
.
id
}
"
,
24
,
WLH
*
index
+
8
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
room
.
full?
?
"【决斗中】"
:
room
.
private?
?
"【私密房】"
:
"【等待中】"
,
8
,
WLH
*
index
+
24
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
room
.
name
,
128
,
WLH
*
index
+
8
,
*
room
.
color
)
@font
.
draw_blended_utf8
(
@contents
,
room
.
player1
.
name
,
128
,
WLH
*
index
+
24
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
room
.
player2
.
name
,
256
,
WLH
*
index
+
24
,
*
@color
)
if
room
.
full?
y
=
item_rect
(
index
)[
1
]
room
=
@items
[
index
]
Surface
.
blit
(
@button
,
@width
*
status
,
room
.
full?
?
WLH
:
0
,
@width
,
WLH
,
@contents
,
0
,
y
)
@font
.
draw_blended_utf8
(
@contents
,
"R-
#{
room
.
id
}
"
,
24
,
y
+
8
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
room
.
full?
?
"【决斗中】"
:
room
.
private?
?
"【私密房】"
:
"【等待中】"
,
8
,
y
+
24
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
room
.
name
,
128
,
y
+
8
,
*
room
.
color
)
@font
.
draw_blended_utf8
(
@contents
,
room
.
player1
.
name
,
128
,
y
+
24
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
room
.
player2
.
name
,
256
,
y
+
24
,
*
@color
)
if
room
.
full?
end
def
item_rect
(
index
)
[
@x
,
WLH
*
index
,
@width
,
WLH
]
end
def
mousemoved
(
x
,
y
)
return
unless
self
.
include?
(
x
,
y
)
self
.
index
=
(
y
-
@y
)
/
WLH
self
.
index
=
(
y
-
@y
)
/
WLH
+
@scroll
end
end
\ No newline at end of file
lib/window_scrollable.rb
0 → 100644
View file @
cafaae12
#encoding: UTF-8
require_relative
'window_list'
class
Window_Scrollable
<
Window_List
attr_reader
:scroll
attr_accessor
:scrolling
def
initialize
(
x
,
y
,
width
,
height
,
z
=
200
)
super
(
x
,
y
,
width
,
height
,
z
)
@page_size
||=
@height
/
self
.
class
::
WLH
@scroll
||=
0
end
def
cursor_up
(
wrap
=
false
)
return
unless
wrap
or
@index
.
nil?
or
@index
>
0
self
.
index
=
@index
?
(
@index
-
@scroll
-
1
)
%
@items
.
size
+
@scroll
:
@scroll
end
def
cursor_down
(
wrap
=
false
)
return
unless
wrap
or
@index
.
nil?
or
@index
<
@items
.
size
-
1
self
.
index
=
@index
?
(
@index
-
@scroll
+
1
)
%
@items
.
size
+
@scroll
:
@scroll
end
def
scroll_up
cursor_up
(
false
)
self
.
scroll
-=
1
end
def
scroll_down
cursor_down
(
false
)
self
.
scroll
+=
1
end
def
scroll
=
(
scroll
)
return
unless
scroll
!=
@scroll
and
scroll
and
scroll
>=
0
and
scroll
<=
@items
.
size
-
@page_size
#有背景的不能这么用....
#if scroll > @scroll
# Surface.blit(@contents, 0, self.class::WLH * (scroll - @scroll), @width, (@page_size - (scroll - @scroll)) * self.class::WLH, @contents, 0, 0)
# clear(0, @page_size - (scroll - @scroll) * self.class::WLH, @width, self.class::WLH * (scroll - @scroll))
#else
# Surface.blit(@contents, 0, 0, @width, (@page_size - (scroll - @scroll)) * self.class::WLH, @contents, 0, self.class::WLH * (scroll - @scroll))
# clear(0, 0, @width, self.class::WLH * (scroll - @scroll))
#end
@scroll
=
scroll
@scrolling
.
scroll
=
@scroll
if
@scrolling
refresh
end
def
refresh
clear
(
@scroll
...
[(
@scroll
+
@page_size
),
@items
.
size
].
min
).
each
{
|
index
|
draw_item
(
index
,
@index
==
index
?
1
:
0
)}
@scrolling
.
scroll_max
=
@items
.
size
-
@page_size
if
@scrolling
end
def
item_rect
(
index
)
[
0
,
(
index
-
@scroll
)
*
self
.
class
::
WLH
,
@width
,
self
.
class
::
WLH
]
end
end
lib/window_title.rb
View file @
cafaae12
...
...
@@ -9,8 +9,7 @@ class Window_Title < Window_List
@single_height
=
@button
.
h
/
Button_Count
super
(
x
,
y
,
@button
.
w
/
3
,
WLH
*
Button_Count
-
(
WLH
-
@button
.
h
/
Button_Count
))
@cursor_se
=
Mixer
::
Wave
.
load
'audio/se/cursor.ogg'
@item_max
=
6
refresh
self
.
items
=
[:
决斗开始
,
:
单人模式
,
:
卡组编成
,
:
选项设置
,
:
退出游戏
]
end
def
index
=
(
index
)
if
index
and
@index
!=
index
...
...
lib/window_user.rb
View file @
cafaae12
...
...
@@ -9,10 +9,10 @@ class Window_User < Window_List
@contents
=
Surface
.
load
(
"graphics/hall/user.png"
).
display_format
#TODO:调用已经加载了的背景
@avatar_boarder
=
Surface
.
load
(
"graphics/hall/avatar_boader.png"
)
@
list
=
[
"发送消息"
,
"查看资料"
]
@
list
<<
"加入游戏"
if
user
.
status
==
:waiting
@
list
<<
"观战"
if
user
.
status
==
:dueling
@item_max
=
@
list
.
size
@
items
=
[
"发送消息"
,
"查看资料"
]
@
items
<<
"加入游戏"
if
user
.
status
==
:waiting
@
items
<<
"观战"
if
user
.
status
==
:dueling
@item_max
=
@
items
.
size
refresh
end
def
refresh
...
...
@@ -34,7 +34,7 @@ class Window_User < Window_List
end
def
draw_item
(
index
,
status
=
0
)
@font
.
draw_blended_utf8
(
@contents
,
@
list
[
index
]
,
172
,
96
+
index
*
WLH
,
0x00
,
0x00
,
0x00
)
@font
.
draw_blended_utf8
(
@contents
,
@
items
[
index
]
,
172
,
96
+
index
*
WLH
,
0x00
,
0x00
,
0x00
)
end
def
item_rect
(
index
)
[
172
,
96
+
index
*
WLH
,
128
,
WLH
]
...
...
lib/window_userlist.rb
View file @
cafaae12
...
...
@@ -4,12 +4,13 @@
# title
#==============================================================================
require_relative
'window_user'
class
Window_UserList
<
Window_List
require_relative
'window_scrollable'
class
Window_UserList
<
Window_Scrollable
attr_reader
:x
,
:y
,
:width
,
:height
WLH
=
20
def
initialize
(
x
,
y
,
list
)
#@contents = Surface.load "graphics/hall/user
list
.png"
#@background = Surface.load "graphics/hall/user
list
.png"
def
initialize
(
x
,
y
,
items
)
#@contents = Surface.load "graphics/hall/user
items
.png"
#@background = Surface.load "graphics/hall/user
items
.png"
super
(
x
,
y
,
272
,
540
)
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
16
)
@color
=
[
0x03
,
0x11
,
0x22
]
...
...
@@ -17,35 +18,33 @@ class Window_UserList < Window_List
@color_click
=
[
200
,
200
,
255
,
0x03
,
0x11
,
0x22
]
#@contents.set_alpha(RLEACCEL, 80)
@contents
.
fill_rect
(
0
,
0
,
@width
,
@height
,
0xFFFFFFFF
)
self
.
list
=
list
self
.
items
=
items
#@contents.f
end
def
draw_item
(
index
,
status
=
0
)
case
status
when
0
@font
.
draw_blended_utf8
(
@contents
,
@
list
[
index
].
name
,
0
,
index
*
WLH
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
@
items
[
index
].
name
,
0
,
item_rect
(
index
)[
1
]
,
*
@color
)
when
1
@font
.
draw_shaded_utf8
(
@contents
,
@
list
[
index
].
name
,
0
,
index
*
WLH
,
*
@color_over
)
@font
.
draw_shaded_utf8
(
@contents
,
@
items
[
index
].
name
,
0
,
item_rect
(
index
)[
1
]
,
*
@color_over
)
when
2
@font
.
draw_shaded_utf8
(
@contents
,
@
list
[
index
].
name
,
0
,
index
*
WLH
,
*
@color_click
)
@font
.
draw_shaded_utf8
(
@contents
,
@
items
[
index
].
name
,
0
,
item_rect
(
index
)[
1
]
,
*
@color_click
)
end
end
#def clear(x=0, y=0, width=@width, height=@height)
# Surface.blit(x, )
#end
def
item_rect
(
index
)
[
0
,
WLH
*
index
,
@width
,
WLH
]
end
#def clear(x=0,y=0,width=@width,height=@height)
# @contents.fill_rect(x,y,width,height,0x66FFFFFF)
#end
def
clicked
#$scene.refresh_rect(*item_rect(@index)){draw_item(@index, 2)} if @index
return
unless
@index
@userwindow
=
Window_User
.
new
(
100
,
100
,
@
list
[
@index
])
@userwindow
=
Window_User
.
new
(
100
,
100
,
@
items
[
@index
])
end
def
mousemoved
(
x
,
y
)
return
unless
include
?(
x
,
y
)
self
.
index
=
(
y
-
@y
)
/
WLH
self
.
index
=
(
y
-
@y
)
/
WLH
+
@scroll
end
end
\ No newline at end of file
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