Advanced Strategic Command
edglobal.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 <stdarg.h>
26 #include "global.h"
27 #include "vehicletype.h"
28 #include "buildingtype.h"
29 #include "edmisc.h"
30 #include "loadbi3.h"
31 #include "edgen.h"
32 #include "edselfnt.h"
33 #include "edglobal.h"
34 #include "gameoptions.h"
35 #include "mapdisplay.h"
36 #include "itemrepository.h"
37 #include "clipboard.h"
39 #ifdef WEATHERGENERATOR
40 # include "weatherdialog.h"
41 #endif
42 #include "maped-mainscreen.h"
43 #include "attack.h"
44 #include "mapimageexport.h"
45 #include "viewcalculation.h"
46 #include "statistics.h"
47 #include "spfst-legacy.h"
48 
49 #include "dialogs/unitinfodialog.h"
50 #include "dialogs/editmapparam.h"
51 #include "dialogs/alliancesetup.h"
52 #include "dialogs/playersetup.h"
54 #include "dialogs/admingame.h"
55 #include "dialogs/eventeditor.h"
56 #include "dialogs/newmap.h"
57 #include "dialogs/terraininfo.h"
58 #include "widgets/textrenderer.h"
60 #include "dialogs/fileselector.h"
61 #include "dialogs/importbi3map.h"
63 #include "dialogs/fileselector.h"
65 #include "stack.h"
66 
67 
69  "End MapEdit",
70  "Help",
71  "Goto EditMode",
72  "Select terrain",
73  "Select terrainAll",
74  "Select unit",
75  "Select color",
76  "Select building",
77  "Select object",
78  "Select objectAll",
79  "Select mine",
80  "Select weather",
81  "Setup alliances",
82  "Setup Players",
83  "Toggle ResourceMode",
84  "Change UnitDirection",
85  "Asc-Resource Mode",
86  "Write Map2PCX",
87  "Load map",
88  "Change players",
89  "New map",
90  "Goto PolygonMode",
91  "Rebuild Display",
92  "Open UnitInfo",
93  "View map",
94  "About",
95  "Create resources",
96  "View/Change cargo",
97  "View/Change resources",
98  "Change TerrainDirection",
99  "View/Change Events",
100  "Toggle Fillmode",
101  "Mapgenerator",
102  "Use active field values as selection",
103  "Delete active thing",
104  "Show palette",
105  "View/Change minestrength",
106  "View/Change mapvalues",
107  "View/Change production",
108  "Save map",
109  "View/Change item Values",
110  "Mirror CX-Pos",
111  "Mirror CY-Pos",
112  "Place mine",
113  "Place active thing",
114  "Delete Unit",
115  "Delete building",
116  "Delete selected object",
117  "Delete topmost object",
118  "Delete all objects",
119  "Delete mine",
120  "AboutBox",
121  "Save map as ...",
122  "End PolygonMode",
123  "Smooth coasts",
124  "Import BI-Map",
125  "SEPARATOR",
126  "BI-Resource Mode",
127  "Resize map",
128  "Insert BI map",
129  "Set zoom level",
130  "Move Building",
131  "set weather of whole map",
132  "set map parameters",
133  "terrain info",
134  "set unit filter",
135  "select graphic set",
136  "unitset transformation",
137  "Unitset Information",
138  "switch maps",
139  "transform map",
140  "Edit Map Archival Information",
141  "Display Resource Comparison",
142  "specify unit production",
143  "Paste",
144  "Copy",
145  "Cut",
146  "Save Clipboard",
147  "Load Clipboard",
148  "Set Turn Number",
149  "Show Pipeline Net",
150  "Edit Technologies",
151  "Edit ResearchPoints",
152  "Generate TechTree",
153  "Edit TechAdapter",
154  "Reset Player Data...",
155  "Fill map with resources",
156  "setup weather generation",
157  "Primary action",
158  "Reset Player Data...",
159  "View Player Strength",
160  "Increase Zoom",
161  "Decrease Zoom",
162  "Edit Preferences",
163  "Clear Mineral Resources",
164  "Dump Building definition",
165  "Dump Vehicle definition",
166  "Dump Object definition",
167  "PBP statistics",
168  "Exchange Graphics",
169  "Open Ctrl-key panel",
170  "Close Ctrl-key panel",
171  "Dump all vehicle definitions",
172  "Clear Selection",
173  "Dump all building definitions",
174  "Mirror map",
175  "Copy Area",
176  "Paste Area",
177  "Crash mapeditor",
178  "Test Debug Function",
179  "Unit Guide Dialog",
180  "Run Lua Script",
181  "Run Translation Script",
182  "Dump all Terrain",
183  "Dump all Objects",
184  "show weapon range"
185  };
186 
187 
188 
190 
191 void SelectionHolder::setSelection( const Placeable& component )
192 {
193  delete currentItem;
194  currentItem = component.clone();
195  selectionChanged( currentItem );
196 }
197 
198 void SelectionHolder::setPlayer( int player )
199 {
200  actplayer = player;
201  playerChanged( player );
202  if ( currentItem )
203  selectionChanged( currentItem );
204 }
205 
207 {
208  currentItem = NULL;
209  selectionChanged( NULL );
210 };
211 
212 void SelectionHolder::setWeather( int weather )
213 {
214  currentWeather = weather;
215  if ( currentItem )
216  selectionChanged( currentItem );
217 }
218 
219 
221 {
222  return currentItem;
223 }
224 
226 {
227  if ( fld->vehicle ) {
228  VehicleItem v ( fld->vehicle->typ );
229  actplayer = fld->vehicle->getOwner();
230  setSelection( v );
231  } else
232  if ( fld->building ) {
233  BuildingItem b ( fld->building->typ );
234  actplayer = fld->building->getOwner();
235  setSelection( b );
236  } else
237  if ( !fld->objects.empty() ) {
238  ObjectItem o ( fld->objects.begin()->typ );
239  setSelection( o );
240  } else {
241  TerrainItem t ( fld->typ->terraintype );
242  setSelection( t );
243  }
244 }
245 
246 
247 
248 
249 // � Infomessage
250 
251 int infomessage( char* formatstring, ... )
252 {
253  char stringtooutput[200];
254  // int linenum = 0;
255 
256  memset (stringtooutput, 0, sizeof ( stringtooutput ));
257 
258  va_list paramlist;
259  va_start ( paramlist, formatstring );
260 
261  vsprintf ( stringtooutput, formatstring, paramlist );
262 
263  va_end ( paramlist );
264 
271  activefontsettings.length = agmp->resolutionx - ( 640 - 387);
272 
273  int yy = agmp->resolutiony - ( 480 - 450 );
274  showtext3c( stringtooutput, 37, yy );
275 
277 
278  if ( formatstring == NULL || formatstring[0] == 0 )
279  lastdisplayedmessageticker = 0xffffff;
280  else
282 
283  return ++actdisplayedmessage;
284 }
285 
286 
288 {
289  ASCString filename = getbi3path();
290  appendbackslash( filename );
291  filename += "mis";
292  filename += pathdelimitterstring;
293  filename += "*.dat";
294 
295  int cnt = 0;
296 
297  while ( !exist ( filename )) {
298  filename = editString("enter Battle Isle path", filename );
299  if ( filename.empty() )
300  return "";
301 
302  appendbackslash(filename);
303 
304  CGameOptions::Instance()->BI3directory = filename;
306 
307  filename += "mis";
308  filename += pathdelimitterstring;
309  filename += "*.dat";
310 
311  cnt++;
312  #if CASE_SENSITIVE_FILE_NAMES == 1
313  if (!exist ( filename ) && cnt == 1 )
314  displaymessage("The 'mis' and 'ger' / 'eng' directories must be lower case to import files from them !", 1 );
315  #endif
316  }
317 
318  return getbi3path();
319 }
320 
321 
322 
323 class PlayerColorPanel : public PG_Widget {
324  int openTime;
325  public:
326  PlayerColorPanel() : PG_Widget(NULL, PG_Rect(20,20,320,40))
327  {
328  int width = 30;
329  int gap = 5;
330  for ( int i = 0; i < max(actmap->getPlayerCount(),9); ++i ) {
331  PG_Widget* bar = new ColoredBar( actmap->getPlayer(i).getColor(), this, PG_Rect( gap + i * (width+gap), gap, width, width ));
332  PG_Label* lab = new PG_Label( bar, PG_Rect(5,5,width-10,width-10), ASCString::toString(i));
333  lab->SetFontSize(15);
334  }
335 
336  PG_Application::GetApp()->sigAppIdle.connect( sigc::hide( sigc::mem_fun( *this, &PlayerColorPanel::idler )));
337  }
338 
339  void Show( bool fade = false )
340  {
341  openTime = ticker;
342  PG_Widget::Show(fade);
343  }
344 
345  void Hide( bool fade = false )
346  {
347  openTime = 0;
348  PG_Widget::Hide(fade);
349  }
350 
351 
352  bool eventKeyDown(const SDL_KeyboardEvent* key)
353  {
354  if ( key->keysym.sym >= '0' && key->keysym.sym <= '9' ) {
355  selection.setPlayer( key->keysym.sym - '0' );
356  return true;
357  }
358  Hide();
359  return false;
360  }
361 
362  bool idler()
363  {
364  if ( !IsVisible() )
365  return false;
366 
367  if ( !openTime )
368  return false;
369 
370  if ( ticker > openTime + 200 ) {
371  Hide();
372  return true;
373  } else
374  return false;
375 
376  }
377 
378 };
379 
380 
381 void showPlayerPanel( bool open )
382 {
383  static PlayerColorPanel* pcp = NULL;
384  if ( open && !pcp )
385  pcp = new PlayerColorPanel();
386 
387 
388  if ( !pcp )
389  return;
390 
391  if( open )
392  pcp->Show();
393  else
394  pcp->Hide();
395 }
396 
397 
399 {
400  int mask = 1 << cont->getOwner();
401  for ( ContainerBase::Cargo::const_iterator i = cont->getCargo().begin(); i != cont->getCargo().end(); ++i )
402  if ( *i )
403  mask |= countPlayersBinary( *i );
404  return mask;
405 }
406 
407 int countPlayers( const ContainerBase* cont )
408 {
409  int res = countPlayersBinary( cont );
410  int count = 0;
411  for ( int i = 0; i < cont->getMap()->getPlayerCount(); ++i )
412  if ( res & (1 << i ))
413  ++count;
414  return count;
415 }
416 
418 {
419  if ( countPlayers( cont ) > 1 )
420  infoMessage("Info: this unit/building contains cargo from other players");
421 }
422 
423 // � ExecAction
424 
425 
427 void execaction( int code)
428 {
429  switch(code) {
430  case act_toggleresourcemode : {
431  if ( mainScreenWidget )
432  mainScreenWidget->toggleMapLayer( "resources");
433  displaymap();
434  }
435  break;
436  case act_asc_resource : {
437  actmap->_resourcemode = false;
438  displaymessage ( "ASC Resource mode enabled", 3 );
439  }
440  break;
441  case act_bi_resource : {
442  actmap->_resourcemode = true;
443  displaymessage ( "Battle Isle Resource mode enabled", 3 );
444  }
445  break;
447  break;
448  /*
449  case act_polymode : {
450  getpolygon(&pfpoly);
451  if (pfpoly != NULL ) {
452  tfill = false;
453  polyfieldmode = true;
454 
455  tchangepoly cp;
456 
457  cp.poly = pfpoly;
458  cp.setpolytemps(1);
459  cursor.gotoxy(1,1);
460 
461  displaymap();
462  pdbaroff();
463  }
464  }
465  break;
466  */
467  case act_viewmap :
468  {
469  while (mouseparams.taste != 0)
471  // showmap ();
472  displaymap();
473  }
474  break;
475  case act_changeunitdir : {
476  MapField* pf2 = getactfield();
477  if ( pf2 && pf2->vehicle ) {
478  pf2->vehicle->direction++;
479  if (pf2->vehicle->direction >= sidenum )
480  pf2->vehicle->direction = 0;
481 
482  mapsaved = false;
483  displaymap();
484  }
485  }
486  break;
488  break;
489  case act_createresources : {
490  tputresourcesdlg prd;
491  prd.init();
492  prd.run();
493  prd.done();
494  if ( mainScreenWidget )
495  mainScreenWidget->activateMapLayer( "resources", true);
496 
497  repaintMap();
498 
499  }
500  break;
501  /*
502  case act_fillmode : if ( polyfieldmode == false ) {
503  if (tfill == true) tfill = false;
504  else tfill = true;
505  fillx1 = cursor.posx + actmap->xpos;
506  filly1 = cursor.posy + actmap->ypos;
507  pdbaroff();
508  }
509  break;
510  */
512  break;
513  case act_setactivefieldvals : if ( getactfield() )
514  selection.pickup( getactfield() );
515  break;
516  case act_deletething : {
517  MapField* pf2 = getactfield();
518  mapsaved = false;
519  if (pf2 != NULL) {
520  if ( !removeCurrentItem() ) {
521  if (pf2->vehicle != NULL)
522  delete pf2->vehicle;
523  else
524  if (pf2->building != NULL)
525  delete pf2->building;
526  else
527  if ( !pf2->mines.empty() )
528  pf2->removemine( -1 );
529  else
530  pf2->removeObject( NULL );
531  }
532 
533 
534  mapsaved = false;
535  mapChanged( actmap );
536  }
537  }
538  break;
539  case act_deleteunit : {
540  MapField* pf2 = getactfield();
541  if (pf2 != NULL)
542  if (pf2->vehicle != NULL) {
543  delete pf2->vehicle;
544  mapsaved = false;
545  mapChanged( actmap );
546  }
547  }
548  break;
549  case act_deletebuilding : {
550  MapField* pf2 = getactfield();
551  if (pf2 != NULL)
552  if (pf2->building != NULL) {
553  delete pf2->building;
554  mapsaved = false;
555  mapChanged( actmap );
556  }
557  }
558  break;
559  case act_deleteobject :
560  case act_deletetopmostobject : {
561  MapField* pf2 = getactfield();
562  if ( pf2 ) {
563  mapsaved = false;
564  pf2->removeObject( NULL );
565  mapChanged( actmap );
566  }
567  }
568  break;
569  case act_deleteallobjects : {
570  MapField* pf2 = getactfield();
571  if ( pf2 ) {
572  mapsaved = false;
573  pf2->objects.clear( );
575  mapChanged( actmap );
576  }
577  }
578  break;
579  case act_deletemine : {
580  MapField* pf2 = getactfield();
581  if (pf2 != NULL) {
582  mapsaved = false;
583  pf2->removemine( -1 );
584  mapChanged( actmap );
585  }
586  }
587  break;
589  break;
590  case act_changeunitvals : {
591  MapField* pf2 = getactfield();
592  if ( pf2 ) {
593  if ( pf2->vehicle ) {
595  displaymap();
596  }
597  else if ( pf2->building ) {
599  } /* endif */
600  } /* endif */
601  }
602  break;
603 
604  case act_mirrorcursorx : {
606  md->cursor.goTo( MapCoordinate(actmap->xsize - md->cursor.pos().x, md->cursor.pos().y ) );
607  }
608 
609  break;
610  case act_mirrorcursory : {
612  md->cursor.goTo( MapCoordinate(md->cursor.pos().x, actmap->ysize - md->cursor.pos().y ) );
613  }
614  break;
615 
616 // case act_placemine : placemine();
617 // break;
619  break;
620  /*
621  case act_endpolyfieldmode : {
622  if (polyfieldmode) {
623  polyfieldmode = false;
624  tchangepoly cp;
625 
626  cp.poly = pfpoly;
627  cp.setpolytemps(0);
628 
629  displaymap();
630  pdbaroff();
631  ch = 255;
632  }
633  }
634  break;
635  */
636  case act_about :
637  case act_aboutbox : {
638 
639  ASCString s = "#fontsize=22#Advanced Strategic Command\nMap Editor#fontsize=14#\n";
641 
642  // s += "\n#fontsize=18#Credits#fontsize=14#\n";
643 
644  s += readtextmessage( 1020 );
645 
646  ViewFormattedText vft( "About", s, PG_Rect(-1,-1,450,550));
647  vft.Show();
648  vft.RunModal();
649 
650  /*
651  help(1020);
652  tviewanytext vat;
653  ASCString msg = kgetstartupmessage();
654  vat.init ( "about", msg.c_str() );
655  vat.run();
656  vat.done();
657  */
658  }
659  break;
660  case act_smoothcoasts : {
661  ForestCalculation::smooth ( 6, actmap, NULL );
662  displaymap();
663  }
664  break;
665  case act_resizemap : resizemap();
666  break;
668  break;
669  case act_setactweatherglobal: setweatherall ( selection.getWeather() );
670  displaymap();
671  break;
673  break;
676  break;
677  // case act_setzoom : choosezoomlevel();
678  // break;
680  break;
682  break;
686  } else
688 
689  break;
690 
692  displaymap();
693  updateFieldInfo();
694  break;
696  break;
698  break;
699  /*
700  case act_specifyunitproduction: unitProductionLimitation();
701  break;
702  */
703  case act_pasteFromClipboard: if ( getactfield() && !getactfield()->getContainer() ) {
704  ClipBoard::Instance().place( actmap->getCursor() );
705  mapsaved = false;
706  displaymap();
707  }
708  break;
709  case act_copyToClipboard: if ( getactfield() ) {
710  if ( getactfield()->vehicle ) {
711  ClipBoard::Instance().clear();
713  ClipBoard::Instance().addUnit( getactfield()->vehicle );
714  } else
715  if ( getactfield()->building ) {
716  ClipBoard::Instance().clear();
718  ClipBoard::Instance().addBuilding( getactfield()->building );
719  }
720  }
721  break;
722  case act_cutToClipboard: if ( getactfield() ) {
723  if ( getactfield()->vehicle ) {
724  ClipBoard::Instance().clear();
726  ClipBoard::Instance().addUnit( getactfield()->vehicle );
728  mapsaved = false;
729  } else
730  if ( getactfield()->building ) {
731  ClipBoard::Instance().clear();
733  ClipBoard::Instance().addBuilding( getactfield()->building );
735  mapsaved = false;
736  }
737  }
738  break;
740  break;
741 
743  break;
744  case act_setTurnNumber: actmap->time.set ( getid("Turn",actmap->time.turn(),0,maxint), 0 );
745  break;
747  repaintMap();
748  break;
750  break;
752  break;
754  break;
756  break;
758  break;
760  break;
761 
762  }
763 }
764 
766 void execaction_pg(int code)
767 {
768  switch(code) {
769 #ifdef WEATHERGENERATOR
771  break;
772 #endif
776  break;
777  case act_selbodentypAll : mainScreenWidget->selectTerrainList();
778  break;
779  case act_selunit : mainScreenWidget->selectVehicle();
780  break;
781  case act_selbuilding : mainScreenWidget->selectBuilding();
782  break;
783  case act_selobject : mainScreenWidget->selectObject();
784  break;
785  case act_selobjectAll: mainScreenWidget->selectObjectList();
786  /* if ( mapSwitcher.getDefaultAction() == MapSwitcher::select )
787  execaction ( act_setactivefieldvals );
788  execaction( act_switchmaps);
789  */
790  break;
791  case act_selmine : mainScreenWidget->selectMine();
792  break;
793  case act_unitinfo : unitInfoDialog();
794  break;
796  break;
797  case act_setupalliances : {
799  setupalliances( actmap, &dass, true );
800  }
801  break;
802  case act_setupplayers : setupPlayers( actmap, true );
803  break;
804  case act_loadmap : {
805  if (mapsaved == false )
806  if (choice_dlg("Map not saved ! Save now ?","~y~es","~n~o") == 1)
807  k_savemap(false);
808 
809  try {
810  k_loadmap();
811  }
812  catch (ASCmsgException message ) {
813  errorMessage( "Could not load map:\n" + message.getMessage());
814  }
815  catch ( ... ) {
816  errorMessage ( "error loading file" );
817  }
818  displaymap();
819  }
820  break;
821  case act_savemap : k_savemap(false);
822  break;
823  case act_savemapas : k_savemap(true);
824  break;
825  case act_maptopcx : {
826  bool view = choice_dlg("Include view ?","~n~o", "~y~es") == 2;
827  if ( view )
828  computeview( actmap );
829  writemaptopcx ( actmap, view );
830  }
831  break;
832  case act_end : {
835  else
836  if (choice_dlg("Do you really want to quit ?","~y~es","~n~o") == 1) {
838  }
839  }
840  break;
841  case act_changecargo :
842  if ( getactfield() && getactfield()->getContainer() )
843  cargoEditor( getactfield()->getContainer() );
844 
845  break;
847  displaymap();
848  break;
849  case act_changeproduction : if ( getactfield() && getactfield()->getContainer() ) {
850  if ( getactfield()->getContainer()->baseType->hasFunction( ContainerBaseType::InternalVehicleProduction ))
852  else
853  warningMessage("this unit/building has no production capabilities");
854  }
855  break;
857  // showallchoices();
858  break;
860  break;
861  case act_increase_zoom:
864  viewChanged();
865  repaintMap();
866  }
867  break;
868  case act_decrease_zoom:
871  viewChanged();
872  repaintMap();
873  }
874  break;
875  case act_editpreferences:
876  editGameOptions( false );
877  break;
878 
879  case act_events : eventEditor( actmap );
880  break;
882  break;
884  break;
885  case act_newmap : newmap();
886  break;
887  case act_clearresources: {
888  for ( int y = 0; y < actmap->ysize; ++y)
889  for ( int x = 0; x < actmap->xsize; ++x ) {
890  actmap->getField(x,y)->fuel = 0;
891  actmap->getField(x,y)->material = 0;
892  }
893  repaintMap();
894  }
895  case act_dumpBuilding:
896  if ( getactfield() && getactfield()->building ) {
897  ASCString filename = selectFile( "*.dump", false );
898  if ( !filename.empty () ) {
899  tn_file_buf_stream stream ( filename, tnstream::writing );
900  PropertyWritingContainer pc ( "BuildingDump", stream );
901  actmap->getbuildingtype_byid(getactfield()->building->typ->id)->runTextIO( pc );
902  }
903  } else
904  errorMessage("no building selected");
905  break;
906  case act_dumpVehicle:
907  if ( getactfield() && getactfield()->vehicle ) {
908  ASCString filename = selectFile( "*.dump", false );
909  if ( !filename.empty () ) {
910  tn_file_buf_stream stream ( filename, tnstream::writing );
911  PropertyWritingContainer pc ( "VehicleDump", stream );
912  actmap->getvehicletype_byid(getactfield()->vehicle->typ->id)->runTextIO( pc );
913  }
914  } else
915  errorMessage("no vehicle selected");
916  break;
917  case act_dumpObject:
918  if ( getactfield() && !getactfield()->objects.empty() ) {
919  ASCString filename = selectFile( "*.dump", false );
920  if ( !filename.empty () ) {
921  tn_file_buf_stream stream ( filename, tnstream::writing );
922  PropertyWritingContainer pc ( "ObjectDump", stream );
923  actmap->getobjecttype_byid( getactfield()->objects.front().typ->id)->runTextIO( pc );
924  }
925  } else
926  errorMessage("no object selected");
927  break;
928  case act_help : help(1000);
929  break;
931  break;
933  break;
935  break;
937  break;
939  StatusMessageWindowHolder smw = MessagingHub::Instance().infoMessageWindow( "dumping all units" );
940  for ( int i = 0; i < vehicleTypeRepository.getNum(); ++i ) {
941  VehicleType* veh = vehicleTypeRepository.getObject_byPos( i );
942  tn_file_buf_stream stream ( "Vehicle" + ASCString::toString( i ) + ".dump", tnstream::writing );
943  PropertyWritingContainer pc ( "VehicleDump", stream );
944  veh->runTextIO( pc );
945  }
946  };
947  break;
948  case act_dumpAllBuildings: {
949  StatusMessageWindowHolder smw = MessagingHub::Instance().infoMessageWindow( "dumping all buildings" );
950  for ( int i = 0; i < buildingTypeRepository.getNum(); ++i ) {
951  BuildingType* bld = buildingTypeRepository.getObject_byPos( i );
952  tn_file_buf_stream stream ( "Building" + ASCString::toString( i ) + ".dump", tnstream::writing );
953  PropertyWritingContainer pc ( "BuildingDump", stream );
954  bld->runTextIO( pc );
955  }
956  };
957  break;
958  case act_dumpAllTerrain: {
959  StatusMessageWindowHolder smw = MessagingHub::Instance().infoMessageWindow( "dumping all terrain" );
960  for ( int i = 0; i < terrainTypeRepository.getNum(); ++i ) {
961  TerrainType* bld = terrainTypeRepository.getObject_byPos( i );
962  tn_file_buf_stream stream ( "terrain" + ASCString::toString( i ) + ".dump", tnstream::writing );
963  PropertyWritingContainer pc ( "terrainDump", stream );
964  bld->runTextIO( pc );
965  }
966  };
967  break;
968  case act_dumpAllObjects: {
969  ASCString text = "dumping all objects";
970  StatusMessageWindowHolder smw = MessagingHub::Instance().infoMessageWindow( text );
971  for ( int i = 0; i < objectTypeRepository.getNum(); ++i ) {
972  ObjectType* bld = objectTypeRepository.getObject_byPos( i );
973  tn_file_buf_stream stream ( "object" + ASCString::toString( i ) + ".dump", tnstream::writing );
974  PropertyWritingContainer pc ( "objectDump", stream );
975  bld->runTextIO( pc );
976  smw.SetText( text + ": " + ASCString::toString( int(i * 100 / objectTypeRepository.getNum() )) + "%" );
977  }
978  };
979  break;
980 
981  case act_clearSelection: selection.clear();
982  break;
984  break;
985  case act_mirrorMap: mirrorMap();
986  break;
987  case act_copyArea: copyArea();
988  break;
989  case act_pasteArea: pasteArea();
990  break;
991  case asc_nullPointerCrash: {
992  char* p = NULL;
993  *p = 1;
994  }
995  break;
997  break;
998  case act_import_bi_map :
999  if (mapsaved == false )
1000  if (choice_dlg("Map not saved ! Save now ?","~y~es","~n~o") == 1)
1001  k_savemap(false);
1002  importBI3Map( actmap );
1003  displaymap();
1004  break;
1005  case act_insert_bi_map :
1006  importBI3Map( actmap, true );
1007  displaymap();
1008  break;
1009  case act_runLuaScript:
1010  selectAndRunLuaScript( "*.lua" );
1011  repaintMap();
1012  break;
1014  selectAndRunLuaScript( "*.map.*" );
1015  repaintMap();
1016  break;
1017  case act_showweapnrange:
1019  displaymap();
1020  break;
1021 
1022 
1023  };
1024 }
1025 
1026 void execaction_ev(int code)
1027 {
1028  execaction_pg(code);
1029  execaction(code);
1030 }
void writemaptopcx(GameMap *gamemap, bool addview)
TerrainType::Weather * typ
the terraintype of the field
Definition: mapfield.h:38
void copyArea()
Definition: edmisc.cpp:3735
void displaymap()
Definition: spfst.cpp:58
tfontsettings activefontsettings
Definition: newfont.cpp:51
Uint8 markcolor
Definition: newfont.h:172
The type of a field.
Definition: terraintype.h:75
const Placeable * getSelection()
Definition: edglobal.cpp:220
Uint8 background
Definition: newfont.h:171
sigc::signal< void, GameMap * > mapChanged
Definition: spfst.cpp:52
ItemRepositoryLoader< ObjectType > objectTypeRepository("objecttype")
Player & getPlayer(PlayerID p)
Definition: gamemap.h:257
MapCoordinate & getCursor()
Definition: gamemap.cpp:933
sigc::signal< void > filtersChangedSignal
Definition: edselfnt.cpp:42
int xsize
the size of the map
Definition: gamemap.h:201
void placeCurrentItem()
Definition: edmisc.cpp:70
int computeview(GameMap *gamemap, int player_fieldcount_mask, bool disableShareView, const Context *context)
completely computes the view
const BuildingType * typ
Definition: buildings.h:48
void unitsettransformation(void)
Definition: edmisc.cpp:1996
ASCString getbi3path(void)
returns the path to the BI3 installation
Definition: loadbi3.cpp:129
#define npush(a)
Definition: stack.h:53
Vehicle * vehicle
Definition: mapfield.h:89
void toggleMapLayer(const ASCString &name)
void execaction(int code)
this executes all functions that use legacy Eventhandling
Definition: edglobal.cpp:427
The clipboard for ASC.
ASCString getbipath(void)
Definition: edglobal.cpp:287
Action getDefaultAction()
Definition: edmisc.cpp:2062
void execaction_pg(int code)
this executes all functions that use Paragui Eventhandling
Definition: edglobal.cpp:766
void init(void)
Definition: edmisc.cpp:146
long int lastdisplayedmessageticker
Definition: dlg_box.cpp:98
ASCString getVersionAndCompilation()
Version: 1.2.3 ; compiled : ...
Definition: strtmesg.cpp:63
ASCString readtextmessage(int id)
returns the message with the given ID from the message system.
Definition: dlg_box.cpp:3048
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
Uint8 material
Definition: mapfield.h:54
TerrainType * terraintype
pointer to the outer structure
Definition: terraintype.h:128
MapCoordinate & pos()
int countPlayersBinary(const ContainerBase *cont)
Definition: edglobal.cpp:398
bool removeCurrentItem()
Definition: edmisc.cpp:82
int turn() const
Definition: typen.h:181
int getOwner() const
returns the number of the player this vehicle/building belongs to
void saveClipboard()
Definition: edmisc.cpp:2508
void toggleMapLayer(const ASCString &name)
void bar(int x1, int y1, int x2, int y2, Uint8 color)
paints a colored bar
Definition: basegfx.cpp:1239
int resolutiony
the number of visible pixels in y direction
Definition: basegfx.h:53
sigc::signal< void, const Placeable * > selectionChanged
Definition: edglobal.h:174
void k_loadmap(void)
Definition: edmisc.cpp:629
void changeUnitPropertyDialog(Vehicle *ae)
void warningMessage(const ASCString &str)
pfont smallarial
Definition: spfst-legacy.h:28
void selectunitsetfilter(void)
Definition: edmisc.cpp:1766
void editTechAdapter(Player &player)
sigc::signal< void > repaintMap
}@
Definition: spfst.cpp:45
void showPlayerPanel(bool open)
Definition: edglobal.cpp:381
Uint8 justify
Definition: newfont.h:176
int mapgenerator(void)
Definition: edgen.cpp:858
int getWeather()
Definition: edglobal.h:167
ItemRepositoryLoader< BuildingType > buildingTypeRepository("buildingtype")
void k_savemap(bool saveas)
Definition: edmisc.cpp:607
#define lefttext
Definition: newfont.h:184
ContainerBase * getContainer()
returns a pointer to the ContainerBase of the field or NULL if there is none
Definition: mapfield.cpp:331
Global platform dependant definitions. This file just branches to the platform specific files in thei...
void pickup(MapField *fld)
Definition: edglobal.cpp:225
a single field of the map
Definition: mapfield.h:26
tgraphmodeparameters * agmp
Definition: basegfx.cpp:39
void editArchivalInformation()
Definition: edmisc.cpp:2434
void activateMapLayer(const ASCString &name, bool active)
struct MapDisplayPG::Cursor cursor
void resourceComparison()
displays a textmessage comparing the resources of all players
Definition: edmisc.cpp:2442
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 setmapparameters(GameMap *gamemap)
Uint8 taste
Definition: events.h:95
void changebuildingvalues(Building &b)
Definition: edmisc.cpp:1141
void setSelection(const Placeable &component)
Definition: edglobal.cpp:191
const int sidenum
the number of sides that a field has; is now fixed at 6;
Definition: typen.h:438
void removemine(int num)
removes a mine
Definition: mapfield.cpp:463
ASCString BI3directory
Definition: gameoptions.h:223
void newmap(void)
Definition: edmisc.cpp:827
The class describing properties that are common to all vehicles of a certain kind.
Definition: vehicletype.h:177
pfont font
Definition: newfont.h:169
static ASCString toString(int i)
converts the parameter to a String
Definition: ascstring.cpp:193
ASC_PG_App & getPGApplication()
Definition: paradialog.cpp:294
Schriften schriften
Definition: spfst.cpp:66
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 setChanged(bool flag=true)
Definition: gameoptions.h:272
ItemRepositoryLoader< VehicleType > vehicleTypeRepository("vehicletype")
void setupPlayers(GameMap *actmap, bool supervisor)
void resourcePlacementDialog()
ItemRepositoryLoader< TerrainType > terrainTypeRepository("terraintype")
void readClipboard()
Definition: edmisc.cpp:2485
Uint8 fuel
mineral resources on this field.
Definition: mapfield.h:54
void Quit()
Definition: paradialog.cpp:223
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
void editGameOptions(bool mainApp)
bool adminGame(GameMap *actmap, TurnSkipper *turnSkipper)
Definition: admingame.cpp:387
void displaymessage(const char *formatstring, int num,...)
displays a dialog box with a message
Definition: dlg_box.cpp:1849
Interface for all the fighting routines of ASC.
void viewUnitSetinfo(void)
Definition: dialog.cpp:1367
The interface for the buildingtype class.
void movebuilding(void)
Definition: edmisc.cpp:1649
Uint16 length
Definition: newfont.h:174
ASCString editString(const ASCString &title, const ASCString &defaultValue)
Definition: dlg_box.cpp:3894
int _resourcemode
how are Resources handled on this map 0= "ASC mode": complex system with mineral resources etc 1= "BI...
Definition: gamemap.h:250
void runTextIO(PropertyContainer &pc)
reads or writes the objecttype to the text stream pc
void calculateallobjects(GameMap *actmap)
recalculates the connection (like road interconnections) of all objects on the map ...
Definition: spfst.cpp:562
const ASCString & getMessage(void) const
Definition: errors.h:42
void runTextIO(PropertyContainer &pc)
registers the properties of this item for loading/writing into asctxt files
sigc::signal< void > updateFieldInfo
Definition: spfst.cpp:47
DI_Color getColor() const
Definition: player.cpp:249
void playerchange(void)
Definition: edmisc.cpp:485
int releasetimeslice(void)
Definition: events.cpp:209
VehicleType * getvehicletype_byid(int id)
Definition: gamemap.cpp:1794
BuildingType * getbuildingtype_byid(int id)
Definition: gamemap.cpp:1805
void resizemap(void)
a dialog box that lets a user resize the active map. Should only be used in the mapeditor ...
Definition: dialog.cpp:1256
void Show(bool fade=false)
Definition: edglobal.cpp:339
void mirrorMap()
Definition: edmisc.cpp:3235
void showtext3c(const char *txt, int xpos, int ypos)
Definition: newfont.cpp:337
MapDisplayPG * getMapDisplay()
void errorMessage(const ASCString &string)
const int red
Definition: basegfx.h:91
static CGameOptions * Instance()
returns the only Instance
Definition: gameoptions.cpp:38
#define npop(a)
Definition: stack.h:54
void exchangeGraphics()
const char * pathdelimitterstring
Definition: unix/fileio.cpp:24
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
void appendbackslash(char *string)
Definition: basestrm.cpp:2596
MineContainer mines
Definition: mapfield.h:117
ASCString selectFile(const ASCString &ext, bool load, bool overwriteMessage)
void help(int id)
displays a dialogbog with the given help topic
Definition: dlg_box.cpp:3286
SelectionHolder selection
Definition: edglobal.cpp:189
void infoMessageClipboardPlayers(const ContainerBase *cont)
Definition: edglobal.cpp:417
void viewterraininfo(GameMap *gamemap, const MapCoordinate &pos, bool fullVisibility)
Definition: terraininfo.cpp:34
void weatherConfigurationDialog()
void testDebugFunction()
Definition: edmisc.cpp:3779
void run(void)
Definition: edmisc.cpp:206
const VehicleType * typ
Definition: vehicle.h:83
void importBI3Map(GameMap *gamemap, bool insert)
Uint8 direction
the direction in which the unit is facing
Definition: vehicle.h:121
Building * building
Definition: mapfield.h:102
void SetText(const ASCString &text)
void goTo(const MapCoordinate &position)
void editProduction(ContainerBase *container)
Definition: edselfnt.cpp:556
void runTextIO(PropertyContainer &pc)
registers the properties of this item for loading/writing into asctxt files
void changeZoom(int delta)
Definition: mapdisplay.h:190
ASC_MainScreenWidget * mainScreenWidget
void setPlayer(int player)
Definition: edglobal.cpp:198
void selectgraphicset(void)
Definition: dialog.cpp:2151
int resolutionx
the number of visible pixels in x direction
Definition: basegfx.h:52
MainScreenWidget * getMainScreenWidget()
sigc::signal< void, int > playerChanged
Definition: edglobal.h:164
#define maxint
Definition: typen.h:462
GameMap * actmap
Definition: spfst.cpp:64
int actdisplayedmessage
Definition: dlg_box.cpp:97
void editResearchPoints()
Definition: edmisc.cpp:2605
const int execactionscount
Definition: edglobal.h:30
GameMap * getMap() const
void transformMap()
replaces the terrain and the objects on a map according to a translation table
Definition: edmisc.cpp:2082
void smooth(int what, GameMap *gamemap, ObjectType *woodObj)
automatically adjusting the pictures of woods and coasts to form coherent structures ...
Definition: objecttype.cpp:748
The parent class of Vehicle and Building; The name Container originates from Battle Isle...
Definition: containerbase.h:40
bool exist(const ASCString &s)
does a file s exist (wildcards allowed)
Definition: basestrm.cpp:2444
const T & max(const T &a, const T &b, const T &c)
Definition: misc.h:97
void eventEditor(GameMap *gamemap)
void Hide(bool fade=false)
Definition: edglobal.cpp:345
void setWeather(int weather)
Definition: edglobal.cpp:212
int infomessage(char *formatstring,...)
Definition: edglobal.cpp:251
void pasteArea()
Definition: edmisc.cpp:3745
const char * execactionnames[execactionscount]
Definition: edglobal.cpp:68
void changeresource(void)
Definition: edmisc.cpp:1561
void showWeaponRange(GameMap *gamemap, const MapCoordinate &pos)
void selectAndRunLuaScript(const ASCString &filenamewildcard)
Definition: edmisc.cpp:3756
void editMap(GameMap *map)
Definition: newmap.cpp:190
ObjectType * getobjecttype_byid(int id)
Definition: gamemap.cpp:1783
int choice_dlg(const ASCString &title, const ASCString &leftButton, const ASCString &rightButton)
Definition: dialog.cpp:616
void editResearch()
Definition: edmisc.cpp:2537
const Cargo & getCargo() const
volatile tmousesettings mouseparams
Definition: events.cpp:35
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
int getPlayerCount() const
Definition: gamemap.h:255
void locateItemByID()
Definition: edmisc.cpp:2857
void unitInfoDialog(const VehicleType *vt)
bool eventKeyDown(const SDL_KeyboardEvent *key)
Definition: edglobal.cpp:352
void cargoEditor(ContainerBase *container)
Interface for a small general-purpose stack (not type safe)
void runTextIO(PropertyContainer &pc)
registers the properties of this item for loading/writing into asctxt files
void pbpplayerstatistics(GameMap *gamemap)
Definition: statistics.cpp:179
const int lightgray
Definition: basegfx.h:94
void unitGuideWindow(int tabs)
int countPlayers(const ContainerBase *cont)
Definition: edglobal.cpp:407
bool setupalliances(GameMap *actmap, AllianceSetupWidget::ApplyStrategy *strategy, bool supervisor)
runs the Alliance-Setup dialog.
void generateTechTree()
Definition: edmisc.cpp:2627
GameTime time
the time in the game, mesured in a turns and moves
Definition: gamemap.h:235
void changeminestrength(void)
Definition: edmisc.cpp:1636
MapSwitcher mapSwitcher
Definition: edmisc.cpp:2071
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
void setweatherall(int weather)
Definition: edmisc.cpp:2518
volatile int ticker
Definition: events.cpp:234
void set(int turn, int move)
Definition: typen.h:183
MapField * getField(int x, int y)
Definition: gamemap.h:465
virtual Placeable * clone() const =0