Skip to content

Instantly share code, notes, and snippets.

@Anach
Created November 27, 2016 03:08
Show Gist options
  • Select an option

  • Save Anach/b7a7ba01aa2be5a6c193476e80e72067 to your computer and use it in GitHub Desktop.

Select an option

Save Anach/b7a7ba01aa2be5a6c193476e80e72067 to your computer and use it in GitHub Desktop.
Adding armour secondary recolouring.
/*
* ArmorObjectMenuComponent.cpp
*
* Created on: 2/4/2013
* Author: bluree
* Credits: TA & Valk
*/
#include "server/zone/objects/creature/CreatureObject.h"
#include "server/zone/objects/player/PlayerObject.h"
#include "server/zone/objects/building/BuildingObject.h"
#include "server/zone/objects/player/sui/colorbox/SuiColorBox.h"
#include "ArmorObjectMenuComponent.h"
#include "server/zone/objects/scene/components/ObjectMenuComponent.h"
#include "server/zone/packets/object/ObjectMenuResponse.h"
#include "server/zone/objects/player/sui/SuiCallback.h"
#include "server/zone/objects/player/sui/callbacks/ColorArmorSuiCallback.h"
#include "server/zone/Zone.h"
#include "server/zone/ZoneServer.h"
#include "templates/customization/AssetCustomizationManagerTemplate.h"
void ArmorObjectMenuComponent::fillObjectMenuResponse(SceneObject* sceneObject, ObjectMenuResponse* menuResponse, CreatureObject* player) const {
if (!sceneObject->isWearableObject())
return;
ManagedReference<SceneObject*> parent = sceneObject->getParent().get();
if (parent != NULL && parent->isCellObject()) {
ManagedReference<SceneObject*> obj = parent->getParent().get();
if (obj != NULL && obj->isBuildingObject()) {
ManagedReference<BuildingObject*> buio = cast<BuildingObject*>(obj.get());
if (!buio->isOnAdminList(player))
return;
}
}
else
{
if (!sceneObject->isASubChildOf(player))
return;
}
String text = "Color Change";
menuResponse->addRadialMenuItem(81, 3, text);
menuResponse->addRadialMenuItem(82, 3, "@sui:color_frame");
WearableObjectMenuComponent::fillObjectMenuResponse(sceneObject, menuResponse, player);
}
int ArmorObjectMenuComponent::handleObjectMenuSelect(SceneObject* sceneObject, CreatureObject* player, byte selectedID) const {
if (selectedID == 81 || selectedID == 82) {
ManagedReference<SceneObject*> parent = sceneObject->getParent().get();
if (parent == NULL)
return 0;
if (parent->isPlayerCreature()) {
player->sendSystemMessage("@armor_rehue:equipped");
return 0;
}
if (parent->isCellObject()) {
ManagedReference<SceneObject*> obj = parent->getParent().get();
if (obj != NULL && obj->isBuildingObject()) {
ManagedReference<BuildingObject*> buio = cast<BuildingObject*>(obj.get());
if (!buio->isOnAdminList(player))
return 0;
}
}
else
{
if (!sceneObject->isASubChildOf(player))
return 0;
}
ZoneServer* server = player->getZoneServer();
if (server != NULL) {
// The color index.
String appearanceFilename = sceneObject->getObjectTemplate()->getAppearanceFilename();
VectorMap<String, Reference<CustomizationVariable*> > variables;
AssetCustomizationManagerTemplate::instance()->getCustomizationVariables(appearanceFilename.hashCode(), variables, false);
// The Sui Box.
ManagedReference<SuiColorBox*> cbox = new SuiColorBox(player, SuiWindowType::COLOR_ARMOR);
cbox->setCallback(new ColorArmorSuiCallback(server));
if (selectedID == 81)
cbox->setColorPalette(variables.elementAt(1).getKey()); // First one seems to be the frame of it? Skip to 2nd.
else
cbox->setColorPalette(variables.elementAt(0).getKey());
cbox->setUsingObject(sceneObject);
// Add to player.
ManagedReference<PlayerObject*> ghost = player->getPlayerObject();
ghost->addSuiBox(cbox);
player->sendMessage(cbox->generateMessage());
}
}
return WearableObjectMenuComponent::handleObjectMenuSelect(sceneObject, player, selectedID);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment