示例#1
0
void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount)
{
    if (!amount)
    {
        if (config.getValue("showpickupchat", 1))
        {
            localChatTab->chatLog(_("Unable to pick up item."), BY_SERVER);
        }
    }
    else
    {
        if (config.getValue("showpickupchat", 1))
        {
            // TRANSLATORS: This sentence may be translated differently
            // for different grammatical numbers (singular, plural, ...)
            localChatTab->chatLog(strprintf(ngettext("You picked up %d "
                    "[@@%d|%s@@].", "You picked up %d [@@%d|%s@@].", amount),
                    amount, itemInfo.getId(), itemInfo.getName().c_str()),
                    BY_SERVER);
        }

        if (mMap && config.getValue("showpickupparticle", 0))
        {
            // Show pickup notification
            addMessageToQueue(itemInfo.getName(), Palette::PICKUP_INFO);
        }
    }
}
示例#2
0
void ItemPopup::setItem(const ItemInfo &item)
{
    if (item.getName() == mItemName->getCaption())
        return;

    mItemType = item.getType();

    mItemName->setCaption(item.getName());
    mItemName->adjustSize();
    mItemName->setForegroundColor(getColor(mItemType));

    mItemDesc->setTextWrapped(item.getDescription(), 196);
    mItemEffect->setTextWrapped(item.getEffect(), 196);
    mItemWeight->setTextWrapped(strprintf(_("Weight: %s"),
                                Units::formatWeight(item.getWeight()).c_str()),
                                196);

    int minWidth = mItemName->getWidth();

    if (mItemDesc->getMinWidth() > minWidth)
        minWidth = mItemDesc->getMinWidth();
    if (mItemEffect->getMinWidth() > minWidth)
        minWidth = mItemEffect->getMinWidth();
    if (mItemWeight->getMinWidth() > minWidth)
        minWidth = mItemWeight->getMinWidth();

    minWidth += 8;
    setWidth(minWidth);

    const int numRowsDesc = mItemDesc->getNumberOfRows();
    const int numRowsEffect = mItemEffect->getNumberOfRows();
    const int numRowsWeight = mItemWeight->getNumberOfRows();
    const int height = getFont()->getHeight();

    if (item.getEffect().empty())
    {
        setContentSize(minWidth, (numRowsDesc + numRowsWeight + getPadding()) *
                       height);

        mItemWeight->setPosition(getPadding(), (numRowsDesc + getPadding()) *
                                 height);
    }
    else
    {
        setContentSize(minWidth, (numRowsDesc + numRowsEffect + numRowsWeight +
                       getPadding()) * height);

        mItemWeight->setPosition(getPadding(), (numRowsDesc + numRowsEffect +
                                 getPadding()) * height);
    }

    mItemDesc->setPosition(getPadding(), 2 * height);
    mItemEffect->setPosition(getPadding(), (numRowsDesc + getPadding()) * height);
}
示例#3
0
void ItemPopup::setItem(const ItemInfo &item)
{
    if (item.getName() == mItemName->getCaption())
        return;

    mItemName->setFont(gui->getBoldFont());
    mItemName->setCaption(item.getName());
    mItemName->setWidth(gui->getBoldFont()->getWidth(item.getName()));
    mItemDesc->setTextWrapped(item.getDescription(), 196);
    mItemEffect->setTextWrapped(item.getEffect(), 196);
    mItemWeight->setTextWrapped(_("Weight: ") + toString(item.getWeight()) +
                                _(" grams"), 196);
    mItemType = item.getType();

    int minWidth = mItemName->getWidth();

    if (mItemDesc->getMinWidth() > minWidth)
        minWidth = mItemDesc->getMinWidth();
    if (mItemEffect->getMinWidth() > minWidth)
        minWidth = mItemEffect->getMinWidth();
    if (mItemWeight->getMinWidth() > minWidth)
        minWidth = mItemWeight->getMinWidth();

    minWidth += 8;
    setWidth(minWidth);

    const int numRowsDesc = mItemDesc->getNumberOfRows();
    const int numRowsEffect = item.getEffect().empty() ? 0 : 
                              mItemEffect->getNumberOfRows();
    const int numRowsWeight = mItemWeight->getNumberOfRows();
    const int height = getFont()->getHeight();

    setContentSize(minWidth, (numRowsDesc + numRowsEffect + numRowsWeight +
                   getPadding()) * height);

    mItemWeight->setPosition(getPadding(), (numRowsDesc + numRowsEffect +
                             getPadding()) * height);

    mItemDesc->setPosition(getPadding(), 2 * height);
    mItemEffect->setPosition(getPadding(), (numRowsDesc + getPadding()) * height);
}
void LoginHandler::notifyChannelDown(ClientSession* clientSession)
{
	_pOmmServerBaseImpl->_userLock.lock();

	ItemInfo* itemInfo;

	for (UInt32 index = 0; index < _itemInfoList.size(); index++)
	{
		itemInfo = _itemInfoList[index];

		if (clientSession == itemInfo->getClientSession())
		{
			_pOmmServerBaseImpl->_reqMsg.clear();
			_pOmmServerBaseImpl->_reqMsg.initialImage(false);
			_pOmmServerBaseImpl->_reqMsg.interestAfterRefresh(false);
			_pOmmServerBaseImpl->_reqMsg.streamId(itemInfo->getStreamId());

			if (itemInfo->hasNameType())
			{
				_pOmmServerBaseImpl->_reqMsg.nameType(itemInfo->getNameType());
			}

			if (itemInfo->hasName())
			{
				_pOmmServerBaseImpl->_reqMsg.name(itemInfo->getName());
			}

			_pOmmServerBaseImpl->_reqMsg.domainType(MMT_LOGIN);

			StaticDecoder::setData(&_pOmmServerBaseImpl->_reqMsg, 0);

			_pOmmServerBaseImpl->ommProviderEvent._clientHandle = itemInfo->getClientSession()->getClientHandle();
			_pOmmServerBaseImpl->ommProviderEvent._closure = _pOmmServerBaseImpl->_pClosure;
			_pOmmServerBaseImpl->ommProviderEvent._provider = _pOmmServerBaseImpl->getProvider();
			_pOmmServerBaseImpl->ommProviderEvent._handle = (UInt64)itemInfo;

			_pOmmServerBaseImpl->_pOmmProviderClient->onAllMsg(_pOmmServerBaseImpl->_reqMsg, _pOmmServerBaseImpl->ommProviderEvent);
			_pOmmServerBaseImpl->_pOmmProviderClient->onClose(_pOmmServerBaseImpl->_reqMsg, _pOmmServerBaseImpl->ommProviderEvent);

			break;
		}
	}

	_pOmmServerBaseImpl->_userLock.unlock();
}
示例#5
0
void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
{
    mFloorItem = floorItem;
    ItemInfo info = floorItem->getInfo();
    mBrowserBox->clearRows();

    // Floor item can be picked up (single option, candidate for removal)
    std::string name = info.getName();
    mBrowserBox->addRow(strprintf("@@pickup|%s@@", strprintf(_("Pick up %s"),
                                  name.c_str()).c_str()));
    mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat")));

    //mBrowserBox->addRow(strprintf("@@look|%s@@", _("Look To")));
    mBrowserBox->addRow("##3---");
    mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));

    showPopup(x, y);
}
RsslReactorCallbackRet LoginHandler::loginCallback(RsslReactor* pReactor, RsslReactorChannel* pReactorChannel, RsslRDMLoginMsgEvent* pRDMLoginMsgEvent)
{
	OmmServerBaseImpl* ommServerBaseImpl = (OmmServerBaseImpl*)pReactor->userSpecPtr;
	ommServerBaseImpl->eventReceived();

	ClientSession* clientSession = (ClientSession*)pReactorChannel->userSpecPtr;
	RsslRDMLoginMsg *pLoginMsg = pRDMLoginMsgEvent->pRDMLoginMsg;

	if (!pLoginMsg)
	{
		if (pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg->msgBase.msgClass == RSSL_MC_GENERIC)
		{
			if (OmmLoggerClient::VerboseEnum >= ommServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
			{
				EmaString temp("Received Generic message on login stream.");
				temp.append(CR).append("Stream Id ").append(pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg->msgBase.streamId)
					.append(CR).append("Client handle ").append(clientSession->getClientHandle())
					.append(CR).append("Instance Name ").append(ommServerBaseImpl->getInstanceName());

				ommServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::VerboseEnum, temp);
			}

			ItemInfo* itemInfo = clientSession->getItemInfo(pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg->msgBase.streamId);

			if (itemInfo)
			{
				StaticDecoder::setRsslData(&ommServerBaseImpl->_genericMsg, pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg,
					pReactorChannel->majorVersion,
					pReactorChannel->minorVersion,
					0);

				ommServerBaseImpl->ommProviderEvent._clientHandle = clientSession->getClientHandle();
				ommServerBaseImpl->ommProviderEvent._closure = ommServerBaseImpl->_pClosure;
				ommServerBaseImpl->ommProviderEvent._provider = ommServerBaseImpl->getProvider();
				ommServerBaseImpl->ommProviderEvent._handle = (UInt64)itemInfo;

				ommServerBaseImpl->_pOmmProviderClient->onAllMsg(ommServerBaseImpl->_genericMsg, ommServerBaseImpl->ommProviderEvent);
				ommServerBaseImpl->_pOmmProviderClient->onGenericMsg(ommServerBaseImpl->_genericMsg, ommServerBaseImpl->ommProviderEvent);
			}

			return RSSL_RC_CRET_SUCCESS;
		}

		EmaString temp("Login message rejected - invalid login domain message.");

		ommServerBaseImpl->getLoginHandler().sendLoginReject(pReactorChannel, pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg->msgBase.streamId, RSSL_SC_USAGE_ERROR, temp);

		if (OmmLoggerClient::ErrorEnum >= ommServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
		{
			temp.append(CR).append("Stream Id ").append(pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg->msgBase.streamId)
				.append(CR).append("Client handle ").append(clientSession->getClientHandle())
				.append(CR).append("Instance Name ").append(ommServerBaseImpl->getInstanceName());

			ommServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::ErrorEnum, temp);
		}

		return RSSL_RC_CRET_SUCCESS;
	}

	switch (pLoginMsg->rdmMsgBase.rdmMsgType)
	{
		case RDM_LG_MT_REQUEST:
		{
			if (OmmLoggerClient::VerboseEnum >= ommServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
			{
				EmaString temp("Received login request message.");
				temp.append(CR).append("Stream Id ").append(pLoginMsg->rdmMsgBase.streamId)
					.append(CR).append("Client handle ").append(clientSession->getClientHandle())
					.append(CR).append("Instance Name ").append(ommServerBaseImpl->getInstanceName());

				ommServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::VerboseEnum, temp);
			}

			StaticDecoder::setRsslData(&ommServerBaseImpl->_reqMsg, pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg,
				pReactorChannel->majorVersion,
				pReactorChannel->minorVersion,
				0);

			ommServerBaseImpl->ommProviderEvent._clientHandle = clientSession->getClientHandle();
			ommServerBaseImpl->ommProviderEvent._channel = pReactorChannel;
			ommServerBaseImpl->ommProviderEvent._closure = ommServerBaseImpl->_pClosure;
			ommServerBaseImpl->ommProviderEvent._provider = ommServerBaseImpl->getProvider();

			ItemInfo* itemInfo = clientSession->getItemInfo(pLoginMsg->rdmMsgBase.streamId);

			if (!itemInfo )
			{
				ItemInfo* itemInfo = ItemInfo::create(*ommServerBaseImpl);

				if (!itemInfo || !itemInfo->setRsslRequestMsg(pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg->requestMsg) )
					return RSSL_RC_CRET_SUCCESS;

				itemInfo->setClientSession(clientSession);

				ommServerBaseImpl->getLoginHandler().addItemInfo(itemInfo);
				ommServerBaseImpl->addItemInfo(itemInfo);

				ommServerBaseImpl->ommProviderEvent._handle = (UInt64)itemInfo;

				ommServerBaseImpl->_pOmmProviderClient->onAllMsg(ommServerBaseImpl->_reqMsg, ommServerBaseImpl->ommProviderEvent);
				ommServerBaseImpl->_pOmmProviderClient->onReqMsg(ommServerBaseImpl->_reqMsg, ommServerBaseImpl->ommProviderEvent);
			}
			else
			{
				if ( !itemInfo->setRsslRequestMsg(pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg->requestMsg) )
					return RSSL_RC_CRET_SUCCESS;

				ommServerBaseImpl->ommProviderEvent._handle = (UInt64)itemInfo;
				ommServerBaseImpl->_pOmmProviderClient->onAllMsg(ommServerBaseImpl->_reqMsg, ommServerBaseImpl->ommProviderEvent);
				ommServerBaseImpl->_pOmmProviderClient->onReissue(ommServerBaseImpl->_reqMsg, ommServerBaseImpl->ommProviderEvent);
			}

			return RSSL_RC_CRET_SUCCESS;
		}
		case RDM_LG_MT_CONSUMER_CONNECTION_STATUS:
		{
			if (OmmLoggerClient::VerboseEnum >= ommServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
			{
				EmaString temp("Received Consumer Connection Status message.");
				temp.append(CR).append("Stream Id ").append(pLoginMsg->rdmMsgBase.streamId)
					.append(CR).append("Client handle ").append(clientSession->getClientHandle())
					.append(CR).append("Instance Name ").append(ommServerBaseImpl->getInstanceName());

				ommServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::VerboseEnum, temp);
			}

			ItemInfo* itemInfo = clientSession->getItemInfo(pLoginMsg->rdmMsgBase.streamId);

			if (itemInfo)
			{
				StaticDecoder::setRsslData(&ommServerBaseImpl->_genericMsg, pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg,
					pReactorChannel->majorVersion,
					pReactorChannel->minorVersion,
					0);

				ommServerBaseImpl->ommProviderEvent._clientHandle = clientSession->getClientHandle();
				ommServerBaseImpl->ommProviderEvent._closure = ommServerBaseImpl->_pClosure;
				ommServerBaseImpl->ommProviderEvent._provider = ommServerBaseImpl->getProvider();
				ommServerBaseImpl->ommProviderEvent._handle = (UInt64)itemInfo;

				ommServerBaseImpl->_pOmmProviderClient->onAllMsg(ommServerBaseImpl->_genericMsg, ommServerBaseImpl->ommProviderEvent);
				ommServerBaseImpl->_pOmmProviderClient->onGenericMsg(ommServerBaseImpl->_genericMsg, ommServerBaseImpl->ommProviderEvent);
			}

			return RSSL_RC_CRET_SUCCESS;
		}
		case RDM_LG_MT_POST:
		{
			if (OmmLoggerClient::ErrorEnum >= ommServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
			{
				EmaString temp("Received post message on login domain.");
				temp.append(CR).append("Stream Id ").append(pLoginMsg->rdmMsgBase.streamId)
					.append(CR).append("Client handle ").append(clientSession->getClientHandle())
					.append(CR).append("Instance Name ").append(ommServerBaseImpl->getInstanceName())
					.append(CR).append("Post message is not support for this release.").append(ommServerBaseImpl->getInstanceName());

				ommServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::ErrorEnum , temp);
			}

			break;
		}
		case RDM_LG_MT_CLOSE:
		{
			if (OmmLoggerClient::VerboseEnum >= ommServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
			{
				EmaString temp("Received login close message.");
				temp.append(CR).append("Stream Id ").append(pLoginMsg->rdmMsgBase.streamId)
					.append(CR).append("Client handle ").append(clientSession->getClientHandle())
					.append(CR).append("Instance Name ").append(ommServerBaseImpl->getInstanceName());

				ommServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::VerboseEnum, temp);
			}

			ItemInfo* itemInfo = clientSession->getItemInfo(pLoginMsg->rdmMsgBase.streamId);

			ommServerBaseImpl->_reqMsg.clear();
			ommServerBaseImpl->_reqMsg.initialImage(false);
			ommServerBaseImpl->_reqMsg.interestAfterRefresh(false);
			ommServerBaseImpl->_reqMsg.streamId(pLoginMsg->rdmMsgBase.streamId);

			if (itemInfo)
			{
				if (itemInfo->hasNameType())
				{
					ommServerBaseImpl->_reqMsg.nameType(itemInfo->getNameType());
				}

				if (itemInfo->hasName())
				{
					ommServerBaseImpl->_reqMsg.name(itemInfo->getName());
				}

				ommServerBaseImpl->_reqMsg.name(itemInfo->getName());
				ommServerBaseImpl->_reqMsg.domainType(itemInfo->getDomainType());

				StaticDecoder::setData(&ommServerBaseImpl->_reqMsg, 0);

				ommServerBaseImpl->ommProviderEvent._clientHandle = clientSession->getClientHandle();
				ommServerBaseImpl->ommProviderEvent._closure = ommServerBaseImpl->_pClosure;
				ommServerBaseImpl->ommProviderEvent._provider = ommServerBaseImpl->getProvider();
				ommServerBaseImpl->ommProviderEvent._handle = (UInt64)itemInfo;

				ommServerBaseImpl->_pOmmProviderClient->onAllMsg(ommServerBaseImpl->_reqMsg, ommServerBaseImpl->ommProviderEvent);
				ommServerBaseImpl->_pOmmProviderClient->onClose(ommServerBaseImpl->_reqMsg, ommServerBaseImpl->ommProviderEvent);

				ommServerBaseImpl->getServerChannelHandler().closeChannel(pReactorChannel);
			}

			return RSSL_RC_CRET_SUCCESS;
		}
		default:
		{
			EmaString temp("Rejected unhandled login message type ");
			temp.append(ConverterRdmLoginMsgTypeToStr[pLoginMsg->rdmMsgBase.rdmMsgType].strMsgType);

			ItemInfo* itemInfo = clientSession->getItemInfo(pLoginMsg->rdmMsgBase.streamId);

			if (!itemInfo)
			{
				ommServerBaseImpl->getLoginHandler().sendLoginReject(pReactorChannel, pLoginMsg->rdmMsgBase.streamId, RSSL_SC_USAGE_ERROR, temp);
			}

			if (OmmLoggerClient::ErrorEnum >= ommServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
			{
				temp.append(CR).append("Stream Id ").append(pLoginMsg->rdmMsgBase.streamId)
					.append(CR).append("Client handle ").append(clientSession->getClientHandle())
					.append(CR).append("Instance Name ").append(ommServerBaseImpl->getInstanceName());

				ommServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::ErrorEnum, temp);
			}
		}
	}

	return RSSL_RC_CRET_SUCCESS;
}
示例#7
0
文件: itempopup.cpp 项目: B-Rich/mana
void ItemPopup::setItem(const ItemInfo &item, bool showImage)
{
    if (item.getName() == mItemName->getCaption())
        return;

    int space = 0;

    Image *oldImage = mIcon->getImage();
    if (oldImage)
        oldImage->decRef();

    if (showImage)
    {
        ResourceManager *resman = ResourceManager::getInstance();
        Image *image = resman->getImage(
                                  paths.getStringValue("itemIcons")
                                  + item.getDisplay().image);

        mIcon->setImage(image);
        if (image)
        {
            int x = getPadding();
            int y = getPadding();
            mIcon->setPosition(x, y);
            space = mIcon->getWidth();
        }
    }
    else
    {
        mIcon->setImage(0);
    }

    mItemType = item.getItemType();

    std::string caption = item.getName();
    if (!mItemEquipSlot.empty())
        caption += " (" + mItemEquipSlot + ")";

    mItemName->setCaption(caption);
    mItemName->adjustSize();
    mItemName->setForegroundColor(getColorFromItemType(mItemType));
    mItemName->setPosition(getPadding() + space, getPadding());

    mItemDesc->setTextWrapped(item.getDescription(), ITEMPOPUP_WRAP_WIDTH);
    {
        const std::vector<std::string> &effect = item.getEffect();
        std::string temp = "";
        for (std::vector<std::string>::const_iterator it = effect.begin(),
             it_end = effect.end(); it != it_end; ++it)
            temp += temp.empty() ? *it : "\n" + *it;
        mItemEffect->setTextWrapped(temp, ITEMPOPUP_WRAP_WIDTH);
    }
    mItemWeight->setTextWrapped(strprintf(_("Weight: %s"),
                                Units::formatWeight(item.getWeight()).c_str()),
                                ITEMPOPUP_WRAP_WIDTH);

    int minWidth = mItemName->getWidth() + space;

    if (mItemDesc->getMinWidth() > minWidth)
        minWidth = mItemDesc->getMinWidth();
    if (mItemEffect->getMinWidth() > minWidth)
        minWidth = mItemEffect->getMinWidth();
    if (mItemWeight->getMinWidth() > minWidth)
        minWidth = mItemWeight->getMinWidth();

    minWidth += 8;
    setWidth(minWidth);

    const int numRowsDesc = mItemDesc->getNumberOfRows();
    const int numRowsEffect = mItemEffect->getNumberOfRows();
    const int numRowsWeight = mItemWeight->getNumberOfRows();
    const int fontHeight = getFont()->getHeight();

    int nameHeight;
    if (mIcon->getHeight() > 2 * fontHeight)
        nameHeight = mIcon->getHeight();
    else
        nameHeight = 2 * fontHeight;

    if (item.getEffect().empty())
    {
        setContentSize(minWidth, nameHeight +
                        (numRowsDesc + numRowsWeight + 1) * fontHeight);

        mItemWeight->setPosition(getPadding(),
                                nameHeight + (numRowsDesc + 1) * fontHeight);
    }
    else
    {
        setContentSize(minWidth, nameHeight + (numRowsDesc + numRowsEffect +
                        numRowsWeight + 1) * fontHeight);

        mItemWeight->setPosition(getPadding(), nameHeight + (numRowsDesc +
                                    numRowsEffect + 1) * fontHeight);
    }

    mItemDesc->setPosition(getPadding(), nameHeight);
    mItemEffect->setPosition(getPadding(), nameHeight +
                            (numRowsDesc + 1) * fontHeight);
}