estriole

EST - NOTEBOOK SYSTEM

Jan 6th, 2013
4,085
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 55.29 KB | None | 0 0
  1. $imported = {} if $imported.nil?
  2. $imported["EST - NOTEBOOK SYSTEM"] = true
  3.  
  4. #===============================================================================
  5. # [VXACE] Notebook System
  6. #-------------------------------------------------------------------------------
  7. # EST - Notebook System
  8. # Version: 2.6
  9. # Released on: 26/07/2012
  10. # Author : Estriole ([email protected])
  11. #
  12. # Licenses :
  13. # Free to use in all project (except one containing pornography)
  14. # as long as i credited (ESTRIOLE)
  15. #
  16. # also credits :
  17. # Woratana for Adv text Reader VX version
  18. # Jet for Notebooks Menu VX version
  19. # Pacman for converting Jet Notebooks menu to ACE
  20. #===============================================================================
  21. =begin
  22. ################################################################################
  23. # Version History:
  24. #  v 1.00 - 2012.07.22 > First relase
  25. #  v 1.01 - 2012.07.23 > replace the old decorate text with escape code usage  
  26. #  v 1.02 - 2012.07.26 > make switch togle between old decorate text and new
  27. #                        escape code version
  28. #  v 2.0  - 2013.01.06 > combine the script with notebooks menu. then improve it.
  29. #                        can be used separately or with notebooks menu.
  30. #                        also change the script name to reflect the changes...
  31. #  v 2.1  - 2013.01.10 > make it compatible with custom resolution.
  32. #  v 2.2  - 2013.01.13 > make notebook not exiting if no entry                      
  33. #  v 2.3  - 2013.07.02 > fix some typo and private method. also compatibility with
  34. #                        yami - pop message script. put this script below it
  35. #  v 2.4  - 2013.07.31 > compatibility with victor sfont script.
  36. #                        but since the sfont make the font wider. you need to
  37. #                        break some lines in your existing txt files. just experiment
  38. #                        until you got the result you wanted.
  39. #                      > add feature to set font size. (both manual and config)
  40. #                        so we can show MORE text in a line...
  41. #                        WARNING: if using victor SFONT this feature DISABLED.
  42. #                      > Add FAQ section in this script header to clear things
  43. #                      > Decide to DISABLE the AUTO LINE BREAK feature since many
  44. #                        people complain about cutted text below. now you must edit
  45. #                        your text files manually if your text exceed window width
  46. #                      > by disabling the auto line break. it's compatible with
  47. #                        custom resolution... so MORE text again in a line !!!
  48. #                      > Accidentally manage to find way to combine old mode feature.
  49. #                        now you could use [b] to bold, [i] to italic, [cen] to center text
  50. #                        while STILL using escape code. so old mode is not needed anymore
  51. #  v 2.5  - 2013.08.04 > when returning from text_reader it will pick the last chosen entry
  52. #                      > Add category feature. search NEW FEATURE FROM v2.5
  53. #                      > Add sorting feature. search NEW FEATURE FROM v2.5
  54. #                      > Add Common Event Launch feature. search NEW FEATURE FROM v2.5
  55. #                        if you manage to do something great using this feature
  56. #                        share with me in the topic page please :D.
  57. #  v 2.6  - 2014.08.16 > added compatibility patch to Galv Menu Themes Engine
  58. #                                            
  59. ###############################################################################
  60.  
  61. --- FAQ (FREQUENTLY ASKED QUESTION ----
  62.  
  63. Q: the notebook file settings in configuration have no effect
  64. A: make sure the filename without .txt in it. and make sure it's CASE SENSITIVE
  65.    means same upper case and lower case as the txt filename.
  66.  
  67. Q: my text go to new line and break my formatting
  68. A: edit your txt files so it won't exceed the window width. from v2.4. i disabled
  69.    the autoline break. so this case won't happen anymore. edit your txt files
  70.    so it won't exceed the window width...  
  71.  
  72. Q: i set the font size to 10. but it have no effect
  73. A: if you use victor sfont script. the font size feature is DISABLED.
  74.  
  75. Q: i got bad size error warning
  76. A: it because you set the font_size to really low value. make sure it 10 or above
  77.  
  78. BELOW FAQ ANSWER MAINLY = DOWNLOAD THE LATEST VERSION :D.  
  79. Q: my text got cutted at the bottom
  80. A: it happen because of you have line that exceed window width and autoadd new line
  81.    you can break that line so it fit the window width. from v2.4. i disabled
  82.    the autoline break. so this case won't happen anymore. edit your txt files.
  83.    so it won't exceed the window width  
  84.    
  85. Q: my text go to new line and got cutted at the bottom. the formatting already
  86.    look fine as is. i'm to lazy to restructure my text and i just want the bottom
  87.    not cutted.
  88. A: add extra enter in the text files bottom. (press enter several times. then save)
  89.    it will then show the missing part. add as much as you need until it show all text.
  90.    from v2.4. i disabled the autoline break. so this case won't happen anymore.
  91.    edit your txt files so it won't exceed the window width...
  92.    
  93. Q: This script sucks because i have to do lots of things MANUALLY
  94.    want to use escape code + align the text to center? add space
  95.    line too long and exceed the window width? add line break and restructure it.
  96. A: you still need to do some work... not all thing can be handled using script.
  97.    BUT FROM v 2.4 you can use [cen] to align text to middle.
  98.    basically combine of old mode and new mode...
  99.    hope you're satisfy now lazy people LOL. just kidding.
  100.  
  101. ================================================================================
  102.                           NEW FEATURE FROM v2.5
  103. --------------------------------------------------------------------------------
  104. CATEGORY FUNCTIOM
  105. --------------------------------------------------------------------------------
  106. > set category to each txt files
  107.   search FILE_READER_SETTING
  108.   and read the documentation above it.
  109.  
  110.   if not set in FILE_READER_SETTING. the txt files will use category from:
  111.   DEFAULT_TXT_CATEGORY
  112.  
  113. > setting starting unlocked category
  114.   search START_CATEGORY in module ESTRIOLE and fill the starting category the
  115.   notebook can access.
  116.  
  117. > adding category in game
  118. To add new category to the journal, use this in an event "Script..." command
  119. add_category("cat_name")
  120. "catname" is a string where will be used as category
  121.  
  122. > to sort category you can sort $game_system.notebook_categories
  123. using script call:
  124. $game_system.notebook_categories.sort!
  125. will sort the category alphabetically A-Z
  126. $game_system.notebook_categories.sort!{|x,y| y <=> x}
  127. will sort the category alphabetically Z-A
  128.  
  129. i didn't add ability to freely sort categories like entries yet. since i don't think
  130. that necessary. unless you have LOOOTS of category. which i think rarely happen.
  131. and even with lots of category. A-Z and Z-A sort might already enough.
  132.  
  133. to remove categories from the journal script call
  134. rem_category("cat_name")
  135.  
  136. --------------------------------------------------------------------------------
  137. SORTING FUNCTIOM
  138. --------------------------------------------------------------------------------
  139. > press shift in entries list. and you can sort the entries by the rules set in module ESTRIOLE
  140.   i include 6 rules:
  141.   1) Alphabetical: A-Z
  142.   2) Alphabetical: Z-A
  143.   3) Priority High
  144.   4) Priority Low
  145.   5) First Received
  146.   6) Last Received
  147.  
  148. > priority sort requires developer to fill FILE_READER_SETTING to set the priority each files.
  149.   search FILE_READER_SETTING
  150.   and read the documentation above it.
  151.   if not set in FILE_READER_SETTING. the txt files will use priority from:
  152.   DEFAULT_PRIORITY
  153.  
  154. > you can custom the sorting rule if you understand ruby.
  155.   search SORTING_RULE
  156.  
  157. --------------------------------------------------------------------------------
  158. COMMON EVENT LAUNCH FUNCTIOM
  159. --------------------------------------------------------------------------------
  160. this feature have two type
  161. 1) LAUNCH AT the text reader scene (before viewing the text)
  162. REQUIRES TSUKIHIME SCENE INTERPRETER SCRIPT
  163. so we can launch common event directly in the scene.
  164.  
  165. this feature is handy if we want to make some little conversation
  166. before reading the text. (might require conditional branch to make
  167. it one time conversation)
  168. example: opening a letter.
  169. actor a said. hey it's a letter from your lover
  170. actor b said. get lost.
  171. sorta like that. :D.
  172.  
  173. COMMON EVENT command some works some don't (since it's not at scene_map).
  174. in demo i show that show text, show choice, play SE works
  175. while show picture not working. (it works but shown on map instead on that scene)
  176. you can try it yourself what works what not. Don't be too lazy ok! :D.
  177.  
  178. to set it search FILE_READER_SETTING
  179. and add
  180. common_event: youridhere,
  181. in the hash (see the example)
  182.  
  183. 2) LAUNCH AFTER the text reader scene (after viewing the text)
  184. this not require any script since it works using default RM reserve common event method.
  185.  
  186. this feature is handy if we want something happen AFTER we read the entry.
  187. just use your imagination. it could be cursed book. or something like that.
  188. or some conversation after reading it (might require conditional branch to make
  189. it one time conversation)
  190.  
  191. since it working in Scene_Map. most command will works.
  192. so if you're a genius eventer... i cannot imagine what you can make using this feature.
  193. (share with me okay :D)
  194.  
  195. to set it search FILE_READER_SETTING
  196. and add
  197. common_event_after: youridhere,
  198. in the hash (see the example)
  199.  
  200. the difference with the first function is it have _after.
  201.  
  202. --------------------------------------------------------------------------------
  203. Major Changes from version 2.0
  204. ================================================================================
  205. - now have notebook function like Jet Notebook menu for vx.
  206. - config to auto adding to yanfly menu system :D
  207. - can add record and remove record to journal at will
  208. - can choose which file to view
  209. - can differ each file how it shown in adv text reader using configuration
  210. - add new call method for adv text reader instead of long scenemanagerplus
  211. thing :D (i'm ashamed but that method actually because of my noobiness as
  212. scripter at that time :D. i don't know about scenemanager.scene.prepare thing :D)
  213.  
  214. i STILL keep the original call so in case you already set your project that way...
  215. you're still okay. (although i wanted to delete the 'shame' but i need to think
  216. the need of many T.T).
  217.  
  218. now original call also can use .txt or not in the filename
  219. (worked really hard to fix shame of the past :D)
  220.  
  221. --------------------------------------------------------------------------------
  222. now we can use script call for adv text reader like this:
  223. --------------------------------------------------------------------------------
  224. SceneManager.call(Text_Reader) #required
  225. SceneManager.scene.set_file("Credits") #required
  226. SceneManager.scene.set_face(1)
  227. SceneManager.scene.set_type("text_title")
  228. SceneManager.scene.set_text_title("This is combat tutorial")
  229. SceneManager.scene.set_font_size(30)
  230. SceneManager.scene.set_old_mode
  231.  
  232. from set face to set old mode is optional.
  233. set_face is for setting face to shown. add the actor id you want the face to show
  234. set_type is for setting the adv reader custom type. either "simple_status" or "text_title"
  235. set_text_title is for setting text title if you use "text_title" mode
  236. set_font_size is to set the font of the window content.
  237. set_old_mode is for setting the adv reader to use old mode once only.
  238.  
  239. ================================================================================
  240.                           NEW NOTEBOOK function
  241. --------------------------------------------------------------------------------
  242. To add new entries to the journal, use this in an event "Script..." command
  243. add_entry("filename")
  244. "filename" should be the name of a .txt file in the text folder, excluding
  245. the .txt. So say i have a file called Test.txt: add_entry("Test")
  246. Even if you use the .rvdata file, the filenames stay the same so make sure
  247. you remember your filenames.
  248.  
  249. i also modify it to add check if that file exist or not either in folder
  250. or if use .rvdata file in the file array.
  251.  
  252. to remove entries from the journal script call
  253. rem_entry("filename")
  254.  
  255. --------------------------------------------------------------------------------
  256. You can call the journal scene with this code in an event "Script..." command:
  257.  
  258. goto_notebook
  259.  
  260. The journal scene will be inaccessable unless the player has at least 1 entry
  261. (edit: from v.2.2 now can open without entry)
  262. --------------------------------------------------------------------------------
  263.  
  264. you can add setting to modify the text reader. see the configuration
  265. search "NOTEBOOK FILE SETTING"
  266.  
  267.  
  268. ===============================================================================
  269.  
  270. Old Script call still works. below is the list of it
  271. ==================================
  272. +[Features in Version 1.2]+
  273.  
  274. ** Start Read Text File by call script:
  275. SceneManager.callplus(Text_Reader,"filename with file type")
  276.  
  277. * For example, you want to read file "test.txt", call script:
  278. SceneManager.callplus(Text_Reader,"test.txt")
  279.  
  280. * ability to use almost all msg system escape codes
  281. such as \c[4], \n[3]. default or custom message system
  282. (known so far yanfly, victor, modern algebra ats)
  283.  
  284. * Advanced syntax to call is like this
  285. SceneManager.callplus(Text_Reader,filename,[actorid],[type],[infocontent])
  286.  
  287. [actorid] & [type] & [infocontent] is optional
  288. [infocontent] will print inside info window when some type chosen max [41char].
  289.  
  290. list of [type]: (what the content of info window)
  291. "default"       - just draw face window (if no actorid) without info window then draw text reader window
  292. "simple_status" - info window containing simple actor status
  293. "text_title"    - info window containing titles for the text centered and yellow color
  294. still building more [type]
  295.  
  296. example of some variation to call advanced syntax:
  297. SceneManager.callplus(Text_Reader,"test.txt",11,"simple_status")
  298. means it will draw actor 11 face and actor 11 simple status then below
  299. is test.txt content.
  300.  
  301. or
  302.  
  303. SceneManager.callplus(Text_Reader,"test.txt",nil,"text_title","Stupid Tutorial")
  304. which translate to : only info window containing text "Stupid Tutorial" with larger
  305. font and yellow color centered (vertical and horizontal). and below it is the
  306. test.txt content. (no actor face window because you put nil)
  307.  
  308. or
  309. SceneManager.callplus(Text_Reader,"test.txt",12)
  310. translate to : test.txt content with actor face window (small square at top left
  311. of the test.txt (means it will block any text that below it. but its not a problem
  312. if you center the text (manualy or using decorate text if you didn't need icons, color, etc)
  313.  
  314. ** Custom Folder for Text File
  315. You can change Text File's folder at line:
  316. TEXT_FOLDER = "folder you want"
  317.  
  318. "" << for no folder, text file should be in your game's folder.
  319. "Files/" << for folder "Your Game Folder > Files"
  320. "Data/Files/" << for folder "Your Game Folder > Data > Files"
  321.  
  322. ==================================
  323. decorate text feature below can be used by editing :
  324.  
  325. TR_old_mode_switch = 0
  326. change to switch you want.
  327. if the switch turn on you can use decorate text feature below but lost ability
  328. to use all the escape code (such as \c[5] \n[3] etc)
  329.  
  330. so basicly you can switch between using decorate text and using escape codes.
  331.    
  332. +[Decorate Text]+ [if you still want to use this feature instead nice icon and pics]
  333. You can decorate your text by following features:
  334.  
  335. [b] << Bold Text
  336. [/b] << Not Bold Text
  337.  
  338. [i] << Italic Text
  339. [/i] << Not Italic Text
  340.  
  341. [s] << Text with Shadow
  342. [/s] << Text without Shadow
  343.  
  344. [cen] << Show Text in Center
  345. [left] << Show Text in Left side
  346. [right] << Show Text in Right side
  347.  
  348. * Note: Don't put features that have opposite effects in same line...
  349. For example, [b] that make text bold, and [/b] that make text not bold
  350.  
  351. * Note2: The decoration effect will be use in the next lines,
  352. Until you use opposite effect features... For example,
  353.  
  354. [b]text1
  355. text2
  356. [/b]text3
  357.  
  358. text1 and text2 will be bold text, and text3 will be thin text.
  359.  
  360. ==================================
  361. +[Configuration]+
  362.  
  363. OPEN_SPEED = Speed when Reader Window is Opening/Closing
  364. SCROLL_SPEED = Speed when player Scroll Reader Window up/down
  365.  
  366. TEXT_FOLDER = Folder for Text Files
  367. e.g. "Data/Texts/" for Folder "Your Project Folder > Data > Texts"
  368.  
  369. ================================================================================
  370. compatibility list
  371. ================================================================================
  372. message system
  373. - yanfly ace msg system
  374. - victor msg system
  375. - modern algebra ats msg system
  376. and i'm using loooottss of script and no conflict but i won't list them there
  377. because it's not necessary (the one who can conflict only the one who alter
  378. window_base or scene_base heavily like overwriting the method without mercy lol)
  379.  
  380. ================================================================================
  381. =end
  382. # editable region
  383. module ESTRIOLE
  384.    TR_old_mode_switch = 31 # switch if on use old decorate text mode change to 0
  385.                           # you dont want to use the decorate text mode at all
  386.    DISABLE_SFONT_SWITCH = 32 # if using victor sfont script and you want to disable
  387.                              # it. turn on this switch...  
  388.    
  389.    TEXT_FOLDER = "Notebook/" # Folder for Text Files -> this means at your project folder/text
  390.    OPEN_SPEED = 30 # Open/Close Speed of Reader Window (Higher = Faster)
  391.    SCROLL_SPEED = 30 # Scroll Up/Down Speed
  392.      
  393.   # Would you like to convert all .txt files in the "Notebook" folder to a
  394.   # .rvdata data file which can be encrpyted with the game, and used with
  395.   # the USE_RVDATA_FILE option?
  396.   DO_CONVERSION_TO_RVDATA = false
  397.  
  398.   # Would you like to use the Notebook.rvdata file generated with the
  399.   # DO_CONVERSION_TO_RVDATA instead of the .txt files in the "Notebook" folder?
  400.   USE_RVDATA_FILE = false
  401.  
  402.   # What is the notebook called?
  403.   NOTEBOOK_NAME = "Notebook"
  404.  
  405.   ADV_READER_USE_YANFLY_MENU = true
  406.   ADV_READER_PUT_BELOW = :status #this must be valid symbol in yanfly menu
  407.  
  408. =begin  
  409.   NOTEBOOK FILE SETTING
  410.   this setting for if you want to customize for each file how it
  411.   will shown in text reader. AUTOMATICALLY when choosing it in notebook menu
  412.  
  413.   make sure you don't forget the , (coma) for every setting.
  414.   and to be sure just copy from "entry 1" to "end entry 1" so you don't break the
  415.   hash format...
  416.   format is like this
  417.  
  418.    "Filename" => {
  419.                    type: x,
  420.                    face_id: y,
  421.                    text_title: z,
  422.                    old_mode: v,
  423.                    desc: w,
  424.                    font_size: n,
  425.                    priority: m,
  426.                    category: a,
  427.                  },
  428.   ----------------------------------------------------------------------------
  429.   "Filename" => string. the filename without .txt extension. CASE SENSITIVE.
  430.                 means upper case and lower case must match the filename
  431.    x => string. this is the type of the text reader. available type:
  432.                  "Default" => default mode
  433.                  "Simple_status" => will add status for the actor if face_id exist
  434.                  "Text_Title" => will add text title. usefull for tutorial type
  435.    
  436.    y => int. id of the actor you want it face to shown. usefull if you want it like
  437.              this information is told by that actor/about that actor (like suikoden investigation file)
  438.    z => string. if use text title type. it will use this as title
  439.    v => true/false. true will use old mode for one time. false didn't use it at all.
  440.    w => string. what you want to shown as text description in notebook menu
  441.    n => integer. font size the window reader content will use. minimum 10.
  442.    n => integer. priority of the files. means that files more important the higher the value
  443.    a => array. categories this txt files belong to
  444. =end
  445.  
  446.   FILE_READER_SETTING = {#do not touch
  447.   #entry 1 ##############################
  448.   "Credits" => {
  449.                 type: "TEXT_TITLE",
  450.                 face_id: 10,
  451.                 text_title: "THANK YOU ALL FOR YOUR WORKS",
  452.                 desc: "text_title, face=10, font = 10\nfont feature disabled if sfont installed",
  453.                 font_size: 10,
  454.                 category: ["All","System"],
  455.                },
  456.   #end entry 1 ##########################
  457.   #entry 2 ##############################
  458.   "English" => {
  459.                 type: "SIMPLE_STATUS",
  460.                 face_id: 1,
  461.                 old_mode: true,
  462.                 category: ["All","System"],
  463.                 priority: 20,
  464.                 desc: "test one time only jibber jabber conversation\nsee common event 3 for more info",
  465.                 common_event: 3,
  466.                },              
  467.   #end entry 2 ##########################  
  468.   #entry 3 ##############################
  469.   "FontSizeTest" => {
  470.                 type: "TEXT_TITLE",
  471.                 face_id: 1,
  472.                 text_title: "THANK YOU ALL FOR YOUR WORKS",
  473.                 desc: "font = 40, face = 1, text_title",
  474.                 font_size: 40,
  475.                 category: ["All","Testing"],
  476.                },
  477.   #end entry 3 ##########################  
  478.   #entry 4 ##############################
  479.   "Note from Elsie" => {
  480.                 type: "TEXT_TITLE",
  481.                 face_id: 1,
  482.                 text_title: "THANK YOU ALL FOR YOUR WORKS",
  483.                 desc: "A letter from beloved Elsie\nFrom London",
  484.                 category: ["Letter"],
  485.                 priority: 100,
  486.                },
  487.   #end entry 4 ##########################  
  488.   #entry 5 ##############################
  489.   "Common Event Test" => {
  490.                 type: "SIMPLE_STATUS",
  491.                 face_id: 1,
  492.                 category: ["All","System"],
  493.                 priority: 20,
  494.                 desc: "will execute Common Event 4 at text reader\nwill execute Common Event 5 after closing",
  495.                 common_event: 4,
  496.                 common_event_after: 5,
  497.                },              
  498.   #end entry 5 ##########################  
  499.   }#do not touch
  500.    
  501.   DEFAULT_NOTEBOOK_FILE_DESC = "No information about this specific #{NOTEBOOK_NAME}'s entry"
  502.   NOTEBOOK_NO_ENTRY_DESC = "No entries"  
  503.  
  504. ## CATEGORY CUSTOMIZATION #####
  505.   #category which contain every text - must not empty
  506.   ALL_TXT_CATEGORY = ["All"]
  507.  
  508.   #the game will start with these category unlocked already. if you want to unlock
  509.   #you can use the script call method if you don't want any category to unlocked
  510.   #just change it to []
  511.   START_CATEGORY = [ALL_TXT_CATEGORY[0],"Letter"]
  512.   # CHANGE ABOVE TO = [] if you don't want any category
  513.  
  514.   #help text that will be shown when hovering at category
  515.   CATEGORY_HELP_TEXT = {
  516.   "All" => "All Notebook Entries",
  517.   "Letter" => "Letter written by someone",
  518.   "System" => "System related notebook entry",
  519.   "Testing" => "for debug and testing purpose entry",
  520.   }# do not remove this line
  521.  
  522.   #if didn't set the help text above. use this instead.
  523.   CATEGORY_DEFAULT_HELP_TEXT = "No information about this specific category"
  524.  
  525.   #if not set in file_reader_setting. text will belong to these categories
  526.   DEFAULT_TXT_CATEGORY = [ALL_TXT_CATEGORY[0],"Letter"]
  527.  
  528. ## SORTING CUSTOMIZATION #####
  529.   #if not set in file_reader_setting. then it will use this default priority
  530.   DEFAULT_PRIORITY = 1
  531.  
  532.  
  533. =begin
  534.   IF YOU WANT CUSTOM SORTING RULE...
  535.   Enter your sorting rule in hash below
  536.   REQUIRE RUBY KNOWLEDGE !!! it's better not mess with it if you don't know ruby
  537.   and just use what i already made
  538.  
  539.   "SORT TYPE" => {"RUBY COMMAND IN STRING"},
  540.  
  541.   RUBY COMMAND IN STRING explanation
  542.   entries is an array that you sort so you can do:
  543.   "entries.sort!{|x,y| y <=> x}"
  544.   and it will sort descending (Z-A)
  545.  
  546. =end
  547.   SORTING_RULE = {
  548.   "Alphabet: A-Z" => "entries.sort!",
  549.   "Alphabet: Z-A" => "entries.sort!{|x,y| y <=> x}",
  550.   "Priority High" =>"entries.sort!{|x,y| ESTRIOLE.get_priority(x) <=> ESTRIOLE.get_priority(y)}",
  551.   "Priority Low" => "entries.sort!{|x,y| ESTRIOLE.get_priority(y) <=> ESTRIOLE.get_priority(x)}",
  552.   "First Received" => "",  #no sorting
  553.   "Last Received" => "entries.reverse!", #reverse order
  554.   }#DO NOT TOUCH THIS LINE
  555.  
  556.   def self.get_priority(string)
  557.     priority = DEFAULT_PRIORITY
  558.     setting = FILE_READER_SETTING[string] rescue nil
  559.     priority = setting[:priority] if setting && setting[:priority] rescue DEFAULT_PRIORITY
  560.     return priority
  561.   end
  562.  
  563. ###### YANFLY MENU PATCH #######################################################
  564.  
  565. #do not touch below this... unless you know what you're doing
  566.   ADV_TEXT_TYPE = ["DEFAULT","SIMPLE_STATUS","TEXT_TITLE"]
  567.  
  568. # SIMPLY ADD :notebook to the COMMANDS in yanfly configuration
  569.   #below in setting for yanfly menu.
  570.   NOTEBOOK_CUSTOM_COMMAND = {
  571.     :notebook => [  "#{NOTEBOOK_NAME}", 0, 0, :command_to_notebook],
  572.   } # <- Do not delete.
  573.  
  574.   YEA::MENU::CUSTOM_COMMANDS.merge!(NOTEBOOK_CUSTOM_COMMAND) if $imported["YEA-AceMenuEngine"] == true  
  575.  
  576. end
  577.  
  578. #===========================================================================
  579. # do not edit below this line except you know what you're doing
  580. #===========================================================================
  581.  
  582. module SceneManager
  583.   def self.callplus(scene_class,filename,actor = nil,type="DEFAULT",infocontent="")
  584.     @stack.push(@scene)
  585.     @scene = scene_class.new(filename,actor,type,infocontent)
  586.   end  
  587. end
  588.  
  589. if ESTRIOLE::ADV_READER_USE_YANFLY_MENU && $imported["YEA-AceMenuEngine"] == true
  590. # AUTO INSERTING NOTE BELOW CERTAIN SYMBOL
  591. index, target = nil
  592. for i in 0..YEA::MENU::COMMANDS.size-1
  593.  index = i if YEA::MENU::COMMANDS[i] == ESTRIOLE::ADV_READER_PUT_BELOW
  594. end
  595. target = index - YEA::MENU::COMMANDS.size if index !=nil
  596. YEA::MENU::COMMANDS.insert(target,:notebook) if target!=nil
  597. YEA::MENU::COMMANDS.insert(-1,:notebook)if target==nil
  598. # END AUTO INSERTING
  599. end
  600.  
  601. class Scene_Menu < Scene_MenuBase
  602.   #--------------------------------------------------------------------------
  603.   # compatibility method : command_tocrafting
  604.   #--------------------------------------------------------------------------
  605.   def command_to_notebook
  606.     SceneManager.call(Scene_Notebook)
  607.   end
  608. end # class Scene_Menu
  609.  
  610. class Text_Reader < Scene_MenuBase  
  611.   OPEN_SPEED = ESTRIOLE::OPEN_SPEED
  612.   SCROLL_SPEED = ESTRIOLE::SCROLL_SPEED
  613.   TEXT_FOLDER = ESTRIOLE::TEXT_FOLDER  
  614.   def initialize(file_name = "",actor = nil,type="DEFAULT",infocontent="",mode = 0)
  615.     #compatibility with old script call
  616.     name = file_name.partition(".")
  617.     @filename = name[0]
  618.     @infocontent = infocontent
  619.     @actorx = actor.nil?? nil : $game_actors[actor]
  620.     @mode = mode
  621.     @type = type
  622.     create_interpreter if $imported["TH_SceneInterpreter"]
  623.   end
  624.  
  625.   #configuration
  626.   def set_file(file_name)
  627.   @filename = file_name
  628.   end
  629.   def set_face(id=nil)
  630.   @actorx = id.nil?? nil : $game_actors[id]
  631.   end
  632.   def set_type(type="DEFAULT")
  633.   return if type.nil?
  634.   @type = type.upcase if ESTRIOLE::ADV_TEXT_TYPE.include?(type.upcase)
  635.   end
  636.   def set_text_title(text="")
  637.   return if text.nil?
  638.   @infocontent = text
  639.   end
  640.   def set_old_mode
  641.   $game_switches[ESTRIOLE::TR_old_mode_switch] = true
  642.   @old_mode_one_time_only = true
  643.   end
  644.   def set_font_size(size)
  645.   @font_size = size
  646.   end
  647.   def set_common_event(id)
  648.   @common_event_id = id
  649.   end
  650.   def set_common_event_after(id)
  651.   @common_event_after_id = id
  652.   puts @common_event_after_id
  653.   end
  654.   def start
  655.     super
  656.     create_reader_windows
  657.     return if !$imported["TH_SceneInterpreter"]
  658.     @interpreter.setup($data_common_events[@common_event_id].list) if @common_event_id
  659.   end
  660.  
  661.   def create_reader_windows
  662.     if ESTRIOLE::USE_RVDATA_FILE
  663.       file = load_data("Data/Notebook.rvdata2")[@filename + ".txt"]
  664.     else
  665.       file = File.open(TEXT_FOLDER + @filename + ".txt")
  666.     end
  667.     @text = []
  668.     file.each_line do |line|
  669.       @text.push line.sub(/\n/) {}
  670.     end
  671.     if @mode == 1
  672.       @text[0] = @text[0].sub(/^./m) {}
  673.     end
  674.        
  675.     @window = Window_Reader.new(@text,@actorx,@type,@font_size)
  676.     @window.visible = true
  677.    
  678.     if @actorx == nil
  679.      
  680.     else
  681.     @actor_face_window = Window_Top_Reader_Face.new(@actorx)
  682.     end
  683.  
  684.     case @type.upcase
  685.     when "DEFAULT"
  686.     else;
  687.       @info_window = Window_Top_Reader_Info.new(@actorx,@type,@infocontent)
  688.     end
  689.   end
  690.  
  691.   def restart
  692.     @window.dispose if @window
  693.     @actor_face_window.dispose if @actor_face_window
  694.     @info_window.dispose if @info_window
  695.     @window = nil if @window
  696.     @actor_face_window = nil if @actor_face_window
  697.     @info_window = nil if @info_window
  698.     create_reader_windows
  699.   end
  700.      
  701.   def update
  702.     super
  703.     @window.update
  704.     process_exit if Input.trigger?(:B) or Input.trigger?(:C)
  705.     process_down if Input.repeat?(:DOWN)
  706.     process_up if Input.repeat?(:UP)
  707.   end
  708.  
  709.   def process_exit
  710.       return if $imported["TH_SceneInterpreter"] == true && @interpreter.running?      
  711.       puts @common_event_after
  712.       Sound.play_cancel
  713.       #SceneManager.call(Scene_Map)
  714.       $game_switches[ESTRIOLE::TR_old_mode_switch] = false if @old_mode_one_time_only
  715.       return reserve_common_event(@common_event_after_id) if @common_event_after_id
  716.       SceneManager.return
  717.   end
  718.  
  719.   def reserve_common_event(id)
  720.       $game_temp.reserve_common_event(id)
  721.       $game_temp.notebook_entries_chosen = nil
  722.       $game_temp.notebook_categories_chosen = nil    
  723.       SceneManager.goto(Scene_Map)
  724.   end
  725.  
  726.   def process_down
  727.       return if $imported["TH_SceneInterpreter"] == true && @interpreter.running?      
  728.       Sound.play_cursor if (@window.oy + 272) < @window.contents.height
  729.       @window.oy += SCROLL_SPEED if (@window.oy + 272) < @window.contents.height
  730.   end
  731.  
  732.   def process_up
  733.       return if $imported["TH_SceneInterpreter"] == true && @interpreter.running?      
  734.       Sound.play_cursor if (@window.oy + 272) < @window.contents.height
  735.       @window.oy -= SCROLL_SPEED if @window.oy > 0
  736.   end  
  737.  
  738.   def scene_changing?
  739.     SceneManager.scene != self
  740.   end
  741. end
  742.  
  743. class Window_Top_Reader_Face < Window_Base
  744.   def initialize(actor)
  745.     super(0,0,116,116)
  746.     draw_actor_face(actor,0,0,true)
  747.   end
  748. end
  749.  
  750. class Window_Top_Reader_Info < Window_Base
  751.   def initialize(actor,type,infocontent)
  752.     if actor == nil
  753.     super(0,0,Graphics.width,116)
  754.     @infowidth = Graphics.width
  755.     else
  756.     super(116,0,Graphics.width-116,116)
  757.     @infowidth = Graphics.width - 116
  758.     end
  759.     case type.upcase
  760.     when "SIMPLE_STATUS"
  761.       draw_actor_simple_status(actor, 10, 10) if actor != nil
  762.     when "TEXT_TITLE"
  763.       make_font_bigger
  764.       make_font_bigger if actor == nil
  765.       change_color(text_color(6))
  766.       draw_text(0, 28, @infowidth - 40, 40, infocontent, 1) if actor == nil
  767.       draw_text(0, 32, @infowidth - 40, 32, infocontent, 1) if actor != nil
  768.       reset_font_settings
  769.     else;
  770.     end
  771.   end
  772. end
  773.  
  774. class Window_Reader < Window_Base
  775.   #include ATS_Formatting_WindowMessage
  776.   attr_accessor :firstline, :nowline
  777.  
  778.   def initialize(text,actorx,type,size)
  779.     if actorx == nil
  780.       case type.upcase
  781.         when "DEFAULT"
  782.           super(0,0,Graphics.width,Graphics.height)
  783.         else;
  784.           super(0,116,Graphics.width,Graphics.height - 116)
  785.       end
  786.     else
  787.       case type.upcase
  788.         when "DEFAULT"
  789.           super(0,0,Graphics.width,Graphics.height)
  790.         else;
  791.           super(0,116,Graphics.width,Graphics.height - 116)    
  792.       end
  793.     end
  794.  
  795.     @font_size = size
  796.     @firstline = @nowline = 0
  797.     @text = text
  798.     @align = 0
  799.     @line_index = 0
  800.     draw_text_reader
  801.   end
  802.  
  803.  
  804.   def update
  805.     if self.openness < 255
  806.       self.openness += Text_Reader::OPEN_SPEED
  807.     end
  808.   end
  809.  
  810.   def draw_text_reader
  811.     self.contents = Bitmap.new(width - 32, @text.size * (@font_size) + 32) if (@font_size && !($imported[:ve_sfonts] && Victor_Engine::VE_ALL_SFONT))
  812.     self.contents = Bitmap.new(width - 32, @text.size * 24 + 32) if !(@font_size && !($imported[:ve_sfonts] && Victor_Engine::VE_ALL_SFONT))
  813.     self.contents.font.size = @font_size if @font_size && !($imported[:ve_sfonts] && Victor_Engine::VE_ALL_SFONT)
  814.     a = contents.sfont = $sfont[0] if Victor_Engine::VE_ALL_SFONT rescue nil
  815.     @line_index = 0
  816.     for i in 0..@text.size
  817.       if @text[i] == nil
  818.       else
  819.         text = decorate_text(@text[i])
  820.         if $game_switches[ESTRIOLE::TR_old_mode_switch] == true
  821.           self.contents.draw_text(0, @line_index * self.contents.font.size, width - 32, 24, text, @align)
  822.         else
  823.           self.draw_text_ex_mod(0, @line_index * self.contents.font.size, text)
  824.         end
  825.       end
  826.       @line_index += 1
  827.     end      
  828.   end
  829.  
  830.   def draw_text_ex_mod(x, y, text)
  831.     #reset_font_settings
  832.     text = convert_escape_characters(text)
  833.     text_width = text_size(text).width
  834.     win_width = width - 2 * standard_padding - 6
  835.     case @align
  836.     when 1
  837.       #center align
  838.       x = x + (win_width - text_width)/2
  839.     when 2
  840.       #right align
  841.       x = x + win_width - text_width
  842.     else
  843.       #left align so do nothing
  844.     end
  845.     @pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  846.     process_character(text.slice!(0, 1), text, @pos) until text.empty?
  847.   end
  848.  
  849.   def process_normal_character(c, pos)
  850.     text_width = text_size(c).width
  851.     draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c)
  852.     pos[:x] += text_width
  853.   end
  854.  
  855.  
  856.   def decorate_text(text)
  857.      a = text.scan(/(\[\/b\])/)
  858.      if $1.to_s != ""
  859.        self.contents.font.bold = false
  860.        text.sub!(/\[\/b\]/) {}
  861.      end
  862.      
  863.      a = text.scan(/(\[b\])/)
  864.      if $1.to_s != ""
  865.        self.contents.font.bold = true
  866.        text.sub!(/\[b\]/) {}
  867.      end
  868.      
  869.     a = text.scan(/(\[\/i\])/)
  870.      if $1.to_s != ""
  871.        self.contents.font.italic = false
  872.        text.sub!(/\[\/i\]/) {}
  873.      end
  874.      
  875.      a = text.scan(/(\[i\])/)
  876.      if $1.to_s != ""
  877.        self.contents.font.italic = true
  878.        text.sub!(/\[i\]/) {}
  879.      end
  880.      
  881.      a = text.scan(/(\[\/s\])/)
  882.      if $1.to_s != ""
  883.        self.contents.font.shadow = false
  884.        text.sub!(/\[\/s\]/) {}
  885.      end
  886.      
  887.      a = text.scan(/(\[s\])/)
  888.      if $1.to_s != ""
  889.        self.contents.font.shadow = true
  890.        text.sub!(/\[s\]/) {}
  891.      end
  892.      
  893.      a = text.scan(/(\[cen\])/)
  894.      if $1.to_s != ""
  895.        @align = 1
  896.        text.sub!(/\[cen\]/) {}
  897.      end
  898.      
  899.     a = text.scan(/(\[left\])/)
  900.      if $1.to_s != ""
  901.        @align = 0
  902.        text.sub!(/\[left\]/) {}
  903.      end
  904.      
  905.     a = text.scan(/(\[right\])/)
  906.      if $1.to_s != ""
  907.        @align = 2
  908.        text.sub!(/\[right\]/) {}
  909.      end
  910.      
  911.      return text
  912.   end
  913. end
  914.  
  915. ######################## below is the note book section ########################
  916.  
  917. #==============================================================================
  918. # ** Game_System
  919. #------------------------------------------------------------------------------
  920. #  This class handles system data. It saves the disable state of saving and
  921. # menus. Instances of this class are referenced by $game_system.
  922. #==============================================================================
  923.  
  924. class Game_System
  925.   #--------------------------------------------------------------------------
  926.   # Public Instance Variables
  927.   #--------------------------------------------------------------------------
  928.   attr_accessor :notebook_entries
  929.   attr_accessor :notebook_categories
  930.   attr_accessor :notebook_sort_mode
  931.  
  932.   #--------------------------------------------------------------------------
  933.   # Alias listing
  934.   #--------------------------------------------------------------------------
  935.   alias jet1835_initialize initialize
  936.   #--------------------------------------------------------------------------
  937.   # * Object Initialization
  938.   #--------------------------------------------------------------------------
  939.   def initialize(*args, &block)
  940.     @notebook_entries = []
  941.     @notebook_categories = ESTRIOLE::START_CATEGORY rescue []
  942.     @notebook_categories = [] if !@notebook_categories.is_a?(Array)
  943.     jet1835_initialize(*args, &block)
  944.   end
  945. end
  946.  
  947. class Game_Temp
  948.   attr_accessor :notebook_entries_count
  949.   attr_accessor :notebook_categories_count
  950.   attr_accessor :notebook_entries_chosen
  951.   attr_accessor :notebook_categories_chosen
  952. end
  953.  
  954. #==============================================================================
  955. # ** Game_Interpreter
  956. #------------------------------------------------------------------------------
  957. #  An interpreter for executing event commands. This class is used within the
  958. # Game_Map, Game_Troop, and Game_Event classes.
  959. #==============================================================================
  960.  
  961. class Game_Interpreter
  962.   #--------------------------------------------------------------------------
  963.   # * Add Notebook Entry to Database
  964.   #--------------------------------------------------------------------------
  965.   def add_entry(filename)
  966.     unless $game_system.notebook_entries.include?(filename)
  967.       if ESTRIOLE::USE_RVDATA_FILE
  968.         file = load_data("Data/Notebook.rvdata2")[filename + ".txt"]
  969.         test = true if file
  970.       else
  971.         test = FileTest.file?("#{ESTRIOLE::TEXT_FOLDER}#{filename}.txt")
  972.       end      
  973.       $game_system.notebook_entries.push(filename) if test
  974.     end
  975.   end
  976.   def rem_entry(filename)
  977.     $game_system.notebook_entries.delete(filename)
  978.   end
  979.   #--------------------------------------------------------------------------
  980.   # * Add Notebook Category to Database
  981.   #--------------------------------------------------------------------------
  982.   def add_category(cat_name)
  983.     $game_system.notebook_categories.push(cat_name) unless $game_system.notebook_categories.include?(cat_name)
  984.   end
  985.   def rem_category(cat_name)
  986.     $game_system.notebook_categories.delete(cat_name)
  987.   end
  988.   #--------------------------------------------------------------------------
  989.   # * Activate Notebook Scene
  990.   #--------------------------------------------------------------------------
  991.   def goto_notebook
  992.     SceneManager.call(Scene_Notebook)
  993.   end
  994. end
  995.  
  996. #==============================================================================
  997. # ** Scene_Title
  998. #------------------------------------------------------------------------------
  999. #  This class performs the title screen processing.
  1000. #==============================================================================
  1001.  
  1002. class Scene_Title
  1003.   #--------------------------------------------------------------------------
  1004.   # Alias listing
  1005.   #--------------------------------------------------------------------------
  1006.   alias jet1934_initialize initialize unless $@
  1007.   #--------------------------------------------------------------------------
  1008.   # * Object Initialization
  1009.   #--------------------------------------------------------------------------
  1010.   def initialize(*args, &block)
  1011.     convert_txt if ESTRIOLE::DO_CONVERSION_TO_RVDATA && $TEST
  1012.     jet1934_initialize(*args, &block)
  1013.   end
  1014.   #--------------------------------------------------------------------------
  1015.   # * Convert text from .txt to .rvdata2
  1016.   #--------------------------------------------------------------------------
  1017.   def convert_txt
  1018.     file = Dir.entries("Notebook")
  1019.     file.reverse!
  1020.     2.times {|i| file.pop }
  1021.     file.reverse!
  1022.     if file.empty?
  1023.       p "No files found in Notebook, aborting conversion process."
  1024.     end
  1025.     text_hash = {}
  1026.     for txt in file
  1027.       text_hash[txt] = File.open("#{ESTRIOLE::TEXT_FOLDER}#{txt}", "r") {|a| a.read}
  1028.     end
  1029.     b = File.new("Data/Notebook.rvdata2", "wb")
  1030.     Marshal.dump(text_hash, b)
  1031.     b.close
  1032.     p "Notebook file successfully converted."
  1033.   end
  1034. end
  1035.  
  1036. #==============================================================================
  1037. # ** Scene_Gameover
  1038. #------------------------------------------------------------------------------
  1039. #  The string class. Can handle character sequences of arbitrary lengths.
  1040. # See String Literals for more information.
  1041. #==============================================================================
  1042.  
  1043. class String
  1044.   #--------------------------------------------------------------------------
  1045.   # * Split to each word
  1046.   #--------------------------------------------------------------------------
  1047.   def each_word
  1048.     array = self.split(" ")
  1049.     if block_given?
  1050.       array.each {|a| yield a }
  1051.     else
  1052.       return array
  1053.     end
  1054.   end
  1055. end
  1056.  
  1057. #==============================================================================
  1058. # ** Window_Notebook
  1059. #------------------------------------------------------------------------------
  1060. #  This window displays the note currently open. reserved maybe for something else
  1061. #==============================================================================
  1062.  
  1063. class Window_Notebook_Desc < Window_Help
  1064.   def set_text(text)
  1065.     if text != @text
  1066.       @text = text
  1067.       refresh
  1068.     end
  1069.   end
  1070.   def refresh
  1071.     contents.clear
  1072.     draw_text(0, 0, width,24,@text,1)
  1073.   end  
  1074. end
  1075.  
  1076.  
  1077. class Window_Sort < Window_Command
  1078.   def update
  1079.     super
  1080.     return unless @command_window
  1081.     return unless open? && active
  1082.     old_sort = @command_window.sort
  1083.     @command_window.sort = current_data[:name] if old_sort != current_data[:name]
  1084.   end
  1085.   def select_name(name)
  1086.     @list.each_index {|i| select(i) if @list[i][:name].upcase == name.upcase }
  1087.   end
  1088.   def window_width
  1089.     return Graphics.width/2
  1090.   end
  1091.   def command_window=(command_window)
  1092.     return if @command_window == command_window
  1093.     @command_window = command_window
  1094.     refresh
  1095.   end
  1096.   def alignment
  1097.     return 0
  1098.   end
  1099.   def make_command_list
  1100.     sorting = ESTRIOLE::SORTING_RULE.keys
  1101.     for sort in sorting
  1102.       add_command(sort, :sort)
  1103.     end
  1104.   end
  1105. end
  1106.  
  1107. class Window_CatCommand < Window_Command
  1108.   def select_name(name)
  1109.     @list.each_index {|i| select(i) if @list[i][:name].upcase == name.upcase }
  1110.   end
  1111.   def window_width
  1112.     return Graphics.width
  1113.   end
  1114.   def alignment
  1115.     return 0
  1116.   end
  1117.   def make_command_list
  1118.     categories = $game_system.notebook_categories
  1119.     for cat in categories
  1120.       add_command(cat, :cat)
  1121.     end
  1122.     $game_temp.notebook_categories_count = categories.size
  1123.   end
  1124. end
  1125.  
  1126. #==============================================================================
  1127. # ** Window_NoteCommand
  1128. #------------------------------------------------------------------------------
  1129. #  This window is the selection window for the notebook entries.
  1130. #==============================================================================
  1131.  
  1132. class Window_NoteCommand < Window_Command
  1133.   def select_name(name)
  1134.     @list.each_index {|i| select(i) if @list[i][:name].upcase == name.upcase }
  1135.   end
  1136.  
  1137.   def window_width
  1138.     return Graphics.width
  1139.   end
  1140.   def alignment
  1141.     return 0
  1142.   end
  1143.   def cat
  1144.     @cat
  1145.   end
  1146.   def cat=(cat)
  1147.     return if @cat == cat
  1148.     @cat = cat
  1149.     refresh
  1150.   end
  1151.   def sort
  1152.     @sort
  1153.   end
  1154.   def sort=(sort)
  1155.     return if @sort == sort
  1156.     @sort = sort
  1157.     refresh
  1158.   end
  1159.   alias est_mags_process_handling process_handling
  1160.   def process_handling
  1161.     return unless open? && active
  1162.     est_mags_process_handling
  1163.     return call_handler(:shift) if handle?(:shift)   && Input.trigger?(:A)
  1164.   end    
  1165.   #--------------------------------------------------------------------------
  1166.   # * Form list of commands
  1167.   #--------------------------------------------------------------------------
  1168.   def make_command_list
  1169.     @cat = ESTRIOLE::ALL_TXT_CATEGORY.sample if !@cat
  1170.     entries = $game_system.notebook_entries.select {|entry|
  1171.     cat = ESTRIOLE::FILE_READER_SETTING[entry][:category].collect{|c| c.upcase} rescue ESTRIOLE::DEFAULT_TXT_CATEGORY.collect{|c| c.upcase}
  1172.     cat = cat + ESTRIOLE::ALL_TXT_CATEGORY.collect{|c| c.upcase}
  1173.     cat.uniq!
  1174.     a = cat.include?(@cat.upcase) rescue false
  1175.     }    
  1176.     if @sort
  1177.      chk = eval(ESTRIOLE::SORTING_RULE[@sort]) rescue nil
  1178.     end        
  1179.     for entry in entries
  1180.       add_command(entry, :entry)
  1181.     end
  1182.     $game_temp.notebook_entries_count = entries.size
  1183.   end
  1184. end
  1185.  
  1186. #==============================================================================
  1187. # ** Window_Entries
  1188. #------------------------------------------------------------------------------
  1189. #  This window displays the number of entries in the notebook database.
  1190. #==============================================================================
  1191.  
  1192. class Window_Entries < Window_Base
  1193.   #--------------------------------------------------------------------------
  1194.   # * Object Initialization
  1195.   #--------------------------------------------------------------------------
  1196.   def on_entry=(on_entry)
  1197.     return if @on_entry == on_entry
  1198.     @on_entry = on_entry
  1199.     refresh
  1200.   end  
  1201.   def initialize
  1202.     super(0, Graphics.height - 48, 160, 48)
  1203.     refresh
  1204.   end
  1205.   def update
  1206.     super
  1207.     refresh if @old_entries_size != $game_temp.notebook_entries_count
  1208.     @old_entries_size = $game_temp.notebook_entries_count
  1209.   end
  1210.   #--------------------------------------------------------------------------
  1211.   # * Refresh window
  1212.   #--------------------------------------------------------------------------
  1213.   def refresh
  1214.     $game_temp.notebook_entries_count = 0 if !$game_temp.notebook_entries_count
  1215.     $game_temp.notebook_categories_count = 0 if !$game_temp.notebook_entries_count
  1216.     contents.clear
  1217.     contents.font.color = system_color
  1218.     no_category = false
  1219.     no_category = true if !$game_system.notebook_categories || $game_system.notebook_categories.size == 0
  1220.     text = @on_entry || no_category ? "Entries:" : "Categories:"    
  1221.     number = @on_entry || no_category ? $game_temp.notebook_entries_count : $game_temp.notebook_categories_count
  1222.     contents.draw_text(0, 0, 100, 24, text)
  1223.     contents.font.color = normal_color
  1224.     contents.draw_text(104, 0, 40, 24, number, 1)
  1225.   end
  1226. end
  1227.  
  1228. class Window_Notebook_Title < Window_Base
  1229.   def initialize(line_number = 2,twh = nil)
  1230.     @wh = twh.nil?? Graphics.width : twh
  1231.     super(0, 0, @wh, fitting_height(line_number))
  1232.   end
  1233.  
  1234.   def set_text(text)
  1235.     if text != @text
  1236.       @text = text
  1237.       refresh
  1238.     end
  1239.   end
  1240.  
  1241.   def clear
  1242.     set_text("")
  1243.   end
  1244.  
  1245.   def set_item(item)
  1246.     set_text(item ? item.description : "")
  1247.   end
  1248.  
  1249.   def refresh
  1250.     contents.clear
  1251.     draw_text(-24, 0, @wh,24,@text,2)
  1252.   end
  1253.  
  1254. end
  1255.  
  1256.  
  1257. class Scene_Notebook < Scene_Base
  1258.   #--------------------------------------------------------------------------
  1259.   # * Start Processing
  1260.   #--------------------------------------------------------------------------
  1261.   def start
  1262.     #if $game_system.notebook_entries.empty?
  1263.     #  return_scene
  1264.     #end
  1265.     super
  1266.     create_background if $mog_rgss3_wallpaper_ex == true    
  1267.     @help_window = Window_Help.new
  1268.     @no_category = true if !$game_system.notebook_categories || $game_system.notebook_categories.size == 0
  1269.    
  1270.     @command_window = Window_NoteCommand.new(0, 0)
  1271.     @command_window.set_handler(:ok,     method(:on_text_list_ok))
  1272.     @command_window.set_handler(:cancel, method(:on_text_list_cancel))
  1273.     @command_window.set_handler(:shift, method(:on_text_list_shift))
  1274.     @command_window.height = Graphics.height - 110
  1275.     @command_window.y = @help_window.height
  1276.     @command_window.sort = $game_system.notebook_sort_mode
  1277.     #test    
  1278.    
  1279.     @entries_window = Window_Entries.new
  1280.     @command_window.height = Graphics.height - (@entries_window.height +
  1281.     @help_window.height)
  1282.  
  1283.     @command_window.hide.deactivate
  1284.    
  1285.     @cat_window = Window_CatCommand.new(0,0)
  1286.     @cat_window.set_handler(:ok,     method(:on_cat_list_ok))
  1287.     @cat_window.set_handler(:cancel,     method(:return_scene))
  1288.     @cat_window.height = @command_window.height
  1289.     @cat_window.y = @command_window.y
  1290.    
  1291.     twh = Graphics.width - @entries_window.width
  1292.     @title_window = Window_Notebook_Title.new(1,twh)
  1293.     @title_window.x = @entries_window.width
  1294.     @title_window.y = @help_window.height + @command_window.height
  1295.     @title_window.set_text(ESTRIOLE::NOTEBOOK_NAME) if !@no_category
  1296.     @title_window.set_text("Press Shift to sort Entries") if @no_category
  1297.    
  1298.     @help_text = ""
  1299.     @help_window.set_text(@help_text)
  1300.     straight_to_entry if @no_category
  1301.     select_last
  1302.    
  1303.     @sort_window = Window_Sort.new(Graphics.width/2 - (Graphics.width/4),0)
  1304.     @sort_window.y = @command_window.y + (@command_window.height-@sort_window.height)/2
  1305.     @sort_window.command_window = @command_window
  1306.     @sort_window.set_handler(:ok,     method(:on_sort_list_ok))
  1307.     @sort_window.set_handler(:cancel,     method(:on_sort_list_cancel))
  1308.     @sort_window.hide.deactivate
  1309.   end
  1310.  
  1311.   def on_text_list_shift
  1312.     @command_window.deactivate
  1313.     @sort_window.show.activate
  1314.     Input.update
  1315.   end
  1316.  
  1317.   def on_sort_list_ok
  1318.     $game_system.notebook_sort_mode = @sort_window.current_data[:name]
  1319.     @command_window.sort = $game_system.notebook_sort_mode
  1320.     @sort_window.hide.deactivate
  1321.     @command_window.activate
  1322.   end
  1323.   def on_sort_list_cancel
  1324.     @command_window.sort = $game_system.notebook_sort_mode
  1325.     @sort_window.hide.deactivate
  1326.     @command_window.activate    
  1327.   end
  1328.  
  1329.   def straight_to_entry
  1330.     @cat_window.hide.deactivate
  1331.     @command_window.show.activate
  1332.     @on_entry = true
  1333.   end
  1334.   def select_last
  1335.     @cat_window.select_name($game_temp.notebook_categories_chosen) if $game_temp.notebook_categories_chosen
  1336.     @command_window.cat = @cat_window.current_data[:name] if $game_temp.notebook_categories_chosen
  1337.     @command_window.select_name($game_temp.notebook_entries_chosen) if $game_temp.notebook_entries_chosen    
  1338.     @cat_window.hide.deactivate if $game_temp.notebook_entries_chosen    
  1339.     @command_window.show.activate if $game_temp.notebook_entries_chosen
  1340.   end
  1341.   #--------------------------------------------------------------------------
  1342.   # * Frame update
  1343.   #--------------------------------------------------------------------------
  1344.   def update
  1345.     old_index = @command_window.index
  1346.     super    
  1347.     if @on_entry
  1348.     file = @command_window.current_data[:name] if @command_window.current_data
  1349.     setting = ESTRIOLE::FILE_READER_SETTING[file] if file
  1350.     @help_text = ESTRIOLE::DEFAULT_NOTEBOOK_FILE_DESC
  1351.     @help_text = setting[:desc] if setting[:desc] if setting
  1352.     @help_text = ESTRIOLE::NOTEBOOK_NO_ENTRY_DESC if !file
  1353.     @title_window.set_text("Press Shift to sort Entries")
  1354.     @entries_window.on_entry = @on_entry
  1355.     @help_window.set_text(@help_text)      
  1356.     else
  1357.     return if @no_category
  1358.     @entries_window.on_entry = @on_entry
  1359.     cat = @cat_window.current_data[:name] if @command_window.current_data
  1360.     @help_text = ESTRIOLE::CATEGORY_HELP_TEXT[cat] ? ESTRIOLE::CATEGORY_HELP_TEXT[cat] : ESTRIOLE::CATEGORY_DEFAULT_HELP_TEXT
  1361.     @title_window.set_text(ESTRIOLE::NOTEBOOK_NAME)
  1362.     @help_window.set_text(@help_text)      
  1363.     end
  1364.   end
  1365.    
  1366.   def on_text_list_ok
  1367.     return if !@command_window.current_data
  1368.     @command_window.activate
  1369.     file = @command_window.current_data[:name]
  1370.     setting = ESTRIOLE::FILE_READER_SETTING[file]
  1371.     if setting
  1372.       type = setting[:type]
  1373.       face = setting[:face_id]
  1374.       text = setting[:text_title]
  1375.       font_size = setting[:font_size]
  1376.       old_mode = setting[:old_mode]
  1377.       common_event_id = setting[:common_event]
  1378.       common_event_after_id = setting[:common_event_after]
  1379.     end
  1380.     puts common_event_after_id
  1381.     $game_temp.notebook_entries_chosen = @command_window.current_data[:name]
  1382.     SceneManager.call(Text_Reader)
  1383.     SceneManager.scene.set_file(file)
  1384.     SceneManager.scene.set_type(type)
  1385.     SceneManager.scene.set_face(face)
  1386.     SceneManager.scene.set_text_title(text)
  1387.     SceneManager.scene.set_font_size(font_size) if font_size  
  1388.     SceneManager.scene.set_old_mode if old_mode        
  1389.     SceneManager.scene.set_common_event(common_event_id) if common_event_id
  1390.     SceneManager.scene.set_common_event_after(common_event_after_id) if common_event_after_id
  1391.   end
  1392.   def on_text_list_cancel
  1393.     $game_temp.notebook_entries_chosen = nil
  1394.     on_cat_list_cancel if @no_category
  1395.     @command_window.hide.deactivate
  1396.     @on_entry = false
  1397.     @cat_window.show.activate
  1398.   end
  1399.  
  1400.   def on_cat_list_ok
  1401.     $game_temp.notebook_categories_chosen = @cat_window.current_data[:name]
  1402.     @cat_window.hide.deactivate
  1403.     @on_entry = true
  1404.     old_cat = @command_window.cat
  1405.     @command_window.cat = @cat_window.current_data[:name]
  1406.     @command_window.select(0) if old_cat != @command_window.cat
  1407.     @command_window.show.activate
  1408.   end
  1409.   def on_cat_list_cancel
  1410.     $game_temp.notebook_categories_chosen = nil    
  1411.     return_scene
  1412.   end
  1413.  
  1414. end
  1415.  
  1416.  
  1417. #yami pop message compatibility
  1418. if $imported["YES-PopMessage"] == true
  1419. class Window_Message < Window_Base
  1420.   attr_reader :face_window
  1421.   def close_and_wait
  1422.     @face_window.hide_face if @face_window
  1423.     @bubble_sprite.opacity = 0 if @bubble_sprite
  1424.     yes_pop_message_close_and_wait
  1425.     cancel_pop_message
  1426.   end  
  1427. end
  1428. class Scene_Map
  1429.   alias est_notebook_yami_pop_patch_terminate terminate
  1430.   def terminate
  1431.   est_notebook_yami_pop_patch_terminate  
  1432.   chk = @message_window.face_window.dispose rescue nil
  1433.   end
  1434. end
  1435. end
  1436.  
  1437. #victor sfont safeguard method (when bitmap didn't use sfont it won't crash)
  1438.  
  1439. if $imported[:ve_sfonts]
  1440. class Window_Base < Window
  1441.   def change_color(color, enabled = true)
  1442.     change_color_ve_sfont(color, enabled)
  1443.     contents.sfont.alpha = enabled ? 255 : translucent_alpha if contents.sfont
  1444.   end  
  1445. end
  1446. end
  1447.  
  1448. if $imported["Galv_Menu_Themes"]
  1449. class Scene_Notebook < Scene_Base
  1450.   include Check_Theme
  1451.    
  1452.   alias est_gmenu_engine_sb_start start
  1453.   def start
  1454.     est_gmenu_engine_sb_start
  1455.     if SceneManager.themed_scene
  1456.       $game_temp.themed_scene = true
  1457.       create_background
  1458.       create_theme_backgrounds
  1459.     end
  1460.   end
  1461.  
  1462.   def create_background
  1463.     @background_sprite = Sprite.new
  1464.     @background_sprite.bitmap = SceneManager.background_bitmap
  1465.     @background_sprite.color.set(16, 16, 16, 128)
  1466.   end
  1467.  
  1468.  
  1469.   def create_theme_backgrounds
  1470.     create_background1
  1471.     create_themebg2
  1472.   end
  1473.    
  1474.   def create_background1
  1475.     @background1 = Plane.new
  1476.     @background1.bitmap = Cache.gmenu(name + "_Background",$game_system.menu_theme) rescue
  1477.       Cache.gmenu("Background",$game_system.menu_theme)
  1478.     @background1.opacity = mtheme::BACK1_OPACITY
  1479.     @background1.z = -1
  1480.     @background_sprite.z = -2
  1481.   end
  1482.    
  1483.   def create_themebg2
  1484.     @themebg2 = Sprite.new
  1485.     if !SceneManager.scene_is?(Scene_Menu)
  1486.       @themebg2.bitmap = Cache.gmenu(name + "_Background2",$game_system.menu_theme) rescue
  1487.       Cache.gmenu("Scene_Generic_Background2",$game_system.menu_theme) rescue
  1488.       nil
  1489.     end
  1490.     @themebg2.opacity = mtheme::SCENE_BACK_OPACITY
  1491.     if @themebg2.bitmap
  1492.       @themebg2.x = [(Graphics.width - @themebg2.bitmap.width) / 2,0].max
  1493.     end
  1494.     @themebg2.z = 0
  1495.   end
  1496.    
  1497.   alias est_gmenu_engine_sb_update update
  1498.   def update
  1499.     est_gmenu_engine_sb_update
  1500.     if @background1
  1501.       @background1.ox -= mtheme::BACK1_XY[0]
  1502.       @background1.oy -= mtheme::BACK1_XY[1]
  1503.     end
  1504.   end
  1505.    
  1506.   alias est_gmenu_engine_sb_terminate terminate
  1507.   def terminate
  1508.     est_gmenu_engine_sb_terminate
  1509.     $game_temp.themed_scene = false
  1510.     @background1.dispose if @background1
  1511.     @themebg2.dispose if @themebg2
  1512.   end
  1513.    
  1514.   def name
  1515.     if self.to_s =~ /#<(.*):/i
  1516.       return $1
  1517.     else
  1518.       return ""
  1519.     end
  1520.   end
  1521. end # Scene_Base
  1522.  
  1523. end #end imported galv menu themes
  1524.  
  1525. #===============================================================================
  1526. #
  1527. # END OF SCRIPT
  1528. #
  1529. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment