Advanced Strategic Command
dlgraph.cpp
Go to the documentation of this file.
1 
8 // $Id: dlgraph.cpp,v 1.16 2008-12-20 14:25:47 mbickel Exp $
9 //
10 // $Log: not supported by cvs2svn $
11 // Revision 1.15 2007/04/13 16:15:53 mbickel
12 // Merged ASC2 branch
13 //
14 // Revision 1.13.2.1 2006/03/01 21:00:50 mbickel
15 // Clean up of source
16 // Fixed to construction icons
17 //
18 // Revision 1.13 2001/07/30 17:43:13 mbickel
19 // Added Microsoft Visual Studio .net project files
20 // Fixed some warnings
21 //
22 // Revision 1.12 2001/07/14 14:26:10 mbickel
23 // Some cleanup
24 //
25 // Revision 1.11 2001/02/11 11:39:31 mbickel
26 // Some cleanup and documentation
27 //
28 // Revision 1.10 2001/01/28 14:04:12 mbickel
29 // Some restructuring, documentation and cleanup
30 // The resource network functions are now it their own files, the dashboard
31 // as well
32 // Updated the TODO list
33 //
34 // Revision 1.9 2000/10/16 14:34:12 mbickel
35 // Win32 port is now running fine.
36 // Removed MSVC project files and put them into a zip file in
37 // asc/source/win32/msvc/
38 //
39 // Revision 1.8 2000/08/12 09:17:26 gulliver
40 // *** empty log message ***
41 //
42 // Revision 1.7 2000/08/08 09:48:12 mbickel
43 //
44 // speed up of dialog boxes in linux
45 // fixed graphical errors in attack
46 // fixed graphical error in ammo transfer
47 // fixed reaction fire not allowing manual attack
48 //
49 // Revision 1.6 2000/05/23 20:40:43 mbickel
50 // Removed boolean type
51 //
52 // Revision 1.5 2000/04/27 16:25:20 mbickel
53 // Attack functions cleanup
54 // New vehicle categories
55 // Rewrote resource production in ASC resource mode
56 // Improved mine system: several mines on a single field allowed
57 // Added unitctrl.* : Interface for vehicle functions
58 // currently movement and height change included
59 // Changed timer to SDL_GetTicks
60 //
61 // Revision 1.4 1999/12/30 20:30:32 mbickel
62 // Improved Linux port again.
63 //
64 // Revision 1.3 1999/12/28 21:02:52 mbickel
65 // Continued Linux port
66 // Added KDevelop project files
67 //
68 // Revision 1.2 1999/11/16 03:41:27 tmwilson
69 // Added CVS keywords to most of the files.
70 // Started porting the code to Linux (ifdef'ing the DOS specific stuff)
71 // Wrote replacement routines for kbhit/getch for Linux
72 // Cleaned up parts of the code that gcc barfed on (char vs unsigned char)
73 // Added autoconf/automake capabilities
74 // Added files used by 'automake --gnu'
75 //
76 //
77 /*
78  This file is part of Advanced Strategic Command; http://www.asc-hq.de
79  Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger
80 
81  This program is free software; you can redistribute it and/or modify
82  it under the terms of the GNU General Public License as published by
83  the Free Software Foundation; either version 2 of the License, or
84  (at your option) any later version.
85 
86  This program is distributed in the hope that it will be useful,
87  but WITHOUT ANY WARRANTY; without even the implied warranty of
88  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
89  GNU General Public License for more details.
90 
91  You should have received a copy of the GNU General Public License
92  along with this program; see the file COPYING. If not, write to the
93  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
94  Boston, MA 02111-1307 USA
95 */
96 
97 void tdialogbox::rahmen(bool invers,
98  int x1,
99  int y1,
100  int x2,
101  int y2)
102 {
103  collategraphicoperations cgs ( x1, y1, x2, y2 );
104 
105  Uint8 col = (invers == false) ? white : darkgray;
106 
107  line(x1,y1,x1,y2,col);
108  line(x1,y1,x2,y1,col);
109 
110  col = (invers == true) ? white : darkgray;
111 
112  line(x2,y1,x2,y2,col);
113  line(x1,y2,x2,y2,col);
114 }
115 
116 void tdialogbox::rahmen( bool invers,
117  tmouserect rect )
118 {
119  rahmen ( invers, rect.x1, rect.y1, rect.x2,rect.y2 );
120 }
121 
122 void tdialogbox::knopf(int xx1,
123  int yy1,
124  int xx2,
125  int yy2)
126 {
127  collategraphicoperations cgs ( xx1, yy1, xx2, yy2 );
128 
129  paintsurface2(xx1,yy1,xx2,yy2);
130  rahmen(false,xx1,yy1,xx2,yy2);
131 }
132 
133 
135  int yy1,
136  int xx2,
137  int yy2)
138 {
139 
140  collategraphicoperations cgs ( xx1, yy1, xx2, yy2 );
141 
142  void* p;
143  int mt;
144 
145  mt = mouseparams.taste;
146  mousevisible(false);
147 
148  void* pq = malloc ( imagesize ( xx1 , yy1 , xx2 , yy2 ));
149  getimage( xx1 , yy1 , xx2 , yy2 , pq );
150 
151  p = malloc ( imagesize ( xx1 + 1,yy1 + 1,xx2 - 2,yy2 - 2 ));
152  getimage(xx1 + 1,yy1 + 1,xx2 - 2,yy2 - 2, p);
153  putimage(xx1 + 3,yy1 + 3, p );
154  rahmen(true, xx1, yy1, xx2, yy2);
155  mousevisible(true);
156  knopfsuccessful = true;
157  bool kn = true;
158  do {
159  if ((mouseparams.x > xx2) || (mouseparams.x < xx1) || (mouseparams.y > yy2) || (mouseparams.y < yy1)) {
160  knopfsuccessful = false;
161  kn = false;
162  }
163  if (mouseparams.taste != mt)
164  kn = false;
166  } while (kn == true);
167  mousevisible(false);
168 
169  putimage(xx1 + 1,yy1 + 1, p);
170  free ( p );
171 
172  putimage( xx1 , yy1 , pq );
173  free ( pq );
174 
175  mousevisible(true);
176 }
177 
178 
179 
180 void tdialogbox::newknopf(int xx1,
181  int yy1,
182  int xx2,
183  int yy2)
184 {
185  collategraphicoperations cgs ( xx1-1, yy1-1, xx2+1, yy2+1 );
186 
187  paintsurface2(xx1,yy1,xx2,yy2);
188 
189  rahmen(true, xx1 - 1, yy1 - 1,xx2 + 1,yy2 + 1);
190  rahmen(false, xx1,yy1, xx2,yy2);
191 }
192 
193 
195  int yy1,
196  int xx2,
197  int yy2)
198 {
199 
200  void* p;
201  bool kn;
202  int mt;
203  {
204  collategraphicoperations cgs ( xx1 -1, yy1 -1, xx2 + 1, yy2 + 1 );
205  mt = mouseparams.taste;
206  mousevisible(false);
207  p = malloc ( imagesize ( xx1 + 1,yy1 + 1,xx2 - 2,yy2 - 2 ) );
208  getimage(xx1 + 1,yy1 + 1,xx2 - 2,yy2 - 2, p);
209  putimage(xx1 + 3,yy1 + 3, p);
210 
211  line(xx1 - 1,yy1 - 1,xx2 + 1,yy1 - 1, 8);
212  line(xx1 - 1,yy1 - 1,xx1 - 1,yy2 + 1, 8);
213  line(xx2 + 1,yy1 - 1,xx2 + 1,yy2 + 1, 15);
214  line(xx1 - 1,yy2 + 1,xx2 + 1,yy2 + 1, 15);
215 
216  line(xx1,yy1,xx2,yy1, 8);
217  line(xx1,yy1,xx1,yy2, 8);
218  line(xx2,yy1,xx2,yy2, 15);
219  line(xx1,yy2,xx2,yy2, 15);
220 
221  mousevisible(true);
222  knopfsuccessful = true;
223  kn = true;
224  }
225  do {
226  if ((mouseparams.x > xx2) || (mouseparams.x < xx1) || (mouseparams.y > yy2) || (mouseparams.y < yy1)) {
227  knopfsuccessful = false;
228  kn = false;
229  }
230  if (mouseparams.taste != mt)
231  kn = false;
233  } while (kn == true);
234  {
235  collategraphicoperations cgo ( xx1 - 1, yy1 - 1, xx2 + 1, yy2 + 1 );
236 
237  mousevisible(false);
238 
239  if (knopfsuccessful == false)
240  putimage (xx1 + 1,yy1 + 1,p);
241  free ( p );
242 
243  if (knopfsuccessful == false) {
244  line(xx1 - 1,yy1 - 1,xx2 + 1,yy1 - 1, 8);
245  line(xx1 - 1,yy1 - 1,xx1 - 1,yy2 + 1, 8);
246  line(xx2 + 1,yy1 - 1,xx2 + 1,yy2 + 1, 15);
247  line(xx1 - 1,yy2 + 1,xx2 + 1,yy2 + 1, 15);
248 
249  line(xx1,yy1,xx2,yy1, 15);
250  line(xx1,yy1,xx1,yy2, 15);
251  line(xx2,yy1,xx2,yy2, 8);
252  line(xx1,yy2,xx2,yy2, 8);
253  }
254  mousevisible(true);
255  }
256 
257 }
258 
259 
261  int yy1,
262  int xx2,
263  int yy2)
264 {
265  collategraphicoperations cgs ( xx1, yy1, xx2, yy2 );
266 
267  void* p;
268 
269  // vom reingedr?ckten in den Normalzustand
270 
271  p = malloc ( imagesize ( xx1 + 4,yy1 + 4,xx2 - 2,yy2 - 2 ));
272  getimage(xx1 + 4,yy1 + 4,xx2 - 2,yy2 - 2, p );
273 
274  putimage(xx1 + 2,yy1 + 2,p);
275  free ( p );
276 
277  rahmen(false,xx1,yy1,xx2,yy2);
278 }
279 
280 
281 
282 
284  int yy1,
285  int xx2,
286  int yy2)
287 {
288  collategraphicoperations cgs ( xx1, yy1, xx2, yy2 );
289 
290  void* p;
291  // reindr?cken
292 
293  p = malloc ( imagesize ( xx1 + 2,yy1 + 2,xx2 - 4,yy2 - 4 )) ;
294  getimage(xx1 + 2,yy1 + 2,xx2 - 4,yy2 - 4, p);
295  putimage(xx1 + 4,yy1 + 4, p);
296  free ( p );
297 
298  rahmen(true,xx1,yy1,xx2,yy2);
299 }
300 
301 
303  int yy1,
304  int xx2,
305  int yy2)
306 {
307 
308  void* p;
309  bool kn;
310  int mt;
311  void* pq ;
312  {
313  collategraphicoperations cgs( xx1-1, yy1-1, xx2+1, yy2+1 );
314  mt = mouseparams.taste;
315  mousevisible(false);
316 
317  pq = malloc ( imagesize ( xx1 , yy1 , xx2 , yy2 ));
318  getimage( xx1 , yy1 , xx2 , yy2 , pq );
319 
320 
321  p = malloc ( imagesize ( xx1 + 1,yy1 + 1,xx2 - 2,yy2 - 2 ));
322  getimage(xx1 + 1,yy1 + 1,xx2 - 2,yy2 - 2, p);
323  putimage(xx1 + 3,yy1 + 3, p);
324 
325  line(xx1 - 1,yy1 - 1,xx2 + 1,yy1 - 1, 8);
326  line(xx1 - 1,yy1 - 1,xx1 - 1,yy2 + 1, 8);
327 
328  line(xx2 + 1,yy1 - 1,xx2 + 1,yy2 + 1, 15);
329  line(xx1 - 1,yy2 + 1,xx2 + 1,yy2 + 1, 15);
330 
331  line(xx1,yy1,xx2,yy1, 8);
332  line(xx1,yy1,xx1,yy2, 8);
333 
334  line(xx2,yy1,xx2,yy2, 15);
335  line(xx1,yy2,xx2,yy2, 15);
336  mousevisible(true);
337 
338  knopfsuccessful = true;
339  kn = true;
340  }
341  do {
342  if ((mouseparams.x > xx2) || (mouseparams.x < xx1) || (mouseparams.y > yy2) || (mouseparams.y < yy1)) {
343  knopfsuccessful = false;
344  kn = false;
345  }
346  if (mouseparams.taste != mt)
347  kn = false;
349  } while (kn == true);
350  {
351  collategraphicoperations cgo( xx1-1, yy1-1, xx2+1, yy2+1 );
352  mousevisible(false);
353  putimage(xx1 + 1,yy1 + 1,p);
354  free ( p ) ;
355 
356  line(xx1 - 1,yy1 - 1,xx2 + 1,yy1 - 1, 8);
357  line(xx1 - 1,yy1 - 1,xx1 - 1,yy2 + 1, 8);
358 
359  line(xx2 + 1,yy1 - 1,xx2 + 1,yy2 + 1, 15);
360  line(xx1 - 1,yy2 + 1,xx2 + 1,yy2 + 1, 15);
361 
362  line(xx1,yy1,xx2,yy1, 15);
363  line(xx1,yy1,xx1,yy2, 15);
364 
365  line(xx2,yy1,xx2,yy2, 8);
366  line(xx1,yy2,xx2,yy2, 8);
367 
368  putimage( xx1 , yy1 , pq );
369  free ( pq );
370 
371  mousevisible(true);
372  }
373 }
void paintsurface2(int xx1, int yy1, int xx2, int yy2)
Definition: dlg_box.cpp:2492
void putimage(int x1, int y1, void *img)
puts the image pointed to by buffer to the screen
Definition: basegfx.cpp:1280
void rahmen(bool invers, int x1, int y1, int x2, int y2)
Definition: dlgraph.cpp:97
int x1
Definition: events.h:64
void newknopf(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:180
void knopfdruck(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:134
Uint8 taste
Definition: events.h:95
int knopfsuccessful
Definition: dlg_box.h:214
char * malloc(int)
const int white
Definition: basegfx.h:102
void newknopfdruck4(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:283
void knopf(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:122
void newknopfdruck3(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:260
int releasetimeslice(void)
Definition: events.cpp:209
int imagesize(int x1, int y1, int x2, int y2)
returns the size for a buffer that can contain an image of the given size.
Definition: basegfx.cpp:896
int y2
Definition: events.h:65
void newknopfdruck2(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:194
void newknopfdruck(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:302
const int darkgray
Definition: basegfx.h:95
void getimage(int x1, int y1, int x2, int y2, void *buffer)
copy an image to a buffer. buffer must have been alloced before with malloc ( imagesize ( x1...
Definition: basegfx.cpp:1256
int y1
Definition: events.h:64
void mousevisible(int an)
Definition: events.cpp:75
volatile tmousesettings mouseparams
Definition: events.cpp:35
Collects all graphic operations and updates the screen on destruction When porting ASC from DOS to SD...
Definition: basegfx.h:406
int x2
Definition: events.h:65
void line(int x1, int y1, int x2, int y2, Uint8 actcol)
draws a simple line on the screen. Not very fast...
Definition: basegfx.cpp:181