1 /*
2 * Seven Kingdoms: Ancient Adversaries
3 *
4 * Copyright 1997,1998 Enlight Software Ltd.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 //Filename : OSITE2.CPP
22 //Description : Object Site Material - display info functions
23
24 #include <OVGA.h>
25 #include <vga_util.h>
26 #include <OINFO.h>
27 #include <OFONT.h>
28 #include <OWORLD.h>
29 #include <OIMGRES.h>
30 #include <ORAWRES.h>
31 #include <OGODRES.h>
32 #include <ORACERES.h>
33 #include <OSITE.h>
34 #include "gettext.h"
35 #include <OMOUSE.h>
36
37 //--------- Begin of function Site::disp_info ---------//
38 //
disp_info(int refreshFlag)39 void Site::disp_info(int refreshFlag)
40 {
41 if( refreshFlag != INFO_REPAINT )
42 return;
43
44 //------- natural resource site ------//
45
46 if( site_type == SITE_RAW )
47 {
48 font_san.d3_put( INFO_X1, INFO_Y1, INFO_X2, INFO_Y1+17, _("Natural Resource") );
49 vga_util.d3_panel_up( INFO_X1, INFO_Y1+20, INFO_X2, INFO_Y1+59, 1 );
50
51 int x=INFO_X1+4, y=INFO_Y1+24;
52
53 font_san.put_field( x, y , _("Resource"), x+70, _(raw_res[object_id]->name) );
54 font_san.put_field( x, y+16, _("Reserve") , x+70, reserve_qty, 1 );
55 }
56
57 //--------- scroll of power --------//
58
59 else if( site_type == SITE_SCROLL )
60 {
61 font_san.d3_put( INFO_X1, INFO_Y1, INFO_X2, INFO_Y1+17, _("Scroll of Power") );
62 vga_util.d3_panel_up( INFO_X1, INFO_Y1+20, INFO_X2, INFO_Y1+59, 1 );
63
64 int x=INFO_X1+4, y=INFO_Y1+24;
65
66 GodInfo* godInfo = god_res[object_id];
67
68 font_san.put_field( x, y , _("Nationality"), x+82, _(race_res[godInfo->race_id]->name) );
69 font_san.put_field( x, y+16, _("Invoke") , x+82, _(unit_res[godInfo->unit_id]->name) );
70 }
71
72 //----------- gold coins -----------//
73
74 else if( site_type == SITE_GOLD_COIN )
75 {
76 font_san.d3_put( INFO_X1, INFO_Y1, INFO_X2, INFO_Y1+17, _("Treasure") );
77 vga_util.d3_panel_up( INFO_X1, INFO_Y1+20, INFO_X2, INFO_Y1+43, 1 );
78
79 int x=INFO_X1+4, y=INFO_Y1+24;
80
81 font_san.put_field( x, y, _("Worth"), x+60, object_id, 2 );
82 }
83 }
84 //----------- End of function Site::disp_info -----------//
85
86
87 //--------- Begin of function Site::detect_info ---------//
88 //
detect_info()89 void Site::detect_info()
90 {
91 if( ISKEY(KEYEVENT_OBJECT_PREV) )
92 {
93 site_array.disp_next(-1, 0); // previous same object type of any nation
94 return;
95 }
96
97 if( ISKEY(KEYEVENT_OBJECT_NEXT) )
98 {
99 site_array.disp_next(1, 0); // next same object type of any nation
100 return;
101 }
102
103 if( ISKEY(KEYEVENT_NATION_OBJECT_PREV) )
104 {
105 site_array.disp_next(-1, 1); // prevous same object type of the same nation
106 return;
107 }
108
109 if( ISKEY(KEYEVENT_NATION_OBJECT_NEXT) )
110 {
111 site_array.disp_next(1, 1); // next same object type of the same nation
112 return;
113 }
114 }
115 //----------- End of function Site::detect_info -----------//
116
117
118 //--------- Begin of function Site::draw ---------//
119 //
draw(int x,int y)120 void Site::draw(int x, int y)
121 {
122 char* bmpPtr;
123
124 switch( site_type )
125 {
126 case SITE_RAW:
127 bmpPtr = raw_res.large_raw_icon(object_id);
128 break;
129
130 case SITE_SCROLL:
131 {
132 char iconName[]="SCROLL-0";
133 iconName[7] = race_res[object_id]->code[0];
134 bmpPtr = image_spict.get_ptr(iconName);
135 break;
136 }
137
138 case SITE_GOLD_COIN:
139 {
140 // ##### begin Gilbert 30/8 ######//
141 #define MAX_COINS_TYPE 8
142 // ##### end Gilbert 30/8 ######//
143
144 char iconName[]="COINS-0";
145 iconName[6] = '1' + object_id % MAX_COINS_TYPE;
146 bmpPtr = image_spict.get_ptr(iconName);
147 break;
148 }
149 }
150
151 vga_back.put_bitmap_trans( x, y, bmpPtr );
152 }
153 //----------- End of function Site::draw -----------//
154
155
156 //------- Begin of function Site::draw_selected -----------//
157 //
158 // Draw a square around the raw material site on the map.
159 //
draw_selected()160 void Site::draw_selected()
161 {
162 Location* locPtr = world.get_loc(map_x_loc, map_y_loc);
163
164 if( locPtr->is_firm() || locPtr->is_town() ) // do not draw the selection frame if there is a firm or town built on the top of the site
165 return;
166
167 //------ calculate frame coordinations ---------//
168
169 int x1 = map_x_loc * ZOOM_LOC_WIDTH;
170 int y1 = map_y_loc * ZOOM_LOC_HEIGHT;
171 int x2 = x1 + ZOOM_LOC_WIDTH - 1;
172 int y2 = y1 + ZOOM_LOC_HEIGHT - 1;
173
174 x1 = x1 - World::view_top_x + ZOOM_X1;
175 y1 = y1 - World::view_top_y + ZOOM_Y1;
176 x2 = x2 - World::view_top_x + ZOOM_X1;
177 y2 = y2 - World::view_top_y + ZOOM_Y1;
178
179 //------------ draw the square frame now ------------//
180
181 if( x1>=ZOOM_X1 && y1>=ZOOM_Y1 && x2<=ZOOM_X2 && y2<=ZOOM_Y2 )
182 {
183 vga_back.rect( x1, y1, x2, y2, 1, OWN_SELECT_FRAME_COLOR );
184 }
185 }
186 //--------- End of function Site::draw_selected -----------//
187
188
189 //--------- Begin of function SiteArray::draw_dot ---------//
190 //
191 // Draw 2x2 tiny squares on map window representing the
192 // location of raw materials sites.
193 //
draw_dot()194 void SiteArray::draw_dot()
195 {
196 char* vgaBufPtr = vga_back.buf_ptr();
197 char* writePtr;
198 int i, mapX, mapY;
199 Site* rawPtr;
200
201 // ###### begin Gilbert 7/7 #######//
202 int vgaBufPitch = vga_back.buf_pitch();
203 // ###### end Gilbert 7/7 #######//
204
205 for(i=1; i <=size() ; i++)
206 {
207 if( is_deleted(i) )
208 continue;
209
210 rawPtr = operator[](i);
211
212 mapX = MAP_X1 + rawPtr->map_x_loc;
213 mapY = MAP_Y1 + rawPtr->map_y_loc;
214
215 if( mapX == MAP_WIDTH-1 )
216 mapX = MAP_WIDTH-2;
217
218 if( mapY == MAP_HEIGHT-1 )
219 mapY = MAP_HEIGHT-2;
220
221 // ###### begin Gilbert 2/9 #######//
222 writePtr = vgaBufPtr + mapY*vgaBufPitch + mapX;
223
224 if( writePtr[-vgaBufPitch-1] != UNEXPLORED_COLOR )
225 writePtr[-vgaBufPitch-1] = (char) SITE_COLOR;
226
227 if( writePtr[-vgaBufPitch] != UNEXPLORED_COLOR )
228 writePtr[-vgaBufPitch] = (char) SITE_COLOR;
229
230 if( writePtr[-vgaBufPitch+1] != UNEXPLORED_COLOR )
231 writePtr[-vgaBufPitch+1] = (char) SITE_COLOR;
232
233 if( writePtr[-1] != UNEXPLORED_COLOR )
234 writePtr[-1] = (char) SITE_COLOR;
235
236 if( writePtr[0] != UNEXPLORED_COLOR )
237 writePtr[0] = (char) SITE_COLOR;
238
239 if( writePtr[1] != UNEXPLORED_COLOR )
240 writePtr[1] = (char) SITE_COLOR;
241
242 if( writePtr[vgaBufPitch-1] != UNEXPLORED_COLOR )
243 writePtr[vgaBufPitch-1] = (char) SITE_COLOR;
244
245 if( writePtr[vgaBufPitch] != UNEXPLORED_COLOR )
246 writePtr[vgaBufPitch] = (char) SITE_COLOR;
247
248 if( writePtr[vgaBufPitch+1] != UNEXPLORED_COLOR )
249 writePtr[vgaBufPitch+1] = (char) SITE_COLOR;
250
251 // ###### end Gilbert 2/9 #######//
252 }
253 }
254 //----------- End of function SiteArray::draw_dot -----------//
255
256