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

nothing

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