Exemplo n.º 1
0
int GUI::sub(GUI &gui, int startCode, bool showSelf) {
	GfxMan.lockFrame();

	removeFocus();

	// Show the sub GUI
	if (startCode == 0)
		gui.show();
	hide();

	GfxMan.unlockFrame();

	// Run the sub GUI
	int code = gui.run(startCode);

	GfxMan.lockFrame();

	// Hide the sub GUI
	if (showSelf)
		show();
	gui.hide();

	// Update the mouse position
	removeFocus();
	updateMouse();

	GfxMan.unlockFrame();

	return code;
}
Exemplo n.º 2
0
int GUI::run(int startCode) {
	_startCode  = startCode;
	_returnCode = 0;

	EventMan.flushEvents();

	removeFocus();
	updateMouse();

	// Run as long as we don't have a return code
	while (_returnCode == 0) {
		// Call the periodic run callback
		callbackRun();
		if (_returnCode != 0)
			break;

		// But return immediately when an engine quit was requested
		if (EventMan.quitRequested())
			return 0;

		// Handle events
		Events::Event event;
		while (EventMan.pollEvent(event))
			addEvent(event);

		processEventQueue();

		// Delay for a while
		if (!EventMan.quitRequested() && (_returnCode != 0))
			EventMan.delay(10);
	}

	return _returnCode;
}
Exemplo n.º 3
0
void PartyLeader::callbackActive(Widget &widget) {
	if (widget.getTag() == "ButtonOptions") {
		removeFocus();
		_module->showMenu();
		return;
	}

}
Exemplo n.º 4
0
void DOSBoxMenu::showMenu(bool show) {
    if (menuVisible != show) {
        menuVisible = show;
        needRedraw = true;
        removeFocus();
        updateRect();
    }
}
Exemplo n.º 5
0
Area::~Area() {
	_module->removeObject(*this);

	hide();

	removeFocus();

	clear();
}
Exemplo n.º 6
0
Area::~Area() {
	hide();

	removeFocus();

	for (ObjectList::iterator o = _objects.begin(); o != _objects.end(); ++o)
		delete *o;

	for (std::vector<Room *>::iterator r = _rooms.begin(); r != _rooms.end(); ++r)
		delete *r;
}
//! sets the focus to an element
void CGUIEnvironment::setFocus(IGUIElement* element)
{
	if (Focus == element)
		return;

	removeFocus(Focus);

	Focus = element;
	if (Focus)
		Focus->grab();
}
Exemplo n.º 8
0
bool UINode::checkFocus (int32_t x, int32_t y)
{
	if (x <= -1 || y <= -1 || !isVisible() || !isActive()) {
		if (hasFocus())
			removeFocus();
		return false;
	}

	if (checkBounds(x, y)) {
		if (_nodes.empty()) {
			addFocus(x, y);
			return true;
		}

		const int childX = x - getRenderX();
		const int childY = y - getRenderY();
		bool focusOnChildren = false;
		for (UINodeListRevIter i = _nodes.rbegin(); i != _nodes.rend(); ++i) {
			UINode* nodePtr = *i;
			int focusX = childX;
			int focusY = childY;
			if (focusOnChildren) {
				focusX = focusY = -1;
			}
			const bool focus = nodePtr->checkFocus(focusX, focusY);
			focusOnChildren |= focus;
		}

		if (focusOnChildren) {
			addFocus(x, y);
			return true;
		}
	}

	if (hasFocus()) {
		removeFocus();
	}
	return false;
}
Exemplo n.º 9
0
void Area::unload() {
	hide();
	removeFocus();

	for (ObjectList::iterator o = _objects.begin(); o != _objects.end(); ++o)
		delete *o;

	for (RoomList::iterator r = _rooms.begin(); r != _rooms.end(); ++r)
		delete *r;

	_objects.clear();
	_rooms.clear();

	_loaded = false;
}
Exemplo n.º 10
0
void Area::hide() {
	if (!_visible)
		return;

	removeFocus();

	GfxMan.lockFrame();

	// Hide objects
	for (ObjectList::iterator o = _objects.begin(); o != _objects.end(); ++o)
		(*o)->hide();

	// Hide rooms
	for (RoomList::iterator r = _rooms.begin(); r != _rooms.end(); ++r)
		(*r)->hide();

	GfxMan.unlockFrame();

	_visible = false;
}
Exemplo n.º 11
0
bool UINode::nextFocus ()
{
	if (_nodes.empty()) {
		if (!isActive())
			return false;
		if (hasFocus())
			return false;
		addFocus(0, 0);
		return true;
	}

	for (UINodeListIter i = _nodes.begin(); i != _nodes.end(); ++i) {
		UINode* nodePtr = *i;
		// search the node that currently has the focus
		if (!nodePtr->hasFocus())
			continue;

		if (nodePtr->nextFocus()) {
			addFocus(0, 0);
			return true;
		}

		nodePtr->removeFocus();
		for (++i; i != _nodes.end(); ++i) {
			UINode* focusNodePtr = *i;
			if (focusNodePtr->addFirstFocus()) {
				addFocus(0, 0);
				return true;
			}
		}
		break;
	}

	removeFocus();

	return false;
}
Exemplo n.º 12
0
void Area::hide() {
	assert(_loaded);

	if (!_visible)
		return;

	removeFocus();

	stopSound();

	GfxMan.lockFrame();

	// Hide objects
	for (ObjectList::iterator o = _objects.begin(); o != _objects.end(); ++o)
		(*o)->hide();

	// Hide rooms
	for (std::vector<Room *>::iterator room = _rooms.begin(); room != _rooms.end(); ++room)
		(*room)->model->hide();

	GfxMan.unlockFrame();

	_visible = false;
}
Exemplo n.º 13
0
void Area::hide() {
	if (!_visible)
		return;

	removeFocus();

	stopSound();

	GfxMan.lockFrame();

	// Hide objects
	for (ObjectList::iterator o = _objects.begin(); o != _objects.end(); ++o)
		(*o)->hide();

	// Hide tiles
	for (std::vector<Tile>::iterator t = _tiles.begin(); t != _tiles.end(); ++t)
		t->model->hide();

	GfxMan.unlockFrame();

	unloadModels();

	_visible = false;
}
Exemplo n.º 14
0
void Area::hide() {
	if (!_visible)
		return;

	removeFocus();

	stopAmbientMusic();

	GfxMan.lockFrame();

	// Hide objects
	for (ObjectList::iterator o = _objects.begin(); o != _objects.end(); ++o)
		(*o)->hide();

	// Hide area geometry model
	if (_model)
		_model->show();

	GfxMan.unlockFrame();

	unloadModels();

	_visible = false;
}
Exemplo n.º 15
0
//! called if an event happened.
bool MainMenu::onEvent(const NEvent& event)
{
	if (isEnabled())
	{
		switch(event.EventType)
		{
		case OC3_GUI_EVENT:
			switch(event.GuiEvent.EventType)
			{
			case OC3_ELEMENT_FOCUS_LOST:
				if (event.GuiEvent.Caller == this && !isMyChild(event.GuiEvent.Element))
				{
					closeAllSubMenus_();
					setHoverIndex_( -1 );
				}
				break;
			case OC3_ELEMENT_FOCUSED:
				if (event.GuiEvent.Caller == this )
				{
					bringToFront();
				}
				break;
			default:
				break;
			}
			break;
		case OC3_MOUSE_EVENT:
			switch(event.MouseEvent.Event)
			{
			case OC3_LMOUSE_PRESSED_DOWN:
			{
				if (!getEnvironment()->hasFocus(this))
				{
					getEnvironment()->setFocus(this);
				}

    	  bringToFront();

				Point p(event.MouseEvent.getPosition() );
				bool shouldCloseSubMenu = hasOpenSubMenu_();
				if (!getAbsoluteClippingRect().isPointInside(p))
				{
					shouldCloseSubMenu = false;
				}
				isHighlighted_( event.MouseEvent.getPosition(), true);
				if ( shouldCloseSubMenu )
				{
          getEnvironment()->removeFocus(this);
				}

				return true;
			}

			case OC3_LMOUSE_LEFT_UP:
			{
        Point p(event.MouseEvent.getPosition() );
				if (!getAbsoluteClippingRect().isPointInside(p))
				{
					int t = sendClick_(p);
					if ((t==0 || t==1) && isFocused())
						removeFocus();
				}

			  return true;
			}

      case OC3_MOUSE_MOVED:
      {
				if (getEnvironment()->hasFocus(this) && getHoveredIndex() >= 0)
				{
				  int oldHighLighted = getHoveredIndex();
					isHighlighted_( event.MouseEvent.getPosition(), true);
					if ( getHoveredIndex() < 0 )
          {
            setHoverIndex_( oldHighLighted );   // keep last hightlight active when moving outside the area
          }
				}
				return true;
      }

      default:
			break;
			}
		break;
		
    default:
		break;
		}
	}

	return Widget::onEvent(event);
}
Exemplo n.º 16
0
void UINode::setVisible (bool visible)
{
	if (!visible)
		removeFocus();
	_visible = visible;
}
Exemplo n.º 17
0
//! called if an event happened.
bool MainMenu::onEvent(const NEvent& event)
{
	if (isEnabled())
	{
		switch(event.EventType)
		{
		case sEventGui:
			switch(event.GuiEvent.EventType)
			{
			case guiElementFocusLost:
				if (event.GuiEvent.Caller == this && !isMyChild(event.GuiEvent.Element))
				{
					closeAllSubMenus_();
					setHoverIndex_( -1 );
				}
				break;
			case guiElementFocused:
				if (event.GuiEvent.Caller == this )
				{
					bringToFront();
				}
				break;
			default:
				break;
			}
			break;
		case sEventMouse:
			switch(event.MouseEvent.Event)
			{
			case mouseLbtnPressed:
			{
				if (!getEnvironment()->hasFocus(this))
				{
					getEnvironment()->setFocus(this);
				}

    	  bringToFront();

				Point p(event.MouseEvent.getPosition() );
				bool shouldCloseSubMenu = hasOpenSubMenu_();
				if (!getAbsoluteClippingRect().isPointInside(p))
				{
					shouldCloseSubMenu = false;
				}
				isHighlighted_( event.MouseEvent.getPosition(), true);
				if ( shouldCloseSubMenu )
				{
          getEnvironment()->removeFocus(this);
				}

				return true;
			}

			case mouseLbtnRelease:
			{
        Point p(event.MouseEvent.getPosition() );
				if (!getAbsoluteClippingRect().isPointInside(p))
				{
					int t = sendClick_(p);
					if ((t==0 || t==1) && isFocused())
						removeFocus();
				}

			  return true;
			}

      case mouseMoved:
      {
				if (getEnvironment()->hasFocus(this) && getHoveredIndex() >= 0)
				{
				  int oldHighLighted = getHoveredIndex();
					isHighlighted_( event.MouseEvent.getPosition(), true);
					if ( getHoveredIndex() < 0 )
          {
            setHoverIndex_( oldHighLighted );   // keep last hightlight active when moving outside the area
          }
				}
				return true;
      }

      default:
			break;
			}
		break;
		
    default:
		break;
		}
	}

	return Widget::onEvent(event);
}