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_root.h
12 *** \author  Tyler Olsen, roots@allacrost.org
13 *** \brief   Header file for root interface of shop mode
14 *** ***************************************************************************/
15 
16 #ifndef __SHOP_ROOT_HEADER__
17 #define __SHOP_ROOT_HEADER__
18 
19 #include "defs.h"
20 #include "utils.h"
21 
22 #include "video.h"
23 #include "global.h"
24 
25 #include "shop_utils.h"
26 
27 namespace hoa_shop {
28 
29 namespace private_shop {
30 
31 /** ****************************************************************************
32 *** \brief Assists the RootInterface in proper draw orientation of object category icons and text
33 ***
34 *** Shops have anywhere between one and eight different categories of objects that they may deal in.
35 *** One job of the root interface is to display the icon and name of all categories which the shop
36 *** deals in. This information is displayed in rows of four. To keep the interface looking nice and consistent
37 *** with all the different possible combinations of category numbers, the y draw position for the rows is altered
38 *** depending on whether one or two rows are to be drawn. The x draw position of the category icons and text is
39 *** also variable depending on the number of categories to be drawn in that row.
40 *** ***************************************************************************/
41 class CategoryDrawData {
42 public:
43 	/** \brief Determines the appropriate values to set for each class member
44 	*** \param number_categories The total number of object categories to draw. Valid range: 1-8
45 	**/
46 	void ComputeCoordinates(uint8 number_categories);
47 
48 	/** \brief The number of object categories in the first and second rows
49 	*** \note The first row may have 1-4 categories and the second row may have 0-4 categories
50 	**/
51 	uint8 first_row_num, second_row_num;
52 
53 	//! \brief Starting draw positions for the first and second rows of object categories
54 	float first_row_x, first_row_y, second_row_x, second_row_y;
55 }; // class CategoryDrawData
56 
57 
58 /** ****************************************************************************
59 *** \brief The highest level shopping interface which displays information about the shop
60 ***
61 *** This interface is the first information that the player sees when entering the shop.
62 *** Its function serves two purposes. The first is to allow the user to select between the
63 *** primary shop actions which are: buy, sell, trade, confirm, and leave. Its second purpose
64 *** is to display statistical information about the shop, including its name, price levels,
65 *** the type of wares it deals in, and a short greeting message from the shop keeper.
66 ***
67 *** The top window contains the shop actions which the user may select from. Take note that
68 *** the processing and display code for this segment is managed by the ShopMode class and not
69 *** here. This is so because the top window is mostly static throughout the different interface
70 *** classes, so having ShopMode manage it eliminates redundant code.
71 ***
72 *** The middle window contains the name of the shop at the top. Below that are star indicators
73 *** that inform the user how good the buy and sell prices for the shop are. The more stars, the
74 *** better it is to buy or sell equipment at the shop. Below the price information are a series
75 *** of icon images and labels that represent each type of object which may be bought or sold.
76 *** Not all stores deal in all types of objects, so those object types which the store does not
77 *** deal in are displayed in grayscale text.
78 ***
79 *** Finally, the bottom window contains nothing more than a short message or greeting from the
80 *** shop keeper.
81 *** ***************************************************************************/
82 class RootInterface : public ShopInterface {
83 public:
84 	RootInterface();
85 
~RootInterface()86 	~RootInterface() {}
87 
88 	//! \brief Initializes various textual and image data based on the shop properties
89 	void Initialize();
90 
91 	//! \brief No actions need to take place when this interface becomes activated
MakeActive()92 	void MakeActive()
93 		{}
94 
95 	//! \brief No actions need to take place when a transaction occurs
TransactionNotification()96 	void TransactionNotification()
97 		{}
98 
99 	//! \brief Updates the state of GUI objects and may also process user input
100 	void Update();
101 
102 	//! \brief Draws the root window and, if shop mode is in the correct state, the greeting window
103 	void Draw();
104 
105 	/** \brief Create's the shop name's text
106 	*** \param name The name of the shop
107 	**/
108 	void SetShopName(hoa_utils::ustring name);
109 
110 	/** \brief Creates the shop keeper's greeting message text
111 	*** \param greeting The textual greeting
112 	**/
113 	void SetGreetingText(hoa_utils::ustring greeting);
114 
115 private:
116 	//! \brief The rendered text image of the shop name
117 	hoa_video::TextImage _shop_name;
118 
119 	//! \brief Text for displaying price levels
120 	hoa_video::TextImage _buy_price_text, _sell_price_text;
121 
122 	//! \brief A composite image for the star rating of the buy and sell price levels
123 	hoa_video::CompositeImage _buy_price_rating, _sell_price_rating;
124 
125 	/** \brief Container for the text object representing each object category's name
126 	*** Categories which the shop does not deal in will have their text rendered in grayscale
127 	**/
128 	std::vector<hoa_video::TextImage> _category_names;
129 
130 	/** \brief Container for icon images that represent each object category
131 	*** Categories which the shop does not deal in will have their icon rendered in grayscale
132 	**/
133 	std::vector<hoa_video::StillImage> _category_icons;
134 
135 	//! \brief A textbox displaying a short greeting or message from the shop keeper
136 	hoa_gui::TextBox _greeting_text;
137 
138 	//! \brief A container holding the correct draw coordinates and information for object categories
139 	CategoryDrawData _category_draw_data;
140 }; // class RootInterface : public ShopInterface
141 
142 } // namespace private_shop
143 
144 } // namespace hoa_shop
145 
146 #endif // __SHOP_ROOT_HEADER__
147