Advertisement
Dekita

Password Protection v1.1

Sep 14th, 2012
923
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 DekitaRPG@gmail.com
  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. return !@name.empty?
  390. end
  391. #--------------------------------------------------------------------------
  392. # * Add Text Character
  393. # ch : character to add
  394. #--------------------------------------------------------------------------
  395. def add(ch)
  396. return false if @index >= @max_char
  397. @name += ch
  398. @index += 1
  399. refresh
  400. return true
  401. end
  402. #--------------------------------------------------------------------------
  403. # * Go Back One Character
  404. #--------------------------------------------------------------------------
  405. def back
  406. return false if @index == 0
  407. @index -= 1
  408. @name = @name[0, @index]
  409. refresh
  410. return true
  411. end
  412. #--------------------------------------------------------------------------
  413. # * Get Character Width
  414. #--------------------------------------------------------------------------
  415. def char_width
  416. text_size($game_system.japanese? ? "あ" : "A").width
  417. end
  418. #--------------------------------------------------------------------------
  419. # * Get Coordinates of Left Side for Drawing Name
  420. #--------------------------------------------------------------------------
  421. def left
  422. name_center = (contents_width) / 2
  423. name_width = (@max_char + 1) * char_width
  424. return [name_center - name_width / 2, contents_width - name_width].min
  425. end
  426. #--------------------------------------------------------------------------
  427. # * Get Rectangle for Displaying Item
  428. #--------------------------------------------------------------------------
  429. def item_rect(index)
  430. Rect.new(left + index * char_width, 36, char_width, line_height)
  431. end
  432. #--------------------------------------------------------------------------
  433. # * Get Underline Rectangle
  434. #--------------------------------------------------------------------------
  435. def underline_rect(index)
  436. rect = item_rect(index)
  437. rect.x += 1
  438. rect.y += rect.height - 4
  439. rect.width -= 2
  440. rect.height = 2
  441. rect
  442. end
  443. #--------------------------------------------------------------------------
  444. # * Get Underline Color
  445. #--------------------------------------------------------------------------
  446. def underline_color
  447. color = normal_color
  448. color.alpha = 48
  449. color
  450. end
  451. #--------------------------------------------------------------------------
  452. # * Draw Underline
  453. #--------------------------------------------------------------------------
  454. def draw_underline(index)
  455. contents.fill_rect(underline_rect(index), underline_color)
  456. end
  457. #--------------------------------------------------------------------------
  458. # * Draw Text
  459. #--------------------------------------------------------------------------
  460. def draw_char(index)
  461. rect = item_rect(index)
  462. rect.x -= 1
  463. rect.width += 4
  464. change_color(normal_color)
  465. draw_text(rect, @name[index] || "")
  466. end
  467. #--------------------------------------------------------------------------
  468. # * Refresh
  469. #--------------------------------------------------------------------------
  470. def refresh
  471. contents.clear
  472. draw_actor_face(@actor, 0, 0)
  473. @max_char.times {|i| draw_underline(i) }
  474. @name.size.times {|i| draw_char(i) }
  475. cursor_rect.set(item_rect(@index))
  476. end
  477. end
  478. #==============================================================================
  479. # ** Window_NameInput
  480. #------------------------------------------------------------------------------
  481. # This window is used to select text characters on the name input screen.
  482. #==============================================================================
  483. class Window_PasswordInput < Window_Selectable
  484. #--------------------------------------------------------------------------
  485. # * Character Tables (Latin)
  486. #--------------------------------------------------------------------------
  487. PASSWORD = [
  488. 'A','B','C','D','E', 'a','b','c','d','e',
  489. 'F','G','H','I','J', 'f','g','h','i','j',
  490. 'K','L','M','N','O', 'k','l','m','n','o',
  491. 'P','Q','R','S','T', 'p','q','r','s','t',
  492. 'U','V','W','X','Y', 'u','v','w','x','y',
  493. 'Z',' ',' ',' ',' ', 'z',' ',' ',' ',' ',
  494. '0','1','2','3','4', ' ',' ',' ',' ',' ',
  495. '5','6','7','8','9', ' ',' ',' ',' ',' ',
  496. ' ',' ',' ',' ',' ', ' ',' ','«','Page','OK']
  497. PASSWORD2 = [
  498. 'Á','É','Í','Ó','Ú', 'á','é','í','ó','ú',
  499. 'À','È','Ì','Ò','Ù', 'à','è','ì','ò','ù',
  500. 'Â','Ê','Î','Ô','Û', 'â','ê','î','ô','û',
  501. 'Ä','Ë','Ï','Ö','Ü', 'ä','ë','ï','ö','ü',
  502. 'Ā','Ē','Ī','Ō','Ū', 'ā','ē','ī','ō','ū',
  503. 'Ã','Å','Æ','Ç','Ð', 'ã','å','æ','ç','ð',
  504. 'Ñ','Õ','Ø','Š','Ŵ', 'ñ','õ','ø','š','ŵ',
  505. 'Ý','Ŷ','Ÿ','Ž','Þ', 'ý','ÿ','ŷ','ž','þ',
  506. 'IJ','Œ','ij','œ','ß', ' ',' ','«','Page','OK']
  507. #--------------------------------------------------------------------------
  508. # * Object Initialization
  509. #--------------------------------------------------------------------------
  510. def initialize(edit_window)
  511. super(edit_window.x, edit_window.y + edit_window.height + 8,
  512. edit_window.width, fitting_height(9))
  513. @edit_window = edit_window
  514. @page = 0
  515. @index = 0
  516. refresh
  517. update_cursor
  518. activate
  519. self.opacity = DPB::LOGIN::OPACITY
  520. end
  521. #--------------------------------------------------------------------------
  522. # * Get Text Table
  523. #--------------------------------------------------------------------------
  524. def table
  525. return [PASSWORD, PASSWORD2]
  526. end
  527. #--------------------------------------------------------------------------
  528. # * Get Text Character
  529. #--------------------------------------------------------------------------
  530. def character
  531. @index < 88 ? table[@page][@index] : ""
  532. end
  533. #--------------------------------------------------------------------------
  534. # * Determining if Page Changed and Cursor Location
  535. #--------------------------------------------------------------------------
  536. def is_page_change?
  537. @index == 88
  538. end
  539. #--------------------------------------------------------------------------
  540. # * Determine Cursor Location: Confirmation
  541. #--------------------------------------------------------------------------
  542. def is_ok?
  543. @index == 89
  544. end
  545. #--------------------------------------------------------------------------
  546. # * Get Rectangle for Displaying Item
  547. #--------------------------------------------------------------------------
  548. def item_rect(index)
  549. rect = Rect.new
  550. rect.x = index % 10 * 32 + index % 10 / 5 * 16
  551. rect.y = index / 10 * line_height
  552. rect.width = 32
  553. rect.height = line_height
  554. rect
  555. end
  556. #--------------------------------------------------------------------------
  557. # * Refresh
  558. #--------------------------------------------------------------------------
  559. def refresh
  560. contents.clear
  561. change_color(normal_color)
  562. 90.times {|i| draw_text(item_rect(i), table[@page][i], 1) }
  563. end
  564. #--------------------------------------------------------------------------
  565. # * Update Cursor
  566. #--------------------------------------------------------------------------
  567. def update_cursor
  568. cursor_rect.set(item_rect(@index))
  569. end
  570. #--------------------------------------------------------------------------
  571. # * Determine if Cursor is Moveable
  572. #--------------------------------------------------------------------------
  573. def cursor_movable?
  574. active
  575. end
  576. #--------------------------------------------------------------------------
  577. # * Move Cursor Down
  578. # wrap : Wraparound allowed
  579. #--------------------------------------------------------------------------
  580. def cursor_down(wrap)
  581. if @index < 80 or wrap
  582. @index = (index + 10) % 90
  583. end
  584. end
  585. #--------------------------------------------------------------------------
  586. # * Move Cursor Up
  587. # wrap : Wraparound allowed
  588. #--------------------------------------------------------------------------
  589. def cursor_up(wrap)
  590. if @index >= 10 or wrap
  591. @index = (index + 80) % 90
  592. end
  593. end
  594. #--------------------------------------------------------------------------
  595. # * Move Cursor Right
  596. # wrap : Wraparound allowed
  597. #--------------------------------------------------------------------------
  598. def cursor_right(wrap)
  599. if @index % 10 < 9
  600. @index += 1
  601. elsif wrap
  602. @index -= 9
  603. end
  604. end
  605. #--------------------------------------------------------------------------
  606. # * Move Cursor Left
  607. # wrap : Wraparound allowed
  608. #--------------------------------------------------------------------------
  609. def cursor_left(wrap)
  610. if @index % 10 > 0
  611. @index -= 1
  612. elsif wrap
  613. @index += 9
  614. end
  615. end
  616. #--------------------------------------------------------------------------
  617. # * Move to Next Page
  618. #--------------------------------------------------------------------------
  619. def cursor_pagedown
  620. @page = (@page + 1) % table.size
  621. refresh
  622. end
  623. #--------------------------------------------------------------------------
  624. # * Move to Previous Page
  625. #--------------------------------------------------------------------------
  626. def cursor_pageup
  627. @page = (@page + table.size - 1) % table.size
  628. refresh
  629. end
  630. #--------------------------------------------------------------------------
  631. # * Cursor Movement Processing
  632. #--------------------------------------------------------------------------
  633. def process_cursor_move
  634. last_page = @page
  635. super
  636. update_cursor
  637. Sound.play_cursor if @page != last_page
  638. end
  639. #--------------------------------------------------------------------------
  640. # * Handling Processing for OK and Cancel Etc.
  641. #--------------------------------------------------------------------------
  642. def process_handling
  643. return unless open? && active
  644. process_jump if Input.trigger?(:A)
  645. process_back if Input.repeat?(:B)
  646. process_ok if Input.trigger?(:C)
  647. end
  648. #--------------------------------------------------------------------------
  649. # * Jump to OK
  650. #--------------------------------------------------------------------------
  651. def process_jump
  652. if @index != 89
  653. @index = 89
  654. Sound.play_cursor
  655. end
  656. end
  657. #--------------------------------------------------------------------------
  658. # * Go Back One Character
  659. #--------------------------------------------------------------------------
  660. def process_back
  661. Sound.play_cancel if @edit_window.back
  662. end
  663. #--------------------------------------------------------------------------
  664. # * Processing When OK Button Is Pressed
  665. #--------------------------------------------------------------------------
  666. def process_ok
  667. if character == "«"
  668. process_back
  669. elsif !character.empty?
  670. on_name_add
  671. elsif is_page_change?
  672. Sound.play_ok
  673. cursor_pagedown
  674. elsif is_ok?
  675. on_name_ok
  676. end
  677. end
  678. #--------------------------------------------------------------------------
  679. # * Add Text to Name
  680. #--------------------------------------------------------------------------
  681. def on_name_add
  682. if @edit_window.add(character)
  683. Sound.play_ok
  684. else
  685. Sound.play_buzzer
  686. end
  687. end
  688. #--------------------------------------------------------------------------
  689. # * Decide Name
  690. #--------------------------------------------------------------------------
  691. def on_name_ok
  692. if @edit_window.name.empty?
  693. if @edit_window.restore_default
  694. Sound.play_ok
  695. else
  696. Sound.play_buzzer
  697. end
  698. else
  699. Sound.play_ok
  700. call_ok_handler
  701. end
  702. end
  703. end
  704. #==============================================================================
  705. # ** Scene_Title
  706. #------------------------------------------------------------------------------
  707. # This class performs the title screen processing.
  708. #==============================================================================
  709. class Scene_Title < Scene_Base
  710.  
  711. def msg
  712. s = [
  713. "#{DPB::LOGIN::HELP_VOCAB1}
  714. #{""} #{""}",
  715. "#{DPB::LOGIN::HELP_VOCAB2}
  716. #{""} #{""}"]
  717. return s
  718. end
  719. def sndmsg
  720. s = [
  721. "#{DPB::LOGIN::HELP_VOCAB3}
  722. #{""} #{""}",
  723. "#{DPB::LOGIN::HELP_VOCAB3}
  724. #{""} #{""}",
  725. "#{DPB::LOGIN::HELP_VOCAB3}
  726. #{""} #{""}"]
  727. return s
  728. end
  729. #--------------------------------------------------------------------------
  730. # * Start Processing
  731. #--------------------------------------------------------------------------
  732. alias dpbztitlestart start
  733. def start
  734. # super
  735. dpbztitlestart
  736. create_help_window
  737. @help_window.opacity = DPB::LOGIN::OPACITY
  738. end
  739.  
  740. alias dpbztitleupdate update
  741. def update
  742. # super
  743. dpbztitleupdate
  744. @sprite1.ox += DPB::LOGIN::TITLE_MOVE_X
  745. @sprite1.oy += DPB::LOGIN::TITLE_MOVE_Y
  746. @sprite2.ox -= DPB::LOGIN::IMAGE2_MOVE_X
  747. @sprite2.oy += DPB::LOGIN::IMAGE2_MOVE_Y
  748. if $dpbzpasswordhelpwindowinfo == 1
  749. @help_window.set_text(sndmsg[@command_window.index])
  750. else
  751. @help_window.set_text(msg[@command_window.index])
  752. end
  753. end
  754. #--------------------------------------------------------------------------
  755. # * Create Help Window
  756. #--------------------------------------------------------------------------
  757. def create_help_window
  758. @help_window = Window_Help.new
  759. @help_window.visible = true
  760. @help_window.set_text(msg[@command_window.index])
  761. end
  762. #--------------------------------------------------------------------------
  763. # * Create Background
  764. #--------------------------------------------------------------------------
  765. def create_background
  766. @sprite1 = Plane.new
  767. @sprite1.bitmap = Cache.parallax(DPB::LOGIN::TITLE_PICTURE)
  768. @sprite2 = Plane.new
  769. @sprite2.bitmap = Cache.parallax(DPB::LOGIN::TITLE_IMAGE2)
  770. end
  771. #--------------------------------------------------------------------------
  772. # * Create Command Window
  773. #--------------------------------------------------------------------------
  774. def create_command_window
  775. @command_window = Window_TitleCommand.new
  776. # @command_window.set_handler(:new_game, method(:command_new_game))
  777. # @command_window.set_handler(:continue, method(:command_continue))
  778. # @command_window.set_handler(:shutdown, method(:command_shutdown))
  779. @command_window.set_handler(:login_account, method(:command_login_account))
  780. @command_window.set_handler(:create_account, method(:command_create_account))
  781. end
  782. #--------------------------------------------------------------------------
  783. # * Create Command Window
  784. #--------------------------------------------------------------------------
  785. def create_login_window
  786. @command_window = Window_TitleLoginCommand.new
  787. @command_window.set_handler(:login_file1, method(:command_login_file1))
  788. @command_window.set_handler(:login_file2, method(:command_login_file2))
  789. @command_window.set_handler(:login_file3, method(:command_login_file3))
  790. @command_window.set_handler(:cancel, method(:command_backtotitle))
  791. end
  792. #--------------------------------------------------------------------------
  793. # * Create Command Window
  794. #--------------------------------------------------------------------------
  795. def create_create_window
  796. @command_window = Window_TitleCreateCommand.new
  797. @command_window.set_handler(:create_file1, method(:command_create_file1))
  798. @command_window.set_handler(:create_file2, method(:command_create_file2))
  799. @command_window.set_handler(:create_file3, method(:command_create_file3))
  800. @command_window.set_handler(:cancel, method(:command_backtotitle))
  801. end
  802. #--------------------------------------------------------------------------
  803. # * Close Command Window
  804. #--------------------------------------------------------------------------
  805. def close_command_window
  806. @command_window.close
  807. update until @command_window.close?
  808. end
  809. def command_backtotitle
  810. @command_window.hide
  811. $dpbzpasswordhelpwindowinfo = 0
  812. create_command_window
  813. end
  814. ################################################################################
  815. #--------------------------------------------------------------------------
  816. # * [Login] Command
  817. #--------------------------------------------------------------------------
  818. def command_login_account
  819. $dpbzpasswordhelpwindowinfo = 1
  820. DataManager.setup_new_game
  821. close_command_window
  822. create_login_window
  823. end
  824. #--------------------------------------------------------------------------
  825. # * [Create] Command
  826. #--------------------------------------------------------------------------
  827. def command_create_account
  828. $dpbzpasswordhelpwindowinfo = 1
  829. DataManager.setup_new_game
  830. close_command_window
  831. create_create_window
  832. end
  833. ################################################################################
  834. #--------------------------------------------------------------------------
  835. # * [Login File1] Command
  836. #--------------------------------------------------------------------------
  837. def command_login_file1
  838. close_command_window
  839. SceneManager.call(Scene_PasswordConfirm)
  840. SceneManager.scene.prepare(DPB::LOGIN::PASSWORD_ACTOR_ID, DPB::LOGIN::PASSWORD_MAX, 1)
  841. end
  842. #--------------------------------------------------------------------------
  843. # * [Login File2] Command
  844. #--------------------------------------------------------------------------
  845. def command_login_file2
  846. close_command_window
  847. SceneManager.call(Scene_PasswordConfirm)
  848. SceneManager.scene.prepare(DPB::LOGIN::PASSWORD_ACTOR_ID, DPB::LOGIN::PASSWORD_MAX, 2)
  849. end
  850. #--------------------------------------------------------------------------
  851. # * [Login File3] Command
  852. #--------------------------------------------------------------------------
  853. def command_login_file3
  854. close_command_window
  855. SceneManager.call(Scene_PasswordConfirm)
  856. SceneManager.scene.prepare(DPB::LOGIN::PASSWORD_ACTOR_ID, DPB::LOGIN::PASSWORD_MAX, 3)
  857. end
  858. ################################################################################
  859. #--------------------------------------------------------------------------
  860. # * [Create File1] Command
  861. #--------------------------------------------------------------------------
  862. def command_create_file1
  863. close_command_window
  864. SceneManager.call(Scene_CreatePassword)
  865. SceneManager.scene.prepare(DPB::LOGIN::PASSWORD_ACTOR_ID, DPB::LOGIN::PASSWORD_MAX, 1)
  866. end
  867. #--------------------------------------------------------------------------
  868. # * [Create File2] Command
  869. #--------------------------------------------------------------------------
  870. def command_create_file2
  871. close_command_window
  872. SceneManager.call(Scene_CreatePassword)
  873. SceneManager.scene.prepare(DPB::LOGIN::PASSWORD_ACTOR_ID, DPB::LOGIN::PASSWORD_MAX, 2)
  874. end
  875. #--------------------------------------------------------------------------
  876. # * [Create File3] Command
  877. #--------------------------------------------------------------------------
  878. def command_create_file3
  879. close_command_window
  880. SceneManager.call(Scene_CreatePassword)
  881. SceneManager.scene.prepare(DPB::LOGIN::PASSWORD_ACTOR_ID, DPB::LOGIN::PASSWORD_MAX, 3)
  882. end
  883. end# end scene title
  884.  
  885. ##################################
  886. class Scene_MenuBase < Scene_Base#
  887. #--------------------------------------------------------------------------
  888. # * Processing When Load Is Successful
  889. #--------------------------------------------------------------------------
  890. def on_load_success
  891. Sound.play_load
  892. fadeout_all
  893. $game_system.on_after_load
  894. SceneManager.goto(Scene_Map)
  895. end
  896.  
  897. def dpbzpasswordwait(time)
  898. t = 0
  899. loop do
  900. Graphics.update
  901. if t == time
  902. break
  903. end
  904. t += 1
  905. end
  906. end
  907. end # end class
  908. #==============================================================================
  909. # ** Scene_Name
  910. #------------------------------------------------------------------------------
  911. # This class performs name input screen processing.
  912. #==============================================================================
  913. class Scene_CreatePassword < Scene_MenuBase
  914. #--------------------------------------------------------------------------
  915. # * Prepare
  916. #--------------------------------------------------------------------------
  917. def prepare(actor_id, max_char, file)
  918. @actor_id = actor_id
  919. @max_char = max_char
  920. @file = file
  921. end
  922. #--------------------------------------------------------------------------
  923. # * Start Processing
  924. #--------------------------------------------------------------------------
  925. def start
  926. super
  927. @actor = $game_actors[@actor_id]
  928. @edit_window = Window_PasswordEdit.new(@actor, @max_char)
  929. @input_window = Window_PasswordInput.new(@edit_window)
  930. @input_window.set_handler(:ok, method(:on_input_ok))
  931. create_help_window
  932. end
  933. #--------------------------------------------------------------------------
  934. # * Create Help Window
  935. #--------------------------------------------------------------------------
  936. def create_help_window
  937. @help_window = Window_Help.new
  938. @help_window.visible = true
  939. @help_window.set_text(DPB::LOGIN::CREATE_USERNAME)
  940. @help_window.opacity = DPB::LOGIN::OPACITY
  941. end
  942. #--------------------------------------------------------------------------
  943. # * Input [OK]
  944. #--------------------------------------------------------------------------
  945. def on_input_ok
  946. @actor.name = @edit_window.name
  947. return_scene
  948. $dpbzpasswordhelpwindowinfo = 0
  949. if DPB::LOGIN::USE_SECOND_PASSWORD
  950. SceneManager.call(Scene_CreateSecondPassword)
  951. SceneManager.scene.prepare(DPB::LOGIN::PASSWORD_ACTOR_ID, DPB::LOGIN::PASSWORD_MAX, @file)
  952. else
  953. DataManager.save_game(@file)
  954. if DPB::LOGIN::START_NEWGAME_ON_CREATE_FILE
  955. on_load_success
  956. else
  957. return_scene
  958. SceneManager.call(Scene_Title)
  959. end
  960. end
  961. end
  962.  
  963. end#scene
  964. #==============================================================================
  965. # ** Scene_Name
  966. #------------------------------------------------------------------------------
  967. # This class performs name input screen processing.
  968. #==============================================================================
  969. class Scene_CreateSecondPassword < Scene_MenuBase
  970. #--------------------------------------------------------------------------
  971. # * Prepare
  972. #--------------------------------------------------------------------------
  973. def prepare(actor_id, max_char, file)
  974. @actor_id = actor_id
  975. @max_char = max_char
  976. @file = file
  977. end
  978. #--------------------------------------------------------------------------
  979. # * Start Processing
  980. #--------------------------------------------------------------------------
  981. def start
  982. super
  983. @actor = $game_actors[@actor_id]
  984. @edit_window = Window_PasswordEdit.new(@actor, @max_char)
  985. @input_window = Window_PasswordInput.new(@edit_window)
  986. @input_window.set_handler(:ok, method(:on_input_ok))
  987. create_help_window
  988. end
  989. #--------------------------------------------------------------------------
  990. # * Create Help Window
  991. #--------------------------------------------------------------------------
  992. def create_help_window
  993. @help_window = Window_Help.new
  994. @help_window.visible = true
  995. @help_window.set_text(DPB::LOGIN::CREATE_PASSWORD)
  996. @help_window.opacity = DPB::LOGIN::OPACITY
  997. end
  998. #--------------------------------------------------------------------------
  999. # * Input [OK]
  1000. #--------------------------------------------------------------------------
  1001. def on_input_ok
  1002. @actor.nickname = @edit_window.name
  1003. DataManager.save_game(@file)
  1004. if DPB::LOGIN::START_NEWGAME_ON_CREATE_FILE
  1005. on_load_success
  1006. else
  1007. return_scene
  1008. SceneManager.call(Scene_Title)
  1009. end
  1010. end
  1011. end#scene
  1012.  
  1013. #==============================================================================
  1014. # ** Scene_Name
  1015. #------------------------------------------------------------------------------
  1016. # This class performs name input screen processing.
  1017. #==============================================================================
  1018. class Scene_PasswordConfirm < Scene_MenuBase
  1019. #--------------------------------------------------------------------------
  1020. # * Prepare
  1021. #--------------------------------------------------------------------------
  1022. def prepare(actor_id, max_char,file)
  1023. @actor_id = actor_id
  1024. @max_char = max_char
  1025. @account = file
  1026. end
  1027. #--------------------------------------------------------------------------
  1028. # * Start Processing
  1029. #--------------------------------------------------------------------------
  1030. def start
  1031. super
  1032. @actor = $game_actors[@actor_id]
  1033. @edit_window = Window_PasswordEdit.new(@actor, @max_char)
  1034. @input_window = Window_PasswordInput.new(@edit_window)
  1035. @input_window.set_handler(:ok, method(:on_input_ok))
  1036. create_help_window
  1037. end
  1038. #--------------------------------------------------------------------------
  1039. # * Create Help Window
  1040. #--------------------------------------------------------------------------
  1041. def create_help_window
  1042. @help_window = Window_Help.new
  1043. @help_window.visible = true
  1044. @help_window.set_text(DPB::LOGIN::INPUT_USERNAME)
  1045. @help_window.opacity = DPB::LOGIN::OPACITY
  1046. end
  1047. #--------------------------------------------------------------------------
  1048. # * Input [OK]
  1049. #--------------------------------------------------------------------------
  1050. def on_input_ok
  1051. DataManager.load_game(@account)
  1052. @actor = $game_actors[DPB::LOGIN::PASSWORD_ACTOR_ID]
  1053. if @edit_window.name == @actor.name
  1054. return_scene
  1055. $dpbzpasswordhelpwindowinfo = 0
  1056. if DPB::LOGIN::USE_SECOND_PASSWORD
  1057. SceneManager.call(Scene_SecondPasswordConfirm)
  1058. SceneManager.scene.prepare(DPB::LOGIN::PASSWORD_ACTOR_ID, DPB::LOGIN::PASSWORD_MAX, @account)
  1059. else
  1060. on_load_success
  1061. end
  1062. else
  1063. @help_window.set_text(DPB::LOGIN::FAILED_USERNAME)
  1064. dpbzpasswordwait(DPB::LOGIN::FAILED_WAIT)
  1065. return_scene
  1066. end
  1067. end
  1068. ######
  1069. end # scene
  1070. #==============================================================================
  1071. # ** Scene_Name
  1072. #------------------------------------------------------------------------------
  1073. # This class performs name input screen processing.
  1074. #==============================================================================
  1075. class Scene_SecondPasswordConfirm < Scene_MenuBase
  1076. #--------------------------------------------------------------------------
  1077. # * Prepare
  1078. #--------------------------------------------------------------------------
  1079. def prepare(actor_id, max_char, file)
  1080. @actor_id = actor_id
  1081. @max_char = max_char
  1082. @account = file
  1083. end
  1084. #--------------------------------------------------------------------------
  1085. # * Start Processing
  1086. #--------------------------------------------------------------------------
  1087. def start
  1088. super
  1089. DataManager.setup_new_game
  1090. @actor = $game_actors[@actor_id]
  1091. @edit_window = Window_PasswordEdit.new(@actor, @max_char)
  1092. @input_window = Window_PasswordInput.new(@edit_window)
  1093. @input_window.set_handler(:ok, method(:on_input_ok))
  1094. create_help_window
  1095. @help_window.opacity = DPB::LOGIN::OPACITY
  1096. end
  1097. #--------------------------------------------------------------------------
  1098. # * Create Help Window
  1099. #--------------------------------------------------------------------------
  1100. def create_help_window
  1101. @help_window = Window_Help.new
  1102. @help_window.visible = true
  1103. @help_window.set_text(DPB::LOGIN::INPUT_PASSWORD)
  1104. @help_window.opacity = DPB::LOGIN::OPACITY
  1105. end
  1106. #--------------------------------------------------------------------------
  1107. # * Input [OK]
  1108. #--------------------------------------------------------------------------
  1109. def on_input_ok
  1110. DataManager.load_game(@account)
  1111. @actor = $game_actors[DPB::LOGIN::PASSWORD_ACTOR_ID]
  1112. if @edit_window.name == @actor.nickname
  1113. on_load_success
  1114. else
  1115. return_scene
  1116. @help_window.set_text(DPB::LOGIN::FAILED_PASSWORD)
  1117. dpbzpasswordwait(DPB::LOGIN::FAILED_WAIT)
  1118. end
  1119. end
  1120.  
  1121. end # scene
  1122. ####################
  1123. # Awesome Autosave #
  1124. ####################
  1125. if DPB::LOGIN::USE_AUTOSAVE
  1126. # Keyboard four de map ? no
  1127. class Scene_Map < Scene_Base
  1128. alias dpbzautosavestart start
  1129. def start
  1130. # super
  1131. dpbzautosavestart
  1132. @dpbzautosavecounter = 0
  1133. end
  1134.  
  1135. #@dpbzautosavecounter = 0
  1136. alias dpbzautosave update_scene
  1137. def update_scene
  1138. dpbzautosave
  1139. @dpbzautosavecounter += 1
  1140. if @dpbzautosavecounter == DPB::LOGIN::SAVE_FREQ
  1141. update_call_autosave
  1142. @dpbzautosavecounter = 0
  1143. end
  1144. end # update scene
  1145. # Define call
  1146. def update_call_autosave
  1147. if !$game_player.moving?
  1148. call_autosave
  1149. end
  1150. end
  1151. # Define call
  1152. def call_autosave
  1153. @file = DataManager.last_savefile_index
  1154. DataManager.save_game(@file)
  1155. end
  1156.  
  1157. end# scenemap
  1158. end
  1159. #==============================================================================
  1160. # ** Scene_Load
  1161. #------------------------------------------------------------------------------
  1162. # This class performs load screen processing.
  1163. #==============================================================================
  1164. class Scene_Load < Scene_File
  1165. #--------------------------------------------------------------------------
  1166. # * Processing When Load Is Successful
  1167. #--------------------------------------------------------------------------
  1168. alias dpbzawsomeautosaveonloadsuccess on_load_success
  1169. def on_load_success
  1170. @file = DataManager.last_savefile_index
  1171. DataManager.save_game(@file)
  1172. dpbzawsomeautosaveonloadsuccess
  1173. end
  1174. end
  1175. #===============================================================================
  1176. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  1177. #===============================================================================
  1178. #
  1179. # ★ Perfect Password Protection™ ★
  1180. # ★ SCRIPT END ★
  1181. #
  1182. #===============================================================================
  1183. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  1184. #===============================================================================
  1185. ################################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement