Ejemplo n.º 1
0
void MessageOut::writeInt32(const int32_t value, const char *const str)
{
    DEBUGLOG2("writeInt32: " + toStringPrint(CAST_U32(value)),
        mPos, str);
    expand(4);
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
    int32_t swap = SDL_Swap32(value);
    memcpy(mData + CAST_SIZE(mPos), &swap, sizeof(int32_t));
#else
    memcpy(mData + CAST_SIZE(mPos), &value, sizeof(int32_t));
#endif
    mPos += 4;
    PacketCounters::incOutBytes(4);
}
Ejemplo n.º 2
0
const Image *ExtendedNamesModel::getImageAt(int i)
{
    if (i >= CAST_S32(mImages.size()) || i < 0)
        return nullptr;

    return mImages[CAST_SIZE(i)];
}
Ejemplo n.º 3
0
void MessageOut::writeCoordinates(const uint16_t x,
                                  const uint16_t y,
                                  unsigned char direction,
                                  const char *const str)
{
    DEBUGLOG2(strprintf("writeCoordinates: %u,%u %u",
        CAST_U32(x), static_cast<unsigned>(y),
        CAST_U32(direction)), mPos, str);
    unsigned char *const data = reinterpret_cast<unsigned char*>(mData)
        + CAST_SIZE(mPos);
    mNetwork->mOutSize += 3;
    mPos += 3;

    uint16_t temp = x;
    temp <<= 6;
    data[0] = 0;
    data[1] = 1;
    data[2] = 2;
    data[0] = HIBYTE(temp);
    data[1] = CAST_U8(temp);
    temp = y;
    temp <<= 4;
    data[1] |= HIBYTE(temp);
    data[2] = LOBYTE(temp);
    direction = toServerDirection(direction);
    data[2] |= direction;
    PacketCounters::incOutBytes(3);
}
Ejemplo n.º 4
0
MessageOut::MessageOut(const int16_t id) :
    Net::MessageOut(id),
    mNetwork(TmwAthena::Network::instance())
{
    mNetwork->fixSendBuffer();
    mData = mNetwork->mOutBuffer + CAST_SIZE(mNetwork->mOutSize);
}
Ejemplo n.º 5
0
const ColorPair *ColorModel::getColorAt(const int i) const
{
    if (i >= CAST_S32(mColors.size()) || i < 0)
        return &mColors[0];

    return &mColors[CAST_SIZE(i)];
}
Ejemplo n.º 6
0
void EmoteShortcut::useEmote(const size_t index) const
{
    if (localPlayer == nullptr)
        return;

    if (index <= CAST_SIZE(SHORTCUT_EMOTES))
    {
        if (mEmotes[index - 1] > 0)
        {
            const uint8_t emote = mEmotes[index - 1];
            switch (settings.emoteType)
            {
                case EmoteType::Player:
                default:
                    LocalPlayer::emote(emote);
                    break;
                case EmoteType::Pet:
                    petHandler->emote(emote);
                    break;
                case EmoteType::Homunculus:
                    homunculusHandler->emote(emote);
                    break;
                case EmoteType::Mercenary:
                    mercenaryHandler->emote(emote);
                    break;
            }
        }
    }
}
Ejemplo n.º 7
0
uint16_t MessageIn::readId() const
{
    int16_t value = -1;
    if (mPos + 2 <= mLength)
    {
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
        int16_t swap;
        memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int16_t));
        value = SDL_Swap16(swap);
#else  // SDL_BYTEORDER == SDL_BIG_ENDIAN

        memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int16_t));
