Example #1
0
Bool PaletteSubDialog::CoreMessage(Int32 id, const BaseContainer& msg)
{
    switch ( id )
    {
      case  PALETTE_ID:
			Int64 color =  (Int64) msg.GetVoid( BFM_CORE_PAR1 );
			Int64 palette = (Int64) msg.GetVoid( BFM_CORE_PAR2 );
            if( palette == -1){
                BaseContainer *bc = GetActiveDocument()->BaseList2D::GetDataInstance()->GetContainerInstance(PALETTE_SCENE_HOOK_ID)->GetContainerInstance(m_id);
                if(bc != nullptr){
                    FromContainer(*bc);
                } else {
                    BaseContainer tmp;
                    m_paletteID = 0;
                    m_rows = 1;
                    m_layout = 0;
                    m_searchString = "";
                    m_showLabel = FALSE;
                    ToContainer(tmp);
                    GetActiveDocument()->BaseList2D::GetDataInstance()->GetContainerInstance(PALETTE_SCENE_HOOK_ID)->SetContainer(m_id,tmp);
                    FromContainer(tmp);
                }
            }
			if((palette == m_paletteID || palette == -1) && color == -1){
				LoadPalette(m_paletteID);
			}
        break;
    }
    return GeDialog::CoreMessage( id, msg );
}
void CEquipmentSystemInterface::InitItems(IGameToEditorInterface* pGTE)
{
	// Get ItemParams from ItemSystem
	// Creates the following entries
	// "item"               All Item classes
	// "item_selectable"    All Item classes which can be selected
	// "item_givable",      All Item classes which can be given
	// "weapon"             All Weapon classes (an Item of class 'Weapon' or an Item which has ammo)
	// "weapon_selectable"  All Weapon classes which can be selected
	// "weapon_givable"     All Weapon classes which can be given
	// and for any weapon which has ammo
	// "ammo_WEAPONNAME"    All Ammos for this weapon

	IItemSystem* pItemSys = m_pIItemSystem;
	int maxCountItems = pItemSys->GetItemParamsCount();
	int maxAllocItems = maxCountItems+1; // allocate one more to store empty
	const char** allItemClasses = new const char*[maxAllocItems];
	const char** givableItemClasses = new const char*[maxAllocItems];
	const char** selectableItemClasses = new const char*[maxAllocItems];
	const char** allWeaponClasses = new const char*[maxAllocItems];
	const char** givableWeaponClasses = new const char*[maxAllocItems];
	const char** selectableWeaponClasses = new const char*[maxAllocItems];

	int numAllItems = 0;
	int numAllWeapons = 0;
	int numGivableItems = 0;
	int numSelectableItems = 0;
	int numSelectableWeapons = 0;
	int numGivableWeapons = 0;
	std::set<string> allAmmosSet;

	// store default "---" -> "" value
	{
		const char* empty = "";
		selectableWeaponClasses[numSelectableWeapons++] = empty;
		givableWeaponClasses[numGivableWeapons++] = empty;
		allWeaponClasses[numAllWeapons++] = empty;
		selectableItemClasses[numSelectableItems++] = empty;
		givableItemClasses[numGivableItems++] = empty;
		allItemClasses[numAllItems++] = empty;
		allAmmosSet.insert(empty);
	}

	for (int i=0; i<maxCountItems; ++i)
	{
		const char* itemName = pItemSys->GetItemParamName(i);
		allItemClasses[numAllItems++] = itemName;

		const IItemParamsNode* pItemRootParams = pItemSys->GetItemParams(itemName);

		if (pItemRootParams)
		{
			bool givable = false;
			bool selectable = false;
			bool uiWeapon = false;
			const IItemParamsNode *pChildItemParams = pItemRootParams->GetChild("params");
			if (pChildItemParams) 
			{
				CItemParamReader reader (pChildItemParams);

				//FIXME: the equipeable(?) flag is supposed to be used for weapons that are not givable (alien weapons)
				//but that are still needed to be in the equipment weapon list.
				bool equipeable = false;
				reader.Read("equipeable", equipeable);
				reader.Read("giveable", givable);
				givable |= equipeable;

				reader.Read("selectable", selectable);
				reader.Read("ui_weapon", uiWeapon);
			}

			if (givable)
				givableItemClasses[numGivableItems++] = itemName;
			if (selectable)
				selectableItemClasses[numSelectableItems++] = itemName;

			const IItemParamsNode* pAmmos = pItemRootParams->GetChild("ammos");
			if (pAmmos)
			{
				int maxAmmos = pAmmos->GetChildCount();
				int numAmmos = 0;
				const char** ammoNames = new const char*[maxAmmos];
				for (int j=0; j<maxAmmos; ++j)
				{
					const IItemParamsNode* pAmmoParams = pAmmos->GetChild(j);
					if (stricmp(pAmmoParams->GetName(), "ammo") == 0)
					{
						const char* ammoName = pAmmoParams->GetAttribute("name");
						if (ammoName)
						{
							ammoNames[numAmmos] = ammoName;
							++numAmmos;
							allAmmosSet.insert(ammoName);
						}
					}
				}
				if (numAmmos > 0)
				{
					// make it a weapon when there's ammo
					allWeaponClasses[numAllWeapons++] = itemName;
					if (selectable)
						selectableWeaponClasses[numSelectableWeapons++] = itemName;
					if (givable)
						givableWeaponClasses[numGivableWeapons++] = itemName;

					string ammoEntryName = "ammo_";
					ammoEntryName+=itemName;
					pGTE->SetUIEnums(ammoEntryName.c_str(), ammoNames, numAmmos);
				}
				delete[] ammoNames;
			}
			else
			{
				const char* itemClass = pItemRootParams->GetAttribute("class");
				if (uiWeapon || (itemClass != 0 && stricmp(itemClass, "weapon") == 0))
				{
					// make it a weapon when there's ammo
					allWeaponClasses[numAllWeapons++] = itemName;
					if (selectable)
						selectableWeaponClasses[numSelectableWeapons++] = itemName;
					if (givable)
						givableWeaponClasses[numGivableWeapons++] = itemName;
				}
			}
		}
	}

	int numAllAmmos = 0;
	const char** allAmmos = new const char*[allAmmosSet.size()];
	std::set<string>::const_iterator iter (allAmmosSet.begin());
	while (iter != allAmmosSet.end())
	{
		allAmmos[numAllAmmos++] = iter->c_str();
		++iter;
	}
	pGTE->SetUIEnums("ammos", allAmmos, numAllAmmos);
	ToContainer(allAmmos+1, numAllAmmos-1, m_itemMap["Ammo"]);
	delete[] allAmmos;

	pGTE->SetUIEnums("weapon_selectable", selectableWeaponClasses, numSelectableWeapons);
	pGTE->SetUIEnums("weapon_givable", givableWeaponClasses, numGivableWeapons);
	pGTE->SetUIEnums("weapon", allWeaponClasses, numAllWeapons);
	pGTE->SetUIEnums("item_selectable", selectableItemClasses, numSelectableItems);
	pGTE->SetUIEnums("item_givable", givableItemClasses, numGivableItems);
	pGTE->SetUIEnums("item", allItemClasses, numAllItems);

	ToContainer(allItemClasses+1,numAllItems-1,m_itemMap["Item"]);
	ToContainer(givableItemClasses+1,numGivableItems-1,m_itemMap["ItemGivable"]);
	ToContainer(allWeaponClasses+1,numAllWeapons-1,m_itemMap["Weapon"]);

	delete[] selectableWeaponClasses;
	delete[] givableWeaponClasses;
	delete[] allWeaponClasses;
	delete[] selectableItemClasses;
	delete[] givableItemClasses; 
	delete[] allItemClasses;
}
Example #3
0
void PaletteSubDialog::SaveSettings()
{
    BaseContainer bc;
    ToContainer(bc);
    GetActiveDocument()->BaseList2D::GetDataInstance()->GetContainerInstance(PALETTE_SCENE_HOOK_ID)->SetContainer(m_id, bc);
}
void CEquipmentSystemInterface::InitItems(IGameToEditorInterface* pGTE)
{
	// Get ItemParams from ItemSystem
	// Creates the following entries
	// "item"               All Item classes
	// "item_selectable"    All Item classes which can be selected
	// "item_givable",      All Item classes which can be given
	// "weapon"             All Weapon classes (an Item of class 'Weapon' or an Item which has ammo)
	// "weapon_selectable"  All Weapon classes which can be selected
	// "weapon_givable"     All Weapon classes which can be given
	// and for any weapon which has ammo
	// "ammo_WEAPONNAME"    All Ammos for this weapon

	IItemSystem* pItemSys = m_pIItemSystem;
	int maxCountItems = pItemSys->GetItemParamsCount();
	int maxAllocItems = maxCountItems+1; // allocate one more to store empty
	const char** allItemClasses = new const char*[maxAllocItems];
	const char** givableItemClasses = new const char*[maxAllocItems];
	const char** selectableItemClasses = new const char*[maxAllocItems];
	const char** allWeaponClasses = new const char*[maxAllocItems];
	const char** givableWeaponClasses = new const char*[maxAllocItems];
	const char** selectableWeaponClasses = new const char*[maxAllocItems];

	int numAllItems = 0;
	int numAllWeapons = 0;
	int numGivableItems = 0;
	int numSelectableItems = 0;
	int numSelectableWeapons = 0;
	int numGivableWeapons = 0;
	std::set<string> allAmmosSet;

	// store default "---" -> "" value
	{
		const char* empty = "";
		selectableWeaponClasses[numSelectableWeapons++] = empty;
		givableWeaponClasses[numGivableWeapons++] = empty;
		allWeaponClasses[numAllWeapons++] = empty;
		selectableItemClasses[numSelectableItems++] = empty;
		givableItemClasses[numGivableItems++] = empty;
		allItemClasses[numAllItems++] = empty;
		allAmmosSet.insert(empty);
	}

	for (int i=0; i<maxCountItems; ++i)
	{
		const char* itemName = pItemSys->GetItemParamName(i);
		allItemClasses[numAllItems++] = itemName;

		const char* itemDescriptionFile = pItemSys->GetItemParamsDescriptionFile(itemName);
		
		CRY_ASSERT(itemDescriptionFile);
		XmlNodeRef itemRootParams = gEnv->pSystem->LoadXmlFromFile(itemDescriptionFile);

		if (!itemRootParams)
		{
			GameWarning("Item description file %s doesn't exist for item %s", itemDescriptionFile, itemName);
			continue;
		}

		CGameXmlParamReader rootReader(itemRootParams);
		const char* inheritItem = itemRootParams->getAttr("inherit");
		bool isInherited = (inheritItem && inheritItem[0] != 0);
		if (isInherited)
		{
			const char* baseItemFile = pItemSys->GetItemParamsDescriptionFile(inheritItem);
			itemRootParams = gEnv->pSystem->LoadXmlFromFile(baseItemFile);
		}

		if (itemRootParams)
		{
			bool givable = false;
			bool selectable = false;
			bool uiWeapon = false;
			XmlNodeRef childItemParams = itemRootParams->findChild("params");
			if (childItemParams) 
			{
				CGameXmlParamReader reader(childItemParams);

				//the equipeable flag is supposed to be used for weapons that are not givable
				//but that are still needed to be in the equipment weapon list.
				bool equipeable = false;
				reader.ReadParamValue<bool>("equipeable", equipeable);
				reader.ReadParamValue<bool>("giveable", givable);
				givable |= equipeable;

				reader.ReadParamValue<bool>("selectable", selectable);
				reader.ReadParamValue<bool>("ui_weapon", uiWeapon);
			}

			if (givable)
				givableItemClasses[numGivableItems++] = itemName;
			if (selectable)
				selectableItemClasses[numSelectableItems++] = itemName;

			XmlNodeRef childAccessoriesNode = itemRootParams->findChild("accessories");

			if(childAccessoriesNode)
			{
				const int numAccessories = childAccessoriesNode->getChildCount();

				for(int childIdx = 0; childIdx < numAccessories; childIdx++)
				{
					XmlNodeRef childAccessory = childAccessoriesNode->getChild(childIdx);

					if(childAccessory && stricmp(childAccessory->getTag(), "accessory") == 0)
					{
						const char* accessoryName = childAccessory->getAttr("name");
						const char* categoryName = childAccessory->getAttr("category");			

						if(categoryName && accessoryName)
						{
							m_accessoryMap[itemName][categoryName].push_back(accessoryName);
						}
					}
				}
			}

			XmlNodeRef ammosNode = itemRootParams->findChild("ammos");
			if (ammosNode)
			{
				CGameXmlParamReader reader(ammosNode);

				const int maxAmmos = reader.GetUnfilteredChildCount();
				int numAmmos = 0;
				const char** ammoNames = new const char*[maxAmmos];
				for (int j=0; j<maxAmmos; ++j)
				{
					XmlNodeRef ammoChildNode = reader.GetFilteredChildAt(j);
					if ((ammoChildNode != NULL) && stricmp(ammoChildNode->getTag(), "ammo") == 0)
					{
						const char* ammoName = ammoChildNode->getAttr("name");
						if (ammoName && ammoName[0])
						{
							ammoNames[numAmmos] = ammoName;
							++numAmmos;
							allAmmosSet.insert(ammoName);
						}
					}
				}
				if (numAmmos > 0)
				{
					// make it a weapon when there's ammo
					allWeaponClasses[numAllWeapons++] = itemName;
					if (selectable)
						selectableWeaponClasses[numSelectableWeapons++] = itemName;
					if (givable)
						givableWeaponClasses[numGivableWeapons++] = itemName;

					string ammoEntryName = "ammo_";
					ammoEntryName+=itemName;
					pGTE->SetUIEnums(ammoEntryName.c_str(), ammoNames, numAmmos);
				}
				delete[] ammoNames;
			}
			else
			{
				const char* itemClass = itemRootParams->getAttr("class");
				if (uiWeapon || (itemClass != 0 && stricmp(itemClass, "weapon") == 0))
				{
					// make it a weapon when there's ammo
					allWeaponClasses[numAllWeapons++] = itemName;
					if (selectable)
						selectableWeaponClasses[numSelectableWeapons++] = itemName;
					if (givable)
						givableWeaponClasses[numGivableWeapons++] = itemName;
				}
			}
		}
	}

	int numAllAmmos = 0;
	const char** allAmmos = new const char*[allAmmosSet.size()];
	std::set<string>::const_iterator iter (allAmmosSet.begin());
	while (iter != allAmmosSet.end())
	{
		allAmmos[numAllAmmos++] = iter->c_str();
		++iter;
	}
	pGTE->SetUIEnums("ammos", allAmmos, numAllAmmos);
	ToContainer(allAmmos+1, numAllAmmos-1, m_itemMap["Ammo"]);
	delete[] allAmmos;

	pGTE->SetUIEnums("weapon_selectable", selectableWeaponClasses, numSelectableWeapons);
	pGTE->SetUIEnums("weapon_givable", givableWeaponClasses, numGivableWeapons);
	pGTE->SetUIEnums("weapon", allWeaponClasses, numAllWeapons);
	pGTE->SetUIEnums("item_selectable", selectableItemClasses, numSelectableItems);
	pGTE->SetUIEnums("item_givable", givableItemClasses, numGivableItems);
	pGTE->SetUIEnums("item", allItemClasses, numAllItems);

	ToContainer(allItemClasses+1,numAllItems-1,m_itemMap["Item"]);
	ToContainer(givableItemClasses+1,numGivableItems-1,m_itemMap["ItemGivable"]);
	ToContainer(allWeaponClasses+1,numAllWeapons-1,m_itemMap["Weapon"]);

	delete[] selectableWeaponClasses;
	delete[] givableWeaponClasses;
	delete[] allWeaponClasses;
	delete[] selectableItemClasses;
	delete[] givableItemClasses; 
	delete[] allItemClasses;
}