123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637 |
- #include "Gruppe.h"
- #include <Punkt.h>
- #include <Rahmen.h>
- #include "..\..\..\Global\Variablen.h"
- #include "..\..\..\Global\Initialisierung.h"
- #include "..\..\..\Leser\KartenLeser.h"
- #include <DateiSystem.h>
- #include <AlphaFeld.h>
- #include <ToolTip.h>
- // Inhalt der GruppeEinladungAccount Klasse aus Gruppe.h
- // Konstruktor
- GruppeEinladungAccount::GruppeEinladungAccount( Schrift *zSchrift )
- {
- Bild *nachrichtBild = bilder->get( "chat.ltdb/nachricht.png" );
- if( !nachrichtBild )
- {
- LTDBDatei *datei = new LTDBDatei();
- datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
- datei->leseDaten( 0 );
- nachrichtBild = datei->laden( 0, new Text( "nachricht.png" ) );
- datei->release();
- bilder->add( "chat.ltdb/nachricht.png", nachrichtBild->getThis() );
- }
- Bild *neuSendenBild = bilder->get( "chat.ltdb/neusenden.png" );
- if( !neuSendenBild )
- {
- LTDBDatei *datei = new LTDBDatei();
- datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
- datei->leseDaten( 0 );
- neuSendenBild = datei->laden( 0, new Text( "neusenden.png" ) );
- datei->release();
- bilder->add( "chat.ltdb/neusenden.png", neuSendenBild->getThis() );
- }
- Bild *entfernenBild = bilder->get( "chat.ltdb/entfernen.png" );
- if( !entfernenBild )
- {
- LTDBDatei *datei = new LTDBDatei();
- datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
- datei->leseDaten( 0 );
- entfernenBild = datei->laden( 0, new Text( "entfernen.png" ) );
- datei->release();
- bilder->add( "chat.ltdb/entfernen.png", entfernenBild->getThis() );
- }
- rahmen = new LRahmen();
- rahmen->setFarbe( 0xFFFFFFFF );
- rahmen->setRamenBreite( 1 );
- auswahl = new AlphaFeld();
- auswahl->setFarbe( 0x0000FF00 );
- auswahl->setStrength( -2 );
- auswahl->setPosition( 1, 1 );
- name = initTextFeld( 0, 5, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, "" );
- nachrichtSenden = initKnopf( 0, 30, 20, 20, 0, 0, "" );
- nachrichtSenden->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
- nachrichtSenden->setHintergrundBildZ( nachrichtBild );
- initToolTip( nachrichtSenden, "Nachricht senden.", zSchrift->getThis(), hauptScreen );
- erneutSenden = initKnopf( 0, 30, 20, 20, 0, 0, "" );
- erneutSenden->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
- erneutSenden->setHintergrundBildZ( neuSendenBild );
- initToolTip( erneutSenden, "Einladung erneut senden.", zSchrift->getThis(), hauptScreen );
- einladungAbbrechen = initKnopf( 0, 30, 20, 20, 0, 0, "" );
- einladungAbbrechen->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
- einladungAbbrechen->setHintergrundBildZ( entfernenBild );
- initToolTip( einladungAbbrechen, "Einladung abbrechen.", zSchrift->getThis(), hauptScreen );
- status = 0;
- knopfX = 500;
- tickVal = 0;
- mausIn = 0;
- remove = 0;
- gruppeId = 0;
- accountId = 0;
- admin = 0;
- höhe = 0;
- animation = 0x1;
- rend = 0;
- ref = 1;
- }
- // Destruktor
- GruppeEinladungAccount::~GruppeEinladungAccount()
- {
- rahmen->release();
- auswahl->release();
- name->release();
- nachrichtSenden->release();
- erneutSenden->release();
- einladungAbbrechen->release();
- }
- // nicht constant
- void GruppeEinladungAccount::setGruppeId( int gruppeId )
- {
- this->gruppeId = gruppeId;
- }
- void GruppeEinladungAccount::setAccountId( int id )
- {
- this->accountId = id;
- name->setText( infoClient->getSpielerName( id ) );
- rend = 1;
- }
- void GruppeEinladungAccount::setSize( int br )
- {
- if( this->br != br )
- rend = 1;
- this->br = br;
- if( knopfX == 500 )
- {
- knopfX = br;
- rend = 1;
- }
- }
- void GruppeEinladungAccount::setAbgelehnt()
- {
- status = 1;
- }
- void GruppeEinladungAccount::setAngenommen()
- {
- status = 2;
- }
- void GruppeEinladungAccount::setRemove()
- {
- animation &= ~0x1;
- }
- void GruppeEinladungAccount::setAdmin( int admin )
- {
- this->admin = admin;
- }
- bool GruppeEinladungAccount::tick( double tickVal )
- {
- rend |= name->tick( tickVal );
- rend |= nachrichtSenden->tick( tickVal );
- rend |= erneutSenden->tick( tickVal );
- rend |= einladungAbbrechen->tick( tickVal );
- this->tickVal += tickVal * 100;
- int val = (int)this->tickVal;
- if( val < 1 )
- {
- bool ret = rend;
- rend = 0;
- return ret;
- }
- if( val > 4 )
- val = 4;
- this->tickVal -= val;
- if( ( animation | 0x1 ) == animation )
- {
- if( höhe < 30 )
- {
- höhe += val;
- if( höhe > 30 )
- höhe = 30;
- rend = 1;
- }
- }
- else
- {
- if( höhe > 0 )
- {
- höhe -= val;
- if( höhe < 0 )
- höhe = 0;
- rend = 1;
- }
- }
- if( mausIn )
- {
- if( admin == loginClient->getAccountId() && !status )
- {
- if( knopfX > br - 60 )
- {
- knopfX -= val;
- if( knopfX < br - 60 )
- knopfX = br - 60;
- rend = 1;
- }
- }
- else if( admin == loginClient->getAccountId() && status != 2 )
- {
- if( knopfX > br - 40 )
- {
- knopfX -= val;
- if( knopfX < br - 40 )
- knopfX = br - 40;
- rend = 1;
- }
- }
- else
- {
- if( knopfX > br - 20 )
- {
- knopfX -= val;
- if( knopfX < br - 20 )
- knopfX = br - 20;
- rend = 1;
- }
- }
- }
- else
- {
- if( knopfX < br )
- {
- knopfX += val;
- if( knopfX > br )
- knopfX = br;
- rend = 1;
- }
- }
- switch( status )
- {
- case 1:
- if( 1 )
- {
- int r = ( rahmen->getFarbe() >> 16 ) & 0xFF;
- int g = ( rahmen->getFarbe() >> 8 ) & 0xFF;
- int b = rahmen->getFarbe() & 0xFF;
- if( r < 255 )
- {
- r += val;
- if( r > 255 )
- r = 255;
- rend = 1;
- }
- if( g > 0 )
- {
- g -= val;
- if( g < 0 )
- g = 0;
- rend = 1;
- }
- if( b > 0 )
- {
- b -= val;
- if( b < 0 )
- b = 0;
- rend = 1;
- }
- int f = ( ( r << 16 ) & 0xFF0000 ) | ( ( g << 8 ) & 0xFF00 ) | ( b & 0xFF );
- rahmen->setFarbe( ( rahmen->getFarbe() & 0xFF000000 ) | f );
- auswahl->setFarbe( ( auswahl->getFarbe() & 0xFF000000 ) | f );
- }
- break;
- case 2:
- if( 1 )
- {
- int r = ( rahmen->getFarbe() >> 16 ) & 0xFF;
- int g = ( rahmen->getFarbe() >> 8 ) & 0xFF;
- int b = rahmen->getFarbe() & 0xFF;
- if( r > 0 )
- {
- r -= val;
- if( r < 0 )
- r = 0;
- rend = 1;
- }
- if( g < 255 )
- {
- g += val;
- if( g > 255 )
- g = 255;
- rend = 1;
- }
- if( b > 0 )
- {
- b -= val;
- if( b < 0 )
- b = 0;
- rend = 1;
- }
- int f = ( ( r << 16 ) & 0xFF0000 ) | ( ( g << 8 ) & 0xFF00 ) | ( b & 0xFF );
- rahmen->setFarbe( ( rahmen->getFarbe() & 0xFF000000 ) | f );
- auswahl->setFarbe( ( auswahl->getFarbe() & 0xFF000000 ) | f );
- }
- break;
- }
- bool ret = rend;
- rend = 0;
- return ret;
- }
- void GruppeEinladungAccount::doMausEreignis( MausEreignis & me )
- {
- if( me.mx < 0 || me.my < 0 || me.mx > br || me.my > höhe )
- mausIn = 0;
- else
- mausIn = 1;
- bool ak = !me.verarbeitet;
- nachrichtSenden->doMausEreignis( me );
- int aktion = ( me.verarbeitet && ak ) ? 1 : 0;
- erneutSenden->doMausEreignis( me );
- aktion = ( me.verarbeitet && ak && !aktion ) ? 2 : aktion;
- einladungAbbrechen->doMausEreignis( me );
- aktion = ( me.verarbeitet && ak && !status && !aktion ) ? 3 : aktion;
- if( me.id != ME_RLinks || !mausIn )
- return;
- switch( aktion )
- {
- case 1:
- nachLogin->zChatLeiste()->addChat( accountId, 0 );
- break;
- case 2:
- if( !anmeldungClient )
- anmeldungClient = mainClient->createAnmeldungServerClient();
- if( !anmeldungClient )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- if( !anmeldungClient->verbinde() )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- else
- {
- if( !anmeldungClient->gruppeSpielerEinladen( accountId, gruppeId ) )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- anmeldungClient->trenne( 0 );
- }
- break;
- case 3:
- if( !anmeldungClient )
- anmeldungClient = mainClient->createAnmeldungServerClient();
- if( !anmeldungClient )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- if( !anmeldungClient->verbinde() )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- else
- {
- if( !anmeldungClient->gruppeEinladungAbbrechen( accountId, gruppeId ) )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- anmeldungClient->trenne( 0 );
- }
- break;
- }
- }
- void GruppeEinladungAccount::render( int y, Bild & zrObj )
- {
- if( !zrObj.setDrawOptions( 0, y, br, höhe ) )
- return;
- rahmen->setSize( br, höhe );
- rahmen->render( zrObj );
- int rbr = rahmen->getRBreite();
- if( !zrObj.setDrawOptions( rbr, rbr, br - rbr * 2, höhe - rbr * 2 ) )
- {
- zrObj.releaseDrawOptions();
- return;
- }
- auswahl->setSize( br - rbr * 2, höhe - rbr * 2 );
- auswahl->render( zrObj );
- nachrichtSenden->setPosition( knopfX, 5 );
- nachrichtSenden->render( zrObj );
- erneutSenden->setPosition( knopfX + 20, 5 );
- erneutSenden->render( zrObj );
- einladungAbbrechen->setPosition( knopfX + 40, 5 );
- einladungAbbrechen->render( zrObj );
- name->render( zrObj );
- zrObj.releaseDrawOptions();
- zrObj.releaseDrawOptions();
- }
- // constant
- bool GruppeEinladungAccount::getRemove() const
- {
- return remove;
- }
- int GruppeEinladungAccount::getAccountId() const
- {
- return accountId;
- }
- int GruppeEinladungAccount::getHeight() const
- {
- return höhe;
- }
- // Reference Counting
- GruppeEinladungAccount *GruppeEinladungAccount::getThis()
- {
- ref++;
- return this;
- }
- GruppeEinladungAccount *GruppeEinladungAccount::release()
- {
- ref--;
- if( !ref )
- delete this;
- return 0;
- }
- // Inhalt der GruppeEinladungListe Klasse aus Gruppe.h
- // Konstruktor
- GruppeEinladungListe::GruppeEinladungListe( Schrift * zSchrift )
- {
- schrift = zSchrift->getThis();
- Bild *maximierenBild = bilder->get( "chat.ltdb/maximieren.png" );
- if( !maximierenBild )
- {
- LTDBDatei *datei = new LTDBDatei();
- datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
- datei->leseDaten( 0 );
- maximierenBild = datei->laden( 0, new Text( "maximieren.png" ) );
- datei->release();
- bilder->add( "chat.ltdb/maximieren.png", maximierenBild->getThis() );
- }
- pos = Punkt( 200, 0 );
- gr = Punkt( 150, 350 );
- rahmen = new LRahmen();
- rahmen->setRamenBreite( 1 );
- rahmen->setFarbe( 0xFFFFFFFF );
- rahmen->setSize( 150, 350 );
- einladenName = initTextFeld( 5, 5, 115, 20, zSchrift, TextFeld::Style::TextFeld, "" );
- initToolTip( einladenName, "Name des Spielers den du einladen möchtest.", zSchrift->getThis(), hauptScreen );
- einladen = initKnopf( 125, 5, 20, 20, 0, 0, "" );
- einladen->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
- einladen->setHintergrundBildZ( maximierenBild );
- initToolTip( einladen, "Diesen Spieler einladen.", zSchrift->getThis(), hauptScreen );
- scroll = new VScrollBar();
- accounts = new RCArray< GruppeEinladungAccount >();
- einladungHöhe = 0;
- tickVal = 0;
- anzahl = 0;
- gruppeId = 0;
- admin = 0;
- rend = 0;
- ref = 1;
- }
- // Destruktor
- GruppeEinladungListe::~GruppeEinladungListe()
- {
- rahmen->release();
- einladenName->release();
- einladen->release();
- scroll->release();
- accounts->release();
- schrift->release();
- }
- // nicht constant
- void GruppeEinladungListe::reset()
- {
- einladenName->setText( "" );
- scroll->update( 0, 0 );
- einladungHöhe = 0;
- tickVal = 0;
- accounts->leeren();
- anzahl = 0;
- gruppeId = 0;
- admin = 0;
- rend = 1;
- }
- void GruppeEinladungListe::setGruppeId( int gruppeId )
- {
- this->gruppeId = gruppeId;
- for( int i = 0; i < anzahl; i++ )
- accounts->z( i )->setGruppeId( gruppeId );
- }
- void GruppeEinladungListe::addAccount( int id )
- {
- for( int i = 0; i < anzahl; i++ )
- {
- GruppeEinladungAccount *tmp = accounts->z( i );
- if( tmp->getAccountId() == id )
- tmp->setRemove();
- }
- GruppeEinladungAccount * tmp = new GruppeEinladungAccount( schrift );
- tmp->setGruppeId( gruppeId );
- tmp->setAccountId( id );
- tmp->setAdmin( admin );
- accounts->add( tmp, anzahl );
- anzahl++;
- rend = 1;
- }
- void GruppeEinladungListe::setAbgelehnt( int id )
- {
- for( int i = 0; i < anzahl; i++ )
- {
- GruppeEinladungAccount *tmp = accounts->z( i );
- if( tmp && tmp->getAccountId() == id )
- {
- tmp->setAbgelehnt();
- break;
- }
- }
- }
- void GruppeEinladungListe::setAngenommen( int id )
- {
- for( int i = 0; i < anzahl; i++ )
- {
- GruppeEinladungAccount *tmp = accounts->z( i );
- if( tmp && tmp->getAccountId() == id )
- {
- tmp->setAngenommen();
- break;
- }
- }
- }
- void GruppeEinladungListe::remove( int id )
- {
- for( int i = 0; i < anzahl; i++ )
- {
- GruppeEinladungAccount *tmp = accounts->z( i );
- if( tmp && tmp->getAccountId() == id )
- {
- tmp->setRemove();
- break;
- }
- }
- }
- void GruppeEinladungListe::setAdmin( int admin )
- {
- this->admin = admin;
- for( int i = 0; i < anzahl; i++ )
- {
- GruppeEinladungAccount *tmp = accounts->z( i );
- if( tmp )
- tmp->setAdmin( admin );
- }
- }
- bool GruppeEinladungListe::tick( double tickVal )
- {
- rend |= einladenName->tick( tickVal );
- rend |= einladen->tick( tickVal );
- rend |= scroll->getRend();
- this->tickVal += tickVal * 100;
- int val = (int)this->tickVal;
- if( val < 1 )
- {
- bool ret = rend;
- rend = 0;
- return ret;
- }
- if( val > 4 )
- val = 4;
- this->tickVal -= val;
- if( admin == loginClient->getAccountId() )
- {
- if( einladungHöhe < 30 )
- {
- einladungHöhe += val;
- if( einladungHöhe > 30 )
- einladungHöhe = 30;
- rend = 1;
- }
- }
- else
- {
- if( einladungHöhe > 0 )
- {
- einladungHöhe -= val;
- if( einladungHöhe < 0 )
- einladungHöhe = 0;
- rend = 1;
- }
- }
- for( int i = 0; i < anzahl; i++ )
- {
- GruppeEinladungAccount *tmp = accounts->z( i );
- if( tmp )
- rend |= tmp->tick( tickVal );
- }
- for( int i = 0; i < anzahl; i++ )
- {
- GruppeEinladungAccount *tmp = accounts->z( i );
- if( !tmp->getHeight() )
- {
- accounts->remove( i );
- anzahl--;
- rend = 1;
- }
- }
- bool ret = rend;
- rend = 0;
- return ret;
- }
- void GruppeEinladungListe::doMausEreignis( MausEreignis & me )
- {
- int tmpX = me.mx;
- int tmpY = me.my;
- me.mx -= pos.x;
- me.my -= pos.y;
- if( einladungHöhe == 30 )
- {
- einladenName->doMausEreignis( me );
- bool ak = !me.verarbeitet;
- einladen->doMausEreignis( me );
- if( me.verarbeitet && ak )
- {
- if( me.id == ME_RLinks )
- {
- if( einladenName->zText()->getLength() )
- {
- int accountId = infoClient->getAccountId( einladenName->zText()->getText() );
- if( accountId )
- {
- if( !anmeldungClient )
- anmeldungClient = mainClient->createAnmeldungServerClient();
- if( !anmeldungClient )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- if( !anmeldungClient->verbinde() )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- else
- {
- if( !anmeldungClient->gruppeSpielerEinladen( accountId, gruppeId ) )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- else
- {
- einladenName->setText( "" );
- einladenName->setAuswahl( 0, 0 );
- rend = 1;
- }
- anmeldungClient->trenne( 0 );
- }
- }
- else
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( "Der Account wurde nicht gefunden." ),
- new Text( "Ok" ), 0 );
- }
- }
- }
- return;
- }
- }
- scroll->doMausMessage( 134, 1 + einladungHöhe, 15, 348 - einladungHöhe, me );
- me.my -= einladungHöhe + 1;
- for( int i = 0; i < anzahl; i++ )
- {
- GruppeEinladungAccount *tmp = accounts->z( i );
- if( tmp )
- {
- tmp->doMausEreignis( me );
- if( tmp->getRemove() )
- {
- accounts->remove( i );
- anzahl--;
- rend = 1;
- }
- me.my -= tmp->getHeight();
- }
- }
- me.mx = tmpX;
- me.my = tmpY;
- }
- void GruppeEinladungListe::doTastaturEreignis( TastaturEreignis & te )
- {
- bool b = !te.verarbeitet;
- einladenName->doTastaturEreignis( te );
- if( te.verarbeitet && b && te.id == TE_Release && te.taste == T_Enter )
- {
- if( einladenName->zText()->getLength() )
- {
- int accountId = infoClient->getAccountId( einladenName->zText()->getText() );
- if( accountId )
- {
- if( !anmeldungClient )
- anmeldungClient = mainClient->createAnmeldungServerClient();
- if( !anmeldungClient )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- if( !anmeldungClient->verbinde() )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- else
- {
- if( !anmeldungClient->gruppeSpielerEinladen( accountId, gruppeId ) )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- else
- {
- einladenName->setText( "" );
- einladenName->setAuswahl( 0, 0 );
- rend = 1;
- }
- anmeldungClient->trenne( 0 );
- }
- }
- else
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( "Der Account wurde nicht gefunden." ),
- new Text( "Ok" ), 0 );
- }
- }
- }
- }
- void GruppeEinladungListe::render( Bild & zRObj )
- {
- if( !zRObj.setDrawOptions( pos, gr ) )
- return;
- rahmen->render( zRObj );
- int rbr = rahmen->getRBreite();
- if( einladungHöhe )
- {
- if( zRObj.setDrawOptions( rbr, rbr, gr.x - rbr * 2, einladungHöhe - rbr * 2 ) )
- {
- einladenName->render( zRObj );
- einladen->render( zRObj );
- zRObj.releaseDrawOptions();
- }
- }
- if( !zRObj.setDrawOptions( rbr, einladungHöhe + rbr, gr.x - rbr * 2, gr.y - rbr * 2 ) )
- {
- zRObj.releaseDrawOptions();
- return;
- }
- scroll->render( 134, 0, 15, 348 - einladungHöhe, zRObj );
- int höhe = 0;
- for( int i = 0; i < anzahl; i++ )
- {
- GruppeEinladungAccount *tmp = accounts->z( i );
- if( tmp )
- {
- tmp->setSize( gr.x - 15 - rbr * 2 );
- tmp->render( höhe - scroll->getScroll(), zRObj );
- höhe += tmp->getHeight();
- }
- }
- scroll->update( höhe, gr.y - rbr * 2 - einladungHöhe );
- zRObj.releaseDrawOptions();
- zRObj.releaseDrawOptions();
- }
- // constant
- // Reference Counting
- GruppeEinladungListe *GruppeEinladungListe::getThis()
- {
- ref++;
- return this;
- }
- GruppeEinladungListe *GruppeEinladungListe::release()
- {
- ref--;
- if( !ref )
- delete this;
- return 0;
- }
- // Inhalt der GruppeAccountDaten Klasse aus Gruppe.h
- // Konstruktor
- GruppeAccountDaten::GruppeAccountDaten( Schrift * zSchrift )
- {
- Bild *nachrichtBild = bilder->get( "chat.ltdb/nachricht.png" );
- if( !nachrichtBild )
- {
- LTDBDatei *datei = new LTDBDatei();
- datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
- datei->leseDaten( 0 );
- nachrichtBild = datei->laden( 0, new Text( "nachricht.png" ) );
- datei->release();
- bilder->add( "chat.ltdb/nachricht.png", nachrichtBild->getThis() );
- }
- Bild *einladungBild = bilder->get( "chat.ltdb/neuerfreund.png" );
- if( !nachrichtBild )
- {
- LTDBDatei *datei = new LTDBDatei();
- datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
- datei->leseDaten( 0 );
- einladungBild = datei->laden( 0, new Text( "neuerfreund.png" ) );
- datei->release();
- bilder->add( "chat.ltdb/neuerfreund.png", einladungBild->getThis() );
- }
- Bild *ansehenBild = bilder->get( "chat.ltdb/ansehen.png" );
- if( !ansehenBild )
- {
- LTDBDatei *datei = new LTDBDatei();
- datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
- datei->leseDaten( 0 );
- ansehenBild = datei->laden( 0, new Text( "ansehen.png" ) );
- datei->release();
- bilder->add( "chat.ltdb/ansehen.png", ansehenBild->getThis() );
- }
- Bild *entfernenBild = bilder->get( "chat.ltdb/entfernen.png" );
- if( !entfernenBild )
- {
- LTDBDatei *datei = new LTDBDatei();
- datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
- datei->leseDaten( 0 );
- entfernenBild = datei->laden( 0, new Text( "entfernen.png" ) );
- datei->release();
- bilder->add( "chat.ltdb/entfernen.png", entfernenBild->getThis() );
- }
- rahmen = new LRahmen();
- rahmen->setFarbe( 0xFFFFFFFF );
- rahmen->setRamenBreite( 1 );
- auswahl = new AlphaFeld();
- auswahl->setFarbe( 0x0000FF00 );
- auswahl->setStrength( -2 );
- auswahl->setPosition( 1, 1 );
- name = initTextFeld( 1, 6, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, "" );
- punkte = initTextFeld( 101, 6, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, "0p" );
- nachrichtSenden = initKnopf( 0, 30, 20, 20, 0, 0, "" );
- nachrichtSenden->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
- nachrichtSenden->setHintergrundBildZ( nachrichtBild );
- initToolTip( nachrichtSenden, "Nachricht senden.", zSchrift->getThis(), hauptScreen );
- freundEinladung = initKnopf( 0, 30, 20, 20, 0, 0, "" );
- freundEinladung->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
- freundEinladung->setHintergrundBildZ( einladungBild );
- initToolTip( freundEinladung, "Freundeseinladung senden.", zSchrift->getThis(), hauptScreen );
- accountAnsehen = initKnopf( 0, 30, 20, 20, 0, 0, "" );
- accountAnsehen->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
- accountAnsehen->setHintergrundBildZ( ansehenBild );
- initToolTip( accountAnsehen, "Account ansehen.", zSchrift->getThis(), hauptScreen );
- kick = initKnopf( 0, 30, 20, 20, 0, 0, "" );
- kick->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
- kick->setHintergrundBildZ( entfernenBild );
- initToolTip( kick, "Diesen Spieler kicken.", zSchrift->getThis(), hauptScreen );
- tickVal = 0;
- mausIn = 0;
- remove = 0;
- gruppeId = 0;
- accountId = 0;
- admin = 0;
- höhe = 0;
- animation = 0x1;
- rend = 0;
- ref = 1;
- }
- // Destruktor
- GruppeAccountDaten::~GruppeAccountDaten()
- {
- rahmen->release();
- auswahl->release();
- name->release();
- punkte->release();
- nachrichtSenden->release();
- freundEinladung->release();
- accountAnsehen->release();
- kick->release();
- }
- // nicht constant
- void GruppeAccountDaten::setGruppeId( int gruppeId )
- {
- this->gruppeId = gruppeId;
- }
- void GruppeAccountDaten::setAccountId( int id )
- {
- accountId = id;
- name->setText( infoClient->getSpielerName( id ) );
- punkte->setText( "" );
- punkte->zText()->append( infoClient->getSpielerPunkte( id, infoClient->getSpielId( infoClient->getGruppenKarteId( gruppeId ) ) ) );
- punkte->zText()->append( "p" );
- rend = 1;
- }
- void GruppeAccountDaten::setSize( int x )
- {
- if( br != x )
- {
- br = x;
- rend = 1;
- }
- }
- void GruppeAccountDaten::entfernen()
- {
- animation &= ~0x1;
- }
- void GruppeAccountDaten::setAdmin( int admin )
- {
- this->admin = admin;
- rend = 1;
- }
- bool GruppeAccountDaten::tick( double tickVal )
- {
- rend |= name->tick( tickVal );
- rend |= punkte->tick( tickVal );
- rend |= nachrichtSenden->tick( tickVal );
- rend |= accountAnsehen->tick( tickVal );
- rend |= freundEinladung->tick( tickVal );
- rend |= kick->tick( tickVal );
- this->tickVal += tickVal * 100;
- int val = (int)this->tickVal;
- if( val < 1 )
- {
- bool ret = rend;
- rend = 0;
- return ret;
- }
- if( val > 4 )
- val = 4;
- this->tickVal -= val;
- if( admin == accountId )
- {
- int r = ( auswahl->getFarbe() >> 16 ) & 0xFF;
- if( r < 200 )
- {
- r += val;
- if( r > 200 )
- r = 200;
- auswahl->setFarbe( ( auswahl->getFarbe() & 0xFF00FFFF ) | ( ( r << 16 ) & 0xFF0000 ) );
- rend = 1;
- }
- }
- else
- {
- int r = ( auswahl->getFarbe() >> 16 ) & 0xFF;
- if( r > 0 )
- {
- if( r - val < 0 )
- r = 0;
- else
- r -= val;
- auswahl->setFarbe( ( auswahl->getFarbe() & 0xFF00FFFF ) | ( ( r << 16 ) & 0xFF0000 ) );
- rend = 1;
- }
- }
- if( ( animation | 0x1 ) == animation )
- {
- if( höhe < 30 )
- {
- höhe += val;
- if( höhe > 30 )
- höhe = 30;
- rend = 1;
- }
- if( mausIn )
- {
- if( höhe < 50 )
- {
- höhe += val;
- if( höhe > 50 )
- höhe = 50;
- rend = 1;
- }
- int a = ( auswahl->getFarbe() >> 24 ) & 0xFF;
- if( a < 50 )
- {
- a += val;
- if( a > 50 )
- a = 50;
- auswahl->setFarbe( ( ( a << 24 ) & 0xFF000000 ) | ( auswahl->getFarbe() & 0xFFFFFF ) );
- rend = 1;
- }
- }
- else
- {
- if( höhe > 30 )
- {
- höhe -= val;
- if( höhe < 30 )
- höhe = 30;
- rend = 1;
- }
- int a = ( auswahl->getFarbe() >> 24 ) & 0xFF;
- if( a > 0 )
- {
- if( a - val < 0 )
- a = 0;
- else
- a -= val;
- auswahl->setFarbe( ( ( a << 24 ) & 0xFF000000 ) | ( auswahl->getFarbe() & 0xFFFFFF ) );
- rend = 1;
- }
- }
- if( accountId != loginClient->getAccountId() )
- {
- if( nachrichtSenden->getBreite() < 20 )
- {
- nachrichtSenden->setSize( nachrichtSenden->getBreite() + val, nachrichtSenden->getHeight() );
- if( nachrichtSenden->getBreite() > 20 )
- nachrichtSenden->setSize( 20, nachrichtSenden->getHeight() );
- rend = 1;
- }
- }
- else
- {
- if( nachrichtSenden->getBreite() > 0 )
- {
- nachrichtSenden->setSize( nachrichtSenden->getBreite() - val, nachrichtSenden->getHeight() );
- if( nachrichtSenden->getBreite() < 0 )
- nachrichtSenden->setSize( 0, nachrichtSenden->getHeight() );
- rend = 1;
- }
- }
- if( accountAnsehen->getBreite() < 20 )
- {
- accountAnsehen->setSize( accountAnsehen->getBreite() + val, accountAnsehen->getHeight() );
- if( accountAnsehen->getBreite() > 20 )
- accountAnsehen->setSize( 20, accountAnsehen->getHeight() );
- rend = 1;
- }
- if( accountId == loginClient->getAccountId() || nachLogin->zFreundesListe()->istFreund( accountId ) )
- {
- if( freundEinladung->getBreite() > 0 )
- {
- freundEinladung->setSize( freundEinladung->getBreite() - val, freundEinladung->getHeight() );
- if( freundEinladung->getBreite() < 0 )
- freundEinladung->setSize( 0, freundEinladung->getHeight() );
- rend = 1;
- }
- }
- else
- {
- if( freundEinladung->getBreite() < 20 )
- {
- freundEinladung->setSize( freundEinladung->getBreite() + val, freundEinladung->getHeight() );
- if( freundEinladung->getBreite() > 20 )
- freundEinladung->setSize( 20, freundEinladung->getHeight() );
- rend = 1;
- }
- }
- if( accountId == loginClient->getAccountId() || admin != loginClient->getAccountId() )
- {
- if( kick->getBreite() > 0 )
- {
- kick->setSize( kick->getBreite() - val, kick->getHeight() );
- if( kick->getBreite() < 0 )
- kick->setSize( 0, kick->getHeight() );
- rend = 1;
- }
- }
- else
- {
- if( kick->getBreite() < 20 )
- {
- kick->setSize( kick->getBreite() + val, kick->getHeight() );
- if( kick->getBreite() > 20 )
- kick->setSize( 20, kick->getHeight() );
- rend = 1;
- }
- }
- }
- else
- {
- if( höhe > 0 )
- {
- höhe -= val;
- if( höhe <= 0 )
- {
- höhe = 0;
- remove = 1;
- }
- rend = 1;
- }
- }
- bool ret = rend;
- rend = 0;
- return ret;
- }
- void GruppeAccountDaten::doMausEreignis( MausEreignis & me )
- {
- if( me.mx < 0 || me.my < 0 || me.mx > br || me.my > höhe )
- mausIn = 0;
- else
- mausIn = 1;
- bool ak = !me.verarbeitet;
- nachrichtSenden->doMausEreignis( me );
- int aktion = ( me.verarbeitet && ak ) ? 1 : 0;
- accountAnsehen->doMausEreignis( me );
- aktion = ( me.verarbeitet && ak && !aktion ) ? 2 : aktion;
- freundEinladung->doMausEreignis( me );
- aktion = ( me.verarbeitet && ak && !aktion ) ? 3 : aktion;
- kick->doMausEreignis( me );
- aktion = ( me.verarbeitet && ak && !aktion ) ? 4 : aktion;
- if( me.id != ME_RLinks )
- return;
- switch( aktion )
- {
- case 1:
- nachLogin->zChatLeiste()->addChat( accountId, 0 );
- break;
- case 2:
- if( nachLogin->zAccountAnsehenFenster()->setSpielerDetails( accountId, 2 ) )
- {
- MausEreignis me = { ME_RLinks, 0, 0, 0, 0, 0 };
- nachLogin->zTitelLeiste()->druckAccountAnsehen( me );
- }
- break;
- case 3:
- chatClient->freundesAnfrage( accountId );
- break;
- case 4:
- if( !anmeldungClient )
- anmeldungClient = mainClient->createAnmeldungServerClient();
- if( !anmeldungClient )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- if( !anmeldungClient->verbinde() )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- else
- {
- if( !anmeldungClient->kickSpielerAusGruppe( accountId, gruppeId ) )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- anmeldungClient->trenne( 0 );
- }
- break;
- }
- }
- void GruppeAccountDaten::render( int y, Bild & zrObj )
- {
- if( !zrObj.setDrawOptions( 0, y, br, höhe ) )
- return;
- rahmen->setSize( br, höhe );
- rahmen->render( zrObj );
- int rbr = rahmen->getRBreite();
- auswahl->setPosition( rbr, rbr );
- auswahl->setSize( br - rbr * 2, höhe - rbr * 2 );
- auswahl->render( zrObj );
- name->render( zrObj );
- punkte->render( zrObj );
- if( !zrObj.setDrawOptions( rbr, rbr, br - rbr * 2, höhe - rbr * 2 ) )
- {
- zrObj.releaseDrawOptions();
- return;
- }
- int b = kick->getBreite();
- kick->setPosition( br - rbr - b, 30 );
- kick->render( zrObj );
- b += freundEinladung->getBreite();
- freundEinladung->setPosition( br - rbr - b, 30 );
- freundEinladung->render( zrObj );
- b += accountAnsehen->getBreite();
- accountAnsehen->setPosition( br - rbr - b, 30 );
- accountAnsehen->render( zrObj );
- b += nachrichtSenden->getBreite();
- nachrichtSenden->setPosition( br - rbr - b, 30 );
- nachrichtSenden->render( zrObj );
- zrObj.releaseDrawOptions();
- zrObj.releaseDrawOptions();
- }
- // constant
- bool GruppeAccountDaten::getRemove() const
- {
- return remove;
- }
- int GruppeAccountDaten::getAccountId() const
- {
- return accountId;
- }
- int GruppeAccountDaten::getHeight() const
- {
- return höhe;
- }
- // Reference Counting
- GruppeAccountDaten *GruppeAccountDaten::getThis()
- {
- ref++;
- return this;
- }
- GruppeAccountDaten *GruppeAccountDaten::release()
- {
- ref--;
- if( !ref )
- delete this;
- return 0;
- }
- // Inhalt der GruppeAccountListe Klasse aus Gruppe.h
- // Konstruktor
- GruppeAccountListe::GruppeAccountListe( Schrift * zSchrift )
- {
- schrift = zSchrift->getThis();
- pos = Punkt( 0, 0 );
- gr = Punkt( 200, 350 );
- rahmen = new LRahmen();
- rahmen->setFarbe( 0xFFFFFFFF );
- rahmen->setRamenBreite( 1 );
- rahmen->setSize( 200, 350 );
- scroll = new VScrollBar();
- accounts = new RCArray< GruppeAccountDaten >();
- anzahl = 0;
- gruppeId = 0;
- admin = 0;
- rend = 0;
- ref = 1;
- }
- // Destruktor
- GruppeAccountListe::~GruppeAccountListe()
- {
- schrift->release();
- rahmen->release();
- scroll->release();
- accounts->release();
- }
- // nicht constant
- void GruppeAccountListe::reset()
- {
- accounts->leeren();
- anzahl = 0;
- gruppeId = 0;
- admin = 0;
- rend = 1;
- }
- void GruppeAccountListe::setGruppeId( int gruppeId )
- {
- this->gruppeId = gruppeId;
- for( int i = 0; i < anzahl; i++ )
- accounts->z( i )->setGruppeId( gruppeId );
- }
- void GruppeAccountListe::addAccount( int id )
- {
- GruppeAccountDaten *tmp = new GruppeAccountDaten( schrift );
- tmp->setGruppeId( gruppeId );
- tmp->setAccountId( id );
- tmp->setAdmin( admin );
- accounts->add( tmp, anzahl );
- anzahl++;
- rend = 1;
- }
- void GruppeAccountListe::removeAccount( int id )
- {
- for( int i = 0; i < anzahl; i++ )
- {
- GruppeAccountDaten *tmp = accounts->z( i );
- if( tmp && tmp->getAccountId() == id )
- {
- tmp->entfernen();
- break;
- }
- }
- }
- void GruppeAccountListe::setAdmin( int admin )
- {
- this->admin = admin;
- for( int i = 0; i < anzahl; i++ )
- {
- GruppeAccountDaten *tmp = accounts->z( i );
- if( tmp )
- tmp->setAdmin( admin );
- }
- }
- bool GruppeAccountListe::tick( double tickVal )
- {
- rend |= scroll->getRend();
- for( int i = 0; i < anzahl; i++ )
- {
- GruppeAccountDaten *tmp = accounts->z( i );
- if( tmp )
- rend |= tmp->tick( tickVal );
- }
- bool ret = rend;
- rend = 0;
- return ret;
- }
- void GruppeAccountListe::doMausEreignis( MausEreignis & me )
- {
- int tmpX = me.mx;
- int tmpY = me.my;
- me.mx -= pos.x;
- me.my -= pos.y;
- scroll->doMausMessage( 184, 1, 15, 248, me );
- for( int i = 0; i < anzahl; i++ )
- {
- GruppeAccountDaten *tmp = accounts->z( i );
- if( tmp )
- {
- tmp->doMausEreignis( me );
- me.my -= tmp->getHeight();
- if( tmp->getRemove() )
- {
- accounts->remove( i );
- anzahl--;
- i--;
- rend = 1;
- }
- }
- }
- me.mx = tmpX;
- me.my = tmpY;
- }
- void GruppeAccountListe::render( Bild & zRObj )
- {
- if( !zRObj.setDrawOptions( pos, gr ) )
- return;
- rahmen->render( zRObj );
- int rbr = rahmen->getRBreite();
- scroll->render( gr.x - 15 - rbr, 1, 15, gr.y - rbr * 2, zRObj );
- if( !zRObj.setDrawOptions( rbr, rbr, gr.x - rbr * 2, gr.y - rbr * 2 ) )
- {
- zRObj.releaseDrawOptions();
- return;
- }
- int höhe = 0;
- for( int i = 0; i < anzahl; i++ )
- {
- GruppeAccountDaten *tmp = accounts->z( i );
- if( tmp )
- {
- tmp->setSize( gr.x - 15 - rbr * 2 );
- tmp->render( höhe - scroll->getScroll(), zRObj );
- höhe += tmp->getHeight();
- }
- }
- zRObj.releaseDrawOptions();
- zRObj.releaseDrawOptions();
- scroll->update( höhe, gr.y - rbr * 2 );
- }
- // constant
- // Reference Counting
- GruppeAccountListe *GruppeAccountListe::getThis()
- {
- ref++;
- return this;
- }
- GruppeAccountListe *GruppeAccountListe::release()
- {
- ref--;
- if( !ref )
- delete this;
- return 0;
- }
- // Inhalt der GruppeChat Klasse aus Gruppe.h
- // Konstruktor
- GruppeChat::GruppeChat( Schrift * zSchrift )
- {
- Bild *sendenBild = bilder->get( "chat.ltdb/senden.png" );
- if( !sendenBild )
- {
- LTDBDatei *datei = new LTDBDatei();
- datei->setDatei( new Text( "data/client/bilder/chat.ltdb" ) );
- datei->leseDaten( 0 );
- sendenBild = datei->laden( 0, new Text( "senden.png" ) );
- datei->release();
- bilder->add( "chat.ltdb/senden.png", sendenBild->getThis() );
- }
- pos = Punkt( 0, 350 );
- gr = Punkt( 750, 200 );
- rahmen = new LRahmen();
- rahmen->setFarbe( 0xFFFFFFFF );
- rahmen->setRamenBreite( 1 );
- rahmen->setSize( 750, 200 );
- nachricht = initTextFeld( 2, 176, 724, 20, zSchrift, TextFeld::Style::TextFeld, "" );
- initToolTip( nachricht, "Nachricht an die Gruppe senden.", zSchrift->getThis(), hauptScreen );
- senden = initKnopf( 726, 176, 20, 20, 0, 0, "" );
- senden->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
- senden->setHintergrundBildZ( sendenBild );
- initToolTip( senden, "Diese Nachricht an die Gruppe senden.", zSchrift->getThis(), hauptScreen );
- verlauf = initTextFeld( 2, 2, 746, 174, zSchrift, TextFeld::Style::TextGebiet, "" );
- verlauf->removeStyle( TextFeld::Style::Erlaubt );
- verlauf->updateVScroll();
- verlauf->setVertikalKlickScroll( 5 );
- gruppeId = 0;
- rend = 0;
- ref = 1;
- }
- // Destruktor
- GruppeChat::~GruppeChat()
- {
- rahmen->release();
- nachricht->release();
- senden->release();
- verlauf->release();
- }
- // nicht constant
- void GruppeChat::reset()
- {
- gruppeId = 0;
- verlauf->setText( "" );
- verlauf->updateVScroll();
- nachricht->setText( "" );
- rend = 1;
- }
- void GruppeChat::setGruppeId( int gruppeId )
- {
- this->gruppeId = gruppeId;
- }
- void GruppeChat::gruppeNachricht( const char *nachricht )
- {
- verlauf->addZeile( nachricht );
- verlauf->updateVScroll();
- rend = 1;
- }
- bool GruppeChat::tick( double tickVal )
- {
- rend |= verlauf->tick( tickVal );
- rend |= nachricht->tick( tickVal );
- rend |= senden->tick( tickVal );
- bool ret = rend;
- rend = 0;
- return ret;
- }
- void GruppeChat::doMausEreignis( MausEreignis & me )
- {
- me.mx -= pos.x;
- me.my -= pos.y;
- verlauf->doMausEreignis( me );
- nachricht->doMausEreignis( me );
- bool ak = !me.verarbeitet;
- senden->doMausEreignis( me );
- int aktion = ( me.verarbeitet && ak ) ? 1 : 0;
- if( me.id != ME_RLinks )
- {
- me.mx += pos.x;
- me.my += pos.y;
- return;
- }
- if( aktion )
- {
- if( !anmeldungClient )
- anmeldungClient = mainClient->createAnmeldungServerClient();
- if( !anmeldungClient )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- if( !anmeldungClient->verbinde() )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- else
- {
- if( anmeldungClient->gruppeNachricht( gruppeId, nachricht->zText()->getText() ) )
- {
- nachricht->setText( "" );
- nachricht->setAuswahl( 0, 0 );
- rend = 1;
- }
- else
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- anmeldungClient->trenne( 0 );
- }
- }
- me.mx += pos.x;
- me.my += pos.y;
- }
- void GruppeChat::doTastaturEreignis( TastaturEreignis & te )
- {
- bool b = te.verarbeitet;
- nachricht->doTastaturEreignis( te );
- if( te.verarbeitet && !b && te.id == TE_Release && te.taste == T_Enter )
- {
- if( !anmeldungClient )
- anmeldungClient = mainClient->createAnmeldungServerClient();
- if( !anmeldungClient )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- if( !anmeldungClient->verbinde() )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- else
- {
- if( anmeldungClient->gruppeNachricht( gruppeId, nachricht->zText()->getText() ) )
- {
- nachricht->setText( "" );
- nachricht->setAuswahl( 0, 0 );
- rend = 1;
- }
- else
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- anmeldungClient->trenne( 0 );
- }
- }
- }
- void GruppeChat::render( Bild & zRObj )
- {
- if( !zRObj.setDrawOptions( pos.x, pos.y, gr.x, gr.y ) )
- return;
- verlauf->render( zRObj );
- nachricht->render( zRObj );
- senden->render( zRObj );
- zRObj.releaseDrawOptions();
- }
- // constant
- // Reference Counting
- GruppeChat *GruppeChat::getThis()
- {
- ref++;
- return this;
- }
- GruppeChat *GruppeChat::release()
- {
- ref--;
- if( !ref )
- delete this;
- return 0;
- }
- // Inhalt der GruppeAnmeldung Klasse aus Gruppe.h
- // Konstruktor
- GruppeAnmeldung::GruppeAnmeldung( Schrift * zSchrift )
- {
- pos = Punkt( 750, 350 );
- gr = Punkt( 200, 200 );
- rahmen = new LRahmen();
- rahmen->setFarbe( 0xFFFFFFFF );
- rahmen->setRamenBreite( 1 );
- rahmen->setSize( 200, 200 );
- spielerHinzufügen = initKontrollKnopf( 25, 45, 150, 20, zSchrift, KontrollKnopf::Style::Normal, "Spieler hinzufügen" );
- spielerHinzufügen->removeStyle( KontrollKnopf::Style::Erlaubt );
- spielerHinzufügen->setMausEreignis( _ret1ME );
- initToolTip( spielerHinzufügen, "Es werden nur Spieler aus dieser Gruppe mit ins Spiel kommen.", zSchrift->getThis(), hauptScreen );
- angemeldet = initKontrollKnopf( 25, 75, 150, 20, zSchrift, KontrollKnopf::Style::Normal, "in Warteschlange" );
- angemeldet->removeStyle( KontrollKnopf::Style::Erlaubt );
- angemeldet->setMausEreignis( _ret1ME );
- initToolTip( angemeldet, "Die Gruppe befindet sich momentan nicht in der Warteschlange.", zSchrift->getThis(), hauptScreen );
- zeit = initTextFeld( 0, 105, 200, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, "Zeit in Warteschlange: " );
- gruppeVerlassen = initKnopf( 40, 135, 120, 20, zSchrift, Knopf::Style::Normal, "Gruppe verlassen" );
- admin = 0;
- time = 0;
- gruppeId = 0;
- rend = 0;
- ref = 1;
- }
- // Destruktor
- GruppeAnmeldung::~GruppeAnmeldung()
- {
- rahmen->release();
- spielerHinzufügen->release();
- angemeldet->release();
- zeit->release();
- gruppeVerlassen->release();
- }
- // nicht constant
- void GruppeAnmeldung::reset()
- {
- spielerHinzufügen->removeStyle( KontrollKnopf::Style::Selected );
- angemeldet->removeStyle( KontrollKnopf::Style::Selected );
- admin = 0;
- time = 0;
- gruppeId = 0;
- rend = 1;
- }
- void GruppeAnmeldung::setGruppeId( int gruppeId )
- {
- this->gruppeId = gruppeId;
- spielerHinzufügen->setStyle( KontrollKnopf::Style::Selected, infoClient->getGruppeSpielerHinzufügen( gruppeId ) );
- rend = 1;
- }
- void GruppeAnmeldung::setAdmin( int admin )
- {
- this->admin = admin;
- if( admin == loginClient->getAccountId() )
- {
- spielerHinzufügen->addStyle( KontrollKnopf::Style::Erlaubt );
- angemeldet->addStyle( KontrollKnopf::Style::Erlaubt );
- }
- else
- {
- spielerHinzufügen->removeStyle( KontrollKnopf::Style::Erlaubt );
- angemeldet->removeStyle( KontrollKnopf::Style::Erlaubt );
- }
- rend = 1;
- }
- void GruppeAnmeldung::setSpielerHinzufügen( bool spielerHinzufügen )
- {
- this->spielerHinzufügen->setStyle( KontrollKnopf::Style::Selected, spielerHinzufügen );
- // TODO
- /*if( spielerHinzufügen )
- this->spielerHinzufügen->zToolTip()->setText( "Es kommen auch andere Spieler mit ins Spiel,\ndie nicht in dieser Gruppe sind." );
- else
- this->spielerHinzufügen->zToolTip()->setText( "Es werden nur Spieler aus dieser Gruppe mit ins Spiel kommen." );*/
- rend = 1;
- }
- void GruppeAnmeldung::setAngemeldet( bool angemeldet )
- {
- this->angemeldet->setStyle( KontrollKnopf::Style::Selected, angemeldet );
- // TODO
- /*
- if( angemeldet )
- this->angemeldet->zToolTip()->setText( "Die Gruppe befindet sich in der Warteschlange." );
- else
- this->angemeldet->zToolTip()->setText( "Die Gruppe befindet sich momentan nicht in der Warteschlange." );*/
- time = 0;
- rend = 1;
- }
- void GruppeAnmeldung::zurückInWarteschlange( int stunden, int minuten, int sekunden )
- {
- this->angemeldet->setStyle( KontrollKnopf::Style::Selected, 1 );
- time = sekunden + minuten * 60 + stunden * 60 * 60;
- rend = 1;
- }
- void GruppeAnmeldung::spielGefunden()
- {
- this->angemeldet->setStyle( KontrollKnopf::Style::Selected, 0 );
- time = 0;
- rend = 1;
- }
- bool GruppeAnmeldung::tick( double tickVal )
- {
- if( angemeldet->hatStyle( KontrollKnopf::Style::Selected ) )
- {
- if( (int)( time / 1 ) != (int)( ( time + tickVal ) / 1 ) )
- rend = 1;
- time += tickVal;
- }
- if( rend )
- {
- zeit->setText( "Zeit in Warteschlange: " );
- zeit->zText()->append( (int)( time / 60 / 60 ) );
- zeit->zText()->append( ":" );
- zeit->zText()->append( (int)( time / 60 ) % 60 );
- zeit->zText()->append( ":" );
- zeit->zText()->append( (int)( time ) % 60 );
- }
- rend |= spielerHinzufügen->tick( tickVal );
- rend |= angemeldet->tick( tickVal );
- rend |= gruppeVerlassen->tick( tickVal );
- bool ret = rend;
- rend = 0;
- return ret;
- }
- void GruppeAnmeldung::doMausEreignis( MausEreignis & me )
- {
- me.mx -= pos.x;
- me.my -= pos.y;
- bool ak = !me.verarbeitet;
- int aktion = 0;
- if( admin == loginClient->getAccountId() )
- {
- spielerHinzufügen->doMausEreignis( me );
- aktion = ( me.verarbeitet && admin == loginClient->getAccountId() && ak ) ? 1 : aktion;
- angemeldet->doMausEreignis( me );
- aktion = ( me.verarbeitet && admin == loginClient->getAccountId() && ak && !aktion ) ? 2 : aktion;
- }
- gruppeVerlassen->doMausEreignis( me );
- aktion = ( me.verarbeitet && ak && !aktion ) ? 3 : aktion;
- if( me.id != ME_RLinks )
- {
- me.mx += pos.x;
- me.my += pos.y;
- return;
- }
- switch( aktion )
- {
- case 1:
- if( !anmeldungClient )
- anmeldungClient = mainClient->createAnmeldungServerClient();
- if( !anmeldungClient )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- spielerHinzufügen->setStyle( KontrollKnopf::Style::Selected, spielerHinzufügen->hatStyleNicht( KontrollKnopf::Style::Selected ) );
- rend = 1;
- }
- if( !anmeldungClient->verbinde() )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- spielerHinzufügen->setStyle( KontrollKnopf::Style::Selected, spielerHinzufügen->hatStyleNicht( KontrollKnopf::Style::Selected ) );
- rend = 1;
- }
- else
- {
- if( !anmeldungClient->gruppeSpielStarten( gruppeId, spielerHinzufügen->hatStyleNicht( KontrollKnopf::Style::Selected ) ) )
- {
- spielerHinzufügen->setStyle( KontrollKnopf::Style::Selected, spielerHinzufügen->hatStyleNicht( KontrollKnopf::Style::Selected ) );
- rend = 1;
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- anmeldungClient->trenne( 0 );
- }
- break;
- case 2:
- if( !anmeldungClient )
- anmeldungClient = mainClient->createAnmeldungServerClient();
- if( !anmeldungClient )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- angemeldet->setStyle( KontrollKnopf::Style::Selected, angemeldet->hatStyleNicht( KontrollKnopf::Style::Selected ) );
- rend = 1;
- }
- if( !anmeldungClient->verbinde() )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- angemeldet->setStyle( KontrollKnopf::Style::Selected, angemeldet->hatStyleNicht( KontrollKnopf::Style::Selected ) );
- rend = 1;
- }
- else
- {
- if( angemeldet->hatStyle( KontrollKnopf::Style::Selected ) )
- {
- if( !anmeldungClient->gruppeAnmelden( gruppeId ) )
- {
- angemeldet->setStyle( KontrollKnopf::Style::Selected, angemeldet->hatStyleNicht( KontrollKnopf::Style::Selected ) );
- rend = 1;
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- }
- else
- {
- if( !anmeldungClient->gruppeAbmelden( gruppeId ) )
- {
- angemeldet->setStyle( KontrollKnopf::Style::Selected, angemeldet->hatStyleNicht( KontrollKnopf::Style::Selected ) );
- rend = 1;
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- }
- anmeldungClient->trenne( 0 );
- }
- break;
- case 3:
- if( !anmeldungClient )
- anmeldungClient = mainClient->createAnmeldungServerClient();
- if( !anmeldungClient )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( mainClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- rend = 1;
- }
- if( !anmeldungClient->verbinde() )
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- rend = 1;
- }
- else
- {
- if( anmeldungClient->gruppeVerlassen( gruppeId ) )
- nachLogin->zSpielenFenster()->gruppeVerlassen();
- else
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( anmeldungClient->getLetzterFehler() ),
- new Text( "Ok" ), 0 );
- }
- anmeldungClient->trenne( 0 );
- }
- break;
- }
- me.mx += pos.x;
- me.my += pos.y;
- }
- void GruppeAnmeldung::render( Bild & zRObj )
- {
- if( !zRObj.setDrawOptions( pos.x, pos.y, gr.x, gr.y ) )
- return;
- rahmen->render( zRObj );
- spielerHinzufügen->render( zRObj );
- angemeldet->render( zRObj );
- zeit->render( zRObj );
- gruppeVerlassen->render( zRObj );
- zRObj.releaseDrawOptions();
- }
- // constant
- // Reference Counting
- GruppeAnmeldung *GruppeAnmeldung::getThis()
- {
- ref++;
- return this;
- }
- GruppeAnmeldung *GruppeAnmeldung::release()
- {
- ref--;
- if( !ref )
- delete this;
- return 0;
- }
- void GruppeKarteKSGSAktion( void *p, RCArray< KSGSVariable > * parameter, KSGSVariable * *retVal )
- {
- if( !p )
- return;
- ( (GruppeKarte *)p )->ksgsAktion( parameter, retVal );
- }
- // Inhalt der GruppeKarte Klasse aus Gruppe.h
- // Konstruktor
- GruppeKarte::GruppeKarte( Schrift * zSchrift )
- {
- schrift = zSchrift;
- tr = new TextRenderer( schrift->getThis() );
- pos = Punkt( 350, 0 );
- gr = Punkt( 600, 350 );
- rahmen = new LRahmen();
- rahmen->setFarbe( 0xFFFFFFFF );
- rahmen->setRamenBreite( 1 );
- rahmen->setSize( 350, 350 );
- rahmen->setPosition( 248, 0 );
- info = 0;
- ksgs = dllDateien->ladeDLL( "KSGScript.dll", "data/bin/KSGScript.dll" );
- if( ksgs )
- {
- KSGSGetZeichnung getKSGScript = (KSGSGetZeichnung)GetProcAddress( ksgs, KSGS_START_FUNKTION );
- if( getKSGScript )
- {
- info = getKSGScript();
- info->setBildschirmZ( hauptScreen->getThis() );
- info->setSchriftZ( schrift->getThis() );
- info->setSize( 248, 350 );
- info->setRückrufParam( this );
- info->setRückrufFunktion( GruppeKarteKSGSAktion );
- }
- else
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ),
- new Text( "Der Einstiegspunkt '" KSGS_START_FUNKTION "' in der DLL-Datei "
- "'data/bin/KSGScript.dll' konnte nicht gefunden werden." ),
- new Text( "Ok" ), 0 );
- }
- }
- else
- {
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ),
- new Text( "Die DLL-Datei 'data/bin/KSGScript.dll' konnte nicht geladen werden." ),
- new Text( "Ok" ), 0 );
- }
- hintergrund = 0;
- fehler = 0;
- alpha1 = 0;
- alpha2 = 0;
- ladenZeit = 0;
- tickVal = 0;
- ladeBild = 0;
- karteId = 0;
- gruppeId = 0;
- exit = 0;
- geladen = 0;
- rend = 0;
- ref = 1;
- }
- // Destruktor
- GruppeKarte::~GruppeKarte()
- {
- exit = 1;
- warteAufThread( 5000 );
- if( run )
- ende();
- rahmen->release();
- if( info )
- {
- info->zurücksetzen();
- info->release();
- }
- if( hintergrund )
- hintergrund->release();
- if( fehler )
- fehler->release();
- if( schrift )
- schrift->release();
- tr->release();
- if( ksgs )
- dllDateien->releaseDLL( "KSGScript.dll" );
- }
- // nicht constant
- void GruppeKarte::reset()
- {
- if( info )
- info->zurücksetzen();
- if( hintergrund )
- hintergrund = hintergrund->release();
- if( fehler )
- fehler = (TextFeld *)fehler->release();
- if( run )
- {
- exit = 1;
- warteAufThread( 5000 );
- if( run )
- ende();
- }
- geladen = 0;
- alpha1 = 0;
- alpha2 = 0;
- ladenZeit = 0;
- tickVal = 0;
- ladeBild = 0;
- karteId = 0;
- gruppeId = 0;
- exit = 0;
- rend = 1;
- }
- void GruppeKarte::ksgsAktion( RCArray< KSGSVariable > * parameter, KSGSVariable * *retVal )
- {
- }
- void GruppeKarte::setGruppeId( int gruppeId )
- {
- this->gruppeId = gruppeId;
- if( run )
- {
- exit = 1;
- warteAufThread( 5000 );
- if( run )
- ende();
- exit = 0;
- }
- geladen = 0;
- rend = 1;
- start();
- }
- bool GruppeKarte::tick( double tickVal )
- {
- if( !gruppeId )
- return 0;
- if( info )
- rend |= info->tick( tickVal );
- ladenZeit += tickVal;
- if( ladenZeit >= 1 / 30.0 )
- {
- ladenZeit -= 1 / 30.0;
- if( ladeAnimation &&ladeAnimation->zAnimationData() )
- {
- if( alpha1 )
- rend = 1;
- ladeBild++;
- if( ladeBild >= ladeAnimation->zAnimationData()->getBildAnzahl() )
- ladeBild = 0;
- }
- }
- this->tickVal += tickVal * 300;
- int val = (int)this->tickVal;
- if( val < 1 )
- {
- bool ret = rend;
- rend = 0;
- return ret;
- }
- if( val > 10 )
- val = 10;
- this->tickVal -= val;
- if( !geladen && !fehler )
- {
- if( alpha1 != 255 || alpha2 != 0 )
- rend = 1;
- if( alpha1 + val > 255 )
- alpha1 = 255;
- else
- alpha1 += val;
- if( alpha2 - val < 0 )
- alpha2 = 0;
- else
- alpha2 -= val;
- }
- else
- {
- if( alpha1 != 0 || alpha2 != 255 )
- rend = 1;
- if( alpha1 - val < 0 )
- alpha1 = 0;
- else
- alpha1 -= val;
- if( alpha2 + val > 255 )
- alpha2 = 255;
- else
- alpha2 += val;
- }
- bool ret = rend;
- rend = 0;
- return ret;
- }
- void GruppeKarte::doMausEreignis( MausEreignis & me )
- {
- me.mx -= pos.x;
- me.my -= pos.y;
- if( info )
- info->doMausEreignis( me );
- me.mx += pos.x;
- me.my += pos.y;
- }
- void GruppeKarte::render( Bild & zrObj )
- {
- int x = pos.x;
- int y = pos.y;
- if( !zrObj.setDrawOptions( x, y, gr.x, gr.y ) )
- return;
- if( alpha1 != 0 && ladeAnimation && ladeAnimation->zAnimationData() )
- {
- Bild *tmp = ladeAnimation->zAnimationData()->zBild( ladeBild );
- if( tmp )
- {
- zrObj.setAlpha( alpha1 );
- zrObj.drawBild( gr.x / 2 - tmp->getBreite() / 2, gr.y / 2 - tmp->getHeight() / 2, tmp->getBreite(), tmp->getHeight(), *tmp );
- zrObj.releaseAlpha();
- }
- }
- if( alpha2 != 0 )
- {
- zrObj.setAlpha( alpha2 );
- if( geladen )
- {
- if( info )
- info->render( zrObj );
- rahmen->render( zrObj );
- zrObj.drawBild( 248 + rahmen->getRBreite(), rahmen->getRBreite(),
- rahmen->getBreite() - rahmen->getRBreite() * 2, rahmen->getHeight() - rahmen->getRBreite() * 2, *hintergrund );
- }
- else if( fehler )
- fehler->render( zrObj );
- zrObj.releaseAlpha();
- }
- zrObj.releaseDrawOptions();
- }
- void GruppeKarte::thread()
- {
- if( info )
- info->zurücksetzen();
- if( hintergrund )
- hintergrund = hintergrund->release();
- if( fehler )
- fehler = (TextFeld *)fehler->release();
- karteId = infoClient->getGruppenKarteId( gruppeId );
- if( !karteId )
- {
- run = 0;
- return;
- }
- KartenLeser *karte = KartenLeser::getInstance();
- karte->lock();
- karte->setKarteId( karteId );
- hintergrund = karte->getKartenVorschauBild();
- if( exit )
- {
- if( hintergrund )
- hintergrund = hintergrund->release();
- karte->unlock();
- karte->release();
- run = 0;
- return;
- }
- if( !hintergrund )
- {
- Text *f = new Text( karte->getLetzterFehler() );
- tr->setSchriftSize( 12 );
- int br = tr->getTextBreite( f->getText() );
- int hö = tr->getTextHeight( f->getText() );
- fehler = initTextFeld( gr.x / 2 - ( br + 10 ) / 2, gr.y / 2 - ( hö + 4 ) / 2, br + 10, hö + 4,
- schrift, TextFeld::Style::Text | TextFeld::Style::Center, f->getText() );
- f->release();
- karte->unlock();
- karte->release();
- run = 0;
- return;
- }
- bool ok = 0;
- if( info )
- {
- if( !karte->getKartenBeschreibung() )
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( "Beschreibung nicht gefunden." ), new Text( "Ok" ) );
- else
- {
- Text *pf = karte->getKartePfad();
- *pf += "beschreibung.ksgs";
- info->setScriptDatei( pf );
- ok = info->neuLaden();
- KSGSVariable *var = info->startFunktion( info->getFunktionId( "_in_gruppe" ), new RCArray< KSGSVariable >() );
- if( var )
- var->release();
- }
- }
- if( !ok )
- {
- Text *f = new Text( karte->getLetzterFehler() );
- tr->setSchriftSize( 12 );
- int br = tr->getTextBreite( f->getText() );
- int hö = tr->getTextHeight( f->getText() );
- fehler = initTextFeld( gr.x / 2 - ( br + 10 ) / 2, gr.y / 2 - ( hö + 4 ) / 2, br + 10, hö + 4,
- schrift, TextFeld::Style::Text | TextFeld::Style::Center, f->getText() );
- f->release();
- karte->unlock();
- karte->release();
- run = 0;
- return;
- }
- karte->unlock();
- karte->release();
- geladen = 1;
- run = 0;
- rend = 1;
- }
- // constant
- int GruppeKarte::getKarteId() const
- {
- return karteId;
- }
- // Reference Counting
- GruppeKarte *GruppeKarte::getThis()
- {
- ref++;
- return this;
- }
- GruppeKarte *GruppeKarte::release()
- {
- ref--;
- if( !ref )
- delete this;
- return 0;
- }
- // Inhalt der GruppeSpielGefunden Klasse aus Gruppe.h
- // Konstruktor
- GruppeSpielGefunden::GruppeSpielGefunden( Schrift * zSchrift )
- {
- pos = Punkt( 375, 235 );
- gr = Punkt( 200, 90 );
- spielGefunden = initFenster( 0, 0, 200, 90, zSchrift, Fenster::Style::Sichtbar | Fenster::Style::Rahmen | Fenster::Style::Titel, "Spiel gefunden" );
- zeit = initTextFeld( 0, 30, 200, 20, zSchrift, TextFeld::Style::Text, "Verbleibende Zeit: 10" );
- warte = initTextFeld( 0, 60, 200, 20, zSchrift, TextFeld::Style::Text & ~TextFeld::Style::Sichtbar, "Warte auf andere Spieler. . ." );
- annehmen = initKnopf( 50, 60, 100, 20, zSchrift, Knopf::Style::Normal, "beitreten" );
- alpha = 0;
- time = 0;
- sichtbar = 0;
- tickVal = 0;
- rend = 0;
- ref = 1;
- }
- // Destruktor
- GruppeSpielGefunden::~GruppeSpielGefunden()
- {
- spielGefunden->release();
- zeit->release();
- warte->release();
- annehmen->release();
- }
- // nicht constant
- void GruppeSpielGefunden::reset()
- {
- zeit->setText( "Verbleibende Zeit: 10" );
- alpha = 0;
- time = 0;
- sichtbar = 0;
- warte->removeStyle( TextFeld::Style::Sichtbar );
- annehmen->addStyle( Knopf::Style::Sichtbar );
- rend = 1;
- }
- void GruppeSpielGefunden::setSichtbar( bool sichtbar )
- {
- warte->removeStyle( TextFeld::Style::Sichtbar );
- annehmen->addStyle( Knopf::Style::Sichtbar );
- this->sichtbar = sichtbar;
- rend = 1;
- }
- void GruppeSpielGefunden::setVerbleibendeZeit( int sekunden )
- {
- if( time != sekunden )
- rend = 1;
- time = sekunden;
- }
- bool GruppeSpielGefunden::tick( double tickVal )
- {
- if( rend )
- {
- zeit->setText( "Verbleibende Zeit: " );
- zeit->zText()->append( (int)time );
- }
- rend |= annehmen->tick( tickVal );
- this->tickVal += tickVal * 300;
- int val = (int)this->tickVal;
- if( val < 1 )
- {
- bool ret = rend;
- rend = 0;
- return ret;
- }
- if( val > 10 )
- val = 10;
- this->tickVal -= val;
- if( sichtbar )
- {
- if( alpha < 255 )
- {
- if( alpha + val > 255 )
- alpha = 255;
- else
- alpha += val;
- rend = 1;
- }
- }
- else
- {
- if( alpha )
- {
- if( alpha - val < 0 )
- alpha = 0;
- else
- alpha -= val;
- rend = 1;
- }
- }
- bool ret = rend;
- rend = 0;
- return ret;
- }
- void GruppeSpielGefunden::doMausEreignis( MausEreignis & me )
- {
- me.mx -= pos.x;
- me.my -= pos.y;
- bool ver = me.verarbeitet;
- annehmen->doMausEreignis( me );
- if( me.verarbeitet && !ver && me.id == ME_RLinks )
- {
- if( spielClient->spielErstelltAnnehmen() )
- {
- annehmen->removeStyle( Knopf::Style::Sichtbar );
- warte->addStyle( TextFeld::Style::Sichtbar );
- rend = 1;
- }
- else if( nachLogin &&nachLogin->zSpielenFenster() )
- nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( spielClient->getLetzterFehler() ), new Text( "Ok" ), 0 );
- }
- me.mx += pos.x;
- me.my += pos.y;
- }
- void GruppeSpielGefunden::render( Bild & zRObj )
- {
- if( !zRObj.setDrawOptions( pos.x, pos.y, gr.x, gr.y ) )
- return;
- zRObj.setAlpha( alpha );
- spielGefunden->render( zRObj );
- zeit->render( zRObj );
- warte->render( zRObj );
- annehmen->render( zRObj );
- zRObj.releaseAlpha();
- zRObj.releaseDrawOptions();
- }
- // constant
- bool GruppeSpielGefunden::istSichtbar() const
- {
- return sichtbar;
- }
- // Reference Counting
- GruppeSpielGefunden *GruppeSpielGefunden::getThis()
- {
- ref++;
- return this;
- }
- GruppeSpielGefunden *GruppeSpielGefunden::release()
- {
- ref--;
- if( !ref )
- delete this;
- return 0;
- }
- // Inhalt der GruppeFenster Klasse aus Gruppe.h
- // Konstruktor
- GruppeFenster::GruppeFenster( Schrift * zSchrift )
- {
- pos = Punkt( 0, 0 );
- gr = Punkt( 950, 550 );
- anmeldung = new GruppeAnmeldung( zSchrift );
- chat = new GruppeChat( zSchrift );
- accounts = new GruppeAccountListe( zSchrift );
- einladungen = new GruppeEinladungListe( zSchrift );
- karte = new GruppeKarte( zSchrift );
- spiel = new GruppeSpielGefunden( zSchrift );
- alpha = 0;
- sichtbar = 0;
- tickVal = 0;
- rend = 0;
- ref = 1;
- }
- // Destruktor
- GruppeFenster::~GruppeFenster()
- {
- anmeldung->release();
- chat->release();
- accounts->release();
- einladungen->release();
- karte->release();
- spiel->release();
- }
- // nicht constant
- void GruppeFenster::setGruppeId( int id )
- {
- gruppeId = id;
- anmeldung->setGruppeId( id );
- chat->setGruppeId( id );
- accounts->setGruppeId( id );
- einladungen->setGruppeId( id );
- karte->setGruppeId( id );
- spiel->setSichtbar( 0 );
- if( id )
- {
- int adminId = infoClient->getGruppeAdminId( id );
- nachLogin->zFreundesListe()->zeigeEinladeKnopf( adminId == loginClient->getAccountId() );
- setAdmin( adminId );
- }
- rend = 1;
- }
- void GruppeFenster::setSichtbar( bool sichtbar )
- {
- this->sichtbar = sichtbar;
- rend = 1;
- }
- void GruppeFenster::chatNachricht( const char *nachricht )
- {
- chat->gruppeNachricht( nachricht );
- }
- void GruppeFenster::neuerSpieler( int accountId )
- {
- einladungen->setAngenommen( accountId );
- accounts->addAccount( accountId );
- }
- void GruppeFenster::spielerVerlässt( int accountId )
- {
- accounts->removeAccount( accountId );
- anmeldung->setAngemeldet( 0 );
- }
- void GruppeFenster::neueEinladung( int accountId )
- {
- einladungen->addAccount( accountId );
- }
- void GruppeFenster::einladungEntfernt( int accountId )
- {
- einladungen->remove( accountId );
- }
- void GruppeFenster::einladungAbgelehnt( int accountId )
- {
- einladungen->setAbgelehnt( accountId );
- }
- void GruppeFenster::setSpielerHinzufügen( bool sh )
- {
- anmeldung->setSpielerHinzufügen( sh );
- }
- void GruppeFenster::setAngemeldet( bool angemeldet )
- {
- anmeldung->setAngemeldet( angemeldet );
- }
- void GruppeFenster::spielGefunden()
- {
- anmeldung->spielGefunden();
- spiel->setSichtbar( 1 );
- rend = 1;
- }
- void GruppeFenster::verbleibendeZeit( int sekunden )
- {
- spiel->setVerbleibendeZeit( sekunden );
- }
- void GruppeFenster::spielGefundenAbbruch()
- {
- spiel->setSichtbar( 0 );
- }
- void GruppeFenster::zurückInWarteschlange( int stunden, int minuten, int sekunden )
- {
- anmeldung->zurückInWarteschlange( stunden, minuten, sekunden );
- }
- void GruppeFenster::setAdmin( int accountId )
- {
- anmeldung->setAdmin( accountId );
- accounts->setAdmin( accountId );
- einladungen->setAdmin( accountId );
- }
- void GruppeFenster::kick()
- {
- }
- void GruppeFenster::reset()
- {
- accounts->reset();
- einladungen->reset();
- karte->reset();
- chat->reset();
- anmeldung->reset();
- spiel->reset();
- }
- bool GruppeFenster::tick( double tickVal )
- {
- if( !spiel->istSichtbar() )
- {
- rend |= anmeldung->tick( tickVal );
- rend |= chat->tick( tickVal );
- rend |= accounts->tick( tickVal );
- rend |= einladungen->tick( tickVal );
- rend |= karte->tick( tickVal );
- }
- rend |= spiel->tick( tickVal );
- this->tickVal += tickVal * 300;
- int val = (int)this->tickVal;
- if( val < 1 )
- {
- bool ret = rend;
- rend = 0;
- return ret;
- }
- if( val > 10 )
- val = 10;
- this->tickVal -= val;
- if( sichtbar )
- {
- if( spiel->istSichtbar() )
- {
- if( alpha > 0x70 )
- {
- if( alpha - val < 0x70 )
- alpha = 0x70;
- else
- alpha -= val;
- rend = 1;
- }
- else if( alpha < 0x70 )
- {
- if( alpha + val > 0x70 )
- alpha = 0x70;
- else
- alpha += val;
- rend = 1;
- }
- }
- else
- {
- if( alpha < 255 )
- {
- if( alpha + val > 255 )
- alpha = 255;
- else
- alpha += val;
- rend = 1;
- }
- }
- }
- else
- {
- if( alpha > 0 )
- {
- if( alpha - val < 0 )
- alpha = 0;
- else
- alpha -= val;
- rend = 1;
- if( !alpha )
- reset();
- }
- }
- bool ret = rend;
- rend = 0;
- return ret;
- }
- void GruppeFenster::doMausEreignis( MausEreignis & me )
- {
- if( !spiel->istSichtbar() )
- {
- anmeldung->doMausEreignis( me );
- chat->doMausEreignis( me );
- accounts->doMausEreignis( me );
- einladungen->doMausEreignis( me );
- karte->doMausEreignis( me );
- }
- spiel->doMausEreignis( me );
- }
- void GruppeFenster::doTastaturEreignis( TastaturEreignis & te )
- {
- if( !spiel->istSichtbar() )
- {
- chat->doTastaturEreignis( te );
- einladungen->doTastaturEreignis( te );
- }
- }
- void GruppeFenster::render( Bild & zRObj )
- {
- if( alpha )
- {
- int x = pos.x;
- int y = pos.y;
- if( !zRObj.setDrawOptions( x, y, gr.x, gr.y ) )
- return;
- unsigned char tmpAlpha = zRObj.getAlpha();
- zRObj.setAlpha( alpha );
- anmeldung->render( zRObj );
- chat->render( zRObj );
- accounts->render( zRObj );
- einladungen->render( zRObj );
- karte->render( zRObj );
- zRObj.releaseAlpha();
- spiel->render( zRObj );
- zRObj.releaseDrawOptions();
- }
- }
- // constant
- int GruppeFenster::getGruppeId() const
- {
- return gruppeId;
- }
- int GruppeFenster::getKarteId() const
- {
- return karte ? karte->getKarteId() : 0;
- }
- // Reference Counting
- GruppeFenster *GruppeFenster::getThis()
- {
- ref++;
- return this;
- }
- GruppeFenster *GruppeFenster::release()
- {
- ref--;
- if( !ref )
- delete this;
- return 0;
- }
|