Gruppe.cpp 75 KB

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