1 /////////////////////////////////////////////////////////////////////////////// 2 // Copyright (C) 2004-2011 by The Allacrost Project 3 // Copyright (C) 2012-2016 by Bertram (Valyria Tear) 4 // All Rights Reserved 5 // 6 // This code is licensed under the GNU GPL version 2. It is free software 7 // and you may modify it and/or redistribute it under the terms of this license. 8 // See https://www.gnu.org/copyleft/gpl.html for details. 9 /////////////////////////////////////////////////////////////////////////////// 10 11 /** **************************************************************************** 12 *** \file map_treasure.h 13 *** \author Tyler Olsen, roots@allacrost.org 14 *** \author Yohann Ferreira, yohann ferreira orange fr 15 *** \brief Header file for map mode treasures. 16 *** *****************************************************************************/ 17 18 #ifndef __MAP_TREASURE_SUPERVISOR_HEADER__ 19 #define __MAP_TREASURE_SUPERVISOR_HEADER__ 20 21 #include "modes/map/map_utils.h" 22 23 #include "common/gui/menu_window.h" 24 #include "common/gui/option.h" 25 #include "common/gui/textbox.h" 26 27 #include "engine/audio/audio_descriptor.h" 28 29 namespace vt_map 30 { 31 32 namespace private_map 33 { 34 35 class TreasureObject; 36 class MapTreasureContent; 37 38 /** *************************************************************************************** 39 *** \brief Displays the contents of a discovered treasure in a menu window 40 *** 41 *** Upon opening a treasure chest or other treasure-containing map object, this menu 42 *** will appear and list the amount of drunes found (if any), a list of the icon and name of 43 *** each GlobalObject found (items, equipment, etc), and a list of player options. 44 *** The player may select to view detailed information about a particular entry, go to menu mode, 45 *** and possibly other actions in the future. 46 *** 47 *** The treasure menu is composed of three sets of windows. The action window is a small window 48 *** at the top of the menu that displays the action options in a horizontal list. The list window 49 *** displays the contents of the treasure in a larger window below the action window. This object 50 *** list is formatted vertically. The detail window shares the same area as the list window and 51 *** displays textual and visual detail about an object selected by the user from the list window. 52 *** 53 *** Proper utilization of this class entails the following steps: 54 *** 55 *** -# Call the Initialize method to show the menu with the treasure that has been obtained 56 *** -# Call the Update method to process user input and update the menu's appearance 57 *** -# Call the Draw method to draw the menu to the screen 58 *** -# Call the Finish method to hide the menu and add the treasure's contents to the player's 59 *** inventory 60 *** 61 *** \todo Allow the player to use or equip selected treasure objects directly from the 62 *** action menu. 63 *** 64 *** \todo Add visual scissoring to the list window so that the option list or detail text does 65 *** not exceed the window boundary when the text or list is exceedingly long. 66 *** 67 *** \todo Instead of forcing the detail window to share the list window, maybe it would look 68 *** better if there was a separate detail window which "popped out" of the other two windows 69 *** and could be placed over them when it was visible? I think this would be much more visually 70 *** pleasing than the current implementation. 71 *** **************************************************************************************/ 72 class TreasureSupervisor 73 { 74 public: 75 //! \brief The possible sub-windows that are selected, used for determining how to process user input 76 enum SELECTION { 77 ACTION_SELECTED = 0, //!< the list of actions a user may take in the treasure menu 78 LIST_SELECTED = 1, //!< active when the user is browsing the list of treasures 79 DETAIL_SELECTED = 2 //!< set when the user is viewing details about a particular treasure 80 }; 81 82 TreasureSupervisor(); 83 84 ~TreasureSupervisor(); 85 86 /** \brief Displays the menu window and initializes it to display the contents of a new treasure 87 *** \param map_object A pointer to the object on the map holding the treasure to procure 88 **/ 89 void Initialize(TreasureObject* map_object); 90 91 /** \brief Displays the menu window and initializes it to display the contents of a new treasure 92 *** \param treasure A pointer to the treasure to display the contents of 93 **/ 94 void Initialize(MapTreasureContent* treasure); 95 96 //! \brief Processes input events from the user and updates the showing/hiding progress of the window 97 void Update(); 98 99 /** \brief Draws the window to the screen 100 *** \note If the Initialize method has not been called with a valid treasure pointer beforehand, this 101 *** method will print a warning and it will not draw anything to the screen. 102 **/ 103 void Draw(); 104 105 //! \brief Hides the window and adds the treasure's contents to the player's inventory 106 void Finish(); 107 108 private: 109 //! \brief A pointer to the treasure to display the contents of 110 MapTreasureContent* _treasure; 111 112 //! \brief The currently selected sub-window for processing user input 113 SELECTION _selection; 114 115 //! \brief Contains options for viewing, using, or equipping inventory, or for exiting the menu 116 vt_gui::MenuWindow _action_window; 117 118 //! \brief Lists all of the drunes and inventory objects contained in the treasure 119 vt_gui::MenuWindow _list_window; 120 121 //! \brief The available actions that a user can currently take. Displayed in the _action_window. 122 vt_gui::OptionBox _action_options; 123 124 //! \brief The name + quantity of all drunes and inventory objects earned. Displayed in the _list_window 125 vt_gui::OptionBox _list_options; 126 127 //! \brief A textbox that displays the detailed description about a selected treasure 128 vt_gui::TextBox _detail_textbox; 129 130 //! \brief A rendering of the name for the treasure window 131 vt_video::TextImage _window_title; 132 133 //! \brief The name of the selected list item 134 vt_video::TextImage _selection_name; 135 136 //! \brief A pointer to the image of the selected list item 137 vt_video::StillImage* _selection_icon; 138 139 //! \brief Tells whether the currently selected item is a key item 140 bool _is_key_item; 141 142 // ---------- Private methods 143 144 //! \brief Processes user input when the action sub-window is selected 145 void _UpdateAction(); 146 147 //! \brief Processes user input when the list sub-window is selected 148 void _UpdateList(); 149 150 //! \brief Processes user input when the detailed view of a treasure object is selected 151 void _UpdateDetail(); 152 }; 153 154 } // namespace private_map 155 156 } // namespace vt_map 157 158 #endif // __MAP_TREASURE_SUPERVISOR_HEADER__ 159