Beispiel #1
0
	virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */)
	{
		CInterfaceManager *im = CInterfaceManager::getInstance();
		CGroupContainer *gc = NULL;
		CCtrlBase *cb = pCaller;
		while (cb)
		{
			gc = dynamic_cast<CGroupContainer *>(cb);
			if (gc) break;
			cb = cb->getParent();
		}
		if (!gc) return;
		AlphaChooserTarget = gc;
		if (!_AlphaObserversAdded)
		{
			_UiVariableBGAlpha = im->getDbProp("UI:VARIABLES:ALPHA_BG");
			_UiVariableContentAlpha = im->getDbProp("UI:VARIABLES:ALPHA_CONTENT");
			_UiVariableRolloverAlphaBG = im->getDbProp("UI:VARIABLES:ALPHA_ROLLOVER_BG");
			_UiVariableRolloverAlphaContent = im->getDbProp("UI:VARIABLES:ALPHA_ROLLOVER_CONTENT");
			ICDBNode::CTextId textIdBGAlpha, textIdContentAlpha, textIdRolloverAlphaBG, textIdRolloverAlphaContent;
			_UiVariableBGAlpha->addObserver(&_BgAlphaObs, textIdBGAlpha);
			_UiVariableContentAlpha->addObserver(&_ContentAlphaObs, textIdContentAlpha);
			_UiVariableRolloverAlphaBG->addObserver(&_RolloverAlphaBGObs, textIdRolloverAlphaBG);
			_UiVariableRolloverAlphaContent->addObserver(&_RolloverAlphaContentObs, textIdRolloverAlphaContent);
			_AlphaObserversAdded = true;
		}
		// disable observers
		_ContentAlphaObs.On = false;
		_BgAlphaObs.On      = false;
		_RolloverAlphaBGObs.On		= false;
		_RolloverAlphaContentObs.On	= false;
		// set alpha of current chosen container
		_UiVariableBGAlpha->setValue32(gc->getContainerAlpha());
		_UiVariableContentAlpha->setValue32(gc->getContentAlpha());
		_UiVariableRolloverAlphaBG->setValue32(255 - gc->getRolloverAlphaContainer());
		_UiVariableRolloverAlphaContent->setValue32(255 - gc->getRolloverAlphaContent());
		// enable observers
		_ContentAlphaObs.On  = true;
		_BgAlphaObs.On       = true;
		_RolloverAlphaBGObs.On		= true;
		_RolloverAlphaContentObs.On	= true;
		// backup current alpha (if the user cancel)
		OldContentAlpha = gc->getContentAlpha();
		OldBgAlpha = gc->getContainerAlpha();
		OldRolloverAlphaBG = gc->getRolloverAlphaContainer();
		OldRolloverAlphaContent = gc->getRolloverAlphaContent();
		OldUseGlobalAlpha = gc->isUsingGlobalAlpha();
		// Enable 'use global alpha' button
		im->getDbProp("UI:VARIABLES:USER_ALPHA")->setValue64(gc->isUsingGlobalAlpha() ? 0 : 1);
		// show the modal box
		im->enableModalWindow(gc, "ui:interface:define_ui_transparency");

	}
Beispiel #2
0
	virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */)
	{
//		CInterfaceManager *im = CInterfaceManager::getInstance();
		CGroupContainer *gc = NULL;
		CCtrlBase *cb = pCaller;
		while (cb)
		{
			gc = dynamic_cast<CGroupContainer *>(cb);
			if (gc) break;
			cb = cb->getParent();
		}
		if (!gc) return;
		//gc->setMovable(!gc->isMovable());
		gc->setLocked(!gc->isLocked());
	}
