void SetInitializedAHUIProperty(CEGUI::Window* pageWnd) { //第一次打开窗口,默认可见 pageWnd->setVisible(false); CEGUI::Window* tab1 = pageWnd->getChildRecursive("Auction/Tab/BuySale"); tab1->setVisible(true);//默认Tab1可见 CEGUI::Editbox* editbox = WEditBox(pageWnd->getChildRecursive("Auction/Pickup/EditGold"));//金币提取编辑框只能为数字 editbox->setText(""); editbox->setReadOnly(true); //editbox->setMaxTextLength(10); //只能输入数字 editbox->setValidationString("[0-9]*"); editbox = WEditBox(pageWnd->getChildRecursive("Auction/Pickup/EditWeimian"));//位面提取编辑框只能为数字 editbox->setText(""); editbox->setReadOnly(true); editbox->setValidationString("[0-9]*"); //editbox->setMaxTextLength(10); CEGUI::MultiColumnList* mcl = WMCL(pageWnd->getChildRecursive("Auction/Tab/BuySale/SaleMCL")); mcl->setUserColumnDraggingEnabled(false);//列不可拖动 mcl->setUserSortControlEnabled(false);//列不可排序 mcl->setUserColumnSizingEnabled(false);//列不可调整宽度 mcl = WMCL(pageWnd->getChildRecursive("Auction/Tab/BuySale/BuyMCL")); mcl->setUserColumnDraggingEnabled(false);//列不可拖动 mcl->setUserSortControlEnabled(false);//列不可排序 mcl->setUserColumnSizingEnabled(false);//列不可调整宽度 CEGUI::Window* wnd = pageWnd->getChildRecursive("Auction/SaleWnd"); wnd->setVisible(false);//出售界面默认不可见 editbox = WEditBox(pageWnd->getChildRecursive("Auction/SaleWnd/saleNum"));//出售界面编辑框只能输入数字 editbox->setText(""); editbox->setMaxTextLength(10); //editbox->setReadOnly(false); editbox->setValidationString("[0-9]*"); editbox = WEditBox(pageWnd->getChildRecursive("Auction/SaleWnd/Text6"));//出售界面交易文本提示 editbox->setText(""); editbox = WEditBox(pageWnd->getChildRecursive("Auction/SaleWnd/Text61"));// editbox->setText(""); wnd = pageWnd->getChildRecursive("Auction/BuyWnd"); wnd->setVisible(false);//购买界面默认不可见 editbox = WEditBox(pageWnd->getChildRecursive("Auction/Buy/buyNum"));//购买界面编辑框只能输入数字 editbox->setText(""); //editbox->setReadOnly(false); editbox->setValidationString("[0-9]*"); editbox->setMaxTextLength(4); editbox = WEditBox(pageWnd->getChildRecursive("Auction/Buy/Text6"));//购买界面交易文本提示 editbox->setText(""); editbox = WEditBox(pageWnd->getChildRecursive("Auction/Buy/Text61")); editbox->setText(""); mcl = WMCL(pageWnd->getChildRecursive("Auction/Tab/Query/MCL"));//个人查询MCL属性 mcl->setUserColumnDraggingEnabled(false);//列不可拖动 mcl->setUserSortControlEnabled(false);//列不可排序 mcl->setUserColumnSizingEnabled(false);//列不可调整宽度 editbox = WEditBox(pageWnd->getChildRecursive("Auction/Tab/Agent/sale/EditNum"));//编辑框只能输入数字 editbox->setText(""); //editbox->setReadOnly(false); editbox->setValidationString("[0-9]*"); editbox->setMaxTextLength(5); editbox = WEditBox(pageWnd->getChildRecursive("Auction/Tab/Agent/sale/EditPrice"));//编辑框只能输入数字 editbox->setText(""); //editbox->setReadOnly(false); editbox->setValidationString("[0-9]*"); editbox->setMaxTextLength(5); editbox = WEditBox(pageWnd->getChildRecursive("Auction/Tab/Agent/Buy/EditNum"));//编辑框只能输入数字 editbox->setText(""); //editbox->setReadOnly(false); editbox->setValidationString("[0-9]*"); editbox->setMaxTextLength(5); editbox = WEditBox(pageWnd->getChildRecursive("Auction/Tab/Agent/Buy/EditPrice"));//编辑框只能输入数字 editbox->setText(""); //editbox->setReadOnly(false); editbox->setValidationString("[0-9]*"); editbox->setMaxTextLength(5); ////////////////////////////////////////////////// //委托页面支付提示 wnd = pageWnd->getChildRecursive("Auction/Tab/Agent/sale/subNum");// wnd->setText(""); wnd = pageWnd->getChildRecursive("Auction/Tab/Agent/sale/subGold");// wnd->setText(""); wnd = pageWnd->getChildRecursive("Auction/Tab/Agent/Buy/subNum"); wnd->setText(""); wnd = pageWnd->getChildRecursive("Auction/Tab/Agent/Buy/subGold"); wnd->setText(""); wnd = pageWnd->getChildRecursive("Auction/Tab/Agent/Buy/Text"); wnd->setText(""); //////////////////////////////////////////////////// ///////////////////////////////////////////////// // zhaohang 2010/5/14 // 刷新按钮屏蔽 wnd = pageWnd->getChildRecursive("Auction/Tab/BuySale/RefreshSale"); wnd->setVisible(false); wnd = pageWnd->getChildRecursive("Auction/Tab/BuySale/RefreshBuy"); wnd->setVisible(false); wnd = pageWnd->getChildRecursive("Auction/Tab/Query/Refresh"); wnd->setVisible(false); ///////////////////////////////////////////////// }
void SetInitProShopCity(CEGUI::Window* pageWnd) { CEGUI::TabControl* tbs = WTabControl(pageWnd->getChildRecursive(SHOPCITY_TAB_NAME)); if(tbs) { //默认让第一个TabContent可见 tbs->setSelectedTabAtIndex(0); CEGUI::Window* tbs1 = tbs->getTabContentsAtIndex(tbs->getSelectedTabIndex()); #ifdef _DEBUG const char* name = tbs1->getName().c_str(); OutputDebugStr(name); OutputDebugStr("\n"); #endif tbs1->setVisible(true); //将唯一ShopCityChild添加到上面 CEGUI::TabControl* child = WTabControl(InitShopCityChild()); //默认让第一tabContent可见 child->setSelectedTabAtIndex(0); tbs1->addChildWindow(child); } //清空moneyEdboxes FireUIEvent(SHOPCITY_PAGE_NAME,SHOPCITY_PAGE_EVENT_CLEARMONEYEDBOXES); //moneyEdboxes属性设置 CEGUI::Editbox* edbox = NULL; //星钻 edbox = WEditBox(pageWnd->getChildRecursive(SHOPCITY_XINGZUAN_EDBOX_NAME)); if(edbox) { //只能输入数字 edbox->setValidationString("[0-9]*"); //数字宽 edbox->setMaxTextLength(9); //只读 edbox->setReadOnly(true); } //点券 edbox = WEditBox(pageWnd->getChildRecursive(SHOPCITY_DIANJUAN_EDBOX_NAME)); if(edbox) { //只能输入数字 edbox->setValidationString("[0-9]*"); //数字宽 edbox->setMaxTextLength(9); //只读 edbox->setReadOnly(true); } //位面 edbox = WEditBox(pageWnd->getChildRecursive(SHOPCITY_WEIMIAN_EDBOX_NAME)); if(edbox) { //只能输入数字 edbox->setValidationString("[0-9]*"); //数字宽 edbox->setMaxTextLength(9); //只读 edbox->setReadOnly(true); } //左搜素框 CEGUI::Combobox* cbboxL = WComboBox(pageWnd->getChildRecursive(SHOPCITY_SEARCH_LEFTWND_NAME)); if(cbboxL) { cbboxL->setReadOnly(true); } //右搜素框 CEGUI::Combobox* cbboxR = WComboBox(pageWnd->getChildRecursive(SHOPCITY_SEARCH_RIGHTWND_NAME)); if(cbboxR) { cbboxR->setReadOnly(true); } }
/************************************************************************* Sample specific initialisation goes here. *************************************************************************/ bool MinesweeperSample::initialise(CEGUI::GUIContext* guiContext) { using namespace CEGUI; d_usedFiles = CEGUI::String(__FILE__); // Register Timer Window WindowFactoryManager::getSingleton().addFactory( &getTimerFactory() ); // load font and setup default if not loaded via scheme Font& defaultFont = FontManager::getSingleton().createFromFile("DejaVuSans-12.font"); // Set default font for the gui context guiContext->setDefaultFont(&defaultFont); d_gameStarted = false; // Get window manager which we wil use for a few jobs here. WindowManager& winMgr = WindowManager::getSingleton(); // Load the scheme to initialse the VanillaSkin which we use in this sample SchemeManager::getSingleton().createFromFile("VanillaSkin.scheme"); SchemeManager::getSingleton().createFromFile("TaharezLook.scheme"); guiContext->setDefaultTooltipType("TaharezLook/Tooltip"); // set default mouse image guiContext->getMouseCursor().setDefaultImage("Vanilla-Images/MouseArrow"); // load an image to use as a background if( !ImageManager::getSingleton().isDefined("SpaceBackgroundImage") ) ImageManager::getSingleton().addFromImageFile("SpaceBackgroundImage", "SpaceBackground.jpg"); // here we will use a StaticImage as the root, then we can use it to place a background image Window* background = winMgr.createWindow("Vanilla/StaticImage"); // set area rectangle background->setArea(URect(cegui_reldim(0), cegui_reldim(0), cegui_reldim(1), cegui_reldim(1))); // disable frame and standard background background->setProperty("FrameEnabled", "false"); background->setProperty("BackgroundEnabled", "false"); // set the background image background->setProperty("Image", "SpaceBackgroundImage"); // install this as the root GUI sheet guiContext->setRootWindow(background); d_alarm = (Timer*)winMgr.createWindow("Timer"); background->addChild(d_alarm); d_alarm->setDelay(0.5); // Tick each 0.5 seconds // create the game frame Window* frame = winMgr.createWindow("Vanilla/FrameWindow"); d_alarm->addChild(frame); frame->setXPosition(UDim(0.3f, 0.0f)); frame->setYPosition(UDim(0.15f, 0.0f)); frame->setWidth(UDim(0.4f, 0.0f)); frame->setHeight(UDim(0.7f, 0.0f)); frame->setText("CEGUI Minesweeper"); // create the action panel Window* action = winMgr.createWindow("DefaultWindow"); frame->addChild(action); action->setXPosition(UDim(0.03f, 0.0f)); action->setYPosition(UDim(0.10f, 0.0f)); action->setWidth(UDim(0.94f, 0.0f)); action->setHeight(UDim(0.1f, 0.0f)); d_counter = (Editbox*)winMgr.createWindow("Vanilla/Editbox", "mine_counter"); action->addChild(d_counter); d_counter->setText("0"); d_counter->setTooltipText("Number of mine"); d_counter->setReadOnly(true); d_counter->setXPosition(UDim(0.0f, 0.0f)); d_counter->setYPosition(UDim(0.0f, 0.0f)); d_counter->setWidth(UDim(0.3f, 0.0f)); d_counter->setHeight(UDim(1.0f, 0.0f)); Window* newGame = winMgr.createWindow("Vanilla/Button", "new_game"); action->addChild(newGame); newGame->setText("Start"); newGame->setTooltipText("Start a new game"); newGame->setXPosition(UDim(0.35f, 0.0f)); newGame->setYPosition(UDim(0.0f, 0.0f)); newGame->setWidth(UDim(0.3f, 0.0f)); newGame->setHeight(UDim(1.0f, 0.0f)); newGame->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&MinesweeperSample::handleGameStartClicked, this)); d_timer = (Editbox*)winMgr.createWindow("Vanilla/Editbox", "timer"); action->addChild(d_timer); d_timer->setText("0"); d_timer->setTooltipText("Time elapsed"); d_timer->setReadOnly(true); d_timer->setXPosition(UDim(0.7f, 0.0f)); d_timer->setYPosition(UDim(0.0f, 0.0f)); d_timer->setWidth(UDim(0.3f, 0.0f)); d_timer->setHeight(UDim(1.0f, 0.0f)); d_alarm->subscribeEvent(Timer::EventTimerAlarm, Event::Subscriber(&MinesweeperSample::handleUpdateTimer, this)); // Board button grid Window* grid = winMgr.createWindow("DefaultWindow"); frame->addChild(grid); grid->setXPosition(UDim(0.03f, 0.0f)); grid->setYPosition(UDim(0.23f, 0.0f)); grid->setWidth( UDim(0.94f, 0.0f)); grid->setHeight( UDim(0.74f, 0.0f)); const float d_inc = 1.0f / MinesweeperSize; for(size_t i = 0 ; i < MinesweeperSize ; ++i) { // create a container for each row Window* row = winMgr.createWindow("DefaultWindow"); row->setArea(URect(UDim(0,0), UDim(d_inc * i, 0), UDim(1,0), UDim(d_inc * (i + 1), 0))); grid->addChild(row); for(size_t j = 0 ; j < MinesweeperSize ; ++j) { // Initialize buttons coordinate d_buttonsMapping[i][j].d_col = j; d_buttonsMapping[i][j].d_row = i; d_buttons[i][j] = (PushButton*)winMgr.createWindow("Vanilla/Button"); row->addChild(d_buttons[i][j]); d_buttons[i][j]->setArea(URect(UDim(d_inc * j, 0), UDim(0,0), UDim(d_inc * (j + 1), 0), UDim(1,0))); d_buttons[i][j]->setEnabled(false); // Associate user data d_buttons[i][j]->setUserData(&(d_buttonsMapping[i][j])); d_buttons[i][j]->setID(0); // Connect event handlers d_buttons[i][j]->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&MinesweeperSample::handleMineButtonClicked, this)); d_buttons[i][j]->subscribeEvent(Window::EventMouseButtonDown, Event::Subscriber(&MinesweeperSample::handleMineButtonDown, this)); } } d_result = winMgr.createWindow("Vanilla/StaticText"); grid->addChild(d_result); d_result->setXPosition(UDim(0.0, 0.0)); d_result->setYPosition(UDim(0.0, 0.0)); d_result->setWidth(UDim(1.0, 0.0)); d_result->setHeight(UDim(1.0, 0.0)); d_result->setAlwaysOnTop(true); d_result->setProperty("HorzFormatting", "HorzCentred"); d_result->setVisible(false); d_result->setAlpha(0.67f); // activate the background window background->activate(); // success! return true; }