Advertisement
Dekita

Password Protection v1.1

Sep 14th, 2012
971
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.30 KB | None | 0 0
  1. #Dekita's=======================================================================
  2. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  3. #===============================================================================
  4. # v1.1
  5. # ★ Perfect Password Protection™ ★
  6. #
  7. #===============================================================================
  8. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  9. #===============================================================================
  10. #
  11. # -- Last updated: 04/09/2o12
  12. #
  13. # -- Difficulty: Plug'n'play - (Easy)
  14. #
  15. # -- Customisation: Better than a kick in the nuts! - (low)
  16. #
  17. # -- Requires: An actor in your database,
  18. #
  19. # -- Recommended: N/A
  20. #
  21. # -- Compatable: RPG Maker VX Ace ONLY!
  22. #
  23. #===============================================================================
  24. #===============================================================================
  25. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  26. #===============================================================================
  27.  
  28. #===============================================================================
  29. # ☆ Script Information:
  30. #=======================
  31. # A simple script to enable password protection on game files by using
  32. # [x] actors name & nickname as a username & password (or two passwords),
  33. # This script will limit you to 3 save files, these saves will be in
  34. # Slots 2, 3 and 4.
  35. # This script almost completely overwrites scene title.
  36. #
  37. # NOTE:
  38. # for the purposes of this script i will refer to the actor that you choose
  39. # to use as your password(s) as "password actor" .
  40. #===============================================================================
  41.  
  42. #===============================================================================
  43. # ☆ TERMS OF USE:
  44. #===============================================================================
  45. #
  46. # 1. You must give credit to Dekita.
  47. #
  48. # 2. This script is for NON-Commercial use ONLY!*
  49. #
  50. # 3. You CANNOT give credit to yourself for Re-posting this script
  51. # or Posting a modified version.*
  52. #
  53. # 4. Do not Re-Distribute this script.
  54. #
  55. # 5. You are NOT allowed to convert this script to any other engine,
  56. # E.G converting it from RGSS3 into RGSS2.*
  57. #
  58. # 6. ENJOY!
  59. #
  60. #-------------------------------------------------------------------------------
  61. # * = Unless permissions are given by Dekita. < e-mail [email protected]
  62. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  63. #===============================================================================
  64.  
  65. #===============================================================================
  66. # ☆ History:
  67. #============
  68. # D - M - Y
  69. # 04/09/2o12 - improved efficency,
  70. # Released v1.0
  71. # 03/09/2o12 - Added Animation,
  72. # Added second password,
  73. # Fixed a few bugs,
  74. # Added Customisation,
  75. # 02/09/2o12 - Finished Login,
  76. # Finished Autosave,
  77. # Started
  78. #===============================================================================
  79. # ☆ Credit and Thanks to :
  80. #==========================
  81. # Mobychan - helping me solve my "saving far too often" dilemma :)
  82. #===============================================================================
  83.  
  84. #===============================================================================
  85. # ☆ INSTRUCTIONS:
  86. #=================
  87. # Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
  88. #===============================================================================
  89.  
  90. #===============================================================================
  91. # ☆ Import:
  92. #===========
  93. $imported = {} if $imported.nil?
  94. $imported["DPB-PERFECTLOGIN"] = true
  95. #
  96. #===============================================================================
  97. module DPB
  98. module LOGIN
  99. ######################################################################
  100. ### CUSTOMISATION ###
  101. ######################################################################
  102.  
  103. # COMMAND WINDOW VOCAB SETTINGS
  104. # Main Title Window Vocab.
  105. LOGIN = "Login"
  106. NEW_ACCOUNT = "New File"
  107. # File Vocab.
  108. FILE1 = "File 1"
  109. FILE2 = "File 2"
  110. FILE3 = "File 3"
  111.  
  112. #HELP INFO VOCAB SETTINGS
  113. #Help info for login command
  114. HELP_VOCAB1 = "Log In To Exsisting File."
  115. #Help info for create new file command
  116. HELP_VOCAB2 = "Create A New File."
  117. #Help info for selecting a file
  118. HELP_VOCAB3 = "Select File."
  119.  
  120. #Help info for creating a username (password 1)
  121. CREATE_USERNAME = "Choose Your Username."
  122. #Help info for creating a password (password 2)
  123. CREATE_PASSWORD = "Choose Your Password."
  124.  
  125. #Help info for inputting username (password 1)
  126. INPUT_USERNAME = "Input Username"
  127. #Help info for inputting password (password 2)
  128. INPUT_PASSWORD = "Input Password"
  129.  
  130. #Help info when username(password 1) is incorrect.
  131. FAILED_USERNAME = "User Does Not Exsist!"
  132. #Help info when password(password 2) is incorrect.
  133. FAILED_PASSWORD = "Password Incorrect!"
  134.  
  135. #ADDITIONAL SETTINGS
  136.  
  137. # Adjust the command window width here.
  138. WINDOW_WIDTH = 120
  139.  
  140. # Adjust the window opacity(transparancy) here.
  141. OPACITY = 0
  142.  
  143. # Use this to set your password actor's id.
  144. PASSWORD_ACTOR_ID = 11
  145.  
  146. # Maximum Username/Password Length.
  147. PASSWORD_MAX = 8
  148.  
  149. # The time you wait after a failed password input.
  150. FAILED_WAIT = (60) #frames. (60 frames = 1 second)
  151.  
  152. #Set this to "true" to use a second password
  153. USE_SECOND_PASSWORD = true
  154.  
  155. #Set this to "false" if you dont want to start a new game automaically
  156. #when a new file is made.
  157. START_NEWGAME_ON_CREATE_FILE = false
  158.  
  159. # The main background, make sure its in the "Parallaxes" folder of your game.
  160. TITLE_PICTURE = "StarlitSky"#"SeaOfClouds" #"Sunset" #"StartlitSky"
  161.  
  162. #The speed that the background moves, make it "-" to change direction.
  163. TITLE_MOVE_X = -1
  164. TITLE_MOVE_Y = 1
  165.  
  166. # The image used for the game title, also must be in the "Parallaxes" folder.
  167. TITLE_IMAGE2 = "Dekita_Title" # "Sunset"
  168.  
  169. # Game title image move speed.
  170. IMAGE2_MOVE_X = 0
  171. IMAGE2_MOVE_Y = 0
  172.  
  173. # I Reccomend you keep this on and disable the save option for your game.
  174. USE_AUTOSAVE = true
  175. SAVE_FREQ = 360 # the time (in frames) per each autosave
  176.  
  177. ######################################################################
  178. ### CUSTOMISATION END ###
  179. ######################################################################
  180. end#module
  181. end#module
  182. #===============================================================================
  183. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  184. #===============================================================================
  185. #
  186. # ★ Perfect Password Protection™ ★
  187. # ★ SCRIPT BEGIN ★
  188. #
  189. #===============================================================================
  190. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  191. #===============================================================================
  192.  
  193. #==============================================================================
  194. # ** Window_TitleCommand
  195. #------------------------------------------------------------------------------
  196. # This window is for selecting New Game/Continue on the title screen.
  197. #==============================================================================
  198. class Window_TitleCommand < Window_Command
  199. #--------------------------------------------------------------------------
  200. # * Object Initialization
  201. #--------------------------------------------------------------------------
  202. def initialize
  203. super(0, 0)
  204. update_placement
  205. self.openness = 0
  206. self.opacity = DPB::LOGIN::OPACITY
  207. open
  208. end
  209. #--------------------------------------------------------------------------
  210. # * Get Window Width
  211. #--------------------------------------------------------------------------
  212. def window_width
  213. return DPB::LOGIN::WINDOW_WIDTH
  214. end
  215. #--------------------------------------------------------------------------
  216. # * Update Window Position
  217. #--------------------------------------------------------------------------
  218. def update_placement
  219. self.x = 0
  220. self.y = (Graphics.height - height)
  221. end
  222. #--------------------------------------------------------------------------
  223. # * Create Command List
  224. #--------------------------------------------------------------------------
  225. def make_command_list
  226. add_command(DPB::LOGIN::LOGIN, :login_account, continue_enabled)
  227. add_command(DPB::LOGIN::NEW_ACCOUNT, :create_account)
  228. end
  229. #--------------------------------------------------------------------------
  230. # * Get Activation State of Continue
  231. #--------------------------------------------------------------------------
  232. def continue_enabled
  233. DataManager.save_file_exists?
  234. end
  235. end # scene end
  236. #==============================================================================
  237. # ** Window_TitleLoginCommand
  238. #------------------------------------------------------------------------------
  239. # This window is for selecting New Game/Continue on the title screen.
  240. #==============================================================================
  241. class Window_TitleLoginCommand < Window_Command
  242. #--------------------------------------------------------------------------
  243. # * Object Initialization
  244. #--------------------------------------------------------------------------
  245. def initialize
  246. super(0, 0)
  247. update_placement
  248. self.openness = 0
  249. self.opacity = DPB::LOGIN::OPACITY
  250. open
  251. end
  252. #--------------------------------------------------------------------------
  253. # * Get Window Width
  254. #--------------------------------------------------------------------------
  255. def window_width
  256. return DPB::LOGIN::WINDOW_WIDTH
  257. end
  258. #--------------------------------------------------------------------------
  259. # * Update Window Position
  260. #--------------------------------------------------------------------------
  261. def update_placement
  262. self.x = 0
  263. self.y = (Graphics.height - height)
  264. end
  265. #--------------------------------------------------------------------------
  266. # * Create Command List
  267. #--------------------------------------------------------------------------
  268. def make_command_list
  269. add_command(DPB::LOGIN::FILE1, :login_file1, file1_enabled)
  270. add_command(DPB::LOGIN::FILE2, :login_file2, file2_enabled)
  271. add_command(DPB::LOGIN::FILE3, :login_file3, file3_enabled)
  272. end
  273. #--------------------------------------------------------------------------
  274. # * Get Activation State of Continue
  275. #--------------------------------------------------------------------------
  276. def file1_enabled
  277. header = DataManager.load_header(1)
  278. return false if header.nil?
  279. return true
  280. end
  281. def file2_enabled
  282. header = DataManager.load_header(2)
  283. return false if header.nil?
  284. return true
  285. end
  286. def file3_enabled
  287. header = DataManager.load_header(3)
  288. return false if header.nil?
  289. return true
  290. end
  291. end # scene end
  292.  
  293. #==============================================================================
  294. # ** Window_TitleLoginCommand
  295. #------------------------------------------------------------------------------
  296. # This window is for selecting New Game/Continue on the title screen.
  297. #==============================================================================
  298. class Window_TitleCreateCommand < Window_Command
  299. #--------------------------------------------------------------------------
  300. # * Object Initialization
  301. #--------------------------------------------------------------------------
  302. def initialize
  303. super(0, 0)
  304. update_placement
  305. self.openness = 0
  306. self.opacity = DPB::LOGIN::OPACITY
  307. open
  308. end
  309. #--------------------------------------------------------------------------
  310. # * Get Window Width
  311. #--------------------------------------------------------------------------
  312. def window_width
  313. return DPB::LOGIN::WINDOW_WIDTH
  314. end
  315. #--------------------------------------------------------------------------
  316. # * Update Window Position
  317. #--------------------------------------------------------------------------
  318. def update_placement
  319. self.x = 0
  320. self.y = (Graphics.height - height)
  321. end
  322. #--------------------------------------------------------------------------
  323. # * Create Command List
  324. #--------------------------------------------------------------------------
  325. def make_command_list
  326. add_command(DPB::LOGIN::FILE1, :create_file1, file1_enabled)
  327. add_command(DPB::LOGIN::FILE2, :create_file2, file2_enabled)
  328. add_command(DPB::LOGIN::FILE3, :create_file3, file3_enabled)
  329. end
  330. #--------------------------------------------------------------------------
  331. # * Get Activation State of Files
  332. #--------------------------------------------------------------------------
  333. def file1_enabled
  334. header = DataManager.load_header(1)
  335. return true if header.nil?
  336. return false
  337. end
  338. def file2_enabled
  339. header = DataManager.load_header(2)
  340. return true if header.nil?
  341. return false
  342. end
  343. def file3_enabled
  344. header = DataManager.load_header(3)
  345. return true if header.nil?
  346. return false
  347. end
  348. end # scene end
  349. #==============================================================================
  350. # ** Window_NameEdit
  351. #------------------------------------------------------------------------------
  352. # This window is used to edit an actor's name on the name input screen.
  353. #==============================================================================
  354. class Window_PasswordEdit < Window_Base
  355. #--------------------------------------------------------------------------
  356. # * Public Instance Variables
  357. #--------------------------------------------------------------------------
  358. attr_reader :name # name
  359. attr_reader :index # cursor position
  360. attr_reader :max_char # maximum number of characters
  361. #--------------------------------------------------------------------------
  362. # * Object Initialization
  363. #--------------------------------------------------------------------------
  364. def initialize(actor, max_char)
  365. x = (Graphics.width - 360) / 2
  366. y = (Graphics.height - (fitting_height(4) + fitting_height(9) + 8)) / 2
  367. super(x, y, 360, fitting_height(4))
  368. @actor = actor
  369. @max_char = max_char
  370. if SceneManager.scene_is?(Scene_CreateSecondPassword)
  371. @default_name = @name = actor.nickname[0, @max_char]
  372. elsif SceneManager.scene_is?(Scene_SecondPasswordConfirm)
  373. @default_name = @name = actor.nickname[0, @max_char]
  374. else
  375. @default_name = @name = actor.name[0, @max_char]
  376. end
  377. @index = @name.size
  378. deactivate
  379. refresh
  380. self.opacity = DPB::LOGIN::OPACITY
  381. end
  382. #--------------------------------------------------------------------------
  383. # * Revert to Default Name
  384. #--------------------------------------------------------------------------
  385. def restore_default
  386. @name = @default_name
  387. @index = @name.size
  388. refresh
  389. end
  390. #--------------------------------------------------------------------------
  391. # * Add Text Character
  392. # ch : character to add
  393. #--------------------------------------------------------------------------
  394. def add(ch)
  395. return false if @index >= @max_char
  396. @name += ch
  397. @index += 1
  398. refresh
  399. return true
  400. end
  401. #--------------------------------------------------------------------------
  402. # * Go Back One Character
  403. #--------------------------------------------------------------------------
  404. def back
  405. return false if @index == 0
  406. @index -= 1
  407. @name = @name[0, @index]
  408. refresh
  409. return true
  410. end
  411. #--------------------------------------------------------------------------
  412. # * Get Character Width
  413. #--------------------------------------------------------------------------
  414. def char_width
  415. text_size($game_system.japanese? ? "あ" : "A").width
  416. end
  417. #--------------------------------------------------------------------------
  418. # * Get Coordinates of Left Side for Drawing Name
  419. #--------------------------------------------------------------------------
  420. def left
  421. name_center = (contents_width) / 2
  422. name_width = (@max_char + 1) * char_width
  423. return [name_center - name_width / 2, contents_width - name_width].min
  424. end
  425. #--------------------------------------------------------------------------
  426. # * Get Rectangle for Displaying Item
  427. #--------------------------------------------------------------------------
  428. def item_rect(index)
  429. Rect.new(left + index * char_width, 36, char_width, line_height)
  430. end
  431. #--------------------------------------------------------------------------
  432. # * Get Underline Rectangle
  433. #--------------------------------------------------------------------------
  434. def underline_rect(index)
  435. rect = item_rect(index)
  436. rect.x += 1
  437. rect.y += rect.height - 4
  438. rect.width -= 2
  439. rect.height = 2
  440. rect
  441. end
  442. #--------------------------------------------------------------------------
  443. # * Get Underline Color
  444. #--------------------------------------------------------------------------
  445. def underline_color
  446. color = normal_color
  447. color.alpha = 48
  448. color
  449. end
  450. #--------------------------------------------------------------------------
  451. # * Draw Underline
  452. #--------------------------------------------------------------------------
  453. def draw_underline(index)
  454. contents.fill_rect(underline_rect(index), underline_color)
  455. end
  456. #--------------------------------------------------------------------------
  457. # * Draw Text
  458. #--------------------------------------------------------------------------
  459. def draw_char(index)
  460. rect = item_rect(index)
  461. rect.x -= 1
  462. rect.width += 4
  463. change_color(normal_color)
  464. draw_text(rect, @name[index] || "")
  465. end
  466. #--------------------------------------------------------------------------
  467. # * Refresh
  468. #--------------------------------------------------------------------------
  469. def refresh
  470. contents.clear
  471. draw_actor_face(@actor, 0, 0)
  472. @max_char.times {|i| draw_underline(i) }
  473. @name.size.times {|i| draw_char(i) }
  474. cursor_rect.set(item_rect(@index))
  475. end
  476. end
  477. #==============================================================================
  478. # ** Window_NameInput
  479. #------------------------------------------------------------------------------
  480. # This window is used to select text characters on the name input screen.
  481. #==============================================================================
  482. class Window_PasswordInput < Window_Selectable
  483. #--------------------------------------------------------------------------
  484. # * Character Tables (Latin)
  485. #--------------------------------------------------------------------------
  486. PASSWORD = [
  487. 'A','B','C','D','E', 'a','b','c','d','e',
  488. 'F','G','H','I','J', 'f','g','h','i','j',
  489. 'K','L','M','N','O', 'k','l','m','n','o',
  490. 'P','Q','R','S','T', 'p','q','r','s','t',
  491. 'U','V','W','X','Y', 'u','v','w','x','y',
  492. 'Z',' ',' ',' ',' ', 'z',' ',' ',' ',' ',
  493. '0','1','2','3','4', ' ',' ',' ',' ',' ',
  494. '5','6','7','8','9', ' ',' ',' ',' ',' ',
  495. ' ',' ',' ',' ',' ', ' ',' ','«','Page','OK']
  496. PASSWORD2 = [
  497. 'Á','É','Í','Ó','Ú', 'á','é','í','ó','ú',
  498. 'À','È','Ì','Ò','Ù', 'à','è','ì','ò','ù',
  499. 'Â','Ê','Î','Ô','Û', 'â','ê','î','ô','û',
  500. 'Ä','Ë','Ï','Ö','Ü', 'ä','ë','ï','ö','ü',
  501. 'Ā','Ē','Ī','Ō','Ū', 'ā','ē','ī','ō','ū',
  502. 'Ã','Å','Æ','Ç','Ð', 'ã','å','æ','ç','ð',
  503. 'Ñ','Õ','Ø','Š','Ŵ', 'ñ','õ','ø','š','ŵ',
  504. 'Ý','Ŷ','Ÿ','Ž','Þ', 'ý','ÿ','ŷ','ž','þ',
  505. 'IJ','Œ','ij','œ','ß', ' ',' ','«','Page','OK']
  506. #--------------------------------------------------------------------------
  507. # * Object Initialization
  508. #--------------------------------------------------------------------------
  509. def initialize(edit_window)
  510. super(edit_window.x, edit_window.y + edit_window.height + 8,
  511. edit_window.width, fitting_height(9))
  512. @edit_window = edit_window
  513. @page = 0
  514. @index = 0
  515. refresh
  516. update_cursor
  517. activate
  518. self.opacity = DPB::LOGIN::OPACITY
  519. end
  520. #--------------------------------------------------------------------------
  521. # * Get Text Table
  522. #--------------------------------------------------------------------------
  523. def table
  524. return [PASSWORD, PASSWORD2]
  525. end
  526. #--------------------------------------------------------------------------
  527. # * Get Text Character
  528. #--------------------------------------------------------------------------
  529. def character
  530. @index < 88 ? table[@page][@index] : ""
  531. end
  532. #--------------------------------------------------------------------------
  533. # * Determining if Page Changed and Cursor Location
  534. #--------------------------------------------------------------------------
  535. def is_page_change?
  536. @index == 88
  537. end
  538. #--------------------------------------------------------------------------
  539. # * Determine Cursor Location: Confirmation
  540. #--------------------------------------------------------------------------
  541. def is_ok?
  542. @index == 89
  543. end
  544. #--------------------------------------------------------------------------
  545. # * Get Rectangle for Displaying Item
  546. #--------------------------------------------------------------------------
  547. def item_rect(index)
  548. rect = Rect.new
  549. rect.x = index % 10 * 32 + index % 10 / 5 * 16
  550. rect.y = index / 10 * line_height
  551. rect.width = 32
  552. rect.height = line_height
  553. rect
  554. end
  555. #--------------------------------------------------------------------------
  556. # * Refresh
  557. #--------------------------------------------------------------------------
  558. def refresh
  559. contents.clear
  560. change_color(normal_color)
  561. 90.times {|i| draw_text(item_rect(i), table[@page][i], 1) }
  562. end
  563. #--------------------------------------------------------------------------
  564. # * Update Cursor
  565. #--------------------------------------------------------------------------
  566. def update_cursor
  567. cursor_rect.set(item_rect(@index))
  568. end
  569. #--------------------------------------------------------------------------
  570. # * Determine if Cursor is Moveable
  571. #--------------------------------------------------------------------------
  572. def cursor_movable?
  573. active
  574. end
  575. #--------------------------------------------------------------------------
  576. # * Move Cursor Down
  577. # wrap : Wraparound allowed
  578. #--------------------------------------------------------------------------
  579. def cursor_down(wrap)
  580. if @index < 80 or wrap
  581. @index = (index + 10) % 90
  582. end
  583. end
  584. #--------------------------------------------------------------------------
  585. # * Move Cursor Up
  586. # wrap : Wraparound allowed
  587. #--------------------------------------------------------------------------
  588. def cursor_up(wrap)
  589. if @index >= 10 or wrap
  590. @index = (index + 80) % 90
  591. end
  592. end
  593. #--------------------------------------------------------------------------
  594. # * Move Cursor Right
  595. # wrap : Wraparound allowed
  596. #--------------------------------------------------------------------------
  597. def cursor_right(wrap)
  598. if @index % 10 < 9
  599. @index += 1
  600. elsif wrap
  601. @index -= 9
  602. end
  603. end
  604. #--------------------------------------------------------------------------
  605. # * Move Cursor Left
  606. # wrap : Wraparound allowed
  607. #--------------------------------------------------------------------------
  608. def cursor_left(wrap)
  609. if @index % 10 > 0
  610. @index -= 1
  611. elsif wrap
  612. @index += 9
  613. end
  614. end
  615. #--------------------------------------------------------------------------
  616. # * Move to Next Page
  617. #--------------------------------------------------------------------------
  618. def cursor_pagedown
  619. @page = (@page + 1) % table.size
  620. refresh
  621. end
  622. #--------------------------------------------------------------------------
  623. # * Move to Previous Page
  624. #--------------------------------------------------------------------------
  625. def cursor_pageup
  626. @page = (@page + table.size - 1) % table.size
  627. refresh
  628. end
  629. #--------------------------------------------------------------------------
  630. # * Cursor Movement Processing
  631. #--------------------------------------------------------------------------
  632. def process_cursor_move
  633. last_page = @page
  634. super
  635. update_cursor
  636. Sound.play_cursor if @page != last_page
  637. end
  638. #--------------------------------------------------------------------------
  639. # * Handling Processing for OK and Cancel Etc.
  640. #--------------------------------------------------------------------------
  641. def process_handling
  642. return unless open? && active
  643. process_jump if Input.trigger?(:A)
  644. process_back if Input.repeat?(:B)
  645. process_ok if Input.trigger?(:C)
  646. end
  647. #--------------------------------------------------------------------------
  648. # * Jump to OK
  649. #--------------------------------------------------------------------------
  650. def process_jump
  651. if @index != 89
  652. @index = 89
  653. Sound.play_cursor
  654. end
  655. end
  656. #--------------------------------------------------------------------------
  657. # * Go Back One Character
  658. #--------------------------------------------------------------------------
  659. def process_back
  660. Sound.play_cancel if @edit_window.back
  661. end
  662. #--------------------------------------------------------------------------
  663. # * Processing When OK Button Is Pressed
  664. #--------------------------------------------------------------------------
  665. def process_ok
  666. if character == "«"
  667. process_back
  668. elsif !character.empty?
  669. on_name_add
  670. elsif is_page_change?
  671. Sound.play_ok
  672. cursor_pagedown
  673. elsif is_ok?
  674. on_name_ok
  675. end
  676. end
  677. #--------------------------------------------------------------------------
  678. # * Add Text to Name
  679. #--------------------------------------------------------------------------
  680. def on_name_add
  681. if @edit_window.add(character)
  682. Sound.play_ok
  683. else
  684. Sound.play_buzzer
  685. end
  686. end
  687. #--------------------------------------------------------------------------
  688. # * Decide Name
  689. #--------------------------------------------------------------------------
  690. def on_name_ok
  691. if @edit_window.name.empty?
  692. if @edit_window.restore_default
  693. Sound.play_ok
  694. else
  695. Sound.play_buzzer
  696. end
  697. else
  698. Sound.play_ok
  699. call_ok_handler
  700. end
  701. end
  702. end
  703. #==============================================================================
  704. # ** Scene_Title
  705. #------------------------------------------------------------------------------
  706. # This class performs the title screen processing.
  707. #==============================================================================
  708. class Scene_Title < Scene_Base
  709.  
  710. def msg
  711. s = [
  712. "#{DPB::LOGIN::HELP_VOCAB1}
  713. #{""} #{""}",
  714. "#{DPB::LOGIN::HELP_VOCAB2}
  715. #{""} #{""}"]
  716. return s
  717. end
  718. def sndmsg
  719. s = [
  720. "#{DPB::LOGIN::HELP_VOCAB3}
  721. #{""} #{""}",
  722. "#{DPB::LOGIN::HELP_VOCAB3}
  723. #{""} #{""}",
  724. "#{DPB::LOGIN::HELP_VOCAB3}
  725. #{""} #{""}"]
  726. return s
  727. end
  728. #--------------------------------------------------------------------------
  729. # * Start Processing
  730. #--------------------------------------------------------------------------
  731. alias dpbztitlestart start
  732. def start
  733. # super
  734. dpbztitlestart
  735. create_help_window
  736. @help_window.opacity = DPB::LOGIN::OPACITY
  737. end
  738.  
  739. alias dpbztitleupdate update
  740. def update
  741. # super
  742. dpbztitleupdate
  743. @sprite1.ox += DPB::LOGIN::TITLE_MOVE_X
  744. @sprite1.oy += DPB::LOGIN::TITLE_MOVE_Y
  745. @sprite2.ox -= DPB::LOGIN::IMAGE2_MOVE_X
  746. @sprite2.oy += DPB::LOGIN::IMAGE2_MOVE_Y
  747. if $dpbzpasswordhelpwindowinfo == 1
  748. @help_window.set_text(sndmsg[@command_window.index])
  749. else
  750. @help_window.set_text(msg[@command_window.index])
  751. end
  752. end
  753. #--------------------------------------------------------------------------
  754. # * Create Help Window
  755. #--------------------------------------------------------------------------
  756. def create_help_window
  757. @help_window = Window_Help.new
  758. @help_window.visible = true
  759. @help_window.set_text(msg[@command_window.index])
  760. end
  761. #--------------------------------------------------------------------------
  762. # * Create Background
  763. #--------------------------------------------------------------------------
  764. def create_background
  765. @sprite1 = Plane.new
  766. @sprite1.bitmap = Cache.parallax(DPB::LOGIN::TITLE_PICTURE)
  767. @sprite2 = Plane.new
  768. @sprite2.bitmap = Cache.parallax(DPB::LOGIN::TITLE_IMAGE2)
  769. end
  770. #--------------------------------------------------------------------------
  771. # * Create Command Window
  772. #--------------------------------------------------------------------------
  773. def create_command_window
  774. @command_window = Window_TitleCommand.new
  775. # @command_window.set_handler(:new_game, method(:command_new_game))
  776. # @command_window.set_handler(:continue, method(:command_continue))
  777. # @command_window.set_handler(:shutdown, method(:command_shutdown))
  778. @command_window.set_handler(:login_account, method(:command_login_account))
  779. @command_window.set_handler(:create_account, method(:command_create_account))
  780. end
  781. #--------------------------------------------------------------------------
  782. # * Create Command Window
  783. #--------------------------------------------------------------------------
  784. def create_login_window
  785. @command_window = Window_TitleLoginCommand.new
  786. @command_window.set_handler(:login_file1, method(:command_login_file1))
  787. @command_window.set_handler(:login_file2, method(:command_login_file2))
  788. @command_window.set_handler(:login_file3, method(:command_login_file3))
  789. @command_window.set_handler(:cancel, method(:command_backtotitle))
  790. end
  791. #--------------------------------------------------------------------------
  792. # * Create Command Window
  793. #--------------------------------------------------------------------------
  794. def create_create_window
  795. @command_window = Window_TitleCreateCommand.new
  796. @command_window.set_handler(:create_file1, method(:command_create_file1))
  797. @command_window.set_handler(:create_file2, method(:command_create_file2))
  798. @command_window.set_handler(:create_file3, method(:command_create_file3))
  799. @command_window.set_handler(:cancel, method(:command_backtotitle))
  800. end
  801. #--------------------------------------------------------------------------
  802. # * Close Command Window
  803. #--------------------------------------------------------------------------
  804. def close_command_window
  805. @command_window.close
  806. update until @command_window.close?
  807. end
  808. def command_backtotitle
  809. @command_window.hide
  810. $dpbzpasswordhelpwindowinfo = 0
  811. create_command_window
  812. end
  813. ################################################################################
  814. #--------------------------------------------------------------------------
  815. # * [Login] Command
  816. #--------------------------------------------------------------------------
  817. def command_login_account
  818. $dpbzpasswordhelpwindowinfo = 1
  819. DataManager.setup_new_game
  820. close_command_window
  821. create_login_window
  822. end
  823. #--------------------------------------------------------------------------
  824. # * [Create] Command
  825. #--------------------------------------------------------------------------
  826. def command_create_account
  827. $dpbzpasswordhelpwindowinfo = 1
  828. DataManager.setup_new_game
  829. close_command_window
  830. create_create_window
  831. end
  832. ################################################################################
  833. #--------------------------------------------------------------------------
  834. # * [Login File1] Command
  835. #--------------------------------------------------------------------------
  836. def command_login_file1
  837. close_command_window
  838. SceneManager.call(Scene_PasswordConfirm)
  839. SceneManager.scene.prepare(DPB::LOGIN::PASSWORD_ACTOR_ID, DPB::LOGIN::PASSWORD_MAX, 1)
  840. end
  841. #--------------------------------------------------------------------------
  842. # * [Login File2] Command
  843. #--------------------------------------------------------------------------
  844. def command_login_file2
  845. close_command_window
  846. SceneManager.call(Scene_PasswordConfirm)
  847. SceneManager.scene.prepare(DPB::LOGIN::PASSWORD_ACTOR_ID, DPB::LOGIN::PASSWORD_MAX, 2)
  848. end
  849. #--------------------------------------------------------------------------
  850. # * [Login File3] Command
  851. #--------------------------------------------------------------------------
  852. def command_login_file3
  853. close_command_window
  854. SceneManager.call(Scene_PasswordConfirm)
  855. SceneManager.scene.prepare(DPB::LOGIN::PASSWORD_ACTOR_ID, DPB::LOGIN::PASSWORD_MAX, 3)
  856. end
  857. ################################################################################
  858. #--------------------------------------------------------------------------
  859. # * [Create File1] Command
  860. #--------------------------------------------------------------------------
  861. def command_create_file1
  862. close_command_window
  863. SceneManager.call(Scene_CreatePassword)
  864. SceneManager.scene.prepare(DPB::LOGIN::PASSWORD_ACTOR_ID, DPB::LOGIN::PASSWORD_MAX, 1)
  865. end
  866. #--------------------------------------------------------------------------
  867. # * [Create File2] Command
  868. #--------------------------------------------------------------------------
  869. def command_create_file2
  870. close_command_window
  871. SceneManager.call(Scene_CreatePassword)
  872. SceneManager.scene.prepare(DPB::LOGIN::PASSWORD_ACTOR_ID, DPB::LOGIN::PASSWORD_MAX, 2)
  873. end
  874. #--------------------------------------------------------------------------
  875. # * [Create File3] Command
  876. #--------------------------------------------------------------------------
  877. def command_create_file3
  878. close_command_window
  879. SceneManager.call(Scene_CreatePassword)
  880. SceneManager.scene.prepare(DPB::LOGIN::PASSWORD_ACTOR_ID, DPB::LOGIN::PASSWORD_MAX, 3)
  881. end
  882. end# end scene title
  883.  
  884. ##################################
  885. class Scene_MenuBase < Scene_Base#
  886. #--------------------------------------------------------------------------
  887. # * Processing When Load Is Successful
  888. #--------------------------------------------------------------------------
  889. def on_load_success
  890. Sound.play_load
  891. fadeout_all
  892. $game_system.on_after_load
  893. SceneManager.goto(Scene_Map)
  894. end
  895.  
  896. def dpbzpasswordwait(time)
  897. t = 0
  898. loop do
  899. Graphics.update
  900. if t == time
  901. break
  902. end
  903. t += 1
  904. end
  905. end
  906. end # end class
  907. #==============================================================================
  908. # ** Scene_Name
  909. #------------------------------------------------------------------------------
  910. # This class performs name input screen processing.
  911. #==============================================================================
  912. class Scene_CreatePassword < Scene_MenuBase
  913. #--------------------------------------------------------------------------
  914. # * Prepare
  915. #--------------------------------------------------------------------------
  916. def prepare(actor_id, max_char, file)
  917. @actor_id = actor_id
  918. @max_char = max_char
  919. @file = file
  920. end
  921. #--------------------------------------------------------------------------
  922. # * Start Processing
  923. #--------------------------------------------------------------------------
  924. def start
  925. super
  926. @actor = $game_actors[@actor_id]
  927. @edit_window = Window_PasswordEdit.new(@actor, @max_char)
  928. @input_window = Window_PasswordInput.new(@edit_window)
  929. @input_window.set_handler(:ok, method(:on_input_ok))
  930. create_help_window
  931. end
  932. #--------------------------------------------------------------------------
  933. # * Create Help Window
  934. #--------------------------------------------------------------------------
  935. def create_help_window
  936. @help_window = Window_Help.new
  937. @help_window.visible = true
  938. @help_window.set_text(DPB::LOGIN::CREATE_USERNAME)
  939. @help_window.opacity = DPB::LOGIN::OPACITY
  940. end
  941. #--------------------------------------------------------------------------
  942. # * Input [OK]
  943. #--------------------------------------------------------------------------
  944. def on_input_ok
  945. @actor.name = @edit_window.name
  946. return_scene
  947. $dpbzpasswordhelpwindowinfo = 0
  948. if DPB::LOGIN::USE_SECOND_PASSWORD
  949. SceneManager.call(Scene_CreateSecondPassword)
  950. SceneManager.scene.prepare(DPB::LOGIN::PASSWORD_ACTOR_ID, DPB::LOGIN::PASSWORD_MAX, @file)
  951. else
  952. DataManager.save_game(@file)
  953. if DPB::LOGIN::START_NEWGAME_ON_CREATE_FILE
  954. on_load_success
  955. else
  956. return_scene
  957. SceneManager.call(Scene_Title)
  958. end
  959. end
  960. end
  961.  
  962. end#scene
  963. #==============================================================================
  964. # ** Scene_Name
  965. #------------------------------------------------------------------------------
  966. # This class performs name input screen processing.
  967. #==============================================================================
  968. class Scene_CreateSecondPassword < Scene_MenuBase
  969. #--------------------------------------------------------------------------
  970. # * Prepare
  971. #--------------------------------------------------------------------------
  972. def prepare(actor_id, max_char, file)
  973. @actor_id = actor_id
  974. @max_char = max_char
  975. @file = file
  976. end
  977. #--------------------------------------------------------------------------
  978. # * Start Processing
  979. #--------------------------------------------------------------------------
  980. def start
  981. super
  982. @actor = $game_actors[@actor_id]
  983. @edit_window = Window_PasswordEdit.new(@actor, @max_char)
  984. @input_window = Window_PasswordInput.new(@edit_window)
  985. @input_window.set_handler(:ok, method(:on_input_ok))
  986. create_help_window
  987. end
  988. #--------------------------------------------------------------------------
  989. # * Create Help Window
  990. #--------------------------------------------------------------------------
  991. def create_help_window
  992. @help_window = Window_Help.new
  993. @help_window.visible = true
  994. @help_window.set_text(DPB::LOGIN::CREATE_PASSWORD)
  995. @help_window.opacity = DPB::LOGIN::OPACITY
  996. end
  997. #--------------------------------------------------------------------------
  998. # * Input [OK]
  999. #--------------------------------------------------------------------------
  1000. def on_input_ok
  1001. @actor.nickname = @edit_window.name
  1002. DataManager.save_game(@file)
  1003. if DPB::LOGIN::START_NEWGAME_ON_CREATE_FILE
  1004. on_load_success
  1005. else
  1006. return_scene
  1007. SceneManager.call(Scene_Title)
  1008. end
  1009. end
  1010. end#scene
  1011.  
  1012. #==============================================================================
  1013. # ** Scene_Name
  1014. #------------------------------------------------------------------------------
  1015. # This class performs name input screen processing.
  1016. #==============================================================================
  1017. class Scene_PasswordConfirm < Scene_MenuBase
  1018. #--------------------------------------------------------------------------
  1019. # * Prepare
  1020. #--------------------------------------------------------------------------
  1021. def prepare(actor_id, max_char,file)
  1022. @actor_id = actor_id
  1023. @max_char = max_char
  1024. @account = file
  1025. end
  1026. #--------------------------------------------------------------------------
  1027. # * Start Processing
  1028. #--------------------------------------------------------------------------
  1029. def start
  1030. super
  1031. @actor = $game_actors[@actor_id]
  1032. @edit_window = Window_PasswordEdit.new(@actor, @max_char)
  1033. @input_window = Window_PasswordInput.new(@edit_window)
  1034. @input_window.set_handler(:ok, method(:on_input_ok))
  1035. create_help_window
  1036. end
  1037. #--------------------------------------------------------------------------
  1038. # * Create Help Window
  1039. #--------------------------------------------------------------------------
  1040. def create_help_window
  1041. @help_window = Window_Help.new
  1042. @help_window.visible = true
  1043. @help_window.set_text(DPB::LOGIN::INPUT_USERNAME)
  1044. @help_window.opacity = DPB::LOGIN::OPACITY
  1045. end
  1046. #--------------------------------------------------------------------------
  1047. # * Input [OK]
  1048. #--------------------------------------------------------------------------
  1049. def on_input_ok
  1050. DataManager.load_game(@account)
  1051. @actor = $game_actors[DPB::LOGIN::PASSWORD_ACTOR_ID]
  1052. if @edit_window.name == @actor.name
  1053. return_scene
  1054. $dpbzpasswordhelpwindowinfo = 0
  1055. if DPB::LOGIN::USE_SECOND_PASSWORD
  1056. SceneManager.call(Scene_SecondPasswordConfirm)
  1057. SceneManager.scene.prepare(DPB::LOGIN::PASSWORD_ACTOR_ID, DPB::LOGIN::PASSWORD_MAX, @account)
  1058. else
  1059. on_load_success
  1060. end
  1061. else
  1062. @help_window.set_text(DPB::LOGIN::FAILED_USERNAME)
  1063. dpbzpasswordwait(DPB::LOGIN::FAILED_WAIT)
  1064. return_scene
  1065. end
  1066. end
  1067. ######
  1068. end # scene
  1069. #==============================================================================
  1070. # ** Scene_Name
  1071. #------------------------------------------------------------------------------
  1072. # This class performs name input screen processing.
  1073. #==============================================================================
  1074. class Scene_SecondPasswordConfirm < Scene_MenuBase
  1075. #--------------------------------------------------------------------------
  1076. # * Prepare
  1077. #--------------------------------------------------------------------------
  1078. def prepare(actor_id, max_char, file)
  1079. @actor_id = actor_id
  1080. @max_char = max_char
  1081. @account = file
  1082. end
  1083. #--------------------------------------------------------------------------
  1084. # * Start Processing
  1085. #--------------------------------------------------------------------------
  1086. def start
  1087. super
  1088. DataManager.setup_new_game
  1089. @actor = $game_actors[@actor_id]
  1090. @edit_window = Window_PasswordEdit.new(@actor, @max_char)
  1091. @input_window = Window_PasswordInput.new(@edit_window)
  1092. @input_window.set_handler(:ok, method(:on_input_ok))
  1093. create_help_window
  1094. @help_window.opacity = DPB::LOGIN::OPACITY
  1095. end
  1096. #--------------------------------------------------------------------------
  1097. # * Create Help Window
  1098. #--------------------------------------------------------------------------
  1099. def create_help_window
  1100. @help_window = Window_Help.new
  1101. @help_window.visible = true
  1102. @help_window.set_text(DPB::LOGIN::INPUT_PASSWORD)
  1103. @help_window.opacity = DPB::LOGIN::OPACITY
  1104. end
  1105. #--------------------------------------------------------------------------
  1106. # * Input [OK]
  1107. #--------------------------------------------------------------------------
  1108. def on_input_ok
  1109. DataManager.load_game(@account)
  1110. @actor = $game_actors[DPB::LOGIN::PASSWORD_ACTOR_ID]
  1111. if @edit_window.name == @actor.nickname
  1112. on_load_success
  1113. else
  1114. return_scene
  1115. @help_window.set_text(DPB::LOGIN::FAILED_PASSWORD)
  1116. dpbzpasswordwait(DPB::LOGIN::FAILED_WAIT)
  1117. end
  1118. end
  1119.  
  1120. end # scene
  1121. ####################
  1122. # Awesome Autosave #
  1123. ####################
  1124. if DPB::LOGIN::USE_AUTOSAVE
  1125. # Keyboard four de map ? no
  1126. class Scene_Map < Scene_Base
  1127. alias dpbzautosavestart start
  1128. def start
  1129. # super
  1130. dpbzautosavestart
  1131. @dpbzautosavecounter = 0
  1132. end
  1133.  
  1134. #@dpbzautosavecounter = 0
  1135. alias dpbzautosave update_scene
  1136. def update_scene
  1137. dpbzautosave
  1138. @dpbzautosavecounter += 1
  1139. if @dpbzautosavecounter == DPB::LOGIN::SAVE_FREQ
  1140. update_call_autosave
  1141. @dpbzautosavecounter = 0
  1142. end
  1143. end # update scene
  1144. # Define call
  1145. def update_call_autosave
  1146. if !$game_player.moving?
  1147. call_autosave
  1148. end
  1149. end
  1150. # Define call
  1151. def call_autosave
  1152. @file = DataManager.last_savefile_index
  1153. DataManager.save_game(@file)
  1154. end
  1155.  
  1156. end# scenemap
  1157. end
  1158. #==============================================================================
  1159. # ** Scene_Load
  1160. #------------------------------------------------------------------------------
  1161. # This class performs load screen processing.
  1162. #==============================================================================
  1163. class Scene_Load < Scene_File
  1164. #--------------------------------------------------------------------------
  1165. # * Processing When Load Is Successful
  1166. #--------------------------------------------------------------------------
  1167. alias dpbzawsomeautosaveonloadsuccess on_load_success
  1168. def on_load_success
  1169. @file = DataManager.last_savefile_index
  1170. DataManager.save_game(@file)
  1171. dpbzawsomeautosaveonloadsuccess
  1172. end
  1173. end
  1174. #===============================================================================
  1175. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  1176. #===============================================================================
  1177. #
  1178. # ★ Perfect Password Protection™ ★
  1179. # ★ SCRIPT END ★
  1180. #
  1181. #===============================================================================
  1182. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  1183. #===============================================================================
  1184. ################################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement