Gruppe.cpp 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636
  1. #include "Gruppe.h"
  2. #include <Punkt.h>
  3. #include <Rahmen.h>
  4. #include "..\..\..\Global\Variablen.h"
  5. #include "..\..\..\Global\Initialisierung.h"
  6. #include "..\..\..\Leser\KartenLeser.h"
  7. #include <DateiSystem.h>
  8. #include <AlphaFeld.h>
  9. #include <ToolTip.h>
  10. // Inhalt der GruppeEinladungAccount Klasse aus Gruppe.h
  11. // Konstruktor
  12. GruppeEinladungAccount::GruppeEinladungAccount( Schrift *zSchrift )
  13. {
  14. Bild *nachrichtBild = bilder->get( "chat.ltdb/nachricht.png" );
  15. if( !nachrichtBild )
  16. {
  17. LTDBDatei *datei = new LTDBDatei();
  18. datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
  19. datei->leseDaten( 0 );
  20. nachrichtBild = datei->laden( 0, new Text( "nachricht.png" ) );
  21. datei->release();
  22. bilder->add( "chat.ltdb/nachricht.png", nachrichtBild->getThis() );
  23. }
  24. Bild *neuSendenBild = bilder->get( "chat.ltdb/neusenden.png" );
  25. if( !neuSendenBild )
  26. {
  27. LTDBDatei *datei = new LTDBDatei();
  28. datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
  29. datei->leseDaten( 0 );
  30. neuSendenBild = datei->laden( 0, new Text( "neusenden.png" ) );
  31. datei->release();
  32. bilder->add( "chat.ltdb/neusenden.png", neuSendenBild->getThis() );
  33. }
  34. Bild *entfernenBild = bilder->get( "chat.ltdb/entfernen.png" );
  35. if( !entfernenBild )
  36. {
  37. LTDBDatei *datei = new LTDBDatei();
  38. datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
  39. datei->leseDaten( 0 );
  40. entfernenBild = datei->laden( 0, new Text( "entfernen.png" ) );
  41. datei->release();
  42. bilder->add( "chat.ltdb/entfernen.png", entfernenBild->getThis() );
  43. }
  44. rahmen = new LRahmen();
  45. rahmen->setFarbe( 0xFFFFFFFF );
  46. rahmen->setRamenBreite( 1 );
  47. auswahl = new AlphaFeld();
  48. auswahl->setFarbe( 0x0000FF00 );
  49. auswahl->setStrength( -2 );
  50. auswahl->setPosition( 1, 1 );
  51. name = initTextFeld( 0, 5, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, "" );
  52. nachrichtSenden = initKnopf( 0, 30, 20, 20, 0, 0, "" );
  53. nachrichtSenden->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
  54. nachrichtSenden->setHintergrundBildZ( nachrichtBild );
  55. initToolTip( nachrichtSenden, "Nachricht senden.", zSchrift->getThis(), hauptScreen );
  56. erneutSenden = initKnopf( 0, 30, 20, 20, 0, 0, "" );
  57. erneutSenden->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
  58. erneutSenden->setHintergrundBildZ( neuSendenBild );
  59. initToolTip( erneutSenden, "Einladung erneut senden.", zSchrift->getThis(), hauptScreen );
  60. einladungAbbrechen = initKnopf( 0, 30, 20, 20, 0, 0, "" );
  61. einladungAbbrechen->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
  62. einladungAbbrechen->setHintergrundBildZ( entfernenBild );
  63. initToolTip( einladungAbbrechen, "Einladung abbrechen.", zSchrift->getThis(), hauptScreen );
  64. status = 0;
  65. knopfX = 500;
  66. tickVal = 0;
  67. mausIn = 0;
  68. remove = 0;
  69. gruppeId = 0;
  70. accountId = 0;
  71. admin = 0;
  72. höhe = 0;
  73. animation = 0x1;
  74. rend = 0;
  75. ref = 1;
  76. }
  77. // Destruktor
  78. GruppeEinladungAccount::~GruppeEinladungAccount()
  79. {
  80. rahmen->release();
  81. auswahl->release();
  82. name->release();
  83. nachrichtSenden->release();
  84. erneutSenden->release();
  85. einladungAbbrechen->release();
  86. }
  87. // nicht constant
  88. void GruppeEinladungAccount::setGruppeId( int gruppeId )
  89. {
  90. this->gruppeId = gruppeId;
  91. }
  92. void GruppeEinladungAccount::setAccountId( int id )
  93. {
  94. this->accountId = id;
  95. name->setText( infoClient->getSpielerName( id ) );
  96. rend = 1;
  97. }
  98. void GruppeEinladungAccount::setSize( int br )
  99. {
  100. if( this->br != br )
  101. rend = 1;
  102. this->br = br;
  103. if( knopfX == 500 )
  104. {
  105. knopfX = br;
  106. rend = 1;
  107. }
  108. }
  109. void GruppeEinladungAccount::setAbgelehnt()
  110. {
  111. status = 1;
  112. }
  113. void GruppeEinladungAccount::setAngenommen()
  114. {
  115. status = 2;
  116. }
  117. void GruppeEinladungAccount::setRemove()
  118. {
  119. animation &= ~0x1;
  120. }
  121. void GruppeEinladungAccount::setAdmin( int admin )
  122. {
  123. this->admin = admin;
  124. }
  125. bool GruppeEinladungAccount::tick( double tickVal )
  126. {
  127. rend |= name->tick( tickVal );
  128. rend |= nachrichtSenden->tick( tickVal );
  129. rend |= erneutSenden->tick( tickVal );
  130. rend |= einladungAbbrechen->tick( tickVal );
  131. this->tickVal += tickVal * 100;
  132. int val = ( int )this->tickVal;
  133. if( val < 1 )
  134. {
  135. bool ret = rend;
  136. rend = 0;
  137. return ret;
  138. }
  139. if( val > 4 )
  140. val = 4;
  141. this->tickVal -= val;
  142. if( ( animation | 0x1 ) == animation )
  143. {
  144. if( höhe < 30 )
  145. {
  146. höhe += val;
  147. if( höhe > 30 )
  148. höhe = 30;
  149. rend = 1;
  150. }
  151. }
  152. else
  153. {
  154. if( höhe > 0 )
  155. {
  156. höhe -= val;
  157. if( höhe < 0 )
  158. höhe = 0;
  159. rend = 1;
  160. }
  161. }
  162. if( mausIn )
  163. {
  164. if( admin == loginClient->getAccountId() && !status )
  165. {
  166. if( knopfX > br - 60 )
  167. {
  168. knopfX -= val;
  169. if( knopfX < br - 60 )
  170. knopfX = br - 60;
  171. rend = 1;
  172. }
  173. }
  174. else if( admin == loginClient->getAccountId() && status != 2 )
  175. {
  176. if( knopfX > br - 40 )
  177. {
  178. knopfX -= val;
  179. if( knopfX < br - 40 )
  180. knopfX = br - 40;
  181. rend = 1;
  182. }
  183. }
  184. else
  185. {
  186. if( knopfX > br - 20 )
  187. {
  188. knopfX -= val;
  189. if( knopfX < br - 20 )
  190. knopfX = br - 20;
  191. rend = 1;
  192. }
  193. }
  194. }
  195. else
  196. {
  197. if( knopfX < br )
  198. {
  199. knopfX += val;
  200. if( knopfX > br )
  201. knopfX = br;
  202. rend = 1;
  203. }
  204. }
  205. switch( status )
  206. {
  207. case 1:
  208. if( 1 )
  209. {
  210. int r = ( rahmen->getFarbe() >> 16 ) & 0xFF;
  211. int g = ( rahmen->getFarbe() >> 8 ) & 0xFF;
  212. int b = rahmen->getFarbe() & 0xFF;
  213. if( r < 255 )
  214. {
  215. r += val;
  216. if( r > 255 )
  217. r = 255;
  218. rend = 1;
  219. }
  220. if( g > 0 )
  221. {
  222. g -= val;
  223. if( g < 0 )
  224. g = 0;
  225. rend = 1;
  226. }
  227. if( b > 0 )
  228. {
  229. b -= val;
  230. if( b < 0 )
  231. b = 0;
  232. rend = 1;
  233. }
  234. int f = ( ( r << 16 ) & 0xFF0000 ) | ( ( g << 8 ) & 0xFF00 ) | ( b & 0xFF );
  235. rahmen->setFarbe( ( rahmen->getFarbe() & 0xFF000000 ) | f );
  236. auswahl->setFarbe( ( auswahl->getFarbe() & 0xFF000000 ) | f );
  237. }
  238. break;
  239. case 2:
  240. if( 1 )
  241. {
  242. int r = ( rahmen->getFarbe() >> 16 ) & 0xFF;
  243. int g = ( rahmen->getFarbe() >> 8 ) & 0xFF;
  244. int b = rahmen->getFarbe() & 0xFF;
  245. if( r > 0 )
  246. {
  247. r -= val;
  248. if( r < 0 )
  249. r = 0;
  250. rend = 1;
  251. }
  252. if( g < 255 )
  253. {
  254. g += val;
  255. if( g > 255 )
  256. g = 255;
  257. rend = 1;
  258. }
  259. if( b > 0 )
  260. {
  261. b -= val;
  262. if( b < 0 )
  263. b = 0;
  264. rend = 1;
  265. }
  266. int f = ( ( r << 16 ) & 0xFF0000 ) | ( ( g << 8 ) & 0xFF00 ) | ( b & 0xFF );
  267. rahmen->setFarbe( ( rahmen->getFarbe() & 0xFF000000 ) | f );
  268. auswahl->setFarbe( ( auswahl->getFarbe() & 0xFF000000 ) | f );
  269. }
  270. break;
  271. }
  272. bool ret = rend;
  273. rend = 0;
  274. return ret;
  275. }
  276. void GruppeEinladungAccount::doMausEreignis( MausEreignis &me )
  277. {
  278. if( me.mx < 0 || me.my < 0 || me.mx > br || me.my > höhe )
  279. mausIn = 0;
  280. else
  281. mausIn = 1;
  282. bool ak = !me.verarbeitet;
  283. nachrichtSenden->doMausEreignis( me );
  284. int aktion = ( me.verarbeitet && ak ) ? 1 : 0;
  285. erneutSenden->doMausEreignis( me );
  286. aktion = ( me.verarbeitet && ak && !aktion ) ? 2 : aktion;
  287. einladungAbbrechen->doMausEreignis( me );
  288. aktion = ( me.verarbeitet && ak && !status && !aktion ) ? 3 : aktion;
  289. if( me.id != ME_RLinks || !mausIn )
  290. return;
  291. switch( aktion )
  292. {
  293. case 1:
  294. nachLogin->zChatLeiste()->addChat( accountId, 0 );
  295. break;
  296. case 2:
  297. if( !anmeldungClient )
  298. anmeldungClient = mainClient->createAnmeldungServerClient();
  299. if( !anmeldungClient )
  300. {
  301. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
  302. new Text( "Ok" ), 0 );
  303. }
  304. if( !anmeldungClient->verbinde() )
  305. {
  306. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  307. new Text( "Ok" ), 0 );
  308. }
  309. else
  310. {
  311. if( !anmeldungClient->gruppeSpielerEinladen( accountId, gruppeId ) )
  312. {
  313. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  314. new Text( "Ok" ), 0 );
  315. }
  316. anmeldungClient->trenne( 0 );
  317. }
  318. break;
  319. case 3:
  320. if( !anmeldungClient )
  321. anmeldungClient = mainClient->createAnmeldungServerClient();
  322. if( !anmeldungClient )
  323. {
  324. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
  325. new Text( "Ok" ), 0 );
  326. }
  327. if( !anmeldungClient->verbinde() )
  328. {
  329. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  330. new Text( "Ok" ), 0 );
  331. }
  332. else
  333. {
  334. if( !anmeldungClient->gruppeEinladungAbbrechen( accountId, gruppeId ) )
  335. {
  336. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  337. new Text( "Ok" ), 0 );
  338. }
  339. anmeldungClient->trenne( 0 );
  340. }
  341. break;
  342. }
  343. }
  344. void GruppeEinladungAccount::render( int y, Bild &zrObj )
  345. {
  346. if( !zrObj.setDrawOptions( 0, y, br, höhe ) )
  347. return;
  348. rahmen->setSize( br, höhe );
  349. rahmen->render( zrObj );
  350. int rbr = rahmen->getRBreite();
  351. if( !zrObj.setDrawOptions( rbr, rbr, br - rbr * 2, höhe - rbr * 2 ) )
  352. {
  353. zrObj.releaseDrawOptions();
  354. return;
  355. }
  356. auswahl->setSize( br - rbr * 2, höhe - rbr * 2 );
  357. auswahl->render( zrObj );
  358. nachrichtSenden->setPosition( knopfX, 5 );
  359. nachrichtSenden->render( zrObj );
  360. erneutSenden->setPosition( knopfX + 20, 5 );
  361. erneutSenden->render( zrObj );
  362. einladungAbbrechen->setPosition( knopfX + 40, 5 );
  363. einladungAbbrechen->render( zrObj );
  364. name->render( zrObj );
  365. zrObj.releaseDrawOptions();
  366. zrObj.releaseDrawOptions();
  367. }
  368. // constant
  369. bool GruppeEinladungAccount::getRemove() const
  370. {
  371. return remove;
  372. }
  373. int GruppeEinladungAccount::getAccountId() const
  374. {
  375. return accountId;
  376. }
  377. int GruppeEinladungAccount::getHeight() const
  378. {
  379. return höhe;
  380. }
  381. // Reference Counting
  382. GruppeEinladungAccount *GruppeEinladungAccount::getThis()
  383. {
  384. ref++;
  385. return this;
  386. }
  387. GruppeEinladungAccount *GruppeEinladungAccount::release()
  388. {
  389. ref--;
  390. if( !ref )
  391. delete this;
  392. return 0;
  393. }
  394. // Inhalt der GruppeEinladungListe Klasse aus Gruppe.h
  395. // Konstruktor
  396. GruppeEinladungListe::GruppeEinladungListe( Schrift *zSchrift )
  397. {
  398. schrift = zSchrift->getThis();
  399. Bild *maximierenBild = bilder->get( "chat.ltdb/maximieren.png" );
  400. if( !maximierenBild )
  401. {
  402. LTDBDatei *datei = new LTDBDatei();
  403. datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
  404. datei->leseDaten( 0 );
  405. maximierenBild = datei->laden( 0, new Text( "maximieren.png" ) );
  406. datei->release();
  407. bilder->add( "chat.ltdb/maximieren.png", maximierenBild->getThis() );
  408. }
  409. pos = Punkt( 200, 0 );
  410. gr = Punkt( 150, 350 );
  411. rahmen = new LRahmen();
  412. rahmen->setRamenBreite( 1 );
  413. rahmen->setFarbe( 0xFFFFFFFF );
  414. rahmen->setSize( 150, 350 );
  415. einladenName = initTextFeld( 5, 5, 115, 20, zSchrift, TextFeld::Style::TextFeld, "" );
  416. initToolTip( einladenName, "Name des Spielers den du einladen möchtest.", zSchrift->getThis(), hauptScreen );
  417. einladen = initKnopf( 125, 5, 20, 20, 0, 0, "" );
  418. einladen->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
  419. einladen->setHintergrundBildZ( maximierenBild );
  420. initToolTip( einladen, "Diesen Spieler einladen.", zSchrift->getThis(), hauptScreen );
  421. scroll = new VScrollBar();
  422. accounts = new RCArray< GruppeEinladungAccount >();
  423. einladungHöhe = 0;
  424. tickVal = 0;
  425. anzahl = 0;
  426. gruppeId = 0;
  427. admin = 0;
  428. rend = 0;
  429. ref = 1;
  430. }
  431. // Destruktor
  432. GruppeEinladungListe::~GruppeEinladungListe()
  433. {
  434. rahmen->release();
  435. einladenName->release();
  436. einladen->release();
  437. scroll->release();
  438. accounts->release();
  439. schrift->release();
  440. }
  441. // nicht constant
  442. void GruppeEinladungListe::reset()
  443. {
  444. einladenName->setText( "" );
  445. scroll->update( 0, 0 );
  446. einladungHöhe = 0;
  447. tickVal = 0;
  448. accounts->leeren();
  449. anzahl = 0;
  450. gruppeId = 0;
  451. admin = 0;
  452. rend = 1;
  453. }
  454. void GruppeEinladungListe::setGruppeId( int gruppeId )
  455. {
  456. this->gruppeId = gruppeId;
  457. for( int i = 0; i < anzahl; i++ )
  458. accounts->z( i )->setGruppeId( gruppeId );
  459. }
  460. void GruppeEinladungListe::addAccount( int id )
  461. {
  462. for( int i = 0; i < anzahl; i++ )
  463. {
  464. GruppeEinladungAccount *tmp = accounts->z( i );
  465. if( tmp->getAccountId() == id )
  466. tmp->setRemove();
  467. }
  468. GruppeEinladungAccount *tmp = new GruppeEinladungAccount( schrift );
  469. tmp->setGruppeId( gruppeId );
  470. tmp->setAccountId( id );
  471. tmp->setAdmin( admin );
  472. accounts->add( tmp, anzahl );
  473. anzahl++;
  474. rend = 1;
  475. }
  476. void GruppeEinladungListe::setAbgelehnt( int id )
  477. {
  478. for( int i = 0; i < anzahl; i++ )
  479. {
  480. GruppeEinladungAccount *tmp = accounts->z( i );
  481. if( tmp && tmp->getAccountId() == id )
  482. {
  483. tmp->setAbgelehnt();
  484. break;
  485. }
  486. }
  487. }
  488. void GruppeEinladungListe::setAngenommen( int id )
  489. {
  490. for( int i = 0; i < anzahl; i++ )
  491. {
  492. GruppeEinladungAccount *tmp = accounts->z( i );
  493. if( tmp && tmp->getAccountId() == id )
  494. {
  495. tmp->setAngenommen();
  496. break;
  497. }
  498. }
  499. }
  500. void GruppeEinladungListe::remove( int id )
  501. {
  502. for( int i = 0; i < anzahl; i++ )
  503. {
  504. GruppeEinladungAccount *tmp = accounts->z( i );
  505. if( tmp && tmp->getAccountId() == id )
  506. {
  507. tmp->setRemove();
  508. break;
  509. }
  510. }
  511. }
  512. void GruppeEinladungListe::setAdmin( int admin )
  513. {
  514. this->admin = admin;
  515. for( int i = 0; i < anzahl; i++ )
  516. {
  517. GruppeEinladungAccount *tmp = accounts->z( i );
  518. if( tmp )
  519. tmp->setAdmin( admin );
  520. }
  521. }
  522. bool GruppeEinladungListe::tick( double tickVal )
  523. {
  524. rend |= einladenName->tick( tickVal );
  525. rend |= einladen->tick( tickVal );
  526. rend |= scroll->getRend();
  527. this->tickVal += tickVal * 100;
  528. int val = ( int )this->tickVal;
  529. if( val < 1 )
  530. {
  531. bool ret = rend;
  532. rend = 0;
  533. return ret;
  534. }
  535. if( val > 4 )
  536. val = 4;
  537. this->tickVal -= val;
  538. if( admin == loginClient->getAccountId() )
  539. {
  540. if( einladungHöhe < 30 )
  541. {
  542. einladungHöhe += val;
  543. if( einladungHöhe > 30 )
  544. einladungHöhe = 30;
  545. rend = 1;
  546. }
  547. }
  548. else
  549. {
  550. if( einladungHöhe > 0 )
  551. {
  552. einladungHöhe -= val;
  553. if( einladungHöhe < 0 )
  554. einladungHöhe = 0;
  555. rend = 1;
  556. }
  557. }
  558. for( int i = 0; i < anzahl; i++ )
  559. {
  560. GruppeEinladungAccount *tmp = accounts->z( i );
  561. if( tmp )
  562. rend |= tmp->tick( tickVal );
  563. }
  564. for( int i = 0; i < anzahl; i++ )
  565. {
  566. GruppeEinladungAccount *tmp = accounts->z( i );
  567. if( !tmp->getHeight() )
  568. {
  569. accounts->remove( i );
  570. anzahl--;
  571. rend = 1;
  572. }
  573. }
  574. bool ret = rend;
  575. rend = 0;
  576. return ret;
  577. }
  578. void GruppeEinladungListe::doMausEreignis( MausEreignis &me )
  579. {
  580. int tmpX = me.mx;
  581. int tmpY = me.my;
  582. me.mx -= pos.x;
  583. me.my -= pos.y;
  584. if( einladungHöhe == 30 )
  585. {
  586. einladenName->doMausEreignis( me );
  587. bool ak = !me.verarbeitet;
  588. einladen->doMausEreignis( me );
  589. if( me.verarbeitet && ak )
  590. {
  591. if( me.id == ME_RLinks )
  592. {
  593. if( einladenName->zText()->getLength() )
  594. {
  595. int accountId = infoClient->getAccountId( einladenName->zText()->getText() );
  596. if( accountId )
  597. {
  598. if( !anmeldungClient )
  599. anmeldungClient = mainClient->createAnmeldungServerClient();
  600. if( !anmeldungClient )
  601. {
  602. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
  603. new Text( "Ok" ), 0 );
  604. }
  605. if( !anmeldungClient->verbinde() )
  606. {
  607. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  608. new Text( "Ok" ), 0 );
  609. }
  610. else
  611. {
  612. if( !anmeldungClient->gruppeSpielerEinladen( accountId, gruppeId ) )
  613. {
  614. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  615. new Text( "Ok" ), 0 );
  616. }
  617. else
  618. {
  619. einladenName->setText( "" );
  620. einladenName->setAuswahl( 0, 0 );
  621. rend = 1;
  622. }
  623. anmeldungClient->trenne( 0 );
  624. }
  625. }
  626. else
  627. {
  628. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( "Der Account wurde nicht gefunden." ),
  629. new Text( "Ok" ), 0 );
  630. }
  631. }
  632. }
  633. return;
  634. }
  635. }
  636. scroll->doMausMessage( 134, 1 + einladungHöhe, 15, 348 - einladungHöhe, me );
  637. me.my -= einladungHöhe + 1;
  638. for( int i = 0; i < anzahl; i++ )
  639. {
  640. GruppeEinladungAccount *tmp = accounts->z( i );
  641. if( tmp )
  642. {
  643. tmp->doMausEreignis( me );
  644. if( tmp->getRemove() )
  645. {
  646. accounts->remove( i );
  647. anzahl--;
  648. rend = 1;
  649. }
  650. me.my -= tmp->getHeight();
  651. }
  652. }
  653. me.mx = tmpX;
  654. me.my = tmpY;
  655. }
  656. void GruppeEinladungListe::doTastaturEreignis( TastaturEreignis &te )
  657. {
  658. bool b = !te.verarbeitet;
  659. einladenName->doTastaturEreignis( te );
  660. if( te.verarbeitet && b && te.id == TE_Release && te.taste == T_Enter )
  661. {
  662. if( einladenName->zText()->getLength() )
  663. {
  664. int accountId = infoClient->getAccountId( einladenName->zText()->getText() );
  665. if( accountId )
  666. {
  667. if( !anmeldungClient )
  668. anmeldungClient = mainClient->createAnmeldungServerClient();
  669. if( !anmeldungClient )
  670. {
  671. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
  672. new Text( "Ok" ), 0 );
  673. }
  674. if( !anmeldungClient->verbinde() )
  675. {
  676. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  677. new Text( "Ok" ), 0 );
  678. }
  679. else
  680. {
  681. if( !anmeldungClient->gruppeSpielerEinladen( accountId, gruppeId ) )
  682. {
  683. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  684. new Text( "Ok" ), 0 );
  685. }
  686. else
  687. {
  688. einladenName->setText( "" );
  689. einladenName->setAuswahl( 0, 0 );
  690. rend = 1;
  691. }
  692. anmeldungClient->trenne( 0 );
  693. }
  694. }
  695. else
  696. {
  697. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( "Der Account wurde nicht gefunden." ),
  698. new Text( "Ok" ), 0 );
  699. }
  700. }
  701. }
  702. }
  703. void GruppeEinladungListe::render( Bild &zRObj )
  704. {
  705. if( !zRObj.setDrawOptions( pos, gr ) )
  706. return;
  707. rahmen->render( zRObj );
  708. int rbr = rahmen->getRBreite();
  709. if( einladungHöhe )
  710. {
  711. if( zRObj.setDrawOptions( rbr, rbr, gr.x - rbr * 2, einladungHöhe - rbr * 2 ) )
  712. {
  713. einladenName->render( zRObj );
  714. einladen->render( zRObj );
  715. zRObj.releaseDrawOptions();
  716. }
  717. }
  718. if( !zRObj.setDrawOptions( rbr, einladungHöhe + rbr, gr.x - rbr * 2, gr.y - rbr * 2 ) )
  719. {
  720. zRObj.releaseDrawOptions();
  721. return;
  722. }
  723. scroll->render( 134, 0, 15, 348 - einladungHöhe, zRObj );
  724. int höhe = 0;
  725. for( int i = 0; i < anzahl; i++ )
  726. {
  727. GruppeEinladungAccount *tmp = accounts->z( i );
  728. if( tmp )
  729. {
  730. tmp->setSize( gr.x - 15 - rbr * 2 );
  731. tmp->render( höhe - scroll->getScroll(), zRObj );
  732. höhe += tmp->getHeight();
  733. }
  734. }
  735. scroll->update( höhe, gr.y - rbr * 2 - einladungHöhe );
  736. zRObj.releaseDrawOptions();
  737. zRObj.releaseDrawOptions();
  738. }
  739. // constant
  740. // Reference Counting
  741. GruppeEinladungListe *GruppeEinladungListe::getThis()
  742. {
  743. ref++;
  744. return this;
  745. }
  746. GruppeEinladungListe *GruppeEinladungListe::release()
  747. {
  748. ref--;
  749. if( !ref )
  750. delete this;
  751. return 0;
  752. }
  753. // Inhalt der GruppeAccountDaten Klasse aus Gruppe.h
  754. // Konstruktor
  755. GruppeAccountDaten::GruppeAccountDaten( Schrift *zSchrift )
  756. {
  757. Bild *nachrichtBild = bilder->get( "chat.ltdb/nachricht.png" );
  758. if( !nachrichtBild )
  759. {
  760. LTDBDatei *datei = new LTDBDatei();
  761. datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
  762. datei->leseDaten( 0 );
  763. nachrichtBild = datei->laden( 0, new Text( "nachricht.png" ) );
  764. datei->release();
  765. bilder->add( "chat.ltdb/nachricht.png", nachrichtBild->getThis() );
  766. }
  767. Bild *einladungBild = bilder->get( "chat.ltdb/neuerfreund.png" );
  768. if( !nachrichtBild )
  769. {
  770. LTDBDatei *datei = new LTDBDatei();
  771. datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
  772. datei->leseDaten( 0 );
  773. einladungBild = datei->laden( 0, new Text( "neuerfreund.png" ) );
  774. datei->release();
  775. bilder->add( "chat.ltdb/neuerfreund.png", einladungBild->getThis() );
  776. }
  777. Bild *ansehenBild = bilder->get( "chat.ltdb/ansehen.png" );
  778. if( !ansehenBild )
  779. {
  780. LTDBDatei *datei = new LTDBDatei();
  781. datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
  782. datei->leseDaten( 0 );
  783. ansehenBild = datei->laden( 0, new Text( "ansehen.png" ) );
  784. datei->release();
  785. bilder->add( "chat.ltdb/ansehen.png", ansehenBild->getThis() );
  786. }
  787. Bild *entfernenBild = bilder->get( "chat.ltdb/entfernen.png" );
  788. if( !entfernenBild )
  789. {
  790. LTDBDatei *datei = new LTDBDatei();
  791. datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
  792. datei->leseDaten( 0 );
  793. entfernenBild = datei->laden( 0, new Text( "entfernen.png" ) );
  794. datei->release();
  795. bilder->add( "chat.ltdb/entfernen.png", entfernenBild->getThis() );
  796. }
  797. rahmen = new LRahmen();
  798. rahmen->setFarbe( 0xFFFFFFFF );
  799. rahmen->setRamenBreite( 1 );
  800. auswahl = new AlphaFeld();
  801. auswahl->setFarbe( 0x0000FF00 );
  802. auswahl->setStrength( -2 );
  803. auswahl->setPosition( 1, 1 );
  804. name = initTextFeld( 1, 6, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, "" );
  805. punkte = initTextFeld( 101, 6, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, "0p" );
  806. nachrichtSenden = initKnopf( 0, 30, 20, 20, 0, 0, "" );
  807. nachrichtSenden->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
  808. nachrichtSenden->setHintergrundBildZ( nachrichtBild );
  809. initToolTip( nachrichtSenden, "Nachricht senden.", zSchrift->getThis(), hauptScreen );
  810. freundEinladung = initKnopf( 0, 30, 20, 20, 0, 0, "" );
  811. freundEinladung->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
  812. freundEinladung->setHintergrundBildZ( einladungBild );
  813. initToolTip( freundEinladung, "Freundeseinladung senden.", zSchrift->getThis(), hauptScreen );
  814. accountAnsehen = initKnopf( 0, 30, 20, 20, 0, 0, "" );
  815. accountAnsehen->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
  816. accountAnsehen->setHintergrundBildZ( ansehenBild );
  817. initToolTip( accountAnsehen, "Account ansehen.", zSchrift->getThis(), hauptScreen );
  818. kick = initKnopf( 0, 30, 20, 20, 0, 0, "" );
  819. kick->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
  820. kick->setHintergrundBildZ( entfernenBild );
  821. initToolTip( kick, "Diesen Spieler kicken.", zSchrift->getThis(), hauptScreen );
  822. tickVal = 0;
  823. mausIn = 0;
  824. remove = 0;
  825. gruppeId = 0;
  826. accountId = 0;
  827. admin = 0;
  828. höhe = 0;
  829. animation = 0x1;
  830. rend = 0;
  831. ref = 1;
  832. }
  833. // Destruktor
  834. GruppeAccountDaten::~GruppeAccountDaten()
  835. {
  836. rahmen->release();
  837. auswahl->release();
  838. name->release();
  839. punkte->release();
  840. nachrichtSenden->release();
  841. freundEinladung->release();
  842. accountAnsehen->release();
  843. kick->release();
  844. }
  845. // nicht constant
  846. void GruppeAccountDaten::setGruppeId( int gruppeId )
  847. {
  848. this->gruppeId = gruppeId;
  849. }
  850. void GruppeAccountDaten::setAccountId( int id )
  851. {
  852. accountId = id;
  853. name->setText( infoClient->getSpielerName( id ) );
  854. punkte->setText( "" );
  855. punkte->zText()->append( infoClient->getSpielerPunkte( id, infoClient->getSpielId( infoClient->getGruppenKarteId( gruppeId ) ) ) );
  856. punkte->zText()->append( "p" );
  857. rend = 1;
  858. }
  859. void GruppeAccountDaten::setSize( int x )
  860. {
  861. if( br != x )
  862. {
  863. br = x;
  864. rend = 1;
  865. }
  866. }
  867. void GruppeAccountDaten::entfernen()
  868. {
  869. animation &= ~0x1;
  870. }
  871. void GruppeAccountDaten::setAdmin( int admin )
  872. {
  873. this->admin = admin;
  874. rend = 1;
  875. }
  876. bool GruppeAccountDaten::tick( double tickVal )
  877. {
  878. rend |= name->tick( tickVal );
  879. rend |= punkte->tick( tickVal );
  880. rend |= nachrichtSenden->tick( tickVal );
  881. rend |= accountAnsehen->tick( tickVal );
  882. rend |= freundEinladung->tick( tickVal );
  883. rend |= kick->tick( tickVal );
  884. this->tickVal += tickVal * 100;
  885. int val = ( int )this->tickVal;
  886. if( val < 1 )
  887. {
  888. bool ret = rend;
  889. rend = 0;
  890. return ret;
  891. }
  892. if( val > 4 )
  893. val = 4;
  894. this->tickVal -= val;
  895. if( admin == accountId )
  896. {
  897. int r = ( auswahl->getFarbe() >> 16 ) & 0xFF;
  898. if( r < 200 )
  899. {
  900. r += val;
  901. if( r > 200 )
  902. r = 200;
  903. auswahl->setFarbe( ( auswahl->getFarbe() & 0xFF00FFFF ) | ( ( r << 16 ) & 0xFF0000 ) );
  904. rend = 1;
  905. }
  906. }
  907. else
  908. {
  909. int r = ( auswahl->getFarbe() >> 16 ) & 0xFF;
  910. if( r > 0 )
  911. {
  912. if( r - val < 0 )
  913. r = 0;
  914. else
  915. r -= val;
  916. auswahl->setFarbe( ( auswahl->getFarbe() & 0xFF00FFFF ) | ( ( r << 16 ) & 0xFF0000 ) );
  917. rend = 1;
  918. }
  919. }
  920. if( ( animation | 0x1 ) == animation )
  921. {
  922. if( höhe < 30 )
  923. {
  924. höhe += val;
  925. if( höhe > 30 )
  926. höhe = 30;
  927. rend = 1;
  928. }
  929. if( mausIn )
  930. {
  931. if( höhe < 50 )
  932. {
  933. höhe += val;
  934. if( höhe > 50 )
  935. höhe = 50;
  936. rend = 1;
  937. }
  938. int a = ( auswahl->getFarbe() >> 24 ) & 0xFF;
  939. if( a < 50 )
  940. {
  941. a += val;
  942. if( a > 50 )
  943. a = 50;
  944. auswahl->setFarbe( ( ( a << 24 ) & 0xFF000000 ) | ( auswahl->getFarbe() & 0xFFFFFF ) );
  945. rend = 1;
  946. }
  947. }
  948. else
  949. {
  950. if( höhe > 30 )
  951. {
  952. höhe -= val;
  953. if( höhe < 30 )
  954. höhe = 30;
  955. rend = 1;
  956. }
  957. int a = ( auswahl->getFarbe() >> 24 ) & 0xFF;
  958. if( a > 0 )
  959. {
  960. if( a - val < 0 )
  961. a = 0;
  962. else
  963. a -= val;
  964. auswahl->setFarbe( ( ( a << 24 ) & 0xFF000000 ) | ( auswahl->getFarbe() & 0xFFFFFF ) );
  965. rend = 1;
  966. }
  967. }
  968. if( accountId != loginClient->getAccountId() )
  969. {
  970. if( nachrichtSenden->getBreite() < 20 )
  971. {
  972. nachrichtSenden->setSize( nachrichtSenden->getBreite() + val, nachrichtSenden->getHeight() );
  973. if( nachrichtSenden->getBreite() > 20 )
  974. nachrichtSenden->setSize( 20, nachrichtSenden->getHeight() );
  975. rend = 1;
  976. }
  977. }
  978. else
  979. {
  980. if( nachrichtSenden->getBreite() > 0 )
  981. {
  982. nachrichtSenden->setSize( nachrichtSenden->getBreite() - val, nachrichtSenden->getHeight() );
  983. if( nachrichtSenden->getBreite() < 0 )
  984. nachrichtSenden->setSize( 0, nachrichtSenden->getHeight() );
  985. rend = 1;
  986. }
  987. }
  988. if( accountAnsehen->getBreite() < 20 )
  989. {
  990. accountAnsehen->setSize( accountAnsehen->getBreite() + val, accountAnsehen->getHeight() );
  991. if( accountAnsehen->getBreite() > 20 )
  992. accountAnsehen->setSize( 20, accountAnsehen->getHeight() );
  993. rend = 1;
  994. }
  995. if( accountId == loginClient->getAccountId() || nachLogin->zFreundesListe()->istFreund( accountId ) )
  996. {
  997. if( freundEinladung->getBreite() > 0 )
  998. {
  999. freundEinladung->setSize( freundEinladung->getBreite() - val, freundEinladung->getHeight() );
  1000. if( freundEinladung->getBreite() < 0 )
  1001. freundEinladung->setSize( 0, freundEinladung->getHeight() );
  1002. rend = 1;
  1003. }
  1004. }
  1005. else
  1006. {
  1007. if( freundEinladung->getBreite() < 20 )
  1008. {
  1009. freundEinladung->setSize( freundEinladung->getBreite() + val, freundEinladung->getHeight() );
  1010. if( freundEinladung->getBreite() > 20 )
  1011. freundEinladung->setSize( 20, freundEinladung->getHeight() );
  1012. rend = 1;
  1013. }
  1014. }
  1015. if( accountId == loginClient->getAccountId() || admin != loginClient->getAccountId() )
  1016. {
  1017. if( kick->getBreite() > 0 )
  1018. {
  1019. kick->setSize( kick->getBreite() - val, kick->getHeight() );
  1020. if( kick->getBreite() < 0 )
  1021. kick->setSize( 0, kick->getHeight() );
  1022. rend = 1;
  1023. }
  1024. }
  1025. else
  1026. {
  1027. if( kick->getBreite() < 20 )
  1028. {
  1029. kick->setSize( kick->getBreite() + val, kick->getHeight() );
  1030. if( kick->getBreite() > 20 )
  1031. kick->setSize( 20, kick->getHeight() );
  1032. rend = 1;
  1033. }
  1034. }
  1035. }
  1036. else
  1037. {
  1038. if( höhe > 0 )
  1039. {
  1040. höhe -= val;
  1041. if( höhe <= 0 )
  1042. {
  1043. höhe = 0;
  1044. remove = 1;
  1045. }
  1046. rend = 1;
  1047. }
  1048. }
  1049. bool ret = rend;
  1050. rend = 0;
  1051. return ret;
  1052. }
  1053. void GruppeAccountDaten::doMausEreignis( MausEreignis &me )
  1054. {
  1055. if( me.mx < 0 || me.my < 0 || me.mx > br || me.my > höhe )
  1056. mausIn = 0;
  1057. else
  1058. mausIn = 1;
  1059. bool ak = !me.verarbeitet;
  1060. nachrichtSenden->doMausEreignis( me );
  1061. int aktion = ( me.verarbeitet && ak ) ? 1 : 0;
  1062. accountAnsehen->doMausEreignis( me );
  1063. aktion = ( me.verarbeitet && ak && !aktion ) ? 2 : aktion;
  1064. freundEinladung->doMausEreignis( me );
  1065. aktion = ( me.verarbeitet && ak && !aktion ) ? 3 : aktion;
  1066. kick->doMausEreignis( me );
  1067. aktion = ( me.verarbeitet && ak && !aktion ) ? 4 : aktion;
  1068. if( me.id != ME_RLinks )
  1069. return;
  1070. switch( aktion )
  1071. {
  1072. case 1:
  1073. nachLogin->zChatLeiste()->addChat( accountId, 0 );
  1074. break;
  1075. case 2:
  1076. if( nachLogin->zAccountAnsehenFenster()->setSpielerDetails( accountId, 2 ) )
  1077. {
  1078. MausEreignis me = { ME_RLinks, 0, 0, 0, 0, 0 };
  1079. nachLogin->zTitelLeiste()->druckAccountAnsehen( me );
  1080. }
  1081. break;
  1082. case 3:
  1083. chatClient->freundesAnfrage( accountId );
  1084. break;
  1085. case 4:
  1086. if( !anmeldungClient )
  1087. anmeldungClient = mainClient->createAnmeldungServerClient();
  1088. if( !anmeldungClient )
  1089. {
  1090. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
  1091. new Text( "Ok" ), 0 );
  1092. }
  1093. if( !anmeldungClient->verbinde() )
  1094. {
  1095. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1096. new Text( "Ok" ), 0 );
  1097. }
  1098. else
  1099. {
  1100. if( !anmeldungClient->kickSpielerAusGruppe( accountId, gruppeId ) )
  1101. {
  1102. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1103. new Text( "Ok" ), 0 );
  1104. }
  1105. anmeldungClient->trenne( 0 );
  1106. }
  1107. break;
  1108. }
  1109. }
  1110. void GruppeAccountDaten::render( int y, Bild &zrObj )
  1111. {
  1112. if( !zrObj.setDrawOptions( 0, y, br, höhe ) )
  1113. return;
  1114. rahmen->setSize( br, höhe );
  1115. rahmen->render( zrObj );
  1116. int rbr = rahmen->getRBreite();
  1117. auswahl->setPosition( rbr, rbr );
  1118. auswahl->setSize( br - rbr * 2, höhe - rbr * 2 );
  1119. auswahl->render( zrObj );
  1120. name->render( zrObj );
  1121. punkte->render( zrObj );
  1122. if( !zrObj.setDrawOptions( rbr, rbr, br - rbr * 2, höhe - rbr * 2 ) )
  1123. {
  1124. zrObj.releaseDrawOptions();
  1125. return;
  1126. }
  1127. int b = kick->getBreite();
  1128. kick->setPosition( br - rbr - b, 30 );
  1129. kick->render( zrObj );
  1130. b += freundEinladung->getBreite();
  1131. freundEinladung->setPosition( br - rbr - b, 30 );
  1132. freundEinladung->render( zrObj );
  1133. b += accountAnsehen->getBreite();
  1134. accountAnsehen->setPosition( br - rbr - b, 30 );
  1135. accountAnsehen->render( zrObj );
  1136. b += nachrichtSenden->getBreite();
  1137. nachrichtSenden->setPosition( br - rbr - b, 30 );
  1138. nachrichtSenden->render( zrObj );
  1139. zrObj.releaseDrawOptions();
  1140. zrObj.releaseDrawOptions();
  1141. }
  1142. // constant
  1143. bool GruppeAccountDaten::getRemove() const
  1144. {
  1145. return remove;
  1146. }
  1147. int GruppeAccountDaten::getAccountId() const
  1148. {
  1149. return accountId;
  1150. }
  1151. int GruppeAccountDaten::getHeight() const
  1152. {
  1153. return höhe;
  1154. }
  1155. // Reference Counting
  1156. GruppeAccountDaten *GruppeAccountDaten::getThis()
  1157. {
  1158. ref++;
  1159. return this;
  1160. }
  1161. GruppeAccountDaten *GruppeAccountDaten::release()
  1162. {
  1163. ref--;
  1164. if( !ref )
  1165. delete this;
  1166. return 0;
  1167. }
  1168. // Inhalt der GruppeAccountListe Klasse aus Gruppe.h
  1169. // Konstruktor
  1170. GruppeAccountListe::GruppeAccountListe( Schrift *zSchrift )
  1171. {
  1172. schrift = zSchrift->getThis();
  1173. pos = Punkt( 0, 0 );
  1174. gr = Punkt( 200, 350 );
  1175. rahmen = new LRahmen();
  1176. rahmen->setFarbe( 0xFFFFFFFF );
  1177. rahmen->setRamenBreite( 1 );
  1178. rahmen->setSize( 200, 350 );
  1179. scroll = new VScrollBar();
  1180. accounts = new RCArray< GruppeAccountDaten >();
  1181. anzahl = 0;
  1182. gruppeId = 0;
  1183. admin = 0;
  1184. rend = 0;
  1185. ref = 1;
  1186. }
  1187. // Destruktor
  1188. GruppeAccountListe::~GruppeAccountListe()
  1189. {
  1190. schrift->release();
  1191. rahmen->release();
  1192. scroll->release();
  1193. accounts->release();
  1194. }
  1195. // nicht constant
  1196. void GruppeAccountListe::reset()
  1197. {
  1198. accounts->leeren();
  1199. anzahl = 0;
  1200. gruppeId = 0;
  1201. admin = 0;
  1202. rend = 1;
  1203. }
  1204. void GruppeAccountListe::setGruppeId( int gruppeId )
  1205. {
  1206. this->gruppeId = gruppeId;
  1207. for( int i = 0; i < anzahl; i++ )
  1208. accounts->z( i )->setGruppeId( gruppeId );
  1209. }
  1210. void GruppeAccountListe::addAccount( int id )
  1211. {
  1212. GruppeAccountDaten *tmp = new GruppeAccountDaten( schrift );
  1213. tmp->setGruppeId( gruppeId );
  1214. tmp->setAccountId( id );
  1215. tmp->setAdmin( admin );
  1216. accounts->add( tmp, anzahl );
  1217. anzahl++;
  1218. rend = 1;
  1219. }
  1220. void GruppeAccountListe::removeAccount( int id )
  1221. {
  1222. for( int i = 0; i < anzahl; i++ )
  1223. {
  1224. GruppeAccountDaten *tmp = accounts->z( i );
  1225. if( tmp && tmp->getAccountId() == id )
  1226. {
  1227. tmp->entfernen();
  1228. break;
  1229. }
  1230. }
  1231. }
  1232. void GruppeAccountListe::setAdmin( int admin )
  1233. {
  1234. this->admin = admin;
  1235. for( int i = 0; i < anzahl; i++ )
  1236. {
  1237. GruppeAccountDaten *tmp = accounts->z( i );
  1238. if( tmp )
  1239. tmp->setAdmin( admin );
  1240. }
  1241. }
  1242. bool GruppeAccountListe::tick( double tickVal )
  1243. {
  1244. rend |= scroll->getRend();
  1245. for( int i = 0; i < anzahl; i++ )
  1246. {
  1247. GruppeAccountDaten *tmp = accounts->z( i );
  1248. if( tmp )
  1249. rend |= tmp->tick( tickVal );
  1250. }
  1251. bool ret = rend;
  1252. rend = 0;
  1253. return ret;
  1254. }
  1255. void GruppeAccountListe::doMausEreignis( MausEreignis &me )
  1256. {
  1257. int tmpX = me.mx;
  1258. int tmpY = me.my;
  1259. me.mx -= pos.x;
  1260. me.my -= pos.y;
  1261. scroll->doMausMessage( 184, 1, 15, 248, me );
  1262. for( int i = 0; i < anzahl; i++ )
  1263. {
  1264. GruppeAccountDaten *tmp = accounts->z( i );
  1265. if( tmp )
  1266. {
  1267. tmp->doMausEreignis( me );
  1268. me.my -= tmp->getHeight();
  1269. if( tmp->getRemove() )
  1270. {
  1271. accounts->remove( i );
  1272. anzahl--;
  1273. i--;
  1274. rend = 1;
  1275. }
  1276. }
  1277. }
  1278. me.mx = tmpX;
  1279. me.my = tmpY;
  1280. }
  1281. void GruppeAccountListe::render( Bild &zRObj )
  1282. {
  1283. if( !zRObj.setDrawOptions( pos, gr ) )
  1284. return;
  1285. rahmen->render( zRObj );
  1286. int rbr = rahmen->getRBreite();
  1287. scroll->render( gr.x - 15 - rbr, 1, 15, gr.y - rbr * 2, zRObj );
  1288. if( !zRObj.setDrawOptions( rbr, rbr, gr.x - rbr * 2, gr.y - rbr * 2 ) )
  1289. {
  1290. zRObj.releaseDrawOptions();
  1291. return;
  1292. }
  1293. int höhe = 0;
  1294. for( int i = 0; i < anzahl; i++ )
  1295. {
  1296. GruppeAccountDaten *tmp = accounts->z( i );
  1297. if( tmp )
  1298. {
  1299. tmp->setSize( gr.x - 15 - rbr * 2 );
  1300. tmp->render( höhe - scroll->getScroll(), zRObj );
  1301. höhe += tmp->getHeight();
  1302. }
  1303. }
  1304. zRObj.releaseDrawOptions();
  1305. zRObj.releaseDrawOptions();
  1306. scroll->update( höhe, gr.y - rbr * 2 );
  1307. }
  1308. // constant
  1309. // Reference Counting
  1310. GruppeAccountListe *GruppeAccountListe::getThis()
  1311. {
  1312. ref++;
  1313. return this;
  1314. }
  1315. GruppeAccountListe *GruppeAccountListe::release()
  1316. {
  1317. ref--;
  1318. if( !ref )
  1319. delete this;
  1320. return 0;
  1321. }
  1322. // Inhalt der GruppeChat Klasse aus Gruppe.h
  1323. // Konstruktor
  1324. GruppeChat::GruppeChat( Schrift *zSchrift )
  1325. {
  1326. Bild *sendenBild = bilder->get( "chat.ltdb/senden.png" );
  1327. if( !sendenBild )
  1328. {
  1329. LTDBDatei *datei = new LTDBDatei();
  1330. datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
  1331. datei->leseDaten( 0 );
  1332. sendenBild = datei->laden( 0, new Text( "senden.png" ) );
  1333. datei->release();
  1334. bilder->add( "chat.ltdb/senden.png", sendenBild->getThis() );
  1335. }
  1336. pos = Punkt( 0, 350 );
  1337. gr = Punkt( 750, 200 );
  1338. rahmen = new LRahmen();
  1339. rahmen->setFarbe( 0xFFFFFFFF );
  1340. rahmen->setRamenBreite( 1 );
  1341. rahmen->setSize( 750, 200 );
  1342. nachricht = initTextFeld( 2, 176, 724, 20, zSchrift, TextFeld::Style::TextFeld, "" );
  1343. initToolTip( nachricht, "Nachricht an die Gruppe senden.", zSchrift->getThis(), hauptScreen );
  1344. senden = initKnopf( 726, 176, 20, 20, 0, 0, "" );
  1345. senden->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
  1346. senden->setHintergrundBildZ( sendenBild );
  1347. initToolTip( senden, "Diese Nachricht an die Gruppe senden.", zSchrift->getThis(), hauptScreen );
  1348. verlauf = initTextFeld( 2, 2, 746, 174, zSchrift, TextFeld::Style::TextGebiet, "" );
  1349. verlauf->removeStyle( TextFeld::Style::Erlaubt );
  1350. verlauf->updateVScroll();
  1351. verlauf->setVertikalKlickScroll( 5 );
  1352. gruppeId = 0;
  1353. rend = 0;
  1354. ref = 1;
  1355. }
  1356. // Destruktor
  1357. GruppeChat::~GruppeChat()
  1358. {
  1359. rahmen->release();
  1360. nachricht->release();
  1361. senden->release();
  1362. verlauf->release();
  1363. }
  1364. // nicht constant
  1365. void GruppeChat::reset()
  1366. {
  1367. gruppeId = 0;
  1368. verlauf->setText( "" );
  1369. verlauf->updateVScroll();
  1370. nachricht->setText( "" );
  1371. rend = 1;
  1372. }
  1373. void GruppeChat::setGruppeId( int gruppeId )
  1374. {
  1375. this->gruppeId = gruppeId;
  1376. }
  1377. void GruppeChat::gruppeNachricht( const char *nachricht )
  1378. {
  1379. verlauf->addZeile( nachricht );
  1380. verlauf->updateVScroll();
  1381. rend = 1;
  1382. }
  1383. bool GruppeChat::tick( double tickVal )
  1384. {
  1385. rend |= verlauf->tick( tickVal );
  1386. rend |= nachricht->tick( tickVal );
  1387. rend |= senden->tick( tickVal );
  1388. bool ret = rend;
  1389. rend = 0;
  1390. return ret;
  1391. }
  1392. void GruppeChat::doMausEreignis( MausEreignis &me )
  1393. {
  1394. me.mx -= pos.x;
  1395. me.my -= pos.y;
  1396. verlauf->doMausEreignis( me );
  1397. nachricht->doMausEreignis( me );
  1398. bool ak = !me.verarbeitet;
  1399. senden->doMausEreignis( me );
  1400. int aktion = ( me.verarbeitet && ak ) ? 1 : 0;
  1401. if( me.id != ME_RLinks )
  1402. {
  1403. me.mx += pos.x;
  1404. me.my += pos.y;
  1405. return;
  1406. }
  1407. if( aktion )
  1408. {
  1409. if( !anmeldungClient )
  1410. anmeldungClient = mainClient->createAnmeldungServerClient();
  1411. if( !anmeldungClient )
  1412. {
  1413. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
  1414. new Text( "Ok" ), 0 );
  1415. }
  1416. if( !anmeldungClient->verbinde() )
  1417. {
  1418. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1419. new Text( "Ok" ), 0 );
  1420. }
  1421. else
  1422. {
  1423. if( anmeldungClient->gruppeNachricht( gruppeId, nachricht->zText()->getText() ) )
  1424. {
  1425. nachricht->setText( "" );
  1426. nachricht->setAuswahl( 0, 0 );
  1427. rend = 1;
  1428. }
  1429. else
  1430. {
  1431. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1432. new Text( "Ok" ), 0 );
  1433. }
  1434. anmeldungClient->trenne( 0 );
  1435. }
  1436. }
  1437. me.mx += pos.x;
  1438. me.my += pos.y;
  1439. }
  1440. void GruppeChat::doTastaturEreignis( TastaturEreignis &te )
  1441. {
  1442. bool b = te.verarbeitet;
  1443. nachricht->doTastaturEreignis( te );
  1444. if( te.verarbeitet && !b && te.id == TE_Release && te.taste == T_Enter )
  1445. {
  1446. if( !anmeldungClient )
  1447. anmeldungClient = mainClient->createAnmeldungServerClient();
  1448. if( !anmeldungClient )
  1449. {
  1450. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
  1451. new Text( "Ok" ), 0 );
  1452. }
  1453. if( !anmeldungClient->verbinde() )
  1454. {
  1455. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1456. new Text( "Ok" ), 0 );
  1457. }
  1458. else
  1459. {
  1460. if( anmeldungClient->gruppeNachricht( gruppeId, nachricht->zText()->getText() ) )
  1461. {
  1462. nachricht->setText( "" );
  1463. nachricht->setAuswahl( 0, 0 );
  1464. rend = 1;
  1465. }
  1466. else
  1467. {
  1468. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1469. new Text( "Ok" ), 0 );
  1470. }
  1471. anmeldungClient->trenne( 0 );
  1472. }
  1473. }
  1474. }
  1475. void GruppeChat::render( Bild &zRObj )
  1476. {
  1477. if( !zRObj.setDrawOptions( pos.x, pos.y, gr.x, gr.y ) )
  1478. return;
  1479. verlauf->render( zRObj );
  1480. nachricht->render( zRObj );
  1481. senden->render( zRObj );
  1482. zRObj.releaseDrawOptions();
  1483. }
  1484. // constant
  1485. // Reference Counting
  1486. GruppeChat *GruppeChat::getThis()
  1487. {
  1488. ref++;
  1489. return this;
  1490. }
  1491. GruppeChat *GruppeChat::release()
  1492. {
  1493. ref--;
  1494. if( !ref )
  1495. delete this;
  1496. return 0;
  1497. }
  1498. // Inhalt der GruppeAnmeldung Klasse aus Gruppe.h
  1499. // Konstruktor
  1500. GruppeAnmeldung::GruppeAnmeldung( Schrift *zSchrift )
  1501. {
  1502. pos = Punkt( 750, 350 );
  1503. gr = Punkt( 200, 200 );
  1504. rahmen = new LRahmen();
  1505. rahmen->setFarbe( 0xFFFFFFFF );
  1506. rahmen->setRamenBreite( 1 );
  1507. rahmen->setSize( 200, 200 );
  1508. spielerHinzufügen = initKontrollKnopf( 25, 45, 150, 20, zSchrift, KontrollKnopf::Style::Normal, "Spieler hinzufügen" );
  1509. spielerHinzufügen->removeStyle( KontrollKnopf::Style::Erlaubt );
  1510. spielerHinzufügen->setMausEreignis( _ret1ME );
  1511. initToolTip( spielerHinzufügen, "Es werden nur Spieler aus dieser Gruppe mit ins Spiel kommen.", zSchrift->getThis(), hauptScreen );
  1512. angemeldet = initKontrollKnopf( 25, 75, 150, 20, zSchrift, KontrollKnopf::Style::Normal, "in Warteschlange" );
  1513. angemeldet->removeStyle( KontrollKnopf::Style::Erlaubt );
  1514. angemeldet->setMausEreignis( _ret1ME );
  1515. initToolTip( angemeldet, "Die Gruppe befindet sich momentan nicht in der Warteschlange.", zSchrift->getThis(), hauptScreen );
  1516. zeit = initTextFeld( 0, 105, 200, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, "Zeit in Warteschlange: " );
  1517. gruppeVerlassen = initKnopf( 40, 135, 120, 20, zSchrift, Knopf::Style::Normal, "Gruppe verlassen" );
  1518. admin = 0;
  1519. time = 0;
  1520. gruppeId = 0;
  1521. rend = 0;
  1522. ref = 1;
  1523. }
  1524. // Destruktor
  1525. GruppeAnmeldung::~GruppeAnmeldung()
  1526. {
  1527. rahmen->release();
  1528. spielerHinzufügen->release();
  1529. angemeldet->release();
  1530. zeit->release();
  1531. gruppeVerlassen->release();
  1532. }
  1533. // nicht constant
  1534. void GruppeAnmeldung::reset()
  1535. {
  1536. spielerHinzufügen->removeStyle( KontrollKnopf::Style::Selected );
  1537. angemeldet->removeStyle( KontrollKnopf::Style::Selected );
  1538. admin = 0;
  1539. time = 0;
  1540. gruppeId = 0;
  1541. rend = 1;
  1542. }
  1543. void GruppeAnmeldung::setGruppeId( int gruppeId )
  1544. {
  1545. this->gruppeId = gruppeId;
  1546. spielerHinzufügen->setStyle( KontrollKnopf::Style::Selected, infoClient->getGruppeSpielerHinzufügen( gruppeId ) );
  1547. rend = 1;
  1548. }
  1549. void GruppeAnmeldung::setAdmin( int admin )
  1550. {
  1551. this->admin = admin;
  1552. if( admin == loginClient->getAccountId() )
  1553. {
  1554. spielerHinzufügen->addStyle( KontrollKnopf::Style::Erlaubt );
  1555. angemeldet->addStyle( KontrollKnopf::Style::Erlaubt );
  1556. }
  1557. else
  1558. {
  1559. spielerHinzufügen->removeStyle( KontrollKnopf::Style::Erlaubt );
  1560. angemeldet->removeStyle( KontrollKnopf::Style::Erlaubt );
  1561. }
  1562. rend = 1;
  1563. }
  1564. void GruppeAnmeldung::setSpielerHinzufügen( bool spielerHinzufügen )
  1565. {
  1566. this->spielerHinzufügen->setStyle( KontrollKnopf::Style::Selected, spielerHinzufügen );
  1567. if( spielerHinzufügen )
  1568. this->spielerHinzufügen->zToolTip()->setText( "Es kommen auch andere Spieler mit ins Spiel,\ndie nicht in dieser Gruppe sind." );
  1569. else
  1570. this->spielerHinzufügen->zToolTip()->setText( "Es werden nur Spieler aus dieser Gruppe mit ins Spiel kommen." );
  1571. rend = 1;
  1572. }
  1573. void GruppeAnmeldung::setAngemeldet( bool angemeldet )
  1574. {
  1575. this->angemeldet->setStyle( KontrollKnopf::Style::Selected, angemeldet );
  1576. if( angemeldet )
  1577. this->angemeldet->zToolTip()->setText( "Die Gruppe befindet sich in der Warteschlange." );
  1578. else
  1579. this->angemeldet->zToolTip()->setText( "Die Gruppe befindet sich momentan nicht in der Warteschlange." );
  1580. time = 0;
  1581. rend = 1;
  1582. }
  1583. void GruppeAnmeldung::zurückInWarteschlange( int stunden, int minuten, int sekunden )
  1584. {
  1585. this->angemeldet->setStyle( KontrollKnopf::Style::Selected, 1 );
  1586. time = sekunden + minuten * 60 + stunden * 60 * 60;
  1587. rend = 1;
  1588. }
  1589. void GruppeAnmeldung::spielGefunden()
  1590. {
  1591. this->angemeldet->setStyle( KontrollKnopf::Style::Selected, 0 );
  1592. time = 0;
  1593. rend = 1;
  1594. }
  1595. bool GruppeAnmeldung::tick( double tickVal )
  1596. {
  1597. if( angemeldet->hatStyle( KontrollKnopf::Style::Selected ) )
  1598. {
  1599. if( (int)( time / 1 ) != (int)( ( time + tickVal ) / 1 ) )
  1600. rend = 1;
  1601. time += tickVal;
  1602. }
  1603. if( rend )
  1604. {
  1605. zeit->setText( "Zeit in Warteschlange: " );
  1606. zeit->zText()->append( (int)( time / 60 / 60 ) );
  1607. zeit->zText()->append( ":" );
  1608. zeit->zText()->append( (int)( time / 60 ) % 60 );
  1609. zeit->zText()->append( ":" );
  1610. zeit->zText()->append( (int)( time ) % 60 );
  1611. }
  1612. rend |= spielerHinzufügen->tick( tickVal );
  1613. rend |= angemeldet->tick( tickVal );
  1614. rend |= gruppeVerlassen->tick( tickVal );
  1615. bool ret = rend;
  1616. rend = 0;
  1617. return ret;
  1618. }
  1619. void GruppeAnmeldung::doMausEreignis( MausEreignis &me )
  1620. {
  1621. me.mx -= pos.x;
  1622. me.my -= pos.y;
  1623. bool ak = !me.verarbeitet;
  1624. int aktion = 0;
  1625. if( admin == loginClient->getAccountId() )
  1626. {
  1627. spielerHinzufügen->doMausEreignis( me );
  1628. aktion = ( me.verarbeitet && admin == loginClient->getAccountId() && ak ) ? 1 : aktion;
  1629. angemeldet->doMausEreignis( me );
  1630. aktion = ( me.verarbeitet && admin == loginClient->getAccountId() && ak && !aktion ) ? 2 : aktion;
  1631. }
  1632. gruppeVerlassen->doMausEreignis( me );
  1633. aktion = ( me.verarbeitet && ak && !aktion ) ? 3 : aktion;
  1634. if( me.id != ME_RLinks )
  1635. {
  1636. me.mx += pos.x;
  1637. me.my += pos.y;
  1638. return;
  1639. }
  1640. switch( aktion )
  1641. {
  1642. case 1:
  1643. if( !anmeldungClient )
  1644. anmeldungClient = mainClient->createAnmeldungServerClient();
  1645. if( !anmeldungClient )
  1646. {
  1647. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
  1648. new Text( "Ok" ), 0 );
  1649. spielerHinzufügen->setStyle( KontrollKnopf::Style::Selected, spielerHinzufügen->hatStyleNicht( KontrollKnopf::Style::Selected ) );
  1650. rend = 1;
  1651. }
  1652. if( !anmeldungClient->verbinde() )
  1653. {
  1654. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1655. new Text( "Ok" ), 0 );
  1656. spielerHinzufügen->setStyle( KontrollKnopf::Style::Selected, spielerHinzufügen->hatStyleNicht( KontrollKnopf::Style::Selected ) );
  1657. rend = 1;
  1658. }
  1659. else
  1660. {
  1661. if( !anmeldungClient->gruppeSpielStarten( gruppeId, spielerHinzufügen->hatStyleNicht( KontrollKnopf::Style::Selected ) ) )
  1662. {
  1663. spielerHinzufügen->setStyle( KontrollKnopf::Style::Selected, spielerHinzufügen->hatStyleNicht( KontrollKnopf::Style::Selected ) );
  1664. rend = 1;
  1665. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1666. new Text( "Ok" ), 0 );
  1667. }
  1668. anmeldungClient->trenne( 0 );
  1669. }
  1670. break;
  1671. case 2:
  1672. if( !anmeldungClient )
  1673. anmeldungClient = mainClient->createAnmeldungServerClient();
  1674. if( !anmeldungClient )
  1675. {
  1676. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
  1677. new Text( "Ok" ), 0 );
  1678. angemeldet->setStyle( KontrollKnopf::Style::Selected, angemeldet->hatStyleNicht( KontrollKnopf::Style::Selected ) );
  1679. rend = 1;
  1680. }
  1681. if( !anmeldungClient->verbinde() )
  1682. {
  1683. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1684. new Text( "Ok" ), 0 );
  1685. angemeldet->setStyle( KontrollKnopf::Style::Selected, angemeldet->hatStyleNicht( KontrollKnopf::Style::Selected ) );
  1686. rend = 1;
  1687. }
  1688. else
  1689. {
  1690. if( angemeldet->hatStyle( KontrollKnopf::Style::Selected ) )
  1691. {
  1692. if( !anmeldungClient->gruppeAnmelden( gruppeId ) )
  1693. {
  1694. angemeldet->setStyle( KontrollKnopf::Style::Selected, angemeldet->hatStyleNicht( KontrollKnopf::Style::Selected ) );
  1695. rend = 1;
  1696. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1697. new Text( "Ok" ), 0 );
  1698. }
  1699. }
  1700. else
  1701. {
  1702. if( !anmeldungClient->gruppeAbmelden( gruppeId ) )
  1703. {
  1704. angemeldet->setStyle( KontrollKnopf::Style::Selected, angemeldet->hatStyleNicht( KontrollKnopf::Style::Selected ) );
  1705. rend = 1;
  1706. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1707. new Text( "Ok" ), 0 );
  1708. }
  1709. }
  1710. anmeldungClient->trenne( 0 );
  1711. }
  1712. break;
  1713. case 3:
  1714. if( !anmeldungClient )
  1715. anmeldungClient = mainClient->createAnmeldungServerClient();
  1716. if( !anmeldungClient )
  1717. {
  1718. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
  1719. new Text( "Ok" ), 0 );
  1720. rend = 1;
  1721. }
  1722. if( !anmeldungClient->verbinde() )
  1723. {
  1724. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1725. new Text( "Ok" ), 0 );
  1726. rend = 1;
  1727. }
  1728. else
  1729. {
  1730. if( anmeldungClient->gruppeVerlassen( gruppeId ) )
  1731. nachLogin->zSpielenFenster()->gruppeVerlassen();
  1732. else
  1733. {
  1734. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1735. new Text( "Ok" ), 0 );
  1736. }
  1737. anmeldungClient->trenne( 0 );
  1738. }
  1739. break;
  1740. }
  1741. me.mx += pos.x;
  1742. me.my += pos.y;
  1743. }
  1744. void GruppeAnmeldung::render( Bild &zRObj )
  1745. {
  1746. if( !zRObj.setDrawOptions( pos.x, pos.y, gr.x, gr.y ) )
  1747. return;
  1748. rahmen->render( zRObj );
  1749. spielerHinzufügen->render( zRObj );
  1750. angemeldet->render( zRObj );
  1751. zeit->render( zRObj );
  1752. gruppeVerlassen->render( zRObj );
  1753. zRObj.releaseDrawOptions();
  1754. }
  1755. // constant
  1756. // Reference Counting
  1757. GruppeAnmeldung *GruppeAnmeldung::getThis()
  1758. {
  1759. ref++;
  1760. return this;
  1761. }
  1762. GruppeAnmeldung *GruppeAnmeldung::release()
  1763. {
  1764. ref--;
  1765. if( !ref )
  1766. delete this;
  1767. return 0;
  1768. }
  1769. void GruppeKarteKSGSAktion( void *p, RCArray< KSGSVariable > *parameter, KSGSVariable **retVal )
  1770. {
  1771. if( !p )
  1772. return;
  1773. ( (GruppeKarte*)p )->ksgsAktion( parameter, retVal );
  1774. }
  1775. // Inhalt der GruppeKarte Klasse aus Gruppe.h
  1776. // Konstruktor
  1777. GruppeKarte::GruppeKarte( Schrift *zSchrift )
  1778. {
  1779. schrift = zSchrift;
  1780. pos = Punkt( 350, 0 );
  1781. gr = Punkt( 600, 350 );
  1782. rahmen = new LRahmen();
  1783. rahmen->setFarbe( 0xFFFFFFFF );
  1784. rahmen->setRamenBreite( 1 );
  1785. rahmen->setSize( 350, 350 );
  1786. rahmen->setPosition( 248, 0 );
  1787. info = 0;
  1788. ksgs = dllDateien->ladeDLL( "KSGScript.dll", "data/bin/KSGScript.dll" );
  1789. if( ksgs )
  1790. {
  1791. KSGSGetZeichnung getKSGScript = (KSGSGetZeichnung)GetProcAddress( ksgs, KSGS_START_FUNKTION );
  1792. if( getKSGScript )
  1793. {
  1794. info = getKSGScript();
  1795. info->setBildschirmZ( hauptScreen->getThis() );
  1796. info->setSchriftZ( schrift->getThis() );
  1797. info->setSize( 248, 350 );
  1798. info->setRückrufParam( this );
  1799. info->setRückrufFunktion( GruppeKarteKSGSAktion );
  1800. }
  1801. else
  1802. {
  1803. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ),
  1804. new Text( "Der Einstiegspunkt '" KSGS_START_FUNKTION "' in der DLL-Datei "
  1805. "'data/bin/KSGScript.dll' konnte nicht gefunden werden." ),
  1806. new Text( "Ok" ), 0 );
  1807. }
  1808. }
  1809. else
  1810. {
  1811. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ),
  1812. new Text( "Die DLL-Datei 'data/bin/KSGScript.dll' konnte nicht geladen werden." ),
  1813. new Text( "Ok" ), 0 );
  1814. }
  1815. hintergrund = 0;
  1816. fehler = 0;
  1817. alpha1 = 0;
  1818. alpha2 = 0;
  1819. ladenZeit = 0;
  1820. tickVal = 0;
  1821. ladeBild = 0;
  1822. karteId = 0;
  1823. gruppeId = 0;
  1824. exit = 0;
  1825. geladen = 0;
  1826. rend = 0;
  1827. ref = 1;
  1828. }
  1829. // Destruktor
  1830. GruppeKarte::~GruppeKarte()
  1831. {
  1832. exit = 1;
  1833. warteAufThread( 5000 );
  1834. if( run )
  1835. ende();
  1836. rahmen->release();
  1837. if( info )
  1838. {
  1839. info->zurücksetzen();
  1840. info->release();
  1841. }
  1842. if( hintergrund )
  1843. hintergrund->release();
  1844. if( fehler )
  1845. fehler->release();
  1846. if( schrift )
  1847. schrift->release();
  1848. if( ksgs )
  1849. dllDateien->releaseDLL( "KSGScript.dll" );
  1850. }
  1851. // nicht constant
  1852. void GruppeKarte::reset()
  1853. {
  1854. if( info )
  1855. info->zurücksetzen();
  1856. if( hintergrund )
  1857. hintergrund = hintergrund->release();
  1858. if( fehler )
  1859. fehler = fehler->release();
  1860. if( run )
  1861. {
  1862. exit = 1;
  1863. warteAufThread( 5000 );
  1864. if( run )
  1865. ende();
  1866. }
  1867. geladen = 0;
  1868. alpha1 = 0;
  1869. alpha2 = 0;
  1870. ladenZeit = 0;
  1871. tickVal = 0;
  1872. ladeBild = 0;
  1873. karteId = 0;
  1874. gruppeId = 0;
  1875. exit = 0;
  1876. rend = 1;
  1877. }
  1878. void GruppeKarte::ksgsAktion( RCArray< KSGSVariable > *parameter, KSGSVariable **retVal )
  1879. {
  1880. }
  1881. void GruppeKarte::setGruppeId( int gruppeId )
  1882. {
  1883. this->gruppeId = gruppeId;
  1884. if( run )
  1885. {
  1886. exit = 1;
  1887. warteAufThread( 5000 );
  1888. if( run )
  1889. ende();
  1890. exit = 0;
  1891. }
  1892. geladen = 0;
  1893. rend = 1;
  1894. start();
  1895. }
  1896. bool GruppeKarte::tick( double tickVal )
  1897. {
  1898. if( !gruppeId )
  1899. return 0;
  1900. if( info )
  1901. rend |= info->tick( tickVal );
  1902. ladenZeit += tickVal;
  1903. if( ladenZeit >= 1 / 30.0 )
  1904. {
  1905. ladenZeit -= 1 / 30.0;
  1906. if( ladeAnimation && ladeAnimation->zAnimationData() )
  1907. {
  1908. if( alpha1 )
  1909. rend = 1;
  1910. ladeBild++;
  1911. if( ladeBild >= ladeAnimation->zAnimationData()->getBildAnzahl() )
  1912. ladeBild = 0;
  1913. }
  1914. }
  1915. this->tickVal += tickVal * 300;
  1916. int val = ( int )this->tickVal;
  1917. if( val < 1 )
  1918. {
  1919. bool ret = rend;
  1920. rend = 0;
  1921. return ret;
  1922. }
  1923. if( val > 10 )
  1924. val = 10;
  1925. this->tickVal -= val;
  1926. if( !geladen && !fehler )
  1927. {
  1928. if( alpha1 != 255 || alpha2 != 0 )
  1929. rend = 1;
  1930. if( alpha1 + val > 255 )
  1931. alpha1 = 255;
  1932. else
  1933. alpha1 += val;
  1934. if( alpha2 - val < 0 )
  1935. alpha2 = 0;
  1936. else
  1937. alpha2 -= val;
  1938. }
  1939. else
  1940. {
  1941. if( alpha1 != 0 || alpha2 != 255 )
  1942. rend = 1;
  1943. if( alpha1 - val < 0 )
  1944. alpha1 = 0;
  1945. else
  1946. alpha1 -= val;
  1947. if( alpha2 + val > 255 )
  1948. alpha2 = 255;
  1949. else
  1950. alpha2 += val;
  1951. }
  1952. bool ret = rend;
  1953. rend = 0;
  1954. return ret;
  1955. }
  1956. void GruppeKarte::doMausEreignis( MausEreignis &me )
  1957. {
  1958. me.mx -= pos.x;
  1959. me.my -= pos.y;
  1960. if( info )
  1961. info->doMausEreignis( me );
  1962. me.mx += pos.x;
  1963. me.my += pos.y;
  1964. }
  1965. void GruppeKarte::render( Bild &zrObj )
  1966. {
  1967. int x = pos.x;
  1968. int y = pos.y;
  1969. if( !zrObj.setDrawOptions( x, y, gr.x, gr.y ) )
  1970. return;
  1971. if( alpha1 != 0 && ladeAnimation && ladeAnimation->zAnimationData() )
  1972. {
  1973. Bild *tmp = ladeAnimation->zAnimationData()->zBild( ladeBild );
  1974. if( tmp )
  1975. {
  1976. zrObj.setAlpha( alpha1 );
  1977. zrObj.drawBild( gr.x / 2 - tmp->getBreite() / 2, gr.y / 2 - tmp->getHeight() / 2, tmp->getBreite(), tmp->getHeight(), *tmp );
  1978. zrObj.releaseAlpha();
  1979. }
  1980. }
  1981. if( alpha2 != 0 )
  1982. {
  1983. zrObj.setAlpha( alpha2 );
  1984. if( geladen )
  1985. {
  1986. if( info )
  1987. info->render( zrObj );
  1988. rahmen->render( zrObj );
  1989. zrObj.drawBild( 248 + rahmen->getRBreite(), rahmen->getRBreite(),
  1990. rahmen->getBreite() - rahmen->getRBreite() * 2, rahmen->getHeight() - rahmen->getRBreite() * 2, *hintergrund );
  1991. }
  1992. else if( fehler )
  1993. fehler->render( zrObj );
  1994. zrObj.releaseAlpha();
  1995. }
  1996. zrObj.releaseDrawOptions();
  1997. }
  1998. void GruppeKarte::thread()
  1999. {
  2000. if( info )
  2001. info->zurücksetzen();
  2002. if( hintergrund )
  2003. hintergrund = hintergrund->release();
  2004. if( fehler )
  2005. fehler = fehler->release();
  2006. karteId = infoClient->getGruppenKarteId( gruppeId );
  2007. if( !karteId )
  2008. {
  2009. run = 0;
  2010. return;
  2011. }
  2012. KartenLeser *karte = KartenLeser::getInstance();
  2013. karte->lock();
  2014. karte->setKarteId( karteId );
  2015. hintergrund = karte->getKartenVorschauBild();
  2016. if( exit )
  2017. {
  2018. if( hintergrund )
  2019. hintergrund = hintergrund->release();
  2020. karte->unlock();
  2021. karte->release();
  2022. run = 0;
  2023. return;
  2024. }
  2025. if( !hintergrund )
  2026. {
  2027. Text *f = new Text( karte->getLetzterFehler() );
  2028. schrift->lock();
  2029. schrift->setSchriftSize( 12 );
  2030. int br = schrift->getTextBreite( f );
  2031. int hö = schrift->getTextHeight( f );
  2032. schrift->unlock();
  2033. fehler = initTextFeld( gr.x / 2 - ( br + 10 ) / 2, gr.y / 2 - ( hö + 4 ) / 2, br + 10, hö + 4,
  2034. schrift, TextFeld::Style::Text | TextFeld::Style::Center, f->getText() );
  2035. f->release();
  2036. karte->unlock();
  2037. karte->release();
  2038. run = 0;
  2039. return;
  2040. }
  2041. bool ok = 0;
  2042. if( info )
  2043. {
  2044. if( !karte->getKartenBeschreibung() )
  2045. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( "Beschreibung nicht gefunden." ), new Text( "Ok" ) );
  2046. else
  2047. {
  2048. Text *pf = karte->getKartePfad();
  2049. *pf += "beschreibung.ksgs";
  2050. info->setScriptDatei( pf );
  2051. ok = info->neuLaden();
  2052. KSGSVariable *var = info->startFunktion( info->getFunktionId( "_in_gruppe" ), new RCArray< KSGSVariable >() );
  2053. if( var )
  2054. var->release();
  2055. }
  2056. }
  2057. if( !ok )
  2058. {
  2059. Text *f = new Text( karte->getLetzterFehler() );
  2060. schrift->lock();
  2061. schrift->setSchriftSize( 12 );
  2062. int br = schrift->getTextBreite( f );
  2063. int hö = schrift->getTextHeight( f );
  2064. schrift->unlock();
  2065. fehler = initTextFeld( gr.x / 2 - ( br + 10 ) / 2, gr.y / 2 - ( hö + 4 ) / 2, br + 10, hö + 4,
  2066. schrift, TextFeld::Style::Text | TextFeld::Style::Center, f->getText() );
  2067. f->release();
  2068. karte->unlock();
  2069. karte->release();
  2070. run = 0;
  2071. return;
  2072. }
  2073. karte->unlock();
  2074. karte->release();
  2075. geladen = 1;
  2076. run = 0;
  2077. rend = 1;
  2078. }
  2079. // constant
  2080. int GruppeKarte::getKarteId() const
  2081. {
  2082. return karteId;
  2083. }
  2084. // Reference Counting
  2085. GruppeKarte *GruppeKarte::getThis()
  2086. {
  2087. ref++;
  2088. return this;
  2089. }
  2090. GruppeKarte *GruppeKarte::release()
  2091. {
  2092. ref--;
  2093. if( !ref )
  2094. delete this;
  2095. return 0;
  2096. }
  2097. // Inhalt der GruppeSpielGefunden Klasse aus Gruppe.h
  2098. // Konstruktor
  2099. GruppeSpielGefunden::GruppeSpielGefunden( Schrift *zSchrift )
  2100. {
  2101. pos = Punkt( 375, 235 );
  2102. gr = Punkt( 200, 90 );
  2103. spielGefunden = initFenster( 0, 0, 200, 90, zSchrift, Fenster::Style::Sichtbar | Fenster::Style::Rahmen | Fenster::Style::Titel, "Spiel gefunden" );
  2104. zeit = initTextFeld( 0, 30, 200, 20, zSchrift, TextFeld::Style::Text, "Verbleibende Zeit: 10" );
  2105. warte = initTextFeld( 0, 60, 200, 20, zSchrift, TextFeld::Style::Text & ~TextFeld::Style::Sichtbar, "Warte auf andere Spieler. . ." );
  2106. annehmen = initKnopf( 50, 60, 100, 20, zSchrift, Knopf::Style::Normal, "beitreten" );
  2107. alpha = 0;
  2108. time = 0;
  2109. sichtbar = 0;
  2110. tickVal = 0;
  2111. rend = 0;
  2112. ref = 1;
  2113. }
  2114. // Destruktor
  2115. GruppeSpielGefunden::~GruppeSpielGefunden()
  2116. {
  2117. spielGefunden->release();
  2118. zeit->release();
  2119. warte->release();
  2120. annehmen->release();
  2121. }
  2122. // nicht constant
  2123. void GruppeSpielGefunden::reset()
  2124. {
  2125. zeit->setText( "Verbleibende Zeit: 10" );
  2126. alpha = 0;
  2127. time = 0;
  2128. sichtbar = 0;
  2129. warte->removeStyle( TextFeld::Style::Sichtbar );
  2130. annehmen->addStyle( Knopf::Style::Sichtbar );
  2131. rend = 1;
  2132. }
  2133. void GruppeSpielGefunden::setSichtbar( bool sichtbar )
  2134. {
  2135. warte->removeStyle( TextFeld::Style::Sichtbar );
  2136. annehmen->addStyle( Knopf::Style::Sichtbar );
  2137. this->sichtbar = sichtbar;
  2138. rend = 1;
  2139. }
  2140. void GruppeSpielGefunden::setVerbleibendeZeit( int sekunden )
  2141. {
  2142. if( time != sekunden )
  2143. rend = 1;
  2144. time = sekunden;
  2145. }
  2146. bool GruppeSpielGefunden::tick( double tickVal )
  2147. {
  2148. if( rend )
  2149. {
  2150. zeit->setText( "Verbleibende Zeit: " );
  2151. zeit->zText()->append( (int)time );
  2152. }
  2153. rend |= annehmen->tick( tickVal );
  2154. this->tickVal += tickVal * 300;
  2155. int val = ( int )this->tickVal;
  2156. if( val < 1 )
  2157. {
  2158. bool ret = rend;
  2159. rend = 0;
  2160. return ret;
  2161. }
  2162. if( val > 10 )
  2163. val = 10;
  2164. this->tickVal -= val;
  2165. if( sichtbar )
  2166. {
  2167. if( alpha < 255 )
  2168. {
  2169. if( alpha + val > 255 )
  2170. alpha = 255;
  2171. else
  2172. alpha += val;
  2173. rend = 1;
  2174. }
  2175. }
  2176. else
  2177. {
  2178. if( alpha )
  2179. {
  2180. if( alpha - val < 0 )
  2181. alpha = 0;
  2182. else
  2183. alpha -= val;
  2184. rend = 1;
  2185. }
  2186. }
  2187. bool ret = rend;
  2188. rend = 0;
  2189. return ret;
  2190. }
  2191. void GruppeSpielGefunden::doMausEreignis( MausEreignis &me )
  2192. {
  2193. me.mx -= pos.x;
  2194. me.my -= pos.y;
  2195. bool ver = me.verarbeitet;
  2196. annehmen->doMausEreignis( me );
  2197. if( me.verarbeitet && !ver && me.id == ME_RLinks )
  2198. {
  2199. if( spielClient->spielErstelltAnnehmen() )
  2200. {
  2201. annehmen->removeStyle( Knopf::Style::Sichtbar );
  2202. warte->addStyle( TextFeld::Style::Sichtbar );
  2203. rend = 1;
  2204. }
  2205. else if( nachLogin && nachLogin->zSpielenFenster() )
  2206. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( spielClient->getLetzterFehler() ), new Text( "Ok" ), 0 );
  2207. }
  2208. me.mx += pos.x;
  2209. me.my += pos.y;
  2210. }
  2211. void GruppeSpielGefunden::render( Bild &zRObj )
  2212. {
  2213. if( !zRObj.setDrawOptions( pos.x, pos.y, gr.x, gr.y ) )
  2214. return;
  2215. zRObj.setAlpha( alpha );
  2216. spielGefunden->render( zRObj );
  2217. zeit->render( zRObj );
  2218. warte->render( zRObj );
  2219. annehmen->render( zRObj );
  2220. zRObj.releaseAlpha();
  2221. zRObj.releaseDrawOptions();
  2222. }
  2223. // constant
  2224. bool GruppeSpielGefunden::istSichtbar() const
  2225. {
  2226. return sichtbar;
  2227. }
  2228. // Reference Counting
  2229. GruppeSpielGefunden *GruppeSpielGefunden::getThis()
  2230. {
  2231. ref++;
  2232. return this;
  2233. }
  2234. GruppeSpielGefunden *GruppeSpielGefunden::release()
  2235. {
  2236. ref--;
  2237. if( !ref )
  2238. delete this;
  2239. return 0;
  2240. }
  2241. // Inhalt der GruppeFenster Klasse aus Gruppe.h
  2242. // Konstruktor
  2243. GruppeFenster::GruppeFenster( Schrift *zSchrift )
  2244. {
  2245. pos = Punkt( 0, 0 );
  2246. gr = Punkt( 950, 550 );
  2247. anmeldung = new GruppeAnmeldung( zSchrift );
  2248. chat = new GruppeChat( zSchrift );
  2249. accounts = new GruppeAccountListe( zSchrift );
  2250. einladungen = new GruppeEinladungListe( zSchrift );
  2251. karte = new GruppeKarte( zSchrift );
  2252. spiel = new GruppeSpielGefunden( zSchrift );
  2253. alpha = 0;
  2254. sichtbar = 0;
  2255. tickVal = 0;
  2256. rend = 0;
  2257. ref = 1;
  2258. }
  2259. // Destruktor
  2260. GruppeFenster::~GruppeFenster()
  2261. {
  2262. anmeldung->release();
  2263. chat->release();
  2264. accounts->release();
  2265. einladungen->release();
  2266. karte->release();
  2267. spiel->release();
  2268. }
  2269. // nicht constant
  2270. void GruppeFenster::setGruppeId( int id )
  2271. {
  2272. gruppeId = id;
  2273. anmeldung->setGruppeId( id );
  2274. chat->setGruppeId( id );
  2275. accounts->setGruppeId( id );
  2276. einladungen->setGruppeId( id );
  2277. karte->setGruppeId( id );
  2278. spiel->setSichtbar( 0 );
  2279. if( id )
  2280. {
  2281. int adminId = infoClient->getGruppeAdminId( id );
  2282. nachLogin->zFreundesListe()->zeigeEinladeKnopf( adminId == loginClient->getAccountId() );
  2283. setAdmin( adminId );
  2284. }
  2285. rend = 1;
  2286. }
  2287. void GruppeFenster::setSichtbar( bool sichtbar )
  2288. {
  2289. this->sichtbar = sichtbar;
  2290. rend = 1;
  2291. }
  2292. void GruppeFenster::chatNachricht( const char *nachricht )
  2293. {
  2294. chat->gruppeNachricht( nachricht );
  2295. }
  2296. void GruppeFenster::neuerSpieler( int accountId )
  2297. {
  2298. einladungen->setAngenommen( accountId );
  2299. accounts->addAccount( accountId );
  2300. }
  2301. void GruppeFenster::spielerVerlässt( int accountId )
  2302. {
  2303. accounts->removeAccount( accountId );
  2304. anmeldung->setAngemeldet( 0 );
  2305. }
  2306. void GruppeFenster::neueEinladung( int accountId )
  2307. {
  2308. einladungen->addAccount( accountId );
  2309. }
  2310. void GruppeFenster::einladungEntfernt( int accountId )
  2311. {
  2312. einladungen->remove( accountId );
  2313. }
  2314. void GruppeFenster::einladungAbgelehnt( int accountId )
  2315. {
  2316. einladungen->setAbgelehnt( accountId );
  2317. }
  2318. void GruppeFenster::setSpielerHinzufügen( bool sh )
  2319. {
  2320. anmeldung->setSpielerHinzufügen( sh );
  2321. }
  2322. void GruppeFenster::setAngemeldet( bool angemeldet )
  2323. {
  2324. anmeldung->setAngemeldet( angemeldet );
  2325. }
  2326. void GruppeFenster::spielGefunden()
  2327. {
  2328. anmeldung->spielGefunden();
  2329. spiel->setSichtbar( 1 );
  2330. rend = 1;
  2331. }
  2332. void GruppeFenster::verbleibendeZeit( int sekunden )
  2333. {
  2334. spiel->setVerbleibendeZeit( sekunden );
  2335. }
  2336. void GruppeFenster::spielGefundenAbbruch()
  2337. {
  2338. spiel->setSichtbar( 0 );
  2339. }
  2340. void GruppeFenster::zurückInWarteschlange( int stunden, int minuten, int sekunden )
  2341. {
  2342. anmeldung->zurückInWarteschlange( stunden, minuten, sekunden );
  2343. }
  2344. void GruppeFenster::setAdmin( int accountId )
  2345. {
  2346. anmeldung->setAdmin( accountId );
  2347. accounts->setAdmin( accountId );
  2348. einladungen->setAdmin( accountId );
  2349. }
  2350. void GruppeFenster::kick()
  2351. {
  2352. }
  2353. void GruppeFenster::reset()
  2354. {
  2355. accounts->reset();
  2356. einladungen->reset();
  2357. karte->reset();
  2358. chat->reset();
  2359. anmeldung->reset();
  2360. spiel->reset();
  2361. }
  2362. bool GruppeFenster::tick( double tickVal )
  2363. {
  2364. if( !spiel->istSichtbar() )
  2365. {
  2366. rend |= anmeldung->tick( tickVal );
  2367. rend |= chat->tick( tickVal );
  2368. rend |= accounts->tick( tickVal );
  2369. rend |= einladungen->tick( tickVal );
  2370. rend |= karte->tick( tickVal );
  2371. }
  2372. rend |= spiel->tick( tickVal );
  2373. this->tickVal += tickVal * 300;
  2374. int val = ( int )this->tickVal;
  2375. if( val < 1 )
  2376. {
  2377. bool ret = rend;
  2378. rend = 0;
  2379. return ret;
  2380. }
  2381. if( val > 10 )
  2382. val = 10;
  2383. this->tickVal -= val;
  2384. if( sichtbar )
  2385. {
  2386. if( spiel->istSichtbar() )
  2387. {
  2388. if( alpha > 0x70 )
  2389. {
  2390. if( alpha - val < 0x70 )
  2391. alpha = 0x70;
  2392. else
  2393. alpha -= val;
  2394. rend = 1;
  2395. }
  2396. else if( alpha < 0x70 )
  2397. {
  2398. if( alpha + val > 0x70 )
  2399. alpha = 0x70;
  2400. else
  2401. alpha += val;
  2402. rend = 1;
  2403. }
  2404. }
  2405. else
  2406. {
  2407. if( alpha < 255 )
  2408. {
  2409. if( alpha + val > 255 )
  2410. alpha = 255;
  2411. else
  2412. alpha += val;
  2413. rend = 1;
  2414. }
  2415. }
  2416. }
  2417. else
  2418. {
  2419. if( alpha > 0 )
  2420. {
  2421. if( alpha - val < 0 )
  2422. alpha = 0;
  2423. else
  2424. alpha -= val;
  2425. rend = 1;
  2426. if( !alpha )
  2427. reset();
  2428. }
  2429. }
  2430. bool ret = rend;
  2431. rend = 0;
  2432. return ret;
  2433. }
  2434. void GruppeFenster::doMausEreignis( MausEreignis &me )
  2435. {
  2436. if( !spiel->istSichtbar() )
  2437. {
  2438. anmeldung->doMausEreignis( me );
  2439. chat->doMausEreignis( me );
  2440. accounts->doMausEreignis( me );
  2441. einladungen->doMausEreignis( me );
  2442. karte->doMausEreignis( me );
  2443. }
  2444. spiel->doMausEreignis( me );
  2445. }
  2446. void GruppeFenster::doTastaturEreignis( TastaturEreignis &te )
  2447. {
  2448. if( !spiel->istSichtbar() )
  2449. {
  2450. chat->doTastaturEreignis( te );
  2451. einladungen->doTastaturEreignis( te );
  2452. }
  2453. }
  2454. void GruppeFenster::render( Bild &zRObj )
  2455. {
  2456. if( alpha )
  2457. {
  2458. int x = pos.x;
  2459. int y = pos.y;
  2460. if( !zRObj.setDrawOptions( x, y, gr.x, gr.y ) )
  2461. return;
  2462. unsigned char tmpAlpha = zRObj.getAlpha();
  2463. zRObj.setAlpha( alpha );
  2464. anmeldung->render( zRObj );
  2465. chat->render( zRObj );
  2466. accounts->render( zRObj );
  2467. einladungen->render( zRObj );
  2468. karte->render( zRObj );
  2469. zRObj.releaseAlpha();
  2470. spiel->render( zRObj );
  2471. zRObj.releaseDrawOptions();
  2472. }
  2473. }
  2474. // constant
  2475. int GruppeFenster::getGruppeId() const
  2476. {
  2477. return gruppeId;
  2478. }
  2479. int GruppeFenster::getKarteId() const
  2480. {
  2481. return karte ? karte->getKarteId() : 0;
  2482. }
  2483. // Reference Counting
  2484. GruppeFenster *GruppeFenster::getThis()
  2485. {
  2486. ref++;
  2487. return this;
  2488. }
  2489. GruppeFenster *GruppeFenster::release()
  2490. {
  2491. ref--;
  2492. if( !ref )
  2493. delete this;
  2494. return 0;
  2495. }