|
@@ -0,0 +1,250 @@
|
|
|
|
+#include "GUI.h"
|
|
|
|
+#include <TextFeld.h>
|
|
|
|
+#include <MausEreignis.h>
|
|
|
|
+#include <M2Datei.h>
|
|
|
|
+#include <Text.h>
|
|
|
|
+#include <DateiSystem.h>
|
|
|
|
+#include <DateiDialog.h>
|
|
|
|
+
|
|
|
|
+Knopf *initKnopf( int x, int y, int br, int hö, Schrift *zSchrift, int style, char *titel )
|
|
|
|
+{
|
|
|
|
+ Knopf *ret = new Knopf();
|
|
|
|
+ ret->addStyle( style );
|
|
|
|
+ ret->setPosition( x, y );
|
|
|
|
+ ret->setSize( br, hö );
|
|
|
|
+ if( zSchrift )
|
|
|
|
+ ret->setSchriftZ( zSchrift->getThis() );
|
|
|
|
+ ret->setText( titel );
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TextFeld *initTextFeld( int x, int y, int br, int hö, Schrift *zSchrift, int style, char *txt )
|
|
|
|
+{
|
|
|
|
+ TextFeld *ret = new TextFeld();
|
|
|
|
+ ret->setStyle( style );
|
|
|
|
+ ret->setSchriftZ( zSchrift->getThis() );
|
|
|
|
+ ret->setText( txt );
|
|
|
|
+ ret->setSchriftFarbe( 0xFFFFFFFF );
|
|
|
|
+ ret->setSchriftSize( 12 );
|
|
|
|
+ if( ret->hatStyle( TextFeld::Style::Buffered ) )
|
|
|
|
+ {
|
|
|
|
+ ret->setAlphaFeldFarbe( 0x5500FF00 );
|
|
|
|
+ ret->setAlphaFeldStrength( -5 );
|
|
|
|
+ }
|
|
|
|
+ if( ret->hatStyle( TextFeld::Style::Rahmen ) )
|
|
|
|
+ {
|
|
|
|
+ ret->setLinienRahmenBreite( 1 );
|
|
|
|
+ ret->setLinienRahmenFarbe( 0xFF00FF00 );
|
|
|
|
+ }
|
|
|
|
+ ret->setPosition( x, y );
|
|
|
|
+ ret->setSize( br, hö );
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+KontrollKnopf *initKontrollKnopf( int x, int y, int br, int hö, Schrift *zSchrift, int style, char *txt )
|
|
|
|
+{
|
|
|
|
+ KontrollKnopf *ret = new KontrollKnopf();
|
|
|
|
+ ret->setStyle( style );
|
|
|
|
+ ret->setSchriftZ( zSchrift->getThis() );
|
|
|
|
+ ret->setText( txt );
|
|
|
|
+ ret->setSText( txt );
|
|
|
|
+ ret->setSFarbe( 0xFFFFFFFF );
|
|
|
|
+ ret->setSSize( 12 );
|
|
|
|
+ if( ret->hatStyle( TextFeld::Style::Buffered ) )
|
|
|
|
+ {
|
|
|
|
+ ret->setAlphaFeldFarbe( 0x5500FF00 );
|
|
|
|
+ ret->setAlphaFeldStrength( -5 );
|
|
|
|
+ }
|
|
|
|
+ if( ret->hatStyle( TextFeld::Style::Rahmen ) )
|
|
|
|
+ {
|
|
|
|
+ ret->setLinienRahmenBreite( 1 );
|
|
|
|
+ ret->setLinienRahmenFarbe( 0xFF00FF00 );
|
|
|
|
+ }
|
|
|
|
+ ret->setPosition( x, y );
|
|
|
|
+ ret->setSize( br, hö );
|
|
|
|
+ ret->loadData( "../data/system.ltdb" );
|
|
|
|
+ ret->setMausEreignis( _ret1ME );
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Inhalt der GUI Klasse aus GUI.h
|
|
|
|
+// Konstruktor
|
|
|
|
+GUI::GUI( Schrift *zSchrift )
|
|
|
|
+{
|
|
|
|
+ laden = initKnopf( 10, 740, 100, 20, zSchrift, Knopf::Style::Sichtbar, "Laden" );
|
|
|
|
+ speichern = initKnopf( 630, 740, 100, 20, zSchrift, Knopf::Style::Sichtbar, "Speichern" );
|
|
|
|
+ pfad = initTextFeld( 120, 740, 300, 20, zSchrift, TextFeld::Style::TextFeld, "Dateipfad" );
|
|
|
|
+ suchen = initKnopf( 430, 740, 80, 20, zSchrift, Knopf::Style::Normal, "Durchsuchen" );
|
|
|
|
+ name = initTextFeld( 520, 740, 100, 20, zSchrift, TextFeld::Style::TextFeld, "Name" );
|
|
|
|
+ textur = initKontrollKnopf( 10, 770, 70, 20, zSchrift, KontrollKnopf::Style::Normal, "Textur" );
|
|
|
|
+ texturSpeichern = initKnopf( 90, 770, 100, 20, zSchrift, Knopf::Style::Sichtbar, "Textur Speichern" );
|
|
|
|
+ texturPfad = initTextFeld( 200, 770, 220, 20, zSchrift, TextFeld::Style::TextFeld, "Textur Pfad" );
|
|
|
|
+ texturSuchen = initKnopf( 430, 770, 80, 20, zSchrift, Knopf::Style::Normal, "Durchsuchen" );
|
|
|
|
+ texturName = initTextFeld( 520, 770, 100, 20, zSchrift, TextFeld::Style::TextFeld, "Textur Name" );
|
|
|
|
+ texturLaden = initKnopf( 630, 770, 100, 20, zSchrift, Knopf::Style::Sichtbar, "Textur Laden" );
|
|
|
|
+ data = new Data( 0 );
|
|
|
|
+ editor = new Editor2D( zSchrift );
|
|
|
|
+ editor->setDataZ( data->getThis() );
|
|
|
|
+ liste = new EditorListe( zSchrift );
|
|
|
|
+ liste->setDataZ( data->getThis() );
|
|
|
|
+ ref = 1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Destruktor
|
|
|
|
+GUI::~GUI()
|
|
|
|
+{
|
|
|
|
+ editor->release();
|
|
|
|
+ liste->release();
|
|
|
|
+ speichern->release();
|
|
|
|
+ laden->release();
|
|
|
|
+ pfad->release();
|
|
|
|
+ suchen->release();
|
|
|
|
+ name->release();
|
|
|
|
+ data->release();
|
|
|
|
+ textur->release();
|
|
|
|
+ texturSpeichern->release();
|
|
|
|
+ texturPfad->release();
|
|
|
|
+ texturSuchen->release();
|
|
|
|
+ texturName->release();
|
|
|
|
+ texturLaden->release();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// nicht constant
|
|
|
|
+void GUI::doMausEreignis( MausEreignis &me )
|
|
|
|
+{
|
|
|
|
+ editor->doMausEreignis( me );
|
|
|
|
+ liste->doMausEreignis( me );
|
|
|
|
+ bool vera = me.verarbeitet;
|
|
|
|
+ speichern->doMausEreignis( me );
|
|
|
|
+ if( me.id == ME_RLinks && me.verarbeitet && !vera )
|
|
|
|
+ {
|
|
|
|
+ M2Datei d;
|
|
|
|
+ d.setPfad( pfad->zText()->getText() );
|
|
|
|
+ d.leseDaten();
|
|
|
|
+ Model2DData *md = data->getM2();
|
|
|
|
+ d.saveModel( md, name->zText()->getText() );
|
|
|
|
+ md->release();
|
|
|
|
+ }
|
|
|
|
+ vera = me.verarbeitet;
|
|
|
|
+ laden->doMausEreignis( me );
|
|
|
|
+ if( me.id == ME_RLinks && me.verarbeitet && !vera )
|
|
|
|
+ {
|
|
|
|
+ M2Datei d;
|
|
|
|
+ d.setPfad( pfad->zText()->getText() );
|
|
|
|
+ d.leseDaten();
|
|
|
|
+ Model2DData *md = d.ladeModel( name->zText()->getText() );
|
|
|
|
+ if( md )
|
|
|
|
+ {
|
|
|
|
+ data->release();
|
|
|
|
+ data = new Data( md );
|
|
|
|
+ editor->setDataZ( data->getThis() );
|
|
|
|
+ liste->setDataZ( data->getThis() );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ MessageBox( 0, "Das Objekt wurde nicht gefunden.", "Fehler", MB_ICONERROR );
|
|
|
|
+ }
|
|
|
|
+ vera = me.verarbeitet;
|
|
|
|
+ suchen->doMausEreignis( me );
|
|
|
|
+ if( me.id == ME_RLinks && me.verarbeitet && !vera )
|
|
|
|
+ {
|
|
|
|
+ DateiDialog d;
|
|
|
|
+ d.addDateiTyp( "2D Modell Datei", "*.m2" );
|
|
|
|
+ Text *path = d.anzeigen( 1 );
|
|
|
|
+ if( path )
|
|
|
|
+ pfad->setText( path );
|
|
|
|
+ }
|
|
|
|
+ vera = me.verarbeitet;
|
|
|
|
+ texturSuchen->doMausEreignis( me );
|
|
|
|
+ if( me.id == ME_RLinks && me.verarbeitet && !vera )
|
|
|
|
+ {
|
|
|
|
+ DateiDialog d;
|
|
|
|
+ d.addDateiTyp( "Bild Archiv", "*.ltdb" );
|
|
|
|
+ Text *path = d.anzeigen( 1 );
|
|
|
|
+ if( path )
|
|
|
|
+ texturPfad->setText( path );
|
|
|
|
+ }
|
|
|
|
+ pfad->doMausEreignis( me );
|
|
|
|
+ name->doMausEreignis( me );
|
|
|
|
+ textur->doMausEreignis( me );
|
|
|
|
+ data->setRTextur( textur->hatStyle( KontrollKnopf::Style::Selected ) );
|
|
|
|
+ vera = me.verarbeitet;
|
|
|
|
+ texturSpeichern->doMausEreignis( me );
|
|
|
|
+ if( !vera && me.verarbeitet && me.id == ME_RLinks )
|
|
|
|
+ data->saveTextur();
|
|
|
|
+ texturPfad->doMausEreignis( me );
|
|
|
|
+ texturName->doMausEreignis( me );
|
|
|
|
+ vera = me.verarbeitet;
|
|
|
|
+ texturLaden->doMausEreignis( me );
|
|
|
|
+ if( !vera && me.verarbeitet && me.id == ME_RLinks )
|
|
|
|
+ {
|
|
|
|
+ LTDBDatei bd;
|
|
|
|
+ bd.setDatei( texturPfad->getText() );
|
|
|
|
+ bd.leseDaten( 0 );
|
|
|
|
+ Bild *t = bd.laden( 0, texturName->getText() );
|
|
|
|
+ if( !t )
|
|
|
|
+ MessageBox( 0, "Das Bild wurde nicht gefunden.", "Fehler", MB_ICONERROR );
|
|
|
|
+ else
|
|
|
|
+ data->setTextur( t );
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void GUI::doTastaturEreignis( TastaturEreignis &te )
|
|
|
|
+{
|
|
|
|
+ editor->doTastaturEreignis( te );
|
|
|
|
+ pfad->doTastaturEreignis( te );
|
|
|
|
+ name->doTastaturEreignis( te );
|
|
|
|
+ texturPfad->doTastaturEreignis( te );
|
|
|
|
+ texturName->doTastaturEreignis( te );
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool GUI::tick( double zeit )
|
|
|
|
+{
|
|
|
|
+ rend |= editor->tick( zeit );
|
|
|
|
+ rend |= liste->tick( zeit );
|
|
|
|
+ rend |= speichern->tick( zeit );
|
|
|
|
+ rend |= laden->tick( zeit );
|
|
|
|
+ rend |= pfad->tick( zeit );
|
|
|
|
+ rend |= suchen->tick( zeit );
|
|
|
|
+ rend |= name->tick( zeit );
|
|
|
|
+ rend |= textur->tick( zeit );
|
|
|
|
+ rend |= texturSpeichern->tick( zeit );
|
|
|
|
+ rend |= texturName->tick( zeit );
|
|
|
|
+ rend |= texturPfad->tick( zeit );
|
|
|
|
+ rend |= texturSuchen->tick( zeit );
|
|
|
|
+ rend |= texturLaden->tick( zeit );
|
|
|
|
+ bool ret = rend;
|
|
|
|
+ rend = 0;
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void GUI::render( Bild &zRObj )
|
|
|
|
+{
|
|
|
|
+ editor->render( zRObj );
|
|
|
|
+ liste->render( zRObj );
|
|
|
|
+ speichern->render( zRObj );
|
|
|
|
+ laden->render( zRObj );
|
|
|
|
+ pfad->render( zRObj );
|
|
|
|
+ suchen->render( zRObj );
|
|
|
|
+ name->render( zRObj );
|
|
|
|
+ textur->render( zRObj );
|
|
|
|
+ texturSpeichern->render( zRObj );
|
|
|
|
+ texturPfad->render( zRObj );
|
|
|
|
+ texturSuchen->render( zRObj );
|
|
|
|
+ texturName->render( zRObj );
|
|
|
|
+ texturLaden->render( zRObj );
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Reference Counting
|
|
|
|
+GUI *GUI::getThis()
|
|
|
|
+{
|
|
|
|
+ ref++;
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+GUI *GUI::release()
|
|
|
|
+{
|
|
|
|
+ ref--;
|
|
|
|
+ if( !ref )
|
|
|
|
+ delete this;
|
|
|
|
+ return 0;
|
|
|
|
+}
|