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

公告

parent e9c3391f
...@@ -9,26 +9,22 @@ class Game_Event ...@@ -9,26 +9,22 @@ class Game_Event
Login Login
when "C" when "C"
AllUsers AllUsers
when "F" when "F", "Q" #F=加入观战
Join Join
when "G" when "G"
Watch Watch
when "H" when "H", "M"
Leave Leave
when "J" when "J"
Action Action
when "K" when "K"
WatchAction WatchAction
when "M"
Leave
when 'N' when 'N'
PrivateChat PrivateChat
when "O" when "O"
Chat Chat
when "P" when "P"
AllRooms AllRooms
when "Q"
NewRoom
when "R" when "R"
QROOMOK #卡表 QROOMOK #卡表
else else
......
#encoding: UTF-8 #encoding: UTF-8
load File.expand_path('window_login.rb', File.dirname(__FILE__)) load File.expand_path('window_login.rb', File.dirname(__FILE__))
require 'open-uri'
class Iduel < Game class Iduel < Game
Version = "20110131" Version = "20110131"
Server = "iduel.ocgsoft.cn" Server = "iduel.ocgsoft.cn"
...@@ -89,7 +90,6 @@ class Iduel < Game ...@@ -89,7 +90,6 @@ class Iduel < Game
private private
def connect def connect
require 'socket' require 'socket'
require 'open-uri'
begin begin
@conn = TCPSocket.new(Server, Port) #TODO: 阻塞优化,注意login。下面注释掉的两句实现connect无阻塞,但是login依然会阻塞所以只优化这里没有意义 @conn = TCPSocket.new(Server, Port) #TODO: 阻塞优化,注意login。下面注释掉的两句实现connect无阻塞,但是login依然会阻塞所以只优化这里没有意义
#@conn = Socket.new(:INET, :STREAM) #@conn = Socket.new(:INET, :STREAM)
...@@ -120,4 +120,21 @@ class Iduel < Game ...@@ -120,4 +120,21 @@ class Iduel < Game
info.gsub!("\n", "\r\n") info.gsub!("\n", "\r\n")
(@conn.write info) rescue Game_Event.push Game_Event::Error.new($!.class.to_s, $!.message) (@conn.write info) rescue Game_Event.push Game_Event::Error.new($!.class.to_s, $!.message)
end end
#公告
$config['iDuel']['announcements'] ||= {"正在读取公告..." => nil}
Thread.new do
begin
open('http://www.duelcn.com/topic-Announce.html') do |file|
file.set_encoding "GBK"
announcements = {}
file.read.scan(/<li><em>.*?<\/em><a href="(.*?)" title="(.*?)" target="_blank">.*?<\/a><\/li>/).each do |url, title|
announcements[title.encode("UTF-8")] = "http://www.duelcn.com/#{url}"
end
$config['iDuel']['announcements'].replace announcements
save_config
end
rescue Exception => exception
$log.error('公告') {[exception.inspect, *exception.backtrace].join("\n")}
end
end
end end
\ No newline at end of file
#encoding: UTF-8 #encoding: UTF-8
class Window_Login class Window_Login
def clicked def clicked
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", "正在登陆")
...@@ -10,13 +11,13 @@ class Window_Login ...@@ -10,13 +11,13 @@ class Window_Login
$config[$config['game']]['password'] = @remember_password.checked? ? @password_inputbox.value : nil $config[$config['game']]['password'] = @remember_password.checked? ? @password_inputbox.value : nil
save_config save_config
$game.login(@username_inputbox.value, @password_inputbox.value) $game.login(@username_inputbox.value, @password_inputbox.value)
@last_clicked = Time.now
when :register when :register
require 'launchy' require 'launchy'
Launchy.open(Iduel::Register_Url) Launchy.open(Iduel::Register_Url)
@last_clicked = Time.now
when :replay when :replay
require 'tk' require 'tk'
#由于Tk对话框点击取消的时候SDL会再识别一次点击,所以这里做一下处理,对两次间隔小于1s的点击忽略
return if @replay_clicked and Time.now - @replay_clicked < 1
file = Tk.getOpenFile file = Tk.getOpenFile
if !file.empty? if !file.empty?
$game = Iduel.new $game = Iduel.new
...@@ -26,7 +27,7 @@ class Window_Login ...@@ -26,7 +27,7 @@ class Window_Login
$log.debug('iduel window_login'){'loading reply file'} $log.debug('iduel window_login'){'loading reply file'}
$scene = Scene_Replay.new Replay.load file $scene = Scene_Replay.new Replay.load file
end end
@replay_clicked = Time.now @last_clicked = Time.now
end end
end end
end end
\ No newline at end of file
#encoding: UTF-8 #encoding: UTF-8
load File.expand_path('window_login.rb', File.dirname(__FILE__))
class NBX < Game class NBX < Game
Version = "20090622" Version = "20090622"
Port=2583 Port=2583
...@@ -146,4 +145,7 @@ class NBX < Game ...@@ -146,4 +145,7 @@ class NBX < Game
end end
end end
$game = NBX.new
$config[$config['game']]['username'] ||= ENV['USERNAME']
save_config
$game.login $config[$config['game']]['username']
#encoding: UTF-8
class Window_Login
def initialize(*args)
$game = NBX.new
username = $config['username'] && !$config['username'].empty? ? $config['username'] : $_ENV['username']
$game.login username
end
end
...@@ -148,16 +148,15 @@ class Scene_Duel < Scene ...@@ -148,16 +148,15 @@ class Scene_Duel < Scene
refresh refresh
when Game_Event::Leave when Game_Event::Leave
$scene = Scene_Lobby.new $scene = Scene_Lobby.new
when Game_Event::NewRoom when Game_Event::Join
if event.room == $game.room $game.room = event.room
@player_lp_window.player = $game.room.player1 @player_lp_window.player = $game.room.player1
@opponent_lp_window.player = $game.room.player2 @opponent_lp_window.player = $game.room.player2
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})")
else else
notify_send("对手离开房间", "对手离开房间") notify_send("对手离开房间", "对手离开房间")
end
end end
else else
super super
...@@ -177,6 +176,9 @@ class Scene_Duel < Scene ...@@ -177,6 +176,9 @@ class Scene_Duel < Scene
@opponent_lp_window.lp = $game.opponent_field.lp @opponent_lp_window.lp = $game.opponent_field.lp
end end
def terminate def terminate
unless $scene.is_a? Scene_Lobby or $scene.is_a? Scene_Duel
$game.exit
end
save_replay save_replay
super super
end end
......
...@@ -11,6 +11,7 @@ class Scene_Lobby < Scene ...@@ -11,6 +11,7 @@ class Scene_Lobby < Scene
require_relative 'window_roomlist' require_relative 'window_roomlist'
require_relative 'window_chat' require_relative 'window_chat'
require_relative 'chatmessage' require_relative 'chatmessage'
require_relative 'scene_duel'
attr_reader :chat_window attr_reader :chat_window
def start def start
WM::set_caption("MyCard - #{$config['game']} - #{$game.user.name}(#{$game.user.id})", "MyCard") WM::set_caption("MyCard - #{$config['game']} - #{$game.user.name}(#{$game.user.id})", "MyCard")
...@@ -81,7 +82,6 @@ class Scene_Lobby < Scene ...@@ -81,7 +82,6 @@ class Scene_Lobby < Scene
when Game_Event::AllRooms when Game_Event::AllRooms
@roomlist.items = $game.rooms @roomlist.items = $game.rooms
when Game_Event::Join when Game_Event::Join
require_relative 'scene_duel'
$scene = Scene_Duel.new(event.room, Deck.load("test1.TXT")) $scene = Scene_Duel.new(event.room, Deck.load("test1.TXT"))
when Game_Event::Watch when Game_Event::Watch
require_relative 'scene_watch' require_relative 'scene_watch'
...@@ -115,4 +115,9 @@ class Scene_Lobby < Scene ...@@ -115,4 +115,9 @@ class Scene_Lobby < Scene
end end
end end
end end
def terminate
unless $scene.is_a? Scene_Lobby or $scene.is_a? Scene_Duel
$game.exit
end
end
end end
\ No newline at end of file
...@@ -5,20 +5,21 @@ ...@@ -5,20 +5,21 @@
#  login #  login
#============================================================================== #==============================================================================
require_relative 'window_gameselect' require_relative 'window_gameselect'
require_relative 'window_announcements'
require_relative 'window_login' require_relative 'window_login'
require_relative 'scene_replay' require_relative 'scene_replay'
class Scene_Login < Scene class Scene_Login < Scene
def start def start
WM::set_caption("MyCard", "MyCard") WM::set_caption("MyCard", "MyCard")
@background = Surface.load("graphics/login/background.png").display_format @background = Surface.load("graphics/login/background.png").display_format
@gameselect_window = Window_GameSelect.new(117,269,$config["game"]) $config['game'] = 'iDuel' #临时修补点击过一次局域网之后无限进入局域网的问题
@gameselect_window = Window_GameSelect.new(117,269)
@announcements_window = Window_Announcements.new(313,265,600,24)
end end
#def handle(event) def update
# case event @announcements_window.update
# when Event::Active super
# if event.gain end
# end
#end
def handle_game(event) def handle_game(event)
case event case event
when Game_Event::Login when Game_Event::Login
......
class Window_Announcements < Window
def initialize(x,y,width,height)
super(x,y,width,height)
@items = $config[$config['game']]['announcements']
@font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 18)
@color = [44,64,78]
@last_announcement = @items.first
refresh
end
def refresh
clear
@font.draw_blended_utf8(@contents, @items.first[0], 0, 0, *@color)
end
def update
if @items.first != @last_announcement
refresh
@last_announcement = @items.first
end
super
end
def clicked
require 'launchy'
Launchy.open(@items.first[1]) if @items.first[1]
end
end
...@@ -35,7 +35,7 @@ class Window_CardInfo < Window ...@@ -35,7 +35,7 @@ class Window_CardInfo < Window
@contents.put @card.image,0,0 @contents.put @card.image,0,0
@font.draw_blended_utf8(@contents, "[#{@card.name}]", 160, 0, 0xFF, 0xFF, 0x55) @font.draw_blended_utf8(@contents, "[#{@card.name}]", 160, 0, 0xFF, 0xFF, 0x55)
@font.draw_blended_utf8(@contents, "卡类: #{@card.card_type}", 160, WLH, 0xFF, 0xFF, 0x55) @font.draw_blended_utf8(@contents, "#{@card.card_type}", 160, WLH, 0xFF, 0xFF, 0x55)
if @card.monster? if @card.monster?
@font.draw_blended_utf8(@contents, "种族: #{@card.type}", 160, WLH*2, 0xFF, 0xFF, 0xFF) @font.draw_blended_utf8(@contents, "种族: #{@card.type}", 160, WLH*2, 0xFF, 0xFF, 0xFF)
@font.draw_blended_utf8(@contents, "星级: #{@card.level}", 160, WLH*3, 0xFF, 0xFF, 0xFF) @font.draw_blended_utf8(@contents, "星级: #{@card.level}", 160, WLH*3, 0xFF, 0xFF, 0xFF)
......
#encoding: UTF-8 #encoding: UTF-8
class Window_GameSelect < Window_List class Window_GameSelect < Window_List
WLH = 56 WLH = 56
def initialize(x,y,game_name=nil) def initialize(x,y)
@font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 24) @font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 24)
@color = [255,255,255] @color = [255,255,255]
@game_color = [47,156,192] @game_color = [47,156,192]
...@@ -23,7 +23,7 @@ class Window_GameSelect < Window_List ...@@ -23,7 +23,7 @@ class Window_GameSelect < Window_List
@button = Surface.load("graphics/login/game_background.png") @button = Surface.load("graphics/login/game_background.png")
#@button.set_alpha(RLEACCEL,255) #@button.set_alpha(RLEACCEL,255)
self.items = @items self.items = @items
self.index = @items.find_index{|game|game["name"] == game_name} || 0 self.index = @items.find_index{|game|game["name"] == $config['game']} || 0
clicked clicked
refresh refresh
end end
......
...@@ -8,9 +8,9 @@ class Window_Login < Window ...@@ -8,9 +8,9 @@ class Window_Login < Window
@password = password @password = password
@button = Surface.load("graphics/login/button.png") @button = Surface.load("graphics/login/button.png")
super(x,y,597,338) super(x,y,597,338)
@username_inputbox = Widget_InputBox.new(@x+192, @y+80, 165, WLH){@password_inputbox.clicked;false} @username_inputbox = Widget_InputBox.new(@x+192, @y+80, 165, WLH){|text|@username_inputbox.value = text;@password_inputbox.clicked;false}
@username ? @username_inputbox.value = @username : @username_inputbox.refresh @username ? @username_inputbox.value = @username : @username_inputbox.refresh
@password_inputbox = Widget_InputBox.new(@x+192, @y+125, 165, WLH){Widget_InputBox.determine;self.index=:login;clicked;false} @password_inputbox = Widget_InputBox.new(@x+192, @y+125, 165, WLH){|text|Widget_InputBox.determine;self.index=:login;clicked;false}
@password_inputbox.type = :password @password_inputbox.type = :password
@password ? @password_inputbox.value = @password : @password_inputbox.refresh @password ? @password_inputbox.value = @password : @password_inputbox.refresh
@color = [255,255,255] @color = [255,255,255]
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
class Window_UserInfo < Window class Window_UserInfo < Window
def initialize(x, y, user) def initialize(x, y, user)
@avatar_boarder = Surface.load("graphics/lobby/avatar_boader.png") @avatar_boarder = Surface.load("graphics/lobby/avatar_boader.png")
super(x,y,240,144) super(x,y,280,144)
@font = TTF.open('fonts/WenQuanYi Micro Hei.ttf', 16) @font = TTF.open('fonts/WenQuanYi Micro Hei.ttf', 16)
@user = user @user = user
@background = Surface.load("graphics/lobby/userinfo.png").display_format @background = Surface.load("graphics/lobby/userinfo.png").display_format
...@@ -26,8 +26,8 @@ class Window_UserInfo < Window ...@@ -26,8 +26,8 @@ class Window_UserInfo < Window
@font.draw_blended_utf8(@contents, @user.name, 160, 12, 0x00,0x00,0x00) @font.draw_blended_utf8(@contents, @user.name, 160, 12, 0x00,0x00,0x00)
@font.draw_blended_utf8(@contents, "id: #{@user.id}" , 160, 12+16*2, 0x00,0x00,0x00) @font.draw_blended_utf8(@contents, "id: #{@user.id}" , 160, 12+16*2, 0x00,0x00,0x00)
@font.draw_blended_utf8(@contents, "Lv: #{@user.level}" , 160, 12+16*3, 0x00,0x00,0x00) if @user.respond_to? :level #TODO:规范化,level是iduel专属的,但是又不太想让iduel来重定义这个window @font.draw_blended_utf8(@contents, "Lv: #{@user.level}" , 160, 12+16*3, 0x00,0x00,0x00) if @user.respond_to? :level and @user.level #TODO:规范化,level是iduel专属的,但是又不太想让iduel来重定义这个window
@font.draw_blended_utf8(@contents, "经验: #{@user.exp}", 160, 12+16*4, 0x00,0x00,0x00) if @user.respond_to? :exp @font.draw_blended_utf8(@contents, "经验: #{@user.exp}", 160, 12+16*4, 0x00,0x00,0x00) if @user.respond_to? :exp and @user.exp
end end
def dispose def dispose
@thread.exit @thread.exit
......
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