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

记住密码

parent 69675801
fullscreen: false
width: 1024
height: 768
\ No newline at end of file
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
...@@ -6,6 +6,9 @@ class Window_Login ...@@ -6,6 +6,9 @@ class Window_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']]['password'] = @remember_password.checked? ? @password_inputbox.value : nil
save_config
$game.login(@username_inputbox.value, @password_inputbox.value) $game.login(@username_inputbox.value, @password_inputbox.value)
when :register when :register
require 'launchy' require 'launchy'
......
...@@ -9,6 +9,7 @@ begin ...@@ -9,6 +9,7 @@ begin
$config['screen'] ||= {} $config['screen'] ||= {}
$config['screen']['width'] ||= 1024 $config['screen']['width'] ||= 1024
$config['screen']['height'] ||= 768 $config['screen']['height'] ||= 768
p $config
end end
def save_config(file="config.yml") def save_config(file="config.yml")
File.open(file,"w"){|file| YAML.dump($config, file)} File.open(file,"w"){|file| YAML.dump($config, file)}
......
...@@ -151,6 +151,8 @@ class Scene_Duel < Scene ...@@ -151,6 +151,8 @@ class Scene_Duel < Scene
notify_send("对手离开房间", "对手离开房间") notify_send("对手离开房间", "对手离开房间")
end end
end end
else
super
end end
end end
def update def update
......
# To change this template, choose Tools | Templates # To change this template, choose Tools | Templates
# and open the template in the editor. # and open the template in the editor.
class Widget_checkbox class Widget_Checkbox < Window
def initialize(window, text, x,y,width=window.width-x,height=20,checked=false) attr_reader :checked
@x = x alias checked? checked
@y = y def initialize(window,x,y,width=window.width-x,height=24,checked=false,text="",&proc)
@text = text super(x+2,y+2,width,height,500) #+2是素材尺寸问题
@window = window @window = window
@text = text
@checked = checked @checked = checked
@checkbox = Surface.load 'graphics/system/checkbox.png' @checkbox = Surface.load('graphics/system/checkbox.png').display_format
@font = TTF.open("fonts/WenQuanYi Micro Hei.ttf", 20)
@proc = proc
refresh
end
def mousemoved(x,y)
if x-@x < 24
@index = 0
else
@index = nil
end
end end
def mouseover(x,y) def clicked
if @index
@checked = !@checked
@proc.call(@checked) if @proc
end
refresh
end end
def refresh def refresh
clear
Surface.blit(@checkbox, 0, @checked ? @checkbox.h/2 : 0, @checkbox.w/3, @checkbox.h/2, self.contents, 0, 0)
@font.draw_blended_utf8(self.contents, @text, 24, 0, 0xFF, 0xFF, 0xFF)
end end
#def clear(x=0,y=0,width=@width,height=@height)
# Surface.blit(@window.contents, @x-@window.x+x, @y-@window.y+y, width,height, self.contents, x, y)
#end
end end
...@@ -12,7 +12,7 @@ class Window_GameSelect < Window_List ...@@ -12,7 +12,7 @@ class Window_GameSelect < Window_List
if game.is_a?(Hash) && game["name"] if game.is_a?(Hash) && game["name"]
game['file'] ||= 'game.rb' game['file'] ||= 'game.rb'
game['file'] = File.expand_path(game['file'], File.dirname(file)) game['file'] = File.expand_path(game['file'], File.dirname(file))
$config[game['name']] = {} $config[game['name']] ||= {}
@items << game @items << game
else else
$log.error "#{game.inspect}读取失败(#{file})" $log.error "#{game.inspect}读取失败(#{file})"
...@@ -56,8 +56,9 @@ class Window_GameSelect < Window_List ...@@ -56,8 +56,9 @@ class Window_GameSelect < Window_List
end end
def clicked def clicked
load @items[@index]["file"] #TODO: load的这种架构微蛋疼,一时想不到更好的方案 load @items[@index]["file"] #TODO: load的这种架构微蛋疼,一时想不到更好的方案
p $config
$config['game'] = @items[@index]['name']
@login_window.destroy if @login_window @login_window.destroy if @login_window
p @items, @index, $config @login_window = Window_Login.new(316,316,$config[$config['game']]["username"],$config[$config['game']]["password"])
@login_window = Window_Login.new(316,316,$config[[@items][@index]['name']]["username"],$config[[@items][@index]['name']]["password"])
end end
end end
#encoding: UTF-8 #encoding: UTF-8
require_relative 'widget_inputbox' require_relative 'widget_inputbox'
require_relative 'widget_msgbox' require_relative 'widget_msgbox'
require_relative 'widget_checkbox'
class Window_Login < Window class Window_Login < Window
def initialize(x,y,username=nil, password=nil) def initialize(x,y,username=nil, password=nil)
@username = username @username = username
...@@ -30,6 +31,7 @@ class Window_Login < Window ...@@ -30,6 +31,7 @@ class Window_Login < Window
:replay => "战报" :replay => "战报"
} }
#self.index = nil #self.index = nil
@remember_password = Widget_Checkbox.new(self, 357+@x,80+@y,self.width-357,24,password,"记住密码")
refresh refresh
end end
def draw_stroked_text(text,x,y,size=1,font=@font) def draw_stroked_text(text,x,y,size=1,font=@font)
......
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