bool OnPlayerShopBuyNumChange(const CEGUI::EventArgs& e) { CEGUI::Window* wnd = WEArgs(e).window; if(!wnd) return false; CEGUI::String buyNum = wnd->getText(); char str[32] = ""; CEGUI::Window* goodsWnd = wnd->getParent(); if (goodsWnd) { CGoods* goods = static_cast<CGoods*>(goodsWnd->getUserData()); if (!goods) return false; PlayerShop::tagGoodsItem* pGoodsItem = GetPlayerShop().FindtagGoods(goods); if (pGoodsItem!=NULL) { ulong num = atoi(buyNum.c_str()); if (num>=pGoodsItem->groupNum) { sprintf(str,"%d",pGoodsItem->groupNum); } else if (num<=0) { sprintf(str,"%d",0); } sprintf(str,"%d",num); wnd->setText(ToCEGUIString(str)); pGoodsItem->readyTradeNum = num; } } return true; }
void HUDDemo::createScorePopup(const CEGUI::Vector2<float>& mousePos, int points) { CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton(); CEGUI::Window* popupWindow = winMgr.createWindow("HUDDemo/PopupLabel"); d_rootIngame->addChild(popupWindow); popupWindow->setPosition(CEGUI::UVector2(cegui_absdim(mousePos.d_x), cegui_absdim(mousePos.d_y))); popupWindow->setText(CEGUI::PropertyHelper<int>::toString(points)); popupWindow->setRiseOnClickEnabled(false); popupWindow->subscribeEvent(AnimationInstance::EventAnimationEnded, Event::Subscriber(&HUDDemo::handleScorePopupAnimationEnded, this)); popupWindow->setPixelAligned(false); popupWindow->setFont("DejaVuSans-14"); popupWindow->setPosition(popupWindow->getPosition() + CEGUI::UVector2(cegui_reldim(0.03f), cegui_reldim(-0.02f))); if(points < 0) popupWindow->setProperty("NormalTextColour", "FF880000"); else { popupWindow->setText( "+" + popupWindow->getText()); popupWindow->setProperty("NormalTextColour", "FF006600"); } CEGUI::EventArgs args; popupWindow->fireEvent("StartAnimation", args); }
void PromptBox::SendPrompt(bool clickedOK) { if (mCallback.IsSet()) { CEGUI::Window* editbox = mPromptBox->getChild(mPromptBox->getName() + "/Editbox"); string text = editbox->getText().c_str(); mCallback.Call(clickedOK, text, mTag); } delete this; }
bool OgreCmdWindow::entryKeyDownHandler(const CEGUI::EventArgs& e) { std::stringstream ss; if(((const CEGUI::KeyEventArgs&)e).scancode == 28) { CEGUI::Window * wnd = ((const CEGUI::KeyEventArgs&)e).window; ((OgreCmdWindow*)wnd->getUserData())->readString(wnd->getText().c_str()); wnd->setText(""); } return true; }
bool OnPlayerShopSubBuyNum(const CEGUI::EventArgs& e) { CEGUI::Window* wnd = WEArgs(e).window; if(!wnd) return false; CEGUI::Window* goodsWnd = wnd->getParent(); if (goodsWnd) { CGoods* goods = static_cast<CGoods*>(goodsWnd->getUserData()); if (!goods) return false; PlayerShop::tagGoodsItem* pGoodsItem = GetPlayerShop().FindtagGoods(goods); if (pGoodsItem!=NULL) { char str[32]; // 取得输入框控件名 CEGUI::String name = wnd->getName(); name.assign(name, 0, name.find_last_of("/")); name += "/BuyNum"; CEGUI::Window* buyNumWnd = GetWndMgr().getWindow(name); int num = atoi(buyNumWnd->getText().c_str()); if (num<=0) { sprintf(str,"%d",0); wnd->disable(); } else sprintf(str,"%d",num--); buyNumWnd->setText(ToCEGUIString(str)); pGoodsItem->readyTradeNum = num; } } return true; }
void Galaga::OnClickButton(CEGUI::Window* window) { Log("Got btn click galaga"); if(window->getName() == "Submit") { string msg = ""; CEGUI::Window* input = userInterface->rootWindow->getChild("Console")->getChild("Input"); CEGUI::Window* history = userInterface->rootWindow->getChild("Console")->getChild("History"); if(history && input) { msg = input->getText(); history->appendText(msg); input->setText(""); } if(msg == "host" && !client) { Log("Hosting."); server = network->AddUser<ChatServer>(); server->Host(22222); // ConnectEvent(SENDER(server, Host), RECEIVER(this, OnHost)); ConnectEvent(SENDER(server, ReceiveMessage), RECEIVER(this, OnReceiveMessage)); } else if(msg == "connect" && !server) { Log("Connecting."); client = network->AddUser<ChatClient>(); client->Connect("127.0.0.1", 22222); // ConnectEvent(SENDER(client, Connect), RECEIVER(this, OnHost)); ConnectEvent(SENDER(client, ReceiveMessage), RECEIVER(this, OnReceiveMessage)); } else if(msg == "disconnect") { if(client) { // Client::Destroy calls Disconnect() for us, if a connection is currently established. client->SendMessage("[RemoveClient client]"); // client->Destroy(); } else if(server) { // Close server? server->SendMessage("[RemoveAllClients]"); // server->Destroy(); } } else if(msg == "destroy") { if(client) { client->Destroy(); } else if(server) { // Close server? server->Destroy(); } } else if(msg != "") { if(client) { client->SendMessage(msg); } else if(server) { server->SendMessage(msg); } } } }
bool DeveloperConsole::onConsoleEditboxTextAccepted(const CEGUI::EventArgs& args) { CEGUI::Window* editbox = mConsoleWindow->getChild("Editbox"); CEGUI::String text = editbox->getText(); onConsoleTextSubmitted(text); editbox->setText(""); }