Advanced Strategic Command
dlg_box.cpp
Go to the documentation of this file.
1 
6 /*
7  This file is part of Advanced Strategic Command; http://www.asc-hq.de
8  Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger
9 
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program; see the file COPYING. If not, write to the
22  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
23  Boston, MA 02111-1307 USA
24 */
25 
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <stdarg.h>
29 #include <ctype.h>
30 #include <cstring>
31 #include <iostream>
32 
33 #include "typen.h"
34 #include "basegfx.h"
35 #include "newfont.h"
36 #include "spfst.h"
37 #include "loaders.h"
38 #include "misc.h"
39 #include "events.h"
40 #include "stack.h"
41 #include "dlg_box.h"
42 #include "paradialog.h"
43 #include "widgets/textrenderer.h"
44 
45 #include "spfst-legacy.h"
46 
47 
48 #ifdef _WIN32_
49  #include <windows.h>
50  #include <winuser.h>
51 #endif
52 
53 
54 
55 char strrstring[200];
56 
57 void strrd8d(int l, char* s)
58 {
59  itoa ( l / minmalq, s, 10);
60 }
61 
62 void strrd8u(int l, char* s)
63 {
64  itoa ( (l + minmalq - 1) / minmalq, s, 10);
65 }
66 
67 void strrd8n(int l, char* s)
68 {
69  itoa ( (l + minmalq/2) / minmalq, s, 10);
70 }
71 
72 
73 char* strrrd8d(int l)
74 {
75  itoa ( l / minmalq, strrstring, 10);
76 
77  return strrstring;
78 }
79 
80 char* strrrd8u(int l)
81 {
82  itoa ( (l + minmalq - 1) / minmalq, strrstring, 10);
83 
84  return strrstring;
85 }
86 
87 char* strrrd8n(int l)
88 {
89  itoa ( (l + minmalq/2) / minmalq, strrstring, 10);
90 
91  return strrstring;
92 }
93 
94 
95 void *dialogtexture = NULL;
96 
98 long int lastdisplayedmessageticker = 0xffffff;
99 
100 
102 
103 
105 {
106  buf = NULL;
107  size = 0;
108 }
109 
111 {
113  buf = malloc( size );
114 }
115 
117 {
118  free( buf );
119  buf = NULL;
120 }
121 
122 
123 char getletter( const char * s)
124 {
125  const char* c = s;
126 
127  while ( *c && (*c != 126 ))
128  c++;
129 
130  if (*c == '~' ) {
131  c++;
132  return *c;
133  } else {
134  return 0;
135  } /* endif */
136 }
137 
138 
140 
142 {
143  eventQueue = setEventRouting ( false, true );
144 
150 
151 
152  virtualbufoffset = 0;
153  boxstatus = 0;
154 
155  dlg_mode = 0;
156  int rdw = 0;
157 
158  if ( first ) {
159  pdialogbox rn = first;
160  rdw &= rn->getcapabilities() & 1;
161  while ( rn->next ) {
162  rn = rn->next;
163  rdw &= rn->getcapabilities() & 1;
164  }
165 
166 
167  prev = rn;
168  rn->next = this;
169  } else {
170  first = this;
171  prev = NULL;
172  }
173  next = NULL;
174 
175  if ( rdw )
176  dlg_mode |= 2;
177 }
178 
179 
181 {
182  return 0;
183 }
184 
185 extern void repaintdisplay ( void );
186 
187 
189 {/*
190  int ms = getmousestatus();
191  if ( ms == 2 )
192  mousevisible ( false );
193 
194  npush ( *agmp );
195  npush ( *hgmp );
196 
197  hgmp->linearaddress = (PointerSizedInt) virtualscreenbuf.buf;
198  hgmp->windowstatus = 100;
199 
200  *agmp = *hgmp;
201 
202  ::repaintdisplay();
203 
204 
205 
206  npop ( *hgmp );
207  setvirtualframebuf();
208  if ( first )
209  first->setclipping();
210 
211  *agmp = *hgmp;
212 
213  putspritetexture ( 0, 0, hgmp->resolutionx-1, hgmp->resolutiony-1, virtualscreenbuf.buf );
214 
215 
216  npop ( *agmp );
217 
218  if ( ms == 2 )
219  mousevisible ( true );
220  */
221 
222 }
223 
225 {
226  paint();
227  if ( prev )
228  prev->redrawall();
229  else
230  repaintDisplay();
231 }
232 
233 void tdialogbox::redrawall2 ( int xx1, int yy1, int xx2, int yy2 )
234 {
235  paint ();
236  if ( x1 > xx1 || y1 > yy1 || x1+xsize < xx2 || y1+ysize < yy2 ) {
237  if ( prev )
238  prev->redrawall2 ( xx1, yy1, xx2, yy2 );
239  else
240  repaintDisplay();
241  }
242 }
243 
244 
246 
248 {
249  agmp->linearaddress = (PointerSizedInt) virtualscreenbuf.buf;
250  agmp->windowstatus = 100;
252 }
253 
255 {
256  bar ( x1, y1, x1 + xsize, y1 + ysize, 255 );
257  if ( next )
258  next->setclipping ( );
259 }
260 
262 {
263  ms = getmousestatus();
264  if (ms == 2)
265  mousevisible(false);
266 
267  npush ( *agmp );
268  void* buf = (void*) agmp->linearaddress;
269  *agmp = *hgmp;
270 
271  putspritetexture ( x1, y1, x1 + xsize, y1 + ysize, buf );
272 
273  /*
274  for ( int y = y1; y <= y1 + ysize; y++ )
275  for ( int x = x1; x <= x1 + xsize; x++ ) {
276  char c = buf[ virtualbufoffset + y * agmp->scanlinelength + x ];
277  char d = buf[ virtualbufoffset + y * agmp->scanlinelength + x+1 ];
278  if ( d != 255 )
279  putpixel ( x+1, y, lightblue );
280  if ( c != 255 )
281  putpixel ( x, y, c );
282  }
283  */
284 
285  npop ( *agmp );
286 
287  if (ms == 2)
288  mousevisible(true);
289 
290 }
291 
292 void tdialogbox::paint ( void )
293 {
295  redraw();
296  if ( next )
297  next->setclipping();
299  *agmp = *hgmp;
300 }
301 
302 
303 int getplayercolor ( int i )
304 {
305  if ( actmap ) {
306  int textcolor = i * 8 + 21;
307  if ( i == 7 || i == 2 )
308  textcolor += 1;
309  return textcolor;
310  } else
311  return 20;
312 }
313 
315 {
316  imagesaved = false;
317  if ( actmap && actmap->actplayer != -1 ) {
319  }
320  else
321  textcolor = 20;
322 
323  firstbutton = NULL;
325  x1 = 50;
326  xsize = 540;
327  y1 = 50;
328  ysize = 380;
329  starty = 40;
330  title = "dialogbox";
334  memset(taborder, 0, sizeof(taborder));
335  tabcount = 0;
336  markedtab = 0;
338  boxstatus = 1;
339  dlg_mode = 0; // |= getcapabilities();
340 }
341 
342 
343 
344 
345 
346 #include "dlgraph.cpp"
347 
348 
349 
350 
351 
352 
353 
354 
355 
357 {
358  /* runerror(211); */
359 }
360 
362 {
363  pbutton pb = firstbutton;
364  while ( pb && (pb->id != id))
365  pb = pb->next;
366  return pb;
367 }
368 
370 {
371  pbutton pb;
372  int w;
373  Uint16 *pw, *pw2;
374 
375  pb = firstbutton;
376  while ( pb ) {
377  if ((pb->art == 5)) { /* Scrollbar */
378  pw = (Uint16*) pb->data;
379  pw2 = (Uint16*) pb->data2;
380  w = *pw;
381  if ((pb->id + 1 == id)) {
382  if (taste == ct_pup) {
383  if (*pw >= pb->max)
384  *pw -= pb->max - 1;
385  else
386  *pw = 0;
387  }
388  else
389  if (taste == ct_pos1) {
390  *pw = 0;
391  }
392  else
393  if (*pw > 0) {
394  if ( pb->newpressed == 0 ) // Tastatur
395  (*pw) --;
396  else
397  if ( pb->newpressed == 1) {
398  (*pw) --;
399  pb->lasttick = ticker;
400  } else
401  if ( pb->newpressed == 2) {
402  int dst = ticker - pb->lasttick;
403  if ( *pw < dst )
404  (*pw) = 0;
405  else
406  (*pw) -= dst;
407  pb->lasttick = ticker;
408  }
409  }
410  }
411  if ((pb->id + 2 == id)) {
412  if (taste == ct_pdown) {
413  if (*pw + (pb->max * 2) - 1 <= *pw2)
414  *pw += pb->max - 1;
415  else
416  *pw = *pw2 - pb->max;
417  }
418  else
419  if (taste == ct_ende) {
420  *pw = *pw2 - pb->max;
421  }
422  else
423  if ( *pw + pb->max < *pw2 ) {
424 
425  if ( pb->newpressed == 0 ) // Tastatur
426  (*pw)++;
427  else
428  if ( pb->newpressed == 1) {
429  (*pw) ++;
430  pb->lasttick = ticker;
431  } else
432  if ( pb->newpressed == 2) {
433  int dst = ticker - pb->lasttick;
434  if ( *pw + dst + pb->max >= *pw2 )
435  *pw = *pw2 - pb->max;
436 
437  else
438  (*pw) += dst;
439  pb->lasttick = ticker;
440  }
441  }
442  }
443  if (w != *pw) {
444  int mss = getmousestatus();
445  if (mss == 2 )
446  mousevisible(false);
447  showbutton(pb->id);
448  buttonpressed(pb->id);
449  if (mss == 2 )
450  mousevisible(true);
451  }
452 
453  }
454  pb = pb->next;
455  }
456 }
457 
458 
459 void tdlgengine::addbutton( const char * ltxt,
460  tmouserect rect1,
461  int lart,
462  int lstyle,
463  int lid,
464  bool enabled)
465 {
466  addbutton ( ltxt, rect1.x1, rect1.y1, rect1.x2, rect1.y2, lart, lstyle, lid, enabled );
467 }
468 
469 const char* emptystring = "";
470 
471 void tdlgengine::addbutton( const char * ltxt,
472  int lx1,
473  int ly1,
474  int lx2,
475  int ly2,
476  int lart,
477  int lstyle,
478  int lid,
479  bool enabled)
480 {
481  pbutton pb;
482  char ch;
483 
484  pb = firstbutton;
485  if (lid <= 0)
486  displaymessage("tdialogbox: \n id equal or less then 0\n:%d\n",2, lid);
487  while ( pb ) {
488  if (pb->id == lid)
489  displaymessage("tdialogbox: duplicate button id: %d\n",2, lid);
490 
491  pb = pb->next;
492  }
493  pb = new tbutton;
494  pb->x1 = lx1;
495  pb->x2 = lx2;
496  pb->y1 = ly1;
497  pb->y2 = ly2;
498  pb->style = lstyle;
499  pb->id = lid;
500  pb->next = firstbutton;
501  if ( ltxt )
502  pb->text = ltxt;
503  else
504  pb->text = emptystring;
505  pb->art = lart;
506  pb->active = enabled;
507  pb->status = 1;
508  pb->scrollspeed = 30;
509  pb->pressed = 0;
510  pb->newpressed = 0;
511 
512  firstbutton = pb;
513 
514  ch = getletter(pb->text);
515  if (ch != 0) {
516  pb->key[0] = char2key( tolower(ch) );
517  pb->keynum = 1;
518  }
519  else
520  pb->keynum = 0;
521  pb->markedkeynum = 1;
522  pb->markedkey[0] = ct_enter;
523 
524 }
525 
526 
528  int* numberofitems,
529  int itemsvisible,
530  int* actitem,
531  int lid,
532  int keys)
533 {
534  addscrollbar ( rec.x1, rec.y1, rec.x2, rec.y2, numberofitems, itemsvisible, actitem, lid, keys );
535 }
536 
537 void tdialogbox :: bar ( tmouserect rect, int color )
538 {
539  ::bar ( rect.x1, rect.y1, rect.x2, rect.y2, color );
540 }
541 
542 void tdialogbox :: bar ( int x1, int y1, int x2, int y2, int color )
543 {
544  ::bar ( x1, y1, x2, y2, color );
545 }
546 
547 
548 void tdlgengine::addDropDown( int x1, int y1, int x2, int y2, int ID, const char** entries, int entrynum, int* pos )
549 {
550  pbutton pb = firstbutton;
551  if ( ID <= 0)
552  displaymessage("tdialogbox: id equal or less then 0", 2);
553  while (pb != NULL) {
554  if (pb->id == ID)
555  displaymessage("tdialogbox: duplicate button id: %d\n",2, ID);
556  pb = pb->next;
557  }
558  pb = new tbutton;
559  pb->x1 = x1;
560  pb->x2 = x2;
561  pb->y1 = y1;
562  pb->y2 = y2;
563  pb->style = 0;
564  pb->id = ID;
565  pb->next = firstbutton;
566  pb->text = NULL;
567  pb->art = 6;
568  pb->active = true;
569  pb->status = 1;
570  pb->keynum = 0;
571  pb->markedkeynum = 0;
572  pb->scrollspeed = 30;
573  pb->pressed = 0;
574  pb->newpressed = 0;
575  pb->entries = entries;
576  pb->entrynum = entrynum;
577  pb->data = pos;
578  firstbutton = pb;
579 }
580 
581 
583  int ly1,
584  int lx2,
585  int ly2,
586  int* numberofitems,
587  int itemsvisible,
588  int* actitem,
589  int lid,
590  int keys)
591 {
592  pbutton pb;
593 
594  pb = firstbutton;
595  if (lid <= 0)
596  displaymessage("tdialogbox: id equal or less then 0", 2);
597  while (pb != NULL) {
598  if (pb->id == lid)
599  displaymessage("tdialogbox: duplicate button id: %d\n",2, lid);
600  pb = pb->next;
601  }
602  pb = new tbutton;
603  pb->x1 = lx1;
604  pb->x2 = lx2;
605  pb->y1 = ly1 + 13;
606  pb->y2 = ly2 - 13;
607  pb->style = 0;
608  pb->id = lid;
609  pb->next = firstbutton;
610  pb->text = NULL;
611  pb->art = 5;
612  pb->active = true;
613  pb->status = 1;
614  pb->keynum = 0;
615  pb->markedkeynum = 0;
616  pb->scrollspeed = 30;
617  pb->pressed = 0;
618  pb->newpressed = 0;
619  firstbutton = pb;
620 
621  addbutton("",lx1+1, ly1 + 1 , lx2 - 1, ly1 + 10, 0, 2, lid + 1, true);
622  addbutton("",lx1+1, ly2 - 10 , lx2 - 1, ly2 - 1, 0, 2, lid + 2, true);
623 
624  if (keys == 2) {
625  addmarkedkey(lid + 1,ct_up);
626  addmarkedkey(lid + 1,ct_pup);
627  addmarkedkey(lid + 1,ct_pos1);
628 
629  addmarkedkey(lid + 2,ct_down);
630  addmarkedkey(lid + 2,ct_pdown);
631  addmarkedkey(lid + 2,ct_ende);
632  }
633  if (keys == 1) {
634  addkey(lid + 1,ct_up);
635  addkey(lid + 1,ct_pup);
636  addkey(lid + 1,ct_pos1);
637 
638  addkey(lid + 2,ct_down);
639  addkey(lid + 2,ct_pdown);
640  addkey(lid + 2,ct_ende);
641  }
642 
643 
644  pb->data = actitem;
645  pb->data2 = numberofitems;
646  pb->max = itemsvisible;
647 
648 }
649 
650 
652 {
653  pbutton pb = firstbutton;
654  int i = 0;
655  ttaborder b;
656 
657  tabcount = 0;
658  while (pb != NULL) {
659  if ((pb->art >= 0) && (pb->art <= 3))
660  if ((pb->status == 1) && pb->active) {
661  tabcount++;
662  taborder[tabcount].id = pb->id;
663  taborder[tabcount].x1 = pb->x1;
664  taborder[tabcount].y1 = pb->y1;
665  taborder[tabcount].x2 = pb->x2;
666  taborder[tabcount].y2 = pb->y2;
667  taborder[tabcount].button = pb;
668 
669  }
670  pb = pb->next;
671  }
672 
673  if (tabcount > 1)
674  for (i = 1; i <= tabcount - 1; i++) {
675  if ((taborder[i].y1 > taborder[i + 1].y1) || ((taborder[i].y1 == taborder[i + 1].y1) && (taborder[i].x1 > taborder[i + 1].x1)))
676  {
677  b = taborder[i];
678  taborder[i] = taborder[i + 1];
679  taborder[i + 1] = b;
680  if (i > 1)
681  i -= 2;
682  }
683  }
684 
685 
686  pbutton pb2 = NULL;
687  if (i > 0) {
688  if (markedtab > 0)
689  pb2 = taborder[i].button;
690  }
691 
693 
694  if ( markedtab ) {
695  markedtab = 0;
696  if (tabcount > 0) {
697  for (i = 1; i <= tabcount; i++)
698  if (taborder[i].button == pb2)
699  markedtab = i;
700  }
701  }
702 
704 }
705 
706 
708 {
709  pbutton pb;
710  int c;
711  int mss = getmousestatus();
712 
713  if (mss == 2)
714  mousevisible(false);
715  pb = firstbutton;
716  while (pb != NULL) {
717  if (pb->id == id)
718  if ( pb->pressed == 0) {
719  c = pb->status;
720  pb->status = 1;
721  if (pb->active)
722  enablebutton(id);
723  else
724  disablebutton(id);
725 
726  if (pb->art == 5) {
727  showbutton ( id + 1);
728  showbutton ( id + 2);
729  } /* endif */
730 
731  if (c != 1)
732  rebuildtaborder();
733  }
734 
735  pb = pb->next;
736  }
737  if (mss == 2)
738  mousevisible(true);
739 }
740 
741 
743 {
744  pbutton pb;
745 
746  pb = firstbutton;
747  while (pb != NULL) {
748  if (pb->id == id) {
749  pb->status = 0;
750  if (pb->art == 5) {
751  hidebutton ( id + 1);
752  hidebutton ( id + 2);
753  } /* endif */
754  }
755  pb = pb->next;
756  }
757  rebuildtaborder();
758 }
759 
760 
761 
762 void tdlgengine::clearkey ( char id )
763 {
764  pbutton pb = firstbutton;
765  while ( pb ) {
766  if ( pb->id == id ) {
767  pb->keynum = 0;
768  pb->markedkeynum = 0;
769  }
770  pb = pb->next;
771  }
772 }
773 
774 void tdlgengine::addkey( int id, tkey key )
775 {
776  pbutton pb = firstbutton;
777  while ( pb ) {
778  if (pb->id == id) {
779  int exist = 0;
780  for ( int i = 0; i < pb->keynum; i++ )
781  if ( pb->key[i] == key )
782  exist++;
783  if ( !exist ) {
784  pb->key [ pb->keynum ] = key;
785  pb->keynum++;
786  }
787  }
788  pb = pb->next;
789  }
790 }
791 
792 
794 {
795  pbutton pb;
796 
797  pb = firstbutton;
798  while ( pb ) {
799  if (pb->id == id) {
800  int exist = 0;
801  for ( int i = 0; i < pb->markedkeynum; i++ )
802  if ( pb->markedkey[i]== key )
803  exist++;
804  if ( !exist ) {
805  pb->markedkey [ pb->markedkeynum ] = key;
806  pb->markedkeynum++;
807  }
808  }
809  pb = pb->next;
810  }
811 }
812 
813 
814 void tdialogbox::setscrollspeed(char id , int speed)
815 {
816  pbutton pb;
817 
818  pb = firstbutton;
819  while (pb != NULL) {
820  if (pb->id == id) {
821  if (pb->art == 5) {
822  setscrollspeed( id + 1, speed );
823  setscrollspeed( id + 2, speed );
824  } else
825  pb->scrollspeed = speed;
826  }
827 
828  pb = pb->next;
829  }
830 }
831 
832 
834  void* data,
835  int min,
836  int max)
837 {
838  pbutton pb;
839 
840  pb = firstbutton;
841  while (pb != NULL) {
842  if (pb->id == lid) {
843  pb->data = data;
844  if ( min > max ) {
845  pb->min = max;
846  pb->max = min;
847  } else {
848  pb->min = min;
849  pb->max = max;
850  }
851  addmarkedkey(pb->id,ct_enter);
852  addmarkedkey(pb->id,ct_space);
853  }
854  pb = pb->next;
855  }
856 }
857 
858 
859 
861 {
862 
863  pbutton pb = firstbutton;
864  if ( !pb )
865  return;
866 
867 
868  while ( pb && pb->id != id )
869  pb = pb->next;
870 
871  if ( !pb )
872  return;
873 
875 
876  collategraphicoperations cgo ( x1 + pb->x1, max ( y1 + pb->y1 - 20, 0 ), x1 + pb->x2, y1 + pb->y2 );
877 
878  char strng[200];
881  activefontsettings.length = pb->x2 - pb->x1 - 10;
885 
886 
887  if (pb->art == 0) {
888  if ((pb->style == 1) || (pb->style == 2))
889  newknopf(x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2);
890 
891  if ( pb->text )
892  if (pb->text[0] ) {
894  showtext3( pb->text,x1 + pb->x1,y1 + (pb->y1 + pb->y2) / 2 - activefontsettings.font->height / 2);
895  }
896  }
897 
898  if ((pb->art == 1) || ( pb->art == 2 )) {
899  rahmen(true,x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2);
900  paintsurface( pb->x1 + 1, pb->y1 + 1, pb->x2 - 1, pb->y2 - 1 );
901  if ( pb->text )
902  if (pb->text[0] ) {
903  if ( pb->style != 3 ) {
904  showtext3(pb->text,x1 + pb->x1,y1 + pb->y1 - activefontsettings.font->height);
905  } else {
908  cgo.off();
909  showtext3(pb->text,x1 + pb->x2 + 10,y1 + pb->y1 );
910  cgo.on();
912  }
913  }
914 
915  if (pb->art == 1)
916  showtext2((char*) pb->data , x1 + pb->x1 + 5,y1 + pb->y1 + 2);
917 
918  if (pb->art == 2) {
919  if (pb->max <= 255 && pb->min >= 0) {
920  char* pbt = (char*) pb->data;
921  itoa ( *pbt, strng, 10 );
922  showtext2( strng, x1 + pb->x1 + 5,y1 + pb->y1 + 2);
923  }
924  else
925  if (pb->max <= 65535 && pb->min >= 0) {
926  Uint16* pw = (Uint16*) pb->data;
927  itoa ( *pw, strng, 10 );
928  showtext2(strng, x1 + pb->x1 + 5,y1 + pb->y1 + 2);
929  }
930  else {
931  int* pl = (int*) pb->data;
932  itoa ( *pl, strng, 10 );
933  showtext2(strng, x1 + pb->x1 + 5,y1 + pb->y1 + 2);
934  }
935  }
936  }
937  if (pb->art == 3) {
938  rahmen(true,x1 + pb->x1,y1 + pb->y1,x1 + pb->x1 + (pb->y2 - pb->y1),y1 + pb->y2);
939 
940  showtext3(pb->text,x1 + pb->x1 + (pb->y2 - pb->y1) + 5,y1 + (pb->y1 + pb->y2 - activefontsettings.font->height) / 2);
941 
942  char* pbl = (char*) pb->data;
943 
944  int cl;
945  if (*pbl)
946  cl = pb->min;
947  else
948  cl = pb->max;
949 
950  line(x1 + pb->x1,y1 + pb->y1,x1 + pb->x1 + (pb->y2 - pb->y1),y1 + pb->y2, cl);
951  line(x1 + pb->x1 + (pb->y2 - pb->y1),y1 + pb->y1,x1 + pb->x1,y1 + pb->y2, cl);
952  }
953 
954  if (pb->art == 5) { // Scrollbar
955  Uint16* pw = (Uint16*) pb->data;
956  Uint16* pw2 =(Uint16*) pb->data2;
957  rahmen(true,x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2);
958 
959  paintsurface2(x1 + pb->x1 + 1,y1 + pb->y1 + 1,x1 + pb->x2 - 1,y1 + pb->y2 - 1 );
960 
961  // if (pb->max <= *pw2) {
962  int l = pb->y2 - pb->y1 - 2;
963  rahmen(false, x1 + pb->x1 + 1, y1 + pb->y1 + 1 + l * *pw / *pw2,
964  x1 + pb->x2 - 1, y1 + pb->y1 + 1 + l * (*pw + pb->max) / *pw2);
965  // }
966  // else
967  // rahmen(true,x1 + pb->x1 + 1,y1 + pb->y1 + 1,x1 + pb->x2 - 1,y1 + pb->y2 - 1);
968 
969  }
970 
971  if ( pb->art == 6 ) {
972  bar ( x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2, lightgray );
973  rahmen(true,x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2);
974  int pos = *( (int*) pb->data );
975  if ( pos < 0 || pos >= pb->entrynum )
976  fatalError("invalid pos in dropdown",2);
977 
978  showtext3(pb->entries[pos], x1 + pb->x1 + (pb->y2 - pb->y1) + 5, y1 + (pb->y1 + pb->y2 - activefontsettings.font->height) / 2);
979 
980  line ( x1 + pb->x2 - 20, y1 + pb->y1 + 4, x1 + pb->x2 - 10, y1 + pb->y1 + 4, textcolor );
981  line ( x1 + pb->x2 - 20, y1 + pb->y1 + 4, x1 + pb->x2 - 15, y1 + pb->y1 + 14, textcolor );
982  line ( x1 + pb->x2 - 10, y1 + pb->y1 + 4, x1 + pb->x2 - 15, y1 + pb->y1 + 14, textcolor );
983  }
984 
985  pb->active = true;
987  rebuildtaborder();
988 }
989 
990 
991 
992 
994 {
995  pbutton pb;
996  int *pl;
997  Uint16 *pw, *pw2;
998  char *pbt;
999  char *pbl;
1000  char* s;
1001  char* t;
1002  int l;
1003  char cl;
1004 
1005  pb = firstbutton;
1006  if ( !pb )
1007  return;
1008  while ((pb != NULL) && (pb->id != id))
1009  pb = pb->next;
1010  if (pb == NULL)
1011  return;
1012 
1016  activefontsettings.length = pb->x2 - pb->x1 - 10;
1018 
1019  s = new char[200];
1020  strcpy(s, pb->text);
1021 
1022  t = strchr( s, 126 );
1023  while ( t != NULL ) {
1024  do {
1025  t[0] = t[1];
1026  t++;
1027  } while ( t[0] !=0 ) ;
1028  t = strchr( s, 126 );
1029  }
1030 
1031  if (pb->art == 0) {
1032  if (pb->text != NULL)
1033  if (pb->text[0] != 0) {
1035  showtext2(s, x1 + pb->x1, y1 + (pb->y1 + pb->y2) / 2 - activefontsettings.font->height / 2);
1036  }
1037  if ((pb->style == 1) || (pb->style == 2)) {
1038  rectangle(x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2,disablecolor);
1039  rectangle(x1 + pb->x1 - 1,y1 + pb->y1 - 1,x1 + pb->x2 + 1,y1 + pb->y2 + 1,disablecolor);
1040  }
1041  }
1042  if ((pb->art == 1) || (pb->art == 2)) {
1043  rectangle(x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2,disablecolor);
1044  if (pb->text != NULL)
1045  if (pb->text[0] != 0) {
1046  if ( pb->style != 3 )
1047 
1048  showtext2(pb->text,x1 + pb->x1,y1 + pb->y1 - activefontsettings.font->height);
1049  else {
1052  showtext2(pb->text,x1 + pb->x2 + 10,y1 + pb->y1 );
1054  }
1055  }
1056 
1057  if (pb->art == 1) {
1058  showtext2( (char*)pb->data,x1 + pb->x1 + 5,y1 + pb->y1 + 2);
1059  }
1060  if (pb->art == 2) {
1061  if (pb->max <= 255 && pb->min >= 0) {
1062  pbt = (char*) pb->data;
1063  itoa ( *pbt, s, 10 );
1064  showtext2(s,x1 + pb->x1 + 5,y1 + pb->y1 + 2);
1065  }
1066  else
1067  if (pb->max <= 65535 && pb->min >= 0) {
1068  pw = (Uint16*) pb->data;
1069  itoa ( *pw, s , 10);
1070  showtext2(s, x1 + pb->x1 + 5,y1 + pb->y1 + 2);
1071  }
1072  else {
1073  pl = (int*) pb->data;
1074  itoa ( *pl, s, 10);
1075  showtext2(s, x1 + pb->x1 + 5,y1 + pb->y1 + 2);
1076  }
1077  }
1078  }
1079  if (pb->art == 3) {
1080  rectangle(x1 + pb->x1,y1 + pb->y1,x1 + pb->x1 + (pb->y2 - pb->y1),y1 + pb->y2,disablecolor);
1081  showtext2(s,x1 + pb->x1 + (pb->y2 - pb->y1) + 5,y1 + (pb->y1 + pb->y2 - activefontsettings.font->height) / 2);
1082  pbl = (char*) pb->data;
1083  if (*pbl)
1084  cl = disablecolor;
1085  else
1086  cl = pb->max;
1087  line(x1 + pb->x1,y1 + pb->y1,x1 + pb->x1 + (pb->y2 - pb->y1),y1 + pb->y2, cl);
1088  line(x1 + pb->x1 + (pb->y2 - pb->y1),y1 + pb->y1,x1 + pb->x1,y1 + pb->y2, cl);
1089  }
1090  if (pb->art == 5) {
1091  pw = (Uint16*) pb->data;
1092  pw2 = (Uint16*) pb->data2;
1093  // waitretrace();
1094  rectangle(x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2,disablecolor);
1095 
1096  paintsurface2(x1 + pb->x1 + 1,y1 + pb->y1 + 1,x1 + pb->x2 - 1,y1 + pb->y2 - 1);
1097 
1098  if (pb->max <= *pw2) {
1099  l = pb->y2 - pb->y1 - 2;
1100  rectangle(x1 + pb->x1 + 1,y1 + pb->y1 + 1 + l * *pw / *pw2,x1 + pb->x2 - 1,y1 + pb->y1 + 1 + l * (*pw + pb->max) / *pw2,disablecolor);
1101  }
1102  else
1103  rectangle(x1 + pb->x1 + 1,y1 + pb->y1 + 1,x1 + pb->x2 - 1,y1 + pb->y2 - 1,disablecolor);
1104 
1105  }
1106  delete[] s;
1107  pb->active = false;
1109  rebuildtaborder();
1110 }
1111 
1112 
1114 {
1115  pbutton pb;
1116 
1117 
1118  knopf(x1,y1,x1 + xsize,y1 + ysize);
1119 
1120 
1121  rahmen(false, x1,y1,x1 + xsize, y1 + ysize);
1122 
1123 
1130 
1131  if (windowstyle & dlg_wintitle ) {
1132  starty = 25;
1133  rahmen(true,x1 + 5,y1 + 3,x1 + xsize - 5,y1 + 20);
1134  bar(x1 + 6,y1 + 4,x1 + xsize - 6,y1 + 19,blue);
1135 
1137  showtext2(title, x1 + 5,y1 + 3);
1138  }
1139  else {
1140  starty = 5;
1141  if ((windowstyle & dlg_notitle) == 0)
1142  if (title != NULL)
1143  if (title[0] ) {
1145  if ( windowstyle & dlg_3dtitle ) {
1146  if ( actmap && actmap->actplayer == 7 ) {
1148  showtext2(title, x1 + 4, y1 + 4 );
1150  showtext2(title, x1 + 6, y1 + 6 );
1151  } else {
1153  showtext2(title, x1 + 4, y1 + 4 );
1155  showtext2(title, x1 + 6, y1 + 6 );
1156  }
1157  }
1158 
1160  showtext2(title, x1 + 5, y1 + 5 );
1161  starty = 40;
1162  }
1163  }
1164  if (windowstyle & dlg_in3d )
1165  rahmen(true,x1 + 5,y1 + starty,x1 + xsize - 5,y1 + ysize - 5);
1166 
1167  pb = firstbutton;
1168  while (pb != NULL) {
1169  if (pb->status) {
1170  if (pb->active)
1171  enablebutton(pb->id);
1172  else
1173  disablebutton(pb->id);
1174  }
1175  pb = pb->next;
1176  }
1177 }
1178 
1179 
1181 {
1182 
1183  if ( x1 == -1 )
1184  x1 = ( agmp->resolutionx - xsize ) / 2;
1185  else
1186  if ( x1 + xsize < 640 )
1187  x1 += (agmp->resolutionx - 640) / 2;
1188 
1189  if ( y1 == -1 )
1190  y1 = ( agmp->resolutiony - ysize ) / 2;
1191  else
1192  if ( y1 + ysize < 480 )
1193  y1 += (agmp->resolutiony - 480) / 2;
1194 
1195  if ( xsize == -1)
1196  xsize = agmp->resolutionx - xsize*2;
1197  if ( ysize == -1)
1198  ysize = agmp->resolutiony - ysize*2;
1199 
1200  if ( pcgo )
1201  delete pcgo;
1202  pcgo = new collategraphicoperations ( x1, y1, x1 + xsize, y1 + ysize );
1203 
1204  if (windowstyle & dlg_notitle )
1205  if (windowstyle & dlg_wintitle )
1207 
1208  ms = getmousestatus();
1209  if (ms == 2)
1210  mousevisible(false);
1211 
1212  if ( !(dlg_mode & 2) ) {
1213  tp = malloc ( imagesize (x1,y1,x1 + xsize,y1 + ysize ) );
1214  getimage(x1,y1,x1 + xsize,y1 + ysize,tp);
1215  imagesaved = true;
1216  }
1217 
1218  if ( dlg_mode & 1 ) {
1219  paint ();
1220  } else {
1221  redraw ();
1222  }
1223 
1224  rebuildtaborder();
1226  boxstatus = 2;
1227 
1228 // if (ms == 2)
1229 // mousevisible(true);
1230 
1231 }
1232 
1233 
1234 
1236 {
1237  pbutton pb;
1238  pbutton pb2;
1239 
1240  if ( boxstatus ) {
1241  ms = getmousestatus();
1242  if (ms == 2)
1243  mousevisible(false);
1244  pb = firstbutton;
1245  while (pb != NULL) {
1246  pb2 = pb->next;
1247  delete ( pb );
1248  pb = pb2;
1249  }
1250 
1251  if (imagesaved) {
1252  if ( first == this )
1253  ::repaintDisplay();
1254  else
1255  putimage(x1,y1,tp);
1256  free ( tp );
1257  }
1259  if (ms == 2)
1260  mousevisible(true);
1261  }
1262  boxstatus = 0;
1263 }
1264 
1265 
1266 void tdialogbox::execbutton( pbutton pb, char mouse )
1267 {
1268  int t, l;
1269  Uint16 *pw, *pw2;
1270 
1271 
1272  if (mouse == false) {
1273  if (pb->art == 0) {
1274  if ((pb->style == 1) || (pb->style == 2))
1275  buttonpressed(pb->id);
1276  }
1277  if (pb->art == 3)
1278  toggleswitch(pb);
1279  }
1280  else {
1281  if (pb->art == 0) {
1282  if (pb->style == 1) {
1283  newknopfdruck(x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2);
1284  if (knopfsuccessful)
1285  buttonpressed(pb->id);
1286  }
1287  if (pb->style == 2) {
1288  mousevisible(false);
1289  pb->pressed = 1;
1290  pb->newpressed = 1;
1291  newknopfdruck4(x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2);
1292  mousevisible(true);
1293  t = ticker;
1294  buttonpressed(pb->id);
1295  pb->newpressed = 2;
1296  while ((mouseparams.x >= x1 + pb->x1) && (mouseparams.x <= x1 + pb->x2) && (mouseparams.y >= y1 + pb->y1) && (mouseparams.y <= y1 + pb->y2) && (mouseparams.taste & 1)) {
1297  if (ticker - t > pb->scrollspeed ) {
1298  t = ticker;
1299  buttonpressed(pb->id);
1300  }
1301  releasetimeslice();
1302  }
1303  mousevisible(false);
1304  newknopfdruck3(x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2);
1305  pb->newpressed = 0;
1306  pb->pressed = 0;
1307  mousevisible(true);
1308  }
1309 
1310  }
1311  if (pb->art == 3) {
1312  toggleswitch(pb);
1313  do {
1314  releasetimeslice();
1315  } while (!(mouseparams.taste == 0));
1316  }
1317 
1318  if (pb->art == 5) { // Scrollbar
1319  pw = (Uint16*) pb->data;
1320  pw2 = (Uint16*) pb->data2;
1321 
1322  l = pb->y2 - pb->y1 - 2;
1323 
1324  int xb1 = x1 + pb->x1;
1325  int yb1 = y1 + pb->y1;
1326  int xb2 = x1 + pb->x2;
1327  int yb2 = y1 + pb->y2;
1328 
1329 
1330  if ( mouseparams.y >= yb1 + 1 + l * *pw / *pw2 && mouseparams.y <= yb1 + 1 + l * (*pw + pb->max) / *pw2) {
1331  int mss = getmousestatus ();
1332  if (mss == 2)
1333  mousevisible(false);
1334 
1335  int ys1 = yb1 + 1 + l * *pw / *pw2;
1336  int ys1a = ys1;
1337  int ys1b = ys1a;
1338  int ysd = yb1 + 1 + l * (*pw + pb->max) / *pw2 - ys1;
1339  rahmen(true, xb1 + 1, ys1,
1340  xb2 - 1, ys1 + ysd);
1341  int mousestarty = mouseparams.y;
1342 
1343  mousevisible( true );
1344 
1345  while (mouseparams.taste & 1) {
1346  int i = mouseparams.y - mousestarty ;
1347  ys1 = ys1a + i;
1348  if ( ys1 <= yb1)
1349  ys1 = yb1+1;
1350  if ( ys1 + ysd >= yb2 )
1351  ys1 = yb2 - ysd - 1;
1352 
1353  if ( ys1 != ys1b ) {
1354  collategraphicoperations cgo ( x1 + pb->x1, y1 + pb->y1, x1 + pb->x2, y1 + pb->y2 );
1355  ys1b = ys1;
1356  // waitretrace();
1357  mousevisible(false);
1358  paintsurface2(x1 + pb->x1 + 1,y1 + pb->y1 + 1,x1 + pb->x2 - 1,y1 + pb->y2 - 1 );
1359  rahmen(true, xb1 + 1, ys1, xb2 - 1, ys1 + ysd);
1360  cgo.off();
1361  int j = (ys1 - yb1 - 1) * (*pw2) / l;
1362  if (j != *pw) {
1363  *pw = j;
1364  buttonpressed(pb->id);
1365  }
1366  mousevisible( true );
1367  }
1368  releasetimeslice();
1369  }
1370  mousevisible( false );
1371  showbutton( pb->id );
1372  if (mss == 2)
1373  mousevisible(true);
1374  } else {
1375 
1376  l = *pw;
1377  t = mouseparams.y - (pb->y1 + y1);
1378  *pw = (10 * t * (*pw2 - pb->max) / (pb->y2 - pb->y1 - 2) + 5) / 10;
1379  if (*pw != l) {
1380  l = getmousestatus();
1381  if (l == 2)
1382  mousevisible(false);
1383  showbutton(pb->id);
1384  buttonpressed(pb->id);
1385  if (l == 2)
1386  mousevisible(true);
1387  }
1388  }
1389  }
1390 
1391  if (pb->art == 6) {
1392 
1393  int height = pb->entrynum * 25 + 10;
1394  int starty = y1 + pb->y2;
1395  if ( starty + height > agmp->resolutiony )
1396  starty = agmp->resolutiony - height;
1397 
1398  mousevisible(false);
1399 
1400  int* pos = (int*) pb->data ;
1401 
1405  activefontsettings.length = (Uint16) (pb->x2 - pb->x1 - 20 );
1406 
1407  void* buf = malloc ( imagesize ( x1 + pb->x1, starty, x1 + pb->x2, starty + height ));
1408  getimage( x1 + pb->x1, starty, x1 + pb->x2, starty + height, buf );
1409 
1410  bar ( x1 + pb->x1, starty, x1 + pb->x2, starty + height, lightgray );
1411  rectangle ( x1 + pb->x1, starty, x1 + pb->x2, starty + height, black );
1412 
1413  bool first = true;
1414  int oldpos = *pos;
1415 
1416  mousevisible(true);
1417  do {
1418  int p = (mouseparams.y - starty - 5);
1419  if ( p < 0 )
1420  p = -1;
1421  else
1422  p /= 25;
1423 
1424  if ( (p >= 0 && p < pb->entrynum ) || first )
1425  if ( p != *pos || first ) {
1426  if ( p != *pos && p >= 0 && p < pb->entrynum )
1427  *pos = p;
1428  for ( int i = 0; i < pb->entrynum; ++i ) {
1429  if ( i == *pos )
1431  else
1433  showtext2 ( pb->entries[i], x1 + pb->x1 + 5, starty + i * 25 + 5 );
1434  }
1435  }
1436  releasetimeslice();
1437  first = false;
1438  } while ((mouseparams.x >= x1 + pb->x1) && (mouseparams.x <= x1 + pb->x2) && (mouseparams.y >= min(starty, y1+pb->y1)) && (mouseparams.y <= starty + height) && (mouseparams.taste & 1)) ;
1439  mousevisible(false);
1440 
1441  putimage ( x1 + pb->x1, starty, buf );
1442  free ( buf );
1443  mousevisible(true);
1444  enablebutton( pb->id );
1445  if ( oldpos != *pos )
1446  buttonpressed( pb->id );
1447  }
1448 
1449  if ( pb->art > 10 ) {
1450  buttonpressed(pb->id);
1451  while ( mouseinrect ( x1 + pb->x1 , y1 + pb->y1 , x1 + pb->x2 , y1 + pb->y2 ) && ( mouseparams.taste & 1))
1452  releasetimeslice();
1453  }
1454 
1455  /*
1456  rahmen(true,x1+pb^.x1,y1+pb^.y1,x1+pb^.x2,y1+pb^.y2);
1457  nbar(x1+pb^.x1+1,y1+pb^.y1+1,x1+pb^.x2-1,y1+pb^.y2-1,dblue);
1458  rahmen(false,x1 + pb^.x1+1,y1 + pb^.y1+1+ l * pw^ div pw2^ ,
1459  x1 + pb^.x2-1,y1 + pb^.y1+1+ l * (pw^+ pb^.max) div pw2^); */
1460 
1461 
1462  }
1463  if ((pb->art == 1) || (pb->art == 2)) {
1464  editfield(pb);
1465  buttonpressed(pb->id);
1466  }
1467 }
1468 
1469 
1471 {
1472  if (b != 0)
1473  xorrectangle(x1 + taborder[b].x1 - 2,y1 + taborder[b].y1 - 2,x1 + taborder[b].x2 + 2,y1 + taborder[b].y2 + 2,15);
1474 }
1475 
1476 
1478 {
1479  if ( pcgo ) {
1480  delete pcgo;
1481  pcgo = NULL;
1482  }
1483 
1484  int xm, ym, xp, yp;
1485  int i, oldx, oldy, xp2, yp2;
1486  pbutton pb;
1487 
1488  taste = ct_invvalue;
1489  if (getmousestatus() == 2) {
1490 
1491  if ((mouseparams.x > x1 + 5) && (mouseparams.y > y1 + 3) && (mouseparams.x < x1 + xsize - 5) && (mouseparams.y < y1 + 20) && (mouseparams.taste == 1) && (dlg_mode & 3) == 3 ) {
1492 
1493  oldx = x1;
1494  oldy = y1;
1495  xp2 = oldx;
1496  yp2 = oldy;
1497 
1498  xm = mouseparams.x;
1499  ym = mouseparams.y;
1500  xp = xm;
1501  yp = ym;
1502 
1503  while (mouseparams.taste == 1) {
1504  if ((mouseparams.x != xp) || (mouseparams.y != yp)) {
1505  x1 = oldx + (mouseparams.x - xm);
1506  y1 = oldy + (mouseparams.y - ym);
1507  if (x1 < 0) x1 = 0;
1508  if (y1 < 0) y1 = 0;
1509  if (x1 + xsize >= agmp->resolutionx) x1 = agmp->resolutionx - xsize - 1;
1510  if (y1 + ysize >= agmp->resolutiony) y1 = agmp->resolutiony - ysize - 1;
1511  if ((x1 != xp2) || (y1 != yp2)) {
1512 
1513  mousevisible(false);
1514  xorrectangle(xp2,yp2,xp2 + xsize,yp2 + ysize,14);
1515  xorrectangle(x1,y1,x1 + xsize,y1 + ysize,14);
1516  mousevisible(true);
1517 
1518  xp2 = x1;
1519  yp2 = y1;
1520 
1521 /*
1522  int ox = xp2;
1523  int oy = yp2;
1524 
1525 
1526  paint();
1527 
1528  if ( prev )
1529  prev->redrawall2( ox, oy, ox + xsize, oy + ysize );
1530  else
1531  repaintdisplay();
1532 */
1533  }
1534  xp = mouseparams.x;
1535  yp = mouseparams.y;
1536  }
1537  releasetimeslice();
1538  }
1539 
1540 
1541  if ((oldx != x1) || (oldy != y1)) {
1542 
1543  paint();
1544 
1545  if ( prev )
1546  prev->redrawall2( oldx, oldy, oldx + xsize, oldy + ysize );
1547  else
1548  repaintDisplay();
1549 
1550  }
1551 
1552  }
1553  if (mouseparams.taste == 1) {
1554  pb = firstbutton;
1555  while (pb != NULL) {
1556  if (pb->status)
1557  if (pb->active) {
1558  if ((mouseparams.x >= x1 + pb->x1) && (mouseparams.x <= x1 + pb->x2) && (mouseparams.y >= y1 + pb->y1) && (mouseparams.y <= y1 + pb->y2)) {
1559  execbutton(pb,true);
1560  break;
1561  }
1562  }
1563  pb = pb->next;
1564  }
1565  }
1566  }
1567  if (keypress()) {
1568  getkeysyms ( &taste, &prntkey );
1569  }
1570  else {
1571  taste = ct_invvalue;
1573  }
1574 
1575  releasetimeslice();
1576 
1577  if (((taste == ct_tab) || (taste == ct_shift_tab)) && (tabcount > 0)) {
1579  if (taste == ct_tab)
1580  markedtab++;
1581  else
1582  markedtab--;
1583  if (markedtab > tabcount)
1584  markedtab = 1;
1585  if (markedtab < 1)
1586  markedtab = tabcount;
1588  }
1589  else {
1590  pb = firstbutton;
1591  while (pb != NULL) {
1592  if (pb->markedkeynum > 0)
1593  for (i = 0; i < pb->markedkeynum; i++)
1594  if (markedtab > 0)
1595  if ((pb->markedkey[i] == prntkey) && (taborder[markedtab].id == pb->id))
1596  if (pb->active)
1597  if (pb->status == 1) {
1598  execbutton(pb,false);
1599  taste = ct_invvalue;
1600  prntkey = ct_invvalue;
1601  }
1602  if (pb->keynum > 0)
1603  for (i = 0; i < pb->keynum; i++)
1604  if (pb->key[i] == prntkey)
1605  if (pb->active)
1606  if (pb->status == 1) {
1607  execbutton(pb,false);
1608  taste = ct_invvalue;
1609  prntkey = ct_invvalue;
1610  }
1611  pb = pb->next;
1612  }
1613  }
1614 }
1615 
1616 
1617 
1619 {
1620 
1621  char *pbl = (char*) pb->data;
1622 
1623  if ( pb->style == 10 )
1624  *pbl = 1;
1625  else
1626  *pbl = ! *pbl;
1627 
1628 
1629  int col;
1630 
1631  if (*pbl)
1632  col = pb->min;
1633  else
1634  col = pb->max;
1635 
1636  line(x1 + pb->x1,y1 + pb->y1,x1 + pb->x1 + (pb->y2 - pb->y1),y1 + pb->y2, col);
1637  line(x1 + pb->x1 + (pb->y2 - pb->y1),y1 + pb->y1,x1 + pb->x1,y1 + pb->y2, col);
1638 
1639  buttonpressed(pb->id);
1640 
1641 }
1642 
1643 
1645  void* p)
1646 {
1647  return true;
1648 }
1649 
1650 
1652 {
1653  pbutton pb = firstbutton;
1654  while ( pb ) {
1655  if (pb->id == id )
1656  editfield ( pb );
1657  pb = pb->next;
1658  }
1659 }
1660 
1661 
1663 {
1664  char *ps = NULL;
1665  int *pl = NULL;
1666  Uint16 *pw = NULL;
1667  char *pbt = NULL;
1668  int l;
1669 
1673  activefontsettings.length = (Uint16) (pb->x2 - pb->x1 - 10 );
1674 
1675  if (pb->art == 1) {
1676  ps = (char*) pb->data;
1677  // mousevisible(false);
1678  do {
1679  stredit(ps, x1 + pb->x1 + 5,y1 + pb->y1 + 2,pb->x2 - pb->x1 - 10, pb->max);
1680  } while ( !checkvalue(pb->id,ps) );
1681  // mousevisible(true);
1682  }
1683  if (pb->art == 2) {
1684  if (pb->max <= 255 && pb->min >= 0) {
1685  pbt = (char*) pb->data;
1686  l = *pbt;
1687  }
1688  else
1689  if (pb->max <= 65535 && pb->min >= 0) {
1690  pw = (Uint16*) pb->data;
1691  l = *pw;
1692  }
1693  else {
1694  pl = (int*) pb->data;
1695  l = *pl;
1696  }
1697  // mousevisible(false);
1698  do {
1699  intedit( &l,x1 + pb->x1 + 5,y1 + pb->y1 + 2,pb->x2 - pb->x1 - 10,pb->min,pb->max);
1700  } while ( !checkvalue(pb->id, &l) );
1701  // mousevisible(true);
1702  if (pb->max <= 255 && pb->min >= 0) {
1703  *pbt = l;
1704  }
1705  else
1706  if (pb->max <= 65535 && pb->min >= 0) {
1707  *pw = l;
1708  }
1709  else {
1710  *pl = l;
1711  }
1712  }
1713 }
1714 
1715 
1716 
1717 
1718 void tdialogbox::rahmen3(const char * txt,
1719  int x1,
1720  int y1,
1721  int x2,
1722  int y2,
1723  int style)
1724 {
1725  collategraphicoperations cgs( x1, y1, x2, y2 );
1726 
1727  Uint16 w;
1728 
1731  w = gettextwdth(txt,NULL);
1732  if (style == 1) {
1733  line(x1,y1,x1,y2,black);
1734  line(x1,y2,x2,y2,black);
1735  line(x2,y1,x2,y2,black);
1736  line(x1,y1,x1 + 9,y1,black);
1737  line(x1 + 10 + w + 5,y1,x2,y1,black);
1738  }
1741  showtext2(txt,x1 + 12,y1 - activefontsettings.font->height / 2);
1742 
1744 }
1745 
1746 
1747 typedef char* tstringa[30];
1748 typedef tstringa* pstringa;
1749 
1750 
1751 class tdisplaymessage : public tdialogbox {
1752  Uint8 status;
1753  int mode;
1754  public:
1755  void init ( tstringa a, int md, int linenum, const char* buttonText = NULL );
1756  virtual void buttonpressed ( int id );
1757  virtual void run ( void );
1758  };
1759 
1760 extern tdisplaymessage* messagebox;
1761 
1762 
1763 void tdisplaymessage::init ( tstringa a, int md, int linenum, const char* buttonText )
1764 {
1765  if ( !buttonText )
1766  buttonText = "~O~K";
1767 
1768  tdialogbox::init();
1769 
1770  int i,j;
1771  int maxlength = 0;
1772 
1773  mode = md;
1774 
1775  for (i=0;i<=linenum ;i++ ) {
1776  j = gettextwdth ( a[i], schriften.smallarial );
1777  while ( j > agmp->resolutionx ) {
1778  a[i][strlen(a[i])-1] = 0;
1779  j = gettextwdth ( a[i], schriften.smallarial );
1780  }
1781  if (maxlength < j)
1782  maxlength = j;
1783  } /* endfor */
1784 
1785  x1 = 50;
1786  y1 = 50;
1787  if (maxlength < 150)
1788  xsize = 200;
1789  else
1790  xsize = maxlength + 50;
1791 
1792  if ( maxlength > agmp->resolutionx - 100 )
1793  x1 = 0;
1794 
1795  if ( xsize > agmp->resolutionx )
1796  xsize = agmp->resolutionx;
1797 
1798  ysize = 55 + linenum * 20;
1800  if (mode != 0) {
1801  ysize+=25;
1802  addbutton ( buttonText, 10, ysize - 35 , xsize - 10 , ysize - 10 ,0,1,1,true );
1803  addkey(1, ct_enter);
1804  addkey(1, ct_esc);
1805  addkey(1, ct_enterk );
1806  addkey(1, ct_space );
1807  };
1808 
1809  buildgraphics();
1811  if (mode == 1) {
1813  } else {
1815  } /* endif */
1816 
1818  for (i=0;i <= linenum ;i++ ) {
1819  showtext2( a[i], x1+10, y1+20+i*20 );
1820  } /* endfor */
1821  status = 0;
1822  if ( pcgo ) {
1823  delete pcgo;
1824  pcgo = NULL;
1825  }
1826 }
1827 
1829 {
1830  if ( id == 1) {
1831  status = 1;
1832  } /* endif */
1833 }
1834 
1836 {
1837  mousevisible(true);
1838  do {
1839  tdialogbox::run();
1840  } while ( status == 0 ); /* enddo */
1841 }
1842 
1843 
1844 // num 0: Box bleibt aufgeklappt,
1845 // 1 box wird geschlossen , text rot (Fehler),
1846 // 2 : Programm wird beendet;
1847 // 3 : normaler text ( OK)
1848 
1849 void displaymessage( const char* formatstring, int num, ... )
1850 {
1851 
1852  va_list paramlist;
1853  va_start ( paramlist, num );
1854 
1855  char tempbuf[1000];
1856 
1857  int lng = vsprintf( tempbuf, formatstring, paramlist );
1858  if ( lng >= 1000 )
1859  displaymessage ( "dlg_box.cpp / displaymessage: string to long !\nPlease report this error",1 );
1860 
1861  va_end ( paramlist );
1862 
1863  displaymessage ( ASCString ( tempbuf ), num );
1864 }
1865 
1866 void displaymessage( const ASCString& text, int num )
1867 {
1868  const char* a = text.c_str();
1869 
1870  tstringa stringtooutput;
1871  memset (stringtooutput, 0, sizeof ( stringtooutput ));
1872  stringtooutput[0] = new char[200];
1873  stringtooutput[0][0] = 0;
1874  char* b = stringtooutput[0];
1875 
1876  int linenum = 0;
1877 
1878  while ( *a ) {
1879  if (*a == '\n') {
1880  *b = 0;
1881  linenum++;
1882  stringtooutput[linenum] = new char[200];
1883  b = stringtooutput[linenum];
1884  *b = 0;
1885  } else {
1886  *b = *a;
1887  b++;
1888  }
1889  a++;
1890  }
1891 
1892  *b = 0;
1893 
1894 
1895  bool displayInternally = true;
1896 
1897  /*
1898  if ( num == 2 )
1899  displayLogMessage ( 0, "fatal error" + text + "\n" );
1900  else
1901  displayLogMessage ( 0, text + "\n" );
1902  */
1903 
1904 
1905  #ifndef NoStdio
1906  if ( num == 2 )
1907  displayInternally = false;
1908  #endif
1909 
1910 
1911  if ( num == 2 )
1912  displayLogMessage(1, text );
1913 
1914 
1915 
1916  if ( !displayInternally ) {
1917  for ( int i=0; i<= linenum ;i++ )
1918  fprintf(stderr,"%s\n",stringtooutput[i]);
1919  fflush( stderr );
1920  } else {
1921  #ifdef _WIN322_
1922  if ( !gameStartupComplete && num==2 ) {
1923  MessageBox(NULL, text.c_str(), "Fatal Error", MB_ICONERROR | MB_OK | MB_TASKMODAL );
1924  exit(1);
1925  }
1926  #endif
1927 
1928  if ( legacyEventSystemActive() ) {
1929  static int messageboxopen = 0;
1930  if ( messageboxopen )
1931  return;
1932 
1933  messageboxopen++;
1934  if ( messagebox ) {
1935  if ( messagebox->boxstatus )
1936  messagebox->done();
1937  delete messagebox;
1938  messagebox = NULL;
1939  }
1940 
1941  messagebox = new tdisplaymessage;
1942 
1943  if ( num== 2 )
1944  messagebox->init( stringtooutput, num, linenum, "~q~uit program");
1945  else
1946  messagebox->init( stringtooutput, num, linenum);
1947 
1948  if (num != 0 ) {
1949  messagebox->run();
1950  messagebox->done();
1951  delete messagebox;
1952  messagebox = NULL;
1953  }
1954 
1955  messageboxopen--;
1956  } else {
1957  MessagingHub::Instance().warning( text );
1958  }
1959  } /* endif */
1960 
1961  if ( num == 2 ) {
1962  #ifdef _WIN32_
1963 // if ( !gameStartupComplete ) {
1964  MessageBox(NULL, text.c_str(), "Fatal Error", MB_ICONERROR | MB_OK | MB_TASKMODAL );
1965  exit(1);
1966  // }
1967  #endif
1968  exit ( 1 );
1969  }
1970 
1971  for ( int i=linenum; i>=0 ;i-- )
1972  delete[] stringtooutput[i];
1973 }
1974 
1975 
1976 void removemessage( void )
1977 {
1978  if ( messagebox ) {
1979  if ( messagebox->boxstatus == 2)
1980  messagebox->done();
1981  delete messagebox;
1982  messagebox = NULL;
1983 
1984  }
1985 }
1986 
1987 
1988 
1989 void tdialogbox::dispeditstring ( char* st, int x1, int y1 )
1990 {
1991  showtext2(st,x1,y1);
1992 }
1993 
1994 
1995 void tdialogbox::stredit(char * s,
1996  int x1,
1997  int y1,
1998  int wdth,
1999  int max)
2000 {
2001 
2002  char *ss, *ss2, *ss3;
2003  char einfuegen;
2004  int position;
2005  int i;
2006 
2007  if ( strlen ( s ) > max )
2008  max = strlen ( s );
2009 
2011  ss = new char[max+5];
2012  ss2 = new char[max+5];
2013  strcpy(ss,s);
2014 
2015  activefontsettings.length = wdth;
2017  {
2018  collategraphicoperations cgo ( x1, y1, x1 + wdth, y1 + activefontsettings.height );
2019  dispeditstring ( ss, x1, y1 );
2020  position = strlen(s);
2021  einfuegen = true;
2022  lne(x1,y1,ss,position,einfuegen);
2023  }
2024 
2025  int cc;
2026  tkey symkey;
2027  do {
2028  if ( keypress() ) {
2029  getkeysyms ( &symkey, &cc );
2030  // cc = rp_key();
2031  } else {
2032  cc = cto_invvalue;
2033  symkey = ct_invvalue;
2034  releasetimeslice();
2035  }
2036 
2037  if (cc != cto_invvalue ) {
2038  lne(x1,y1,ss,position,einfuegen);
2039 
2040 #ifdef _DOS_ // I hate this DOS keyboard stuff !!!!!!
2041  switch (symkey) {
2042  case cto_einf:
2043  {
2044  if (einfuegen == false)
2045  einfuegen = true;
2046  else
2047  einfuegen = false;
2048  }
2049  break;
2050 
2051  case cto_left: if (position >= 1)
2052  position--;
2053  break;
2054 
2055  case cto_right: if (position < strlen ( ss ) )
2056  position++;
2057  break;
2058 
2059  case cto_pos1: position = 0;
2060  break;
2061 
2062  case cto_ende: position = strlen ( ss ) ;
2063  break;
2064 
2065  case cto_entf: if ( ss[ position ] != 0 ) {
2066  for (i=0; i< position ;i++ ) {
2067  ss2[i] = ss[i];
2068  } /* endfor */
2069  while ( ss[i] != 0 ) {
2070  ss2[i] = ss [ i + 1 ];
2071  i++;
2072  } /* endwhile */
2073  ss3 = ss2;
2074  ss2 = ss;
2075  ss = ss3;
2076 
2077  dispeditstring (ss,x1,y1); /* ? */
2078  }
2079  break;
2080 
2081  case cto_right + cto_stp: if ( position < strlen ( ss ) ) {
2082  do {
2083  position++;
2084  } while ( (ss[ position ] != ' ') && ( ss[ position ] != 0 ) );
2085  }
2086  break;
2087 
2088  case cto_left + cto_stp: if ( position > 0 ) {
2089  do {
2090  position--;
2091  } while ( ( position > 0 ) && ( ss [ position - 1 ] != ' ') );
2092  }
2093  break;
2094  }
2095 #else
2096  switch (symkey) {
2097  case ct_einf:
2098  {
2099  if (einfuegen == false)
2100  einfuegen = true;
2101  else
2102  einfuegen = false;
2103  }
2104  break;
2105 
2106  case ct_left: if (position >= 1)
2107  position--;
2108  break;
2109 
2110  case ct_right: if (position < strlen ( ss ) )
2111  position++;
2112  break;
2113 
2114  case ct_pos1: position = 0;
2115  break;
2116 
2117  case ct_ende: position = strlen ( ss ) ;
2118  break;
2119 
2120  case ct_entf: if ( ss[ position ] != 0 ) {
2121  for (i=0; i< position ;i++ ) {
2122  ss2[i] = ss[i];
2123  } /* endfor */
2124  while ( ss[i] != 0 ) {
2125  ss2[i] = ss [ i + 1 ];
2126  i++;
2127  } /* endwhile */
2128  ss3 = ss2;
2129  ss2 = ss;
2130  ss = ss3;
2131 
2132  dispeditstring (ss,x1,y1); /* ? */
2133  }
2134  break;
2135 
2136  case ct_right + ct_stp: if ( position < strlen ( ss ) ) {
2137  do {
2138  position++;
2139  } while ( (ss[ position ] != ' ') && ( ss[ position ] != 0 ) );
2140  }
2141  break;
2142 
2143  case ct_left + ct_stp: if ( position > 0 ) {
2144  do {
2145  position--;
2146  } while ( ( position > 0 ) && ( ss [ position - 1 ] != ' ') );
2147  }
2148  break;
2149  }
2150 #endif
2151 
2152  lne(x1,y1,ss,position,einfuegen);
2153 
2154  if ( ( cc > 31 ) && ( cc < 256 ) && (strlen(ss) < max ) ) { // plain ascii
2155  i=0;
2156  while ( (ss[i] != 0) && ( i < position ) ) {
2157  ss2[i] = ss[i];
2158  i++;
2159  }
2160  ss2 [ i ] = cc;
2161  if (einfuegen) {
2162  while ( ss[i] != 0) {
2163  ss2[i+1] = ss[i];
2164  i++;
2165  } /* endwhile */
2166  ss2[i+1] = 0;
2167  } else {
2168  if (ss[i] != 0) {
2169  i++;
2170  while ( ss[i] != 0) {
2171  ss2[i+1] = ss[i];
2172  i++;
2173  } /* endwhile */
2174  ss2[i] = 0;
2175  } else {
2176  ss2[i+1] = 0;
2177  }
2178  } /* endif */
2179 
2180  if (gettextwdth_stredit( ss2, NULL ) < wdth ) {
2181  collategraphicoperations cgo ( x1, y1, x1 + wdth, y1 + activefontsettings.height );
2182  lne(x1,y1,ss,position,einfuegen);
2183  ss3 = ss2;
2184  ss2 = ss;
2185  ss = ss3;
2186  dispeditstring (ss,x1,y1);
2187  position++;
2188  lne(x1,y1,ss,position,einfuegen);
2189  } /* endif */
2190  }
2191  if ((cc == cto_bspace ) && (position > 0)) { /* Backspace */
2192  collategraphicoperations cgo ( x1, y1, x1 + wdth, y1 + activefontsettings.height );
2193  lne(x1,y1,ss,position,einfuegen);
2194  for (i=0; i+1< position ; i++ ) {
2195  ss2[i] = ss[i];
2196  } /* endfor */
2197  i--;
2198  do {
2199  i++;
2200  ss2[i] = ss[i+1];
2201  } while (ss[i+1] != 0 );
2202  ss3 = ss2;
2203  ss2 = ss;
2204  ss = ss3;
2205  position--;
2206  dispeditstring (ss,x1,y1);
2207  lne(x1,y1,ss,position,einfuegen);
2208  }
2209  }
2210  } while ( cc != cto_enter && cc != cto_esc && !( !mouseinrect ( x1, y1, x1 + wdth, y1 + activefontsettings.height) && mouseparams.taste > 0 ) );
2211 
2212  lne(x1,y1,ss,position,einfuegen);
2213  if (cc != cto_esc )
2214  strcpy(s,ss);
2215  delete[] ss;
2216  delete[] ss2;
2217 }
2218 
2219 
2221 {
2222  return gettextwdth ( txt, font );
2223 }
2224 
2225 
2226 void tdialogbox::lne(int x1,
2227  int y1,
2228  char * s,
2229  int position,
2230  int einfuegen)
2231 {
2232  int i, j, k;
2233 
2234  ASCString ss2 = s;
2235  if ( position < ss2.length() )
2236  ss2.erase(position);
2237 
2238  i = x1 + gettextwdth(ss2.c_str(),activefontsettings.font);
2239  j = y1;
2240  k = y1 + activefontsettings.font->height;
2241  collategraphicoperations cgo ( i-1, j, i+1, k );
2242  xorline(i,j,i,k,3);
2243  if (einfuegen == false) {
2244  xorline(i + 1,j,i + 1,k,3);
2245  xorline(i - 1,j,i - 1,k,3);
2246  }
2247 }
2248 
2249 
2250 
2251 
2252 void tdialogbox::intedit(int * st,
2253  int x1,
2254  int y1,
2255  int wdth,
2256  int min,
2257  int max)
2258 {
2259  char *ss, *ss2, *ss3;
2260  char einfuegen;
2261  int position;
2262  int j;
2263  int i;
2264  int ml;
2265  char ok;
2266 
2267  ml = 12 ;
2269 
2270  ss2 = new char[ml];
2271  ss = new char[ml];
2272  itoa ( *st, ss, 10 );
2274  dispeditstring (ss,x1,y1);
2275  position = strlen(ss) ;
2276  einfuegen = true;
2277 
2278  ok = false;
2279 
2280  int cc;
2281  tkey symkey;
2282  do {
2283  lne(x1,y1,ss,position,einfuegen);
2284  do {
2285  if ( keypress() ) {
2286  getkeysyms ( &symkey, &cc );
2287  } else {
2288  cc = cto_invvalue;
2289  releasetimeslice();
2290  }
2291 
2292  if (cc != cto_invvalue ) {
2293  collategraphicoperations cgo ( x1, y1, x1 + wdth, y1 + activefontsettings.height );
2294 
2295  lne(x1,y1,ss,position,einfuegen);
2296 #ifdef _DOS_
2297  switch (symkey) {
2298 
2299  case cto_einf: {
2300  if (einfuegen == false)
2301  einfuegen = true;
2302  else
2303  einfuegen = false;
2304  }
2305  break;
2306 
2307  case cto_left: if (position >= 1)
2308  position--;
2309  break;
2310 
2311  case cto_right: if (position < strlen ( ss ) )
2312  position++;
2313  break;
2314 
2315  case cto_pos1: position = 0;
2316  break;
2317 
2318  case cto_ende: position = strlen ( ss ) ;
2319  break;
2320 
2321  case cto_entf: if ( ss[ position ] != 0 ) {
2322  for (i=0; i< position ;i++ ) {
2323  ss2[i] = ss[i];
2324  } /* endfor */
2325  while ( ss[i] != 0 ) {
2326  ss2[i] = ss [ i + 1 ];
2327  i++;
2328  } /* endwhile */
2329  ss3 = ss2;
2330  ss2 = ss;
2331  ss = ss3;
2332 
2333  dispeditstring (ss,x1,y1); /* ? */
2334  }
2335  break;
2336 
2337  case cto_right + cto_stp: if ( position < strlen ( ss ) ) {
2338  do {
2339  position++;
2340  } while ( (ss[ position ] != ' ') && ( ss[ position ] != 0 ) );
2341  }
2342  break;
2343 
2344  case cto_left + cto_stp: if ( position > 0 ) {
2345  do {
2346  position--;
2347  } while ( ( position > 0 ) && ( ss [ position - 1 ] != ' ') );
2348  }
2349  break;
2350  }
2351 #else
2352  switch (symkey) {
2353 
2354  case ct_einf: {
2355  if (einfuegen == false)
2356  einfuegen = true;
2357  else
2358  einfuegen = false;
2359  }
2360  break;
2361 
2362  case ct_left: if (position >= 1)
2363  position--;
2364  break;
2365 
2366  case ct_right: if (position < strlen ( ss ) )
2367  position++;
2368  break;
2369 
2370  case ct_pos1: position = 0;
2371  break;
2372 
2373  case ct_ende: position = strlen ( ss ) ;
2374  break;
2375 
2376  case ct_entf: if ( ss[ position ] != 0 ) {
2377  for (i=0; i< position ;i++ ) {
2378  ss2[i] = ss[i];
2379  } /* endfor */
2380  while ( ss[i] != 0 ) {
2381  ss2[i] = ss [ i + 1 ];
2382  i++;
2383  } /* endwhile */
2384  ss3 = ss2;
2385  ss2 = ss;
2386  ss = ss3;
2387 
2388  dispeditstring (ss,x1,y1); /* ? */
2389  }
2390  break;
2391 
2392  case ct_right + ct_stp: if ( position < strlen ( ss ) ) {
2393  do {
2394  position++;
2395  } while ( (ss[ position ] != ' ') && ( ss[ position ] != 0 ) );
2396  }
2397  break;
2398 
2399  case ct_left + ct_stp: if ( position > 0 ) {
2400  do {
2401  position--;
2402  } while ( ( position > 0 ) && ( ss [ position - 1 ] != ' ') );
2403  }
2404  break;
2405  }
2406 #endif
2407  if ( (( cc >= '0' && cc <= '9' ) || ( cc == '-' && !position)) && (strlen(ss) < ml-1 ) ) {
2408  i=0;
2409  while ( (ss[i] != 0) && ( i < position ) ) {
2410  ss2[i] = ss[i];
2411  i++;
2412  }
2413  ss2 [ i ] = cc;
2414  if (einfuegen) {
2415  while ( ss[i] != 0) {
2416  ss2[i+1] = ss[i];
2417  i++;
2418  } /* endwhile */
2419  ss2[i+1] = 0;
2420  } else {
2421  if (ss[i] != 0) {
2422  i++;
2423  while ( ss[i] != 0) {
2424  ss2[i+1] = ss[i];
2425  i++;
2426  } /* endwhile */
2427  } /* endif */
2428  ss2[i] = 0;
2429  } /* endif */
2430 
2431  if (gettextwdth( ss2, NULL ) < wdth ) {
2432  ss3 = ss2;
2433  ss2 = ss;
2434  ss = ss3;
2435  dispeditstring (ss,x1,y1);
2436  position++;
2437  } /* endif */
2438  }
2439  if ((cc == 8 ) && (position > 0)) { /* Backspace */
2440 
2441  for (i=0; i+1< position ; i++ )
2442  ss2[i] = ss[i];
2443 
2444  i--;
2445  do {
2446  i++;
2447  ss2[i] = ss[i+1];
2448  } while (ss[i+1] != 0 );
2449  ss3 = ss2;
2450  ss2 = ss;
2451  ss = ss3;
2452  position--;
2453 
2454  dispeditstring (ss,x1,y1);
2455  }
2456  lne(x1,y1,ss,position,einfuegen);
2457  }
2458 
2459  } while ( (cc != cto_enter) && (cc != cto_esc) && !( !mouseinrect ( x1, y1, x1 + wdth, y1 + activefontsettings.height) && mouseparams.taste > 0 ) );
2460  lne(x1,y1,ss,position,einfuegen);
2461  if (cc != cto_esc ) {
2462  j = strtol ( ss, &ss3, 10 );
2463  if ((ss3 != NULL) && ( (ss3 - ss ) < strlen ( ss ) )) {
2464 
2465  position = (ss3 - ss );
2466  lne(x1,y1,ss,position,einfuegen);
2467  ok = false;
2468 
2469  } else {
2470 
2471  if ( j > max || j < min ) {
2472  ok = false;
2473  displaymessage( "Invalid range ! \n range is %d to %d !", 1, min, max );
2474  } else {
2475  *st = j;
2476  ok = true;
2477  }
2478 
2479  } /* endif */
2480 
2481  } else
2482  ok = true;
2483 
2484  } while ( ! ok );
2485 
2486  delete[] ss;
2487  delete[] ss2;
2488 
2489 }
2490 
2491 
2492 void tdialogbox::paintsurface2 ( int xx1, int yy1, int xx2, int yy2 )
2493 {
2494  if ( dialogtexture )
2495  puttexture( xx1, yy1, xx2, yy2, dialogtexture);
2496  else
2497  bar( xx1, yy1, xx2, yy2, lightgray);
2498 
2499 }
2500 
2501 void tdialogbox::paintsurface ( int xx1, int yy1, int xx2, int yy2 )
2502 {
2503  paintsurface2( xx1 + x1, yy1 + y1, xx2 + x1, yy2 + y1 );
2504 }
2505 
2506 
2507 
2508 
2509 
2510 
2512 {
2513  if ( pcgo ) {
2514  delete pcgo;
2515  pcgo = NULL;
2516  }
2517 
2518  if ( boxstatus )
2519  done();
2520  boxstatus = 0;
2521 
2522  if ( prev ) {
2523  prev->next = NULL;
2524 
2525  if ( dlg_mode & 2 )
2526  prev->redrawall2( x1, y1, x1 + xsize, y1 + ysize );
2527  } else {
2528  first = NULL;
2529  repaintDisplay();
2530  }
2532 
2533  setEventRouting ( eventQueue, !eventQueue );
2534 }
2535 
2536 
2537 
2538 
2539 
2540 
2541 
2542 
2543 
2544 
2545 
2546 
2548 {
2550 
2553  else {
2554  if ( tvt_dispactive )
2556  int tvtny1 = tvt_y1 + tvt_yp - tvt_starty + tvt_maxlineheight;
2557  int tvtny2 = tvt_y1 + tvt_yp - tvt_starty + activefontsettings.height;
2558  int tvtnx1 = tvt_x1;
2559  int tvtnx2 = tvt_x1 + tvt_xp;
2560  if (tvtny1 < tvt_y1) {
2561  tvtny1 = tvt_y1;
2562  tvtnx1 = tvt_x1;
2563  }
2564  if (tvtny2 > tvt_y2)
2565  tvtny2 = tvt_y2;
2566  if (tvtnx2 > tvtnx1)
2567  if (tvtny2 > tvtny1)
2568  bar ( tvtnx1, tvtny1, tvtnx2, tvtny2, tvt_background);
2569  };
2571  }
2572 }
2573 
2574 void tviewtext::fillline ( int x1, int x2 )
2575 {
2576  if ( tvt_dispactive )
2578  int tvtny1 = tvt_y1 + tvt_yp - tvt_starty;
2579  int tvtny2 = tvt_y1 + tvt_yp - tvt_starty + tvt_maxlineheight;
2580  if (tvtny1 < tvt_y1) {
2581  tvtny1 = tvt_y1;
2582  // x1 = tvt_x1;
2583  }
2584  if (tvtny2 > tvt_y2)
2585  tvtny2 = tvt_y2;
2586  if (x2 > x1)
2587  if (tvtny2 > tvtny1)
2588  bar ( x1, tvtny1, x2, tvtny2, tvt_background);
2589  }
2590 }
2591 
2592 void tviewtext::nextline ( int einzug, const char* txtptr )
2593 {
2594  if ( tvt_dispactive == 0 && txtptr ) {
2595  if ( ( tvt_startpoint == NULL && (tvt_yp > 500) ) || ( tvt_startpoint && ( tvt_yp > (tvt_startpoint->ypos+500) ))) {
2596  pstartpoint newstartpoint = new ( tstartpoint );
2597  newstartpoint->ypos = tvt_yp;
2598  newstartpoint->xpos = tvt_xp;
2599  newstartpoint->textcolor = tvt_color;
2600  newstartpoint->background = tvt_background;
2601  newstartpoint->font = activefontsettings.font;
2602  newstartpoint->eeinzug = eeinzug;
2603  newstartpoint->aeinzug = aeinzug;
2604  newstartpoint->height = activefontsettings.height;
2605  newstartpoint->next = tvt_startpoint;
2606  newstartpoint->textpointer = txtptr ;
2607  newstartpoint->maxlineheight = tvt_maxlineheight ;
2608  tvt_startpoint = newstartpoint;
2609  }
2610 
2611  }
2612 
2613  fillline ( tvt_x1 + tvt_xp, tvt_x2 );
2615  tvt_xp = einzug;
2616  fillline ( tvt_x1, tvt_x1 + tvt_xp );
2617  *actline = 0;
2619 
2620 }
2621 
2623 {
2624  int twdth = gettextwdth ( t , NULL );
2625  if ( tvt_dispactive ) {
2626  if ( tvt_yp >= tvt_starty ) {
2627  if ( tvt_yp < tvt_starty + tvt_y2 - tvt_y1) {
2630  if (tvt_x1 + tvt_xp + twdth > tvt_x2)
2632  else
2634  showtext2( t, tvt_x1 + tvt_xp, tvt_y1 + tvt_yp - tvt_starty );
2635  }
2636  } else
2637  if ( t[0] )
2639  npush ( *agmp );
2643  if (tvt_x1 + tvt_xp + twdth > tvt_x2)
2645  else
2647  showtext2( t, tvt_xp, 0 );
2648  npop ( *agmp );
2649  putimageprt ( tvt_x1 + tvt_xp, tvt_y1, tvt_x1 + tvt_xp + twdth, tvt_y1 + activefontsettings.height + ( tvt_yp - tvt_starty ), tvt_firstlinebuf, tvt_xp, tvt_starty - tvt_yp );
2650  }
2651  }
2652 
2653  tvt_xp += twdth ;
2654 }
2655 
2656 
2657 void tviewtext::setpos ( int xx1, int yy1, int xx2, int yy2 )
2658 {
2659  tvt_x1 = xx1;
2660  tvt_y1 = yy1;
2661  tvt_x2 = xx2;
2662  tvt_y2 = yy2;
2663 }
2664 
2665 void tviewtext::setparams ( int xx1, int yy1, int xx2, int yy2, const char* ttxt, char clr, char bkgr)
2666 {
2667  tvt_x1 = xx1;
2668  tvt_y1 = yy1;
2669  tvt_x2 = xx2;
2670  tvt_y2 = yy2;
2671  tvt_text = ttxt;
2672  tvt_color = clr;
2673  defaulttextcolor = clr;
2674  tvt_background = bkgr;
2676  eeinzug = 0;
2677  aeinzug = 0;
2678  tvt_dispactive = 0;
2679  tvt_starty = 0;
2681 
2682  tvt_firstlinebufparm.resolutionx = xx2 - xx1 + 1;
2685  tvt_firstlinebufparm.scanlinelength = xx2 - xx1 + 1;
2687  tvt_firstlinebufparm.bytesperscanline = xx2 - xx1 + 1;
2689 
2690  tvt_startpoint = NULL;
2691 }
2692 
2694 {
2695  auto_ptr<collategraphicoperations> cgo;
2696  if ( tvt_dispactive )
2697  cgo.reset( new collategraphicoperations ( tvt_x1, tvt_y1, tvt_x2, tvt_y2 ) );
2698 
2701  eeinzug = 0;
2702  aeinzug = 0;
2703 
2704 
2705  char *actword, *s5;
2706  const char* s1;
2707  int i;
2708 
2709  tvt_xp = 0;
2710  tvt_yp = 0;
2711 
2713 
2714  actline = new char[200];
2715  actword = new char[200];
2716  s5 = new char[200];
2717 
2718  {
2719  tvt_firstlinebuf = new char [ ( tvt_x2 - tvt_x1) * ( tvt_firstlinebufheight + 5 ) ];
2721 
2722  Uint16* pw = (Uint16*) tvt_firstlinebuf;
2723  *pw = (tvt_x2 - tvt_x1);
2724  pw++;
2725  *pw = tvt_firstlinebufheight;
2726  pw++;
2728  }
2729 
2730 
2731  s1 = tvt_text;
2737 
2738 
2739  if (tvt_dispactive) {
2740 
2741  if ( tvt_startpoint ) {
2742  pstartpoint startpoint = tvt_startpoint;
2743  while ( startpoint && ( startpoint->ypos+100 > tvt_starty ) )
2744  startpoint = startpoint->next;
2745 
2746  if ( startpoint ) {
2747  tvt_color = startpoint->textcolor;
2748  tvt_background = startpoint->background ;
2749  activefontsettings.font = startpoint->font ;
2750  eeinzug = startpoint->eeinzug ;
2751  aeinzug = startpoint->aeinzug ;
2752  tvt_xp = startpoint->xpos;
2753  tvt_yp = startpoint->ypos;
2754  tvt_maxlineheight = startpoint->maxlineheight;
2755  activefontsettings.height = startpoint->height ;
2756  s1 = startpoint->textpointer ;
2757  }
2758  }
2759 
2760  }
2761 
2762  if ( tvt_text ) {
2763  *actline = 0;
2764  *actword = 0;
2765  do {
2766  i = 0;
2767  while (*s1 != '#' && *s1 != 0 && *s1 != '\n' && *s1 != ' ' && *s1 != '-') {
2768  actword[i] = *s1;
2769  i++;
2770  s1++;
2771  } /* endwhile */
2772  if ( *s1 == ' ' || *s1 == '-' ) {
2773  actword[i] = *s1;
2774  i++;
2775  s1++;
2776  }
2777 
2778  actword[i] = 0;
2779 
2780  strcpy ( s5, actline );
2781  strcat ( s5, actword );
2782 
2783  if ( tvt_xp + gettextwdth ( s5, NULL ) < tvt_x2 - tvt_x1 )
2784  strcat ( actline, actword );
2785  else {
2787  nextline ( aeinzug, s1 );
2789  strcpy ( actline, actword );
2790  }
2791 
2792  if (*s1 == '\n') {
2794  nextline ( eeinzug, s1 );
2795  s1++;
2796  }
2797  if (*s1 == 0) {
2799  nextline ( 0, s1 );
2800  }
2801 
2802  if (*s1 == '#') {
2804  *actline = 0;
2805  evalcommand ( &s1 );
2806  }
2807  } while ((*s1 != 0) && ((tvt_yp - tvt_starty < tvt_y2 - tvt_y1) || !tvt_dispactive ));
2808  if ( tvt_dispactive )
2809  if (tvt_yp - tvt_starty < tvt_y2 - tvt_y1)
2811 
2812  }
2813 
2814  delete[] s5;
2815  delete[] actword;
2816  delete[] actline;
2817 
2818  delete[] tvt_firstlinebuf;
2819 
2821 
2822 }
2823 
2824 
2825 
2826 void tviewtext::evalcommand ( const char** s)
2827 {
2828  const char* s3 = *s;
2829  char s4[100];
2830  int k, i = 0,
2831  j = 0;
2832 
2833  memset( s4, 0, sizeof( s4 ));
2834  if (strnicmp(s3, "#COLOR", 6) == 0) {
2835  i+=6;
2836  while (s3[i] != '#') {
2837  s4[j] = s3[i];
2838  j++;
2839  i++;
2840  }
2841  s4[j] = 0;
2842  k = atoi( s4 );
2843  if (k == 256)
2845  else
2847  }
2848 
2849  if (strnicmp(s3, "#BACKGROUND", 11) == 0) {
2850  i+=11;
2851  while (s3[i] != '#') {
2852  s4[j] = s3[i];
2853  j++;
2854  i++;
2855  }
2856  s4[j] = 0;
2857  k = atoi( s4 );
2858  if (k == 256)
2860  else
2862  }
2863 
2864  if (strnicmp(s3, "#FONT", 5) == 0) {
2865  i+=5;
2866  while (s3[i] != '#') {
2867  s4[j] = s3[i];
2868  j++;
2869  i++;
2870  }
2871  s4[j] = 0;
2872 
2873  k = atoi ( s4 );
2874  switch (k) {
2876  break;
2878  break;
2880  break;
2881  } /* endswitch */
2883  }
2884 
2885  if (strnicmp(s3, "#TAB", 4) == 0) {
2886  i+=4;
2887  while (s3[i] != '#') {
2888  s4[j] = s3[i];
2889  j++;
2890  i++;
2891  }
2892  s4[j] = 0;
2893 
2894  k = atoi ( s4 );
2895 
2896  int tvtxp = 0;
2897  if (k)
2898  tvtxp = (tvt_xp / k + 1) * k;
2899 
2900  fillline ( tvt_x1 + tvt_xp, tvt_x1 + tvtxp );
2901  tvt_xp = tvtxp;
2902 
2903  }
2904  if (strnicmp(s3, "#POS", 4) == 0) {
2905  i+=4;
2906  while (s3[i] != '#') {
2907  s4[j] = s3[i];
2908  j++;
2909  i++;
2910  }
2911  s4[j] = 0;
2912 
2913  k = atoi ( s4 );
2914  fillline ( tvt_x1 + tvt_xp, tvt_x1 + k );
2915  tvt_xp = k;
2916  }
2917 
2918  if (strnicmp(s3, "#EEINZUG", 8) == 0) {
2919  i+=8;
2920  while (s3[i] != '#') {
2921  s4[j] = s3[i];
2922  j++;
2923  i++;
2924  }
2925  s4[j] = 0;
2926 
2927  eeinzug = atoi ( s4 );
2928  }
2929  if (strnicmp(s3, "#AEINZUG", 8) == 0) {
2930  i+=8;
2931  while (s3[i] != '#') {
2932  s4[j] = s3[i];
2933  j++;
2934  i++;
2935  }
2936  s4[j] = 0;
2937 
2938  aeinzug = atoi ( s4 );
2939  }
2940 
2941  if (strnicmp(s3, "#CRT#", 5) == 0) {
2942  nextline ( eeinzug, NULL );
2943  i=4;
2944  }
2945  if (strnicmp(s3, "#CRTP", 5) == 0) {
2946  i+=5;
2947  while (s3[i] != '#') {
2948  s4[j] = s3[i];
2949  j++;
2950  i++;
2951  }
2952  s4[j] = 0;
2953  if ( s3[i+1] == '\n' )
2954  i++;
2955  k = atoi ( s4 );
2957  nextline ( eeinzug, NULL );
2958  }
2959 
2960 
2961  (*s)+=i+1;
2962 }
2963 
2964 
2966 {
2967  tvt_startpoint = NULL;
2968 }
2969 
2970 
2972 {
2973  while ( tvt_startpoint ) {
2974  pstartpoint startpoint = tvt_startpoint;
2976  delete startpoint;
2977  }
2978 }
2979 
2980 
2981 
2983 {
2984  int pagepressed_scrollspeedmultiplicator = 8;
2985  int tick = ticker;
2986  while ( (skeypress ( ct_down ) || skeypress ( ct_2k )) && (tvt_starty + textsizey < textsizeycomplete)) {
2987  tvt_starty += ticker - tick;
2988  tick = ticker;
2991 
2992  displaytext();
2993  repaintscrollbar();
2994  }
2995 
2996  tick = ticker;
2997  while ( (skeypress ( ct_up ) || skeypress ( ct_8k )) && (tvt_starty > 0) ) {
2998  tvt_starty -= ticker - tick;
2999  tick = ticker;
3000  if ( tvt_starty < 0 )
3001  tvt_starty = 0;
3002 
3003  displaytext();
3004  repaintscrollbar();
3005  }
3006 
3007  if ( (skeypress ( ct_pos1 ) || skeypress ( ct_7k )) && (tvt_starty > 0)) {
3008  tvt_starty = 0;
3009  displaytext();
3010  repaintscrollbar();
3011  }
3012 
3013  if ( (skeypress ( ct_ende ) || skeypress ( ct_1k )) && (tvt_starty < textsizeycomplete - textsizey )) {
3015  displaytext();
3016  repaintscrollbar();
3017  }
3018 
3019 
3020  tick = ticker;
3021  while ( (skeypress ( ct_pdown ) || skeypress ( ct_3k )) && (tvt_starty + textsizey < textsizeycomplete)) {
3022  tvt_starty += (ticker - tick) * pagepressed_scrollspeedmultiplicator;
3023  tick = ticker;
3026 
3027  displaytext();
3028  repaintscrollbar();
3029  }
3030 
3031  tick = ticker;
3032  while ( (skeypress ( ct_pup ) || skeypress ( ct_9k )) && (tvt_starty > 0) ) {
3033  tvt_starty -= (ticker - tick) * pagepressed_scrollspeedmultiplicator;
3034  tick = ticker;
3035  if ( tvt_starty < 0 )
3036  tvt_starty = 0;
3037 
3038  displaytext();
3039  repaintscrollbar();
3040  }
3041 
3042 }
3043 
3044 
3045 
3046 
3047 
3049 {
3050  char s1[10];
3051  sprintf ( s1, "##%4d", id );
3052  {
3053  char* b = s1;
3054  while ( *b ) {
3055  if ( *b == ' ' )
3056  *b = '0';
3057  b++;
3058  }
3059  }
3060 
3061  ASCString txt;
3062 
3063  int wldcrdnum = 3;
3064 
3065  ASCString tmpstr;
3066  if ( actmap )
3067  tmpstr = actmap->preferredFileNames.mapname[0];
3068 
3069  while ( tmpstr.find ( ".map") != string::npos )
3070  tmpstr.replace ( tmpstr.find ( ".map"), 4, ".msg" );
3071 
3072  while( tmpstr.find ( ".MAP") != string::npos )
3073  tmpstr.replace ( tmpstr.find ( ".MAP"), 4, ".msg" );
3074 
3075  displayLogMessage(7, ASCString("Retrieving message ") + strrr(id) + "; looking for message file " + tmpstr + "\n");
3076 
3077 
3078  tfindfile ff3 ( tmpstr.c_str() );
3079  tfindfile ff2 ( "*.msg" );
3080  tfindfile ff ( "helpsys?.txt" );
3081 
3082 
3083  tfindfile* ffa[3] = { &ff3, &ff, &ff2 };
3084 
3085  for ( int m = 0; m < wldcrdnum; m++ ) {
3086 
3087  tfindfile* pff = ffa[m];
3088 
3089  ASCString filefound = pff->getnextname();
3090 
3091  while( !filefound.empty() ) {
3092 
3093  tnfilestream stream ( filefound.c_str(), tnstream::reading );
3094 
3095  ASCString tempstr;
3096 
3097  bool data = stream.readTextString ( tempstr );
3098  int started = 0;
3099 
3100  while ( data ) {
3101  if ( started ) {
3102  if ( tempstr[0] != ';' ) {
3103  if ( tempstr[0] == '#' && tempstr[1] == '#' ) {
3104  started = 0;
3105  return txt;
3106  } else
3107  txt += tempstr + "\n";
3108  }
3109  } else
3110  if ( tempstr == s1 )
3111  started = 1;
3112 
3113  data = stream.readTextString ( tempstr );
3114  } /* endwhile */
3115 
3116  if ( started ) {
3117  started = 0;
3118  return txt;
3119  }
3120 
3121  filefound = pff->getnextname();
3122 
3123  } /* endwhile */
3124  }
3125 
3126  return txt;
3127 }
3128 
3129 
3130 
3131 
3132  #define ppicture tpicture*
3133 
3134  struct tpicture {
3135  void* pict;
3136  int size;
3138  int x, y;
3140  char descrip[20];
3141  };
3142 
3144  public:
3146  char ok;
3147 
3150  char action;
3152 
3153  void init( int id, const char* titlet );
3154  virtual void setup();
3155  void buildgraphics ( void );
3156  virtual void run ( void );
3157  //void viewtext ( void );
3158  virtual void buttonpressed( int id);
3159  void repaintscrollbar( void );
3160  void done ( void );
3161  };
3162 
3163 
3164 
3166 {
3167  addbutton ( "~O~K", 10, ysize - 30, xsize - 10, ysize - 10, 0, 1, 5, 1 );
3168  addkey ( 5, ct_esc );
3169  addkey ( 5, ct_space );
3170  addkey ( 5, ct_enter );
3171 }
3172 
3173 void thelpsystem::init(int id, const char* titlet )
3174 {
3175 
3176  // dialogbox initialisieren
3177 
3178  tdialogbox::init();
3179  x1 = 70;
3180  y1 = 20;
3181  xsize = 500;
3182  ysize = 440;
3183  textstart = 42;
3184  textsizey = (ysize - textstart - 40);
3185  starty = starty + 10;
3186  title = titlet;
3187  windowstyle ^= dlg_in3d;
3188  action=0;
3189 
3190 
3191 
3192  txt = readtextmessage( id );
3193 
3194  if ( txt.empty() ) {
3195  txt = "help topic not found : ";
3196  txt += strrr (id );
3197  }
3198 
3199  setup();
3200 
3201  // Koordinaten auch bei setpos ndern
3202  setparams ( x1 + 13, y1 + textstart, x1 + xsize - 41, y1 + ysize - 40, txt.c_str(), black, dblue);
3203 
3204  tvt_dispactive = 0;
3205  // buildgraphics();
3206  displaytext( );
3208  tvt_dispactive = 1;
3209 
3210 
3211  if (textsizeycomplete >= textsizey) {
3212  scrollbarvisible = true;
3214  setscrollspeed ( 1 , 1 );
3215 
3216  }
3217  else
3218  scrollbarvisible = false;
3219 
3220  tvt_starty = 0;
3221 
3222 }
3223 
3225 {
3226  enablebutton( 1 );
3227 }
3228 
3229 
3231 {
3233  setpos ( x1 + 13, y1 + textstart, x1 + xsize - 41, y1 + ysize - 40 );
3234  rahmen(true,x1 + 10,y1 + textstart - 2,x1 + xsize - 40,y1 + textstart + textsizey + 2);
3235 
3236  mousevisible(true);
3237 
3243 
3244  firstpict = NULL;
3245 }
3246 
3247 
3249 {
3251  if (id == 1)
3252  displaytext();
3253 
3254  if ( id == 5 )
3255  action = 11;
3256 }
3257 
3258 
3260 {
3261  displaytext();
3262  do {
3263  tdialogbox::run();
3264  checkscrolling();
3265 
3266  } while (action < 10);
3267 }
3268 
3269 
3271 {
3272  ppicture pic1;
3273 
3274  tdialogbox::done();
3275  while (firstpict != NULL) {
3276  pic1 = firstpict;
3277  firstpict = firstpict->next;
3278  free ( pic1->pict );
3279  delete ( pic1 );
3280  }
3281 }
3282 
3283 
3284 
3285 
3286 void help( int id)
3287 {
3288  ASCString s = readtextmessage( id );
3289 
3290  ViewFormattedText vft( "Help System", s, PG_Rect(-1,-1,450,550));
3291  vft.Show();
3292  vft.RunModal();
3293 }
3294 
3295 
3296 void viewtext2 ( int id)
3297 {
3298 
3299  ASCString s = readtextmessage( id );
3300 
3301  ViewFormattedText vft( "Message", s, PG_Rect(-1,-1,450,550));
3302  vft.Show();
3303  vft.RunModal();
3304 }
3305 
3306 
3307 
3308 
3309 class tviewtextquery : public thelpsystem {
3310  const char* st1;
3311  const char* st2;
3312  public:
3313  void init( int id, const char* titel, const char* s1, const char* s2);
3314  virtual void buttonpressed( int id);
3315  void setup( void );
3316  };
3317 
3318 
3320 {
3321 
3322  if ( st2 ) {
3323  addbutton ( st1, 10, ysize - 30, xsize / 2 - 5, ysize - 10, 0, 1,11, 1 );
3324  addbutton ( st2, xsize / 2 + 5, ysize - 30, xsize - 10, ysize - 10, 0, 1,12, 1 );
3325  }
3326  else
3327  addbutton(st1,10, ysize - 30, xsize - 10, ysize - 10, 0, 1, 11, 1 );
3328 
3329 }
3330 
3331 
3332 void tviewtextquery::init( int id, const char* titel, const char* s1, const char* s2 )
3333 {
3334  st1 = s1;
3335  st2 = s2;
3336 
3337  thelpsystem::init(id,titel);
3338 
3339  buildgraphics();
3340 }
3341 
3342 
3344 {
3346  if (id == 12)
3347  action = 12;
3348  if (id == 11)
3349  action = 11;
3350 }
3351 
3352 
3354  const char * title,
3355  const char * s1,
3356  const char * s2)
3357 {
3358  tviewtextquery vtq;
3359  char result;
3360 
3361  vtq.init(id,title,s1,s2);
3362  vtq.run();
3363  result = vtq.action - 11;
3364  vtq.done();
3365  return result;
3366 }
3367 
3368 
3370 
3371  public:
3372  ViewTextQuery( int id, const ASCString& title, const ASCString& button1, const ASCString& button2 ) : ASC_PG_Dialog( NULL, PG_Rect(-1, -1, 450, 500 ), title )
3373  {
3374  PG_Rect r;
3375  if ( button2.length() ) {
3376  r = PG_Rect( 10, Height() - 40, Width()/2-15, 30 );
3377  PG_Button* b = new PG_Button( this, PG_Rect( Width()/2+5, Height() - 40, Width()/2-15, 30 ), button2 );
3378  b->sigClick.connect( sigc::bind( sigc::mem_fun( *this, &ViewTextQuery::quitModalLoopW ), 1));
3379  b->activateHotkey(0);
3380  } else
3381  r = PG_Rect( 10, Height() - 40, Width() - 20, 30 );
3382 
3383 
3384 
3385  PG_Button* b = new PG_Button( this, r, button1 );
3386  b->sigClick.connect( sigc::bind( sigc::mem_fun( *this, &ViewTextQuery::quitModalLoopW ), 0));
3387  b->activateHotkey(0);
3388 
3389  new TextRenderer( this, PG_Rect( 10, 30, Width()-20, Height() - 70 ), readtextmessage( id ));
3390  }
3391 };
3392 
3393 
3394 int viewtextquery( int id,
3395  const char * title,
3396  const char * s1,
3397  const char * s2)
3398 {
3399  if ( legacyEventSystemActive() )
3400  return legacy_viewtextquery( id, title, s1, s2 );
3401  else {
3402  ViewTextQuery vtq( id, title, s1, s2 );
3403  vtq.Show();
3404  return vtq.RunModal();
3405  }
3406 }
3407 
3408 
3409 tdisplaymessage* messagebox = NULL;
3410 
3411 
3412 
3413 
3414 
3416 {
3417  numberoflines = 0;
3418  firstvisibleline = 0;
3419  redline = 0;
3420  startpos = 0;
3421 }
3422 
3423 
3425 {
3426  tdialogbox::init();
3427 
3428  xsize = 570;
3429  ysize = 320;
3430  x1 = ( 640 -xsize ) / 2;
3431  y1 = ( 480 -ysize ) / 2;
3432 
3433  sy = 45;
3434 
3435  sx = 20;
3436  title = "Text-Box";
3438  lnshown = 10;
3439  ey = ysize - 50;
3440  ex = xsize - 30;
3441  setup();
3442 
3444  if (startpos > lnshown -1 ) {
3445  firstvisibleline = startpos - ( lnshown - 1 );
3446  redline = startpos;
3447  } else {
3448  redline = startpos;
3449  } /* endif */
3450 
3451  dk = 0;
3452  action = 0;
3453  dx = (ey - sy) / lnshown;
3454  if (numberoflines > lnshown) {
3455  scrollbarvisible = true;
3457  }
3458  else scrollbarvisible = false;
3459  buildgraphics();
3460  rahmen(true,x1 + sx , y1 + sy,x1 + ex,y1 + ey);
3461  mousevisible(true);
3467  viewtext();
3468 }
3469 
3470 
3472 {
3473 }
3474 
3475 
3477 {
3479  if (id == 1) {
3482  viewtext();
3483  }
3484 }
3485 
3486 
3488 {
3489  char view;
3490  int my;
3491  int ms;
3492 
3493  tdialogbox::run();
3494  if (numberoflines > 0) {
3495  msel = 0;
3496  if (getmousestatus() == 2) {
3497  if ((( ms = mouseparams.taste ) == 0) && (dk == 1)) dk = 2;
3498  if ((mouseparams.x > x1 + 10) & (mouseparams.x < x1 + xsize - 40) && (ms != 0)) {
3499  my = mouseparams.y - y1 - sy;
3500  my = my / dx;
3501  if ((my >= 0) && (my <= lnshown - 1) && (my <= numberoflines - 1)) {
3503  if ((mouseselect == redline) && (dk == 2)) {
3504  msel = ms;
3505  dk = 0;
3506  }
3507  else {
3508  redline = mouseselect;
3509  dk = 1;
3510  ms =0;
3511  viewtext();
3512  }
3513  }
3514  }
3515  }
3516  switch (taste) {
3517 
3518  case ct_up: {
3519  view = true;
3520  if (redline > 0) redline--;
3521  else view = false;
3522  if ((redline < firstvisibleline) && (firstvisibleline > 0)) {
3523  firstvisibleline--;
3524  showbutton( 1 );
3525  }
3526  if (view) viewtext();
3527  }
3528  break;
3529  case ct_pos1: {
3530  view = false;
3531  if ( (redline > 0) || (firstvisibleline > 0) ) {
3532  view = true;
3533  redline = 0;
3534  firstvisibleline = 0;
3535  }
3536  if (view) viewtext();
3537  }
3538  break;
3539 
3540  case ct_ende: {
3541  view = false;
3542  if (redline < numberoflines -1 ) {
3543  view = true;
3544  redline = numberoflines -1 ;
3546  }
3547  if (view) viewtext();
3548  }
3549  break;
3550 
3551  case ct_down: {
3552  view = true;
3553  if (redline < numberoflines - 1) redline++;
3554  else view = false;
3555  if ((redline > firstvisibleline + lnshown - 1) && (firstvisibleline + lnshown - 1 <= numberoflines)) {
3556  firstvisibleline++;
3557  showbutton( 1 );
3558  }
3559  if (view) viewtext();
3560  }
3561  break;
3562  }
3563  }
3564  else redline = -1;
3565 }
3566 
3567 
3569 {
3570  bar(x1 + sx,y1 + sy,x1 + ex,y1 + ey,lightgray);
3571  rahmen(true,x1 + sx ,y1 + sy,x1 + ex,y1 + ey);
3572 }
3573 
3574 void tstringselect::get_text(int nr) //gibt in txt den string zur?ck
3575 {
3576  strcpy(txt,"");
3577 }
3578 
3580 {
3581  scrollbarvisible = true;
3582  addscrollbar(ex + 10 ,sy - 10,ex + 30,ey + 10,&numberoflines,lnshown,&firstvisibleline,1,0);
3583 }
3584 
3585 
3587 {
3588  char s1[200];
3589  Uint16 yp;
3590  int l;
3591 
3592  mousevisible(false);
3593  //showbutton(1);
3595  activefontsettings.length = ex - sx - 10;
3596  yp = y1 + sy + 5;
3597  l = firstvisibleline;
3598  if (numberoflines > 0) {
3599  while ((l<numberoflines) && (l-firstvisibleline < lnshown)) {
3600  get_text(l);
3601  strcpy(s1,txt);
3602  if (l == redline ) activefontsettings.color=red;
3604  showtext2(s1,x1+ sx + 5,yp+( l-firstvisibleline ) * dx );
3605  l++;
3606  } /* endwhile */
3607 
3608  }
3609  // else showtext2("No text available !",x1 + 50,yp + 50);
3610 
3611  //rahmen(true,x1 + sx ,y1 + sy,x1 + ex ,y1 + ey );
3613  mousevisible(true);
3614 }
3615 
3616 
3618 {
3619  tdialogbox::done();
3620  while ( mouseparams.taste )
3621  releasetimeslice();
3622 }
3623 
3624 
3625 class tgetid : public tdialogbox {
3626  public :
3629  int action;
3630  int mid;
3631  char nt[200];
3632  void init(void);
3633  int max,min;
3634  virtual void run(void);
3635  virtual void buttonpressed(int id);
3636  };
3637 
3638 void tgetid::init(void)
3639 {
3640  tdialogbox::init();
3641  title = nt;
3642  x1 = 200;
3643  xsize = 220;
3644  y1 = 150;
3645  ysize = 140;
3646  action = 0;
3647 
3648  if ((mid < min) || (mid > max)) mid = 42; /* ! */
3649 
3651 
3652 
3653  addbutton("~D~one",20,ysize - 40,100,ysize - 20,0,1,1,true);
3654  addkey(1,ct_enter);
3655  addbutton("~C~ancel",120,ysize - 40,200,ysize - 20,0,1,2,true);
3656  addbutton("",20,60,xsize - 20,80,2,1,3,true);
3657  addeingabe(3,&mid,min,max);
3658 
3659  buildgraphics();
3660 
3661  mousevisible(true);
3662 }
3663 
3664 
3665 void tgetid::run(void)
3666 {
3667  int orig = mid;
3668  tdialogbox::run ();
3669  pbutton pb = firstbutton;
3670  while ( pb && (pb->id != 3))
3671  pb = pb->next;
3672 
3673  if ( pb )
3674  if ( pb->id == 3 )
3675  execbutton( pb , false );
3676 
3677  do {
3678  tdialogbox::run();
3679  } while (!((taste == ct_esc) || ((action == 1) || (action == 2))));
3680  if ((action == 2) || (taste == ct_esc)){
3681  if ( onCancel == ReturnZero )
3682  mid = 0;
3683  else
3684  mid = orig;
3685  }
3686 }
3687 
3688 
3690 {
3692  switch (id) {
3693 
3694  case 1:
3695  case 2: action = id;
3696  break;
3697  }
3698 }
3699 
3700 
3701 int getid( const char* title, int lval,int min,int max)
3702 
3703 { tgetid gi;
3705 
3706  strcpy( gi.nt, title );
3707  gi.max = max;
3708  gi.min = min;
3709  gi.mid = lval;
3710  gi.init();
3711  gi.run();
3712  gi.done();
3713  return gi.mid;
3714 }
3715 
3716 
3717 class ChooseString : public tstringselect {
3718  private:
3719  const vector<ASCString>& strings;
3720  const vector<ASCString>& buttons;
3721  char buf[10000];
3722  public :
3723  ChooseString ( const ASCString& _title, const vector<ASCString>& _strings , const vector<ASCString>& _buttons, int defaultEntry );
3724  void setup( );
3725  virtual void buttonpressed(int id);
3726  void run(void);
3727  virtual void get_text(int nr);
3728 };
3729 
3730 
3731 
3732 ChooseString :: ChooseString ( const ASCString& _title, const vector<ASCString>& _strings, const vector<ASCString>& _buttons, int defaultEntry )
3733  : strings ( _strings ), buttons ( _buttons )
3734 {
3735  strcpy ( buf, _title.c_str() );
3736  startpos = defaultEntry;
3737 }
3738 
3739 
3741 {
3742  action = 0;
3743  title = buf;
3744  numberoflines = strings.size();
3745  ey = ysize - 50;
3746  if ( buttons.size() > 4 )
3747  xsize = 640;
3748  int width = (xsize-40)/buttons.size();
3749  for ( int i = 0; i< buttons.size(); ++i )
3750  addbutton( buttons[i].c_str(),25 + i*width,ysize - 45,15 + (i+1)*width,ysize - 20,0,1,20+i,true);
3751 }
3752 
3753 
3755 {
3757  if ( id >= 20 )
3758  action =id ;
3759 }
3760 
3761 
3763 {
3764  strcpy ( txt, strings[nr].c_str());
3765 }
3766 
3767 
3769 {
3770  do {
3772  /*
3773  if ( taste == ct_enter )
3774  if ( redline >= 0 )
3775  action = 2;
3776  */
3777  } while ( action == 0 );
3778 }
3779 
3780 
3781 
3782 
3783 
3784 
3785 
3786 
3787 
3788 int chooseString ( const ASCString& title, const vector<ASCString>& entries, int defaultEntry )
3789 {
3790  vector<ASCString> b;
3791  b.push_back ( "~O~K");
3792  return chooseString ( title, entries, b, defaultEntry).second;
3793 }
3794 
3795 
3796 
3797 
3798 pair<int,int> chooseString ( const ASCString& title, const vector<ASCString>& entries, const vector<ASCString>& buttons, int defaultEntry )
3799 {
3800 
3801  if ( legacyEventSystemActive() ) {
3802  ChooseString gps ( title, entries, buttons, defaultEntry );
3803 
3804  gps.init();
3805  gps.run();
3806  gps.done();
3807  return make_pair(gps.action-20,gps.redline);
3808  } else {
3809  return new_chooseString ( title, entries, buttons, defaultEntry );
3810  }
3811 
3812 
3813 }
3814 
3815 
3816 
3817 
3818 
3819 class StringEdit : public tdialogbox {
3820  public :
3822  char nt[200];
3825  int action;
3826  int mid;
3827  char text[200];
3828  void init(void);
3829  int max,min;
3830  virtual void run(void);
3831  virtual void buttonpressed(int id);
3832  };
3833 
3835 {
3836  tdialogbox::init();
3837  strcpy ( text, org.c_str() );
3838  title = nt;
3839  x1 = 200;
3840  xsize = 220;
3841  y1 = 150;
3842  ysize = 140;
3843  action = 0;
3844 
3846 
3847 
3848  addbutton("~D~one",20,ysize - 40,100,ysize - 20,0,1,1,true);
3849  addkey(1,ct_enter);
3850  addbutton("~C~ancel",120,ysize - 40,200,ysize - 20,0,1,2,true);
3851  addbutton("",20,60,xsize - 20,80,1,1,3,true);
3852  addeingabe(3,text,0,99);
3853 
3854  buildgraphics();
3855 
3856  mousevisible(true);
3857 }
3858 
3859 
3861 {
3862  tdialogbox::run ();
3863  pbutton pb = firstbutton;
3864  while ( pb && (pb->id != 3))
3865  pb = pb->next;
3866 
3867  if ( pb )
3868  if ( pb->id == 3 )
3869  execbutton( pb , false );
3870 
3871  do {
3872  tdialogbox::run();
3873  } while (!((taste == ct_esc) || ((action == 1) || (action == 2))));
3874  if ((action == 2) || (taste == ct_esc)){
3875  if ( onCancel == ReturnZero )
3876  text[0] = 0;
3877  else
3878  strcpy( text, org.c_str() );
3879  }
3880 }
3881 
3882 
3884 {
3886  switch (id) {
3887 
3888  case 1:
3889  case 2: action = id;
3890  break;
3891  }
3892 }
3893 
3894 ASCString editString( const ASCString& title, const ASCString& defaultValue )
3895 {
3896  StringEdit gi;
3897  gi.org = defaultValue;
3899 
3900  strcpy( gi.nt, title.c_str() );
3901  gi.init();
3902  gi.run();
3903  gi.done();
3904  return gi.text;
3905 }
3906 
3907 
3908 
3909 
3910 
3911 #if 0
3912 
3913 class StringSelect : public tdialogbox {
3914  const vector<ASCString>& entries;
3915  const vector<ASCString>& buttons;
3916  ASCString myTitle;
3917  public :
3918  StringSelect( const ASCString& title, const vector<ASCString>& entries_, const vector<ASCString>& buttons_ );
3919  protected:
3920  int ok;
3921  int sy,ey,sx,ex,action,dx;
3922  int dk;
3923  int msel,mouseselect,redline,lnshown,numberoflines,firstvisibleline,startpos;
3924  int scrollbarvisible;
3925  void init(void);
3926  tstringselect ( );
3927  virtual void run(void);
3928  virtual void buttonpressed(int id);
3929  void scrollbar_on(void);
3930  void viewtext(void);
3931  virtual void resettextfield(void);
3932  virtual void get_text( Uint16 nr);
3933  void done(void);
3934  };
3935 
3936 
3937 StringSelect :: StringSelect( const ASCString& title, const vector<ASCString>& entries_, const vector<ASCString>& buttons_ )
3938  : entries( entries_ ), buttons ( buttons_ )
3939 {
3940  numberoflines = 0;
3941  firstvisibleline = 0;
3942  redline = 0;
3943  startpos = 0;
3944  myTitle = title;
3945 }
3946 
3947 
3948 void tstringselect::init(void)
3949 {
3950  tdialogbox::init();
3951 
3952  xsize = 570;
3953  ysize = 320;
3954  x1 = ( 640 -xsize ) / 2;
3955  y1 = ( 480 -ysize ) / 2;
3956 
3957  sy = 45;
3958 
3959  sx = 20;
3960  title = myTitle.c_str();
3962  lnshown = 10;
3963  ey = ysize - 50;
3964  ex = xsize - 30;
3965  setup();
3966 
3967  if (startpos >= numberoflines )
3968  startpos = numberoflines-1;
3969  if (startpos > lnshown -1 ) {
3970  firstvisibleline = startpos - ( lnshown - 1 );
3971  redline = startpos;
3972  } else {
3973  redline = startpos;
3974  } /* endif */
3975 
3976  dk = 0;
3977  action = 0;
3978  dx = (ey - sy) / lnshown;
3979  if (numberoflines > lnshown) {
3980  scrollbarvisible = true;
3982  }
3983  else
3984  scrollbarvisible = false;
3985  buildgraphics();
3986  rahmen(true,x1 + sx , y1 + sy,x1 + ex,y1 + ey);
3987  mousevisible(true);
3993  viewtext();
3994 }
3995 
3996 
3997 
3998 void tstringselect::buttonpressed(int id)
3999 {
4001  if (id == 1) {
4004  viewtext();
4005  }
4006 }
4007 
4008 
4009 void tstringselect::run(void)
4010 {
4011  int view;
4012  int my;
4013  int ms;
4014 
4015  tdialogbox::run();
4016  if (numberoflines > 0) {
4017  msel = 0;
4018  if (getmousestatus() == 2) {
4019  if ((( ms = mouseparams.taste ) == 0) && (dk == 1)) dk = 2;
4020  if ((mouseparams.x > x1 + 10) & (mouseparams.x < x1 + xsize - 40) && (ms != 0)) {
4021  my = mouseparams.y - y1 - sy;
4022  my = my / dx;
4023  if ((my >= 0) && (my <= lnshown - 1) && (my <= numberoflines - 1)) {
4025  if ((mouseselect == redline) && (dk == 2)) {
4026  msel = ms;
4027  dk = 0;
4028  }
4029  else {
4030  redline = mouseselect;
4031  dk = 1;
4032  ms =0;
4033  viewtext();
4034  }
4035  }
4036  }
4037  }
4038  switch (taste) {
4039 
4040  case ct_up: {
4041  view = true;
4042  if (redline > 0) redline--;
4043  else view = false;
4044  if ((redline < firstvisibleline) && (firstvisibleline > 0)) {
4045  firstvisibleline--;
4046  showbutton( 1 );
4047  }
4048  if (view) viewtext();
4049  }
4050  break;
4051  case ct_pos1: {
4052  view = false;
4053  if ( (redline > 0) || (firstvisibleline > 0) ) {
4054  view = true;
4055  redline = 0;
4056  firstvisibleline = 0;
4057  }
4058  if (view) viewtext();
4059  }
4060  break;
4061 
4062  case ct_ende: {
4063  view = false;
4064  if (redline < numberoflines -1 ) {
4065  view = true;
4066  redline = numberoflines -1 ;
4068  }
4069  if (view) viewtext();
4070  }
4071  break;
4072 
4073  case ct_down: {
4074  view = true;
4075  if (redline < numberoflines - 1) redline++;
4076  else view = false;
4077  if ((redline > firstvisibleline + lnshown - 1) && (firstvisibleline + lnshown - 1 <= numberoflines)) {
4078  firstvisibleline++;
4079  showbutton( 1 );
4080  }
4081  if (view) viewtext();
4082  }
4083  break;
4084  }
4085  }
4086  else redline = -1;
4087 }
4088 
4089 
4091 {
4092  bar(x1 + sx,y1 + sy,x1 + ex,y1 + ey,lightgray);
4093  rahmen(true,x1 + sx ,y1 + sy,x1 + ex,y1 + ey);
4094 }
4095 
4096 void tstringselect::get_text(Uint16 nr) //gibt in txt den string zur?ck
4097 {
4098  strcpy(txt,"");
4099  nr = 0;
4100 }
4101 
4102 void tstringselect::scrollbar_on(void)
4103 {
4104  scrollbarvisible = true;
4105  addscrollbar(ex + 10 ,sy - 10,ex + 30,ey + 10,&numberoflines,lnshown,&firstvisibleline,1,0);
4106 }
4107 
4108 
4109 void tstringselect::viewtext(void)
4110 {
4111  char s1[200];
4112  Uint16 yp;
4113  int l;
4114 
4115  mousevisible(false);
4116  //showbutton(1);
4118  activefontsettings.length = ex - sx - 10;
4119  yp = y1 + sy + 5;
4120  l = firstvisibleline;
4121  if (numberoflines > 0) {
4122  while ((l<numberoflines) && (l-firstvisibleline < lnshown)) {
4123  get_text(l);
4124  strcpy(s1,txt);
4125  if (l == redline ) activefontsettings.color=red;
4127  showtext2(s1,x1+ sx + 5,yp+( l-firstvisibleline ) * dx );
4128  l++;
4129  } /* endwhile */
4130 
4131  }
4132  // else showtext2("No text available !",x1 + 50,yp + 50);
4133 
4134  //rahmen(true,x1 + sx ,y1 + sy,x1 + ex ,y1 + ey );
4136  mousevisible(true);
4137 }
4138 
4139 
4140 void tstringselect::done(void)
4141 {
4142  tdialogbox::done();
4143  while ( mouseparams.taste )
4144  releasetimeslice();
4145 }
4146 #endif
const int blue
Definition: basegfx.h:88
void intedit(int *st, int x1, int y1, int wdth, int min, int max)
Definition: dlg_box.cpp:2252
int startpos
Definition: dlg_box.h:420
int mouseselect
Definition: dlg_box.h:420
void xorline(int x1, int y1, int x2, int y2, Uint8 actcol)
draws a simple line on the screen, but performs a XOR operation between the pixel already on screen a...
Definition: basegfx.cpp:241
tbutton * next
Definition: dlg_box.h:56
tfontsettings activefontsettings
Definition: newfont.cpp:51
Uint8 markcolor
Definition: newfont.h:172
int boxstatus
Definition: dlg_box.h:168
const char ** entries
Definition: dlg_box.h:72
#define dblue
Definition: misc.h:33
Uint8 background
Definition: newfont.h:171
void showtabmark(int b)
Definition: dlg_box.cpp:1470
virtual void setvirtualframebuf(void)
Definition: dlg_box.cpp:247
int legacy_viewtextquery(int id, const char *title, const char *s1, const char *s2)
Definition: dlg_box.cpp:3353
int x1
Definition: dlg_box.h:40
ASCString txt
Definition: dlg_box.cpp:3145
#define ct_7k
Definition: keysymbols.h:72
#define centertext
Definition: newfont.h:185
char text[200]
Definition: dlg_box.cpp:3827
int numberoflines
Definition: dlg_box.h:420
tgraphmodeparameters * hgmp
Definition: basegfx.cpp:40
map accessing and usage routines used by ASC and the mapeditor
pbutton firstbutton
Definition: dlg_box.h:86
miscellaneous functions which are used by ASC and all its tools
int markedtab
Definition: dlg_box.h:166
virtual void get_text(int nr)
Definition: dlg_box.cpp:3574
int dlg_mode
Definition: dlg_box.h:206
void paintsurface2(int xx1, int yy1, int xx2, int yy2)
Definition: dlg_box.cpp:2492
virtual void showbutton(int id)=0
int action
Definition: dlg_box.cpp:3629
virtual ~tdialogbox()
Definition: dlg_box.cpp:2511
static pdialogbox first
Definition: dlg_box.h:204
void fillline(int x1, int x2)
Definition: dlg_box.cpp:2574
#define npush(a)
Definition: stack.h:53
#define cto_right
Definition: keysymbols.h:241
sigc::signal< void > repaintDisplay
Definition: spfst.cpp:46
void putimage(int x1, int y1, void *img)
puts the image pointed to by buffer to the screen
Definition: basegfx.cpp:1280
char * strrrd8d(int l)
Definition: dlg_box.cpp:73
virtual int getcapabilities(void)
Definition: dlg_box.cpp:180
int aeinzug
Definition: dlg_box.h:360
#define dlg_notitle
Definition: dlg_box.h:34
#define ct_tab
Definition: keysymbols.h:44
#define cto_left
Definition: keysymbols.h:240
virtual void copyvirtualframebuf(void)
Definition: dlg_box.cpp:261
txlattables xlattables
Definition: palette.cpp:37
void init(void)
Definition: dlg_box.cpp:3424
long int lastdisplayedmessageticker
Definition: dlg_box.cpp:98
const char * text
Definition: dlg_box.h:57
int y1
Definition: dlg_box.h:40
ASCString getnextname(int *loc=NULL, bool *inContainer=NULL, ASCString *location=NULL)
Returns the next entry of the internal file list.
Definition: basestrm.cpp:2211
bool quitModalLoopW(PG_Button *button, int value)
Definition: paradialog.cpp:540
virtual void run(void)
Definition: dlg_box.cpp:1477
ASCString readtextmessage(int id)
returns the message with the given ID from the message system.
Definition: dlg_box.cpp:3048
void xorrectangle(int x1, int y1, int x2, int y2, Uint8 color)
draws a simple rectangle on the screen, but performs a XOR operation between the pixel already on scr...
Definition: basegfx.cpp:313
#define ct_einf
Definition: keysymbols.h:126
void clearkey(char id)
Definition: dlg_box.cpp:762
int ms
Definition: dlg_box.h:159
int mid
Definition: dlg_box.cpp:3630
int defaulttextcolor
Definition: dlg_box.h:371
#define ct_pos1
Definition: keysymbols.h:127
void rahmen3(const char *txt, int x1, int y1, int x2, int y2, int style)
Definition: dlg_box.cpp:1718
virtual Uint8 checkvalue(int id, void *p)
Definition: dlg_box.cpp:1644
void putspritetexture(int x1, int y1, int x2, int y2, void *texture)
Puts a part of texture on the screen.
Definition: basegfx.cpp:1670
#define cto_stp
Definition: keysymbols.h:147
virtual void buttonpressed(int id)
Definition: dlg_box.cpp:369
virtual void run(void)
Definition: dlg_box.cpp:1835
pdialogbox next
Definition: dlg_box.h:202
void strrd8d(int l, char *s)
Definition: dlg_box.cpp:57
const char * tvt_text
Definition: dlg_box.h:362
int starty
Definition: dlg_box.h:158
int xsize
Definition: dlg_box.h:40
void paintsurface(int xx1, int yy1, int xx2, int yy2)
Definition: dlg_box.cpp:2501
tgetid()
Definition: dlg_box.cpp:3627
void rahmen(bool invers, int x1, int y1, int x2, int y2)
Definition: dlgraph.cpp:97
tvirtualscreenbuf virtualscreenbuf
Definition: dlg_box.cpp:101
char nt[200]
Definition: dlg_box.cpp:3822
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
#define ct_left
Definition: keysymbols.h:120
#define cto_esc
Definition: keysymbols.h:163
int tvt_starty
Definition: dlg_box.h:357
int x1
Definition: events.h:64
unsigned long PointerSizedInt
pfont arial8
Definition: spfst-legacy.h:31
virtual void run(void)
Definition: dlg_box.cpp:3860
void buildgraphics(void)
Definition: dlg_box.cpp:1180
void newknopf(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:180
pfont smallarial
Definition: spfst-legacy.h:28
#define ct_ende
Definition: keysymbols.h:128
enum tgetid::CancelMode onCancel
#define ct_enter
Definition: keysymbols.h:51
int tabcount
Definition: dlg_box.h:165
#define ct_enterk
Definition: keysymbols.h:63
Uint8 justify
Definition: newfont.h:176
Sint16 height
Definition: newfont.h:154
#define lefttext
Definition: newfont.h:184
Interface for some basic classes from which all of ASC's dialogs are derived.
int height
Definition: dlg_box.cpp:3137
tkey char2key(int ch)
Definition: events.cpp:200
tgraphmodeparameters * agmp
Definition: basegfx.cpp:39
if(!yyg->yy_init)
Definition: scanner.cpp:695
#define ct_space
Definition: keysymbols.h:30
void buildgraphics(void)
Definition: dlg_box.cpp:3230
int tvt_x1
Definition: dlg_box.h:357
#define ct_stp
Definition: keysymbols.h:27
Uint8 color
Definition: newfont.h:170
int tvt_firstlinebufheight
Definition: dlg_box.h:366
#define dlg_wintitle
Definition: dlg_box.h:32
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
char strrstring[200]
Definition: dlg_box.cpp:55
virtual void lne(int x1, int y1, char *s, int position, int einfuegen)
Definition: dlg_box.cpp:2226
void addscrollbar(int lx1, int ly1, int lx2, int ly2, int *numberofitems, int itemsvisible, int *actitem, int lid, int keys)
Definition: dlg_box.cpp:582
Uint8 taste
Definition: events.h:95
tkey taste
Definition: dlg_box.h:88
const int black
Definition: basegfx.h:87
void hidebutton(int id)
Definition: dlg_box.cpp:742
void repaintdisplay(void)
int ysize
Definition: dlg_box.h:40
int knopfsuccessful
Definition: dlg_box.h:214
void done(void)
Definition: dlg_box.cpp:3617
virtual void buttonpressed(int id)
Definition: dlg_box.cpp:1828
virtual void repaintscrollbar(void)=0
int imagesaved
Definition: dlg_box.h:161
char * malloc(int)
const int white
Definition: basegfx.h:102
int tvt_x2
Definition: dlg_box.h:357
char getletter(const char *s)
Definition: dlg_box.cpp:123
#define ct_invvalue
Definition: keysymbols.h:25
void newknopfdruck4(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:283
struct GameMap::PreferredFilenames preferredFileNames
int tvt_background
Definition: dlg_box.h:358
virtual void dispeditstring(char *st, int x1, int y1)
Definition: dlg_box.cpp:1989
#define cto_entf
Definition: keysymbols.h:245
int firstvisibleline
Definition: dlg_box.h:420
int disablecolor
Definition: dlg_box.h:167
void evalcommand(const char **s)
Definition: dlg_box.cpp:2826
void done(void)
Definition: dlg_box.cpp:3270
pfont font
Definition: newfont.h:169
tstringa * pstringa
Definition: dlg_box.cpp:1748
tkey markedkey[6]
Definition: dlg_box.h:67
int getmousestatus()
Definition: events.cpp:79
int mouseinrect(int x1, int y1, int x2, int y2)
Definition: events.cpp:108
int scanlinenumber
the number of lines (may be larger than resolutiony due to offscreen memory)
Definition: basegfx.h:58
Schriften schriften
Definition: spfst.cpp:66
void puttexture(int x1, int y1, int x2, int y2, void *texture)
function not used any more and obsolete. Use putimageprt instead
Definition: basegfx.cpp:1648
int tvt_yp
Definition: dlg_box.h:357
This file is included by dlg_box.cpp !
void done(void)
Definition: dlg_box.cpp:1235
char * strrr(int a)
converts a to a string.
Definition: misc.cpp:66
int tvt_y2
Definition: dlg_box.h:357
int windowstyle
Definition: dlg_box.h:163
void toggleswitch(pbutton pb)
Definition: dlg_box.cpp:1618
virtual void redrawall(void)
Definition: dlg_box.cpp:224
char txt[2000]
Definition: dlg_box.h:416
static collategraphicoperations * pcgo
Definition: dlg_box.h:169
int tvt_xp
Definition: dlg_box.h:357
virtual ~tviewtext()
Definition: dlg_box.cpp:2971
virtual int gettextwdth_stredit(char *txt, pfont font)
Definition: dlg_box.cpp:2220
void displayLogMessage(int msgVerbosity, const char *message,...)
Adapter class for using Paragui Dialogs in ASC. This class transfers the event control from ASC to Pa...
Definition: paradialog.h:127
int tvt_y1
Definition: dlg_box.h:357
#define ct_entf
Definition: keysymbols.h:125
virtual void setup(void)
Definition: dlg_box.cpp:3471
void knopf(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:122
void displaymessage(const char *formatstring, int num,...)
displays a dialog box with a message
Definition: dlg_box.cpp:1849
pstartpoint tvt_startpoint
Definition: dlg_box.h:370
int scrollbarvisible
Definition: dlg_box.h:421
#define ct_1k
Definition: keysymbols.h:66
class tdialogbox * pdialogbox
Definition: dlg_box.h:152
void addbutton(const char *ltxt, int lx1, int ly1, int lx2, int ly2, int lart, int lstyle, int lid, bool enabled)
Definition: dlg_box.cpp:471
PointerSizedInt linearaddress
the pointer to the actual memory (typecast to char* )
Definition: basegfx.h:63
#define ct_esc
Definition: keysymbols.h:43
tgraphmodeparameters tvt_firstlinebufparm
Definition: dlg_box.h:365
Dialog classes based on the Paragui library.
Searching for files.
Definition: basestrm.h:484
void init(void)
Definition: dlg_box.cpp:110
virtual void disablebutton(int id)
Definition: dlg_box.cpp:993
void rebuildtaborder(void)
Definition: dlg_box.cpp:651
int tvt_color
Definition: dlg_box.h:358
void addDropDown(int x1, int y1, int x2, int y2, int ID, const char **entries, int entrynum, int *pos)
Definition: dlg_box.cpp:548
Uint16 length
Definition: newfont.h:174
ASCString editString(const ASCString &title, const ASCString &defaultValue)
Definition: dlg_box.cpp:3894
const int lightblue
Definition: basegfx.h:96
void strrd8u(int l, char *s)
Definition: dlg_box.cpp:62
void showtext3(const char *txt, int xpos, int ypos)
Definition: newfont.cpp:246
int getplayercolor(int i)
Definition: dlg_box.cpp:303
pbutton getbutton(int id)
Definition: dlg_box.cpp:361
void viewtext(void)
Definition: dlg_box.cpp:3586
const char * textpointer
Definition: dlg_box.h:337
void setpos(int xx1, int yy1, int xx2, int yy2)
Definition: dlg_box.cpp:2657
void repaintscrollbar(void)
Definition: dlg_box.cpp:3224
void bar(tmouserect rect, int color)
Definition: dlg_box.cpp:537
#define cto_invvalue
Definition: keysymbols.h:145
const int lightred
Definition: basegfx.h:99
char * strrrd8u(int l)
Definition: dlg_box.cpp:80
int viewtextquery(int id, const char *title, const char *s1, const char *s2)
Definition: dlg_box.cpp:3394
#define cto_pos1
Definition: keysymbols.h:247
int keypress(void)
Definition: events.cpp:146
#define ct_8k
Definition: keysymbols.h:73
#define ct_2k
Definition: keysymbols.h:67
signed char actplayer
the player who is currently making his moves (may be human or AI)
Definition: gamemap.h:232
int byteperpix
the distance between two pixel
Definition: basegfx.h:62
ttaborder taborder[100]
Definition: dlg_box.h:164
void newknopfdruck3(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:260
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
void editfield(pbutton pb)
Definition: dlg_box.cpp:1662
int gettextwdth(const char *txt, pfont font)
Definition: newfont.cpp:217
void addkey(int id, tkey key)
Definition: dlg_box.cpp:774
void repaintdisplay(void)
Definition: dlg_box.cpp:188
virtual void buttonpressed(int id)
Definition: dlg_box.cpp:3343
const int red
Definition: basegfx.h:91
#define npop(a)
Definition: stack.h:54
char skeypress(tkey keynr)
Definition: events.cpp:181
virtual void run(void)
Definition: dlg_box.cpp:3259
void putimageprt(int x1, int y1, int x2, int y2, void *texture, int dx, int dy)
copies a part of texture to the screen.
Definition: basegfx.cpp:1693
virtual void paint(void)
Definition: dlg_box.cpp:292
void addmarkedkey(int id, tkey key)
Definition: dlg_box.cpp:793
int max
Definition: dlg_box.cpp:3633
int prntkey
Definition: dlg_box.h:89
ASCString org
Definition: dlg_box.cpp:3821
int min
Definition: dlg_box.cpp:3633
void checkscrolling(void)
Definition: dlg_box.cpp:2982
void setscrollspeed(char id, int speed)
Definition: dlg_box.cpp:814
#define cto_enter
Definition: keysymbols.h:171
#define ppicture
Definition: dlg_box.cpp:3132
void * tp
Definition: dlg_box.h:160
void displaytext(void)
Definition: dlg_box.cpp:2693
void showtext2(const ASCString &text, int x, int y)
Definition: basegfx.cpp:1953
int tkey
Definition: events.h:126
void help(int id)
displays a dialogbog with the given help topic
Definition: dlg_box.cpp:3286
void setup(void)
Definition: dlg_box.cpp:3319
#define cto_bspace
Definition: keysymbols.h:151
virtual void buttonpressed(int id)
Definition: dlg_box.cpp:3754
char * itoa(int a, char *b, int c)
Definition: misc.cpp:179
basegfx.h is the interface for the legacy graphic routines (of which some are platform dependent)...
enum StringEdit::@8 onCancel
virtual void get_text(int nr)
Definition: dlg_box.cpp:3762
int imagesize(int x1, int y1, int x2, int y2)
returns the size for a buffer that can contain an image of the given size.
Definition: basegfx.cpp:896
#define ct_right
Definition: keysymbols.h:121
int atoi(const std::string &s)
Definition: misc.cpp:152
virtual void setup()
Definition: dlg_box.cpp:3165
ppicture next
Definition: dlg_box.cpp:3139
int y2
Definition: events.h:65
virtual void execbutton(pbutton pb, char mouse)
Definition: dlg_box.cpp:1266
void removemessage(void)
closes a message dialog box that has been opened by displaymessage()
Definition: dlg_box.cpp:1976
pfont large
Definition: spfst-legacy.h:30
int textcolor
Definition: dlg_box.h:157
int virtualbufoffset
Definition: dlg_box.h:201
#define ct_up
Definition: keysymbols.h:122
char scrollbarvisible
Definition: dlg_box.cpp:3148
void strrd8n(int l, char *s)
Definition: dlg_box.cpp:67
virtual void redraw(void)
Definition: dlg_box.cpp:1113
tbutton * button
Definition: dlg_box.h:82
#define dlg_3dtitle
Definition: dlg_box.h:35
ppicture firstpict
Definition: dlg_box.cpp:3149
void setparams(int xx1, int yy1, int xx2, int yy2, const char *ttxt, char clr, char bkgr)
Definition: dlg_box.cpp:2665
procedure for loading and writing savegames, maps etc.
pdialogbox prev
Definition: dlg_box.h:203
virtual void redrawall2(int xx1, int yy1, int xx2, int yy2)
Definition: dlg_box.cpp:233
char * strrrd8n(int l)
Definition: dlg_box.cpp:87
void * dialogtexture
Definition: dlg_box.cpp:95
void setnewlineheight(int h)
Definition: dlg_box.cpp:2547
bool legacyEventSystemActive()
Definition: events.cpp:651
char * tvt_firstlinebuf
Definition: dlg_box.h:364
int eeinzug
Definition: dlg_box.h:360
char nt[200]
Definition: dlg_box.cpp:3631
int tvt_dispactive
Definition: dlg_box.h:359
void newknopfdruck(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:302
virtual void buttonpressed(int id)
Definition: dlg_box.cpp:3883
virtual void enablebutton(int id)
Definition: dlg_box.cpp:860
int resolutionx
the number of visible pixels in x direction
Definition: basegfx.h:52
int tvt_maxlineheight
Definition: dlg_box.h:361
#define dlg_in3d
Definition: dlg_box.h:33
void init(void)
Definition: dlg_box.cpp:3638
GameMap * actmap
Definition: spfst.cpp:64
char * tstringa[30]
Definition: dlg_box.cpp:1747
int actdisplayedmessage
Definition: dlg_box.cpp:97
void init(void)
Definition: dlg_box.cpp:314
bool setEventRouting(bool queue, bool legacy)
Defines what happens with the SDL events.
Definition: events.cpp:633
char descrip[20]
Definition: dlg_box.cpp:3140
tstartpoint * next
Definition: dlg_box.h:338
void viewtext2(int id)
displays a dialogbog with the given message
Definition: dlg_box.cpp:3296
bool exist(const ASCString &s)
does a file s exist (wildcards allowed)
Definition: basestrm.cpp:2444
void run(void)
Definition: dlg_box.cpp:3768
const T & max(const T &a, const T &b, const T &c)
Definition: misc.h:97
const T & min(const T &a, const T &b, const T &c)
Definition: misc.h:80
tvirtualscreenbuf(void)
Definition: dlg_box.cpp:104
int scanlinelength
the size of a line in byte (may be larger than resolutionx due to offscreen memory) ...
Definition: basegfx.h:57
#define cto_einf
Definition: keysymbols.h:246
const char * emptystring
Definition: dlg_box.cpp:469
#define ct_9k
Definition: keysymbols.h:74
const int darkgray
Definition: basegfx.h:95
virtual void buttonpressed(int id)
Definition: dlg_box.cpp:3476
virtual void changecoordinates(void)
Definition: dlg_box.cpp:356
#define strnicmp
char * actline
Definition: dlg_box.h:363
void getimage(int x1, int y1, int x2, int y2, void *buffer)
copy an image to a buffer. buffer must have been alloced before with malloc ( imagesize ( x1...
Definition: basegfx.cpp:1256
void * pict
Definition: dlg_box.cpp:3135
int windowstatus
determines whether the memory is a linear (windowstatus==100) or paged. When using SDL...
Definition: basegfx.h:55
#define ct_shift_tab
Definition: keysymbols.h:46
int y1
Definition: events.h:64
#define ct_3k
Definition: keysymbols.h:68
#define ct_down
Definition: keysymbols.h:123
virtual void run(void)
Definition: dlg_box.cpp:3665
void setup()
Definition: dlg_box.cpp:3740
void getkeysyms(tkey *keysym, int *keyprnt)
Definition: events.cpp:157
void init(tstringa a, int md, int linenum, const char *buttonText=NULL)
Definition: dlg_box.cpp:1763
virtual void buttonpressed(int id)
Definition: dlg_box.cpp:3248
#define ct_pdown
Definition: keysymbols.h:129
#define cto_ende
Definition: keysymbols.h:248
ChooseString(const ASCString &_title, const vector< ASCString > &_strings, const vector< ASCString > &_buttons, int defaultEntry)
Definition: dlg_box.cpp:3732
Uint8 height
Definition: newfont.h:178
void mousevisible(int an)
Definition: events.cpp:75
volatile tmousesettings mouseparams
Definition: events.cpp:35
void addeingabe(int lid, void *data, int min, int max)
Definition: dlg_box.cpp:833
void fatalError(const ASCString &string)
void scrollbar_on(void)
Definition: dlg_box.cpp:3579
tdisplaymessage * messagebox
Definition: dlg_box.cpp:3409
virtual void run(void)
Definition: dlg_box.cpp:3487
Collects all graphic operations and updates the screen on destruction When porting ASC from DOS to SD...
Definition: basegfx.h:406
void displaysingleline(char *t)
Definition: dlg_box.cpp:2622
int x2
Definition: events.h:65
#define linesshown
Definition: dlg_box.h:386
virtual void setclipping(void)
Definition: dlg_box.cpp:254
int chooseString(const ASCString &title, const vector< ASCString > &entries, int defaultEntry)
displays a dialogbox which lets you choose one of a number of strings.
Definition: dlg_box.cpp:3788
Interface for a small general-purpose stack (not type safe)
ViewTextQuery(int id, const ASCString &title, const ASCString &button1, const ASCString &button2)
Definition: dlg_box.cpp:3372
void init(void)
Definition: dlg_box.cpp:3834
struct txlattables::@19::@21 a
void nextline(int einzug, const char *txtptr)
Definition: dlg_box.cpp:2592
const int lightgray
Definition: basegfx.h:94
int size
Definition: dlg_box.cpp:3136
void showbutton(int id)
Definition: dlg_box.cpp:707
virtual void buttonpressed(int id)
Definition: dlg_box.cpp:3689
int width
Definition: dlg_box.cpp:3137
void rectangle(int x1, int y1, int x2, int y2, Uint8 color)
draws a simple rectangl
Definition: basegfx.cpp:297
int bytesperscanline
the size of a line in byte
Definition: basegfx.h:59
const char * title
Definition: dlg_box.h:162
#define minmalq
Definition: typen.h:430
void init(int id, const char *titel, const char *s1, const char *s2)
Definition: dlg_box.cpp:3332
void line(int x1, int y1, int x2, int y2, Uint8 actcol)
draws a simple line on the screen. Not very fast...
Definition: basegfx.cpp:181
void stredit(char *s, int x1, int y1, int wdth, int max)
Definition: dlg_box.cpp:1995
#define ct_pup
Definition: keysymbols.h:130
int getid(const char *title, int lval, int min, int max)
Definition: dlg_box.cpp:3701
volatile int ticker
Definition: events.cpp:234
Definition: newfont.h:150
virtual void resettextfield(void)
Definition: dlg_box.cpp:3568