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
Widget_Msgbox.new("iDuel", "正在登陆")
$scene.draw #强制重绘一次,下面会阻塞
$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)
when :register
require 'launchy'
......
......@@ -9,6 +9,7 @@ begin
$config['screen'] ||= {}
$config['screen']['width'] ||= 1024
$config['screen']['height'] ||= 768
p $config
end
def save_config(file="config.yml")
File.open(file,"w"){|file| YAML.dump($config, file)}
......
......@@ -151,6 +151,8 @@ class Scene_Duel < Scene
notify_send("对手离开房间", "对手离开房间")
end
end
else
super
end
end
def update
......
# To change this template, choose Tools | Templates
# and open the template in the editor.
class Widget_checkbox
def initialize(window, text, x,y,width=window.width-x,height=20,checked=false)
@x = x
@y = y
@text = text
class Widget_Checkbox < Window
attr_reader :checked
alias checked? checked
def initialize(window,x,y,width=window.width-x,height=24,checked=false,text="",&proc)
super(x+2,y+2,width,height,500) #+2是素材尺寸问题
@window = window
@text = text
@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
def mouseover(x,y)
def clicked
if @index
@checked = !@checked
@proc.call(@checked) if @proc
end
refresh
end
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
#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
......@@ -12,7 +12,7 @@ class Window_GameSelect < Window_List
if game.is_a?(Hash) && game["name"]
game['file'] ||= 'game.rb'
game['file'] = File.expand_path(game['file'], File.dirname(file))
$config[game['name']] = {}
$config[game['name']] ||= {}
@items << game
else
$log.error "#{game.inspect}读取失败(#{file})"
......@@ -56,8 +56,9 @@ class Window_GameSelect < Window_List
end
def clicked
load @items[@index]["file"] #TODO: load的这种架构微蛋疼,一时想不到更好的方案
p $config
$config['game'] = @items[@index]['name']
@login_window.destroy if @login_window
p @items, @index, $config
@login_window = Window_Login.new(316,316,$config[[@items][@index]['name']]["username"],$config[[@items][@index]['name']]["password"])
@login_window = Window_Login.new(316,316,$config[$config['game']]["username"],$config[$config['game']]["password"])
end
end
#encoding: UTF-8
require_relative 'widget_inputbox'
require_relative 'widget_msgbox'
require_relative 'widget_checkbox'
class Window_Login < Window
def initialize(x,y,username=nil, password=nil)
@username = username
......@@ -30,6 +31,7 @@ class Window_Login < Window
:replay => "战报"
}
#self.index = nil
@remember_password = Widget_Checkbox.new(self, 357+@x,80+@y,self.width-357,24,password,"记住密码")
refresh
end
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