KarteAuswahl.cpp 21 KB

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