|
@@ -0,0 +1,301 @@
|
|
|
+#include "KaufHistorie.h"
|
|
|
+#include <Schrift.h>
|
|
|
+#include "../../../../Global/Variablen.h"
|
|
|
+#include "../../../../Global/Initialisierung.h"
|
|
|
+#include <Zeit.h>
|
|
|
+
|
|
|
+// Inhalt der KEKaufHistorie Klasse
|
|
|
+// Konstruktor
|
|
|
+KEKaufHistorie::KEKaufHistorie( int karte, Schrift *zSchrift )
|
|
|
+{
|
|
|
+ schrift = zSchrift->getThis();
|
|
|
+ Text *kName = infoKlient->getKarteName( karte );
|
|
|
+ Text titel = kName ? kName->getText() : "<Karte>";
|
|
|
+ titel += " - Release";
|
|
|
+ if( kName )
|
|
|
+ kName->release();
|
|
|
+ fenster = initFenster( 10, 40, 880, 550, zSchrift, Fenster::Style::Sichtbar | Fenster::Style::Titel | Fenster::Style::TitelBuffered | Fenster::Style::Erlaubt | Fenster::Style::Rahmen, titel );
|
|
|
+ aktualisieren = initKnopf( 10, 10, 100, 20, zSchrift, Knopf::Style::Normal, "Aktualisieren" );
|
|
|
+ aktualisieren->setMausEreignis( [ this ]( void *p, void *obj, MausEreignis me ) -> bool
|
|
|
+ {
|
|
|
+ if( me.id == ME_RLinks && me.verarbeitet == 0 )
|
|
|
+ start();
|
|
|
+ return 1;
|
|
|
+ } );
|
|
|
+ gesammtVerkauf = initTextFeld( 120, 10, 750, 20, zSchrift, TextFeld::Style::Text, "Gesammt verkauft: " );
|
|
|
+ statistik = initLinienDiagramm( 10, 40, 860, 480, zSchrift, LDiag::Style::DatenRahmen, 0 );
|
|
|
+ statistik->setHIntervallBreite( 36.8 );
|
|
|
+ statistik->setDatenStyle( DiagDaten::Style::autoRaster | DiagDaten::Style::intervallTexte | DiagDaten::Style::intervalle | DiagDaten::Style::Sichtbar | DiagDaten::Style::autoIntervall );
|
|
|
+ statistik->setRasterDicke( 1 );
|
|
|
+ statistik->setRasterFarbe( 0xFF505050 );
|
|
|
+ statistik->setHIntervallFarbe( 0xFFFFFFFF );
|
|
|
+ statistik->setHIntervallName( "Tage" );
|
|
|
+ statistik->setVIntervallFarbe( 0xFFFFFFFF );
|
|
|
+ statistik->setVIntervallName( "Anzahl" );
|
|
|
+ laden = (Animation2D*)ladeAnimation->dublizieren();
|
|
|
+ laden->setPosition( 425, 275 );
|
|
|
+ laden->setSichtbar( 0 );
|
|
|
+ fenster->addMember( aktualisieren );
|
|
|
+ fenster->addMember( gesammtVerkauf );
|
|
|
+ fenster->addMember( statistik );
|
|
|
+ animation = 0;
|
|
|
+ tickVal = 0;
|
|
|
+ sichtbar = 0;
|
|
|
+ rechts = 0;
|
|
|
+ xStart = 0;
|
|
|
+ breite = 0;
|
|
|
+ aktion = 0;
|
|
|
+ this->karte = karte;
|
|
|
+ alpha = 255;
|
|
|
+ ref = 1;
|
|
|
+}
|
|
|
+
|
|
|
+// Destruktor
|
|
|
+KEKaufHistorie::~KEKaufHistorie()
|
|
|
+{
|
|
|
+ if( run )
|
|
|
+ {
|
|
|
+ warteAufThread( 5000 );
|
|
|
+ if( run )
|
|
|
+ ende();
|
|
|
+ }
|
|
|
+ statistik->release();
|
|
|
+ aktualisieren->release();
|
|
|
+ gesammtVerkauf->release();
|
|
|
+ fenster->release();
|
|
|
+ laden->release();
|
|
|
+ schrift->release();
|
|
|
+}
|
|
|
+
|
|
|
+// nicht constant
|
|
|
+void KEKaufHistorie::setSichtbar( bool s, bool vr )
|
|
|
+{
|
|
|
+ animation = 1;
|
|
|
+ sichtbar = s;
|
|
|
+ rechts = vr;
|
|
|
+ if( sichtbar )
|
|
|
+ {
|
|
|
+ if( vr )
|
|
|
+ {
|
|
|
+ xStart = 900;
|
|
|
+ breite = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ xStart = 0;
|
|
|
+ breite = 0;
|
|
|
+ }
|
|
|
+ if( !run )
|
|
|
+ {
|
|
|
+ aktion = 0;
|
|
|
+ start();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void KEKaufHistorie::thread()
|
|
|
+{
|
|
|
+ laden->setSichtbar( 1 );
|
|
|
+ Array< int > einnahmen;
|
|
|
+ Array< int > verkauf;
|
|
|
+ Array< int > spiele;
|
|
|
+ int gesammt = editorKlient->getVerkaufStatistik( &verkauf, &einnahmen, &spiele );
|
|
|
+ if( gesammt == 0 && einnahmen.getEintragAnzahl() == 0 )
|
|
|
+ {
|
|
|
+ nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( editorKlient->getLetzterFehler() ), new Text( "Ok" ) );
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ fenster->lockZeichnung();
|
|
|
+ gesammtVerkauf->setText( Text( "Gesammt Verkauft: " ) += gesammt );
|
|
|
+ int wAnz = statistik->zDiagDaten()->werte->getEintragAnzahl();
|
|
|
+ for( int i = 0; i < wAnz; i++ )
|
|
|
+ statistik->removeWert( 0 );
|
|
|
+ wAnz = statistik->zDiagDaten()->hIntervallWerte->getEintragAnzahl();
|
|
|
+ for( int i = 0; i < wAnz; i++ )
|
|
|
+ statistik->removeHIntervallText( statistik->zDiagDaten()->hIntervallWerte->get( 0 ) );
|
|
|
+ wAnz = statistik->zDiagDaten()->vIntervallWerte->getEintragAnzahl();
|
|
|
+ for( int i = 0; i < wAnz; i++ )
|
|
|
+ statistik->removeVIntervallText( statistik->zDiagDaten()->vIntervallWerte->get( 0 ) );
|
|
|
+ int anz = einnahmen.getEintragAnzahl();
|
|
|
+ int maxS = 0;
|
|
|
+ for( int i = 0; i < anz; i++ )
|
|
|
+ {
|
|
|
+ if( einnahmen.hat( i ) && einnahmen.get( i ) > maxS )
|
|
|
+ maxS = einnahmen.get( i );
|
|
|
+ if( verkauf.hat( i ) && verkauf.get( i ) > maxS )
|
|
|
+ maxS = verkauf.get( i );
|
|
|
+ if( spiele.hat( i ) && spiele.get( i ) > maxS )
|
|
|
+ maxS = spiele.get( i );
|
|
|
+ }
|
|
|
+ maxS++;
|
|
|
+ statistik->addVIntervallText( 0, Text() += 0 );
|
|
|
+ statistik->addVIntervallText( maxS + 1, Text() += ( maxS + 1 ) );
|
|
|
+ Datum *d = Framework::getDatum();
|
|
|
+ d->minusTag( 30 );
|
|
|
+ statistik->addHIntervallText( 0, d->getDatum( "y-m-d" ) );
|
|
|
+ d->plusTag( 30 );
|
|
|
+ statistik->addHIntervallText( anz - 1, d->getDatum( "y-m-d" ) );
|
|
|
+ d->release();
|
|
|
+ DiagWert *w = new DiagWert();
|
|
|
+ w->farbe = 0xFF00FFFF;
|
|
|
+ w->hintergrund = 0xFF205050;
|
|
|
+ w->name->setText( "Einnahmen" );
|
|
|
+ w->style = DiagWert::Style::Sichtbar | DiagWert::Style::Name | DiagWert::Style::Hintergrund;
|
|
|
+ statistik->addWert( w );
|
|
|
+ w = new DiagWert();
|
|
|
+ w->farbe = 0xFF00FF00;
|
|
|
+ w->hintergrund = 0xFF205020;
|
|
|
+ w->name->setText( "Verkauft" );
|
|
|
+ w->style = DiagWert::Style::Sichtbar | DiagWert::Style::Name | DiagWert::Style::Hintergrund;
|
|
|
+ statistik->addWert( w );
|
|
|
+ w = new DiagWert();
|
|
|
+ w->farbe = 0xFFFF0000;
|
|
|
+ w->hintergrund = 0xFF502020;
|
|
|
+ w->name->setText( "Spiele" );
|
|
|
+ w->style = DiagWert::Style::Sichtbar | DiagWert::Style::Name | DiagWert::Style::Hintergrund;
|
|
|
+ statistik->addWert( w );
|
|
|
+ for( int i = 0; i < anz; i++ )
|
|
|
+ {
|
|
|
+ statistik->addPunkt( 0, i, einnahmen.get( i ) );
|
|
|
+ statistik->addPunkt( 1, i, verkauf.get( i ) );
|
|
|
+ statistik->addPunkt( 2, i, spiele.get( i ) );
|
|
|
+ }
|
|
|
+ fenster->unlockZeichnung();
|
|
|
+ }
|
|
|
+ laden->setSichtbar( 0 );
|
|
|
+}
|
|
|
+
|
|
|
+void KEKaufHistorie::doMausEreignis( MausEreignis &me )
|
|
|
+{
|
|
|
+ if( !run )
|
|
|
+ fenster->doMausEreignis( me );
|
|
|
+}
|
|
|
+
|
|
|
+void KEKaufHistorie::doTastaturEreignis( TastaturEreignis &te )
|
|
|
+{
|
|
|
+ if( !run )
|
|
|
+ fenster->doTastaturEreignis( te );
|
|
|
+}
|
|
|
+
|
|
|
+bool KEKaufHistorie::tick( double z )
|
|
|
+{
|
|
|
+ bool ret = laden->tick( z );
|
|
|
+ tickVal += z * 150;
|
|
|
+ int val = (int)tickVal;
|
|
|
+ tickVal -= val;
|
|
|
+ if( val )
|
|
|
+ {
|
|
|
+ if( run && alpha != 100 )
|
|
|
+ {
|
|
|
+ if( alpha - val < 100 )
|
|
|
+ alpha = 100;
|
|
|
+ else
|
|
|
+ alpha -= val;
|
|
|
+ ret = 1;
|
|
|
+ }
|
|
|
+ if( !run && alpha != 255 )
|
|
|
+ {
|
|
|
+ if( alpha + val > 255 )
|
|
|
+ alpha = 255;
|
|
|
+ else
|
|
|
+ alpha += val;
|
|
|
+ ret = 1;
|
|
|
+ }
|
|
|
+ val *= 3;
|
|
|
+ if( sichtbar )
|
|
|
+ {
|
|
|
+ if( xStart != 0 || breite != 900 )
|
|
|
+ {
|
|
|
+ if( rechts )
|
|
|
+ {
|
|
|
+ if( xStart - val <= 0 )
|
|
|
+ {
|
|
|
+ xStart = 0;
|
|
|
+ breite = 900;
|
|
|
+ animation = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ xStart -= val;
|
|
|
+ breite += val;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if( breite + val >= 900 )
|
|
|
+ {
|
|
|
+ breite = 900;
|
|
|
+ animation = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ breite += val;
|
|
|
+ }
|
|
|
+ ret = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if( breite != 0 )
|
|
|
+ {
|
|
|
+ if( rechts )
|
|
|
+ {
|
|
|
+ if( breite - val <= 0 )
|
|
|
+ {
|
|
|
+ breite = 0;
|
|
|
+ animation = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ breite -= val;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if( breite - val <= 0 )
|
|
|
+ {
|
|
|
+ breite = 0;
|
|
|
+ xStart = 900;
|
|
|
+ animation = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ breite -= val;
|
|
|
+ xStart += val;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ret = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ret || fenster->tick( z );
|
|
|
+}
|
|
|
+
|
|
|
+void KEKaufHistorie::render( Bild &zRObj )
|
|
|
+{
|
|
|
+ if( !zRObj.setDrawOptions( xStart, 0, breite, 600 ) )
|
|
|
+ return;
|
|
|
+ zRObj.setAlpha( alpha );
|
|
|
+ fenster->render( zRObj );
|
|
|
+ zRObj.releaseAlpha();
|
|
|
+ laden->render( zRObj );
|
|
|
+ zRObj.releaseDrawOptions();
|
|
|
+}
|
|
|
+
|
|
|
+// constant
|
|
|
+bool KEKaufHistorie::istSichtbar() const
|
|
|
+{
|
|
|
+ return sichtbar || animation;
|
|
|
+}
|
|
|
+
|
|
|
+// Reference Counting
|
|
|
+KEKaufHistorie *KEKaufHistorie::getThis()
|
|
|
+{
|
|
|
+ ref++;
|
|
|
+ return this;
|
|
|
+}
|
|
|
+
|
|
|
+KEKaufHistorie *KEKaufHistorie::release()
|
|
|
+{
|
|
|
+ if( !--ref )
|
|
|
+ delete this;
|
|
|
+ return 0;
|
|
|
+}
|