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.h 12 *** \author Tyler Olsen, roots@allacrost.org 13 *** \brief Header file for shop mode interface 14 *** 15 *** This code provides an interface for the user to purchase wares from a 16 *** merchant. This mode is usually entered from a map after speaking with a 17 *** shop keeper. 18 *** ***************************************************************************/ 19 20 #ifndef __SHOP_HEADER__ 21 #define __SHOP_HEADER__ 22 23 #include "defs.h" 24 #include "utils.h" 25 26 #include "mode_manager.h" 27 28 #include "global.h" 29 30 #include "shop_utils.h" 31 32 //! \brief All calls to shop mode are wrapped in this namespace. 33 namespace hoa_shop { 34 35 //! \brief Determines whether the code in the hoa_shop namespace should print debug statements or not. 36 extern bool SHOP_DEBUG; 37 38 //! \brief An internal namespace to be used only within the shop code. Don't use this namespace anywhere else! 39 namespace private_shop { 40 41 /** **************************************************************************** 42 *** \brief A companion class to ShopMode that holds various multimedia data 43 *** 44 *** All of the shop mode interfaces share media data in forming their presentations. 45 *** This class retains all of this common media data and makes it available for 46 *** the shop interfaces to utilize. Like ShopMode, this class contains a static 47 *** pointer to an object of the class type that represents the current instance 48 *** of the class. This makes it easier for the code to get access to the data. 49 *** Below is a typical use case for this class: 50 *** 51 *** ShopMedia::CurrentInstance()->GetObjectCategoryImages(); 52 *** 53 *** \note The accessor methods return non-const pointers to the relevant data 54 *** structures and objects. This is done for reasons of convenience as many places 55 *** in the shop code wish to make non-const copies of data stored in this class. 56 *** Take care not to abuse these pointers and modify the state of any of the data 57 *** members in this class as it would have negative repercussions. 58 *** ***************************************************************************/ 59 class ShopMedia { 60 public: 61 ShopMedia(); 62 63 ~ShopMedia(); 64 65 /** \brief Finishes preparing media data for use 66 *** This function prepares any class members that could not be made ready in the constructor. This 67 *** may be the case, for example, where the contents of a data container are dependent on knowing 68 *** which object categories the shop deals in (which can not be known until shop mode is initialized 69 *** and all wares have been added to the shop). 70 **/ 71 void Initialize(); 72 GetAllCategoryNames()73 std::vector<hoa_utils::ustring>* GetAllCategoryNames() 74 { return &_all_category_names; } 75 GetAllCategoryIcons()76 std::vector<hoa_video::StillImage>* GetAllCategoryIcons() 77 { return &_all_category_icons; } 78 GetSaleCategoryNames()79 std::vector<hoa_utils::ustring>* GetSaleCategoryNames() 80 { return &_sale_category_names; } 81 GetSaleCategoryIcons()82 std::vector<hoa_video::StillImage>* GetSaleCategoryIcons() 83 { return &_sale_category_icons; } 84 GetDrunesIcon()85 hoa_video::StillImage* GetDrunesIcon() 86 { return &_drunes_icon; } 87 GetStarIcon()88 hoa_video::StillImage* GetStarIcon() 89 { return &_star_icon; } 90 GetCheckIcon()91 hoa_video::StillImage* GetCheckIcon() 92 { return &_check_icon; } 93 GetXIcon()94 hoa_video::StillImage* GetXIcon() 95 { return &_x_icon; } 96 GetSocketIcon()97 hoa_video::StillImage* GetSocketIcon() 98 { return &_socket_icon; } 99 GetEquipIcon()100 hoa_video::StillImage* GetEquipIcon() 101 { return &_equip_icon; } 102 GetElementalIcons()103 std::vector<hoa_video::StillImage>* GetElementalIcons() 104 { return &_elemental_icons; } 105 GetStatusIcons()106 std::vector<hoa_video::StillImage>* GetStatusIcons() 107 { return &_status_icons; } 108 GetCharacterSprites()109 std::vector<hoa_video::StillImage>* GetCharacterSprites() 110 { return &_character_sprites; } 111 112 /** \brief Retrieves the category name that represents the specified object type 113 *** \param object_type The type of the global object to retrieve the name for 114 *** \return A pointer to the ustring holding the category's name. NULL if the argument was invalid. 115 *** \note GLOBAL_OBJECT_TOTAL will return the name for "all wares" 116 **/ 117 hoa_utils::ustring* GetCategoryName(hoa_global::GLOBAL_OBJECT object_type); 118 119 /** \brief Retrieves the category icon image that represents the specified object type 120 *** \param object_type The type of the global object to retrieve the icon for 121 *** \return A pointer to the image holding the category's icon. NULL if the argument was invalid. 122 *** \note GLOBAL_OBJECT_TOTAL will return the icon for "all wares" 123 **/ 124 hoa_video::StillImage* GetCategoryIcon(hoa_global::GLOBAL_OBJECT object_type); 125 126 /** \brief Retrieves a specific elemental icon with the proper type and intensity 127 *** \param element_type The type of element the user is trying to retrieve the icon for 128 *** \param intensity The intensity level of the icon to retrieve 129 *** \return The icon representation of the element type and intensity 130 **/ 131 hoa_video::StillImage* GetElementalIcon(hoa_global::GLOBAL_ELEMENTAL element_type, hoa_global::GLOBAL_INTENSITY intensity); 132 133 /** \brief Retrieves a specificstatus icon with the proper type and intensity 134 *** \param status_type The type of status the user is trying to retrieve the icon for 135 *** \param intensity The intensity level of the icon to retrieve 136 *** \return The icon representation of the status type and intensity 137 **/ 138 hoa_video::StillImage* GetStatusIcon(hoa_global::GLOBAL_STATUS status_type, hoa_global::GLOBAL_INTENSITY intensity); 139 140 /** \brief Retrieves a shop sound object 141 *** \param identifier The string identifier for the sound to retrieve 142 *** \return A pointer to the SoundDescriptor, or NULL if no sound had the identifier name 143 **/ 144 hoa_audio::SoundDescriptor* GetSound(std::string identifier); 145 146 private: 147 //! \brief Retains text names for all possible object categories, including "all wares" 148 std::vector<hoa_utils::ustring> _all_category_names; 149 150 //! \brief Retains icon images for all possible object categories, including "all wares" 151 std::vector<hoa_video::StillImage> _all_category_icons; 152 153 //! \brief Retains text names only for those object categories sold by the shop 154 std::vector<hoa_utils::ustring> _sale_category_names; 155 156 //! \brief Retains icon images only for those object categories sold by the shop 157 std::vector<hoa_video::StillImage> _sale_category_icons; 158 159 //! \brief Image icon representing drunes (currency) 160 hoa_video::StillImage _drunes_icon; 161 162 //! \brief Image icon of a single yellow/gold star 163 hoa_video::StillImage _star_icon; 164 165 //! \brief Image icon of a green check mark 166 hoa_video::StillImage _check_icon; 167 168 //! \brief Image icon of a red x 169 hoa_video::StillImage _x_icon; 170 171 //! \brief Image icon representing open sockets available on weapons and armor 172 hoa_video::StillImage _socket_icon; 173 174 //! \brief Image icon that represents when a character has a weapon or armor equipped 175 hoa_video::StillImage _equip_icon; 176 177 //! \brief Retains all icon images that represent the game's elementals 178 std::vector<hoa_video::StillImage> _elemental_icons; 179 180 //! \brief Retains all icon images that represent the game's status effects 181 std::vector<hoa_video::StillImage> _status_icons; 182 183 //! \brief Retains sprite image frames for all characters in the active party 184 std::vector<hoa_video::StillImage> _character_sprites; 185 186 //! \brief A map of the sounds used in shop mode 187 std::map<std::string, hoa_audio::SoundDescriptor*> _sounds; 188 }; // class ShopMedia 189 190 191 /** **************************************************************************** 192 *** \brief Manages all data and graphics for showing detailed information about an object 193 *** 194 *** This class shows summary information about the currently selected object. It displays 195 *** this information in one of two display modes. The first mode uses only the lower window 196 *** and shows only a limited amount of information. This is the default view mode that the 197 *** player sees and this information is visible in tandem with the graphics displayed by the 198 *** BuyListView class. The second view mode is entered if the player requests to see all the 199 *** details about the selected object. In this view mode, the BuyListView class' graphics are 200 *** hidden and this class displays the complete set of information about the selected object 201 *** using both the middle and lower menu windows. The type of information which is displayed is 202 *** different depending upon what type of object is selected. The primary purpose of this class 203 *** is to serve as a helper to the BuyInterface class and to keep the code organized. 204 *** 205 *** \todo Currently this class treats the display of shards the same as it does for items 206 *** and key items. This should be changed once shard properties have a more clear definition 207 *** in the game design. 208 *** 209 *** \todo Status icons are not currently displayed as there are no status effects implemented 210 *** in the game yet. Once status effects are functional and graphics are ready to represent 211 *** them, this code should be updated. 212 *** 213 *** \todo The character sprites are not yet animated in the display. This should be changed 214 *** once the appropriate set of sprite frames are available for this menu. 215 *** ***************************************************************************/ 216 class ShopObjectViewer { 217 public: 218 ShopObjectViewer(); 219 ~ShopObjectViewer()220 ~ShopObjectViewer() 221 {} 222 223 //! \brief Finishes initialization of any data or settings that could not be completed in constructor 224 void Initialize(); 225 226 //! \brief Updates sprite animations and other graphics as necessary 227 void Update(); 228 229 //! \brief Draws the contents to the screen 230 void Draw(); 231 232 /** \brief Changes the selected object to the function argument 233 *** \param object A pointer to the shop object to change (NULL-safe) 234 *** \note The code using this class should always use this function to change the selected object rather than 235 *** changing the public _selected_object member directly. This method updates all of the relevent graphics and 236 *** data displays in addition to changing the pointer member. 237 **/ 238 void SetSelectedObject(ShopObject* object); 239 240 /** \brief Changes the view mode which will effect what content is drawn and where it is drawn 241 *** \param new_mode The view mode to change to 242 *** If the current view mode is the same as the new mode, no action will be taken. If the new mode is unknown 243 *** or otherwise unsupported, a warning message will be printed and no change will take place. 244 **/ 245 void ChangeViewMode(SHOP_VIEW_MODE new_mode); 246 247 private: 248 //! \brief Holds the current view mode of this class 249 SHOP_VIEW_MODE _view_mode; 250 251 //! \brief A pointer to the object who's information should be displayed 252 ShopObject* _selected_object; 253 254 //! \brief The type of the selected object 255 SHOP_OBJECT _object_type; 256 257 //! \name Data that all object types share 258 //@{ 259 //! \brief The name of the selected object 260 hoa_video::TextImage _object_name; 261 262 //! \brief A summary description of the object to display 263 hoa_gui::TextBox _description_text; 264 265 //! \brief A more detailed "lore" description about the object's origins and connections with the world 266 hoa_gui::TextBox _lore_text; 267 //@} 268 269 //! \name Data used only for item object types 270 //@{ 271 //! \brief For items, various header text for identifying specific item properties 272 hoa_video::TextImage _field_use_header, _battle_use_header, _target_type_header; 273 274 //! \brief Image copies of a green check mark and a red x mark 275 hoa_video::StillImage _check_icon, _x_icon; 276 277 //! \brief Holds rendered text images of possible set of target types ("Self — Point", "Ally", "All Enemies", etc.) 278 std::vector<hoa_video::TextImage> _target_type_text; 279 280 //! \brief Booleans that indicate whether the item is usable on maps and/or in battles 281 bool _map_usable, _battle_usable; 282 283 //! \brief Index into the _target_type_text vector to get the appropriate descriptor for this item 284 uint32 _target_type_index; 285 //@} 286 287 //! \name Data used only for weapon and armor object types 288 //@{ 289 //! \brief Header text identifying the physical and metaphysical ratings 290 hoa_video::TextImage _phys_header, _meta_header; 291 292 //! \brief A rendering of the physical and metaphysical attack/defense ratings 293 hoa_video::TextImage _phys_rating, _meta_rating; 294 295 //! \brief An icon image of a shard socket 296 hoa_video::StillImage _socket_icon; 297 298 //! \brief Text indicating how many sockets the selected equipment has available 299 hoa_video::TextImage _socket_text; 300 301 //! \brief Icon images representing elemental effects and intensity properties of the selected object 302 std::vector<hoa_video::StillImage> _elemental_icons; 303 304 //! \brief Icon images representing status effects and intensity properties of the selected object 305 std::vector<hoa_video::StillImage> _status_icons; 306 //@} 307 308 //! \name Data used for displaying character sprites and related status 309 //@{ 310 //! \brief Sprite images of all characters currently in the party 311 std::vector<hoa_video::StillImage> _character_sprites; 312 313 //! \brief For weapons and armor, icon image that represents when a character already has the object equipped 314 hoa_video::StillImage _equip_icon; 315 316 //! \brief For weapons and armor, this member is set to true for each character that has the object equipped 317 std::vector<bool> _character_equipped; 318 319 //! \brief For weapons and armor, text to indicate changes in phys/meta stats from current equipment 320 std::vector<hoa_video::TextImage> _phys_change_text, _meta_change_text; 321 //@} 322 323 /** \brief Updates the data and visuals associated specifically with items for the selected object 324 *** This method should only be called if the _selected_object member is an item 325 **/ 326 void _SetItemData(); 327 328 /** \brief Updates the visible character sprites, equipped status, and stat text and data for the selected object 329 *** This method should only be called if the _selected_object member is a weapon or armor 330 **/ 331 void _SetEquipmentData(); 332 333 /** \brief Updates the data and visuals associated specifically with shards for the selected object 334 *** This method should only be called if the _selected_object member is a shard 335 **/ 336 void _SetShardData(); 337 338 //! \brief Determines the proper window owner, position, dimensions for description text 339 void _SetDescriptionText(); 340 341 /** \brief Renders the desired physical and metaphysical change text 342 *** \param index The index into the _phys_change_text and _meta_change_text containers to re-render 343 *** \param phys_diff The physical change amount 344 *** \param meta_diff The metaphysical change amount 345 **/ 346 void _SetChangeText(uint32 index, int32 phys_diff, int32 meta_diff); 347 348 /** \brief Sets all elemental icons to the proper image when given a container 349 *** \param elemental_effects A const reference to a map of elemental effect types and their associated intensities 350 *** 351 *** The argument is presumed to have an entrity for each type of element. This condition is not checked by the function. 352 *** The format of the parameter comes from the global object code, as object classes return a const std::map reference 353 *** of this type to indicate their elemental effects. 354 **/ 355 void _SetElementalIcons(const std::map<hoa_global::GLOBAL_ELEMENTAL, hoa_global::GLOBAL_INTENSITY>& elemental_effects); 356 357 /** \brief Sets all statusicons to the proper image when given a container 358 *** \param status_effects A const reference to a map of status effect types and their associated intensities 359 *** 360 *** The argument is presumed to have an entrity for each type of status. This condition is not checked by the function. 361 *** The format of the parameter comes from the global object code, as object classes return a const std::map reference 362 *** of this type to indicate their status effects. 363 **/ 364 void _SetStatusIcons(const std::map<hoa_global::GLOBAL_STATUS, hoa_global::GLOBAL_INTENSITY>& status_effects); 365 366 //! \brief Helper function that draws information specific to items 367 void _DrawItem(); 368 369 //! \brief Helper function that draws information specific to equipment 370 void _DrawEquipment(); 371 372 //! \brief Helper function that draws information specific to shards 373 void _DrawShard(); 374 375 //! \brief Helper function that draws information specific to key items 376 void _DrawKeyItem(); 377 }; // class ShopObjectViewer 378 379 } // namespace private_shop 380 381 /** **************************************************************************** 382 *** \brief Handles the game execution while the player is shopping. 383 *** 384 *** ShopMode allows the player to purchase items, weapons, armor, and other 385 *** objects. ShopMode consists of a captured screenshot which forms the 386 *** background image, upon which a series of menu windows are drawn. The 387 *** coordinate system used is 1024x768, and a 800x600 arrangement of three 388 *** menu windows (top, middle, bottom) are drawn on top of that backdrop. These 389 *** windows are shared beteen all states of shop mode (root, buy, sell, etc.) and 390 *** the contents of the windows change depending on the active state of shop mode. 391 *** 392 *** \note The recommended way to create and initialize this class is to call the 393 *** following methods. 394 *** 395 *** -# ShopMode constructor 396 *** -# SetShopName() 397 *** -# SetGreetingText() 398 *** -# SetPriceLevels() 399 *** -# AddObject() for each object to be sold 400 *** -# Wait for the Reset() method to be automatically called, which will finalize shop initialization 401 *** ***************************************************************************/ 402 class ShopMode : public hoa_mode_manager::GameMode { 403 public: 404 ShopMode(); 405 406 ~ShopMode(); 407 408 //! \brief Returns a pointer to the active instance of shop mode CurrentInstance()409 static ShopMode* CurrentInstance() 410 { return _current_instance; } 411 412 //! \brief Provides access to the ShopMedia class members and methods Media()413 private_shop::ShopMedia* Media() 414 { return _shop_media; } 415 416 //! \brief Provides access to the ShopObjectViewer class members and methods ObjectViewer()417 private_shop::ShopObjectViewer* ObjectViewer() 418 { return _object_viewer; } 419 420 //! \brief Resets appropriate settings and initializes shop if appropriate. Called whenever the ShopMode object is made the active game mode. 421 void Reset(); 422 423 /** \brief Loads data and prepares shop for initial use 424 *** This function is only be called once from the Reset() method. If it is called more than 425 *** once it will print a warning and refuse to execute a second time. 426 **/ 427 void Initialize(); 428 429 //! \brief Handles user input and updates the shop menu. 430 void Update(); 431 432 //! \brief Handles the drawing of everything on the shop menu and makes sub-draw function calls as appropriate. 433 void Draw(); 434 435 /** \brief Used when an object has been selected for purchase by the player 436 *** \param object A pointer to the object to add 437 *** \note The buy count of the shop object added should be non-zero before this function is called. 438 *** Otherwise a warning message will be printed, but the object will still be added. 439 **/ 440 void AddObjectToBuyList(private_shop::ShopObject* object); 441 442 /** \brief Used when the player decides not to purchase an object that was previously marked to be bought 443 *** \param object A pointer to the object to remove 444 *** \note The buy count of the shop object added should be zero before this function is called. 445 *** Otherwise a warning message will be printed, but the object will still be removed. 446 **/ 447 void RemoveObjectFromBuyList(private_shop::ShopObject* object); 448 449 /** \brief Used when an object has been selected to be sold by the player 450 *** \param object A pointer to the object to add 451 *** \note The sell count of the shop object added should be non-zero before this function is called. 452 *** Otherwise a warning message will be printed, but the object will still be added. 453 **/ 454 void AddObjectToSellList(private_shop::ShopObject* object); 455 456 /** \brief Used when the player decides not to sell an object that was previously marked to be sold 457 *** \param object A pointer to the object to remove 458 *** \note The sell count of the shop object added should be zero before this function is called. 459 *** Otherwise a warning message will be printed, but the object will still be removed. 460 **/ 461 void RemoveObjectFromSellList(private_shop::ShopObject* object); 462 463 /** \brief Called whenever the player chooses to clear all marked purchases, sales, and trades 464 *** This will empty the buy/sell/trade lists and reset the total costs and sales amounts 465 **/ 466 void ClearOrder(); 467 468 /** \brief Called whenever the player confirms a transaction 469 *** This method processes the transaction, including modifying the party's drune count, adding/removing 470 *** objects from the inventory, and auto equipping/un-equipping traded equipment. 471 **/ 472 void CompleteTransaction(); 473 474 /** \brief Updates the costs and sales totals 475 *** \param costs_amount The amount to change the purchases cost member by 476 *** \param sales_amount The amount to change the sales revenue member by 477 *** 478 *** Obviously if one wishes to only update either costs or sales but not both, pass a zero value for the 479 *** appropriate argument that should not be changed. This function should only be called when necessary because 480 *** it also has to update the finance text. Thus the function does not just modify integer values but in fact 481 *** does have a small amount of computational overhead 482 **/ 483 void UpdateFinances(int32 costs_amount, int32 sales_amount); 484 485 /** \brief Changes the active state of shop mode and prepares the interface of the new state 486 *** \param new_state The state to change the shop to 487 **/ 488 void ChangeState(private_shop::SHOP_STATE new_state); 489 490 //! \brief Returns true if the user has indicated they wish to buy or sell any items HasPreparedTransaction()491 bool HasPreparedTransaction() const 492 { return ((_total_costs != 0) || (_total_sales != 0)); } 493 494 //! \brief Returns the number of drunes that the party would be left with after the marked purchases and sales GetTotalRemaining()495 uint32 GetTotalRemaining() const 496 { return (hoa_global::GlobalManager->GetDrunes() + _total_sales - _total_costs); } 497 498 /** \name Exported class methods 499 *** The methods in this group are avaiable to be called from within Lua. Their intended use is for setting shop settings 500 *** and initializing data before the shop is opened. 501 **/ 502 //@{ 503 /** \brief Sets the name of the store that should be displayed to the player 504 *** \param greeting The name of the shop 505 *** \note This method will only work if it is called before the shop is initialized. Calling it afterwards will 506 *** result in no operation and a warning message 507 **/ 508 void SetShopName(hoa_utils::ustring name); 509 510 /** \brief Sets the greeting message from the shop/merchant 511 *** \param greeting The text 512 *** \note This method will only work if it is called before the shop is initialized. Calling it afterwards will 513 *** result in no operation and a warning message 514 **/ 515 void SetGreetingText(hoa_utils::ustring greeting); 516 517 /** \brief Sets the buy and sell price levels for the shop 518 *** \param buy_level The price level to set for wares that the player would buy from the shop 519 *** \param sell_level The price level to set for wares that the player would sell to the shop 520 *** \note This method will only work if it is called before the shop is initialized. Calling it afterwards will 521 *** result in no operation and a warning message 522 **/ 523 void SetPriceLevels(SHOP_PRICE_LEVEL buy_level, SHOP_PRICE_LEVEL sell_level); 524 525 /** \brief Adds a new object for the shop to sell 526 *** \param object_id The id number of the object to add 527 *** \param stock The amount of the object to make available for sale at the shop 528 *** 529 *** Adding an object after the shop mode instance has already been initialized (by being made the active game state) 530 *** this call will add the object but will not be visible to the player. 531 **/ 532 void AddObject(uint32 object_id, uint32 stock); 533 //@} 534 535 /** \brief Deletes an object from the shop 536 *** \param object_id The id number of the object to remove 537 *** 538 *** This function should be used in only one specific case. This case is when the player owns this object and 539 *** chooses to sell all instances of it and additionally the shop does not sell this item. Trying to remove 540 *** an object that the shop sells to the player or trying to remove an object that still remains in the party's 541 *** inventory will result in a warning message and the object will not be removed. 542 **/ 543 void RemoveObject(uint32 object_id); 544 545 //! \name Class member access functions 546 //@{ IsInitialized()547 bool IsInitialized() const 548 { return _initialized; } 549 GetState()550 private_shop::SHOP_STATE GetState() const 551 { return _state; } 552 GetBuyPriceLevel()553 SHOP_PRICE_LEVEL GetBuyPriceLevel() const 554 { return _buy_price_level; } 555 GetSellPriceLevel()556 SHOP_PRICE_LEVEL GetSellPriceLevel() const 557 { return _sell_price_level; } 558 GetDealTypes()559 uint8 GetDealTypes() const 560 { return _deal_types; } 561 GetTotalCosts()562 uint32 GetTotalCosts() const 563 { return _total_costs; } 564 GetTotalSales()565 uint32 GetTotalSales() const 566 { return _total_sales; } 567 GetShopObjects()568 std::map<uint32, private_shop::ShopObject>* GetShopObjects() 569 { return &_shop_objects; } 570 GetBuyList()571 std::map<uint32, private_shop::ShopObject*>* GetBuyList() 572 { return &_buy_list; } 573 GetSellList()574 std::map<uint32, private_shop::ShopObject*>* GetSellList() 575 { return &_sell_list; } 576 GetTopWindow()577 hoa_gui::MenuWindow* GetTopWindow() 578 { return &_top_window; } 579 GetMiddleWindow()580 hoa_gui::MenuWindow* GetMiddleWindow() 581 { return &_middle_window; } 582 GetBottomWindow()583 hoa_gui::MenuWindow* GetBottomWindow() 584 { return &_bottom_window; } 585 //@} 586 587 private: 588 /** \brief A reference to the current instance of ShopMode 589 *** This is used by other shop clases to be able to refer to the shop that they exist in. This member 590 *** is NULL when no shop is active 591 **/ 592 static ShopMode* _current_instance; 593 594 //! \brief Set to true only after the shop has been initialized and is ready to be used by the player 595 bool _initialized; 596 597 //! \brief Keeps track of what windows are open to determine how to handle user input. 598 private_shop::SHOP_STATE _state; 599 600 //! \brief A bit vector that represents the types of merchandise that the shop deals in (items, weapons, etc) 601 uint8 _deal_types; 602 603 //! \brief The shop's price level of objects that the player buys from the shop 604 SHOP_PRICE_LEVEL _buy_price_level; 605 606 //! \brief The shop's price level of objects that the player sells to the shop 607 SHOP_PRICE_LEVEL _sell_price_level; 608 609 //! \brief The total cost of all marked purchases. 610 uint32 _total_costs; 611 612 //! \brief The total revenue that will be earned from all marked sales. 613 uint32 _total_sales; 614 615 /** \brief A container of objects that ShopMode created itself and need to be deleted when finished 616 *** These also happen to represent a list of all global objects that the shop may sell to the player 617 **/ 618 std::vector<hoa_global::GlobalObject*> _created_objects; 619 620 /** \brief Holds all objects that can be bought, sold, or traded in the shop 621 *** The integer key to this map is the global object ID represented by the ShopObject. 622 **/ 623 std::map<uint32, private_shop::ShopObject> _shop_objects; 624 625 /** \brief Holds pointers to all objects that the player plans to purchase 626 *** The integer key to this map is the global object ID represented by the ShopObject. 627 **/ 628 std::map<uint32, private_shop::ShopObject*> _buy_list; 629 630 /** \brief Holds pointers to all objects that the player plans to sell 631 *** The integer key to this map is the global object ID represented by the ShopObject. 632 **/ 633 std::map<uint32, private_shop::ShopObject*> _sell_list; 634 635 //! \brief A pointer to the ShopMedia object created to coincide with this instance of ShopMode 636 private_shop::ShopMedia* _shop_media; 637 638 /** \brief A pointer to the ShopObjectViewer object created to assist interface classes in visual presentation 639 *** ShopMode only creates and initializes this object and makes it available for the shop interfaces to use. 640 *** It does not call any standard methods on this class such as Update() or Draw(). That has to be done by 641 *** the interface class that uses it. 642 **/ 643 private_shop::ShopObjectViewer* _object_viewer; 644 645 /** \name Shopping interfaces 646 *** These are class objects which are responsible for managing each state in shop mode 647 **/ 648 //@{ 649 private_shop::RootInterface* _root_interface; 650 private_shop::BuyInterface* _buy_interface; 651 private_shop::SellInterface* _sell_interface; 652 private_shop::TradeInterface* _trade_interface; 653 private_shop::ConfirmInterface* _confirm_interface; 654 private_shop::LeaveInterface* _leave_interface; 655 //@} 656 657 //! \brief Holds an image of the screen taken when the ShopMode instance was created 658 hoa_video::StillImage _screen_backdrop; 659 660 //! \brief The highest level window that contains the shop actions and finance information 661 hoa_gui::MenuWindow _top_window; 662 663 //! \brief The largest window usually used to display lists of objects 664 hoa_gui::MenuWindow _middle_window; 665 666 //! \brief The lowest window typically displays detailed information or additional shop options 667 hoa_gui::MenuWindow _bottom_window; 668 669 //! \brief The list of options for what the player may do in shop mode 670 hoa_gui::OptionBox _action_options; 671 672 //! \brief Separate text images for each action option. Displayed when _action_options are hidden 673 std::vector<hoa_video::TextImage> _action_titles; 674 675 //! \brief Table-formatted text containing the financial information about the current purchases and sales 676 hoa_gui::OptionBox _finance_table; 677 }; // class ShopMode : public hoa_mode_manager::GameMode 678 679 } // namespace hoa_shop 680 681 #endif // __SHOP_HEADER__ 682