void JukeboxImplementation::doMusicSelection(CreatureObject* player) {
	PlayerObject* ghost = player->getPlayerObject();

	if (ghost == NULL)
		return;

	PlayerManager* playerManager = player->getZoneServer()->getPlayerManager();

	if (playerManager == NULL)
		return;

	ManagedReference<SuiListBox*> listbox = new SuiListBox(player, SuiWindowType::JUKEBOX_SELECTION);
    listbox->setCallback(new JukeboxSelectionSuiCallback(server->getZoneServer()));
	listbox->setPromptTitle("@event_perk_jukebox_songs:songs_t"); // Music Select
	listbox->setPromptText("@event_perk_jukebox_songs:songs_d"); // Select a song to play from the list below.
	listbox->setUsingObject(_this.getReferenceUnsafeStaticCast());
	listbox->setForceCloseDistance(32.f);
	listbox->setCancelButton(true, "@cancel");

	int songListSize = playerManager->getNumJukeboxSongs();
	JukeboxSong* song = NULL;

	for (int i = 0; i < songListSize; i++) {
		song = playerManager->getJukeboxSong(i);

		if (song != NULL) {
			listbox->addMenuItem(song->getStringId());
		}
	}

	ghost->addSuiBox(listbox);
	player->sendMessage(listbox->generateMessage());
}
void ScavengerDroidImplementation::sendItemListSUI(CreatureObject* player) {
	PlayerObject* ghost = player->getPlayerObject();

	if (ghost == NULL)
		return;

	if (itemList.size() == 0) {
		player->sendSystemMessage("@event_perk:scavenger_no_items");
		return;
	}

	ManagedReference<SuiListBox*> listbox = new SuiListBox(player, SuiWindowType::SCAVENGER_ITEM_LIST);
	listbox->setPromptTitle("@event_perk:scavenger_list_t"); // Scavenger Hunt List
	listbox->setPromptText("@event_perk:scavenger_list_d"); // Below you will find the list of items you need to find for the scavenger hunt. Good luck!
	listbox->setUsingObject(_this.getReferenceUnsafeStaticCast());
	listbox->setForceCloseDistance(32.f);
	listbox->setCancelButton(true, "@cancel");

	for (int i = 0; i < itemList.size(); i++) {
		String itemTemplate = itemList.get(i);
		listbox->addMenuItem(TemplateManager::instance()->getTemplate(itemTemplate.hashCode())->getObjectName());
	}

	ghost->addSuiBox(listbox);
	player->sendMessage(listbox->generateMessage());
}
void FireworkShowMenuComponent::showData(CreatureObject* player, FireworkObject* fireworkShow) const {
	ManagedReference<PlayerObject*> ghost = player->getPlayerObject();
	if (ghost == NULL || ghost->hasSuiBoxWindowType(SuiWindowType::FIREWORK_SHOW_ADDEVENT) || ghost->hasSuiBoxWindowType(SuiWindowType::FIREWORK_SHOW_REMOVEEVENT)
			|| ghost->hasSuiBoxWindowType(SuiWindowType::FIREWORK_SHOW_REORDERSHOW) || ghost->hasSuiBoxWindowType(SuiWindowType::FIREWORK_SHOW_MODIFYEVENT)
				|| ghost->hasSuiBoxWindowType(SuiWindowType::FIREWORK_SHOW_DELAYSELECTION)) {
		return;
	}

	DataObjectComponent* data = fireworkShow->getDataObjectComponent()->get();

	if (data == NULL || !data->isFireworkShowData())
		return;

	FireworkShowDataComponent* fireworkShowData = cast<FireworkShowDataComponent*>(data);

	Locker plocker(player);

	ManagedReference<SuiListBox*> suiBox = new SuiListBox(player, SuiWindowType::FIREWORK_SHOW_ADDEVENT, SuiListBox::HANDLESINGLEBUTTON);
	suiBox->setPromptTitle("@firework:data_title");
	suiBox->setPromptText("@firework:data_prompt");
	suiBox->setOkButton(true, "@ok");
	suiBox->setUsingObject(fireworkShow);

	int totalFireworks = fireworkShowData->getTotalFireworkCount();

	for (int i = 0; i < totalFireworks; i++) {
		ManagedReference<FireworkObject*> firework = fireworkShowData->getFirework(i);
		String fireworkDelay = String::valueOf(float(fireworkShowData->getFireworkDelay(i)) / 1000.f);
		String menuItem = "(" + String::valueOf(i) + ":" + fireworkDelay + "s) " + firework->getDisplayedName();
		suiBox->addMenuItem(menuItem);
	}

	ghost->addSuiBox(suiBox);
	player->sendMessage(suiBox->generateMessage());
}
Example #4
0
	void GroupManager::sendMasterLooterList(GroupObject* group, CreatureObject* leader) {
		//Pre: Leader and group are locked
		//Post: Leader and group are locked

		if (group == NULL || leader == NULL)
			return;

		ManagedReference<PlayerObject*> ghost = leader->getPlayerObject();
		if (ghost == NULL)
			return;

		//Close SUI box if already open.
		ghost->closeSuiWindowType(SuiWindowType::GROUP_LOOT_PICK_LOOTER);

		//Create Master Looter selection list box.
		ManagedReference<SuiListBox*> sui = new SuiListBox(leader, SuiWindowType::GROUP_LOOT_PICK_LOOTER);
		sui->setPromptTitle("@group:master_looter_sui_title"); //"Select Master Looter"
		sui->setPromptText("@group:choose_master_looter"); //"Choose a Master Looter from the list of available players:"
		sui->setCancelButton(true, "@ui:cancel");
		sui->setOkButton(true, "@ui:ok");
		sui->setCallback(new GroupLootPickLooterSuiCallback(leader->getZoneServer()));

		for (int i = 0; i < group->getGroupSize(); ++i) {
			ManagedReference<CreatureObject*> member = (group->getGroupMember(i)).castTo<CreatureObject*>();
				if (member == NULL || !member->isPlayerCreature())
					continue;

			sui->addMenuItem(member->getFirstName(), member->getObjectID());
		}

		//Send list box to the group leader.
		ghost->addSuiBox(sui);
		leader->sendMessage(sui->generateMessage());
	}
