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 : OR_NEWS.CPP
22 //Description : Report for displaying AI actions
23
24 #include <OVGA.h>
25 #include <ODATE.h>
26 #include <OSYS.h>
27 #include <OFONT.h>
28 #include <OMOUSE.h>
29 #include <OIMGRES.h>
30 #include <OVBROWIF.h>
31 #include <OBUTTON.h>
32 #include <OTALKRES.h>
33 #include <ONEWS.h>
34 #include <OINFO.h>
35
36 //------------- Define coordinations -----------//
37
38 enum { NEWS_BROWSE_X1 = ZOOM_X1+6,
39 NEWS_BROWSE_Y1 = ZOOM_Y1+6,
40 NEWS_BROWSE_X2 = ZOOM_X2-6,
41 NEWS_BROWSE_Y2 = ZOOM_Y2-25,
42 };
43
44 //----------- Define static variables ----------//
45
46 static VBrowseIF browse_news;
47
48 //----------- Define static functions ----------//
49
50 static void put_news_rec(int recNo, int x, int y, int refreshFlag);
51
52 //--------- Begin of function Info::disp_news_log ---------//
53 //
disp_news_log(int refreshFlag)54 void Info::disp_news_log(int refreshFlag)
55 {
56 int x=NEWS_BROWSE_X1+9;
57 int y=NEWS_BROWSE_Y1+4;
58
59 if( refreshFlag == INFO_REPAINT )
60 {
61 browse_news.init( NEWS_BROWSE_X1, NEWS_BROWSE_Y1, NEWS_BROWSE_X2, NEWS_BROWSE_Y2,
62 0, 32, news_array.size(), put_news_rec, 1 );
63
64 browse_news.open(browse_news_recno);
65 }
66 else
67 {
68 browse_news.paint();
69 browse_news.open(browse_news_recno, news_array.size());
70 }
71
72 //------- display button ---------//
73
74 image_icon.put_back(ZOOM_X2-20, ZOOM_Y2-18, "NEWS_LOG"); // news log report
75 }
76 //----------- End of function Info::disp_news_log -----------//
77
78
79 //--------- Begin of function Info::detect_news_log ---------//
80 //
detect_news_log()81 void Info::detect_news_log()
82 {
83 if( browse_news.detect() )
84 browse_news_recno = browse_news.recno();
85
86 //--------- detect button --------//
87
88 if( mouse.single_click( ZOOM_X2-20, ZOOM_Y2-18, ZOOM_X2-11, ZOOM_Y2-9 ) )
89 sys.set_view_mode(MODE_NORMAL);
90 }
91 //----------- End of function Info::detect_news_log -----------//
92
93
94 //-------- Begin of static function put_news_rec --------//
95 //
put_news_rec(int recNo,int x,int y,int refreshFlag)96 static void put_news_rec(int recNo, int x, int y, int refreshFlag)
97 {
98 News* newsPtr = news_array[ news_array.size()-recNo+1 ]; // display in reversed order
99
100 char* dateStr = date.date_str(newsPtr->news_date, 1);
101 int dateWidth = font_san.text_width(dateStr) + 5;
102 static int maxDateWidth = 90;
103
104 maxDateWidth = MAX(maxDateWidth, dateWidth);
105
106 font_san.put( x+20, y, dateStr );
107
108 talk_res.msg_add_nation_color = 1;
109 font_san.put_paragraph( x+20+maxDateWidth, y, browse_news.ix2-30, y+30, newsPtr->msg() );
110 talk_res.msg_add_nation_color = 0;
111
112 //----- display and detect the go icon -----//
113
114 if( newsPtr->is_loc_valid() )
115 {
116 image_icon.put_back( x+2, y+1, "NEWS_GO" );
117
118 if( mouse.single_click(x+2, y+1, x+12, y+11) )
119 {
120 vga.use_front();
121 world.go_loc( newsPtr->loc_x, newsPtr->loc_y, 1 ); // 1-select object on the location if there is any
122 vga.use_back();
123 }
124 }
125 }
126 //----------- End of static function put_news_rec -----------//
127
128
129