#endif  // SDL_BYTEORDER == SDL_BIG_ENDIAN
    }
    return value;
}
Ejemplo n.º 8
0
ShaderProgram *ShadersManager::createProgram(const std::string &vertex,
                                             const std::string &fragment,
                                             const bool isNewShader)
{
    Shader *const vertexShader = static_cast<Shader*>(
        Loader::getShader(GL_VERTEX_SHADER, vertex));
    if (!vertexShader)
        return nullptr;

    Shader *const fragmentShader = static_cast<Shader*>(
        Loader::getShader(GL_FRAGMENT_SHADER, fragment));

    if (!fragmentShader)
    {
        vertexShader->decRef();
        return nullptr;
    }

    GLuint programId = mglCreateProgram();
    if (!programId)
    {
        vertexShader->decRef();
        fragmentShader->decRef();
        return nullptr;
    }

    mglAttachShader(programId, vertexShader->getShaderId());
    mglAttachShader(programId, fragmentShader->getShaderId());
    if (isNewShader)
        mglBindFragDataLocation(programId, 0, "outColor");
    else
        mglBindAttribLocation(programId, 0, "position");
    mglLinkProgram(programId);
    GLint isLinked = 0;
    mglGetProgramiv(programId, GL_LINK_STATUS, &isLinked);
    if (isLinked == GL_TRUE)
    {
        mglValidateProgram(programId);
        GLint isValidated = 0;
        mglGetProgramiv(programId,  GL_VALIDATE_STATUS, &isValidated);
        if (isValidated == GL_TRUE)
            return new ShaderProgram(programId, vertexShader, fragmentShader);
        mglDeleteProgram(programId);
        return nullptr;
    }

    GLint len = 0;
    mglGetProgramiv(programId, GL_INFO_LOG_LENGTH, &len);
    char *buf = new char[CAST_SIZE(len) + 1];
    mglGetProgramInfoLog(programId, len, &len, buf);
    buf[len] = 0;
    logger->log("Program '%s, %s' compilation error: %s",
        vertexShader->getIdPath().c_str(),
        fragmentShader->getIdPath().c_str(),
        buf);
    delete [] buf;
    mglDeleteProgram(programId);
    return nullptr;
}
Ejemplo n.º 9
0
void EmoteShortcut::useEmotePlayer(const size_t index) const
{
    if (index <= CAST_SIZE(SHORTCUT_EMOTES))
    {
        if (mEmotes[index - 1] > 0)
            LocalPlayer::emote(mEmotes[index - 1]);
    }
}
Ejemplo n.º 10
0
TextCommand* SpellManager::getSpell(const int spellId) const
{
    if (spellId < 0 || CAST_SIZE(spellId) >= mSpells.size())
        return nullptr;

    const std::map<unsigned int, TextCommand*>::const_iterator
        it = mSpells.find(spellId);

    return it != mSpells.end() ? (*it).second : nullptr;
}
Ejemplo n.º 11
0
int64_t MessageIn::readInt64(const char *const str)
{
    int64_t value = -1;
    if (mPos + 8 <= mLength)
    {
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
        int64_t swap;
        memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int64_t));
        value = SDL_Swap64(swap);
#else  // SDL_BYTEORDER == SDL_BIG_ENDIAN

        memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int64_t));
