Esempio n. 1
0
void PhpBrowser::gettitle(char** ret)
{
	QByteArray title = getTab()->page()->mainFrame()->title().toUtf8();
	int len = title.length()+1;
	*ret = new char[len];
    strcpy(*ret, title.constData());
}
Esempio n. 2
0
BOOL LLTabContainer::selectTab(S32 which)
{
	if (which >= getTabCount()) return FALSE;
	if (which < 0) return FALSE;

	//if( gFocusMgr.childHasKeyboardFocus( this ) )
	//{
	//	gFocusMgr.setKeyboardFocus( NULL );
	//}

	LLTabTuple* selected_tuple = getTab(which);
	if (!selected_tuple)
	{
		return FALSE;
	}

	if (!selected_tuple->mPrecommitChangeCallback)
	{
		return setTab(which);
	}

	mNextTabIdx = which;
	selected_tuple->mPrecommitChangeCallback(selected_tuple->mUserData, false);
	return TRUE;
}
void MapEditorModuleContent::onMapClosed(uint32 mapID)
{
    if (auto pTab = getTab(mapID))
    {
        m_pMapTabs->removeTab(m_pMapTabs->indexOf(pTab));
        pTab->deleteLater();
    }
}
void MapEditorModuleContent::onMapEdited(uint32 mapID)
{
    if (auto pTab = getTab(mapID))
    {
        pTab->reloadMap();
        // get new maximum layer size
        _onLayerTypeChanged();
    }
}
void MapEditorModuleContent::_onMapChanged(uint32 mapID)
{
    if (auto pViewer = getTab(mapID))
    {
        m_pMapTabs->setTabText(m_pMapTabs->indexOf(pViewer), m_DBMgr.getMapDatabase().getPrototype(pViewer->getMapID())->getName()
            + (pViewer->hasChanged() ? "*" : ""));
        m_pRevert->setEnabled(pViewer->hasChanged());
    }
}
Esempio n. 6
0
int PhpBrowser::click(const char *xpath, bool samewnd)
{
	if (!getTab()) return 0;

	QApplication::setActiveWindow(this);

	PhpWebView *view = getTab();
	int res = view->click(QString(xpath), samewnd);

	//std::cerr << "test: ";
	//str_utf8_dump(getTab()->title().toUtf8().constData());
	if ((view->isNewViewCreated || samewnd) && getTab()->viewLoadState == 0)
	{
		QEventLoop loop2;
		QObject::connect(getTab(), SIGNAL(loadFinished(bool)), &loop2, SLOT(quit()));
		loop2.exec();
		res = getTab()->loadError;
	}
Esempio n. 7
0
// virtual
BOOL LLTabContainer::handleMouseUp( S32 x, S32 y, MASK mask )
{
	BOOL handled = FALSE;
	BOOL has_scroll_arrows = (getMaxScrollPos() > 0);

	if (has_scroll_arrows)
	{
		if (mJumpPrevArrowBtn && mJumpPrevArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mJumpPrevArrowBtn->getRect().mLeft;
			S32 local_y = y - mJumpPrevArrowBtn->getRect().mBottom;
			handled = mJumpPrevArrowBtn->handleMouseUp(local_x, local_y, mask);
		}
		else if (mJumpNextArrowBtn && mJumpNextArrowBtn->getRect().pointInRect(x,	y))
		{
			S32	local_x	= x	- mJumpNextArrowBtn->getRect().mLeft;
			S32	local_y	= y	- mJumpNextArrowBtn->getRect().mBottom;
			handled = mJumpNextArrowBtn->handleMouseUp(local_x,	local_y, mask);
		}
		else if (mPrevArrowBtn && mPrevArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mPrevArrowBtn->getRect().mLeft;
			S32 local_y = y - mPrevArrowBtn->getRect().mBottom;
			handled = mPrevArrowBtn->handleMouseUp(local_x, local_y, mask);
		}
		else if (mNextArrowBtn && mNextArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mNextArrowBtn->getRect().mLeft;
			S32 local_y = y - mNextArrowBtn->getRect().mBottom;
			handled = mNextArrowBtn->handleMouseUp(local_x, local_y, mask);
		}
	}
	if (!handled)
	{
		handled = LLPanel::handleMouseUp( x, y, mask );
	}

	commitHoveredButton(x, y);
	LLPanel* cur_panel = getCurrentPanel();
	if (hasMouseCapture())
	{
		if (cur_panel)
		{
			if (!cur_panel->focusFirstItem(FALSE))
			{
				// if nothing in the panel gets focus, make sure the new tab does
				// otherwise the last tab might keep focus
				getTab(getCurrentPanelIndex())->mButton->setFocus(TRUE);
			}
		}
		gFocusMgr.setMouseCapture(NULL);
	}
	return handled;
}
Esempio n. 8
0
//-------------------------------------------------------------------------
bool MainWindow::displaySourceFile(const QString& fileName, bool alwaysLoad)
{
  QPlainTextEdit *tab = getTab(fileName);
  bool result = true;

  if(alwaysLoad || tab->toPlainText().isEmpty())
  {
    result = loadSourceFile(fileName, tab);
  }
  ui.tabWidget->setCurrentWidget(tab);
  return result;
}
Esempio n. 9
0
	iterator												thefind(Node val)
	{
		auto												first = this->c.begin();
		auto												last = this->c.end();
		while (first!=last)
		{
			if (first->getTab() == val.getTab())
				return first;
			++first;
		}
		return last;
	}
uint32 ReplayWindow::onMessage(uint32 message, uint32 wParam, uint32 lParam)
{
  if (message == WM_COMMAND && LOWORD(wParam) == ID_PLAYERBOX && HIWORD(wParam) == CBN_SELCHANGE)
  {
    ComboFrameEx* box = dynamic_cast<ComboFrameEx*>(Window::fromHandle((HWND) lParam));
    if (box)
    {
      W3GPlayer* player = (W3GPlayer*) box->getItemData(box->getCurSel());
      for (int i = 0; i < numTabs(); i++)
        ((ReplayTab*) getTab(i))->setPlayer(player);
      if (player && viewItem)
        viewItem->setPlayer(player->player_id);
    }
    return TRUE;
  }
  else if (message == WM_SETPLAYER)
  {
    W3GPlayer* player = (W3GPlayer*) wParam;
    for (int i = 0; i < numTabs(); i++)
      ((ReplayTab*) getTab(i))->setPlayer(player);
    if (player && viewItem)
      viewItem->setPlayer(player->player_id);
    return 0;
  }
  else if (message == WM_SETTAB)
  {
    setTab(wParam);
    return 0;
  }
  else if (message == WM_NOTIFY && viewItem)
  {
    NMHDR* hdr = (NMHDR*) lParam;
    if (hdr->hwndFrom == hWnd && hdr->code == TCN_SELCHANGE)
    {
      if (viewItem)
        viewItem->setTab(getCurSel());
    }
  }
  return TabFrame::onMessage(message, wParam, lParam);
}
Esempio n. 11
0
bool GUIMainMenu::OnEvent(const SEvent& event)
{
	if(event.EventType==EET_KEY_INPUT_EVENT)
	{
		if(event.KeyInput.Key==KEY_ESCAPE && event.KeyInput.PressedDown)
		{
			m_gamecallback->exitToOS();
			quitMenu();
			return true;
		}
		if(event.KeyInput.Key==KEY_RETURN && event.KeyInput.PressedDown)
		{
			acceptInput();
			quitMenu();
			return true;
		}
	}
	if(event.EventType==EET_GUI_EVENT)
	{
		if(event.GUIEvent.EventType==gui::EGET_ELEMENT_FOCUS_LOST
				&& isVisible())
		{
			if(!canTakeFocus(event.GUIEvent.Element))
			{
				dstream<<"GUIMainMenu: Not allowing focus change."
						<<std::endl;
				// Returning true disables focus change
				return true;
			}
		}
		if(event.GUIEvent.EventType==gui::EGET_LISTBOX_CHANGED)
		{
			readInput(m_data);
		}
		if(event.GUIEvent.EventType==gui::EGET_LISTBOX_SELECTED_AGAIN)
		{
			switch(event.GUIEvent.Caller->getID())
			{
			case GUI_ID_WORLD_LISTBOX:
				acceptInput();
				if(getTab() != TAB_SINGLEPLAYER)
					m_data->address = L""; // Force local game
				quitMenu();
				return true;
			}
		}
	}

	return Parent ? Parent->OnEvent(event) : false;
}
void ReplayWindow::setPlayer(int id)
{
  if (replay)
  {
    W3GPlayer* player = replay->getPlayerById(id);
    if (player)
    {
      for (int i = 0; i < numTabs(); i++)
        ((ReplayTab*) getTab(i))->setPlayer(player);
    }
  }
  if (viewItem)
    viewItem->setPlayer(id);
}
Esempio n. 13
0
void LLTabContainer::setPanelTitle(S32 index, const std::string& title)
{
	if (index >= 0 && index < getTabCount())
	{
		LLTabTuple* tuple = getTab(index);
		LLButton* tab_button = tuple->mButton;
		const LLFontGL* fontp = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL );
		mTotalTabWidth -= tab_button->getRect().getWidth();
		tab_button->reshape(llclamp(fontp->getWidth(title) + TAB_PADDING + tuple->mPadding, mMinTabWidth, mMaxTabWidth), tab_button->getRect().getHeight());
		mTotalTabWidth += tab_button->getRect().getWidth();
		tab_button->setLabelSelected(title);
		tab_button->setLabelUnselected(title);
	}
	updateMaxScrollPos();
}
Esempio n. 14
0
int PhpBrowser::load(const char* url, bool samewnd, int timeout)
{
	QString qstrurl = QString::fromUtf8(url);

	if (!samewnd) newTab();
	PhpWebView *view = getTab();
	view->load(QUrl(qstrurl));

    QEventLoop loop2;
    QObject::connect(view, SIGNAL(loadFinished(bool)), &loop2, SLOT(quit()));
	if (timeout > 0)
		QTimer::singleShot(timeout*1000, &loop2, SLOT(quit()));
    loop2.exec();
	return view->loadError;
}
Esempio n. 15
0
// virtual
BOOL LLTabContainer::handleToolTip( S32 x, S32 y, std::string& msg, LLRect* sticky_rect )
{
	BOOL handled = LLPanel::handleToolTip( x, y, msg, sticky_rect );
	if (!handled && getTabCount() > 0) 
	{
		LLTabTuple* firsttuple = getTab(0);

		BOOL has_scroll_arrows = (getMaxScrollPos() > 0);
		LLRect clip;
		if (mIsVertical)
		{
			clip = LLRect(firsttuple->mButton->getRect().mLeft,
						  has_scroll_arrows ? mPrevArrowBtn->getRect().mBottom - TABCNTRV_PAD : mPrevArrowBtn->getRect().mTop,
						  firsttuple->mButton->getRect().mRight,
						  has_scroll_arrows ? mNextArrowBtn->getRect().mTop + TABCNTRV_PAD : mNextArrowBtn->getRect().mBottom );
		}
		else
		{
			clip = LLRect(has_scroll_arrows ? mPrevArrowBtn->getRect().mRight : mJumpPrevArrowBtn->getRect().mLeft,
						  firsttuple->mButton->getRect().mTop,
						  has_scroll_arrows ? mNextArrowBtn->getRect().mLeft : mJumpNextArrowBtn->getRect().mRight,
						  firsttuple->mButton->getRect().mBottom );
		}

		if( clip.pointInRect( x, y ) )
		{
			for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
			{
				LLTabTuple* tuple = *iter;
				tuple->mButton->setVisible( TRUE );
				S32 local_x = x - tuple->mButton->getRect().mLeft;
				S32 local_y = y - tuple->mButton->getRect().mBottom;
				handled = tuple->mButton->handleToolTip( local_x, local_y, msg, sticky_rect );
				if( handled )
				{
					break;
				}
			}
		}

		for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
		{
			LLTabTuple* tuple = *iter;
			tuple->mButton->setVisible( FALSE );
		}
	}
	return handled;
}
Esempio n. 16
0
	void													myerase(Node val)
	{
		PriorityQueue <Node, std::vector<Node>, Compare>	tmp;

		while (this->c.size() > 0)
		{
			auto											first = this->c.begin();
			if (first->getTab() == val.getTab())
			{
				this->pop();
				break;
			}
			tmp.push(*first);
			this->pop();
		}
		while (tmp.size() > 0)
		{
			this->push(tmp.top());
			tmp.pop();
		}
	}
