Commit fb9bee73 authored by zh99998's avatar zh99998

版本0.5.1 ygocore录像;界面优化

parent b845f12c
......@@ -24,7 +24,7 @@ end
spec = Gem::Specification.new do |s|
s.name = 'mycard'
s.version = '0.5.0'
s.version = '0.5.1'
s.extra_rdoc_files = ['README.txt', 'LICENSE.txt']
s.summary = 'a card game'
s.description = s.summary
......
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
......@@ -32,6 +32,8 @@ class Game
def watching?
@room and @room.include? @user
end
def self.deck_edit
end
end
......@@ -3,7 +3,7 @@ class Window_Login
return if @last_clicked and Time.now - @last_clicked < 3 #防止重复点击
case @index
when :login
Widget_Msgbox.new("iDuel", "正在登")
Widget_Msgbox.new("iDuel", "正在登")
$scene.draw #强制重绘一次,下面会阻塞
$game = Iduel.new
$config[$config['game']]['username'] = @username_inputbox.value
......@@ -15,12 +15,11 @@ class Window_Login
system("start #{Iduel::Register_Url}")
@last_clicked = Time.now
when :replay
require_relative '../dialog'
file = Dialog.get_open_file("播放战报", "所有支持的战报 (*.txt;*.htm)" => "*.txt;*.htm", "iDuel的html的战报 (*.htm)" => "*.htm", "文本战报 (*.txt)" => "*.txt")
file = Dialog.get_open_file("播放录像", "所有支持的录像 (*.txt;*.htm)" => "*.txt;*.htm", "iDuel的html的录像 (*.htm)" => "*.htm", "文本录像 (*.txt)" => "*.txt")
if !file.empty?
$game = Iduel.new
$game.user = User.new(0)
Widget_Msgbox.new("回放战报", "战报读取中...")
Widget_Msgbox.new("回放录像", "录像读取中...")
$scene.draw
$log.info('iduel window_login'){'loading reply file'}
$scene = Scene_Replay.new Replay.load file
......
......@@ -83,6 +83,8 @@ begin
require_relative 'update'
Update.start
require_relative 'dialog'
$log.info("main"){"初始化成功"}
rescue Exception => exception
open('error-程序出错请到论坛反馈.txt', 'w'){|f|f.write [exception.inspect, *exception.backtrace].join("\n")}
......
......@@ -23,7 +23,7 @@ class Scene_Lobby < Scene
@userlist = Window_UserList.new(24,204,$game.users)
@roomlist = Window_RoomList.new(320,50,$game.rooms)
@userinfo = Window_UserInfo.new(24,24, $game.user)
@host_window = Window_LobbyButtons.new(900,16)
@host_window = Window_LobbyButtons.new(830,18)
@active_window = @roomlist
@chat_window = Window_Chat.new(313,543,698,212)
@count = 0
......
......@@ -43,31 +43,8 @@ class Scene_Title < Scene
when 2
require_relative 'widget_msgbox'
require_relative 'scene_login'
Widget_Msgbox.new("编辑卡组", "\"导入\"导入已有卡组,\"编辑\"启动ygocore", :import => "导入", :edit => "编辑") do |button|
case button
when:import
require_relative 'dialog'
file = Dialog.get_open_file("导入卡组", "ygocore卡组 (*.ydk)"=>"*.ydk")#"所有支持的卡组 (*.txt;*.deck;*.ydk)"=>"*.ydk;*.txt;*.deck","ygocore卡组 (*.ydk)"=>"*.ydk", "NBX/iDuel/狐查卡组 (*.txt)" => "*.txt", "图形组卡器卡组 (*.deck)"=>"*.deck")
if !file.empty?
open(file) do |src|
Dir.mkdir "ygocore/deck" unless File.directory?("ygocore/deck")
open("ygocore/deck/#{File.basename(file)}", 'w') do |dest|
dest.write src.read
end
Widget_Msgbox.new("导入卡组", "导入卡组完成", :ok => "确定")
end rescue Widget_Msgbox.new("导入卡组", "导入卡组失败", :ok => "确定")
end
when :edit
load 'lib/ygocore/game.rb' #TODO:不规范啊不规范
if !Update.images.empty?
Widget_Msgbox.new("加入房间", "卡图正在下载中,可能显示不出部分卡图", :ok => "确定"){Ygocore.run_ygocore(:deck)}
else
Ygocore.run_ygocore(:deck)
end
end
end
#require_relative 'scene_deck'
#Scene_Deck.new
load 'lib/ygocore/game.rb' #TODO:不规范啊不规范
Ygocore.deck_edit
when 3
require_relative 'scene_config'
$scene = Scene_Config.new
......
......@@ -2,7 +2,7 @@ require 'open-uri'
require "fileutils"
require_relative 'card'
module Update
Version = '0.5.0'
Version = '0.5.1'
URL = "http://card.touhou.cc/mycard/update.json?version=#{Version}"
class <<self
attr_reader :thumbnails, :images, :status
......
......@@ -2,8 +2,8 @@ class Window_Host < Window
attr_reader :index
def initialize(x,y)
@button = Surface.load("graphics/system/button.png")
@items = {:ok => [116,114,@button.w/3,@button.h]}
@buttons = {:ok => "确定"}
@items = {:ok => [46,110,@button.w/3,@button.h], :cancel => [156,110,@button.w/3, @button.h]}
@buttons = {:ok => "确定", :cancel => "取消"}
@background = Surface.load('graphics/system/msgbox.png').display_format
super((1024-@background.w)/2, 230, @background.w, @background.h)
@font = TTF.open("fonts/wqy-microhei.ttc", 16)
......@@ -18,13 +18,7 @@ class Window_Host < Window
true
end
end
default_name = $game.user.name
1.upto(1000) do |i|
if $game.rooms.all?{|room|room.name != i.to_s}
break default_name = i.to_s
end
end
@roomname_inputbox.value = default_name
@roomname_inputbox.value = rand(1000).to_s
@pvp = Widget_Checkbox.new(self, 33+@x,70+@y,120,24,false,"竞技场")
@pvp.background = @background.copy_rect(33,70,120,24)
@match = Widget_Checkbox.new(self, 120+@x,70+@y,120,24,true,"三回决斗")
......@@ -37,7 +31,9 @@ class Window_Host < Window
clear
@font.draw_blended_utf8(@contents, "新房间", (@width-@font.text_size("新房间")[0])/2, 2, *@title_color)
@font.draw_blended_utf8(@contents, "房间名", 33,43, *@color)
draw_item(:ok, self.index==:ok ? 1 : 0)
@items.each_key do |index|
draw_item(index, self.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])
......@@ -45,17 +41,23 @@ class Window_Host < Window
@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)
if (x - @x).between?(@items[:ok][0], @items[:ok][0]+@items[:ok][2]) and (y-@y).between?(@items[:ok][1], @items[:ok][1]+@items[:ok][3])
self.index = :ok
else
self.index = nil
new_index = nil
@items.each_key do |index|
if (x - @x).between?(@items[index][0], @items[index][0]+@items[index][2]) and (y-@y).between?(@items[index][1], @items[index][1]+@items[index][3])
new_index = index
break
end
end
self.index = new_index
end
def item_rect(index)
@items[index]
end
def index=(index)
return if index == @index
if @index
#clear(*item_rect(@index))
clear(*item_rect(@index))
draw_item(@index, 0)
end
if index.nil? or !@items.include? index
......@@ -72,6 +74,8 @@ class Window_Host < Window
@joinroom_msgbox = Widget_Msgbox.new("建立房间", "正在建立房间")
destroy
$game.host(@roomname_inputbox.value, :pvp => @pvp.checked?, :match => @match.checked?)
when :cancel
destroy
end
end
def destroy
......
require_relative 'window_host'
class Window_LobbyButtons < Window_List
def initialize(x,y)
super(x,y,86,30)
@items = ["新房间"]
@items = ["卡组编辑","建立房间"]
@button = Surface.load("graphics/lobby/button.png")
@font = TTF.open("fonts/wqy-microhei.ttc", 16)
super(x,y,@items.size*@button.w/3+@items.size*4,30)
@font = TTF.open("fonts/wqy-microhei.ttc", 15)
refresh
end
def draw_item(index, status=0)
Surface.blit(@button, status*@button.w/3,0,@button.w/3,@button.h, @contents, 0, 0)
@font.draw_blended_utf8(@contents,"新房间",16,5,20,10,180)
x,y=item_rect(index)
Surface.blit(@button, status*@button.w/3,0,@button.w/3,@button.h, @contents, x,y)
draw_stroked_text(@items[index], x+8,y+3,2,@font,[0xdf,0xf1,0xff], [0x27,0x43,0x59])
end
def item_rect(index)
[index*@button.w/3+(index)*4, 0, @button.w/3, @height]
end
def mousemoved(x,y)
self.index = 0
if (x-@x) % (@button.w/3+4) >= @button.w/3
self.index = nil
else
self.index = (x-@x)/(@button.w/3+4)
end
end
def lostfocus(active_window = nil)
self.index = nil
end
def clicked
@host_window = Window_Host.new(300,200)
case @index
when 0 #卡组编辑
$game.class.deck_edit
when 1 #建立房间
@host_window = Window_Host.new(300,200)
end
end
def update
@host_window.update if @host_window and !@host_window.destroyed?
......
......@@ -45,9 +45,9 @@ class Window_Login < Window
:replay => [378,200,@button.w/3,@button.h]
}
@items_text = {
:login => "登",
:login => "登",
:register => "注册",
:replay => "战报"
:replay => "录像"
}
#self.index = nil
@remember_password = Widget_Checkbox.new(self, 357+@x,80+@y,self.width-357,24,password,"记住密码")
......
......@@ -6,7 +6,7 @@ class Window_User < Window_List
@font = TTF.open('fonts/wqy-microhei.ttc', 16)
@user = user
@contents = Surface.load("graphics/lobby/user.png").display_format #TODO:调用已经加载了的背景
@close = Surface.load("graphics/lobby/userclose.png")
@avatar_boarder = Surface.load("graphics/lobby/avatar_boader.png")
@items = ["发送消息", "查看资料"]
@items << "加入游戏" if user.status == :waiting
......@@ -25,7 +25,8 @@ class Window_User < Window_List
@font.draw_blended_utf8(@contents, @user.name, 172, 24, 0x00,0x00,0x00)
@font.draw_blended_utf8(@contents, "id: #{@user.id}" , 172, 32+WLH, 0x00,0x00,0x00)
@font.draw_blended_utf8(@contents, "#{'房间' + @user.room.id.to_s + ' ' if @user.room}#{case @user.status;when :lobby;'大厅';when :dueling;'决斗中';when :waiting;'等待中';end}", 172, 32+WLH*2, 0x00,0x00,0x00)
@font.draw_blended_utf8(@contents, "#{'房间' + @user.room.id.to_s + '' if @user.room}#{case @user.status;when :lobby;'大厅';when :dueling;'决斗中';when :waiting;'等待中';end}", 172, 32+WLH*2, 0x00,0x00,0x00)
Surface.blit(@close, 0, 0, @close.w/3, @close.h, @contents, @width-24,10)
end
def clear(x=0,y=0,width=@width,height=@height)
......
......@@ -13,16 +13,16 @@ class Ygocore < Game
end
def login(username, password)
if username.empty?
return Widget_Msgbox.new("登", "请输入用户名", :ok => "确定")
return Widget_Msgbox.new("登", "请输入用户名", :ok => "确定")
end
if password.empty?
Widget_Msgbox.new("登陆", "无密码登陆,不能建房,不能加入竞技场", :ok => "确定"){Game_Event.push Game_Event::Login.new(User.new(username.to_sym, username))}
Widget_Msgbox.new("登录", "无密码登录,不能建房,不能加入竞技场", :ok => "确定"){Game_Event.push Game_Event::Login.new(User.new(username.to_sym, username))}
else
require 'cgi'
result = open("#{@@config['api']}?operation=passcheck&username=#{CGI.escape username}&pass=#{CGI.escape password}") do |file|
file.set_encoding "GBK"
result = file.read.encode("UTF-8")
$log.info('用户登传回消息'){result}
$log.info('用户登传回消息'){result}
result
end rescue nil
case result
......@@ -31,9 +31,9 @@ class Ygocore < Game
@password = password
Game_Event.push Game_Event::Login.new(User.new(username.to_sym, username))
when "false"
Game_Event.push Game_Event::Error.new("登", "用户名或密码错误", false)
Game_Event.push Game_Event::Error.new("登", "用户名或密码错误", false)
else
Widget_Msgbox.new("登", "连接服务器失败", :ok => "确定")
Widget_Msgbox.new("登", "连接服务器失败", :ok => "确定")
end
end
end
......@@ -211,6 +211,35 @@ class Ygocore < Game
end
Widget_Msgbox.destroy
end
def self.deck_edit
Widget_Msgbox.new("编辑卡组", "\"导入\"导入已有卡组,\"编辑\"启动ygocore", :import => "导入", :edit => "编辑") do |button|
case button
when:import
file = Dialog.get_open_file("导入卡组", "ygocore卡组 (*.ydk)"=>"*.ydk")#"所有支持的卡组 (*.txt;*.deck;*.ydk)"=>"*.ydk;*.txt;*.deck","ygocore卡组 (*.ydk)"=>"*.ydk", "NBX/iDuel/狐查卡组 (*.txt)" => "*.txt", "图形组卡器卡组 (*.deck)"=>"*.deck")
if !file.empty?
open(file) do |src|
Dir.mkdir "ygocore/deck" unless File.directory?("ygocore/deck")
open("ygocore/deck/#{File.basename(file)}", 'w') do |dest|
dest.write src.read
end
Widget_Msgbox.new("导入卡组", "导入卡组完成", :ok => "确定")
end rescue Widget_Msgbox.new("导入卡组", "导入卡组失败", :ok => "确定")
end
when :edit
if !Update.images.empty?
Widget_Msgbox.new("加入房间", "卡图正在下载中,可能显示不出部分卡图", :ok => "确定"){Ygocore.run_ygocore(:deck)}
else
Ygocore.run_ygocore(:deck)
end
end
end
end
def self.replay(file)
require 'fileutils'
FileUtils.mv Dir.glob('ygocore/replay/*.yrp'), 'replay/'
FileUtils.copy_file(file, "ygocore/replay/#{File.basename(file)}")
run_ygocore(:replay)
end
private
def connect
require 'open-uri'
......
......@@ -3,7 +3,7 @@ class Window_Login
return if @last_clicked and Time.now - @last_clicked < 3 #防止重复点击
case @index
when :login
Widget_Msgbox.new("ygocore", "正在登")
Widget_Msgbox.new("ygocore", "正在登")
$scene.draw #强制重绘一次,下面会阻塞
$game = Ygocore.new
$config[$config['game']]['username'] = @username_inputbox.value
......@@ -14,18 +14,12 @@ class Window_Login
when :register
Ygocore.register
@last_clicked = Time.now
#when :replay
# require 'tk'
# file = Tk.getOpenFile
# if !file.empty?
# $game = Iduel.new
# $game.user = User.new(0)
# Widget_Msgbox.new("回放战报", "战报读取中...")
# $scene.draw
# $log.debug('iduel window_login'){'loading reply file'}
# $scene = Scene_Replay.new Replay.load file
# end
# @last_clicked = Time.now
when :replay
file = Dialog.get_open_file("播放录像", "ygocore录像 (*.yrp)" => "*.yrp")
if !file.empty? and File.file? file
Ygocore.replay file
end
@last_clicked = Time.now
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