Advanced Strategic Command
asc-mainscreen.cpp
Go to the documentation of this file.
1 
2 /***************************************************************************
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  ***************************************************************************/
10 
11 
12 #include "global.h"
13 
14 #include <stdio.h>
15 #include <cstring>
16 #include <stdlib.h>
17 #include <new>
18 #include <cstdlib>
19 #include <ctype.h>
20 #include <algorithm>
21 #include <memory>
22 #include <SDL_image.h>
23 #include <SDL_mixer.h>
24 
25 #include <pgpopupmenu.h>
26 #include <pgmenubar.h>
27 
28 #include "paradialog.h"
29 
30 #include "misc.h"
31 #include "iconrepository.h"
32 #include "dashboard.h"
33 #include "asc-mainscreen.h"
34 #include "guiiconhandler.h"
35 #include "guifunctions.h"
36 #include "graphics/blitter.h"
37 #include "graphics/drawing.h"
38 #include "overviewmappanel.h"
39 #include "ai/ai.h"
40 #include "itemrepository.h"
41 #include "mapdisplay.h"
42 #include "sg.h"
43 #include "gameoptions.h"
44 #include "dialog.h"
46 #include "spfst-legacy.h"
47 
48 #include "weaponrangelayer.h"
49 #include "dialogs/fileselector.h"
50 
52 
54 
55 
57 {
58  return mainScreenWidget;
59 }
60 
61 class Menu : public PG_MenuBar {
62 
63  PG_PopupMenu* currentMenu;
64  typedef list<PG_PopupMenu*> Categories;
65  Categories categories;
66 
67  public:
68  Menu ( PG_Widget *parent, const PG_Rect &rect=PG_Rect::null);
69 
70  protected:
71  void setup();
72  bool execAction (PG_PopupMenu::MenuItem* menuItem );
73 
74  private:
75  void addbutton(const char* name, int id );
76  void addfield ( const char* name );
77 
78 };
79 
80 
81 
82 
83 
84 
85 
86 
87 bool Menu::execAction (PG_PopupMenu::MenuItem* menuItem )
88 {
89  executeUserAction( tuseractions( menuItem->getId() ) );
90 
91  return true;
92 }
93 
94 
95 #define HIGHLIGHT
96 
97 void Menu::addfield( const char* name )
98 {
99  currentMenu = new PG_PopupMenu( NULL, -1, -1, "" );
100 
101 #ifdef HIGHLIGHT
102  categories.push_back ( currentMenu );
103  Add ( name, currentMenu );
104 #else
105  ASCString s = name;
106  while ( s.find ( "~") != ASCString::npos )
107  s.erase( s.find( "~"),1 );
108  Add ( s, currentMenu );
109 #endif
110 
111  currentMenu->sigSelectMenuItem.connect( sigc::mem_fun( *this, &Menu::execAction ));
112 }
113 
114 void Menu::addbutton( const char* name, int id )
115 {
116 #ifdef HIGHLIGHT
117  currentMenu->addMenuItem( name, id );
118 #else
119  ASCString s = name;
120  while ( s.find ( "~") != ASCString::npos )
121  s.erase( s.find( "~"),1 );
122 
123  currentMenu->addMenuItem( s, id );
124 #endif
125 
126 }
127 
128 
130 {
131 
132  addfield ( "Glo~b~al" );
133  addbutton ( "~O~ptions", ua_gamepreferences );
134  addbutton ( "~S~ound options", ua_soundDialog );
135  addbutton ( "~E~mail options", ua_emailOptions );
136  currentMenu->addSeparator();
137  addbutton ( "~M~ain menu\tESC", ua_mainmenu );
138  currentMenu->addSeparator();
139  addbutton ( "~Q~uit\tctrl-q", ua_exitgame );
140 
141 
142  addfield ("~G~ame");
143  addbutton ( "~N~ew Game\tctrl-n", ua_newGame );
144  currentMenu->addSeparator();
145  addbutton ( "~L~oad game\tctrl-l", ua_loadgame );
146  addbutton ( "Load most recent game\tctrl-shift-l", ua_loadrecentgame );
147  addbutton ( "~S~ave game\tctrl-s", ua_savegame );
148  currentMenu->addSeparator();
149  addbutton ( "Continue network game\tF3", ua_continuenetworkgame);
150  addbutton ( "Most recent network game\tShift-F3", ua_continuerecentnetworkgame);
151  // addbutton ( "setup Net~w~ork", ua_setupnetwork );
152  addbutton ( "Change Passw~o~rd", ua_changepassword );
153  addbutton ( "supervise network game\tF4", ua_networksupervisor );
154  currentMenu->addSeparator();
155  addbutton ( "~D~iplomacy", ua_setupalliances);
156  addbutton ( "transfer ~U~nit control", ua_giveunitaway );
157  addbutton ( "~T~ransfer resources", ua_settribute);
158  addbutton ( "Choose Technology", ua_chooseTechnology );
159  addbutton ( "~C~ancel Research", ua_cancelResearch );
160  currentMenu->addSeparator();
161  addbutton ( "~E~dit Player Data", ua_editPlayerData);
162 
163 
164  addfield ( "~A~ction" );
165  addbutton ( "~U~ndo\tctrl-z", ua_undo );
166  addbutton ( "~R~edo\tctrl-shift-z", ua_redo );
167  addbutton ( "~M~anage Actions", ua_actionManager );
168  addbutton ( "Manage ~P~ending Tasks", ua_taskManager );
169  addbutton ( "Run all pending tasks\tctrl-t", ua_runOpenTasks );
170  currentMenu->addSeparator();
171  addbutton ( "Save Script", ua_writeLuaCommands );
172  addbutton ( "Run Script", ua_runLuaCommands );
173 
174 
175  addfield ( "~I~nfo" );
176  addbutton ( "~V~ehicle types", ua_vehicleinfo );
177  addbutton ( "Unit ~w~eapon range\t3", ua_viewunitweaponrange );
178  addbutton ( "Unit ~m~ovement range\t4", ua_viewunitmovementrange );
179  addbutton ( "~G~ame Time", ua_GameStatus );
180  addbutton ( "unit ~S~et information", ua_UnitSetInfo );
181  addbutton ( "unit guide dialog", ua_unitGuideDialog );
182  addbutton ( "~T~errain\t7", ua_viewterraininfo );
183  addbutton ( "~U~nit weight\t8", ua_unitweightinfo );
184  currentMenu->addSeparator();
185  addbutton ( "~R~esearch", ua_researchinfo );
186  addbutton ( "~P~lay time", ua_showPlayerSpeed );
187  addbutton ( "~C~argo Summary\tctrl-c", ua_cargosummary );
188  addbutton ( "Unit Summary\tctrl-f", ua_unitsummary );
189  currentMenu->addSeparator();
190  addbutton ( "Unit Production Analysis", ua_unitproductionanalysis );
191  addbutton ( "Mining Station Analysis", ua_showMiningPower );
192 
193  // addbutton ( "~R~esearch status", ua_showResearchStatus );
194 
195  // addbutton ( "vehicle ~I~mprovement\tF7", ua_dispvehicleimprovement);
196 
197 
198  // addfield ( "~S~tatistics" );
199 
200  // addbutton ( "~R~esources ", ua_statisticdialog );
201  // addbutton ( "seperator");
202  // addbutton ( "~H~istory");
203 
204  addfield ( "~M~essage");
205  addbutton ( "~n~ew message", ua_newmessage );
206  addbutton ( "new reminder\tctrl-r", ua_createReminder );
207  addbutton ( "view ~q~ueued messages", ua_viewqueuedmessages );
208  addbutton ( "view ~s~ent messages", ua_viewsentmessages );
209  addbutton ( "view ~r~eceived messages", ua_viewreceivedmessages);
210  currentMenu->addSeparator();
211  addbutton ( "view ~j~ournal", ua_viewjournal );
212  addbutton ( "~a~ppend to journal", ua_editjournal );
213 
214  addfield ( "~T~ools" );
215  addbutton ( "save ~M~ap as PNG", ua_writemaptopcx );
216  addbutton ( "save ~S~creen as PCX", ua_writescreentopcx );
217  addbutton ( "select graphic set", ua_selectgraphicset );
218  currentMenu->addSeparator();
219  addbutton ( "~G~oto coordinate\tctrl-g", ua_gotoPosition );
220 
221  addfield ( "~V~iew" );
222  addbutton ( "toggle ~R~esourceview\t1", ua_changeresourceview );
223  addbutton ( "toggle unit shading\t2", ua_toggleunitshading );
224  addbutton ( "show ~P~ipeline net\t9", ua_viewPipeNet );
225  addbutton ( "show ~V~isibility Range\t0", ua_visibilityInfo );
226  currentMenu->addSeparator();
227  addbutton ( "show reaction~f~ire", ua_viewReactionfireOverlay );
228  addbutton ( "show unit info\tctrl-1", ua_viewUnitinfoOverlay );
229  addbutton ( "show unit experience\tctrl-2", ua_viewUnitexperienceOverlay );
230  currentMenu->addSeparator();
231  addbutton ( "Button Panel", ua_viewButtonPanel );
232  addbutton ( "Wind Panel", ua_viewWindPanel );
233  addbutton ( "Unit Info Panel", ua_viewUnitInfoPanel );
234  addbutton ( "Overview Map Panel", ua_viewOverviewMapPanel );
235  addbutton ( "Map Control Panel", ua_viewMapControlPanel );
236 // addbutton ( "Action Panel", ua_viewActionPanel );
237 
238  // addbutton("Weathercast", ua_weathercast);
239  currentMenu->addSeparator();
240  addbutton ( "Increase Map Zoom\tKP+", ua_increase_zoom );
241  addbutton ( "Decrease Map Zoom\tKP-", ua_decrease_zoom );
242 
243 
244  addfield ( "~D~ebug" );
245  addbutton ( "Show ASC search ~P~ath", ua_showsearchdirs );
246  addbutton ( "SDL settings", ua_SDLinfo );
247  addbutton ( "Locate File", ua_locatefile );
248  addbutton ( "test messages", ua_testMessages );
249  addbutton ( "view font", ua_viewfont );
250  addbutton ( "memory footprint", ua_getMemoryFootprint );
251  addbutton ( "show event status", ua_eventInfo );
252  currentMenu->addSeparator();
253  addbutton ( "clear image cache", ua_clearImageCache );
254  addbutton ( "reload dialog theme", ua_reloadDlgTheme );
255  currentMenu->addSeparator();
256  addbutton ( "resource analysis", ua_resourceAnalysis );
257  addbutton ( "show techadapter", ua_showTechAdapter );
258  addbutton ( "calc airplane endurance", ua_showUnitEndurance );
259  addbutton ( "show game ~P~arameters", ua_GameParameterInfo );
260  addbutton ( "Recompute View", ua_recompteview );
261  addbutton ( "Create unit cost list ", ua_createUnitCostList );
262  currentMenu->addSeparator();
263  addbutton ( "benchmark without view calc", ua_benchgamewov );
264  addbutton ( "benchmark with view calc", ua_benchgamewv);
265  addbutton ( "compiler benchmark (AI)", ua_aibench );
266  currentMenu->addSeparator();
267  addbutton ( "unit AI properties", ua_unitAiOptions );
268  currentMenu->addSeparator();
269  addbutton ( "show packages used by map", ua_showUsedPackages );
270  // addbutton ( "test memory integrity", ua_heapcheck );
271 
272  addfield ( "~H~elp" );
273  // addbutton ( "HowTo ~S~tart email games", ua_howtostartpbem );
274  // addbutton ( "HowTo ~C~ontinue email games", ua_howtocontinuepbem );
275  // currentMenu->addSeparator();
276  addbutton ( "~K~eys", ua_help );
277  addbutton ( "~M~ap Layer", ua_viewlayerhelp );
278  currentMenu->addSeparator();
279 
280  addbutton ( "~A~bout", ua_viewaboutmessage );
281 }
282 
283 
284 Menu::Menu ( PG_Widget *parent, const PG_Rect &rect)
285  : PG_MenuBar( parent, rect, "MenuBar"),
286  currentMenu(NULL)
287 {
288  activateHotkey( KMOD_ALT );
289  setup();
290 }
291 
292 
293 
294 
295 
296 
297 class UnitMovementRangeLayer : public MapLayer, public sigc::trackable {
298  Surface& icon;
299  GameMap* gamemap;
300 
301  map<MapCoordinate,int> fields;
302 
303  void markField( const MapCoordinate& pos )
304  {
305  fields[pos] |= 1;
306  }
307 
308  bool addUnit( Vehicle* veh )
309  {
310 
311  if ( fieldvisiblenow ( getfield ( veh->xpos, veh->ypos ))) {
312  int counter = 0;
313 
314  AStar3D pathfinder( veh->getMap(), veh, false, veh->maxMovement() );
315  pathfinder.findAllAccessibleFields( );
316 
317  for ( AStar3D::VisitedContainer::iterator i = pathfinder.visited.begin(); i != pathfinder.visited.end(); ++i )
318  if ( fieldvisiblenow ( veh->getMap()->getField(i->h) )) {
319  ++counter;
320  markField( i->h );
321  }
322 
323  if ( counter )
324  fields[veh->getPosition()] |= 2;
325 
326  return counter;
327  } else
328  return false;
329  };
330 
331  void reset()
332  {
333  fields.clear();
334  if ( isActive() ) {
335  setActive(false);
336  statusMessage("Movement range layer disabled");
337  repaintMap();
338  }
339  }
340  public:
341 
343  {
344  if ( !pos.valid() )
345  return;
346 
347  if ( gamemap && gamemap != actmap )
348  fields.clear();
349 
350  gamemap = actmap;
351 
352  if ( fields.find( pos ) != fields.end() ) {
353  if ( fields[pos] & 2 ) {
354  reset();
355  return;
356  }
357  }
358 
359  if ( actmap->getField( pos )->vehicle ) {
360  if ( addUnit( actmap->getField( pos )->vehicle ) ) {
361  setActive(true);
362  statusMessage("Movement range layer enabled");
363  repaintMap();
364  }
365  }
366  }
367 
368  UnitMovementRangeLayer() : icon ( IconRepository::getIcon( "markedfield-blue.png")), gamemap(NULL) {
369  cursorMoved.connect( sigc::mem_fun( *this, &UnitMovementRangeLayer::reset ));
370  }
371 
372  bool onLayer( int layer ) { return layer == 17; };
373 
374  void paintSingleField( const MapRenderer::FieldRenderInfo& fieldInfo, int layer, const SPoint& pos )
375  {
376  if ( fieldInfo.gamemap != gamemap && gamemap) {
377  reset();
378  gamemap = NULL;
379  return;
380  }
381 
382  if ( fieldInfo.visibility >= visible_ago) {
383  if ( fields.find( fieldInfo.pos ) != fields.end() ) {
384  int p = fields[fieldInfo.pos];
385  if ( p )
386  fieldInfo.surface.Blit( icon, pos );
387  }
388  }
389  }
390 };
391 
392 
393 class VisibilityLayer : public MapLayer {
394  void renderText( const MapRenderer::FieldRenderInfo& fieldInfo, SPoint pos, const ASCString& text );
395  public:
396  bool onLayer( int layer ) { return layer == 17; };
397  void paintSingleField( const MapRenderer::FieldRenderInfo& fieldInfo, int layer, const SPoint& pos );
398 };
399 
400 void VisibilityLayer::paintSingleField( const MapRenderer::FieldRenderInfo& fieldInfo, int layer, const SPoint& pos )
401 {
402  if ( fieldVisibility( fieldInfo.fld, fieldInfo.gamemap->getPlayerView() ) >= visible_now ) {
403 
404  int view = 0;
405  int jamming = 0;
406  for ( int i = 0; i < fieldInfo.gamemap->getPlayerCount(); ++i )
407  if ( fieldInfo.gamemap->getPlayer(i).diplomacy.sharesView( fieldInfo.gamemap->getPlayerView())) {
408  view += fieldInfo.fld->view[i].view;
409  jamming += fieldInfo.fld->view[i].jamming;
410  }
411 
412 #if 0
413  ASCString s;
414  s.format( "%d/%d", view, jamming);
415 
416  font->SetColor( 0xffffff );
417  PG_FontEngine::RenderText( fieldInfo.surface.getBaseSurface() , PG_Rect( pos.x, pos.y, fieldsizex, fieldsizey), pos.x+6, pos.y + 21, s, font );
418 
419  font->SetColor( 0 );
420  PG_FontEngine::RenderText( fieldInfo.surface.getBaseSurface() , PG_Rect( pos.x, pos.y, fieldsizex, fieldsizey), pos.x+5, pos.y + 20, s, font );
421 #else
422 
423  renderText( fieldInfo, SPoint(pos.x + 10, pos.y + 5), ASCString::toString( view ) + "V");
424  renderText( fieldInfo, SPoint(pos.x + 10, pos.y + 18), ASCString::toString( jamming ) + "J");
425  renderText( fieldInfo, SPoint(pos.x + 10, pos.y + 31), ASCString::toString( fieldInfo.fld->getjamming() ) + "T" );
426 #endif
427  }
428 }
429 
430 void VisibilityLayer::renderText( const MapRenderer::FieldRenderInfo& fieldInfo, SPoint pos, const ASCString& text )
431 {
432  static PG_Font* font = NULL;
433  if ( !font ) {
434  PG_Label l( NULL );
435  font = new PG_Font( *(l.GetFont()));
436  font->SetSize( 12 );
437  }
438 
439  font->SetColor( 0xffffff );
440  PG_FontEngine::RenderText( fieldInfo.surface.getBaseSurface() , PG_Rect( pos.x, pos.y, fieldsizex, fieldsizey), pos.x+1, pos.y + 13, text, font );
441 
442  font->SetColor( 0 );
443  PG_FontEngine::RenderText( fieldInfo.surface.getBaseSurface() , PG_Rect( pos.x, pos.y, fieldsizex, fieldsizey), pos.x, pos.y+12, text, font );
444 }
445 
446 
447 ASC_MainScreenWidget::ASC_MainScreenWidget( PG_Application& application )
448  : MainScreenWidget( application ), standardActionsLocked(0), guiHost(NULL), menu(NULL), unitInfoPanel(NULL), windInfoPanel(NULL), mapInfoPanel(NULL), actionInfoPanel(NULL)
449 {
450 
451  int mapWidth = Width() - 30;
452 
453  PG_Rect mapView(15,30,Width() - 200, Height() - 73);
454 
455  if ( CGameOptions::Instance()->panelColumns & 1 ) {
456  mapView.x = 185;
457  mapWidth -= 170;
458  }
459  if ( CGameOptions::Instance()->panelColumns & 2 ) {
460  mapWidth -= 170;
461  }
462  mapView.my_width = mapWidth;
463 
464 
465  setup( true, mapView );
466 
467  displayLogMessage ( 7, "done\n Menu ");
468  menu = new Menu(this, PG_Rect(15,0,Width()-200,20));
469 
471  SetID( ASC_PG_App::mainScreenID );
472 
473 
475  mapDisplay->addMapLayer( weaponRangeLayer, "weaprange" );
476 
478  mapDisplay->addMapLayer( movementRangeLayer, "moverange" );
479 
480  mapDisplay->addMapLayer( new VisibilityLayer(), "visibilityvalue" );
481 
482  mapDisplay->layerChanged.connect( sigc::mem_fun( *this, &ASC_MainScreenWidget :: mapLayerChanged));
483 
484  // making a copy, because the activateMapLayer will modify the visibleMapLayer object
485  vector<ASCString> layer = CGameOptions::Instance()->visibleMapLayer;
486  for ( vector<ASCString>::iterator i = layer.begin(); i != layer.end(); ++i )
487  mapDisplay->activateMapLayer(*i,true);
488 
489 
490 
491  int counter = 0;
492  for ( CGameOptions::PanelDataContainer::iterator i = CGameOptions::Instance()->panelData.begin(); i != CGameOptions::Instance()->panelData.end(); ++i ) {
493  if ( i->second.visible ) {
494  if ( spawnPanel( i->first ))
495  ++counter;
496  }
497  }
498 
499  if ( !counter ) {
500  spawnPanel( UnitInfo );
503  }
504 
505  // to persuade the linker to really link that file
507 }
508 
509 void ASC_MainScreenWidget :: mapLayerChanged(bool b, const ASCString& name )
510 {
511  mapDisplay->getActiveLayers( CGameOptions::Instance()->visibleMapLayer );
513 }
514 
515 
516 
518 {
519  standardActionsLocked += dir;
520 
521  if( dir > 0 ) {
522  lockOptionStack.push_back( lockOptions );
523  lockOptions = options;
524  lockOptionsChanged( options );
525  }
526  if ( dir < 0 ) {
527  lockOptions = lockOptionStack.back();
528  lockOptionStack.pop_back();
530  }
531 
532  if ( menu ) {
533  if ( standardActionsLocked <= 0 )
534  menu->Show();
535  else
536  menu->Hide();
537  }
538 }
539 
540 
541 
542 
543 
544 void displaymessage2( const char* formatstring, ... )
545 {
546 
547  ASCString s;
548 
549  std::va_list arg_ptr;
550  va_start ( arg_ptr, formatstring );
551 
552  s.vaformat( formatstring, arg_ptr );
553 
554  va_end ( arg_ptr );
555 
556  if ( mainScreenWidget )
557  mainScreenWidget->displayMessage(s);
558 }
559 
560 
561 
563 {
564  if ( panelName == "WindInfo" ) {
565  spawnPanel ( WindInfo );
566  return true;
567  }
568 
569  if ( panelName == "UnitInfo" ) {
570  spawnPanel ( UnitInfo );
571  return true;
572  }
573 
574  if ( panelName == "GuiIcons" ) {
576  return true;
577  }
578 
579  if ( panelName == "OverviewMap" ) {
581  return true;
582  }
583 
584  if ( panelName == "MapInfo" ) {
586  return true;
587  }
588 
589  if ( panelName == "ActionInfo" ) {
591  return true;
592  }
593 
594  return false;
595 }
596 
598 {
599  if ( panel == WindInfo ) {
600  if ( !windInfoPanel || !CGameOptions::Instance()->cacheASCGUI ) {
601  delete windInfoPanel;
602  windInfoPanel = new WindInfoPanel( this, PG_Rect(Width()-170, 480, 170, 114));
603  }
604  windInfoPanel->Show();
605  }
606  if ( panel == UnitInfo ) {
607  if ( !unitInfoPanel || !CGameOptions::Instance()->cacheASCGUI ) {
608  delete unitInfoPanel;
609  unitInfoPanel = new UnitInfoPanel( this, PG_Rect(Width()-170, 160, 170, 320));
610  }
611  unitInfoPanel->Show();
612  }
613  if ( panel == ButtonPanel ) {
614  if ( !guiHost || !CGameOptions::Instance()->cacheASCGUI ) {
615  delete guiHost;
616  guiHost = new NewGuiHost( this, mapDisplay, PG_Rect(Width()-170, Height()-200, 170, 200));
618  }
619  guiHost->Show();
620  }
621 
622  if ( panel == OverviewMap )
624 
625  if ( panel == MapControl ) {
626  if ( !mapInfoPanel || !CGameOptions::Instance()->cacheASCGUI ) {
627  delete mapInfoPanel;
628  mapInfoPanel = new MapInfoPanel( this, PG_Rect(Width()-170, 0, 170, 135), mapDisplay );
629  }
630  mapInfoPanel->Show();
631  }
632 
633  if ( panel == ActionInfo ) {
634  if ( !actionInfoPanel || !CGameOptions::Instance()->cacheASCGUI ) {
635  delete actionInfoPanel;
636  actionInfoPanel = new ActionInfoPanel( this, PG_Rect(Width()-170, 0, 170, 160) );
637  }
638  actionInfoPanel->Show();
640  }
641 }
642 
643 
645 {
646  movementRangeLayer->operateField( gamemap, pos );
647 }
648 
650 {
651  weaponRangeLayer->operateField( gamemap, pos );
652 }
653 
654 
655 
656 bool ASC_MainScreenWidget::eventKeyDown(const SDL_KeyboardEvent* key)
657 // bool Menu::eventKeyDown(const SDL_KeyboardEvent* key)
658 {
659  if ( standardActionsLocked > 0 )
660  return false;
661 
662  int mod = SDL_GetModState() & ~(KMOD_NUM | KMOD_CAPS | KMOD_MODE);
663 
664  if ( !mod ) {
665  switch ( key->keysym.sym ) {
666  case SDLK_ESCAPE:
668  return true;
669 
670  case SDLK_F1:
672  return true;
673 
674  case SDLK_F3:
676  return true;
677 
678  case SDLK_F4:
680  return true;
681 
682  case SDLK_F8:
683  {
684  int color = actmap->actplayer;
685  for ( int p = 0; p < 8; p++ )
686  if ( actmap->player[p].stat == Player::computer && actmap->player[p].exist() )
687  color = p;
688 
689  if ( actmap->player[color].ai ) {
690  AI* ai = (AI*) actmap->player[color].ai;
692  }
693  }
694  return true;
695 
696  case SDLK_1:
698  return true;
699 
700  case SDLK_2:
702  return true;
703 
704  case SDLK_3:
706  return true;
707 
708  case SDLK_4:
710  return true;
711 
712  /*
713  case SDLK_5:
714  execuseraction ( ua_GameStatus );
715  return true;
716  */
717 
718  case SDLK_5: executeUserAction ( ua_showCargoLayer );
719  return true;
720 
721  /*
722  case SDLK_6:
723  execuseraction ( ua_UnitSetInfo );
724  return true;
725  */
726 
727  case SDLK_7:
729  return true;
730 
731  case SDLK_8:
733  return true;
734 
735  case SDLK_9:
737  return true;
738 
739  case SDLK_0: executeUserAction( ua_visibilityInfo );
740  return true;
741 
742  case SDLK_BACKSPACE:
744  return true;
745 
746 
747  case SDLK_PLUS:
748  case SDLK_KP_PLUS: executeUserAction( ua_increase_zoom );
749  return true;
750 
751  case SDLK_MINUS:
752  case SDLK_KP_MINUS: executeUserAction( ua_decrease_zoom );
753  return true;
754 
755  case SDLK_F10: {
756 
757  PG_ScrollBar* sb = new PG_ScrollBar( NULL, PG_Rect( 20, 50, 15, 400), PG_ScrollBar::VERTICAL, -1, "DLGScrollbar" );
758  sb->SetPageSize(10);
759  sb->SetRange(0, 100);
760  sb->Show();
761 
762  }
763  // testText();
764  break;
765 
766  default:;
767  }
768  }
769 
770  if ( (mod & KMOD_SHIFT) && (mod & KMOD_CTRL)) {
771  switch ( key->keysym.sym ) {
772  case SDLK_F11: {
773  return true;
774  }
775  case SDLK_F10: {
776  return true;
777  }
778  case SDLK_l:
780  return true;
781 
782  case SDLK_LEFT:
784  return true;
785 
786  case SDLK_RIGHT:
788  return true;
789 
790  default:;
791  }
792  switch ( key->keysym.unicode ) {
793  case 26:
795  return true;
796 
797  default:;
798  }
799  }
800 
801  if ( mod & KMOD_CTRL ) {
802  switch ( key->keysym.sym ) {
803 
804  case SDLK_0: executeUserAction( ua_writescreentopcx );
805  return true;
806 
808  return true;
809 
811  return true;
812 
813  case SDLK_F10: {
814  SDL_Surface* s = PG_Application::GetScreen();
815  SDL_LockSurface( s );
816  int* i = (int*) (s->pixels);
817  for ( int x = 0; x < 100; ++x )
818  i[x * s->pitch/4 + x] = 0xffffff;
819  SDL_UnlockSurface( s );
820  SDL_UpdateRect(s,0,0,0,0);
821  return true;
822  }
823 
824 
825  default:;
826  }
827  switch ( key->keysym.unicode ) {
828  case 3: // C
830  return true;
831 
832  case 6: // F
834  return true;
835 
836  case 7: // G
838  return true;
839 
840  case 12: // L
842  return true;
843 
844  case 14: // N
846  return true;
847 
848  case 17: // Q
850  return true;
851 
852  case 18: // R
854  return true;
855 
856  case 19: // S
858  return true;
859 
860  case 20: // T
862  return true;
863 
864  case 26: // Z
866  return true;
867 
868  }
869  }
870 
871  if ( mod & KMOD_ALT ) {
872  switch ( key->keysym.sym ) {
873  case SDLK_RETURN:
875  return true;
876 
877  default:;
878  }
879  }
880 
881  if ( mod & KMOD_SHIFT ) {
882  switch ( key->keysym.sym ) {
883  case SDLK_F3:
885  return true;
886 
887  default:;
888  }
889  }
890  return false;
891 }
void findAllAccessibleFields()
searches for all fields that are within the range of maxDist and marks them.
Definition: astar2.cpp:562
void statusMessage(const ASCString &string)
ASC_MainScreenWidget(PG_Application &application)
Player & getPlayer(PlayerID p)
Definition: gamemap.h:257
MapCoordinate & getCursor()
Definition: gamemap.cpp:933
void getActiveLayers(vector< ASCString > &list)
NewGuiHost * guiHost
virtual void setActive(bool active)
Definition: mapdisplay.h:117
miscellaneous functions which are used by ASC and all its tools
int maxMovement() const
the maximum distance that the unit can drive in a single turn on the current level of height ...
Definition: vehicle.cpp:1069
void operateField(GameMap *actmap, const MapCoordinate &pos)
Vehicle * vehicle
Definition: mapfield.h:89
void lockStandardActions(int dir, int options)
bool valid() const
Definition: typen.h:221
void paintSingleField(const MapRenderer::FieldRenderInfo &fieldInfo, int layer, const SPoint &pos)
Everything that happens on the main screen of ASC.
ASCString & vaformat(const charT *pFormat, va_list ap)
Definition: ascstring.cpp:91
Definition: sg.h:32
BaseAI * ai
if the player is run by an AI, this is the pointer to it
Definition: player.h:144
void showMovementRange(GameMap *gamemap, const MapCoordinate &pos)
sigc::signal< void > dataLoaderTicker
GuiIconHandler primaryGuiIcons
Definition: sg.h:41
DiplomaticStateVector diplomacy
Definition: player.h:209
struct MapField::View view[8]
Definition: sg.h:36
sigc::signal< void, bool, const ASCString & > layerChanged
Definition: mapdisplay.h:298
MapCoordinate3D getPosition() const
returns the units position
Definition: vehicle.cpp:1552
sigc::signal< void > repaintMap
}@
Definition: spfst.cpp:45
Definition: sg.h:36
bool sharesView(PlayerID receivingPlayer) const
Definition: player.h:81
storage_t::iterator iterator
Definition: astar2.h:104
Global platform dependant definitions. This file just branches to the platform specific files in thei...
Definition: ai.h:44
ASCString & format(const charT *pFormat,...)
Definition: ascstring.cpp:78
Definition: sg.h:45
SDL_Surface * getBaseSurface()
Definition: surface.h:116
list< int > lockOptionStack
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
PanelDataContainer panelData
Definition: gameoptions.h:218
Menu(PG_Widget *parent, const PG_Rect &rect=PG_Rect::null)
int getPlayerView() const
the player which is currently viewing the map.
Definition: gamemap.cpp:1007
MapField * getfield(int x, int y)
returns the field at the given coordinates
Definition: spfst.cpp:199
#define fieldsizey
Definition: typen.h:441
Interface for various global functions and variables.
bool fieldvisiblenow(const MapField *pe, Vehicle *veh, int player)
{@
Definition: spfst.cpp:399
UnitWeaponRangeLayer * weaponRangeLayer
static ASCString toString(int i)
converts the parameter to a String
Definition: ascstring.cpp:193
ASC_PG_App & getPGApplication()
Definition: paradialog.cpp:294
void setChanged(bool flag=true)
Definition: gameoptions.h:272
void uselessCallToTextRenderAddons()
void paintSingleField(const MapRenderer::FieldRenderInfo &fieldInfo, int layer, const SPoint &pos)
Definition: sg.h:46
enum Player::PlayerStatus stat
void displayLogMessage(int msgVerbosity, const char *message,...)
Coordinate on the twodimensional map.
Definition: typen.h:202
MapDisplayPG * mapDisplay
Definition: sg.h:44
Dialog classes based on the Paragui library.
bool onLayer(int layer)
void setup()
tuseractions
Definition: edglobal.h:34
signed char actplayer
the player who is currently making his moves (may be human or AI)
Definition: gamemap.h:232
#define fieldsizex
Definition: typen.h:440
VisibilityStates visibility
Definition: mapdisplay.h:55
Definition: sg.h:36
SDLmm::SPoint SPoint
Definition: surface.h:27
Player player[9]
Definition: gamemap.h:253
DashboardPanel * unitInfoPanel
VisibilityStates fieldVisibility(const MapField *pe)
}@
Definition: spfst.cpp:440
static CGameOptions * Instance()
returns the only Instance
Definition: gameoptions.cpp:38
MapInfoPanel * mapInfoPanel
bool toggleFullscreen()
Definition: paradialog.cpp:258
void addMapLayer(MapLayer *layer, const ASCString &name)
The widget that controls the main screen of ASC.
void displayMessage(const ASCString &message)
void activateMapLayer(const ASCString &name, bool active)
void operateField(GameMap *actmap, const MapCoordinate &pos)
void displaymessage2(const char *formatstring,...)
displays a message in the status line of ASC
Interface for all the dialog boxes used by the game and the mapeditor.
int xpos
the position on the map
Definition: vehicle.h:124
The interface for the artificial intelligence of ASC.
bool isActive()
Definition: mapdisplay.h:116
UnitMovementRangeLayer * movementRangeLayer
int getjamming(void)
the radar jamming that is on this field
Definition: mapfield.cpp:537
ActionInfoPanel * actionInfoPanel
A 3D path finding algorithm, based on the 2D algorithm by Amit J. Patel.
Definition: astar2.h:19
Definition: sg.h:46
ASC_MainScreenWidget * mainScreenWidget
MainScreenWidget * getMainScreenWidget()
sigc::signal< void > cursorMoved
Definition: spfst.cpp:48
GameMap * actmap
Definition: spfst.cpp:64
WindInfoPanel * windInfoPanel
GameMap * getMap() const
bool execAction(PG_PopupMenu::MenuItem *menuItem)
void showWeaponRange(GameMap *gamemap, const MapCoordinate &pos)
void update(GameMap *map)
Definition: dashboard.cpp:963
void spawnPanel(Panels panel)
Definition: sg.h:45
void spawnOverviewMapPanel(const ASCString &panelName="OverviewMap")
int ypos
Definition: vehicle.h:124
The box displaying unit information.
int getPlayerCount() const
Definition: gamemap.h:255
void setup(bool messageLine, const PG_Rect &mapView)
static void pushIconHandler(GuiIconHandler *iconHandler)
static const int mainScreenID
Definition: paradialog.h:88
bool exist() const
does the player exist at all
Definition: player.cpp:313
sigc::signal< void, int > lockOptionsChanged
void executeUserAction(tuseractions action)
Definition: sg.cpp:759
bool eventKeyDown(const SDL_KeyboardEvent *key)
vector< ASCString > visibleMapLayer
Definition: gameoptions.h:206
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182
Definition: sg.h:32
MapField * getField(int x, int y)
Definition: gamemap.h:465
void showFieldInformation(int x, int y)
Definition: base.cpp:378