AccountHistorie.cpp 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548
  1. #include "AccountHistorie.h"
  2. #include "../../../Global/Initialisierung.h"
  3. #include "../../../Leser/KartenLeser.h"
  4. #include "../../../Global/Variablen.h"
  5. #include <Text.h>
  6. #include <Rahmen.h>
  7. #include <DateiSystem.h>
  8. #include <Zeit.h>
  9. #include <Punkt.h>
  10. typedef AccountHistorieStatistikV* ( *AHSSDLLStart )( void );
  11. typedef AufzeichnungV* ( *AHSADLLStart )( void );
  12. // Inahlt der AHSpielStatistik Klasse aus AccountHistorie.h
  13. // Konstruktor
  14. AHSpielStatistik::AHSpielStatistik( Schrift *schrift )
  15. : Thread(),
  16. schrift( schrift )
  17. {
  18. statistikF = initFenster( 10, 40, 780, 450, schrift, Fenster::Style::Sichtbar | Fenster::Style::Titel | Fenster::Style::TitelBuffered | Fenster::Style::Rahmen, "Spiel Ergebnis" );
  19. laden = (Animation2D*)ladeAnimation->dublizieren();
  20. laden->setSichtbar( 0 );
  21. laden->setPosition( 380, 245 );
  22. dllName = new Text( "" );
  23. dllHandle = 0;
  24. alpha = 0;
  25. sichtbar = 0;
  26. statistik = 0;
  27. tickVal = 0;
  28. ref = 1;
  29. }
  30. // Destruktor
  31. AHSpielStatistik::~AHSpielStatistik()
  32. {
  33. statistikF->release();
  34. if( dllHandle )
  35. reset();
  36. dllName->release();
  37. schrift->release();
  38. laden->release();
  39. }
  40. // nicht constant
  41. void AHSpielStatistik::reset()
  42. {
  43. if( run )
  44. warteAufThread( INFINITE );
  45. if( dllHandle )
  46. {
  47. if( statistik )
  48. statistik = statistik->release();
  49. dllDateien->releaseDLL( *dllName );
  50. dllHandle = 0;
  51. }
  52. }
  53. bool AHSpielStatistik::ladeDaten( int spielId, int karteId )
  54. {
  55. if( dllHandle )
  56. reset();
  57. KartenLeser *reader = KartenLeser::getInstance();
  58. reader->lock();
  59. reader->setKarteId( karteId );
  60. Text *pfad = reader->getSpielPfad();
  61. if( !pfad )
  62. {
  63. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( reader->getLetzterFehler() ), new Text( "Ok" ) );
  64. reader->unlock();
  65. reader->release();
  66. return 0;
  67. }
  68. pfad->append( "bin/" );
  69. Text *spielArtName = reader->getSpielName();
  70. if( !spielArtName )
  71. {
  72. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( reader->getLetzterFehler() ), new Text( "Ok" ) );
  73. reader->unlock();
  74. reader->release();
  75. pfad->release();
  76. return 0;
  77. }
  78. pfad->append( spielArtName->getText() );
  79. pfad->append( ".dll" );
  80. reader->unlock();
  81. reader->release();
  82. dllName->setText( "Spiele/" );
  83. dllName->append( spielArtName->getText() );
  84. dllName->append( ".dll" );
  85. spielArtName->release();
  86. dllHandle = dllDateien->ladeDLL( *dllName, *pfad );
  87. if( !dllHandle )
  88. {
  89. Text *msg = new Text( "Die DLL Datei '" );
  90. msg->append( pfad->getText() );
  91. msg->append( "' konnte nicht geladen werden." );
  92. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), msg, new Text( "Ok" ) );
  93. pfad->release();
  94. return 0;
  95. }
  96. AHSSDLLStart startFunk = (AHSSDLLStart)GetProcAddress( dllHandle, "GetAccountHistorieStatistik" );
  97. if( !startFunk )
  98. {
  99. if( dllHandle )
  100. {
  101. dllDateien->releaseDLL( *dllName );
  102. dllHandle = 0;
  103. }
  104. Text *msg = new Text( "Die Funktion 'GetAccountHistorieStatistik' konnte in der DLL Datei '" );
  105. msg->append( pfad->getText() );
  106. msg->append( "' nicht gefunden werden." );
  107. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), msg, new Text( "Ok" ) );
  108. pfad->release();
  109. return 0;
  110. }
  111. pfad->release();
  112. statistik = startFunk();
  113. if( !statistik )
  114. {
  115. if( dllHandle )
  116. {
  117. dllDateien->releaseDLL( *dllName );
  118. dllHandle = 0;
  119. }
  120. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( "Für diese Spielart ist keine genauere Ansicht der Spiel Ergebnisse verfügbar." ), new Text( "Ok" ) );
  121. return 0;
  122. }
  123. this->spielId = spielId;
  124. statistik->setSchrift( schrift->getThis() );
  125. statistik->setBildschirm( hauptScreen->getThis() );
  126. start();
  127. return 1;
  128. }
  129. void AHSpielStatistik::thread()
  130. {
  131. laden->setSichtbar( 1 );
  132. KSGClient::HistorieServerClient *historieClient = infoClient->createHistorieServerClient( spielId );
  133. if( !historieClient )
  134. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( infoClient->getLetzterFehler() ), new Text( "Ok" ) );
  135. else
  136. {
  137. if( !historieClient->downloadSpielHistorie() )
  138. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( historieClient->getLetzterFehler() ), new Text( "Ok" ) );
  139. else
  140. {
  141. statistik->ladeDaten( spielId );
  142. if( sichtbar )
  143. statistik->setSichtbar( 1 );
  144. laden->setSichtbar( 0 );
  145. historieClient->release();
  146. return;
  147. }
  148. historieClient->release();
  149. }
  150. laden->setSichtbar( 0 );
  151. setSichtbar( 0 );
  152. }
  153. void AHSpielStatistik::setPosition( int x, int y )
  154. {
  155. statistikF->setPosition( x, y );
  156. }
  157. void AHSpielStatistik::setSichtbar( bool sichtbar )
  158. {
  159. if( !statistik )
  160. return;
  161. if( !run )
  162. statistik->setSichtbar( sichtbar );
  163. this->sichtbar = sichtbar;
  164. if( sichtbar && !alpha )
  165. alpha = 1;
  166. }
  167. void AHSpielStatistik::doMausEreignis( MausEreignis &me )
  168. {
  169. if( !statistik || alpha != 255 )
  170. return;
  171. me.mx -= 1 + statistikF->getX();
  172. me.my -= 20 + statistikF->getY();
  173. statistik->doMausEreignis( me );
  174. if( statistik->wurdeGeschlossen() )
  175. setSichtbar( 0 );
  176. me.mx += 1 + statistikF->getX();
  177. me.my += 20 + statistikF->getY();
  178. }
  179. void AHSpielStatistik::doTastaturEreignis( TastaturEreignis &te )
  180. {
  181. if( !statistik || alpha != 255 )
  182. return;
  183. statistik->doTastaturEreignis( te );
  184. }
  185. bool AHSpielStatistik::tick( double tickVal )
  186. {
  187. if( !statistik || !alpha )
  188. return 0;
  189. bool ret = statistik->tick( tickVal );
  190. ret |= laden->tick( tickVal );
  191. this->tickVal += tickVal * 150;
  192. int val = ( int )this->tickVal;
  193. this->tickVal -= val;
  194. if( val )
  195. {
  196. if( sichtbar && alpha != 255 )
  197. {
  198. if( alpha + val > 255 )
  199. alpha = 255;
  200. else
  201. alpha += (unsigned char)val;
  202. ret = 1;
  203. }
  204. if( !sichtbar && alpha )
  205. {
  206. if( alpha - val < 0 )
  207. alpha = 0;
  208. else
  209. alpha -= (unsigned char)val;
  210. if( !alpha && statistik->istNochSichtbar() )
  211. alpha = 1;
  212. ret = 1;
  213. }
  214. }
  215. return ret;
  216. }
  217. void AHSpielStatistik::render( Bild &zRObj )
  218. {
  219. if( !statistik || !alpha )
  220. return;
  221. zRObj.setAlpha( alpha );
  222. statistikF->render( zRObj );
  223. if( !zRObj.setDrawOptions( statistikF->getX() + 1, statistikF->getY() + 21, statistikF->getBreite() - 2, statistikF->getHeight() - 22 ) )
  224. {
  225. zRObj.releaseAlpha();
  226. return;
  227. }
  228. statistik->render( zRObj );
  229. zRObj.releaseDrawOptions();
  230. laden->render( zRObj );
  231. zRObj.releaseAlpha();
  232. }
  233. // constant
  234. bool AHSpielStatistik::istNochSichtbar() const
  235. {
  236. if( alpha )
  237. return 1;
  238. return statistik ? statistik->istNochSichtbar() : 0;
  239. }
  240. // Refernce Counting
  241. AHSpielStatistik *AHSpielStatistik::getThis()
  242. {
  243. ref++;
  244. return this;
  245. }
  246. AHSpielStatistik *AHSpielStatistik::release()
  247. {
  248. ref--;
  249. if( !ref )
  250. delete this;
  251. return 0;
  252. }
  253. // Inahlt der AHSpielVideo Klasse aus AccountHistorie.h
  254. // Konstruktor
  255. AHSpielVideo::AHSpielVideo( Schrift *schrift )
  256. : Thread(),
  257. schrift( schrift )
  258. {
  259. videoF = initFenster( 10, 40, 780, 450, schrift, Fenster::Style::Sichtbar | Fenster::Style::Titel | Fenster::Style::TitelBuffered | Fenster::Style::Rahmen, "Spiel Aufzeichnung" );
  260. laden = (Animation2D*)ladeAnimation->dublizieren();
  261. laden->setSichtbar( 0 );
  262. laden->setPosition( 380, 245 );
  263. dllName = new Text( "" );
  264. dllHandle = 0;
  265. alpha = 0;
  266. sichtbar = 0;
  267. video = 0;
  268. tickVal = 0;
  269. ref = 1;
  270. }
  271. // Destruktor
  272. AHSpielVideo::~AHSpielVideo()
  273. {
  274. videoF->release();
  275. if( dllHandle )
  276. reset();
  277. dllName->release();
  278. schrift->release();
  279. laden->release();
  280. }
  281. // nicht constant
  282. void AHSpielVideo::reset()
  283. {
  284. if( run )
  285. warteAufThread( INFINITE );
  286. if( dllHandle )
  287. {
  288. if( video )
  289. video = video->release();
  290. dllDateien->releaseDLL( *dllName );
  291. dllHandle = 0;
  292. }
  293. }
  294. bool AHSpielVideo::ladeDaten( int spielId, int karteId )
  295. {
  296. if( dllHandle )
  297. reset();
  298. KartenLeser *reader = KartenLeser::getInstance();
  299. reader->lock();
  300. reader->setKarteId( karteId );
  301. Text *pfad = reader->getSpielPfad();
  302. if( !pfad )
  303. {
  304. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( reader->getLetzterFehler() ), new Text( "Ok" ) );
  305. reader->unlock();
  306. reader->release();
  307. return 0;
  308. }
  309. pfad->append( "bin/" );
  310. Text *spielArtName = reader->getSpielName();
  311. if( !spielArtName )
  312. {
  313. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( reader->getLetzterFehler() ), new Text( "Ok" ) );
  314. reader->unlock();
  315. reader->release();
  316. pfad->release();
  317. return 0;
  318. }
  319. pfad->append( spielArtName->getText() );
  320. pfad->append( ".dll" );
  321. reader->unlock();
  322. reader->release();
  323. dllName->setText( "Spiele/" );
  324. dllName->append( spielArtName->getText() );
  325. dllName->append( ".dll" );
  326. spielArtName->release();
  327. dllHandle = dllDateien->ladeDLL( *dllName, *pfad );
  328. if( !dllHandle )
  329. {
  330. Text *msg = new Text( "Die DLL Datei '" );
  331. msg->append( pfad->getText() );
  332. msg->append( "' konnte nicht geladen werden." );
  333. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), msg, new Text( "Ok" ) );
  334. pfad->release();
  335. return 0;
  336. }
  337. AHSADLLStart startFunk = (AHSADLLStart)GetProcAddress( dllHandle, "GetAufzeichnung" );
  338. if( !startFunk )
  339. {
  340. if( dllHandle )
  341. {
  342. dllDateien->releaseDLL( *dllName );
  343. dllHandle = 0;
  344. }
  345. Text *msg = new Text( "Die Funktion 'GetAufzeichnung' konnte in der DLL Datei '" );
  346. msg->append( pfad->getText() );
  347. msg->append( "' nicht gefunden werden." );
  348. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), msg, new Text( "Ok" ) );
  349. pfad->release();
  350. return 0;
  351. }
  352. pfad->release();
  353. video = startFunk();
  354. if( !video )
  355. {
  356. if( dllHandle )
  357. {
  358. dllDateien->releaseDLL( *dllName );
  359. dllHandle = 0;
  360. }
  361. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( "Für diese Spielart ist keine Aufzeichnung verfügbar." ), new Text( "Ok" ) );
  362. return 0;
  363. }
  364. this->spielId = spielId;
  365. video->setSchrift( schrift->getThis() );
  366. video->setBildschirm( hauptScreen->getThis() );
  367. start();
  368. return 1;
  369. }
  370. void AHSpielVideo::thread()
  371. {
  372. laden->setSichtbar( 1 );
  373. KSGClient::HistorieServerClient *historieClient = infoClient->createHistorieServerClient( spielId );
  374. if( !historieClient->downloadSpielHistorie() )
  375. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( historieClient->getLetzterFehler() ), new Text( "Ok" ) );
  376. historieClient->release();
  377. video->ladeSpiel( spielId );
  378. laden->setSichtbar( 0 );
  379. if( sichtbar )
  380. {
  381. nachLogin->setSpielAufzeichnung( video->getThis() );
  382. aktion = 7; // Aufzeichnung betreten
  383. }
  384. run = 0;
  385. }
  386. void AHSpielVideo::setSichtbar( bool sichtbar )
  387. {
  388. if( !video )
  389. return;
  390. if( sichtbar && !run )
  391. {
  392. nachLogin->setSpielAufzeichnung( video->getThis() );
  393. aktion = 7; // Aufzeichnung betreten
  394. }
  395. this->sichtbar = sichtbar;
  396. if( sichtbar && !alpha )
  397. alpha = 1;
  398. }
  399. bool AHSpielVideo::tick( double tickVal )
  400. {
  401. if( !video || !alpha )
  402. return 0;
  403. if( video->hatVerlassen( 0 ) && sichtbar )
  404. setSichtbar( 0 );
  405. bool ret = laden->tick( tickVal );
  406. this->tickVal += tickVal * 150;
  407. int val = ( int )this->tickVal;
  408. this->tickVal -= val;
  409. if( val )
  410. {
  411. if( sichtbar && alpha != 255 )
  412. {
  413. if( alpha + val > 255 )
  414. alpha = 255;
  415. else
  416. alpha += (unsigned char)val;
  417. ret = 1;
  418. }
  419. if( !sichtbar && alpha )
  420. {
  421. if( alpha - val < 0 )
  422. alpha = 0;
  423. else
  424. alpha -= (unsigned char)val;
  425. ret = 1;
  426. }
  427. }
  428. return ret;
  429. }
  430. void AHSpielVideo::render( Bild &zRObj )
  431. {
  432. if( !video || !alpha )
  433. return;
  434. if( !zRObj.setDrawOptions( 0, 0, videoF->getBreite() + 10, videoF->getHeight() + 40 ) )
  435. return;
  436. zRObj.setAlpha( alpha );
  437. videoF->render( zRObj );
  438. laden->render( zRObj );
  439. zRObj.releaseAlpha();
  440. zRObj.releaseDrawOptions();
  441. }
  442. // constant
  443. bool AHSpielVideo::istNochSichtbar() const
  444. {
  445. return alpha != 0;
  446. }
  447. // Refernce Counting
  448. AHSpielVideo *AHSpielVideo::getThis()
  449. {
  450. ref++;
  451. return this;
  452. }
  453. AHSpielVideo *AHSpielVideo::release()
  454. {
  455. ref--;
  456. if( !ref )
  457. delete this;
  458. return 0;
  459. }
  460. // Inhalt der AHSLETeamListeSpieler Klasse aus AccountHistorie.h
  461. // Konstruktor
  462. AHSLETeamListeSpieler::AHSLETeamListeSpieler( Schrift *zSchrift, char *name, int punkte, char *status, int farbe, int br )
  463. : nameTF( initTextFeld( 5, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, name ) ),
  464. punkteTF( initTextFeld( 110, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Punkte: " ) += punkte ) ),
  465. statusTF( initTextFeld( 215, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, status ) ),
  466. ram( new LRahmen() ),
  467. ref( 1 )
  468. {
  469. zSchrift->lock();
  470. zSchrift->setSchriftSize( 12 );
  471. nameTF->setSize( zSchrift->getTextBreite( nameTF->zText() ) + 5, 20 );
  472. punkteTF->setSize( zSchrift->getTextBreite( punkteTF->zText() ) + 5, 20 );
  473. statusTF->setSize( zSchrift->getTextBreite( statusTF->zText() ) + 5, 20 );
  474. zSchrift->unlock();
  475. if( nameTF->getBreite() > 100 )
  476. punkteTF->setPosition( 10 + nameTF->getBreite(), 0 );
  477. if( punkteTF->getX() + punkteTF->getBreite() > 210 )
  478. statusTF->setPosition( punkteTF->getX() + punkteTF->getBreite() + 5, 0 );
  479. ram->setFarbe( farbe );
  480. ram->setSize( br, 20 );
  481. ram->setRamenBreite( 1 );
  482. }
  483. // Destruktor
  484. AHSLETeamListeSpieler::~AHSLETeamListeSpieler()
  485. {
  486. nameTF->release();
  487. punkteTF->release();
  488. statusTF->release();
  489. ram->release();
  490. }
  491. // nicht constant
  492. void AHSLETeamListeSpieler::render( int yOff, Bild &zRObj )
  493. {
  494. if( !zRObj.setDrawOptions( 2, yOff, ram->getBreite(), ram->getHeight() ) )
  495. return;
  496. nameTF->render( zRObj );
  497. punkteTF->render( zRObj );
  498. statusTF->render( zRObj );
  499. ram->render( zRObj );
  500. zRObj.releaseDrawOptions();
  501. }
  502. // cnstant
  503. // Reference Counting
  504. AHSLETeamListeSpieler *AHSLETeamListeSpieler::getThis()
  505. {
  506. ref++;
  507. return this;
  508. }
  509. AHSLETeamListeSpieler *AHSLETeamListeSpieler::release()
  510. {
  511. ref--;
  512. if( !ref )
  513. delete this;
  514. return 0;
  515. }
  516. // Inhalt der AHSLETeamListeTeam Klasse aus AccountHistorie.h
  517. // Konstruktor
  518. AHSLETeamListeTeam::AHSLETeamListeTeam( Schrift *zSchrift, char *name, int sAnz, char *status, int farbe, int br )
  519. : nameTF( initTextFeld( 5, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, name ) ),
  520. sAnzahlTF( initTextFeld( 110, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Spieleranzahl: " ) += sAnz ) ),
  521. statusTF( initTextFeld( 215, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, status ) ),
  522. ram( new LRahmen() ),
  523. members( new RCArray< AHSLETeamListeSpieler >() ),
  524. ref( 1 )
  525. {
  526. zSchrift->lock();
  527. zSchrift->setSchriftSize( 12 );
  528. nameTF->setSize( zSchrift->getTextBreite( nameTF->zText() ) + 5, 20 );
  529. sAnzahlTF->setSize( zSchrift->getTextBreite( sAnzahlTF->zText() ) + 5, 20 );
  530. statusTF->setSize( zSchrift->getTextBreite( statusTF->zText() ) + 5, 20 );
  531. zSchrift->unlock();
  532. if( nameTF->getBreite() > 100 )
  533. sAnzahlTF->setPosition( 10 + nameTF->getBreite(), 0 );
  534. if( sAnzahlTF->getX() + sAnzahlTF->getBreite() > 210 )
  535. statusTF->setPosition( sAnzahlTF->getX() + sAnzahlTF->getBreite() + 5, 0 );
  536. ram->setFarbe( farbe );
  537. ram->setSize( br, 20 );
  538. ram->setRamenBreite( 1 );
  539. }
  540. // Destruktor
  541. AHSLETeamListeTeam::~AHSLETeamListeTeam()
  542. {
  543. nameTF->release();
  544. sAnzahlTF->release();
  545. statusTF->release();
  546. ram->release();
  547. members->release();
  548. }
  549. // nicht constant
  550. void AHSLETeamListeTeam::addSpieler( AHSLETeamListeSpieler *s )
  551. {
  552. members->add( s );
  553. int maxHö = 20;
  554. int anz = members->getEintragAnzahl();
  555. if( anz )
  556. maxHö += 4 + 20 * anz;
  557. ram->setSize( ram->getBreite(), maxHö );
  558. }
  559. void AHSLETeamListeTeam::render( int xOff, int yOff, Bild &zRObj )
  560. {
  561. if( !zRObj.setDrawOptions( xOff, yOff, ram->getBreite(), ram->getHeight() ) )
  562. return;
  563. nameTF->render( zRObj );
  564. sAnzahlTF->render( zRObj );
  565. statusTF->render( zRObj );
  566. ram->render( zRObj );
  567. yOff = 22;
  568. int anz = members->getEintragAnzahl();
  569. for( int i = 0; i < anz; i++ )
  570. {
  571. members->z( i )->render( yOff, zRObj );
  572. yOff += 20;
  573. }
  574. zRObj.releaseDrawOptions();
  575. }
  576. // constant
  577. int AHSLETeamListeTeam::getHeight() const
  578. {
  579. return ram->getHeight();
  580. }
  581. // Reference Counting
  582. AHSLETeamListeTeam *AHSLETeamListeTeam::getThis()
  583. {
  584. ref++;
  585. return this;
  586. }
  587. AHSLETeamListeTeam *AHSLETeamListeTeam::release()
  588. {
  589. ref--;
  590. if( !ref )
  591. delete this;
  592. return 0;
  593. }
  594. // Inhalt der AHSLETeamListe Klasse aus AccountHistorie.h
  595. // Konstruktor
  596. AHSLETeamListe::AHSLETeamListe( int xPos )
  597. : members( new RCArray< AHSLETeamListeTeam >() ),
  598. xPos( xPos ),
  599. ref( 1 )
  600. {
  601. }
  602. // Destruktor
  603. AHSLETeamListe::~AHSLETeamListe()
  604. {
  605. members->release();
  606. }
  607. // nicht constant
  608. void AHSLETeamListe::addTeam( AHSLETeamListeTeam *t )
  609. {
  610. members->add( t );
  611. }
  612. void AHSLETeamListe::render( Bild &zRObj )
  613. {
  614. int y = 25;
  615. int anz = members->getEintragAnzahl();
  616. for( int i = 0; i < anz; i++ )
  617. {
  618. members->z( i )->render( xPos, y, zRObj );
  619. y += members->z( i )->getHeight();
  620. }
  621. }
  622. // constant
  623. int AHSLETeamListe::getHeight() const
  624. {
  625. int anz = members->getEintragAnzahl();
  626. int hö = 0;
  627. for( int i = 0; i < anz; i++ )
  628. hö += members->z( i )->getHeight();
  629. return hö;
  630. }
  631. int AHSLETeamListe::getBreite() const
  632. {
  633. return 730 - xPos;
  634. }
  635. // Reference Counting
  636. AHSLETeamListe *AHSLETeamListe::getThis()
  637. {
  638. ref++;
  639. return this;
  640. }
  641. AHSLETeamListe *AHSLETeamListe::release()
  642. {
  643. ref--;
  644. if( !ref )
  645. delete this;
  646. return 0;
  647. }
  648. // Inhalt der AHSpielListeEintrag Klasse aus AccountHistorie.h
  649. // Konstruktor
  650. AHSpielListeEintrag::AHSpielListeEintrag( int id, int karteId, Schrift *zSchrift, char *spiel, char *karte, char *datum, char *status,
  651. char *dauer, char *spielStatus, char *gewinner, int sAnzahl )
  652. : spielTF( initTextFeld( 5, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Spiel: " ) += spiel ) ),
  653. karteTF( initTextFeld( 110, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Karte: " ) += karte ) ),
  654. datumTF( initTextFeld( 215, 0, 180, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Datum: " ) += datum ) ),
  655. statusTF( initTextFeld( 400, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Status: " ) += status ) ),
  656. spiel( new Text( spiel ) ),
  657. karte( new Text( karte ) ),
  658. datum( new Text( datum ) ),
  659. status( new Text( status ) ),
  660. detailsK( initKnopf( 715, 0, 20, 20, 0, 0, "" ) ),
  661. dauerTF( initTextFeld( 5, 25, 100, 20, zSchrift, TextFeld::Style::Text, Text( "Dauer: " ) += dauer ) ),
  662. spielStatusTF( initTextFeld( 5, 45, 100, 20, zSchrift, TextFeld::Style::Text, Text( "Status: " ) += spielStatus ) ),
  663. gewinnerTF( initTextFeld( 5, 65, 100, 20, zSchrift, TextFeld::Style::Text, Text( "Gewinner: " ) += gewinner ) ),
  664. sAnzahlTF( initTextFeld( 5, 85, 100, 20, zSchrift, TextFeld::Style::Text, Text( "Spieleranzahl: " ) += sAnzahl ) ),
  665. statistikK( initKnopf( 5, 105, 100, 20, zSchrift, Knopf::Style::Sichtbar, "Statistik" ) ),
  666. videoK( initKnopf( 5, 130, 100, 20, zSchrift, Knopf::Style::Sichtbar, "Aufzeichnung" ) ),
  667. liste( 0 ),
  668. ram( new LRahmen() ),
  669. ausklappen( bilder->get( "account.ltdb/ausklappen.png" ) ),
  670. einklappen( bilder->get( "account.ltdb/einklappen.png" ) ),
  671. id( id ),
  672. karteId( karteId ),
  673. tickVal( 0 ),
  674. aktion( 0 ),
  675. maxHö( 155 ),
  676. ref( 1 )
  677. {
  678. if( !einklappen )
  679. {
  680. LTDBDatei *datei = new LTDBDatei();
  681. datei->setDatei( new Text( "data/client/bilder/account.ltdb" ) );
  682. datei->leseDaten( 0 );
  683. einklappen = datei->laden( 0, new Text( "einklappen.png" ) );
  684. datei->release();
  685. bilder->add( "account.ltdb/einklappen.png", einklappen->getThis() );
  686. }
  687. if( !ausklappen )
  688. {
  689. LTDBDatei *datei = new LTDBDatei();
  690. datei->setDatei( new Text( "data/client/bilder/account.ltdb" ) );
  691. datei->leseDaten( 0 );
  692. ausklappen = datei->laden( 0, new Text( "ausklappen.png" ) );
  693. datei->release();
  694. bilder->add( "account.ltdb/ausklappen.png", ausklappen->getThis() );
  695. }
  696. detailsK->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
  697. detailsK->setHintergrundBildZ( ausklappen->getThis() );
  698. initToolTip( detailsK, "Details anzeigen.", zSchrift->getThis(), hauptScreen );
  699. zSchrift->lock();
  700. zSchrift->setSchriftSize( 12 );
  701. spielTF->setSize( zSchrift->getTextBreite( spielTF->zText() ) + 5, 20 );
  702. karteTF->setSize( zSchrift->getTextBreite( karteTF->zText() ) + 5, 20 );
  703. datumTF->setSize( zSchrift->getTextBreite( datumTF->zText() ) + 5, 20 );
  704. statusTF->setSize( zSchrift->getTextBreite( statusTF->zText() ) + 5, 20 );
  705. dauerTF->setSize( zSchrift->getTextBreite( dauerTF->zText() ), 20 );
  706. spielStatusTF->setSize( zSchrift->getTextBreite( spielStatusTF->zText() ), 20 );
  707. gewinnerTF->setSize( zSchrift->getTextBreite( gewinnerTF->zText() ), 20 );
  708. sAnzahlTF->setSize( zSchrift->getTextBreite( sAnzahlTF->zText() ), 20 );
  709. zSchrift->unlock();
  710. if( spielTF->getBreite() > 100 )
  711. karteTF->setPosition( 10 + spielTF->getBreite(), 0 );
  712. if( karteTF->getX() + karteTF->getBreite() > 210 )
  713. datumTF->setPosition( karteTF->getX() + karteTF->getBreite() + 5, 0 );
  714. if( datumTF->getX() + datumTF->getBreite() > 395 )
  715. statusTF->setPosition( datumTF->getX() + datumTF->getBreite() + 5, 0 );
  716. ram->setFarbe( 0xFFFFFFFF );
  717. ram->setSize( 735, 20 );
  718. ram->setRamenBreite( 1 );
  719. int br = dauerTF->getBreite();
  720. br = br > spielStatusTF->getBreite() ? br : spielStatusTF->getBreite();
  721. br = br > gewinnerTF->getBreite() ? br : gewinnerTF->getBreite();
  722. br = br > sAnzahlTF->getBreite() ? br : sAnzahlTF->getBreite();
  723. statistikK->setSize( br, statistikK->getHeight() );
  724. videoK->setSize( br, videoK->getHeight() );
  725. liste = new AHSLETeamListe( br + 10 );
  726. }
  727. // Destruktor
  728. AHSpielListeEintrag::~AHSpielListeEintrag()
  729. {
  730. spielTF->release();
  731. karteTF->release();
  732. datumTF->release();
  733. statusTF->release();
  734. spiel->release();
  735. karte->release();
  736. datum->release();
  737. status->release();
  738. detailsK->release();
  739. dauerTF->release();
  740. spielStatusTF->release();
  741. gewinnerTF->release();
  742. sAnzahlTF->release();
  743. statistikK->release();
  744. videoK->release();
  745. liste->release();
  746. ram->release();
  747. einklappen->release();
  748. ausklappen->release();
  749. }
  750. // nicht constant
  751. void AHSpielListeEintrag::addTeam( AHSLETeamListeTeam *t )
  752. {
  753. liste->addTeam( t );
  754. maxHö = liste->getHeight();
  755. maxHö = 155 > maxHö + 30 ? 155 : maxHö + 30;
  756. }
  757. bool AHSpielListeEintrag::tick( double tickVal )
  758. {
  759. bool ret = detailsK->tick( tickVal );
  760. ret |= statistikK->tick( tickVal );
  761. ret |= videoK->tick( tickVal );
  762. this->tickVal += tickVal * 150;
  763. int val = ( int )this->tickVal;
  764. this->tickVal -= val;
  765. if( val )
  766. {
  767. if( detailsK->zHintergrundBild() == ausklappen && ram->getHeight() != 20 )
  768. {
  769. if( ram->getHeight() - val < 20 )
  770. ram->setSize( ram->getBreite(), 20 );
  771. else
  772. ram->setSize( ram->getBreite(), ram->getHeight() - val );
  773. ret = 1;
  774. }
  775. if( detailsK->zHintergrundBild() == einklappen )
  776. {
  777. if( ram->getHeight() > maxHö )
  778. {
  779. if( ram->getHeight() - val < maxHö )
  780. ram->setSize( ram->getBreite(), maxHö );
  781. else
  782. ram->setSize( ram->getBreite(), ram->getHeight() - val );
  783. ret = 1;
  784. }
  785. if( ram->getHeight() < maxHö )
  786. {
  787. if( ram->getHeight() + val > maxHö )
  788. ram->setSize( ram->getBreite(), maxHö );
  789. else
  790. ram->setSize( ram->getBreite(), ram->getHeight() + val );
  791. ret = 1;
  792. }
  793. }
  794. }
  795. return ret;
  796. }
  797. void AHSpielListeEintrag::doMausEreignis( MausEreignis &me )
  798. {
  799. bool meVera = 0;
  800. bool meVeraTmp = 0;
  801. if( me.mx < 0 || me.my < 0 || me.mx >= ram->getBreite() || me.my >= ram->getHeight() )
  802. {
  803. meVeraTmp = me.verarbeitet;
  804. me.verarbeitet = 1;
  805. meVera = 1;
  806. }
  807. int vera = me.verarbeitet;
  808. detailsK->doMausEreignis( me );
  809. if( !vera && me.verarbeitet && me.id == ME_RLinks )
  810. {
  811. if( detailsK->zHintergrundBild() == einklappen )
  812. detailsK->setHintergrundBildZ( ausklappen->getThis() );
  813. else
  814. detailsK->setHintergrundBildZ( einklappen->getThis() );
  815. }
  816. vera = me.verarbeitet;
  817. statistikK->doMausEreignis( me );
  818. if( !vera && me.verarbeitet && me.id == ME_RLinks )
  819. aktion = 1;
  820. vera = me.verarbeitet;
  821. videoK->doMausEreignis( me );
  822. if( !vera && me.verarbeitet && me.id == ME_RLinks )
  823. aktion = 2;
  824. if( meVera )
  825. me.verarbeitet = meVeraTmp;
  826. }
  827. void AHSpielListeEintrag::render( int yOff, Bild &zRObj )
  828. {
  829. if( !zRObj.setDrawOptions( 5, yOff, ram->getBreite(), ram->getHeight() ) )
  830. return;
  831. ram->render( zRObj );
  832. if( ram->getHeight() > 20 )
  833. zRObj.drawLinieH( 1, 20, ram->getBreite() - 2, ram->getFarbe() );
  834. if( !zRObj.setDrawOptions( 1, 1, ram->getBreite() - 2, ram->getHeight() - 2 ) )
  835. {
  836. zRObj.releaseDrawOptions();
  837. return;
  838. }
  839. spielTF->render( zRObj );
  840. karteTF->render( zRObj );
  841. datumTF->render( zRObj );
  842. statusTF->render( zRObj );
  843. detailsK->render( zRObj );
  844. dauerTF->render( zRObj );
  845. spielStatusTF->render( zRObj );
  846. gewinnerTF->render( zRObj );
  847. sAnzahlTF->render( zRObj );
  848. statistikK->render( zRObj );
  849. videoK->render( zRObj );
  850. liste->render( zRObj );
  851. zRObj.releaseDrawOptions();
  852. zRObj.releaseDrawOptions();
  853. }
  854. int AHSpielListeEintrag::getAktion()
  855. {
  856. int ret = aktion;
  857. aktion = 0;
  858. return ret;
  859. }
  860. // constant
  861. int AHSpielListeEintrag::getKarteId() const
  862. {
  863. return karteId;
  864. }
  865. int AHSpielListeEintrag::getHeight() const
  866. {
  867. return ram->getHeight();
  868. }
  869. int AHSpielListeEintrag::getId() const
  870. {
  871. return id;
  872. }
  873. int AHSpielListeEintrag::getListeBreite() const
  874. {
  875. return liste->getBreite();
  876. }
  877. Text *AHSpielListeEintrag::zSpiel() const
  878. {
  879. return spiel;
  880. }
  881. Text *AHSpielListeEintrag::zKarte() const
  882. {
  883. return karte;
  884. }
  885. Text *AHSpielListeEintrag::zDatum() const
  886. {
  887. return datum;
  888. }
  889. Text *AHSpielListeEintrag::zStatus() const
  890. {
  891. return status;
  892. }
  893. // Reference Counting
  894. AHSpielListeEintrag *AHSpielListeEintrag::getThis()
  895. {
  896. ref++;
  897. return this;
  898. }
  899. AHSpielListeEintrag *AHSpielListeEintrag::release()
  900. {
  901. ref--;
  902. if( !ref )
  903. delete this;
  904. return 0;
  905. }
  906. // Inhalt der AHSpielListe Klasse aus AccountHistorie.h
  907. // Konstruktor
  908. AHSpielListe::AHSpielListe()
  909. : Zeichnung(),
  910. ram( new LRahmen() ),
  911. scroll( new VScrollBar() ),
  912. members( new RCArray< AHSpielListeEintrag >() ),
  913. sortSpalte( new Text( "Spiel" ) ),
  914. sortAbsteigend( 0 ),
  915. ref( 1 )
  916. {
  917. pos = Punkt( 10, 40 );
  918. ram->setFarbe( 0xFFFFFFFF );
  919. ram->setRamenBreite( 1 );
  920. ram->setSize( 760, 380 );
  921. scroll->update( 0, 380 );
  922. }
  923. // Destruktor
  924. AHSpielListe::~AHSpielListe()
  925. {
  926. ram->release();
  927. scroll->release();
  928. members->release();
  929. sortSpalte->release();
  930. }
  931. // privat
  932. int AHSpielListe::getReihenfolge( int *arr )
  933. {
  934. lockZeichnung();
  935. int anz = members->getEintragAnzahl();
  936. if( !anz )
  937. {
  938. unlockZeichnung();
  939. return 0;
  940. }
  941. int ret = 0;
  942. bool *fertig = new bool[ anz ];
  943. ZeroMemory( fertig, anz );
  944. for( int i = 0; i < anz; i++ )
  945. {
  946. int index = -1;
  947. Text minMaxT;
  948. Zeit minMaxZ;
  949. for( int j = 0; j < anz; j++ )
  950. {
  951. AHSpielListeEintrag *tmp = members->z( j );
  952. if( sortSpalte->istGleich( "Spiel" ) && !fertig[ j ] && ( index < 0 ||
  953. ( sortAbsteigend && *tmp->zSpiel() > minMaxT ) || ( !sortAbsteigend && *tmp->zSpiel() < minMaxT ) ) )
  954. {
  955. minMaxT = tmp->zSpiel()->getText();
  956. index = j;
  957. }
  958. else if( sortSpalte->istGleich( "Karte" ) && !fertig[ j ] && ( index < 0 ||
  959. ( sortAbsteigend && *tmp->zKarte() > minMaxT ) || ( !sortAbsteigend && *tmp->zKarte() < minMaxT ) ) )
  960. {
  961. minMaxT = tmp->zKarte()->getText();
  962. index = j;
  963. }
  964. else if( sortSpalte->istGleich( "Datum" ) && !fertig[ j ] && ( index < 0 ||
  965. ( sortAbsteigend && minMaxZ.istKleiner( "y-m-d h:i", tmp->zDatum()->getText() ) ) ||
  966. ( !sortAbsteigend && minMaxZ.istLater( "y-m-d h:i", tmp->zDatum()->getText() ) ) ) )
  967. {
  968. minMaxZ.setZeit( "y-m-d h:i", tmp->zDatum()->getText() );
  969. index = j;
  970. }
  971. else if( sortSpalte->istGleich( "Status" ) && !fertig[ j ] && ( index < 0 ||
  972. ( sortAbsteigend && *tmp->zStatus() > minMaxT ) || ( !sortAbsteigend && *tmp->zStatus() < minMaxT ) ) )
  973. {
  974. minMaxT = tmp->zStatus()->getText();
  975. index = j;
  976. }
  977. }
  978. if( index < 0 )
  979. break;
  980. fertig[ index ] = 1;
  981. arr[ ret ] = index;
  982. ret++;
  983. }
  984. delete[] fertig;
  985. unlockZeichnung();
  986. return ret;
  987. }
  988. // nicht constant
  989. void AHSpielListe::setSortSpalte( char *sp )
  990. {
  991. lockZeichnung();
  992. sortSpalte->setText( sp );
  993. unlockZeichnung();
  994. }
  995. void AHSpielListe::setSortRichtung( bool absteigend )
  996. {
  997. sortAbsteigend = absteigend;
  998. }
  999. void AHSpielListe::reset()
  1000. {
  1001. lockZeichnung();
  1002. members->leeren();
  1003. unlockZeichnung();
  1004. }
  1005. void AHSpielListe::addSpiel( AHSpielListeEintrag *s )
  1006. {
  1007. lockZeichnung();
  1008. members->add( s );
  1009. unlockZeichnung();
  1010. }
  1011. bool AHSpielListe::tick( double tickVal )
  1012. {
  1013. bool ret = scroll->getRend();
  1014. lockZeichnung();
  1015. int anz = members->getEintragAnzahl();
  1016. for( int i = 0; i < anz; i++ )
  1017. ret |= members->z( i )->tick( tickVal );
  1018. unlockZeichnung();
  1019. return ret;
  1020. }
  1021. void AHSpielListe::doMausEreignis( MausEreignis &me )
  1022. {
  1023. bool vera = 0;
  1024. if( me.mx - pos.x <= 0 || me.mx - pos.x >= ram->getBreite() || me.my - pos.y <= 0 || me.my - pos.y >= ram->getHeight() )
  1025. {
  1026. vera = 1;
  1027. me.verarbeitet = 1;
  1028. }
  1029. int mx = me.mx, my = me.my;
  1030. me.mx -= pos.x;
  1031. me.my -= pos.y;
  1032. scroll->doMausMessage( ram->getBreite() - 16, 1, 15, ram->getHeight() - 2, me );
  1033. me.mx -= 5;
  1034. me.my -= 5 - scroll->getScroll();
  1035. lockZeichnung();
  1036. int anz = members->getEintragAnzahl();
  1037. int *rf = new int[ anz ];
  1038. int rfAnz = getReihenfolge( rf );
  1039. for( int i = 0; i < rfAnz; i++ )
  1040. {
  1041. members->z( rf[ i ] )->doMausEreignis( me );
  1042. me.my -= members->z( rf[ i ] )->getHeight() + 5;
  1043. }
  1044. delete[] rf;
  1045. unlockZeichnung();
  1046. me.mx = mx, me.my = my;
  1047. if( vera )
  1048. me.verarbeitet = 0;
  1049. }
  1050. void AHSpielListe::render( Bild &zRObj )
  1051. {
  1052. if( !zRObj.setDrawOptions( pos, ram->getSize() ) )
  1053. return;
  1054. ram->render( zRObj );
  1055. scroll->render( ram->getBreite() - 16, 1, 15, ram->getHeight() - 2, zRObj );
  1056. if( !zRObj.setDrawOptions( 1, 1, ram->getBreite() - 15, ram->getHeight() - 2 ) )
  1057. {
  1058. zRObj.releaseDrawOptions();
  1059. return;
  1060. }
  1061. int anzHö = 5;
  1062. lockZeichnung();
  1063. int anz = members->getEintragAnzahl();
  1064. int *rf = new int[ anz ];
  1065. int rfAnz = getReihenfolge( rf );
  1066. for( int i = 0; i < rfAnz; i++ )
  1067. {
  1068. members->z( rf[ i ] )->render( anzHö - scroll->getScroll(), zRObj );
  1069. anzHö += members->z( rf[ i ] )->getHeight() + 5;
  1070. }
  1071. delete[] rf;
  1072. unlockZeichnung();
  1073. scroll->update( anzHö, ram->getHeight() - 2 );
  1074. zRObj.releaseDrawOptions();
  1075. zRObj.releaseDrawOptions();
  1076. }
  1077. // constant
  1078. int AHSpielListe::getAktion( int *spielId, int *karteId ) const
  1079. {
  1080. int anz = members->getEintragAnzahl();
  1081. for( int i = 0; i < anz; i++ )
  1082. {
  1083. int ak = members->z( i )->getAktion();
  1084. if( ak )
  1085. {
  1086. *spielId = members->z( i )->getId();
  1087. *karteId = members->z( i )->getKarteId();
  1088. return ak;
  1089. }
  1090. }
  1091. return 0;
  1092. }
  1093. // Reference Counting
  1094. AHSpielListe *AHSpielListe::getThis()
  1095. {
  1096. ref++;
  1097. return this;
  1098. }
  1099. AHSpielListe *AHSpielListe::release()
  1100. {
  1101. ref--;
  1102. if( !ref )
  1103. delete this;
  1104. return 0;
  1105. }
  1106. // Inhalt der AccountHistorie Klasse aus AccountHistorie.h
  1107. // Konstruktor
  1108. AccountHistorie::AccountHistorie( Schrift *zSchrift )
  1109. : Thread(),
  1110. schrift( zSchrift->getThis() ),
  1111. historieF( initFenster( 810, 40, 780, 450, zSchrift, Fenster::Style::Sichtbar | Fenster::Style::Titel | Fenster::Style::TitelBuffered | Fenster::Style::Rahmen | Fenster::Style::Erlaubt, "Historie von " ) ),
  1112. sortSpalte( initAuswahlBox( 10, 10, 150, 20, zSchrift, ABSTYLE, { "Spiel", "Karte", "Datum", "Status" } ) ),
  1113. sortRichtung( initAuswahlBox( 170, 10, 150, 20, zSchrift, ABSTYLE, { "Aufwärts", "Abwärts" } ) ),
  1114. liste( new AHSpielListe() ),
  1115. statistik( new AHSpielStatistik( zSchrift->getThis() ) ),
  1116. video( new AHSpielVideo( zSchrift->getThis() ) ),
  1117. status( 0 ),
  1118. accId( 0 ),
  1119. animation( 0 ),
  1120. alpha( 255 ),
  1121. alpha2( 255 ),
  1122. alpha3( 255 ),
  1123. tickVal( 0 ),
  1124. rend( 0 ),
  1125. ref( 1 )
  1126. {
  1127. initToolTip( sortSpalte, "Wähle aus, nach welcher Spalte die\nTabelle sortiert werden soll.", zSchrift->getThis(), hauptScreen );
  1128. initToolTip( sortRichtung, "Wähle aus, ob Aufwärts oder Abwärts\nsortiert werden soll.", zSchrift->getThis(), hauptScreen );
  1129. historieF->addMember( liste );
  1130. historieF->addMember( sortSpalte );
  1131. historieF->addMember( sortRichtung );
  1132. historieF->setMausEreignis( _ret1ME );
  1133. }
  1134. // Destruktor
  1135. AccountHistorie::~AccountHistorie()
  1136. {
  1137. schrift->release();
  1138. historieF->release();
  1139. sortSpalte->release();
  1140. sortRichtung->release();
  1141. statistik->release();
  1142. liste->release();
  1143. video->release();
  1144. }
  1145. // nicht constant
  1146. void AccountHistorie::reset()
  1147. {
  1148. liste->reset();
  1149. statistik->reset();
  1150. video->reset();
  1151. }
  1152. void AccountHistorie::ladeStatistik( int accId )
  1153. {
  1154. if( this->accId == accId )
  1155. return;
  1156. this->status = 0;
  1157. if( run )
  1158. {
  1159. warteAufThread( 1000 );
  1160. ende();
  1161. }
  1162. if( ( animation | 0x1 ) == animation )
  1163. {
  1164. animation |= 0x4;
  1165. this->accId = accId;
  1166. this->status = 1;
  1167. return;
  1168. }
  1169. if( this->accId )
  1170. reset();
  1171. this->accId = accId;
  1172. start();
  1173. this->status = 1;
  1174. }
  1175. void AccountHistorie::thread()
  1176. {
  1177. Text *name = infoClient->getSpielerName( accId );
  1178. if( name )
  1179. {
  1180. name->insert( 0, "Historie von " );
  1181. historieF->setTitel( *name );
  1182. name->release();
  1183. }
  1184. Array< KSGClient::SpielHistorieDaten > *daten = infoClient->getSpielHistorieDaten( accId );
  1185. int anz = daten->getEintragAnzahl();
  1186. for( int i = 0; i < anz; i++ )
  1187. {
  1188. KSGClient::SpielHistorieDaten spiel = daten->get( i );
  1189. AHSpielListeEintrag *spielE = new AHSpielListeEintrag( spiel.id, spiel.karteId, schrift, spiel.spiel, spiel.karte,
  1190. spiel.datum, spiel.status, spiel.dauer,
  1191. spiel.spielStatus, spiel.gewinner, spiel.sAnzahl );
  1192. int tAnz = spiel.teams.getEintragAnzahl();
  1193. for( int j = 0; j < tAnz; j++ )
  1194. {
  1195. KSGClient::SpielHistorieTeamDaten team = spiel.teams.get( j );
  1196. AHSLETeamListeTeam *teamE = new AHSLETeamListeTeam( schrift, team.name, team.sAnzahl, team.status,
  1197. team.farbe, spielE->getListeBreite() );
  1198. int sAnz = team.spieler.getEintragAnzahl();
  1199. for( int k = 0; k < sAnz; k++ )
  1200. {
  1201. KSGClient::SpielHistorieSpielerDaten spieler = team.spieler.get( k );
  1202. AHSLETeamListeSpieler *spielerE = new AHSLETeamListeSpieler( schrift, spieler.name, spieler.punkte, spieler.status,
  1203. spieler.farbe, spielE->getListeBreite() - 4 );
  1204. teamE->addSpieler( spielerE );
  1205. }
  1206. spielE->addTeam( teamE );
  1207. }
  1208. liste->addSpiel( spielE );
  1209. }
  1210. daten->release();
  1211. animation &= ~0x4;
  1212. status = 2;
  1213. run = 0;
  1214. }
  1215. void AccountHistorie::setSichtbar( bool sichtbar, bool nachRechts )
  1216. {
  1217. if( sichtbar )
  1218. {
  1219. if( ( animation | 0x1 ) != animation || ( ( nachRechts && ( animation | 0x2 ) != animation ) || !nachRechts && ( animation | 0x2 ) == animation ) )
  1220. {
  1221. if( nachRechts )
  1222. historieF->setPosition( -810, 40 );
  1223. else
  1224. historieF->setPosition( 810, 40 );
  1225. }
  1226. animation |= 0x1;
  1227. }
  1228. else
  1229. animation &= ~0x1;
  1230. if( nachRechts )
  1231. animation |= 0x2;
  1232. else
  1233. animation &= ~0x2;
  1234. }
  1235. bool AccountHistorie::tick( double zeit )
  1236. {
  1237. if( !statistik->istNochSichtbar() && !video->istNochSichtbar() )
  1238. rend |= historieF->tick( zeit );
  1239. rend |= statistik->tick( zeit );
  1240. rend |= video->tick( zeit );
  1241. tickVal += zeit;
  1242. int valA = (int)( tickVal * 150 );
  1243. int valB = (int)( tickVal * 500 );
  1244. tickVal -= valA / 150.0;
  1245. if( valA )
  1246. {
  1247. if( ( animation | 0x8 ) == animation && alpha2 )
  1248. {
  1249. if( alpha2 - valA <= 0 )
  1250. {
  1251. alpha2 = 0;
  1252. statistik->setSichtbar( 1 );
  1253. }
  1254. else
  1255. alpha2 -= valA;
  1256. rend = 1;
  1257. }
  1258. if( ( animation | 0x8 ) != animation && alpha2 != 255 )
  1259. {
  1260. if( alpha2 + valA >= 255 )
  1261. alpha2 = 255;
  1262. else
  1263. alpha2 += valA;
  1264. rend = 1;
  1265. }
  1266. if( ( animation | 0x10 ) == animation && alpha3 )
  1267. {
  1268. if( alpha3 - valA <= 0 )
  1269. {
  1270. alpha3 = 0;
  1271. video->setSichtbar( 1 );
  1272. }
  1273. else
  1274. alpha3 -= valA;
  1275. rend = 1;
  1276. }
  1277. if( ( animation | 0x10 ) != animation && alpha3 != 255 )
  1278. {
  1279. if( alpha3 + valA >= 255 )
  1280. alpha3 = 255;
  1281. else
  1282. alpha3 += valA;
  1283. rend = 1;
  1284. }
  1285. if( ( animation | 0x4 ) == animation && alpha )
  1286. {
  1287. if( alpha - valA <= 0 )
  1288. alpha = 0;
  1289. else
  1290. alpha -= valA;
  1291. rend = 1;
  1292. if( !alpha )
  1293. {
  1294. reset();
  1295. start();
  1296. }
  1297. }
  1298. if( ( animation | 0x4 ) != animation && alpha != 255 )
  1299. {
  1300. if( alpha + valA >= 255 )
  1301. alpha = 255;
  1302. else
  1303. alpha += valA;
  1304. rend = 1;
  1305. }
  1306. }
  1307. if( valB )
  1308. {
  1309. if( ( animation | 0x1 ) == animation )
  1310. { // Sichtbar
  1311. if( ( animation | 0x2 ) == animation )
  1312. { // Nach Rechts
  1313. if( historieF->getX() != 10 )
  1314. {
  1315. if( historieF->getX() + valB > 10 )
  1316. historieF->setPosition( 10, historieF->getY() );
  1317. else
  1318. historieF->setPosition( historieF->getX() + valB, historieF->getY() );
  1319. statistik->setPosition( historieF->getX(), historieF->getY() );
  1320. rend = 1;
  1321. }
  1322. }
  1323. else
  1324. { // Nach Links
  1325. if( historieF->getX() != 10 )
  1326. {
  1327. if( historieF->getX() - valB < 10 )
  1328. historieF->setPosition( 10, historieF->getY() );
  1329. else
  1330. historieF->setPosition( historieF->getX() - valB, historieF->getY() );
  1331. statistik->setPosition( historieF->getX(), historieF->getY() );
  1332. rend = 1;
  1333. }
  1334. }
  1335. }
  1336. else
  1337. { // Unsichtbar
  1338. if( ( animation | 0x2 ) == animation )
  1339. { // Nach Rechts
  1340. if( historieF->getX() != 810 )
  1341. {
  1342. if( historieF->getX() + valB > 810 )
  1343. historieF->setPosition( 810, historieF->getY() );
  1344. else
  1345. historieF->setPosition( historieF->getX() + valB, historieF->getY() );
  1346. statistik->setPosition( historieF->getX(), historieF->getY() );
  1347. rend = 1;
  1348. }
  1349. }
  1350. else
  1351. { // Nach Links
  1352. if( historieF->getX() != -810 )
  1353. {
  1354. if( historieF->getX() - valB < -810 )
  1355. historieF->setPosition( -810, historieF->getY() );
  1356. else
  1357. historieF->setPosition( historieF->getX() - valB, historieF->getY() );
  1358. statistik->setPosition( historieF->getX(), historieF->getY() );
  1359. rend = 1;
  1360. }
  1361. }
  1362. }
  1363. }
  1364. if( !alpha2 && !statistik->istNochSichtbar() )
  1365. {
  1366. animation &= ~0x8;
  1367. statistik->reset();
  1368. }
  1369. if( !alpha3 && !video->istNochSichtbar() )
  1370. {
  1371. animation &= ~0x10;
  1372. video->reset();
  1373. }
  1374. bool ret = rend;
  1375. rend = 0;
  1376. return ret;
  1377. }
  1378. void AccountHistorie::doMausEreignis( MausEreignis &me )
  1379. {
  1380. if( !statistik->istNochSichtbar() && !video->istNochSichtbar() && alpha == 255 && alpha2 == 255 && alpha3 == 255 )
  1381. {
  1382. int sortSpalteS = sortSpalte->getAuswahl();
  1383. int sortRichtungS = sortRichtung->getAuswahl();
  1384. historieF->doMausEreignis( me );
  1385. if( sortSpalte->getAuswahl() != sortSpalteS )
  1386. {
  1387. liste->setSortSpalte( sortSpalte->zEintrag( sortSpalte->getAuswahl() )->zText()->getText() );
  1388. sortSpalte->einklappen();
  1389. }
  1390. if( sortRichtung->getAuswahl() != sortRichtungS )
  1391. {
  1392. liste->setSortRichtung( sortRichtung->getAuswahl() != 0 );
  1393. sortRichtung->einklappen();
  1394. }
  1395. int spielId = 0;
  1396. int karteId = 0;
  1397. int ak = liste->getAktion( &spielId, &karteId );
  1398. if( ak == 1 )
  1399. { // Statistik anzeigen
  1400. if( statistik->ladeDaten( spielId, karteId ) )
  1401. animation |= 0x8;
  1402. }
  1403. if( ak == 2 )
  1404. { // Aufzeichnung abspielen
  1405. if( video->ladeDaten( spielId, karteId ) )
  1406. animation |= 0x10;
  1407. }
  1408. }
  1409. if( statistik->istNochSichtbar() )
  1410. statistik->doMausEreignis( me );
  1411. }
  1412. void AccountHistorie::doTastaturEreignis( TastaturEreignis &te )
  1413. {
  1414. if( statistik->istNochSichtbar() )
  1415. statistik->doTastaturEreignis( te );
  1416. }
  1417. void AccountHistorie::render( Bild &zRObj )
  1418. {
  1419. zRObj.setAlpha( alpha );
  1420. if( alpha2 && alpha3 )
  1421. {
  1422. zRObj.setAlpha( alpha2 );
  1423. zRObj.setAlpha( alpha3 );
  1424. historieF->render( zRObj );
  1425. zRObj.releaseAlpha();
  1426. zRObj.releaseAlpha();
  1427. }
  1428. if( statistik->istNochSichtbar() )
  1429. statistik->render( zRObj );
  1430. if( video->istNochSichtbar() )
  1431. video->render( zRObj );
  1432. zRObj.releaseAlpha();
  1433. }
  1434. // constant
  1435. int AccountHistorie::getStatus() const
  1436. {
  1437. return status;
  1438. }
  1439. // Reference Counting
  1440. AccountHistorie *AccountHistorie::getThis()
  1441. {
  1442. ref++;
  1443. return this;
  1444. }
  1445. AccountHistorie *AccountHistorie::release()
  1446. {
  1447. ref--;
  1448. if( !ref )
  1449. delete this;
  1450. return 0;
  1451. }