Beispiel #3
0
	virtual void execute (CCtrlBase *pCaller, const string &Params)
	{
		CInterfaceManager *im = CInterfaceManager::getInstance();

		// get the parent container
		CGroupContainer *gc = NULL;
		CCtrlBase *cb = pCaller;
		while (cb)
		{
			gc = dynamic_cast<CGroupContainer *>(cb);
			if (gc) break;
			cb = cb->getParent();
		}

		// update GC_POPUP flag
		if (gc)
		{
			im->getDbProp("UI:VARIABLES:GC_POPUP")->setValue64((gc->isPopuped() || gc->getLayerSetup() == 0) ? 1 : 0);
		}
		else
		{
			im->getDbProp("UI:VARIABLES:GC_POPUP")->setValue64(0);
		}

		// update GC_HAS_HELP flag
		if(gc && !gc->getHelpPage().empty())
		{
			im->getDbProp("UI:VARIABLES:GC_HAS_HELP")->setValue64(1);
		}
		else
		{
			im->getDbProp("UI:VARIABLES:GC_HAS_HELP")->setValue64(0);
		}

		// open the menu
		if (CDBCtrlSheet::getDraggedSheet() == NULL)
		{
			CInterfaceManager::getInstance()->enableModalWindow (pCaller, getParam(Params, "menu"));
		}
	}
Beispiel #4
0
	CInterfaceElement* CRootGroup::getElement (const std::string &id)
	{
		if (_Id == id)
		return this;

		if (id.substr(0, _Id.size()) != _Id)
			return NULL;

		std::vector<CViewBase*>::const_iterator itv;
		for (itv = _Views.begin(); itv != _Views.end(); itv++)
		{
			CViewBase *pVB = *itv;
			if (pVB->getId() == id)
				return pVB;
		}

		std::vector<CCtrlBase*>::const_iterator itc;
		for (itc = _Controls.begin(); itc != _Controls.end(); itc++)
		{
			CCtrlBase* ctrl = *itc;
			if (ctrl->getId() == id)
				return ctrl;
		}

		// Accelerate
		std::string sTmp = id;
		sTmp = sTmp.substr(_Id.size()+1,sTmp.size());
		std::string::size_type pos = sTmp.find(':');
		if (pos != std::string::npos)
			sTmp = sTmp.substr(0,pos);

		std::map<std::string,CInterfaceGroup*>::iterator it = _Accel.find(sTmp);
		if (it != _Accel.end())
		{
			CInterfaceGroup *pIG = it->second;
			return pIG->getElement(id);
		}
		return NULL;
	}
Beispiel #5
0
    virtual void OnInitDialog()
    {
        // what, no plugins?!
        if (arDbPlugins.getCount() == 0) {
            m_driverList.Enable(false);
            m_profileName.Enable(false);
            ShowWindow(m_warning.GetHwnd(), TRUE);
        }
        else {
            for (int i = 0; i < arDbPlugins.getCount(); i++) {
                DATABASELINK *p = arDbPlugins[i];
                m_driverList.AddString(TranslateTS(p->szFullName), (LPARAM)p);
            }
        }

        // default item
        m_driverList.SetCurSel(0);

        // subclass the profile name box
        mir_subclassWindow(m_profileName.GetHwnd(), ProfileNameValidate);

        // decide if there is a default profile name given in the INI and if it should be used
        if (m_pd->noProfiles || (shouldAutoCreate(m_pd->ptszProfile) && _taccess(m_pd->ptszProfile, 0))) {
            TCHAR *profile = _tcsrchr(m_pd->ptszProfile, '\\');
            if (profile) ++profile;
            else profile = m_pd->ptszProfile;

            TCHAR *p = _tcsrchr(profile, '.');
            TCHAR c = 0;
            if (p) {
                c = *p;
                *p = 0;
            }

            m_profileName.SetText(profile);
            if (c) *p = c;
        }

        // focus on the textbox
        PostMessage(m_hwnd, WM_FOCUSTEXTBOX, 0, 0);
    }
Beispiel #6
0
	virtual void OnInitDialog()
	{
		SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_DETAILSLOGO), IMAGE_ICON, g_iIconSX, g_iIconSY, 0));
		SendMessage(m_hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_DETAILSLOGO), IMAGE_ICON, g_iIconX, g_iIconY, 0));

		if (m_pd->noProfiles || shouldAutoCreate(m_pd->ptszProfile))
			m_tab.ActivatePage(1);

		// service mode combobox
		if (servicePlugins.getCount() == 0) {
			ShowWindow(m_warning.GetHwnd(), FALSE);
			ShowWindow(m_servicePlugs.GetHwnd(), FALSE);
		}
		else {
			m_servicePlugs.AddStringA("", -1);
			m_servicePlugs.SetCurSel(0);

			for (int i = 0; i < servicePlugins.getCount(); i++) {
				pluginEntry *p = servicePlugins[i];
				m_servicePlugs.AddString(TranslateTS(p->pluginname), i);
			}
		}
	}