#endif  // SDL_BYTEORDER == SDL_BIG_ENDIAN
    }
    DEBUGLOG2("readInt64:  " + toStringPrint(CAST_U32(value)),
        mPos, str);
    mPos += 8;
    PacketCounters::incInBytes(8);
    return value;
}
Ejemplo n.º 12
0
uint16_t MessageIn::readUInt16(const char *const str)
{
    uint16_t value = 0xffU;
    if (mPos + 2 <= mLength)
    {
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
        uint16_t swap;
        memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(uint16_t));
        value = SDL_Swap16(swap);
#else  // SDL_BYTEORDER == SDL_BIG_ENDIAN

        memcpy(&value, mData + CAST_SIZE(mPos), sizeof(uint16_t));
#endif  // SDL_BYTEORDER == SDL_BIG_ENDIAN
    }
    DEBUGLOG2("readUInt16:  " + toStringPrint(CAST_U32(
        CAST_U16(value))),
        mPos, str);
    mPos += 2;
    PacketCounters::incInBytes(2);
    return value;
}
Ejemplo n.º 13
0
void Logger::log_r(const char *const log_text, ...)
{
    if (settings.disableLoggingInGame)
        return;

    SDL_mutexP(mMutex);

    unsigned size = 1024;
    if (strlen(log_text) * 3 > size)
        size = CAST_U32(strlen(log_text) * 3);

    char* buf = new char[CAST_SIZE(size + 1)];
    va_list ap;

    // Use a temporary buffer to fill in the variables
    va_start(ap, log_text);
    vsnprintf(buf, size, log_text, ap);
    buf[size] = 0;
    va_end(ap);

    // Get the current system time
    timeval tv;
    gettimeofday(&tv, nullptr);

    // Print the log entry
    DATESTREAM
    SPECIALLOG(buf)

    if (mLogFile != nullptr)
    {
        std::string tmpStr = strprintf(
            "%s %s\n",
            timeStr.c_str(),
            buf);
        mThreadLocked = true;
        mDelayedLog.push_back(tmpStr);
        mThreadLocked = false;
    }

    if (mLogToStandardOut)
    {
        fprintf(stdout,
            "%s %s\n",
            timeStr.c_str(),
            buf);
    }

    // Delete temporary buffer
    delete [] buf;

    SDL_mutexV(mMutex);
}
Ejemplo n.º 14
0
void Inventory::resize(const unsigned int newSize)
{
    clear();
    if (mSize == newSize)
        return;

    for (unsigned i = 0; i < mSize; i++)
        delete mItems[i];
    delete [] mItems;

    mSize = newSize;
    mItems = new Item*[CAST_SIZE(mSize)];
    std::fill_n(mItems, mSize, static_cast<Item*>(nullptr));
}
Ejemplo n.º 15
0
const SoundInfo &BeingInfo::getSound(const ItemSoundEvent::Type event) const
{
    static SoundInfo emptySound("", 0);

    const ItemSoundEvents::const_iterator i = mSounds.find(event);

    if (i == mSounds.end())
        return emptySound;

    const SoundInfoVect *const vect = i->second;
    if (!vect || vect->empty())
        return emptySound;
    else
        return vect->at(CAST_SIZE(rand()) % vect->size());
}
Ejemplo n.º 16
0
void ActorSprite::setTargetType(const TargetCursorTypeT type)
{
    if (type == TargetCursorType::NONE)
    {
        untarget();
    }
    else
    {
        const size_t sz = CAST_SIZE(getTargetCursorSize());
        mUsedTargetCursor = targetCursor[CAST_S32(type)][sz];
        if (mUsedTargetCursor)
        {
            static const int targetWidths[CAST_SIZE(
                TargetCursorSize::NUM_TC)]
                = {0, 0, 0};
            static const int targetHeights[CAST_SIZE(
                TargetCursorSize::NUM_TC)]
                = {-mapTileSize / 2, -mapTileSize / 2, -mapTileSize};

            mCursorPaddingX = CAST_S32(targetWidths[sz]);
            mCursorPaddingY = CAST_S32(targetHeights[sz]);
        }
    }
}
Ejemplo n.º 17
0
void Logger::assertLog(const char *const log_text, ...)
{
    if (settings.disableLoggingInGame)
        return;

    unsigned size = 1024;
    if (strlen(log_text) * 3 > size)
        size = CAST_U32(strlen(log_text) * 3);

    char* buf = new char[CAST_SIZE(size + 1)];
    va_list ap;

    // Use a temporary buffer to fill in the variables
    va_start(ap, log_text);
    vsnprintf(buf, size, log_text, ap);
    buf[size] = 0;
    va_end(ap);

    // Get the current system time
    timeval tv;
    gettimeofday(&tv, nullptr);

    // Print the log entry
    DATESTREAM
    SPECIALLOG(buf)

    if (mLogFile != nullptr)
    {
        fprintf(mLogFile,
            "%s %s\n",
            timeStr.c_str(),
            buf);
        fflush(mLogFile);
    }

    if (mLogToStandardOut)
    {
        fprintf(stdout,
            "%s %s\n",
            timeStr.c_str(),
            buf);
    }

    DebugMessageListener::distributeEvent(buf);

    // Delete temporary buffer
    delete [] buf;
}
Ejemplo n.º 18
0
Shader *ShadersManager::createShader(const unsigned int type,
                                     const std::string &fileName)
{
    const std::string str = Files::loadTextFileString(fileName);
    const char *ptrStr = str.c_str();
    GLuint shaderId = mglCreateShader(type);
    mglShaderSource(shaderId, 1, &ptrStr, nullptr);
    mglCompileShader(shaderId);

    GLint isCompiled = 0;
    mglGetShaderiv(shaderId, GL_COMPILE_STATUS, &isCompiled);
    if (isCompiled == GL_TRUE)
        return new Shader(shaderId);
    GLint len = 0;
    mglGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &len);
    char *buf = new char[CAST_SIZE(len) + 1];
    mglGetShaderInfoLog(shaderId, len, &len, buf);
    buf[len] = 0;
    logger->log("Shader '%s' compilation error: %s", fileName.c_str(), buf);
    delete [] buf;
    mglDeleteShader(shaderId);
    return nullptr;
}
Ejemplo n.º 19
0
void Logger::log(const char *const log_text, ...)
{
    if (settings.disableLoggingInGame)
        return;

    unsigned size = 1024;
    if (strlen(log_text) * 3 > size)
        size = CAST_U32(strlen(log_text) * 3);

    char* buf = new char[CAST_SIZE(size + 1)];
    va_list ap;

    // Use a temporary buffer to fill in the variables
    va_start(ap, log_text);
    vsnprintf(buf, size, log_text, ap);
    buf[size] = 0;
    va_end(ap);

    // Get the current system time
    timeval tv;
    gettimeofday(&tv, nullptr);

    // Print the log entry
    std::stringstream timeStr;
    DATESTREAM
    SPECIALLOG(buf)

    if (mLogFile.is_open())
        mLogFile << timeStr.str() << buf << std::endl;

    if (mLogToStandardOut)
        std::cout << timeStr.str() << buf << std::endl;

    // Delete temporary buffer
    delete [] buf;
}
Ejemplo n.º 20
0
            return 8;
        default:
            logger->log("incorrect direction: %d",
                CAST_S32(serverDir));
            return 0;
    }
}

