Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11353


Ignore:
Timestamp:
Mar 9, 2017, 2:46:20 PM (7 years ago)
Author:
patricwi
Message:

merged HUD branch to trunk

Location:
code/trunk
Files:
17 edited
4 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/README

    r9398 r11353  
    2020Cheers,
    2121The Orxonox Development Team
     22
  • code/trunk/data/defaultConfig/keybindings.ini

    r10622 r11353  
    7070KeyNoConvert=
    7171KeyNumLock=
    72 KeyNumRow0=
    73 KeyNumRow1="toggleFormationFlight"
    74 KeyNumRow2="FFChangeMode"
    75 KeyNumRow3=
    76 KeyNumRow4=
    77 KeyNumRow5=
    78 KeyNumRow6=
    79 KeyNumRow7=
    80 KeyNumRow8=
    81 KeyNumRow9=
    82 KeyNumpad0=
    83 KeyNumpad1=
    84 KeyNumpad2=
    85 KeyNumpad3=
    86 KeyNumpad4=
    87 KeyNumpad5=
    88 KeyNumpad6=
    89 KeyNumpad7=
    90 KeyNumpad8=
    91 KeyNumpad9=
     72KeyNumRow0="useUnusePickup 0"
     73KeyNumRow1="useUnusePickup 1"
     74KeyNumRow2="useUnusePickup 2"
     75KeyNumRow3="useUnusePickup 3"
     76KeyNumRow4="useUnusePickup 4"
     77KeyNumRow5="useUnusePickup 5"
     78KeyNumRow6="useUnusePickup 6"
     79KeyNumRow7="useUnusePickup 7"
     80KeyNumRow8="useUnusePickup 8"
     81KeyNumRow9="useUnusePickup 9"
     82KeyNumpad0="useUnusePickup 0"
     83KeyNumpad1="useUnusePickup 1"
     84KeyNumpad2="useUnusePickup 2"
     85KeyNumpad3="useUnusePickup 3"
     86KeyNumpad4="useUnusePickup 4"
     87KeyNumpad5="useUnusePickup 5"
     88KeyNumpad6="useUnusePickup 6"
     89KeyNumpad7="useUnusePickup 7"
     90KeyNumpad8="useUnusePickup 8"
     91KeyNumpad9="useUnusePickup 9"
    9292KeyNumpadAdd=
    9393KeyNumpadComma=
     
    9696KeyNumpadPeriod=
    9797KeyNumpadSubtract=
    98 KeyO=
    99 KeyP=
     98KeyO="toggleFormationFlight"
     99KeyP="FFChangeMode"
    100100KeyPageDown="scale -1 rotateRoll"
    101101KeyPageUp=
  • code/trunk/data/gui/scripts/KeyBindMenu.lua

    r8232 r11353  
    3636    table.insert(commandList, "pause")
    3737    table.insert(commandList, "printScreen")
     38    table.insert(commandList, "useUnusePickup")
    3839    if orxonox.GUIManager:inDevMode() then
    3940        table.insert(commandList, "printScreenHD")
     
    7172    table.insert(nameList, "Pause")
    7273    table.insert(nameList, "Screenshot")
     74    table.insert(nameList, "Pickup 0")
    7375    if orxonox.GUIManager:inDevMode() then
    7476        table.insert(nameList, "HD screenshot")
  • code/trunk/data/overlays/HUDTemplates3.oxo

    r11052 r11353  
    185185    />
    186186   
     187    <HUDPickupSystem
     188     name                   = "PickupSystem"
     189     correctaspect          = true
     190     position               = "0.32, 0.81"
     191     pickpoint              = "0.0, 0.0"
     192     visible                = "true"
     193    />
     194
    187195    <HUDTimer
    188196     name     = "Timer"
    189      position = "0.5, 0.85"
     197     position = "0.5, 0.25"
    190198     font     = "VeraMono"
    191199     textsize = 0.1
  • code/trunk/data/overlays/HUDTemplatesFPS.oxo

    r11104 r11353  
    104104    />
    105105
     106    <HUDPickupSystem
     107     name                   = "PickupSystem"
     108     correctaspect          = true
     109     position               = "0.45, 0.95"
     110     pickpoint              = "0.0, 0.0"
     111     visible                = "true"
     112    />
     113
    106114    <HUDTimer
    107115     name     = "Timer"
  • code/trunk/src/modules/overlays/OverlaysPrereqs.h

    r11052 r11353  
    104104    class PauseNotice;
    105105    class TeamBaseMatchScore;
     106    class HUDPickupSystem;
     107    class HUDPickupItem;
    106108
    107109    // stats
  • code/trunk/src/modules/overlays/hud/CMakeLists.txt

    r11052 r11353  
    1414  HUDWeapon.cc
    1515  HUDWeaponSystem.cc
     16  HUDPickupItem.cc
     17  HUDPickupSystem.cc
    1618  ChatOverlay.cc
    1719  AnnounceMessage.cc
  • code/trunk/src/modules/pickup/CMakeLists.txt

    r9348 r11353  
    1919    PickupPrecompiledHeaders.h
    2020  LINK_LIBRARIES
     21    overlays
    2122    orxonox
    2223  SOURCE_FILES ${PICKUP_SRC_FILES}
  • code/trunk/src/modules/pickup/PickupManager.cc

    r11099 r11353  
    4141#include "network/Host.h"
    4242#include "network/NetworkFunctionIncludes.h"
     43#include "core/input/KeyBinderManager.h"    //for keybinding
     44#include "core/input/KeyBinder.h"           //for keybinding
     45#include "core/command/ConsoleCommandIncludes.h"
    4346
    4447#include "infos/PlayerInfo.h"
     
    4851#include "CollectiblePickup.h"
    4952#include "PickupRepresentation.h"
     53#include "overlays/hud/HUDPickupSystem.h"
    5054
    5155namespace orxonox
     
    6367
    6468    RegisterAbstractClass(PickupManager).inheritsFrom<PickupListener>();
     69
     70    SetConsoleCommand("useUnusePickup", &PickupManager::useUnusePickup).addShortcut().setActive(true);
    6571
    6672    /**
     
    260266        assert(pickup);
    261267
     268        for (HUDPickupSystem* hud : ObjectList<HUDPickupSystem>())
     269            pickupSystem = hud;
     270       
    262271        if(!GameMode::isMaster()) // If this is neither standalone nor the server.
    263272            return;
     
    283292        if(pickedUp) // If the Pickupable has changed to picked up, it is added to the required lists.
    284293        {
    285             index = this->getPickupIndex(); // Ge a new identifier (index) for the Pickupable.
     294            index = this->getPickupIndex(); // Get a new identifier (index) for the Pickupable.
    286295            // Add the Pickupable to the indexes_ and pickups_ lists.
    287296            this->indexes_[pickup] = index;
    288297            this->pickups_[index] = pickup;
     298
     299            this->picks.push_back(pickup);
     300
     301            if(pickupSystem)
     302                pickupSystem->updatePickupList(picks, indexes_);
     303           
    289304        }
    290305        else // If it was dropped, it is removed from the required lists.
     
    294309            index = it->second;
    295310
    296             // Remove the Pickupable from the indexes_ and pickups_ list.
    297             this->indexes_.erase(it);
    298             this->pickups_.erase(index);
     311            this->indexes_.erase(pickup);
     312            this->pickups_.erase(index); //set to null, so that can be identified as free slot by getPickupIndex()
     313
     314
     315            this->picks.erase(std::remove(this->picks.begin(), this->picks.end(), pickup), this->picks.end()); //remove pickup from vector
     316
     317            if(pickupSystem)
     318                pickupSystem->removePickup(pickup);
    299319        }
    300320
     
    323343
    324344    }
     345
     346    //This function is called by the command line or by the key binding
     347    //it uses or unuses the pickup, depending on its current state
     348    //or drops it (depends what you comment/uncomment)
     349    void PickupManager::useUnusePickup(uint32_t index)
     350    {
     351        PickupManager& manager = PickupManager::getInstance();
     352
     353        if(!manager.pickups_.count(index)) return; //if pickup is no longer here, dont do anything
     354
     355        Pickupable* pickup=manager.pickups_.find(index)->second;
     356        if(pickup==nullptr)
     357        {
     358            return;                       //pickup does not exist
     359        }
     360
     361        //if the pickup should be dropped upon key press
     362        manager.dropPickup(index);
     363
     364        //if the pickup should be used/unused upon key press
     365
     366        // if(pickup->isUsed())
     367        //     manager.usePickup(index, false);
     368        // else
     369        //     manager.usePickup(index, true);
     370    }
     371
    325372
    326373    /**
     
    402449            Pickupable* pickupable = this->pickups_.find(pickup)->second;
    403450            if(pickupable != nullptr)
     451            {
    404452                pickupable->drop();
     453
     454            }
    405455        }
    406456        // If we're neither server nor standalone we drop the pickup by calling dropPickupNetworked() of the PickupManager on the server.
     
    495545    /**
    496546    @brief
    497         Get a new index for a Pickupable.
    498         This will work as long as the number of Pickupables that are picked up is sufficiently small and as long as they don't exist forever.
     547        Get a new index between 0 and 9 for a Pickupable.
     548        If all slots are occupied, the Pickupable in the first slot will be dropped.
    499549    @return
    500550        Returns the new index.
     
    502552    uint32_t PickupManager::getPickupIndex(void)
    503553    {
    504         if(this->pickupHighestIndex_ == uint32_t(~0x0)-1) // If we've reached the highest possible number, we wrap around.
    505             this->pickupHighestIndex_ = 0;
    506         return this->pickupHighestIndex_++;
     554        //check if there are free slots available
     555
     556        for(uint32_t i=0; i<10; i++)
     557        {
     558            if(!pickups_.count(i)) return i;
     559        }
     560        //all slots are full and we have to drop sth
     561        orxout(internal_info, context::pickups) << "everything was full and we have now dropped the first element" << endl;
     562        this->dropPickup(0);
     563        return 0;
    507564    }
    508565
  • code/trunk/src/modules/pickup/PickupManager.h

    r11071 r11353  
    4242
    4343#include "PickupRepresentation.h"
    44 
     44#include "interfaces/Pickupable.h"
    4545#include "util/Singleton.h"
    4646#include "interfaces/PickupListener.h"
     47#include "overlays/hud/HUDPickupSystem.h"
    4748
    4849namespace orxonox // tolua_export
     
    135136
    136137            void dropPickup(uint32_t pickup); //!< Drop the input Pickupable.
     138            static void useUnusePickup(uint32_t index); //tolua_export
    137139            void usePickup(uint32_t pickup, bool use); //!< Use (or unuse) the input Pickupable.
    138140             /**
     
    147149            static void dropPickupNetworked(uint32_t pickup); //!< Helper method to drop the input pickup on the server.
    148150            static void usePickupNetworked(uint32_t pickup, bool use); //!< Helper method to use (or unuse) the input Pickupable on the server.
     151            void setPickupSystem(HUDPickupSystem* system);
    149152
    150153        private:
     154            HUDPickupSystem* pickupSystem;
     155            std::vector<Pickupable*> picks;
     156
    151157            static PickupManager* singletonPtr_s;
    152158            static const std::string guiName_s; //!< The name of the PickupInventory
     
    166172            void updateGUI(void); //!< Updates the PickupInventory GUI.
    167173            uint32_t getPickupIndex(void); //!< Get a new index for a Pickupable.
    168 
     174           
    169175    }; // tolua_export
    170176
  • code/trunk/src/modules/pickup/items/SpeedPickup.h

    r9667 r11353  
    4848        A Pickup which can manipulate the Speed of a Pawn.
    4949
    50         There are 5 parameters that can be cosen:
     50        There are 5 parameters that can be chosen:
    5151        - The @b speedMultiply, specifies a factor by which the Spaceships speed is multiplied. The default is 1.
    5252        - The @b speedAdd, specifies a value that is added to the speed of the Spaceship. The default is 0.
  • code/trunk/src/orxonox/CMakeLists.txt

    r11080 r11353  
    2020INCLUDE_DIRECTORIES(
    2121  ${CMAKE_SOURCE_DIR}/src/libraries
     22  ${CMAKE_SOURCE_DIR}/src/modules
    2223  ${CMAKE_CURRENT_SOURCE_DIR}
    2324)
  • code/trunk/src/orxonox/controllers/HumanController.h

    r11071 r11353  
    6969            void stopBoosting(void);
    7070
    71 
    7271            static void greet();
    7372            static void switchCamera();
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r11071 r11353  
    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/trunk/src/orxonox/gamestates/GSLevel.h

    r11071 r11353  
    3131
    3232#include "OrxonoxPrereqs.h"
     33// #include "overlays/OverlaysPrereqs.h"
    3334
    3435#include <string>
  • code/trunk/src/orxonox/interfaces/Pickupable.h

    r11071 r11353  
    9696
    9797            /**
     98            @brief Check whether the Pickupable is in the process of being destroyed.
     99            @return Returns true if so.
     100            */
     101            inline bool isBeingDestroyed(void)
     102                { return this->beingDestroyed_; }
     103               
     104            /**
    98105            @brief Returns whether the Pickupable is currently picked up.
    99106            @return Returns true if the Pickupable is currently picked up, false if not.
     
    155162
    156163            /**
    157             @brief Check whether the Pickupable is in the process of being destroyed.
    158             @return Returns true if so.
    159             */
    160             inline bool isBeingDestroyed(void)
    161                 { return this->beingDestroyed_; }
    162 
    163             /**
    164164            @brief Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
    165165                   This method must be implemented by any class directly inheriting from Pickupable.
Note: See TracChangeset for help on using the changeset viewer.