void MapEditorModuleContent::onMapOpened(uint32 mapID)
{
    if (auto pTab = getTab(mapID))
        return;

    auto pEditor = new MapEditor(mapID, m_CacheMgr, m_MappingObject, m_DBMgr, this);
    try
    {
        m_pMapTabs->addTab(pEditor, m_DBMgr.getMapDatabase().getPrototype(mapID)->getName());
        m_pMapTabs->setCurrentWidget(pEditor);
        connect(this, SIGNAL(save()), pEditor, SLOT(_onSave()));
        connect(this, SIGNAL(changeMappingMode(MAPPING_MODE::Type)), pEditor, SLOT(onMappingModeChanged(MAPPING_MODE::Type)));
        connect(pEditor, SIGNAL(actionMousePress(MapEditor&, QMouseEvent*)), &m_MappingObject,
            SLOT(press(MapEditor&, QMouseEvent*)));
        connect(pEditor, SIGNAL(actionMouseRelease(MapEditor&, QMouseEvent*)), &m_MappingObject,
            SLOT(release(MapEditor&, QMouseEvent*)));
        connect(pEditor, SIGNAL(actionMouseMove(MapEditor&, QMouseEvent*)), &m_MappingObject, SLOT(move(MapEditor&, QMouseEvent*)));
        connect(pEditor, SIGNAL(actionKeyPress(MapEditor&, const QPoint&, QKeyEvent*)),
            &m_MappingObject, SLOT(onActionKeyPressed(MapEditor&, const QPoint&, QKeyEvent*)));
        connect(pEditor, SIGNAL(actionKeyRelease(MapEditor&, const QPoint&, QKeyEvent*)),
            &m_MappingObject, SLOT(onActionKeyReleased(MapEditor&, const QPoint&, QKeyEvent*)));

        connect(pEditor, SIGNAL(actionCopy(const MapEditor&)), &m_MappingObject, SLOT(onActionCopy(const MapEditor&)));
        connect(pEditor, SIGNAL(actionCut(const MapEditor&)), &m_MappingObject, SLOT(onActionCut(const MapEditor&)));
        connect(pEditor, SIGNAL(actionDelete(MapEditor&)), &m_MappingObject, SLOT(onActionDelete(MapEditor&)));
        connect(pEditor, SIGNAL(actionPaste(MapEditor&, const QPoint&)), &m_MappingObject, SLOT(onActionPaste(MapEditor&, const QPoint&)));

        connect(pEditor, SIGNAL(changed(uint32)), this, SLOT(_onMapChanged(uint32)));

        connect(pEditor, SIGNAL(setupContextMenu(MapEditor&, QContextMenuEvent*)), &m_MappingObject, SLOT(onContextMenuRequest(MapEditor&, QContextMenuEvent*)));
    }
    catch (const std::bad_alloc& e)
    {
        pEditor->deleteLater();
        QMessageBox::information(0, "Memory Error.", QString("It looks as if the map is too large.\n") +
            QString("The Error-Message is: ") + QString(e.what()), QMessageBox::Ok, QMessageBox::Ok);
    }
}
Esempio n. 18
0
// virtual
BOOL LLTabContainer::handleMouseDown( S32 x, S32 y, MASK mask )
{
	BOOL handled = FALSE;
	BOOL has_scroll_arrows = (getMaxScrollPos() > 0);

	if (has_scroll_arrows)
	{
		if (mJumpPrevArrowBtn&& mJumpPrevArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mJumpPrevArrowBtn->getRect().mLeft;
			S32 local_y = y - mJumpPrevArrowBtn->getRect().mBottom;
			handled = mJumpPrevArrowBtn->handleMouseDown(local_x, local_y, mask);
		}
		else if (mJumpNextArrowBtn && mJumpNextArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mJumpNextArrowBtn->getRect().mLeft;
			S32 local_y = y - mJumpNextArrowBtn->getRect().mBottom;
			handled = mJumpNextArrowBtn->handleMouseDown(local_x, local_y, mask);
		}
		else if (mPrevArrowBtn && mPrevArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mPrevArrowBtn->getRect().mLeft;
			S32 local_y = y - mPrevArrowBtn->getRect().mBottom;
			handled = mPrevArrowBtn->handleMouseDown(local_x, local_y, mask);
		}
		else if (mNextArrowBtn && mNextArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mNextArrowBtn->getRect().mLeft;
			S32 local_y = y - mNextArrowBtn->getRect().mBottom;
			handled = mNextArrowBtn->handleMouseDown(local_x, local_y, mask);
		}
	}
	if (!handled)
	{
		handled = LLPanel::handleMouseDown( x, y, mask );
	}

	S32 tab_count = getTabCount();
	if (tab_count > 0)
	{
		LLTabTuple* firsttuple = getTab(0);
		LLRect tab_rect;
		if (mIsVertical)
		{
			tab_rect = LLRect(firsttuple->mButton->getRect().mLeft,
							  has_scroll_arrows ? mPrevArrowBtn->getRect().mBottom - TABCNTRV_PAD : mPrevArrowBtn->getRect().mTop,
							  firsttuple->mButton->getRect().mRight,
							  has_scroll_arrows ? mNextArrowBtn->getRect().mTop + TABCNTRV_PAD : mNextArrowBtn->getRect().mBottom );
		}
		else
		{
			tab_rect = LLRect(has_scroll_arrows ? mPrevArrowBtn->getRect().mRight : mJumpPrevArrowBtn->getRect().mLeft,
							  firsttuple->mButton->getRect().mTop,
							  has_scroll_arrows ? mNextArrowBtn->getRect().mLeft : mJumpNextArrowBtn->getRect().mRight,
							  firsttuple->mButton->getRect().mBottom );
		}
		if( tab_rect.pointInRect( x, y ) )
		{
			S32 index = getCurrentPanelIndex();
			index = llclamp(index, 0, tab_count-1);
			LLButton* tab_button = getTab(index)->mButton;
			gFocusMgr.setMouseCapture(this);
			gFocusMgr.setKeyboardFocus(tab_button);
		}
	}
	return handled;
}
Esempio n. 19
0
bool GUIMainMenu::OnEvent(const SEvent& event)
{
	if(event.EventType==EET_KEY_INPUT_EVENT)
	{
		if(event.KeyInput.Key==KEY_ESCAPE && event.KeyInput.PressedDown)
		{
			m_gamecallback->exitToOS();
			quitMenu();
			return true;
		}
		if(event.KeyInput.Key==KEY_RETURN && event.KeyInput.PressedDown)
		{
			acceptInput();
			quitMenu();
			return true;
		}
	}
	if(event.EventType==EET_GUI_EVENT)
	{
		if(event.GUIEvent.EventType==gui::EGET_ELEMENT_FOCUS_LOST
				&& isVisible())
		{
			if(!canTakeFocus(event.GUIEvent.Element))
			{
				dstream<<"GUIMainMenu: Not allowing focus change."
						<<std::endl;
				// Returning true disables focus change
				return true;
			}
		}
		if(event.GUIEvent.EventType==gui::EGET_TAB_CHANGED)
		{
			if(!m_is_regenerating)
				regenerateGui(m_screensize_old);
			return true;
		}
		if(event.GUIEvent.EventType==gui::EGET_BUTTON_CLICKED)
		{
			switch(event.GUIEvent.Caller->getID())
			{
			case GUI_ID_JOIN_GAME_BUTTON: {
				MainMenuData cur;
				readInput(&cur);
				if(cur.address == L"" && getTab() == TAB_MULTIPLAYER){
					(new GUIMessageMenu(env, parent, -1, menumgr,
							wgettext("Address required."))
							)->drop();
					return true;
				}
				acceptInput();
				quitMenu();
				return true;
			}
			case GUI_ID_CHANGE_KEYS_BUTTON: {
				GUIKeyChangeMenu *kmenu = new GUIKeyChangeMenu(env, parent, -1,menumgr);
				kmenu->drop();
				return true;
			}
			case GUI_ID_DELETE_WORLD_BUTTON: {
				MainMenuData cur;
				readInput(&cur);
				if(cur.selected_world == -1){
					(new GUIMessageMenu(env, parent, -1, menumgr,
							wgettext("Cannot delete world: Nothing selected"))
							)->drop();
				} else {
					WorldSpec spec = m_data->worlds[cur.selected_world];
					ConfirmDestDeleteWorld *dest = new
							ConfirmDestDeleteWorld(spec, this);
					(new GUIConfirmMenu(env, parent, -1, menumgr, dest,
							(std::wstring(wgettext("Delete world "))
							+L"\""+narrow_to_wide(spec.name)+L"\"?").c_str()
							))->drop();
				}
				return true;
			}
			case GUI_ID_CREATE_WORLD_BUTTON: {
				std::vector<SubgameSpec> games = getAvailableGames();
				if(games.size() == 0){
					GUIMessageMenu *menu = new GUIMessageMenu(env, parent,
							-1, menumgr,
							wgettext("Cannot create world: No games found"));
					menu->drop();
				} else {
					CreateWorldDest *dest = new CreateWorldDestMainMenu(this);
					GUICreateWorld *menu = new GUICreateWorld(env, parent, -1,
							menumgr, dest, games);
					menu->drop();
				}
				return true;
			}
			case GUI_ID_CONFIGURE_WORLD_BUTTON: {
				GUIMessageMenu *menu = new GUIMessageMenu(env, parent,
						-1, menumgr,
						wgettext("Nothing here"));
				menu->drop();
				return true;
			}
			}
		}
		if(event.GUIEvent.EventType==gui::EGET_EDITBOX_ENTER)
		{
			switch(event.GUIEvent.Caller->getID())
			{
				case GUI_ID_ADDRESS_INPUT: case GUI_ID_PORT_INPUT: case GUI_ID_NAME_INPUT: case 264:
				acceptInput();
				quitMenu();
				return true;
			}
		}
		if(event.GUIEvent.EventType==gui::EGET_LISTBOX_SELECTED_AGAIN)
		{
			switch(event.GUIEvent.Caller->getID())
			{
			case GUI_ID_WORLD_LISTBOX:
				acceptInput();
				if(getTab() != TAB_SINGLEPLAYER)
					m_data->address = L""; // Force local game
				quitMenu();
				return true;
			}
		}
	}

	return Parent ? Parent->OnEvent(event) : false;
}
Esempio n. 20
0
void GUIMainMenu::drawMenu()
{
	gui::IGUISkin* skin = Environment->getSkin();
	if (!skin)
		return;
	video::IVideoDriver* driver = Environment->getVideoDriver();
	
	/*video::SColor bgcolor(140,0,0,0);
	driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect);*/

	video::SColor bgcolor(140,0,0,0);

	if(getTab() == TAB_SINGLEPLAYER)
	{
		{
			core::rect<s32> rect(0, 0, m_size_client.X, m_size_client.Y);
			rect += AbsoluteRect.UpperLeftCorner + m_topleft_client;
			driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect);
		}
	}
	else if(getTab() == TAB_MULTIPLAYER)
	{
		{
			core::rect<s32> rect(0, 0, m_size_client.X, m_size_client.Y);
			rect += AbsoluteRect.UpperLeftCorner + m_topleft_client;
			driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect);
		}
	}
	else if(getTab() == TAB_ADVANCED)
	{
		{
			core::rect<s32> rect(0, 0, m_size_client.X, m_size_client.Y);
			rect += AbsoluteRect.UpperLeftCorner + m_topleft_client;
			driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect);
		}
		{
			core::rect<s32> rect(0, 0, m_size_server.X, m_size_server.Y);
			rect += AbsoluteRect.UpperLeftCorner + m_topleft_server;
			driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect);
		}
	}
	else if(getTab() == TAB_SETTINGS)
	{
		{
			core::rect<s32> rect(0, 0, m_size_client.X, m_size_client.Y);
			rect += AbsoluteRect.UpperLeftCorner + m_topleft_client;
			driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect);
		}
	}
	else if(getTab() == TAB_CREDITS)
	{
		{
			core::rect<s32> rect(0, 0, m_size_client.X, m_size_client.Y);
			rect += AbsoluteRect.UpperLeftCorner + m_topleft_client;
			driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect);
		}
		video::ITexture *logotexture =
				driver->getTexture(getTexturePath("menulogo.png").c_str());
		if(logotexture)
		{
			v2s32 logosize(logotexture->getOriginalSize().Width,
					logotexture->getOriginalSize().Height);
			logosize *= 2;
			core::rect<s32> rect(0,0,logosize.X,logosize.Y);
			rect += AbsoluteRect.UpperLeftCorner + m_topleft_client;
			rect += v2s32(130, 50);
			driver->draw2DImage(logotexture, rect,
				core::rect<s32>(core::position2d<s32>(0,0),
				core::dimension2di(logotexture->getSize())),
				NULL, NULL, true);
		}
	}

	gui::IGUIElement::draw();
}
Esempio n. 21
0
BOOL LLTabContainer::setTab(S32 which)
{
	if (which == -1)
	{
		if (mNextTabIdx == -1)
		{
			return FALSE;
		}
		which = mNextTabIdx;
		mNextTabIdx = -1;
	}

	LLTabTuple* selected_tuple = getTab(which);
	if (!selected_tuple)
	{
		return FALSE;
	}

	BOOL is_visible = FALSE;
	if (selected_tuple->mButton->getEnabled())
	{
		setCurrentPanelIndex(which);

		S32 i = 0;
		for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
		{
			LLTabTuple* tuple = *iter;
			BOOL is_selected = ( tuple == selected_tuple );
			tuple->mTabPanel->setVisible( is_selected );
// 			tuple->mTabPanel->setFocus(is_selected); // not clear that we want to do this here.
			tuple->mButton->setToggleState( is_selected );
			// RN: this limits tab-stops to active button only, which would require arrow keys to switch tabs
			tuple->mButton->setTabStop( is_selected );
			
			if( is_selected && (mIsVertical || (getMaxScrollPos() > 0)))
			{
				// Make sure selected tab is within scroll region
				if (mIsVertical)
				{
					S32 num_visible = getTabCount() - getMaxScrollPos();
					if( i >= getScrollPos() && i <= getScrollPos() + num_visible)
					{
						setCurrentPanelIndex(which);
						is_visible = TRUE;
					}
					else
					{
						is_visible = FALSE;
					}
				}
				else
				{
					if( i < getScrollPos() )
					{
						setScrollPos(i);
					}
					else
					{
						S32 available_width_with_arrows = getRect().getWidth() - mRightTabBtnOffset - 2 * (LLPANEL_BORDER_WIDTH + TABCNTR_ARROW_BTN_SIZE  + TABCNTR_ARROW_BTN_SIZE + 1);
						S32 running_tab_width = tuple->mButton->getRect().getWidth();
						S32 j = i - 1;
						S32 min_scroll_pos = i;
						if (running_tab_width < available_width_with_arrows)
						{
							while (j >= 0)
							{
								LLTabTuple* other_tuple = getTab(j);
								running_tab_width += other_tuple->mButton->getRect().getWidth();
								if (running_tab_width > available_width_with_arrows)
								{
									break;
								}
								j--;
							}
							min_scroll_pos = j + 1;
						}
						setScrollPos(llclamp(getScrollPos(), min_scroll_pos, i));
						setScrollPos(llmin(getScrollPos(), getMaxScrollPos()));
					}
					is_visible = TRUE;
				}
			}
			i++;
		}
		if( selected_tuple->mOnChangeCallback )
		{
			selected_tuple->mOnChangeCallback( selected_tuple->mUserData, false );
		}
	}
	if (mIsVertical && getCurrentPanelIndex() >= 0)
	{
		LLTabTuple* tuple = getTab(getCurrentPanelIndex());
		tuple->mTabPanel->setVisible( TRUE );
		tuple->mButton->setToggleState( TRUE );
	}
	return is_visible;
}
Esempio n. 22
0
bool GUIMainMenu::OnEvent(const SEvent& event)
{
	if(event.EventType==EET_KEY_INPUT_EVENT)
	{
		if(event.KeyInput.Key==KEY_ESCAPE && event.KeyInput.PressedDown)
		{
			m_gamecallback->exitToOS();
			quitMenu();
			return true;
		}
		if(event.KeyInput.Key==KEY_RETURN && event.KeyInput.PressedDown)
		{
			acceptInput();
			quitMenu();
			return true;
		}
	}
	if(event.EventType==EET_GUI_EVENT)
	{
		if(event.GUIEvent.EventType==gui::EGET_ELEMENT_FOCUS_LOST
				&& isVisible())
		{
			if(!canTakeFocus(event.GUIEvent.Element))
			{
				dstream<<"GUIMainMenu: Not allowing focus change."
						<<std::endl;
				// Returning true disables focus change
				return true;
			}
		}
		if(event.GUIEvent.EventType==gui::EGET_TAB_CHANGED)
		{
			if(!m_is_regenerating)
				regenerateGui(m_screensize_old);
			return true;
		}
		if(event.GUIEvent.EventType==gui::EGET_LISTBOX_CHANGED && event.GUIEvent.Caller->getID() == GUI_ID_SERVERLIST)
		{
			serverListOnSelected();
			return true;
		}
		if(event.GUIEvent.EventType==gui::EGET_BUTTON_CLICKED)
		{
			switch(event.GUIEvent.Caller->getID())
			{
			case GUI_ID_JOIN_GAME_BUTTON: {
				MainMenuData cur;
				readInput(&cur);
				if (getTab() == TAB_MULTIPLAYER && cur.address == L"")
				{
					wchar_t* text = wgettext("Address required.");
					(new GUIMessageMenu(env, parent, -1, menumgr,
							text)
							)->drop();
					delete[] text;
					return true;
				}
				acceptInput();
				quitMenu();
				return true;
			}
			case GUI_ID_CHANGE_KEYS_BUTTON: {
				GUIKeyChangeMenu *kmenu = new GUIKeyChangeMenu(env, parent, -1,menumgr);
				kmenu->drop();
				return true;
			}
			case GUI_ID_DELETE_WORLD_BUTTON: {
				MainMenuData cur;
				readInput(&cur);
				if(cur.selected_world == -1){
					wchar_t* text = wgettext("Cannot delete world: Nothing selected");
					(new GUIMessageMenu(env, parent, -1, menumgr,
							text)
							)->drop();
					delete[] text;
				} else {
					WorldSpec spec = m_data->worlds[cur.selected_world];
					// Get files and directories involved
					std::vector<std::string> paths;
					paths.push_back(spec.path);
					fs::GetRecursiveSubPaths(spec.path, paths);
					// Launch confirmation dialog
					ConfirmDestDeleteWorld *dest = new
							ConfirmDestDeleteWorld(spec, this, paths);
					wchar_t* text1 = wgettext("Delete world");
					wchar_t* text2 = wgettext("Files to be deleted");
					std::wstring text = text1;
					text += L" \"";
					text += narrow_to_wide(spec.name);
					text += L"\"?\n\n";
					text += text2;
					text += L":\n";
					delete[] text1;
					delete[] text2;
					for(u32 i=0; i<paths.size(); i++){
						if(i == 3){ text += L"..."; break; }
						text += narrow_to_wide(paths[i]) + L"\n";
					}
					(new GUIConfirmMenu(env, parent, -1, menumgr, dest,
							text.c_str()))->drop();
				}
				return true;
			}
			case GUI_ID_CREATE_WORLD_BUTTON: {
				const std::vector<SubgameSpec> &games = m_data->games;
				if(games.size() == 0){
					wchar_t* text = wgettext("Cannot create world: No games found");
					GUIMessageMenu *menu = new GUIMessageMenu(env, parent,
							-1, menumgr,
							text);
					menu->drop();
					delete[] text;
				} else {
					CreateWorldDest *dest = new CreateWorldDestMainMenu(this);
					GUICreateWorld *menu = new GUICreateWorld(env, parent, -1,
							menumgr, dest, games, m_data->selected_game);
					menu->drop();
				}
				return true;
			}
			case GUI_ID_CONFIGURE_WORLD_BUTTON: {
				MainMenuData cur;
				readInput(&cur);
				if(cur.selected_world == -1)
				{
					wchar_t* text = wgettext("Cannot configure world: Nothing selected");
					(new GUIMessageMenu(env, parent, -1, menumgr,
							text)
							)->drop();
					delete[] text;
				} 
				else 
				{
					WorldSpec wspec = m_data->worlds[cur.selected_world];
					GUIConfigureWorld *menu = new GUIConfigureWorld(env, parent,
										-1, menumgr, wspec);
					menu->drop();
				}
				return true;
			}
			case GUI_ID_SERVERLIST_DELETE: {
				gui::IGUIListBox *serverlist = (gui::IGUIListBox*)getElementFromId(GUI_ID_SERVERLIST);
				s32 selected = ((gui::IGUIListBox*)serverlist)->getSelected();
				if (selected == -1) return true;
				ServerList::deleteEntry(m_data->servers[selected]);
				m_data->servers = ServerList::getLocal();
				updateGuiServerList();
				if (selected > 0)
					selected -= 1;
				serverlist->setSelected(selected);
				serverListOnSelected();
				return true;
			}
			#if USE_CURL
			case GUI_ID_SERVERLIST_TOGGLE: {
				gui::IGUIElement *togglebutton = getElementFromId(GUI_ID_SERVERLIST_TOGGLE);
				gui::IGUIElement *deletebutton = getElementFromId(GUI_ID_SERVERLIST_DELETE);
				gui::IGUIListBox *serverlist = (gui::IGUIListBox*)getElementFromId(GUI_ID_SERVERLIST);
				gui::IGUIElement *title = getElementFromId(GUI_ID_SERVERLIST_TITLE);
				if (m_data->selected_serverlist == SERVERLIST_PUBLIC) // switch to favorite list
				{
					m_data->servers = ServerList::getLocal();
					wchar_t* text1 = wgettext("Show Public");
					wchar_t* text2 = wgettext("Favorites:");
					togglebutton->setText(text1);
					title->setText(text2);
					delete[] text1;
					delete[] text2;
					deletebutton->setVisible(true);
					updateGuiServerList();
					serverlist->setSelected(0);
					m_data->selected_serverlist = SERVERLIST_FAVORITES;
				}
				else // switch to online list
				{
					m_data->servers = ServerList::getOnline();
					wchar_t* text1 = wgettext("Show Favorites");
					wchar_t* text2 = wgettext("Public Server List:");
					togglebutton->setText(text1);
					title->setText(text2);
					delete[] text1;
					delete[] text2;
					deletebutton->setVisible(false);
					updateGuiServerList();
					serverlist->setSelected(0);
					m_data->selected_serverlist = SERVERLIST_PUBLIC;
				}
				serverListOnSelected();
			}
			#endif
			}
			/* Game buttons */
			int eid = event.GUIEvent.Caller->getID();
			if(eid >= GUI_ID_GAME_BUTTON_FIRST &&
					eid <= GUI_ID_GAME_BUTTON_MAX){
				m_data->selected_game =
						m_data->games[eid - GUI_ID_GAME_BUTTON_FIRST].id;
				m_data->selected_game_name =
						m_data->games[eid - GUI_ID_GAME_BUTTON_FIRST].name;
				regenerateGui(m_screensize_old);
			}
		}
		if(event.GUIEvent.EventType==gui::EGET_EDITBOX_ENTER)
		{
			switch(event.GUIEvent.Caller->getID())
			{
				case GUI_ID_ADDRESS_INPUT: case GUI_ID_PORT_INPUT: case GUI_ID_NAME_INPUT: case 264:
				MainMenuData cur;
				readInput(&cur);
				if (getTab() == TAB_MULTIPLAYER && cur.address == L"")
				{
					wchar_t* text = wgettext("Address required.");
					(new GUIMessageMenu(env, parent, -1, menumgr,
							text)
							)->drop();
					delete[] text;
					return true;
				}
				acceptInput();
				quitMenu();
				return true;
			}
		}
		if(event.GUIEvent.EventType==gui::EGET_LISTBOX_CHANGED)
		{
			readInput(m_data);
		}
		if(event.GUIEvent.EventType==gui::EGET_LISTBOX_SELECTED_AGAIN)
		{
			switch(event.GUIEvent.Caller->getID())
			{
			case GUI_ID_WORLD_LISTBOX:
				acceptInput();
				if(getTab() != TAB_SINGLEPLAYER)
					m_data->address = L""; // Force local game
				quitMenu();
				return true;
			case GUI_ID_SERVERLIST:
				gui::IGUIListBox *serverlist = (gui::IGUIListBox*)getElementFromId(GUI_ID_SERVERLIST);
				if (serverlist->getSelected() > -1)
				{
					acceptInput();
					quitMenu();
					return true;
				}
			}
		}
	}

	return Parent ? Parent->OnEvent(event) : false;
}