Advanced Strategic Command
edmisc.cpp
Go to the documentation of this file.
1 
5 /*
6  This file is part of Advanced Strategic Command; http://www.asc-hq.de
7  Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger
8 
9  This program is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; see the file COPYING. If not, write to the
21  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22  Boston, MA 02111-1307 USA
23 */
24 
25 // #include <QClipbrd.hpp>
26 
27 #include <string>
28 #include <iostream>
29 #include <math.h>
30 
31 
32 #include "sdl/graphics.h"
33 #include "vehicletype.h"
34 #include "buildingtype.h"
35 #include "edmisc.h"
36 #include "loadbi3.h"
37 #include "edgen.h"
38 #include "edselfnt.h"
39 #include "edglobal.h"
40 #include "dialogs/pwd_dlg.h"
41 #include "mapdisplay.h"
42 #include "graphicset.h"
43 #include "itemrepository.h"
44 #include "textfileparser.h"
45 #include "textfile_evaluation.h"
46 #include "textfiletags.h"
47 #include "clipboard.h"
48 #include "dialogs/cargowidget.h"
49 #include "dialogs/fieldmarker.h"
50 #include "dialogs/newmap.h"
51 #include "stack.h"
52 
53 #include "unitset.h"
54 #include "maped-mainscreen.h"
55 #include "gameevents.h"
56 #include "gameevent_dialogs.h"
57 #include "dialogs/fileselector.h"
58 #include "pgeventsupplier.h"
60 #include "spfst-legacy.h"
61 #include "textfile_evaluation.h"
62 #include "lua/luarunner.h"
63 #include "lua/luastate.h"
64 #include "widgets/multilistbox.h"
65 
66 bool mapsaved;
67 
68 
69 
71 {
72  if ( selection.getSelection() && actmap->getCursor().valid() ) {
75  } else {
77  }
78  mapChanged( actmap );
79  }
80 }
81 
83 {
86  else
87  return false;
88 }
89 
90 
91 bool mousePressedOnField( const MapCoordinate& pos, const SPoint& mousePos, bool cursorChanged, int button, int prio )
92 {
93  if ( prio > 1 )
94  return false;
95 
96  if ( button == 1 ) {
98  return true;
99  } else
100  return false;
101 }
102 
103 bool mouseDraggedToField( const MapCoordinate& pos, const SPoint& mousePos, bool cursorChanged, int prio )
104 {
105  if ( prio > 1 )
106  return false;
108  return true;
109 }
110 
111 
112 // � Checkobject
113 
115 {
116  return !pf->objects.empty();
117 }
118 
119 
120 
121 // � PutResource
122 
123 void tputresources :: init ( int sx, int sy, int dst, int restype, int resmax, int resmin )
124 {
125  centerPos = MapCoordinate(sx,sy);
126  initsearch( centerPos, dst, 0);
127  resourcetype = restype;
128  maxresource = resmax;
129  minresource = resmin;
130  maxdst = dst;
131  startsearch();
132 }
133 
135 {
136  int dist = beeline ( mc, centerPos ) / 10;
137  int m = maxresource - dist * ( maxresource - minresource ) / maxdst;
138 
139  MapField* fld = gamemap->getField ( mc );
140  if ( resourcetype == 1 )
141  fld->material = min( 255, fld->material + m);
142  else
143  fld->fuel = min( 255, fld->fuel + m );
144 }
145 
147 {
148  resourcetype = 1;
149  restp2 = 0;
150  status = 0;
152  title = "set resources";
153  xsize = 400;
154  ysize = 300;
155  maxresource = 200;
156  minresource = 0;
157  dist = 10;
158 
159  addbutton ( "~O~k", 10, ysize - 30, xsize/2 - 5, ysize - 10 , 0, 1, 1, true );
160  addkey ( 1, ct_enter );
161  addbutton ( "~C~ancel", xsize/2 + 5, ysize - 30, xsize-10 - 5, ysize - 10 , 0, 1, 2, true );
162  addkey ( 2, ct_esc );
163 
164  addbutton ( "ma~x~ resources ( at center )", xsize/2 + 5, 80, xsize-20 - 5, 100 , 2, 1, 3, true );
165  addeingabe ( 3, &maxresource, 0, 255 );
166 
167  addbutton ( "mi~n~ resources ", xsize/2 + 5, 120, xsize-20 - 5, 140 , 2, 1, 4, true );
168  addeingabe ( 4, &minresource, 0, 255 );
169 
170  addbutton ( "max ~d~istance", 20, 120, xsize/2-5, 140 , 2, 1, 5, true );
171  addeingabe ( 5, &dist, 1, 20 );
172 
173  addbutton ( "~m~aterial", 20, 160, xsize/2-5, 180, 3, 10, 6, true );
174  addeingabe ( 6, &resourcetype, black, dblue );
175 
176  addbutton ( "~f~uel", xsize/2 + 5, 160, xsize - 20, 180, 3, 10, 7, true );
177  addeingabe ( 7, &restp2, black, dblue );
178 
179  buildgraphics();
180 
181 }
182 
184 {
186 
187  switch ( id ) {
188  case 1:
189  status = 11;
190  break;
191  case 2:
192  status = 10;
193  break;
194  case 6:
195  restp2 = 0;
196  enablebutton ( 7 );
197  break;
198  case 7:
199  resourcetype = 0;
200  enablebutton ( 6 );
201  break;
202  } /* endswitch */
203 
204 }
205 
207 {
208  mousevisible ( true );
209  do {
210  tdialogbox :: run ( );
211  } while ( status < 10 ); /* enddo */
212  if ( status == 11 ) {
213  tputresources pr ( actmap );
214  pr.init ( actmap->getCursor().x, actmap->getCursor().y, dist, resourcetype ? 1 : 2, maxresource, minresource );
215  }
216 }
217 
218 
219 
220 
221 // � Lines
222 
223 void lines(int x1,int y1,int x2,int y2)
224 {
225  line(x1,y1,x2,y1,white);
226  line(x2,y1,x2,y2,darkgray);
227  line(x1,y2,x2,y2,darkgray);
228  line(x1,y1,x1,y2,white);
229 }
230 
231 
232 
233 
234 // � PlayerChange
235 
236 /* class tcolorsel : public tstringselect {
237  public :
238  virtual void setup(void);
239  virtual void buttonpressed(int id);
240  virtual void run(void);
241  virtual void get_text(int nr);
242  };
243 
244 void tcolorsel::setup(void)
245 {
246 
247  action = 0;
248  title = "Select Color";
249  numberoflines = 9;
250  xsize = 250;
251  ex = xsize - 100;
252  ey = ysize - 60;
253  addbutton("~D~one",20,ysize - 40,120,ysize - 20,0,1,2,true);
254  addkey(2,ct_enter);
255  addbutton("~C~ancel",130,ysize - 40,230,ysize - 20,0,1,3,true);
256 }
257 
258 
259 void tcolorsel::buttonpressed(int id)
260 {
261  tstringselect::buttonpressed(id);
262  switch (id) {
263 
264  case 2:
265  case 3: action = id;
266  break;
267  }
268 }
269 
270 
271 void tcolorsel::get_text(int nr)
272 {
273  if (nr == 8) strcpy(txt,"Neutral");
274  else {
275  if ((nr>=0) && (nr<=7)) {
276  strcpy(txt,"Color ");
277  strcat(txt,strrr(nr+1));
278  } else {
279  strcpy(txt,"");
280  }
281  }
282 }
283 
284 
285 void tcolorsel::run(void)
286 {
287  mousevisible(false);
288  for (i=0;i<=8 ;i++ ) bar(x1 + 160,y1 + 52 + i*21 ,x1 + 190 ,y1 + 62 + i * 21,20 + i * 8);
289  mousevisible(true);
290  do {
291  tstringselect::run();
292  } while ( ! ( (taste == ct_esc) || ( (action == 2) || (action == 3) ) || (msel == 1)) );
293  if ( (action == 3) || (taste == ct_esc) ) redline = 255;
294 }
295 
296 
297 int colorselect(void)
298 {
299  tcolorsel sm;
300 
301  sm.init();
302  sm.run();
303  sm.done();
304  return sm.redline;
305 } */
306 
307 
308 class tplayerchange : public tdialogbox {
309 public :
310  int action;
311  int sel1,sel2;
312  int bkgcolor;
313  void init(void);
314  virtual void run(void);
315  virtual void buttonpressed(int id);
316  void anzeige(void);
317 };
318 
319 
320 
321 
323 {
324  char *s1;
325 
327  title = "Player Change";
328  x1 = 50;
329  xsize = 370;
330  y1 = 50;
331  ysize = 410;
332  action = 0;
333  sel1 = 255;
334  sel2 = 255;
336 
338 
339  for ( int i=0; i<=8 ; i++ ) {
340  s1 = new(char[12]);
341  if (i == 8) {
342  strcpy(s1,"~N~eutral");
343  } else {
344  strcpy(s1,"Player ~");
345  strcat(s1,strrr(i+1));
346  strcat(s1,"~");
347  }
348  addbutton(s1,20,55+i*30,150,75+i*30,0,1,6+i,true);
349  addkey(1,ct_1+i);
350  }
351 
352  //addbutton("~C~hange",20,ysize - 70,80,ysize - 50,0,1,3,true);
353  addbutton("X~c~hange",20,ysize - 70,170,ysize - 50,0,1,4,true);
354  addbutton("~M~erge",200,ysize - 70,350,ysize - 50,0,1,5,true);
355 
356  addbutton("~D~one",20,ysize - 40,170,ysize - 20,0,1,1,true);
357  addkey(1,ct_enter);
358  addbutton("E~x~it",200,ysize - 40,350,ysize - 20,0,1,2,true);
359 
360  buildgraphics();
361 
362  for ( int i=0; i<=8 ; i++ ) bar(x1 + 170,y1 + 60 + i*30 ,x1 + 190 ,y1 + 70 + i * 30,20 + ( i << 3 ));
363 
364  anzeige();
365 
366  mousevisible(true);
367 }
368 
370 {
371  int e,b,m[9];
372  for ( int i=0; i<=8 ; i++ )
373  m[i] =0;
374 
375  for ( int i =0; i < actmap->xsize * actmap->ysize ; i++ ) {
376  int color = actmap->field[i].mineowner();
377  if ( color >= 0 && color < 8 )
378  m[color]++;
379  }
385  mousevisible(false);
386  showtext2("Units",x1+210,y1+35);
387  showtext2("Build.",x1+260,y1+35);
388  showtext2("Mines",x1+310,y1+35);
389  for ( int i=0; i<=8 ; i++ ) {
390  if (i == sel1 ) rectangle (x1 + 16,y1+51+i*30,x1+154,y1+79+i*30, 20 );
391  else if ( i == sel2 ) rectangle (x1 + 16,y1+51+i*30,x1+154,y1+79+i*30, 28 );
392  else rectangle (x1 + 16,y1+51+i*30,x1+154,y1+79+i*30, bkgcolor );
393  e = actmap->player[i].vehicleList.size();
394  b = actmap->player[i].buildingList.size();
396  showtext2(strrr(e),x1+200,y1+56+i*30);
397  showtext2(strrr(b),x1+255,y1+56+i*30);
398  showtext2(strrr(m[i]),x1+310,y1+56+i*30);
399  } /* endfor */
400  mousevisible(true);
401 }
402 
403 
405 {
406 
407  do {
408  tdialogbox::run();
409  if (taste == ct_f1) help ( 1050 );
410  } while (!((taste == ct_esc) || ((action == 1) || (action ==2))));
411 // ???? if ((action == 2) || (taste == ct_esc)) ;
412 }
413 
414 
416 {
418  switch (id) {
419 
420  case 1:
421  case 2:
422  action = id;
423  break;
424  /* case 3: {
425  int sel = colorselect();
426  if ( ( sel != 255) && ( sel != sel1 ) && ( sel1 != 255 ) &&
427  ( actmap->player[sel].firstvehicle == NULL ) && ( actmap->player[sel].firstbuilding == NULL ) ) {
428 
429  }
430  }
431  break; */
432  case 4: {
433  if ( ( sel1 != 255) && ( sel2 != sel1 ) && ( sel2 != 255 ) && ( sel1 != 8) && ( sel2 != 8 ) ) {
435  anzeige();
436  }
437  }
438  break;
439  case 5: {
440  if ( ( sel1 != 255) && ( sel2 != sel1 ) && ( sel2 != 255 ) ) {
441 
442  // adding everything from player sel2 to sel1
443 
444  if ( sel1 != 8 )
445  for ( Player::VehicleList::iterator i = actmap->player[sel2].vehicleList.begin(); i != actmap->player[sel2].vehicleList.end(); ) {
446  (*i)->color = sel1*8;
447  actmap->player[sel1].vehicleList.push_back ( *i );
448  i = actmap->player[sel2].vehicleList.erase( i );
449  }
450 
452  for ( Player::BuildingList::iterator i = bl.begin(); i != bl.end(); ++i)
453  (*i)->convert( sel1 );
454 
455  for (int i =0; i < actmap->xsize * actmap->ysize ; i++ ) {
456  MapField* fld = &actmap->field[i];
457  for ( MapField::MineContainer::iterator i = fld->mines.begin(); i != fld->mines.end(); i++ )
458  if ( i->player == sel2 && sel1 != 8)
459  i->player = sel1;
460 
461  } /* endfor */
462  anzeige();
463  }
464  }
465  break;
466  case 6:
467  case 7:
468  case 8:
469  case 9:
470  case 10:
471  case 11:
472  case 12:
473  case 13:
474  case 14:
475  if ( id-6 != sel1 ) {
476  sel2 = sel1;
477  sel1 = id-6;
478  anzeige();
479  }
480  break;
481  }
482 }
483 
484 
485 void playerchange(void)
486 {
487  tplayerchange sc;
488 
489  sc.init();
490  sc.run();
491  sc.done();
493 }
494 
495 
496 
497 
498 void exchg(int * a1,
499  int * a2)
500 {
501  int ex;
502 
503  ex = *a1;
504  *a1 = *a2;
505  *a2 = ex;
506 }
507 
508 
509 
510 
511 // � TCDPlayer
512 
513 /*
514 
515 class tcdplayer : public tstringselect {
516  public :
517  virtual void setup(void);
518  virtual void buttonpressed(int id);
519  virtual void run(void);
520  virtual void get_text(int nr);
521  };
522 
523 void tcdplayer ::setup(void)
524 {
525 
526  action = 0;
527  xsize = 400;
528  ysize = 400;
529  x1 = 100;
530  title = "CD- Player";
531  numberoflines = cdrom.cdinfo.lasttrack;
532  ey = ysize - 60;
533  ex = xsize - 120;
534  addbutton("~R~CD",320,50,390,70,0,1,11,true);
535  addbutton("~P~lay",320,90,390,110,0,1,12,true);
536  addbutton("~S~top",320,130,390,150,0,1,13,true);
537  addbutton("E~x~it",10,ysize - 40,290,ysize - 20,0,1,10,true);
538 }
539 
540 
541 void tcdplayer ::buttonpressed(int id)
542 {
543  tstringselect::buttonpressed(id);
544  switch (id) {
545 
546  case 10: action = 3;
547  break;
548  case 11: {
549  cdrom.readcdinfo();
550  redline = 0;
551  firstvisibleline = 0;
552  numberoflines = cdrom.cdinfo.lasttrack;
553  viewtext();
554  }
555  break;
556  case 12: {
557  cdrom.playtrack(redline);
558  }
559  break;
560  case 13: cdrom.stopaudio ();
561  break;
562  }
563 }
564 
565 
566 void tcdplayer ::get_text(int nr)
567 {
568  if (cdrom.cdinfo.track[nr]->type > 3) {
569  strcpy(txt,"Data Track ");
570  strcat(txt,strrr(nr+1));
571  } else {
572  strcpy(txt,"");
573  strcat(txt,strrr(cdrom.cdinfo.track[nr]->min));
574  strcat(txt," : ");
575  strcat(txt,strrr(cdrom.cdinfo.track[nr]->sec));
576  strcat(txt," : ");
577  strcat(txt,strrr(cdrom.cdinfo.track[nr]->frame));
578  strcat(txt," Track ");
579  strcat(txt,strrr(nr+1));
580  }
581 }
582 
583 
584 void tcdplayer ::run(void)
585 {
586  do {
587  tstringselect::run();
588  if ( (msel == 1) || ( taste == ct_enter ) ) cdrom.playtrack(redline);
589  } while ( ! ( (taste == ct_esc) || (action == 3) ) );
590 }
591 
592 
593 void cdplayer( void )
594 {
595  tcdplayer cd;
596 
597  cd.init();
598  cd.run();
599  cd.done();
600 }
601 
602 */
603 
604 
605 #ifndef pbpeditor
606 
607 void k_savemap(bool saveas)
608 {
609  ASCString filename;
610 
611  int nameavail = 0;
612  if ( !actmap->preferredFileNames.mapname[0].empty() ) {
613  nameavail = 1;
614  filename = actmap->preferredFileNames.mapname[0];;
615  }
616 
617  if ( saveas || !nameavail ) {
618  filename = selectFile(mapextension, false);
619  }
620  if ( !filename.empty() ) {
621  mapsaved = true;
622  actmap->preferredFileNames.mapname[0] = filename;
623  savemap( filename, actmap );
624  displaymap();
625  }
626 }
627 
628 
629 void k_loadmap(void)
630 {
631  ASCString s1 = selectFile( mapextension, true );
632  if ( !s1.empty() ) {
633  StatusMessageWindowHolder smw = MessagingHub::Instance().infoMessageWindow( "loading map " + s1 );
635  if ( !mp )
636  return;
637 
638  /*
639  if ( mp->campaign.avail && !mp->campaign.directaccess && !mp->codeWord.empty() ) {
640  tlockdispspfld ldsf;
641  removemessage();
642  Password pwd;
643  pwd.setUnencoded ( mp->codeWord );
644  if ( enterpassword ( pwd ) == ;
645  } else
646  removemessage();
647 */
648 
649  delete actmap;
650  actmap = mp;
651 
652  displaymap();
653  mapsaved = true;
654  }
655 }
656 
657 #else
658 
659 #include "pbpeditor.cpp"
660 
661 #endif
662 
663 
664 void selectUnitFromMap ( GameMap* gamemap, MapCoordinate& pos )
665 {
667  list.push_back( pos );
668 
669  SelectFromMap sfm( list, gamemap );
670  sfm.Show();
671  sfm.RunModal();
672 
673  if ( list.empty() )
674  pos = MapCoordinate( -1, -1 );
675  else
676  pos = *list.begin();
677 }
678 
679 
680 
682 {
685  activefontsettings. background = 0;
686 
687  mapsaved = true;
688 
689 }
690 
691 //* � FillPolygonevent
692 
693 
694 
695 //* � FillPolygonbdt
696 /*
697 void tfillpolygonbodentyp::setpointabs ( int x, int y )
698 {
699  tfield* ffield = getfield ( x , y );
700  if (ffield) {
701  ffield->a.temp = tempvalue;
702  if ( auswahl->weather[auswahlw] )
703  ffield->typ = auswahl->weather[auswahlw];
704  else
705  ffield->typ = auswahl->weather[0];
706  ffield->direction = auswahld;
707  ffield->setparams();
708  if (ffield->vehicle != NULL)
709  if ( terrainaccessible(ffield,ffield->vehicle) == false ) {
710  delete ffield->vehicle;
711  ffield->vehicle = NULL;
712  }
713  }
714 }
715 
716 void tfillpolygonbodentyp::initevent ( void )
717 {
718 }
719 
720 // � FillPolygonunit
721 
722 void tfillpolygonunit::setpointabs ( int x, int y )
723 {
724  tfield* ffield = getfield ( x , y );
725  if (ffield) {
726  if ( terrainaccessible(ffield,ffield->vehicle) )
727  {
728  if (ffield->vehicle != NULL) {
729  delete ffield->vehicle;
730  ffield->vehicle = NULL;
731  }
732  if (auswahlf != NULL) {
733  ffield->vehicle = new Vehicle ( auswahlf,actmap, farbwahl );
734  ffield->vehicle->fillMagically();
735  ffield->vehicle->height=1;
736  while ( ! ( ( ( ( ffield->vehicle->height & ffield->vehicle->typ->height ) > 0) && (terrainaccessible(ffield,ffield->vehicle) == 2) ) ) && (ffield->vehicle->height != 0) )
737  ffield->vehicle->height = ffield->vehicle->height * 2;
738  for (i = 0; i <= 31; i++) ffield->vehicle->loading[i] = NULL;
739  if (ffield->vehicle->height == 0 ) {
740  delete ffield->vehicle;
741  ffield->vehicle = NULL;
742  }
743  else ffield->vehicle->setMovement ( ffield->vehicle->typ->movement[getFirstBit(ffield->vehicle->height)] );
744  ffield->vehicle->direction = auswahld;
745  }
746  }
747  else
748  if (auswahlf == NULL)
749  if (ffield->vehicle != NULL) {
750  delete ffield->vehicle;
751  ffield->vehicle=NULL;
752  }
753  ffield->a.temp = tempvalue;
754  }
755 }
756 
757 void tfillpolygonunit::initevent ( void )
758 {
759 }
760 
761 
762 // � ChangePoly
763 */
764 
765 
767 protected:
768  virtual void setpointabs ( int x, int y ) {
769  MapField* ffield = getfield ( x , y );
770  if (ffield)
771  ffield->setaTemp2(1);
772  };
773 public:
774  bool paintPolygon ( const Poly_gon& poly ) {
776  for ( int i = 0; i < poly.vertex.size(); ++i ) {
777  MapField* ffield = actmap->getField ( poly.vertex[i] );
778  if (ffield)
779  ffield->setaTemp(1);
780  }
781  return res;
782  };
783 };
784 
785 
786 class PolygonEditor : public SelectFromMap {
787 protected:
789  {
790  Poly_gon poly;
791  for ( CoordinateList::const_iterator i = coordinateList.begin(); i != coordinateList.end(); ++i )
792  poly.vertex.push_back( MapCoordinate(*i) );
793 
795  if ( !sput.paintPolygon ( poly ) )
796  displaymessage("Invalid Polygon !",1 );
797 
798  repaintMap();
799  }
800 
801 public:
802  PolygonEditor( CoordinateList& list, GameMap* map ) : SelectFromMap( list, map ) {};
803 };
804 
805 
806 
808 {
809  savemap ( "_backup_polygoneditor.map", actmap );
810 
812 
813  for ( Poly_gon::VertexIterator i = poly.vertex.begin(); i != poly.vertex.end(); ++i )
814  list.push_back( *i );
815 
816  PolygonEditor cp ( list, actmap );
817  cp.Show();
818  cp.RunModal();
819 
820  poly.vertex.clear();
821  for ( PolygonEditor::CoordinateList::iterator i = list.begin(); i != list.end(); ++i )
822  poly.vertex.push_back( *i );
823 }
824 
825 
826 
827 void newmap(void)
828 {
829  GameMap* map = createNewMap();
830  if ( map ) {
831  delete actmap;
832  actmap = map;
833  // displaymap();
834  mapChanged( actmap );
835  // tspfldloaders::mapLoaded( actmap );
836  }
837 }
838 
839 
840 //* � MapVals
841 
842 
843 
844 class BuildingValues : public tdialogbox {
845  int action;
846  Building& gbde;
847  int rs,mrs;
848  Resources plus,mplus, biplus,storage;
849  int col;
850  int damage;
851  Uint8 tvisible;
852  char name[260];
853  int ammo[waffenanzahl];
854  virtual void buttonpressed(int id);
855  int lockmaxproduction;
856  TemporaryContainerStorage buildingBackup; // if the editing is cancelled
857 
858 public :
859  BuildingValues ( Building& building ) : gbde ( building ), buildingBackup ( &building ) {};
860  void init(void);
861  virtual void run(void);
862 };
863 
864 
866 {
867  Uint8 b;
868 
869  for ( int i = 0; i< waffenanzahl; i++ )
870  ammo[i] = gbde.ammo[i];
871 
872  lockmaxproduction = 1;
873 
875  action = 0;
876  title = "Building Values";
877  x1 = 0;
878  xsize = 640;
879  y1 = 10;
880  ysize = 480;
881  // int w = (xsize - 60) / 2;
882  action = 0;
883 
885 
886  storage = gbde.actstorage;
887  plus = gbde.plus;
888  mplus = gbde.maxplus;
889  rs = gbde.researchpoints;
890  mrs = gbde.maxresearchpoints;
891  tvisible = gbde.visible;
892  biplus = gbde.bi_resourceplus;
893  col = gbde.color / 8;
894  damage = gbde.damage;
895 
896  strcpy( name, gbde.name.c_str() );
897 
898  addbutton("~N~ame",15,50,215,70,1,1,10,true);
899  addeingabe(10,&name[0],0,25);
900 
901  addbutton("~E~nergy-Storage",15,90,215,110,2,1,1,true);
902  addeingabe(1,&storage.energy,0,gbde.getStorageCapacity().resource(0));
903 
904  addbutton("~M~aterial-Storage",15,130,215,150,2,1,2,true);
905  addeingabe(2,&storage.material,0,gbde.getStorageCapacity().resource(1));
906 
907  addbutton("~F~uel-Storage",15,170,215,190,2,1,3,true);
908  addeingabe(3,&storage.fuel,0,gbde.getStorageCapacity().resource(2));
909 
915  b = true;
916  else
917  b = false;
918 
919  addbutton("Energy-Max-Plus",230,50,430,70,2,1,13,b);
920  addeingabe(13,&mplus.energy,0,gbde.typ->maxplus.energy);
921 
925  b = true;
926  else
927  b = false;
928 
929 
930  addbutton("Energ~y~-Plus",230,90,430,110,2,1,4,b);
931  addeingabe(4,&plus.energy,0,mplus.energy);
932 
935  b = true;
936  else
937  b = false;
938 
939  addbutton("Material-Max-Plus",230,130,430,150,2,1,14,b);
940  addeingabe(14,&mplus.material,0,gbde.typ->maxplus.material);
941 
942  addbutton("M~a~terial-Plus",230,170,430,190,2,1,5,b);
943  addeingabe(5,&plus.material,0,mplus.material);
944 
947  b = true;
948  else
949  b = false;
950 
951  addbutton("Fuel-Max-Plus",230,210,430,230,2,1,15,b);
952  addeingabe(15,&mplus.fuel,0,gbde.typ->maxplus.fuel);
953 
954  addbutton("F~u~el-Plus",230,250,430,270,2,1,6,b);
955  addeingabe(6,&plus.fuel, 0, mplus.fuel);
956 
957  if ( gbde.typ->hasFunction( ContainerBaseType::Research) || ( gbde.typ->maxresearchpoints > 0))
958  b = true;
959  else
960  b = false;
961 
962  addbutton("~R~esearch-Points",15,210,215,230,2,1,9,b);
964  addeingabe(9,&rs,0,gbde.typ->maxresearchpoints);
965  else
967 
968  addbutton("Ma~x~research-Points",15,250,215,270,2,1,11,b);
970  addeingabe(11,&mrs,0,gbde.typ->maxresearchpoints);
971  else
973 
974 
975  addbutton("~V~isible",15,290,215,300,3,1,12,true);
976  addeingabe(12,&tvisible,0,lightgray);
977 
978  addbutton("~L~ock MaxPlus ratio",230,290,430,300,3,1,120,true);
979  addeingabe(120,&lockmaxproduction,0,lightgray);
980 
981 
982  addbutton("~C~olor",230,370,430,390,2,1,104,true);
983  addeingabe(104,&col,0,8);
984 
985  addbutton("~D~amage",230,410,430,430,2,1,105,true);
986  addeingabe(105,&damage,0,99);
987 
988 
989  addbutton("BI energy plus",15,330,215,350,2,1,101,1);
990  addeingabe(101,&biplus.energy,0,maxint);
991 
992  addbutton("BI material plus",230,330,430,350,2,1,102,1);
993  addeingabe(102,&biplus.material,0,maxint);
994 
995  addbutton("BI fuel plus",15,370,215,390,2,1,103,1);
996  addeingabe(103,&biplus.fuel,0,maxint);
997 
998 
999  addbutton("~S~et Values",10,ysize - 40, xsize/3-5,ysize - 10,0,1,7,true);
1000  addkey(7,ct_enter);
1001 
1002  /*
1003 
1004 
1005 
1006  addbutton("Help (~F1~)", xsize/3+5, ysize - 40, xsize/3*2-5, ysize-10, 0, 1, 110, true );
1007  addkey(110, ct_f1 );
1008  */
1009 
1010  addbutton("~C~ancel",xsize/3*2+5,ysize - 40,xsize-10,ysize - 10,0,1,8,true);
1011  addkey(8, ct_esc );
1012 
1013 
1014  for ( int i = 0; i < waffenanzahl; i++ ) {
1015  addbutton ( cwaffentypen[i], 460, 90+i*40, 620, 110+i*40, 2, 1, 200+i, 1 );
1016  addeingabe(200+i, &ammo[i], 0, maxint );
1017  }
1018 
1019  buildgraphics();
1020  line(x1+450, y1+45, x1+450, y1+55+9*40, darkgray );
1023  showtext2("ammunition:", x1 + 460, y1 + 50 );
1024 
1025  mousevisible(true);
1026 }
1027 
1028 
1030 {
1031  do {
1032  tdialogbox::run();
1033  } while (!((taste == ct_esc) || (action == 1)));
1034 }
1035 
1036 
1037 void BuildingValues::buttonpressed(int id)
1038 {
1039  switch (id) {
1040  case 4: // energy, material & fuel plus
1041  case 5:
1042  case 6: {
1043  int changed_resource = id - 4;
1044  for ( int r = 0; r < 3; r++ )
1045  if ( r != changed_resource )
1046  if ( mplus.resource(changed_resource) ) {
1047  int a = mplus.resource(r) * plus.resource(changed_resource) / mplus.resource(changed_resource);
1048  if ( a != plus.resource(r) ) {
1049  plus.resource(r) = a;
1050  showbutton ( 4 + r );
1051  }
1052  }
1053  }
1054  break;
1055  case 13: // energy, material and fuel maxplus
1056  case 14:
1057  case 15: {
1058  int changed_resource = id - 13;
1059  if ( lockmaxproduction )
1060  for ( int r = 0; r < 3; r++ )
1061  if ( r != changed_resource )
1062  if ( gbde.typ->maxplus.resource(changed_resource) ) {
1063  int a = gbde.typ->maxplus.resource(r) * mplus.resource(changed_resource) / gbde.typ->maxplus.resource(changed_resource);
1064  if ( a != mplus.resource(r) ) {
1065  mplus.resource(r) = a;
1066  showbutton ( 13 + r );
1067  }
1068  }
1069 
1070  for ( int r = 0; r < 3; r++ ) {
1071  if ( (mplus.resource(r) >= 0 && plus.resource(r) > mplus.resource(r) ) ||
1072  (mplus.resource(r) < 0 && plus.resource(r) < mplus.resource(r) )) {
1073  plus.resource(r) = mplus.resource(r);
1074  showbutton ( 4 + r );
1075  }
1076  addeingabe(4+r, &plus.resource(r), 0, mplus.resource(r) );
1077  }
1078  }
1079  break;
1080  case 7: {
1081  mapsaved = false;
1082  action = 1;
1083  gbde.actstorage = storage;
1084 
1085  gbde.plus = plus;
1086  gbde.maxplus = mplus;
1087  if ( col != gbde.color/8 )
1088  gbde.convert ( col );
1089 
1090  gbde.researchpoints = rs;
1091  gbde.maxresearchpoints = mrs;
1092  gbde.visible = tvisible;
1093  gbde.bi_resourceplus = biplus;
1094  gbde.name = name;
1095  gbde.damage = damage;
1096  for ( int i = 0; i< waffenanzahl; i++ )
1097  gbde.ammo[i] = ammo[i];
1098 
1099  }
1100  break;
1101  case 8:
1102  action = 1;
1103  break;
1104 
1105  /*
1106 
1107  case 13: {
1108  addeingabe(4,&plus.energy,0,mplus.energy);
1109  if (mplus.energy < plus.energy ) {
1110  plus.energy = mplus.energy;
1111  enablebutton(4);
1112  }
1113  }
1114  break;
1115  case 14: {
1116  addeingabe(5,&plus.material,0,mplus.material);
1117  if (mplus.material < plus.material) {
1118  plus.material =mplus.material;
1119  enablebutton(5);
1120  }
1121  }
1122 
1123  break;
1124  case 15: {
1125  addeingabe(6,&plus.fuel,0,mplus.fuel);
1126  if (plus.fuel > mplus.fuel) {
1127  plus.fuel = mplus.fuel;
1128  enablebutton(6);
1129  }
1130  }
1131  break;
1132  */
1133  case 110:
1134  help ( 41 );
1135  break;
1136 
1137  }
1138 }
1139 
1140 
1142 {
1143  BuildingValues bval ( b );
1144  bval.init();
1145  bval.run();
1146  bval.done();
1147 
1148  displaymap();
1149 }
1150 
1151 // � Class-Change
1152 
1153 
1154 // � Polygon-Management
1155 /*
1156 class tpolygon_managementbox: public tstringselect {
1157  public:
1158  ppolygon poly;
1159  virtual void setup(void);
1160  virtual void buttonpressed(int id);
1161  virtual void run(void);
1162  virtual void get_text(int nr);
1163  };
1164 
1165 
1166 tpolygon_management::tpolygon_management(void)
1167 {
1168  polygonanz = 0;
1169  lastpolygon = firstpolygon;
1170 }
1171 
1172 void tpolygon_managementbox::setup(void)
1173 {
1174  action = 0;
1175  title = "Choose Polygon";
1176 
1177  x1 = 70;
1178  y1 = 40;
1179  xsize = 500;
1180  ysize = 400;
1181  lnshown = 10;
1182  numberoflines = polymanage.polygonanz;
1183  activefontsettings.length = xsize - 30;
1184  addbutton("~D~one",20,ysize - 40,170,ysize - 20,0,1,1,true);
1185  addkey(1,ct_enter);
1186  addbutton("~C~ancel",190,ysize - 40,340,ysize - 20,0,1,2,true);
1187 }
1188 
1189 
1190 void tpolygon_managementbox::buttonpressed(int id)
1191 {
1192  tstringselect::buttonpressed(id);
1193  switch (id) {
1194  case 1:
1195  case 2: action = id;
1196  break;
1197  }
1198 }
1199 
1200 
1201 void tpolygon_managementbox::get_text(int nr)
1202 {
1203  char s[200];
1204  ppolystructure pps;
1205  int i,vn;
1206 
1207  const int showmaxvertex = 5;
1208 
1209  pps = polymanage.firstpolygon;
1210  for (i=0 ;i<nr; i++ )
1211  pps =pps->next;
1212  strcpy(s,"");
1213  if ( pps->poly->vertexnum> showmaxvertex ) vn=5;
1214  else vn = pps->poly->vertexnum;
1215  switch (pps->place) {
1216  case 0: {
1217  strcat(s,"Events: ");
1218  strcat(s,ceventactions[pps->id]);
1219  }
1220  break;
1221  }
1222  for (i=0;i <= vn-1;i++ ) {
1223  strcat(s,"(");
1224  strcat(s,strrr(pps->poly->vertex[i].x));
1225  strcat(s,"/");
1226  strcat(s,strrr(pps->poly->vertex[i].y));
1227  strcat(s,") ");
1228  }
1229  if (vn < pps->poly->vertexnum ) strcat(s,"...");
1230  strcpy(txt,s);
1231 }
1232 
1233 
1234 void tpolygon_managementbox::run(void)
1235 {
1236  do {
1237  tstringselect::run();
1238  if (taste ==ct_f1) help (1030);
1239  } while ( ! ( (taste == ct_enter ) || (taste == ct_esc) || ( (action == 1) || (action == 2) ) ) );
1240  if ( ( ( taste == ct_enter ) || (action == 1 ) ) && (redline != 255 ) ) {
1241  ppolystructure pps;
1242 
1243  pps = polymanage.firstpolygon;
1244  for (i=0 ;i<redline; i++ ) pps =pps->next;
1245  poly = pps->poly;
1246  }
1247 }
1248 
1249 void tpolygon_management::addpolygon(ppolygon *poly, int place, int id)
1250 {
1251  (*poly) = new(tpolygon);
1252 
1253  (*poly)->vertexnum = 0;
1254  (*poly)->vertex = (tpunkt*) malloc ( 1 * sizeof ( (*poly)->vertex[0] ) );
1255  if (polygonanz == 0 ) {
1256  lastpolygon = new ( tpolystructure );
1257  firstpolygon = lastpolygon;
1258  }
1259  else {
1260  lastpolygon->next = new ( tpolystructure );
1261  lastpolygon = lastpolygon->next;
1262  }
1263  lastpolygon->poly = (*poly);
1264  lastpolygon->id = id;
1265  lastpolygon->place = place;
1266  polygonanz++;
1267 }
1268 
1269 void tpolygon_management::deletepolygon(ppolygon *poly)
1270 {
1271  asc_free( (*poly)->vertex );
1272  asc_free(*poly);
1273 }
1274 
1275 
1276 int getpolygon(ppolygon *poly) //return Fehlerstatus
1277 {
1278  tpolygon_managementbox polymanagebox;
1279 
1280  polymanagebox.poly = (*poly);
1281  polymanagebox.init();
1282  polymanagebox.run();
1283  polymanagebox.done();
1284  (*poly) = polymanagebox.poly;
1285  if ( (polymanagebox.action == 2) || (polymanagebox.taste == ct_esc ) ) return 1;
1286  else return 0;
1287 }
1288 */
1289 // � Unit-Values
1290 
1291 
1293  const char** text;
1294 public :
1296  StringSelector ( const char* title_, const char** text_, int itemNum_ ) : text ( text_ ) {
1297  lastchoice = 0;
1298  numberoflines = itemNum_;
1299  title = title_;
1300  };
1301  virtual void setup(void);
1302  virtual void buttonpressed(int id);
1303  virtual void run(void);
1304  virtual void get_text(int nr);
1305 };
1306 
1308 {
1309  action = 0;
1310  ey = ysize - 90;
1311  startpos = lastchoice;
1312  addbutton("~O~k",20,ysize - 50,xsize-20,ysize - 20,0,1,13,true);
1313  addkey ( 13, ct_enter );
1314 }
1315 
1316 
1318 {
1320  switch (id) {
1321 
1322  case 12:
1323  if ( redline >= 0 )
1324  action = id-10;
1325  break;
1326 
1327  case 13:
1328  action = id-10;
1329  break;
1330  }
1331 }
1332 
1333 
1335 {
1336  strcpy(txt, text[nr] );
1337 }
1338 
1339 
1341 {
1342  do {
1344  if ( taste == ct_enter ) {
1345  if ( redline >= 0 )
1346  action = 2;
1347  else
1348  action = 3;
1349  }
1350  } while ( action == 0 );
1351 }
1352 
1353 
1354 int selectString( int lc, const char* title, const char** text, int itemNum )
1355 {
1356  StringSelector ss ( title, text, itemNum );
1357  ss.lastchoice = lc;
1358  ss.init();
1359  ss.run();
1360  ss.done();
1361  return ss.redline;
1362 }
1363 
1364 
1365 class EditAiParam : public tdialogbox {
1366  Vehicle* unit;
1368  int action;
1369  AiParameter& aiv;
1370  int z;
1371 public:
1372  EditAiParam ( Vehicle* veh, int player ) : unit ( veh ), tus ( veh ), aiv ( *veh->aiparam[player] ) {};
1373  void init ( );
1374  void run ( );
1375  void buttonpressed ( int id );
1376  int getcapabilities ( void ) {
1377  return 1;
1378  };
1379 };
1380 
1381 
1383 {
1384  tdialogbox::init();
1385  action = 0;
1386  title = "Unit AI Values";
1387 
1389 
1390  x1 = 20;
1391  xsize = 600;
1392  y1 = 40;
1393  ysize = 400;
1394  int w = (xsize - 60) / 2;
1395  action = 0;
1396 
1397  addbutton("dest ~X~",50,80,250,100,2,1,1,true);
1398  addeingabe(1, &aiv.dest.x, minint, maxint);
1399 
1400  addbutton("dest ~Y~",50,120,250,140,2,1,2,true);
1401  addeingabe(2, &aiv.dest.y, minint, maxint);
1402 
1403  z = aiv.dest.getNumericalHeight();
1404  addbutton("dest ~Z~",50,160,250,180,2,1,3,true);
1405  addeingabe(3, &z, minint, maxint);
1406 
1407  addbutton("dest ~N~WID",50,200,250,220,2,1,4,true);
1408  addeingabe(4, &aiv.dest_nwid, minint, maxint);
1409 
1410  addbutton("~V~alue",410,80,570,100,2,1,10,true);
1411  addeingabe( 10, &aiv.value, minint, maxint );
1412 
1413  addbutton("~A~dded value",410,120,570,140,2,1,11,true);
1414  addeingabe( 11, &aiv.addedValue, minint, maxint );
1415 
1416  addbutton("~R~eset task after completion",410,160,570,180,3,1,12,true);
1418 
1419 
1420  addbutton("~S~elect Dest",50,240,250,260,0,1,22,true);
1421 
1422  addbutton("~T~ask",20,ysize - 70,20 + w,ysize - 50,0,1,20,true);
1423  addbutton("~J~ob",40 + w,ysize - 70,40 + 2 * w,ysize - 50,0,1,21,true);
1424 
1425  addbutton("~S~et Values",20,ysize - 40,20 + w,ysize - 10,0,1,30,true);
1426  addkey(30,ct_enter );
1427  addbutton("~C~ancel",40 + w,ysize - 40,40 + 2 * w,ysize - 10,0,1,31,true);
1428  addkey(31,ct_esc );
1429 
1430  buildgraphics();
1431  mousevisible(true);
1432 }
1433 
1434 
1436 {
1437  do {
1438  tdialogbox::run();
1439  } while ( !action );
1440 }
1441 
1442 
1444 {
1445  switch (id) {
1446  case 20 :
1447  aiv.setTask( AiParameter::Task( selectString ( aiv.getTask(), "Select Task", AItasks , AiParameter::taskNum) ));
1448  break;
1449  case 21 : {
1451  j.push_back ( AiParameter::Job( selectString ( aiv.getJob(), "Select Job", AIjobs , AiParameter::jobNum) ) );
1452  aiv.setJob ( j );
1453  }
1454  break;
1455  /*
1456  case 22 : getxy ( &aiv.dest.x, &aiv.dest.y );
1457  aiv.dest.setnum ( aiv.dest.x, aiv.dest.y, -2 );
1458  z = -2;
1459  redraw();
1460  break;
1461  */
1462  case 30 :
1463  action = 1;
1464  aiv.dest.setnum ( aiv.dest.x, aiv.dest.y, z );
1465  break;
1466  case 31 :
1467  action = 1;
1468  tus.restore();
1469  break;
1470  } /* endswitch */
1471 }
1472 
1473 
1475 {
1476  if ( !veh )
1477  return;
1478 
1479  static int player = 0;
1480  player = getid("player",player,0,7);
1481  if ( !veh->aiparam[player] )
1482  veh->aiparam[player] = new AiParameter ( veh );
1483 
1484  EditAiParam eap ( veh, player );
1485  eap.init();
1486  eap.run();
1487 }
1488 
1489 
1490 
1491 //* � Resource
1492 
1493 class tres: public tdialogbox {
1494  MapField* pf2;
1495 public :
1496  int action;
1498  void init(void);
1499  virtual void run(void);
1500  virtual void buttonpressed(int id);
1501 };
1502 
1503 
1504 
1505 void tres::init(void)
1506 {
1507  int w;
1508 
1509  tdialogbox::init();
1510  action = 0;
1511  title = "Resources";
1512  x1 = 170;
1513  xsize = 200;
1514  y1 = 70;
1515  ysize = 200;
1516  w = (xsize - 60) / 2;
1517  action = 0;
1518  pf2 = getactfield();
1519  fuel = pf2->fuel;
1520  material = pf2->material;
1521 
1523 
1524  activefontsettings.length = 200;
1525 
1526  addbutton("~F~uel (0-255)",50,70,150,90,2,1,1,true);
1527  addeingabe(1,&fuel,0,255);
1528  addbutton("~M~aterial (0-255)",50,110,150,130,2,1,2,true);
1529  addeingabe(2,&material,0,255);
1530 
1531  addbutton("~S~et Vals",20,ysize - 40,20 + w,ysize - 10,0,1,7,true);
1532  addkey(7,ct_enter);
1533  addbutton("~C~ancel",40 + w,ysize - 40,40 + 2 * w,ysize - 10,0,1,8,true);
1534 
1535  buildgraphics();
1536 
1537  mousevisible(true);
1538 }
1539 
1540 
1541 void tres::run(void)
1542 {
1543  do {
1544  tdialogbox::run();
1545  } while (!((taste == ct_esc) || (action == 1)));
1546 }
1547 
1548 
1550 {
1551  if (id == 7) {
1552  mapsaved = false;
1553  action = 1;
1554  pf2->fuel = fuel;
1555  pf2->material = material;
1556  }
1557  if (id == 8) action = 1;
1558 }
1559 
1560 
1561 void changeresource(void)
1562 {
1563  tres resource;
1564 
1565  resource.init();
1566  resource.run();
1567  resource.done();
1568 }
1569 
1570 //* � MineStrength
1571 
1572 class tminestrength: public tdialogbox {
1573  MapField* pf2;
1574 public :
1575  int action;
1577  void init(void);
1578  virtual void run(void);
1579  virtual void buttonpressed(int id);
1580 };
1581 
1582 
1583 
1585 {
1586  int w;
1587 
1588  tdialogbox::init();
1589  action = 0;
1590  title = "Minestrength";
1591  x1 = 170;
1592  xsize = 200;
1593  y1 = 70;
1594  ysize = 160;
1595  w = (xsize - 60) / 2;
1596  action = 0;
1597  pf2 = getactfield();
1598  strength = pf2->mines.begin()->strength;
1599 
1601 
1602  activefontsettings.length = 200;
1603 
1604  addbutton("~S~trength (0-255)",30,70,170,90,2,1,1,true);
1605  addeingabe(1,&strength,0,255);
1606 
1607  addbutton("~S~et Vals",20,ysize - 40,20 + w,ysize - 10,0,1,7,true);
1608  addkey(7,ct_enter);
1609  addbutton("~C~ancel",40 + w,ysize - 40,40 + 2 * w,ysize - 10,0,1,8,true);
1610 
1611  buildgraphics();
1612 
1613  mousevisible(true);
1614 }
1615 
1616 
1618 {
1619  do {
1620  tdialogbox::run();
1621  } while (!((taste == ct_esc) || (action == 1)));
1622 }
1623 
1624 
1626 {
1627  if (id == 7) {
1628  mapsaved = false;
1629  action = 1;
1630  pf2->mines.begin()->strength = strength;
1631  }
1632  if (id == 8) action = 1;
1633 }
1634 
1635 
1637 {
1638  if ( getactfield()->mines.empty() )
1639  return;
1640 
1641  tminestrength ms;
1642  ms.init();
1643  ms.run();
1644  ms.done();
1645 }
1646 
1647 
1648 
1649 void movebuilding ( void )
1650 {
1651  warningMessage("sorry, not implemented yet in ASC2!");
1652 #if 0
1653  mapsaved = false;
1654  MapField* fld = getactfield();
1655  if ( fld->vehicle ) {
1656  Vehicle* v = fld->vehicle;
1657  fld->vehicle = NULL;
1658 
1659  int x = v->xpos;
1660  int y = v->ypos;
1661  int res2 = -1;
1662  do {
1663  res2 = selectfield ( &x, &y );
1664  if ( res2 > 0 ) {
1665  if ( getfield(x,y)->vehicle || getfield(x,y)->vehicle || !terrainaccessible(getfield(x,y),v)) {
1666  displaymessage ( "you cannot place the vehicle here", 1 );
1667  res2 = -1;
1668  } else {
1669  getfield(x,y)->vehicle = v;
1670  v->setnewposition( x, y );
1671  }
1672  }
1673  } while ( res2 < 0 );
1674  displaymap();
1675 
1676  }
1677  if ( fld->building ) {
1678  Building* bld = fld->building;
1679 
1680  bld->unchainbuildingfromfield ();
1681 
1682  MapCoordinate mc = bld->getEntry();
1683  MapCoordinate oldPosition = mc;
1684  int res2 = -1;
1685  do {
1686  res2 = selectfield ( &mc.x, &mc.y );
1687  if ( res2 > 0 ) {
1688  int res = bld->chainbuildingtofield ( mc );
1689  if ( res ) {
1690  displaymessage ( "you cannot place the building here", 1 );
1691  res2 = -1;
1692  }
1693  }
1694  } while ( res2 < 0 );
1695  if ( res2 == 0 ) { // operation canceled
1696  if ( bld->chainbuildingtofield ( oldPosition ))
1697  displaymessage ( "severe inconsistency in movebuilding !", 1 );
1698  }
1699  displaymap();
1700  }
1701 #endif
1702 }
1703 
1704 
1706 
1707  PG_ListBox* listbox;
1708 
1709  PG_Button* okButton;
1710  vector<PG_ListBoxItem*> items;
1711 
1712 public:
1713  SelectUnitSetFilter() : ASC_PG_Dialog( NULL, PG_Rect( -1, -1, 300, 500 ), "Visible UnitSet Filter" ) {
1714 
1715  listbox = (new MultiListBox( this, PG_Rect( 10, 30, Width()-20, Height()-80)))->getListBox();
1716 
1717 
1718  for ( int i = 0; i < ItemFiltrationSystem::itemFilters.size(); i++ ) {
1719  PG_ListBoxItem* item = new PG_ListBoxItem( listbox, 20, ItemFiltrationSystem::itemFilters[i]->name );
1720  items.push_back( item );
1721  item->Select( !ItemFiltrationSystem::itemFilters[i]->isActive() );
1722  }
1723 
1724  okButton = AddStandardButton( "OK" );
1725  okButton->sigClick.connect( sigc::hide( sigc::mem_fun( *this, &SelectUnitSetFilter::ok )));
1726  };
1727 
1728  bool ok() {
1729  for ( int i = 0; i < items.size(); ++i )
1730  ItemFiltrationSystem::itemFilters[i]->setActive( !items[i]->IsSelected() );
1731 
1732  QuitModal();
1733  return true;
1734  }
1735 
1736  bool eventKeyDown(const SDL_KeyboardEvent* key) {
1737 
1738  if ( key->keysym.sym == SDLK_RETURN )
1739  return ok();
1740 
1741  if ( key->keysym.sym == SDLK_ESCAPE ) {
1742  QuitModal();
1743  return true;
1744  }
1745 
1746  if ( key->keysym.sym == 'a' ) {
1747  for ( vector<PG_ListBoxItem*>::const_iterator i = items.begin(); i != items.end(); ++i )
1748  (*i)->Select( true );
1749  listbox->Update();
1750  return true;
1751  }
1752 
1753  if ( key->keysym.sym == 'n' ) {
1754  for ( vector<PG_ListBoxItem*>::const_iterator i = items.begin(); i != items.end(); ++i )
1755  (*i)->Select( false );
1756 
1757  listbox->Update();
1758  return true;
1759  }
1760 
1761  return false;
1762  }
1763 };
1764 
1765 
1766 void selectunitsetfilter ( void )
1767 {
1768  if ( ItemFiltrationSystem::itemFilters.size() > 0 ) {
1769  SelectUnitSetFilter susf;
1770  susf.Show();
1771  susf.RunModal();
1772 
1774  } else
1775  displaymessage ( " no Filters defined !", 1 );
1776 }
1777 
1778 
1779 
1781 
1782  class UnitSetSelection : public tstringselect {
1783  public :
1784  virtual void setup(void);
1785  virtual void buttonpressed(int id);
1786  virtual void run(void);
1787  virtual void get_text(int nr);
1788  };
1789  class TranslationTableSelection : public tstringselect {
1790  int unitsetnum;
1791  public :
1792  virtual void setup( void );
1793  void setup2 ( int _unitset ) {
1794  unitsetnum = _unitset;
1795  };
1796  virtual void buttonpressed(int id);
1797  virtual void run(void);
1798  virtual void get_text(int nr);
1799  };
1800 
1801  int unitstransformed;
1802  int unitsnottransformed;
1803 
1804  VehicleType* transformvehicletype ( const VehicleType* type, int unitsetnum, int translationnum );
1805  void transformvehicle ( Vehicle* veh, int unitsetnum, int translationnum );
1806  set<int> vehicleTypesNotTransformed;
1807 public:
1808  void run ( void );
1809 } ;
1810 
1811 
1812 void UnitTypeTransformation :: UnitSetSelection::setup(void)
1813 {
1814  action = 0;
1815  title = "Select UnitSet";
1816  numberoflines = unitSets.size();
1817  ey = ysize - 60;
1818  addbutton("~D~one",20,ysize - 40,170,ysize - 20,0,1,202,true);
1819  addkey(202,ct_enter);
1820  addbutton("~C~ancel",190,ysize - 40,340,ysize - 20,0,1,203,true);
1821  addkey(203,ct_esc);
1822 }
1823 
1824 void UnitTypeTransformation :: UnitSetSelection::buttonpressed(int id)
1825 {
1827  switch (id) {
1828  case 202:
1829  case 203:
1830  action = id - 200;
1831  break;
1832  }
1833 }
1834 
1835 void UnitTypeTransformation :: UnitSetSelection::get_text(int nr)
1836 {
1837  strcpy(txt,unitSets[nr]->name.c_str() );
1838 }
1839 
1840 void UnitTypeTransformation :: UnitSetSelection::run(void)
1841 {
1842  do {
1844  } while ( ! ( action > 0 || (msel == 1)) );
1845 
1846  if ( action == 3)
1847  redline = -1;
1848 }
1849 
1850 
1851 
1852 void UnitTypeTransformation :: TranslationTableSelection::setup( void )
1853 {
1854  action = 0;
1855  title = "Select Transformation Table";
1856  numberoflines = unitSets[unitsetnum]->transtab.size();
1857  ey = ysize - 60;
1858  addbutton("~D~one",20,ysize - 40,170,ysize - 20,0,1,202,true);
1859  addkey(202,ct_enter);
1860  addbutton("~C~ancel",190,ysize - 40,340,ysize - 20,0,1,203,true);
1861  addkey(203,ct_esc);
1862 }
1863 
1864 void UnitTypeTransformation :: TranslationTableSelection::buttonpressed(int id)
1865 {
1867  switch (id) {
1868  case 202:
1869  case 203:
1870  action = id-200;
1871  break;
1872  }
1873 }
1874 
1875 void UnitTypeTransformation :: TranslationTableSelection::get_text(int nr)
1876 {
1877  strcpy(txt, unitSets[unitsetnum]->transtab[nr]->name.c_str() );
1878 }
1879 
1880 void UnitTypeTransformation :: TranslationTableSelection::run(void)
1881 {
1882  do {
1884  } while ( ! ( action > 0 || (msel == 1)) );
1885 
1886  if ( action == 3)
1887  redline = -1;
1888 }
1889 
1890 VehicleType* UnitTypeTransformation :: transformvehicletype ( const VehicleType* type, int unitsetnum, int translationnum )
1891 {
1892  for ( int i = 0; i < unitSets[unitsetnum]->transtab[translationnum]->translation.size(); i++ )
1893  if ( unitSets[unitsetnum]->transtab[translationnum]->translation[i].from == type->id ) {
1894  VehicleType* tp = vehicleTypeRepository.getObject_byID ( unitSets[unitsetnum]->transtab[translationnum]->translation[i].to );
1895  if ( tp )
1896  return tp;
1897  }
1898 
1899  vehicleTypesNotTransformed.insert( type->id );
1900 
1901  return NULL;
1902 }
1903 
1904 void UnitTypeTransformation ::transformvehicle ( Vehicle* veh, int unitsetnum, int translationnum )
1905 {
1906  for ( ContainerBase::Cargo::const_iterator i = veh->getCargo().begin(); i != veh->getCargo().end(); ++i )
1907  if ( *i )
1908  transformvehicle ( *i, unitsetnum, translationnum );
1909 
1910  VehicleType* nvt = transformvehicletype ( veh->typ, unitsetnum, translationnum );
1911  if ( !nvt ) {
1912  unitsnottransformed++;
1913  return;
1914  }
1915  veh->transform ( nvt );
1916 
1917  unitstransformed++;
1918 }
1919 
1920 
1922 {
1923  UnitSetSelection uss;
1924  uss.init();
1925  uss.run();
1926  uss.done();
1927 
1928  int unitsetnum = uss.redline;
1929  if ( unitsetnum == -1 )
1930  return;
1931 
1932  TranslationTableSelection tss;
1933  tss.setup2( unitsetnum );
1934  tss.init();
1935  tss.run();
1936  tss.done();
1937 
1938  int translationsetnum = tss.redline;
1939  if ( translationsetnum == -1 || translationsetnum == 255 )
1940  return;
1941 
1942  unitstransformed = 0;
1943  unitsnottransformed = 0;
1944 
1945 
1946  for ( int y = 0; y < actmap->ysize; y++ )
1947  for ( int x = 0; x < actmap->xsize; x++ ) {
1948  MapField* fld = getfield ( x, y );
1949  if ( fld->vehicle )
1950  transformvehicle ( fld->vehicle, unitsetnum, translationsetnum );
1951  if ( fld->building && (fld->bdt & getTerrainBitType(cbbuildingentry) ).any() ) {
1952  for ( ContainerBase::Cargo::const_iterator i = fld->building->getCargo().begin(); i != fld->building->getCargo().end(); ++i )
1953  if ( *i )
1954  transformvehicle ( *i, unitsetnum, translationsetnum );
1955 
1957  for ( ContainerBase::Production::iterator j = prod.begin(); j != prod.end(); ++j )
1958  if ( *j && transformvehicletype ( *j, unitsetnum, translationsetnum ) ) {
1959  *j = transformvehicletype ( *j, unitsetnum, translationsetnum );
1960  ++unitstransformed;
1961  }
1962 
1963  fld->building->setProductionLines( prod );
1964  }
1965  }
1966 
1967  if ( vehicleTypesNotTransformed.size() ) {
1968  ASCString s = "The following vehicles could not be transformed: ";
1969  for ( set<int>::const_iterator i = vehicleTypesNotTransformed.begin(); i != vehicleTypesNotTransformed.end(); ++i ) {
1970  s += "\n ID ";
1971  s += ASCString::toString( *i );
1972  s += " : ";
1973  VehicleType* vt = vehicleTypeRepository.getObject_byID ( *i );
1974  if ( !vt-> name.empty() )
1975  s += vt->name;
1976  else
1977  s += vt->description;
1978  }
1979 
1980  s += "\n";
1981  s += strrr ( unitstransformed );
1982  s += " units were transformed\n";
1983  s += strrr ( unitsnottransformed );
1984  s += " units were NOT transformed\n (production included)";
1985 
1986  tviewanytext vat;
1987  vat.init ( "warningMessage", s.c_str() );
1988  vat.run();
1989  vat.done();
1990  } else
1991  displaymessage ( "All units were transformed !\ntotal number: %d", 3, unitstransformed );
1992 
1993 
1994 }
1995 
1997 {
1999  utt.run();
2000 }
2001 
2002 
2004 {
2005  delete actmap;
2006  actmap = NULL;
2007  toggle();
2008  delete actmap;
2009  actmap = NULL;
2010 }
2011 
2013 {
2014  maps[active].map = actmap;
2015  maps[active].changed = !mapsaved;
2016 
2017  if ( getMainScreenWidget() ) {
2019  if ( md )
2020  maps[active].windowpos = md->upperLeftCorner();
2021  }
2022 
2023  active = !active;
2024 
2025 
2026 
2027  actmap = maps[active].map;
2028  mapsaved = !maps[active].changed;
2029 
2030 
2031  if ( getMainScreenWidget() ) {
2033  if ( md )
2034  md->cursor.goTo( actmap->getCursor(), maps[active].windowpos );
2035  }
2036 
2037  displaymap();
2038  viewChanged();
2039 
2040  int x,y;
2041  SDL_Event ev;
2042  while ( PG_Application::GetEventSupplier()->GetMouseState(x,y))
2043  PG_Application::GetEventSupplier()->WaitEvent (&ev);
2044 }
2045 
2047 {
2048  const char* name[2] = { "primary", "secondary" };
2049  string s;
2050  s = name[active];
2051 
2052  if ( actmap )
2053  if ( !actmap->preferredFileNames.mapname[0].empty() ) {
2054  s += " ( ";
2056  s += " ) ";
2057  }
2058 
2059  return s;
2060 }
2061 
2063 {
2064  if ( active )
2065  return select;
2066  else
2067  return set;
2068 }
2069 
2070 
2072 
2073 
2074 VehicleType* transform( int id, const vector<int>& translation )
2075 {
2076  for ( int i = 0; i < translation.size()/2; i++ )
2077  if ( id == translation[i*2] )
2078  return vehicleTypeRepository.getObject_byID ( translation[i*2+1] );
2079  return NULL;
2080 }
2081 
2083 {
2084 
2085  ASCString filename = selectFile( "*.ascmapxlat", true );
2086 
2087  if ( filename.empty() )
2088  return;
2089 
2090 
2091  vector<int> terraintranslation;
2092  vector<int> objecttranslation;
2093  vector<int> terrainobjtranslation;
2094  vector<int> buildingtranslation;
2095  vector<int> vehicletranslation;
2096  vector<int> o2ot_translation;
2097  vector<ASCString> techAdapterTranslation;
2098 
2099  try {
2100  tnfilestream s ( filename, tnstream::reading );
2101 
2102  TextFormatParser tfp ( &s );
2103  TextPropertyGroup* tpg = tfp.run();
2104 
2105  PropertyReadingContainer pc ( "maptranslation", tpg );
2106 
2107  pc.addIntegerArray ( "TerrainTranslation", terraintranslation );
2108  pc.addIntegerArray ( "TerrainObjTranslation", terrainobjtranslation );
2109  pc.addIntegerArray ( "ObjectTranslation", objecttranslation );
2110  pc.addIntegerArray ( "BuildingTranslation", buildingtranslation );
2111  if ( pc.find( "VehicleTranslation" ))
2112  pc.addIntegerArray ( "VehicleTranslation", vehicletranslation );
2113 
2114  if ( pc.find( "Object2ObjTerrainTranslation" ))
2115  pc.addIntegerArray( "Object2ObjTerrainTranslation", o2ot_translation );
2116 
2117  if ( pc.find( "TechAdapterTranslation" ))
2118  pc.addStringArray( "TechAdapterTranslation", techAdapterTranslation );
2119 
2120  delete tpg;
2121  }
2122  catch ( ParsingError err ) {
2123  displaymessage ( "Error parsing file : " + err.getMessage() , 1 );
2124  return;
2125  }
2126  catch ( ASCexception ) {
2127  displaymessage ( "Error reading file " + filename , 1 );
2128  return;
2129  }
2130 
2131  if ( terraintranslation.size() % 2 ) {
2132  displaymessage ( "Map Translation : terraintranslation - Invalid number of entries ", 1);
2133  return;
2134  }
2135 
2136  if ( terrainobjtranslation.size() % 3 ) {
2137  displaymessage ( "Map Translation : terrainobjtranslation - Invalid number of entries ", 1);
2138  return;
2139  }
2140 
2141  if ( objecttranslation.size() % 2 ) {
2142  displaymessage ( "Map Translation : objecttranslation - Invalid number of entries ", 1);
2143  return;
2144  }
2145 
2146  if ( buildingtranslation.size() % 2 ) {
2147  displaymessage ( "Map Translation : buildingtranslation - Invalid number of entries ", 1);
2148  return;
2149  }
2150 
2151  if ( vehicletranslation.size() % 2 ) {
2152  displaymessage ( "Map Translation : VehicleTranslation - Invalid number of entries ", 1);
2153  return;
2154  }
2155 
2156  if ( o2ot_translation.size() % 3 ) {
2157  displaymessage ( "Map Translation : Object2ObjTerrainTranslation - Invalid number of entries ", 1);
2158  return;
2159  }
2160 
2161  if ( techAdapterTranslation.size() % 2 ) {
2162  displaymessage ( "Map Translation : TechAdapterTranslation - Invalid number of entries ", 1);
2163  return;
2164  }
2165 
2166 
2167  for ( int y = 0; y < actmap->ysize; y++ )
2168  for ( int x = 0; x < actmap->xsize; x++ ) {
2169  MapField* fld = actmap->getField ( x, y );
2170  for ( int i = 0; i < terraintranslation.size()/2; i++ )
2171  if ( fld->typ->terraintype->id == terraintranslation[i*2] ) {
2172  TerrainType* tt = terrainTypeRepository.getObject_byID ( terraintranslation[i*2+1] );
2173  if ( tt ) {
2174  TerrainType::Weather* tw = tt->weather[fld->getWeather()];
2175  if ( !tw )
2176  tw = tt->weather[0];
2177  fld->typ = tw;
2178  fld->setparams();
2179  }
2180  }
2181 
2182  for ( int i = 0; i < terrainobjtranslation.size()/3; i++ )
2183  if ( fld->typ->terraintype->id == terrainobjtranslation[i*3] ) {
2184  TerrainType* tt = terrainTypeRepository.getObject_byID ( terrainobjtranslation[i*3+1] );
2185  if ( tt ) {
2186  TerrainType::Weather* tw = tt->weather[fld->getWeather()];
2187  if ( !tw )
2188  tw = tt->weather[0];
2189  fld->typ = tw;
2190  fld->addobject ( objectTypeRepository.getObject_byID ( terrainobjtranslation[i*3+2] ), -1, true );
2191  fld->setparams();
2192  }
2193  }
2194 
2195 
2196  for ( int j = 0; j < fld->objects.size(); ++j )
2197  for ( int i = 0; i < objecttranslation.size() / 2; i++ )
2198  if ( fld->objects[j].typ->id == objecttranslation[i*2] ) {
2199  ObjectType* ot = objectTypeRepository.getObject_byID ( objecttranslation[i*2+1] );
2200  if ( ot ) {
2201  fld->objects[j].typ = ot;
2202  fld->sortobjects();
2203  fld->setparams();
2204  j = -1; // restarting the outer loop
2205  break;
2206  } else {
2207  fld->removeObject( fld->objects[j].typ, true );
2208  j = -1;
2209  break;
2210  }
2211  }
2212  for ( int b = 0; b < buildingtranslation.size()/2; ++b )
2213  if ( (fld->bdt & getTerrainBitType(cbbuildingentry)).any() && fld->building && fld->building->typ->id == buildingtranslation[b*2] ) {
2214  BuildingType* newtype = buildingTypeRepository.getObject_byID ( buildingtranslation[b*2+1] );
2215  if ( newtype ) {
2216  Building* bld = fld->building;
2217  const BuildingType* orgtype = fld->building->typ;
2218  MapCoordinate orgpos = bld->getEntry();
2219  MapCoordinate pos = orgpos;
2220  bld->unchainbuildingfromfield();
2221  bld->typ = newtype;
2222  int iteration = 0;
2223  enum { trying, success, failed } state = trying;
2224  do {
2225  if ( bld->chainbuildingtofield( pos )) {
2226  pos = getNeighbouringFieldCoordinate( orgpos, iteration );
2227  } else
2228  state = success;
2229 
2230  ++iteration;
2231 
2232  if ( iteration > 6 && state != success ) {
2233  state = failed;
2234  bld->typ = orgtype;
2235  bld->chainbuildingtofield( orgpos );
2236  }
2237  } while ( state == trying );
2238 
2239  } else {
2240  delete fld->building;
2241  }
2242  }
2243 
2244  for ( int j = 0; j < fld->objects.size(); ++j )
2245  for ( int i = 0; i < o2ot_translation.size() / 3; i++ )
2246  if ( fld->objects[j].typ->id == o2ot_translation[i*3] ) {
2247  fld->removeObject( fld->objects[j].typ, true );
2248  TerrainType* tt = terrainTypeRepository.getObject_byID ( o2ot_translation[i*3+2] );
2249  if ( tt ) {
2250  TerrainType::Weather* tw = tt->weather[fld->getWeather()];
2251  if ( !tw )
2252  tw = tt->weather[0];
2253  fld->typ = tw;
2254  }
2255  ObjectType* ot = objectTypeRepository.getObject_byID ( o2ot_translation[i*3+1] );
2256  if ( ot )
2257  fld->addobject ( ot, -1, true );
2258 
2259 
2260  fld->setparams();
2261 
2262  j = -1; // restarting the outer loop
2263  break;
2264  }
2265  }
2266 
2267 
2268 
2269  for ( int p = 0; p < actmap->getPlayerCount(); ++p ) {
2270  Player::VehicleList::iterator di = actmap->getPlayer(p).vehicleList.begin();
2271  while ( di != actmap->getPlayer(p).vehicleList.end() ) {
2272  bool found = false;
2273  for ( int i = 0; i < vehicletranslation.size()/2; ++i )
2274  if ( (*di)->typ->id == vehicletranslation[i*2] && vehicletranslation[i*2+1] <= 0 ) {
2275  delete *di;
2276  found = true;
2277  break;
2278  }
2279  if ( found )
2280  di = actmap->getPlayer(p).vehicleList.begin();
2281  else
2282  ++di;
2283  }
2284 
2285 
2286 
2287  for ( Player::VehicleList::iterator i = actmap->getPlayer(p).vehicleList.begin(); i != actmap->getPlayer(p).vehicleList.end(); ++i) {
2288  (*i)->transform( transform( (*i)->typ->id, vehicletranslation));
2289 
2290  ContainerBase::Production prod = (*i)->getProduction();
2291  for ( ContainerBase::Production::iterator j = prod.begin(); j != prod.end(); ++j )
2292  if ( *j && transform((*j)->id, vehicletranslation) )
2293  *j = transform((*j)->id, vehicletranslation);
2294 
2295  (*i)->setProductionLines( prod );
2296  }
2297  for ( Player::BuildingList::iterator i = actmap->getPlayer(p).buildingList.begin(); i != actmap->getPlayer(p).buildingList.end(); ++i) {
2298  ContainerBase::Production prod = (*i)->getProduction();
2299  for ( ContainerBase::Production::iterator j = prod.begin(); j != prod.end(); ++j )
2300  if ( *j && transform((*j)->id, vehicletranslation) )
2301  *j = transform((*j)->id, vehicletranslation);
2302 
2303  (*i)->setProductionLines( prod );
2304  }
2305 
2306  Research& r = actmap->getPlayer(p).research;
2307  for ( vector<ASCString>::iterator tat = techAdapterTranslation.begin(); tat != techAdapterTranslation.end(); ) {
2308  ASCString from = *(tat++);
2309  ASCString to = *(tat++);
2310 
2311  vector<ASCString> triggeredAdapters( r.triggeredTechAdapter.begin(), r.triggeredTechAdapter.end() );
2312  replace( triggeredAdapters.begin(), triggeredAdapters.end(), from, to );
2313  r.triggeredTechAdapter.clear();
2314  r.triggeredTechAdapter.insert( triggeredAdapters.begin(), triggeredAdapters.end() );
2315 
2316  replace( r.predefinedTechAdapter.begin(), r.predefinedTechAdapter.end(), from, to );
2317  }
2318 
2319  }
2320 
2321 // for ( int i = 0; i < vehicleTypeRepository.getNum(); ++i )
2322 
2323  /*
2324  tn_file_buf_stream s ( "out.txt", tnstream::writing );
2325  for ( int j = 0; j < vehicletranslation.size()/2; j++ ) {
2326  Vehicletype* vt1 = vehicleTypeRepository.getObject_byID ( vehicletranslation[j*2] );
2327  Vehicletype* vt2 = vehicleTypeRepository.getObject_byID ( vehicletranslation[j*2+1] );
2328  ASCString st = ASCString::toString( vehicletranslation[j*2] ) + " " +
2329  ASCString::toString( vehicletranslation[j*2+1] );
2330 
2331 
2332  if ( vt1 ) {
2333  st += " ; " + vt1->name;
2334  if ( vt2 )
2335  st += " -> " + vt2->name;
2336  }
2337 
2338  s.writeString( st + "\n" );
2339  }
2340  */
2341 
2343  displaymap();
2344 }
2345 
2346 
2348  GameMap* gamemap;
2349  char maptitle[10000];
2350  char author[10000];
2351  ASCString description;
2352  char tags[10000];
2353  char requirements[10000];
2354  int action;
2355 public:
2357  void init();
2358  void run();
2359  void buttonpressed ( int id );
2360 };
2361 
2362 
2364 {
2365  strcpy ( maptitle, map->maptitle.c_str() );
2366  strcpy ( author, map->archivalInformation.author.c_str() );
2367  description = map->archivalInformation.description;
2368  strcpy ( tags, map->archivalInformation.tags.c_str() );
2369  strcpy ( requirements, map->archivalInformation.requirements.c_str() );
2370 }
2371 
2373 {
2374  tdialogbox::init();
2375  title = "Edit Archival Information";
2376  xsize = 600;
2377  ysize = 410;
2378  action = 0;
2379 
2380 
2381  addbutton("~T~itle",20,70,xsize - 20,90,1,1,10,true);
2382  addeingabe(10,maptitle,0,10000);
2383 
2384  addbutton("~A~uthor",20,120,xsize - 20,140,1,1,11,true);
2385  addeingabe(11,author,0,10000);
2386 
2387  addbutton("Ta~g~s",20,170,xsize - 20,190,1,1,12,true);
2388  addeingabe(12,tags,0,10000);
2389 
2390  addbutton("~R~equirements ( see http://asc-hq.sf.net/req.php for possible values)",20,220,xsize - 20,240,1,1,13,true);
2391  addeingabe(13,requirements,0,10000);
2392 
2393 
2394  addbutton("Edit ~D~escription",20,ysize - 70,170,ysize - 50,0,1,14,true);
2395 
2396  addbutton("~O~k",20,ysize - 40,xsize/2-10,ysize - 20,0,1,1,true);
2397  addkey(1,ct_enter);
2398  addbutton("~C~ancel",xsize/2+10,ysize - 40,xsize-20,ysize - 20,0,1,2,true);
2399  addkey(2,ct_esc);
2400 
2401  buildgraphics();
2402 }
2403 
2405 {
2406  switch ( id ) {
2407  case 14: {
2408  MultilineEdit mle ( description, "Map Description" );
2409  mle.init();
2410  mle.run();
2411  mle.done();
2412  break;
2413  }
2414  case 1:
2415  gamemap->archivalInformation.author = author;
2416  gamemap->archivalInformation.tags = tags;
2417  gamemap->archivalInformation.requirements = requirements;
2418  gamemap->archivalInformation.description = description;
2419  gamemap->maptitle = maptitle;
2420  mapsaved = false;
2421  case 2:
2422  action = id;
2423  }
2424 }
2425 
2427 {
2428  do {
2429  tdialogbox::run();
2430  } while ( action == 0);
2431 }
2432 
2433 
2435 {
2437  eai.init();
2438  eai.run();
2439  eai.done();
2440 }
2441 
2443 {
2444  ASCString s;
2445  for ( int i = 0; i < 9; i++ ) {
2446  s += ASCString("player ") + strrr ( i ) + " : ";
2447  Resources plus;
2448  Resources have;
2449  for ( Player::BuildingList::iterator b = actmap->player[i].buildingList.begin(); b != actmap->player[i].buildingList.end(); ++b ) {
2450  if ( actmap->_resourcemode == 0 )
2451  plus += (*b)->plus;
2452  else
2453  plus += (*b)->bi_resourceplus;
2454 
2455  have += (*b)->actstorage;
2456  }
2457  for ( int r = 0; r < resourceTypeNum; r++ ) {
2458  s += ASCString(resourceNames[r]) + " " + strrr ( have.resource(r)) + " +";
2459  s += strrr(plus.resource(r));
2460  s += "; ";
2461  }
2462 
2463  s += "\n\n";
2464  }
2465 
2466  Resources res;
2467  for ( int x = 0; x < actmap->xsize; x++)
2468  for ( int y = 0; y < actmap->ysize; y++ ) {
2469  res.material += actmap->getField(x,y)->material;
2470  res.fuel += actmap->getField(x,y)->fuel;
2471  }
2472 
2473  s += "Mineral Resources: ";
2474  s += strrr(res.material );
2475  s += " Material, ";
2476  s += strrr(res.material );
2477  s += " Fuel";
2478 
2479  displaymessage ( s, 3 );
2480 }
2481 
2482 
2483 
2484 
2486 {
2488  if ( !filename.empty() ) {
2489  try {
2490  if ( patimat( oldClipboardFileExtension, filename )) {
2491  tnfilestream stream ( filename, tnstream::reading );
2492  ClipBoard::Instance().read( stream );
2493  } else {
2494  tnfilestream stream ( filename, tnstream::reading );
2495  TextFormatParser parser(&stream);
2496  PropertyReadingContainer pc ( "ClipboardInfo", parser.run() );
2497  ClipBoard::Instance().readProperties( pc );
2498  }
2499  } catch ( ASCmsgException me ) {
2500  errorMessage( "Error reading clipboard file:\n" + me.getMessage());
2501  } catch ( ... ) {
2502  errorMessage( "Error reading clipboard file" );
2503  }
2504 
2505  }
2506 }
2507 
2509 {
2510  ASCString filename = selectFile( clipboardFileExtension, false);
2511  if ( !filename.empty() ) {
2512  tn_file_buf_stream txtstream ( filename, tnstream::writing );
2513  PropertyWritingContainer pc ( "ClipboardInfo", txtstream );
2514  ClipBoard::Instance().writeProperties( pc );
2515  }
2516 }
2517 
2518 void setweatherall ( int weather )
2519 {
2520  for (int y=0; y < actmap->ysize; y++)
2521  for (int x=0; x < actmap->xsize; x++)
2522  actmap->getField(x,y)->setWeather( weather );
2523 }
2524 
2525 
2527 {
2528  ASCString s;
2529  s.format ( "%7d ", id );
2530  const Technology* t = technologyRepository.getObject_byID ( id );
2531  if ( t )
2532  s += t->name;
2533 
2534  return s;
2535 }
2536 
2538 {
2539  vector<ASCString> buttons;
2540  buttons.push_back ( "~A~dd" );
2541  buttons.push_back ( "~R~emove" );
2542  buttons.push_back ( "~C~lose" );
2543 
2544  vector<ASCString> buttons2;
2545  buttons2.push_back ( "~A~dd" );
2546  buttons2.push_back ( "~C~ancel" );
2547 
2548  vector<ASCString> buttonsP;
2549  buttonsP.push_back ( "~E~dit" );
2550  buttonsP.push_back ( "~C~lose" );
2551 
2552  pair<int,int> playerRes;
2553  do {
2554  vector<ASCString> player;
2555  for ( int i = 0; i < 8; ++i )
2556  player.push_back ( ASCString ( strrr(i)) + " " + actmap->player[i].getName());
2557 
2558  playerRes = chooseString ( "Choose Player", player, buttonsP );
2559  if ( playerRes.first == 0 && playerRes.second >= 0 ) {
2560  int player = playerRes.second;
2561 
2562  pair<int,int> res;
2563  do {
2564  vector<int>& devTech = actmap->player[player].research.developedTechnologies;
2565  vector<ASCString> techs;
2566  map<ASCString,int> techIds;
2567  for ( int i = 0; i < devTech.size(); ++i ) {
2568  int id = devTech[i];
2569  ASCString s = printTech(id );
2570  techs.push_back ( s );
2571  techIds[s] = id;
2572  }
2573  sort (techs.begin(), techs.end() );
2574  res = chooseString ( "Available Technologies", techs, buttons );
2575  if ( res.first == 0 ) {
2576  vector<ASCString> techs;
2577  vector<int> techIds;
2578  for ( int i = 0; i < technologyRepository.getNum(); ++i ) {
2579  const Technology* t = technologyRepository.getObject_byPos(i);
2580  if ( find ( devTech.begin(), devTech.end(), t->id ) == devTech.end() )
2582  techs.push_back ( printTech ( t->id ));
2583  techIds.push_back ( t->id );
2584  }
2585  }
2586 
2587  if ( techIds.empty() ) {
2588  infoMessage("No technologies found. Please review Item Filters");
2589  } else {
2590  // sort (techs.begin(), techs.end() );
2591  pair<int,int> r = chooseString ( "Unresearched Technologies", techs, buttons2 );
2592  if ( r.first == 0 && r.second >= 0 ) {
2593  devTech.push_back ( techIds[r.second] );
2594  }
2595  }
2596  } else if ( res.first == 1 && res.second >= 0 ) {
2597  vector<int>::iterator p = find ( devTech.begin(), devTech.end(), techIds[techs[res.second]]);
2598  devTech.erase ( p );
2599  }
2600  } while ( res.first != 2 );
2601  }
2602  } while ( playerRes.first != 1 );
2603 }
2604 
2606 {
2607  vector<ASCString> buttonsP;
2608  buttonsP.push_back ( "~E~dit" );
2609  buttonsP.push_back ( "~C~lose" );
2610 
2611  pair<int,int> playerRes;
2612  do {
2613  vector<ASCString> player;
2614  for ( int i = 0; i < 8; ++i ) {
2615  ASCString s = strrr(i);
2616  player.push_back ( s + " " + actmap->player[i].getName() + " (" + strrr(actmap->player[i].research.progress) + " Points)" );
2617  }
2618 
2619  playerRes = chooseString ( "Choose Player", player, buttonsP );
2620  if ( playerRes.first == 0 && playerRes.second >= 0 )
2621  actmap->player[playerRes.second].research.progress = editInt ( "Points", actmap->player[playerRes.second].research.progress );
2622 
2623  } while ( playerRes.first != 1 );
2624 }
2625 
2626 
2628 {
2629  ASCString filename = selectFile("*.dot", false);
2630  if ( !filename.empty() ) {
2631 
2632  map<ASCString,int> temptechs;
2633  for ( int i = 0; i < technologyRepository.getNum(); ++i ) {
2634  const Technology* t = technologyRepository.getObject_byPos(i);
2636  temptechs[t->name] = t->id;
2637  }
2638  }
2639 
2640  vector<ASCString> techs;
2641  vector<int> techIds;
2642  for ( map<ASCString,int>::iterator i = temptechs.begin(); i != temptechs.end(); ++i ) {
2643  techs.push_back ( printTech ( i->second ));
2644  techIds.push_back ( i->second );
2645  }
2646 
2647 
2648 
2649  /*
2650  for ( int i = 1; i < techIds.size(); )
2651  if ( technologyRepository.getObject_byID( techIds[i-1] )->name > technologyRepository.getObject_byID( techIds[i] )->name ) {
2652  int a = techIds[i];
2653  int b = techIds[i-1];
2654  techs[i] = printTech ( b );
2655  techs[i-1] = printTech ( a );
2656  techIds[i] = b;
2657  techIds[i-1] = a;
2658  if ( i > 1 )
2659  --i;
2660  } else
2661  ++i;
2662  */
2663 
2664 
2665  vector<ASCString> buttons2;
2666  buttons2.push_back ( "~O~k" );
2667  buttons2.push_back ( "~C~ancel" );
2668 
2669  bool leavesUp = choice_dlg ( "tree direction", "leaves up", "root up" ) == 1;
2670 
2671  if ( leavesUp ) {
2672 
2673  pair<int,int> r = chooseString ( "Choose Base Technology", techs, buttons2 );
2674  if ( r.first == 0 ) {
2675 
2676 
2677  bool reduce = choice_dlg ( "generate sparce tree ?", "~y~es", "~n~o" ) == 1;
2678 
2679  tn_file_buf_stream f ( filename, tnstream::writing );
2680 
2681  f.writeString ( "digraph \"ASC Technology Tree\" { \nnode [color=gray]\n", false );
2682 
2683  for ( int i = 0; i < technologyRepository.getNum(); ++i ) {
2684  const Technology* t = technologyRepository.getObject_byPos(i);
2686  vector<int> stack;
2687  if ( t->techDependency.findInheritanceLevel( techIds[r.second], stack, techs[r.second] ) > 0 )
2688  t->techDependency.writeTreeOutput( t->name, f, reduce );
2689  }
2690 
2691  }
2692 
2693  ASCString stn2 = technologyRepository.getObject_byID(techIds[r.second])->name;
2694  while ( stn2.find ( "\"" ) != ASCString::npos )
2695  stn2.erase ( stn2.find ( "\"" ),1 );
2696 
2697  f.writeString ( "\"" + stn2 + "\" [shape=doublecircle] \n", false );
2698  f.writeString ( "}\n", false );
2699  }
2700  } else {
2701  pair<int,int> r = chooseString ( "Choose Tip Technology", techs, buttons2 );
2702  if ( r.first == 0 ) {
2703 
2704  tn_file_buf_stream f ( filename, tnstream::writing );
2705 
2706  f.writeString ( "digraph \"ASC Technology Tree\" { \nnode [color=gray]\n", false );
2707 
2708  const Technology* t = technologyRepository.getObject_byID(techIds[r.second]);
2709  vector<int> history;
2710  vector<pair<int,int> > blockedPrintList;
2711  if ( t )
2712  t->techDependency.writeInvertTreeOutput( t->name, f, history, blockedPrintList );
2713 
2714  ASCString stn2 = technologyRepository.getObject_byID(techIds[r.second])->name;
2715  while ( stn2.find ( "\"" ) != ASCString::npos )
2716  stn2.erase ( stn2.find ( "\"" ),1 );
2717 
2718  f.writeString ( "\"" + stn2 + "\" [shape=doublecircle] \n", false );
2719  f.writeString ( "}\n", false );
2720  }
2721  }
2722 
2723  }
2724 }
2725 
2726 
2727 
2729 {
2730  vector<ASCString> buttons;
2731  buttons.push_back ( "~A~dd" );
2732  buttons.push_back ( "~R~emove" );
2733  buttons.push_back ( "~C~lose" );
2734 
2735  vector<ASCString> buttons2;
2736  buttons2.push_back ( "~A~dd" );
2737  buttons2.push_back ( "~C~ancel" );
2738 
2739  vector<ASCString> buttonsP;
2740  buttonsP.push_back ( "~E~dit" );
2741  buttonsP.push_back ( "~C~lose" );
2742 
2743  pair<int,int> playerRes;
2744  do {
2745  vector<ASCString> player;
2746  for ( int i = 0; i < 8; ++i )
2747  player.push_back ( ASCString ( strrr(i)) + " " + actmap->player[i].getName());
2748 
2749  playerRes = chooseString ( "Choose Player", player, buttonsP );
2750  if ( playerRes.first == 0 && playerRes.second >= 0) {
2751  int player = playerRes.second;
2752  editTechAdapter(actmap->player[player] );
2753  }
2754  } while ( playerRes.first != 1 );
2755 }
2756 
2757 
2758 
2760 {
2761  return actmap->getField( actmap->getCursor() );;
2762 }
2763 
2764 
2765 class ItemLocator : public ASC_PG_Dialog {
2766 
2767  PG_LineEdit* idField;
2768  DropDownSelector* typeSelector;
2769 
2770 
2771  bool findUnit( ContainerBase* c, int id )
2772  {
2773  if ( !c )
2774  return false;
2775 
2776  for ( ContainerBase::Cargo::const_iterator i = c->getCargo().begin(); i != c->getCargo().end(); ++i ) {
2777  if ( (*i) ) {
2778  if ( (*i)->typ->id == id )
2779  return true;
2780  if ( findUnit( *i, id ))
2781  return true;
2782  }
2783  }
2784  return false;
2785  }
2786 
2787  bool ok()
2788  {
2789  int id = atoi ( idField->GetText().c_str() );
2790  if ( id != 0 ) {
2791  for ( int y = 0; y < actmap->ysize; ++y )
2792  for ( int x = 0; x < actmap->xsize; ++x ) {
2793  MapField* fld = actmap->getField(x,y);
2794  if ( fld ) {
2795  bool found = false;
2796  switch ( typeSelector->GetSelectedItemIndex () ) {
2797  case 0:
2798  if ( fld->typ->terraintype->id == id )
2799  found = true;
2800  break;
2801  case 1:
2802  if ( fld->vehicle && fld->vehicle->typ->id == id )
2803  found = true;
2804  if ( findUnit( fld->vehicle, id ))
2805  found = true;
2806  break;
2807  case 2:
2808  if ( fld->building && fld->building->typ->id == id )
2809  found = true;
2810  if ( findUnit( fld->building, id ))
2811  found = true;
2812  break;
2813  case 3:
2814  if ( fld->checkForObject( objectTypeRepository.getObject_byID( id )) )
2815  found = true;
2816  break;
2817  }
2818 
2819 
2820  if ( found ) {
2822  QuitModal();
2823  return true;
2824  }
2825  }
2826  }
2827 
2828  }
2829  return false;
2830  }
2831 
2832  bool cancel()
2833  {
2834  QuitModal();
2835  return true;
2836  }
2837 
2838 public:
2839  ItemLocator() : ASC_PG_Dialog(NULL, PG_Rect(-1,-1,400,200 ), "Item Locator")
2840  {
2841  AddStandardButton("OK")->sigClick.connect( sigc::hide( sigc::mem_fun(*this, &ItemLocator::ok )));
2842  AddStandardButton("cancel")->sigClick.connect( sigc::hide( sigc::mem_fun(*this, &ItemLocator::cancel )));
2843 
2844  typeSelector = new DropDownSelector(this, PG_Rect(20, 60, 150, 25 ));
2845  typeSelector->AddItem("Terrain");
2846  typeSelector->AddItem("Vehicle");
2847  typeSelector->AddItem("Building");
2848  typeSelector->AddItem("Object");
2849 
2850  new PG_Label ( this, PG_Rect(20, 100, 50, 25), "ID: " );
2851  idField = new PG_LineEdit( this, PG_Rect( 70, 100, 150, 25 ));
2852  }
2853 
2854 };
2855 
2856 
2858 {
2859  ItemLocator il;
2860  il.Show();
2861  il.RunModal();
2862 }
2863 
2864 
2865 /********************************************************************/
2866 /********************************************************************/
2867 /****** mirrorMap and utitity methods ******/
2868 /********************************************************************/
2869 /********************************************************************/
2870 
2871 
2872 void copyVehicleData( Vehicle* source, Vehicle* target, GameMap* targetMap, int* playerTranslation )
2873 {
2874 
2875  target->height = source->height;
2876  target->tank = source->getTank();
2877  target->name = source->name;
2878  target->setExperience_offensive( source->getExperience_offensive() );
2879  target->setExperience_defensive ( source->getExperience_defensive() );
2880  target->damage = source->damage;
2881 
2882 
2884  target->reactionfire.disable();
2885  else
2886  target->reactionfire.enable();
2887 
2888  // for( int i=0; i<8; i++ ) target->aiparam[ i ] = source->aiparam[ i ];
2889  for ( int i=0; i<16; i++ ) target->ammo[ i ] = source->ammo[ i ];
2890 
2891  // containing units
2892  ContainerBase::Cargo sourceCargo = source->getCargo();
2893  for ( int i=0; i<sourceCargo.size(); i++ )
2894  {
2895  int playerID = playerTranslation[ sourceCargo[ i ]->getOwner() ];
2896  Vehicle* cargo = new Vehicle( sourceCargo[ i ]->typ, targetMap, playerID );
2897  copyVehicleData( sourceCargo[ i ], cargo, targetMap, playerTranslation );
2898  target->addToCargo( cargo );
2899  }
2900 
2901  target->deleteAllProductionLines();
2902  for ( ContainerBase::Production::const_iterator i = source->getProduction().begin(); i != source->getProduction().end(); ++i )
2903  target->addProductionLine( *i );
2904 
2905 }
2906 
2907 
2908 void copyBuildingData( Building* source, Building* target, GameMap* targetMap, int *playerTranslation, bool mirrorUnits )
2909 {
2910  for ( int i=0; i<waffenanzahl; i++ )
2911  target->ammo[ i ] = source->ammo[ i ];
2912  target->name = source->name;
2913  target->netcontrol = source->netcontrol;
2914  target->visible = source->visible;
2915  /*
2916  for( int i=0; i<8; i++ )
2917  target->aiparam[ i ] = source->aiparam[ i ];
2918  */
2919  target->lastmineddist = source->lastmineddist;
2920  target->actstorage = source->actstorage;
2921  target->damage = source->damage;
2922 
2923  if ( mirrorUnits )
2924  {
2925  // containing units
2926  ContainerBase::Cargo sourceCargo = source->getCargo();
2927  for ( int i=0; i<sourceCargo.size(); i++ )
2928  {
2929  int playerID = playerTranslation[ sourceCargo[ i ]->getOwner() ];
2930  Vehicle* cargo = new Vehicle( sourceCargo[ i ]->typ, targetMap, playerID );
2931  copyVehicleData( sourceCargo[ i ], cargo, targetMap, playerTranslation );
2932  target->addToCargo( cargo );
2933  }
2934  }
2935 
2936  target->deleteAllProductionLines();
2937  for ( ContainerBase::Production::const_iterator i = source->getProduction().begin(); i != source->getProduction().end(); ++i )
2938  target->addProductionLine( *i );
2939 
2940 }
2941 
2942 void copyFieldStep1( MapField* sourceField, MapField* targetField, bool mirrorTerrain, bool mirrorResources, bool mirrorWeather )
2943 {
2944  targetField->deleteeverything();
2945  while ( targetField->objects.size() > 0 )
2946  targetField->removeObject( targetField->objects[ 0 ].typ, true );
2947 
2948  if ( mirrorTerrain )
2949  {
2950  targetField->typ = sourceField->typ;
2951  targetField->bdt = sourceField->bdt;
2952  }
2953 
2954  if ( mirrorResources )
2955  {
2956  targetField->fuel = sourceField->fuel;
2957  targetField->material = sourceField->material;
2958  }
2959  if ( mirrorWeather ) targetField->setWeather( sourceField->getWeather() );
2960 }
2961 
2962 void copyFieldStep2( MapField* sourceField, MapField* targetField, GameMap* targetMap, int *directionTranslation, int *playerTranslation, bool mirrorObjects, bool mirrorBuildings, bool mirrorUnits, bool mirrorMines )
2963 {
2964  if ( mirrorObjects )
2965  {
2966  for ( int i=0; i<sourceField->objects.size(); i++ )
2967  targetField->addobject( sourceField->objects[ i ].typ, -1, true );
2968  }
2969 
2970  if ( mirrorBuildings )
2971  {
2972  if ( sourceField->building != NULL && sourceField->building->getEntryField() == sourceField )
2973  {
2974  int playerID = playerTranslation[ sourceField->building->getOwner() ];
2975  Building *newBuilding = new Building( targetMap, MapCoordinate( targetField->getx(), targetField->gety() ), sourceField->building->typ, playerID );
2976  copyBuildingData( sourceField->building, newBuilding, targetMap, playerTranslation, mirrorUnits );
2977  }
2978  }
2979 
2980  if ( mirrorUnits )
2981  {
2982  if ( sourceField->vehicle != NULL )
2983  {
2984  int playerID = playerTranslation[ sourceField->vehicle->getOwner() ];
2985  targetField->vehicle = new Vehicle( sourceField->vehicle->typ, targetMap, playerID );
2986  copyVehicleData( sourceField->vehicle, targetField->vehicle, targetMap, playerTranslation );
2987  targetField->vehicle->setnewposition( targetField->getx(), targetField->gety() );
2988  targetField->vehicle->direction = directionTranslation[ int(sourceField->vehicle->direction) ];
2989  }
2990  }
2991 
2992  if ( mirrorMines )
2993  {
2994  for ( int i=0; i<sourceField->mines.size(); i++ )
2995  {
2996  Mine sourceMine = sourceField->getMine( i );
2997  targetField->putmine( playerTranslation[ sourceMine.player ], sourceMine.type, sourceMine.strength );
2998  }
2999  }
3000 }
3001 
3002 class MirrorMap : public tdialogbox
3003 {
3004  int mirrorUnits;
3005  int mirrorBuildings;
3006  int mirrorObjects;
3007  int mirrorMines;
3008  int mirrorResources;
3009  int mirrorWeather;
3010 
3011  int playerTranslation[ 9 ];
3012 
3013  bool doneMirrorMap;
3014 
3015 public:
3016  void init( void );
3017  void buttonpressed ( int id );
3018  void run ( void );
3019  Uint8 checkvalue( int id, void* p );
3020 
3021 protected:
3022 
3023 
3024  void mirrorX();
3025  void mirrorY();
3026 };
3027 
3028 Uint8 MirrorMap::checkvalue( int id, void* p )
3029 {
3030  return 1;
3031 }
3032 
3034 {
3036 
3037  if ( id == 1 )
3038  doneMirrorMap = true;
3039 
3040  if ( id == 2 )
3041  {
3042  mirrorX();
3043  doneMirrorMap = true;
3044  }
3045 
3046  if ( id == 3 )
3047  {
3048  mirrorY();
3049  doneMirrorMap = true;
3050  }
3051 
3052 }
3053 
3054 void MirrorMap::init( void )
3055 {
3056  doneMirrorMap = false;
3057 
3058  mirrorUnits = true;
3059  mirrorBuildings = true;
3060  mirrorObjects = true;
3061  mirrorMines = true;
3062  mirrorResources = true;
3063  mirrorWeather = true;
3064  for ( int i=0; i<8; i++ )
3065  playerTranslation[ i ] = 7-i;
3066  playerTranslation[ 8 ] = 8;
3067 
3068  tdialogbox::init();
3069  title = "Mirror Map";
3070 
3071  xsize = 400;
3072  ysize = 450;
3073 
3074  x1 = -1;
3075  y1 = -1;
3076 
3077  addbutton( "~C~ancel", 10, ysize - 35, xsize / 3 - 5, ysize - 10, 0, 1, 1, true );
3078  addkey ( 1, ct_esc );
3079 
3080  addbutton( "Mirror ~X~", xsize / 3 + 5, ysize - 35, xsize / 3 * 2 - 5, ysize - 10, 0, 1, 2, true );
3081  addkey ( 2, ct_x );
3082 
3083  addbutton ( "Mirror ~Y~", xsize / 3 * 2 + 5, ysize - 35, xsize - 10, ysize - 10, 0, 1, 3, true );
3084  addkey ( 3, ct_y );
3085 
3086  addbutton( "~O~bjects", xsize - 100, 50, xsize - 10, 65, 3, 0, 4, true );
3087  addeingabe( 4, &mirrorObjects, 0, lightgray );
3088  addkey ( 4, ct_o );
3089 
3090  addbutton( "~U~nits", xsize - 100, 70, xsize - 10, 85, 3, 0, 5, true );
3091  addeingabe( 5, &mirrorUnits, 0, lightgray );
3092  addkey ( 5, ct_u );
3093 
3094  addbutton( "~B~uildings", xsize - 100, 90, xsize - 10, 105, 3, 0, 6, true );
3095  addeingabe( 6, &mirrorBuildings, 0, lightgray );
3096  addkey ( 6, ct_b );
3097 
3098  addbutton( "~M~ines", xsize - 100, 110, xsize - 10, 125, 3, 0, 7, true );
3099  addeingabe( 7, &mirrorMines, 0, lightgray );
3100  addkey ( 7, ct_m );
3101 
3102  addbutton( "~R~esources", xsize - 100, 130, xsize - 10, 145, 3, 0, 8, true );
3103  addeingabe( 8, &mirrorResources, 0, lightgray );
3104  addkey ( 8, ct_r );
3105 
3106  addbutton( "~W~eather", xsize - 100, 150, xsize - 10, 165, 3, 0, 9, true );
3107  addeingabe( 9, &mirrorWeather, 0, lightgray );
3108  addkey ( 9, ct_w );
3109 
3110  addbutton( "Player Conversions:", 30, 50, xsize - 120, 70, 0, 0, 10, true );
3111  addbutton( "Player 0:", 30, 80, 130, 95, 2, 0, 12, true );
3112  addeingabe( 12, &playerTranslation[ 0 ], 0, 8 );
3113  addbutton( "Player 1:", 30, 110, 130, 125, 2, 0, 13, true );
3114  addeingabe( 13, &playerTranslation[ 1 ], 0, 8 );
3115  addbutton( "Player 2:", 30, 140, 130, 155, 2, 0, 14, true );
3116  addeingabe( 14, &playerTranslation[ 2 ], 0, 8 );
3117  addbutton( "Player 3:", 30, 170, 130, 185, 2, 0, 15, true );
3118  addeingabe( 15, &playerTranslation[ 3 ], 0, 8 );
3119  addbutton( "Player 4:", 30, 200, 130, 215, 2, 0, 16, true );
3120  addeingabe( 16, &playerTranslation[ 4 ], 0, 8 );
3121  addbutton( "Player 5:", 150, 80, xsize - 120, 95, 2, 0, 17, true );
3122  addeingabe( 17, &playerTranslation[ 5 ], 0, 8 );
3123  addbutton( "Player 6:", 150, 110, xsize - 120, 125, 2, 0, 18, true );
3124  addeingabe( 18, &playerTranslation[ 6 ], 0, 8 );
3125  addbutton( "Player 7:", 150, 140, xsize - 120, 155, 2, 0, 19, true );
3126  addeingabe( 19, &playerTranslation[ 7 ], 0, 8 );
3127  addbutton( "Player 8:", 150, 170, xsize - 120, 185, 2, 0, 20, true );
3128  addeingabe( 20, &playerTranslation[ 8 ], 0, 8 );
3129 
3130  buildgraphics();
3131 
3136 
3137  showtext2( "Warnings:", x1 + 25, y1 + 220 );
3138  showtext2( "right&lower border might have to be manually fixed", x1 + 25, y1 + 260 );
3139  showtext2( "mountains, battle isle graphics coasts and similar", x1 + 25, y1 + 280 );
3140  showtext2( "terrain needs manual adaption", x1 + 25, y1 + 300 );
3141  showtext2( "building directions might be weird, resulting in:", x1 + 25, y1 + 330 );
3142  showtext2( "- pipeline net might be broken due to building directions", x1 + 25, y1 + 350 );
3143  showtext2( "- buildings might be missing due to terrain", x1 + 25, y1 + 370 );
3144  showtext2( "- units might be missing due to building locations", x1 + 25, y1 + 390 );
3145 
3146 }
3147 
3148 
3149 void MirrorMap::run ( void )
3150 {
3151  mousevisible ( true );
3152  do {
3153  tdialogbox::run();
3154  } while ( !doneMirrorMap ); /* enddo */
3155 }
3156 
3157 
3159 {
3160  if ( actmap->xsize % 2 == 1 ) actmap->resize ( 0, 0, 0, 1 );
3161  int maxX = actmap->xsize/2;
3162  int xOffset = 2;
3163  int directionTranslation[ 6 ] = { 0, 5, 4, 3, 2, 1 };
3164 
3165  // run 1: object removal and terrain copy
3166  for ( int x=0; x<maxX; x++ )
3167  {
3168  for ( int y=0; y<actmap->ysize; y++ )
3169  {
3170  int targetX = actmap->xsize - x - xOffset;
3171  if ( y%2 == 0 ) targetX++;
3172  if ( targetX >= actmap->xsize || targetX == x ) continue;
3173 
3174  MapField *targetField = actmap->getField( targetX, y );
3175  MapField *sourceField = actmap->getField( x, y );
3176 
3177  copyFieldStep1( sourceField, targetField, true, mirrorResources, mirrorWeather );
3178  }
3179  }
3180 
3181  // run 2: object copy
3182  for ( int x=0; x<maxX; x++ )
3183  {
3184  for ( int y=0; y<actmap->ysize; y++ )
3185  {
3186  int targetX = actmap->xsize - x - xOffset;
3187  if ( y%2 == 0 ) targetX++;
3188  if ( targetX >= actmap->xsize || targetX == x ) continue;
3189 
3190  MapField *targetField = actmap->getField( targetX, y );
3191  MapField *sourceField = actmap->getField( x, y );
3192 
3193  copyFieldStep2( sourceField, targetField, actmap, directionTranslation, playerTranslation, mirrorObjects, mirrorBuildings, mirrorUnits, mirrorMines );
3194  }
3195  }
3196  doneMirrorMap = true;
3197 }
3198 
3200 {
3201  int yOffset = 2;
3202  int maxY = actmap->ysize/2;
3203  int directionTranslation[ 6 ] = { 3, 2, 1, 0, 5, 4 };
3204 
3205  // run 1: object removal and terrain copy
3206  for ( int x=0; x<actmap->xsize; x++ )
3207  {
3208  for ( int y=0; y<maxY; y++ )
3209  {
3210  int targetY = actmap->ysize - y - yOffset;
3211 
3212  MapField *targetField = actmap->getField( x, targetY );
3213  MapField *sourceField = actmap->getField( x, y );
3214 
3215  copyFieldStep1( sourceField, targetField, true, mirrorResources, mirrorWeather );
3216  }
3217  }
3218 
3219  // run 2: object copy
3220  for ( int x=0; x<actmap->xsize; x++ )
3221  {
3222  for ( int y=0; y<maxY; y++ )
3223  {
3224  int targetY = actmap->ysize - y - yOffset;
3225 
3226  MapField *targetField = actmap->getField( x, targetY );
3227  MapField *sourceField = actmap->getField( x, y );
3228 
3229  copyFieldStep2( sourceField, targetField, actmap, directionTranslation, playerTranslation, mirrorObjects, mirrorBuildings, mirrorUnits, mirrorMines );
3230  }
3231  }
3232  doneMirrorMap = true;
3233 }
3234 
3236 {
3237  MirrorMap mm;
3238  mm.init();
3239  mm.run();
3240  mm.done();
3241  mapChanged( actmap );
3242  displaymap();
3243 }
3244 
3245 /********************************************************************/
3246 /********************************************************************/
3247 /****** mirrorMap and utitity methods END ******/
3248 /********************************************************************/
3249 /********************************************************************/
3250 
3251 /********************************************************************/
3252 /********************************************************************/
3253 /****** copy area and utitity methods START ******/
3254 /********************************************************************/
3255 /********************************************************************/
3256 
3257 class CopyMap : public FieldAddressing, public ASC_PG_Dialog
3258 {
3259 private:
3260  GameMap *map;
3261  bool* fieldCopied;
3262 
3263  int mapStartX, mapStartY, mapEndX, mapEndY, sizeX, sizeY;
3264  int copyStep;
3265 
3266  int *directionTranslation;
3267  int *playerTranslation;
3268 
3269  PG_CheckButton* mirrorTerrain;
3270  PG_CheckButton* mirrorResources;
3271  PG_CheckButton* mirrorWeather;
3272  PG_CheckButton* mirrorObjects;
3273  PG_CheckButton* mirrorBuildings;
3274  PG_CheckButton* mirrorUnits;
3275  PG_CheckButton* mirrorMines;
3276 
3277  PG_CheckButton* mirrorX;
3278  PG_CheckButton* mirrorY;
3279 
3280  PG_CheckButton* autoIncreaseMapSize;
3281 
3282  PG_LineEdit* playerTranslation0;
3283  PG_LineEdit* playerTranslation1;
3284  PG_LineEdit* playerTranslation2;
3285  PG_LineEdit* playerTranslation3;
3286  PG_LineEdit* playerTranslation4;
3287  PG_LineEdit* playerTranslation5;
3288  PG_LineEdit* playerTranslation6;
3289  PG_LineEdit* playerTranslation7;
3290  PG_LineEdit* playerTranslation8;
3291 
3292 
3293 public:
3294  CopyMap();
3295  ~CopyMap();
3296  bool paste();
3297  void copy();
3298  void selectArea();
3299 
3300 protected:
3301  virtual void fieldOperator( const MapCoordinate& point );
3302 };
3303 
3304 CopyMap::CopyMap() : FieldAddressing( actmap ), ASC_PG_Dialog( NULL, PG_Rect( 30, 30, 550, 400 ), "Paste Options" )
3305 {
3306  addressingMode = poly;
3307  mapStartX = -1;
3308  mapStartY = -1;
3309  mapEndX = -1;
3310  mapEndY = -1;
3311  map = NULL;
3312  fieldCopied = NULL;
3313 
3314  directionTranslation = new int[ 6 ];
3315  for ( int i=0; i<6; i++ ) directionTranslation[ i ] = i;
3316  playerTranslation = new int[ 9 ];
3317  for ( int i=0; i<9; i++ ) playerTranslation[ i ] = i;
3318 
3319  int dialogLine = 0;
3320  int lineHeight = 20;
3321  int lineSpacing = 10;
3322 
3323  int startX = 20;
3324  int startY = 20;
3325  int startX2 = 200;
3326  int startX3 = 250;
3327  int startX4 = 400;
3328  int xSpacer = 20;
3329 
3330  PG_Label* label = new PG_Label ( this, PG_Rect( startX, startY + dialogLine*(lineHeight+lineSpacing) , startX2 - xSpacer - startX, lineHeight ) );
3331  label->SetAlignment( PG_Label::LEFT );
3332  label->SetText( "Terrain" );
3333  mirrorTerrain = new PG_CheckButton( this, PG_Rect( startX2, startY + dialogLine*(lineHeight+lineSpacing) , startX3 - xSpacer - startX2, lineHeight ) );
3334  mirrorTerrain->SetPressed();
3335  dialogLine++;
3336 
3337  label = new PG_Label ( this, PG_Rect( startX, startY + dialogLine*(lineHeight+lineSpacing) , startX2 - xSpacer - startX, lineHeight ) );
3338  label->SetAlignment( PG_Label::LEFT );
3339  label->SetText( "Resources" );
3340  mirrorResources = new PG_CheckButton( this, PG_Rect( startX2, startY + dialogLine*(lineHeight+lineSpacing) , startX3 - xSpacer - startX2, lineHeight ) );
3341  mirrorResources->SetPressed();
3342  dialogLine++;
3343 
3344  label = new PG_Label ( this, PG_Rect( startX, startY + dialogLine*(lineHeight+lineSpacing) , startX2 - xSpacer - startX, lineHeight ) );
3345  label->SetAlignment( PG_Label::LEFT );
3346  label->SetText( "Weather" );
3347  mirrorWeather = new PG_CheckButton( this, PG_Rect( startX2, startY + dialogLine*(lineHeight+lineSpacing) , startX3 - xSpacer - startX2, lineHeight ) );
3348  mirrorWeather->SetPressed();
3349  dialogLine++;
3350 
3351  label = new PG_Label ( this, PG_Rect( startX, startY + dialogLine*(lineHeight+lineSpacing) , startX2 - xSpacer - startX, lineHeight ) );
3352  label->SetAlignment( PG_Label::LEFT );
3353  label->SetText( "Objects" );
3354  mirrorObjects = new PG_CheckButton( this, PG_Rect( startX2, startY + dialogLine*(lineHeight+lineSpacing) , startX3 - xSpacer - startX2, lineHeight ) );
3355  mirrorObjects->SetPressed();
3356  dialogLine++;
3357 
3358  label = new PG_Label ( this, PG_Rect( startX, startY + dialogLine*(lineHeight+lineSpacing) , startX2 - xSpacer - startX, lineHeight ) );
3359  label->SetAlignment( PG_Label::LEFT );
3360  label->SetText( "Buildings" );
3361  mirrorBuildings = new PG_CheckButton( this, PG_Rect( startX2, startY + dialogLine*(lineHeight+lineSpacing) , startX3 - xSpacer - startX2, lineHeight ) );
3362  mirrorBuildings->SetPressed();
3363  dialogLine++;
3364 
3365  label = new PG_Label ( this, PG_Rect( startX, startY + dialogLine*(lineHeight+lineSpacing) , startX2 - xSpacer - startX, lineHeight ) );
3366  label->SetAlignment( PG_Label::LEFT );
3367  label->SetText( "Units" );
3368  mirrorUnits = new PG_CheckButton( this, PG_Rect( startX2, startY + dialogLine*(lineHeight+lineSpacing) , startX3 - xSpacer - startX2, lineHeight ) );
3369  mirrorUnits->SetPressed();
3370  dialogLine++;
3371 
3372  label = new PG_Label ( this, PG_Rect( startX, startY + dialogLine*(lineHeight+lineSpacing) , startX2 - xSpacer - startX, lineHeight ) );
3373  label->SetAlignment( PG_Label::LEFT );
3374  label->SetText( "Mines" );
3375  mirrorMines = new PG_CheckButton( this, PG_Rect( startX2, startY + dialogLine*(lineHeight+lineSpacing) , startX3 - xSpacer - startX2, lineHeight ) );
3376  mirrorMines->SetPressed();
3377  dialogLine++;
3378 
3379  label = new PG_Label ( this, PG_Rect( startX, startY + dialogLine*(lineHeight+lineSpacing) , startX2 - xSpacer - startX, lineHeight ) );
3380  label->SetAlignment( PG_Label::LEFT );
3381  label->SetText( "X" );
3382  mirrorX = new PG_CheckButton( this, PG_Rect( startX2, startY + dialogLine*(lineHeight+lineSpacing) , startX3 - xSpacer - startX2, lineHeight ) );
3383  dialogLine++;
3384 
3385  label = new PG_Label ( this, PG_Rect( startX, startY + dialogLine*(lineHeight+lineSpacing) , startX2 - xSpacer - startX, lineHeight ) );
3386  label->SetAlignment( PG_Label::LEFT );
3387  label->SetText( "Y" );
3388  mirrorY = new PG_CheckButton( this, PG_Rect( startX2, startY + dialogLine*(lineHeight+lineSpacing) ,startX3 - xSpacer - startX2, lineHeight ) );
3389  dialogLine++;
3390 
3391  label = new PG_Label ( this, PG_Rect( startX, startY + dialogLine*(lineHeight+lineSpacing) , startX2 - xSpacer - startX, lineHeight ) );
3392  label->SetAlignment( PG_Label::LEFT );
3393  label->SetText( "autoIncreaseMapSize" );
3394  autoIncreaseMapSize = new PG_CheckButton( this, PG_Rect( startX2, startY + dialogLine*(lineHeight+lineSpacing) , startX3 - xSpacer - startX2, lineHeight ) );
3395  autoIncreaseMapSize->SetPressed();
3396  dialogLine++;
3397 
3398 
3399  PG_Button* ok = new PG_Button( this, PG_Rect( startX, startY + dialogLine*(lineHeight+lineSpacing) , startX2 - xSpacer - startX, lineHeight ), "Paste" );
3400  ok->sigClick.connect( sigc::hide( sigc::mem_fun( *this, &CopyMap::paste )));
3401 
3402  dialogLine = 0;
3403 
3404  label = new PG_Label ( this, PG_Rect( startX3, startY + dialogLine*(lineHeight+lineSpacing) , startX4 - xSpacer - startX, lineHeight ) );
3405  label->SetAlignment( PG_Label::LEFT );
3406  label->SetText( "playerTranslation0" );
3407  playerTranslation0 = new PG_LineEdit( this, PG_Rect( startX4, startY + dialogLine*(lineHeight+lineSpacing) , this->Width() - xSpacer - startX4, lineHeight ) );
3408  playerTranslation0->SetText( "0" );
3409  dialogLine++;
3410 
3411  label = new PG_Label ( this, PG_Rect( startX3, startY + dialogLine*(lineHeight+lineSpacing) , startX4 - xSpacer - startX, lineHeight ) );
3412  label->SetAlignment( PG_Label::LEFT );
3413  label->SetText( "playerTranslation1" );
3414  playerTranslation1 = new PG_LineEdit( this, PG_Rect( startX4, startY + dialogLine*(lineHeight+lineSpacing) , this->Width() - xSpacer - startX4, lineHeight ) );
3415  playerTranslation1->SetText( "1" );
3416  dialogLine++;
3417 
3418  label = new PG_Label ( this, PG_Rect( startX3, startY + dialogLine*(lineHeight+lineSpacing) , startX4 - xSpacer - startX, lineHeight ) );
3419  label->SetAlignment( PG_Label::LEFT );
3420  label->SetText( "playerTranslation2" );
3421  playerTranslation2 = new PG_LineEdit( this, PG_Rect( startX4, startY + dialogLine*(lineHeight+lineSpacing) , this->Width() - xSpacer - startX4, lineHeight ) );
3422  playerTranslation2->SetText( "2" );
3423  dialogLine++;
3424 
3425  label = new PG_Label ( this, PG_Rect( startX3, startY + dialogLine*(lineHeight+lineSpacing) , startX4 - xSpacer - startX, lineHeight ) );
3426  label->SetAlignment( PG_Label::LEFT );
3427  label->SetText( "playerTranslation3" );
3428  playerTranslation3 = new PG_LineEdit( this, PG_Rect( startX4, startY + dialogLine*(lineHeight+lineSpacing) , this->Width() - xSpacer - startX4, lineHeight ) );
3429  playerTranslation3->SetText( "3" );
3430  dialogLine++;
3431 
3432  label = new PG_Label ( this, PG_Rect( startX3, startY + dialogLine*(lineHeight+lineSpacing) , startX4 - xSpacer - startX, lineHeight ) );
3433  label->SetAlignment( PG_Label::LEFT );
3434  label->SetText( "playerTranslation4" );
3435  playerTranslation4 = new PG_LineEdit( this, PG_Rect( startX4, startY + dialogLine*(lineHeight+lineSpacing) , this->Width() - xSpacer - startX4, lineHeight ) );
3436  playerTranslation4->SetText( "4" );
3437  dialogLine++;
3438 
3439  label = new PG_Label ( this, PG_Rect( startX3, startY + dialogLine*(lineHeight+lineSpacing) , startX4 - xSpacer - startX, lineHeight ) );
3440  label->SetAlignment( PG_Label::LEFT );
3441  label->SetText( "playerTranslation5" );
3442  playerTranslation5 = new PG_LineEdit( this, PG_Rect( startX4, startY + dialogLine*(lineHeight+lineSpacing) , this->Width() - xSpacer - startX4, lineHeight ) );
3443  playerTranslation5->SetText( "5" );
3444  dialogLine++;
3445 
3446  label = new PG_Label ( this, PG_Rect( startX3, startY + dialogLine*(lineHeight+lineSpacing) , startX4 - xSpacer - startX, lineHeight ) );
3447  label->SetAlignment( PG_Label::LEFT );
3448  label->SetText( "playerTranslation6" );
3449  playerTranslation6 = new PG_LineEdit( this, PG_Rect( startX4, startY + dialogLine*(lineHeight+lineSpacing) , this->Width() - xSpacer - startX4, lineHeight ) );
3450  playerTranslation6->SetText( "6" );
3451  dialogLine++;
3452 
3453  label = new PG_Label ( this, PG_Rect( startX3, startY + dialogLine*(lineHeight+lineSpacing) , startX4 - xSpacer - startX, lineHeight ) );
3454  label->SetAlignment( PG_Label::LEFT );
3455  label->SetText( "playerTranslation7" );
3456  playerTranslation7 = new PG_LineEdit( this, PG_Rect( startX4, startY + dialogLine*(lineHeight+lineSpacing) , this->Width() - xSpacer - startX4, lineHeight ) );
3457  playerTranslation7->SetText( "7" );
3458  dialogLine++;
3459 
3460  label = new PG_Label ( this, PG_Rect( startX3, startY + dialogLine*(lineHeight+lineSpacing) , startX4 - xSpacer - startX, lineHeight ) );
3461  label->SetAlignment( PG_Label::LEFT );
3462  label->SetText( "playerTranslation8" );
3463  playerTranslation8 = new PG_LineEdit( this, PG_Rect( startX4, startY + dialogLine*(lineHeight+lineSpacing) , this->Width() - xSpacer - startX4, lineHeight ) );
3464  playerTranslation8->SetText( "8" );
3465  dialogLine++;
3466 
3467 }
3468 
3470 {
3471  if ( map != NULL )
3472  {
3473  delete map;
3474  delete[] fieldCopied;
3475  }
3476  delete[] directionTranslation;
3477  delete[] playerTranslation;
3478 }
3479 
3481 {
3482  polygons.clear();
3483 
3484  Poly_gon area;
3485  editpolygon( area );
3486  setPolygon( area );
3487 }
3488 
3490 {
3491  if ( map != NULL )
3492  {
3493  delete map;
3494  delete[] fieldCopied;
3495  }
3496 
3497  mapStartX = -1;
3498  mapStartY = -1;
3499  mapEndX = -1;
3500  mapEndY = -1;
3501  copyStep = 0;
3502  operate();
3503 
3504  sizeX = mapEndX-mapStartX + 1;
3505  sizeY = mapEndY-mapStartY + 1;
3506 
3507  map = new GameMap;
3508  map->allocateFields( sizeX, sizeY, terrainTypeRepository.getObject_byID(30)->weather[0] );
3509 
3510  int* oldDirectoyTranslation = directionTranslation;
3511  int* oldPlayerTranslation = playerTranslation;
3512 
3513  directionTranslation = new int[ 6 ];
3514  for ( int i=0; i<6; i++ ) directionTranslation[ i ] = i;
3515  playerTranslation = new int[ 9 ];
3516  for ( int i=0; i<9; i++ ) playerTranslation[ i ] = i;
3517 
3518  fieldCopied = new bool[ sizeY * sizeX ];
3519  for ( int i=0; i<sizeY * sizeX; i++ )
3520  fieldCopied[ i ] = false;
3521 
3522  copyStep = 1;
3523  operate();
3524  copyStep = 2;
3525  operate();
3526 
3527  delete[] directionTranslation;
3528  delete[] playerTranslation;
3529  directionTranslation = oldDirectoyTranslation;
3530  playerTranslation = oldPlayerTranslation;
3531 }
3532 
3534 {
3535  QuitModal();
3536  Hide();
3537  if ( map == NULL ) return false;
3538 
3539  MapField *field = getactfield();
3540  if ( field == NULL ) return false;
3541 
3542  int pasteStartX = field->getx();
3543  int pasteStartY = field->gety();
3544 
3545  if ( autoIncreaseMapSize->GetPressed() )
3546  {
3547  int targetSizeX = pasteStartX + map->xsize;
3548  int targetSizeY = pasteStartY + map->ysize;
3549 
3550  if ( targetSizeY%2 == 1 )
3551  targetSizeY++;
3552 
3553  if ( targetSizeX > actmap->xsize )
3554  {
3555  actmap->resize( 0, 0, 0, targetSizeX - actmap->xsize );
3556  }
3557 
3558  if ( targetSizeY > actmap->ysize )
3559  {
3560  actmap->resize( 0, targetSizeY - actmap->ysize, 0, 0 );
3561  }
3562  }
3563 
3564  playerTranslation[ 0 ] = atoi( playerTranslation0->GetText() );
3565  playerTranslation[ 1 ] = atoi( playerTranslation1->GetText() );
3566  playerTranslation[ 2 ] = atoi( playerTranslation2->GetText() );
3567  playerTranslation[ 3 ] = atoi( playerTranslation3->GetText() );
3568  playerTranslation[ 4 ] = atoi( playerTranslation4->GetText() );
3569  playerTranslation[ 5 ] = atoi( playerTranslation5->GetText() );
3570  playerTranslation[ 6 ] = atoi( playerTranslation6->GetText() );
3571  playerTranslation[ 7 ] = atoi( playerTranslation7->GetText() );
3572  playerTranslation[ 8 ] = atoi( playerTranslation8->GetText() );
3573 
3574  int* oldDirectoyTranslation = directionTranslation;
3575 
3576  directionTranslation = new int[ 6 ];
3577  for ( int i=0; i<6; i++ ) directionTranslation[ i ] = i;
3578 
3579  if ( mirrorY->GetPressed() )
3580  {
3581  int directionTranslationNew[ 6 ] =
3582  {
3583  directionTranslation[ 3 ],
3584  directionTranslation[ 2 ],
3585  directionTranslation[ 1 ],
3586  directionTranslation[ 0 ],
3587  directionTranslation[ 5 ],
3588  directionTranslation[ 4 ]
3589  };
3590 
3591  for ( int i=0; i<6; i++ ) directionTranslation[ i ] = directionTranslationNew[ i ];
3592  }
3593 
3594  if ( mirrorX->GetPressed() )
3595  {
3596  int directionTranslationNew[ 6 ] =
3597  {
3598  directionTranslation[ 0 ],
3599  directionTranslation[ 5 ],
3600  directionTranslation[ 4 ],
3601  directionTranslation[ 3 ],
3602  directionTranslation[ 2 ],
3603  directionTranslation[ 1 ]
3604  };
3605 
3606  for ( int i=0; i<6; i++ ) directionTranslation[ i ] = directionTranslationNew[ i ];
3607  }
3608 
3609 
3610 
3611 
3612  for ( int x=0; x<map->xsize; x++ )
3613  {
3614  for ( int y=0; y<map->ysize; y++ )
3615  {
3616  if ( fieldCopied[ x + y * sizeX ] )
3617  {
3618  int fieldX = pasteStartX + x;
3619  int fieldY = pasteStartY + y;
3620 
3621  if ( pasteStartY%2 == 1 && fieldY%2 == 0 )
3622  fieldX++;
3623 
3624  if ( mirrorX->GetPressed() )
3625  {
3626  fieldX = pasteStartX + sizeX - x - 1;
3627 
3628  if ( pasteStartY%2 == 0 && fieldY%2 == 1 )
3629  fieldX--;
3630  }
3631 
3632  if ( mirrorY->GetPressed() )
3633  {
3634  fieldY = pasteStartY + sizeY - y - 1;
3635  }
3636 
3637  if ( fieldX >= actmap->xsize ) continue;
3638  if ( fieldY >= actmap->ysize ) continue;
3639 
3640  MapField* target = actmap->getField( fieldX, fieldY );
3641  MapField* source = map->getField( x, y );
3642 
3643  copyFieldStep1( source, target, mirrorTerrain->GetPressed(), mirrorResources->GetPressed(), mirrorWeather->GetPressed() );
3644  }
3645  }
3646  }
3647 
3648  for ( int x=0; x<map->xsize; x++ )
3649  {
3650  for ( int y=0; y<map->ysize; y++ )
3651  {
3652  if ( fieldCopied[ x + y * sizeX ] )
3653  {
3654  int fieldX = pasteStartX + x;
3655  int fieldY = pasteStartY + y;
3656 
3657  if ( pasteStartY%2 == 1 && fieldY%2 == 0 )
3658  fieldX++;
3659 
3660  if ( mirrorX->GetPressed() )
3661  {
3662  fieldX = pasteStartX + sizeX - x - 1;
3663 
3664  if ( pasteStartY%2 == 0 && fieldY%2 == 1 )
3665  fieldX--;
3666  }
3667 
3668  if ( mirrorY->GetPressed() )
3669  {
3670  fieldY = pasteStartY + sizeY - y - 1;
3671  }
3672 
3673  if ( fieldX >= actmap->xsize ) continue;
3674  if ( fieldY >= actmap->ysize ) continue;
3675 
3676  MapField* target = actmap->getField( fieldX, fieldY );
3677  MapField* source = map->getField( x, y );
3678 
3679  copyFieldStep2( source, target, actmap, directionTranslation, playerTranslation, mirrorObjects->GetPressed(), mirrorBuildings->GetPressed(), mirrorUnits->GetPressed(), mirrorMines->GetPressed() );
3680  }
3681  }
3682  }
3683 
3684  delete[] directionTranslation;
3685  directionTranslation = oldDirectoyTranslation;
3686 
3687  return true;
3688 
3689 }
3690 
3692 {
3693  int mapX = point.x - mapStartX;
3694  int mapY = point.y - mapStartY;
3695 
3696  if ( mapStartY%2 == 1 && mapY%2 == 1 )
3697  mapX--;
3698 
3699  if ( copyStep == 0 )
3700  {
3701  if ( mapStartX == -1 || point.x < mapStartX )
3702  mapStartX = point.x;
3703 
3704  if ( mapStartY == -1 || point.y < mapStartY )
3705  mapStartY = point.y;
3706 
3707  if ( mapEndX == -1 || point.x > mapEndX )
3708  mapEndX = point.x;
3709 
3710  if ( mapEndY == -1 || point.y > mapEndY )
3711  mapEndY = point.y;
3712  } else if ( copyStep == 1 )
3713  {
3714  fieldCopied[ mapX + mapY * sizeX ] = true;
3715 
3716  MapField* source = actmap->getField( point );
3717  MapField* target = map->getField( mapX, mapY );
3718 
3719 
3720 
3721  copyFieldStep1( source, target, true, true, true );
3722 
3723  } else if ( copyStep == 2 )
3724  {
3725  MapField* source = actmap->getField( point );
3726  MapField* target = map->getField( mapX, mapY );
3727 
3728  copyFieldStep2( source, target, map, directionTranslation, playerTranslation, true, true, true, true );
3729 
3730  }
3731 }
3732 
3734 
3735 void copyArea()
3736 {
3737  if ( copyMap == NULL )
3738  {
3739  copyMap = new CopyMap();
3740  }
3741  copyMap -> selectArea();
3742  copyMap -> copy();
3743 }
3744 
3746 {
3747  if ( copyMap != NULL )
3748  {
3749  copyMap -> Show();
3750  copyMap -> RunModal();
3751  mapChanged( actmap );
3752  displaymap();
3753  }
3754 }
3755 
3756 void selectAndRunLuaScript( const ASCString& filenamewildcard )
3757 {
3758  ASCString file = selectFile( filenamewildcard, true );
3759  if ( file.size() ) {
3760  LuaState state;
3761  LuaRunner runner( state );
3762  runner.runFile( file );
3763  if ( !runner.getErrors().empty() )
3764  errorMessage( runner.getErrors() );
3765  updateFieldInfo();
3766  }
3767 }
3768 
3769 
3770 /********************************************************************/
3771 /********************************************************************/
3772 /****** copy area and utitity methods END ******/
3773 /********************************************************************/
3774 /********************************************************************/
3775 
3776 
3777 
3778 
3780 {
3781  // tempsvisible = true;
3782  actmap->cleartemps(7);
3783  for ( int x = 0; x < actmap->xsize; ++x )
3784  for ( int y = 0; y < actmap->ysize; ++y ) {
3785  MapField* fld = actmap->getField(x,y);
3786  if ( fld->getVisibility(5) >= visible_now )
3787  fld->setaTemp(1);
3788  else
3789  fld->setaTemp(0);
3790  }
3791 
3792  repaintMap();
3793 }
virtual void setup(void)
Definition: edmisc.cpp:1307
void init(const char *title, const char *text, int xx1=50, int yy1=50, int xxsize=360, int yysize=360)
Definition: dialog.cpp:920
virtual void run(void)
Definition: edmisc.cpp:1029
TerrainType::Weather * typ
the terraintype of the field
Definition: mapfield.h:38
ASCString printTech(int id)
Definition: edmisc.cpp:2526
int fuel
Definition: typen.h:101
int startpos
Definition: dlg_box.h:420
void copyArea()
Definition: edmisc.cpp:3735
void displaymap()
Definition: spfst.cpp:58
tfontsettings activefontsettings
Definition: newfont.cpp:51
The type of a field.
Definition: terraintype.h:75
const Placeable * getSelection()
Definition: edglobal.cpp:220
virtual void run(void)
Definition: edmisc.cpp:404
#define dblue
Definition: misc.h:33
Uint8 background
Definition: newfont.h:171
#define ct_x
Definition: keysymbols.h:99
int x1
Definition: dlg_box.h:40
sigc::signal< void, GameMap * > mapChanged
Definition: spfst.cpp:52
bool mouseDraggedToField(const MapCoordinate &pos, const SPoint &mousePos, bool cursorChanged, int prio)
Definition: edmisc.cpp:103
void setaTemp(Uint8 atemp)
Various algorithms need to store some information in the fields they process.
Definition: mapfield.cpp:49
string getName()
Definition: edmisc.cpp:2046
void writeInvertTreeOutput(const Technology *tech, tnstream &stream, vector< int > &history, vector< pair< int, int > > &blockedPrintList, const vector< IntRange > *onlyWithBaseTechs=NULL) const
Definition: research.cpp:237
ItemRepositoryLoader< ObjectType > objectTypeRepository("objecttype")
void cleartemps(int b=-1, int value=0)
Definition: gamemap.cpp:964
Player & getPlayer(PlayerID p)
Definition: gamemap.h:257
MapCoordinate & getCursor()
Definition: gamemap.cpp:933
void deleteeverything(void)
deletes everything placed on the field
Definition: mapfield.cpp:295
vector< Point > vertex
Definition: mappolygons.h:39
virtual void testfield(const MapCoordinate &mc)
Definition: edmisc.cpp:134
sigc::signal< void > filtersChangedSignal
Definition: edselfnt.cpp:42
int xsize
the size of the map
Definition: gamemap.h:201
int getExperience_defensive() const
Definition: vehicle.cpp:258
void vPlace(const MapCoordinate &mc) const
just a wrapper so we have a function return void
void copyBuildingData(Building *source, Building *target, GameMap *targetMap, int *playerTranslation, bool mirrorUnits)
Definition: edmisc.cpp:2908
int numberoflines
Definition: dlg_box.h:420
void placeCurrentItem()
Definition: edmisc.cpp:70
Mine & getMine(int n)
returns the nth mine. This function should only be used by legacy code; new code should store an iter...
Definition: mapfield.cpp:204
bool putmine(int owner, MineTypes typ, int strength)
put a mine of type typ for player owner and a punch of strength on the field. Strength is an absolute...
Definition: mapfield.cpp:441
const char * AItasks[AiParameter::taskNum]
const BuildingType * typ
Definition: buildings.h:48
virtual bool supportMultiFieldPlacement() const =0
virtual void run(void)
Definition: edmisc.cpp:1340
void run(void)
Definition: dialog.cpp:2136
void transform(const VehicleType *type)
to be used with EXTREME caution, and only in the mapeditor !!
Definition: vehicle.cpp:405
void unitsettransformation(void)
Definition: edmisc.cpp:1996
int damage
Damage. 0 is no damage, when damage reaches 100 the container is destroyed.
const char * oldClipboardFileExtension
Definition: clipboard.cpp:37
Vehicle * vehicle
Definition: mapfield.h:89
const int waffenanzahl
The number of different weapon types.
Definition: typen.h:58
const char * AIjobs[AiParameter::jobNum]
int energy
Definition: typen.h:99
bool valid() const
Definition: typen.h:221
ASCString name
a name given by the user or the map creator
The clipboard for ASC.
void buttonpressed(int id)
Definition: edmisc.cpp:1443
void setnewposition(int x, int y)
checks whether the unit can construct a building of the given type.
Definition: vehicle.cpp:808
TextPropertyGroup * run()
Action getDefaultAction()
Definition: edmisc.cpp:2062
virtual void buttonpressed(int id)
Definition: edmisc.cpp:1317
AiParameter * aiparam[8]
Definition: vehicle.h:182
void run(void)
Definition: edmisc.cpp:3149
void init(void)
Definition: edmisc.cpp:146
virtual bool remove(const MapCoordinate &mc) const
int ammo[16]
Definition: vehicle.h:87
void copyFieldStep2(MapField *sourceField, MapField *targetField, GameMap *targetMap, int *directionTranslation, int *playerTranslation, bool mirrorObjects, bool mirrorBuildings, bool mirrorUnits, bool mirrorMines)
Definition: edmisc.cpp:2962
void init(void)
Definition: dlg_box.cpp:3424
int y1
Definition: dlg_box.h:40
void editTechAdapter()
Definition: edmisc.cpp:2728
virtual void run(void)
Definition: dlg_box.cpp:1477
int chainbuildingtofield(const MapCoordinate &entryPos, bool setupImages=true)
registers the building at the given position on the map
Definition: buildings.cpp:268
CoordinateList & coordinateList
Definition: fieldmarker.h:48
Loading Battle Isle 3 maps. The central BI3 map loading class is a straight conversion of Joerg Richt...
void execaction_ev(int code)
Definition: edglobal.cpp:1026
ASCString getName() const
returns the name of the player
Definition: player.cpp:274
Uint8 material
Definition: mapfield.h:54
void runFile(const ASCString &filename)
Definition: luarunner.cpp:25
Resources getStorageCapacity() const
returns the local storage capacity for the given resource, which depends on the resource mode of the ...
TerrainType * terraintype
pointer to the outer structure
Definition: terraintype.h:128
BuildingValues(Building &building)
Definition: edmisc.cpp:859
Weather * weather[cwettertypennum]
Definition: terraintype.h:140
void lines(int x1, int y1, int x2, int y2)
Definition: edmisc.cpp:223
void buttonpressed(int id)
Definition: edmisc.cpp:183
void run()
Definition: edmisc.cpp:1435
bool removeCurrentItem()
Definition: edmisc.cpp:82
bool hasFunction(ContainerFunctions function) const
virtual void buttonpressed(int id)
Definition: dlg_box.cpp:369
virtual int place(const MapCoordinate &mc) const =0
void addIntegerArray(const ASCString &name, vector< int > &property, bool required=true)
int getOwner() const
returns the number of the player this vehicle/building belongs to
void deleteAllProductionLines()
void saveClipboard()
Definition: edmisc.cpp:2508
vector< int > developedTechnologies
Definition: research.h:183
int xsize
Definition: dlg_box.h:40
Functions to evaluate the parsed *.asctxt files.
void savemap(const ASCString &name, GameMap *gamemap)
saves the map located in actmap to the map file name
Definition: loaders.cpp:1428
MapCoordinate3D getEntry() const
returns the position of the buildings entry
Definition: buildings.cpp:410
const char * cwaffentypen[weaponTypeNum]
Definition: vehicletype.cpp:71
Loki::Functor< GameMap *, LOKI_TYPELIST_1(const ASCString &) > MapLoadingFunction
Definition: loaders.h:57
void setExperience_defensive(int experience)
Definition: vehicle.cpp:279
#define ct_y
Definition: keysymbols.h:100
vector< AiParameter::Job > JobList
class GameMap::ArchivalInformation archivalInformation
void init(void)
Definition: edmisc.cpp:1584
static const int taskNum
int getNumericalHeight() const
Definition: typen.h:242
void k_loadmap(void)
Definition: edmisc.cpp:629
vector< Point >::iterator VertexIterator
Definition: mappolygons.h:38
void buildgraphics(void)
Definition: dlg_box.cpp:1180
void warningMessage(const ASCString &str)
pfont smallarial
Definition: spfst-legacy.h:28
void selectunitsetfilter(void)
Definition: edmisc.cpp:1766
#define ct_enter
Definition: keysymbols.h:51
sigc::signal< void > repaintMap
}@
Definition: spfst.cpp:45
A system that provides a set of images for vehicles, buildings, etc.
Uint8 justify
Definition: newfont.h:176
int mineowner(void)
the player who placed the mines on this field.
Definition: mapfield.cpp:454
ItemRepositoryLoader< BuildingType > buildingTypeRepository("buildingtype")
void k_savemap(bool saveas)
Definition: edmisc.cpp:607
#define lefttext
Definition: newfont.h:184
void init(void)
Definition: edmisc.cpp:865
The class that manages the switching between the primary map (for editing) and the secondary map (for...
Definition: edmisc.h:104
Resources getTank() const
returns the resources that the unit is carrying
Definition: vehicle.cpp:378
Uint8 checkobject(MapField *pf)
Definition: edmisc.cpp:114
a single field of the map
Definition: mapfield.h:26
#define ct_w
Definition: keysymbols.h:98
ASCString & format(const charT *pFormat,...)
Definition: ascstring.cpp:78
void editArchivalInformation()
Definition: edmisc.cpp:2434
if(!yyg->yy_init)
Definition: scanner.cpp:695
#define ct_u
Definition: keysymbols.h:96
MapField * getEntryField() const
returns the field the buildings entry is standing on
Definition: buildings.cpp:405
struct MapDisplayPG::Cursor cursor
virtual void run(void)
Definition: edmisc.cpp:1541
ItemRepositoryLoader< Technology > technologyRepository("technology")
static GameMap * loadmap(const ASCString &name)
Definition: loaders.cpp:1039
void resourceComparison()
displays a textmessage comparing the resources of all players
Definition: edmisc.cpp:2442
int netcontrol
a bitmapped variable containing the status of the resource-net connection.
Definition: buildings.h:57
Uint8 color
Definition: newfont.h:170
A class that hols a MessageWindow. This class ensures that the window is removed if the last copy of ...
Definition: messaginghub.h:34
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
void setJob(const JobList &jobs)
Definition: gamemap.cpp:2112
ASCString description
short description of the units role, for example "strategic bomber"
void copyVehicleData(Vehicle *source, Vehicle *target, GameMap *targetMap, int *playerTranslation)
Definition: edmisc.cpp:2872
bool mousePressedOnField(const MapCoordinate &pos, const SPoint &mousePos, bool cursorChanged, int button, int prio)
Definition: edmisc.cpp:91
void mirrorX()
Definition: edmisc.cpp:3158
const Production & getProduction() const
void copyFieldStep1(MapField *sourceField, MapField *targetField, bool mirrorTerrain, bool mirrorResources, bool mirrorWeather)
Definition: edmisc.cpp:2942
void editpolygon(Poly_gon &poly)
Definition: edmisc.cpp:807
int selectString(int lc, const char *title, const char **text, int itemNum)
Definition: edmisc.cpp:1354
int selectfield(int *cx, int *cy)
tkey taste
Definition: dlg_box.h:88
VehicleType * transform(int id, const vector< int > &translation)
Definition: edmisc.cpp:2074
const int black
Definition: basegfx.h:87
void addStringArray(const ASCString &name, vector< ASCString > &property)
void changebuildingvalues(Building &b)
Definition: edmisc.cpp:1141
int height
the current level of height ( BITMAPPED ! )
Definition: vehicle.h:118
EditArchivalInformation(GameMap *map)
Definition: edmisc.cpp:2363
int ysize
Definition: dlg_box.h:40
int beeline(const Vehicle *a, const Vehicle *b)
returns the distance between the units a and b
int getWeather()
the weather that is on this field
Definition: mapfield.cpp:370
void done(void)
Definition: dlg_box.cpp:3617
void buttonpressed(int id)
Definition: edmisc.cpp:3033
virtual void writeString(const string &pc, bool binary=true)
writes the C++ String pc to the stream.
Definition: basestrm.cpp:545
MapField * getfield(int x, int y)
returns the field at the given coordinates
Definition: spfst.cpp:199
virtual void run(void)
Definition: dialog.cpp:1009
const int white
Definition: basegfx.h:102
int resize(int top, int bottom, int left, int right)
resizes the map. Positive numbers enlarge the map in that direction
Definition: gamemap.cpp:1636
void newmap(void)
Definition: edmisc.cpp:827
void mirrorY()
Definition: edmisc.cpp:3199
struct GameMap::PreferredFilenames preferredFileNames
The class describing properties that are common to all vehicles of a certain kind.
Definition: vehicletype.h:177
pfont font
Definition: newfont.h:169
void unitAiProperties(Vehicle *veh)
Definition: edmisc.cpp:1474
static ASCString toString(int i)
converts the parameter to a String
Definition: ascstring.cpp:193
class Vehicle::ReactionFire reactionfire
AddressingMode addressingMode
Definition: gameevents.h:101
int terrainaccessible(const MapField *field, const Vehicle *vehicle, int uheight)
Checks if the unit can drive on the field.
Definition: spfst.cpp:70
void selectUnitFromMap(GameMap *gamemap, MapCoordinate &pos)
Definition: edmisc.cpp:664
Schriften schriften
Definition: spfst.cpp:66
StringSelector(const char *title_, const char **text_, int itemNum_)
Definition: edmisc.cpp:1296
TechDependency techDependency
Definition: research.h:143
VehicleList vehicleList
a list of all units
Definition: player.h:135
void done(void)
Definition: dlg_box.cpp:1235
The class describing properties that are common to all buildings of a certain kind.
Definition: buildingtype.h:35
bool mapsaved
Definition: edmisc.cpp:66
void Show(bool fade=false)
ItemRepositoryLoader< VehicleType > vehicleTypeRepository("vehicletype")
CopyMap()
Definition: edmisc.cpp:3304
int enable()
enables the reaction fire or returns an error code ( result < 0 = -errorNr )
Definition: vehicle.cpp:689
void setTask(Task t)
TerrainBits getTerrainBitType(TerrainBitTypes tbt)
char * strrr(int a)
converts a to a string.
Definition: misc.cpp:66
void exchg(int *a1, int *a2)
Definition: edmisc.cpp:498
virtual void buttonpressed(int id)
Definition: edmisc.cpp:1625
int windowstyle
Definition: dlg_box.h:163
int fuel
Definition: edmisc.cpp:1497
const int resourceTypeNum
The number of different resources that ASC uses.
Definition: typen.h:77
GameMap * mapLoadingExceptionChecker(const ASCString &filename, MapLoadingFunction loader)
Definition: loaders.cpp:1539
char txt[2000]
Definition: dlg_box.h:416
PolygonEditor(CoordinateList &list, GameMap *map)
Definition: edmisc.cpp:802
virtual void fieldOperator(const MapCoordinate &point)
Definition: edmisc.cpp:3691
void sortobjects(void)
sorts the objects. Since objects can be on different levels of height, the lower one must be displaye...
Definition: mapfield.cpp:436
Interface to the event handling of ASC.
ItemRepositoryLoader< TerrainType > terrainTypeRepository("terraintype")
Interface to game event dialogs.
void readClipboard()
Definition: edmisc.cpp:2485
virtual void buttonpressed(int id)
Definition: edmisc.cpp:1549
static bool isFiltered(Category cat, int id)
void setExperience_offensive(int experience)
Definition: vehicle.cpp:274
virtual void get_text(int nr)
Definition: edmisc.cpp:1334
void initsearch(const MapCoordinate &startPosition, int _firstDistance, int _lastDistance)
Uint8 fuel
mineral resources on this field.
Definition: mapfield.h:54
const char * mapextension
Definition: loaders.cpp:79
An object that can be placed on fields. Roads, pipelines and ditches are examples of objects...
Definition: objecttype.h:30
MapField * getactfield(void)
Definition: edmisc.cpp:2759
Coordinate on the twodimensional map.
Definition: typen.h:202
Adapter class for using Paragui Dialogs in ASC. This class transfers the event control from ASC to Pa...
Definition: paradialog.h:127
MineTypes type
void circularFieldIterator(GameMap *gamemap, const MapCoordinate &center, int startDist, int stopDist, FieldIterationFunctor functor)
int player
the player who placed the mine; range 0 .. 7
int unchainbuildingfromfield(void)
unregister the building from the map position
Definition: buildings.cpp:332
void setparams(ObjectRemovalStrategy *objectRemovalStrategy)
recalculates the terrain properties, movemalus etc from the terraintype and the objects,
Definition: mapfield.cpp:605
void displaymessage(const char *formatstring, int num,...)
displays a dialog box with a message
Definition: dlg_box.cpp:1849
static deallocating_vector< ItemFilter * > itemFilters
void allocateFields(int x, int y, TerrainType::Weather *terrain=NULL)
Definition: gamemap.cpp:982
void addbutton(const char *ltxt, int lx1, int ly1, int lx2, int ly2, int lart, int lstyle, int lid, bool enabled)
Definition: dlg_box.cpp:471
int ammo[waffenanzahl]
the ammo that is stored in the building
Definition: buildings.h:50
void copy()
Definition: edmisc.cpp:3489
bool paintPolygon(const Poly_gon &poly)
Definition: mappolygons.cpp:42
#define ct_esc
Definition: keysymbols.h:43
The interface for the buildingtype class.
void setnum(int _x, int _y, int numericalz)
Definition: typen.h:250
void deleteMaps()
Definition: edmisc.cpp:2003
void movebuilding(void)
Definition: edmisc.cpp:1649
int efficiencymaterial
currently only used by mining stations: the efficiency of the resource extraction from the ground...
void selectArea()
Definition: edmisc.cpp:3480
Uint16 length
Definition: newfont.h:174
virtual void startsearch(void)
int _resourcemode
how are Resources handled on this map 0= "ASC mode": complex system with mineral resources etc 1= "BI...
Definition: gamemap.h:250
Resources maxplus
the maximum amount of Resources that the building can produce each turn in the ASC resource mode ; se...
int strength
the effective punch of the mine
void calculateallobjects(GameMap *actmap)
recalculates the connection (like road interconnections) of all objects on the map ...
Definition: spfst.cpp:562
#define ct_m
Definition: keysymbols.h:88
bool addobject(const ObjectType *obj, int dir=-1, bool force=false, ObjectRemovalStrategy *objectRemovalStrategy=NULL)
add an object to the field
Definition: mapfield.cpp:212
int material
Definition: typen.h:100
const ASCString & getMessage(void) const
Definition: errors.h:42
void bar(tmouserect rect, int color)
Definition: dlg_box.cpp:537
void addProductionLine(const VehicleType *type)
CopyMap * copyMap
Definition: edmisc.cpp:3733
int getx()
Definition: mapfield.cpp:477
sigc::signal< void > updateFieldInfo
Definition: spfst.cpp:47
bool paste()
Definition: edmisc.cpp:3533
void playerchange(void)
Definition: edmisc.cpp:485
MapCoordinate upperLeftCorner()
Definition: mapdisplay.cpp:947
void anzeige(void)
Definition: edmisc.cpp:369
int gety()
Definition: mapfield.cpp:483
void addkey(int id, tkey key)
Definition: dlg_box.cpp:774
void setPolygon(const Poly_gon &poly_gon)
void mirrorMap()
Definition: edmisc.cpp:3235
SDLmm::SPoint SPoint
Definition: surface.h:27
Player player[9]
Definition: gamemap.h:253
Resources plus
the Resources that are produced each turn
MapDisplayPG * getMapDisplay()
Parses a .ASCTXT file and returns a TextPropertyGroup.
virtual void run(void)
Definition: edmisc.cpp:1617
void errorMessage(const ASCString &string)
const int red
Definition: basegfx.h:91
All parameters the AI stores persistently about a unit.
static const int jobNum
void swap(Player &secondPlayer)
swaps all information, units, buildings etc with the given player
Definition: player.cpp:350
#define ct_b
Definition: keysymbols.h:77
int ysize
Definition: gamemap.h:201
void toggle()
Definition: edmisc.cpp:2012
sigc::signal< void > viewChanged
the view of the player onto the map changed, for example because he scrolled the map ...
Definition: spfst.cpp:51
TerrainBits bdt
the terraintype properties. They determine which units can move over the field. This variable is reca...
Definition: mapfield.h:161
MineContainer mines
Definition: mapfield.h:117
Class that stores all the (preparsed) entries of an .ASCTXT file.
ASCString selectFile(const ASCString &ext, bool load, bool overwriteMessage)
void showtext2(const ASCString &text, int x, int y)
Definition: basegfx.cpp:1953
#define ct_1
Definition: keysymbols.h:108
void help(int id)
displays a dialogbog with the given help topic
Definition: dlg_box.cpp:3286
SelectionHolder selection
Definition: edglobal.cpp:189
void init()
Definition: edmisc.cpp:1382
int lastmineddist
Definition: buildings.h:72
BuildingList buildingList
a list of all units
Definition: player.h:139
Resources actstorage
the current storage of Resources
Definition: buildings.h:91
Resources bi_resourceplus
the maximum amount of Resources that the building can produce each turn in the BI resource mode ; see...
int atoi(const std::string &s)
Definition: misc.cpp:152
void convert(int player, bool recursive=true)
changes the building's owner.
Definition: buildings.cpp:105
int color
The owner of the container.
Research research
the status of the scientific research
Definition: player.h:142
MapField * field
the array of fields
Definition: gamemap.h:204
int & resource(int type)
Definition: typen.h:105
ASCString maptitle
the title of the map
Definition: gamemap.h:213
int xpos
the position on the map
Definition: vehicle.h:124
~CopyMap()
Definition: edmisc.cpp:3469
void setWeather(int weather)
Definition: mapfield.cpp:380
vector< MapCoordinate > CoordinateList
Definition: fieldmarker.h:45
void testDebugFunction()
Definition: edmisc.cpp:3779
void run(void)
Definition: edmisc.cpp:206
vector< const VehicleType * > Production
Definition: containerbase.h:87
void addToCargo(Vehicle *veh, int position=-1)
adds the unit to the cargo
const VehicleType * typ
Definition: vehicle.h:83
Uint8 direction
the direction in which the unit is facing
Definition: vehicle.h:121
int editInt(const ASCString &title, int defaultValue, int minValue, int maxValue)
Definition: dialog.cpp:2163
Uint8 checkvalue(int id, void *p)
Definition: edmisc.cpp:3028
void init(void)
Definition: edmisc.cpp:322
Building * building
Definition: mapfield.h:102
ASCString name
Definition: research.h:137
void AddItem(const std::string &text, void *userdata=NULL, Uint16 height=0)
void goTo(const MapCoordinate &position)
#define ct_o
Definition: keysymbols.h:90
virtual void enablebutton(int id)
Definition: dlg_box.cpp:860
void buttonpressed(int id)
Definition: edmisc.cpp:2404
MainScreenWidget * getMainScreenWidget()
#define righttext
Definition: newfont.h:186
void init(void)
Definition: edmisc.cpp:3054
#define dlg_in3d
Definition: dlg_box.h:33
const ASCString & getErrors()
Definition: luarunner.cpp:61
list< Building * > BuildingList
Definition: player.h:137
#define maxint
Definition: typen.h:462
const char * resourceNames[3]
the names of the different resources. Redundent, as we already have Resources::name ...
Definition: typen.cpp:79
GameMap * actmap
Definition: spfst.cpp:64
void editResearchPoints()
Definition: edmisc.cpp:2605
void init(void)
Definition: dlg_box.cpp:314
void transformMap()
replaces the terrain and the objects on a map according to a translation table
Definition: edmisc.cpp:2082
void init(void)
Definition: dialog.cpp:2069
int maxresearchpoints
the maximum number of research points a research center may produce
UnitSets unitSets
Definition: unitset.cpp:211
The parent class of Vehicle and Building; The name Container originates from Battle Isle...
Definition: containerbase.h:40
bool paintPolygon(const Poly_gon &poly)
Definition: edmisc.cpp:774
#define minint
Definition: typen.h:463
void init(void)
Definition: edmisc.cpp:1505
An actual building on the map, which references a BuildingType Buildings have an owner,.
Definition: buildings.h:38
const T & min(const T &a, const T &b, const T &c)
Definition: misc.h:80
Polygons polygons
Definition: gameevents.h:103
Status getStatus() const
for each player that can still be attacked one bit is set
Definition: vehicle.h:155
void setaTemp2(Uint8 atemp2)
Definition: mapfield.cpp:56
vector< Vehicle * > Cargo
GameMap * createNewMap()
Definition: newmap.cpp:182
void pasteArea()
Definition: edmisc.cpp:3745
Resources are basically the currency of ASC.
Definition: typen.h:97
int getcapabilities(void)
Definition: edmisc.cpp:1376
const int darkgray
Definition: basegfx.h:95
virtual void buttonpressed(int id)
Definition: dlg_box.cpp:3476
void changeresource(void)
Definition: edmisc.cpp:1561
#define ct_f1
Definition: keysymbols.h:132
MapCoordinate3D dest
int researchpoints
the current amount of research that the building conducts every turn
void selectAndRunLuaScript(const ASCString &filenamewildcard)
Definition: edmisc.cpp:3756
#define ct_r
Definition: keysymbols.h:93
VisibilityStates getVisibility(int actplayer)
Definition: mapfield.h:240
EditAiParam(Vehicle *veh, int player)
Definition: edmisc.cpp:1372
int choice_dlg(const ASCString &title, const ASCString &leftButton, const ASCString &rightButton)
Definition: dialog.cpp:616
void writeTreeOutput(const ASCString &sourceTechName, tnstream &stream, bool reduce) const
outputs the dependencies in text format for processing by GraphViz
Definition: research.cpp:173
void editResearch()
Definition: edmisc.cpp:2537
bool patimat(const char *pat, const char *str, bool forceCaseInsensitivity)
Definition: basestrm.cpp:1997
PG_Button * AddStandardButton(const ASCString &name)
Definition: paradialog.cpp:516
const Cargo & getCargo() const
virtual void buttonpressed(int id)
Definition: edmisc.cpp:415
bool find(const ASCString &name)
void init(int sx, int sy, int dst, int restype, int resmax, int resmin)
Definition: edmisc.cpp:123
Object * checkForObject(const ObjectType *o)
checks if there are objects from the given type on the field and returns them
Definition: mapfield.cpp:648
int ypos
Definition: vehicle.h:124
bool visible
is the building visible? Building can be made invisible, but this feature should be used only in some...
Definition: buildings.h:63
void mousevisible(int an)
Definition: events.cpp:75
void addeingabe(int lid, void *data, int min, int max)
Definition: dlg_box.cpp:833
bool removeObject(const ObjectType *obj, bool force=false, ObjectRemovalStrategy *objectRemovalStrategy=NULL)
removes all objects of the given type from the field
Definition: mapfield.cpp:256
virtual void run(void)
Definition: dlg_box.cpp:3487
int getPlayerCount() const
Definition: gamemap.h:255
void locateItemByID()
Definition: edmisc.cpp:2857
int progress
Definition: research.h:189
int chooseString(const ASCString &title, const vector< ASCString > &entries, int defaultEntry)
displays a dialogbox which lets you choose one of a number of strings.
Definition: dlg_box.cpp:3788
Interface for a small general-purpose stack (not type safe)
GameMap * gamemap
Definition: mapalgorithms.h:30
void showFieldMarking(const CoordinateList &coordinateList)
Definition: edmisc.cpp:788
bool eventKeyDown(const SDL_KeyboardEvent *key)
Definition: edmisc.cpp:1736
int findInheritanceLevel(int id, vector< int > &stack, const ASCString &sourceTechName) const
Definition: research.cpp:130
const int lightgray
Definition: basegfx.h:94
const char * clipboardFileExtension
Definition: clipboard.cpp:36
void showbutton(int id)
Definition: dlg_box.cpp:707
void rectangle(int x1, int y1, int x2, int y2, Uint8 color)
draws a simple rectangl
Definition: basegfx.cpp:297
ASCString name
a short name, for example B-52
Loki::Functor< void, LOKI_TYPELIST_1(const MapCoordinate &) > FieldIterationFunctor
Definition: mapalgorithms.h:43
const char * title
Definition: dlg_box.h:162
void generateTechTree()
Definition: edmisc.cpp:2627
Functions to parse the *.asctxt files.
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
void changeminestrength(void)
Definition: edmisc.cpp:1636
int material
Definition: edmisc.cpp:1497
MapSwitcher mapSwitcher
Definition: edmisc.cpp:2071
void setstartvariables(void)
Definition: edmisc.cpp:681
MapCoordinate3D getNeighbouringFieldCoordinate(const MapCoordinate3D &pos, int direc)
returns the coordinate of the field that is adjecent to the given field in the direction of direc ...
bool resetAfterJobCompletion
void infoMessage(const ASCString &string)
ObjectContainer objects
Definition: mapfield.h:124
int getid(const char *title, int lval, int min, int max)
Definition: dlg_box.cpp:3701
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182
void setweatherall(int weather)
Definition: edmisc.cpp:2518
void setProductionLines(const Production &production)
int efficiencyfuel
currently only used by mining stations: the efficiency of the resource extraction from the ground...
MapField * getField(int x, int y)
Definition: gamemap.h:465
virtual void setpointabs(int x, int y)
Definition: edmisc.cpp:768
int action
Definition: edmisc.cpp:1496
int getExperience_offensive() const
Definition: vehicle.cpp:253