Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 15, 2018, 12:11:04 AM (6 years ago)
Author:
landauf
Message:

[CampaignMap_HS17] some cleanup

Location:
code/branches/Presentation_HS17_merge/src/modules/overlays/hud
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Presentation_HS17_merge/src/modules/overlays/hud/StoryModeHUD.cc

    r11743 r11745  
    6666    {
    6767        RegisterObject(StoryModeHUD);
     68
     69        this->textSize_ = 1.0;
    6870    }
    6971
    7072    // Destructor of the StoryMode HUD
    7173    StoryModeHUD::~StoryModeHUD()
    72     {}
     74    {
     75        for(Ogre::TextAreaOverlayElement* text : texts)
     76            Ogre::OverlayManager::getSingleton().destroyOverlayElement(text);
     77    }
    7378
    7479    // Functions of the StoryMode HUD
     
    9297        CameraManager::getInstance().getActiveCamera()->setOrientation(Vector3::UNIT_X, Degree(-30));
    9398
    94         int i = 0;
    9599        for(NameableStaticEntity* planet : ObjectList<NameableStaticEntity>()){
    96100
     
    100104
    101105            texts.push_back(text);
    102             texts[i]->setDimensions(xScale, yScale);
     106            text->setDimensions(xScale, yScale);
    103107
    104108            //font name of the text needs to be set here, not in the xml setter function
    105             texts[i]->setFontName(this->fontName_);
    106             texts[i]->setCharHeight(this->textSize_ * yScale);
     109            text->setFontName(this->fontName_);
     110            text->setCharHeight(this->textSize_ * yScale);
    107111
    108112            //set text
    109             texts[i]->setCaption(planet->getLevelName());
     113            text->setCaption(planet->getLevelName());
    110114
    111             texts[i]->hide();
     115            text->hide();
    112116       
    113             this->background_->addChild(texts[i]);
    114             i++;
     117            this->background_->addChild(text);
    115118        }
    116119    }
     
    170173        const Matrix4& camTransform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix();
    171174
    172         int i = 0;
     175        size_t i = 0;
    173176        for(NameableStaticEntity* planet : ObjectList<NameableStaticEntity>()){
     177            if (i >= texts.size()) {
     178                break;
     179            }
     180            Ogre::TextAreaOverlayElement* text = texts[i];
     181            i++;
    174182
    175183            // Transform to screen coordinates
     
    180188                   
    181189                // Position text
    182                 texts[i]->setLeft((pos.x+1)/2); // The (0,0) Coordinate is in the upper left corner.
    183                 texts[i]->setTop((-pos.y+1)/2);  // With those two calculations we set the desired positions
     190                text->setLeft((pos.x+1)/2); // The (0,0) Coordinate is in the upper left corner.
     191                text->setTop((-pos.y+1)/2);  // With those two calculations we set the desired positions
    184192
    185193                // Make sure the overlays are shown
    186                 texts[i]->show();
     194                text->show();
    187195            }
    188             i++;
    189 
    190196        }
    191197    }
  • code/branches/Presentation_HS17_merge/src/modules/overlays/hud/StoryModeHUD.h

    r11743 r11745  
    5050            virtual void tick(float dt) override;
    5151
     52        private:
     53            void initialize();
    5254
    53         private:
    54             std::vector<Ogre::TextAreaOverlayElement*> texts;
    55             void initialize();
    56             virtual void setTextSize(float size);
    57             virtual float getTextSize() const;
     55            void setTextSize(float size);
     56            float getTextSize() const;
    5857
    59             virtual void setFont(const std::string& font);
     58            void setFont(const std::string& font);
    6059            const std::string& getFont() const;
    6160
     61            std::vector<Ogre::TextAreaOverlayElement*> texts;
    6262            std::string fontName_;
    6363            float textSize_;
Note: See TracChangeset for help on using the changeset viewer.