Gruppe.cpp 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637
  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. // TODO
  1568. /*if( spielerHinzufügen )
  1569. this->spielerHinzufügen->zToolTip()->setText( "Es kommen auch andere Spieler mit ins Spiel,\ndie nicht in dieser Gruppe sind." );
  1570. else
  1571. this->spielerHinzufügen->zToolTip()->setText( "Es werden nur Spieler aus dieser Gruppe mit ins Spiel kommen." );*/
  1572. rend = 1;
  1573. }
  1574. void GruppeAnmeldung::setAngemeldet( bool angemeldet )
  1575. {
  1576. this->angemeldet->setStyle( KontrollKnopf::Style::Selected, angemeldet );
  1577. // TODO
  1578. /*
  1579. if( angemeldet )
  1580. this->angemeldet->zToolTip()->setText( "Die Gruppe befindet sich in der Warteschlange." );
  1581. else
  1582. this->angemeldet->zToolTip()->setText( "Die Gruppe befindet sich momentan nicht in der Warteschlange." );*/
  1583. time = 0;
  1584. rend = 1;
  1585. }
  1586. void GruppeAnmeldung::zurückInWarteschlange( int stunden, int minuten, int sekunden )
  1587. {
  1588. this->angemeldet->setStyle( KontrollKnopf::Style::Selected, 1 );
  1589. time = sekunden + minuten * 60 + stunden * 60 * 60;
  1590. rend = 1;
  1591. }
  1592. void GruppeAnmeldung::spielGefunden()
  1593. {
  1594. this->angemeldet->setStyle( KontrollKnopf::Style::Selected, 0 );
  1595. time = 0;
  1596. rend = 1;
  1597. }
  1598. bool GruppeAnmeldung::tick( double tickVal )
  1599. {
  1600. if( angemeldet->hatStyle( KontrollKnopf::Style::Selected ) )
  1601. {
  1602. if( (int)( time / 1 ) != (int)( ( time + tickVal ) / 1 ) )
  1603. rend = 1;
  1604. time += tickVal;
  1605. }
  1606. if( rend )
  1607. {
  1608. zeit->setText( "Zeit in Warteschlange: " );
  1609. zeit->zText()->append( (int)( time / 60 / 60 ) );
  1610. zeit->zText()->append( ":" );
  1611. zeit->zText()->append( (int)( time / 60 ) % 60 );
  1612. zeit->zText()->append( ":" );
  1613. zeit->zText()->append( (int)( time ) % 60 );
  1614. }
  1615. rend |= spielerHinzufügen->tick( tickVal );
  1616. rend |= angemeldet->tick( tickVal );
  1617. rend |= gruppeVerlassen->tick( tickVal );
  1618. bool ret = rend;
  1619. rend = 0;
  1620. return ret;
  1621. }
  1622. void GruppeAnmeldung::doMausEreignis( MausEreignis & me )
  1623. {
  1624. me.mx -= pos.x;
  1625. me.my -= pos.y;
  1626. bool ak = !me.verarbeitet;
  1627. int aktion = 0;
  1628. if( admin == loginClient->getAccountId() )
  1629. {
  1630. spielerHinzufügen->doMausEreignis( me );
  1631. aktion = ( me.verarbeitet && admin == loginClient->getAccountId() && ak ) ? 1 : aktion;
  1632. angemeldet->doMausEreignis( me );
  1633. aktion = ( me.verarbeitet && admin == loginClient->getAccountId() && ak && !aktion ) ? 2 : aktion;
  1634. }
  1635. gruppeVerlassen->doMausEreignis( me );
  1636. aktion = ( me.verarbeitet && ak && !aktion ) ? 3 : aktion;
  1637. if( me.id != ME_RLinks )
  1638. {
  1639. me.mx += pos.x;
  1640. me.my += pos.y;
  1641. return;
  1642. }
  1643. switch( aktion )
  1644. {
  1645. case 1:
  1646. if( !anmeldungClient )
  1647. anmeldungClient = mainClient->createAnmeldungServerClient();
  1648. if( !anmeldungClient )
  1649. {
  1650. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
  1651. new Text( "Ok" ), 0 );
  1652. spielerHinzufügen->setStyle( KontrollKnopf::Style::Selected, spielerHinzufügen->hatStyleNicht( KontrollKnopf::Style::Selected ) );
  1653. rend = 1;
  1654. }
  1655. if( !anmeldungClient->verbinde() )
  1656. {
  1657. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1658. new Text( "Ok" ), 0 );
  1659. spielerHinzufügen->setStyle( KontrollKnopf::Style::Selected, spielerHinzufügen->hatStyleNicht( KontrollKnopf::Style::Selected ) );
  1660. rend = 1;
  1661. }
  1662. else
  1663. {
  1664. if( !anmeldungClient->gruppeSpielStarten( gruppeId, spielerHinzufügen->hatStyleNicht( KontrollKnopf::Style::Selected ) ) )
  1665. {
  1666. spielerHinzufügen->setStyle( KontrollKnopf::Style::Selected, spielerHinzufügen->hatStyleNicht( KontrollKnopf::Style::Selected ) );
  1667. rend = 1;
  1668. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1669. new Text( "Ok" ), 0 );
  1670. }
  1671. anmeldungClient->trenne( 0 );
  1672. }
  1673. break;
  1674. case 2:
  1675. if( !anmeldungClient )
  1676. anmeldungClient = mainClient->createAnmeldungServerClient();
  1677. if( !anmeldungClient )
  1678. {
  1679. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
  1680. new Text( "Ok" ), 0 );
  1681. angemeldet->setStyle( KontrollKnopf::Style::Selected, angemeldet->hatStyleNicht( KontrollKnopf::Style::Selected ) );
  1682. rend = 1;
  1683. }
  1684. if( !anmeldungClient->verbinde() )
  1685. {
  1686. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1687. new Text( "Ok" ), 0 );
  1688. angemeldet->setStyle( KontrollKnopf::Style::Selected, angemeldet->hatStyleNicht( KontrollKnopf::Style::Selected ) );
  1689. rend = 1;
  1690. }
  1691. else
  1692. {
  1693. if( angemeldet->hatStyle( KontrollKnopf::Style::Selected ) )
  1694. {
  1695. if( !anmeldungClient->gruppeAnmelden( gruppeId ) )
  1696. {
  1697. angemeldet->setStyle( KontrollKnopf::Style::Selected, angemeldet->hatStyleNicht( KontrollKnopf::Style::Selected ) );
  1698. rend = 1;
  1699. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1700. new Text( "Ok" ), 0 );
  1701. }
  1702. }
  1703. else
  1704. {
  1705. if( !anmeldungClient->gruppeAbmelden( gruppeId ) )
  1706. {
  1707. angemeldet->setStyle( KontrollKnopf::Style::Selected, angemeldet->hatStyleNicht( KontrollKnopf::Style::Selected ) );
  1708. rend = 1;
  1709. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1710. new Text( "Ok" ), 0 );
  1711. }
  1712. }
  1713. anmeldungClient->trenne( 0 );
  1714. }
  1715. break;
  1716. case 3:
  1717. if( !anmeldungClient )
  1718. anmeldungClient = mainClient->createAnmeldungServerClient();
  1719. if( !anmeldungClient )
  1720. {
  1721. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
  1722. new Text( "Ok" ), 0 );
  1723. rend = 1;
  1724. }
  1725. if( !anmeldungClient->verbinde() )
  1726. {
  1727. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1728. new Text( "Ok" ), 0 );
  1729. rend = 1;
  1730. }
  1731. else
  1732. {
  1733. if( anmeldungClient->gruppeVerlassen( gruppeId ) )
  1734. nachLogin->zSpielenFenster()->gruppeVerlassen();
  1735. else
  1736. {
  1737. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
  1738. new Text( "Ok" ), 0 );
  1739. }
  1740. anmeldungClient->trenne( 0 );
  1741. }
  1742. break;
  1743. }
  1744. me.mx += pos.x;
  1745. me.my += pos.y;
  1746. }
  1747. void GruppeAnmeldung::render( Bild & zRObj )
  1748. {
  1749. if( !zRObj.setDrawOptions( pos.x, pos.y, gr.x, gr.y ) )
  1750. return;
  1751. rahmen->render( zRObj );
  1752. spielerHinzufügen->render( zRObj );
  1753. angemeldet->render( zRObj );
  1754. zeit->render( zRObj );
  1755. gruppeVerlassen->render( zRObj );
  1756. zRObj.releaseDrawOptions();
  1757. }
  1758. // constant
  1759. // Reference Counting
  1760. GruppeAnmeldung *GruppeAnmeldung::getThis()
  1761. {
  1762. ref++;
  1763. return this;
  1764. }
  1765. GruppeAnmeldung *GruppeAnmeldung::release()
  1766. {
  1767. ref--;
  1768. if( !ref )
  1769. delete this;
  1770. return 0;
  1771. }
  1772. void GruppeKarteKSGSAktion( void *p, RCArray< KSGSVariable > * parameter, KSGSVariable * *retVal )
  1773. {
  1774. if( !p )
  1775. return;
  1776. ( (GruppeKarte *)p )->ksgsAktion( parameter, retVal );
  1777. }
  1778. // Inhalt der GruppeKarte Klasse aus Gruppe.h
  1779. // Konstruktor
  1780. GruppeKarte::GruppeKarte( Schrift * zSchrift )
  1781. {
  1782. schrift = zSchrift;
  1783. tr = new TextRenderer( schrift->getThis() );
  1784. pos = Punkt( 350, 0 );
  1785. gr = Punkt( 600, 350 );
  1786. rahmen = new LRahmen();
  1787. rahmen->setFarbe( 0xFFFFFFFF );
  1788. rahmen->setRamenBreite( 1 );
  1789. rahmen->setSize( 350, 350 );
  1790. rahmen->setPosition( 248, 0 );
  1791. info = 0;
  1792. ksgs = dllDateien->ladeDLL( "KSGScript.dll", "data/bin/KSGScript.dll" );
  1793. if( ksgs )
  1794. {
  1795. KSGSGetZeichnung getKSGScript = (KSGSGetZeichnung)GetProcAddress( ksgs, KSGS_START_FUNKTION );
  1796. if( getKSGScript )
  1797. {
  1798. info = getKSGScript();
  1799. info->setBildschirmZ( hauptScreen->getThis() );
  1800. info->setSchriftZ( schrift->getThis() );
  1801. info->setSize( 248, 350 );
  1802. info->setRückrufParam( this );
  1803. info->setRückrufFunktion( GruppeKarteKSGSAktion );
  1804. }
  1805. else
  1806. {
  1807. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ),
  1808. new Text( "Der Einstiegspunkt '" KSGS_START_FUNKTION "' in der DLL-Datei "
  1809. "'data/bin/KSGScript.dll' konnte nicht gefunden werden." ),
  1810. new Text( "Ok" ), 0 );
  1811. }
  1812. }
  1813. else
  1814. {
  1815. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ),
  1816. new Text( "Die DLL-Datei 'data/bin/KSGScript.dll' konnte nicht geladen werden." ),
  1817. new Text( "Ok" ), 0 );
  1818. }
  1819. hintergrund = 0;
  1820. fehler = 0;
  1821. alpha1 = 0;
  1822. alpha2 = 0;
  1823. ladenZeit = 0;
  1824. tickVal = 0;
  1825. ladeBild = 0;
  1826. karteId = 0;
  1827. gruppeId = 0;
  1828. exit = 0;
  1829. geladen = 0;
  1830. rend = 0;
  1831. ref = 1;
  1832. }
  1833. // Destruktor
  1834. GruppeKarte::~GruppeKarte()
  1835. {
  1836. exit = 1;
  1837. warteAufThread( 5000 );
  1838. if( run )
  1839. ende();
  1840. rahmen->release();
  1841. if( info )
  1842. {
  1843. info->zurücksetzen();
  1844. info->release();
  1845. }
  1846. if( hintergrund )
  1847. hintergrund->release();
  1848. if( fehler )
  1849. fehler->release();
  1850. if( schrift )
  1851. schrift->release();
  1852. tr->release();
  1853. if( ksgs )
  1854. dllDateien->releaseDLL( "KSGScript.dll" );
  1855. }
  1856. // nicht constant
  1857. void GruppeKarte::reset()
  1858. {
  1859. if( info )
  1860. info->zurücksetzen();
  1861. if( hintergrund )
  1862. hintergrund = hintergrund->release();
  1863. if( fehler )
  1864. fehler = (TextFeld *)fehler->release();
  1865. if( run )
  1866. {
  1867. exit = 1;
  1868. warteAufThread( 5000 );
  1869. if( run )
  1870. ende();
  1871. }
  1872. geladen = 0;
  1873. alpha1 = 0;
  1874. alpha2 = 0;
  1875. ladenZeit = 0;
  1876. tickVal = 0;
  1877. ladeBild = 0;
  1878. karteId = 0;
  1879. gruppeId = 0;
  1880. exit = 0;
  1881. rend = 1;
  1882. }
  1883. void GruppeKarte::ksgsAktion( RCArray< KSGSVariable > * parameter, KSGSVariable * *retVal )
  1884. {
  1885. }
  1886. void GruppeKarte::setGruppeId( int gruppeId )
  1887. {
  1888. this->gruppeId = gruppeId;
  1889. if( run )
  1890. {
  1891. exit = 1;
  1892. warteAufThread( 5000 );
  1893. if( run )
  1894. ende();
  1895. exit = 0;
  1896. }
  1897. geladen = 0;
  1898. rend = 1;
  1899. start();
  1900. }
  1901. bool GruppeKarte::tick( double tickVal )
  1902. {
  1903. if( !gruppeId )
  1904. return 0;
  1905. if( info )
  1906. rend |= info->tick( tickVal );
  1907. ladenZeit += tickVal;
  1908. if( ladenZeit >= 1 / 30.0 )
  1909. {
  1910. ladenZeit -= 1 / 30.0;
  1911. if( ladeAnimation &&ladeAnimation->zAnimationData() )
  1912. {
  1913. if( alpha1 )
  1914. rend = 1;
  1915. ladeBild++;
  1916. if( ladeBild >= ladeAnimation->zAnimationData()->getBildAnzahl() )
  1917. ladeBild = 0;
  1918. }
  1919. }
  1920. this->tickVal += tickVal * 300;
  1921. int val = (int)this->tickVal;
  1922. if( val < 1 )
  1923. {
  1924. bool ret = rend;
  1925. rend = 0;
  1926. return ret;
  1927. }
  1928. if( val > 10 )
  1929. val = 10;
  1930. this->tickVal -= val;
  1931. if( !geladen && !fehler )
  1932. {
  1933. if( alpha1 != 255 || alpha2 != 0 )
  1934. rend = 1;
  1935. if( alpha1 + val > 255 )
  1936. alpha1 = 255;
  1937. else
  1938. alpha1 += val;
  1939. if( alpha2 - val < 0 )
  1940. alpha2 = 0;
  1941. else
  1942. alpha2 -= val;
  1943. }
  1944. else
  1945. {
  1946. if( alpha1 != 0 || alpha2 != 255 )
  1947. rend = 1;
  1948. if( alpha1 - val < 0 )
  1949. alpha1 = 0;
  1950. else
  1951. alpha1 -= val;
  1952. if( alpha2 + val > 255 )
  1953. alpha2 = 255;
  1954. else
  1955. alpha2 += val;
  1956. }
  1957. bool ret = rend;
  1958. rend = 0;
  1959. return ret;
  1960. }
  1961. void GruppeKarte::doMausEreignis( MausEreignis & me )
  1962. {
  1963. me.mx -= pos.x;
  1964. me.my -= pos.y;
  1965. if( info )
  1966. info->doMausEreignis( me );
  1967. me.mx += pos.x;
  1968. me.my += pos.y;
  1969. }
  1970. void GruppeKarte::render( Bild & zrObj )
  1971. {
  1972. int x = pos.x;
  1973. int y = pos.y;
  1974. if( !zrObj.setDrawOptions( x, y, gr.x, gr.y ) )
  1975. return;
  1976. if( alpha1 != 0 && ladeAnimation && ladeAnimation->zAnimationData() )
  1977. {
  1978. Bild *tmp = ladeAnimation->zAnimationData()->zBild( ladeBild );
  1979. if( tmp )
  1980. {
  1981. zrObj.setAlpha( alpha1 );
  1982. zrObj.drawBild( gr.x / 2 - tmp->getBreite() / 2, gr.y / 2 - tmp->getHeight() / 2, tmp->getBreite(), tmp->getHeight(), *tmp );
  1983. zrObj.releaseAlpha();
  1984. }
  1985. }
  1986. if( alpha2 != 0 )
  1987. {
  1988. zrObj.setAlpha( alpha2 );
  1989. if( geladen )
  1990. {
  1991. if( info )
  1992. info->render( zrObj );
  1993. rahmen->render( zrObj );
  1994. zrObj.drawBild( 248 + rahmen->getRBreite(), rahmen->getRBreite(),
  1995. rahmen->getBreite() - rahmen->getRBreite() * 2, rahmen->getHeight() - rahmen->getRBreite() * 2, *hintergrund );
  1996. }
  1997. else if( fehler )
  1998. fehler->render( zrObj );
  1999. zrObj.releaseAlpha();
  2000. }
  2001. zrObj.releaseDrawOptions();
  2002. }
  2003. void GruppeKarte::thread()
  2004. {
  2005. if( info )
  2006. info->zurücksetzen();
  2007. if( hintergrund )
  2008. hintergrund = hintergrund->release();
  2009. if( fehler )
  2010. fehler = (TextFeld *)fehler->release();
  2011. karteId = infoClient->getGruppenKarteId( gruppeId );
  2012. if( !karteId )
  2013. {
  2014. run = 0;
  2015. return;
  2016. }
  2017. KartenLeser *karte = KartenLeser::getInstance();
  2018. karte->lock();
  2019. karte->setKarteId( karteId );
  2020. hintergrund = karte->getKartenVorschauBild();
  2021. if( exit )
  2022. {
  2023. if( hintergrund )
  2024. hintergrund = hintergrund->release();
  2025. karte->unlock();
  2026. karte->release();
  2027. run = 0;
  2028. return;
  2029. }
  2030. if( !hintergrund )
  2031. {
  2032. Text *f = new Text( karte->getLetzterFehler() );
  2033. tr->setSchriftSize( 12 );
  2034. int br = tr->getTextBreite( f->getText() );
  2035. int hö = tr->getTextHeight( f->getText() );
  2036. fehler = initTextFeld( gr.x / 2 - ( br + 10 ) / 2, gr.y / 2 - ( hö + 4 ) / 2, br + 10, hö + 4,
  2037. schrift, TextFeld::Style::Text | TextFeld::Style::Center, f->getText() );
  2038. f->release();
  2039. karte->unlock();
  2040. karte->release();
  2041. run = 0;
  2042. return;
  2043. }
  2044. bool ok = 0;
  2045. if( info )
  2046. {
  2047. if( !karte->getKartenBeschreibung() )
  2048. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( "Beschreibung nicht gefunden." ), new Text( "Ok" ) );
  2049. else
  2050. {
  2051. Text *pf = karte->getKartePfad();
  2052. *pf += "beschreibung.ksgs";
  2053. info->setScriptDatei( pf );
  2054. ok = info->neuLaden();
  2055. KSGSVariable *var = info->startFunktion( info->getFunktionId( "_in_gruppe" ), new RCArray< KSGSVariable >() );
  2056. if( var )
  2057. var->release();
  2058. }
  2059. }
  2060. if( !ok )
  2061. {
  2062. Text *f = new Text( karte->getLetzterFehler() );
  2063. tr->setSchriftSize( 12 );
  2064. int br = tr->getTextBreite( f->getText() );
  2065. int hö = tr->getTextHeight( f->getText() );
  2066. fehler = initTextFeld( gr.x / 2 - ( br + 10 ) / 2, gr.y / 2 - ( hö + 4 ) / 2, br + 10, hö + 4,
  2067. schrift, TextFeld::Style::Text | TextFeld::Style::Center, f->getText() );
  2068. f->release();
  2069. karte->unlock();
  2070. karte->release();
  2071. run = 0;
  2072. return;
  2073. }
  2074. karte->unlock();
  2075. karte->release();
  2076. geladen = 1;
  2077. run = 0;
  2078. rend = 1;
  2079. }
  2080. // constant
  2081. int GruppeKarte::getKarteId() const
  2082. {
  2083. return karteId;
  2084. }
  2085. // Reference Counting
  2086. GruppeKarte *GruppeKarte::getThis()
  2087. {
  2088. ref++;
  2089. return this;
  2090. }
  2091. GruppeKarte *GruppeKarte::release()
  2092. {
  2093. ref--;
  2094. if( !ref )
  2095. delete this;
  2096. return 0;
  2097. }
  2098. // Inhalt der GruppeSpielGefunden Klasse aus Gruppe.h
  2099. // Konstruktor
  2100. GruppeSpielGefunden::GruppeSpielGefunden( Schrift * zSchrift )
  2101. {
  2102. pos = Punkt( 375, 235 );
  2103. gr = Punkt( 200, 90 );
  2104. spielGefunden = initFenster( 0, 0, 200, 90, zSchrift, Fenster::Style::Sichtbar | Fenster::Style::Rahmen | Fenster::Style::Titel, "Spiel gefunden" );
  2105. zeit = initTextFeld( 0, 30, 200, 20, zSchrift, TextFeld::Style::Text, "Verbleibende Zeit: 10" );
  2106. warte = initTextFeld( 0, 60, 200, 20, zSchrift, TextFeld::Style::Text & ~TextFeld::Style::Sichtbar, "Warte auf andere Spieler. . ." );
  2107. annehmen = initKnopf( 50, 60, 100, 20, zSchrift, Knopf::Style::Normal, "beitreten" );
  2108. alpha = 0;
  2109. time = 0;
  2110. sichtbar = 0;
  2111. tickVal = 0;
  2112. rend = 0;
  2113. ref = 1;
  2114. }
  2115. // Destruktor
  2116. GruppeSpielGefunden::~GruppeSpielGefunden()
  2117. {
  2118. spielGefunden->release();
  2119. zeit->release();
  2120. warte->release();
  2121. annehmen->release();
  2122. }
  2123. // nicht constant
  2124. void GruppeSpielGefunden::reset()
  2125. {
  2126. zeit->setText( "Verbleibende Zeit: 10" );
  2127. alpha = 0;
  2128. time = 0;
  2129. sichtbar = 0;
  2130. warte->removeStyle( TextFeld::Style::Sichtbar );
  2131. annehmen->addStyle( Knopf::Style::Sichtbar );
  2132. rend = 1;
  2133. }
  2134. void GruppeSpielGefunden::setSichtbar( bool sichtbar )
  2135. {
  2136. warte->removeStyle( TextFeld::Style::Sichtbar );
  2137. annehmen->addStyle( Knopf::Style::Sichtbar );
  2138. this->sichtbar = sichtbar;
  2139. rend = 1;
  2140. }
  2141. void GruppeSpielGefunden::setVerbleibendeZeit( int sekunden )
  2142. {
  2143. if( time != sekunden )
  2144. rend = 1;
  2145. time = sekunden;
  2146. }
  2147. bool GruppeSpielGefunden::tick( double tickVal )
  2148. {
  2149. if( rend )
  2150. {
  2151. zeit->setText( "Verbleibende Zeit: " );
  2152. zeit->zText()->append( (int)time );
  2153. }
  2154. rend |= annehmen->tick( tickVal );
  2155. this->tickVal += tickVal * 300;
  2156. int val = (int)this->tickVal;
  2157. if( val < 1 )
  2158. {
  2159. bool ret = rend;
  2160. rend = 0;
  2161. return ret;
  2162. }
  2163. if( val > 10 )
  2164. val = 10;
  2165. this->tickVal -= val;
  2166. if( sichtbar )
  2167. {
  2168. if( alpha < 255 )
  2169. {
  2170. if( alpha + val > 255 )
  2171. alpha = 255;
  2172. else
  2173. alpha += val;
  2174. rend = 1;
  2175. }
  2176. }
  2177. else
  2178. {
  2179. if( alpha )
  2180. {
  2181. if( alpha - val < 0 )
  2182. alpha = 0;
  2183. else
  2184. alpha -= val;
  2185. rend = 1;
  2186. }
  2187. }
  2188. bool ret = rend;
  2189. rend = 0;
  2190. return ret;
  2191. }
  2192. void GruppeSpielGefunden::doMausEreignis( MausEreignis & me )
  2193. {
  2194. me.mx -= pos.x;
  2195. me.my -= pos.y;
  2196. bool ver = me.verarbeitet;
  2197. annehmen->doMausEreignis( me );
  2198. if( me.verarbeitet && !ver && me.id == ME_RLinks )
  2199. {
  2200. if( spielClient->spielErstelltAnnehmen() )
  2201. {
  2202. annehmen->removeStyle( Knopf::Style::Sichtbar );
  2203. warte->addStyle( TextFeld::Style::Sichtbar );
  2204. rend = 1;
  2205. }
  2206. else if( nachLogin &&nachLogin->zSpielenFenster() )
  2207. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( spielClient->getLetzterFehler() ), new Text( "Ok" ), 0 );
  2208. }
  2209. me.mx += pos.x;
  2210. me.my += pos.y;
  2211. }
  2212. void GruppeSpielGefunden::render( Bild & zRObj )
  2213. {
  2214. if( !zRObj.setDrawOptions( pos.x, pos.y, gr.x, gr.y ) )
  2215. return;
  2216. zRObj.setAlpha( alpha );
  2217. spielGefunden->render( zRObj );
  2218. zeit->render( zRObj );
  2219. warte->render( zRObj );
  2220. annehmen->render( zRObj );
  2221. zRObj.releaseAlpha();
  2222. zRObj.releaseDrawOptions();
  2223. }
  2224. // constant
  2225. bool GruppeSpielGefunden::istSichtbar() const
  2226. {
  2227. return sichtbar;
  2228. }
  2229. // Reference Counting
  2230. GruppeSpielGefunden *GruppeSpielGefunden::getThis()
  2231. {
  2232. ref++;
  2233. return this;
  2234. }
  2235. GruppeSpielGefunden *GruppeSpielGefunden::release()
  2236. {
  2237. ref--;
  2238. if( !ref )
  2239. delete this;
  2240. return 0;
  2241. }
  2242. // Inhalt der GruppeFenster Klasse aus Gruppe.h
  2243. // Konstruktor
  2244. GruppeFenster::GruppeFenster( Schrift * zSchrift )
  2245. {
  2246. pos = Punkt( 0, 0 );
  2247. gr = Punkt( 950, 550 );
  2248. anmeldung = new GruppeAnmeldung( zSchrift );
  2249. chat = new GruppeChat( zSchrift );
  2250. accounts = new GruppeAccountListe( zSchrift );
  2251. einladungen = new GruppeEinladungListe( zSchrift );
  2252. karte = new GruppeKarte( zSchrift );
  2253. spiel = new GruppeSpielGefunden( zSchrift );
  2254. alpha = 0;
  2255. sichtbar = 0;
  2256. tickVal = 0;
  2257. rend = 0;
  2258. ref = 1;
  2259. }
  2260. // Destruktor
  2261. GruppeFenster::~GruppeFenster()
  2262. {
  2263. anmeldung->release();
  2264. chat->release();
  2265. accounts->release();
  2266. einladungen->release();
  2267. karte->release();
  2268. spiel->release();
  2269. }
  2270. // nicht constant
  2271. void GruppeFenster::setGruppeId( int id )
  2272. {
  2273. gruppeId = id;
  2274. anmeldung->setGruppeId( id );
  2275. chat->setGruppeId( id );
  2276. accounts->setGruppeId( id );
  2277. einladungen->setGruppeId( id );
  2278. karte->setGruppeId( id );
  2279. spiel->setSichtbar( 0 );
  2280. if( id )
  2281. {
  2282. int adminId = infoClient->getGruppeAdminId( id );
  2283. nachLogin->zFreundesListe()->zeigeEinladeKnopf( adminId == loginClient->getAccountId() );
  2284. setAdmin( adminId );
  2285. }
  2286. rend = 1;
  2287. }
  2288. void GruppeFenster::setSichtbar( bool sichtbar )
  2289. {
  2290. this->sichtbar = sichtbar;
  2291. rend = 1;
  2292. }
  2293. void GruppeFenster::chatNachricht( const char *nachricht )
  2294. {
  2295. chat->gruppeNachricht( nachricht );
  2296. }
  2297. void GruppeFenster::neuerSpieler( int accountId )
  2298. {
  2299. einladungen->setAngenommen( accountId );
  2300. accounts->addAccount( accountId );
  2301. }
  2302. void GruppeFenster::spielerVerlässt( int accountId )
  2303. {
  2304. accounts->removeAccount( accountId );
  2305. anmeldung->setAngemeldet( 0 );
  2306. }
  2307. void GruppeFenster::neueEinladung( int accountId )
  2308. {
  2309. einladungen->addAccount( accountId );
  2310. }
  2311. void GruppeFenster::einladungEntfernt( int accountId )
  2312. {
  2313. einladungen->remove( accountId );
  2314. }
  2315. void GruppeFenster::einladungAbgelehnt( int accountId )
  2316. {
  2317. einladungen->setAbgelehnt( accountId );
  2318. }
  2319. void GruppeFenster::setSpielerHinzufügen( bool sh )
  2320. {
  2321. anmeldung->setSpielerHinzufügen( sh );
  2322. }
  2323. void GruppeFenster::setAngemeldet( bool angemeldet )
  2324. {
  2325. anmeldung->setAngemeldet( angemeldet );
  2326. }
  2327. void GruppeFenster::spielGefunden()
  2328. {
  2329. anmeldung->spielGefunden();
  2330. spiel->setSichtbar( 1 );
  2331. rend = 1;
  2332. }
  2333. void GruppeFenster::verbleibendeZeit( int sekunden )
  2334. {
  2335. spiel->setVerbleibendeZeit( sekunden );
  2336. }
  2337. void GruppeFenster::spielGefundenAbbruch()
  2338. {
  2339. spiel->setSichtbar( 0 );
  2340. }
  2341. void GruppeFenster::zurückInWarteschlange( int stunden, int minuten, int sekunden )
  2342. {
  2343. anmeldung->zurückInWarteschlange( stunden, minuten, sekunden );
  2344. }
  2345. void GruppeFenster::setAdmin( int accountId )
  2346. {
  2347. anmeldung->setAdmin( accountId );
  2348. accounts->setAdmin( accountId );
  2349. einladungen->setAdmin( accountId );
  2350. }
  2351. void GruppeFenster::kick()
  2352. {
  2353. }
  2354. void GruppeFenster::reset()
  2355. {
  2356. accounts->reset();
  2357. einladungen->reset();
  2358. karte->reset();
  2359. chat->reset();
  2360. anmeldung->reset();
  2361. spiel->reset();
  2362. }
  2363. bool GruppeFenster::tick( double tickVal )
  2364. {
  2365. if( !spiel->istSichtbar() )
  2366. {
  2367. rend |= anmeldung->tick( tickVal );
  2368. rend |= chat->tick( tickVal );
  2369. rend |= accounts->tick( tickVal );
  2370. rend |= einladungen->tick( tickVal );
  2371. rend |= karte->tick( tickVal );
  2372. }
  2373. rend |= spiel->tick( tickVal );
  2374. this->tickVal += tickVal * 300;
  2375. int val = (int)this->tickVal;
  2376. if( val < 1 )
  2377. {
  2378. bool ret = rend;
  2379. rend = 0;
  2380. return ret;
  2381. }
  2382. if( val > 10 )
  2383. val = 10;
  2384. this->tickVal -= val;
  2385. if( sichtbar )
  2386. {
  2387. if( spiel->istSichtbar() )
  2388. {
  2389. if( alpha > 0x70 )
  2390. {
  2391. if( alpha - val < 0x70 )
  2392. alpha = 0x70;
  2393. else
  2394. alpha -= val;
  2395. rend = 1;
  2396. }
  2397. else if( alpha < 0x70 )
  2398. {
  2399. if( alpha + val > 0x70 )
  2400. alpha = 0x70;
  2401. else
  2402. alpha += val;
  2403. rend = 1;
  2404. }
  2405. }
  2406. else
  2407. {
  2408. if( alpha < 255 )
  2409. {
  2410. if( alpha + val > 255 )
  2411. alpha = 255;
  2412. else
  2413. alpha += val;
  2414. rend = 1;
  2415. }
  2416. }
  2417. }
  2418. else
  2419. {
  2420. if( alpha > 0 )
  2421. {
  2422. if( alpha - val < 0 )
  2423. alpha = 0;
  2424. else
  2425. alpha -= val;
  2426. rend = 1;
  2427. if( !alpha )
  2428. reset();
  2429. }
  2430. }
  2431. bool ret = rend;
  2432. rend = 0;
  2433. return ret;
  2434. }
  2435. void GruppeFenster::doMausEreignis( MausEreignis & me )
  2436. {
  2437. if( !spiel->istSichtbar() )
  2438. {
  2439. anmeldung->doMausEreignis( me );
  2440. chat->doMausEreignis( me );
  2441. accounts->doMausEreignis( me );
  2442. einladungen->doMausEreignis( me );
  2443. karte->doMausEreignis( me );
  2444. }
  2445. spiel->doMausEreignis( me );
  2446. }
  2447. void GruppeFenster::doTastaturEreignis( TastaturEreignis & te )
  2448. {
  2449. if( !spiel->istSichtbar() )
  2450. {
  2451. chat->doTastaturEreignis( te );
  2452. einladungen->doTastaturEreignis( te );
  2453. }
  2454. }
  2455. void GruppeFenster::render( Bild & zRObj )
  2456. {
  2457. if( alpha )
  2458. {
  2459. int x = pos.x;
  2460. int y = pos.y;
  2461. if( !zRObj.setDrawOptions( x, y, gr.x, gr.y ) )
  2462. return;
  2463. unsigned char tmpAlpha = zRObj.getAlpha();
  2464. zRObj.setAlpha( alpha );
  2465. anmeldung->render( zRObj );
  2466. chat->render( zRObj );
  2467. accounts->render( zRObj );
  2468. einladungen->render( zRObj );
  2469. karte->render( zRObj );
  2470. zRObj.releaseAlpha();
  2471. spiel->render( zRObj );
  2472. zRObj.releaseDrawOptions();
  2473. }
  2474. }
  2475. // constant
  2476. int GruppeFenster::getGruppeId() const
  2477. {
  2478. return gruppeId;
  2479. }
  2480. int GruppeFenster::getKarteId() const
  2481. {
  2482. return karte ? karte->getKarteId() : 0;
  2483. }
  2484. // Reference Counting
  2485. GruppeFenster *GruppeFenster::getThis()
  2486. {
  2487. ref++;
  2488. return this;
  2489. }
  2490. GruppeFenster *GruppeFenster::release()
  2491. {
  2492. ref--;
  2493. if( !ref )
  2494. delete this;
  2495. return 0;
  2496. }