Commit f7ebe964 authored by 神楽坂玲奈's avatar 神楽坂玲奈

滚动条

parent 13a0b92e
......@@ -97,6 +97,12 @@ class Scene
when 5
@active_window.scroll_down if @active_window
end
when Event::MouseButtonUp
case event.button
when Mouse::BUTTON_LEFT
update_active_window(event.x, event.y)
@active_window.mouseleftbuttonup if @active_window
end
when Event::KeyDown
case event.sym
when Key::F12
......
......@@ -57,16 +57,6 @@ class Scene_Lobby < Scene
$game.exit
$scene = Scene_Login.new
end
when Event::KeyUp
case event.sym
when Key::RETURN
determine
end
when Event::MouseButtonUp
case event.button
when Mouse::BUTTON_LEFT
determine
end
else
super
end
......@@ -98,20 +88,6 @@ class Scene_Lobby < Scene
@count += 1
super
end
def determine
case @active_window
when @roomlist
return unless @roomlist.index and room = @roomlist.items[@roomlist.index]
if room.full?
$game.watch room
@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入观战")
else
$game.join room, "test"
@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入房间")
end
end
end
def terminate
unless $scene.is_a? Scene_Lobby or $scene.is_a? Scene_Duel
$game.exit
......
......@@ -10,6 +10,7 @@ class Widget_ScrollBar < Window
@contents.fill_rect(0,0,@width, @height, 0xFFFFFFFF)
@scroll ||= 0
@scroll_max ||= 0
@scrolling = nil
Surface.transform_draw(@back,@contents,0,1,@contents.h.to_f/@back.h,0,0,0,0,0)
refresh
end
......@@ -55,6 +56,9 @@ class Widget_ScrollBar < Window
end
end
def mousemoved(x,y)
if Mouse.state[2] and @scrolling and @scroll_max > 0
@parent_window.scroll = [[0, (y - @y - @scrolling) / ((@height-40-24)/@scroll_max)].max, @scroll_max].min
end
case y-@y
when 0...20 #上按钮
self.index = :up
......@@ -70,7 +74,20 @@ class Widget_ScrollBar < Window
scroll_up
when :down
scroll_down
when :scroll
y = (@height-40-24)*@scroll/(@scroll_max)
case Mouse.state[1] - @y - 20
when 0...y
scroll_up
when y..(y+24)
@scrolling = Mouse.state[1] - @y - y
else
scroll_down
end
end
end
def mouseleftbuttonup
@scrolling = nil
end
def scroll_up
@parent_window.scroll_up
......
......@@ -72,6 +72,9 @@ class Window
def clicked
#子类定义
end
def mouseleftbuttonup
#子类定义
end
def lostfocus(active_window=nil)
#子类定义
end
......
......@@ -27,7 +27,7 @@ class Window_Chat < Window_Scrollable
Game_Event.push Game_Event::Chat.new(chatmessage)
end
@font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 14)
@scrolling = Widget_ScrollBar.new(self,@x+@width-20-8,@y+31+3,@height-68)
@scrollbar = Widget_ScrollBar.new(self,@x+@width-20-8,@y+31+3,@height-68)
@page_size = (@height-68)/WLH
@@list ||= {}
@list_splited = {}
......@@ -121,7 +121,7 @@ class Window_Chat < Window_Scrollable
@font.draw_blended_utf8(@contents, chatmessage.user.name+':', x, y, *chatmessage.name_color) if chatmessage.name_visible?
@font.draw_blended_utf8(@contents, message, x+name_width(chatmessage), y, *chatmessage.message_color) unless chatmessage.message.empty?
else
@font.draw_blended_utf8(@contents, message, x, y, *chatmessage)
@font.draw_blended_utf8(@contents, message, x, y, *chatmessage) unless message.empty?
end
end
def item_rect(index)
......
......@@ -17,7 +17,7 @@ class Window_RoomList < Window_Scrollable
@item_max = 0
@font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 16)
@color = [0x03, 0x11, 0x22]
@scrolling = Widget_ScrollBar.new(self,@x+@width,@y,@height)
@scrollbar = Widget_ScrollBar.new(self,@x+@width,@y,@height)
self.items = items
end
......@@ -36,4 +36,14 @@ class Window_RoomList < Window_Scrollable
return unless self.include?(x,y)
self.index = (y - @y) / WLH + @scroll
end
def clicked
return unless @index and room = @items[@index]
if room.full?
$game.watch room
@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入观战")
else
$game.join room, "test"
@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入房间")
end
end
end
\ No newline at end of file
......@@ -2,7 +2,7 @@
require_relative 'window_list'
class Window_Scrollable < Window_List
attr_reader :scroll
attr_accessor :scrolling
attr_accessor :scrollbar
def initialize(x, y, width, height, z=200)
super(x, y, width, height, z)
@page_size ||= @height / self.class::WLH
......@@ -40,8 +40,10 @@ class Window_Scrollable < Window_List
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, 0].max if @scrolling
@scrolling.scroll = @scroll if @scrolling
if @scrollbar
@scrollbar.scroll_max = [@items.size - @page_size, 0].max
@scrollbar.scroll = @scroll
end
end
def item_rect(index)
[0, (index-@scroll)*self.class::WLH, @width, self.class::WLH]
......
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