void PropertyGridUpdater::visitGroup(GroupElement* e) {
        _grid->BeginBatch();

        setGridHeight(2);
        _grid->SetCellValue("x", 0, 0);       _grid->SetCellValue(va("%.3f", e->pos[0]).c_str(), 0, 1);
        _grid->SetCellValue("y", 1, 0);       _grid->SetCellValue(va("%.3f", e->pos[1]).c_str(), 1, 1);
        _grid->AutoSizeColumn(0);

        _grid->EndBatch();
    }
    void PropertyGridUpdater::visitGeometry(GeometryElement* e) {
        _grid->BeginBatch();

        std::string tex(e->material ? e->material->texture : "");

        setGridHeight(3);
        _grid->SetCellValue("Texture", 0, 0); _grid->SetCellValue(tex.c_str(), 0, 1);
        _grid->SetCellValue("x", 1, 0);       _grid->SetCellValue(va("%.3f", e->pos[0]).c_str(), 1, 1);
        _grid->SetCellValue("y", 2, 0);       _grid->SetCellValue(va("%.3f", e->pos[1]).c_str(), 2, 1);
        _grid->AutoSizeColumn(0);

        _grid->EndBatch();
    }
Esempio n. 3
0
bool CRole::init(const string& unitId, bool editorMode)
{
    do
    {
        m_isEditMode = editorMode;
        
        BREAK_IF(!CSpriteObject::init());
        
        m_faceToPrefix.resize(FACE_TO_MAX);
        m_faceToPrefix[FACE_TO_LEFT_DOWN] = ROLE_FACE_TO_LEFT_PREFIX;
        m_faceToPrefix[FACE_TO_RIGHT_DOWN] = ROLE_FACE_TO_RIGHT_PREFIX;
        m_faceToPrefix[FACE_TO_LEFT_UP] = ROLE_BACK_TO_LEFT_PREFIX;
        m_faceToPrefix[FACE_TO_RIGHT_UP] = ROLE_BACK_TO_RIGHT_PREFIX;

        
        changeState(ROLE_STATE_MOVE);

        setUnitId(unitId);
        
        const DTUnit::_Data* unitData = DTUNIT->getData(getUnitId());
        CC_ASSERT(unitData);
        setGridWidth(unitData->gridWidth);
        setGridHeight(unitData->gridHeight);
        
        setSpeed(unitData->speed);
        setMaxHP(unitData->hp);
        setCurHP(getMaxHP());
        setATK(unitData->atk);
        setAtkSpeed(unitData->rate);
        
        BREAK_IF_FAILED(CSpriteObject::setSpriteFromCcbi(unitData->resourceID.c_str()));
        
        if (!editorMode)
        {
            BREAK_IF_FAILED(createHPBar());
            m_pHPBar->setPercentage(1.f);
            Size sz = getSpriteContentSize();
            m_pHPBar->setPosition(0, sz.height);
        }
        return true;
    } while (false);
    
    return false;
}