Commit 4fbb42d5 authored by 神楽坂玲奈's avatar 神楽坂玲奈

resolution: 1024x640

parent f896c850
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
module Association
module_function
def register
if Windows
require 'win32/registry'
path, command, icon = paths
Win32::Registry::HKEY_CLASSES_ROOT.create('mycard') { |reg| reg['URL Protocol'] = path.ljust path.bytesize }
Win32::Registry::HKEY_CLASSES_ROOT.create('mycard\shell\open\command') { |reg| reg[nil] = command.ljust command.bytesize }
Win32::Registry::HKEY_CLASSES_ROOT.create('mycard\DefaultIcon') { |reg| reg[nil] = icon.ljust icon.bytesize }
Win32::Registry::HKEY_CLASSES_ROOT.create('.ydk') { |reg| reg[nil] = 'mycard' }
Win32::Registry::HKEY_CLASSES_ROOT.create('.yrp') { |reg| reg[nil] = 'mycard' }
Win32::Registry::HKEY_CLASSES_ROOT.create('.deck') { |reg| reg[nil] = 'mycard' }
end
end
def paths
pwd = Dir.pwd.gsub('/', '\\')
path = '"' + pwd + '\ruby\bin\rubyw.exe" -C"' + pwd + '" -KU lib/main.rb'
command = path + ' "%1"'
icon = '"' + pwd + '\mycard.exe", 0'
[path, command, icon]
end
def need?
return false unless Windows
return false if $config['no_assoc']
path, command, icon = paths
require 'win32/registry'
begin
Win32::Registry::HKEY_CLASSES_ROOT.open('mycard') { |reg| return true unless reg['URL Protocol'] == path }
Win32::Registry::HKEY_CLASSES_ROOT.open('mycard\shell\open\command') { |reg| return true unless reg[nil] == command }
Win32::Registry::HKEY_CLASSES_ROOT.open('mycard\DefaultIcon') { |reg| return true unless reg[nil] == icon }
Win32::Registry::HKEY_CLASSES_ROOT.open('.ydk') { |reg| return true unless reg[nil] == 'mycard' }
Win32::Registry::HKEY_CLASSES_ROOT.open('.yrp') { |reg| return true unless reg[nil] == 'mycard' }
Win32::Registry::HKEY_CLASSES_ROOT.open('.deck') { |reg| return true unless reg[nil] == 'mycard' }
rescue
return true
end
end
def request
require_relative 'widget_msgbox'
Widget_Msgbox.new("mycard", "即将进行文件关联, 弹出安全警告请点允许", ok: "确定", cancel: "取消") do |clicked|
if clicked == :ok
yield
else
Widget_Msgbox.new("mycard", "没有进行关联,要重新关联请删除config.yml")
$config['no_assoc'] = true
Config.save
end
end
end
def start
if need?
request do
register rescue Dialog.uac("ruby/bin/rubyw.exe", "-KU lib/main.rb register_association")
end
end
end
end
\ No newline at end of file
require 'yaml'
require_relative 'resolution'
Config = Module.new
module Config
module_function
def load(file="config.yml")
config = YAML.load_file(file) rescue {}
config = {} unless config.is_a? Hash
config['bgm'] = true if config['bgm'].nil?
config['screen'] ||= {}
config['screen']['width'], config['screen']['height'] = Resolution.default unless Resolution.all.include? [config['screen']['width'], config['screen']['height']]
config
end
def save(config=$config, file="config.yml")
File.open(file, "w") { |file| YAML.dump(config, file) }
end
end
\ No newline at end of file
module Graphics
module_function
Ext = ['.png', '.jpg', '.gif']
def load(directory, filename, alpha=true)
extname = File.extname(filename)
path = "graphics/#{directory}/#{File.dirname(filename)}/#{File.basename(filename, extname)}"
result = if extname.empty?
Ext.each do |ext|
result = load_file(path, ext)
break result if result
end
else
load_file(path, extname)
end
raise 'file not exist' if result.nil?
if alpha
result.display_format_alpha
else
result.display_format
end
end
def load_file(path, ext)
path_with_resolution = "#{path}-#{$config['screen']['width']}x#{$config['screen']['height']}#{ext}"
if File.file? path_with_resolution
Surface.load path_with_resolution
elsif File.file? path += ext
Surface.load path
end
end
end
\ No newline at end of file
...@@ -117,7 +117,7 @@ class Iduel < Game ...@@ -117,7 +117,7 @@ class Iduel < Game
User.new(id).friend = true User.new(id).friend = true
$config['iDuel']['friends'] << id $config['iDuel']['friends'] << id
end end
save_config Config.save
end end
rescue Exception => exception rescue Exception => exception
$log.error('读取好友信息') {[exception.inspect, *exception.backtrace].collect{|str|str.encode("UTF-8")}.join("\n")} $log.error('读取好友信息') {[exception.inspect, *exception.backtrace].collect{|str|str.encode("UTF-8")}.join("\n")}
...@@ -169,7 +169,7 @@ class Iduel < Game ...@@ -169,7 +169,7 @@ class Iduel < Game
announcements << Announcement.new(title.encode("UTF-8"), "http://www.duelcn.com/#{url}", nil) announcements << Announcement.new(title.encode("UTF-8"), "http://www.duelcn.com/#{url}", nil)
end end
$config['iDuel']['announcements'].replace announcements $config['iDuel']['announcements'].replace announcements
save_config Config.save
end end
rescue Exception => exception rescue Exception => exception
$log.error('公告') {[exception.inspect, *exception.backtrace].collect{|str|str.encode("UTF-8")}.join("\n")} $log.error('公告') {[exception.inspect, *exception.backtrace].collect{|str|str.encode("UTF-8")}.join("\n")}
......
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
save_config 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
This diff is collapsed.
module Resolution
module_function
def all
[
[1024, 768],
[1024, 640]
]
end
def system
return [1024, 768]
if Windows
require 'win32api'
get_system_metrics = Win32API.new "User32.dll", "GetSystemMetrics", ["L"], "L"
[get_system_metrics.call(0), get_system_metrics.call(1)]
else
`xrandr`.scan(/current (\d+) x (\d+)/).flatten.collect { |n| n.to_i }
end
end
def default
system_resolution = self.system
all.each do |width, height|
#p [width, height, system_resolution[0], system_resolution[1], (system_resolution[0] < width and system_resolution[1] < height)]
return [width, height] if system_resolution[0] > width and system_resolution[1] > height
end
all.last
end
end
\ No newline at end of file
...@@ -51,7 +51,7 @@ class Scene ...@@ -51,7 +51,7 @@ class Scene
# ● 开始处理 # ● 开始处理
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
def start def start
if $config['bgm'] and @@last_bgm != bgm and File.file? "audio/bgm/#{bgm}" if $config['bgm'] and @@last_bgm != bgm and SDL.inited_system(INIT_AUDIO) != 0 and File.file? "audio/bgm/#{bgm}"
@@bgm.destroy if @@bgm @@bgm.destroy if @@bgm
@@bgm = Mixer::Music.load "audio/bgm/#{bgm}" @@bgm = Mixer::Music.load "audio/bgm/#{bgm}"
Mixer.fade_in_music(@@bgm, -1, 800) Mixer.fade_in_music(@@bgm, -1, 800)
...@@ -130,7 +130,7 @@ class Scene ...@@ -130,7 +130,7 @@ class Scene
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)
save_config Config.save
end end
when Key::F12 when Key::F12
$scene = Scene_Title.new $scene = Scene_Title.new
......
...@@ -43,7 +43,7 @@ class Scene_Duel < Scene ...@@ -43,7 +43,7 @@ class Scene_Duel < Scene
@player_lp_window = Window_LP.new(0,0, @room.player1, true) @player_lp_window = Window_LP.new(0,0, @room.player1, true)
@opponent_lp_window = Window_LP.new(360,0, @room.player2, false) @opponent_lp_window = Window_LP.new(360,0, @room.player2, false)
@join_se = Mixer::Wave.load("audio/se/join.ogg") @join_se = Mixer::Wave.load("audio/se/join.ogg") if SDL.inited_system(INIT_AUDIO) != 0
create_action_window create_action_window
create_chat_window create_chat_window
...@@ -161,7 +161,7 @@ class Scene_Duel < Scene ...@@ -161,7 +161,7 @@ class Scene_Duel < Scene
player = $game.room.player1 == $game.user ? $game.room.player2 : $game.room.player1 player = $game.room.player1 == $game.user ? $game.room.player2 : $game.room.player1
if player if player
notify_send("对手加入房间", "#{player.name}(#{player.id})") notify_send("对手加入房间", "#{player.name}(#{player.id})")
Mixer.play_channel(-1,@join_se,0) Mixer.play_channel(-1,@join_se,0) if SDL.inited_system(INIT_AUDIO) != 0
else else
notify_send("对手离开房间", "对手离开房间") notify_send("对手离开房间", "对手离开房间")
end end
...@@ -175,7 +175,7 @@ class Scene_Duel < Scene ...@@ -175,7 +175,7 @@ class Scene_Duel < Scene
super super
end end
def refresh def refresh
@fieldback_window.card = $game.player_field.field[0] && $game.player_field.field[0].card_type == :场地魔法 && $game.player_field.field[0].position == :attack ? $game.player_field.field[0] : $game.opponent_field.field[0] && $game.opponent_field.field[0].card_type == :场地魔法 && $game.opponent_field.field[0].position == :attack ? $game.opponent_field.field[0] : nil @fieldback_window.card = $game.player_field.field[0] && $game.player_field.field[0].card_type == :"场地魔法" && $game.player_field.field[0].position == :attack ? $game.player_field.field[0] : $game.opponent_field.field[0] && $game.opponent_field.field[0].card_type == :"场地魔法" && $game.opponent_field.field[0].position == :attack ? $game.opponent_field.field[0] : nil
@player_field_window.refresh @player_field_window.refresh
@opponent_field_window.refresh @opponent_field_window.refresh
@phases_window.player = $game.turn_player @phases_window.player = $game.turn_player
......
#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 = Surface.load("graphics/lobby/background.png").display_format @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
<<<<<<< HEAD @chat_window = Window_Chat.new(313,$config['screen']['height'] - 225,698,212)
@chat_window = Window_Chat.new(313,543,698,212) @count = 0
======= super
@chat_window = Window_Chat.new(313,$config['screen']['height'] - 225,698,212) end
>>>>>>> 8031a2a def bgm
@count = 0 "lobby.ogg"
super end
end def handle(event)
def bgm case event
"lobby.ogg" when Event::KeyDown
end case event.sym
def handle(event) when Key::UP
case event @active_window.cursor_up
when Event::KeyDown when Key::DOWN
case event.sym @active_window.cursor_down
when Key::UP when Key::F2
@active_window.cursor_up #@joinroom_msgbox = Widget_Msgbox.new("创建房间", "正在等待对手")
when Key::DOWN #$game.host Room.new(0, $game.user.name)
@active_window.cursor_down when Key::F3
when Key::F2 #@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入房间")
#@joinroom_msgbox = Widget_Msgbox.new("创建房间", "正在等待对手") #$game.join 'localhost'
#$game.host Room.new(0, $game.user.name) when Key::F5
when Key::F3 $game.refresh
#@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入房间") when Key::F12
#$game.join 'localhost' $game.exit
when Key::F5 $scene = Scene_Login.new
$game.refresh end
when Key::F12 else
$game.exit super
$scene = Scene_Login.new end
end end
else
super def handle_game(event)
end case event
end when Game_Event::AllUsers
@userlist.items = $game.users
def handle_game(event) when Game_Event::AllRooms
case event @roomlist.items = $game.rooms
when Game_Event::AllUsers when Game_Event::Join
@userlist.items = $game.users join(event.room)
when Game_Event::AllRooms when Game_Event::Watch
@roomlist.items = $game.rooms require_relative 'scene_watch'
when Game_Event::Join $scene = Scene_Watch.new(event.room)
join(event.room) when Game_Event::Chat
when Game_Event::Watch @chat_window.add event.chatmessage
require_relative 'scene_watch' else
$scene = Scene_Watch.new(event.room) super
when Game_Event::Chat end
@chat_window.add event.chatmessage end
else def join(room)
super $scene = Scene_Duel.new(room)
end end
end def update
def join(room) @chat_window.update
$scene = Scene_Duel.new(room) @host_window.update
end @roomlist.update
def update if @count >= $game.refresh_interval*60
@chat_window.update $game.refresh
@host_window.update @count = 0
@roomlist.update end
if @count >= $game.refresh_interval*60 @count += 1
$game.refresh super
@count = 0 end
end def terminate
@count += 1 unless $scene.is_a? Scene_Lobby or $scene.is_a? Scene_Duel
super $game.exit
end end
def terminate end
unless $scene.is_a? Scene_Lobby or $scene.is_a? Scene_Duel
$game.exit
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 = Surface.load("graphics/login/background.png").display_format @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'
...@@ -15,8 +15,8 @@ class Scene_Title < Scene ...@@ -15,8 +15,8 @@ class Scene_Title < Scene
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, 300) @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") @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)
...@@ -24,7 +24,7 @@ class Scene_Title < Scene ...@@ -24,7 +24,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) 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'
......
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) 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
save_config 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
#encoding: UTF-8 #encoding: UTF-8
#============================================================================== #==============================================================================
# ■ Window_Roomitems # ■ Window_Roomitems
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
#  大厅内房间列表 #  大厅内房间列表
#============================================================================== #==============================================================================
require_relative 'window_scrollable' require_relative 'window_scrollable'
require_relative 'window_join' require_relative 'window_join'
class Window_RoomList < Window_Scrollable class Window_RoomList < Window_Scrollable
attr_reader :items attr_reader :items
WLH = 48 WLH = 48
def initialize(x, y, items) def initialize(x, y, items)
@button = Surface.load('graphics/lobby/room.png') @button = Surface.load('graphics/lobby/room.png')
@button.set_alpha(RLEACCEL, 255) @button.set_alpha(RLEACCEL, 255)
#@background = Surface.load 'graphics/lobby/roomitems.png' #@background = Surface.load 'graphics/lobby/roomitems.png'
#@contents = Surface.load 'graphics/lobby/roomitems.png' #@contents = Surface.load 'graphics/lobby/roomitems.png'
<<<<<<< HEAD super(x,y,@button.w / 3, ($config['screen']['height'] - 288) / 48 * 48)
super(x,y,@button.w / 3, 48 * 10) @item_max = 0
======= @font = TTF.open("fonts/wqy-microhei.ttc", 16)
super(x,y,@button.w / 3, ($config['screen']['height'] - 288) / 48 * 48) @color = [0x03, 0x11, 0x22]
>>>>>>> 8031a2a @scrollbar = Widget_ScrollBar.new(self,@x+@width,@y,@height)
@item_max = 0 self.items = items
@font = TTF.open("fonts/wqy-microhei.ttc", 16) end
@color = [0x03, 0x11, 0x22]
@scrollbar = Widget_ScrollBar.new(self,@x+@width,@y,@height) def draw_item(index, status=0)
self.items = items y = item_rect(index)[1]
end room = @items[index]
Surface.blit(@button, @width*status, room.full? ? WLH : 0, @width, WLH, @contents, 0, y)
def draw_item(index, status=0) @font.draw_blended_utf8(@contents, room.id.to_s, 24, y+8, *@color)
y = item_rect(index)[1] @font.draw_blended_utf8(@contents, room.full? ? "【决斗中】" : room.private? ? "【私密房】" : "【等待中】", 8, y+24, *@color)
room = @items[index] @font.draw_blended_utf8(@contents, room.name, 128, y+8, *room.color) unless room.name.empty? or room.name.size > 100
Surface.blit(@button, @width*status, room.full? ? WLH : 0, @width, WLH, @contents, 0, y) $log.error('标题过长') {room.name} if room.name.size > 100
@font.draw_blended_utf8(@contents, room.id.to_s, 24, y+8, *@color) @font.draw_blended_utf8(@contents, room.player1.name, 128, y+24, *room.player1.color) if room.player1 and !room.player1.name.empty?
@font.draw_blended_utf8(@contents, room.full? ? "【决斗中】" : room.private? ? "【私密房】" : "【等待中】", 8, y+24, *@color) @font.draw_blended_utf8(@contents, room.player2.name, 320, y+24, *room.player2.color) if room.player2 and !room.player2.name.empty?
@font.draw_blended_utf8(@contents, room.name, 128, y+8, *room.color) unless room.name.empty? or room.name.size > 100 room.extra.each_with_index do |extra, index|
$log.error('标题过长') {room.name} if room.name.size > 100 str, color = extra
@font.draw_blended_utf8(@contents, room.player1.name, 128, y+24, *room.player1.color) if room.player1 and !room.player1.name.empty? @font.draw_blended_utf8(@contents, str, 300+index*96, y+8, *color)
@font.draw_blended_utf8(@contents, room.player2.name, 320, y+24, *room.player2.color) if room.player2 and !room.player2.name.empty? end
room.extra.each_with_index do |extra, index| end
str, color = extra def update
@font.draw_blended_utf8(@contents, str, 300+index*96, y+8, *color) @join_window.update if @join_window and !@join_window.destroyed?
end end
end def mousemoved(x,y)
def update return unless self.include?(x,y)
@join_window.update if @join_window and !@join_window.destroyed? self.index = (y - @y) / WLH + @scroll
end end
def mousemoved(x,y) def clicked
return unless self.include?(x,y) return unless @index and room = @items[@index]
self.index = (y - @y) / WLH + @scroll if room.full?
end @joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入观战")
def clicked $game.watch room
return unless @index and room = @items[@index] else
if room.full? if room.private
@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入观战") @join_window = Window_Join.new(0,0,room)
$game.watch room else
else @joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入房间")
if room.private $game.join room
@join_window = Window_Join.new(0,0,room) end
else end
@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入房间") end
$game.join room
end
end
end
end end
\ No newline at end of file
require_relative 'window_list' require_relative 'window_list'
class Window_Title < Window_List class Window_Title < Window_List
Button_Count = 5 Button_Count = 5
WLH = 50 WLH = 50
attr_reader :x, :y, :width, :height, :single_height, :index attr_reader :x, :y, :width, :height, :single_height, :index
def initialize(x,y) def initialize(x,y)
@button = Surface.load("graphics/system/titlebuttons.png") @button = Surface.load("graphics/system/titlebuttons.png")
@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' @cursor_se = Mixer::Wave.load 'audio/se/cursor.ogg' if SDL.inited_system(INIT_AUDIO) != 0
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) Mixer.play_channel(-1,@cursor_se,0) if SDL.inited_system(INIT_AUDIO) != 0
end end
super super
end end
def mousemoved(x,y) def mousemoved(x,y)
self.index = (y - @y) / WLH self.index = (y - @y) / WLH
end end
def draw_item(index, status=0) def draw_item(index, status=0)
Surface.blit(@button, @width*status, @single_height*index, @width, @single_height, @contents, 0, WLH*index) Surface.blit(@button, @width*status, @single_height*index, @width, @single_height, @contents, 0, WLH*index)
end end
def clicked def clicked
$scene.determine if $scene.is_a? Scene_Title $scene.determine if $scene.is_a? Scene_Title
end end
def clear(x=0,y=0,width=@width,height=@height) def clear(x=0,y=0,width=@width,height=@height)
@contents.fill_rect(x,y,width, height, 0x00000000) @contents.fill_rect(x,y,width, height, 0x00000000)
end end
end end
\ No newline at end of file
...@@ -208,7 +208,7 @@ class Ygocore < Game ...@@ -208,7 +208,7 @@ class Ygocore < Game
announcements << Announcement.new(title, @@config['index'], nil) announcements << Announcement.new(title, @@config['index'], nil)
end end
$config['ygocore']['announcements'].replace announcements $config['ygocore']['announcements'].replace announcements
save_config Config.save
end end
rescue Exception => exception rescue Exception => exception
$log.error('公告读取失败') { [exception.inspect, *exception.backtrace].collect { |str| str.encode("UTF-8") }.join("\n") } $log.error('公告读取失败') { [exception.inspect, *exception.backtrace].collect { |str| str.encode("UTF-8") }.join("\n") }
......
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("ygocore", "正在登录") Widget_Msgbox.new("ygocore", "正在登录")
$scene.draw #强制重绘一次,下面会阻塞 $scene.draw #强制重绘一次,下面会阻塞
$game = Ygocore.new $game = Ygocore.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
save_config 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
Ygocore.register Ygocore.register
@last_clicked = Time.now @last_clicked = Time.now
when :replay when :replay
file = Dialog.get_open_file("播放录像", "ygocore录像 (*.yrp)" => "*.yrp") file = Dialog.get_open_file("播放录像", "ygocore录像 (*.yrp)" => "*.yrp")
if !file.empty? and File.file? file if !file.empty? and File.file? file
Ygocore.replay file Ygocore.replay file
end end
@last_clicked = Time.now @last_clicked = Time.now
end end
end end
end end
\ No newline at end of file
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
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