设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2388|回复: 3
打印 上一主题 下一主题

[已经解决] 有没有兼容性好的任务系统,不与物品制造系统1.0冲突的

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
59 小时
注册时间
2012-3-4
帖子
86
跳转到指定楼层
1
发表于 2012-6-13 23:01:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
     http://rpg.blue/thread-233788-1-1.html    物品制造系统
不与它冲突就可以

Lv1.梦旅人

梦石
0
星屑
50
在线时间
244 小时
注册时间
2008-1-25
帖子
312
2
发表于 2012-6-14 07:49:00 | 只看该作者
本帖最后由 迷糊的安安 于 2012-6-14 10:47 编辑

这个是我在论坛搜的,任务编写在760行,我把它跟物品制造系统放,没有发现冲突,按理来讲应该也不会有什么冲突吧。。。
       使用方法自己也不是很清楚,
quest(1)                                       这个是接受任务,后面是你在760行以后的任务编号
reveal_objective(1,0,1,2,3)          这个可以显示该任务里0,1,2,3四个目标
complete_objective(1, 1)             这个是完成目标,前面的1是任务编号,后面的是目标编号
至于自动奖励,我试了没成功,不过反正可以自己在事件里自己加,不重要。
  1. #==============================================================================
  2. #    Quest Journal [VXA]
  3. #    Version: 1.0d
  4. #    Author: modern algebra (rmrk.net)
  5. #    Date: February 27, 2012
  6. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7. #  Description:
  8. #
  9. #    This script provides a graphical interface for showing quest progress. It
  10. #   is objective-based, meaning that you choose when to reveal objectives and
  11. #   you can set it so that they show up as complete or failed. That said, this
  12. #   script does not build quests for you; it is only a supplementary scene for
  13. #   showing them. As such, you need to event all of the quests yourself and
  14. #   update quest progress via script call. Therefore, pay close attention to
  15. #   the instructions here and in the Editable Regions at lines 232 and 612.
  16. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  17. #  Instructions:
  18. #
  19. #    Paste this script into its own slot or slots, above Main and below
  20. #   Materials. If you are using the menu access feature, you should put any
  21. #   other menu scripts above this one.
  22. #
  23. #    All of the configuration is done in the QuestData module. While it is not
  24. #   necessary, it is recommended that you separate the configuration module
  25. #   from the rest of the script by cutting and pasting it into its own slot in
  26. #   the Script Editor (as you will see if you have the demo). The reason for
  27. #   this is that, if and when this script gets updated, you can preserve the
  28. #   configuration section and only replace the other parts of the script. If
  29. #   you wish to do that, you must cut everything from the first line down to
  30. #   the final end of the module. The first lines of the body script should be
  31. #   the equals bar right above # ** Game_Quest. Again, it's up to you whether
  32. #   you do it.
  33. #
  34. #    You can go to EDITABLE REGION A at line 232 to configure the default
  35. #   settings for the script. All of these will work fine without modification,
  36. #   of course, but even if do not want to configure now, you should familiarize
  37. #   yourself with all the settings so that you can make the best use of your
  38. #   script. I have included tons of settings so that you can make the Quest
  39. #   Journal unique for your game, even down to the order in which each section
  40. #   of the info window is drawn. A brief description of each setting is
  41. #   included either to the right or directly above each constant.
  42. #
  43. #    EDITABLE REGION B is the real heart of the script however - this is where
  44. #   you fill in all of the details for the quests. Read the instructions at
  45. #   line 612 very carefully!
  46. #
  47. #    You can activate and access a quest with this code in the Script event
  48. #   command:
  49. #
  50. #        quest(quest_id)
  51. #          quest_id : the integer ID of the quest you want to access
  52. #
  53. #   From that, you can access or alter any relevant data stored in the quest,
  54. #   like name, description, objectives, etc... Example:
  55. #         quest(1).name = "Rest in Pieces"
  56. #
  57. #    More relevantly, when it comes to controlling the progress of quests the
  58. #   following codes can be used in a Script event command. The arguments are
  59. #   the same for each command so I only explain them once. All of them are
  60. #   pretty self-explanatory and using any of them will activate the quest
  61. #   (unless you are using the MANUAL REVEAL setting at line 267).
  62. #   
  63. #        reveal_objective(quest_id, objective_id_1, ..., objective_id_n)
  64. #            quest_id : the integer ID of the quest you want to access.
  65. #            objective_id_1, ..., objective_id_n : a list of the IDs of the
  66. #              objectives you want to operate on. It can be as few as one or as
  67. #              many as all of them.
  68. #          Will show the listed objectives in the Quest's information
  69. #
  70. #        conceal_objective(quest_id, objective_id_1, ..., objective_id_n)
  71. #          Will hide the listed objectives in the Quest's information
  72. #
  73. #        complete_objective(quest_id, objective_id_1, ..., objective_id_n)
  74. #          Changes the colour of the listed objectives to the completed colour.
  75. #          The quest is completed once all prime objectives are.
  76. #
  77. #        uncomplete_objective (quest_id, objective_id_1, ..., objective_id_n)
  78. #          Changes the status of the listed complete objectives back to active
  79. #
  80. #        fail_objective(quest_id, objective_id_1, ..., objective_id_n)
  81. #          Changes the colour of the listed objectives to the failed colour.
  82. #          The quest is failed once one prime objective is.
  83. #
  84. #        unfail_objective(quest_id, objective_id_1, ..., objective_id_n)
  85. #          Changes the status of the listed failed objectives back to active
  86. #
  87. #        change_reward_status(quest_id, value)
  88. #            value : either true or false. If excluded, defaults to true.
  89. #          Totally optional, but this is just a personal switch which you can
  90. #          turn on when the reward is given. You can then make it a condition
  91. #          so you don't reward the players more than once. (see line 180)
  92. #
  93. #  EXAMPLES:
  94. #    reveal_objective(1, 0)
  95. #      This would reveal the first objective of the quest with ID 1
  96. #    complete_objective(6, 2, 3)
  97. #      This would complete the third & fourth objectives of the quest with ID 6
  98. #    change_reward_status(8)
  99. #      This would set the reward switch to true for the quest with ID 8.
  100. #
  101. #   Another new feature is the ability to set rewards that will show up in the
  102. #  menu (see EDITABLE REGION B). In addition to that, you can use the following
  103. #  code to automatically distribute the specified rewards for a quest if the
  104. #  quest is complete and no reward has yet been given:
  105. #
  106. #        distribute_quest_rewards(quest_id)
  107. #          quest_id : the ID of the quest whose rewards you want to distribute
  108. #
  109. #   Of course, it can only distribute the material rewards (items, weapons,
  110. #   armors, gold, or exp). It won't distribute rewards you specify by string.
  111. #   To that end though, you can also use this code in a conditional branch and
  112. #   it will be satisfied only if it distributes the rewards. Thus, if you
  113. #   wanted to add some special rewards or do things like that, you can just put
  114. #   that in the branch for when it is true. This feature is not really
  115. #   recommended, since I think it is better to do it by events.
  116. #
  117. #    Other codes for the Script event command that can be useful are:
  118. #   
  119. #        reset_quest(quest_id)
  120. #            quest_id : the integer ID of the quest you want to access.
  121. #          This will re-initialize the quest, meaning all quest progress to
  122. #          date will be lost
  123. #
  124. #        remove_quest(quest_id)
  125. #          Deactivates the quest and resets it
  126. #
  127. #        conceal_quest(quest_id)
  128. #          Deactivates the quest so it won't show up in the scene, but progress
  129. #          is saved
  130. #
  131. #        reveal_quest(quest_id)
  132. #          Activates or reactivates the quest. This command is NECESSARY if
  133. #          MANUAL_REVEAL at line 284 is true or it has previously been
  134. #          concealed. Otherwise, it is sufficient just to operate on the quest
  135. #
  136. #        change_quest_access(:symbol)
  137. #          :symbol must be one of six options (include the colon!):
  138. #            :disable - prevents access to the quest scene (greys out in menu)
  139. #            :enable - enables access to the quest scene
  140. #            :disable_menu - this removes the quest option from the menu
  141. #            :enable_menu - this adds the quest option to the menu
  142. #            :disable_map - this prevents access by key from the map
  143. #            :enable_map - this allows access by key to the map
  144. #
  145. #        change_quest_background("bg_filename", bg_opacity, bg_blend_type)
  146. #            bg_filename   : the filename of the picture for the background in  
  147. #              the Pictures folder
  148. #            bg_opacity    : the opacity of the background graphic. If
  149. #              excluded, this defaults to the value of the setting at line 434.
  150. #            bg_blend_type : the blend type of the background graphic. If
  151. #              excluded, this defaults to the value of the setting at line 437.
  152. #
  153. #        change_quest_windows ("windowskin_filename", tone, opacity)
  154. #            windowskin_filename : the name of the Window graphic in the
  155. #              System folder of Graphics
  156. #            opacity             : the opacity of the windows. If excluded,
  157. #              this defaults to the value of the setting at line 423.
  158. #            blend_type          : the blend_type of the windows. If excluded,
  159. #              this defaults to the value of the setting at line 426.
  160. #
  161. #    Also, there are a few codes that can be used in the Script command of a
  162. #   conditional branch. I note here that all of these are optional. You could
  163. #   use switch and variable checks and monitor quest progress solely through
  164. #   events. However, these commands make it a little easier and they are:
  165. #
  166. #        quest_revealed?(quest_id)
  167. #            quest_id : the integer ID of the quest you want to access.
  168. #          This is satisfied if the quest has been activated.
  169. #
  170. #        quest_complete?(quest_id)
  171. #          This is satisfied if all prime objectives of the quest are complete
  172. #
  173. #        quest_failed?(quest_id)
  174. #          This is satisfied if any prime objective of the quest is failed
  175. #
  176. #        quest_rewarded?(quest_id)
  177. #          This is satisfied if you have changed the reward status to true.
  178. #
  179. #        objective_revealed?(quest_id, objective_id_1, ... objective_id_n)
  180. #            objective_id_1, ..., objective_id_n : a list of the IDs of the
  181. #              objectives you want to operate on. It can be as few as one or as
  182. #              many as all of them.
  183. #          This is satisfied if the listed objectives have been revealed
  184. #
  185. #        objective_active?(quest_id, objective_id_1, ... objective_id_n)
  186. #          This is satisfied if all the listed objectives are revealed and
  187. #          neither complete nor failed.
  188. #
  189. #        objective_complete?(quest_id, objective_id_1, ... objective_id_n)
  190. #          This is satisfied if all the listed objectives have been completed
  191. #
  192. #        objective_failed?(quest_id, objective_id_1, ... objective_id_n)
  193. #          This is satisfied if all the listed objectives have been failed
  194. #
  195. #    If you want to call the Quest scene from an event, you use the following
  196. #   code in a call script:
  197. #
  198. #        call_quest_journal
  199. #        call_quest_journal(quest_id)
  200. #          quest_id : ID of the quest you want to open the scene on
  201. #
  202. #  If you do not specify a quest_id (line 198) then it will simply open the
  203. #  scene as it would normally. If you do specify a quest_id (line 199) then it
  204. #  will open the scene on that quest so long as it has been revealed and it is
  205. #  normally accessible through the quest menu.
  206. #
  207. #   Finally, the default way this script operates is that quests automatically
  208. #  complete or fail based on the status of the prime objectives. However, you
  209. #  can set it so that there are no prime objectives, in which case you can only
  210. #  complete, fail, or (re)activate a quest manually through the following code
  211. #  in a script call:
  212. #
  213. #        manually_complete_quest(quest_id)
  214. #          quest_id : ID of the quest you want to manually complete
  215. #        manually_fail_quest(quest_id)
  216. #          quest_id : ID of the quest you want to manually fail
  217. #        manually_activate_quest(quest_id)
  218. #          quest_id : ID of the quest you want to manually activate
  219. #==============================================================================

  220. $imported ||= {}
  221. $imported[:"MA_QuestJournal_1.0"] = true

  222. #==============================================================================
  223. # *** QuestData
  224. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  225. #  This module contains all the configuration data for the quest journal
  226. #==============================================================================

  227. module QuestData
  228.   #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  229.   #  BEGIN Editable Region A
  230.   #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  231.   #  MENU_ACCESS - If true, you can access the quest journal through a command
  232.   # in the menu. If false, there will be no such command.
  233.   MENU_ACCESS = true
  234.   #  MENU_INDEX - If MENU_ACCESS is true, this determines where it appears
  235.   MENU_INDEX = 5
  236.   #  MAP_ACCESS - If true, this allows you to access the quest journal by
  237.   # pressing a key on the map.
  238.   MAP_ACCESS = true
  239.   #  MAP_BUTTON - If MAP_ACCESS is true, this determines which button calls the
  240.   # Quest Journal
  241.   MAP_BUTTON = :L
  242.   #  OPEN_TO_LAST_REVEALED_QUEST - If true, then the first time you open the
  243.   # quest journal after revealing a new quest, it will open to the new quest.
  244.   OPEN_TO_LAST_REVEALED_QUEST = true
  245.   #  OPEN_TO_LAST_CHANGED_QUEST - If true, then the Quest Journal will open to
  246.   # the last quest whose objective status has changed.
  247.   OPEN_TO_LAST_CHANGED_QUEST = false
  248.   #  LIST_WINDOW_WIDTH - The width, in pixels, of the List Window
  249.   LIST_WINDOW_WIDTH = 192
  250.   #  BASIC_DATA_TYPES  - This lets you set up additional types of data. Just
  251.   # include an identifying signal in the Array. Then, you will need to give
  252.   # each signal an icon (in the ICONS hash at line 322) and a signal text (in
  253.   # the VOCAB array at line 333, though it can be an empty string). Then, you
  254.   # can set the data itself when setting up quests by simply adding a:
  255.   #    q[:symbol] = ""
  256.   # line to the quest. You will also need to include the data type somewhere in
  257.   # the DATA_LAYOUT at line 306. As an example of this, I have included :client
  258.   # and :location by default. You can CTRL+F for anything in this section with
  259.   # one of those symbols (excluding :) and you will there need to add something
  260.   # for any new data types you add.
  261.   BASIC_DATA_TYPES = [:client, :location]
  262.   #  BASIC_DATA_WIDTH - This determines how much room, in pixels, is given to  
  263.   # any basic data types you set up in the data window.
  264.   BASIC_DATA_WIDTH = 240
  265.   #  CONCURRENT_ACTIVITY - If true, then when in the Quest Journal scene, you
  266.   # can switch categories or scroll down the quest list at the same time. If
  267.   # false, you will first need to select a category before you can start
  268.   # scrolling through the quest list.
  269.   CONCURRENT_ACTIVITY = true
  270.   #  HIDE_CATEGORY_CURSOR - If true, then the Category Window will not have a
  271.   # cursor and will instead just highlight the currently selected category.
  272.   # This is best when CONCURRENT_ACTIVITY is true.
  273.   HIDE_CATEGORY_CURSOR = true
  274.   #  SHOW_QUEST_ICONS - If true, then the icon you choose for each quest will
  275.   # be displayed to the left of its name in the Quest List window
  276.   SHOW_QUEST_ICONS = true
  277.   #  MANUAL_REVEAL - If false, then quests will be revealed the moment you
  278.   # first reveal, complete, or fail an objective. If this is true, you will
  279.   # need to specifically reveal each quest via a separate script call:
  280.   #    reveal_quest(quest_id)
  281.   MANUAL_REVEAL = false
  282.   #  DATA_LAYOUT - This controls the way that the quest window lays out all of
  283.   # the relevant data. If you set one of the entries to be an array, then any
  284.   # of the commands there will be drawn at the same y. With exception to :line,
  285.   # none of the commands will be drawn if the quest is not set to have that
  286.   # particular data. The symbols are:
  287.   #    :line        - Draws a horizontal line across the window.
  288.   #    :name        - Draws the name of the quest
  289.   #    :level       - Draws the level of the quest
  290.   #    :banner      - Draws the banner for the quest
  291.   #    :client      - Draws the client set in the quest   (basic data)
  292.   #    :location    - Draws the location set in the quest (basic data)
  293.   #    :description - Draws the quest's description
  294.   #    :objectives  - Draws all the quest's objectives that have been revealed
  295.   #    :rewards     - Draws whatever rewards have been set
  296.   #
  297.   # You will also need to add an entry for any new BASIC_DATA that you place
  298.   # in BASIC_DATA_TYPES at line 264.
  299.   #
  300.   # Remember to place a comma after each entry. Also note that this is only the
  301.   # default layout. You can set a different layout for any quest, and when
  302.   # viewing that quest, it will be the custom layout that is shown.
  303.   DATA_LAYOUT = [
  304.     [:line, :name, :level],
  305.     :banner,
  306.     :client,
  307.     :location,
  308.     :description,
  309.     :objectives,
  310.     [:line, :rewards],
  311.     :line,
  312.   ] # <= Do not touch.
  313.   #  ICONS - This is where you setup many of the icons used in the script. The
  314.   # purpose of each is listed next to it. Also, if you make any custom
  315.   # categories, you NEED to give them an icon by placing a line like the
  316.   # others. So, if the new custom category is :romance then you would need to
  317.   # set it like this:
  318.   #    romance:     107,
  319.   ICONS = {
  320.     all:         226, # The icon for the All Quests category
  321.     active:      236, # The icon for the Active Quests category
  322.     complete:    238, # The icon for the Complete Quests category
  323.     failed:      227, # The icon for the Failed Quests category
  324.     client:      121, # The icon for client data. If none wanted, set to 0
  325.     location:    231, # The icon for location data. If none wanted, set to 0
  326.     reward_gold: 262, # The icon for gold rewards. If none wanted, set to 0
  327.     reward_exp:  117, # The icon for exp rewards. If none wanted, set to 0
  328.   } # <= Do not touch.
  329.   #  VOCAB - This lets you choose some of the words used in the quest scene
  330.   VOCAB = {
  331.     # menu_label:  The command name in the menu if MENU_ACCESS is true
  332.     menu_label:       "任务",
  333.     # scene_label: The label at the top of the scene. If empty, no window
  334.     scene_label:      "任务详细",
  335.     # description: The heading to identify the description
  336.     description:      "描述",
  337.     # objectives: The heading to identify the objectives
  338.     objectives:       "目标",
  339.     # objective_bullet: The bullet which shows up to the left of every
  340.     #  objective. If %d is included, it shows the objective's ID.
  341.     objective_bullet: "?",
  342.     # rewards: The heading to identify the rewards.
  343.     rewards:          "奖励",
  344.     # reward_amount: For item rewards, this is the text to show the amount.
  345.     #  It should include %d to show the amount.
  346.     reward_amount:    "x%d",
  347.     # reward_gold: Text to identify gold rewards
  348.     reward_gold:      "",
  349.     # reward_exp: Text to identify exp rewards
  350.     reward_exp:       "",
  351.     # level: If LEVEL_ICON is 0, this is the text which precedes the level
  352.     level:            "难度: ",
  353.     # location: The text label for quest location
  354.     location:         "",
  355.     # location: The text label for quest client
  356.     client:           "",
  357.   } # <= Do not touch.
  358.   #  CATEGORIES - This array allows you to set which categories are available
  359.   # in the Quest scene. The default categories are :all, :active, :complete,
  360.   # and :failed, and their names are self-explanatory. You can add custom
  361.   # categories as well, but note that you will need to make sure that each new
  362.   # category has an icon set in the ICONS hash, as well as a label set in the
  363.   # CATEGORY_VOCAB hash (if you are using SHOW_CATEGORY_LABEL). It is also
  364.   # advisable to give it a sort type, unless you are fine with it being sorted
  365.   # by ID, as is default.
  366.   CATEGORIES = [:all, :active, :complete, :failed]
  367.   #  SHOW_CATEGORY_LABEL - This allows you to choose whether to show the name
  368.   # of the currently selected category. If true, it will choose the name out
  369.   # of the CATEGORY_VOCAB hash.
  370.   SHOW_CATEGORY_LABEL = true
  371.   #  CATEGORY_LABEL_IN_SAME_WINDOW - If SHOW_CATEGORY_LABEL is true, then this
  372.   # options lets you choose whether the label is shown in the same window as
  373.   # the category icons or in a separate window below. true = same window.
  374.   CATEGORY_LABEL_IN_SAME_WINDOW = true
  375.   #  CATEGORY_VOCAB - If SHOW_CATEGORY_LABEL is true, this hash lets you set the
  376.   # label for each category. For any custom categories you create, you will
  377.   # need to add a line for each below and in the same format:
  378.   #    :category => "Label",
  379.   # Don't forget to add the comma at the end of each line.
  380.   CATEGORY_VOCAB = {
  381.     :all =>      "所有任务",      # The label for the :all category
  382.     :active =>   "已接任务",   # The label for the :active category
  383.     :complete => "完成任务", # The label for the :complete category
  384.     :failed =>   "失败任务",   # The label for the :failed category
  385.   } # <= Do not touch.
  386.   #  SORT_TYPE - This hash allows you to choose how each category is sorted.
  387.   # For each category, default or custom, you can set a different sort method
  388.   # There are seven options to choose from:
  389.   #    :id - The quests are sorted from lowest to highest ID
  390.   #    :alphabet - The quests are sorted in alphabetical order
  391.   #    :level - The quests are sorted from the lowest to highest level
  392.   #    :reveal - The quests are sorted from most recently revealed on.
  393.   #            Every time a new quest is revealed, it will be at the top.
  394.   #    :change - The quests are sorted from the one whose status most recently
  395.   #            changed on. So, every time an objective is modified, that quest
  396.   #            will be thrown to the top.
  397.   #    :complete - The quests are sorted from the most recently completed on.
  398.   #            Every time a quest is completed, it will be thrown to the top.
  399.   #    :failed - The quests are sorted from the most recently failed on.
  400.   #            Every time a quest is failed, it will be thrown to the top.
  401.   #
  402.   # Additionally, you can put _r at the end of any of the sort options and it
  403.   # will reverse the order. So, for instance, if the sort method for a category
  404.   # is :alphabet_r, then the quests will show up from Z-A
  405.   SORT_TYPE = {
  406.     :all =>      :id,       # Sort type for the All Quests category
  407.     :active =>   :change,   # Sort type for the Active Quests category
  408.     :complete => :complete, # Sort type for the Complete Quests category
  409.     :failed =>   :failed,   # Sort type for the Failed Quests category
  410.   } # <= Do not touch.
  411.   #  WINDOWSKIN - The windowskin for each window in the Quest scene. It must
  412.   # refer to a graphic in the System folder of Graphics. If set to false, then
  413.   # it will use whatever windowskin is default. If you are using a script which
  414.   # lets the player choose the windowskin, false is the recommended value.
  415.   WINDOWSKIN = false
  416.   #  WINDOW_TONE - The tone for each window. It must be an array in the form:
  417.   #      WINDOW_TONE = [red, green, blue, gray]
  418.   # gray can be excluded, but the other three must be present. If you set this
  419.   # value to false, then the windows will have whatever tone is default.
  420.   WINDOW_TONE = false
  421.   #  WINDOW_OPACITY - The opacity of the windows in the Quest scene. If set to
  422.   # false, it will use the default opacity for windows.
  423.   WINDOW_OPACITY = false
  424.   #  BG_PICTURE - This is a string referring to a picture in the Picture folder
  425.   # of Graphics. If set to "", then there will be no picture. Otherwise, it
  426.   # will display the selected picture below the windows but above the map in
  427.   # the Quest scene.
  428.   BG_PICTURE = ""
  429.   #  BG_OPACITY - This allows you to set the opacity of the background picture,
  430.   # if you have selected one.
  431.   BG_OPACITY = 255
  432.   #  BG_BLEND_TYPE - This allows you to set the blend type of the background
  433.   # picture, if you have selected one.
  434.   BG_BLEND_TYPE = 0
  435.   #  DESCRIPTION_IN_BOX - This is a graphical option, and it allows you to
  436.   # choose whether the description should be shown in a box.
  437.   DESCRIPTION_IN_BOX = true
  438.   #  LEVEL_ICON - This sets how levels are shown. If set to an integer, then it
  439.   # will draw the same icon numerous times up to the level of the quest. Ie. If
  440.   # the level's quest is 1, then the icon will only be drawn once, but if the
  441.   # level's quest is 4, it will be drawn 4 times. LEVEL_ICONS_SPACE determines
  442.   # the space between them. If you set LEVEL_ICON to 0, however, then it will
  443.   # instead draw a signal for the level, corresponding to that index in the
  444.   # LEVEL_SIGNALS array. If the LEVEL_SIGNALS array is empty, then it will just
  445.   # draw the integer for the level. Finally, LEVEL_ICON can also be an array of
  446.   # integers, in which case the level will be represented only by the icon set
  447.   # which corresponds to it in the array.
  448.   LEVEL_ICON = 125
  449.   #  LEVEL_ICONS_SPACE - If LEVEL_ICON is an integer, this is the amount of
  450.   # space between each time the icon is drawn.
  451.   LEVEL_ICONS_SPACE = 16
  452.   #  LEVEL_SIGNALS - If LEVEL_ICON is 0, this allows you to set what string
  453.   # should be the signal for each level. If this array is empty, then it will
  454.   # just draw the level integer. Ie. if the Quest is Level 4, it will draw 4.
  455.   LEVEL_SIGNALS = ["F", "E", "D", "C", "B", "A", "S"]
  456.   #  COLOURS - This lets you change the colour for various aspects of the
  457.   # quest scene. Each can be set in one of three ways:
  458.   #    :symbol - If you use a symbol, the colour will be the result of calling
  459.   #      the method of the same name. For instance, if you set something to
  460.   #      :system_color, it will set the colour to the result of the Window_Base
  461.   #      system_color method.
  462.   #    Integer - If you set the colour to an integer, then it will take its
  463.   #      colour from the windowskin palette, just like using \c[x] in messages.
  464.   #    Array - You can also set the rgba values directly with an array in the
  465.   #      format: [red, green, blue, alpha]. alpha can be excluded, but you must
  466.   #      have values for red, green, and blue.
  467.   COLOURS = {
  468.     # active: This sets the colour for active quests in the list and the name
  469.     #  of the active quest when shown in the data window.
  470.     active:           :normal_color,
  471.     # complete: This sets the colour for complete quests in the list and the
  472.     #  name of the complete quest when shown in the data window.
  473.     complete:         3,
  474.     # failed: This sets the colour for failed quests in the list and the name
  475.     #  of the failed quest when shown in the data window.
  476.     failed:           10,
  477.     # line:  This sets the colour for lines or boxes drawn in the quest scene
  478.     line:             :system_color,
  479.     # line_shadow:  This sets the colour of the shadow for lines or boxes drawn
  480.     #  in the quest scene
  481.     line_shadow: [0, 0, 0, 128],
  482.     # scene_label: This sets the colour for the scene label, if shown
  483.     scene_label:      :system_color,
  484.     # category_label: This sets the colour for the category label, if shown
  485.     category_label:   :normal_color,
  486.     # level_signal: This sets the colour for the level signal, if shown
  487.     level_signal:     :normal_color,
  488.     # objective_bullet: This sets the colour for objectives; if set to
  489.     #  :maqj_objective_color, it will reflect the completion status of the
  490.     #  objective, but you can change it to something else if you prefer
  491.     objective_bullet: :maqj_objective_color,
  492.     # reward_amount: The colour of the item amount, when shown
  493.     reward_amount:    :normal_color,
  494.     # heading: The colour of any headings in the script, like "Description"
  495.     heading:          :system_color,
  496.     # basic_label: For basic data, like client, the colour of the label
  497.     basic_label:      :system_color,
  498.     # basic_value: For basic data, like client, the colour of the value
  499.     basic_value:      :normal_color,
  500.   } # <= Do not touch.
  501.   #  HEADING_ALIGN - This sets the alignment for the aspects listed. 0 is Left;
  502.   # 1 is Centre; 2 is Right
  503.   HEADING_ALIGN = {
  504.     description: 0, # Alignment for the Description heading
  505.     objectives:  0, # Alignment for the Objectives heading
  506.     rewards:     1, # Alignment for the Rewards heading
  507.     level:       2  # Alignment when showing the level
  508.   } # <= Do not touch.
  509.   #````````````````````````````````````````````````````````````````````````````
  510.   #    Font Aspects
  511.   #
  512.   #  All of the following options (FONTNAMES, FONTSIZES, FONTBOLDS, and
  513.   # FONTITALICS) allow you to alter the fonts used for various aspects of the
  514.   # scene. The only one listed there by default is normal:, which is the
  515.   # font used by default for the entire scene. However, you can change the  
  516.   # fonts for almost any aspect - all you need to do is add a line like so:
  517.   #
  518.   #    description: value,
  519.   #
  520.   # and that will change that font aspect when drawing the description. The
  521.   # following symbols are available for changing:
  522.   #
  523.   #   normal:         The default font used for every part of the scene
  524.   #   list:           The font used in the List Window
  525.   #   scene_label:    The font used when drawing the Scene Label, if shown
  526.   #   category_label: The font used when drawing the Category Label, if shown
  527.   #   heading:        The font used when drawing any headings, like "Description"
  528.   #   name:           The font used when drawing the quest name in data window
  529.   #   description:    The font used when drawing the Description
  530.   #   objectives:     The font used when drawing the objectives
  531.   #   rewards:        The font used when drawing the rewards
  532.   #   client:         The font used when drawing the client
  533.   #   location:       The font used when drawing the location
  534.   #
  535.   # For any of them, you need to set a value. What the value can be depends
  536.   # on which font aspect you are changing and is described below, but for any
  537.   # of them setting it to the false will mean it will simply use the default
  538.   #
  539.   # For any that you add, remember that you must put a comma after the value.
  540.   #````````````````````````````````````````````````````````````````````````````
  541.   #  FONTNAMES - Here you can change the font used for any of the various
  542.   # options. It can take any of the following types of values:
  543.   #     false    - The default font will be used
  544.   #     "String" - The font with the name "String" will be used.
  545.   #     [Array]  - The array must be in the form: ["String1", "String2", ...]
  546.   #               The font used will be the first one in the array that the
  547.   #               player has installed.
  548.   #
  549.   #  EXAMPLES:
  550.   #
  551.   #    normal:      false,
  552.   #      The font used for unaltered aspects of the scene is the default font
  553.   #    scene_label: "Algerian",
  554.   #      The font used for the Scene Label will be Algerian.
  555.   #    description: ["Cambria", "Times New Roman"],
  556.   #      The font used when drawing the description will be Cambria if the
  557.   #      player has Cambria installed. If the player does not have Cambria
  558.   #      installed, then the font used will be Times New Roman
  559.   FONTNAMES = {
  560.     normal: false, # normal: the default font name
  561.   } # <= Do not touch.
  562.   #  FONTSIZES - Here you can change the size of the font. There are two types
  563.   # of values you can set:
  564.   #    false   - The default fontsize will be used
  565.   #    Integer - The fontsize will be equal to the value of the Integer.
  566.   #  
  567.   # For everything but the label windows, this shouldn't exceed 24, since that
  568.   # is the line_height. However, for scene_label: and category_label:, the size
  569.   # of the window will be adjusted to whatever size you set the font.
  570.   FONTSIZES = {
  571.     normal:         false, # normal: default font size
  572.     scene_label:    28,    # scene_label: fontsize for the Scene Label window
  573.     category_label: 24,    # category_label: fontsize for Category Label window
  574.   } # <= Do not touch.
  575.   #  FONTBOLDS - Here you can set whether the font will be bolded. You can set
  576.   # it to either false, in which case it will not be bolded, or true, in which
  577.   # case it will be bolded.
  578.   FONTBOLDS = {
  579.     scene_label:  true, # scene_label: whether font is bold for Scene Label
  580.     heading:      true, # heading: whether font is bold for the headings
  581.     level_signal: true, # level_signal: whether font is bold for level
  582.   } # <= Do not touch.
  583.   #  FONTITALICS - Here you can set whether the font will be italicized. You
  584.   # can set it to either false, in which case it will not be italicized, or
  585.   # true, in which case it will be italicized.
  586.   FONTITALICS = {
  587.   }
  588.   #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  589.   #  END Editable Region A
  590.   #//////////////////////////////////////////////////////////////////////////
  591.   CATEGORIES = [:all] if !CATEGORIES || CATEGORIES.empty?
  592.   VOCAB.default = ""
  593.   ICONS.default = 0
  594.   CATEGORY_VOCAB.default = ""
  595.   SORT_TYPE.default = :id
  596.   COLOURS.default = :normal_color
  597.   HEADING_ALIGN.default = 0
  598.   FONTNAMES.default = false
  599.   FONTSIZES.default = false
  600.   FONTBOLDS.default = false
  601.   FONTITALICS.default = false
  602.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  603.   # * Setup Quest
  604.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  605.   def self.setup_quest(quest_id)
  606.     q = { objectives: [] }
  607.     case quest_id
  608.     #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  609.     #  BEGIN Editable Region B
  610.     #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  611.     #    Quest Setup
  612.     #
  613.     #  This is where you set up the data for every quest in the game. While
  614.     # it may seem complicated, I urge you to pay attention and, once you get
  615.     # the hang of it, I am sure it will quickly become second nature.
  616.     #
  617.     #  Every single quest should be set up in the following format, but note
  618.     # that if you are not setting anything for a particular aspect, you can
  619.     # delete that line. Anyway, this is what each quest should look like, with
  620.     # the values on the left being the default values if you don't set them:
  621.     #
  622.     #  when quest_id
  623.     #   q[:name]              = "??????"
  624.     #   q[:icon_index]        = 0
  625.     #   q[:level]             = 0
  626.     #   q[:description]       = ""
  627.     #   q[:banner]            = ""
  628.     #   q[:banner_hue]        = 0
  629.     #   q[:objectives][0]     = ""
  630.     #   q[:objectives][1]     = ""
  631.     #   q[:objectives][2]     = ""
  632.     #   q[:objectives][n]     = ""
  633.     #   q[:prime_objectives]  = [0, 1, 2, n]
  634.     #   q[:custom_categories] = []
  635.     #   q[:client]            = ""
  636.     #   q[:location]          = ""
  637.     #   q[:rewards]           = []
  638.     #   q[:common_event_id]   = 0
  639.     #   q[:layout]            = false
  640.     #
  641.     #  For each line, with the exception of objectives, it is only the value on
  642.     # the right of the equals sign that you will need to change. Now I will
  643.     # explain each line:
  644.     #
  645.     # when quest_id
  646.     #    quest_id - is an integer of your choosing, and this is how you
  647.     #        reference a quest in order to advance and do anything else. It
  648.     #        must be unique for every quest; if you use 1 for the first quest,
  649.     #        you cannot use 1 for any other quest.
  650.     #
  651.     #   q[:name]              = ""
  652.     #     "" - This line sets the name of the quest which shows in the Quest
  653.     #        List.
  654.     #   
  655.     #   q[:icon_index]        = 0
  656.     #     0  - This line sets the icon to be used for this quest. It will show
  657.     #        to the left of the quest's name in the Quest List.
  658.     #
  659.     #   q[:level]             = 0
  660.     #     0  - This line sets the level of the quest. If 0, no level will be
  661.     #        shown. See the level options at lines 441-458 for more detail.
  662.     #   
  663.     #   q[:description]       = ""
  664.     #     "" - This line sets the description of the quest. You can use message
  665.     #        codes in this string, but if you are using "" then you need to use
  666.     #        \\ to identify codes and not just \. Ie. It's \\v[x], not \v[x]
  667.     #
  668.     #   q[:objectives][0]     = ""
  669.     #   q[:objectives][1]     = ""
  670.     #   q[:objectives][2]     = ""
  671.     #   q[:objectives][n]     = ""
  672.     #  Objectives are slightly different. Notice that after q[:objectives] on
  673.     # each line there is an integer enclosed in square brackets:
  674.     #    [n] - This is the ID of the objective, and n MUST be an integer. No
  675.     #       quest can have more than one objective with the same ID. This is
  676.     #       how you identify which objective you want to reveal, complete or
  677.     #       fail. That said, you can make as many objectives as you want, as
  678.     #       long as you give them all distinct IDs. The IDs should be in
  679.     #       sequence as well, so there shouldn't be a q[:objectives][5] if
  680.     #       there is no q[:objectives][4].
  681.     #     "" - This is the text of the objective. You can use message codes in
  682.     #        this string, but if you are using "" then you will need to use
  683.     #        \\ to identify codes and not just \. Ie: It's \\v[x], not \v[x]
  684.     #
  685.     #   q[:prime_objectives]  = [0, 1, 2, n]
  686.     #     [0, 1, 2, n] - This array determines what objectives need to be
  687.     #        completed in order for the quest to be complete. In other words,
  688.     #        all of the objectives with the IDs in this array need to be
  689.     #        complete for the quest to be complete. If any one of them is
  690.     #        failed, the quest will be failed. If you remove this line
  691.     #        altogether, then all objectives are prime. If you set this to [],
  692.     #        then the quest will never be automatically completed or failed and
  693.     #        you need to use the manual options described at lines 207-218.
  694.     #
  695.     #   q[:custom_categories] = []
  696.     #     [] - This allows you to set an array of custom categories for this
  697.     #        quest, whiich means this quest will show up in each of those
  698.     #        categories if you add it to the CATEGORIES array at line 369.
  699.     #        Note that each category you make must be identified by a unique
  700.     #        :symbol, and you must set up all the category details for that
  701.     #        :symbol.
  702.     #
  703.     #   q[:banner]            = ""
  704.     #     "" - This line sets the banner to be used for a quest. It must be the
  705.     #        filename of an image in the Pictures folder of Graphics.
  706.     #
  707.     #   q[:banner_hue]        = 0
  708.     #     0 - The hue of the banner graphic, if used
  709.     #
  710.     #   q[:client]            = ""
  711.     #     "" - This line sets the client name for this quest. (basic data)
  712.     #
  713.     #   q[:location]          = ""
  714.     #     "" - This line sets the location of the quest. (basic data)
  715.     #
  716.     #   q[:rewards]           = []
  717.     #    [] - In this array, you can identify particular rewards that will
  718.     #       show up
  719.     #
  720.     #   q[:common_event_id]   = 0
  721.     #     0  - This allows you to call the identified common event immediately
  722.     #        and automatically once the quest is completed. It is generally
  723.     #        not recommended, as for most quests you should be controlling it
  724.     #        enough not to need this feature.
  725.     #
  726.     #   q[:layout]            = false
  727.     #     false - The default value for this is false, and when it is false the
  728.     #        layout for the quest will be inherited from the default you set at
  729.     #        302. However, you can also give the quest its own layout - the
  730.     #        format would be the same as you set for the default at line 306.
  731.     #  
  732.     # Template:
  733.     #
  734.     #  When making a new quest, I recommend that you copy and paste the
  735.     # following template, removing whichever lines you don't want to alter.
  736.     # Naturally, you need to remove the #~. You can do so by highlighting
  737.     # the entire thing and pressing CTRL+Q:
  738. #~     when 2 # <= REMINDER: The Quest ID MUST be unique
  739. #~       q[:name]              = "??????"
  740. #~       q[:icon_index]        = 0
  741. #~       q[:level]             = 0
  742. #~       q[:description]       = ""
  743. #~       # REMINDER: You can make as many objectives as you like, but each must
  744. #~       # have a unique ID.
  745. #~       q[:objectives][0]     = ""
  746. #~       q[:objectives][1]     = ""
  747. #~       q[:objectives][2]     = ""
  748. #~       q[:prime_objectives]  = [0, 1, 2]
  749. #~       q[:custom_categories] = []
  750. #~       q[:banner]            = ""
  751. #~       q[:banner_hue]        = 0
  752. #~       q[:client]            = ""
  753. #~       q[:location]          = ""
  754. #~       q[:rewards]           = []
  755. #~       q[:common_event_id]   = 0
  756.     when 1 # Quest 1 - SAMPLE QUEST
  757.       q[:name]              = "理查登新人"
  758.       q[:level]             = 1
  759.       q[:icon_index]        = 7
  760.       q[:description]       = "作为新人,必须在不断地战斗中磨练自己,才能成为大师。"
  761.       q[:objectives][0]     = "请先向城里的司徒国老人问好。"
  762.       q[:objectives][1]     = "为老人找到他要的东西。"
  763.       q[:objectives][2]     = "请为自己赚取第一个1000元。"
  764.       q[:objectives][3]     = "请将自己的等级升到2级。"
  765.       q[:prime_objectives]  = [2, 3]
  766.       q[:custom_categories] = []
  767.       q[:banner]            = ""
  768.       q[:banner_hue]        = 0
  769.       q[:client]            = "司徒国"
  770.       q[:location]          = "竹之林"
  771.       q[:common_event_id]   = 0
  772.       q[:rewards]           = [
  773.         [:item, 1, 10],
  774.         [:gold, 500],
  775.       ]
  776.       q[:layout]            = false
  777.     #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  778.     #  END Editable Region B
  779.     #//////////////////////////////////////////////////////////////////////
  780.     end
  781.     q
  782.   end
  783. end

  784. #==============================================================================
  785. # *** DataManager
  786. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  787. #  Summary of Changes:
  788. #    aliased method - self.extract_save_contents
  789. #==============================================================================

  790. class << DataManager
  791.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  792.   # * Extract Save Contents
  793.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  794.   alias maqj_extractsavecons_2kw5 extract_save_contents
  795.   def extract_save_contents(*args, &block)
  796.     maqj_extractsavecons_2kw5(*args, &block) # Call Original Method
  797.     if $game_party.quests.nil?
  798.       $game_party.init_maqj_data
  799.       $game_system.init_maqj_data
  800.     end
  801.   end
  802. end

  803. #==============================================================================
  804. # ** MAQJ_SortedArray
  805. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  806. #  This module mixes in to an array to maintain the sorted order when inserting
  807. #==============================================================================

  808. module MAQJ_SortedArray
  809.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  810.   # * Insert to Array
  811.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  812.   def maqj_insert_sort(el, &block)
  813.     index = bsearch_index(el, 0, size, &block)
  814.     index ? insert(index, el) : push(el)
  815.   end
  816.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  817.   # * Retrieve Index from Binary Search
  818.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  819.   def bsearch_index(el, b = 0, e = size, &block)
  820.     return bsearch_index(el, b, e) { |a,b| a <=> b } if block.nil?
  821.     return b if b == e # Return the discovered insertion index
  822.     return if b > e
  823.     m = (b + e) / 2    # Get Middle
  824.     block.call(el, self[m]) > 0 ? b = m + 1 : e = m
  825.     bsearch_index(el, b, e, &block)
  826.   end
  827. end

  828. #==============================================================================
  829. # ** Game_Quest
  830. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  831. #  This class holds all instance data for a quest
  832. #==============================================================================

  833. class Game_Quest
  834.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  835.   # * Public Instance Variables
  836.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  837.   attr_reader   :id                  # Unique identifier for this quest
  838.   attr_reader   :name                # The name to be shown for the quest
  839.   attr_reader   :level               # The level of difficulty of the quest
  840.   attr_reader   :objectives          # An array of objective strings
  841.   attr_reader   :prime_objectives    # An array of crucial objective IDs
  842.   attr_reader   :revealed_objectives # An array of revealed objective IDs
  843.   attr_reader   :complete_objectives # An array of completed objective IDs
  844.   attr_reader   :failed_objectives   # An array of failed objective IDs
  845.   attr_reader   :custom_categories   # An array of category symbols
  846.   attr_accessor :icon_index          # Icon associated with this quest
  847.   attr_accessor :common_event_id     # ID of common event to call upon complete
  848.   attr_accessor :description         # The description for the quest
  849.   attr_accessor :banner              # Picture shown to represent the quest
  850.   attr_accessor :banner_hue          # The hue of the banner
  851.   attr_accessor :layout              # The layout of this quest in scene
  852.   attr_accessor :rewards             # An array of rewards to show
  853.   attr_accessor :reward_given        # Boolean tracking if quest was rewarded
  854.   attr_accessor :concealed           # Whether or not the quest is visible
  855.   attr_accessor :manual_status       # Quest status if not using prime objectives
  856.   QuestData::BASIC_DATA_TYPES.each { |data_type| attr_accessor(data_type) }
  857.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  858.   # * Object Initialization
  859.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  860.   def initialize(quest_id)
  861.     @id = quest_id
  862.     @concealed = default_value_for(:concealed)
  863.     @reward_given = default_value_for(:reward_given)
  864.     reset
  865.   end
  866.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  867.   # * Reset
  868.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  869.   def reset
  870.     data = QuestData.setup_quest(@id)
  871.     data_symbol_array.each { |meth| instance_variable_set(:"@#{meth}",
  872.       data[meth] ? data[meth] : default_value_for(meth)) }
  873.     @revealed_objectives = [].send(:extend, MAQJ_SortedArray)
  874.     @complete_objectives = [].send(:extend, MAQJ_SortedArray)
  875.     @failed_objectives =   [].send(:extend, MAQJ_SortedArray)
  876.     @manual_status = default_value_for(:manual_status)
  877.   end
  878.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  879.   # * Data Symbol Array
  880.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  881.   def data_symbol_array
  882.     [:name, :level, :objectives, :prime_objectives, :custom_categories,
  883.       :icon_index, :description, :banner, :banner_hue, :common_event_id,
  884.       :layout, :rewards] + QuestData::BASIC_DATA_TYPES
  885.   end
  886.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  887.   # * Default Value
  888.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  889.   def default_value_for(method)
  890.     case method
  891.     when :name then "??????"
  892.     when :description, :banner then ""
  893.     when :level, :banner_hue, :icon_index, :common_event_id then 0
  894.     when :objectives, :rewards, :custom_categories then []
  895.     when :prime_objectives then Array.new(objectives.size) { |x| x }
  896.     when :concealed then QuestData::MANUAL_REVEAL
  897.     when :manual_status then :active
  898.     when :layout, :reward_given then false
  899.     else ""
  900.     end
  901.   end
  902.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  903.   # * Reveal/Conceal Objective
  904.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  905.   def reveal_objective(*obj)
  906.     valid_obj = obj.select {|x| x < objectives.size && !@revealed_objectives.include?(x) }
  907.     valid_obj.each {|i| @revealed_objectives.maqj_insert_sort(i) }
  908.     quest_status_changed unless valid_obj.empty?
  909.   end
  910.   def conceal_objective(*obj)
  911.     quest_status_changed unless (obj & @revealed_objectives).empty?
  912.     obj.each { |obj_id| @revealed_objectives.delete(obj_id) }
  913.   end
  914.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  915.   # * Complete/Uncomplete Objective
  916.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  917.   def complete_objective(*obj)
  918.     valid_obj = obj.select {|x| x < objectives.size && !@complete_objectives.include?(x) }
  919.     reveal_objective(*valid_obj)
  920.     unfail_objective(*valid_obj)
  921.     was_complete = status?(:complete)
  922.     valid_obj.each {|i| @complete_objectives.maqj_insert_sort(i) }
  923.     quest_status_changed unless valid_obj.empty?
  924.     # If just completed
  925.     if status?(:complete) && !was_complete
  926.       $game_temp.reserve_common_event(common_event_id)
  927.       $game_party.quests.add_to_sort_array(:complete, @id)
  928.     end
  929.   end
  930.   def uncomplete_objective(*obj)
  931.     quest_status_changed unless (obj & @complete_objectives).empty?
  932.     obj.each { |obj_id| @complete_objectives.delete(obj_id) }
  933.   end
  934.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  935.   # * Fail/Unfail Objective
  936.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  937.   def fail_objective(*obj)
  938.     valid_obj = obj.select {|x| x < objectives.size && !@failed_objectives.include?(x) }
  939.     reveal_objective(*valid_obj)
  940.     uncomplete_objective(*valid_obj)
  941.     was_failed = status?(:failed)
  942.     valid_obj.each {|i| @failed_objectives.maqj_insert_sort(i) }
  943.     quest_status_changed unless valid_obj.empty?
  944.     $game_party.quests.add_to_sort_array(:failed, @id) if status?(:failed) && !was_failed
  945.   end
  946.   def unfail_objective(*obj)
  947.     quest_status_changed unless (obj & @failed_objectives).empty?
  948.     obj.each { |obj_id| @failed_objectives.delete(obj_id) }
  949.   end
  950.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  951.   # * Updates when the quest status has been changed
  952.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  953.   def quest_status_changed
  954.     $game_party.quests.add_to_sort_array(:change, @id)
  955.     $game_system.last_quest_id = @id if QuestData::OPEN_TO_LAST_CHANGED_QUEST
  956.   end
  957.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  958.   # * Objective Status?
  959.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  960.   def objective_status?(status_check, *obj)
  961.     return false if obj.empty?
  962.     case status_check
  963.     when :failed   then !(obj & @failed_objectives).empty?
  964.     when :complete then obj.size == (obj & @complete_objectives).size
  965.     when :revealed then obj.size == (obj & @revealed_objectives).size
  966.     when :active then objective_status?(:revealed, *obj) &&
  967.       !objective_status?(:complete, *obj) && !objective_status?(:failed, *obj)
  968.     end
  969.   end
  970.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  971.   # * Status?
  972.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  973.   def status?(status_check)
  974.     case status_check
  975.     when :failed  
  976.       @prime_objectives.empty? ? @manual_status == :failed :
  977.         !(@failed_objectives & @prime_objectives).empty?
  978.     when :complete
  979.       @prime_objectives.empty? ? @manual_status == :complete : !status?(:failed) &&
  980.         ((@prime_objectives & @complete_objectives) == @prime_objectives)
  981.     when :active then !concealed && !status?(:complete) && !status?(:failed)
  982.     when :reward then @reward_given
  983.     end
  984.   end
  985.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  986.   # * Set Name
  987.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  988.   def name=(new_name)
  989.     @name = new_name
  990.     $game_party.quests.add_to_sort_array(:alphabet, @id) if $game_party &&
  991.       $game_party.quests
  992.   end
  993.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  994.   # * Set Level
  995.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  996.   def level=(new_lvl)
  997.     @level = new_lvl
  998.     $game_party.quests.add_to_sort_array(:level, @id) if $game_party &&
  999.       $game_party.quests
  1000.   end
  1001. end

  1002. #==============================================================================
  1003. # ** Game_Quests
  1004. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1005. #  This is a wrapper for an array holding Game_Quest objects
  1006. #==============================================================================

  1007. class Game_Quests
  1008.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1009.   # * Object Initialization
  1010.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1011.   def initialize
  1012.     @data = {}
  1013.     @sort_arrays = {
  1014.       reveal: [], change: [], complete: [], failed: [],
  1015.       id:       [].send(:extend, MAQJ_SortedArray),
  1016.       alphabet: [].send(:extend, MAQJ_SortedArray),
  1017.       level:    [].send(:extend, MAQJ_SortedArray)
  1018.     }
  1019.   end
  1020.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1021.   # * Get Quest
  1022.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1023.   def [](quest_id)
  1024.     reset_quest(quest_id) if !@data[quest_id]
  1025.     @data[quest_id]
  1026.   end
  1027.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1028.   # * Set Quest <- Not sure when this would ever be useful.
  1029.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1030.   def []=(quest_id, value)
  1031.     @data[quest_id] = value
  1032.   end
  1033.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1034.   # * List
  1035.   #    list_type : the type of list to return
  1036.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1037.   def list(list_type = :all, sort_type = $game_system.quest_sort_type[list_type])
  1038.     sort_type_s = sort_type.to_s
  1039.     reverse = !(sort_type_s.sub!(/_r$/, "")).nil?
  1040.     sort_type = sort_type_s.to_sym
  1041.     list = @sort_arrays[sort_type].select { |quest_id| include?(quest_id, list_type) }
  1042.     list.reverse! if reverse
  1043.     list.collect { |quest_id| @data[quest_id] }
  1044.   end
  1045.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1046.   # * Include?
  1047.   #    determines whether to include a particular quest depending on list type
  1048.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1049.   def include?(quest_id, list_type = :all)
  1050.     return false if !revealed?(quest_id)
  1051.     case list_type
  1052.     when :all then true
  1053.     when :complete, :failed, :active then @data[quest_id].status?(list_type)
  1054.     else
  1055.       @data[quest_id].custom_categories.include?(list_type)
  1056.     end
  1057.   end
  1058.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1059.   # * Revealed?
  1060.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1061.   def revealed?(quest_id)
  1062.     (!@data[quest_id].nil? && !@data[quest_id].concealed)
  1063.   end
  1064.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1065.   # * Setup Quest
  1066.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1067.   def setup_quest(quest_id)
  1068.     return if @data[quest_id]
  1069.     @data[quest_id] = Game_Quest.new(quest_id)
  1070.     # Open to this quest next time the QJ is opened
  1071.     $game_system.last_quest_id = quest_id if QuestData::OPEN_TO_LAST_REVEALED_QUEST
  1072.     # Save sorting order in separate arrays to avoid re-sorting every time
  1073.     @sort_arrays.keys.each { |sym| add_to_sort_array(sym, quest_id) }
  1074.   end
  1075.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1076.   # * Delete Quest
  1077.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1078.   def delete_quest(quest_id)
  1079.     @data.delete(quest_id)
  1080.     @sort_arrays.values.each { |ary| ary.delete(quest_id) }
  1081.   end
  1082.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1083.   # * Reset Quest
  1084.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1085.   def reset_quest(quest_id)
  1086.     delete_quest(quest_id)
  1087.     setup_quest(quest_id)
  1088.   end
  1089.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1090.   # * Add to Sorted Array
  1091.   #    sort_type : array to alter
  1092.   #    quest_id  : ID of the quest to add.
  1093.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1094.   def add_to_sort_array(sort_type, quest_id)
  1095.     @sort_arrays[sort_type].delete(quest_id) # Make sure always unique
  1096.     case sort_type
  1097.     when :reveal, :change, :complete, :failed
  1098.       @sort_arrays[sort_type].unshift(quest_id)
  1099.     when :id
  1100.       @sort_arrays[sort_type].maqj_insert_sort(quest_id)
  1101.     when :alphabet
  1102.       @sort_arrays[sort_type].maqj_insert_sort(quest_id) { |a, b| @data[a].name.downcase <=> @data[b].name.downcase }
  1103.     when :level
  1104.       @sort_arrays[sort_type].maqj_insert_sort(quest_id) { |a, b| @data[a].level <=> self[b].level }
  1105.     end
  1106.   end
  1107.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1108.   # * Find Location
  1109.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1110.   def find_location(quest_id, cat = nil)
  1111.     if revealed?(quest_id)
  1112.       categories = $game_system.quest_categories.dup
  1113.       # If cat specified, check in that category first.
  1114.       if cat && categories.include?(cat)
  1115.         categories.delete(cat)
  1116.         categories.unshift(cat)
  1117.       end
  1118.       for category in categories # Check all categories
  1119.         index = list(category).index(@data[quest_id])
  1120.         return category, index if index != nil
  1121.       end
  1122.     end
  1123.     return nil, nil
  1124.   end
  1125.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1126.   # * Clear
  1127.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1128.   def clear
  1129.     @data.clear
  1130.   end
  1131. end

  1132. #==============================================================================
  1133. # ** Game System
  1134. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1135. #  Summary of Changes:
  1136. #    new attr_accessor - quest_menu_access; quest_map_access; quest_sort_type;
  1137. #      quest_bg_picture; quest_bg_opacity; quest_windowskin;
  1138. #      quest_window_opacity; quest_access_disabled; last_quest_cat;
  1139. #      last_quest_id
  1140. #    aliased methods - initialize
  1141. #    new methods - init_maqj_data
  1142. #==============================================================================

  1143. class Game_System
  1144.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1145.   # * Public Instance Variables
  1146.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1147.   attr_reader   :quest_menu_access     # Whether the scene is called from menu
  1148.   attr_accessor :quest_map_access      # Whether the scene is called from map
  1149.   attr_accessor :quest_sort_type       # The sort types for each category
  1150.   attr_accessor :quest_bg_picture      # The filename of the background picture
  1151.   attr_accessor :quest_bg_opacity      # The opacity of the background picture
  1152.   attr_accessor :quest_bg_blend_type   # The blend type of the background pic
  1153.   attr_accessor :quest_windowskin      # The windowskin used for the scene
  1154.   attr_accessor :quest_window_tone     # The tone of windows in the scene
  1155.   attr_accessor :quest_window_opacity  # The opacity of windows in the scene
  1156.   attr_accessor :quest_access_disabled # Whether access to Quests is disabled
  1157.   attr_accessor :quest_categories      # The categories to show in the scene
  1158.   attr_accessor :quest_scene_label     # The label to show in the scene
  1159.   attr_accessor :last_quest_cat        # The category to open to
  1160.   attr_accessor :last_quest_id         # The ID to open to
  1161.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1162.   # * Object Initialization
  1163.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1164.   alias maqj_initialze_2cy9 initialize
  1165.   def initialize(*args, &block)
  1166.     maqj_initialze_2cy9(*args, &block)
  1167.     init_maqj_data
  1168.   end
  1169.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1170.   # * Initialize Quest Data
  1171.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1172.   def init_maqj_data
  1173.     # Initialize new variables
  1174.     self.quest_menu_access = QuestData::MENU_ACCESS
  1175.     @quest_map_access = QuestData::MAP_ACCESS
  1176.     @quest_sort_type = QuestData::SORT_TYPE
  1177.     @quest_bg_picture = QuestData::BG_PICTURE
  1178.     @quest_bg_opacity = QuestData::BG_OPACITY
  1179.     @quest_bg_blend_type = QuestData::BG_BLEND_TYPE
  1180.     @quest_windowskin = QuestData::WINDOWSKIN
  1181.     @quest_window_tone = QuestData::WINDOW_TONE
  1182.     @quest_window_opacity = QuestData::WINDOW_OPACITY
  1183.     @quest_access_disabled = false
  1184.     @quest_categories = QuestData::CATEGORIES
  1185.     @quest_scene_label = QuestData::VOCAB[:scene_label]
  1186.     @last_quest_cat = @quest_categories[0]
  1187.     @last_quest_id = 0
  1188.   end
  1189.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1190.   # * Set Quest Menu Access
  1191.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1192.   def quest_menu_access=(boolean)
  1193.     @quest_menu_access = boolean
  1194.     maic_inserted_menu_commands.delete(:quest_journal)
  1195.     maic_inserted_menu_commands.push(:quest_journal) if @quest_menu_access
  1196.     maic_inserted_menu_commands.sort!
  1197.   end
  1198. end

  1199. #==============================================================================
  1200. # ** Game_Party
  1201. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1202. #  Summary of Changes:
  1203. #    new attr_reader - quests
  1204. #    aliased method - initialize
  1205. #    new method - init_maqj_data
  1206. #==============================================================================

  1207. class Game_Party
  1208.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1209.   # * Public Instance Variables
  1210.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1211.   attr_reader :quests
  1212.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1213.   # * Object Initialization
  1214.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1215.   alias maqj_intiaze_2si9 initialize
  1216.   def initialize(*args, &block)
  1217.     maqj_intiaze_2si9(*args, &block) # Call Original Method
  1218.     init_maqj_data
  1219.   end
  1220.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1221.   # * Initialize Quests
  1222.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1223.   def init_maqj_data
  1224.     @quests = Game_Quests.new # Initialize @quests
  1225.   end
  1226. end

  1227. #==============================================================================
  1228. # ** Game_Interpreter
  1229. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1230. #  Summary of Changes:
  1231. #    new methods - change_quest_access; change_quest_background;
  1232. #      change_quest_windows; setup_quest; delete_quest; reset_quest; quest;
  1233. #      reveal_quest; conceal_quest; manually_complete_quest;
  1234. #      manually_fail_quest; reveal_objective; conceal_objective;
  1235. #      complete_objective; uncomplete_objective; fail_objective;
  1236. #      unfail_objective; quest_revealed?; quest_complete?; quest_active?;
  1237. #      quest_failed?; objective_complete?; objective_active?;
  1238. #      objective_failed?; distribute_quest_rewards; distribute_quest_reward;
  1239. #      call_quest_journal
  1240. #==============================================================================

  1241. class Game_Interpreter
  1242.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1243.   # * Change Quest Access
  1244.   #    sym : symbol representing what aspect of access is being changed
  1245.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1246.   def change_quest_access(sym)
  1247.     case sym
  1248.     when :enable then $game_system.quest_access_disabled = false
  1249.     when :disable then $game_system.quest_access_disabled = true
  1250.     when :enable_menu then $game_system.quest_menu_access = true
  1251.     when :disable_menu then $game_system.quest_menu_access = false
  1252.     when :enable_map then $game_system.quest_map_access = true
  1253.     when :disable_map then $game_system.quest_map_access = false
  1254.     end
  1255.   end
  1256.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1257.   # * Change Quest Background
  1258.   #    picture : picture to show in the scene's background
  1259.   #    opacity : opacity of the picture shown in the scene's background
  1260.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1261.   def change_quest_background(picture, opacity = $game_system.quest_bg_opacity,
  1262.       blend_type = $game_system.quest_bg_blend_type)
  1263.     $game_system.quest_bg_picture = picture
  1264.     $game_system.quest_bg_opacity = opacity
  1265.     $game_system.quest_bg_blend_type = blend_type
  1266.   end
  1267.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1268.   # * Change Quest Windows
  1269.   #    skin    : windowskin name to use in the scene
  1270.   #    tone    : tone for the windowskin
  1271.   #    opacity : opacity of windows in the scene
  1272.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1273.   def change_quest_windows(skin, tone = $game_system.quest_window_tone,
  1274.       opacity = $game_system.quest_window_opacity)
  1275.     $game_system.quest_windowskin = skin
  1276.     $game_system.quest_window_tone = tone
  1277.     $game_system.quest_window_opacity = opacity
  1278.   end
  1279.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1280.   # * Setup/Delete/Reset Quest
  1281.   #    quest_id : ID of the quest to be setup or deleted or reset
  1282.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1283.   [:setup_quest, :delete_quest, :reset_quest].each { |method|
  1284.     define_method(:"quest_#{method}") do |quest_id|
  1285.       $game_party.quests.send(method, quest_id)
  1286.     end
  1287.   }
  1288.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1289.   # * Retrieve Quest
  1290.   #    quest_id : ID of the quest to retrieve
  1291.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1292.   def quest(quest_id);         $game_party.quests[quest_id];      end
  1293.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1294.   # * Reveal/Conceal Quest
  1295.   #    quest_id : ID of the quest to be revealed or concealed
  1296.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1297.   def reveal_quest(quest_id);  quest(quest_id).concealed = false; end
  1298.   def conceal_quest(quest_id); quest(quest_id).concealed = true;  end
  1299.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1300.   # * Manually Complete/Fail Quest
  1301.   #    quest_id : ID of the quest to be revealed or concealed
  1302.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1303.   def manually_complete_quest(quest_id)
  1304.     quest(quest_id).prime_objectives.clear
  1305.     quest(quest_id).manual_status = :complete
  1306.   end
  1307.   def manually_fail_quest(quest_id)
  1308.     quest(quest_id).prime_objectives.clear
  1309.     quest(quest_id).manual_status = :failed
  1310.   end
  1311.   def manually_activate_quest(quest_id)
  1312.     quest(quest_id).manual_status = :active
  1313.   end
  1314.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1315.   # * Reveal/Complete/Fail/Conceal/Uncomplete/Unfail Objective
  1316.   #    quest_id : ID of the quest whose objectives will be modified
  1317.   #    *obj     : IDs of objectives to reveal or complete or fail (or opposite)
  1318.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1319.   [:reveal_objective, :complete_objective, :fail_objective, :conceal_objective,
  1320.   :uncomplete_objective, :unfail_objective].each { |method|
  1321.     define_method(method) do |quest_id, *obj|
  1322.       quest(quest_id).send(method, *obj)
  1323.     end
  1324.   }
  1325.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1326.   # * Quest Revealed?
  1327.   #    quest_id : ID of the quest you are checking is revealed
  1328.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1329.   def quest_revealed?(quest_id)
  1330.     $game_party.quests.revealed?(quest_id)
  1331.   end
  1332.   [:complete, :failed, :active].each { |method|
  1333.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1334.     # * Quest Complete/Failed/Active?
  1335.     #    quest_id : ID of the quest whose completion status is being checked
  1336.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1337.     define_method(:"quest_#{method}?") do |quest_id|
  1338.       quest_revealed?(quest_id) && quest(quest_id).status?(method)
  1339.     end
  1340.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1341.     # * Objective Complete/Failed/Active?
  1342.     #    quest_id : ID of the quest whose objectives are being checked
  1343.     #    *obj     : IDs of objectives to check completion status
  1344.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1345.     define_method(:"objective_#{method}?") do |quest_id, *obj|
  1346.       quest_revealed?(quest_id) && quest(quest_id).objective_status?(method, *obj)
  1347.     end
  1348.   }
  1349.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1350.   # * Objective Revealed?
  1351.   #    quest_id : ID of the quest you are checking is revealed
  1352.   #    *obj     : IDs of objectives to check completion status
  1353.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1354.   def objective_revealed?(quest_id, *obj)
  1355.     quest_revealed?(quest_id) && quest(quest_id).objective_status?(:revealed, *obj)
  1356.   end
  1357.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1358.   # * Quest Rewarded?
  1359.   #    quest_id : ID of the quest you are checking is revealed
  1360.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1361.   def quest_rewarded?(quest_id)
  1362.     quest_revealed?(quest_id) && quest(quest_id).status?(:reward)
  1363.   end
  1364.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1365.   # * Change Reward Status
  1366.   #    quest_id : ID of the quest you are checking is revealed
  1367.   #    value    : true or false
  1368.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1369.   def change_reward_status(quest_id, value = true)
  1370.     quest(quest_id).reward_given = value
  1371.   end
  1372.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1373.   # * Distribute Rewards
  1374.   #    quest_id : ID of the quest whose rewards are to be distributed
  1375.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1376.   def distribute_quest_rewards(quest_id)
  1377.     if quest_revealed?(quest_id) && !quest_rewarded?(quest_id)
  1378.       params = @params.dup
  1379.       change_reward_status(quest_id, true)
  1380.       quest(quest_id).rewards.each { |reward| distribute_quest_reward(reward) }
  1381.       @params = params
  1382.       true
  1383.     else
  1384.       false
  1385.     end
  1386.   end
  1387.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1388.   # * Distribute Reward
  1389.   #    reward : an array identifying the reward
  1390.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1391.   def distribute_quest_reward(reward)
  1392.     @params = [reward[1], 0, 0, (reward[2] ? reward[2] : 1)]
  1393.     case reward[0]
  1394.     when :item, 0 then   command_126 # Item
  1395.     when :weapon, 1 then command_127 # Weapon
  1396.     when :armor, 2 then  command_128 # Armor
  1397.     when :gold, 3   # Gold
  1398.       @params = [0, 0, reward[1] ? reward[1] : 0]
  1399.       command_125
  1400.     when :exp, 4    # Exp
  1401.       @params = [0, 0, 0, 0, reward[1] ? reward[1] : 0, true]
  1402.       command_315
  1403.     end
  1404.   end
  1405.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1406.   # * Call Quest Journal
  1407.   #    quest_id : ID of the quest to open the journal to
  1408.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1409.   def call_quest_journal(quest_id = nil)
  1410.     return if $game_party.in_battle
  1411.     $game_system.last_quest_id = quest_id if quest_id
  1412.     SceneManager.call(Scene_Quest)
  1413.     Fiber.yield
  1414.   end
  1415. end

  1416. unless $imported[:"MA_ParagraphFormat_1.0"]
  1417. #==============================================================================
  1418. # ** MA_Window_ParagraphFormat
  1419. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1420. #  This module inserts into Window_Base and provides a method to format the
  1421. # strings so as to go to the next line if it exceeds a set limit. This is
  1422. # designed to work with draw_text_ex, and a string formatted by this method
  1423. # should go through that, not draw_text.
  1424. #==============================================================================

  1425. module MA_Window_ParagraphFormat
  1426.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1427.   # * Calc Line Width
  1428.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1429.   def mapf_calc_line_width(line, tw = 0, contents_dummy = false)
  1430.     return tw if line.nil?
  1431.     line = line.clone
  1432.     unless contents_dummy
  1433.       real_contents = contents # Preserve Real Contents
  1434.       # Create a dummy contents
  1435.       self.contents = Bitmap.new(contents_width, 24)
  1436.       reset_font_settings
  1437.     end
  1438.     pos = {x: 0, y: 0, new_x: 0, height: calc_line_height(line)}
  1439.     while line[/^(.*?)\e(.*)/]
  1440.       tw += text_size($1).width
  1441.       line = $2
  1442.       # Remove all ancillaries to the code, like parameters
  1443.       code = obtain_escape_code(line)
  1444.       # If direct setting of x, reset tw.
  1445.       tw = 0 if ($imported[:ATS_SpecialMessageCodes] && code.upcase == 'X') ||
  1446.         ($imported["YEA-MessageSystem"] && code.upcase == 'PX')
  1447.       #  If I need to do something special on the basis that it is testing,
  1448.       # alias process_escape_character and differentiate using @atsf_testing
  1449.       process_escape_character(code, line, pos)
  1450.     end
  1451.     #  Add width of remaining text, as well as the value of pos[:x] under the
  1452.     # assumption that any additions to it are because the special code is
  1453.     # replaced by something which requires space (like icons)
  1454.     tw += text_size(line).width + pos[:x]
  1455.     unless contents_dummy
  1456.       contents.dispose # Dispose dummy contents
  1457.       self.contents = real_contents # Restore real contents
  1458.     end
  1459.     return tw
  1460.   end
  1461.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1462.   # * Format Paragraph
  1463.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1464.   def mapf_format_paragraph(text, max_width = contents_width)
  1465.     text = text.clone
  1466.     #  Create a Dummy Contents - I wanted to boost compatibility by using the
  1467.     # default process method for escape codes. It may have the opposite effect,
  1468.     # for some :(
  1469.     real_contents = contents # Preserve Real Contents
  1470.     self.contents = Bitmap.new(contents_width, 24)
  1471.     reset_font_settings
  1472.     paragraph = ""
  1473.     while !text.empty?
  1474.       text.lstrip!
  1475.       oline, nline, tw = mapf_format_by_line(text.clone, max_width)
  1476.       # Replace old line with the new one
  1477.       text.sub!(/#{Regexp.escape(oline)}/m, nline)
  1478.       paragraph += text.slice!(/.*?(\n|$)/)
  1479.     end
  1480.     contents.dispose # Dispose dummy contents
  1481.     self.contents = real_contents # Restore real contents
  1482.     return paragraph
  1483.   end
  1484.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1485.   # * Format By Line
  1486.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1487.   def mapf_format_by_line(text, max_width = contents_width)
  1488.     oline, nline, tw = "", "", 0
  1489.     loop do
  1490.       #  Format each word until reach the width limit
  1491.       oline, nline, tw, done = mapf_format_by_word(text, nline, tw, max_width)
  1492.       return oline, nline, tw if done
  1493.     end
  1494.   end
  1495.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1496.   # * Format By Word
  1497.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1498.   def mapf_format_by_word(text, line, tw, max_width)
  1499.     return line, line, tw, true if text.nil? || text.empty?
  1500.     # Extract next word
  1501.     if text.sub!(/(\s*)([^\s\n\f]*)([\n\f]?)/, "") != nil
  1502.       prespace, word, line_end = $1, $2, $3
  1503.       ntw = mapf_calc_line_width(word, tw, true)
  1504.       pw = contents.text_size(prespace).width
  1505.       if (pw + ntw >= max_width)
  1506.         # Insert
  1507.         if line.empty?
  1508.           # If one word takes entire line
  1509.           return prespace + word, word + "\n", ntw, true
  1510.         else
  1511.           return line + prespace + word, line + "\n" + word, tw, true
  1512.         end
  1513.       else
  1514.         line += prespace + word
  1515.         tw = pw + ntw
  1516.         # If the line is force ended, then end
  1517.         return line, line, tw, true if !line_end.empty?
  1518.       end
  1519.     else
  1520.       return line, line, tw, true
  1521.     end
  1522.     return line, line, tw, false
  1523.   end
  1524. end

  1525. class Window_Base
  1526.   include MA_Window_ParagraphFormat
  1527. end

  1528. $imported[:"MA_ParagraphFormat_1.0"] = true
  1529. end

  1530. #==============================================================================
  1531. # *** MAQJ Window_QuestBase
  1532. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1533. #  This module mixes in with all quest windows
  1534. #==============================================================================

  1535. module MAQJ_Window_QuestBase
  1536.   attr_reader :maqj_objective_color
  1537.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1538.   # * Object Initialization
  1539.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1540.   def initialize(*args, &block)
  1541.     super(*args, &block)
  1542.     reset_font_settings
  1543.     set_data_font(:normal)
  1544.     @maqj_default_font = contents.font.dup
  1545.     # Change the windowskin, tone if they are set to be changed
  1546.     self.windowskin = Cache.system($game_system.quest_windowskin) if $game_system.quest_windowskin
  1547.     self.opacity = $game_system.quest_window_opacity if $game_system.quest_window_opacity
  1548.   end
  1549.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1550.   # * Reset Font Settings
  1551.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1552.   def reset_font_settings(*args, &block)
  1553.     super(*args, &block)
  1554.     set_data_font(@maqj_font_data_type) if @maqj_font_data_type
  1555.   end
  1556.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1557.   # * Set Data Font
  1558.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1559.   def set_data_font(data_type)
  1560.     @maqj_default_font = contents.font.dup unless @maqj_default_font
  1561.     contents.font.name = QuestData::FONTNAMES[data_type] ?
  1562.       QuestData::FONTNAMES[data_type] : @maqj_default_font.name
  1563.     contents.font.size = QuestData::FONTSIZES[data_type] ?
  1564.       QuestData::FONTSIZES[data_type] : @maqj_default_font.size
  1565.     contents.font.bold = QuestData::FONTBOLDS.keys.include?(data_type) ?
  1566.       QuestData::FONTBOLDS[data_type] : @maqj_default_font.bold
  1567.     contents.font.italic = QuestData::FONTITALICS.keys.include?(data_type) ?
  1568.       QuestData::FONTITALICS[data_type] : @maqj_default_font.italic
  1569.     case data_type
  1570.     when :objectives then change_color(@maqj_objective_color) if @maqj_objective_color
  1571.     when :name then change_color(quest_name_colour(@quest)) if @quest
  1572.     else
  1573.       change_color(text_color(QuestData::COLOURS[data_type])) if QuestData::COLOURS.keys.include?(data_type)
  1574.     end
  1575.   end
  1576.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1577.   # * Draw Horizontal Line
  1578.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1579.   def draw_horizontal_line(y, h = 2)
  1580.     contents.fill_rect(0, y, contents_width, h, text_color(QuestData::COLOURS[:line]))
  1581.     contents.fill_rect(0, y + h, contents_width, [h / 2, 1].max, text_color(QuestData::COLOURS[:line_shadow]))
  1582.   end
  1583.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1584.   # * MA Text Color
  1585.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1586.   def text_color(param)
  1587.     begin
  1588.       colour = case param
  1589.       when Integer then super(param) rescue normal_color
  1590.       when Symbol then send(param) rescue normal_color
  1591.       when Array then Color.new(*param) rescue normal_color
  1592.       else
  1593.         normal_color
  1594.       end
  1595.     end
  1596.     colour.is_a?(Color) ? colour : normal_color
  1597.   end
  1598.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1599.   # * Quest Name Colour
  1600.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1601.   def quest_name_colour(quest = @quest)
  1602.     return if !quest
  1603.     quest = $game_party.quests[quest] if quest.is_a?(Integer)
  1604.     s = [:failed, :complete, :active].find { |status| quest.status?(status) }
  1605.     text_color(QuestData::COLOURS[s])
  1606.   end
  1607.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1608.   # * Quest Objective Colour
  1609.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1610.   def quest_objective_colour(quest, obj_id)
  1611.     return if !quest
  1612.     quest = $game_party.quests[quest] if quest.is_a?(Integer)
  1613.     s = [:failed, :complete, :active].find { |status| quest.objective_status?(status, obj_id) }
  1614.     text_color(QuestData::COLOURS[s])
  1615.   end
  1616.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1617.   # * Update Tone
  1618.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1619.   def update_tone
  1620.     $game_system.quest_window_tone ?
  1621.       self.tone.set(*$game_system.quest_window_tone) : super
  1622.   end
  1623. end

  1624. unless $imported[:"MA_IconHorzCommand_1.0"]
  1625. #==============================================================================
  1626. # ** Window_MA_IconHorzCommand
  1627. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1628. #  This window is a base window to show a horizontal command window populated
  1629. # with icons.
  1630. #==============================================================================

  1631. class Window_MA_IconHorzCommand < Window_HorzCommand
  1632.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1633.   # * Public Instance Variable
  1634.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1635.   attr_reader   :observing_procs
  1636.   attr_accessor :cursor_hide
  1637.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1638.   # * Object Initialization
  1639.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1640.   def initialize(*args, &block)
  1641.     @observing_procs = {}
  1642.     super(*args, &block)
  1643.   end
  1644.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1645.   # * Column Max
  1646.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1647.   def col_max; [(width - standard_padding) / (24 + spacing), item_max].min; end
  1648.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1649.   # * Item
  1650.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1651.   def item
  1652.     @list[index] ? @list[index][:symbol] : nil
  1653.   end
  1654.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1655.   # * Enabled? / Current Item Enabled?
  1656.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1657.   def enable?(index); self.index == index; end
  1658.   def current_item_enabled?; !current_data.nil?; end
  1659.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1660.   # * Draw Item
  1661.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1662.   def draw_item(index)
  1663.     rect = item_rect(index)
  1664.     contents.clear_rect(rect)
  1665.     draw_icon(@list[index][:ext], rect.x + ((rect.width - 24) / 2), rect.y, enable?(index))
  1666.   end
  1667.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1668.   # * Set Index
  1669.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1670.   def index=(index)
  1671.     old_index = self.index
  1672.     super(index)
  1673.     draw_item(old_index)
  1674.     draw_item(self.index)
  1675.   end
  1676.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1677.   # * Frame Update
  1678.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1679.   def update
  1680.     super
  1681.     @observing_procs.values.each { |block| block.call(item) }
  1682.   end
  1683.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1684.   # * Add/Remove Observing Window
  1685.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1686.   def add_observing_proc(id, &block)
  1687.     @observing_procs[id] = block
  1688.     update
  1689.   end
  1690.   def remove_observing_proc(id)     ; @observing_procs.delete(id) ; end
  1691.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1692.   # * Update Cursor
  1693.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1694.   def update_cursor
  1695.     super
  1696.     cursor_rect.empty if @cursor_hide
  1697.   end
  1698. end
  1699. $imported[:"MA_IconHorzCommand_1.0"] = true
  1700. end

  1701. #==============================================================================
  1702. # ** Window_QuestCategory
  1703. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1704. #  This window allows the player to switch between quest categories.
  1705. #==============================================================================

  1706. class Window_QuestCategory < Window_MA_IconHorzCommand
  1707.   include MAQJ_Window_QuestBase
  1708.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1709.   # * Object Initialization
  1710.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1711.   def initialize(x, y, categories = $game_system.quest_categories)
  1712.     @cursor_hide = QuestData::HIDE_CATEGORY_CURSOR
  1713.     @categories = categories
  1714.     super(x, y)
  1715.   end
  1716.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1717.   # * Window Width
  1718.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1719.   def window_width; QuestData::LIST_WINDOW_WIDTH; end
  1720.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1721.   # * Category=
  1722.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1723.   def category=(category)
  1724.     self.index = @categories.index(category) if @categories.include?(category)
  1725.   end
  1726.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1727.   # * Make Command List
  1728.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1729.   def make_command_list
  1730.     @categories.each { |cat|
  1731.       add_command("", cat, false, QuestData::ICONS[cat]) }
  1732.   end
  1733. end

  1734. #==============================================================================
  1735. # ** Window QuestLabel
  1736. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1737. #  This window simply shows a label for the Quests scene
  1738. #==============================================================================

  1739. class Window_QuestLabel < Window_Base
  1740.   include MAQJ_Window_QuestBase
  1741.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1742.   # * Object Initialization
  1743.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1744.   def initialize(x, y, label = "")
  1745.     super(x, y, window_width, window_height)
  1746.     refresh(label)
  1747.   end
  1748.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1749.   # * Reset Font Settings
  1750.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1751.   def reset_font_settings; set_data_font(:scene_label); end
  1752.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1753.   # * Window Attributes
  1754.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1755.   def window_width
  1756.     w = ($game_system.quest_categories.size > 1 || QuestData::SHOW_CATEGORY_LABEL) ?
  1757.       Graphics.width - QuestData::LIST_WINDOW_WIDTH : QuestData::LIST_WINDOW_WIDTH
  1758.   end
  1759.   def window_height; line_height + (standard_padding*2); end
  1760.   def line_height(*args)
  1761.     line_h = super(*args)
  1762.     QuestData::FONTSIZES[:scene_label] ?
  1763.       [QuestData::FONTSIZES[:scene_label], line_h].max : line_h
  1764.   end
  1765.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1766.   # * Refresh
  1767.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1768.   def refresh(label = @label)
  1769.     @label = label.is_a?(String) ? convert_escape_characters(label) : ""
  1770.     contents.clear
  1771.     reset_font_settings
  1772.     tw = mapf_calc_line_width(@label)
  1773.     draw_text_ex((contents_width - tw) / 2, 0, @label)
  1774.   end
  1775. end

  1776. #==============================================================================
  1777. # ** Window QuestLabel
  1778. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1779. #  This window simply shows a label for category currently selected
  1780. #==============================================================================

  1781. class Window_QuestCategoryLabel < Window_QuestLabel
  1782.   include MAQJ_Window_QuestBase
  1783.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1784.   # * Reset Font Settings
  1785.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1786.   def reset_font_settings; set_data_font(:category_label); end
  1787.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1788.   # * Window Attributes
  1789.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1790.   def window_width; QuestData::LIST_WINDOW_WIDTH; end
  1791.   def line_height(*args)
  1792.     line_h = super(*args)
  1793.     QuestData::FONTSIZES[:category_label] ?
  1794.       [QuestData::FONTSIZES[:category_label], line_h].max : line_h
  1795.   end
  1796.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1797.   # * Set Category
  1798.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1799.   def category=(category)
  1800.     return if @category == category
  1801.     @category = category
  1802.     refresh(QuestData::CATEGORY_VOCAB[category])
  1803.   end
  1804. end

  1805. #==============================================================================
  1806. # ** Window_QuestCategoryDummy
  1807. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1808. #  This window shows up behind the category and category label window
  1809. #==============================================================================

  1810. class Window_QuestCategoryDummy < Window_Base
  1811.   include MAQJ_Window_QuestBase
  1812. end

  1813. #==============================================================================
  1814. # ** Window_QuestList
  1815. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1816. #  This window shows all quests in a selected category.
  1817. #==============================================================================

  1818. class Window_QuestList < Window_Selectable
  1819.   include MAQJ_Window_QuestBase
  1820.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1821.   # * Object Initialization
  1822.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1823.   def initialize(x, y, width, height)
  1824.     super
  1825.     @data = []
  1826.     self.index = 0
  1827.     activate
  1828.   end
  1829.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1830.   # * Set Category
  1831.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1832.   def category=(category)
  1833.     return if @category == category
  1834.     @category = category
  1835.     refresh
  1836.     self.index = 0
  1837.     update_help if @help_window
  1838.   end
  1839.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1840.   # * Get Quest
  1841.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1842.   def item; @data && index >= 0 ? @data[index] : nil; end
  1843.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1844.   # * Column/Item Max
  1845.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1846.   def col_max; 1; end
  1847.   def item_max; @data ? @data.size : 1; end
  1848.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1849.   # * Whether it should be drawn enabled
  1850.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1851.   def enable?(item); true; end
  1852.   def current_item_enabled?
  1853.     (@help_window && @help_window.maqj_visible_height < @help_window.contents_height)
  1854.   end
  1855.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1856.   # * Make Item List
  1857.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1858.   def make_item_list
  1859.     @data = @category ? $game_party.quests.list(@category) : []
  1860.   end
  1861.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1862.   # * Draw Item
  1863.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1864.   def draw_item(index)
  1865.     quest = @data[index]
  1866.     if quest
  1867.       rect = item_rect_for_text(index)
  1868.       if QuestData::SHOW_QUEST_ICONS
  1869.         draw_icon(quest.icon_index, rect.x, rect.y, enable?(quest))
  1870.         rect.x += 24
  1871.         rect.width -= 24
  1872.       end
  1873.       change_color(quest_name_colour(quest), enable?(quest))
  1874.       draw_text(rect, quest.name)
  1875.     end
  1876.   end
  1877.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1878.   # * Refresh
  1879.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1880.   def refresh
  1881.     make_item_list
  1882.     create_contents
  1883.     set_data_font(:list)
  1884.     draw_all_items
  1885.   end
  1886.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1887.   # * Update Help
  1888.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1889.   def update_help
  1890.     @help_window.quest = item
  1891.   end
  1892. end

  1893. #==============================================================================
  1894. # ** Window_QuestData
  1895. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1896. #  This window shows all quest data
  1897. #==============================================================================

  1898. class Window_QuestData < Window_Selectable
  1899.   include MAQJ_Window_QuestBase
  1900.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1901.   # * Object Initialization
  1902.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1903.   def initialize(x, y, w, h, layout = QuestData::DATA_LAYOUT)
  1904.     @dest_scroll_oy = 0
  1905.     super(x, y, w, h)
  1906.     @dest_scroll_oy = self.oy
  1907.     self.layout = layout
  1908.   end
  1909.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1910.   # * Contents Height
  1911.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1912.   alias maqj_visible_height contents_height
  1913.   def contents_height
  1914.     @q_contents_height ? [@q_contents_height, maqj_visible_height].max : maqj_visible_height
  1915.   end
  1916.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1917.   # * Calculate Contents Height
  1918.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1919.   def calc_contents_height
  1920.     @q_contents_height = 0
  1921.     @layout.each { |dt| @q_contents_height += data_height(dt) } if @quest
  1922.   end
  1923.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1924.   # * Draw Data?
  1925.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1926.   def draw_data?(data_type)
  1927.     case data_type
  1928.     when :line then true
  1929.     when :level then @quest.level > 0
  1930.     when :objectives then [email protected]_objectives.empty?
  1931.     when Array then (data_type - [:line]).any? { |dt| draw_data?(dt) }
  1932.     else [email protected](data_type).empty? # :description, :name, etc...
  1933.     end
  1934.   end
  1935.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1936.   # * Get Data Height
  1937.   #    This method calculates the height required for a specified element of
  1938.   #   the current quest. This is to calculate the needed space in contents,
  1939.   #   as well as advance the @draw_y variable.
  1940.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1941.   def data_height(data_type)
  1942.     return 0 unless draw_data?(data_type)
  1943.     return line_height if QuestData::BASIC_DATA_TYPES.include?(data_type)
  1944.     @maqj_font_data_type = data_type
  1945.     reset_font_settings
  1946.     return case data_type
  1947.     when :line, :level, :name then line_height
  1948.     when :banner
  1949.       bmp = Cache.picture(@quest.banner)
  1950.       hght = bmp.rect.height
  1951.       bmp.dispose
  1952.       hght
  1953.     when :description
  1954.       buff = description_x*2
  1955.       paragraph = mapf_format_paragraph(@quest.description, contents_width - buff)
  1956.       line_num = paragraph.scan(/\n/).size + 1
  1957.       line_num += (QuestData::DESCRIPTION_IN_BOX ? 2 :
  1958.         !QuestData::VOCAB[:description].empty? ? 1 : 0)
  1959.       line_num*line_height
  1960.     when :objectives
  1961.       objectives = @quest.revealed_objectives.collect { |obj_id|
  1962.         @quest.objectives[obj_id] }
  1963.       line_num = QuestData::VOCAB[:objectives].empty? ? 0 : 1
  1964.       buff = (objective_x*2) + text_size(QuestData::VOCAB[:objective_bullet]).width
  1965.       objectives.each { |obj|
  1966.         paragraph = mapf_format_paragraph(obj, contents_width - buff)
  1967.         line_num += paragraph.scan(/\n/).size + 1 }
  1968.       line_num*line_height
  1969.     when :rewards
  1970.       line_num = QuestData::VOCAB[:rewards].empty? ? 0 : 1
  1971.       (line_num + @quest.rewards.size)*line_height
  1972.     when Array then data_height(data_type.max_by { |dt| data_height(dt) })
  1973.     else 0
  1974.     end
  1975.   end
  1976.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1977.   # * Set Quest
  1978.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1979.   def quest=(value)
  1980.     return if @quest == value
  1981.     @quest = value
  1982.     @layout = (@quest && @quest.layout) ? @quest.layout : @default_layout
  1983.     refresh
  1984.   end
  1985.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1986.   # * Set Layout
  1987.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1988.   def layout=(value)
  1989.     return if @default_layout == value && @layout == value
  1990.     @default_layout = value
  1991.     @layout = value
  1992.     refresh
  1993.   end
  1994.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1995.   # * Refresh
  1996.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1997.   def refresh
  1998.     contents.clear
  1999.     calc_contents_height
  2000.     create_contents
  2001.     return unless @quest && @layout
  2002.     self.oy = 0
  2003.     @dest_scroll_oy = 0
  2004.     #  The basic idea here is that each draw_ method will rely on and advance
  2005.     # the @draw_y variable. Where they are an array, the elements will be
  2006.     # drawn at the same @draw_y.
  2007.     @draw_y = 0
  2008.     @layout.each {|dt|
  2009.       next unless draw_data?(dt)
  2010.       dt.is_a?(Array) ? draw_data_array(dt) : draw_data(dt)
  2011.     }
  2012.   end
  2013.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2014.   # * Draw Data
  2015.   #    data_type : the data block to draw next
  2016.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2017.   def draw_data(data_type)
  2018.     @maqj_font_data_type = data_type
  2019.     reset_font_settings
  2020.     send(:"draw_#{data_type}") if self.class.method_defined?(:"draw_#{data_type}")
  2021.     @draw_y += data_height(data_type)
  2022.   end
  2023.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2024.   # * Draw Data Array
  2025.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2026.   def draw_data_array(layout_array)
  2027.     y, max_y = @draw_y, @draw_y
  2028.     # Draw each data aspect at the same starting @draw_y
  2029.     layout_array.each { |dt|
  2030.       @draw_y = y
  2031.       draw_data(dt)
  2032.       max_y = @draw_y if @draw_y > max_y
  2033.     }
  2034.     @draw_y = max_y
  2035.   end
  2036.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2037.   # * Draw Line
  2038.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2039.   def draw_line; draw_horizontal_line(@draw_y + (line_height / 2) - 1, 2); end
  2040.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2041.   # * Draw Name
  2042.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2043.   def draw_name
  2044.     set_data_font(:name)
  2045.     clear_and_draw_text(0, @draw_y, contents_width, line_height, @quest.name, 1)
  2046.   end
  2047.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2048.   # * Draw Level
  2049.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2050.   def draw_level
  2051.     case QuestData::LEVEL_ICON
  2052.     when Array then QuestData::LEVEL_ICON.empty? ? draw_level_text : draw_level_array
  2053.     when 0 then draw_level_text
  2054.     else
  2055.       draw_level_stacked
  2056.     end
  2057.   end
  2058.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2059.   # * Draw Stacked Level
  2060.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2061.   def draw_level_stacked(icon_index = QuestData::LEVEL_ICON)
  2062.     align = QuestData::HEADING_ALIGN[:level]
  2063.     es = QuestData::LEVEL_ICONS_SPACE*(@quest.level - 1)
  2064.     x = align == 2 ? contents_width - 24 : align == 1 ?
  2065.       (contents_width - 24 - (es)) / 2 : es
  2066.     @quest.level.times do
  2067.       draw_icon(icon_index, x, @draw_y)
  2068.       x -= QuestData::LEVEL_ICONS_SPACE
  2069.     end
  2070.   end
  2071.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2072.   # * Draw Array Level
  2073.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2074.   def draw_level_array(icon_index = QuestData::LEVEL_ICON)
  2075.     return if icon_index.empty?
  2076.     icon_index = icon_index[@quest.level - 1] ? icon_index[@quest.level - 1] : icon_index[-1]
  2077.     align = QuestData::HEADING_ALIGN[:level]
  2078.     x = align == 2 ? contents_width - 24 : align == 1 ? (contents_width-24)/2 : 0
  2079.     draw_icon(icon_index, x, @draw_y)
  2080.   end
  2081.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2082.   # * Draw Text Level
  2083.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2084.   def draw_level_text
  2085.     reset_font_settings
  2086.     level = QuestData::LEVEL_SIGNALS && QuestData::LEVEL_SIGNALS[@quest.level - 1] ?
  2087.       QuestData::LEVEL_SIGNALS[@quest.level - 1] : @quest.level.to_s
  2088.     align = QuestData::HEADING_ALIGN[:level]
  2089.     tw = text_size(QuestData::VOCAB[:level]).width + 4
  2090.     tw2 = text_size(level).width + 2
  2091.     space = contents_width - tw - tw2
  2092.     x = align == 2 ? space : align == 1 ? space / 2 : 0
  2093.     clear_and_draw_text(x, @draw_y, tw, line_height, QuestData::VOCAB[:level])
  2094.     set_data_font(:level_signal)
  2095.     clear_and_draw_text(x + tw, @draw_y, tw2, line_height, level, 2)
  2096.   end
  2097.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2098.   # * Draw Banner
  2099.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2100.   def draw_banner
  2101.     bmp = Cache.picture(@quest.banner) # Get Picture
  2102.     # Shift the hue if requested
  2103.     bmp.hue_change(@quest.banner_hue) unless @quest.banner_hue == 0
  2104.     x = (contents_width - bmp.rect.width) / 2
  2105.     if x < 0 # Stretch horizontally if the banner is too wide
  2106.       dest_rect = bmp.rect.dup
  2107.       dest_rect.width = contents_width
  2108.       contents.stretch_blt(dest_rect, bmp, bmp.rect)
  2109.     else
  2110.       contents.blt(x, @draw_y, bmp, bmp.rect)
  2111.     end
  2112.     bmp.dispose
  2113.   end
  2114.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2115.   # * Draw Description
  2116.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2117.   def draw_description
  2118.     buff = description_x*2
  2119.     paragraph = mapf_format_paragraph(@quest.description, contents_width - buff)
  2120.     y = @draw_y
  2121.     # Draw Rect
  2122.     draw_box(paragraph.scan(/\n/).size + 1) if QuestData::DESCRIPTION_IN_BOX
  2123.     # Draw Description Label
  2124.     draw_heading(:description, y) unless QuestData::VOCAB[:description].empty?
  2125.     # Draw Description
  2126.     y += line_height if !QuestData::VOCAB[:description].empty? || QuestData::DESCRIPTION_IN_BOX
  2127.     draw_text_ex(description_x, y, paragraph)
  2128.   end
  2129.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2130.   # * Draw Objectives
  2131.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2132.   def draw_objectives
  2133.     y = @draw_y
  2134.     unless QuestData::VOCAB[:objectives].empty?
  2135.       draw_heading(:objectives, y)
  2136.       y += line_height
  2137.     end
  2138.     @quest.revealed_objectives.each { |obj_id| y = draw_objective(obj_id, y) }
  2139.   end
  2140.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2141.   # * Draw Objective
  2142.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2143.   def draw_objective(obj_id, y)
  2144.     bullet = QuestData::VOCAB[:objective_bullet]
  2145.     bullet_tw = text_size(bullet).width + 2
  2146.     buff = (objective_x*2) + bullet_tw
  2147.     paragraph = mapf_format_paragraph(@quest.objectives[obj_id], contents_width - buff)
  2148.     line_num = 1 + paragraph.scan(/\n/).size
  2149.     # Since draw_text_ex resets the font, set colour here
  2150.     @maqj_objective_color = quest_objective_colour(@quest, obj_id)
  2151.     change_color(text_color(QuestData::COLOURS[:objective_bullet]))
  2152.     draw_text(objective_x, y, bullet_tw, line_height, sprintf(bullet, obj_id + 1))
  2153.     draw_text_ex(objective_x + bullet_tw, y, paragraph)
  2154.     @maqj_objective_color = false
  2155.     y += (line_num*line_height)
  2156.   end
  2157.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2158.   # * Draw Rewards
  2159.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2160.   def draw_rewards
  2161.     y = @draw_y
  2162.     unless QuestData::VOCAB[:rewards].empty?
  2163.       draw_heading(:rewards, y)
  2164.       y += line_height
  2165.     end
  2166.     for i in [email][email protected][/email] do draw_reward(i, y + i*line_height) end
  2167.   end
  2168.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2169.   # * Draw Reward
  2170.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2171.   def draw_reward(r_id, y)
  2172.     reward = @quest.rewards[r_id]
  2173.     case reward[0]
  2174.     when :item, 0   # Item
  2175.       draw_item_reward(y, $data_items[reward[1]], reward[2] ? reward[2] : 1)
  2176.     when :weapon, 1 # Weapon
  2177.       draw_item_reward(y, $data_weapons[reward[1]], reward[2] ? reward[2] : 1)
  2178.     when :armor, 2  # Armor
  2179.       draw_item_reward(y, $data_armors[reward[1]], reward[2] ? reward[2] : 1)
  2180.     when :gold, 3   # Gold
  2181.       draw_basic_data(y, QuestData::ICONS[:reward_gold],
  2182.         QuestData::VOCAB[:reward_gold], (reward[1] ? reward[1] : 0).to_s)
  2183.     when :exp, 4    # Exp
  2184.       draw_basic_data(y, QuestData::ICONS[:reward_exp],
  2185.         QuestData::VOCAB[:reward_exp], (reward[1] ? reward[1] : 0).to_s)
  2186.     when :string, 5 # String
  2187.       draw_basic_data(y, reward[1] ? reward[1] : 0, reward[3] ? reward[3] : "",
  2188.         reward[2] ? reward[2] : "")
  2189.     end
  2190.   end
  2191.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2192.   # * Draw Item Reward
  2193.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2194.   def draw_item_reward(y, item, amount = 1)
  2195.     w = contents_width
  2196.     w = QuestData::BASIC_DATA_WIDTH if QuestData::BASIC_DATA_WIDTH.between?(1, w)
  2197.     x = (contents_width - w) / 2
  2198.     draw_item_name(item, x, y, true, w - 40)
  2199.     if amount > 1
  2200.       change_color(text_color(QuestData::COLOURS[:reward_amount]))
  2201.       draw_text(x + w - 40, y, 40, line_height, sprintf(QuestData::VOCAB[:reward_amount], amount), 2)
  2202.     end
  2203.   end
  2204.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2205.   # * Draw Basic Data Methods
  2206.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2207.   QuestData::BASIC_DATA_TYPES.each { |data_type|
  2208.     define_method(:"draw_#{data_type}") {
  2209.       draw_basic_data(@draw_y, QuestData::ICONS[data_type],
  2210.         QuestData::VOCAB[data_type], @quest.send(data_type))
  2211.     }
  2212.   }
  2213.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2214.   # * Draw Basic Data
  2215.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2216.   def draw_basic_data(y, icon_index, vocab, value)
  2217.     w = contents_width
  2218.     w = QuestData::BASIC_DATA_WIDTH if QuestData::BASIC_DATA_WIDTH.between?(1, w)
  2219.     x = (contents_width - w) / 2
  2220.     unless icon_index == 0
  2221.       draw_icon(icon_index, x, y)
  2222.       x += 24
  2223.       w -= 24
  2224.     end
  2225.     tw = text_size(vocab).width
  2226.     change_color(text_color(QuestData::COLOURS[:basic_label]))
  2227.     draw_text(x, y, tw, line_height, vocab)
  2228.     change_color(text_color(QuestData::COLOURS[:basic_value]))
  2229.     draw_text(x + tw, y, w - tw, line_height, value, 2)
  2230.   end
  2231.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2232.   # * Draw Heading
  2233.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2234.   def draw_heading(data_type, y)
  2235.     set_data_font(:heading)
  2236.     clear_and_draw_text(40, y, contents_width - 80, line_height,
  2237.       QuestData::VOCAB[data_type], QuestData::HEADING_ALIGN[data_type])
  2238.     reset_font_settings
  2239.   end
  2240.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2241.   # * Clear and Draw Text
  2242.   #    Clear the field before drawing the text
  2243.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2244.   def clear_and_draw_text(*args)
  2245.     rect = []
  2246.     while !args[0].is_a?(String) do rect.push(args.shift) end
  2247.     rect[0].is_a?(Rect) ? rect = rect[0] : rect = Rect.new(*rect)
  2248.     align = args[1] ? args[1] : 0
  2249.     ts = text_size(args[0])
  2250.     ts.width = [ts.width + 4, rect.width].min
  2251.     align == 1 ? ts.x = rect.x + ((rect.width - ts.width) / 2) :
  2252.       align == 2 ? ts.x = rect.x + rect.width - ts.width : ts.x = rect.x
  2253.     ts.y = rect.y
  2254.     contents.clear_rect(ts)
  2255.     ts.x += 2
  2256.     draw_text(ts, args[0], align)
  2257.   end
  2258.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2259.   # * Draw Description Box
  2260.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2261.   def draw_box(line_num)
  2262.     return if line_num < 1
  2263.     x = (line_height / 2) - 1
  2264.     y = @draw_y + (line_height / 2) - 1
  2265.     w = contents_width - 2*x
  2266.     h = (1 + line_num)*line_height
  2267.     draw_rect_outline_with_shadow(x, y, w, h)
  2268.   end
  2269.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2270.   # * Draw Rect Outline
  2271.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2272.   def draw_rect_outline(x, y, w, h, colour)
  2273.     # Horizontal Lines
  2274.     contents.fill_rect(x, y, w, 2, colour)
  2275.     contents.fill_rect(x, y + h - 2, w, 2, colour)
  2276.     # Vertical Lines
  2277.     contents.fill_rect(x, y, 2, h, colour)
  2278.     contents.fill_rect(x + w - 2, y, 2, h, colour)
  2279.   end
  2280.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2281.   # * Draw Rect Outline with Shadow
  2282.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2283.   def draw_rect_outline_with_shadow(x, y, w, h)
  2284.     draw_rect_outline(x + 1, y + 1, w, h, text_color(QuestData::COLOURS[:line_shadow]))
  2285.     draw_rect_outline(x, y, w, h, text_color(QuestData::COLOURS[:line]))
  2286.   end
  2287.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2288.   # * Objective/Description X
  2289.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2290.   def objective_x; line_height / 2; end
  2291.   def description_x; QuestData::DESCRIPTION_IN_BOX ? line_height : (line_height/2); end
  2292.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2293.   # * Update
  2294.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2295.   def update(*args, &block)
  2296.     super(*args, &block)
  2297.     if open? && active && @dest_scroll_oy == self.oy
  2298.       scroll_down if Input.press?(:DOWN)
  2299.       scroll_up if Input.press?(:UP)
  2300.     end
  2301.     if self.oy != @dest_scroll_oy
  2302.       mod = (@dest_scroll_oy <=> self.oy)
  2303.       self.oy += 3*mod
  2304.       self.oy = @dest_scroll_oy if (@dest_scroll_oy <=> self.oy) != mod
  2305.     end
  2306.   end
  2307.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2308.   # * Scroll Down
  2309.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2310.   def scroll_down(*args, &block)
  2311.     max_oy = contents_height - maqj_visible_height
  2312.     dest = ((@dest_scroll_oy / line_height) + 1)*line_height
  2313.     @dest_scroll_oy = [dest, max_oy].min
  2314.   end
  2315.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2316.   # * Scroll Up
  2317.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2318.   def scroll_up(*args, &block)
  2319.     dest = ((@dest_scroll_oy / line_height) - 1)*line_height
  2320.     @dest_scroll_oy = [dest, 0].max
  2321.   end
  2322. end

  2323. #==============================================================================
  2324. # ** Scene_Quest
  2325. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2326. #  This class handles processing for the Quest scene
  2327. #==============================================================================

  2328. class Scene_Quest < Scene_MenuBase
  2329.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2330.   # * Start Scene Processing
  2331.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2332.   def start
  2333.     super
  2334.     @init_category, @init_quest_index = $game_party.quests.find_location($game_system.last_quest_id, $game_system.last_quest_cat)
  2335.     create_maqj_picture unless $game_system.quest_bg_picture.empty?
  2336.     create_all_windows
  2337.     adjust_window_positions
  2338.   end
  2339.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2340.   # * Terminate Scene
  2341.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2342.   def terminate
  2343.     $game_system.quest_categories = QuestData::CATEGORIES
  2344.     $game_system.quest_scene_label = QuestData::VOCAB[:scene_label]
  2345.     $game_system.last_quest_id = @quest_list_window.item ? @quest_list_window.item.id : 0
  2346.     $game_system.last_quest_cat = @quest_category_window.item
  2347.     super
  2348.     dispose_maqj_picture
  2349.   end
  2350.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2351.   # * Create Background Picture
  2352.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2353.   def create_maqj_picture
  2354.     @maqj_picture_sprite = Sprite.new
  2355.     @maqj_picture_sprite.bitmap = Cache.picture($game_system.quest_bg_picture)
  2356.     @maqj_picture_sprite.opacity = $game_system.quest_bg_opacity
  2357.     @maqj_picture_sprite.blend_type = $game_system.quest_bg_blend_type
  2358.     @maqj_picture_sprite.z = @background_sprite.z + 1 if @background_sprite
  2359.   end
  2360.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2361.   # * Create All Windows
  2362.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2363.   def create_all_windows
  2364.     create_quest_label_window unless $game_system.quest_scene_label.empty?
  2365.     create_quest_category_window if $game_system.quest_categories.size > 1
  2366.     create_quest_category_label_window if QuestData::SHOW_CATEGORY_LABEL
  2367.     create_dummy_category_window if QuestData::CATEGORY_LABEL_IN_SAME_WINDOW &&
  2368.       @quest_category_window && @quest_category_label_window
  2369.     create_quest_list_window
  2370.     create_quest_data_window
  2371.   end
  2372.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2373.   # * Create QuestLabel Window
  2374.   #    This window shows the name of the scene
  2375.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2376.   def create_quest_label_window
  2377.     @quest_label_window = Window_QuestLabel.new(0, 0, $game_system.quest_scene_label)
  2378.   end
  2379.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2380.   # * Create QuestCategory Window
  2381.   #    This window allows the player to switch categories.
  2382.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2383.   def create_quest_category_window
  2384.     @quest_category_window = Window_QuestCategory.new(0, 0, $game_system.quest_categories)
  2385.     @quest_category_window.category = @init_category if @init_category
  2386.     @quest_category_window.set_handler(:cancel, method(:on_category_cancel))
  2387.     @quest_category_window.set_handler(:ok, method(:on_category_ok))
  2388.   end
  2389.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2390.   # * Create QuestCategoryLabel Window
  2391.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2392.   def create_quest_category_label_window
  2393.     if @quest_category_window
  2394.       @quest_category_label_window = Window_QuestCategoryLabel.new(0, @quest_category_window.height)
  2395.       @quest_category_window.add_observing_proc(:label) { |category|
  2396.         @quest_category_label_window.category = category }
  2397.     else
  2398.       @quest_category_label_window = Window_QuestCategoryLabel.new(0, 0)
  2399.       @quest_category_label_window.category = $game_system.quest_categories ? $game_system.quest_categories[0] : :all
  2400.     end
  2401.   end
  2402.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2403.   # * Create Dummy Category Label Window
  2404.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2405.   def create_dummy_category_window
  2406.     @quest_category_label_window.y -= 12
  2407.     @quest_category_label_window.opacity = 0
  2408.     @quest_category_window.opacity = 0
  2409.     w = [@quest_category_window.width, @quest_category_label_window.width].max
  2410.     h = @quest_category_window.height + @quest_category_label_window.height - 12
  2411.     @category_dummy_window = Window_QuestCategoryDummy.new(0, 0, w, h)
  2412.     @category_dummy_window.z = [@quest_category_window.z, @quest_category_label_window.z].min - 1
  2413.     # Draw Horz Line
  2414.     @category_dummy_window.draw_horizontal_line(@quest_category_window.height - @quest_category_window.padding - 7, 2)
  2415.   end
  2416.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2417.   # * Create QuestList Window
  2418.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2419.   def create_quest_list_window
  2420.     if @category_dummy_window
  2421.       y = @category_dummy_window.height
  2422.     else
  2423.       y = @quest_category_window ? @quest_category_window.height : 0
  2424.       y += @quest_category_label_window ? @quest_category_label_window.height : 0
  2425.       y = @quest_label_window.height if y == 0
  2426.     end
  2427.     @quest_list_window = Window_QuestList.new(0, y, QuestData::LIST_WINDOW_WIDTH,
  2428.       Graphics.height - y)
  2429.     @quest_list_window.set_handler(:ok, method(:on_list_ok))
  2430.     if !QuestData::CONCURRENT_ACTIVITY
  2431.       @quest_list_window.deactivate
  2432.       @quest_list_window.set_handler(:cancel, method(:on_list_cancel))
  2433.     end
  2434.     if @quest_category_window
  2435.       @quest_category_window.add_observing_proc(:list) { |category|
  2436.         @quest_list_window.category = category }
  2437.     else
  2438.       @quest_list_window.category = $game_system.quest_categories[0]
  2439.     end
  2440.     @quest_list_window.index = @init_quest_index if @init_quest_index
  2441.   end
  2442.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2443.   # * Create QuestData Window
  2444.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2445.   def create_quest_data_window
  2446.     x = @quest_list_window.width
  2447.     y = (@quest_label_window && (@quest_category_window ||
  2448.       @quest_category_label_window)) ? @quest_label_window.height : 0
  2449.     @quest_data_window = Window_QuestData.new(x, y, Graphics.width - x,
  2450.       Graphics.height - y)
  2451.     @quest_list_window.help_window = @quest_data_window
  2452.     @quest_data_window.quest = @quest_list_window.item
  2453.     @quest_data_window.set_handler(:ok, method(:on_data_ok))
  2454.     @quest_data_window.set_handler(:cancel, method(:on_data_cancel))
  2455.   end
  2456.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2457.   # * Dispose Background Picture
  2458.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2459.   def dispose_maqj_picture
  2460.     @maqj_picture_sprite.dispose if @maqj_picture_sprite
  2461.   end
  2462.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2463.   # * Adjust Window Positions
  2464.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2465.   def adjust_window_positions
  2466.     if @quest_label_window && (@quest_category_window || @quest_category_label_window)
  2467.       @quest_label_window.x = QuestData::LIST_WINDOW_WIDTH
  2468.     end
  2469.   end
  2470.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2471.   # * Category OK
  2472.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2473.   def on_category_ok; @quest_list_window.activate; end
  2474.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2475.   # * Category Cancel
  2476.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2477.   def on_category_cancel; return_scene; end
  2478.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2479.   # * List OK
  2480.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2481.   def on_list_ok
  2482.     @quest_category_window.deactivate
  2483.     @quest_data_window.activate
  2484.   end
  2485.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2486.   # * List Cancel
  2487.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2488.   def on_list_cancel; @quest_category_window.activate; end
  2489.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2490.   # * Data OK
  2491.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2492.   def on_data_ok; on_data_cancel; end
  2493.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2494.   # * Data Cancel
  2495.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2496.   def on_data_cancel
  2497.     @quest_list_window.activate
  2498.     @quest_category_window.activate if QuestData::CONCURRENT_ACTIVITY
  2499.   end
  2500.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2501.   # * Update All Windows
  2502.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2503.   def update_all_windows(*args, &block)
  2504.     # To accomodate for concurrent activity, must deactivate category
  2505.     @quest_category_window.deactivate if QuestData::CONCURRENT_ACTIVITY &&
  2506.       @quest_list_window.active && Input.trigger?(:C)
  2507.     super(*args, &block)
  2508.     @quest_category_window.activate if QuestData::CONCURRENT_ACTIVITY &&
  2509.       @quest_list_window.active
  2510.   end
  2511. end

  2512. #==============================================================================
  2513. # ** Scene_Map
  2514. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2515. #  Summary of Changes:
  2516. #    aliased method - update_scene
  2517. #    new methods - update_call_quest_journal; call_quest_journal
  2518. #==============================================================================

  2519. class Scene_Map
  2520.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2521.   # * Update Scene
  2522.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2523.   alias maqj_updascne_9kh4 update_scene
  2524.   def update_scene(*args, &block)
  2525.     maqj_updascne_9kh4(*args, &block)
  2526.     update_call_quest_journal if $game_system.quest_map_access && !scene_changing?
  2527.   end
  2528.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2529.   # * Update Call Quest Journal
  2530.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2531.   def update_call_quest_journal
  2532.     if $game_map.interpreter.running?
  2533.       @quest_journal_calling = false
  2534.     else
  2535.       if Input.trigger?(QuestData::MAP_BUTTON)
  2536.         $game_system.quest_access_disabled || $game_party.quests.list.empty? ?
  2537.           Sound.play_buzzer : @quest_journal_calling = true
  2538.       end
  2539.       call_quest_journal if @quest_journal_calling && !$game_player.moving?
  2540.     end
  2541.   end
  2542.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2543.   # * Call Quest Journal
  2544.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2545.   def call_quest_journal
  2546.     @quest_journal_calling = false
  2547.     Sound.play_ok
  2548.     SceneManager.call(Scene_Quest)
  2549.   end
  2550. end

  2551. # Menu Access
  2552. if !$imported[:MA_InsertCommand]
  2553. # Initialize the Insertion Hash
  2554. MA_COMMAND_INSERTS = {}
  2555. MA_InsertableMenuCommand = Struct.new(:name, :index, :enable, :scene, :other)

  2556. #==============================================================================
  2557. # ** Game_System
  2558. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2559. #  Summary of Changes:
  2560. #    new public instance variable - maic_menu_commands
  2561. #    aliased method - initialize
  2562. #==============================================================================

  2563. class Game_System
  2564.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2565.   # * Inserted Menu Commands
  2566.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2567.   def maic_inserted_menu_commands
  2568.     # Lazy Instantiation so that old save files are not corrupted
  2569.     if !@maic_inserted_menu_commands
  2570.       @maic_inserted_menu_commands = MA_COMMAND_INSERTS.keys
  2571.       # Sort by index
  2572.       @maic_inserted_menu_commands.sort! { |a, b| MA_COMMAND_INSERTS[a].index <=> MA_COMMAND_INSERTS[b].index }
  2573.     end
  2574.     @maic_inserted_menu_commands
  2575.   end
  2576. end

  2577. #==============================================================================
  2578. # ** Window_MenuCommand
  2579. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2580. #  Summary of Changes:
  2581. #    aliased method - make_command_list; maic_insert_command
  2582. #==============================================================================

  2583. class Window_MenuCommand
  2584.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2585.   # * Make Command List
  2586.   #``````````````````````````````````````````````````````````````````````````
  2587.   #  I alias this method instead of add_original_commands because I need to
  2588.   # have all commands created before I can insert at the correct index
  2589.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2590.   alias maic_mkcmmndl_6yd2 make_command_list
  2591.   def make_command_list(*args, &block)
  2592.     maic_mkcmmndl_6yd2(*args, &block) # Run Original Method
  2593.     # Insert new commands
  2594.     $game_system.maic_inserted_menu_commands.each { |sym| maic_insert_command(sym) }
  2595.   end
  2596.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2597.   # * Insert Command
  2598.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2599.   def maic_insert_command(symbol)
  2600.     command = MA_COMMAND_INSERTS[symbol]
  2601.     # Get the command name
  2602.     name = command.name.is_a?(Symbol) ? eval(command.name.to_s) : command.name
  2603.     # Check whether enabled
  2604.     enabled = case command.enable
  2605.     when Integer then command.enable == 0 ? true : $game_switches[command.enable]
  2606.     when String then eval(command.enable)
  2607.     when Symbol then self.send(command.enable)
  2608.     else
  2609.       enabled = true
  2610.     end
  2611.     # Add the command to the list
  2612.     add_command(name, symbol, enabled)
  2613.     added = @list.pop
  2614.     @list.insert([command.index, @list.size].min, added) # Insert at specific index
  2615.   end
  2616. end

  2617. #==============================================================================
  2618. # ** Scene_Menu
  2619. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2620. #  Summary of Changes:
  2621. #    aliased method - create_command_window; on_personal_ok
  2622. #    new methods - maic_set_insert_handler; maic_command_insert
  2623. #==============================================================================

  2624. class Scene_Menu
  2625.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2626.   # * Create Command Window
  2627.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2628.   alias maic_createcndwin_3ey7 create_command_window
  2629.   def create_command_window(*args, &block)
  2630.     maic_createcndwin_3ey7(*args, &block) # Run Original Method
  2631.     # Add handlers for all custom commands
  2632.     $game_system.maic_inserted_menu_commands.each { |symbol| maic_set_insert_handler(symbol) }
  2633.   end
  2634.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2635.   # * Set Inserted Handler
  2636.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2637.   def maic_set_insert_handler(symbol)
  2638.     other = MA_COMMAND_INSERTS[symbol].other
  2639.     handler = case other
  2640.     when Symbol then method(other)
  2641.     when String then lambda { eval(other) }
  2642.     when TrueClass then method(:command_personal)
  2643.     else
  2644.       handler = method(:maic_command_insert)
  2645.     end
  2646.     @command_window.set_handler(symbol, handler)
  2647.   end
  2648.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2649.   # * Custom Command
  2650.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2651.   def maic_command_insert
  2652.     SceneManager.call(Kernel.const_get(MA_COMMAND_INSERTS[@command_window.current_symbol].scene))
  2653.   end
  2654.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2655.   # * Personal OK
  2656.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2657.   alias maic_onpok_3ek9 on_personal_ok
  2658.   def on_personal_ok(*args, &block)
  2659.     if $game_system.maic_inserted_menu_commands.include?(@command_window.current_symbol)
  2660.       maic_command_insert
  2661.     else
  2662.       maic_onpok_3ek9(*args, &block) # Run Original Method
  2663.     end
  2664.   end
  2665. end

  2666. $imported[:MA_InsertCommand] = true
  2667. end

  2668. MA_COMMAND_INSERTS[:quest_journal] =
  2669.   MA_InsertableMenuCommand.new(QuestData::VOCAB[:menu_label], QuestData::MENU_INDEX,
  2670.   "!$game_system.quest_access_disabled && !$game_party.quests.list.empty?",
  2671.   :Scene_Quest, false)
复制代码
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
79 小时
注册时间
2007-2-11
帖子
140
3
发表于 2012-6-14 10:37:03 | 只看该作者
你赢了。。俩脚本都是我写的。。总的来说没冲突,只是有个函数重命名问题。。
115下载
以上是没冲突的代码下载。。不是范例

点评

我自己写的时候是合并的,发到论坛里以后拆开了。。  发表于 2012-6-14 18:52
看到"俩脚本都是我写的" 我真的笑了 / w \ 相信當初也沒想到會有這問題吧...  发表于 2012-6-14 18:03
好的  发表于 2012-6-14 12:54
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
59 小时
注册时间
2012-3-4
帖子
86
4
 楼主| 发表于 2012-6-14 12:56:13 | 只看该作者
asd11000 发表于 2012-6-14 10:37
你赢了。。俩脚本都是我写的。。总的来说没冲突,只是有个函数重命名问题。。
115下载
以上是没冲突的代码 ...

。。。。妹子,,,多大估计没我大吧不过谢谢你啊


‘‘──562305484于2012-6-14 12:57补充以下内容:

先在这里谢谢了
’’


‘‘──562305484于2012-6-14 22:52补充以下内容:

怎么呼出菜单?而且我添加后显示错误
’’
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-26 17:47

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表