CrowMakerVX

Gamepedia2.0

Feb 3rd, 2013
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 31.53 KB | None | 0 0
  1. ################################################################################
  2. #                             Gamepedia 2.0
  3. #                             By: Ixfuru
  4. #                        2.0 released Feb 3, 2013
  5. ################################################################################
  6.  
  7. ################################################################################
  8. #
  9. #   This script creates a scene of selectable windows that can display
  10. # information that you supply it.  It would be ideal for creating a how to guide,
  11. # or a good place to put credits.  You can basically use it as you wish, but I
  12. # created it as a personal need to provide an 'encyclopedia' for my project,
  13. # where one can look up and reference abbreviations, controls and other such
  14. # items that the player may need without the aid of an instruction manual.  
  15. # Follow the instructions in each section within the "CUSTOMIZATION SECTION"s to
  16. # set up what you want displayed.  I'll be using not only layman's terms for
  17. # those who want to 'use' the script, but I'll try to add some scripting info
  18. # as well so that someone who wants to add on to it, or get an idea from it, will
  19. # understand how I did the things I did.
  20. #
  21. # To call the scene, you just use the 'script' command on the third page inside
  22. # an event and enter:
  23. #
  24. #          $scene = Scene_Gamepedia.new
  25. #
  26. ################################################################################
  27. #
  28. ################################################################################
  29. #      THIS SCRIPT REQUIRES ModernAlgebra's ParagraphFormatter Script, which
  30. # can be found here:
  31. #
  32. #               http://rmrk.net/index.php/topic,25129.0.html
  33. #
  34. # You must abide by the rules and license statement on this page if you use his
  35. # script in conjunction with this one.
  36. ################################################################################
  37.  
  38. #*******************************************************************************
  39. #
  40. # You can use this script for free NON-COMMERCIALLY.  If you intend to market
  41. # your project and want to include my script, please just give credit to IXFURU
  42. # somewhere in the game (Maybe in the Gamepedia) and contact me to discuss
  43. # if any compensation would be necessary.
  44. #
  45. #*******************************************************************************
  46.  
  47. #*******************************************************************************
  48. #                             OTHER CREDITS:
  49. # LoganF was a great help with two of the lingering bugs in the script.
  50. # ThallionDarkshine, Heretic86 and Mangomight for offering their assistance on
  51. # the some bugs, as well.
  52. #
  53. # ModernAlgebra for his Paragraph Formatter script, without which, the Entries
  54. # window is not functional.
  55. #
  56. # A sample windowskin by Cassy was used to show the capability to show different
  57. # skins in the scene.  If you use this skin in your project, you must credit her.
  58. #
  59. # Here is a link to her other skins:
  60. #
  61. # http://www.rpgmakervx.net/index.php?showtopic=7859
  62. #
  63. # In GAMEPEDIA 2.0, special credit goes to both Johnny0798 and trakel, for it was
  64. # only after their suggestion that hidden topics/subjects was implemented.
  65. #
  66. #*******************************************************************************
  67.  
  68.  
  69. module GAMEPEDIA
  70.  
  71.   ##############################################################################
  72.   #                 CUSTOMIZATION SECTION START
  73.   ##############################################################################
  74.  
  75.   #*************                  PHAZE 1                  *********************
  76.   # The first order of business is to add strings as "Subjects".  These strings
  77.   # will be visible as selectable options in the Gamepedia scene.  Each 'Subject'
  78.   # will have a number of child 'Topics' which you will set up later.  For this
  79.   # section, just add to the given array below with double-quoted (") words
  80.   # (strings).  The order in which these subjects are placed will not only be
  81.   # important in the rest of the setup, but will be referenced as selectable
  82.   # indexes in the scene.
  83.   #*****************************************************************************
  84.  
  85.   SUBJECTS = ["ANIMALS", "FOOD", "SPORTS", "CREDITS"]
  86.  
  87.   #*************                  PHAZE 2                  *********************
  88.   # Next, you need to set up the 'Topics' in the below hash.  You must use the
  89.   # following formula to set it up:
  90.   #
  91.   #                        subject_position => [topic1, topic2, etc],
  92.   #
  93.   # subject_position:
  94.   #
  95.   # This is where you will reference the subjects in the first
  96.   # array above.  As all arrays start with 0, not 1, you'll need to use '0' as
  97.   # your subject_position.  The word position was given to show that you are in
  98.   # essence taking the subject in the array above from the given position in the
  99.   # array.  The topics will change in the Gamepedia scene, according to which
  100.   # subject is highlighted.  
  101.   #
  102.   # topics:
  103.   # You can place anything as the topics in the array, as long as they
  104.   # are double-quoted.  These will be the selectable options in the Topics
  105.   # selectable window in the scene.  Their order in the array will also be
  106.   # the order in which they are displayed.  
  107.   #
  108.   # It is important that you END EVERY ARRAY with a comma (,).  
  109.   #*****************************************************************************
  110.  
  111.   TOPICS = {#<<<Don't delete this!
  112.  
  113.   0 => ["DOGS", "CATS", "CROWS", "SALAMANDERS", "FROGS"],
  114.   1 => ["APPLES", "ORANGES", "ICE CREAM"],
  115.   2 => ["FOOTBALL", "BASEBALL", "BOXING", "BASKETBALL", "BOWLING", "MARTIAL ARTS"],
  116.   3 => ["SCRIPT HELP", "MAD GENIUSES", "REQUIREMENTS"]
  117.        
  118.   }#<<<Don't delete this!
  119.  
  120.   #*************                  PHAZE 3                  *********************
  121.   # This section enables you to set up the displayable text (or information)
  122.   # about the selected topic in the Gamepedia scene.  In the hash, you need to
  123.   # add a single string, which will then be shown in the large window.  This
  124.   # will be the guts of the Gamepedia scene, where you set up just what you want
  125.   # to display.  Though there is no limit to the amount of words or characters
  126.   # one can use in the string, you'll need to remember, it must be double-quoted
  127.   # and end in a comma, like before.  In addition, the ids (number to the left of
  128.   # the "=>"), should be in numerical order and all displayable text should be
  129.   # kept in the order of the topics above.  For instance, if you have the topic
  130.   # set up as follows:
  131.   #
  132.   #                  0 => [stuff, morestuff, scratches_head],
  133.   #                  1 => [people, chicks, more_chicks],
  134.   #
  135.   # You would then want to set up the ENTRIES in the same order.  Like this:
  136.   #
  137.   # 0 => stuff about stuff
  138.   # 1 => more stuff about more stuff
  139.   # 2 => why are you scratching your head
  140.   # 3 => talk about people
  141.   # 4 => talking about chicks
  142.   # 5 => chicks rule!
  143.   #
  144.   # This will make more sense in the next phaze.  But this is VERY IMPORTANT.  
  145.   # Failure to follow these guidelines will cause displayed text to not match the
  146.   # selected topic.  It may wise to place commented divider lines between the
  147.   # displays for each topic.  So the above would look more like this:
  148.   #
  149.   # 0 => stuff about stuff
  150.   # 1 => more stuff about more stuff
  151.   # 2 => why are you scratching your head
  152.   #--------------------2-----------------------
  153.   # 3 => talk about people
  154.   # 4 => talking about chicks
  155.   # 5 => chicks rule!
  156.   #
  157.   # That way, you would be sure you were adding the displayable entires for section
  158.   # 2 in the correct location.
  159.   #*****************************************************************************
  160.  
  161.   ENTRIES = {#<<<Don't delete this!
  162.  
  163.  
  164.   #---------------------ANIMAL TOPICS------------------------------------------
  165.   0 =>  "The first pet I can remember having when I was a kid was a dog named GYPSY.  GYPSY helped me and my siblings escape a horse which was chasing us.  Ultimately, GYPSY got really sick and died.",
  166.   1 => "We had a cat once named MOSES.  It was an all-black cat.  It had big green eyes.  We named it MOSES, yet after several months, it became obvious, MOSES was a girl!  We never considered changing her name.",
  167.   2 => "I've always liked Crows.  As Poe was the Raven, I have always considered myself a vast pupil of his, and likened myself a crow.  I even made a project once about a Red Crow.",
  168.   3 => "I found a salamander one day while termite treating a house.  I took the salamader home.  Me and my brother built a box to keep it in.  I thought the light was too bright.  Only a day after we made the box, he disappeared.  Either he escaped, or fizzled away from the heat of the overhead light.",
  169.   4 => "I had a shirt once that said, Frogs are the birds of the night.  They give it a voice.  I've always liked frogs because of that.  On a side note, never dump your grease from fried frog legs on a bush outside your home.",
  170.  
  171.   #---------------------FOOD TOPICS----------------------------------------
  172.   5 => "Apples are pretty good.  However, whoever decided to couple them with cinamon, needs shot.  There's no worse pop tart on the market, and no two flavors together have ever turned my taste buds inside out more.",
  173.   6 => "The best way to enjoy an orange is in drink form.  The wife and I had screwdrivers on our honeymoon.  But I forget what happened after that.",
  174.   7 => "Ice Cream is perhaps the greatest of all desserts.  As long as it isn't Apple Cinamon.",
  175.  
  176.   #-------------------SPORTS TOPICS--------------------------------------------------
  177.   8 => "There's no sport better than American Football.  There's no team I love more than the Cleveland Browns.  One day, maybe we'll make it to the Superbowl.  Then the rest of the league will quit ignoring us.",
  178.   9 => "When I was a kid, I loved to play baseball.  I played everyday.  I watched the Indians every night I could.  And I played on the local little league teams during their seasons.  I was a pitcher and a firstbaseman.",
  179.   10 => "Why is it that there are no good American Heavyweights anymore?  Back in the day, you had Foreman, Tyson, Holyfield, Bowe and countless others.  Now, The Europeans put out much better Heavyweights.",
  180.   11 => "I've never liked Basketball very much.  I was never very good at it.  And I think the games a little too simple for my taste.",
  181.   12 => "Is bowling even a sport?   I dont know, but I sure love to bowl.  I'm no good at it, but I love it just the same.  I think my high score is like a 140-something.",
  182.   13 => "Martial Arts are cool.  I like the UFC and MMA in general.  What I don't like however, is when they just lay on each other for 15 minutes.  That sucks!",
  183.  
  184.   #-----------------CREDITS TOPICS----------------------------------------------
  185.   45 => "Gotta give some credit to those who helped me with this script.  Whether their assistance ended up being useful or not.  Sometimes overlooked is the amount of time it takes just to TRY and help someone.  I appreciate it LoganF, Mangomight, Heretic60, ThallionDarkshine and Hungrysnake.",
  186.   109 => "I've seen a lot of good VX scripts.  I just want to mention a few of my favorites.  One of whom's scripts is a necessity for this script.  ModernAlgebra, Jet, Yanfly and ???noBody???",
  187.   16 => "I require many things.  One of the things I require the most is Pepsi.  I also require (though I wish I could quit) Camel Lights.  RPGMaker is a bit of a requirement, too.",
  188.  
  189.   }#<<<Don't delete this!
  190.  
  191.   #*************                  PHAZE 4                  *********************
  192.   # In this phaze you will reference the subjects, by their positions, (just like
  193.   # in the TOPICS hash, and you will then give a high and lo value following a
  194.   # boolean (true or false).  Now, if you've followed directions precisely, you
  195.   # should be able to place 'true' as the boolean in the first position of all
  196.   # the following inner-hash arrays.   However, just because I know that some
  197.   # may have made an error, or wish to add more entries later, I wanted to add
  198.   # some type of solution to get you out of a jam without having to re-order
  199.   # the entries above.  Here's how this all comes together:
  200.   #
  201.   # subject_position => [boolean true, low, high] or
  202.   # subject_position => [boolean false, entry1, entry2, entry3, etc.]
  203.   #
  204.   # You place the values just like you did in the topics, telling the system that
  205.   # the entries in this range are to be shown when a topic in this subject is
  206.   # selected.  
  207.   # Next, the boolean will be the answer to the following question for each
  208.   # subject:  
  209.   #       "Are the entries in the same order as their topics?"
  210.   # If you answer the question, "yes", then you want to place true, if "no", you'll
  211.   # put false.  
  212.   # Low and High are values between and including the entry ids above where the
  213.   # system will search for the displayable text information.  If you select true
  214.   # for your boolean, then the system will display the text in numerical order
  215.   # pertaining to which ever topic you have currently selected.
  216.   # If by chance you used 'false' as your boolean, any following values will be
  217.   # direct reference to specific entries.  If this is your setup:
  218.   #
  219.   # credits => [false, 7, 12, 3, 5, 9],
  220.   #
  221.   # Then as you move the cursor down the selected topics, it will jump to the
  222.   # values you provided dependent upon index.  entry 7 will be displayed when
  223.   # the cursor is in index position 0, entry 12 will be displayed when in index
  224.   # 1, and so on...
  225.   #
  226.   #*****************************************************************************
  227.  
  228.   ENTRY_INDEXES = {#<<<Don't delete this!
  229.  
  230.   0 => [true, 0, 4],
  231.   1 => [true, 5, 7],
  232.   2 => [true, 8, 13],
  233.   3 => [false, 45, 109, 16],  # This line demonstrates that you don't have to have
  234.                                 # the topics in any particular order.
  235.  
  236.   }#<<<Don't delete this
  237.  
  238.   #*************                  PHAZE 5                  *********************
  239.   # The last part of the customization just allows you to change trivial values
  240.   # that will be used in deciding colors and text during the scene.  
  241.   #*****************************************************************************
  242.  
  243.   ENCYCLOPEDIA_TITLE = "GAMEPEDIA"
  244.   TITLE_COLOR = 14
  245.   TOPIC_HEADING_COLOR = 27
  246.   NEW_WINDOWSKIN = true #Set to false if you just want to use the project's default skin
  247.   GP_WINDOWSKIN = "CassyOldWoodSkin"  #You MUST credit "Cassy" if you use this skin
  248.   HIDDEN_COMMAND = "???????"
  249.   HIDDEN_ENTRY_TEXT = "No information, regarding this topic is currently available."
  250.   USE_FROM_MENU = true #Set to false if you don't want to access the scene from menu
  251.   GAMEPEDIA_MENU_COMMAND = "Gamepedia" #if above is true, what you want to be the command
  252.   #**************************SPECIAL COMMANDS***********************************
  253.   # The following commands can be used via script call (3rd page of event commands)
  254.   # and will offer methods to change existing Gamepedia Information.
  255.   #******************************************************************************
  256.   #  You can 'hide' a topics information by using the following:
  257.   #                     $gamepedia.mark_hidden_topic(subject_id, topic_index)
  258.   #
  259.   #
  260.   #  You can 'unhide' a topic and restore default by using:
  261.   #                      $gamepedia.reveal_topic(subject_id, topic_index)
  262.   #
  263.   # You can 'hide' a subject's information by using the following:
  264.   #                      $gamepedia.mark_hidden_subject(subject_id)
  265.   #
  266.   # You can 'unhide' a subject's information by using the following:
  267.   #                        $gamepedia.reveal_subject(subject_id)
  268.   #
  269.   ##############################################################################
  270.   #                         CUSTOMIZATION SECTION END
  271.   # If you alter anything below this point, you risk screwing things up.  
  272.   ##############################################################################
  273.  
  274.   ##############################################################################
  275.   #             !!!!!!!!!!!!!!!!!!!PLEASE READ!!!!!!!!!!!!
  276.   #
  277.   # Be careful when revealing and hiding SUBJECTS.   When you reveal a subject,
  278.   # all the topics of that subject will be revealed, as well.  And if you hide
  279.   # a subject, all the topics of that subject will be hidden.  So, if you want
  280.   # to reveal a subject, yet keep certain topics hidden, you'll have to use the
  281.   # 'mark_hidden_topic' script call on each of the topics which are to remain
  282.   # hidden after you reveal the subject.
  283.   #
  284.   ##############################################################################
  285.  
  286. end
  287.  
  288. ################################################################################
  289. #                     Gamepedia Class
  290. ################################################################################
  291.  
  292. class Gamepedia
  293.  
  294.   include GAMEPEDIA
  295.  
  296.   attr_accessor :subjects
  297.   attr_accessor :topics
  298.   attr_accessor :entries
  299.   attr_accessor :hidden_subjects
  300.   attr_accessor :hidden_topics
  301.  
  302.   def initialize
  303.     @subjects = SUBJECTS
  304.     @hidden_subjects = []
  305.     @hidden_topics = []
  306.     unless $game_temp.topics_declared
  307.       get_topics
  308.     end
  309.   end
  310.  
  311.   def get_topics
  312.     @topics = TOPICS
  313.     $game_temp.topics_declared = true
  314.   end
  315.  
  316.   def get_entries(subject) #receives the value from the current subject index.
  317.     entdex = ENTRY_INDEXES
  318.     entkeys = ENTRIES.keys
  319.     subnow = subject
  320.     tempent = []
  321.     if entdex[subnow][0] == true
  322.       lo = entdex[subnow][1]
  323.       hi = entdex[subnow][2]
  324.       for i in lo..hi
  325.         tempent.push(i)
  326.       end
  327.       @entries = tempent
  328.       @entries.sort
  329.     else
  330.       get_jumbled_entries(subnow)
  331.     end
  332.   end
  333.  
  334.   #  This method retrieves displayable text from topics whose text is not in order
  335.   def get_jumbled_entries(subject)
  336.     entdex = ENTRY_INDEXES
  337.     entkeys = ENTRIES.keys
  338.     subnow = subject
  339.     tempent = []
  340.     for key in entkeys
  341.       if entdex[subnow].include?(key)
  342.         tempent.push(key)
  343.       end
  344.     end
  345.     @entries = tempent
  346.   end
  347.  
  348.   def mark_hidden_topic(subject, topic)
  349.     @hidden_topics.push(@topics[subject][topic])
  350.   end
  351.  
  352.   def reveal_topic(subject, topic)
  353.     @hidden_topics.delete(@topics[subject][topic])
  354.   end
  355.    
  356.   def mark_hidden_subject(subject)
  357.     @hidden_subjects.push(@subjects[subject])
  358.     for i in 0...@topics[subject].size
  359.       unless @hidden_topics.include?(@topics[subject][i])
  360.         @hidden_topics.push(@topics[subject][i])
  361.       end
  362.     end
  363.   end
  364.  
  365.   def reveal_subject(subject)
  366.     @hidden_subjects.delete(@subjects[subject])
  367.     for i in 0...@topics[subject].size
  368.       @hidden_topics.delete(@topics[subject][i])
  369.     end
  370.   end
  371.  
  372. end
  373.  
  374. ################################################################################
  375. #                         GAME TEMP
  376. ################################################################################
  377.  
  378. class Game_Temp
  379.  
  380.   attr_accessor :last_pediasubject
  381.   attr_accessor :pedia_menu
  382.   attr_accessor :topics_declared
  383.  
  384.   alias nqenc_gtemp_initialize initialize unless $@
  385.   def initialize
  386.     nqenc_gtemp_initialize
  387.     @last_pediasubject = 0
  388.     @pedia_menu = false
  389.     @topics_declared = false
  390.   end
  391.  
  392. end
  393.  
  394. ################################################################################
  395. #                    WINDOW: SUBJECTS COMMANDS
  396. ################################################################################
  397.  
  398. class Window_PediaSubjects < Window_Selectable
  399.  
  400.   include GAMEPEDIA
  401.  
  402.   def initialize(x, y)
  403.     super(x, y, 120, 416)
  404.     @item_max = $gamepedia.subjects.size
  405.     @commands = $gamepedia.subjects
  406.     if NEW_WINDOWSKIN
  407.       self.windowskin = Cache.system(GP_WINDOWSKIN)
  408.     end
  409.     refresh
  410.     self.index = $game_temp.last_pediasubject
  411.   end
  412.  
  413.   def refresh
  414.     self.contents.clear
  415.     for i in 0...@item_max
  416.       draw_item(i)
  417.     end
  418.   end
  419.  
  420.   def draw_item(index, enabled = true)
  421.     rect = item_rect(index)
  422.     rect.x += 4
  423.     rect.width -= 8
  424.     self.contents.font.color = normal_color
  425.     self.contents.font.size = 12
  426.     if $gamepedia.hidden_subjects.include?($gamepedia.subjects[index])
  427.       self.contents.draw_text(rect, HIDDEN_COMMAND)
  428.     else
  429.       self.contents.draw_text(rect, @commands[index])
  430.     end
  431.   end
  432.  
  433. end
  434.  
  435. ################################################################################
  436. #                 WINDOW: TOPICS COMMANDS
  437. ################################################################################
  438.  
  439. class Window_PediaTopics < Window_Selectable
  440.  
  441.   include GAMEPEDIA
  442.  
  443.   attr_writer :item_max
  444.   attr_writer :commands
  445.   attr_accessor :cur_subject
  446.  
  447.   def initialize(x, y)
  448.     super(x, y, 120, 416)
  449.     @cur_subject = $game_temp.last_pediasubject
  450.     @item_max = $gamepedia.topics[cur_subject].size
  451.     @commands = $gamepedia.topics[cur_subject]
  452.     if NEW_WINDOWSKIN
  453.       self.windowskin = Cache.system(GP_WINDOWSKIN)
  454.     end
  455.     refresh
  456.     self.index = 0
  457.   end
  458.  
  459.   def refresh
  460.     create_contents
  461.     self.contents.clear
  462.     for i in 0...@item_max
  463.       draw_item(i)
  464.     end
  465.   end
  466.  
  467.   def change_commands(subject)
  468.     @item_max = $gamepedia.topics[subject].size
  469.     @commands = $gamepedia.topics[subject]
  470.   end
  471.  
  472.  
  473.   def draw_item(index, enabled = true)
  474.     rect = item_rect(index)
  475.     self.contents.clear_rect(rect)
  476.     rect.x += 4
  477.     rect.width -= 8
  478.     self.contents.font.color = normal_color
  479.     self.contents.font.size = 12
  480.     if $gamepedia.hidden_topics.include?($gamepedia.topics[@cur_subject][index])
  481.       self.contents.draw_text(rect, HIDDEN_COMMAND)
  482.     else
  483.       self.contents.draw_text(rect, @commands[index])
  484.     end
  485.   end
  486.  
  487. end
  488.  
  489. ################################################################################
  490. #                  WINDOW: VIEW TOPIC
  491. ################################################################################
  492.  
  493. class Window_PediaViewTopic < Window_Base
  494.  
  495.   include GAMEPEDIA
  496.  
  497.   attr_writer :topic_dex
  498.   attr_accessor :cur_subject
  499.  
  500.   def initialize(x, y, heading, entry)
  501.     super(x, y, 304, 346)
  502.     @heading = heading
  503.     @entry = entry
  504.     @topic_dex = 0
  505.     @cur_subject = $game_temp.last_pediasubject
  506.     if NEW_WINDOWSKIN
  507.       self.windowskin = Cache.system(GP_WINDOWSKIN)
  508.     end
  509.     refresh
  510.   end
  511.  
  512.   def refresh
  513.     self.contents.clear
  514.     self.contents.font.size = 14    
  515.     self.contents.font.color = text_color(TOPIC_HEADING_COLOR)
  516.     self.contents.draw_text(-16, 0, self.width, WLH, @heading, 1)
  517.     self.contents.font.size = 12    
  518.     self.contents.font.color = normal_color
  519.     if $gamepedia.hidden_topics.include?($gamepedia.topics[@cur_subject][@topic_dex])
  520.       self.contents.draw_paragraph(0, WLH, self.width - 50, self.height, HIDDEN_ENTRY_TEXT)
  521.     else
  522.       self.contents.draw_paragraph(0, WLH, self.width - 50, self.height, @entry)
  523.     end
  524.   end
  525.  
  526.  
  527.   def change_heading(heading)
  528.     @heading = heading
  529.   end
  530.  
  531.   def change_text(entry)
  532.     @entry = entry
  533.   end
  534.  
  535.  
  536. end
  537.  
  538. ################################################################################
  539. #                  WINDOW: ENCYCLOPEDIA TITLE
  540. ################################################################################
  541.  
  542. class Window_PediaTitle < Window_Base
  543.  
  544.   include GAMEPEDIA
  545.  
  546.   def initialize(x, y)
  547.     super(x, y, 304, 70)
  548.     if NEW_WINDOWSKIN
  549.       self.windowskin = Cache.system(GP_WINDOWSKIN)
  550.     end
  551.     refresh
  552.   end
  553.  
  554.   def refresh
  555.     et = ENCYCLOPEDIA_TITLE
  556.     self.contents.clear
  557.     self.contents.font.color = text_color(TITLE_COLOR)
  558.     self.contents.draw_text(-16, 0, self.width, WLH, et, 1)
  559.   end
  560.  
  561. end
  562.  
  563. ################################################################################
  564. #                        SCENE: TITLE
  565. ################################################################################
  566. class Scene_Title < Scene_Base
  567.  
  568.   alias nq_st_create_game_objects create_game_objects unless $@
  569.   def create_game_objects
  570.     nq_st_create_game_objects
  571.     $gamepedia = Gamepedia.new
  572.   end
  573.  
  574. end
  575.  
  576. ################################################################################
  577. #                         SCENE: MENU
  578. ################################################################################
  579. class Scene_Menu < Scene_Base
  580.  
  581.   include GAMEPEDIA
  582.  
  583.   alias nq_create_command_window create_command_window unless $@
  584.   def create_command_window
  585.     if USE_FROM_MENU
  586.       s1 = Vocab::item
  587.       s2 = Vocab::skill
  588.       s3 = Vocab::equip
  589.       s4 = Vocab::status
  590.       s5 = GAMEPEDIA_MENU_COMMAND
  591.       s6 = Vocab::save
  592.       s7 = Vocab::game_end
  593.       @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
  594.       @command_window.index = @menu_index
  595.       if $game_party.members.size == 0          # If number of party members is 0
  596.         @command_window.draw_item(0, false)     # Disable item
  597.         @command_window.draw_item(1, false)     # Disable skill
  598.         @command_window.draw_item(2, false)     # Disable equipment
  599.         @command_window.draw_item(3, false)     # Disable status
  600.       end
  601.       if $game_system.save_disabled             # If save is forbidden
  602.         @command_window.draw_item(4, false)     # Disable save
  603.       end
  604.     else
  605.       nq_create_command_window
  606.     end
  607.   end
  608.  
  609.   alias nq_update_command_selection update_command_selection unless $@
  610.   def update_command_selection
  611.     if USE_FROM_MENU
  612.       if Input.trigger?(Input::B)
  613.         Sound.play_cancel
  614.         $scene = Scene_Map.new
  615.       elsif Input.trigger?(Input::C)
  616.         if $game_party.members.size == 0 and @command_window.index < 4
  617.           Sound.play_buzzer
  618.           return
  619.         elsif $game_system.save_disabled and @command_window.index == 4
  620.           Sound.play_buzzer
  621.           return
  622.         end
  623.         Sound.play_decision
  624.         case @command_window.index
  625.         when 0      # Item
  626.           $scene = Scene_Item.new
  627.         when 1,2,3  # Skill, equipment, status
  628.           start_actor_selection
  629.         when 4
  630.           $game_temp.pedia_menu = true
  631.           $scene = Scene_Gamepedia.new
  632.         when 5      # Save
  633.           $scene = Scene_File.new(true, false, false)
  634.         when 6      # End Game
  635.           $scene = Scene_End.new
  636.         end
  637.       end
  638.     else
  639.       nq_update_command_selection
  640.     end
  641.   end
  642.  
  643.  
  644. end
  645.  
  646.  
  647.  
  648. ################################################################################
  649. #                        SCENE: FILE
  650. ################################################################################
  651.  
  652. class Scene_File < Scene_Base
  653.  
  654.   alias nq_sfile_write_save_data write_save_data
  655.   def write_save_data(file)
  656.     nq_sfile_write_save_data(file)
  657.     Marshal.dump($gamepedia, file)
  658.   end
  659.  
  660.   alias nq_sfile_read_save_data read_save_data
  661.   def read_save_data(file)
  662.     nq_sfile_read_save_data(file)
  663.     $gamepedia = Marshal.load(file)
  664.   end
  665.  
  666. end
  667.  
  668. ################################################################################
  669. #                        SCENE: ENCYCLOPEDIA
  670. ################################################################################
  671.  
  672. class Scene_Gamepedia < Scene_Base
  673.  
  674.   include GAMEPEDIA
  675.  
  676.   def start
  677.     super
  678.     create_menu_background
  679.     @win_title = Window_PediaTitle.new(241, 0)
  680.     @win_subjects = Window_PediaSubjects.new(0, 0)
  681.     @win_topics = Window_PediaTopics.new(121, 0)
  682.     get_current_heading
  683.     get_current_entry
  684.     @win_viewtopic = Window_PediaViewTopic.new(241, 71, @cur_head, @cur_entry)
  685.     activate_subjects
  686.   end
  687.  
  688.   #-----------------------------------------------------------------------------
  689.   #                        Get Current Entry Heading
  690.   #-----------------------------------------------------------------------------
  691.   def get_current_heading
  692.     @cur_head = $gamepedia.topics[@win_subjects.index][@win_topics.index]
  693.   end
  694.  
  695.   #-----------------------------------------------------------------------------
  696.   #                     Get Current Entry Text
  697.   #-----------------------------------------------------------------------------
  698.   def get_current_entry
  699.     $gamepedia.get_entries(@win_subjects.index)
  700.     if @cur_head == "???????"
  701.       @cur_entry = HIDDEN_ENTRY_TEXT
  702.     else
  703.       @cur_entry = ENTRIES[$gamepedia.entries[@win_topics.index]]
  704.     end
  705.   end
  706.  
  707.   #-----------------------------------------------------------------------------
  708.   #                           Update
  709.   #-----------------------------------------------------------------------------
  710.   def update
  711.     super
  712.     update_menu_background
  713.     @win_title.refresh
  714.     if @win_subjects.active
  715.       update_subject_selection
  716.     elsif @win_topics.active
  717.       update_topic_selection
  718.     end
  719.   end
  720.  
  721.   #-----------------------------------------------------------------------------
  722.   #                    Activate Topics Window
  723.   #-----------------------------------------------------------------------------
  724.  
  725.   def activate_topics
  726.     @win_subjects.active = false
  727.     $game_temp.last_pediasubject = @win_subjects.index
  728.     @win_topics.cur_subject = @win_subjects.index
  729.     @win_viewtopic.cur_subject = @win_subjects.index
  730.     @win_topics.refresh
  731.     @win_viewtopic.refresh
  732.     @win_topics.active = true
  733.   end
  734.  
  735.   #-----------------------------------------------------------------------------
  736.   #                    Activate Subjects Window
  737.   #-----------------------------------------------------------------------------
  738.   def activate_subjects
  739.     @win_topics.active = false
  740.     @win_topics.index = 0
  741.     @win_subjects.index = $game_temp.last_pediasubject
  742.     @win_subjects.active = true
  743.   end
  744.  
  745.   #-----------------------------------------------------------------------------
  746.   #                       Update Subject Selection
  747.   #-----------------------------------------------------------------------------
  748.    
  749.   def update_subject_selection
  750.     @win_subjects.update
  751.     if Input.trigger?(Input::B)
  752.       Sound.play_cancel
  753.       if $game_temp.pedia_menu
  754.         $scene = Scene_Menu.new
  755.         $game_temp.pedia_menu = false
  756.       else
  757.         $scene = Scene_Map.new
  758.       end
  759.     elsif Input.trigger?(Input::C)
  760.       if $gamepedia.hidden_subjects.include?($gamepedia.subjects[@win_subjects.index])
  761.         Sound.play_buzzer
  762.       else
  763.         Sound.play_decision
  764.         @win_topics.change_commands(@win_subjects.index)
  765.         @win_topics.refresh
  766.         get_current_heading
  767.         get_current_entry
  768.         @win_viewtopic.change_heading(@cur_head)
  769.         @win_viewtopic.change_text(@cur_entry)
  770.         @win_viewtopic.refresh
  771.         activate_topics
  772.       end
  773.     end
  774.   end
  775.  
  776.   #-----------------------------------------------------------------------------
  777.   #                      Update Topic Selection
  778.   #-----------------------------------------------------------------------------
  779.  
  780.   def update_topic_selection
  781.     @win_topics.update
  782.     @win_viewtopic.topic_dex = @win_topics.index
  783.     if Input.trigger?(Input::B)
  784.       Sound.play_cancel
  785.       activate_subjects
  786.     elsif Input.trigger?(Input::C)
  787.       if $gamepedia.hidden_topics.include?($gamepedia.topics[@win_subjects.index][@win_topics.index])
  788.         Sound.play_buzzer
  789.       else
  790.         Sound.play_decision
  791.         @win_topics.refresh
  792.         get_current_heading
  793.         get_current_entry
  794.         @win_viewtopic.change_heading(@cur_head)
  795.         @win_viewtopic.change_text(@cur_entry)
  796.         @win_viewtopic.refresh
  797.       end
  798.     end
  799.   end
  800.  
  801.   #-----------------------------------------------------------------------------
  802.   #                       Terminate
  803.   #-----------------------------------------------------------------------------
  804.   def terminate
  805.     @win_title.dispose
  806.     @win_subjects.dispose
  807.     @win_topics.dispose
  808.     @win_viewtopic.dispose
  809.   end
  810.  
  811. end
Add Comment
Please, Sign In to add comment