123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077 |
- #include "TeamAuswahl.h"
- #include <AlphaFeld.h>
- #include <AuswahlBox.h>
- #include <DateiSystem.h>
- #include <Rahmen.h>
- #include "..\..\..\Global\Initialisierung.h"
- #include "..\..\..\Global\Variablen.h"
- // Inhalt der TeamAuswahlListeSpieler Klasse aus TeamAuswahl.h
- // Konstruktor
- TeamAuswahlListeSpieler::TeamAuswahlListeSpieler(
- SpielerTeamStruktur* sts, int accountId, int karteId)
- : ReferenceCounter()
- {
- this->accountId = accountId;
- Text* n = infoClient->getSpielerName(accountId);
- name = initTextFeld(1,
- 1,
- 99,
- 20,
- TextFeld::Style::Text | TextFeld::Style::Center,
- n->getText());
- n->release();
- if (accountId == loginClient->getAccountId())
- {
- teamAuswahl = uiFactory.createAuswahlBox(uiFactory.initParam);
- teamAuswahl->setStyle(
- AuswahlBox::Style::Sichtbar | AuswahlBox::Style::Erlaubt
- | AuswahlBox::Style::Rahmen | AuswahlBox::Style::MultiStyled
- | AuswahlBox::Style::MaxHeight | AuswahlBox::Style::VScroll
- | AuswahlBox::Style::Hintergrund);
- teamAuswahl->setPosition(100, 1);
- teamAuswahl->setSize(150, 20);
- teamAuswahl->setEventParam(this);
- teamAuswahl->setEventAktion(TeamAuswahlListeSpielerTeamAuswahlE);
- }
- else
- team = initTextFeld(100,
- 1,
- 150,
- 20,
- TextFeld::Style::Text | TextFeld::Style::Center,
- "");
- Array<int>* statistik = new Array<int>();
- infoClient->getSpielStatistik(
- accountId, infoClient->getSpielId(karteId), statistik);
- punkte = initTextFeld(250,
- 1,
- 80,
- 20,
- TextFeld::Style::Text | TextFeld::Style::Center,
- "Punkte: ");
- punkte->zText()->append(statistik->hat(3) ? statistik->get(3) : 0);
- spiele = initTextFeld(330,
- 1,
- 80,
- 20,
- TextFeld::Style::Text | TextFeld::Style::Center,
- "Spiele: ");
- spiele->zText()->append(statistik->hat(0) ? statistik->get(0) : 0);
- gewonnen = initTextFeld(410,
- 1,
- 90,
- 20,
- TextFeld::Style::Text | TextFeld::Style::Center,
- "Gewonnen: ");
- gewonnen->zText()->append(statistik->hat(1) ? statistik->get(1) : 0);
- statistik->release();
- farbe = initTextFeld(500,
- 1,
- 50,
- 20,
- TextFeld::Style::Text | TextFeld::Style::Center,
- "Farbe:");
- spielerFarbe = 0;
- rahmen = new LRahmen();
- rahmen->setSize(581, 22);
- rahmen->setFarbe(0xFFFFFFFF);
- rahmen->setRamenBreite(1);
- teamName = new Text("");
- this->sts = sts;
- rend = 0;
- }
- // Destruktor
- TeamAuswahlListeSpieler::~TeamAuswahlListeSpieler()
- {
- name->release();
- if (accountId == loginClient->getAccountId())
- teamAuswahl->release();
- else
- team->release();
- punkte->release();
- spiele->release();
- gewonnen->release();
- farbe->release();
- rahmen->release();
- teamName->release();
- sts->release();
- }
- // nicht constant
- void TeamAuswahlListeSpieler::disable()
- {
- if (accountId == loginClient->getAccountId())
- teamAuswahl->removeStyle(AuswahlBox::Style::Erlaubt);
- }
- void TeamAuswahlListeSpieler::spielerTeamAuswahlE(
- AuswahlBox* obj, int p1, int p2)
- {
- Text* tmpTeamName = obj->zEintragText(p2);
- if (!tmpTeamName->istGleich(teamName->getText()))
- {
- if (tmpTeamName->istGleich("Zufällig"))
- {
- if (!spielClient->spielErstelltTeamWechseln(0))
- obj->setAuswahl(obj->getEintragPos(teamName->getText()));
- }
- else
- {
- int neuTeam = 0;
- for (int i = 0; i < sts->teamAnzahl; i++)
- {
- if (sts->teamName->z(i)->istGleich(tmpTeamName->getText()))
- {
- neuTeam = i + 1;
- break;
- }
- }
- if (!spielClient->spielErstelltTeamWechseln(neuTeam))
- obj->setAuswahl(obj->getEintragPos(teamName->getText()));
- }
- obj->einklappen();
- }
- }
- void TeamAuswahlListeSpieler::setFarbe(int farbe)
- {
- this->spielerFarbe = farbe;
- if (farbe)
- rahmen->setFarbe(farbe);
- else
- rahmen->setFarbe(0xFFFFFFFF);
- rend = 1;
- }
- void TeamAuswahlListeSpieler::setTeam(Text* zName)
- {
- teamName->setText(zName->getText());
- rend = 1;
- }
- void TeamAuswahlListeSpieler::setTeamErlaubt(
- Text* zName, bool erlaubt, int teamFarbe)
- {
- if (accountId != loginClient->getAccountId()) return;
- if (erlaubt)
- {
- if (teamAuswahl->getEintragPos(zName->getText()) < 0)
- {
- int p = teamAuswahl->getEintragAnzahl();
- teamAuswahl->addEintrag(zName->getText());
- teamAuswahl->setMsStyle(p,
- AuswahlBox::Style::FeldRahmen | AuswahlBox::Style::MausBuffer
- | AuswahlBox::Style::AuswahlBuffer
- | AuswahlBox::Style::FeldBuffer);
- if (teamFarbe) teamAuswahl->zEintrag(p)->setRahmenFarbe(teamFarbe);
- teamAuswahl->setMsAuswAlphaFeldFarbe(
- p, 0x50000000 | (teamFarbe & 0x00FFFFFF));
- teamAuswahl->setMsAuswAlphaFeldStrength(p, -15);
- teamAuswahl->setMsMausAlphaFeldFarbe(
- p, 0x10000000 | (teamFarbe & 0x00FFFFFF));
- teamAuswahl->setMsMausAlphaFeldStrength(p, -15);
- }
- }
- else
- {
- if (zName->istGleich(teamName->getText())) return;
- if (teamAuswahl->getEintragPos(zName->getText()) >= 0)
- teamAuswahl->removeEintrag(
- teamAuswahl->getEintragPos(zName->getText()));
- }
- }
- bool TeamAuswahlListeSpieler::tick(double tickVal)
- {
- if (accountId == loginClient->getAccountId())
- rend |= teamAuswahl->tick(tickVal);
- else if (!team->zText()->istGleich(teamName->getText()))
- {
- team->setText("");
- team->zText()->append(teamName->getText());
- }
- bool ret = rend;
- rend = 0;
- return ret;
- }
- void TeamAuswahlListeSpieler::doPublicMausEreignis(MausEreignis& me)
- {
- if (accountId == loginClient->getAccountId())
- teamAuswahl->doPublicMausEreignis(me);
- }
- void TeamAuswahlListeSpieler::render(int yOff, Bild& zRObj)
- {
- if (!zRObj.setDrawOptions(0, yOff, 581, 22)) return;
- rahmen->render(zRObj);
- name->render(zRObj);
- if (loginClient->getAccountId() == accountId)
- teamAuswahl->render(zRObj);
- else
- team->render(zRObj);
- punkte->render(zRObj);
- spiele->render(zRObj);
- gewonnen->render(zRObj);
- farbe->render(zRObj);
- zRObj.alphaRegion(550, 2, 18, 18, spielerFarbe);
- zRObj.releaseDrawOptions();
- }
- // constant
- int TeamAuswahlListeSpieler::getAccountId() const
- {
- return accountId;
- }
- // Inhalt der TeamAuswahlListeTeam Klasse aus TeamAuswahl.h
- // Konstruktor
- TeamAuswahlListeTeam::TeamAuswahlListeTeam()
- : ReferenceCounter()
- {
- maxSpieler = 0;
- jetztSpieler = 0;
- team = 0;
- name = initTextFeld(0,
- 0,
- 300,
- 20,
- TextFeld::Style::Text | TextFeld::Style::Center,
- "Team: ");
- mjSpieler = initTextFeld(300,
- 0,
- 150,
- 20,
- TextFeld::Style::Text | TextFeld::Style::Center,
- "Spieler: 0/0");
- farbe = initTextFeld(450,
- 0,
- 100,
- 20,
- TextFeld::Style::Text | TextFeld::Style::Center,
- "Team Farbe:");
- teamFarbe = 0;
- spieler = new RCArray<TeamAuswahlListeSpieler>();
- rahmen = new LRahmen();
- rahmen->setSize(583, 22);
- rahmen->setFarbe(0xFFFFFFFF);
- rahmen->setRamenBreite(1);
- titelAf = new AlphaFeld();
- titelAf->setPosition(1, 1);
- titelAf->setSize(581, 20);
- titelAf->setFarbe(0x1000FF00);
- titelAf->setStrength(-15);
- teamName = new Text("");
- tickVal = 0;
- höhe = 22;
- rend = 0;
- }
- // Destruktor
- TeamAuswahlListeTeam::~TeamAuswahlListeTeam()
- {
- name->release();
- mjSpieler->release();
- farbe->release();
- spieler->release();
- rahmen->release();
- titelAf->release();
- teamName->release();
- }
- // nicht constant
- void TeamAuswahlListeTeam::disable()
- {
- for (int i = 0; i < jetztSpieler; i++)
- spieler->z(i)->disable();
- }
- void TeamAuswahlListeTeam::setMaxSpieler(int maxSpieler)
- {
- this->maxSpieler = maxSpieler;
- rend = 1;
- }
- void TeamAuswahlListeTeam::setName(Text* name)
- {
- teamName->setText(name->getText());
- name->release();
- rend = 1;
- }
- void TeamAuswahlListeTeam::setFarbe(int farbe)
- {
- teamFarbe = farbe;
- rahmen->setFarbe(teamFarbe);
- rend = 1;
- }
- void TeamAuswahlListeTeam::setTeam(int team)
- {
- this->team = team;
- rend = 1;
- }
- void TeamAuswahlListeTeam::addSpieler(TeamAuswahlListeSpieler* spieler)
- {
- if (!jetztSpieler) höhe++;
- spieler->setTeam(teamName);
- höhe += 22;
- this->spieler->set(spieler, jetztSpieler);
- jetztSpieler++;
- rend = 1;
- }
- void TeamAuswahlListeTeam::removeSpieler(int accountId)
- {
- höhe -= 22;
- for (int i = 0; i < jetztSpieler; i++)
- {
- if (spieler->z(i)->getAccountId() == accountId)
- {
- jetztSpieler--;
- spieler->remove(i);
- rend = 1;
- break;
- }
- }
- if (!jetztSpieler) höhe = 22;
- }
- void TeamAuswahlListeTeam::setTeamErlaubt(
- Text* zName, bool erlaubt, int teamFarbe)
- {
- for (int i = 0; i < jetztSpieler; i++)
- spieler->z(i)->setTeamErlaubt(zName, erlaubt, teamFarbe);
- }
- bool TeamAuswahlListeTeam::tick(double tickVal)
- {
- this->tickVal += tickVal * 50;
- int val = (int)this->tickVal;
- if (val > 2) val = 2;
- this->tickVal -= val;
- if (val)
- {
- if (rahmen->getHeight() > höhe)
- {
- rahmen->setSize(rahmen->getBreite(), rahmen->getHeight() - val);
- if (rahmen->getHeight() < höhe)
- rahmen->setSize(rahmen->getBreite(), höhe);
- rend = 1;
- }
- if (rahmen->getHeight() < höhe)
- {
- rahmen->setSize(rahmen->getBreite(), rahmen->getHeight() + val);
- if (rahmen->getHeight() > höhe)
- rahmen->setSize(rahmen->getBreite(), höhe);
- rend = 1;
- }
- }
- name->setText("Team: ");
- name->zText()->append(teamName->getText());
- mjSpieler->setText("Spieler: ");
- mjSpieler->zText()->append(jetztSpieler);
- mjSpieler->zText()->append("/");
- mjSpieler->zText()->append(maxSpieler);
- for (int i = 0; i < jetztSpieler; i++)
- rend |= spieler->z(i)->tick(tickVal);
- bool ret = rend;
- rend = 0;
- return ret;
- }
- void TeamAuswahlListeTeam::doPublicMausEreignis(MausEreignis& me)
- {
- int tmpX = me.mx;
- int tmpY = me.my;
- me.mx--;
- me.my -= 22;
- for (int i = 0; i < jetztSpieler; i++)
- {
- spieler->z(i)->doPublicMausEreignis(me);
- me.my -= 22;
- }
- me.mx = tmpX;
- me.my = tmpY;
- }
- void TeamAuswahlListeTeam::render(int yOff, Bild& zRObj)
- {
- if (!zRObj.setDrawOptions(50, yOff, 583, rahmen->getHeight() + 1)) return;
- rahmen->render(zRObj);
- titelAf->setPosition(1, 1);
- titelAf->render(zRObj);
- name->render(zRObj);
- mjSpieler->render(zRObj);
- farbe->render(zRObj);
- zRObj.alphaRegion(550, 2, 18, 18, teamFarbe);
- zRObj.drawLinieH(1, 21, 581, rahmen->getFarbe());
- if (!zRObj.setDrawOptions(1, 22, 582, rahmen->getHeight()))
- {
- zRObj.releaseDrawOptions();
- return;
- }
- int y = 22 * (jetztSpieler - 1);
- for (int i = jetztSpieler - 1; i >= 0; i--)
- {
- spieler->z(i)->render(y, zRObj);
- y -= 22;
- }
- zRObj.releaseDrawOptions();
- zRObj.releaseDrawOptions();
- }
- // constant
- int TeamAuswahlListeTeam::getTeamNummer() const
- {
- return team;
- }
- int TeamAuswahlListeTeam::getHeight() const
- {
- return rahmen->getHeight() + 1;
- }
- bool TeamAuswahlListeTeam::istPlatzFrei() const
- {
- return jetztSpieler < maxSpieler;
- }
- int TeamAuswahlListeTeam::getMaxSpieler() const
- {
- return maxSpieler;
- }
- Text* TeamAuswahlListeTeam::zName() const
- {
- return teamName;
- }
- TeamAuswahlListeSpieler* TeamAuswahlListeTeam::getSpielerDaten(
- int accountId) const
- {
- for (int i = 0; i < jetztSpieler; i++)
- {
- if (spieler->z(i)->getAccountId() == accountId) return spieler->get(i);
- }
- return 0;
- }
- TeamAuswahlListeSpieler* TeamAuswahlListeTeam::zSpielerDaten(
- int accountId) const
- {
- for (int i = 0; i < jetztSpieler; i++)
- {
- if (spieler->z(i)->getAccountId() == accountId) return spieler->z(i);
- }
- return 0;
- }
- // Inhalt der TeamAuswahlListe Klasse aus TeamAuswahl.h
- // Konstruktor
- TeamAuswahlListe::TeamAuswahlListe(SpielerTeamStruktur* sts, int karteId)
- : ReferenceCounter()
- {
- rahmen = new LRahmen();
- rahmen->setSize(698, 398);
- rahmen->setFarbe(0xFFFFFFFF);
- rahmen->setRamenBreite(1);
- scroll = new VScrollBar();
- scroll->update(0, 396);
- scroll->setKlickScroll(7);
- teams = new RCArray<TeamAuswahlListeTeam>();
- TeamAuswahlListeTeam* zufall = new TeamAuswahlListeTeam();
- zufall->setTeam(0);
- zufall->setName(new Text("Zufällig"));
- zufall->setMaxSpieler(sts->spielerAnzahl);
- teams->set(zufall, 0);
- for (int i = 0; i < sts->teamAnzahl; i++)
- {
- TeamAuswahlListeTeam* tmp = new TeamAuswahlListeTeam();
- tmp->setTeam(i);
- tmp->setName(sts->teamName->get(i));
- tmp->setFarbe(sts->teamFarbe->hat(i) ? sts->teamFarbe->get(i) : 0);
- tmp->setMaxSpieler(sts->teamSize->hat(i) ? sts->teamSize->get(i) : 0);
- teams->set(tmp, i + 1);
- }
- teamAnzahl = 1 + sts->teamAnzahl;
- this->karteId = karteId;
- this->sts = sts;
- rend = 0;
- }
- // Destruktor
- TeamAuswahlListe::~TeamAuswahlListe()
- {
- rahmen->release();
- scroll->release();
- teams->release();
- sts->release();
- }
- // nicht constant
- void TeamAuswahlListe::disable()
- {
- for (int i = 0; i < teamAnzahl; i++)
- teams->z(i)->disable();
- }
- void TeamAuswahlListe::setTeamVonSpieler(int accountId, int spielerNummer)
- {
- if (spielerNummer == 0)
- {
- int neuTeam = 0;
- int altTeam = 0;
- for (int j = 0; j < teamAnzahl; j++)
- {
- if (teams->z(j)->zSpielerDaten(accountId))
- {
- altTeam = j;
- break;
- }
- }
- TeamAuswahlListeSpieler* tmp
- = teams->z(altTeam)->getSpielerDaten(accountId);
- teams->z(altTeam)->removeSpieler(accountId);
- tmp->setFarbe(0);
- teams->z(neuTeam)->addSpieler(tmp);
- }
- else
- {
- int team = 0;
- int max = 0;
- int min = 0;
- for (int i = 0; i < sts->teamAnzahl; i++)
- {
- min = max;
- max += sts->teamSize->get(i);
- if (spielerNummer - 1 >= min && spielerNummer - 1 < max)
- {
- int neuTeam = i + 1;
- int altTeam = 0;
- for (int j = 0; j < teamAnzahl; j++)
- {
- if (teams->z(j)->zSpielerDaten(accountId))
- {
- altTeam = j;
- break;
- }
- }
- TeamAuswahlListeSpieler* tmp
- = teams->z(altTeam)->getSpielerDaten(accountId);
- teams->z(altTeam)->removeSpieler(accountId);
- tmp->setFarbe(sts->spielerFarbe->hat(spielerNummer - 1)
- ? sts->spielerFarbe->get(spielerNummer - 1)
- : 0);
- teams->z(neuTeam)->addSpieler(tmp);
- break;
- }
- }
- }
- for (int i = 0; i < teamAnzahl; i++)
- {
- for (int j = 0; j < teamAnzahl; j++)
- {
- if (i == 0)
- teams->z(j)->setTeamErlaubt(
- teams->z(i)->zName(), teams->z(i)->istPlatzFrei(), 0);
- else
- teams->z(j)->setTeamErlaubt(teams->z(i)->zName(),
- teams->z(i)->istPlatzFrei(),
- sts->teamFarbe->hat(i - 1) ? sts->teamFarbe->get(i - 1)
- : 0);
- }
- }
- rend = 1;
- }
- void TeamAuswahlListe::addSpieler(int accountId)
- {
- TeamAuswahlListeSpieler* tmp
- = new TeamAuswahlListeSpieler(sts->getThis(), accountId, karteId);
- for (int i = 0; i < teamAnzahl; i++)
- {
- if (teams->z(i)->istPlatzFrei())
- {
- if (i == 0)
- tmp->setTeamErlaubt(teams->z(i)->zName(), 1, 0);
- else
- tmp->setTeamErlaubt(teams->z(i)->zName(),
- 1,
- sts->teamFarbe->hat(i - 1) ? sts->teamFarbe->get(i - 1)
- : 0);
- }
- }
- teams->z(0)->addSpieler(tmp);
- for (int i = 0; i < teamAnzahl; i++)
- teams->z(i)->setTeamErlaubt(
- teams->z(0)->zName(), teams->z(0)->istPlatzFrei(), 0);
- rend = 1;
- }
- void TeamAuswahlListe::removeSpieler(int accountId)
- {
- for (int i = 0; i < teamAnzahl; i++)
- {
- if (teams->z(i)->zSpielerDaten(accountId))
- teams->z(i)->removeSpieler(accountId);
- }
- for (int i = 0; i < teamAnzahl; i++)
- {
- for (int j = 0; j < teamAnzahl; j++)
- {
- if (i == 0)
- teams->z(j)->setTeamErlaubt(
- teams->z(i)->zName(), teams->z(i)->istPlatzFrei(), 0);
- else
- teams->z(j)->setTeamErlaubt(teams->z(i)->zName(),
- teams->z(i)->istPlatzFrei(),
- sts->teamFarbe->hat(i - 1) ? sts->teamFarbe->get(i - 1)
- : 0);
- }
- }
- rend = 1;
- }
- bool TeamAuswahlListe::tick(double tickVal)
- {
- for (int i = 0; i < teamAnzahl; i++)
- rend |= teams->z(i)->tick(tickVal);
- rend |= scroll->getRend();
- bool ret = rend;
- rend = 0;
- return ret;
- }
- void TeamAuswahlListe::doPublicMausEreignis(MausEreignis& me)
- {
- int tmpX = me.mx;
- int tmpY = me.my;
- me.mx -= 50;
- me.my -= 50 - scroll->getScroll();
- for (int i = 0; i < teamAnzahl; i++)
- {
- teams->z(i)->doPublicMausEreignis(me);
- me.my -= 20 + teams->z(i)->getHeight();
- }
- me.mx = tmpX;
- me.my = tmpY;
- if (me.mx > 1 && me.mx < 698 && me.my > 1 && me.my < 397)
- {
- scroll->doMausMessage(683, 1, 15, 396, me);
- me.verarbeitet = 1;
- }
- }
- void TeamAuswahlListe::render(Bild& zRObj)
- {
- if (!zRObj.setDrawOptions(0, 0, 698, 398)) return;
- rahmen->render(zRObj);
- int maxHöhe = 50;
- for (int i = 0; i < teamAnzahl; i++)
- maxHöhe += 20 + teams->z(i)->getHeight();
- maxHöhe += 30;
- scroll->update(maxHöhe, 396);
- scroll->render(683, 1, 15, 396, zRObj);
- if (!zRObj.setDrawOptions(1, 1, 682, 395))
- {
- zRObj.releaseDrawOptions();
- return;
- }
- int y = 50 - scroll->getScroll();
- for (int i = 0; i < teamAnzahl - 1; i++)
- y += 20 + teams->z(i)->getHeight();
- for (int i = teamAnzahl - 1; i >= 0; i--)
- {
- teams->z(i)->render(y, zRObj);
- if (i > 0) y -= 20 + teams->z(i - 1)->getHeight();
- }
- zRObj.releaseDrawOptions();
- zRObj.releaseDrawOptions();
- }
- // Inhalt der TeamAuswahlTimer Klasse aus TeamAuswahl.h
- // Konstruktor
- TeamAuswahlTimer::TeamAuswahlTimer()
- : ReferenceCounter()
- {
- zeit = initTextFeld(
- 0, 0, 200, 200, TextFeld::Style::Text | TextFeld::Style::Center, "");
- bestätigen = initKnopf(65, 170, 70, 20, Knopf::Style::Sichtbar, "Fertig");
- time = 0;
- maxTime = 0;
- grad = 0;
- rend = 0;
- }
- // Destruktor
- TeamAuswahlTimer::~TeamAuswahlTimer()
- {
- zeit->release();
- bestätigen->release();
- }
- // nicht constant
- void TeamAuswahlTimer::setVerbleibendeZeit(int sekunden)
- {
- if (!maxTime) maxTime = sekunden;
- if (time != sekunden) rend = 1;
- time = sekunden;
- }
- bool TeamAuswahlTimer::doPublicMausEreignis(MausEreignis& me)
- {
- bool vera = me.verarbeitet;
- bestätigen->doPublicMausEreignis(me);
- if (!vera && me.verarbeitet && me.id == ME_RLinks)
- {
- if (spielClient->spielErstelltTeamFertig())
- {
- bestätigen->removeStyle(Knopf::Style::Erlaubt);
- return 1;
- }
- }
- return 0;
- }
- bool TeamAuswahlTimer::tick(double tickVal)
- {
- zeit->setText("");
- zeit->zText()->append(time);
- grad += (tickVal * 2);
- rend = 1;
- if (grad > 360) grad -= 360;
- bool ret = rend;
- rend = 0;
- return ret;
- }
- void TeamAuswahlTimer::render(Bild& zRObj)
- {
- if (!zRObj.setDrawOptions(498, 398, 200, 200)) return;
- zeit->render(zRObj);
- int r = (maxTime && time)
- ? 90 - (int)(75.0 / ((double)maxTime / (maxTime - time)) + 0.5)
- : 15;
- zRObj.drawKreis(100, 100, 15, 0xFFFF0000);
- zRObj.drawKreis(100, 100, r, 0xFF00FF00);
- int x1 = 100 + (int)(sin(grad) * 15);
- int y1 = 100 + (int)(cos(grad) * 15);
- int x2 = 100 + (int)(sin(grad) * r);
- int y2 = 100 + (int)(cos(grad) * r);
- zRObj.drawLinie(Punkt(x1, y1), Punkt(x2, y2), 0xFFFFFF00);
- bestätigen->render(zRObj);
- zRObj.releaseDrawOptions();
- }
- // constant
- int TeamAuswahlTimer::getZeit() const
- {
- return time;
- }
- // Inhalt der TeamAuswahlChat Klasse aus TeamAuswahl.h
- // Konstruktor
- TeamAuswahlChat::TeamAuswahlChat()
- : ReferenceCounter()
- {
- nachricht = initTextFeld(2, 178, 472, 20, TextFeld::Style::TextFeld, "");
- Bild* sendenBild = bilder->get("data/client/bilder/chat.ltdb/senden.png");
- senden = initKnopf(476, 178, 20, 20, 0, "");
- senden->setStyle(Knopf::Style::Sichtbar | Knopf::Style::Erlaubt
- | Knopf::Style::Hintergrund | Knopf::Style::HAlpha
- | Knopf::Style::HBild | Knopf::Style::KlickBuffer);
- senden->setHintergrundBildZ(sendenBild);
- verlauf = initTextFeld(2,
- 2,
- 494,
- 174,
- TextFeld::Style::TextGebiet & ~TextFeld::Style::Erlaubt,
- "");
- verlauf->updateVScroll();
- verlauf->setVertikalKlickScroll(5);
- rahmen = new LRahmen();
- rahmen->setSize(498, 200);
- rahmen->setFarbe(0xFFFFFFFF);
- rahmen->setRamenBreite(1);
- rend = 0;
- }
- // Destruktor
- TeamAuswahlChat::~TeamAuswahlChat()
- {
- nachricht->release();
- senden->release();
- verlauf->release();
- rahmen->release();
- }
- // nicht constant
- void TeamAuswahlChat::addNachricht(const char* nachricht)
- {
- verlauf->addZeile(nachricht);
- verlauf->updateVScroll();
- rend = 1;
- }
- bool TeamAuswahlChat::tick(double tickVal)
- {
- rend |= verlauf->tick(tickVal);
- rend |= nachricht->tick(tickVal);
- rend |= senden->tick(tickVal);
- bool ret = rend;
- rend = 0;
- return ret;
- }
- void TeamAuswahlChat::doPublicMausEreignis(MausEreignis& me)
- {
- verlauf->doPublicMausEreignis(me);
- nachricht->doPublicMausEreignis(me);
- bool ver = !me.verarbeitet;
- senden->doPublicMausEreignis(me);
- int aktion = (ver && me.verarbeitet && me.id == ME_RLinks) ? 1 : 0;
- if (aktion == 1)
- { // Nachricht senden
- if (spielClient->spielErstelltChatNachricht(
- nachricht->zText()->getText()))
- {
- nachricht->setText("");
- nachricht->setAuswahl(0, 0);
- rend = 1;
- }
- else
- nachLogin->zNachrichtenListe()->addNachricht(new Text("Fehler"),
- new Text(spielClient->getLetzterFehler()),
- new Text("Ok"),
- 0);
- }
- }
- void TeamAuswahlChat::doTastaturEreignis(TastaturEreignis& te)
- {
- bool ver = !te.verarbeitet;
- nachricht->doTastaturEreignis(te);
- int aktion = (ver && te.verarbeitet && te.id == TE_Release
- && te.virtualKey == T_Enter)
- ? 1
- : 0;
- if (aktion == 1)
- { // Nachricht senden
- if (spielClient->spielErstelltChatNachricht(
- nachricht->zText()->getText()))
- {
- nachricht->setText("");
- nachricht->setAuswahl(0, 0);
- rend = 1;
- }
- else
- nachLogin->zNachrichtenListe()->addNachricht(new Text("Fehler"),
- new Text(spielClient->getLetzterFehler()),
- new Text("Ok"),
- 0);
- }
- }
- void TeamAuswahlChat::render(Bild& zRObj)
- {
- if (!zRObj.setDrawOptions(0, 398, 498, 200)) return;
- rahmen->render(zRObj);
- verlauf->render(zRObj);
- nachricht->render(zRObj);
- senden->render(zRObj);
- zRObj.releaseDrawOptions();
- }
- // Inhalt der TeamAuswahl Klasse aus TeamAuswahl.h
- // Konstruktor
- TeamAuswahl::TeamAuswahl()
- : ReferenceCounter()
- {
- tickVal = 0;
- animation = 0;
- sichtbar = 0;
- alpha = 0;
- karteId = 0;
- sts = 0;
- chat = 0;
- timer = 0;
- liste = 0;
- rend = 0;
- }
- // Destruktor
- TeamAuswahl::~TeamAuswahl()
- {
- if (sichtbar) setSichtbar(0);
- if (chat) chat->release();
- if (timer) timer->release();
- if (liste) liste->release();
- if (sts) sts->release();
- }
- // nicht constant
- void TeamAuswahl::setKarteId(int karteId)
- {
- this->karteId = karteId;
- }
- void TeamAuswahl::setSichtbar(bool sichtbar, bool sofort)
- {
- this->sichtbar = sichtbar;
- if (sichtbar)
- animation |= 0x1;
- else
- {
- if (sofort)
- alpha = 0;
- else
- animation &= ~0x1;
- }
- rend = 1;
- }
- void TeamAuswahl::initSTS(SpielerTeamStruktur* sts)
- {
- uiFactory.initParam.bildschirm->lock();
- if (this->sts) this->sts->release();
- this->sts = sts;
- if (chat) chat = (TeamAuswahlChat*)chat->release();
- if (timer) timer = (TeamAuswahlTimer*)timer->release();
- if (liste) liste = (TeamAuswahlListe*)liste->release();
- chat = new TeamAuswahlChat();
- timer = new TeamAuswahlTimer();
- liste = new TeamAuswahlListe(sts->getThis(), karteId);
- uiFactory.initParam.bildschirm->unlock();
- rend = 1;
- }
- void TeamAuswahl::addSpieler(int accountId)
- {
- if (liste) liste->addSpieler(accountId);
- }
- void TeamAuswahl::setSpielerNummer(int accountId, int sNummer)
- {
- if (liste) liste->setTeamVonSpieler(accountId, sNummer);
- }
- void TeamAuswahl::removeSpieler(int accountId)
- {
- if (liste) liste->removeSpieler(accountId);
- }
- void TeamAuswahl::verbleibendeZeit(int sekunden)
- {
- if (timer) timer->setVerbleibendeZeit(sekunden);
- }
- void TeamAuswahl::addNachricht(const char* nachricht)
- {
- if (chat) chat->addNachricht(nachricht);
- }
- bool TeamAuswahl::tick(double tickVal)
- {
- if (!sichtbar && !alpha) return 0;
- if (chat) rend |= chat->tick(tickVal);
- if (timer) rend |= timer->tick(tickVal);
- if (liste) rend |= liste->tick(tickVal);
- this->tickVal += tickVal * 150;
- int val = (int)this->tickVal;
- if (!val)
- {
- bool ret = rend;
- rend = 0;
- return ret;
- }
- if (val > 5) val = 5;
- this->tickVal -= val;
- if ((animation | 0x1) == animation) // sichtbar werden
- {
- if (alpha != 255)
- {
- if (alpha + val < 255)
- alpha += val;
- else
- alpha = 255;
- rend = 1;
- }
- }
- else // unsichtbar werden
- {
- if (alpha != 0)
- {
- if (alpha - val >= 0)
- alpha -= val;
- else
- alpha = 0;
- rend = 1;
- }
- }
- bool ret = rend;
- rend = 0;
- return ret;
- }
- void TeamAuswahl::doPublicMausEreignis(MausEreignis& me)
- {
- if (!alpha) return;
- if (liste) liste->doPublicMausEreignis(me);
- if (chat)
- {
- me.my -= 398;
- chat->doPublicMausEreignis(me);
- me.mx -= 498;
- if (timer->doPublicMausEreignis(me)) liste->disable();
- me.my += 398;
- me.mx += 498;
- }
- }
- void TeamAuswahl::doTastaturEreignis(TastaturEreignis& te)
- {
- if (!alpha) return;
- if (chat) chat->doTastaturEreignis(te);
- }
- void TeamAuswahl::render(Bild& zRObj)
- {
- if (!alpha) return;
- if (!zRObj.setDrawOptions(0, 0, 700, 600)) return;
- zRObj.setAlpha(alpha);
- if (timer) timer->render(zRObj);
- if (chat) chat->render(zRObj);
- if (liste) liste->render(zRObj);
- zRObj.releaseAlpha();
- zRObj.releaseDrawOptions();
- }
- // constant
- bool TeamAuswahl::istSichtbar() const
- {
- return sichtbar;
- }
- int TeamAuswahl::getKarteId() const
- {
- return karteId;
- }
- SpielerTeamStruktur* TeamAuswahl::getSTS() const
- {
- return sts->getThis();
- }
- // Event Aktionen
- void TeamAuswahlListeSpielerTeamAuswahlE(
- void* p, AuswahlBox* obj, int p1, int p2)
- {
- if (!p) return;
- ((TeamAuswahlListeSpieler*)p)->spielerTeamAuswahlE(obj, p1, p2);
- }
|