00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <stdarg.h>
00026 #include "global.h"
00027 #include "vehicletype.h"
00028 #include "buildingtype.h"
00029 #include "edmisc.h"
00030 #include "loadbi3.h"
00031 #include "edgen.h"
00032 #include "edselfnt.h"
00033 #include "edglobal.h"
00034 #include "gameoptions.h"
00035 #include "mapdisplay.h"
00036 #include "itemrepository.h"
00037 #include "clipboard.h"
00038 #include "resourceplacementdialog.h"
00039 #ifdef WEATHERGENERATOR
00040 # include "weatherdialog.h"
00041 #endif
00042 #include "maped-mainscreen.h"
00043 #include "attack.h"
00044 #include "mapimageexport.h"
00045 #include "viewcalculation.h"
00046 #include "statistics.h"
00047 #include "spfst-legacy.h"
00048
00049 #include "dialogs/unitinfodialog.h"
00050 #include "dialogs/editmapparam.h"
00051 #include "dialogs/alliancesetup.h"
00052 #include "dialogs/playersetup.h"
00053 #include "dialogs/editgameoptions.h"
00054 #include "dialogs/admingame.h"
00055 #include "dialogs/eventeditor.h"
00056 #include "dialogs/newmap.h"
00057 #include "dialogs/terraininfo.h"
00058 #include "widgets/textrenderer.h"
00059 #include "dialogs/exchangegraphics.h"
00060 #include "dialogs/fileselector.h"
00061 #include "dialogs/importbi3map.h"
00062 #include "dialogs/unitguidedialog.h"
00063 #include "dialogs/fileselector.h"
00064 #include "stack.h"
00065
00066
00067 const char* execactionnames[execactionscount] = {
00068 "End MapEdit",
00069 "Help",
00070 "Goto EditMode",
00071 "Select terrain",
00072 "Select terrainAll",
00073 "Select unit",
00074 "Select color",
00075 "Select building",
00076 "Select object",
00077 "Select objectAll",
00078 "Select mine",
00079 "Select weather",
00080 "Setup alliances",
00081 "Setup Players",
00082 "Toggle ResourceMode",
00083 "Change UnitDirection",
00084 "Asc-Resource Mode",
00085 "Write Map2PCX",
00086 "Load map",
00087 "Change players",
00088 "New map",
00089 "Goto PolygonMode",
00090 "Rebuild Display",
00091 "Open UnitInfo",
00092 "View map",
00093 "About",
00094 "Create resources",
00095 "View/Change cargo",
00096 "View/Change resources",
00097 "Change TerrainDirection",
00098 "View/Change Events",
00099 "Toggle Fillmode",
00100 "Mapgenerator",
00101 "Use active field values as selection",
00102 "Delete active thing",
00103 "Show palette",
00104 "View/Change minestrength",
00105 "View/Change mapvalues",
00106 "View/Change production",
00107 "Save map",
00108 "View/Change item Values",
00109 "Mirror CX-Pos",
00110 "Mirror CY-Pos",
00111 "Place mine",
00112 "Place active thing",
00113 "Delete Unit",
00114 "Delete building",
00115 "Delete selected object",
00116 "Delete topmost object",
00117 "Delete all objects",
00118 "Delete mine",
00119 "AboutBox",
00120 "Save map as ...",
00121 "End PolygonMode",
00122 "Smooth coasts",
00123 "Import BI-Map",
00124 "SEPERATOR",
00125 "BI-Resource Mode",
00126 "Resize map",
00127 "Insert BI map",
00128 "Set zoom level",
00129 "Move Building",
00130 "set weather of whole map",
00131 "set map parameters",
00132 "terrain info",
00133 "set unit filter",
00134 "select graphic set",
00135 "unitset transformation",
00136 "Unitset Information",
00137 "switch maps",
00138 "transform map",
00139 "Edit Map Archival Information",
00140 "Display Resource Comparison",
00141 "specify unit production",
00142 "Paste",
00143 "Copy",
00144 "Cut",
00145 "Save Clipboard",
00146 "Load Clipboard",
00147 "Set Turn Number",
00148 "Show Pipeline Net",
00149 "Edit Technologies",
00150 "Edit ResearchPoints",
00151 "Generate TechTree",
00152 "Edit TechAdapter",
00153 "Reset Player Data...",
00154 "Fill map with resources",
00155 "setup weather generation",
00156 "Primary action",
00157 "Reset Player Data...",
00158 "View Player Strength",
00159 "Increase Zoom",
00160 "Decrease Zoom",
00161 "Edit Preferences",
00162 "Clear Mineral Resources",
00163 "Dump Building definition",
00164 "Dump Vehicle definition",
00165 "Dump Object definition",
00166 "PBP statistics",
00167 "Exchange Graphics",
00168 "Open Ctrl-key panel",
00169 "Close Ctrl-key panel",
00170 "Dump all vehicle definitions",
00171 "Clear Selection",
00172 "Dump all building definitions",
00173 "Mirror map",
00174 "Copy Area",
00175 "Paste Area",
00176 "Crash mapeditor",
00177 "Test Debug Function",
00178 "Unit Guide Dialog",
00179 "Run Lua Script",
00180 "Run Translation Script",
00181 "Dump all Terrain",
00182 "Dump all Objects",
00183 "show weapon range"
00184 };
00185
00186
00187
00188 SelectionHolder selection;
00189
00190 void SelectionHolder::setSelection( const Placeable& component )
00191 {
00192 delete currentItem;
00193 currentItem = component.clone();
00194 selectionChanged( currentItem );
00195 }
00196
00197 void SelectionHolder::setPlayer( int player )
00198 {
00199 actplayer = player;
00200 playerChanged( player );
00201 if ( currentItem )
00202 selectionChanged( currentItem );
00203 }
00204
00205 void SelectionHolder::clear()
00206 {
00207 currentItem = NULL;
00208 selectionChanged( NULL );
00209 };
00210
00211 void SelectionHolder::setWeather( int weather )
00212 {
00213 currentWeather = weather;
00214 if ( currentItem )
00215 selectionChanged( currentItem );
00216 }
00217
00218
00219 const Placeable* SelectionHolder::getSelection()
00220 {
00221 return currentItem;
00222 }
00223
00224 void SelectionHolder::pickup ( MapField* fld )
00225 {
00226 if ( fld->vehicle ) {
00227 VehicleItem v ( fld->vehicle->typ );
00228 actplayer = fld->vehicle->getOwner();
00229 setSelection( v );
00230 } else
00231 if ( fld->building ) {
00232 BuildingItem b ( fld->building->typ );
00233 actplayer = fld->building->getOwner();
00234 setSelection( b );
00235 } else
00236 if ( !fld->objects.empty() ) {
00237 ObjectItem o ( fld->objects.begin()->typ );
00238 setSelection( o );
00239 } else {
00240 TerrainItem t ( fld->typ->terraintype );
00241 setSelection( t );
00242 }
00243 }
00244
00245
00246
00247
00248
00249
00250 int infomessage( char* formatstring, ... )
00251 {
00252 char stringtooutput[200];
00253 char* b;
00254 char* c = new char[200];
00255
00256
00257 memset (stringtooutput, 0, sizeof ( stringtooutput ));
00258
00259 b = stringtooutput;
00260
00261 va_list paramlist;
00262 va_start ( paramlist, formatstring );
00263
00264 vsprintf ( stringtooutput, formatstring, paramlist );
00265
00266 va_end ( paramlist );
00267
00268 npush ( activefontsettings );
00269 activefontsettings.justify = lefttext;
00270 activefontsettings.font = schriften.smallarial;
00271 activefontsettings.color = lightgray;
00272 activefontsettings.markcolor = red;
00273 activefontsettings.background = 0;
00274 activefontsettings.length = agmp->resolutionx - ( 640 - 387);
00275
00276 int yy = agmp->resolutiony - ( 480 - 450 );
00277 showtext3c( stringtooutput, 37, yy );
00278
00279 npop( activefontsettings );
00280
00281 if ( formatstring == NULL || formatstring[0] == 0 )
00282 lastdisplayedmessageticker = 0xffffff;
00283 else
00284 lastdisplayedmessageticker = ticker;
00285
00286
00287 delete ( c );
00288
00289 return ++actdisplayedmessage;
00290 }
00291
00292
00293 ASCString getbipath ( void )
00294 {
00295 ASCString filename = getbi3path();
00296 appendbackslash( filename );
00297 filename += "mis";
00298 filename += pathdelimitterstring;
00299 filename += "*.dat";
00300
00301 int cnt = 0;
00302
00303 while ( !exist ( filename )) {
00304 filename = editString("enter Battle Isle path", filename );
00305 if ( filename.empty() )
00306 return "";
00307
00308 appendbackslash(filename);
00309
00310 CGameOptions::Instance()->BI3directory = filename;
00311 CGameOptions::Instance()->setChanged ( 1 );
00312
00313 filename += "mis";
00314 filename += pathdelimitterstring;
00315 filename += "*.dat";
00316
00317 cnt++;
00318 #if CASE_SENSITIVE_FILE_NAMES == 1
00319 if (!exist ( filename ) && cnt == 1 )
00320 displaymessage("The 'mis' and 'ger' / 'eng' directories must be lower case to import files from them !", 1 );
00321 #endif
00322 }
00323
00324 return getbi3path();
00325 }
00326
00327
00328
00329 class PlayerColorPanel : public PG_Widget {
00330 int openTime;
00331 public:
00332 PlayerColorPanel() : PG_Widget(NULL, PG_Rect(20,20,320,40))
00333 {
00334 int width = 30;
00335 int gap = 5;
00336 for ( int i = 0; i < max(actmap->getPlayerCount(),9); ++i ) {
00337 PG_Widget* bar = new ColoredBar( actmap->getPlayer(i).getColor(), this, PG_Rect( gap + i * (width+gap), gap, width, width ));
00338 PG_Label* lab = new PG_Label( bar, PG_Rect(5,5,width-10,width-10), ASCString::toString(i));
00339 lab->SetFontSize(15);
00340 }
00341
00342 PG_Application::GetApp()->sigAppIdle.connect( SigC::slot( *this, &PlayerColorPanel::idler ));
00343 }
00344
00345 void Show( bool fade = false )
00346 {
00347 openTime = ticker;
00348 PG_Widget::Show(fade);
00349 }
00350
00351 void Hide( bool fade = false )
00352 {
00353 openTime = 0;
00354 PG_Widget::Hide(fade);
00355 }
00356
00357
00358 bool eventKeyDown(const SDL_KeyboardEvent* key)
00359 {
00360 if ( key->keysym.sym >= '0' && key->keysym.sym <= '9' ) {
00361 selection.setPlayer( key->keysym.sym - '0' );
00362 return true;
00363 }
00364 Hide();
00365 return false;
00366 }
00367
00368 bool idler()
00369 {
00370 if ( !IsVisible() )
00371 return false;
00372
00373 if ( !openTime )
00374 return false;
00375
00376 if ( ticker > openTime + 200 ) {
00377 Hide();
00378 return true;
00379 } else
00380 return false;
00381
00382 }
00383
00384 };
00385
00386
00387 void showPlayerPanel( bool open )
00388 {
00389 static PlayerColorPanel* pcp = NULL;
00390 if ( open && !pcp )
00391 pcp = new PlayerColorPanel();
00392
00393
00394 if ( !pcp )
00395 return;
00396
00397 if( open )
00398 pcp->Show();
00399 else
00400 pcp->Hide();
00401 }
00402
00403
00404 int countPlayersBinary( const ContainerBase* cont )
00405 {
00406 int mask = 1 << cont->getOwner();
00407 for ( ContainerBase::Cargo::const_iterator i = cont->getCargo().begin(); i != cont->getCargo().end(); ++i )
00408 if ( *i )
00409 mask |= countPlayersBinary( *i );
00410 return mask;
00411 }
00412
00413 int countPlayers( const ContainerBase* cont )
00414 {
00415 int res = countPlayersBinary( cont );
00416 int count = 0;
00417 for ( int i = 0; i < cont->getMap()->getPlayerCount(); ++i )
00418 if ( res & (1 << i ))
00419 ++count;
00420 return count;
00421 }
00422
00423 void infoMessageClipboardPlayers(const ContainerBase* cont )
00424 {
00425 if ( countPlayers( cont ) > 1 )
00426 infoMessage("Info: this unit/building contains cargo from other players");
00427 }
00428
00429
00430
00431
00433 void execaction( int code)
00434 {
00435 switch(code) {
00436 case act_toggleresourcemode : {
00437 if ( mainScreenWidget )
00438 mainScreenWidget->toggleMapLayer( "resources");
00439 displaymap();
00440 }
00441 break;
00442 case act_asc_resource : {
00443 actmap->_resourcemode = false;
00444 displaymessage ( "ASC Resource mode enabled", 3 );
00445 }
00446 break;
00447 case act_bi_resource : {
00448 actmap->_resourcemode = true;
00449 displaymessage ( "Battle Isle Resource mode enabled", 3 );
00450 }
00451 break;
00452 case act_changeplayers : playerchange();
00453 break;
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473 case act_viewmap :
00474 {
00475 while (mouseparams.taste != 0)
00476 releasetimeslice();
00477
00478 displaymap();
00479 }
00480 break;
00481 case act_changeunitdir : {
00482 MapField* pf2 = getactfield();
00483 if ( pf2 && pf2->vehicle ) {
00484 pf2->vehicle->direction++;
00485 if (pf2->vehicle->direction >= sidenum )
00486 pf2->vehicle->direction = 0;
00487
00488 mapsaved = false;
00489 displaymap();
00490 }
00491 }
00492 break;
00493 case act_changeresources : changeresource();
00494 break;
00495 case act_createresources : {
00496 tputresourcesdlg prd;
00497 prd.init();
00498 prd.run();
00499 prd.done();
00500 if ( mainScreenWidget )
00501 mainScreenWidget->activateMapLayer( "resources", true);
00502
00503 repaintMap();
00504
00505 }
00506 break;
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517 case act_mapgenerator : mapgenerator();
00518 break;
00519 case act_setactivefieldvals : if ( getactfield() )
00520 selection.pickup( getactfield() );
00521 break;
00522 case act_deletething : {
00523 MapField* pf2 = getactfield();
00524 mapsaved = false;
00525 if (pf2 != NULL) {
00526 if ( !removeCurrentItem() ) {
00527 if (pf2->vehicle != NULL)
00528 delete pf2->vehicle;
00529 else
00530 if (pf2->building != NULL)
00531 delete pf2->building;
00532 else
00533 if ( !pf2->mines.empty() )
00534 pf2->removemine( -1 );
00535 else
00536 pf2->removeObject( NULL );
00537 }
00538
00539
00540 mapsaved = false;
00541 mapChanged( actmap );
00542 }
00543 }
00544 break;
00545 case act_deleteunit : {
00546 MapField* pf2 = getactfield();
00547 if (pf2 != NULL)
00548 if (pf2->vehicle != NULL) {
00549 delete pf2->vehicle;
00550 mapsaved = false;
00551 mapChanged( actmap );
00552 }
00553 }
00554 break;
00555 case act_deletebuilding : {
00556 MapField* pf2 = getactfield();
00557 if (pf2 != NULL)
00558 if (pf2->building != NULL) {
00559 delete pf2->building;
00560 mapsaved = false;
00561 mapChanged( actmap );
00562 }
00563 }
00564 break;
00565 case act_deleteobject :
00566 case act_deletetopmostobject : {
00567 MapField* pf2 = getactfield();
00568 if ( pf2 ) {
00569 mapsaved = false;
00570 pf2->removeObject( NULL );
00571 mapChanged( actmap );
00572 }
00573 }
00574 break;
00575 case act_deleteallobjects : {
00576 MapField* pf2 = getactfield();
00577 if ( pf2 ) {
00578 mapsaved = false;
00579 pf2->objects.clear( );
00580 calculateallobjects( actmap );
00581 mapChanged( actmap );
00582 }
00583 }
00584 break;
00585 case act_deletemine : {
00586 MapField* pf2 = getactfield();
00587 if (pf2 != NULL) {
00588 mapsaved = false;
00589 pf2->removemine( -1 );
00590 mapChanged( actmap );
00591 }
00592 }
00593 break;
00594 case act_changeminestrength : changeminestrength();
00595 break;
00596 case act_changeunitvals : {
00597 MapField* pf2 = getactfield();
00598 if ( pf2 ) {
00599 if ( pf2->vehicle ) {
00600 changeunitvalues(pf2->vehicle);
00601 displaymap();
00602 }
00603 else if ( pf2->building ) {
00604 changebuildingvalues(*pf2->building);
00605 }
00606 }
00607 }
00608 break;
00609
00610 case act_mirrorcursorx : {
00611 MapDisplayPG* md = getMainScreenWidget()->getMapDisplay();
00612 md->cursor.goTo( MapCoordinate(actmap->xsize - md->cursor.pos().x, md->cursor.pos().y ) );
00613 }
00614
00615 break;
00616 case act_mirrorcursory : {
00617 MapDisplayPG* md = getMainScreenWidget()->getMapDisplay();
00618 md->cursor.goTo( MapCoordinate(md->cursor.pos().x, actmap->ysize - md->cursor.pos().y ) );
00619 }
00620 break;
00621
00622
00623
00624 case act_placething : placeCurrentItem();
00625 break;
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642 case act_about :
00643 case act_aboutbox : {
00644
00645 ASCString s = "#fontsize=22#Advanced Strategic Command\nMap Editor#fontsize=14#\n";
00646 s += getVersionAndCompilation();
00647
00648
00649
00650 s += readtextmessage( 1020 );
00651
00652 ViewFormattedText vft( "About", s, PG_Rect(-1,-1,450,550));
00653 vft.Show();
00654 vft.RunModal();
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664 }
00665 break;
00666 case act_smoothcoasts : {
00667 ForestCalculation::smooth ( 6, actmap, NULL );
00668 displaymap();
00669 }
00670 break;
00671 case act_resizemap : resizemap();
00672 break;
00673 case act_movebuilding: movebuilding();
00674 break;
00675 case act_setactweatherglobal: setweatherall ( selection.getWeather() );
00676 displaymap();
00677 break;
00678 case act_terraininfo: viewterraininfo( actmap, actmap->getCursor(), true);
00679 break;
00680 case act_setunitfilter: selectunitsetfilter();
00681 filtersChangedSignal();
00682 break;
00683
00684
00685 case act_unitsettransformation: unitsettransformation();
00686 break;
00687 case act_unitSetInformation: viewUnitSetinfo();
00688 break;
00689 case act_primaryAction: if ( mapSwitcher.getDefaultAction() == MapSwitcher::select ) {
00690 execaction ( act_setactivefieldvals );
00691 execaction(act_switchmaps);
00692 } else
00693 execaction( act_placething );
00694
00695 break;
00696
00697 case act_switchmaps: mapSwitcher.toggle();
00698 displaymap();
00699 updateFieldInfo();
00700 break;
00701 case act_editArchivalInformation: editArchivalInformation();
00702 break;
00703 case act_displayResourceComparison : resourceComparison();
00704 break;
00705
00706
00707
00708
00709 case act_pasteFromClipboard: if ( getactfield() && !getactfield()->getContainer() ) {
00710 ClipBoard::Instance().place( actmap->getCursor() );
00711 mapsaved = false;
00712 displaymap();
00713 }
00714 break;
00715 case act_copyToClipboard: if ( getactfield() ) {
00716 if ( getactfield()->vehicle ) {
00717 ClipBoard::Instance().clear();
00718 infoMessageClipboardPlayers( getactfield()->vehicle );
00719 ClipBoard::Instance().addUnit( getactfield()->vehicle );
00720 } else
00721 if ( getactfield()->building ) {
00722 ClipBoard::Instance().clear();
00723 infoMessageClipboardPlayers( getactfield()->building );
00724 ClipBoard::Instance().addBuilding( getactfield()->building );
00725 }
00726 }
00727 break;
00728 case act_cutToClipboard: if ( getactfield() ) {
00729 if ( getactfield()->vehicle ) {
00730 ClipBoard::Instance().clear();
00731 infoMessageClipboardPlayers( getactfield()->vehicle );
00732 ClipBoard::Instance().addUnit( getactfield()->vehicle );
00733 execaction ( act_deleteunit );
00734 mapsaved = false;
00735 } else
00736 if ( getactfield()->building ) {
00737 ClipBoard::Instance().clear();
00738 infoMessageClipboardPlayers( getactfield()->building );
00739 ClipBoard::Instance().addBuilding( getactfield()->building );
00740 execaction ( act_deletebuilding );
00741 mapsaved = false;
00742 }
00743 }
00744 break;
00745 case act_saveClipboard: saveClipboard();
00746 break;
00747
00748 case act_readClipBoard: readClipboard();
00749 break;
00750 case act_setTurnNumber: actmap->time.set ( getid("Turn",actmap->time.turn(),0,maxint), 0 );
00751 break;
00752 case act_showPipeNet: mainScreenWidget->getMapDisplay()->toggleMapLayer("pipes");
00753 repaintMap();
00754 break;
00755 case act_editResearch: editResearch();
00756 break;
00757 case act_editResearchPoints: editResearchPoints();
00758 break;
00759 case act_generateTechTree: generateTechTree();
00760 break;
00761 case act_editTechAdapter: editTechAdapter();
00762 break;
00763 case act_playerStrengthSummary: pbpplayerstatistics( actmap );
00764 break;
00765 case act_unitGuideDialog: unitGuideWindow(2);
00766 break;
00767
00768 }
00769 }
00770
00772 void execaction_pg(int code)
00773 {
00774 switch(code) {
00775 #ifdef WEATHERGENERATOR
00776 case act_setactnewweather: weatherConfigurationDialog();
00777 break;
00778 #endif
00779 case act_selbodentyp : if ( mapSwitcher.getDefaultAction() == MapSwitcher::select )
00780 execaction ( act_setactivefieldvals );
00781 execaction( act_switchmaps);
00782 break;
00783 case act_selbodentypAll : mainScreenWidget->selectTerrainList();
00784 break;
00785 case act_selunit : mainScreenWidget->selectVehicle();
00786 break;
00787 case act_selbuilding : mainScreenWidget->selectBuilding();
00788 break;
00789 case act_selobject : mainScreenWidget->selectObject();
00790 break;
00791 case act_selobjectAll: mainScreenWidget->selectObjectList();
00792
00793
00794
00795
00796 break;
00797 case act_selmine : mainScreenWidget->selectMine();
00798 break;
00799 case act_unitinfo : unitInfoDialog();
00800 break;
00801 case act_setmapparameters: setmapparameters( actmap );
00802 break;
00803 case act_setupalliances : {
00804 DirectAllianceSetupStrategy dass;
00805 setupalliances( actmap, &dass, true );
00806 }
00807 break;
00808 case act_setupplayers : setupPlayers( actmap, true );
00809 break;
00810 case act_loadmap : {
00811 if (mapsaved == false )
00812 if (choice_dlg("Map not saved ! Save now ?","~y~es","~n~o") == 1)
00813 k_savemap(false);
00814
00815 try {
00816 k_loadmap();
00817 }
00818 catch (ASCmsgException message ) {
00819 errorMessage( "Could not load map:\n" + message.getMessage());
00820 }
00821 catch ( ... ) {
00822 errorMessage ( "error loading file" );
00823 }
00824 displaymap();
00825 }
00826 break;
00827 case act_savemap : k_savemap(false);
00828 break;
00829 case act_savemapas : k_savemap(true);
00830 break;
00831 case act_maptopcx : {
00832 bool view = choice_dlg("Include view ?","~n~o", "~y~es") == 2;
00833 if ( view )
00834 computeview( actmap );
00835 writemaptopcx ( actmap, view );
00836 }
00837 break;
00838 case act_end : {
00839 if ( mapSwitcher.getDefaultAction() == MapSwitcher::select )
00840 execaction(act_switchmaps);
00841 else
00842 if (choice_dlg("Do you really want to quit ?","~y~es","~n~o") == 1) {
00843 getPGApplication().Quit();
00844 }
00845 }
00846 break;
00847 case act_changecargo :
00848 if ( getactfield() && getactfield()->getContainer() )
00849 cargoEditor( getactfield()->getContainer() );
00850
00851 break;
00852 case act_createresources2 : resourcePlacementDialog();
00853 displaymap();
00854 break;
00855 case act_changeproduction : if ( getactfield() && getactfield()->getContainer() ) {
00856 if ( getactfield()->getContainer()->baseType->hasFunction( ContainerBaseType::InternalVehicleProduction ))
00857 editProduction( getactfield()->getContainer() );
00858 else
00859 warningMessage("this unit/building has no production capabilities");
00860 }
00861 break;
00862 case act_selectgraphicset: selectgraphicset();
00863
00864 break;
00865 case act_transformMap: transformMap();
00866 break;
00867 case act_increase_zoom:
00868 if ( mainScreenWidget && mainScreenWidget->getMapDisplay() ) {
00869 mainScreenWidget->getMapDisplay()->changeZoom( 10 );
00870 viewChanged();
00871 repaintMap();
00872 }
00873 break;
00874 case act_decrease_zoom:
00875 if ( mainScreenWidget && mainScreenWidget->getMapDisplay() ) {
00876 mainScreenWidget->getMapDisplay()->changeZoom( -10 );
00877 viewChanged();
00878 repaintMap();
00879 }
00880 break;
00881 case act_editpreferences:
00882 editGameOptions( false );
00883 break;
00884
00885 case act_events : eventEditor( actmap );
00886 break;
00887 case act_resetPlayerData: adminGame( actmap );
00888 break;
00889 case act_changemapvals : editMap(actmap);
00890 break;
00891 case act_newmap : newmap();
00892 break;
00893 case act_clearresources: {
00894 for ( int y = 0; y < actmap->ysize; ++y)
00895 for ( int x = 0; x < actmap->xsize; ++x ) {
00896 actmap->getField(x,y)->fuel = 0;
00897 actmap->getField(x,y)->material = 0;
00898 }
00899 repaintMap();
00900 }
00901 case act_dumpBuilding:
00902 if ( getactfield() && getactfield()->building ) {
00903 ASCString filename = selectFile( "*.dump", false );
00904 if ( !filename.empty () ) {
00905 tn_file_buf_stream stream ( filename, tnstream::writing );
00906 PropertyWritingContainer pc ( "BuildingDump", stream );
00907 actmap->getbuildingtype_byid(getactfield()->building->typ->id)->runTextIO( pc );
00908 }
00909 } else
00910 errorMessage("no building selected");
00911 break;
00912 case act_dumpVehicle:
00913 if ( getactfield() && getactfield()->vehicle ) {
00914 ASCString filename = selectFile( "*.dump", false );
00915 if ( !filename.empty () ) {
00916 tn_file_buf_stream stream ( filename, tnstream::writing );
00917 PropertyWritingContainer pc ( "VehicleDump", stream );
00918 actmap->getvehicletype_byid(getactfield()->vehicle->typ->id)->runTextIO( pc );
00919 }
00920 } else
00921 errorMessage("no vehicle selected");
00922 break;
00923 case act_dumpObject:
00924 if ( getactfield() && !getactfield()->objects.empty() ) {
00925 ASCString filename = selectFile( "*.dump", false );
00926 if ( !filename.empty () ) {
00927 tn_file_buf_stream stream ( filename, tnstream::writing );
00928 PropertyWritingContainer pc ( "ObjectDump", stream );
00929 actmap->getobjecttype_byid( getactfield()->objects.front().typ->id)->runTextIO( pc );
00930 }
00931 } else
00932 errorMessage("no object selected");
00933 break;
00934 case act_help : help(1000);
00935 break;
00936 case act_pbpstatistics: pbpplayerstatistics( actmap );
00937 break;
00938 case act_exchangeGraphics: exchangeGraphics();
00939 break;
00940 case act_openControlPanel: showPlayerPanel(true);
00941 break;
00942 case act_releaseControlPanel: showPlayerPanel(false);
00943 break;
00944 case act_dumpAllVehicleDefinitions: {
00945 StatusMessageWindowHolder smw = MessagingHub::Instance().infoMessageWindow( "dumping all units" );
00946 for ( int i = 0; i < vehicleTypeRepository.getNum(); ++i ) {
00947 VehicleType* veh = vehicleTypeRepository.getObject_byPos( i );
00948 tn_file_buf_stream stream ( "Vehicle" + ASCString::toString( i ) + ".dump", tnstream::writing );
00949 PropertyWritingContainer pc ( "VehicleDump", stream );
00950 veh->runTextIO( pc );
00951 }
00952 };
00953 break;
00954 case act_dumpAllBuildings: {
00955 StatusMessageWindowHolder smw = MessagingHub::Instance().infoMessageWindow( "dumping all buildings" );
00956 for ( int i = 0; i < buildingTypeRepository.getNum(); ++i ) {
00957 BuildingType* bld = buildingTypeRepository.getObject_byPos( i );
00958 tn_file_buf_stream stream ( "Building" + ASCString::toString( i ) + ".dump", tnstream::writing );
00959 PropertyWritingContainer pc ( "BuildingDump", stream );
00960 bld->runTextIO( pc );
00961 }
00962 };
00963 break;
00964 case act_dumpAllTerrain: {
00965 StatusMessageWindowHolder smw = MessagingHub::Instance().infoMessageWindow( "dumping all terrain" );
00966 for ( int i = 0; i < terrainTypeRepository.getNum(); ++i ) {
00967 TerrainType* bld = terrainTypeRepository.getObject_byPos( i );
00968 tn_file_buf_stream stream ( "terrain" + ASCString::toString( i ) + ".dump", tnstream::writing );
00969 PropertyWritingContainer pc ( "terrainDump", stream );
00970 bld->runTextIO( pc );
00971 }
00972 };
00973 break;
00974 case act_dumpAllObjects: {
00975 ASCString text = "dumping all objects";
00976 StatusMessageWindowHolder smw = MessagingHub::Instance().infoMessageWindow( text );
00977 for ( int i = 0; i < objectTypeRepository.getNum(); ++i ) {
00978 ObjectType* bld = objectTypeRepository.getObject_byPos( i );
00979 tn_file_buf_stream stream ( "object" + ASCString::toString( i ) + ".dump", tnstream::writing );
00980 PropertyWritingContainer pc ( "objectDump", stream );
00981 bld->runTextIO( pc );
00982 smw.SetText( text + ": " + ASCString::toString( int(i * 100 / objectTypeRepository.getNum() )) + "%" );
00983 }
00984 };
00985 break;
00986
00987 case act_clearSelection: selection.clear();
00988 break;
00989 case act_locateItemByID: locateItemByID();
00990 break;
00991 case act_mirrorMap: mirrorMap();
00992 break;
00993 case act_copyArea: copyArea();
00994 break;
00995 case act_pasteArea: pasteArea();
00996 break;
00997 case asc_nullPointerCrash: {
00998 char* p = NULL;
00999 *p = 1;
01000 }
01001 break;
01002 case asc_testFunction: testDebugFunction();
01003 break;
01004 case act_import_bi_map :
01005 if (mapsaved == false )
01006 if (choice_dlg("Map not saved ! Save now ?","~y~es","~n~o") == 1)
01007 k_savemap(false);
01008 importBI3Map( actmap );
01009 displaymap();
01010 break;
01011 case act_insert_bi_map :
01012 importBI3Map( actmap, true );
01013 displaymap();
01014 break;
01015 case act_runLuaScript:
01016 selectAndRunLuaScript( "*.lua" );
01017 repaintMap();
01018 break;
01019 case act_runTranslationScript:
01020 selectAndRunLuaScript( "*.map.*" );
01021 repaintMap();
01022 break;
01023 case act_showweapnrange:
01024 mainScreenWidget->showWeaponRange( actmap, actmap->getCursor() );
01025 displaymap();
01026 break;
01027
01028
01029 };
01030 }
01031
01032 void execaction_ev(int code)
01033 {
01034 execaction_pg(code);
01035 execaction(code);
01036 }