void MessageIn::readCoordinates(uint16_t &restrict x,
                                uint16_t &restrict y,
                                uint8_t &restrict direction,
                                const char *const str)
{
    if (mPos + 3 <= mLength)
    {
        const char *const data = mData + CAST_SIZE(mPos);
        uint16_t temp = MAKEWORD(data[1] & 0x00c0, data[0] & 0x00ff);
        x = CAST_U16(temp >> 6);
        temp = MAKEWORD(data[2] & 0x00f0, data[1] & 0x003f);
        y = CAST_U16(temp >> 4);

        const uint8_t serverDir = CAST_U8(data[2] & 0x000f);
        direction = fromServerDirection(serverDir);

        DEBUGLOG2(std::string("readCoordinates: ").append(toString(
            CAST_S32(x))).append(",").append(toString(
            CAST_S32(y))).append(",").append(toString(
            CAST_S32(serverDir))), mPos, str);
    }
    else
    {
Ejemplo n.º 21
0
#define for_each_cursors() \
    for (int size = CAST_S32(TargetCursorSize::SMALL); \
         size < CAST_S32(TargetCursorSize::NUM_TC); \
         size ++) \
    { \
        for (int type = CAST_S32(TargetCursorType::NORMAL); \
             type < CAST_S32(TargetCursorType::NUM_TCT); \
             type ++) \

#define end_foreach }

static const unsigned int STATUS_EFFECTS = 32;

AnimatedSprite *ActorSprite::targetCursor
    [CAST_SIZE(TargetCursorType::NUM_TCT)]
    [CAST_SIZE(TargetCursorSize::NUM_TC)];
bool ActorSprite::loaded = false;

ActorSprite::ActorSprite(const BeingId id) :
    CompoundSprite(),
    Actor(),
    mStatusEffects(),
    mStatusParticleEffects(),
    mChildParticleEffects(&mStatusParticleEffects, false),
    mHorseId(0),
    mId(id),
    mUsedTargetCursor(nullptr),
    mActorSpriteListeners(),
    mCursorPaddingX(0),
    mCursorPaddingY(0),
Ejemplo n.º 22
0
UserPalette::UserPalette() :
    Palette(CAST_S32(UserColorId::USER_COLOR_LAST)),
    ListModel()
{
    mColors[CAST_SIZE(UserColorId::BEING)] = ColorElem();
    mColors[CAST_SIZE(UserColorId::PC)] = ColorElem();
    mColors[CAST_SIZE(UserColorId::SELF)] = ColorElem();
    mColors[CAST_SIZE(UserColorId::GM)] = ColorElem();
    mColors[CAST_SIZE(UserColorId::NPC)] = ColorElem();
    mColors[CAST_SIZE(UserColorId::MONSTER)] = ColorElem();

    addLabel(UserColorId::LABEL_BEING,
        // TRANSLATORS: palette label
        _("Beings"));
    addColor(UserColorId::BEING,
        0xffffff,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Being"),
        GRADIENT_DELAY);
    addColor(UserColorId::FRIEND,
        0xb0ffb0,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Friend names"),
        GRADIENT_DELAY);
    addColor(UserColorId::DISREGARDED,
        0xa00000,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Disregarded names"),
        GRADIENT_DELAY);
    addColor(UserColorId::IGNORED,
        0xff0000,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Ignored names"),
        GRADIENT_DELAY);
    addColor(UserColorId::ERASED,
        0xff0000,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Erased names"),
        GRADIENT_DELAY);
    addColor(UserColorId::ENEMY,
        0xff4040,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Enemy"),
        GRADIENT_DELAY);
    addColor(UserColorId::PC,
        0xffffff,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Other players names"),
        GRADIENT_DELAY);
    addColor(UserColorId::SELF,
        0xff8040,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Own name"),
        GRADIENT_DELAY);
    addColor(UserColorId::GM,
        0x00ff00,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("GM names"),
        GRADIENT_DELAY);
    addColor(UserColorId::NPC,
        0xc8c8ff,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("NPCs"),
        GRADIENT_DELAY);
    addColor(UserColorId::MONSTER,
        0xff4040,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Monsters"),
        GRADIENT_DELAY);
    addColor(UserColorId::PET,
        0xffffff,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Pets"),
        GRADIENT_DELAY);
    addColor(UserColorId::MERCENARY,
        0xffffff,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Mercenary"),
        GRADIENT_DELAY);
    addColor(UserColorId::HOMUNCULUS,
        0xffffff,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Homunculus"),
        GRADIENT_DELAY);
    addColor(UserColorId::SKILLUNIT,
        0xffffff,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Skill unit"),
        GRADIENT_DELAY);
    addColor(UserColorId::PARTY,
        0xff00d8,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Party members"),
        GRADIENT_DELAY);
    addColor(UserColorId::GUILD,
        0xff00d8,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Guild members"),
        GRADIENT_DELAY);
    addColor(UserColorId::TEAM1,
        0x0000ff,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        strprintf(_("Team %d"), 1),
        GRADIENT_DELAY);
    addColor(UserColorId::TEAM2,
        0x00a020,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        strprintf(_("Team %d"), 2),
        GRADIENT_DELAY);
    addColor(UserColorId::TEAM3,
        0xffff20,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        strprintf(_("Team %d"), 3),
        GRADIENT_DELAY);
    addLabel(UserColorId::LABEL_PARTICLES,
        // TRANSLATORS: palette label
        _("Particles"));
    addColor(UserColorId::PARTICLE,
        0xffffff,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Particle effects"),
        GRADIENT_DELAY);
    addColor(UserColorId::PICKUP_INFO,
        0x28dc28,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Pickup notification"),
        GRADIENT_DELAY);
    addColor(UserColorId::EXP_INFO,
        0xffff00,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Exp notification"),
        GRADIENT_DELAY);
    addLabel(UserColorId::LABEL_HP,
        // TRANSLATORS: palette label
        _("Hp bars"));
    addColor(UserColorId::PLAYER_HP,
        0x00ff00,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Player HP bar"), 50);
    addColor(UserColorId::PLAYER_HP2,
        0xff0000,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Player HP bar (second color)"),
        50);
    addColor(UserColorId::MONSTER_HP,
        0x00ff00,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Monster HP bar"),
        50);
    addColor(UserColorId::MONSTER_HP2,
        0xff0000,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Monster HP bar (second color)"),
        50);
    addColor(UserColorId::HOMUN_HP,
        0x00ff00,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Homunculus HP bar"),
        50);
    addColor(UserColorId::HOMUN_HP2,
        0xff0000,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Homunculus HP bar (second color)"),
        50);
    addColor(UserColorId::MERC_HP,
        0x00ff00,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Mercenary HP bar"),
        50);
    addColor(UserColorId::MERC_HP2,
        0xff0000,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Mercenary HP bar (second color)"),
        50);

    addColor(UserColorId::ELEMENTAL_HP,
        0x00ff00,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Elemental HP bar"),
        50);
    addColor(UserColorId::ELEMENTAL_HP2,
        0xff0000,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Elemental HP bar (second color)"),
        50);
    addLabel(UserColorId::LABEL_HITS,
        // TRANSLATORS: palette label
        _("Hits"));
    addColor(UserColorId::HIT_PLAYER_MONSTER,
        0x0064ff,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Player hits monster"),
        GRADIENT_DELAY);
    addColor(UserColorId::HIT_MONSTER_PLAYER,
        0xff3232,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Monster hits player"),
        GRADIENT_DELAY);
    addColor(UserColorId::HIT_PLAYER_PLAYER,
        0xff5050,
        GradientType::STATIC,
       // TRANSLATORS: palette color
       _("Other player hits local player"),
        GRADIENT_DELAY);
    addColor(UserColorId::HIT_CRITICAL,
        0xff0000,
        GradientType::RAINBOW,
        // TRANSLATORS: palette color
        _("Critical Hit"),
        GRADIENT_DELAY);
    addColor(UserColorId::HIT_LOCAL_PLAYER_MONSTER,
        0x00ff00,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Local player hits monster"),
        GRADIENT_DELAY);
    addColor(UserColorId::HIT_LOCAL_PLAYER_CRITICAL,
        0xff0000,
        GradientType::RAINBOW,
        // TRANSLATORS: palette color
        _("Local player critical hit"),
        GRADIENT_DELAY);
    addColor(UserColorId::HIT_LOCAL_PLAYER_MISS,
        0x00ffa6,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Local player miss"),
        GRADIENT_DELAY);
    addColor(UserColorId::MISS, 0xffff00,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Misses"),
        GRADIENT_DELAY);
    addLabel(UserColorId::LABEL_TILES,
        // TRANSLATORS: palette label
        _("Tiles"));
    addColor(UserColorId::PORTAL_HIGHLIGHT,
        0xC80000,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Portal highlight"),
        GRADIENT_DELAY);
    addColor(UserColorId::COLLISION_HIGHLIGHT,
        0x0000C8,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Default collision highlight"),
        64);
    addColor(UserColorId::AIR_COLLISION_HIGHLIGHT,
        0xe0e0ff,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Air collision highlight"),
        64);
    addColor(UserColorId::WATER_COLLISION_HIGHLIGHT,
        0x2050e0,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Water collision highlight"),
        64);
    addColor(UserColorId::MONSTER_COLLISION_HIGHLIGHT,
        0x2050e0,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Monster collision highlight"),
        64);
    addColor(UserColorId::GROUNDTOP_COLLISION_HIGHLIGHT,
        0xffff00,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Special ground collision highlight"),
        20);
    addColor(UserColorId::WALKABLE_HIGHLIGHT,
        0x00D000,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Walkable highlight"),
        255);
    addColor(UserColorId::NET,
        0x000000,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Tiles border"), 64);
    addLabel(UserColorId::LABEL_RANGES,
        // TRANSLATORS: palette label
        _("Ranges"));
    addColor(UserColorId::ATTACK_RANGE,
        0xffffff,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Local player attack range"),
        5);
    addColor(UserColorId::ATTACK_RANGE_BORDER,
        0x0,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Local player attack range border"),
        76);
    addColor(UserColorId::MONSTER_ATTACK_RANGE,
        0xff0000,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Monster attack range"),
        20);
    addColor(UserColorId::SKILL_ATTACK_RANGE,
        0x0,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Skill attack range border"),
        76);
    addLabel(UserColorId::LABEL_OTHER,
        // TRANSLATORS: palette label
        _("Other"));
    addColor(UserColorId::FLOOR_ITEM_TEXT,
        0xffffff,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Floor item amount color"),
        100);
    addColor(UserColorId::HOME_PLACE,
        0xffffff,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Home place"),
        20);
    addColor(UserColorId::HOME_PLACE_BORDER,
        0xffff00,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Home place border"),
        200);
    addColor(UserColorId::ROAD_POINT,
        0x000000,
        GradientType::STATIC,
        // TRANSLATORS: palette color
        _("Road point"), 100);
    commit(true);
}
Ejemplo n.º 23
0
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "gui/userpalette.h"

#include "configuration.h"

#include "utils/foreach.h"
#include "utils/gettext.h"

#include "debug.h"

UserPalette *userPalette = nullptr;

const std::string ColorTypeNames[CAST_SIZE(
    UserColorId::USER_COLOR_LAST)] =
{
    "",
    "ColorBeing",
    "ColorFriend",
    "ColorDisregarded",
    "ColorIgnored",
    "ColorErased",
    "ColorEnemy",
    "ColorPlayer",
    "ColorSelf",
    "ColorGM",
    "ColorNPC",
    "ColorMonster",
    "ColorPet",
    "ColorMercenary",
Ejemplo n.º 24
0
int TestMain::exec(const bool testAudio)
{
    initConfig();
    int softwareTest = invokeSoftwareRenderTest("1");
    int soundTest = -1;
    int rescaleTest[6];
    int softFps = 0;
    int normalOpenGLFps = 0;
    int safeOpenGLFps = 0;
    int modernOpenGLFps = 0;
    int textureSize[6];
    std::string textureSizeStr;

    RenderType openGLMode = RENDER_SOFTWARE;
    int detectMode = 0;
    for (int f = 0; f < 6; f ++)
    {
        rescaleTest[f] = -1;
        textureSize[f] = 1024;
    }
    std::string info;

    const int videoDetectTest = invokeTest("99");
    if (videoDetectTest == 0)
        detectMode = readValue2(99);

    int normalOpenGLTest = invokeNormalOpenGLRenderTest("2");
    int safeOpenGLTest = invokeSafeOpenGLRenderTest("3");
    int modernOpenGLTest = invokeModernOpenGLRenderTest("19");
    if (testAudio)
        soundTest = invokeTest4();
    else
        soundTest = 0;

    info.append(strprintf("%d.%d,%d,%d,%d.", soundTest, softwareTest,
        normalOpenGLTest, safeOpenGLTest, modernOpenGLTest));

    if (softwareTest == 0)
    {
        int softFpsTest = invokeSoftwareRenderTest("8");
        info.append(strprintf("%d", softFpsTest));
        if (softFpsTest == 0)
        {
            softFps = readValue2(8);
            info.append(strprintf(",%d", softFps));
            if (softFps == 0)
            {
                softwareTest = -1;
                softFpsTest = -1;
            }
            else
            {
                rescaleTest[0] = invokeSoftwareRenderTest("5");
                info.append(strprintf(",%d", rescaleTest[0]));
            }
        }
        else
        {
            softwareTest = -1;
        }
    }
    info.append(".");
    if (modernOpenGLTest == 0)
    {
        int modernOpenGLFpsTest = invokeModernOpenGLRenderTest("17");
        info.append(strprintf("%d", modernOpenGLFpsTest));
        if (modernOpenGLFpsTest == 0)
        {
            modernOpenGLFps = readValue2(17);
            info.append(strprintf(",%d", modernOpenGLFps));
            if (modernOpenGLFps == 0)
            {
                modernOpenGLTest = -1;
                modernOpenGLFpsTest = -1;
            }
            else
            {
                rescaleTest[3] = invokeModernOpenGLRenderTest("18");
                info.append(strprintf(",%d", rescaleTest[3]));
            }
        }
        else
        {
            modernOpenGLTest = -1;
        }
    }
    info.append(".");
    if (normalOpenGLTest == 0)
    {
        int normalOpenGLFpsTest = invokeNormalOpenGLRenderTest("9");
        info.append(strprintf("%d", normalOpenGLFpsTest));
        if (normalOpenGLFpsTest == 0)
        {
            normalOpenGLFps = readValue2(9);
            info.append(strprintf(",%d", normalOpenGLFps));
            if (normalOpenGLFps == 0)
            {
                normalOpenGLTest = -1;
                normalOpenGLFpsTest = -1;
            }
            else
            {
                rescaleTest[1] = invokeNormalOpenGLRenderTest("6");
                info.append(strprintf(",%d", rescaleTest[1]));
            }
        }
        else
        {
            normalOpenGLTest = -1;
        }
    }
    info.append(".");
    if (safeOpenGLTest == 0)
    {
        int safeOpenGLFpsTest = invokeSafeOpenGLRenderTest("10");
        info.append(strprintf("%d", safeOpenGLFpsTest));
        if (safeOpenGLFpsTest == 0)
        {
            safeOpenGLFps = readValue2(10);
            info.append(strprintf(",%d", safeOpenGLFps));
            if (safeOpenGLFps == 0)
            {
                safeOpenGLTest = -1;
                safeOpenGLFpsTest = -1;
            }
            else
            {
                rescaleTest[2] = invokeSafeOpenGLRenderTest("7");
                info.append(strprintf(",%d", rescaleTest[2]));
            }
        }
        else
        {
            safeOpenGLTest = -1;
        }
    }
    info.append(".");

    int maxFps = softFps;
    if (maxFps < normalOpenGLFps)
    {
        openGLMode = RENDER_NORMAL_OPENGL;
        maxFps = normalOpenGLFps;
    }
    if (maxFps < modernOpenGLFps)
    {
        openGLMode = RENDER_MODERN_OPENGL;
        maxFps = modernOpenGLFps;
    }
    if (maxFps < safeOpenGLFps)
    {
        openGLMode = RENDER_SAFE_OPENGL;
        maxFps = safeOpenGLFps;
    }

    int batchSize = 256;

    if (invokeNormalOpenBatchTest("11") == 0)
        batchSize = readValue2(11);
    if (batchSize < 256)
        batchSize = 256;

    if (invokeNormalOpenBatchTest("14") == 0)
    {
        textureSize[CAST_SIZE(RENDER_NORMAL_OPENGL)]
            = readValue2(14);
    }
    if (invokeModernOpenBatchTest("15") == 0)
    {
        textureSize[CAST_SIZE(RENDER_MODERN_OPENGL)]
            = readValue2(15);
    }
    if (invokeSafeOpenBatchTest("16") == 0)
    {
        textureSize[CAST_SIZE(RENDER_SAFE_OPENGL)]
            = readValue2(16);
    }
    if (invokeMobileOpenBatchTest("20") == 0)
    {
        textureSize[CAST_SIZE(RENDER_GLES_OPENGL)]
            = readValue2(20);
    }
    for (int f = 0; f < 6; f ++)
        info.append(strprintf(",%d", textureSize[f]));
    info.append(",-");

    textureSizeStr = toString(textureSize[0]);
    for (int f = 1; f < 6; f ++)
        textureSizeStr.append(strprintf(",%d", textureSize[f]));

    // if OpenGL implimentation is not good, disable it.
    if ((detectMode & 15) == 0)
        openGLMode = RENDER_SOFTWARE;

    writeConfig(openGLMode, rescaleTest[CAST_SIZE(openGLMode)],
        soundTest, info, batchSize, textureSizeStr, detectMode);
    return 0;
}
Ejemplo n.º 25
0
std::string ExtendedNamesModel::getElementAt(int i)
{
    if (i >= getNumberOfElements() || i < 0)
        return "???";
    return mNames[CAST_SIZE(i)];
}