Beispiel #7
0
	virtual void execute (CCtrlBase *pCaller, const string &Params)
	{
		CInterfaceManager *pIM = CInterfaceManager::getInstance();
		string dblink   = getParam (Params, "dblink");
		string property = getParam (Params, "target_property");
		string propertyToEval = getParam (Params, "target");
		string expr = getParam (Params, "value");
		//nlinfo("set %s %s %s %s", dblink.c_str(), property.c_str(), propertyToEval.c_str(), expr.c_str());
		CInterfaceExprValue value;
		if (CInterfaceExpr::eval(expr, value, NULL))
		{
			if (!dblink.empty())
			{
				// Do not allow Write on SERVER: or LOCAL:
				static const std::string	dbServer= "SERVER:";
				static const std::string	dbLocal= "LOCAL:";
				static const std::string	dbLocalR2= "LOCAL:R2";
				if( (0==dblink.compare(0,    dbServer.size(),    dbServer)) ||
					(0==dblink.compare(0,    dbLocal.size(),    dbLocal))
					)
				{
					if (0!=dblink.compare(0,    dbLocalR2.size(),    dbLocalR2))
					{
						//nlwarning("You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database");
						nlstop;
						return;
					}
				}

				string dblinkeval;
				CInterfaceExpr::unpackDBentry(dblink.c_str(), NULL, dblinkeval);
				if (!value.toInteger())
				{
					nlwarning("<CAHSet:execute> expression doesn't evaluate to a numerical value");
				}
				CInterfaceProperty ip;

				if (!value.toInteger())
				{
					nlwarning("<CAHSet:execute> expression doesn't evaluate to a numerical value");
				}
				if (ip.link (dblinkeval.c_str()))
				{
					ip.setSInt64(value.getInteger());
				}
			}

			if (!propertyToEval.empty())
			{
				CInterfaceExprValue res;
				if (!CInterfaceExpr::eval(propertyToEval, res, NULL)) return;
				res.toString();
				property = res.getString();
			}


			if (!property.empty())
			{
				std::vector<CInterfaceLink::CTargetInfo> targets;
				// find first enclosing group
				CCtrlBase *currCtrl = pCaller;
				CInterfaceGroup *ig = NULL;
				while (currCtrl)
				{
					ig = dynamic_cast<CInterfaceGroup *>(currCtrl);
					if (ig != NULL) break;
					currCtrl = currCtrl->getParent();
				}
				if (ig == NULL)
				{
					string elt = property.substr(0,property.rfind(':'));
					CInterfaceElement *pIE = pIM->getElementFromId(elt);
					ig = dynamic_cast<CInterfaceGroup*>(pIE);
					if (ig == NULL && pIE != NULL)
						ig = pIE->getParent();
				}

				if (ig != NULL)
				{
					CInterfaceParser::splitLinkTargets(property, ig, targets);
					for(uint k = 0; k < targets.size(); ++k)
					{
						if (targets[k].Elem) targets[k].affect(value);
					}
				}
			}
		}
		else
		{
			nlwarning("<CAHSet::execute> Couldn't evaluate expression to affect, expr = %s", expr.c_str());
		}
	}
