Commit 7252ed1a authored by 神楽坂玲奈's avatar 神楽坂玲奈

temp2

parent 59e18392
This diff is collapsed.
#encoding: UTF-8 #encoding: UTF-8
#============================================================================== #==============================================================================
# Scene_Lobby # Scene_Lobby
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# 大厅 # 大厅
#============================================================================== #==============================================================================
class Scene_Lobby < Scene class Scene_Lobby < Scene
require_relative 'window_userlist' require_relative 'window_userlist'
require_relative 'window_userinfo' require_relative 'window_userinfo'
require_relative 'window_roomlist' require_relative 'window_roomlist'
require_relative 'window_chat' require_relative 'window_chat'
require_relative 'window_host' require_relative 'window_host'
require_relative 'window_lobbybuttons' require_relative 'window_lobbybuttons'
require_relative 'chatmessage' require_relative 'chatmessage'
require_relative 'scene_duel' require_relative 'scene_duel'
attr_reader :chat_window attr_reader :chat_window
def start def start
WM::set_caption("MyCard v#{Update::Version} - #{$config['game']} - #{$game.user.name}(#{$game.user.id})", "MyCard") WM::set_caption("MyCard v#{Update::Version} - #{$config['game']} - #{$game.user.name}(#{$game.user.id})", "MyCard")
$game.refresh $game.refresh
@background = Surface.load("graphics/lobby/background.png").display_format @background = Surface.load("graphics/lobby/background.png").display_format
Surface.blit(@background,0,0,0,0,$screen,0,0) Surface.blit(@background,0,0,0,0,$screen,0,0)
@userlist = Window_UserList.new(24,204,$game.users) @userlist = Window_UserList.new(24,204,$game.users)
@roomlist = Window_RoomList.new(320,50,$game.rooms) @roomlist = Window_RoomList.new(320,50,$game.rooms)
@userinfo = Window_UserInfo.new(24,24, $game.user) @userinfo = Window_UserInfo.new(24,24, $game.user)
@host_window = Window_LobbyButtons.new(748,18) @host_window = Window_LobbyButtons.new(748,18)
@active_window = @roomlist @active_window = @roomlist
@chat_window = Window_Chat.new(313,543,698,212) @chat_window = Window_Chat.new(313,543,698,212)
@count = 0 @count = 0
super super
end end
def bgm def bgm
"lobby.ogg" "lobby.ogg"
end end
def handle(event) def handle(event)
case event case event
when Event::KeyDown when Event::KeyDown
case event.sym case event.sym
when Key::UP when Key::UP
@active_window.cursor_up @active_window.cursor_up
when Key::DOWN when Key::DOWN
@active_window.cursor_down @active_window.cursor_down
when Key::F2 when Key::F2
#@joinroom_msgbox = Widget_Msgbox.new("创建房间", "正在等待对手") #@joinroom_msgbox = Widget_Msgbox.new("创建房间", "正在等待对手")
#$game.host Room.new(0, $game.user.name) #$game.host Room.new(0, $game.user.name)
when Key::F3 when Key::F3
#@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入房间") #@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入房间")
#$game.join 'localhost' #$game.join 'localhost'
when Key::F5 when Key::F5
$game.refresh $game.refresh
when Key::F12 when Key::F12
$game.exit $game.exit
$scene = Scene_Login.new $scene = Scene_Login.new
end end
else else
super super
end end
end end
def handle_game(event) def handle_game(event)
case event case event
when Game_Event::AllUsers when Game_Event::AllUsers
@userlist.items = $game.users @userlist.items = $game.users
when Game_Event::AllRooms when Game_Event::AllRooms
@roomlist.items = $game.rooms @roomlist.items = $game.rooms
when Game_Event::Join when Game_Event::Join
join(event.room) join(event.room)
when Game_Event::Watch when Game_Event::Watch
require_relative 'scene_watch' require_relative 'scene_watch'
$scene = Scene_Watch.new(event.room) $scene = Scene_Watch.new(event.room)
when Game_Event::Chat when Game_Event::Chat
@chat_window.add event.chatmessage @chat_window.add event.chatmessage
else else
super super
end end
end end
def join(room) def join(room)
$scene = Scene_Duel.new(room) $scene = Scene_Duel.new(room)
end end
def update def update
@chat_window.update @chat_window.update
@host_window.update @host_window.update
@roomlist.update @roomlist.update
if @count >= $game.refresh_interval*60 if @count >= $game.refresh_interval*60
$game.refresh $game.refresh
@count = 0 @count = 0
end end
@count += 1 @count += 1
super super
end end
def terminate def terminate
unless $scene.is_a? Scene_Lobby or $scene.is_a? Scene_Duel unless $scene.is_a? Scene_Lobby or $scene.is_a? Scene_Duel
$game.exit $game.exit
end end
end end
end end
\ No newline at end of file
This diff is collapsed.
#encoding: UTF-8 #encoding: UTF-8
#============================================================================== #==============================================================================
# ■ Window_Roomitems # ■ Window_Roomitems
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
#  大厅内房间列表 #  大厅内房间列表
#============================================================================== #==============================================================================
require_relative 'window_scrollable' require_relative 'window_scrollable'
require_relative 'window_join' require_relative 'window_join'
class Window_RoomList < Window_Scrollable class Window_RoomList < Window_Scrollable
attr_reader :items attr_reader :items
WLH = 48 WLH = 48
def initialize(x, y, items) def initialize(x, y, items)
@button = Surface.load('graphics/lobby/room.png') @button = Surface.load('graphics/lobby/room.png')
@button.set_alpha(RLEACCEL, 255) @button.set_alpha(RLEACCEL, 255)
#@background = Surface.load 'graphics/lobby/roomitems.png' #@background = Surface.load 'graphics/lobby/roomitems.png'
#@contents = Surface.load 'graphics/lobby/roomitems.png' #@contents = Surface.load 'graphics/lobby/roomitems.png'
super(x,y,@button.w / 3, 48 * 10) super(x,y,@button.w / 3, 48 * 10)
@item_max = 0 @item_max = 0
@font = TTF.open("fonts/wqy-microhei.ttc", 16) @font = TTF.open("fonts/wqy-microhei.ttc", 16)
@color = [0x03, 0x11, 0x22] @color = [0x03, 0x11, 0x22]
@scrollbar = Widget_ScrollBar.new(self,@x+@width,@y,@height) @scrollbar = Widget_ScrollBar.new(self,@x+@width,@y,@height)
self.items = items self.items = items
end end
def draw_item(index, status=0) def draw_item(index, status=0)
y = item_rect(index)[1] y = item_rect(index)[1]
room = @items[index] room = @items[index]
Surface.blit(@button, @width*status, room.full? ? WLH : 0, @width, WLH, @contents, 0, y) Surface.blit(@button, @width*status, room.full? ? WLH : 0, @width, WLH, @contents, 0, y)
@font.draw_blended_utf8(@contents, room.id.to_s, 24, y+8, *@color) @font.draw_blended_utf8(@contents, room.id.to_s, 24, y+8, *@color)
@font.draw_blended_utf8(@contents, room.full? ? "【决斗中】" : room.private? ? "【私密房】" : "【等待中】", 8, y+24, *@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) unless room.name.empty? or room.name.size > 100 @font.draw_blended_utf8(@contents, room.name, 128, y+8, *room.color) unless room.name.empty? or room.name.size > 100
$log.error('标题过长') {room.name} if room.name.size > 100 $log.error('标题过长') {room.name} if room.name.size > 100
@font.draw_blended_utf8(@contents, room.player1.name, 128, y+24, *room.player1.color) if room.player1 and !room.player1.name.empty? @font.draw_blended_utf8(@contents, room.player1.name, 128, y+24, *room.player1.color) if room.player1 and !room.player1.name.empty?
@font.draw_blended_utf8(@contents, room.player2.name, 320, y+24, *room.player2.color) if room.player2 and !room.player2.name.empty? @font.draw_blended_utf8(@contents, room.player2.name, 320, y+24, *room.player2.color) if room.player2 and !room.player2.name.empty?
room.extra.each_with_index do |extra, index| room.extra.each_with_index do |extra, index|
str, color = extra str, color = extra
@font.draw_blended_utf8(@contents, str, 300+index*96, y+8, *color) @font.draw_blended_utf8(@contents, str, 300+index*96, y+8, *color)
end end
end end
def update def update
@join_window.update if @join_window and !@join_window.destroyed? @join_window.update if @join_window and !@join_window.destroyed?
end end
def mousemoved(x,y) def mousemoved(x,y)
return unless self.include?(x,y) return unless self.include?(x,y)
self.index = (y - @y) / WLH + @scroll self.index = (y - @y) / WLH + @scroll
end end
def clicked def clicked
return unless @index and room = @items[@index] return unless @index and room = @items[@index]
if room.full? if room.full?
@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入观战") @joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入观战")
$game.watch room $game.watch room
else else
if room.private if room.private
@join_window = Window_Join.new(0,0,room) @join_window = Window_Join.new(0,0,room)
else else
@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入房间") @joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入房间")
$game.join room $game.join room
end end
end end
end end
end end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment