Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 12, 2016, 4:20:50 PM (8 years ago)
Author:
patricwi
Message:

finished version of HUD and PickupSystem. crash bug remaining

Location:
code/branches/HUD_HS16/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc

    r11325 r11336  
    5353        overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", name ));
    5454
    55         overlayElement_->setDimensions(0.075f,0.1f);
     55        overlayElement_->setDimensions(0.075f,0.08f);
    5656       
    5757    }
     
    6767    void HUDPickupItem::initializeMaterial(const std::string& s, float x, float y)
    6868    {
    69         orxout() << "material name is: " << s << endl;
    7069        overlayElement_->setMaterialName(s);
    7170        overlayElement_->setPosition(x, y);
     
    7978        assert(overlayElement_);
    8079        assert(this->background_);
    81         // if(p->isBeingDestroyed()) //if the pickup is being destroyed, we do nothing
    82         // {
    83         //     orxout() << "now i didnt repaint" << endl;
    84         //     return;
    85         // }
    86         orxout() << "name overlay element: " << overlayElement_->getName() << endl;
    87         // orxout() << this << " has called hide" << endl;
    8880        overlayElement_->hide();
    8981        this->background_->removeChild(overlayElement_->getName());
    90         // this->background_->_update();
    91         // orxout() << "after the call the element is visible: " << overlayElement_->isVisible() << endl;
    9282    }
    9383}
  • code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h

    r11325 r11336  
    2626        Ogre::PanelOverlayElement* overlayElement_;
    2727        virtual ~HUDPickupItem();
    28 
    29         // virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    30         // virtual void tick(float dt) override;
    31         // virtual void changedOwner() override;
    32         // virtual void changedOverlayGroup() override;
    33         // virtual void changedVisibility() override;
    34         // virtual void changedName() override;
    35         // virtual void positionChanged() override;
    36         // virtual void sizeChanged() override;
    37 
    38         // void setPickup(Pickup* pickup); 
     28       
    3929        void initializeMaterial(const std::string& s, float x, float y); 
    4030        void hideMe(Pickupable* p, bool repaint);
    4131
    42     private:
    43         // void createHUDChilds();
    44         // void positionHUDChilds();
    45         // void destroyHUDChilds();
    46         // void updateWeaponModeList();
    47         // void updateSize();
    48         // void updatePosition();
    49 
    50        
     32    private:       
    5133        WeakPtr<Pawn> owner_;
    5234        WeakPtr<Pickup> pickup_;
  • code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc

    r11325 r11336  
    6262    }
    6363
    64     void HUDPickupSystem::updatePickupList(std::vector<Pickupable*> picks)
     64    void HUDPickupSystem::updatePickupList(std::vector<Pickupable*> picks, std::map<Pickupable*, uint32_t> indexes_)
    6565    {
    66         int i=0;
    67         const float offsetX = 0.335f;
    68         float offsetY = 0.77f;
    69         const float x = 0.1f;
    70 
    71         orxout() << "size: " << picks.size() << endl;
     66        int i =0;
     67        const float offsetX = 0.345f;
     68        float offsetY = 0.82f;
     69        const float x = 0.102f;
    7270
    7371        if(picks.size()>0)
    7472        {
    75 
    7673            for(Pickupable* p : picks)
    7774            {
    78                 // orxout() << "actual pick is: " << p << endl;
    79                 if(i%5==0)
     75                i = indexes_.find(p)->second;
     76                offsetY = 0.82f;
     77
     78                if(i>=5)
    8079                {
    81                     offsetY+=0.04f;
    82                     i=0;
     80                    offsetY+=0.075f;
     81                    i-=5;
    8382                }   
    8483                if(this->picks.count(p)==0)
     
    8685                    HUDPickupItem* item = new HUDPickupItem(this->getContext());
    8786                    item->initializeMaterial(this->getIcon(((Pickup*)p)->getRepresentationName()), offsetX+i*x, offsetY);
    88                     orxout() << ((Pickup*)p)->getRepresentationName() << endl;
    8987               
    9088                    item->setOverlayGroup(this->getOverlayGroup());
    9189                    this->picks[p] = item;
    9290                }
    93                
    94                 ++i;
    9591            }
    9692        }
     
    105101        assert(pickup);
    106102        HUDPickupItem* item = this->picks.find(pickup)->second;
    107         orxout() << "removePickup: pickup= " << pickup << " item= " << item << endl;
     103        orxout(internal_info, context::pickups) << "removePickup: pickup= " << pickup << " item= " << item << endl;
    108104        assert(item);
    109         // item->setOverlayGroup(nullptr);
    110105        item->hideMe(pickup, repaint);
    111106        assert(overlayElement_);
    112         // overlayElement_->_update();
    113107        assert(this->background_);
    114         // this->background_->_update();
    115108        this->picks.erase(pickup);
    116109    }
     
    124117    {
    125118        if(repName.find("invisible", 0)!=std::string::npos) return "Eye";
    126         else if(repName.find("tri", 0)!=std::string::npos) return "Asterix";
     119        else if(repName.find("tri", 0)!=std::string::npos) return "Asterisk";
    127120        else if(repName.find("health", 0)!=std::string::npos || repName.find("Health", 0)!=std::string::npos) return "Cross";
    128121        else if(repName.find("shield", 0)!=std::string::npos) return "Shield";
     
    132125        else if(repName.find("speed", 0)!=std::string::npos) return "3arrowsup";
    133126        else if(repName.find("drone", 0)!=std::string::npos) return "Damage";
    134         //        else if(repName.find("xxxxxxx", 0)!=std::string::npos) return "Splash";
    135127        else return "Unknown";
    136128    }
  • code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h

    r11325 r11336  
    5656        virtual ~HUDPickupSystem();
    5757
    58         // virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    59         // virtual void changedOwner() override;
    60         // virtual void changedOverlayGroup() override;
    61         // virtual void changedVisibility() override;
    62         // virtual void changedName() override;
    63         // virtual void positionChanged() override;
    64         // virtual void sizeChanged() override;
    65         void updatePickupList(std::vector<Pickupable*> picks); 
     58        void updatePickupList(std::vector<Pickupable*> picks, std::map<Pickupable*, uint32_t> indexes_); 
    6659        void createPickupList(); 
    6760        void removePickup(Pickupable* pickup);
    6861
    69         bool repaint=true;
     62        bool repaint=true; //if we shouldnt repaint, set this to false
    7063
    7164    private:
  • code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc

    r11325 r11336  
    266266        assert(pickup);
    267267
    268 
    269268        for (HUDPickupSystem* hud : ObjectList<HUDPickupSystem>())
    270269            pickupSystem = hud;
    271270       
    272         assert(pickupSystem); //pickupSystem HAS to be there!
    273 
    274271        if(!GameMode::isMaster()) // If this is neither standalone nor the server.
    275272            return;
     
    300297            this->pickups_[index] = pickup;
    301298
    302             orxout() << "the pickup is: " << pickup << endl;
    303 
    304299            this->picks.push_back(pickup);
    305300
    306             pickupSystem->updatePickupList(picks);
     301            if(pickupSystem)
     302                pickupSystem->updatePickupList(picks, indexes_);
    307303           
    308304        }
     
    319315            this->picks.erase(std::remove(this->picks.begin(), this->picks.end(), pickup), this->picks.end()); //remove pickup from vector
    320316
    321             pickupSystem->removePickup(pickup);
     317            if(pickupSystem)
     318                pickupSystem->removePickup(pickup);
    322319        }
    323320
     
    349346    //This function is called by the command line or by the key binding
    350347    //it uses or unuses the pickup, depending on its current state
     348    //or drops it (depends what you comment/uncomment)
    351349    void PickupManager::useUnusePickup(uint32_t index)
    352350    {
    353         orxout() << "Hello there I was here " << index << endl;
    354 
    355351        PickupManager& manager = PickupManager::getInstance();
    356352
     
    360356        if(pickup==nullptr)
    361357        {
    362             orxout() << "The pickup does not exist." << endl;
    363358            return;                       //pickup does not exist
    364359        }
    365360
    366         orxout() << "The pickup is being used: " << pickup->isUsed() << endl;
    367 
     361        //if the pickup should be dropped upon key press
    368362        manager.dropPickup(index);
     363
     364        //if the pickup should be used/unused upon key press
    369365
    370366        // if(pickup->isUsed())
     
    563559        }
    564560        //all slots are full and we have to drop sth
    565         orxout() << "everything was full and we have now dropped the first element" << endl;
     561        orxout(internal_info, context::pickups) << "everything was full and we have now dropped the first element" << endl;
    566562        this->dropPickup(0);
    567563        return 0;
  • code/branches/HUD_HS16/src/modules/pickup/PickupManager.h

    r11314 r11336  
    172172            void updateGUI(void); //!< Updates the PickupInventory GUI.
    173173            uint32_t getPickupIndex(void); //!< Get a new index for a Pickupable.
    174 
    175             void addKeyBindingForNewPickup(Pickupable* pickup, uint32_t index);
    176             void removeKeyBindingForOldPickup(Pickupable* pickup, uint32_t index);
    177174           
    178175    }; // tolua_export
  • code/branches/HUD_HS16/src/orxonox/gamestates/GSLevel.cc

    r11071 r11336  
    5050#include "PlayerManager.h"
    5151#include "GSRoot.h"
     52// #include "overlays/hud/HUDPickupSystem.h"
    5253
    5354namespace orxonox
     
    126127            InputManager::getInstance().leaveState("game");
    127128
     129        // HUDPickupSystem* pickupSystem;
     130
     131        // for (HUDPickupSystem* hud : ObjectList<HUDPickupSystem>())
     132        //     pickupSystem = hud;
     133
     134        // pickupSystem->repaint=false;
     135
    128136        // disconnect all HumanPlayers
    129137        PlayerManager::getInstance().disconnectAllClients();
  • code/branches/HUD_HS16/src/orxonox/gamestates/GSLevel.h

    r11071 r11336  
    3131
    3232#include "OrxonoxPrereqs.h"
     33// #include "overlays/OverlaysPrereqs.h"
    3334
    3435#include <string>
Note: See TracChangeset for help on using the changeset viewer.