AccountHistorie.cpp 38 KB

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