Exemplo n.º 1
0
///Обновление
  void Update ()
  {
    buffer_size = 0;
    
    PropertyDesc* desc = &properties [0];

    for (size_t i=0; i<properties.size (); i++, desc++)
    {
      desc->name    = 0;
      desc->offset  = buffer_size;      
      buffer_size  += get_size (desc->type) * desc->elements_count;
    }
      
    hash = crc32 (&properties [0], properties.size () * sizeof (PropertyDesc), crc32 (names.Buffer (), names.BufferSize ()));

    desc = &properties [0];    

    for (size_t i=0; i<properties.size (); i++, desc++)
      desc->name = names [i];

    need_update = false;    
  }  
    void PropertiesWindow::addPropertyArray(const Property& prop, const CeGuiString& key)
    {
        // Create the new MultiColumnList with two columns
        // Type and Value and set tab text to key
        int tabCount = mTabPane->getTabCount();
        CEGUI::MultiColumnList* newTable = static_cast<CEGUI::MultiColumnList*>
            (CEGUI::WindowManager::getSingleton().createWindow("RastullahLook/MultiColumnList",
            "PropertiesWindow/PropertiesTabControl/" + key));

        // Set table properties
        newTable->setText(key);
        newTable->setPosition(CEGUI::UVector2(
            CEGUI::UDim(0,0),
            CEGUI::UDim(0,0)));
        newTable->setSize(CEGUI::UVector2(
            CEGUI::UDim(1,0),
            CEGUI::UDim(1,0)));
        newTable->setUserSortControlEnabled(false);
        newTable->setFont("Vera Serif-8");

        newTable->addColumn("Type", 0, cegui_reldim(0.3));
        newTable->addColumn("Value", 1, cegui_reldim(0.7));

        // Add the MultiColumnList to the tab pane
        mTabPane->addTab(newTable);

        // Get access to the vector
        PropertyArray vProp = prop.toArray();

        // Iterate through the vector entries and add them
        // to the table
        for(PropertyArray::const_iterator it = vProp.begin(); it != vProp.end(); it++)
        {
            // Check for Int
            if (it->isInt() )
            {
                addPropertyInt(*it, newTable);
            }
            // Check for IntPair
            else if (it->isIntPair() )
            {
                addPropertyIntPair(*it, newTable);
                int rowCount = newTable->getRowCount();
                newTable->addRow(rowCount);
                newTable->setItem(new ListboxTextItem(""), 0, rowCount);
            }
            // Check for IntTriple
            else if (it->isIntTriple() )
            {
                addPropertyIntTriple(*it, newTable);
                int rowCount = newTable->getRowCount();
                newTable->addRow(rowCount);
                newTable->setItem(new ListboxTextItem(""), 0, rowCount);
            }
            // Check for String
            else if (it->isString() )
            {
                addPropertyString(*it, newTable);
            }
            // Check for Bool
            else if (it->isBool() )
            {
                addPropertyBool(*it, newTable);
            }
            // Check for Real
            else if (it->isReal() )
            {
                addPropertyReal(*it, newTable);
            }
            // Check for Vector3
            else if (it->isVector3() )
            {
                addPropertyArray3(*it, newTable);
                int rowCount = newTable->getRowCount();
                newTable->addRow(rowCount);
                newTable->setItem(new ListboxTextItem(""), 0, rowCount);
            }
            // Check for Quaternion
            else if (it->isQuaternion() )
            {
                addPropertyQuaternion(*it, newTable);
                int rowCount = newTable->getRowCount();
                newTable->addRow(rowCount);
                newTable->setItem(new ListboxTextItem(""), 0, rowCount);
            }
        }
        newTable->autoSizeColumnHeader(0);
        newTable->autoSizeColumnHeader(1);
    }
Exemplo n.º 3
0
	void Inventory::setProperty(const CeGuiString& key, const Property& value)
	{
        if (key == Inventory::PROPERTY_SLOTS)
        {
            PropertyArray slotVec = value.toArray();

            for (PropertyArray::const_iterator it = slotVec.begin(); it != slotVec.end(); ++it)
            {
                PropertyMap slotProps = it->toMap();

                CeGuiString name = slotProps["name"].toString();
                int holdItems = Item::ITEMTYPE_ALL_ITEMS;
                if (slotProps.find("holds") != slotProps.end())
                {
                    holdItems = slotProps["holds"].toInt();
                }
                int readyItems = Item::ITEMTYPE_ALL_ITEMS;
                if (slotProps.find("readies") != slotProps.end())
                {
                    readyItems = slotProps["readies"].toInt();
                }

                CeGuiString type = slotProps.find("type")->second.toString();
                if (type == "bone")
                {
                    CeGuiString bone = slotProps["bone"].toString();
                    LOG_MESSAGE("Inventory", "Add bone slot "+ bone);
                    addSlot(name, bone.c_str(), readyItems, holdItems, SLOT_BONE);
                }
                else if (type == "submesh")
                {
                    CeGuiString submesh = slotProps["submesh"].toString();
                    LOG_MESSAGE("Inventory", "Add submesh slot "+ submesh);
                    addSlot(name, submesh.c_str(), readyItems, holdItems, SLOT_SUBMESH);
                }
                else if (type == "material")
                {
                    CeGuiString submesh = slotProps["submesh"].toString();
                    LOG_MESSAGE("Inventory", "Add material slot "+ submesh);
                    addSlot(name, submesh.c_str(), readyItems, holdItems, SLOT_MATERIAL);
                }
                else if (type == "default")
                {
                    LOG_MESSAGE("Inventory", "Add default slot "+ name);
                    addSlot(name, "", readyItems, holdItems, SLOT_DEFAULT);
                }
                else
                {
                    LOG_ERROR(Logger::RULES, 
                        "Unknown slot type '"+type+"' in inventory properties.");
                }
            }
        }
		else if (key == Inventory::PROPERTY_CONTENT)
		{
			PropertyMap bonesContent = value.toMap();
			for (PropertyMap::const_iterator it = bonesContent.begin();
				it != bonesContent.end(); ++it)
			{
				Item* item = dynamic_cast<Item*>(
					GameObjectManager::getSingleton().createGameObjectFromProperty(
						(*it).second));
				if (item)
				{
					LOG_MESSAGE("Inventory", "Add item " + it->second.toString() + " to slot "+ (*it).first);
					hold(item, (*it).first);
				}
			}
		}
	}