Beispiel #8
0
// --------------------------------------------------------------------------------------------------------------------
void CViewPointer::draw ()
{
	// Do not display the pointer if not visible.
	if(!_PointerVisible)
		return;

	CInterfaceManager *pIM = CInterfaceManager::getInstance();
	CViewRenderer &rVR = pIM->getViewRenderer();

	if (pIM->isInGame())
	if (!_StringCursor)
	{
		// Create the string cursor instance
		std::vector<std::pair<std::string,std::string> > templateParams;
		templateParams.push_back (std::pair<std::string,std::string>("id", "string_cursor"));

		_StringCursor = pIM->createGroupInstance("string_cursor", "", templateParams);
		if (_StringCursor)
			_StringCursor->setParentPos(pIM->getElementFromId("ui:interface"));

		templateParams.clear();
		templateParams.push_back (std::pair<std::string,std::string>("id", "string_cursor_hardware"));
		_StringCursorHardware = pIM->createGroupInstance("string_cursor_hardware", "", templateParams);
		if (_StringCursorHardware)
			_StringCursorHardware->setParentPos(pIM->getElementFromId("ui:interface"));
	}

	CRGBA col;
	if(getModulateGlobalColor())
		col.modulateFromColor (_Color, pIM->getGlobalColor());
	else
		col= _Color;

	//col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColor().A+1))>>8);
	col.A = _Color.A;

	if (_LastHightLight != NULL)
	{
		_LastHightLight->setHighLighted(false,0);
		_LastHightLight = NULL;
	}

	if (pIM->getCapturePointerLeft() != NULL && pIM->isMouseHandlingEnabled())
	{
		CCtrlMover *pCM = dynamic_cast<CCtrlMover*>(pIM->getCapturePointerLeft());
		if ((pCM != NULL) && (pCM->canMove() == true))
		{
			CGroupContainer *pGC = dynamic_cast<CGroupContainer *>(pCM->getParent());
			if (pGC != NULL && !pGC->isLocked())
			{
				pGC->setHighLighted(true, 255);
				_LastHightLight = pGC;
			}
		}
	}

	if (_TxIdDefault == -2)
	{
		_TxIdDefault	= rVR.getTextureIdFromName (_TxDefault);
		_TxIdMoveWindow = rVR.getTextureIdFromName (_TxMoveWindow);
		_TxIdResizeBRTL = rVR.getTextureIdFromName (_TxResizeBRTL);
		_TxIdResizeBLTR = rVR.getTextureIdFromName (_TxResizeBLTR);
		_TxIdResizeTB	= rVR.getTextureIdFromName (_TxResizeTB);
		_TxIdResizeLR	= rVR.getTextureIdFromName (_TxResizeLR);
		_TxIdRotate		= rVR.getTextureIdFromName (_TxRotate);
		_TxIdScale		= rVR.getTextureIdFromName (_TxScale);
		_TxIdColPick	= rVR.getTextureIdFromName (_TxColPick);
		_TxIdPan		= rVR.getTextureIdFromName (_TxPan);
		_TxIdCanPan		= rVR.getTextureIdFromName (_TxCanPan);
		if (ClientCfg.R2EDEnabled)
		{
			_TxIdPanR2		= rVR.getTextureIdFromName (_TxPanR2);
			_TxIdCanPanR2	= rVR.getTextureIdFromName (_TxCanPanR2);
		}
	}

	const vector<CCtrlBase *> &rICL = pIM->getCtrlsUnderPointer ();


	// Draw the captured cursor
	CCtrlBase *pCB = pIM->getCapturePointerLeft();
	if (pCB != NULL)
	{
		if (drawResizer(pCB,col)) return;
		//if (drawMover(pCB,col)) return;
		if (drawColorPicker(pCB,col)) return;
		if (drawRotate(pCB,col)) return;
		if (drawPan(pCB,col)) return;
		if (drawCustom(pCB)) return;
		drawCursor(_TxIdDefault, col, 0);
		return;
	}

	const vector<CViewBase *> &vUP = pIM->getViewsUnderPointer ();

	for(uint i=0;i<vUP.size();i++)
	{
		CViewLink *vLink = dynamic_cast<CViewLink*>(vUP[i]);
		if (vLink != NULL)
		{
			string tooltip;
			uint8 rot;

			if (vLink->getMouseOverShape(tooltip, rot, col))
			{
				setString(ucstring(tooltip));
				sint32 texId = rVR.getTextureIdFromName ("curs_pick.tga");

				CInterfaceGroup *stringCursor = IsMouseCursorHardware() ? _StringCursorHardware : _StringCursor;
				if (stringCursor)
				{
					stringCursor->setX(_PointerX);
					stringCursor->setY(_PointerY);
					stringCursor->updateCoords();
					stringCursor->draw();
					// if in hardware mode, force to draw the default cursor no matter what..
					if (IsMouseCursorHardware())
						drawCursor(texId, col, 0);
				}
				else
				{
					drawCursor(texId, col, 0);
				}
				return;
			}
		}
	}

	// Draw if capture right
	pCB = pIM->getCapturePointerRight();
	if (pCB != NULL)
	{
		// Is it a 3d scene ?
		if (drawScale(pCB,col)) return;
		drawCursor(_TxIdDefault, col, 0);
		return;
	}

	bool overModalWindow = false;


	// is the cursor currently over a modal window ?
	CInterfaceGroup *currModal = pIM->getModalWindow();
	if (currModal)
	{
		sint32 xPos = _XReal + _OffsetX;
		sint32 yPos = _YReal + _OffsetY;
		overModalWindow = currModal->isIn(xPos, yPos, _WReal, _HReal);
	}

	// Draw the cursor type that are under the pointer
	if (pIM->isMouseHandlingEnabled())
	{
		// Sorts the controls according to their depth, to approximate as best the CapturePointerLeft algo.
		// Especially important so that Resizers controls get the precedence over the move control (else could randomly bug like in chat group)
		static vector<CCtrlDepthEntry>		sortedControls;
		sortedControls.clear();
		for(uint i=0;i<rICL.size();i++)
		{
			CCtrlDepthEntry		cde;
			cde.Ctrl= rICL[i];
			// NB: not the exact CInterfaceManager getDepth test here, but should work fine
			cde.Depth= cde.Ctrl->getParentDepth() + cde.Ctrl->getDeltaDepth();
			sortedControls.push_back(cde);
		}
		std::sort(sortedControls.begin(), sortedControls.end());

		// Then draw the correct cursor
		for (uint32 i = 0; i < sortedControls.size(); ++i)
		{
			CCtrlBase *pCB = sortedControls[i].Ctrl;

			if (overModalWindow)
			{
				if (!pCB->isSonOf(currModal)) continue;
			}

			if (drawBrowse(pCB, col)) return;
			if (drawResizer(pCB,col)) return;
			if (drawColorPicker(pCB,col)) return;
			if (drawLink (pCB, col)) return;
			if (drawCustom(pCB)) return;

			// test for move highlight
			if (_LastHightLight == NULL)
			{
				CCtrlMover *pCM = dynamic_cast<CCtrlMover*>(pCB);
				if ( (pCM != NULL) && (pCM->canMove() == true) )
				{
					CGroupContainer *pGC = dynamic_cast<CGroupContainer *>(pCM->getParent());
					if (pGC != NULL && !pGC->isLocked())
					{
						if (pIM->getCapturePointerLeft() != pCM)
							pGC->setHighLighted(true, 128);
						else
							pGC->setHighLighted(true, 255);
						_LastHightLight = pGC;
						break;
					}
				}
			}

			//if (drawMover(pCB,col)) return;
		}
	}

	if (pIM->isMouseHandlingEnabled())
	{
		if (rICL.empty())
		{
			const vector<CInterfaceGroup *> &rIGL = pIM->getGroupsUnderPointer ();
			for (uint32 i = 0; i < rIGL.size(); ++i)
			{
				CInterfaceGroup *pG = rIGL[i];
				if (overModalWindow)
				{
					if (!pG->isSonOf(currModal)) continue;
				}
				if (drawPan (pG, col)) return;
				if (drawBrowse(pG, col)) return;
			}
		}
	}

	if (_StringMode && pIM->isMouseHandlingEnabled())
	{
		CInterfaceGroup *stringCursor = IsMouseCursorHardware() ? _StringCursorHardware : _StringCursor;
		if (stringCursor)
		{
			stringCursor->setX(_PointerX);
			stringCursor->setY(_PointerY);
			stringCursor->updateCoords();
			stringCursor->draw();
			// if in hardware mode, force to draw the default cursor no matter what..
			if (IsMouseCursorHardware())
			{
				drawCursor(_TxIdDefault, col, 0);
			}
		}
	}
	else
	{
		// Draw the default cursor
		drawCursor(_TxIdDefault, col, 0);
	}
}