1 /////////////////////////////////////////////////////////////////////////////// 2 // Copyright (C) 2004-2010 by The Allacrost Project 3 // All Rights Reserved 4 // 5 // This code is licensed under the GNU GPL version 2. It is free software 6 // and you may modify it and/or redistribute it under the terms of this license. 7 // See http://www.gnu.org/copyleft/gpl.html for details. 8 /////////////////////////////////////////////////////////////////////////////// 9 10 /** **************************************************************************** 11 *** \file shop_leave.h 12 *** \author Tyler Olsen, roots@allacrost.org 13 *** \brief Header file for leave interface of shop mode 14 *** 15 *** \note The contents of this file are near identical to the contents of 16 *** shop_confirm.h. When making any changes to this file, please look to 17 *** shop_confirm.h to see if it should have similar changes made. 18 *** ***************************************************************************/ 19 20 #ifndef __SHOP_LEAVE_HEADER__ 21 #define __SHOP_LEAVE_HEADER__ 22 23 #include "defs.h" 24 #include "utils.h" 25 26 #include "video.h" 27 #include "global.h" 28 29 #include "shop_utils.h" 30 31 namespace hoa_shop { 32 33 namespace private_shop { 34 35 /** **************************************************************************** 36 *** \brief An interface to prevent the player from leaving the shop with marked transactions 37 *** 38 *** This interface is only entered if the player tries to leave the shop and they still 39 *** have marked purchases, sales, or trades. Its primary purpose is to serve as a fail-safe 40 *** so that the player doesn't accidentally leave the shop before they complete their transaction. 41 *** The class itself is similar in display and function to the ConfirmInterface, but it uses a 42 *** reduced subset of the abilities found in that interface. Specifically the player may not modify 43 *** their order in any way from this interface, although they can view their order and selected 44 *** objects in that order. 45 *** 46 *** 47 *** After the player has selected their purchases, sales, and trades, they typically 48 *** enter this interface to finalize their choices and complete the transaction. There 49 *** are four primary actions that a player may chose from while in this interface. 50 *** 51 *** -# "View Order": allows the player to view the buy/sell/trade lists and selected entries 52 *** -# "Confirm Order": sends the player to the confirm interface so that the order can be completed 53 *** -# "Leave Shop": leaves shop mode entirely without further interruption 54 *** ***************************************************************************/ 55 class LeaveInterface : public ShopInterface { 56 //! \brief States of the leave interface used to determine how to process user input and what information to draw 57 enum LEAVE_STATE { 58 LEAVE_STATE_INVALID = -1, 59 LEAVE_STATE_MAIN = 0, //!< User input is focused on the main interface prompt 60 LEAVE_STATE_LIST = 2, //!< User input is focused on the buy/sell/trade list 61 LEAVE_STATE_INFO = 3, //!< User input is focused on the detailed view of a selected object or trade 62 LEAVE_STATE_TOTAL = 4 63 }; 64 65 //! \brief States that determine what transaction list is active and should be displayed 66 enum ACTIVE_LIST { 67 ACTIVE_LIST_INVALID = -1, 68 ACTIVE_LIST_BUY = 0, 69 ACTIVE_LIST_SELL = 1, 70 ACTIVE_LIST_TRADE = 2, 71 ACTIVE_LIST_TOTAL = 3 72 }; 73 74 public: 75 LeaveInterface(); 76 77 ~LeaveInterface(); 78 79 //! \brief Not used by this interface as all initialization is performed in the class constructor and MakeActive() method Initialize()80 void Initialize() 81 {} 82 83 //! \brief Processes the buy/sell/trade lists and determines the counts and other information about each transaction 84 void MakeActive(); 85 86 //! \brief No actions need to take place when a transaction occurs TransactionNotification()87 void TransactionNotification() 88 {} 89 90 //! \brief Handles user input and internal state management 91 void Update(); 92 93 //! \brief Draws the visible displays, text, and GUI objects to the screen 94 void Draw(); 95 96 private: 97 //! \brief Stores the active state of the leave interface 98 LEAVE_STATE _state; 99 100 //! \brief Keeps track of which type of list (buy/sell/trade) is currently active 101 ACTIVE_LIST _active_list; 102 103 //! \brief The total number of objects marked for purchase 104 uint32 _buy_count; 105 106 //! \brief The number of unique objects marked for purchase (e.g. buying four healing potions count as one unique purchase) 107 uint32 _buy_unique; 108 109 //! \brief The total number of objects marked for sale 110 uint32 _sell_count; 111 112 //! \brief The number of unique objects marked for sale (e.g. selling four healing potions count as one unique sale) 113 uint32 _sell_unique; 114 115 //! \brief The total number of marked trades 116 uint32 _trade_count; 117 118 //! \brief The number of characters that will transact in at least one trade 119 uint32 _trade_characters; 120 121 //! \brief Displays "Purchases" in different text styles based on whether or not the buy list is in view 122 hoa_video::TextImage _buy_header; 123 124 //! \brief Displays the buy count/unique data below the buy header 125 hoa_video::TextImage _buy_stats; 126 127 //! \brief Displays "Sales" in different text styles based on whether or not the sell list is in view 128 hoa_video::TextImage _sell_header; 129 130 //! \brief Displays the sell count/unique data below the sell header 131 hoa_video::TextImage _sell_stats; 132 133 //! \brief Displays "Trades" in different text styles based on whether or not the trade list is in view 134 hoa_video::TextImage _trade_header; 135 136 //! \brief Displays the trade count/characters data below the trade header 137 hoa_video::TextImage _trade_stats; 138 139 //! \brief List header text for the name field 140 hoa_video::TextImage _name_header; 141 142 //! \brief List header text for the list of object properties (refer to the BuyListDisplay class) 143 hoa_gui::OptionBox _properties_header; 144 145 //! \brief Text to display in the middle window when the selected transaction list is empty 146 hoa_video::TextImage _empty_list_text; 147 148 //! \brief A display of all wares marked for purchase and their properties 149 BuyListDisplay* _buy_list_display; 150 151 //! \brief A display of all inventory objects marked for sale and their properties 152 SellListDisplay* _sell_list_display; 153 154 // TODO: Add once trade interface is working and this class is defined 155 // TradeListDisplay* _trade_list_display; 156 157 //! \brief Text that prompts the user for their desired action 158 hoa_video::TextImage _main_prompt; 159 160 //! \brief The list of actions that the user can take 161 hoa_gui::OptionBox _main_actions; 162 163 private: 164 /** \brief Changes the current state and modifies other members and display properties appropriately 165 *** \param new_state The new state to change the leave interface to 166 **/ 167 void _ChangeState(LEAVE_STATE new_state); 168 169 //! \brief Changes the active transaction list and updates the transaction header texts 170 void _CycleActiveTransactionList(); 171 }; // class LeaveInterface : public ShopInterface 172 173 } // namespace private_shop 174 175 } // namespace hoa_shop 176 177 #endif // __SHOP_LEAVE_HEADER__ 178