Commit 2bf29600 authored by 神楽坂玲奈's avatar 神楽坂玲奈

临时,不能用

parent 3d02ed93
This diff was suppressed by a .gitattributes entry.
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#============================================================================== #==============================================================================
class Scene class Scene
attr_reader :windows
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# ● 主处理 # ● 主处理
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
...@@ -16,6 +17,9 @@ class Scene ...@@ -16,6 +17,9 @@ class Scene
end end
terminate terminate
end end
def initialize
@windows = []
end
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# ● 开始处理 # ● 开始处理
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
...@@ -44,6 +48,11 @@ class Scene ...@@ -44,6 +48,11 @@ class Scene
while event = Event.poll while event = Event.poll
handle(event) handle(event)
end end
$screen.fill_rect(0,0,0,0,0x000000)
@windows.each do |window|
$screen.put(window.contents, window.x, window.y) if window.contents
end
$screen.update_rect(0,0,0,0)
end end
def handle(event) def handle(event)
case event case event
......
class Window class Window
attr_reader :x, :y, :width, :height attr_reader :x, :y, :width, :height, :z, :contents
def initialize(x, y, width, height) def initialize(x, y, width, height, z=200)
@x = x @x = x
@y = y @y = y
@z = z
@width = width @width = width
@height = height @height = height
unless @background
@background = Surface.new(SWSURFACE|SRCALPHA, @width, @height, 32, 0xFF0000, 0x00FF00, 0x0000FF, 0xFF000000)
@background.fill_rect(0,0,@width,@height,0xFF00FF00)
end
unless @contents
@contents = Surface.new(SWSURFACE|SRCALPHA, @width, @height, 32, 0xFF0000, 0x00FF00, 0x0000FF, 0xFF000000)
@contents.fill_rect(0,0,@width,@height,0xFF00FF00)
end
#按Z坐标插入
unless $scene.windows.each_with_index do |window, index|
if window.z > @z
$scene.windows.insert(index, self)
break true
end
end == true
$scene.windows << self
end
end end
def refresh
end
def include?(x,y) def include?(x,y)
x > @x && x < @x + @width && y > @y && y < @y + @height x > @x && x < @x + @width && y > @y && y < @y + @height
end end
def dispose def destroy
$scene.refresh_rect(@x, @y, @width, @height) @destroted = true
@contents.destroy if @contents
end
def destroted?
@destroted
end
def update
#子类定义
end
def refresh
#子类定义
end
def clear(x, y, width, height)
Surface.blit()
@contents.put(background.put
end end
end end
\ No newline at end of file
...@@ -16,9 +16,9 @@ class Window_List < Window ...@@ -16,9 +16,9 @@ class Window_List < Window
end end
def index=(index) def index=(index)
return if index == @index || @item_max.zero? return if index == @index || @item_max.zero?
$scene.refresh_rect(*item_rect(@index)){draw_item(@index, 0)} if @index draw_item(@index, 0) if @index
@index = index @index = index
$scene.refresh_rect(*item_rect(@index)){draw_item(@index, 1)} if @index draw_item(@index, 1) if @index
end end
...@@ -29,11 +29,7 @@ class Window_List < Window ...@@ -29,11 +29,7 @@ class Window_List < Window
#子类定义 #子类定义
end end
def refresh def refresh
$scene.refresh_rect(@x, @y, @width, @height) do @item_max.times {|index|draw_item(index)}
@item_max.times do |index|
draw_item(index)
end
end
end end
def cursor_up def cursor_up
self.index = @index ? (@index - @column_max) % [@list.size, @item_max].min : 0 self.index = @index ? (@index - @column_max) % [@list.size, @item_max].min : 0
......
...@@ -5,27 +5,32 @@ ...@@ -5,27 +5,32 @@
#============================================================================== #==============================================================================
class Window_PlayerList < Window_List class Window_PlayerList < Window_List
BackGround = Surface.load "graphics/hall/playerlist.png"
attr_reader :x, :y, :width, :height attr_reader :x, :y, :width, :height
WLH = 16 WLH = 24
def initialize(x, y) def initialize(x, y)
super(x,y,272,16*34) @contents = Surface.load "graphics/hall/playerlist.png"
@font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", WLH) super(x,y,272,WLH*22)
@font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 20)
@color = [0x03, 0x11, 0x22] @color = [0x03, 0x11, 0x22]
@color_over = [0x03, 0x11, 0x22, 200,200,255] @color_over = [0x03, 0x11, 0x22, 200,200,255]
@color_click = [200,200,255, 0x03, 0x11, 0x22] @color_click = [200,200,255, 0x03, 0x11, 0x22]
#@contents.fill_rect(0,0,0,0,0xFFFFFFFF)
refresh
#@contents.f
end end
def draw_item(index, status=0) def draw_item(index, status=0)
case status case status
when 0 when 0
@font.draw_blended_utf8($screen, @list[index].name, @x, @y+index*WLH, *@color) @font.draw_blended_utf8(@contents, @list[index].name, 0, index*WLH, *@color)
when 1 when 1
@font.draw_shaded_utf8($screen, @list[index].name, @x, @y+index*WLH, *@color_over) @font.draw_shaded_utf8(@contents, @list[index].name, 0, index*WLH, *@color_over)
when 2 when 2
@font.draw_shaded_utf8($screen, @list[index].name, @x, @y+index*WLH, *@color_click) @font.draw_shaded_utf8(@contents, @list[index].name, 0, index*WLH, *@color_click)
end end
end end
def item_rect(index) def item_rect(index)
[@x, @y+WLH*index, @width, WLH] [0, WLH*index, @width, WLH]
end end
def list=(list) def list=(list)
@list = list @list = list
...@@ -34,7 +39,7 @@ class Window_PlayerList < Window_List ...@@ -34,7 +39,7 @@ class Window_PlayerList < Window_List
refresh refresh
end end
def clicked def clicked
$scene.refresh_rect(*item_rect(@index)){draw_item(@index, 2)} if @index #$scene.refresh_rect(*item_rect(@index)){draw_item(@index, 2)} if @index
@userwindow = Window_User.new(100,100,@list[@index]) @userwindow = Window_User.new(100,100,@list[@index])
end end
def mousemoved(x,y) def mousemoved(x,y)
......
class Window_User < Window class Window_User < Window
BackGround = Surface.load "graphics/hall/user.png"
Boarder = Surface.load "graphics/hall/avatar_boader.png"
def initialize(x, y, user) def initialize(x, y, user)
@background = Surface.load "graphics/hall/user.png" super(x,y,BackGround.w,BackGround.h)
@boarder = Surface.load "graphics/hall/avatar_boader.png"
super(x,y,@background.w,@background.h)
@font = TTF.open('fonts/WenQuanYi Micro Hei.ttf', 16) @font = TTF.open('fonts/WenQuanYi Micro Hei.ttf', 16)
@user = user @user = user
@contents = Surface.load "graphics/hall/user.png" #TODO:调用已经加载了的背景
refresh refresh
end end
def refresh(x=@x, y=@y, width=@width, height=@height) def refresh
$scene.refresh_rect(@x, @y, @width, @height, @background, -@x, -@y) do @thread.kill if @thread
Surface.blit(@background, 0,0,0,0,$screen,@x,@y) @contents.put(BackGround, 0,0)
@thread = @user.avatar(:middle) do |avatar|
@thread = @user.avatar(:middle) do |avatar| @contents.put(avatar, 24, 24)
$scene.refresh_rect(@x+12, @y+12, @boarder.w, @boarder.h, @background, -@x, -@y) do @contents.put(Boarder, 12, 12)
Surface.blit(avatar, 0,0,0,0,$screen,@x+24,@y+24) end
Surface.blit(@boarder, 0,0,0,0,$screen,@x+12,@y+12)
end
end
@font.draw_blended_utf8($screen, @user.name, @x+172, @y+24, 0x00,0x00,0x00)
@font.draw_blended_utf8($screen, "id: #{@user.id}" , @x+172, @y+24+16*2, 0x00,0x00,0x00)
@font.draw_blended_utf8($screen, @user.status , @x+172, @y+24+16*3, 0x00,0x00,0x00)
@font.draw_blended_utf8(@contents, @user.name, 172, 24, 0x00,0x00,0x00)
@font.draw_blended_utf8(@contents, "id: #{@user.id}" , 172, 24+16*2, 0x00,0x00,0x00)
@font.draw_blended_utf8(@contents, @user.status , 172, 24+16*3, 0x00,0x00,0x00)
@font.draw_blended_utf8($screen, "发送消息" , @x+172, @y+24+16*4+8, 0x00,0x00,0x00) @font.draw_blended_utf8(@contents, "发送消息" , 172, 24+16*4+8, 0x00,0x00,0x00)
@font.draw_blended_utf8($screen, "查看资料" , @x+172, @y+24+16*5+8, 0x00,0x00,0x00) @font.draw_blended_utf8(@contents, "查看资料" , 172, 24+16*5+8, 0x00,0x00,0x00)
@font.draw_blended_utf8($screen, "加为好友" , @x+172, @y+24+16*6+8, 0x00,0x00,0x00) @font.draw_blended_utf8(@contents, "加为好友" , 172, 24+16*6+8, 0x00,0x00,0x00)
@font.draw_blended_utf8($screen, "加入游戏" , @x+172, @y+24+16*7+8, 0x00,0x00,0x00) @font.draw_blended_utf8(@contents, "加入游戏" , 172, 24+16*7+8, 0x00,0x00,0x00)
end
end end
def clicked def clicked
end end
......
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