Commit 57c1bb43 authored by XiaoXiaoMN's avatar XiaoXiaoMN

mac

parent cd60e054
/nbproject/ /nbproject/
/.idea/ /.idea/
.DS_Store
Thumbs.db
Thumbs.db
/fonts/
/replay/ /fonts/
/ygocore/ /replay/
/mycard.exe /ygocore/
/config.yml /mycard.exe
/log.log /config.yml
/profile.log /log.log
/error-程序出错请到论坛反馈.txt /profile.log
/error-程序出错请到论坛反馈.txt
/ruby/
/pkg/ /ruby/
/pkg/
/Gemfile.lock /Gemfile.lock
\ 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 rescue p $! end rescue p $!
result result
end end
spec = Gem::Specification.new do |s| spec = Gem::Specification.new do |s|
s.name = 'mycard' s.name = 'mycard'
s.version = '1.1.3' s.version = '1.1.3'
s.extra_rdoc_files = ['README.txt', 'LICENSE.txt'] s.extra_rdoc_files = ['README.txt', 'LICENSE.txt']
s.summary = 'a card game platform' s.summary = 'a card game platform'
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://my-card.in/' s.homepage = 'http://my-card.in/'
# 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 locales graphics ygocore}.each{|dir|s.files.concat list(dir)} %w{lib audio data locales graphics ygocore}.each{|dir|s.files.concat list(dir)}
if Windows if Windows
s.files += %w(mycard.exe) + list("ruby") + list("fonts") s.files += %w(mycard.exe) + list("ruby") + list("fonts")
else else
s.files += %w(mycard.sh) s.files += %w(mycard.sh)
s.platform = Gem::Platform::CURRENT s.platform = Gem::Platform::CURRENT
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 a' p.zip_command = '7z a'
def p.zip_file def p.zip_file
"#{package_name}-win32.7z" "#{package_name}-win32.7z"
end end
else else
p.need_tar_gz = true p.need_tar_gz = 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").reject{|file|File.basename(file) =~ /(?:error|loading)_(?: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").reject{|file|File.basename(file) =~ /(?:error|loading)_(?:small|middle|large)\.png/} + list("ygocore/deck").keep_if{|file|File.basename(file) != 'sample.ydk'}
...@@ -7,7 +7,7 @@ class Card ...@@ -7,7 +7,7 @@ class Card
@diy = {} @diy = {}
@count = @db.get_first_value("select COUNT(*) from `yu-gi-oh`") rescue 0 @count = @db.get_first_value("select COUNT(*) from `yu-gi-oh`") rescue 0
@db.results_as_hash = true @db.results_as_hash = true
PicPath = if RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"] PicPath = if Windows
require 'win32/registry' require 'win32/registry'
ospicpath = Win32::Registry::HKEY_CURRENT_USER.open('Software\OCGSOFT\Cards'){|reg|reg['Path']} rescue '' ospicpath = Win32::Registry::HKEY_CURRENT_USER.open('Software\OCGSOFT\Cards'){|reg|reg['Path']} rescue ''
ospicpath.force_encoding "GBK" ospicpath.force_encoding "GBK"
......
...@@ -20,16 +20,24 @@ class ChatMessage ...@@ -20,16 +20,24 @@ class ChatMessage
end end
def name_color def name_color
case user.role case user.affiliation
when :moderator when :owner
[220,20,60]
when :admin
[148,43,226] [148,43,226]
else else
user == $game.user ? [0, 128, 0] : [0, 0, 255] if user.id == :subject
[128,128,128]
else
user == $game.user ? [0, 128, 0] : [0, 0, 255]
end
end end
end end
def message_color def message_color
if name_visible? if user.id == :subject
[128,128,128]
elsif name_visible?
[0, 0, 0] [0, 0, 0]
elsif user == $game.user or ($game.room and !$game.room.include?($user) and user == $game.room.player1) elsif user == $game.user or ($game.room and !$game.room.include?($user) and user == $game.room.player1)
[0, 128, 0] [0, 128, 0]
......
...@@ -19,7 +19,7 @@ class Game_Event ...@@ -19,7 +19,7 @@ class Game_Event
attr_reader :user attr_reader :user
def initialize(user) def initialize(user)
@user = user @user = user
$game.user = @user $game.user = @user
end end
end end
...@@ -42,6 +42,7 @@ class Game_Event ...@@ -42,6 +42,7 @@ class Game_Event
class AllServers < Game_Event class AllServers < Game_Event
attr_reader :servers attr_reader :servers
def initialize(servers) def initialize(servers)
$game.servers.replace servers $game.servers.replace servers
end end
...@@ -52,14 +53,21 @@ class Game_Event ...@@ -52,14 +53,21 @@ class Game_Event
def initialize(user) def initialize(user)
@user = user @user = user
unless $game.users.include? @user case @user.affiliation
if @user.friend? or @user.role == :moderator when :owner
$game.users.unshift @user if index = $game.users.find_index { |user| user.affiliation != :owner }
#p $game.users $game.users.insert(index, @user)
#$a = 2 else
$game.users << @user
end
when :admin
if index = $game.users.find_index { |user| user.affiliation != :owner and user.affiliation != :admin }
$game.users.insert(index, @user)
else else
$game.users << @user $game.users << @user
end end
else
$game.users << @user
end end
end end
end end
...@@ -129,7 +137,7 @@ class Game_Event ...@@ -129,7 +137,7 @@ class Game_Event
attr_reader :room attr_reader :room
def initialize(room) def initialize(room)
@room = room @room = room
$game.room = @room $game.room = @room
end end
end end
...@@ -139,7 +147,7 @@ class Game_Event ...@@ -139,7 +147,7 @@ class Game_Event
attr_reader :room attr_reader :room
def initialize(room) def initialize(room)
@room = room @room = room
$game.room = @room $game.room = @room
end end
end end
...@@ -151,7 +159,7 @@ class Game_Event ...@@ -151,7 +159,7 @@ class Game_Event
attr_reader :user attr_reader :user
def initialize(user) def initialize(user)
@user = user @user = user
$game.room.player2 = @user $game.room.player2 = @user
end end
end end
...@@ -166,7 +174,7 @@ class Game_Event ...@@ -166,7 +174,7 @@ class Game_Event
def initialize(action, str=action.escape) def initialize(action, str=action.escape)
@action = action @action = action
@str = str @str = str
end end
end end
...@@ -175,9 +183,9 @@ class Game_Event ...@@ -175,9 +183,9 @@ class Game_Event
attr_reader :title, :message, :fatal attr_reader :title, :message, :fatal
def initialize(title, message, fatal=true) def initialize(title, message, fatal=true)
@title = title @title = title
@message = message @message = message
@fatal = fatal @fatal = fatal
$log.error(@fatal ? "致命错误" : "一般错误") { "#{@title}: #{@message} #{caller}" } $log.error(@fatal ? "致命错误" : "一般错误") { "#{@title}: #{@message} #{caller}" }
end end
end end
......
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin begin
Windows = RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"] Windows = RUBY_PLATFORM["mswin"] || RUBY_PLATFORM["ming"]
Font = ['fonts/wqy-microhei.ttc', '/usr/share/fonts/wqy-microhei/wqy-microhei.ttc', '/usr/share/fonts/truetype/wqy/wqy-microhei.ttc'].find{|file|File.file? file} Font = ['fonts/wqy-microhei.ttc', '/usr/share/fonts/wqy-microhei/wqy-microhei.ttc', '/usr/share/fonts/truetype/wqy/wqy-microhei.ttc', '/Library/Fonts/Hiragino Sans GB W3.otf'].find{|file|File.file? file}
#System_Encoding = Windows ? "CP#{`chcp`.scan(/\d+$/)}" : `locale |grep LANG |awk -F '=' '{print $2}'` #System_Encoding = Windows ? "CP#{`chcp`.scan(/\d+$/)}" : `locale |grep LANG |awk -F '=' '{print $2}'`
Dir.glob('post_update_*.rb').sort.each { |file| load file } Dir.glob('post_update_*.rb').sort.each { |file| load file }
......
...@@ -14,7 +14,7 @@ module Resolution ...@@ -14,7 +14,7 @@ module Resolution
get_system_metrics = Win32API.new "User32.dll", "GetSystemMetrics", ["L"], "L" get_system_metrics = Win32API.new "User32.dll", "GetSystemMetrics", ["L"], "L"
[get_system_metrics.call(0), get_system_metrics.call(1)] [get_system_metrics.call(0), get_system_metrics.call(1)]
else else
`xdpyinfo`.scan(/dimensions: (\d+)x(\d+) pixels/).flatten.collect { |n| n.to_i } `xdpyinfo`.scan(/dimensions: (\d+)x(\d+) pixels/).flatten.collect { |n| n.to_i } rescue [1440, 900]
end end
end end
......
...@@ -17,7 +17,7 @@ class Scene_Title < Scene ...@@ -17,7 +17,7 @@ class Scene_Title < Scene
@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 : title["special"] ? 42 : 400, title["special"] ? 321 : $config['screen']['height']/2-100) @command_window = Window_Title.new(title["left"] ? 200 : title["right"] ? 600 : title["special"] ? 42 : 400, title["special"] ? 321 : $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) rescue nil
super super
end end
def clear(x,y,width,height) def clear(x,y,width,height)
...@@ -25,7 +25,7 @@ class Scene_Title < Scene ...@@ -25,7 +25,7 @@ class Scene_Title < Scene
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 @decision_se
case @command_window.index case @command_window.index
when 0 when 0
require_relative 'scene_login' require_relative 'scene_login'
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require "fileutils" require "fileutils"
require_relative 'card' require_relative 'card'
module Update module Update
Version = '1.1.3' Version = '1.1.5'
URL = "https://my-card.in/mycard/update.json?version=#{Version}" URL = "https://my-card.in/mycard/update.json?version=#{Version}"
class <<self class <<self
attr_reader :thumbnails, :images, :status attr_reader :thumbnails, :images, :status
......
require_relative 'cacheable' require_relative 'cacheable'
class User class User
attr_accessor :id, :name, :friend, :role attr_accessor :id, :name, :friend, :affiliation
alias friend? friend alias friend? friend
extend Cacheable extend Cacheable
def initialize(id, name="") def initialize(id, name="")
......
...@@ -27,7 +27,7 @@ class Window_Chat < Window_Scrollable ...@@ -27,7 +27,7 @@ class Window_Chat < Window_Scrollable
if !@chat_input.value.empty? if !@chat_input.value.empty?
chatmessage = ChatMessage.new($game.user, @chat_input.value, @channel) chatmessage = ChatMessage.new($game.user, @chat_input.value, @channel)
$game.chat chatmessage $game.chat chatmessage
Game_Event.push Game_Event::Chat.new(chatmessage) if !$game.is_a? Ygocore Game_Event.push Game_Event::Chat.new(chatmessage) if @channel != :lobby
true true
end end
end end
......
...@@ -8,12 +8,12 @@ class Window_Title < Window_List ...@@ -8,12 +8,12 @@ class Window_Title < Window_List
@button.set_alpha(RLEACCEL,255) @button.set_alpha(RLEACCEL,255)
@single_height = @button.h / Button_Count @single_height = @button.h / Button_Count
super(x,y,@button.w / 3,WLH * Button_Count - (WLH - @button.h / Button_Count)) super(x,y,@button.w / 3,WLH * Button_Count - (WLH - @button.h / Button_Count))
@cursor_se = Mixer::Wave.load 'audio/se/cursor.ogg' if SDL.inited_system(INIT_AUDIO) != 0 @cursor_se = (Mixer::Wave.load 'audio/se/cursor.ogg' if SDL.inited_system(INIT_AUDIO) != 0) rescue nil
self.items = [:决斗开始, :单人模式, :卡组编成, :选项设置, :退出游戏] self.items = [:决斗开始, :单人模式, :卡组编成, :选项设置, :退出游戏]
end end
def index=(index) def index=(index)
if index and @index != index if index and @index != index
Mixer.play_channel(-1,@cursor_se,0) if SDL.inited_system(INIT_AUDIO) != 0 Mixer.play_channel(-1,@cursor_se,0) if @cursor_se
end end
super super
end end
......
...@@ -49,6 +49,9 @@ class Ygocore < Game ...@@ -49,6 +49,9 @@ class Ygocore < Game
Game_Event.push(Game_Event::Chat.new(ChatMessage.new(User.new(:system, 'System'), '聊天服务连接中断: ' + exception.to_s))) Game_Event.push(Game_Event::Chat.new(ChatMessage.new(User.new(:system, 'System'), '聊天服务连接中断: ' + exception.to_s)))
end end
@@im_room.add_message_callback do |m| @@im_room.add_message_callback do |m|
if m.from.resource.nil? and m.subject
Game_Event.push Game_Event::Chat.new ChatMessage.new(User.new(:subject, '主题'), m.subject, :lobby) rescue $log.error('收到聊天消息') { $! }
end
if m.from.resource and m.body if m.from.resource and m.body
user = m.from.resource == nickname ? @user : User.new(m.from.resource.to_sym, m.from.resource) user = m.from.resource == nickname ? @user : User.new(m.from.resource.to_sym, m.from.resource)
Game_Event.push Game_Event::Chat.new ChatMessage.new(user, m.body, :lobby) rescue $log.error('收到聊天消息') { $! } Game_Event.push Game_Event::Chat.new ChatMessage.new(user, m.body, :lobby) rescue $log.error('收到聊天消息') { $! }
...@@ -62,7 +65,7 @@ class Ygocore < Game ...@@ -62,7 +65,7 @@ class Ygocore < Game
end end
@@im_room.add_join_callback do |m| @@im_room.add_join_callback do |m|
user = User.new m.from.resource.to_sym, m.from.resource user = User.new m.from.resource.to_sym, m.from.resource
user.role = m.x.first_element('item').role rescue nil user.affiliation = m.x('http://jabber.org/protocol/muc#user').first_element('item').affiliation rescue nil
Game_Event.push Game_Event::NewUser.new user Game_Event.push Game_Event::NewUser.new user
end end
@@im_room.add_leave_callback do |m| @@im_room.add_leave_callback do |m|
......
class User class User
attr_reader :certified attr_reader :certified
def initialize(id, name = "", certified = true) def initialize(id, name = "", certified = true)
@id = id @id = id
@name = name @name = name
@certified = certified @certified = certified
end end
def set(id, name = :keep, certified = :keep) def set(id, name = :keep, certified = :keep)
@id = id unless id == :keep @id = id unless id == :keep
@name = name unless name == :keep @name = name unless name == :keep
@certified = certified unless certified == :keep @certified = certified unless certified == :keep
end end
def color def color
case @role case @affiliation
when :moderator when :owner
[148,43,226] [220,20,60]
else when :admin
@certified ? [0,0,0] : [128,128,128] [148, 43, 226]
else
@certified ? [0, 0, 0] : [128, 128, 128]
end end
end end
def space def space
if @certified if @certified
Dialog.web "https://my-card.in/users/#{CGI.escape @id.to_s}" Dialog.web "https://my-card.in/users/#{CGI.escape @id.to_s}"
...@@ -25,8 +31,9 @@ class User ...@@ -25,8 +31,9 @@ class User
Widget_Msgbox.new("查看资料", "用户#{@name}没有注册", :ok => "确定") Widget_Msgbox.new("查看资料", "用户#{@name}没有注册", :ok => "确定")
end end
end end
def avatar(size = :small) def avatar(size = :small)
id = (@id.respond_to?(:bare) ? @id.bare : @id).to_s id = (@id.respond_to?(:bare) ? @id.bare : @id).to_s
cache = "graphics/avatars/mycard_#{id}_#{size}.png" cache = "graphics/avatars/mycard_#{id}_#{size}.png"
result = Surface.load(cache) rescue Surface.load("graphics/avatars/loading_#{size}.png") result = Surface.load(cache) rescue Surface.load("graphics/avatars/loading_#{size}.png")
scene = $scene scene = $scene
...@@ -34,13 +41,13 @@ class User ...@@ -34,13 +41,13 @@ class User
yield result yield result
Thread.new do Thread.new do
require 'cgi' require 'cgi'
$log.info('读取头像'){"https://my-card.in/users/#{CGI.escape id.to_s}.png"} $log.info('读取头像') { "https://my-card.in/users/#{CGI.escape id.to_s}.png" }
begin begin
open("https://my-card.in/users/#{CGI.escape id.to_s}.png", 'rb') {|io|open(cache, 'wb') {|c|c.write io.read}} open("https://my-card.in/users/#{CGI.escape id.to_s}.png", 'rb') { |io| open(cache, 'wb') { |c| c.write io.read } }
rescue Exception => exception rescue Exception => exception
$log.error('下载头像'){[exception.inspect, *exception.backtrace].join("\n").force_encoding("UTF-8")} $log.error('下载头像') { [exception.inspect, *exception.backtrace].join("\n").force_encoding("UTF-8") }
cache = "graphics/avatars/error_#{size}.png" cache = "graphics/avatars/error_#{size}.png"
end end
(yield Surface.load(cache) if scene == $scene) rescue nil (yield Surface.load(cache) if scene == $scene) rescue nil
end end
else else
......
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