AccountHistorie.cpp 38 KB

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