Advertisement
Guest User

ArmorObjectMenuComponent.cpp

a guest
Jan 21st, 2019
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.32 KB | None | 0 0
  1. /*
  2.  * ArmorObjectMenuComponent.cpp
  3.  */
  4.  
  5. #include "server/zone/objects/creature/CreatureObject.h"
  6. #include "server/zone/objects/player/PlayerObject.h"
  7. #include "server/zone/objects/building/BuildingObject.h"
  8. #include "server/zone/objects/player/sui/colorbox/SuiColorBox.h"
  9. #include "ArmorObjectMenuComponent.h"
  10. #include "server/zone/packets/object/ObjectMenuResponse.h"
  11. #include "server/zone/objects/player/sui/callbacks/ColorArmorSuiCallback.h"
  12. #include "server/zone/ZoneServer.h"
  13. #include "templates/customization/AssetCustomizationManagerTemplate.h"
  14.  
  15. void ArmorObjectMenuComponent::fillObjectMenuResponse(SceneObject* sceneObject, ObjectMenuResponse* menuResponse, CreatureObject* player) const {
  16.  
  17.     if (!sceneObject->isWearableObject())
  18.         return;
  19.  
  20.     ManagedReference<SceneObject*> parent = sceneObject->getParent().get();
  21.  
  22.     if (parent != NULL && parent->isCellObject()) {
  23.         ManagedReference<SceneObject*> obj = parent->getParent().get();
  24.  
  25.         if (obj != NULL && obj->isBuildingObject()) {
  26.             ManagedReference<BuildingObject*> buio = cast<BuildingObject*>(obj.get());
  27.  
  28.             if (!buio->isOnAdminList(player))
  29.                 return;
  30.         }
  31.     }
  32.     else
  33.     {
  34.         if (!sceneObject->isASubChildOf(player))
  35.             return;
  36.     }
  37.  
  38.     if (!parent->isPlayerCreature()) {
  39.                 menuResponse->addRadialMenuItem(81, 3, "Modify Color");
  40.         }
  41.    
  42.     WearableObjectMenuComponent::fillObjectMenuResponse(sceneObject, menuResponse, player);    
  43. }
  44.  
  45. int ArmorObjectMenuComponent::handleObjectMenuSelect(SceneObject* sceneObject, CreatureObject* player, byte selectedID) const {
  46.  
  47.     if (selectedID == 81) {
  48.        
  49.         ManagedReference<SceneObject*> parent = sceneObject->getParent().get();
  50.    
  51.         if (parent == NULL)
  52.             return 0;
  53.    
  54.         if (parent->isPlayerCreature()) {
  55.             player->sendSystemMessage("@armor_rehue:equipped");
  56.             return 0;
  57.         }  
  58.  
  59.         if (parent->isCellObject()) {
  60.             ManagedReference<SceneObject*> obj = parent->getParent().get();
  61.  
  62.             if (obj != NULL && obj->isBuildingObject()) {
  63.                 ManagedReference<BuildingObject*> buio = cast<BuildingObject*>(obj.get());
  64.  
  65.                 if (!buio->isOnAdminList(player))
  66.                     return 0;
  67.             }
  68.         }
  69.         else
  70.         {
  71.             if (!sceneObject->isASubChildOf(player))
  72.                 return 0;
  73.         }
  74.  
  75.         ZoneServer* server = player->getZoneServer();
  76.  
  77.         if (server != NULL)
  78.         {      
  79.  
  80.         // The color index.
  81.         String appearanceFilename = sceneObject->getObjectTemplate()->getAppearanceFilename();
  82.         VectorMap<String, Reference<CustomizationVariable*> > variables;
  83.         AssetCustomizationManagerTemplate::instance()->getCustomizationVariables(appearanceFilename.hashCode(), variables, false);
  84.  
  85.         for(int i = 0; i < variables.size(); i++)
  86.         {
  87.             String varkey = variables.elementAt(i).getKey();
  88.                 if (varkey.contains("color"))
  89.                 {
  90.                    
  91.                     // The Sui Box.
  92.                     ManagedReference<SuiColorBox*> cbox = new SuiColorBox(player, SuiWindowType::COLOR_ARMOR);
  93.                     cbox->setCallback(new ColorArmorSuiCallback(server));
  94.                     cbox->setColorPalette(variables.elementAt(i).getKey()); // First one seems to be the frame of it? Skip to 2nd.
  95.                     cbox->setUsingObject(sceneObject);
  96.  
  97.                     // Add to player.
  98.                     ManagedReference<PlayerObject*> ghost = player->getPlayerObject();
  99.                     ghost->addSuiBox(cbox);
  100.                     player->sendMessage(cbox->generateMessage());
  101.                    
  102.                 }
  103.         }
  104.         }
  105.     }
  106.    
  107.     return WearableObjectMenuComponent::handleObjectMenuSelect(sceneObject, player, selectedID);
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement