AccountHistorie.cpp 35 KB

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