Esempio n. 1
0
void ResetDataBySexSelChanged()
{
    CEGUI::WindowManager& mgr = GetWndMgr();
    CEGUI::Combobox* SelFac = WComboBox(mgr.getWindow(CREATEROLE_SEL_FAC_CCB));
    uint SelSex = (uint)CREvent::GetSelectSex();
    if(SelFac)
    {
        SelFac->resetList();
        //更改性别后,修改默认Face和HairStyle时,对应修改文本显示
        SelFac->getEditbox()->setText(CEGUI::PropertyHelper::intToString(0));
        for(short i = 0 ; i < CREvent::GetFaceNum(SelSex) ; ++i)
        {
            CEGUI::ListboxTextItem* lti = new CEGUI::ListboxTextItem(CEGUI::PropertyHelper::intToString(i));
            lti->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME);
            lti->setID(i);//ID和FacIndex关联
            if(0==i)		//更改性别后,修改默认Face和HairStyle时,对应修改ItemList选中状态
                lti->setSelected(true);
            SelFac->addItem(lti);
        }
    }
    CEGUI::Combobox* SelHair = WComboBox(mgr.getWindow(CREATEROLE_SEL_HAIR_CCB));
    if(SelHair)
    {
        SelHair->resetList();
        //更改性别后,修改默认Face和HairStyle时,对应修改文本显示
        SelHair->getEditbox()->setText(CEGUI::PropertyHelper::intToString(0));
        for(short i = 0 ; i < CREvent::GetHairNum(SelSex) ; ++i)
        {
            CEGUI::ListboxTextItem* lti = new CEGUI::ListboxTextItem(CEGUI::PropertyHelper::intToString(i));
            lti->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME);
            lti->setID(i);// ID和HairIndex关联
            if(0 == i)//更改性别后,修改默认Face和HairStyle时,对应修改ItemList选中状态
                lti->setSelected(true);
            SelHair->addItem(lti);
        }
    }
}
Esempio n. 2
0
void SetCreateRoleInitProperty(CEGUI::Window* pgWnd)
{
    if(!pgWnd)
        return;
    CEGUI::Combobox* SelCountry = WComboBox(pgWnd->getChildRecursive(CREATEROLE_SEL_COUNTRY_CCB));
    if(SelCountry)
    {
        SelCountry->subscribeEvent(CEGUI::Combobox::EventListSelectionAccepted,CEGUI::SubscriberSlot(OnCountryChanged));
        SelCountry->setReadOnly(true);
        CCountryList::MapCountryList* mapCL = CCountryList::GetCountryList();
        for(uint cnt = 0; cnt < mapCL->size(); ++cnt)
        {
            const char* ctName = CCountryList::GetCountryName((BYTE)cnt+1);
            if(ctName)
            {
                CEGUI::ListboxTextItem* lti = new CEGUI::ListboxTextItem(ToCEGUIString(ctName));
                lti->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME);
                lti->setID(cnt+1);//ID和国家ID关联
                if(cnt == 0)
                    lti->setSelected(true);//设置国家默认值
                SelCountry->addItem(lti);
            }
        }
        //根据国家默认值,设置显示文本
        SelCountry->getEditbox()->setText(ToCEGUIString(CCountryList::GetCountryName(0+1)));//加一是因为data/CountryList.xml配置造成
        /***********************************************************************/
        /* zhaohang fix 2010-9-3
        /***********************************************************************/
        CREvent::SetSelectCountry(1);//逻辑上的国家默认值
    }
    CEGUI::Combobox* selHair = WComboBox(pgWnd->getChildRecursive(CREATEROLE_SEL_HAIR_CCB));
    if(selHair)
    {
        selHair->subscribeEvent(CEGUI::Combobox::EventListSelectionAccepted,CEGUI::SubscriberSlot(OnHairChanged));
        selHair->setReadOnly(true);
    }
    CEGUI::Combobox* selHairColor = WComboBox(pgWnd->getChildRecursive(CREATEROLE_SEL_HAIRCOLOR_CCB));
    if(selHairColor)
    {
        selHairColor->subscribeEvent(CEGUI::Combobox::EventListSelectionAccepted,CEGUI::SubscriberSlot(OnHairColorChanged));
        selHairColor->setReadOnly(true);
    }
    CEGUI::Combobox* selFac = WComboBox(pgWnd->getChildRecursive(CREATEROLE_SEL_FAC_CCB));
    if(selFac)
    {
        selFac->subscribeEvent(CEGUI::Combobox::EventListSelectionAccepted,CEGUI::SubscriberSlot(OnFacChanged));
        selFac->setReadOnly(true);
    }
    CEGUI::Combobox* selSex = WComboBox(pgWnd->getChildRecursive(CREATEROLE_SEL_SEX_CCB));
    if(selSex)
    {
        CEGUI::ListboxTextItem* itm1  = new CEGUI::ListboxTextItem(ToCEGUIString(CREATEROLE_SEX_MALE));
        itm1->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME);
        itm1->setID(0);//用ID和性别关联
        selSex->addItem(itm1);
        CEGUI::ListboxTextItem* itm2 = new CEGUI::ListboxTextItem(ToCEGUIString(CREATEROLE_SEX_FAMALE));
        itm2->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME);
        itm2->setID(1);//用ID和性别关联
        selSex->addItem(itm2);
        //注册事件
        selSex->subscribeEvent(CEGUI::Combobox::EventListSelectionAccepted,CEGUI::SubscriberSlot(OnSexChanged));
        selSex->setReadOnly(true);
    }
}