Эх сурвалжийг харах

Objekt styles können im editor eingestellt werden un objekte können gelöscht werden

Kolja Strohm 5 жил өмнө
parent
commit
0f975dc11e

+ 65 - 1
Asteroids/Editor/Interface/RightTools/ObjektOptionen/ObjektOptionen.cpp

@@ -65,6 +65,7 @@ ObjektTool::ObjektTool( Schrift *zSchrift, KarteDaten *daten )
                             o.pos.x = 0;
                             o.pos.y = 0;
                             o.rot = 0;
+                            o.style = 0;
                             this->daten->addObjekt( o, [ this ]( int id )
                             {
                                 objekte->addEintrag( Text( id ) );
@@ -147,7 +148,13 @@ ObjektTool::ObjektTool( Schrift *zSchrift, KarteDaten *daten )
     anz = daten->getTeamAnzahl();
     for( int i = 0; i < anz; i++ )
         team->addEintrag( daten->getTeamName( i ) );
-    speichern = initKnopf( 0, 695, 100, 20, zSchrift, Knopf::Style::Normal, "Speichern" );
+    verwundbar = initKontrollKnopf( 0, 695, 145, 20, zSchrift, KontrollKnopf::Style::Normal, "Verwundbar" );
+    beweglich = initKontrollKnopf( 150, 695, 145, 20, zSchrift, KontrollKnopf::Style::Normal, "Beweglich" );
+    collision = initKontrollKnopf( 0, 720, 145, 20, zSchrift, KontrollKnopf::Style::Normal, "Kollision" );
+    laserCollision = initKontrollKnopf( 150, 720, 145, 20, zSchrift, KontrollKnopf::Style::Normal, "Laser Kollision" );
+    neutral = initKontrollKnopf( 0, 745, 145, 20, zSchrift, KontrollKnopf::Style::Normal, "Neutral" );
+    erfahrung = initKontrollKnopf( 150, 745, 145, 20, zSchrift, KontrollKnopf::Style::Normal, "Treffer Erfahrung" );
+    speichern = initKnopf( 0, 770, 100, 20, zSchrift, Knopf::Style::Normal, "Speichern" );
     speichern->setMausEreignis( [ this ]( void *p, void *o, MausEreignis me )
     {
         if( me.id == ME_RLinks )
@@ -165,12 +172,35 @@ ObjektTool::ObjektTool( Schrift *zSchrift, KarteDaten *daten )
                     o->reparatur = *reparatur->zText();
                     o->akkuLeistung = *akkuLeistung->zText();
                     o->team = team->getAuswahl();
+                    o->style = 0;
+                    if( verwundbar->hatStyle( KontrollKnopf::Style::Selected ) )
+                        o->style |= 0x1;
+                    if( beweglich->hatStyle( KontrollKnopf::Style::Selected ) )
+                        o->style |= 0x2;
+                    if( collision->hatStyle( KontrollKnopf::Style::Selected ) )
+                        o->style |= 0x4;
+                    if( laserCollision->hatStyle( KontrollKnopf::Style::Selected ) )
+                        o->style |= 0x8;
+                    if( neutral->hatStyle( KontrollKnopf::Style::Selected ) )
+                        o->style |= 0x10;
+                    if( erfahrung->hatStyle( KontrollKnopf::Style::Selected ) )
+                        o->style |= 0x20;
                     o->update();
                 } );
             } );
         }
         return 1;
     } );
+    löschen = initKnopf( 105, 770, 100, 20, zSchrift, Knopf::Style::Normal, "Löschen" );
+    löschen->setMausEreignis( [ this ]( void *p, void *o, MausEreignis me )
+    {
+        if( me.id == ME_RLinks )
+        {
+            this->daten->removeObjekt( this->daten->getObjektIndexById( *objekte->zEintrag( objekte->getAuswahl() )->zText() ) );
+            selectObject( 0 );
+        }
+        return 1;
+    } );
     selectObject( 0 );
 }
 
@@ -198,7 +228,14 @@ ObjektTool::~ObjektTool()
     akkuLeistungT->release();
     akkuLeistung->release();
     team->release();
+    verwundbar->release();
+    beweglich->release();
+    collision->release();
+    laserCollision->release();
+    neutral->release();
+    erfahrung->release();
     speichern->release();
+    löschen->release();
     daten->release();
     schrift->release();
 }
@@ -235,7 +272,14 @@ void ObjektTool::doMausEreignis( MausEreignis & me )
     energieRadius->doMausEreignis( me );
     reparatur->doMausEreignis( me );
     akkuLeistung->doMausEreignis( me );
+    verwundbar->doMausEreignis( me );
+    beweglich->doMausEreignis( me );
+    collision->doMausEreignis( me );
+    laserCollision->doMausEreignis( me );
+    neutral->doMausEreignis( me );
+    erfahrung->doMausEreignis( me );
     speichern->doMausEreignis( me );
+    löschen->doMausEreignis( me );
     me.mx += pos.x;
     me.my += pos.y;
     if( hatStyleNicht( Zeichnung::Style::Sichtbar ) )
@@ -278,7 +322,14 @@ bool ObjektTool::tick( double tickVal )
     rend |= reparatur->tick( tickVal );
     rend |= akkuLeistung->tick( tickVal );
     rend |= team->tick( tickVal );
