Advanced Strategic Command
paradialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  paradialog.cpp - description
3  -------------------
4  begin : Thu Feb 21 2002
5  copyright : (C) 2002 by Martin Bickel
6  email : bickel@asc-hq.org
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 
19 #include "global.h"
20 
21 #include <boost/algorithm/string.hpp>
22 #include <SDL_image.h>
23 #include <signal.h>
24 
25 #include <paragui.h>
26 #include <pgapplication.h>
27 #include <pgmessagebox.h>
28 #include <pgdropdown.h>
29 #include "pgbutton.h"
30 #include "pglabel.h"
31 #include "pgwindow.h"
32 #include "pgscrollbar.h"
33 #include "pgprogressbar.h"
34 #include "pgradiobutton.h"
35 #include "pgthemewidget.h"
36 #include "pgcheckbutton.h"
37 #include "pgslider.h"
38 #include "pglistbox.h"
39 #include "pgpopupmenu.h"
40 #include "pgmenubar.h"
41 #include "pgimage.h"
42 #include "pgmessagebox.h"
43 #include "pgwindow.h"
44 #include "pgrichedit.h"
45 #include "pgsdleventsupplier.h"
46 #include "pgmultilineedit.h"
47 #include "pgtooltiphelp.h"
48 #include "pglog.h"
49 
50 #include "widgets/multilistbox.h"
51 #include "widgets/textrenderer.h"
53 
54 #include "dialogs/messagedialog.h"
55 
56 #include "paradialog.h"
57 #include "events.h"
58 #include "gameoptions.h"
59 #include "spfst.h"
60 #include "strtmesg.h"
61 
62 #include "graphics/drawing.h"
63 
64 #include "util/messaginghub.h"
65 
66 
67 #include "sdl/graphicsqueue.h"
68 
69 class EventSupplier: public PG_SDLEventSupplier {
70  public:
71 
79  bool PollEvent(SDL_Event* event) {
80  bool result = getQueuedEvent( *event );
81  if ( result )
82  CombineMouseMotionEvents( event );
83  return result;
84  };
85 
93  bool PeepEvent(SDL_Event* event) {
94  return peekEvent( *event );
95  }
96 
103  int WaitEvent(SDL_Event* event)
104  {
105  while ( !getQueuedEvent( *event ))
107  CombineMouseMotionEvents( event );
108  return 1;
109  };
110 
111 } eventSupplier;
112 
113 
114 
115 
116 
117 
119 
120 
121 void signalQuit( int i )
122 {
124 }
125 
126 
127 class ASC_PG_ScreenUpdater : public PG_ScreenUpdater {
128  public:
129  void UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Sint32 w, Sint32 h)
130  {
131  #ifdef WIN32
132  queueOperation( new UpdateRectOp( screen, x, y, w, h ));
133  #else
134  SDL_UpdateRect( screen,x,y,w,h);
135  postScreenUpdate(screen);
136  #endif
137  };
138 
139  void UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects)
140  {
141  #ifdef WIN32
142  queueOperation( new UpdateRectsOp( screen, numrects, rects ));
143  #else
144  SDL_UpdateRects( screen, numrects, rects );
145  postScreenUpdate(screen);
146  #endif
147  }
149 
150 
151 ASC_PG_App :: ASC_PG_App ( const ASCString& themeName ) : fullScreen(false), bitsperpixel(0)
152 {
153  this->themeName = themeName;
154  EnableSymlinks(true);
155  EnableAppIdleCalls();
156  sigAppIdle.connect( sigc::hide( idleEvent.make_slot() ));
157  int i = 0;
158  bool themeFound = false;
159  ASCString path;
160  do {
161  path = getSearchPath ( i++ );
162  if ( !path.empty() ) {
163  AddArchive ( path );
164  if ( !themeFound ){
165  ASCString arch = path + themeName + ".zip";
166  themeFound = AddArchive ( arch.c_str() );
167  if ( themeFound )
168  displayLogMessage( 4, "found dialog theme at " + arch );
169 
170  }
171  }
172  } while ( !path.empty() );
173  PG_LogConsole::SetLogLevel ( PG_LOG_ERR );
174 
175  if ( !themeFound )
176  displayLogMessage( 2, "did not found dialog theme!!" );
177 
178  reloadTheme();
179 
180  pgApp = this;
181  SetEventSupplier ( &eventSupplier );
182  SetScreenUpdater ( &ascScreenUpdater );
183 
184  signal ( SIGINT, &signalQuit );
185 
186  PG_LineEdit::SetBlinkingTime( 500 );
187 
188  SetHighlightingTag( '~' );
189 
190  setMouseUpdateFlag( &CGameOptions::Instance()->hideMouseOnScreenUpdates );
191 
192 }
193 
194 bool ASC_PG_App :: queueWidgetForDeletion( PG_Widget* widget )
195 {
196  deletionQueue.push_back( widget );
197  widget->sigDelete.connect( sigc::mem_fun( *this, &ASC_PG_App::removeFromDeletionQueue ));
198  return true;
199 }
200 
201 
202 bool ASC_PG_App :: removeFromDeletionQueue( const PG_MessageObject* obj )
203 {
204  DeletionQueue::iterator i = find ( deletionQueue.begin(), deletionQueue.end(), obj );
205  if ( i != deletionQueue.end() )
206  deletionQueue.erase( i );
207  return true;
208 }
209 
210 
211 void ASC_PG_App :: setIcon( const ASCString& filename )
212 {
213  SDL_Surface *icn = NULL;
214  try {
215  tnfilestream iconl ( filename, tnstream::reading );
216  icn = IMG_Load_RW ( SDL_RWFromStream( &iconl ), 1);
217  // SDL_SetColorKey(icn, SDL_SRCCOLORKEY, *((Uint8 *)icn->pixels));
218  if ( icn )
219  SDL_WM_SetIcon( icn, NULL );
220  } catch ( ... ) {}
221 }
222 
224 {
225  sigQuit(this);
226  PG_Application::Quit();
227 }
228 
229 
230 bool ASC_PG_App::eventQuit(int id, PG_MessageObject* widget, unsigned long data)
231 {
232  sigQuit(this);
233  return PG_Application::eventQuit( id, widget, data );
234 }
235 
237 {
238  if ( redrawScreen ) {
239  PG_Widget::UpdateScreen();
240  PG_Application::UpdateRect(PG_Application::GetScreen(), 0,0,0,0);
241  redrawScreen = false;
242  }
243 
244  if ( !deletionQueue.empty() )
245  delete deletionQueue.front();
246 
247  PG_Application::eventIdle();
248 }
249 
250 #include "sdl/graphicsqueue.h"
251 
252 void ASC_PG_App::SetNewScreenSurface( SDL_Surface* surface )
253 {
254  SetScreen(surface, false);
255 }
256 
257 
259 {
260  if ( !GetScreen() )
261  return false;
262 
263  int w = GetScreen()->w;
264  int h = GetScreen()->h;
265 
266  // queueOperation( new MouseVisibility( false ), true );
267 
268  int flags = SDL_SWSURFACE;
269  if ( !fullScreen )
270  flags |= SDL_FULLSCREEN;
271 
273  fullScreen = GetScreen()->flags & SDL_FULLSCREEN;
274 
275 
276 /*
277  SDL_Surface* screen = SDL_SetVideoMode(w, h, bitsperpixel, flags);
278  if (screen == NULL) {
279  screen = SDL_SetVideoMode(w, h, bitsperpixel, 0);
280  fullScreen = false;
281  } else
282  fullScreen = !fullScreen;
283  SetScreen(screen);
284 */
285 
286  PG_Widget::UpdateScreen();
287 
288  // queueOperation( new MouseVisibility( true ), true );
289 
290  return true;
291 }
292 
293 
295 {
296  return *pgApp;
297 }
298 
299 
300 static const int progressHeight = 15;
301 
302 StartupScreen::StartupScreen( const ASCString& filename, sigc::signal<void>& ticker ) : versionLabel(NULL), background(NULL), progressBar(NULL), fullscreenImage(NULL)
303 {
304  MessagingHub::Instance().statusInformation.connect( sigc::mem_fun( *this, &StartupScreen::disp ));
305 
306  tnfilestream s ( filename, tnstream::reading );
307 
308 
309  int rt = 0;
310  int gt = 0;
311  int bt = 0;
312 
313  fullscreenImage = Surface( IMG_Load_RW( SDL_RWFromStream( &s ), true ));
314  if ( fullscreenImage.valid() ) {
315  for ( int y = 0; y < fullscreenImage.h(); ++y ) {
316  for ( int x = 0; x < fullscreenImage.w(); ++x ) {
317  Uint8 r,g,b;
318  fullscreenImage.GetPixelFormat().GetRGB( fullscreenImage.GetPixel(x,y), r,g,b );
319  rt += r;
320  gt += g;
321  bt += b;
322  }
323  }
324  rt /= fullscreenImage.h() * fullscreenImage.w();
325  gt /= fullscreenImage.h() * fullscreenImage.w();
326  bt /= fullscreenImage.h() * fullscreenImage.w();
327  }
328 
329 
330 
331 
332  background = new PG_ThemeWidget(NULL, PG_Rect(0,0,PG_Application::GetScreenWidth(), PG_Application::GetScreenHeight()));
333  background->SetSimpleBackground(true);
334  background->SetBackgroundColor( PG_Color( rt, gt, bt ));
335 
336  if ( fullscreenImage.valid() ) {
337  float enw = float(PG_Application::GetScreenWidth() )/float(fullscreenImage.w());
338  float enh = float(PG_Application::GetScreenHeight())/float(fullscreenImage.h());
339 
340  displayLogMessage(6, "Startupscreen : %f / %f", enw, enh );
341 
342  // we allow a asymetric stretch of 5%
343  if ( enw / enh < 0.95 || enw / enh > 1.05 )
344  enh = enw = min( enw, enh );
345 
346  int w = int( ceil( enw * fullscreenImage.w()));
347  int h = int( ceil( enh * fullscreenImage.h()));
348  PG_Rect rect ( (PG_Application::GetScreenWidth()-w)/2, (PG_Application::GetScreenHeight()-h)/2, w,h);
349  PG_ThemeWidget* image = new PG_ThemeWidget( background, rect );
350  image->SetBackground ( fullscreenImage.getBaseSurface(), PG_Draw::STRETCH );
351  }
352 
353  SDL_Surface* screen = PG_Application::GetApp()->GetScreen();
354  progressBar = new AutoProgressBar( ticker, background, PG_Rect( 0, screen->h - progressHeight, screen->w, progressHeight ) );
355 
356  if ( MessagingHub::Instance().getVerbosity() > 0 ) {
357  versionLabel = new PG_Label( background, PG_Rect( 10, screen->h - progressHeight - 25, screen->w/2, 20 ));
358  versionLabel->SetAlignment( PG_Label::LEFT );
359  versionLabel->SetText( getVersionString() );
360  }
361 
362  background->Show();
363 }
364 
368 void StartupScreen::dispLine( const ASCString& s, int line ) {
369  SDL_Surface* screen = PG_Application::GetApp()->GetScreen();
370  while ( infoLabels.size() <= line ) {
371  int y = screen->h - progressHeight - 25 * ( 1 + infoLabels.size());
372  if ( y < 0 )
373  return;
374 
375  PG_Label* l = new PG_Label( background, PG_Rect( screen->w/2, y, screen->w/2 - 10, 20 ));
376  l->SetAlignment( PG_Label::RIGHT );
377  l->SetVisible(true);
378  infoLabels.push_back( l );
379  }
380  infoLabels[line]->SetText(s);
381 }
382 
383 void StartupScreen::disp( const ASCString& s )
384 {
385  vector<ASCString> strs;
386  boost::split(strs, s, boost::is_any_of("\n"));
387 
388  for ( int i = 0; i < strs.size(); ++i)
389  dispLine(strs[i], strs.size() -1 - i);
390  for ( int i = strs.size(); i < infoLabels.size(); ++i )
391  dispLine("", i );
392 }
393 
394 
396 {
397  progressBar->close();
398  delete background;
399 }
400 
401 
402 
403 bool ASC_PG_App:: InitScreen ( int w, int h, int depth, Uint32 flags )
404 {
405  bitsperpixel = depth;
406  bool result = PG_Application::InitScreen ( w, h, depth, flags );
407  if ( result ) {
408  initASCGraphicSubsystem ( GetScreen() );
409  Surface::SetScreen( GetScreen() );
410 
411  fullScreen = flags & SDL_FULLSCREEN;
412 
413  MessagingHub::Instance().error.connect( sigc::bind( sigc::mem_fun( *this, &ASC_PG_App:: messageDialog ), MessagingHubBase::Error ));
414  MessagingHub::Instance().fatalError.connect( sigc::bind( sigc::mem_fun( *this, &ASC_PG_App:: messageDialog ), MessagingHubBase::FatalError ));
415  MessagingHub::Instance().warning.connect(sigc::bind( sigc::mem_fun( *this, &ASC_PG_App:: messageDialog ), MessagingHubBase::Warning ));
416  MessagingHub::Instance().infoMessage.connect( sigc::bind( sigc::mem_fun( *this, &ASC_PG_App:: messageDialog ), MessagingHubBase::InfoMessage ));
417  }
418 
419  return result;
420 }
421 
422 
424 {
425  if ( !LoadTheme(themeName ))
426  fatalError ( "Could not load Paragui theme for ASC: " + themeName );
427 }
428 
429 
431 {
432  return !setEventRouting ( !use, use );
433 }
434 
435 
437 {
438  SDL_Event event;
439  if ( GetEventSupplier()->PollEvent(&event))
440  PumpIntoEventQueue(&event);
441 }
442 
443 
445 {
446  enableLegacyEventHandling ( false );
447  PG_Application::Run();
448 
449  return 0;
450 }
451 
453 {
454  while ( !deletionQueue.empty() )
455  delete deletionQueue.front();
456 
458 }
459 
460 
461 
462 ASC_PG_Dialog :: ASC_PG_Dialog ( PG_Widget *parent, const PG_Rect &r, const ASCString& windowtext, WindowFlags flags, const ASCString& style, int heightTitlebar )
463  :PG_Window ( parent, centerRectangle(r), windowtext, flags, style, heightTitlebar ),stdButtonNum(0), caller(0), standardButtonDir( Vertical )
464 {
465 
466  // it looks nice if you can see the map behind the dialog, but seeing other dialogs stacked above each other is just confusing, so we reduce transparency
467  int t = GetTransparency();
468  if ( WindowCounter::num() >= 1 ) {
469  SetTransparency ( t/2 );
470  }
471 }
472 
473 int WindowCounter::windowNum = 0;
474 
475 
477 {
478  WindowCounter wc;
479 
480  return PG_Window::RunModal();
481 }
482 
483 
484 PG_Rect ASC_PG_Dialog::centerRectangle( const PG_Rect& rect )
485 {
486  PG_Rect r = rect;
487 
488  if ( r.w > PG_Application::GetScreenWidth() )
489  r.w = PG_Application::GetScreenWidth();
490 
491  if ( r.h > PG_Application::GetScreenHeight() )
492  r.h = PG_Application::GetScreenHeight();
493 
494 
495  if ( r.x < 0 )
496  r.x = (PG_Application::GetScreenWidth() - r.w) / 2;
497 
498  if ( r.y < 0 )
499  r.y = (PG_Application::GetScreenHeight() - r.h) / 2;
500 
501 
502  if ( r.x + r.w > PG_Application::GetScreenWidth() )
503  r.x = PG_Application::GetScreenWidth() - r.w;
504 
505  if ( r.y + r.h > PG_Application::GetScreenHeight() )
506  r.y = PG_Application::GetScreenHeight() - r.h;
507 
508  return r;
509 }
510 
512 {
513  standardButtonDir = dir;
514 }
515 
517 {
518  ++stdButtonNum;
519 
520  if ( name.length() == 0 )
521  return NULL;
522 
523  if ( standardButtonDir == Vertical )
524  return new PG_Button( this, PG_Rect( Width() - 110, Height() - stdButtonNum * 40, 100, 30 ), name );
525  else
526  return new PG_Button( this, PG_Rect( Width() - 110 * stdButtonNum, Height() -40 , 100, 30 ), name );
527 }
528 
529 
530 
531 bool ASC_PG_Dialog::eventKeyDown(const SDL_KeyboardEvent *key){
532  if(key->keysym.sym == SDLK_ESCAPE) {
533  closeWindow();
534  }
535  return true;
536 }
537 
538 
539 
540 bool ASC_PG_Dialog::quitModalLoopW(PG_Button* button, int value )
541 {
542  return quitModalLoop( value );
543 }
544 
546 {
547  SetModalStatus( value );
548  PG_Window::QuitModal();
549  return true;
550 }
551 
552 
553 /*
554 bool ASC_PG_Dialog::eventKeyUp (const SDL_KeyboardEvent *key){
555 if(key->keysym.sym == SDLK_ESCAPE){
556  closeWindow();
557  }
558  return true;
559 
560 }
561 
562 
563 bool ASC_PG_Dialog::eventKeyUp (const SDL_KeyboardEvent *key){
564 if(key->keysym.sym == SDLK_ESCAPE){
565  closeWindow();
566  }else if(key->keysym.sym == SDLK_DOWN){
567 
568  }else if(key->keysym.sym == SDLK_UP){
569 
570  }else if(key->keysym.sym == SDLK_RIGHT){
571 
572  }else if(key->keysym.sym == SDLK_LEFT){
573 
574  }
575  return true;
576 
577 }*/
578 
579 
581  PG_Window::QuitModal();
582  if( caller != 0){
583  caller->SetInputFocus();
584  }
585  return true;
586 }
587 
588 
589 
590 
592  bool bulk;
593 public:
595  bulk = PG_Application::GetBulkMode();
596  if ( bulk )
597  PG_Application::SetBulkMode(false);
598  }
600  if ( bulk )
601  PG_Application::SetBulkMode(true);
602  }
603 };
604 
605 
606 void ASC_PG_App:: messageDialog( const ASCString& message, MessagingHubBase::MessageType mt )
607 {
608  AntiBulkHandler abh;
609  ASCString title;
610  ASCString style;
611  switch ( mt ) {
613  title = "Error";
614  style = "ErrorMessage";
615  break;
617  title = "Warning";
618  style = "WarningMessage";
619  break;
621  title = "Information";
622  style = "Window";
623  break;
625  title = "Fatal Error";
626  style = "FatalErrorMessage";
627  break;
628  default: break;
629  };
630 
631  PG_Rect size = calcMessageBoxSize(message);
632  MessageDialog msg( NULL, size, title, message,"OK", PG_Label::CENTER, style );
633  msg.Show();
634  msg.RunModal();
635 }
636 
637 
639 {
640  md = new MessageDialog( NULL, calcMessageBoxSize( msg ), "status", msg, PG_Label::CENTER, "Window" );
641  md->Show();
642 };
643 
645 {
646  md->SetText( text );
647 }
648 
649 
651 {
652  delete md;
653 };
654 
655 
657  PG_ListBox* listbox;
658  int button;
659  int item;
660 
661  bool buttonpressed( PG_Widget* w, int i )
662  {
663  button = i;
664  QuitModal();
665  return true;
666  }
667 
668  bool itemSelected( PG_ListBoxBaseItem* l )
669  {
670  PG_ListBoxDataItem<int>* listitem = dynamic_cast<PG_ListBoxDataItem<int>*>( l );
671  if ( listitem ) {
672  item = listitem->getData();
673  return true;
674  } else
675  return false;
676  }
677 
678  public :
679  NewStringChooser ( const ASCString& _title, const vector<ASCString>& _strings , const vector<ASCString>& _buttons, int defaultEntry ) : ASC_PG_Dialog( NULL, PG_Rect( -1, -1, 500, 300 ), _title ), button(-1), item(-1)
680  {
681  listbox = new PG_ListBox( this, PG_Rect( 10, 30, Width()-140, Height() - 40) );
682  listbox->SetMultiSelect( false );
683  listbox->sigSelectItem.connect( sigc::mem_fun( *this, &NewStringChooser::itemSelected ));
684 
685  int counter = 0;
686  for ( vector<ASCString>::const_iterator i = _strings.begin(); i != _strings.end(); ++i ) {
687  PG_ListBoxDataItem<int>* listitem = new PG_ListBoxDataItem<int>(listbox, 20, *i, counter );
688  if ( counter == defaultEntry )
689  listitem->Select();
690  ++counter;
691  }
692 
693  counter = 0;
694  for ( vector<ASCString>::const_iterator i = _buttons.begin(); i != _buttons.end(); ++i ) {
695  AddStandardButton(*i)->sigClick.connect( sigc::bind( sigc::mem_fun( *this, & NewStringChooser::buttonpressed ),counter ));
696  ++counter;
697  }
698  }
699 
700  int getButton()
701  {
702  return button;
703  }
704  int getItem()
705  {
706  return item;
707  }
708 
709 };
710 
711 
712 pair<int,int> new_chooseString ( const ASCString& title, const vector<ASCString>& entries, const vector<ASCString>& buttons, int defaultEntry )
713 {
714  NewStringChooser nsc ( title, entries, buttons, defaultEntry );
715  nsc.Show();
716  nsc.RunModal();
717  return make_pair(nsc.getButton(), nsc.getItem() );
718 }
719 
720 
721 
723  PG_MultiLineEdit* editor;
724 
725  public:
726  MultiLineEditorDialog( const ASCString& title, const ASCString& textToEdit ) : ASC_PG_Dialog( NULL, PG_Rect( -1, -1, 400, 400 ), title), editor(NULL)
727  {
728  editor = new PG_MultiLineEdit( this, PG_Rect( 10, 40, Width() - 20, Height() - 80 ) );
729  editor->SetText( textToEdit );
730  AddStandardButton( "OK" )->sigClick.connect( sigc::bind( sigc::mem_fun( *this, &MultiLineEditorDialog::quitModalLoopW ), 1 ));
731  }
732 
733  ASCString GetEditedText() { return editor->GetText(); };
734 };
735 
736 bool MultiLineEditor( const ASCString& title, ASCString& textToEdit )
737 {
738  MultiLineEditorDialog mle ( title, textToEdit );
739  mle.Show();
740  if ( mle.RunModal() ) {
741  textToEdit = mle.GetEditedText();
742  return true;
743  } else
744  return false;
745 
746 }
747 
749 {
750  bulk = PG_Application::GetBulkMode();
751  this->parent = parent;
752  PG_Application::SetBulkMode( true );
753  active = true;
754 };
755 
756 
758 {
759  if ( !bulk && active ) {
760  PG_Application::SetBulkMode( false );
761  if ( parent )
762  parent->Update();
763  }
764  active = false;
765 }
766 
768 {
769  release();
770 }
771 
772 void Emboss::eventBlit (SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst)
773 {
774  Surface s = Surface::Wrap( PG_Application::GetScreen() );
775 
776  PG_Rect clip= dst.IntersectRect( PG_Application::GetScreen()->clip_rect );
777  if ( inv )
778  rectangle<4> ( s, SPoint(dst.x, dst.y), dst.w, dst.h, ColorMerger_Brightness<4>( 0.7 ), ColorMerger_Brightness<4>( 1.4 ), clip);
779  else
780  rectangle<4> ( s, SPoint(dst.x, dst.y), dst.w, dst.h, ColorMerger_Brightness<4>( 1.4 ), ColorMerger_Brightness<4>( 0.7 ), clip);
781 };
782 
783 
784 class StringEditor : public ASC_PG_Dialog {
785  PG_LineEdit* editor;
786 
787  public:
788  StringEditor( const ASCString& title, const ASCString& textToEdit ) : ASC_PG_Dialog( NULL, PG_Rect( -1, -1, 400, 200 ), title), editor(NULL)
789  {
790  editor = new PG_LineEdit( this, PG_Rect( 10, 40, Width() - 20, 25 ) );
791  editor->SetText( textToEdit );
792  AddStandardButton( "OK" )->sigClick.connect( sigc::bind( sigc::mem_fun( *this, &StringEditor::quitModalLoopW ), 1 ));
793  }
794 
795  ASCString GetEditedText() { return editor->GetText(); };
796 };
797 
798 ASCString editString2( const ASCString& title, const ASCString& defaultValue )
799 {
800  StringEditor se ( title, defaultValue );
801  se.Show();
802  se.RunModal();
803  return se.GetEditedText();
804 }
805 
806 int choiceDialog(const ASCString& text, const ASCString& button1, const ASCString& button2, const ASCString& shortLabel )
807 {
808 
809  map<ASCString,int>& answers = CGameOptions::Instance()->dialogAnswers;
810 
811  map<ASCString,int>::iterator i = answers.find( shortLabel );
812  if ( i != answers.end() )
813  return i->second;
814 
815  bool saveResult = false;
816  int result = new_choice_dlg(text, shortLabel, button1, button2, saveResult);
817 
818  if ( saveResult ) {
819  answers[shortLabel] = result;
821  }
822 
823  return result;
824 
825 }
826 
StartupScreen(const ASCString &filename, sigc::signal< void > &ticker)
Definition: paradialog.cpp:302
void eventBlit(SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst)
Definition: paradialog.cpp:772
int WaitEvent(SDL_Event *event)
Waits indefinitely for the next available event.
Definition: paradialog.cpp:103
bool getQueuedEvent(SDL_Event &event)
if the events are being queue, get one.
Definition: events.cpp:657
map accessing and usage routines used by ASC and the mapeditor
ASC_PG_App * pgApp
Definition: paradialog.cpp:118
ASCString getSearchPath(int i)
Definition: basestrm.cpp:2539
void setIcon(const ASCString &filename)
Definition: paradialog.cpp:211
bool quitModalLoopW(PG_Button *button, int value)
Definition: paradialog.cpp:540
PG_StatusWindowData(const ASCString &msg)
Definition: paradialog.cpp:638
static int num()
Definition: paradialog.h:121
void SetText(const std::string &text)
int choiceDialog(const ASCString &text, const ASCString &button1, const ASCString &button2, const ASCString &shortLabel)
Definition: paradialog.cpp:806
void StandardButtonDirection(StandardButtonDirectonType dir)
Definition: paradialog.cpp:511
virtual bool eventKeyDown(const SDL_KeyboardEvent *key)
Definition: paradialog.cpp:531
StandardButtonDirectonType
Definition: paradialog.h:139
void SetNewScreenSurface(SDL_Surface *surface)
Definition: paradialog.cpp:252
void processEvent()
Definition: paradialog.cpp:436
bool MultiLineEditor(const ASCString &title, ASCString &textToEdit)
Definition: paradialog.cpp:736
PG_MessageObject * caller
Definition: paradialog.h:131
bool InitScreen(int w, int h, int depth=0, Uint32 flags=SDL_SWSURFACE|SDL_HWPALETTE)
Definition: paradialog.cpp:403
Global platform dependant definitions. This file just branches to the platform specific files in thei...
SDL_Surface * getBaseSurface()
Definition: surface.h:116
ASC_PG_Dialog(PG_Widget *parent, const PG_Rect &r, const ASCString &windowtext, WindowFlags flags=DEFAULT, const ASCString &style="Window", int heightTitlebar=25)
Definition: paradialog.cpp:462
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
static const int progressHeight
Definition: paradialog.cpp:300
ASC_PG_App(const ASCString &themeName)
Definition: paradialog.cpp:151
void initASCGraphicSubsystem(SDL_Surface *_screen)
Definition: graphics.cpp:42
StringEditor(const ASCString &title, const ASCString &textToEdit)
Definition: paradialog.cpp:788
bool enableLegacyEventHandling(bool use)
Definition: paradialog.cpp:430
void UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Sint32 w, Sint32 h)
Definition: paradialog.cpp:129
ASCString GetEditedText()
Definition: paradialog.cpp:733
ASC_PG_App & getPGApplication()
Definition: paradialog.cpp:294
void setChanged(bool flag=true)
Definition: gameoptions.h:272
bool quitModalLoop(int value)
Definition: paradialog.cpp:545
MultiLineEditorDialog(const ASCString &title, const ASCString &textToEdit)
Definition: paradialog.cpp:726
void Quit()
Definition: paradialog.cpp:223
void displayLogMessage(int msgVerbosity, const char *message,...)
static void SetScreen(SDL_Surface *screen)
Definition: surface.cpp:78
void setMouseUpdateFlag(const bool *flag)
passes a references which' value determines if the mouse cursor is hidden on screen updates ...
Definition: events.cpp:69
NewStringChooser(const ASCString &_title, const vector< ASCString > &_strings, const vector< ASCString > &_buttons, int defaultEntry)
Definition: paradialog.cpp:679
Adapter class for using Paragui Dialogs in ASC. This class transfers the event control from ASC to Pa...
Definition: paradialog.h:127
DialogAnswers dialogAnswers
Definition: gameoptions.h:252
Dialog classes based on the Paragui library.
void eventIdle()
Definition: paradialog.cpp:236
virtual bool closeWindow()
Definition: paradialog.cpp:580
ASC_PG_ScreenUpdater ascScreenUpdater
int releasetimeslice(void)
Definition: events.cpp:209
pair< int, int > new_chooseString(const ASCString &title, const vector< ASCString > &entries, const vector< ASCString > &buttons, int defaultEntry)
Definition: paradialog.cpp:712
SDLmm::SPoint SPoint
Definition: surface.h:27
static CGameOptions * Instance()
returns the only Instance
Definition: gameoptions.cpp:38
sigc::signal< void, const SDL_Surface * > postScreenUpdate
Definition: events.cpp:392
bool toggleFullscreen()
Definition: paradialog.cpp:258
bool eventQuit(int id, PG_MessageObject *widget, unsigned long data)
Definition: paradialog.cpp:230
void shutdownASCGraphicSubsystem()
Definition: graphics.cpp:69
void UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects)
Definition: paradialog.cpp:139
int new_choice_dlg(const ASCString &title, const ASCString &leftButton, const ASCString &rightButton)
EventSupplier eventSupplier
sigc::signal< bool > idleEvent
Definition: spfst.cpp:53
static PG_Rect centerRectangle(const PG_Rect &rect)
Definition: paradialog.cpp:484
PG_Rect calcMessageBoxSize(const ASCString &message)
bool setEventRouting(bool queue, bool legacy)
Defines what happens with the SDL events.
Definition: events.cpp:633
void queueOperation(GraphicsQueueOperation *gqo, bool wait, bool forceAsync)
Definition: events.cpp:394
static Surface Wrap(SDL_Surface *surface)
Definition: surface.h:76
const T & min(const T &a, const T &b, const T &c)
Definition: misc.h:80
SDL_RWops * SDL_RWFromStream(tnstream *stream)
Definition: basestrm.cpp:693
bool PollEvent(SDL_Event *event)
Polls for currently pending events, and returns true if there are any pending events, or false if there are none available.
Definition: paradialog.cpp:79
ASCString GetEditedText()
Definition: paradialog.cpp:795
bool queueWidgetForDeletion(PG_Widget *widget)
Definition: paradialog.cpp:194
PG_Button * AddStandardButton(const ASCString &name)
Definition: paradialog.cpp:516
void signalQuit(int i)
Definition: paradialog.cpp:121
bool PeepEvent(SDL_Event *event)
Checks if an event is in the queue.
Definition: paradialog.cpp:93
void fatalError(const ASCString &string)
void reloadTheme()
Definition: paradialog.cpp:423
void SetText(const ASCString &text)
Definition: paradialog.cpp:644
SDL_Surface * screen
Definition: graphics.cpp:31
bool redrawScreen
Definition: events.cpp:63
const char * getVersionString()
Definition: strtmesg.cpp:32
Loki::Functor< void, LOKI_TYPELIST_1(SDL_Surface *) > ScreenRegistrationFunctor
Definition: graphicsqueue.h:54
ASCString editString2(const ASCString &title, const ASCString &defaultValue)
uses the new dialog engine
Definition: paradialog.cpp:798
BulkGraphicUpdates(PG_Widget *parent=NULL)
Definition: paradialog.cpp:748
bool peekEvent(SDL_Event &event)
gets the next event without removing it from the queue.
Definition: events.cpp:670
void line(int x1, int y1, int x2, int y2, Uint8 actcol)
draws a simple line on the screen. Not very fast...
Definition: basegfx.cpp:181
volatile int ticker
Definition: events.cpp:234