Пример #1
0
void GameMenuDemo::updateIntroText()
{
    static const CEGUI::String firstPart = "Connection established...";
    static const CEGUI::String secondPart = "Warning! User Authentication required!";

    CEGUI::String finalText;

    int firstPartTypeProgress = static_cast<int>((d_timeSinceStart - s_firstStartDelay) / 0.08f);
    if(firstPartTypeProgress > 0)
        finalText += firstPart.substr(0, std::min<unsigned int>(firstPart.length(), firstPartTypeProgress));

    int secondPartTypeProgress = static_cast<int>((d_timeSinceStart - s_secondStartDelay) / 0.08f);
    if(secondPartTypeProgress > 0)
        finalText += "\n" + secondPart.substr(0, std::min<unsigned int>(secondPart.length(), secondPartTypeProgress));

    finalText += "[font='DejaVuSans-12']";

    static double blinkStartDelay = 3.6f;
    double blinkPeriod = 0.8;
    double blinkTime = std::modf(static_cast<double>(d_timeSinceStart), &blinkPeriod);
    if(blinkTime > 0.55 || d_timeSinceStart < blinkStartDelay || d_currentWriteFocus != WF_BotBar)
        finalText += "[colour='00000000']";

    finalText += reinterpret_cast<const encoded_char*>("❚");

    d_botBarLabel->setText(finalText);
}
Пример #2
0
void WidgetDemo::logFiredEvent(const CEGUI::String& logMessage)
{
    ListboxItem* item = d_widgetSelectorListbox->getFirstSelectedItem();
    if(!item)
        return;

    CEGUI::String eventsLog = d_widgetsEventsLog->getText();
    eventsLog += logMessage;

    //Remove line
    int pos = std::max<int>(static_cast<int>(eventsLog.length() - 2056), 0);
    int len = std::min<int>(static_cast<int>(eventsLog.length()), 2056);
    eventsLog = eventsLog.substr(pos, len);
    if(len == 2056)
    {
        int newlinePos = eventsLog.find_first_of("\n");
        if(newlinePos != std::string::npos)
            eventsLog = eventsLog.substr(newlinePos, std::string::npos);
    }
    d_widgetsEventsLog->setText(eventsLog);

    //Scroll to end
    CEGUI::Scrollbar* scrollbar = static_cast<CEGUI::Scrollbar*>(d_widgetsEventsLog->getChild("__auto_vscrollbar__"));
    scrollbar->setScrollPosition(scrollbar->getDocumentSize() - scrollbar->getPageSize());
}
Пример #3
0
void GameMenuDemo::updateLoginStartButtonText(float passedTime)
{
    if(d_timeSinceLoginAccepted <= 0.0f)
        return;

    static const float writeDelay = 1.7f;
    static const CEGUI::String displayText = "Proceed by selecting a planet";

    CEGUI::String finalText;

    int progress = static_cast<int>((d_timeSinceLoginAccepted - writeDelay) / 0.08f);
    if(progress > 0)
        finalText += displayText.substr(0, std::min<unsigned int>(displayText.length(), progress));

    finalText += "[font='DejaVuSans-12']";


    double blinkPeriod = 0.8;
    double blinkTime = std::modf(static_cast<double>(d_timeSinceStart), &blinkPeriod);
    if(blinkTime > 0.55 || d_currentWriteFocus != WF_BotBar)
        finalText += "[colour='00000000']";

    if(d_timeSinceLoginAccepted >= writeDelay)
        d_currentWriteFocus = WF_BotBar;

    finalText += reinterpret_cast<const encoded_char*>("❚");

    d_botBarLabel->setText(finalText);
}
Пример #4
0
void FontDemo::generateNewFontName()
{
    CEGUI::String fileName = d_fontFileNameSelector->getText();
    CEGUI::String pointSize = d_fontSizeEditbox->getText();

    CEGUI::String fontName = fileName.substr(0, fileName.find_last_of("."));
    fontName += "-" + pointSize;

    d_fontNameEditbox->setText(fontName);
}
Пример #5
0
CEGUI::Window* GameMenuDemo::getIconWindowFromLabel(CEGUI::Window* window)
{
    const CEGUI::String windowPrefix = "Label";
    const CEGUI::String iconPostfix = "SelectionIcon";

    CEGUI::String windowName = window->getName();

    windowName = windowName.substr(windowPrefix.length());
    return window->getParent()->getParent()->getChild(windowName + iconPostfix);
}
Пример #6
0
void WidgetDemo::initialiseAvailableWidgetsMap()
{
    //Retrieve the widget look types and add a Listboxitem for each widget, to the right scheme in the map
    CEGUI::WindowFactoryManager& windowFactorymanager = CEGUI::WindowFactoryManager::getSingleton();
    CEGUI::WindowFactoryManager::FalagardMappingIterator falMappingIter = windowFactorymanager.getFalagardMappingIterator();

    while(!falMappingIter.isAtEnd())
    {
        CEGUI::String falagardBaseType = falMappingIter.getCurrentValue().d_windowType;

        int slashPos = falagardBaseType.find_first_of('/');
        CEGUI::String group = falagardBaseType.substr(0, slashPos);
        CEGUI::String name = falagardBaseType.substr(slashPos + 1, falagardBaseType.size() - 1);

        if(group.compare("SampleBrowserSkin") != 0)
        {

            std::map<CEGUI::String, WidgetListType>::iterator iter = d_skinListItemsMap.find(group);
            if(iter == d_skinListItemsMap.end())
            {
                //Create new list
                d_skinListItemsMap[group];
            }

            WidgetListType& widgetList = d_skinListItemsMap.find(group)->second;
            addItemToWidgetList(name, widgetList);
        }

        ++falMappingIter;
    }

    //Add the default types as well
    d_skinListItemsMap["No Skin"];
    WidgetListType& defaultWidgetsList = d_skinListItemsMap["No Skin"];

    addItemToWidgetList("DefaultWindow", defaultWidgetsList);
    addItemToWidgetList("DragContainer", defaultWidgetsList);
    addItemToWidgetList("VerticalLayoutContainer", defaultWidgetsList);
    addItemToWidgetList("HorizontalLayoutContainer", defaultWidgetsList);
    addItemToWidgetList("GridLayoutContainer", defaultWidgetsList);
}
Пример #7
0
void ColouredRenderedStringParser::appendRenderedText(CEGUI::RenderedString& rs, const CEGUI::String& text) const
{
	size_t cpos = 0;
	// split the given string into lines based upon the newline character
	while (text.length() > cpos) {
		// find next newline
		const size_t nlpos = text.find('\n', cpos);
		// calculate length of this substring
		const size_t len = ((nlpos != CEGUI::String::npos) ? nlpos : text.length()) - cpos;

		// construct new text component and append it.
		if (len > 0) {
			//If we're using colours different from those of the default colours we'll also use our own implementation which doesn't do modulation.
			if (d_initialColours.d_bottom_left != d_colours.d_bottom_left || d_initialColours.d_top_left != d_colours.d_top_left || d_initialColours.d_top_right != d_colours.d_top_right || d_initialColours.d_bottom_right != d_colours.d_bottom_right) {
				RenderedColourStringTextComponent rtc(text.substr(cpos, len), d_fontName);
				rtc.setPadding(d_padding);
				rtc.setColours(d_colours);
				rtc.setVerticalFormatting(d_vertAlignment);
				rtc.setAspectLock(d_aspectLock);
				rs.appendComponent(rtc);
			} else {
				CEGUI::RenderedStringTextComponent rtc(text.substr(cpos, len), d_fontName);
				rtc.setPadding(d_padding);
				rtc.setColours(d_colours);
				rtc.setVerticalFormatting(d_vertAlignment);
				rtc.setAspectLock(d_aspectLock);
				rs.appendComponent(rtc);
			}
		}

		// break line if needed
		if (nlpos != CEGUI::String::npos)
			rs.appendLineBreak();

		// advance current position.  +1 to skip the \n char
		cpos += len + 1;
	}
}
Пример #8
0
bool MainGui::changeMenu(const CEGUI::EventArgs & e)
{
	Menu * aux;
	const CEGUI::MouseEventArgs& we = static_cast<const CEGUI::MouseEventArgs&>(e);
	CEGUI::String senderID = we.window->getName();

	int pos = senderID.find_first_of("@",0);
	CEGUI::String currentMenu= senderID.substr(0,pos);
	CEGUI::String nextMenu= senderID.substr(pos+1,senderID.length());

	map<CEGUI::String, Menu*>::iterator it1, it2;

	it1 = mapaMenus.find(currentMenu);
	it2 = mapaMenus.find(nextMenu);

	aux = it1->second;
	aux->animateMenu();

	aux = it2->second;
	aux->animateMenu();

	return true;
}
void vis_settings_panel_impl::init_menu_bar(CEGUI::Menubar* menuBar)
{
	CEGUI::String skin = menuBar->getType();
	skin = skin.substr(0, skin.find_first_of('/'));
	CEGUI::String menuItemMapping = skin + "/MenuItem";
	CEGUI::String popupMenuMapping = skin + "/PopupMenu";

	CEGUI::WindowManager& windowManager = CEGUI::WindowManager::getSingleton(); 
	CEGUI::MenuItem* fileMenuItem = static_cast<CEGUI::MenuItem*>(windowManager.createWindow(menuItemMapping, "FileMenuItem"));
	fileMenuItem->setText("File");
	menuBar->addChild(fileMenuItem);

	CEGUI::PopupMenu* filePopupMenu = static_cast<CEGUI::PopupMenu*>(windowManager.createWindow(popupMenuMapping, "FilePopupMenu"));
	fileMenuItem->addChild(filePopupMenu);

	CEGUI::MenuItem* menuItem;
	menuItem = static_cast<CEGUI::MenuItem*>(windowManager.createWindow(menuItemMapping, "FileTestMenuItem1"));
	menuItem->setText("Open");
	filePopupMenu->addItem(menuItem);

	menuItem = static_cast<CEGUI::MenuItem*>(windowManager.createWindow(menuItemMapping, "FileTestMenuItem2"));
	menuItem->setText("Save");
	filePopupMenu->addItem(menuItem);

	menuItem = static_cast<CEGUI::MenuItem*>(windowManager.createWindow(menuItemMapping, "FileTestMenuItem3"));
	menuItem->setText("Exit");
	filePopupMenu->addItem(menuItem);

	menuItem->subscribeEvent(MenuItem::EventClicked, 
		Event::Subscriber([=](const CEGUI::EventArgs& args)->bool 
		{

			exit_app_signal_(); 
			return true;

		})
		); 

	CEGUI::MenuItem* viewMenuItem = static_cast<CEGUI::MenuItem*>(windowManager.createWindow(menuItemMapping, "ViewMenuItem"));
	viewMenuItem->setText("View");
	menuBar->addChild(viewMenuItem);

	CEGUI::PopupMenu* viewPopupMenu = static_cast<CEGUI::PopupMenu*>(windowManager.createWindow(popupMenuMapping, "ViewPopupMenu"));
	viewMenuItem->addChild(viewPopupMenu);

	menuItem = static_cast<CEGUI::MenuItem*>(windowManager.createWindow(menuItemMapping, "ViewTestMenuItem1"));
	menuItem->setText("Lights");
	viewPopupMenu->addItem(menuItem);
}
Пример #10
0
void translateCeguiWindow(CEGUI::Window* ceguiWindow, bool isRecursive)
{
	// If null return
	if (!ceguiWindow)
		return;
	// Translate
	CEGUI::String text = ceguiWindow->getText();
	if (text.length() > 0 && text[0] == '@')
	{
		std::string code = ceguiStringToUtf8(text.substr(1, text.length() - 1));
		ceguiWindow->setText(utf8ToCeguiString(GameSettingsSingleton.getLanguage().textForCode(code)));
	}
	// Recursive for all children
	if (isRecursive)
		for (size_t i = 0; i < ceguiWindow->getChildCount(); ++i)
			translateCeguiWindow(ceguiWindow->getChildAtIdx(i));
}
Пример #11
0
size_t menu_impl::add_string(std::string const &text, target const &click, target const &hover)
{
    //QAction *act = addAction(QString::fromUtf8(text.c_str())) ;
    //connect(act, SIGNAL(triggered()), this, SLOT(action_slot())) ;

	CEGUI::String skin = base_->getType();
	skin = skin.substr(0, skin.find_first_of('/'));
	CEGUI::String menuItemMapping = skin + "/MenuItem";
	CEGUI::String popupMenuMapping = skin + "/PopupMenu";

	CEGUI::WindowManager& windowManager = CEGUI::WindowManager::getSingleton();
	auto menuItem = static_cast<CEGUI::MenuItem*>(windowManager.createWindow(menuItemMapping, text + "_MenuItem"));
	menuItem->setText(text);
	base_->addItem(menuItem);

    if (click)
    //    actions_.insert(act, click) ;
	{
		menuItem->subscribeEvent(MenuItem::EventClicked, 
			Event::Subscriber([=](const CEGUI::EventArgs& args)->bool 
			{
				click(); 
				return true;
			})			
			
			); 	
	}	

    if (hover)
    //    hovers_.insert(act, hover) ;
	{
		menuItem->subscribeEvent(MenuItem::EventMouseEntersArea, 
			Event::Subscriber([=](const CEGUI::EventArgs& args)->bool 
			{
				hover(); 
				return true;
			})			
			
			); 	
	}

	size_t act = 0;

    return (size_t)act ;
}
Пример #12
0
void WidgetDemo::initMenubar(CEGUI::Menubar* menuBar)
{
    CEGUI::String skin = menuBar->getType();
    skin = skin.substr(0, skin.find_first_of('/'));
    CEGUI::String menuItemMapping = skin + "/MenuItem";
    CEGUI::String popupMenuMapping = skin + "/PopupMenu";

    CEGUI::WindowManager& windowManager = CEGUI::WindowManager::getSingleton(); 
    CEGUI::MenuItem* fileMenuItem = static_cast<CEGUI::MenuItem*>(windowManager.createWindow(menuItemMapping, "FileMenuItem"));
    fileMenuItem->setText("File");
    menuBar->addChild(fileMenuItem);
 
    CEGUI::PopupMenu* filePopupMenu = static_cast<CEGUI::PopupMenu*>(windowManager.createWindow(popupMenuMapping, "FilePopupMenu"));
    fileMenuItem->addChild(filePopupMenu);

    CEGUI::MenuItem* menuItem;
    menuItem = static_cast<CEGUI::MenuItem*>(windowManager.createWindow(menuItemMapping, "FileTestMenuItem1"));
    menuItem->setText("Open");
    filePopupMenu->addItem(menuItem);

    menuItem = static_cast<CEGUI::MenuItem*>(windowManager.createWindow(menuItemMapping, "FileTestMenuItem2"));
    menuItem->setText("Save");
    filePopupMenu->addItem(menuItem);

    menuItem = static_cast<CEGUI::MenuItem*>(windowManager.createWindow(menuItemMapping, "FileTestMenuItem3"));
    menuItem->setText("Exit");
    filePopupMenu->addItem(menuItem);


    CEGUI::MenuItem* viewMenuItem = static_cast<CEGUI::MenuItem*>(windowManager.createWindow(menuItemMapping, "ViewMenuItem"));
    fileMenuItem->setText("View");
    menuBar->addChild(viewMenuItem);

    CEGUI::PopupMenu* viewPopupMenu = static_cast<CEGUI::PopupMenu*>(windowManager.createWindow(popupMenuMapping, "ViewPopupMenu"));
    viewMenuItem->addChild(viewPopupMenu);

    menuItem = static_cast<CEGUI::MenuItem*>(windowManager.createWindow(menuItemMapping, "ViewTestMenuItem1"));
    menuItem->setText("Midgets");
    viewPopupMenu->addItem(menuItem);
}
Пример #13
0
void GameMenuDemo::updateLoginWelcomeText(float passedTime)
{
    if(d_timeSinceLoginAccepted <= 0.0f)
        return;

    static const CEGUI::String firstPart = "Welcome ";
    CEGUI::String displayText = firstPart + d_userName;
    CEGUI::String finalText;

    int progress = static_cast<int>(d_timeSinceLoginAccepted / 0.08f);
    if(progress > 0)
        finalText += displayText.substr(0, std::min<unsigned int>(displayText.length(), progress));

    finalText += "[font='DejaVuSans-12']";

    double blinkPeriod = 0.8;
    double blinkTime = std::modf(static_cast<double>(d_timeSinceStart), &blinkPeriod);
    if(blinkTime > 0.55 || d_currentWriteFocus != WF_TopBar)
        finalText += "[colour='00000000']";

    finalText += reinterpret_cast<const encoded_char*>("❚");

    d_topBarLabel->setText(finalText);
}