void Interface::Basic::EventSystemDialog(void)
{
    const Settings & conf = Settings::Get();

    // Change and save system settings
    const int changes = Dialog::SystemOptions();

    // change scroll
    if(0x10 & changes)
    {
	// hardcore reset pos
	gameArea.SetCenter(0, 0);
	if(GetFocusType() != GameFocus::UNSEL)
	    gameArea.SetCenter(GetFocusCenter());
        gameArea.SetRedraw();

	if(conf.ExtGameHideInterface())
	    controlPanel.ResetTheme();
    }

    // interface themes
    if(0x08 & changes)
    {
        SetRedraw(REDRAW_ICONS | REDRAW_BUTTONS | REDRAW_STATUS | REDRAW_BORDER);
    }

    // interface hide/show
    if(0x04 & changes)
    {
	SetHideInterface(conf.ExtGameHideInterface());
        SetRedraw(REDRAW_ALL);
	ResetFocus(GameFocus::HEROES);
	Redraw();
    }
}
示例#2
0
// Initiate the overlay-box
void MenuSystem::OverlayInit(std::string title, std::string text)
{
	// Setup overlay
	overlayText = text;
	overlayShow = true;
	ResetFocus();

	// Update the text-item
	overlayTextItem->SetText(overlayText);
	overlayTextItem->SetMaxWidth(350);
	overlayTextItem->SetAlign(MenuItem::Align::CENTER);

	// Setup box
	overlayBox->SetTitle(title);
	Vec2 boxSize;
	boxSize = overlayTextItem->GetSize() + Vec2(100, 150);
	if (boxSize.x < OVERLAY_MAX_BOXSIZE.x)
		boxSize.x = OVERLAY_MAX_BOXSIZE.x;
	if (boxSize.y < OVERLAY_MAX_BOXSIZE.y)
		boxSize.y = OVERLAY_MAX_BOXSIZE.y;
	overlayBox->SetSize(boxSize);
	overlayBox->SetPosition(Vec2(0, (Context::getWindowHeight() - overlayBox->GetSize().y) / 2));

	// Update the text-item position, based on the box's width
	overlayTextItem->SetPosition(Vec2(boxSize.x / 2, 70));
}
示例#3
0
// Hide the overlay
void MenuSystem::HideOverlay()
{
	if (messageQueue.size() > 0)
	{
		messageQueue.erase(messageQueue.begin());
	}

	if (messageQueue.size() == 0)
	{
		overlayBackgroundAlphaTarget = 0.0f;
	}

	overlayShow = false;
	ResetFocus();
}
示例#4
0
文件: Container.cpp 项目: Lectem/luib
 void Container::detach(Element * const element)
 {
     if(element != nullptr)
     {
         ResetFocus();
         for (auto childPtrIt = _children.begin(); childPtrIt != _children.end(); ++childPtrIt)
         {
             if (childPtrIt->get() == element)
             {
                 (*childPtrIt)->_upper = nullptr;
                 onDetach(childPtrIt->get());
                 _children.erase(childPtrIt);
                 return;
             }
         }
     }
     requestLayout();
 }
