KarteAuswahl.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. #include "KarteAuswahl.h"
  2. #include <Text.h>
  3. #include <Rahmen.h>
  4. #include <Punkt.h>
  5. #include <Schrift.h>
  6. #include <AlphaFeld.h>
  7. #include <TextFeld.h>
  8. #include <Datei.h>
  9. #include <DateiSystem.h>
  10. #include "..\..\..\Global\Initialisierung.h"
  11. #include <MausEreignis.h>
  12. #include "..\..\..\Global\Variablen.h"
  13. #include "..\..\..\Leser\KartenLeser.h"
  14. void KarteAuswahlKSGSAktion( void *p, RCArray< KSGSVariable > *parameter, KSGSVariable **retVal )
  15. {
  16. if( !p )
  17. return;
  18. ( (KarteDaten*)p )->ksgsAktion( parameter, retVal );
  19. }
  20. KarteDaten::Loader::Loader( KarteDaten *kd, int aktion )
  21. {
  22. this->aktion = aktion;
  23. this->kd = kd;
  24. ref = 2;
  25. start();
  26. }
  27. void KarteDaten::Loader::thread()
  28. {
  29. if( !aktion )
  30. {
  31. kd->geladen = 0;
  32. if( kd->hintergrund )
  33. kd->hintergrund = kd->hintergrund->release();
  34. if( kd->beschreibung )
  35. {
  36. kd->beschreibung->zurücksetzen();
  37. kd->beschreibung = kd->beschreibung->release();
  38. }
  39. kd->rend = 1;
  40. if( kd->ksgs )
  41. {
  42. dllDateien->releaseDLL( "KSGScript.dll" );
  43. kd->ksgs = 0;
  44. }
  45. }
  46. else
  47. {
  48. KartenLeser *mapReader = KartenLeser::getInstance();
  49. mapReader->lock();
  50. mapReader->setKarteId( kd->karteId );
  51. if( aktion == 1 )
  52. {
  53. if( !kd->hintergrund )
  54. kd->hintergrund = mapReader->getKartenTitelBild( kd->schrift );
  55. if( !kd->geladen )
  56. kd->geladen = 1;
  57. kd->rend = 1;
  58. }
  59. if( aktion == 2 )
  60. {
  61. if( !mapReader->getKartenBeschreibung() )
  62. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( "Beschreibung nicht gefunden." ), new Text( "Ok" ) );
  63. if( kd->beschreibung )
  64. {
  65. kd->beschreibung->zurücksetzen();
  66. kd->beschreibung = kd->beschreibung->release();
  67. }
  68. if( !kd->ksgs )
  69. kd->ksgs = dllDateien->ladeDLL( "KSGScript.dll", "data/bin/KSGScript.dll" );
  70. if( kd->ksgs )
  71. {
  72. KSGSGetZeichnung getKSGScript = (KSGSGetZeichnung)GetProcAddress( kd->ksgs, KSGS_START_FUNKTION );
  73. if( getKSGScript )
  74. {
  75. kd->beschreibung = getKSGScript();
  76. kd->beschreibung->setBildschirmZ( hauptScreen->getThis() );
  77. kd->beschreibung->setSchriftZ( kd->schrift->getThis() );
  78. kd->beschreibung->setSize( 578, 428 );
  79. kd->beschreibung->setRückrufParam( kd );
  80. kd->beschreibung->setRückrufFunktion( KarteAuswahlKSGSAktion );
  81. Text *pf = mapReader->getKartePfad();
  82. *pf += "beschreibung.ksgs";
  83. kd->beschreibung->setScriptDatei( pf );
  84. }
  85. else
  86. {
  87. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ),
  88. new Text( "Der Einstiegspunkt '" KSGS_START_FUNKTION "' in der DLL-Datei "
  89. "'data/bin/KSGScript.dll' konnte nicht gefunden werden." ),
  90. new Text( "Ok" ), 0, NachrichtType::nachricht, 0 );
  91. }
  92. }
  93. else
  94. {
  95. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ),
  96. new Text( "Die DLL-Datei 'data/bin/KSGScript.dll' konnte nicht geladen werden." ),
  97. new Text( "Ok" ), 0, NachrichtType::nachricht, 0 );
  98. }
  99. if( kd->beschreibung )
  100. {
  101. kd->geladen = 2;
  102. if( kd->ausgewählt )
  103. {
  104. kd->animation |= 0x4;
  105. kd->beschreibung->neuLaden();
  106. KSGSGetVariable getKSGSVar = (KSGSGetVariable)GetProcAddress( kd->ksgs, KSGS_VARIABLE_FUNKTION );
  107. RCArray< KSGSVariable > *params = new RCArray< KSGSVariable >();
  108. KSGSVariableDef p1;
  109. p1.typId = KSGS_BOOL;
  110. p1.wert = (int)kd->erlaubt;
  111. params->add( getKSGSVar( kd->beschreibung, &p1 ) );
  112. KSGSVariable *var = kd->beschreibung->startFunktion( kd->beschreibung->getFunktionId( "_set_Erlaubt" ), params );
  113. if( var )
  114. var->release();
  115. }
  116. }
  117. kd->rend = 1;
  118. }
  119. mapReader->unlock();
  120. mapReader->release();
  121. }
  122. if( !kd->erlaubt )
  123. kd->updateErlaubt();
  124. kd->rend = 1;
  125. release();
  126. }
  127. KarteDaten::Loader *KarteDaten::Loader::release()
  128. {
  129. if( !--ref )
  130. delete this;
  131. return 0;
  132. };
  133. int KarteDaten::Loader::getAction() const
  134. {
  135. return aktion;
  136. }
  137. // Inhalt der KarteDaten Klasse aus KarteAuswahl.h
  138. // Konstruktor
  139. KarteDaten::KarteDaten( Schrift *zSchrift, int id )
  140. {
  141. hintergrund = 0;
  142. beschreibung = 0;
  143. ksgs = 0;
  144. rahmen = new LRahmen();
  145. rahmen->setFarbe( 0xFFFFFFFF );
  146. rahmen->setRamenBreite( 1 );
  147. tickVal = 0;
  148. animation = 0;
  149. ausgewählt = 0;
  150. pos = Punkt( 0, 500 );
  151. gr = Punkt( 200, 100 );
  152. schrift = zSchrift->getThis();
  153. karteId = id;
  154. geladen = 0;
  155. auswahl = new AlphaFeld();
  156. auswahl->setFarbe( 0x0000FF00 );
  157. auswahl->setStrength( 8 );
  158. auswahl->setSize( 200, 100 );
  159. auswAlpha = 0;
  160. rend = 0;
  161. erlaubt = 0;
  162. tAlpha = 0;
  163. alpha = 0;
  164. ref = 1;
  165. loader = new Loader( this, 1 );
  166. }
  167. // Destruktor
  168. KarteDaten::~KarteDaten()
  169. {
  170. if( loader && loader->isRunning() )
  171. loader->warteAufThread( INT_MAX );
  172. loader->release();
  173. if( schrift )
  174. schrift->release();
  175. if( hintergrund )
  176. hintergrund->release();
  177. if( beschreibung )
  178. {
  179. beschreibung->zurücksetzen();
  180. beschreibung->release();
  181. }
  182. if( ksgs )
  183. {
  184. dllDateien->releaseDLL( "KSGScript.dll" );
  185. ksgs = 0;
  186. }
  187. rahmen->release();
  188. auswahl->release();
  189. }
  190. // nicht constant
  191. void KarteDaten::updateErlaubt()
  192. {
  193. if( geladen != 2 )
  194. return;
  195. bool update = erlaubt;
  196. erlaubt = infoClient->istKarteErlaubt( karteId );
  197. if( update != erlaubt && beschreibung && ksgs )
  198. {
  199. KSGSGetVariable getKSGSVar = (KSGSGetVariable)GetProcAddress( ksgs, KSGS_VARIABLE_FUNKTION );
  200. RCArray< KSGSVariable > *params = new RCArray< KSGSVariable >();
  201. KSGSVariableDef p1;
  202. p1.typId = KSGS_BOOL;
  203. p1.wert = (int)erlaubt;
  204. params->add( getKSGSVar( beschreibung, &p1 ) );
  205. KSGSVariable *var = beschreibung->startFunktion( beschreibung->getFunktionId( "_set_Erlaubt" ), params );
  206. if( var )
  207. var->release();
  208. }
  209. }
  210. void KarteDaten::ksgsAktion( RCArray< KSGSVariable > *parameter, KSGSVariable **retVal )
  211. {
  212. if( parameter && parameter->getEintragAnzahl() > 0 )
  213. {
  214. Text *txt = parameter->z( 0 )->getText();
  215. if( erlaubt && txt->istGleich( "anmelden" ) )
  216. {
  217. if( nachLogin && nachLogin->zSpielenFenster() )
  218. nachLogin->zSpielenFenster()->anmelden( karteId );
  219. }
  220. if( erlaubt && txt->istGleich( "gruppeErstellen" ) )
  221. {
  222. if( !anmeldungClient )
  223. anmeldungClient = mainClient->createAnmeldungServerClient();
  224. if( !anmeldungClient )
  225. {
  226. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
  227. new Text( "Ok" ), 0, NachrichtType::nachricht, 0 );
  228. rend = 1;
  229. }
  230. if( !anmeldungClient->verbinde() )
  231. {
  232. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  233. new Text( "Ok" ), 0, NachrichtType::nachricht, 0 );
  234. rend = 1;
  235. }
  236. else
  237. {
  238. int ret = anmeldungClient->gruppeErstellen( karteId );
  239. if( !ret && nachLogin )
  240. {
  241. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  242. new Text( "Ok" ), 0, NachrichtType::nachricht, 0 );
  243. }
  244. else if( nachLogin )
  245. nachLogin->zSpielenFenster()->gruppeBetreten( ret );
  246. anmeldungClient->trenne( 0 );
  247. }
  248. }
  249. txt->release();
  250. }
  251. }
  252. void KarteDaten::setSichtbar( bool sichtbar )
  253. {
  254. if( sichtbar )
  255. animation |= 0x1;
  256. else
  257. {
  258. animation &= ~0x1;
  259. setAuswahl( 0 );
  260. }
  261. if( sichtbar && geladen != 2 && loader->getAction() != 2 )
  262. {
  263. Loader *altLoader = loader;
  264. loader = new Loader( this, 2 );
  265. altLoader->release();
  266. }
  267. rend = 1;
  268. }
  269. void KarteDaten::setSichtbar()
  270. {
  271. animation |= 0x1;
  272. if( ausgewählt && geladen == 2 )
  273. {
  274. animation |= 0x4;
  275. beschreibung->setPosition( beschreibung->getX(), 0 );
  276. }
  277. if( geladen != 2 && loader->getAction() != 2 )
  278. {
  279. Loader *altLoader = loader;
  280. loader = new Loader( this, 2 );
  281. altLoader->release();
  282. }
  283. rend = 1;
  284. }
  285. void KarteDaten::setAuswahl( bool auswahl )
  286. {
  287. if( ausgewählt == auswahl )
  288. return;
  289. ausgewählt = auswahl;
  290. if( auswahl )
  291. {
  292. animation |= 0x4;
  293. if( beschreibung && ksgs )
  294. {
  295. beschreibung->neuLaden();
  296. KSGSGetVariable getKSGSVar = (KSGSGetVariable)GetProcAddress( ksgs, KSGS_VARIABLE_FUNKTION );
  297. RCArray< KSGSVariable > *params = new RCArray< KSGSVariable >();
  298. KSGSVariableDef p1;
  299. p1.typId = KSGS_BOOL;
  300. p1.wert = (int)erlaubt;
  301. params->add( getKSGSVar( beschreibung, &p1 ) );
  302. KSGSVariable *var = beschreibung->startFunktion( beschreibung->getFunktionId( "_set_Erlaubt" ), params );
  303. if( var )
  304. var->release();
  305. }
  306. }
  307. else
  308. animation &= ~0x4;
  309. rend = 1;
  310. }
  311. void KarteDaten::setPosition( int lPos )
  312. {
  313. pos.y = lPos * 100;
  314. rend = 1;
  315. }
  316. bool KarteDaten::tick( double tickVal )
  317. {
  318. if( beschreibung )
  319. rend |= beschreibung->tick( tickVal );
  320. this->tickVal += tickVal * 500;
  321. int val = ( int ) this->tickVal;
  322. if( val < 1 )
  323. {
  324. bool ret = rend;
  325. rend = 0;
  326. return ret;
  327. }
  328. if( val > 17 )
  329. val = 17;
  330. this->tickVal -= val;
  331. if( ausgewählt )
  332. {
  333. if( auswAlpha != 0xF0 )
  334. {
  335. auswAlpha += val;
  336. if( auswAlpha > 0xF0 )
  337. auswAlpha = 0xF0;
  338. rend = 1;
  339. }
  340. }
  341. else
  342. {
  343. if( auswAlpha != 0 )
  344. {
  345. auswAlpha -= val;
  346. if( auswAlpha > 0xF0 )
  347. auswAlpha = 0;
  348. rend = 1;
  349. }
  350. }
  351. if( ( animation | 0x1 ) == animation ) // sichtbar
  352. {
  353. if( tAlpha != 255 )
  354. {
  355. if( tAlpha + val > 255 )
  356. tAlpha = 255;
  357. else
  358. tAlpha += val;
  359. rend = 1;
  360. }
  361. }
  362. else // unsichtbar
  363. {
  364. if( tAlpha != 0 )
  365. {
  366. if( tAlpha - val < 0 )
  367. tAlpha = 0;
  368. else
  369. tAlpha -= val;
  370. rend = 1;
  371. }
  372. }
  373. if( ( animation | 0x4 ) == animation ) // auswählen
  374. {
  375. if( beschreibung )
  376. {
  377. if( alpha != 255 )
  378. {
  379. if( alpha + val < 255 )
  380. alpha += val;
  381. else
  382. alpha = 255;
  383. rend = 1;
  384. }
  385. }
  386. }
  387. else // abwählen
  388. {
  389. int a = ( auswahl->getFarbe() >> 24 ) & 0xFF;
  390. if( a != 0 )
  391. {
  392. a -= val;
  393. if( a < 0 )
  394. a = 0;
  395. auswahl->setFarbe( ( ( a << 24 ) & 0xFF000000 ) | ( auswahl->getFarbe() & 0xFFFFFF ) );
  396. rend = 1;
  397. }
  398. if( beschreibung )
  399. {
  400. if( alpha != 0 )
  401. {
  402. if( alpha - val > 0 )
  403. alpha -= val;
  404. else
  405. alpha = 0;
  406. rend = 1;
  407. }
  408. }
  409. }
  410. bool ret = rend;
  411. rend = 0;
  412. return ret;
  413. }
  414. void KarteDaten::doMausEreignis( MausEreignis &me )
  415. {
  416. me.mx -= gr.x;
  417. if( beschreibung )
  418. beschreibung->doMausEreignis( me );
  419. me.mx += gr.x;
  420. }
  421. void KarteDaten::render( Bild &zRObj )
  422. {
  423. int x = pos.x;
  424. int y = pos.y;
  425. int br = gr.x;
  426. int hö = gr.y;
  427. if( !zRObj.setDrawOptions( x, y, br, hö ) )
  428. return;
  429. zRObj.setAlpha( tAlpha );
  430. rahmen->setSize( br, hö );
  431. rahmen->render( zRObj );
  432. int rbr = rahmen->getRBreite();
  433. if( geladen && hintergrund )
  434. zRObj.drawBild( rbr, rbr, br - rbr * 2, hö - rbr * 2, *hintergrund );
  435. if( auswAlpha && auswahl )
  436. {
  437. auswahl->setFarbe( ( auswahl->getFarbe() & 0x00FFFFFF ) | ( auswAlpha << 24 ) );
  438. auswahl->setPosition( rbr, rbr );
  439. auswahl->setSize( br - rbr * 2, hö - rbr * 2 );
  440. auswahl->render( zRObj );
  441. }
  442. zRObj.releaseDrawOptions();
  443. x = br;
  444. y = 0;
  445. br = 580;
  446. hö = 480;
  447. if( !zRObj.setDrawOptions( x, y, br, hö ) )
  448. {
  449. zRObj.releaseAlpha();
  450. return;
  451. }
  452. if( geladen == 2 )
  453. {
  454. zRObj.setAlpha( alpha );
  455. if( beschreibung )
  456. beschreibung->render( zRObj );
  457. zRObj.releaseAlpha();
  458. }
  459. zRObj.releaseDrawOptions();
  460. zRObj.releaseAlpha();
  461. }
  462. // constant
  463. int KarteDaten::getKarteId() const
  464. {
  465. return karteId;
  466. }
  467. bool KarteDaten::istausgewählt() const
  468. {
  469. return ausgewählt;
  470. }
  471. // Reference Counting
  472. KarteDaten *KarteDaten::getThis()
  473. {
  474. ref++;
  475. return this;
  476. }
  477. KarteDaten *KarteDaten::release()
  478. {
  479. ref--;
  480. if( !ref )
  481. delete this;
  482. return 0;
  483. }
  484. // Inhalt der KarteAuswahlFenster Klasse aus KarteAuswahl.h
  485. // Konstruktor
  486. KarteAuswahlFenster::KarteAuswahlFenster( Schrift *zSchrift )
  487. {
  488. schrift = zSchrift->getThis();
  489. rahmen = new LRahmen();
  490. rahmen->setFarbe( 0xFFFFFFFF );
  491. rahmen->setRamenBreite( 1 );
  492. rahmen->setSize( 760, 500 );
  493. members = new RCArray< KarteDaten >();
  494. anzahl = 0;
  495. animation = 0;
  496. auswahl = -1;
  497. tickVal = 0;
  498. seite = 0;
  499. pos = Punkt( 10, 10 );
  500. gr = Punkt( 780, 430 );
  501. spielId = 0;
  502. rend = 0;
  503. alpha = 0;
  504. ref = 1;
  505. }
  506. // Destruktor
  507. KarteAuswahlFenster::~KarteAuswahlFenster()
  508. {
  509. if( schrift )
  510. schrift->release();
  511. if( rahmen )
  512. rahmen->release();
  513. if( members )
  514. members->release();
  515. }
  516. // nicht constant
  517. void KarteAuswahlFenster::setSpielId( int id )
  518. {
  519. spielId = id;
  520. members->leeren();
  521. anzahl = 0;
  522. start();
  523. }
  524. void KarteAuswahlFenster::setSichtbar( bool sichtbar )
  525. {
  526. if( sichtbar )
  527. {
  528. animation |= 0x1;
  529. start();
  530. }
  531. else
  532. {
  533. auswahl = -1;
  534. for( int i = seite * 4; i >= 0 && i < anzahl && i < seite * 4 + 4; i++ )
  535. members->z( i )->setSichtbar( 0 );
  536. animation &= ~0x1;
  537. }
  538. rend = 1;
  539. }
  540. void KarteAuswahlFenster::blättern( bool oben )
  541. {
  542. for( int i = seite * 4; i >= 0 && i < anzahl && i < seite * 4 + 4; i++ )
  543. members->z( i )->setSichtbar( 0 );
  544. seite += oben ? 1 : -1;
  545. for( int i = seite * 4; i >= 0 && i < anzahl && i < seite * 4 + 4; i++ )
  546. {
  547. members->z( i )->setPosition( i % 4 );
  548. members->z( i )->setSichtbar( 1 );
  549. }
  550. auswahl = -1;
  551. rend = 1;
  552. }
  553. void KarteAuswahlFenster::updateListe()
  554. {
  555. if( run )
  556. return;
  557. start();
  558. }
  559. void KarteAuswahlFenster::thread()
  560. {
  561. Array< int > *liste = infoClient->getAccountKarteListe( spielId );
  562. if( !liste )
  563. {
  564. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( infoClient->getLetzterFehler() ),
  565. new Text( "Ok" ), 0, NachrichtType::nachricht, 0 );
  566. run = 0;
  567. return;
  568. }
  569. int anz = liste->getEintragAnzahl();
  570. for( int i = 0; i < anz; i++ )
  571. {
  572. bool gefunden = 0;
  573. for( int j = 0; j < anzahl; j++ )
  574. {
  575. KarteDaten *tmp = members->z( j );
  576. if( liste->hat( i ) && tmp->getKarteId() == liste->get( i ) )
  577. {
  578. gefunden = 1;
  579. break;
  580. }
  581. }
  582. if( !gefunden )
  583. {
  584. KarteDaten *tmp = new KarteDaten( schrift, liste->hat( i ) ? liste->get( i ) : 0 );
  585. members->add( tmp, anzahl );
  586. anzahl++;
  587. }
  588. }
  589. if( liste )
  590. liste->release();
  591. for( int i = 0; i < anzahl; i++ )
  592. members->z( i )->updateErlaubt();
  593. for( int i = seite * 4; i < anzahl && i >= 0 && i < seite * 4 + 4; i++ )
  594. {
  595. members->z( i )->setPosition( i % 4 );
  596. members->z( i )->setSichtbar();
  597. }
  598. rend = 1;
  599. run = 0;
  600. }
  601. bool KarteAuswahlFenster::tick( double tickVal )
  602. {
  603. for( int i = 0; i < anzahl; i++ )
  604. rend |= members->z( i )->tick( tickVal );
  605. this->tickVal += tickVal * 750;
  606. int val = ( int )this->tickVal;
  607. if( val < 1 )
  608. {
  609. bool ret = rend;
  610. rend = 0;
  611. return ret;
  612. }
  613. if( val > 25 )
  614. val = 25;
  615. this->tickVal -= val;
  616. if( ( animation | 0x1 ) == animation ) // sichtbar
  617. {
  618. if( alpha < 255 )
  619. {
  620. if( alpha + val >= 255 )
  621. {
  622. alpha = 255;
  623. for( int i = seite * 4; i < anzahl && i >= 0 && i < seite * 4 + 4; i++ )
  624. {
  625. members->z( i )->setPosition( i % 4 );
  626. members->z( i )->setSichtbar( 1 );
  627. }
  628. }
  629. else
  630. alpha += val;
  631. rend = 1;
  632. }
  633. }
  634. else // unsichtbar
  635. {
  636. if( alpha > 0 )
  637. {
  638. if( alpha - val < 0 )
  639. alpha = 0;
  640. else
  641. alpha -= val;
  642. rend = 1;
  643. }
  644. }
  645. bool ret = rend;
  646. rend = 0;
  647. return ret;
  648. }
  649. void KarteAuswahlFenster::doMausEreignis( MausEreignis &me )
  650. {
  651. if( !members )
  652. return;
  653. if( pos.x != 10 )
  654. return;
  655. me.mx -= pos.x;
  656. me.my -= pos.y;
  657. for( int i = 0; i < anzahl; i++ )
  658. members->z( i )->doMausEreignis( me );
  659. if( me.mx < 0 || me.my < 0 )
  660. {
  661. me.mx += pos.x;
  662. me.my += pos.y;
  663. return;
  664. }
  665. if( me.mx > 200 || me.my > getAnzahlAufSeite() * 100 )
  666. {
  667. me.mx += pos.x;
  668. me.my += pos.y;
  669. return;
  670. }
  671. if( me.id == ME_RLinks )
  672. {
  673. int treffer = me.my / 100 + seite * 4;
  674. if( treffer >= anzahl )
  675. {
  676. me.mx += pos.x;
  677. me.my += pos.y;
  678. return;
  679. }
  680. if( treffer == auswahl )
  681. {
  682. me.mx += pos.x;
  683. me.my += pos.y;
  684. return;
  685. }
  686. if( auswahl >= 0 )
  687. members->z( auswahl )->setAuswahl( 0 );
  688. members->z( treffer )->setAuswahl( 1 );
  689. auswahl = treffer;
  690. rend = 1;
  691. }
  692. me.mx += pos.x;
  693. me.my += pos.y;
  694. }
  695. void KarteAuswahlFenster::render( Bild &zrObj )
  696. {
  697. int x = pos.x;
  698. int y = pos.y;
  699. int br = gr.x;
  700. int hö = gr.y;
  701. if( !zrObj.setDrawOptions( x, y, br, hö ) )
  702. return;
  703. zrObj.setAlpha( alpha );
  704. rahmen->setSize( br, hö );
  705. rahmen->render( zrObj );
  706. int rbr = rahmen->getRBreite();
  707. if( !zrObj.setDrawOptions( rbr, rbr, br - rbr * 2, hö - rbr * 2 ) )
  708. {
  709. zrObj.releaseDrawOptions();
  710. zrObj.releaseAlpha();
  711. return;
  712. }
  713. for( int i = seite * 4; i >= 0 && i < anzahl && i < seite * 4 + 4; i++ )
  714. members->z( i )->render( zrObj );
  715. zrObj.releaseDrawOptions();
  716. if( !anzahl )
  717. {
  718. Text t = "Dieser Account besitzt momentan noch keine Karten für dieses Spiel.\nBesuche den Shop um neue Karten zu erwerben!";
  719. schrift->lock();
  720. schrift->setDrawPosition( 10, 10 );
  721. schrift->setSchriftSize( 12 );
  722. schrift->renderText( &t, zrObj, 0xFFFFFFFF );
  723. schrift->unlock();
  724. }
  725. zrObj.releaseDrawOptions();
  726. zrObj.releaseAlpha();
  727. }
  728. // constant
  729. int KarteAuswahlFenster::getAnzahl() const
  730. {
  731. return anzahl;
  732. }
  733. int KarteAuswahlFenster::getSeiteAnzahl() const
  734. {
  735. return ( anzahl / 4.0 == anzahl / 4 ) ? ( anzahl / 4 ) : ( anzahl / 4 + 1 );
  736. }
  737. int KarteAuswahlFenster::getSeite() const
  738. {
  739. return seite;
  740. }
  741. int KarteAuswahlFenster::getAnzahlAufSeite() const
  742. {
  743. return ( anzahl < seite * 4 + 4 ) ? ( anzahl - seite * 4 ) : 4;
  744. }
  745. bool KarteAuswahlFenster::hatAuswahl() const
  746. {
  747. return auswahl != -1;
  748. }
  749. KarteDaten *KarteAuswahlFenster::getAuswahl() const
  750. {
  751. return members->get( auswahl );
  752. }
  753. // Reference Counting
  754. KarteAuswahlFenster *KarteAuswahlFenster::getThis()
  755. {
  756. ref++;
  757. return this;
  758. }
  759. KarteAuswahlFenster *KarteAuswahlFenster::release()
  760. {
  761. ref--;
  762. if( !ref )
  763. delete this;
  764. return 0;
  765. }