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

msgbox初步

parent 51f4ec56
This diff was suppressed by a .gitattributes entry.
......@@ -109,7 +109,7 @@ class Action
if @from_pos.is_a? Integer
from_pos = @from_pos
else
from_pos = @card.is_a?(Game_Card) ? from_field.index(@card) : from_field.index{|card|card.card == @card.card} or from_field.index{|card|!card.known?}
from_pos = (@card.is_a?(Game_Card) ? from_field.index(@card) : from_field.index{|card|card.card == @card}) or from_field.index{|card|!card.known?}
end
to_field = case @to_pos
......
......@@ -149,7 +149,7 @@ attr_accessor :tokens
Card.cache[@id] = self
end
def image
@image ||= Surface.load "#{PicPath}/#{@id-1}.jpg" rescue Surface.load "graphics/field/card.png"
@image ||= Surface.load "#{PicPath}/#{@id-1}.jpg" rescue Surface.load "graphics/field/card.jpg"
end
def image_small
@image_small ||= image.transform_surface(0,0,54.0/image.w, 81.0/image.h,0).copy_rect(1,1,54,81) #尼玛!
......
......@@ -154,6 +154,7 @@ end
class Iduel::Event::WATCHSTOP < Iduel::Event
end
class Iduel::Event::Error < Iduel::Event
attr_reader :title, :message
def initialize(info)
@title, @message = case info.to_i
when 0x00
......@@ -190,8 +191,8 @@ class Iduel::Event::Error < Iduel::Event
["错误", "请求的房间无效"]
end
#Exception.new(@message).raise
puts @title.encode! "GBK"
puts @message.encode! "GBK"
p @title
p @message
#system("pause")
end
end
......
......@@ -44,6 +44,7 @@ require_relative 'window_list'
require_relative 'window_user'
require_relative 'scene_title'
require_relative 'fpstimer'
require_relative 'widget_msgbox'
$fpstimer = FPSTimer.new
$scene = Scene_Title.new
while $scene
......
......@@ -58,13 +58,15 @@ class Scene
@fps.contents.fill_rect(0,0,@fps.contents.w,@fps.contents.h,0x00000000)
@font.draw_solid_utf8(@fps.contents, "%.1f" % $fpstimer.real_fps, 0, 0, 0xFF, 0xFF, 0xFF)
@windows.each do |window|
if window.contents && window.visible && !window.destroted?
if window.angle.zero?
Surface.blit(window.contents, *window.viewport, $screen, window.x, window.y) if window.contents && window.visible
Surface.blit(window.contents, *window.viewport, $screen, window.x, window.y)
else
contents = window.contents.transform_surface(0x66000000,180,1,1,0)
Surface.blit(contents, *window.viewport, $screen, window.x, window.y) if window.contents && window.visible
Surface.blit(contents, *window.viewport, $screen, window.x, window.y)
#Surface.transform_blit(window.contents,$screen,0,1,1,100,100,100,100,Surface::TRANSFORM_AA)#,0,0)
end
end
#$screen.put(window.contents, window.x, window.y) if window.contents && window.visible
end
$screen.update_rect(0,0,0,0)
......
......@@ -154,6 +154,8 @@ class Scene_Duel < Scene
event.action.run
@player_field_window.refresh
@opponent_field_window.refresh
when Iduel::Event::Error
Widget_Msgbox.new(event.title, event.message){$scene = Scene_Title.new}
end
end
def update
......
......@@ -110,6 +110,8 @@ class Scene_Hall < Scene
$scene = Scene_Watch.new(event.room)
when Iduel::Event::PCHAT
@chat.add event.user, event.content
when Iduel::Event::Error
Widget_Msgbox.new(event.title, event.message){$scene = Scene_Title.new}
else
puts "---unhandled iduel event----"
p event
......
......@@ -36,6 +36,8 @@ class Scene_Login < Scene
when Iduel::Event::LOGINOK
require_relative 'scene_hall'
$scene = Scene_Hall.new
when Iduel::Event::Error
Widget_Msgbox.new(event.title, event.message){$scene = Scene_Title.new}
else
p event
end
......
......@@ -3,7 +3,7 @@
#------------------------------------------------------------------------------
#  title
#==============================================================================
=begin
class Scene_Single < Scene
def start
@background = Sprite.new
......@@ -40,3 +40,4 @@ class Scene_Single < Scene
end
end
=end
\ No newline at end of file
# To change this template, choose Tools | Templates
# and open the template in the editor.
class Widget_Msgbox < Window
def initialize(title, message, buttons={:ok => "确定"}, &proc)
@contents = Surface.load 'graphics/system/msgbox.png'
@button = Surface.load 'graphics/system/button.png'
@font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 16)
super((1024-@contents.w)/2, 230, @contents.w, @contents.h)
@title = title
@message = message
@buttons = buttons
@proc = proc
@index = nil
@items = {}
@space = (@width - @buttons.size * @button.w / 3) / (@buttons.size + 1)
button_y = 100
@buttons.each_with_index do |button, index|
@items[button[0]] = [(@space+@button.w)*index+@space, button_y, @button.w/3, @button.h]
end
refresh
end
def refresh
@font.draw_blended_utf8(@contents, @title, (@width-@font.text_size(@title)[0])/2, 2, 0xFF, 0xFF, 0xFF)
@font.draw_blended_utf8(@contents, @message, 0, 24, 0xFF, 0xFF, 0x66)
@items.each_key do |index|
draw_item(index, @index == index ? 1 : 0)
end
end
def draw_item(index, status=0)
Surface.blit(@button,@button.w/3*status,0,@button.w/3,@button.h,@contents,@items[index][0],@items[index][1])
text_size = @font.text_size(@buttons[index])
@font.draw_blended_utf8(@contents, @buttons[index], @items[index][0]+(@button.w/3-text_size[0])/2, @items[index][1]+(@button.h-text_size[1])/2, 0xFF, 0xFF, 0xFF)
end
def mousemoved(x,y)
self.index = @items.each do |index, item_rect|
if x.between?(@x+item_rect[0], @x+item_rect[0]+item_rect[2]) and y.between?(@y+item_rect[1], @y+item_rect[1]+item_rect[3])
break index
end
end
end
def index=(index)
return if index == @index
if @index
#clear(*item_rect(@index))
draw_item(@index, 0)
end
if index.nil? or !@items.include? index
@index = nil
else
@index = index
draw_item(@index, 1)
end
end
def clicked
@proc.call(@index) if @index
self.destroy
end
end
......@@ -37,7 +37,9 @@ class Window_List < Window
[0, @index*self.class::WLH, @width, self.class::WLH]
end
def refresh
@item_max.times {|index|draw_item(index, index==@index ? 1 : 0)}
@item_max.times do |index|
draw_item(index, index==@index ? 1 : 0)
end
end
def cursor_up
self.index = @index ? (@index - @column_max) % [@list.size, @item_max].min : 0
......
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