+    rend |= verwundbar->tick( tickVal );
+    rend |= beweglich->tick( tickVal );
+    rend |= collision->tick( tickVal );
+    rend |= laserCollision->tick( tickVal );
+    rend |= neutral->tick( tickVal );
+    rend |= erfahrung->tick( tickVal );
     rend |= speichern->tick( tickVal );
+    rend |= löschen->tick( tickVal );
     return RightTool::tick( tickVal );
 }
 
@@ -304,7 +355,14 @@ void ObjektTool::render( Bild & rObj )
         reparatur->render( rObj );
         akkuLeistungT->render( rObj );
         akkuLeistung->render( rObj );
+        verwundbar->render( rObj );
+        beweglich->render( rObj );
+        collision->render( rObj );
+        laserCollision->render( rObj );
+        neutral->render( rObj );
+        erfahrung->render( rObj );
         speichern->render( rObj );
+        löschen->render( rObj );
         team->render( rObj );
         rObj.releaseDrawOptions();
     }
@@ -364,6 +422,12 @@ void ObjektTool::selectObject( int id )
         akkuLeistung->setText( Text( o->akkuLeistung ) );
         team->setAuswahl( Text( o->team ) );
         model->addStyle( M2DVorschau::Style::Sichtbar );
+        verwundbar->setStyle( KontrollKnopf::Style::Selected, ( o->style | 0x1 ) == o->style );
+        beweglich->setStyle( KontrollKnopf::Style::Selected, ( o->style | 0x2 ) == o->style );
+        collision->setStyle( KontrollKnopf::Style::Selected, ( o->style | 0x4 ) == o->style );
+        laserCollision->setStyle( KontrollKnopf::Style::Selected, ( o->style | 0x8 ) == o->style );
+        neutral->setStyle( KontrollKnopf::Style::Selected, ( o->style | 0x10 ) == o->style );
+        erfahrung->setStyle( KontrollKnopf::Style::Selected, ( o->style | 0x20 ) == o->style );
         changeModel->addStyle( M2DVorschau::Style::Sichtbar );
         changeTextur->addStyle( M2DVorschau::Style::Sichtbar );
         stabilitätT->addStyle( M2DVorschau::Style::Sichtbar );

+ 7 - 0
Asteroids/Editor/Interface/RightTools/ObjektOptionen/ObjektOptionen.h

@@ -28,7 +28,14 @@ namespace Editor
         TextFeld *akkuLeistungT;
         TextFeld *akkuLeistung;
         AuswahlBox *team;
+        KontrollKnopf *verwundbar;
+        KontrollKnopf *beweglich;
+        KontrollKnopf *collision;
+        KontrollKnopf *laserCollision;
+        KontrollKnopf *neutral;
+        KontrollKnopf *erfahrung;
         Knopf *speichern;
+        Knopf *löschen;
         KarteDaten *daten;
         Schrift *schrift;
         Text modelPath;

+ 20 - 4
Asteroids/Editor/Karte/EditorKarte.cpp

@@ -44,16 +44,24 @@ ObjektDaten::ObjektDaten( const ObjektDaten &daten )
 }
 
 
-EditorObject::EditorObject()
+EditorObject::EditorObject( EditorObject::ObjektTyp typ, int id )
     : Model2DObject()
-{}
+{
+    this->typ = typ;
+    this->id = id;
+}
 
 EditorObject::~EditorObject()
 {}
 
+bool EditorObject::isObjekt( EditorObject::ObjektTyp typ, int id )
+{
+    return this->typ == typ && this->id == id;
+}
+
 
 EdSpieler::EdSpieler( SpielerDaten *model )
-    : EditorObject()
+    : EditorObject( SPIELER, model->id )
 {
     mdl = model;
 }
@@ -70,7 +78,7 @@ void EdSpieler::update()
 
 
 EdObjekt::EdObjekt( ObjektDaten *model )
-    : EditorObject()
+    : EditorObject( OBJEKT, model->id )
 {
     mdl = model;
 }
@@ -336,6 +344,14 @@ void KarteDaten::removeObjekt( int index )
 {
     cs.lock();
     int id = objekte.get( index )->id;
+    EditorObject *obj = 0;
+    for( auto o = welt->getMembers(); o; o++ )
+    {
+        obj = (EditorObject *)o._;
+        if( obj->isObjekt( EditorObject::OBJEKT, id ) )
+            break;
+    }
+    welt->removeObject( obj );
     delete objekte.get( index );
     objekte.remove( index );
     EditorKlient *c = client;

+ 13 - 1
Asteroids/Editor/Karte/EditorKarte.h

@@ -88,9 +88,21 @@ namespace Editor
     class EditorObject : public Model2DObject
     {
     public:
-        EditorObject();
+        enum ObjektTyp
+        {
+            SPIELER,
+            OBJEKT
+        };
+
+    private:
+        ObjektTyp typ;
+        int id;
+
+    public:
+        EditorObject( ObjektTyp typ, int id );
         virtual ~EditorObject();
         virtual void update() = 0;
+        bool isObjekt( ObjektTyp typ, int id );
     };
 
     class EdSpieler : public EditorObject