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

临时,不能用

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