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

nothing

parent c1f6f124
/nbproject/
/.idea/
/ruby/
/pkg/
/config.yml
/log.log
/profile.log
/replay/
/mycard/
/mycard.exe
/7z.exe
/ygocore/
/graphics/avatars/*_*.png
/error-程序出错请到论坛反馈.txt
/nbproject/
/.idea/
/ruby/
/pkg/
/config.yml
/log.log
/profile.log
/replay/
/mycard/
/mycard.exe
/7z.exe
/ygocore/
/graphics/avatars/*_*.png
/error-程序出错请到论坛反馈.txt
Thumbs.db
\ No newline at end of file
#encoding: UTF-8
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rubygems/package_task'
require 'rdoc/task'
#require 'rake/testtask'
Windows = RUBY_PLATFORM["mingw"] || RUBY_PLATFORM["mswin"]
#在windows上UTF-8脚本编码环境中 Dir.glob无法列出中文目录下的文件 所以自己写个递归
def list(path)
result = []
Dir.foreach(path) do |file|
next if file == "." or file == ".."
result << "#{path}/#{file}"
result.concat list(result.last) if File.directory? result.last
end
result
end
spec = Gem::Specification.new do |s|
s.name = 'mycard'
s.version = '0.7.4'
s.extra_rdoc_files = ['README.txt', 'LICENSE.txt']
s.summary = 'a card game'
s.description = s.summary
s.author = 'zh99998'
s.email = 'zh99998@gmail.com'
s.homepage = 'http://card.touhou,cc'
# s.executables = ['your_executable_here']
s.files = %w(LICENSE.txt README.txt replay)
%w{lib audio data fonts graphics ygocore}.each{|dir|s.files.concat list(dir)}
if Windows
s.files += %w(mycard.exe) + list("ruby")
else
s.files += %w(install.sh)
end
s.require_path = "lib"
#s.bindir = "bin"
end
Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
if Windows
p.need_zip = true
p.zip_command = '../7z.exe a'
def p.zip_file
"#{package_name}-win32.7z"
end
else
p.need_tar = true
end
end
Rake::RDocTask.new do |rdoc|
files =['README.txt', 'LICENSE.txt', 'lib/**/*.rb']
rdoc.rdoc_files.add(files)
rdoc.main = "README.txt" # page to start on
rdoc.title = "Mycard Docs"
rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
rdoc.options << '--line-numbers'
end
CLOBBER.include %w(error-程序出错请到论坛反馈.txt log.log profile.log config.yml doc ygocore/pics) + list('replay') + list('ygocore/replay') + list('.').keep_if{|file|File.basename(file) == "Thumbs.db"} + list("graphics/avatars").keep_if{|file|File.basename(file) =~ /.*_(?:small|middle|large)\.png/} + list("ygocore/deck").keep_if{|file|File.basename(file) != 'sample.ydk'}
#encoding: UTF-8
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rubygems/package_task'
require 'rdoc/task'
#require 'rake/testtask'
Windows = RUBY_PLATFORM["mingw"] || RUBY_PLATFORM["mswin"]
#在windows上UTF-8脚本编码环境中 Dir.glob无法列出中文目录下的文件 所以自己写个递归
def list(path)
result = []
Dir.foreach(path) do |file|
next if file == "." or file == ".."
result << "#{path}/#{file}"
result.concat list(result.last) if File.directory? result.last
end
result
end
spec = Gem::Specification.new do |s|
s.name = 'mycard'
s.version = '0.7.4'
s.extra_rdoc_files = ['README.txt', 'LICENSE.txt']
s.summary = 'a card game'
s.description = s.summary
s.author = 'zh99998'
s.email = 'zh99998@gmail.com'
s.homepage = 'http://card.touhou,cc'
# s.executables = ['your_executable_here']
s.files = %w(LICENSE.txt README.txt replay)
%w{lib audio data fonts graphics ygocore}.each{|dir|s.files.concat list(dir)}
if Windows
s.files += %w(mycard.exe) + list("ruby")
else
s.files += %w(install.sh)
end
s.require_path = "lib"
#s.bindir = "bin"
end
Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
if Windows
p.need_zip = true
p.zip_command = '../7z.exe a'
def p.zip_file
"#{package_name}-win32.7z"
end
else
p.need_tar = true
end
end
Rake::RDocTask.new do |rdoc|
files =['README.txt', 'LICENSE.txt', 'lib/**/*.rb']
rdoc.rdoc_files.add(files)
rdoc.main = "README.txt" # page to start on
rdoc.title = "Mycard Docs"
rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
rdoc.options << '--line-numbers'
end
CLOBBER.include %w(error-程序出错请到论坛反馈.txt log.log profile.log config.yml doc ygocore/pics) + list('replay') + list('ygocore/replay') + list('.').keep_if{|file|File.basename(file) == "Thumbs.db"} + list("graphics/avatars").keep_if{|file|File.basename(file) =~ /.*_(?:small|middle|large)\.png/} + list("ygocore/deck").keep_if{|file|File.basename(file) != 'sample.ydk'}
---
name: "沙沙"
field:
cardimage:
- 1
- 2
- 3
- 4
cardtext:
- 5
- 6
- 7
- 8
chat:
- 9
- 10
- 11
- 12
---
name: "沙沙"
field:
cardimage:
- 1
- 2
- 3
- 4
cardtext:
- 5
- 6
- 7
- 8
chat:
- 9
- 10
- 11
- 12
This diff is collapsed.
This diff is collapsed.
module Dialog
#选择文件对话框
require 'win32api'
GetOpenFileName = Win32API.new("comdlg32.dll", "GetOpenFileNameW", "p", "i")
GetSaveFileName = Win32API.new("comdlg32.dll", "GetSaveFileNameW", "p", "i")
OFN_EXPLORER = 0x00080000
OFN_PATHMUSTEXIST = 0x00000800
OFN_FILEMUSTEXIST = 0x00001000
OFN_ALLOWMULTISELECT = 0x00000200
OFN_FLAGS = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST |
OFN_ALLOWMULTISELECT
#打开网页
require 'win32ole'
Shell = WIN32OLE.new('Shell.Application')
module_function
def get_open_file(title="选择文件", filter = {"所有文件 (*.*)" => "*.*"}, save=nil)
szFile = (0.chr * 20481).encode("UTF-16LE")
szFileTitle = 0.chr * 2049
szTitle = (title+"\0").encode("UTF-16LE")
szFilter = (filter.flatten.join("\0")+"\0\0").encode("UTF-16LE")
szInitialDir = "\0"
ofn =
[
76, # lStructSize L
0, # hwndOwner L
0, # hInstance L
szFilter, # lpstrFilter L
0, # lpstrCustomFilter L
0, # nMaxCustFilter L
1, # nFilterIndex L
szFile, # lpstrFile L
szFile.size - 1, # nMaxFile L
szFileTitle, # lpstrFileTitle L
szFileTitle.size - 1, # nMaxFileTitle L
szInitialDir, # lpstrInitialDir L
szTitle, # lpstrTitle L
OFN_FLAGS, # Flags L
0, # nFileOffset S
0, # nFileExtension S
0, # lpstrDefExt L
0, # lCustData L
0, # lpfnHook L
0 # lpTemplateName L
].pack("LLLPLLLPLPLPPLS2L4")
Dir.chdir {
if save
GetSaveFileName.call(ofn)
else
GetOpenFileName.call(ofn)
end
}
szFile.delete!("\0".encode("UTF-16LE"))
result = szFile.encode("UTF-8")
if !result.empty? and save.is_a? Array
ext = save[ofn.unpack("LLLPLLLPLPLPPLS2L4")[6] - 1]
if result[-ext.size, ext.size].downcase != ext.downcase
result << ext
end
end
result
end
def web(url)
Shell.ShellExecute url
end
def uac(command, *args)
Shell.ShellExecute File.expand_path(command), args.join(' '), Dir.pwd, "runas"
end
module Dialog
#选择文件对话框
require 'win32api'
GetOpenFileName = Win32API.new("comdlg32.dll", "GetOpenFileNameW", "p", "i")
GetSaveFileName = Win32API.new("comdlg32.dll", "GetSaveFileNameW", "p", "i")
OFN_EXPLORER = 0x00080000
OFN_PATHMUSTEXIST = 0x00000800
OFN_FILEMUSTEXIST = 0x00001000
OFN_ALLOWMULTISELECT = 0x00000200
OFN_FLAGS = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST |
OFN_ALLOWMULTISELECT
#打开网页
require 'win32ole'
Shell = WIN32OLE.new('Shell.Application')
module_function
def get_open_file(title="选择文件", filter = {"所有文件 (*.*)" => "*.*"}, save=nil)
szFile = (0.chr * 20481).encode("UTF-16LE")
szFileTitle = 0.chr * 2049
szTitle = (title+"\0").encode("UTF-16LE")
szFilter = (filter.flatten.join("\0")+"\0\0").encode("UTF-16LE")
szInitialDir = "\0"
ofn =
[
76, # lStructSize L
0, # hwndOwner L
0, # hInstance L
szFilter, # lpstrFilter L
0, # lpstrCustomFilter L
0, # nMaxCustFilter L
1, # nFilterIndex L
szFile, # lpstrFile L
szFile.size - 1, # nMaxFile L
szFileTitle, # lpstrFileTitle L
szFileTitle.size - 1, # nMaxFileTitle L
szInitialDir, # lpstrInitialDir L
szTitle, # lpstrTitle L
OFN_FLAGS, # Flags L
0, # nFileOffset S
0, # nFileExtension S
0, # lpstrDefExt L
0, # lCustData L
0, # lpfnHook L
0 # lpTemplateName L
].pack("LLLPLLLPLPLPPLS2L4")
Dir.chdir {
if save
GetSaveFileName.call(ofn)
else
GetOpenFileName.call(ofn)
end
}
szFile.delete!("\0".encode("UTF-16LE"))
result = szFile.encode("UTF-8")
if !result.empty? and save.is_a? Array
ext = save[ofn.unpack("LLLPLLLPLPLPPLS2L4")[6] - 1]
if result[-ext.size, ext.size].downcase != ext.downcase
result << ext
end
end
result
end
def web(url)
Shell.ShellExecute url
end
def uac(command, *args)
Shell.ShellExecute File.expand_path(command), args.join(' '), Dir.pwd, "runas"
end
end
\ No newline at end of file
#游戏适配器的抽象类
require_relative 'game_event'
require_relative 'action'
require_relative 'user'
require_relative 'room'
class Game
attr_reader :users, :rooms
attr_accessor :user, :room, :player_field, :opponent_field, :turn, :turn_player, :phase
def initialize
@users = []
@rooms = []
end
def login(username, password=nil)
end
def refresh
end
def host(room_name, room_config)
end
def join(room)
end
def watch(room)
end
def leave
end
def action(action)
end
def chat(chatmessage)
end
def exit
$scene = Scene_Login.new if $scene
end
def watching?
@room and @room.include? @user
end
def self.deck_edit
require_relative 'window_deck'
@deck_window = Window_Deck.new
end
def refresh_interval
5
end
def show_chat_self
false
end
end
#游戏适配器的抽象类
require_relative 'game_event'
require_relative 'action'
require_relative 'user'
require_relative 'room'
class Game
attr_reader :users, :rooms
attr_accessor :user, :room, :player_field, :opponent_field, :turn, :turn_player, :phase
def initialize
@users = []
@rooms = []
end
def login(username, password=nil)
end
def refresh
end
def host(room_name, room_config)
end
def join(room)
end
def watch(room)
end
def leave
end
def action(action)
end
def chat(chatmessage)
end
def exit
$scene = Scene_Login.new if $scene
end
def watching?
@room and @room.include? @user
end
def self.deck_edit
require_relative 'window_deck'
@deck_window = Window_Deck.new
end
def refresh_interval
5
end
def show_chat_self
false
end
end
This diff is collapsed.
class Window_Login
def clicked
return if @last_clicked and Time.now - @last_clicked < 3 #防止重复点击
case @index
when :login
Widget_Msgbox.new("iDuel", "正在登录")
$scene.draw #强制重绘一次,下面会阻塞
$game = Iduel.new
$config[$config['game']]['username'] = @username_inputbox.value
$config[$config['game']]['password'] = @remember_password.checked? ? @password_inputbox.value : nil
Config.save
$game.login(@username_inputbox.value, @password_inputbox.value)
@last_clicked = Time.now
when :register
Dialog.web Iduel::Register_Url
@last_clicked = Time.now
when :replay
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("回放录像", "录像读取中...")
$scene.draw
$log.info('iduel window_login'){'loading reply file'}
$scene = Scene_Replay.new Replay.load file
end
@last_clicked = Time.now
end
end
class Window_Login
def clicked
return if @last_clicked and Time.now - @last_clicked < 3 #防止重复点击
case @index
when :login
Widget_Msgbox.new("iDuel", "正在登录")
$scene.draw #强制重绘一次,下面会阻塞
$game = Iduel.new
$config[$config['game']]['username'] = @username_inputbox.value
$config[$config['game']]['password'] = @remember_password.checked? ? @password_inputbox.value : nil
Config.save
$game.login(@username_inputbox.value, @password_inputbox.value)
@last_clicked = Time.now
when :register
Dialog.web Iduel::Register_Url
@last_clicked = Time.now
when :replay
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("回放录像", "录像读取中...")
$scene.draw
$log.info('iduel window_login'){'loading reply file'}
$scene = Scene_Replay.new Replay.load file
end
@last_clicked = Time.now
end
end
end
\ No newline at end of file
#!/usr/bin/env ruby
begin
Windows = RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"]
Thread.abort_on_exception = true
require_relative 'resolution'
require_relative 'announcement'
require_relative 'config'
require_relative 'association'
#读取配置文件
$config = Config.load
Config.save
#读取命令行参数
log = "log.log"
log_level = "INFO"
profile = nil
ARGV.each do |arg|
arg = arg.dup.force_encoding("UTF-8")
arg.force_encoding("GBK") unless arg.valid_encoding?
case arg
when /--log=(.*)/
log.replace $1
when /--log-level=(.*)/
log_level.replace $1
when /--profile=(.*)/
profile = $1
when /^mycard:.*|\.ydk$|\.yrp$|\.deck$/
require_relative 'quickstart'
$scene = false
when /register_association/
Association.register
$scene = false
end
end
unless $scene == false
#加载文件
require 'logger'
require 'sdl'
include SDL
require_relative 'dialog'
require_relative 'graphics'
require_relative 'window'
require_relative 'widget_msgbox'
#日志
if log == "STDOUT" #调试用
log = STDOUT
end
$log = Logger.new(log)
$log.level = Logger.const_get log_level
#性能分析
if profile
if profile == "STDOUT"
profile = STDOUT
else
profile = open(profile, 'w')
end
require 'profiler'
RubyVM::InstructionSequence.compile_option = {
:trace_instruction => true,
:specialized_instruction => false
}
Profiler__::start_profile
end
SDL::Event::APPMOUSEFOCUS = 1
SDL::Event::APPINPUTFOCUS = 2
SDL::Event::APPACTIVE = 4
SDL.putenv ("SDL_VIDEO_CENTERED=1");
SDL.init(INIT_VIDEO)
WM::set_caption("MyCard", "MyCard")
WM::icon = Surface.load("graphics/system/icon.gif")
$screen = Screen.open($config['screen']['width'], $config['screen']['height'], 0, HWSURFACE | ($config['screen']['fullscreen'] ? FULLSCREEN : 0))
TTF.init
#声音
begin
SDL.init(INIT_AUDIO)
Mixer.open(Mixer::DEFAULT_FREQUENCY, Mixer::DEFAULT_FORMAT, Mixer::DEFAULT_CHANNELS, 1536)
Mixer.set_volume_music(60)
rescue
nil
end
#标题场景
require_relative 'scene_title'
$scene = Scene_Title.new
#自动更新, 加载放到SDL前面会崩, 原因不明
require_relative 'update'
Update.start
WM::set_caption("MyCard v#{Update::Version}", "MyCard")
#文件关联
Association.start
#初始化完毕
$log.info("main") { "初始化成功" }
end
rescue Exception => exception
open('error-程序出错请到论坛反馈.txt', 'w') { |f| f.write [exception.inspect, *exception.backtrace].join("\n") }
$scene = false
end
#主循环
begin
$scene.main while $scene
rescue Exception => exception
exception.backtrace.each { |backtrace| break if backtrace =~ /^(.*)\.rb:\d+:in `.*'"$/ } #由于脚本是从main.rb开始执行的,总会有个能匹配成功的文件
$log.fatal($1) { [exception.inspect, *exception.backtrace].collect { |str| str.force_encoding("UTF-8") }.join("\n") }
$game.exit if $game
require_relative 'scene_error'
$scene = Scene_Error.new
retry
ensure
if profile
Profiler__::print_profile(profile)
profile.close
end
$log.close rescue nil
#!/usr/bin/env ruby
begin
Windows = RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"]
Thread.abort_on_exception = true
require_relative 'resolution'
require_relative 'announcement'
require_relative 'config'
require_relative 'association'
#读取配置文件
$config = Config.load
Config.save
#读取命令行参数
log = "log.log"
log_level = "INFO"
profile = nil
ARGV.each do |arg|
arg = arg.dup.force_encoding("UTF-8")
arg.force_encoding("GBK") unless arg.valid_encoding?
case arg
when /--log=(.*)/
log.replace $1
when /--log-level=(.*)/
log_level.replace $1
when /--profile=(.*)/
profile = $1
when /^mycard:.*|\.ydk$|\.yrp$|\.deck$/
require_relative 'quickstart'
$scene = false
when /register_association/
Association.register
$scene = false
end
end
unless $scene == false
#加载文件
require 'logger'
require 'sdl'
include SDL
require_relative 'dialog'
require_relative 'graphics'
require_relative 'window'
require_relative 'widget_msgbox'
#日志
if log == "STDOUT" #调试用
log = STDOUT
end
$log = Logger.new(log)
$log.level = Logger.const_get log_level
#性能分析
if profile
if profile == "STDOUT"
profile = STDOUT
else
profile = open(profile, 'w')
end
require 'profiler'
RubyVM::InstructionSequence.compile_option = {
:trace_instruction => true,
:specialized_instruction => false
}
Profiler__::start_profile
end
SDL::Event::APPMOUSEFOCUS = 1
SDL::Event::APPINPUTFOCUS = 2
SDL::Event::APPACTIVE = 4
SDL.putenv ("SDL_VIDEO_CENTERED=1");
SDL.init(INIT_VIDEO)
WM::set_caption("MyCard", "MyCard")
WM::icon = Surface.load("graphics/system/icon.gif")
$screen = Screen.open($config['screen']['width'], $config['screen']['height'], 0, HWSURFACE | ($config['screen']['fullscreen'] ? FULLSCREEN : 0))
TTF.init
#声音
begin
SDL.init(INIT_AUDIO)
Mixer.open(Mixer::DEFAULT_FREQUENCY, Mixer::DEFAULT_FORMAT, Mixer::DEFAULT_CHANNELS, 1536)
Mixer.set_volume_music(60)
rescue
nil
end
#标题场景
require_relative 'scene_title'
$scene = Scene_Title.new
#自动更新, 加载放到SDL前面会崩, 原因不明
require_relative 'update'
Update.start
WM::set_caption("MyCard v#{Update::Version}", "MyCard")
#文件关联
Association.start
#初始化完毕
$log.info("main") { "初始化成功" }
end
rescue Exception => exception
open('error-程序出错请到论坛反馈.txt', 'w') { |f| f.write [exception.inspect, *exception.backtrace].join("\n") }
$scene = false
end
#主循环
begin
$scene.main while $scene
rescue Exception => exception
exception.backtrace.each { |backtrace| break if backtrace =~ /^(.*)\.rb:\d+:in `.*'"$/ } #由于脚本是从main.rb开始执行的,总会有个能匹配成功的文件
$log.fatal($1) { [exception.inspect, *exception.backtrace].collect { |str| str.force_encoding("UTF-8") }.join("\n") }
$game.exit if $game
require_relative 'scene_error'
$scene = Scene_Error.new
retry
ensure
if profile
Profiler__::print_profile(profile)
profile.close
end
$log.close rescue nil
end
\ No newline at end of file
#==============================================================================
# 鈻�Scene_Title
#------------------------------------------------------------------------------
# 銆�itle
#==============================================================================
class Picture < Image
@load_path = "graphics/picture"
end
#==============================================================================
# 鈻�Scene_Title
#------------------------------------------------------------------------------
# 銆�itle
#==============================================================================
class Picture < Image
@load_path = "graphics/picture"
end
This diff is collapsed.
This diff is collapsed.
#encoding: UTF-8
#==============================================================================
# Scene_Lobby
#------------------------------------------------------------------------------
# 大厅
#==============================================================================
class Scene_Lobby < Scene
require_relative 'window_userlist'
require_relative 'window_userinfo'
require_relative 'window_roomlist'
require_relative 'window_chat'
require_relative 'window_host'
require_relative 'window_lobbybuttons'
require_relative 'chatmessage'
require_relative 'scene_duel'
attr_reader :chat_window
def start
WM::set_caption("MyCard v#{Update::Version} - #{$config['game']} - #{$game.user.name}(#{$game.user.id})", "MyCard")
$game.refresh
@background = Graphics.load('lobby', 'background', false)
Surface.blit(@background,0,0,0,0,$screen,0,0)
@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(748,18)
@active_window = @roomlist
@chat_window = Window_Chat.new(313,$config['screen']['height'] - 225,698,212)
@count = 0
super
end
def bgm
"lobby.ogg"
end
def handle(event)
case event
when Event::KeyDown
case event.sym
when Key::UP
@active_window.cursor_up
when Key::DOWN
@active_window.cursor_down
when Key::F2
#@joinroom_msgbox = Widget_Msgbox.new("创建房间", "正在等待对手")
#$game.host Room.new(0, $game.user.name)
when Key::F3
#@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入房间")
#$game.join 'localhost'
when Key::F5
$game.refresh
when Key::F12
$game.exit
$scene = Scene_Login.new
end
else
super
end
end
def handle_game(event)
case event
when Game_Event::AllUsers
@userlist.items = $game.users
when Game_Event::AllRooms
@roomlist.items = $game.rooms
when Game_Event::Join
join(event.room)
when Game_Event::Watch
require_relative 'scene_watch'
$scene = Scene_Watch.new(event.room)
when Game_Event::Chat
@chat_window.add event.chatmessage
else
super
end
end
def join(room)
$scene = Scene_Duel.new(room)
end
def update
@chat_window.update
@host_window.update
@roomlist.update
if @count >= $game.refresh_interval*60
$game.refresh
@count = 0
end
@count += 1
super
end
def terminate
unless $scene.is_a? Scene_Lobby or $scene.is_a? Scene_Duel
$game.exit
end
end
#encoding: UTF-8
#==============================================================================
# Scene_Lobby
#------------------------------------------------------------------------------
# 大厅
#==============================================================================
class Scene_Lobby < Scene
require_relative 'window_userlist'
require_relative 'window_userinfo'
require_relative 'window_roomlist'
require_relative 'window_chat'
require_relative 'window_host'
require_relative 'window_lobbybuttons'
require_relative 'chatmessage'
require_relative 'scene_duel'
attr_reader :chat_window
def start
WM::set_caption("MyCard v#{Update::Version} - #{$config['game']} - #{$game.user.name}(#{$game.user.id})", "MyCard")
$game.refresh
@background = Graphics.load('lobby', 'background', false)
Surface.blit(@background,0,0,0,0,$screen,0,0)
@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(748,18)
@active_window = @roomlist
@chat_window = Window_Chat.new(313,$config['screen']['height'] - 225,698,212)
@count = 0
super
end
def bgm
"lobby.ogg"
end
def handle(event)
case event
when Event::KeyDown
case event.sym
when Key::UP
@active_window.cursor_up
when Key::DOWN
@active_window.cursor_down
when Key::F2
#@joinroom_msgbox = Widget_Msgbox.new("创建房间", "正在等待对手")
#$game.host Room.new(0, $game.user.name)
when Key::F3
#@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入房间")
#$game.join 'localhost'
when Key::F5
$game.refresh
when Key::F12
$game.exit
$scene = Scene_Login.new
end
else
super
end
end
def handle_game(event)
case event
when Game_Event::AllUsers
@userlist.items = $game.users
when Game_Event::AllRooms
@roomlist.items = $game.rooms
when Game_Event::Join
join(event.room)
when Game_Event::Watch
require_relative 'scene_watch'
$scene = Scene_Watch.new(event.room)
when Game_Event::Chat
@chat_window.add event.chatmessage
else
super
end
end
def join(room)
$scene = Scene_Duel.new(room)
end
def update
@chat_window.update
@host_window.update
@roomlist.update
if @count >= $game.refresh_interval*60
$game.refresh
@count = 0
end
@count += 1
super
end
def terminate
unless $scene.is_a? Scene_Lobby or $scene.is_a? Scene_Duel
$game.exit
end
end
end
\ No newline at end of file
#encoding: UTF-8
#==============================================================================
# ■ Scene_Login
#------------------------------------------------------------------------------
#  login
#==============================================================================
require_relative 'window_gameselect'
require_relative 'window_announcements'
require_relative 'window_login'
require_relative 'scene_replay'
require_relative 'scene_lobby'
class Scene_Login < Scene
def start
WM::set_caption("MyCard v#{Update::Version}", "MyCard")
@background = Graphics.load('login', 'background', false)
#======================================================
# We'll pay fpr that soon or later.
#======================================================
if $config['screen']['height'] == 768
@gameselect_window = Window_GameSelect.new(117,269)
elsif $config['screen']['height'] == 640
@gameselect_window = Window_GameSelect.new(117,134)
else
raise "无法分辨的分辨率"
end
#======================================================
# ENDS HERE
#======================================================
super
end
def update
@gameselect_window.update
super
end
def handle_game(event)
case event
when Game_Event::Login
require_relative 'scene_lobby'
$scene = Scene_Lobby.new
else
super
end
end
#def terminate
# @gameselect_window.destroy
#end
#encoding: UTF-8
#==============================================================================
# ■ Scene_Login
#------------------------------------------------------------------------------
#  login
#==============================================================================
require_relative 'window_gameselect'
require_relative 'window_announcements'
require_relative 'window_login'
require_relative 'scene_replay'
require_relative 'scene_lobby'
class Scene_Login < Scene
def start
WM::set_caption("MyCard v#{Update::Version}", "MyCard")
@background = Graphics.load('login', 'background', false)
#======================================================
# We'll pay fpr that soon or later.
#======================================================
if $config['screen']['height'] == 768
@gameselect_window = Window_GameSelect.new(117,269)
elsif $config['screen']['height'] == 640
@gameselect_window = Window_GameSelect.new(117,134)
else
raise "无法分辨的分辨率"
end
#======================================================
# ENDS HERE
#======================================================
super
end
def update
@gameselect_window.update
super
end
def handle_game(event)
case event
when Game_Event::Login
require_relative 'scene_lobby'
$scene = Scene_Lobby.new
else
super
end
end
#def terminate
# @gameselect_window.destroy
#end
end
\ No newline at end of file
#encoding: UTF-8
#==============================================================================
# Scene_Title
#------------------------------------------------------------------------------
# title
#==============================================================================
require_relative 'scene'
require_relative 'widget_inputbox'
require_relative 'window_title'
BGM = 'title.ogg'
class Scene_Title < Scene
def start
WM::set_caption("MyCard v#{Update::Version}", "MyCard")
title = Dir.glob("graphics/titles/title_*.*")
title = title[rand(title.size)]
@background = Surface.load(title).display_format
Surface.blit(@background,0,0,0,0,$screen,0,0)
@command_window = Window_Title.new(title["left"] ? 200 : title["right"] ? 600 : 400, $config['screen']['height']/2-100)
@decision_se = Mixer::Wave.load("audio/se/decision.ogg") if SDL.inited_system(INIT_AUDIO) != 0
super
end
def clear(x,y,width,height)
Surface.blit(@background,x,y,width,height,$screen,x,y)
end
def determine
return unless @command_window.index
Mixer.play_channel(-1,@decision_se,0) if SDL.inited_system(INIT_AUDIO) != 0
case @command_window.index
when 0
require_relative 'scene_login'
$scene = Scene_Login.new
when 1
#require_relative 'scene_single'
require_relative 'widget_msgbox'
Widget_Msgbox.new("mycard", "功能未实现", :ok => "确定")
#Scene_Single.new
when 2
require_relative 'widget_msgbox'
require_relative 'scene_login'
require_relative 'deck'
load 'lib/ygocore/game.rb' #TODO:不规范啊不规范
Ygocore.deck_edit
when 3
require_relative 'scene_config'
$scene = Scene_Config.new
when 4
$scene = nil
end
end
def terminate
@command_window.destroy
@background.destroy
super
end
end
#encoding: UTF-8
#==============================================================================
# Scene_Title
#------------------------------------------------------------------------------
# title
#==============================================================================
require_relative 'scene'
require_relative 'widget_inputbox'
require_relative 'window_title'
BGM = 'title.ogg'
class Scene_Title < Scene
def start
WM::set_caption("MyCard v#{Update::Version}", "MyCard")
title = Dir.glob("graphics/titles/title_*.*")
title = title[rand(title.size)]
@background = Surface.load(title).display_format
Surface.blit(@background,0,0,0,0,$screen,0,0)
@command_window = Window_Title.new(title["left"] ? 200 : title["right"] ? 600 : 400, $config['screen']['height']/2-100)
@decision_se = Mixer::Wave.load("audio/se/decision.ogg") if SDL.inited_system(INIT_AUDIO) != 0
super
end
def clear(x,y,width,height)
Surface.blit(@background,x,y,width,height,$screen,x,y)
end
def determine
return unless @command_window.index
Mixer.play_channel(-1,@decision_se,0) if SDL.inited_system(INIT_AUDIO) != 0
case @command_window.index
when 0
require_relative 'scene_login'
$scene = Scene_Login.new
when 1
#require_relative 'scene_single'
require_relative 'widget_msgbox'
Widget_Msgbox.new("mycard", "功能未实现", :ok => "确定")
#Scene_Single.new
when 2
require_relative 'widget_msgbox'
require_relative 'scene_login'
require_relative 'deck'
load 'lib/ygocore/game.rb' #TODO:不规范啊不规范
Ygocore.deck_edit
when 3
require_relative 'scene_config'
$scene = Scene_Config.new
when 4
$scene = nil
end
end
def terminate
@command_window.destroy
@background.destroy
super
end
end
#encoding: UTF-8
#==============================================================================
# ■ Scene_Watch
#------------------------------------------------------------------------------
#  观战
#==============================================================================
require_relative 'scene_duel'
class Scene_Watch < Scene_Duel
def create_action_window
end
def chat(text)
$game.chat text, $game.room
Game_Event.push Game_Event::Action.new(Action::Chat.new(true, text), "#{$game.user}:#{text}")
end
def action(action)
end
def start
super
#$game.chat "#{$game.user.name}(#{$game.user.id})进入了观战", @room
end
def terminate
#$game.chat "#{$game.user.name}(#{$game.user.id})离开了观战", @room
end
def handle_game(event)
case event
when Game_Event::Leave
Widget_Msgbox.new("离开房间", "观战结束", :ok => "确定") { $scene = Scene_Lobby.new }
else
super
end
end
end
#encoding: UTF-8
#==============================================================================
# ■ Scene_Watch
#------------------------------------------------------------------------------
#  观战
#==============================================================================
require_relative 'scene_duel'
class Scene_Watch < Scene_Duel
def create_action_window
end
def chat(text)
$game.chat text, $game.room
Game_Event.push Game_Event::Action.new(Action::Chat.new(true, text), "#{$game.user}:#{text}")
end
def action(action)
end
def start
super
#$game.chat "#{$game.user.name}(#{$game.user.id})进入了观战", @room
end
def terminate
#$game.chat "#{$game.user.name}(#{$game.user.id})离开了观战", @room
end
def handle_game(event)
case event
when Game_Event::Leave
Widget_Msgbox.new("离开房间", "观战结束", :ok => "确定") { $scene = Scene_Lobby.new }
else
super
end
end
end
This diff is collapsed.
class Window
WLH = 24
attr_accessor :x, :y, :width, :height, :z, :contents, :visible, :viewport, :background
alias visible? visible
def initialize(x, y, width, height, z=200)
@x = x
@y = y
@z = z
@width = width
@height = height
@visible = true
#@angle = 0
@viewport = [0, 0, @width, @height]
@destroyed = false
amask = 0xff000000
rmask = 0x00ff0000
gmask = 0x0000ff00
bmask = 0x000000ff
#@background ||= Surface.new(SWSURFACE, @width, @height, 32, rmask, gmask, bmask, amask)
@contents ||= Surface.new(SWSURFACE, @width, @height, 32, rmask, gmask, bmask, amask)
#按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 draw_stroked_text(text,x,y,size=1,font=@font,color=@color,color_stroke=@color_stroke)
[[x-size,y-size], [x-size,y], [x-size,y+size],
[x,y-size], [x,y+size],
[x+size,y-size], [x+size,y], [x+size,y+size],
].each{|pos|font.draw_blended_utf8(@contents, text, pos[0], pos[1], *color)}
font.draw_blended_utf8(@contents, text, x, y, *color_stroke)
end
def include?(x,y)
x >= @x && x < @x + @width && y >= @y && y < @y + @height
end
def destroy
@destroyed = true
@contents.destroy if @contents
$scene.windows.delete self if $scene
end
def destroyed?
@destroyed
end
def draw(screen)
return unless self.contents && self.visible? && !self.destroyed?
Surface.blit(self.contents, *self.viewport, screen, self.x, self.y)
end
def clear(x=0, y=0, width=@width, height=@height)
if @background
Surface.blit(@background,x,y,width,height,@contents,x,y)
elsif $scene and $scene.background
Surface.blit($scene.background,@x+x,@y+y,width,height,@contents,x,y)
else
@contents.fill_rect(x,y,width,height,0xFF000000)
end
end
def update
#子类定义
end
def refresh
#子类定义
end
def mousemoved(x,y)
#子类定义
end
def clicked
#子类定义
end
def mouseleftbuttonup
#子类定义
end
def lostfocus(active_window=nil)
#子类定义
end
def cursor_up(wrap=false)
#子类定义
end
def cursor_down(wrap=false)
#子类定义
end
def scroll_up
cursor_up
end
def scroll_down
cursor_down
end
class Window
WLH = 24
attr_accessor :x, :y, :width, :height, :z, :contents, :visible, :viewport, :background
alias visible? visible
def initialize(x, y, width, height, z=200)
@x = x
@y = y
@z = z
@width = width
@height = height
@visible = true
#@angle = 0
@viewport = [0, 0, @width, @height]
@destroyed = false
amask = 0xff000000
rmask = 0x00ff0000
gmask = 0x0000ff00
bmask = 0x000000ff
#@background ||= Surface.new(SWSURFACE, @width, @height, 32, rmask, gmask, bmask, amask)
@contents ||= Surface.new(SWSURFACE, @width, @height, 32, rmask, gmask, bmask, amask)
#按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 draw_stroked_text(text,x,y,size=1,font=@font,color=@color,color_stroke=@color_stroke)
[[x-size,y-size], [x-size,y], [x-size,y+size],
[x,y-size], [x,y+size],
[x+size,y-size], [x+size,y], [x+size,y+size],
].each{|pos|font.draw_blended_utf8(@contents, text, pos[0], pos[1], *color)}
font.draw_blended_utf8(@contents, text, x, y, *color_stroke)
end
def include?(x,y)
x >= @x && x < @x + @width && y >= @y && y < @y + @height
end
def destroy
@destroyed = true
@contents.destroy if @contents
$scene.windows.delete self if $scene
end
def destroyed?
@destroyed
end
def draw(screen)
return unless self.contents && self.visible? && !self.destroyed?
Surface.blit(self.contents, *self.viewport, screen, self.x, self.y)
end
def clear(x=0, y=0, width=@width, height=@height)
if @background
Surface.blit(@background,x,y,width,height,@contents,x,y)
elsif $scene and $scene.background
Surface.blit($scene.background,@x+x,@y+y,width,height,@contents,x,y)
else
@contents.fill_rect(x,y,width,height,0xFF000000)
end
end
def update
#子类定义
end
def refresh
#子类定义
end
def mousemoved(x,y)
#子类定义
end
def clicked
#子类定义
end
def mouseleftbuttonup
#子类定义
end
def lostfocus(active_window=nil)
#子类定义
end
def cursor_up(wrap=false)
#子类定义
end
def cursor_down(wrap=false)
#子类定义
end
def scroll_up
cursor_up
end
def scroll_down
cursor_down
end
end
\ No newline at end of file
This diff is collapsed.
class Window_Config < Window
def initialize(x,y)
super(x,y,$screen.w, $screen.h)
@checkbox = Surface.load('graphics/system/checkbox.png')
@button = Surface.load('graphics/system/button.png')
@background = Surface.load('graphics/config/background.png').display_format
@contents = Surface.load('graphics/config/background.png').display_format
@font = TTF.open('fonts/wqy-microhei.ttc', 20)
@index = nil
@items = {
:fullscreen => [200,160,120,WLH],
:bgm => [200,160+WLH,120,WLH],
:avatar_cache => [200+220, 160+WLH*2,@button.w/3, @button.h],
:return => [200,160+WLH*3+10,100,WLH]
}
refresh
end
def draw_item(index, status=0)
case index
when :fullscreen
Surface.blit(@checkbox, 20*status, $config['screen']['fullscreen'] ? 20 : 0, 20, 20, @contents, @items[:fullscreen][0],@items[:fullscreen][1])
case status
when 0
@font.draw_blended_utf8(@contents, "全屏模式", @items[:fullscreen][0]+24, @items[:fullscreen][1], 0xFF,0xFF,0xFF)
when 1
@font.draw_shaded_utf8(@contents, "全屏模式", @items[:fullscreen][0]+24, @items[:fullscreen][1], 0xFF,0xFF,0xFF, 0x11, 0x11, 0x11)
when 2
@font.draw_shaded_utf8(@contents, "全屏模式", @items[:fullscreen][0]+24, @items[:fullscreen][1], 0x11,0x11,0x11, 0xFF, 0xFF, 0xFF)
end
when :bgm
Surface.blit(@checkbox, 20*status, $config['bgm'] ? 20 : 0, 20, 20, @contents, @items[:bgm][0], @items[:bgm][1])
case status
when 0
@font.draw_blended_utf8(@contents, "BGM", @items[:bgm][0]+24, @items[:bgm][1], 0xFF,0xFF,0xFF)
when 1
@font.draw_shaded_utf8(@contents, "BGM", @items[:bgm][0]+24, @items[:bgm][1], 0xFF,0xFF,0xFF, 0x11, 0x11, 0x11)
when 2
@font.draw_shaded_utf8(@contents, "BGM", @items[:bgm][0]+24, @items[:bgm][1], 0x11,0x11,0x11, 0xFF, 0xFF, 0xFF)
end
when :avatar_cache
size = 0
count = 0
Dir.glob("graphics/avatars/*_*.png") do |file|
count += 1
size += File.size(file)
end
@font.draw_blended_utf8(@contents, "头像缓存: #{count}个文件, #{filesize_inspect(size)}", 200, @items[:avatar_cache][1], 0xFF,0xFF,0xFF)
Surface.blit(@button, @button.w/3*status, 0, @button.w/3, @button.h, @contents, @items[:avatar_cache][0],@items[:avatar_cache][1])
@font.draw_blended_utf8(@contents, "清空", @items[:avatar_cache][0]+10, @items[:avatar_cache][1]+5, 0xFF,0xFF,0xFF)
when :return
@font.draw_blended_utf8(@contents, "回到标题画面", @items[:return][0],@items[:return][1], 0xFF,0xFF,0xFF)
end
end
def item_rect(index)
@items[index]
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
clear(*item_rect(@index))
draw_item(@index, 1)
end
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 refresh
clear
@items.each_key{|index|draw_item(index)}
end
def clicked
case @index
when :fullscreen
clear(*item_rect(@index))
$config['screen']['fullscreen'] = !$config['screen']['fullscreen']
$screen.destroy
style = HWSURFACE
style |= FULLSCREEN if $config['screen']["fullscreen"]
$screen = Screen.open($config['screen']["width"], $config['screen']["height"], 0, style)
draw_item(@index, 1)
when :bgm
clear(*item_rect(@index))
$config['bgm'] = !$config['bgm']
if $config['bgm']
$scene = Scene_Config.new
else
$scene.last_bgm = nil
Mixer.fade_out_music(800) if SDL.inited_system(INIT_AUDIO) != 0
end
draw_item(@index, 1)
when :avatar_cache
#clear(*item_rect(@index))
Dir.glob("graphics/avatars/*_*.png") do |file|
File.delete file
end
refresh
#draw_item(:avatar_cache,1)
when :return
$scene = Scene_Title.new
end
Config.save
end
def filesize_inspect(size)
case size
when 0...1024
size.to_s + "B"
when 1024...1024*1024
(size/1024).to_s + "KB"
else
(size/1024/1024).to_s + "MB"
end
end
class Window_Config < Window
def initialize(x,y)
super(x,y,$screen.w, $screen.h)
@checkbox = Surface.load('graphics/system/checkbox.png')
@button = Surface.load('graphics/system/button.png')
@background = Surface.load('graphics/config/background.png').display_format
@contents = Surface.load('graphics/config/background.png').display_format
@font = TTF.open('fonts/wqy-microhei.ttc', 20)
@index = nil
@items = {
:fullscreen => [200,160,120,WLH],
:bgm => [200,160+WLH,120,WLH],
:avatar_cache => [200+220, 160+WLH*2,@button.w/3, @button.h],
:return => [200,160+WLH*3+10,100,WLH]
}
refresh
end
def draw_item(index, status=0)
case index
when :fullscreen
Surface.blit(@checkbox, 20*status, $config['screen']['fullscreen'] ? 20 : 0, 20, 20, @contents, @items[:fullscreen][0],@items[:fullscreen][1])
case status
when 0
@font.draw_blended_utf8(@contents, "全屏模式", @items[:fullscreen][0]+24, @items[:fullscreen][1], 0xFF,0xFF,0xFF)
when 1
@font.draw_shaded_utf8(@contents, "全屏模式", @items[:fullscreen][0]+24, @items[:fullscreen][1], 0xFF,0xFF,0xFF, 0x11, 0x11, 0x11)
when 2
@font.draw_shaded_utf8(@contents, "全屏模式", @items[:fullscreen][0]+24, @items[:fullscreen][1], 0x11,0x11,0x11, 0xFF, 0xFF, 0xFF)
end
when :bgm
Surface.blit(@checkbox, 20*status, $config['bgm'] ? 20 : 0, 20, 20, @contents, @items[:bgm][0], @items[:bgm][1])
case status
when 0
@font.draw_blended_utf8(@contents, "BGM", @items[:bgm][0]+24, @items[:bgm][1], 0xFF,0xFF,0xFF)
when 1
@font.draw_shaded_utf8(@contents, "BGM", @items[:bgm][0]+24, @items[:bgm][1], 0xFF,0xFF,0xFF, 0x11, 0x11, 0x11)
when 2
@font.draw_shaded_utf8(@contents, "BGM", @items[:bgm][0]+24, @items[:bgm][1], 0x11,0x11,0x11, 0xFF, 0xFF, 0xFF)
end
when :avatar_cache
size = 0
count = 0
Dir.glob("graphics/avatars/*_*.png") do |file|
count += 1
size += File.size(file)
end
@font.draw_blended_utf8(@contents, "头像缓存: #{count}个文件, #{filesize_inspect(size)}", 200, @items[:avatar_cache][1], 0xFF,0xFF,0xFF)
Surface.blit(@button, @button.w/3*status, 0, @button.w/3, @button.h, @contents, @items[:avatar_cache][0],@items[:avatar_cache][1])
@font.draw_blended_utf8(@contents, "清空", @items[:avatar_cache][0]+10, @items[:avatar_cache][1]+5, 0xFF,0xFF,0xFF)
when :return
@font.draw_blended_utf8(@contents, "回到标题画面", @items[:return][0],@items[:return][1], 0xFF,0xFF,0xFF)
end
end
def item_rect(index)
@items[index]
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
clear(*item_rect(@index))
draw_item(@index, 1)
end
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 refresh
clear
@items.each_key{|index|draw_item(index)}
end
def clicked
case @index
when :fullscreen
clear(*item_rect(@index))
$config['screen']['fullscreen'] = !$config['screen']['fullscreen']
$screen.destroy
style = HWSURFACE
style |= FULLSCREEN if $config['screen']["fullscreen"]
$screen = Screen.open($config['screen']["width"], $config['screen']["height"], 0, style)
draw_item(@index, 1)
when :bgm
clear(*item_rect(@index))
$config['bgm'] = !$config['bgm']
if $config['bgm']
$scene = Scene_Config.new
else
$scene.last_bgm = nil
Mixer.fade_out_music(800) if SDL.inited_system(INIT_AUDIO) != 0
end
draw_item(@index, 1)
when :avatar_cache
#clear(*item_rect(@index))
Dir.glob("graphics/avatars/*_*.png") do |file|
File.delete file
end
refresh
#draw_item(:avatar_cache,1)
when :return
$scene = Scene_Title.new
end
Config.save
end
def filesize_inspect(size)
case size
when 0...1024
size.to_s + "B"
when 1024...1024*1024
(size/1024).to_s + "KB"
else
(size/1024/1024).to_s + "MB"
end
end
end
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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