Пример #1
0
void QDiscordStateComponent::guildMemberUpdateReceived(const QJsonObject& object)
{
	QSharedPointer<QDiscordGuild> guildPtr =
			guild(object["guild_id"].toString(""));
	if(guildPtr)
	{
		QSharedPointer<QDiscordMember> memberPtr =
				guildPtr->member(object["user"].toObject()["id"].toString(""));
		if(memberPtr)
		{
			memberPtr->update(object, guildPtr);
			emit guildMemberUpdated(memberPtr);
		}
#ifdef QDISCORD_LIBRARY_DEBUG
		else
		{
			qDebug()<<this<<
			"DESYNC: Member update received but member is not stored in guild.\n"
			"Member ID: "+object["user"].toObject()["id"].toString("")+"\n"
			"Guild ID: "+guildPtr->id();
		}
#endif
	}
#ifdef QDISCORD_LIBRARY_DEBUG
	else
	{
		qDebug()<<this<<
		"DESYNC: Member update received but guild is not stored in state.\n"
		"Guild ID: "+object["guild_id"].toString("");
	}
#endif
}
Пример #2
0
void QDiscordStateComponent::guildMemberRemoveReceived(const QJsonObject& object)
{
	QSharedPointer<QDiscordGuild> guildPtr =
			guild(object["guild_id"].toString(""));
	QSharedPointer<QDiscordMember> member;
	if(guildPtr)
	{
		QSharedPointer<QDiscordMember> tmpMember =
				guildPtr->member(object["user"].toObject()["id"].toString(""));
		if(tmpMember)
		{
			member = QSharedPointer<QDiscordMember>(
						new QDiscordMember(*tmpMember)
						);
			guildPtr->removeMember(tmpMember);
		}
		else
		{
			member =QSharedPointer<QDiscordMember>(
						new QDiscordMember(object,
										   QSharedPointer<QDiscordGuild>())
						);
		}
	}
	else
	{
		member = QSharedPointer<QDiscordMember>(
					new QDiscordMember(object, QSharedPointer<QDiscordGuild>())
					);
	}
	QDiscordMember newMember(*member);
	emit guildMemberRemoved(newMember);
}
Пример #3
0
void QDiscordStateComponent::guildMemberAddReceived(const QJsonObject& object)
{
	QSharedPointer<QDiscordGuild> guildPtr =
			guild(object["guild_id"].toString(""));
	QSharedPointer<QDiscordMember> member =
			QSharedPointer<QDiscordMember>(new QDiscordMember(object, guildPtr));
	if(guildPtr)
		guildPtr->addMember(member);
	emit guildMemberAdded(member);

}
Пример #4
0
void QDiscordStateComponent::channelDeleteReceived(const QJsonObject& object)
{
	QDiscordChannel channel(object, guild(object["guild_id"].toString("")));
	if(channel.isPrivate())
	{
		_privateChannels.remove(channel.id());
		emit privateChannelDeleted(channel);
	}
	else
	{
		if(!channel.guild())
			return;
		channel.guild()->removeChannel(channel.guild()->channel(channel.id()));
		emit channelDeleted(channel);
	}
}
Пример #5
0
void QDiscordStateComponent::channelCreateReceived(const QJsonObject& object)
{
	QSharedPointer<QDiscordChannel> channel =
		QSharedPointer<QDiscordChannel>(
			new QDiscordChannel(object, guild(object["guild_id"].toString("")))
		);
	if(channel->isPrivate())
	{
		_privateChannels.insert(channel->id(), channel);
		emit privateChannelCreated(channel);
	}
	else
	{
		if(!channel->guild())
			return;
		channel->guild()->addChannel(channel);
		emit channelCreated(channel);
	}
}
Пример #6
0
void QDiscordStateComponent::guildDeleteReceived(const QJsonObject& object)
{
	QDiscordGuild guild(object);
	_guilds.remove(guild.id());
	emit guildDeleted(guild);
}
void psEntityLabels::SetObjectText(GEMClientObject* object)
{
    if ( !object )
    {
        Warning1( LOG_ANY, "NULL object passed..." );
        return;
    }

    int colour = entityColors[ENTITY_DEFAULT];  // Default color, on inanimate objects
    if ( object->IsAlive() )
    {
        int type = object->GetMasqueradeType();
        if (type > 26)
            type = 26;

        switch ( type )    
        {
            default:
            case 0: // player or unknown group
                colour = entityColors[ENTITY_PLAYER];
                break;

            case -1: // NPC
                colour = entityColors[ENTITY_NPC];
                break;
            case -3: // DEAD
                colour = entityColors[ENTITY_DEAD];
                break;

            case 10: // Tester
                colour = entityColors[ENTITY_TESTER];
                break;
            case 21: // GM1
                colour = entityColors[ENTITY_GM1];
                break;            

            case 22:
            case 23:
            case 24:
            case 25: // GM2-5
                colour = entityColors[ENTITY_GM25];
                break;

            case 26: // dev char
                colour = entityColors[ENTITY_DEV];
                break;
        }                    
    }

    // Is our object an actor?
    GEMClientActor* actor = dynamic_cast<GEMClientActor*>(object);

    // Grouped with have other color
    bool grouped = false;
    if (actor && actor->IsGroupedWith(celClient->GetMainPlayer()))
    {
      colour = entityColors[ENTITY_GROUP];
      grouped = true;
    }

    // White colour labels for invisible objects should overide all (for living objects)
    int flags = object->Flags();
    bool invisible = object->IsAlive() && (flags & psPersistActor::INVISIBLE);
    
    if ( invisible )
    {
        colour = 0xffffff;                    
    }

    psEffectTextRow nameRow;
    psEffectTextRow guildRow;

    nameRow.text = object->GetName();
    nameRow.align = ETA_CENTER;
    nameRow.colour = colour;
    nameRow.hasShadow = false;
    nameRow.hasOutline = true;
    nameRow.outlineColour = 0;

    if (actor && showGuild)
    {
        csString guild( actor->GetGuildName() );
        csString guild2( psengine->GetGuildName() );

        if ( guild.Length() )
        {
            // If same guild, indicate with color, unless grouped or invisible
            if (guild == guild2 && !invisible && !grouped)
                colour = entityColors[ENTITY_GUILD];

            guildRow.text = "<" + guild + ">";
            guildRow.align = ETA_CENTER;
            guildRow.colour = colour;
            guildRow.hasShadow = false;
            guildRow.hasOutline = true;
            guildRow.outlineColour = 0;
        }
    }

    // Apply
    psEffect* entityLabel = object->GetEntityLabel();
    if(!entityLabel)
    {
        // Weird case
        Error2("Lost entity label of object %s!",object->GetName());
        return;
    }

    psEffectObjTextable* txt = entityLabel->GetMainTextObj();
    if(!txt)
    {
        // Ill-modded effect
        Error1("Effect 'entitylabel' has no text object");
        return;
    }

    size_t nameCharCount = nameRow.text.Length();
    size_t guildCharCount = guildRow.text.Length();
    size_t maxCharCount = nameCharCount > guildCharCount ? nameCharCount : guildCharCount;
    float scale = sqrt((float)maxCharCount) / 4.0f;

    // Finally set the text, with a black outline
    if (guildRow.text.Length())
    {
        txt->SetText(2, &nameRow, &guildRow);
        scale *= 1.5f;
    }
    else
    {
        txt->SetText(1, &nameRow);
    }        

    entityLabel->SetScaling(scale, 1.0f);
}