示例#5
0
void MenuSystem::HandleInput()
{
	// Handle input on dropdowns
	if (IsDropdownActive())
	{
		// This handles input on the items of the current dropdown
		activeDropdown->HandleItems();

		// Make sure dropdown is deactivated/reset if the user clicks somewhere
		if (Input::getMouseLeftReleased())
		{
			activeDropdown->toggleDropdownStatus();
			ResetFocus();
		}
	}

	// Handle deactivation of the active input-field
	if (activeInputField != NULL)
	{
		if (Input::getMouseLeftPressed() && focusedItem != activeInputField)
		{
			activeInputField->ToggleInputActive();
			activeInputField = NULL;
		}
	}

	// Handle input on all menus
	for(GLuint i = 0; i < menus.size(); i ++)
	{
		menus[i]->HandleInput();
	}

	// Handle overlay-menus
	if (abs(overlaySlide) == 0.0f && overlayShow)
	{
		// Update overlay items
		for(GLuint i = 0; i < overlayItems.size(); i ++)
		{
			overlayItems[i]->HandleInput();
		}
	}
}
void Interface::Basic::EventNextTown(void)
{
    Kingdom & myKingdom = world.GetKingdom(Settings::Get().CurrentColor());
    KingdomCastles & myCastles = myKingdom.GetCastles();

    if(myCastles.size())
    {
	if(GetFocusCastle())
	{
	    KingdomCastles::const_iterator it = std::find(myCastles.begin(), myCastles.end(),
						    GetFocusCastle());
    	    ++it;
    	    if(it == myCastles.end()) it = myCastles.begin();
	    SetFocus(*it);
        }
	else
	    ResetFocus(GameFocus::CASTLE);

        RedrawFocus();
    }
}
void Interface::Basic::EventNextHero(void)
{
    const Kingdom & myKingdom = world.GetKingdom(Settings::Get().CurrentColor());
    const KingdomHeroes & myHeroes = myKingdom.GetHeroes();

    if(myHeroes.empty()) return;

    if(GetFocusHeroes())
    {
	KingdomHeroes::const_iterator it = std::find(myHeroes.begin(), myHeroes.end(),
								GetFocusHeroes());
	++it;
	if(it == myHeroes.end()) it = myHeroes.begin();
	SetFocus(*it);
    }
    else
    {
	ResetFocus(GameFocus::HEROES);
    }
    RedrawFocus();
}
 void Display() {
     SetFocus();
     DoDisplay();
     ResetFocus();
 }
示例#9
0
MenuSystem::MenuSystem(Sprite* sprCursor, Sprite* sprUI, Font* fontBold, Font* fontRegular)
{
	printf("-> Creating MenuSystem...\n");

	// Initialize variables
	ResetFocus();
	this->sprUI = sprUI;
	this->fontBold = fontBold;
	this->fontRegular = fontRegular;
	this->sprCursor = sprCursor;
	rot = 0;
	cursorOffset = 0;

	// Tooltip variables
	tooltipPosition = Vec2(0, 0);
	tooltipSize = Vec2(0, 0);
	tooltipString = "?";
	tooltipTimer = -1.0;

	// Overlay variables
	overlayRenderTarget = new RenderTarget(0, 0);
	overlayItemsRenderTarget = new RenderTarget(0, 0);
	overlayItemsRenderTargetPosition = Vec2(0, 0);
	overlayShow = false;
	overlayText = "?";
	overlaySlide = -1.0f;
	overlayBackgroundAlpha = 0.0f;
	overlayBackgroundAlphaTarget = 0.0f;
	onOverlayButton1 = [](){};
	onOverlayButton2 = [](){};

	// Add elements to message overlay system

	// Box
	overlayBox = new Box(this, "", 0, 0, 0, 0, 0);
	overlayBox->visible = false;

	// Button 1
	overlayItems.push_back(new Button(this, "", Vec2(0, 0), Vec2(0, 0), MenuItem::CENTER, 0, "", [](){}));
	overlayButton1 = (Button*)overlayItems[overlayItems.size() - 1];
	overlayButton1->SetOnClick([=](){ this->OnOverlayButton1(); });

	// Button 2
	overlayItems.push_back(new Button(this, "", Vec2(0, 0), Vec2(0, 0), MenuItem::CENTER, 0, "", [](){}));
	overlayButton2 = (Button*)overlayItems[overlayItems.size() - 1];
	overlayButton2->SetOnClick([=](){ this->OnOverlayButton2(); });

	// Text item
	overlayTextItem = new Text(this, "", Vec2(0, 0), fontRegular, 0);
	overlayTextItem->SetColor(Color(255, 255, 255));
	overlayTextItem->SetShadowAttributes(Color(0, 0, 0), 0.3f);

	// Current scrollbox variables
	currentScrollboxFocus = 0;

	// Initialize dropdown-variables
	activeDropdown = NULL;

	// Initialize input-field variables
	activeInputField = NULL;
}