Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 13, 2017, 4:20:31 PM (7 years ago)
Author:
fanconic
Message:

Das StoryModeHUD.cc wurde kompiliert und ist momentan bugfrei. Es funktioniert ein Text an einer gewuenschten Stelle im Spiel zu generieren,

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

Legend:

Unmodified
Added
Removed
  • code/branches/CampaignMap_HS17/src/modules/overlays/hud/CMakeLists.txt

    r11353 r11560  
    2727  LastTeamStandingInfos.cc
    2828  CountDown.cc
     29  StoryModeHUD.cc
    2930)
  • code/branches/CampaignMap_HS17/src/modules/overlays/hud/StoryModeHUD.cc

    r11544 r11560  
    6868    {
    6969        RegisterObject(StoryModeHUD);
    70  
     70
    7171        // Set default values
    72         this->setFont("Monofur");
    73         this->setTextSize(0.5f);
     72        //this->setFont("Monofur");
     73        //this->setTextSize(0.5f);
     74
     75        // Scales used for dimensions and text size
     76        float xScale = this->getActualSize().x;
     77        float yScale = this->getActualSize().y;
     78
     79        // Create text
     80        text_ = static_cast<Ogre::TextAreaOverlayElement*>( Ogre::OverlayManager::getSingleton()
     81                .createOverlayElement("TextArea", "StoryModeHUD_navText_" + getUniqueNumberString()));
     82        //text->setFontName(this->fontName_);
     83        //text->setCharHeight(this->textSize_ * yScale);
     84        text_->setDimensions(xScale, yScale);
     85
     86        text_->hide();
     87       
     88        this->background_->addChild(text_);
    7489    }
    7590
     
    102117        }
    103118        this->fontName_ = font;
    104         for (const auto& mapEntry : this->activeObjectList_)
    105         {
    106             if (mapEntry.second.text_ != nullptr)
    107                 mapEntry.second.text_->setFontName(this->fontName_);
    108         }
     119        if(text_ != nullptr)
     120            text_->setFontName(this->fontName_);
    109121    }
    110122   
     
    124136        }
    125137        this->textSize_ = size;
    126         for (const auto& mapEntry : this->activeObjectList_)
    127         {
    128             if (mapEntry.second.text_)
    129                 mapEntry.second.text_->setCharHeight(size);
    130         }
     138       
    131139    }
    132140
     
    151159
    152160
    153                     //display name next to cursor
    154                     //TODO: Planet.getName()
    155                     text_->setCaption("Hello Muthafuckin' World!");
     161        //display name next to cursor
     162        //TODO: Planet.getName()
     163        text_->setCaption("Was geht ab?");
    156164
    157                     // Transform to screen coordinates
    158                     Vector3 pos = camTransform *  planet->getRVWorldPosition();
     165        // Transform to screen coordinates
     166        Vector3 pos = camTransform * Vector3(0,0,0); // planet->getRVWorldPosition();
     167
     168        // If you fly passed the description, it gets out of sight
     169        if (pos.z > 1.0)
     170            return;
    159171       
    160                     // Position text
    161                     text_->setLeft((pos.x + 1.0f + it->second.panel_->getWidth()) * 0.5f);
    162                     it->second.text_->setTop((-pos.y + 1.0f + it->second.panel_->getHeight()) * 0.5f);
     172        // Position text
     173        text_->setLeft((pos.x+1)/2); // The (0,0) Coordinate is in the upper left corner.
     174        text_->setTop((-pos.y+1)/2);  // With those two calculations we set the desired positions
    163175
    164                     // Make sure the overlays are shown
    165                     it->second.text_->show();
     176        // Make sure the overlays are shown
     177        text_->show();
    166178
    167179    }
    168180
    169     void StoryModeHUD::addObject()
    170     {
    171         // Scales used for dimensions and text size
    172         float xScale = this->getActualSize().x;
    173         float yScale = this->getActualSize().y;
     181    //void StoryModeHUD::addObject()
    174182
    175         // Create text
    176         Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*>( Ogre::OverlayManager::getSingleton()
    177                 .createOverlayElement("TextArea", "StoryModeHUD_navText_" + getUniqueNumberString()));
    178         text->setFontName(this->fontName_);
    179         text->setCharHeight(this->textSize_ * yScale);
    180         text->setColour(object->getRadarObjectColour());
    181 
    182         text->hide();
    183        
    184         this->background_->addChild(text);
    185     }
    186 
    187     void StoryModeHUD::removeObject(RadarViewable* viewable)
     183    /*void StoryModeHUD::removeObject(RadarViewable* viewable)
    188184    {
    189185        Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.text_);
    190     }
     186    }*/
    191187}
Note: See TracChangeset for help on using the changeset viewer.