KarteAuswahl.cpp 20 KB

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