int DestroyStructureSessionImplementation::initializeSession() {
	//TODO: Temporary until CreatureObject* dependency removed.
	if (!creatureObject->isPlayerCreature())
		return cancelSession();

	creatureObject->addActiveSession(SessionFacadeType::DESTROYSTRUCTURE, _this.getReferenceUnsafeStaticCast());

	Locker _lock(structureObject, creatureObject);

	CreatureObject* player = cast<CreatureObject*>( creatureObject.get());

	String no = "\\#FF6347 @player_structure:can_redeed_no_suffix \\#.";
	String yes = "\\#32CD32 @player_structure:can_redeed_yes_suffix \\#.";

	String redeed = (structureObject->isRedeedable()) ? yes : no;

	StringBuffer maint;
	maint << "@player_structure:redeed_maintenance \\#" << ((structureObject->isRedeedable()) ? "32CD32 " : "FF6347 ") << structureObject->getSurplusMaintenance() << "/" << structureObject->getRedeedCost() << "\\#.";

	StringBuffer entry;
	entry << "@player_structure:confirm_destruction_d1 ";
	entry << "@player_structure:confirm_destruction_d2 \n\n";
	entry << "@player_structure:confirm_destruction_d3a ";
	entry << "\\#32CD32 @player_structure:confirm_destruction_d3b \\#. ";
	entry << "@player_structure:confirm_destruction_d4 \n";
	entry << "@player_structure:redeed_confirmation " << redeed;

	StringBuffer cond;
	cond << "@player_structure:redeed_condition \\#32CD32 " << (structureObject->getMaxCondition() - structureObject->getConditionDamage()) << "/" << structureObject->getMaxCondition() << "\\#.";

	ManagedReference<SuiListBox*> sui = new SuiListBox(player);
	sui->setCallback(new DestroyStructureRequestSuiCallback(creatureObject->getZoneServer()));
	sui->setCancelButton(true, "@no");
	sui->setOkButton(true, "@yes");
	sui->setUsingObject(structureObject);
	sui->setPromptTitle(structureObject->getDisplayedName());
	sui->setPromptText(entry.toString());

	sui->addMenuItem("@player_structure:can_redeed_alert " + redeed);
	sui->addMenuItem(cond.toString());
	sui->addMenuItem(maint.toString());

	player->getPlayerObject()->addSuiBox(sui);
	player->sendMessage(sui->generateMessage());

	return 0;
}
Example #6
0
void SuiManager::sendListBox(SceneObject* usingObject, SceneObject* player, const String& title, const String& text, const uint8& numOfButtons, const String& cancelButton, const String& otherButton, const String& okButton, LuaObject& options, const String& screenplay, const String& callback) {
	if (usingObject == NULL)
		return;

	if (player == NULL || !player->isCreatureObject())
		return;

	CreatureObject* creature = cast<CreatureObject*>(player);

	PlayerObject* playerObject = creature->getPlayerObject();

	if (playerObject != NULL) {

		ManagedReference<SuiListBox*> box = NULL;

		switch (numOfButtons) {
		case 1:
			box = new SuiListBox(creature, 0x00, SuiListBox::HANDLESINGLEBUTTON);
			box->setCancelButton(false, "");
			box->setOtherButton(false, "");
			box->setOkButton(true, okButton);
			break;
		case 2:
			box = new SuiListBox(creature, 0x00, SuiListBox::HANDLETWOBUTTON);
			box->setCancelButton(true, cancelButton);
			box->setOtherButton(false, "");
			box->setOkButton(true, okButton);
			break;
		case 3:
			box = new SuiListBox(creature, 0x00, SuiListBox::HANDLETHREEBUTTON);
			box->setCancelButton(true, cancelButton);
			box->setOtherButton(true, otherButton);
			box->setOkButton(true, okButton);
			break;
		default:
			return;
			break;
		}

		if(options.isValidTable()){
			for(int i = 1; i <= options.getTableSize(); ++i){
				String optionString = options.getStringAt(i);
				box->addMenuItem(optionString);
			}
			options.pop();
		}

		box->setCallback(new LuaSuiCallback(creature->getZoneServer(), screenplay, callback));
		box->setPromptTitle(title);
		box->setPromptText(text);
		box->setUsingObject(usingObject);
		box->setForceCloseDistance(32.f);

		creature->sendMessage(box->generateMessage());
		playerObject->addSuiBox(box);
	}
}
void PlantObjectImplementation::sendResourceSUI(CreatureObject* player, int type) {
	ManagedReference<PlayerObject*> ghost = player->getPlayerObject();

	if (ghost == NULL)
		return;

	ManagedReference<SuiListBox*> suiBox = new SuiListBox(player, SuiWindowType::GROWABLE_PLANT, SuiListBox::HANDLETWOBUTTON);
	suiBox->setCallback(new GrowablePlantSuiCallback(player->getZoneServer()));
	suiBox->setPromptTitle("@plant_grow:select_resource_sub");
	suiBox->setPromptText("@plant_grow:select_resource_body");
	suiBox->setOkButton(true, "@ok");
	suiBox->setCancelButton(true, "@cancel");
	suiBox->setUsingObject(_this.getReferenceUnsafeStaticCast());
	suiBox->setForceCloseDistance(32.f);

	ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");
	ManagedReference<SceneObject*> sceneObject = NULL;

	for (int i=0; i< inventory->getContainerObjectsSize(); i++) {
		sceneObject = inventory->getContainerObject(i);

		if (sceneObject == NULL)
			continue;

		if (sceneObject->isResourceContainer()) {
			ManagedReference<ResourceContainer*> rcno = cast<ResourceContainer*>( sceneObject.get());

			if (rcno == NULL)
				continue;

			ManagedReference<ResourceSpawn*> spawn = rcno->getSpawnObject();

			if (spawn == NULL)
				continue;

			if ((type == 1 && spawn->isType("organic")) || (type == 2 && spawn->isType("water"))) {
				suiBox->addMenuItem(spawn->getName(), sceneObject->getObjectID());
			}
		}
	}

	if (suiBox->getMenuSize() > 0) {
		ghost->closeSuiWindowType(SuiWindowType::GROWABLE_PLANT);
		ghost->addSuiBox(suiBox);
		player->sendMessage(suiBox->generateMessage());
	} else {
		if (type == 1)
			player->sendSystemMessage("@plant_grow:no_nutrients"); // You don't have any nutrients.
		else
			player->sendSystemMessage("@plant_grow:no_water"); // You don't have any water.
	}
}
void SurveyToolImplementation::sendRangeSui(CreatureObject* player) {
	int surveyMod = player->getSkillMod("surveying");

	ManagedReference<SuiListBox*> suiToolRangeBox = new SuiListBox(player, SuiWindowType::SURVEY_TOOL_RANGE, 0);

	suiToolRangeBox->setPromptTitle("@base_player:swg");
	suiToolRangeBox->setPromptText("@survey:select_range");

	if (surveyMod >= 20)
		suiToolRangeBox->addMenuItem("64m x 3pts", 0);

	if (surveyMod >= 35)
		suiToolRangeBox->addMenuItem("128m x 4pts", 1);

	if (surveyMod >= 55)
		suiToolRangeBox->addMenuItem("192m x 4pts", 2);

	if (surveyMod >= 75)
		suiToolRangeBox->addMenuItem("256m x 5pts", 3);

	if (surveyMod >= 100)
		suiToolRangeBox->addMenuItem("320m x 5pts", 4);


	/// The options below are not true to pre-cu
	if (surveyMod >= 105)
		suiToolRangeBox->addMenuItem("384m x 5pts", 5);

	if (surveyMod >= 110)
		suiToolRangeBox->addMenuItem("448m x 5pts", 6);

	if (surveyMod >= 115)
		suiToolRangeBox->addMenuItem("512m x 5pts", 7);

	if (surveyMod >= 125)
		suiToolRangeBox->addMenuItem("1024m x 1024m", 8);

	suiToolRangeBox->setUsingObject(_this.getReferenceUnsafeStaticCast());
	suiToolRangeBox->setCallback(new SurveyToolSetRangeSuiCallback(server->getZoneServer()));
	player->getPlayerObject()->addSuiBox(suiToolRangeBox);
	player->sendMessage(suiToolRangeBox->generateMessage());
}
void VehicleObjectImplementation::sendRepairConfirmTo(CreatureObject* player) {
	ManagedReference<SuiListBox*> listbox = new SuiListBox(player, SuiWindowType::GARAGE_REPAIR);
    listbox->setCallback(new RepairVehicleSuiCallback(server->getZoneServer()));
	listbox->setPromptTitle("@pet/pet_menu:confirm_repairs_t"); //Confirm Vehicle Repairs
	listbox->setPromptText("@pet/pet_menu:vehicle_repair_d"); //You have chosen to repair your vehicle. Please review the listed details and confirm your selection.
	listbox->setUsingObject(_this.getReferenceUnsafeStaticCast());
	listbox->setCancelButton(true, "@cancel");

	int repairCost = calculateRepairCost(player);
	int totalFunds = player->getBankCredits();
	int tax = 0;

	ManagedReference<CityRegion*> city = getCityRegion();
	if(city != NULL && city->getGarageTax() > 0){
		repairCost += repairCost * city->getGarageTax() / 100;
	}

	listbox->addMenuItem("@pet/pet_menu:vehicle_prompt " + getDisplayedName()); //Vehicle:
	listbox->addMenuItem("@pet/pet_menu:repair_cost_prompt " + String::valueOf(repairCost)); //Repair Cost:
	listbox->addMenuItem("@pet/pet_menu:total_funds_prompt " + String::valueOf(totalFunds)); //Total Funds Available:

	player->getPlayerObject()->addSuiBox(listbox);
	player->sendMessage(listbox->generateMessage());
}
Example #10
0
void StructureManager::promptMaintenanceDroid(StructureObject* structure, CreatureObject* creature) {
	ManagedReference<PlayerObject*> ghost = creature->getPlayerObject();

	if (ghost == NULL)
		return;

	Vector<DroidObject*> droids;
	ManagedReference<SceneObject*> datapad = creature->getSlottedObject("datapad");
	if(datapad == NULL) {
		return;
	}
	for (int i = 0; i < datapad->getContainerObjectsSize(); ++i) {
		ManagedReference<SceneObject*> object = datapad->getContainerObject(i);

		if (object != NULL && object->isPetControlDevice()) {
			PetControlDevice* device = cast<PetControlDevice*>( object.get());

			if (device->getPetType() == PetManager::DROIDPET) {
				DroidObject* pet = cast<DroidObject*>(device->getControlledObject());
				if (pet->isMaintenanceDroid()) {
					droids.add(pet);
				}
			}
		}
	}
	if (droids.size() == 0) {
		creature->sendSystemMessage("@player_structure:no_droids");
		return;
	}

	ManagedReference<SuiListBox*> box = new SuiListBox(creature,SuiWindowType::STRUCTURE_ASSIGN_DROID);
	box->setCallback(new StructureAssignDroidSuiCallback(creature->getZoneServer()));

	box->setPromptText("@sui:assign_droid_prompt");
	box->setPromptTitle("@sui:assign_droid_title"); // Configure Effects
	box->setOkButton(true, "@ok");

	// Check if player has a droid called with a maintenance module installed
	for (int i = 0; i < droids.size(); ++i) {
		DroidObject* droidObject = droids.elementAt(i);
		box->addMenuItem(droidObject->getDisplayedName(),droidObject->getObjectID());
	}
	box->setUsingObject(structure);
	ghost->addSuiBox(box);
	creature->sendMessage(box->generateMessage());

}
void DroidStimpackModuleDataComponent::sendLoadUI(CreatureObject* player) {
	ManagedReference<SceneObject* > inventory = player->getSlottedObject("inventory");

	if (inventory == NULL)
		return;

	ManagedReference<SuiListBox*> loader = new SuiListBox(player, SuiWindowType::DROID_LOAD_STIMPACK, SuiListBox::HANDLETWOBUTTON);
	loader->setPromptTitle("@pet/droid_modules:load_stimpack");
	loader->setPromptText("@group:set_loot_type_text");
	loader->setOkButton(true, "@ok");
	loader->setCancelButton(true, "@cancel");

	for (int i = 0; i < inventory->getContainerObjectsSize(); ++i) {
		SceneObject* item = inventory->getContainerObject(i);

		if (!item->isPharmaceuticalObject())
			continue;

		// check it they have atleast 1 stim pack
		PharmaceuticalObject* pharma = cast<PharmaceuticalObject*>(item);

		if (pharma->isStimPack()) {
			StimPack* stim = cast<StimPack*>(pharma);

			if (stim->isClassA()) {
				String name;

				if (stim->getCustomObjectName().isEmpty()) {
					name = "@" + stim->getObjectNameStringIdFile() + ":" + stim->getObjectNameStringIdName();
				} else {
					name = stim->getCustomObjectName().toString();
				}

				loader->addMenuItem(name, stim->getObjectID());
			}
		}
	}

	loader->setCallback(new LoadStimpackSuiCallback(getParent()->getZoneServer()));
	loader->setUsingObject(getDroidObject());
	player->getPlayerObject()->addSuiBox(loader);
	player->sendMessage(loader->generateMessage());
}
void FireworkShowMenuComponent::reorderShow(CreatureObject* player, FireworkObject* fireworkShow) const {
	ManagedReference<PlayerObject*> ghost = player->getPlayerObject();
	if (ghost == NULL || ghost->hasSuiBoxWindowType(SuiWindowType::FIREWORK_SHOW_ADDEVENT) || ghost->hasSuiBoxWindowType(SuiWindowType::FIREWORK_SHOW_REMOVEEVENT)
			|| ghost->hasSuiBoxWindowType(SuiWindowType::FIREWORK_SHOW_REORDERSHOW) || ghost->hasSuiBoxWindowType(SuiWindowType::FIREWORK_SHOW_MODIFYEVENT)
				|| ghost->hasSuiBoxWindowType(SuiWindowType::FIREWORK_SHOW_DELAYSELECTION)) {
		return;
	}

	DataObjectComponent* data = fireworkShow->getDataObjectComponent()->get();

	if (data == NULL || !data->isFireworkShowData())
		return;

	FireworkShowDataComponent* fireworkShowData = cast<FireworkShowDataComponent*>(data);

	Locker plocker(player);

	ManagedReference<SuiListBox*> suiBox = new SuiListBox(player, SuiWindowType::FIREWORK_SHOW_REORDERSHOW, SuiListBox::HANDLETHREEBUTTON);
	suiBox->setPromptTitle("@firework:modify_index_title"); // Remove Show Event
	suiBox->setPromptText("@firework:modify_index_prompt"); // Select the event index for which you would like to modify the delay time.
	suiBox->setOkButton(true, "@ui:done");
	suiBox->setCancelButton(true, "@ui:moveup");
	suiBox->setOtherButton(true, "@ui:movedown");
	suiBox->setUsingObject(fireworkShow);

	int totalFireworks = fireworkShowData->getTotalFireworkCount();

	for (int i = 0; i < totalFireworks; i++) {
		ManagedReference<FireworkObject*> firework = fireworkShowData->getFirework(i);
		String fireworkDelay = String::valueOf(float(fireworkShowData->getFireworkDelay(i)) / 1000.f);
		String menuItem = "(" + String::valueOf(i) + ":" + fireworkDelay + "s) " + firework->getDisplayedName();
		suiBox->addMenuItem(menuItem, firework->getObjectID());
	}

	suiBox->setCallback(new FireworkShowReorderShowSuiCallback(player->getZoneServer()));
	ghost->addSuiBox(suiBox);
	player->sendMessage(suiBox->generateMessage());
}
Example #13
0
void StructureManager::reportStructureStatus(CreatureObject* creature,
		StructureObject* structure) {
	ManagedReference<PlayerObject*> ghost = creature->getPlayerObject();

	if (ghost == NULL)
		return;

	//Close the window if it is already open.
	ghost->closeSuiWindowType(SuiWindowType::STRUCTURE_STATUS);

	ManagedReference<SuiListBox*> status = new SuiListBox(creature,
			SuiWindowType::STRUCTURE_STATUS);
	status->setPromptTitle("@player_structure:structure_status_t"); //Structure Status
	status->setPromptText(
			"@player_structure:structure_name_prompt "
					+ structure->getDisplayedName()); //Structure Name:
	status->setUsingObject(structure);
	status->setOkButton(true, "@refresh");
	status->setCancelButton(true, "@cancel");
	status->setCallback(new StructureStatusSuiCallback(server));

	ManagedReference<SceneObject*> ownerObject = server->getObject(
			structure->getOwnerObjectID());

	if (ownerObject != NULL && ownerObject->isCreatureObject()) {
		CreatureObject* owner = cast<CreatureObject*>(ownerObject.get());
		status->addMenuItem(
				"@player_structure:owner_prompt " + owner->getFirstName());
	}

	uint64 declaredOidResidence = ghost->getDeclaredResidence();

	ManagedReference<BuildingObject*> declaredResidence =
			server->getObject(declaredOidResidence).castTo<BuildingObject*>();

	if (declaredResidence == structure) {
		status->addMenuItem("@player_structure:declared_residency"); //You have declared your residency here.
	}

	if (structure->isPrivateStructure() && !structure->isCivicStructure()) {
		status->addMenuItem("@player_structure:structure_private"); //This structure is private
	} else {
		status->addMenuItem("@player_structure:structure_public"); //This structure is public
	}

	status->addMenuItem(
			"@player_structure:condition_prompt "
					+ String::valueOf(structure->getDecayPercentage()) + "%");

	if (!structure->isCivicStructure()) {

		// property tax
		float propertytax = 0.f;
		if(!structure->isCivicStructure() && structure->getCityRegion() != NULL){
			ManagedReference<CityRegion*> city = structure->getCityRegion().get();
			if(city != NULL){
				propertytax = city->getPropertyTax()/ 100.f * structure->getMaintenanceRate();
				status->addMenuItem(
							"@city/city:property_tax_prompt : "
									+ String::valueOf(ceil(propertytax))
									+  " cr/hr");
			}
		}

		// maintenance
		float secsRemainingMaint = 0.f;
		if( structure->getSurplusMaintenance() > 0 ){
			float totalrate = (float)structure->getMaintenanceRate() + propertytax;
			secsRemainingMaint = ((float)structure->getSurplusMaintenance() / totalrate)*3600;
		}

		status->addMenuItem(
			"@player_structure:maintenance_pool_prompt "
					+ String::valueOf( (int) floor( (float) structure->getSurplusMaintenance()))
					+ " "
					+ getTimeString( (uint32)secsRemainingMaint ) );

		status->addMenuItem(
			"@player_structure:maintenance_rate_prompt "
					+ String::valueOf(structure->getMaintenanceRate())
					+ " cr/hr");

		status->addMenuItem(
			"@player_structure:maintenance_mods_prompt "
					+ structure->getMaintenanceMods());
	}


	if (structure->isInstallationObject() && !structure->isGeneratorObject() && !structure->isCivicStructure()) {
		InstallationObject* installation = cast<InstallationObject*>(structure);

		float secsRemainingPower = 0.f;
		if( installation->getSurplusPower() > 0 ){
			secsRemainingPower = ((float)installation->getSurplusPower() / (float)installation->getBasePowerRate())*3600;
		}

		status->addMenuItem(
				"@player_structure:power_reserve_prompt "
						+ String::valueOf( (int) installation->getSurplusPower())
						+ " "
						+ getTimeString( (uint32)secsRemainingPower ) );

		status->addMenuItem(
				"@player_structure:power_consumption_prompt "
						+ String::valueOf(
								(int) installation->getBasePowerRate())
						+ " @player_structure:units_per_hour");
	}

	if (structure->isBuildingObject()) {
		BuildingObject* building = cast<BuildingObject*>(structure);

		status->addMenuItem(
				"@player_structure:items_in_building_prompt "
						+ String::valueOf(
								building->getCurrentNumberOfPlayerItems())); //Number of Items in Building:
	}

	ghost->addSuiBox(status);
	creature->sendMessage(status->generateMessage());
}
Example #14
0
void VendorManager::handleDisplayStatus(CreatureObject* player, TangibleObject* vendor) {

	if(vendor->getZone() == NULL) {
		error("NULL zone in VendorManager::handleDisplayStatus");
		return;
	}

	DataObjectComponentReference* data = vendor->getDataObjectComponent();
	if(data == NULL || data->get() == NULL || !data->get()->isVendorData()) {
		error("Vendor has no data component");
		return;
	}

	VendorDataComponent* vendorData = cast<VendorDataComponent*>(data->get());
	if(vendorData == NULL) {
		error("Vendor has wrong data component");
		return;
	}

	ManagedReference<SuiListBox*> statusBox = new SuiListBox(player, SuiWindowType::STRUCTURE_VENDOR_STATUS);
	statusBox->setUsingObject(vendor);
	statusBox->setPromptTitle("@player_structure:vendor_status");
	statusBox->setPromptText("Vendor Status");

	ManagedReference<CreatureObject*> owner = server->getZoneServer()->getObject(vendorData->getOwnerId()).castTo<CreatureObject*>();
	String ownerName;

	if (owner == NULL)
		ownerName = "NULL";
	else
		ownerName = owner->getFirstName();

	statusBox->addMenuItem("Owner: " + ownerName);

	int condition = (((float)vendor->getMaxCondition() - (float)vendor->getConditionDamage()) / (float)vendor->getMaxCondition()) * 100;
	statusBox->addMenuItem("Condition: " + String::valueOf(condition) + "%");

	float secsRemaining = 0.f;
	if( vendorData->getMaint() > 0 ){
		secsRemaining = (vendorData->getMaint() / vendorData->getMaintenanceRate())*3600;
	}

	statusBox->addMenuItem("Maintenance Pool: " +
			               String::valueOf(vendorData->getMaint()) +
			               "cr " + getTimeString( (uint32)secsRemaining ) );
	statusBox->addMenuItem("Maintenance Rate: " + String::valueOf((int)vendorData->getMaintenanceRate()) + " cr/hr");

	ManagedReference<AuctionManager*> auctionManager = server->getZoneServer()->getAuctionManager();
	if(auctionManager == NULL) {
		error("null auction manager");
		return;
	}
	ManagedReference<AuctionsMap*> auctionsMap = auctionManager->getAuctionMap();
	if(auctionsMap == NULL) {
		error("null auctionsMap");
		return;
	}

	String planet = vendor->getZone()->getZoneName();
	String region = "@planet_n:" + vendor->getZone()->getZoneName();


	ManagedReference<CityRegion*> regionObject = vendor->getCityRegion();
	if(regionObject != NULL)
		region = regionObject->getRegionName();

	TerminalListVector vendorList = auctionsMap->getVendorTerminalData(planet, region, vendor);

	uint32 itemsForSaleCount = 0;

	if(vendorList.size() > 0) {

		Reference<TerminalItemList*> list = vendorList.get(0);
		if (list != NULL) {

			for (int j = 0; j < list->size(); ++j) {
				ManagedReference<AuctionItem*> item = list->get(j);
				if (item == NULL)
					continue;

				int itemSize = item->getSize();

				if (itemSize > 50)
					itemsForSaleCount += 50;
				else if (itemSize > 0)
					itemsForSaleCount += itemSize;
				else
					itemsForSaleCount++;
			}
		}
	}


	statusBox->addMenuItem("Number of Items For Sale: " + String::valueOf(itemsForSaleCount));

	if (vendorData->isVendorSearchEnabled())
		statusBox->addMenuItem("@player_structure:vendor_search_enabled");
	else
		statusBox->addMenuItem("@player_structure:vendor_search_disabled");

	statusBox->addMenuItem("\\#32CD32Vendor Operating Normally\\#.");

	player->getPlayerObject()->addSuiBox(statusBox);
	player->sendMessage(statusBox->generateMessage());

}
int DroidMaintenanceModuleDataComponent::handleObjectMenuSelect(CreatureObject* player, byte selectedID, PetControlDevice* controller) {

	ManagedReference<DroidObject*> droid = getDroidObject();
	if( droid == NULL ){
		info( "Droid is null");
		return 0;
	}

	Locker dlock( droid, player );

	// Perform Maintenance Run
	if( selectedID == MAINT_MODULE_PERFORM ){

		// Init Maintenance Run Session
		//droid->getCooldownTimerMap()->updateToCurrentAndAddMili("Droid_Cooldown",1800000);
		// Interplanetary Time + 1 hour 40 minutes, 33 seconds
		// Local time: distance < 432 == 15 mins + (1s per 3 meters to next structure for that planet @ < 432m from first structure)
		// Local time: distance > 432 == 48 minutes 20 seconds
		// Start a session for the player and this module!
		ManagedReference<DroidMaintenanceSession*> session = new DroidMaintenanceSession(this, player);
		session->initialize();
		player->addActiveSession(SessionFacadeType::DROIDMAINTENANCERUN, session);
		session->sendMaintanceRunBox();
		return 0;
	}
	// Edit Maintenance List
	else if( selectedID == MAINT_MODULE_EDIT ){

		if( assignedStructures.isEmpty() ){
			player->sendSystemMessage( "@pet/droid_modules:droid_maint_empty_list" ); // The maintenance list for this droid is empty. Go to one of your structures and assign this droid to maintain it.
			return 0;
		}

		// Build List of Assigned Structures
		ManagedReference<SuiListBox*> box = new SuiListBox(player, SuiWindowType::DROID_EDIT_ASSIGNED_STRUCTURES, SuiListBox::HANDLETWOBUTTON);
		box->setCallback(new RemoveDroidStructureSuiCallback(player->getZoneServer(), this));
		box->setPromptTitle("@pet/droid_modules:droid_maint_edit_title"); // Edit Maintenance List
		box->setPromptText("@pet/droid_modules:droid_maint_edit_prompt"); // Please select a structure to remove from this droid's maintenance list.

		box->setOkButton(true, "@delete");
		box->setCancelButton(true, "@cancel");

		for (int i = 0; i < assignedStructures.size(); i++) {

			uint64 objectId = assignedStructures.elementAt(i);
			ManagedReference<SceneObject*> obj = player->getZoneServer()->getObject(objectId);
			if( obj != NULL && obj->isStructureObject() ){
				StructureObject* structureObject = cast<StructureObject*>(obj.get());
				if( structureObject != NULL ){
					box->addMenuItem( structureObject->getDisplayedName(), objectId );
				}
			}
		}

		box->setUsingObject(droid);
		player->getPlayerObject()->addSuiBox(box);
		player->sendMessage(box->generateMessage());

	}

	return 0;
}
int DroidCustomKitObjectMenuComponent::handleObjectMenuSelect(SceneObject* sceneObject, CreatureObject* player, byte selectedID) {

	if (player == NULL)
		return 0;

	if (!sceneObject->isASubChildOf(player))
		return 0;

	if (selectedID != 20)
		return TangibleObjectMenuComponent::handleObjectMenuSelect(sceneObject, player, selectedID);

	if(!sceneObject->isTangibleObject())
		return 0;

	ManagedReference<TangibleObject*> kitTano = cast<TangibleObject*>(sceneObject);
	if(kitTano == NULL)
		return 0;

	uint64 targetID = player->getTargetID();
	ZoneServer* server = player->getZoneServer();
	if (server == NULL)
		return 0;

	ManagedReference<TangibleObject*> target = server->getObject(targetID, true).castTo<TangibleObject*>();
	if (target == NULL || !target->isDroidObject()) {
		player->sendSystemMessage("You can only use this tool to customize droids");
		return 0;
	}
	//permission check
	CreatureObject* droid = cast<CreatureObject*>(target.get());
	uint64 ownerID = droid->getCreatureLinkID();
	if ( ownerID != player->getObjectID()){
		bool hasConsent = false;

		ManagedReference<CreatureObject*> targetOwner = server->getObject(ownerID, true).castTo<CreatureObject*>();
		if (targetOwner != NULL)
		{
			Locker crossLock(targetOwner, player);
			ManagedReference<PlayerObject*> ghostOwner = targetOwner->getPlayerObject();
			for (int i = 0; i < ghostOwner->getConsentListSize(); ++i) {
				String entryName = ghostOwner->getConsentName(i);
				if (!entryName.isEmpty()){
					if (entryName == player->getFirstName().toLowerCase()){
						hasConsent = true;
					}
				}
			}
		}
		if (!hasConsent){
			player->sendSystemMessage("You require consent to customize another player's droid");
			return 0;
		}
	}
	//end permission check

	Locker clocker(droid, player);

	String appearanceFilename = target->getObjectTemplate()->getAppearanceFilename();
	VectorMap<String, Reference<CustomizationVariable*> > variables;
	AssetCustomizationManagerTemplate::instance()->getCustomizationVariables(appearanceFilename.hashCode(), variables, false);
	int numPalette = 0;
	for(int i = 0; i< variables.size(); ++i)
	{
		String varkey = variables.elementAt(i).getKey();
		if (varkey.contains("color"))
		{
			++numPalette;
		}
	}

	if (numPalette == 0) {
		player->sendSystemMessage("No customization options available on this droid"); // protocol droids
		return 0;
	}

	DroidObject* painted = cast<DroidObject*>(droid);
	if (painted != NULL){
		painted->refreshPaint();
	}

	ManagedReference<SuiListBox*> frameTrimSelector = new SuiListBox(player, SuiWindowType::CUSTOMIZE_KIT);
	frameTrimSelector->setUsingObject(player);
	frameTrimSelector->setCallback(new CustomDroidSuiCallback(server, numPalette, kitTano));
	frameTrimSelector->setUsingObject(target);
	frameTrimSelector->setPromptTitle("Customize");
	frameTrimSelector->setPromptText("Please select the customization action you would like to take");

	frameTrimSelector->addMenuItem("Color Frame");

	if (numPalette > 1 ) {
		frameTrimSelector->addMenuItem("Color Trim");
	}

	if (numPalette > 2 ) {
		frameTrimSelector->addMenuItem("Color Extra Trim");
	}

	frameTrimSelector->setCancelButton(true, "");
	frameTrimSelector->setOkButton(true, "@ok");

	ManagedReference<PlayerObject*> ghost = player->getPlayerObject();
	ghost->addSuiBox(frameTrimSelector);
	player->sendMessage(frameTrimSelector->generateMessage());

	return 0;
}
void CampTerminalMenuComponent::showCampStatus(SceneObject* sceneObject,
		CreatureObject* player) const {

	Terminal* terminal = cast<Terminal*>(sceneObject);
	if(terminal == NULL) {
		error("Terminal is null in CampTerminalMenuComponent::showCampStatus");
		return;
	}

	if (!player->isInRange(terminal, 16)) {
		return;
	}

	StructureObject* camp = cast<StructureObject*>(terminal->getControlledObject());
	if(camp == NULL) {
		error("Camp is null in CampTerminalMenuComponent::showCampStatus");
		return;
	}

	// Get Camp Area
	SortedVector<ManagedReference<ActiveArea* > >* areas = camp->getActiveAreas();
	ManagedReference<ActiveArea*> area = NULL;
	for(int i = 0; i < areas->size(); ++i) {
		area = areas->get(i);
		if(area->isCampArea()) {
			break;
		}

		area = NULL;
	}

	if(area == NULL) {

		Reference<StructureManager*> structureManager = StructureManager::instance();
		if (structureManager == NULL) {
			error("Unable to get StructureManager in CampTerminalMenuComponent::showCampStatus");
			return;
		}

		structureManager->destroyStructure(camp);
		player->sendSystemMessage("This camp is broken, removing from world.  Thanks!");
		error("CampSiteActiveArea is null in CampTerminalMenuComponent::showCampStatus");
		return;
	}

	CampSiteActiveArea* campArea = cast<CampSiteActiveArea*>(area.get());
	if(campArea == NULL) {
		error("How the f**k did this happen");
		return;
	}
	/// Get Ghost
	Reference<PlayerObject*> ghost = player->getSlottedObject("ghost").castTo<PlayerObject*>();
	if (ghost == NULL) {
		error("PlayerCreature has no ghost in CampTerminalMenuComponent::showCampStatus: " + String::valueOf(player->getObjectID()));
		return;
	}

	ManagedReference<SuiListBox*> suiBox = new SuiListBox(player, SuiWindowType::CAMP_STATUS);
	suiBox->setPromptTitle("@camp:mnu_status");
	suiBox->setUsingObject(terminal);
	suiBox->setPromptText(terminal->getDisplayedName());

	StringBuffer owner, time, visitors;
	owner << "Owner: " << campArea->getOwner()->getFirstName() << " " <<
			camp->getOwnerCreatureObject()->getLastName() << endl;
	suiBox->addMenuItem(owner.toString());

	time << "Time: " << (campArea->getUptime() / 60) << " minutes, "<< (campArea->getUptime() % 60) << "seconds";
	suiBox->addMenuItem(time.toString());

	visitors << "Visitors: " << campArea->getVisitorCount() << endl;
	suiBox->addMenuItem(visitors.toString());

	ghost->addSuiBox(suiBox);
	player->sendMessage(suiBox->generateMessage());
}
void FireworkShowMenuComponent::addEvent(CreatureObject* player, FireworkObject* fireworkShow) const {

	DataObjectComponent* data = fireworkShow->getDataObjectComponent()->get();

	if (data == NULL || !data->isFireworkShowData())
		return;

	FireworkShowDataComponent* fireworkShowData = cast<FireworkShowDataComponent*>(data);

	int curFireworks = fireworkShowData->getTotalFireworkCount();
	int showCapacity = fireworkShow->getCapacity();

	ManagedReference<PlayerObject*> ghost = player->getPlayerObject();

	if (ghost == NULL)
		return;

	if (curFireworks >= showCapacity && !ghost->isPrivileged()) {
		player->sendSystemMessage("This firework show is at full capacity.");
		return;
	}

	if (ghost->hasSuiBoxWindowType(SuiWindowType::FIREWORK_SHOW_ADDEVENT) || ghost->hasSuiBoxWindowType(SuiWindowType::FIREWORK_SHOW_REMOVEEVENT)
			|| ghost->hasSuiBoxWindowType(SuiWindowType::FIREWORK_SHOW_REORDERSHOW) || ghost->hasSuiBoxWindowType(SuiWindowType::FIREWORK_SHOW_MODIFYEVENT)
				|| ghost->hasSuiBoxWindowType(SuiWindowType::FIREWORK_SHOW_DELAYSELECTION)) {
		return;
	}

	Locker plocker(player);

	ManagedReference<SuiListBox*> suiBox = new SuiListBox(player, SuiWindowType::FIREWORK_SHOW_ADDEVENT, SuiListBox::HANDLETWOBUTTON);
	suiBox->setPromptTitle("Select Show Addition");
	suiBox->setPromptText("Select the firework to append to the end of the show package.");
	suiBox->setOkButton(true, "@ok");
	suiBox->setCancelButton(true, "@cancel");
	suiBox->setUsingObject(fireworkShow);

	ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");
	SceneObject* sceneObject = NULL;

	for (int i = 0; i < inventory->getContainerObjectsSize(); i++) {
		sceneObject = inventory->getContainerObject(i);
		if (sceneObject == NULL)
			continue;

		FireworkObject* firework = cast<FireworkObject*>(sceneObject);
		if (firework == NULL)
			continue;

		DataObjectComponent* data = firework->getDataObjectComponent()->get();

		if (data != NULL && data->isFireworkShowData())
			continue;

		if (sceneObject->getObjectID() != fireworkShow->getObjectID()) {
			String itemWithUseCount = sceneObject->getDisplayedName() + " (" + firework->getUseCount() + ")";
			suiBox->addMenuItem(itemWithUseCount, sceneObject->getObjectID());
		}
	}

	suiBox->setCallback(new FireworkShowAddEventSuiCallback(player->getZoneServer()));
	ghost->addSuiBox(suiBox);
	player->sendMessage(suiBox->generateMessage());
}
void DroidMaintenanceSessionImplementation::sendMaintanceRunBox(){
	// main ui
	selectedStructure = NULL;

	ManagedReference<CreatureObject*> creature = this->player.get();

	if (structures.size() == 0 && maintenance.isEmpty()) {
		creature->sendSystemMessage("@pet/droid_modules:droid_maint_no_valid_struct");
		cancelSession();
		return;
	}

	ManagedReference<DroidMaintenanceModuleDataComponent*> module = this->maintModule.get();

	ManagedReference<SuiListBox*> box = new SuiListBox(creature, SuiWindowType::DROID_MAINTENANCE_RUN_LIST, SuiListBox::HANDLETHREEBUTTON);
	box->setCallback(new DroidMaintenanceSessionRunMenuSuiCallback(creature->getZoneServer()));
	// we need to add additional text i think
	StringBuffer promptText;
	box->setPromptTitle("@pet/droid_modules:droid_maint_list_title"); // Maintenance Run
	SuiListBox* b;
	box->setOkButton(true, "@go");
	box->setOtherButton(true,"@add");
	box->setCancelButton(true, "@cancel");
	// we have all we need in the session.
	int addCount = 0;
	// we need to add a line item for every structure on this droids list, then track amount per structure + fees + interplanetary. i.e. if not interplanetary capable, dont show them.
	//Vector<StructureObject*> list = module->getStructureList(creature->getZoneServer(),creature->getZone()->getZoneCRC());
	for(int i=0;i<structures.size();i++) {
		ManagedReference<StructureObject*> obj = structures.elementAt(i);
		StringBuffer buff;
		String zoneName = "the void";
		if (obj->getZone() != NULL) {
			zoneName = obj->getZone()->getZoneName();
		}
		// assume 30 chars per section, 3 sections so 90 chars.
		int nameLength = obj->getDisplayedName().length();
		int zoneNameLength = zoneName.length();
		buff << obj->getDisplayedName();
		if (nameLength < 30) {
			// pad the diff to teh end
			for(int x=0;x<30-nameLength;x++)
				buff << " ";
			nameLength = 30;
		}
		int finalOffset = zoneName.length() + 15;

		buff << "\t" << zoneName << "(" << String::valueOf((int)obj->getPositionX()) << "," << String::valueOf((int)obj->getPositionY()) << ")";
		if (maintenance.contains(obj->getObjectID())) {
			if (addCount == 0)
				promptText << "@pet/droid_modules:droid_maint_list_header\n\n";
			addCount += 1;
			promptText << buff.toString();
			if (finalOffset < 30) {
				for(int x=0;x<30-finalOffset;x++)
					promptText << " ";
			}
			promptText << "+" << maintenance.get(obj->getObjectID()) << "\n";
		} else {
			box->addMenuItem( buff.toString(), obj->getObjectID());
		}
	}
	if (addCount > 0)
		promptText << "\n";
	promptText << "@pet/droid_modules:droid_maint_list_prompt"; // Please select a structure to perform a maintenance run on. Once all structures to be maintained have been selected, press the Go button.
	box->setPromptText(promptText.toString());
	creature->getPlayerObject()->addSuiBox(box);
	creature->sendMessage(box->generateMessage());
}
int DroidHarvestModuleDataComponent::handleObjectMenuSelect(CreatureObject* player, byte selectedID, PetControlDevice* controller) {

	if (selectedID == HARVEST_SET_INTEREST) {
		ManagedReference<DroidObject*> droid = getDroidObject();
		if( droid == NULL ){
			info( "Droid is null");
			return 0;
		}

		if( !droid->hasPower() ){
			player->sendSystemMessage("@pet/droid_modules:playback_msg_play_out_of_power");
			return 0;
		}

		// popup a ui to choose the correct interest.
		ManagedReference<SuiListBox*> box = new SuiListBox(player, SuiWindowType::DROID_SET_INTEREST, SuiListBox::HANDLETWOBUTTON);
		box->setCallback(new SelectHarvestSuiCallback(player->getZoneServer()));
		box->setPromptText("@pet/droid_modules:set_interest_d");
		box->setPromptTitle("@pet/droid_modules:set_interest_d");
		box->setOkButton(true,"@ok");
		box->setCancelButton(true, "@cancel");
		// Add tracks
		box->addMenuItem("@pet/droid_modules:set_interest_random",INTREST_RANDOM);
		box->addMenuItem("@pet/droid_modules:set_interest_bone",INTREST_BONE);
		box->addMenuItem("@pet/droid_modules:set_interest_meat",INTREST_MEAT);
		box->addMenuItem("@pet/droid_modules:set_interest_hide",INTREST_HIDE);
		box->setUsingObject(droid);
		player->getPlayerObject()->addSuiBox(box);
		player->sendMessage(box->generateMessage());
		return 0;
	}
	// Handle toggle on/off
	if (selectedID == HARVEST_PROGRAM_COMMAND) {
		if( controller == NULL )
			return 0;
		controller->setTrainingCommand( PetManager::HARVEST );
		return 0;
	}
	if( selectedID == HARVEST_TOGGLE ){

		ManagedReference<DroidObject*> droid = getDroidObject();
		if( droid == NULL ){
			info( "Droid is null");
			return 0;
		}

		Locker dlock( droid, player );

		// Toggle off
		if (active){
			deactivate();
			player->sendSystemMessage("@pet/droid_modules:auto_harvest_off");  // You turn off auto-repair
		}
		else{ // Toggle on

			// Check droid states
			if( droid->isDead() || droid->isIncapacitated())
				return 0;

			// Droid must have power
			if( !droid->hasPower() ){
				droid->showFlyText("npc_reaction/flytext","low_power", 204, 0, 0);  // "*Low Power*"
				return 0;
			}

			// Ensure we don't accidentally have another task outstanding
			deactivate();
			player->sendSystemMessage("@pet/droid_modules:auto_harvest_on");  // You turn on auto-repair
			if (observer == NULL) {
				observer = new DroidHarvestObserver(this);
				observer->deploy();
			}
			Locker plock(player);
			player->registerObserver(ObserverEventType::KILLEDCREATURE, observer);
			active = true;
		}

	}
	return 0;
}