Example #1
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]);
        }
    }
}
Example #2
0
void Inventory::restoreVirtuals()
{
    const int sz = CAST_S32(mSize);

    FOR_EACH (IntMapCIter, it, mVirtualRemove)
    {
        const int index = (*it).first;
        if (index < 0 || index >= sz)
            continue;
        Item *const item = mItems[index];
        if (item == nullptr)
            continue;
        item->mQuantity += (*it).second;
    }
    mVirtualRemove.clear();
}
Example #3
0
ColorPage::ColorPage(const Widget2 *const widget,
                     ListModel *const listModel,
                     const std::string &skin) :
    ListBox(widget, listModel, skin)
{
    mItemPadding = mSkin != nullptr ? mSkin->getOption("itemPadding") : 1;
    const Font *const font = getFont();
    mRowHeight = CAST_U32(font->getHeight() +
        2 * mItemPadding);
    if (mListModel != nullptr)
    {
        setHeight(CAST_S32(getRowHeight()) *
            mListModel->getNumberOfElements()
            + 2 * mPadding + 20);
    }
}
Example #4
0
int TestLauncher::calcFps(const timeval &start,
                          const timeval &end,
                          const int calls) const
{
    long mtime;
    long seconds;
    long useconds;

    seconds  = end.tv_sec  - start.tv_sec;
    useconds = end.tv_usec - start.tv_usec;

    mtime = (seconds * 1000 + useconds / 1000.0) + 0.5;
    if (mtime == 0)
        return 100000;

    return CAST_S32(static_cast<long>(calls) * 10000 / mtime);
}
Example #5
0
bool Inventory::addVirtualItem(const Item *const item,
                               int index,
                               const int amount)
{
    if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
    {
        if (index >= 0 && index < CAST_S32(mSize))
        {
            if (mItems[index] != nullptr)
                return false;
            setItem(index,
                item->getId(),
                item->getType(),
                amount,
                1,
                item->getColor(),
                item->getIdentified(),
                item->getDamaged(),
                item->getFavorite(),
                Equipm_false,
                Equipped_false);
        }
        else
        {
            index = addItem(item->getId(),
                item->getType(),
                amount,
                1,
                item->getColor(),
                item->getIdentified(),
                item->getDamaged(),
                item->getFavorite(),
                Equipm_false,
                Equipped_false);
        }
        if (index == -1)
            return false;

        Item *const item2 = getItem(index);
        if (item2 != nullptr)
            item2->setTag(item->getInvIndex());
        return true;
    }
    return false;
}
Example #6
0
    FOR_EACH (Colors::const_iterator, col, mColors)
    {
        if (col->grad == GradientType::LABEL)
            continue;
        const std::string &configName = ColorTypeNames[col->type];
        config.setValue(configName + "Gradient",
            CAST_S32(col->committedGrad));
        config.setValue(configName + "Delay", col->delay);

        if (col->grad == GradientType::STATIC ||
            col->grad == GradientType::PULSE)
        {
            char buffer[20];
            snprintf(buffer, sizeof(buffer), "0x%06x", col->getRGB());
            buffer[19] = 0;
            config.setValue(configName, std::string(buffer));
        }
    }
Example #7
0
int PlayerRelationsManager::getPlayerIgnoreStrategyIndex(
    const std::string &name)
{
    const std::vector<PlayerIgnoreStrategy *> *const strategies
        = getPlayerIgnoreStrategies();

    if (!strategies)
        return -1;

    const size_t sz = strategies->size();
    for (size_t i = 0; i < sz; i++)
    {
        if ((*strategies)[i]->mShortName == name)
            return CAST_S32(i);
    }

    return -1;
}
Example #8
0
void Setup_Relations::reset()
{
    // We now have to search through the list of ignore choices to find the
    // current selection. We could use an index into the table of config
    // options in player_relations instead of strategies to sidestep this.
    int selection = 0;
    for (size_t i = 0, sz = player_relations.getPlayerIgnoreStrategies()
         ->size(); i < sz; ++ i)
    {
        if ((*player_relations.getPlayerIgnoreStrategies())[i] ==
            player_relations.getPlayerIgnoreStrategy())
        {
            selection = CAST_S32(i);
            break;
        }
    }
    mIgnoreActionChoicesBox->setSelected(selection);
}
Example #9
0
void Inventory::virtualRestore(const Item *const item,
                               const int amount)
{
    const int index = item->getTag();
    const IntMapCIter it = mVirtualRemove.find(index);
    if (it != mVirtualRemove.end())
    {
        mVirtualRemove[index] -= amount;
        if (mVirtualRemove[index] < 0)
            mVirtualRemove.erase(index);
        if (index < 0 ||
            index >= CAST_S32(mSize) ||
            mItems[index] == nullptr)
        {
            return;
        }
        mItems[index]->mQuantity += amount;
    }
}
Example #10
0
void ItemShortcut::save() const
{
    std::string name;
    std::string color;
    std::string data;
    if (mNumber == SHORTCUT_AUTO_TAB)
        return;
    if (mNumber != 0)
    {
        name = std::string("shortcut").append(
            toString(CAST_S32(mNumber))).append("_");
        color = std::string("shortcutColor").append(
            toString(CAST_U32(mNumber))).append("_");
        data = std::string("shortcutData").append(
            toString(CAST_U32(mNumber))).append("_");
    }
    else
    {
        name = "shortcut";
        color = "shortcutColor";
        data = "shortcutData";
    }

    for (unsigned int i = 0; i < SHORTCUT_ITEMS; i++)
    {
        const int itemId = mItems[i] != 0 ? mItems[i] : -1;
        const int itemColor = toInt(mItemColors[i], int);
        if (itemId != -1)
        {
            const std::string itemData = mItemData[i];
            serverConfig.setValue(name + toString(i), itemId);
            serverConfig.setValue(color + toString(i), itemColor);
            serverConfig.setValue(data + toString(i), itemData);
        }
        else
        {
            serverConfig.deleteKey(name + toString(i));
            serverConfig.deleteKey(color + toString(i));
            serverConfig.deleteKey(data + toString(i));
        }
    }
}
Example #11
0
bool SpellManager::addSpell(TextCommand *const spell)
{
    if (!spell)
        return false;

    const int id = spell->getId();
    if (id < 0 || id >= CAST_S32(SPELL_SHORTCUT_ITEMS
        * SPELL_SHORTCUT_TABS))
    {
        delete spell;
        return false;
    }
    const std::map<unsigned int, TextCommand*>::const_iterator
        i = mSpells.find(spell->getId());
    if (i == mSpells.end())
    {
        mSpells[spell->getId()] = spell;
        mSpellsVector.push_back(spell);
        return true;
    }
    return false;
}
Example #12
0
void Setup_Video::cancel()
{
    mFpsCheckBox->setSelected(mFps > 0);
    mFsCheckBox->setSelected(mFullScreenEnabled);
    mOpenGLDropDown->setSelected(renderToIndex[mOpenGLEnabled]);
    mCustomCursorCheckBox->setSelected(mCustomCursorEnabled);
    mFpsSlider->setEnabled(mFps > 0);
    mFpsSlider->setValue(mFps);
    mAltFpsSlider->setEnabled(mAltFps > 0);
    mAltFpsSlider->setValue(mAltFps);
    mFpsLabel->setCaption(mFpsCheckBox->isSelected()
    // TRANSLATORS: video settings label
                          ? toString(mFps) : _("None"));
    // TRANSLATORS: video settings label
    mAltFpsLabel->setCaption(_("Alt FPS limit: ") + toString(mAltFps));
    mEnableResizeCheckBox->setSelected(mEnableResize);
    mNoFrameCheckBox->setSelected(mNoFrame);
#ifdef USE_SDL2
    mAllowHighDPICheckBox->setSelected(mAllowHighDPI);
#endif  // USE_SDL2

    config.setValue("screen", mFullScreenEnabled);

    // Set back to the current video mode.
    std::string videoMode = toString(mainGraphics->mActualWidth).append("x")
        .append(toString(mainGraphics->mActualHeight));
    mModeList->setSelected(mModeListModel->getIndexOf(videoMode));
    config.setValue("screenwidth", mainGraphics->mActualWidth);
    config.setValue("screenheight", mainGraphics->mActualHeight);

    config.setValue("customcursor", mCustomCursorEnabled);
    config.setValue("opengl", CAST_S32(mOpenGLEnabled));
    config.setValue("enableresize", mEnableResize);
#ifdef USE_SDL2
    config.setValue("allowHighDPI", mAllowHighDPI);
#endif  // USE_SDL2
}
Example #13
0
unsigned int PlayerRelationsManager::checkPermissionSilently(
    const std::string &player_name, const unsigned int flags) const
{
    const std::map<std::string, PlayerRelation *>::const_iterator
        it = mRelations.find(player_name);
    if (it == mRelations.end())
    {
        return mDefaultPermissions & flags;
    }
    else
    {
        const PlayerRelation *const r = (*it).second;
        unsigned int permissions = PlayerRelation::RELATION_PERMISSIONS[
            CAST_S32(r->mRelation)];

        switch (r->mRelation)
        {
            case Relation::NEUTRAL:
                permissions = mDefaultPermissions;
                break;

            case Relation::FRIEND:
                permissions |= mDefaultPermissions;  // widen
                break;

            case Relation::DISREGARDED:
            case Relation::IGNORED:
            case Relation::ERASED:
            case Relation::BLACKLISTED:
            case Relation::ENEMY2:
            default:
                permissions &= mDefaultPermissions;  // narrow
        }

        return permissions & flags;
    }
}
Example #14
0
void ItemShortcut::load()
{
    std::string name;
    std::string color;
    std::string data;
    if (mNumber == SHORTCUT_AUTO_TAB)
        return;

    const Configuration *cfg = &serverConfig;
    if (mNumber != 0)
    {
        name = std::string("shortcut").append(
            toString(CAST_S32(mNumber))).append("_");
        color = std::string("shortcutColor").append(
            toString(CAST_U32(mNumber))).append("_");
        data = std::string("shortcutData").append(
            toString(CAST_U32(mNumber))).append("_");
    }
    else
    {
        name = "shortcut";
        color = "shortcutColor";
        data = "shortcutData";
    }
    for (unsigned int i = 0; i < SHORTCUT_ITEMS; i++)
    {
        const int itemId = cfg->getValue(name + toString(i), -1);
        const ItemColor itemColor = fromInt(
            cfg->getValue(color + toString(i), 1),
            ItemColor);

        mItems[i] = itemId;
        mItemColors[i] = itemColor;
        mItemData[i] = cfg->getValue(data + toString(i), std::string());
    }
}
Example #15
0
void ActorSprite::setStatusEffectBlock(const int offset,
                                       const uint16_t newEffects)
{
    for (unsigned i = 0; i < STATUS_EFFECTS; i++)
    {
        const bool val = (newEffects & (1 << i)) > 0;
        const int32_t index = StatusEffectDB::blockIdToId(
            offset + i);  // block-id (offset + i) to id (index)

        if (index != -1)
        {
            setStatusEffect(index, fromBool(val, Enable));
        }
        else if (val && config.getBoolValue("unimplimentedLog"))
        {
            const std::string str = strprintf(
                "Error: unknown effect by block-index. "
                "Offset: %d, effect int: %d, i: %u",
                offset, CAST_S32(newEffects), i);
            logger->log(str);
            DebugMessageListener::distributeEvent(str);
        }
    }
}
CharacterViewSmall::CharacterViewSmall(CharSelectDialog *const widget,
                                       std::vector<CharacterDisplay*>
                                       *const entries,
                                       const int padding) :
    CharacterViewBase(widget, padding),
    mSelectedEntry(nullptr),
    mPrevious(new Button(this, "<", "prev", this)),
    mNext(new Button(this, ">", "next", this)),
    mNumber(new Label(this, "??")),
    mCharacterEntries(entries)
{
    addKeyListener(widget);
    if (entries)
    {
        FOR_EACHP (std::vector<CharacterDisplay*>::iterator,
                   it, entries)
        {
            add(*it);
        }
        const int sz = CAST_S32(mCharacterEntries->size());
        if (sz > 0)
        {
            mSelected = 0;
            mSelectedEntry = (*mCharacterEntries)[mSelected];
            mSelectedEntry->setVisible(Visible_true);
            mNumber->setCaption(strprintf("%d / %d", mSelected + 1, sz));
            mNumber->adjustSize();
        }
        else
        {
            mSelected = -1;
            mSelectedEntry = nullptr;
            mNumber->setCaption("0 / 0");
            mNumber->adjustSize();
        }
    }
Example #17
0
void PlayerRelationsManager::load()
{
    Configuration *const cfg = &serverConfig;
    clear();

    mPersistIgnores = cfg->getValue(PERSIST_IGNORE_LIST, 1);
    mDefaultPermissions = CAST_S32(cfg->getValue(DEFAULT_PERMISSIONS,
                                           mDefaultPermissions));

    const std::string ignore_strategy_name = cfg->getValue(
        PLAYER_IGNORE_STRATEGY, DEFAULT_IGNORE_STRATEGY);
    const int ignore_strategy_index = getPlayerIgnoreStrategyIndex(
        ignore_strategy_name);

    if (ignore_strategy_index >= 0)
    {
        setPlayerIgnoreStrategy((*getPlayerIgnoreStrategies())
                                [ignore_strategy_index]);
    }

    cfg->getList<std::pair<std::string, PlayerRelation *>,
                   std::map<std::string, PlayerRelation *> *>
        ("player",  &(mRelations), &player_conf_serialiser);
}
Example #18
0
bool ComplexInventory::addVirtualItem(const Item *const item,
                                      int index,
                                      const int amount)
{
    if ((item == nullptr) || PlayerInfo::isItemProtected(item->getId()))
        return false;

    if (index >= 0 && index < CAST_S32(mSize))
    {
        ComplexItem *citem = nullptr;
        if (mItems[index] != nullptr)
        {
            const Item *const item2 = mItems[index];
            if (item->getId() != item2->getId() ||
                item->getColor() != item2->getColor())
            {   // not same id or color
                return false;
            }
            citem = dynamic_cast<ComplexItem*>(mItems[index]);
            if (citem == nullptr)
            {   // if in inventory not complex item, converting it to complex
                citem = new ComplexItem(item2->getId(),
                    item2->getType(),
                    item2->getQuantity(),
                    item2->getRefine(),
                    item2->getColor(),
                    item2->getIdentified(),
                    item2->getDamaged(),
                    item2->getFavorite(),
                    Equipm_false,
                    Equipped_false);
                citem->setTag(item2->getTag());
                delete mItems[index];
                mItems[index] = citem;
            }
        }
        else
        {
            citem = new ComplexItem(item->getId(),
                item->getType(),
                0,
                item->getRefine(),
                item->getColor(),
                item->getIdentified(),
                item->getDamaged(),
                item->getFavorite(),
                Equipm_false,
                Equipped_false);
            mItems[index] = citem;
        }
        citem->addChild(item, amount);
    }
    else
    {
        index = addItem(item->getId(),
            item->getType(),
            1,
            1,
            item->getColor(),
            item->getIdentified(),
            item->getDamaged(),
            item->getFavorite(),
            Equipm_false,
            Equipped_false);
    }
    if (index == -1)
        return false;

    Item *const item2 = getItem(index);
    if (item2 != nullptr)
        item2->setTag(item->getInvIndex());
    return true;
}
Example #19
0
DefaultsData* getConfigDefaults()
{
    DefaultsData *const configData = new DefaultsData;
    AddDEF("OverlayDetail", 2);
    AddDEF("speechBubbleAlpha", 1.0F);
    AddDEF("MostUsedServerName0", "server.themanaworld.org");
    AddDEF("visiblenames", VisibleName::Show);
    AddDEF("speech", CAST_S32(BeingSpeech::NO_NAME_IN_BUBBLE));
    AddDEF("showgender", true);
    AddDEF("showlevel", false);
    AddDEF("showMonstersTakedDamage", true);
    AddDEF("highlightAttackRange", false);
    AddDEF("highlightMapPortals", true);
    AddDEF("highlightMonsterAttackRange", false);
    AddDEF("chatMaxCharLimit", 512);
    AddDEF("lowTraffic", true);
    AddDEF("invertMoveDirection", 0);
    AddDEF("crazyMoveType", 1);
    AddDEF("attackWeaponType", 1);
    AddDEF("quickDropCounter", 1);
    AddDEF("pickUpType", 5);
    AddDEF("magicAttackType", 0);
    AddDEF("attackType", 2);
    AddDEF("targetingType", 0);
    AddDEF("followMode", 0);
    AddDEF("imitationMode", 0);
    AddDEF("syncPlayerMove", true);
    AddDEF("syncPlayerMoveDistance", 5);
    AddDEF("drawPath", false);
    AddDEF("moveToTargetType", 10);
    AddDEF("crazyMoveProgram", "mumrsonmdmlon");
    AddDEF("disableGameModifiers", true);
    AddDEF("targetDeadPlayers", false);
    AddDEF("afkMessage", "I am away from keyboard.");
    AddDEF("afkFormat", 0);
    AddDEF("particleMaxCount", 3000);
    AddDEF("particleFastPhysics", 1);
    AddDEF("particleEmitterSkip", 1);
    AddDEF("particleeffects", true);
    AddDEF("logToStandardOut", false);
    AddDEF("opengl", 0);
#ifdef ANDROID
    AddDEF("screenwidth", 0);
    AddDEF("screenheight", 0);
    AddDEF("showScreenJoystick", true);
    AddDEF("showScreenButtons", true);
    AddDEF("showBeingPopup", false);
    AddDEF("mouseDirectionMove", true);
    AddDEF("showScreenKeyboard", true);
    AddDEF("fpslimit", 100);
    AddDEF("theme", "jewelry");
    AddDEF("showChatColorsList", false);
    AddDEF("customcursor", false);
    AddDEF("showDidYouKnow", false);
    AddDEF("longmouseclick", true);
#else  // ANDROID

    AddDEF("screenwidth", defaultScreenWidth);
    AddDEF("screenheight", defaultScreenHeight);
    AddDEF("showScreenJoystick", false);
    AddDEF("showScreenButtons", false);
    AddDEF("showBeingPopup", true);
    AddDEF("mouseDirectionMove", false);
    AddDEF("showScreenKeyboard", false);
    AddDEF("fpslimit", 60);
    AddDEF("theme", "");
    AddDEF("showChatColorsList", true);
    AddDEF("customcursor", true);
    AddDEF("showDidYouKnow", true);
    AddDEF("longmouseclick", false);
#endif  // ANDROID

    AddDEF("showEmotesButton", true);
    AddDEF("screen", false);
    AddDEF("hwaccel", false);
    AddDEF("sound", false);
    AddDEF("sfxVolume", 100);
    AddDEF("musicVolume", 60);
    AddDEF("remember", false);
    AddDEF("username", "");
    AddDEF("lastCharacter", "");
    AddDEF("altfpslimit", 5);
    AddDEF("updatehost", "");
    AddDEF("screenshotDirectory3", "");
    AddDEF("useScreenshotDirectorySuffix", true);
    AddDEF("screenshotDirectorySuffix", "");
    AddDEF("EnableSync", false);
    AddDEF("joystickEnabled", false);
    AddDEF("upTolerance", 100);
    AddDEF("downTolerance", 100);
    AddDEF("leftTolerance", 100);
    AddDEF("rightTolerance", 100);
    AddDEF("logNpcInGui", true);
    AddDEF("download-music", true);
    AddDEF("guialpha", 0.8F);
    AddDEF("ChatLogLength", 0);
    AddDEF("enableChatLog", true);
    AddDEF("whispertab", true);
    AddDEF("showownname", true);
    AddDEF("showpickupparticle", true);
    AddDEF("showpickupchat", true);
    AddDEF("ReturnToggles", false);
    AddDEF("ScrollLaziness", 16);
    AddDEF("ScrollRadius", 0);
    AddDEF("ScrollCenterOffsetX", 0);
    AddDEF("ScrollCenterOffsetY", 0);
    AddDEF("enableMumble", false);
    AddDEF("playBattleSound", true);
    AddDEF("playGuiSound", true);
    AddDEF("playMusic", true);
    AddDEF("packetcounters", true);
    AddDEF("safemode", false);
    AddDEF("font", "fonts/dejavusans.ttf");
    AddDEF("boldFont", "fonts/dejavusans-bold.ttf");
    AddDEF("particleFont", "fonts/dejavusans.ttf");
    AddDEF("helpFont", "fonts/dejavusansmono.ttf");
    AddDEF("secureFont", "fonts/dejavusansmono.ttf");
    AddDEF("japanFont", "fonts/mplus-1p-regular.ttf");
    AddDEF("chinaFont", "fonts/wqy-microhei.ttf");
    AddDEF("npcFont", "fonts/dejavusans.ttf");
    AddDEF("showBackground", true);
    AddDEF("enableTradeTab", true);
    AddDEF("cyclePlayers", true);
    AddDEF("cycleMonsters", true);
    AddDEF("cycleNPC", true);
    AddDEF("floorItemsHighlight", true);
    AddDEF("enableBotCheker", true);
    AddDEF("removeColors", true);
    AddDEF("showMagicInDebug", true);
    AddDEF("allowCommandsInChatTabs", true);
    AddDEF("serverMsgInDebug", true);
    AddDEF("hideShopMessages", true);
    AddDEF("showChatHistory", true);
    AddDEF("chatMaxLinesLimit", 40);
    AddDEF("chatColor", 0);
    AddDEF("showJob", true);
    AddDEF("updateOnlineList", true);
    AddDEF("targetOnlyReachable", true);
    AddDEF("errorsInDebug", true);
    AddDEF("tradebot", true);
    AddDEF("debugLog", false);
    AddDEF("unimplimentedLog", false);
    AddDEF("drawHotKeys", true);
    AddDEF("serverAttack", true);
    AddDEF("autofixPos", false);
    AddDEF("alphaCache", true);
    AddDEF("attackMoving", true);
    AddDEF("attackNext", false);
    AddDEF("quickStats", true);
    AddDEF("warpParticle", false);
    AddDEF("autoShop", false);
    AddDEF("enableBattleTab", false);
    AddDEF("showBattleEvents", false);
    AddDEF("showMobHP", true);
    AddDEF("showOwnHP", true);
    AddDEF("usePersistentIP", true);
    AddDEF("showJobExp", true);
    AddDEF("showExtMinimaps", false);
    AddDEF("hideChatInput", true);
    AddDEF("enableAttackFilter", true);
    AddDEF("enablePickupFilter", true);
    AddDEF("securetrades", true);
    AddDEF("unsecureChars", "IO0@#$");
    AddDEF("currentTip", 0);
    AddDEF("useLocalTime", false);
    AddDEF("enableAdvert", true);
    AddDEF("enableMapReduce", true);
    AddDEF("showPlayersStatus", true);
    AddDEF("beingopacity", false);
    AddDEF("adjustPerfomance", true);
    AddDEF("enableAlphaFix", false);
    AddDEF("disableAdvBeingCaching", true);
    AddDEF("disableBeingCaching", false);
    AddDEF("enableReorderSprites", true);
    AddDEF("showip", false);
    AddDEF("seflMouseHeal", true);
    AddDEF("enableLazyScrolling", false);
    AddDEF("extMouseTargeting", true);
    AddDEF("showMVP", false);
    AddDEF("pvpAttackType", 0);
    AddDEF("lang", "");
    AddDEF("selectedJoystick", 0);
    AddDEF("useInactiveJoystick", false);
    AddDEF("testInfo", "");
    AddDEF("enableresize", true);
    AddDEF("noframe", false);
    AddDEF("groupFriends", true);
    AddDEF("grabinput", false);
    AddDEF("usefbo", false);
    AddDEF("gamma", 1);
    AddDEF("vsync", 0);
    AddDEF("enableBuggyServers", true);
    AddDEF("soundwhisper", "newmessage");
    AddDEF("soundhighlight", "reminder");
    AddDEF("soundglobal", "email");
    AddDEF("sounderror", "error");
    AddDEF("soundtrade", "start");
    AddDEF("soundinfo", "notify");
    AddDEF("soundrequest", "attention");
    AddDEF("soundguild", "newmessage");
    AddDEF("soundshowwindow", "page");
    AddDEF("soundhidewindow", "book");
    AddDEF("autohideButtons", true);
    AddDEF("autohideChat", false);
    AddDEF("downloadProxy", "");
    AddDEF("downloadProxyType", 0);
    AddDEF("blur", false);
#if defined(WIN32) || defined(__APPLE__)
    AddDEF("centerwindow", true);
#else  // defined(WIN32) || defined(__APPLE__)

    AddDEF("centerwindow", false);
#endif  // defined(WIN32) || defined(__APPLE__)

    AddDEF("audioFrequency", 44100);
    AddDEF("audioChannels", 2);
#ifdef USE_SDL2
    AddDEF("repeateDelay", 500);
    AddDEF("repeateInterval", 30);
    AddDEF("repeateInterval2", 500);
#else  // USE_SDL2

    AddDEF("repeateDelay", SDL_DEFAULT_REPEAT_DELAY);
    AddDEF("repeateInterval", SDL_DEFAULT_REPEAT_INTERVAL);
    AddDEF("repeateInterval2", SDL_DEFAULT_REPEAT_DELAY);
#endif  // USE_SDL2

    AddDEF("compresstextures", 0);
    AddDEF("rectangulartextures", false);
    AddDEF("networksleep", 0);
    AddDEF("newtextures", true);
    AddDEF("videodetected", false);
    AddDEF("hideErased", false);
    AddDEF("enableDelayedAnimations", true);
    AddDEF("enableCompoundSpriteDelay", true);
#ifdef ANDROID
    AddDEF("useAtlases", false);
#else  // ANDROID

    AddDEF("useAtlases", true);
#endif  // ANDROID

    AddDEF("useTextureSampler", false);
    AddDEF("ministatussaved", 0);
    AddDEF("allowscreensaver", false);
    AddDEF("debugOpenGL", 0);
    AddDEF("protectChatFocus", true);
#if defined(__APPLE__)
    AddDEF("enableGamma", false);
#else  // defined(__APPLE__)

    AddDEF("enableGamma", true);
#endif  // defined(__APPLE__)

    AddDEF("logInput", false);
    AddDEF("highlightWords", "");
    AddDEF("globalsFilter", "Sagatha");
    AddDEF("selfMouseHeal", true);
    AddDEF("serverslistupdate", "");
    AddDEF("fadeoutmusic", true);
    AddDEF("screenActionKeyboard", CAST_S32(
        InputAction::SHOW_KEYBOARD));
    AddDEF("screenActionButton0", CAST_S32(InputAction::TALK));
    AddDEF("screenActionButton1", CAST_S32(
        InputAction::TARGET_ATTACK));
    AddDEF("screenActionButton2", CAST_S32(InputAction::PICKUP));
    AddDEF("screenActionButton3", CAST_S32(InputAction::STOP_SIT));
    AddDEF("screenActionButton4", CAST_S32(InputAction::TARGET_NPC));
    AddDEF("screenActionButton5", CAST_S32(
        InputAction::WINDOW_STATUS));
    AddDEF("screenActionButton6", CAST_S32(
        InputAction::WINDOW_INVENTORY));
    AddDEF("screenActionButton7", CAST_S32(InputAction::WINDOW_SKILL));
    AddDEF("screenActionButton8", CAST_S32(
        InputAction::WINDOW_SOCIAL));
    AddDEF("screenActionButton9", CAST_S32(InputAction::WINDOW_DEBUG));
    AddDEF("screenActionButton10", CAST_S32(
        InputAction::CHANGE_TRADE));
    AddDEF("screenActionButton11", CAST_S32(InputAction::DIRECT_DOWN));
    AddDEF("screenButtonsFormat", 0);
    AddDEF("autoresizeminimaps", false);
    AddDEF("showGuildOnline", false);
    AddDEF("showPartyOnline", false);
    AddDEF("enableGmTab", true);
    AddDEF("gamecount", 0);
    AddDEF("rated", false);
    AddDEF("weightMsg", true);
    AddDEF("enableLangTab", true);
    AddDEF("showAllLang", false);
    AddDEF("moveNames", false);
    AddDEF("uselonglivesprites", false);
    AddDEF("uselonglivesounds", true);
    AddDEF("screenDensity", 0);
    AddDEF("cfgver", 14);
    AddDEF("enableDebugLog", false);
    AddDEF("doubleClick", true);
    AddDEF("useDiagonalSpeed", true);
    AddDEF("protectedItems", "");
    AddDEF("inventorySortOrder", 0);
    AddDEF("storageSortOrder", 0);
    AddDEF("cartSortOrder", 0);
    AddDEF("buySortOrder", 0);
    AddDEF("showmotd", false);
    AddDEF("playMapAnimations", true);
    AddDEF("usepets", true);
    AddDEF("scale", 1);
    AddDEF("addwatermark", true);
    AddDEF("hidesupport", false);
    AddDEF("showserverpos", false);
    AddDEF("textureSize", "1024,1024,1024,1024,1024,1024");
    AddDEF("ignorelogpackets", "");
    AddDEF("disableLoggingInGame", false);
    AddDEF("sellShopName", "unnamed");
    AddDEF("showBadges", 1);
    AddDEF("tradescreenshot", false);
    AddDEF("skillAutotarget", true);
    AddDEF("logPlayerActions", false);
    AddDEF("enableGuiOpacity", true);
    AddDEF("enableTradeFilter", true);
    AddDEF("enableIdCollecting", false);
    AddDEF("checkOpenGLVersion", true);
    AddDEF("openglContext", false);
    return configData;
}
void FocusHandler::tabPrevious()
{
    if (mFocusedWidget)
    {
        if (!mFocusedWidget->isTabOutEnabled())
            return;
    }

    if (mWidgets.empty())
    {
        mFocusedWidget = nullptr;
        return;
    }

    int i;
    int focusedWidget = -1;
    const int sz = CAST_S32(mWidgets.size());
    for (i = 0; i < sz; ++ i)
    {
        if (mWidgets[i] == mFocusedWidget)
            focusedWidget = i;
    }
    const int focused = focusedWidget;
    bool done = false;

    // i is a counter that ensures that the following loop
    // won't get stuck in an infinite loop
    i = sz;
    do
    {
        -- focusedWidget;

        if (i == 0)
        {
            focusedWidget = -1;
            break;
        }

        -- i;

        if (focusedWidget <= 0)
            focusedWidget = sz - 1;

        if (focusedWidget == focused)
            return;

        const Widget *const widget = mWidgets.at(focusedWidget);
        if (widget->isFocusable() && widget->isTabInEnabled() &&
            (!mModalFocusedWidget || widget->isModalFocused()))
        {
            done = true;
        }
    }
    while (!done);

    if (focusedWidget >= 0)
    {
        mFocusedWidget = mWidgets.at(focusedWidget);
        Event focusEvent(mFocusedWidget);
        distributeFocusGainedEvent(focusEvent);
    }

    if (focused >= 0)
    {
        Event focusEvent(mWidgets.at(focused));
        distributeFocusLostEvent(focusEvent);
    }

    checkForWindow();
}
Example #21
0
    }

    // Check string lengths
    if (itA == endA && itB == endB)
        return 0;
    else if (itA == endA)
        return -1;
    else
        return 1;
}

const std::string findSameSubstring(const std::string &restrict str1,
                                    const std::string &restrict str2)
{
    const int minLength = str1.length() > str2.length()
        ? CAST_S32(str2.length()) : CAST_S32(str1.length());
    for (int f = 0; f < minLength; f ++)
    {
        if (str1.at(f) != str2.at(f))
            return str1.substr(0, f);
    }
    return str1.substr(0, minLength);
}

const std::string findSameSubstringI(const std::string &restrict s1,
                                     const std::string &restrict s2)
{
    std::string str1 = s1;
    std::string str2 = s2;
    toLower(str1);
    toLower(str2);
Example #22
0
void ConfigManager::initConfiguration()
{
#ifdef DEBUG_CONFIG
    config.setIsMain(true);
#endif

    // Fill configuration with defaults
    config.setValue("hwaccel", false);
#ifdef USE_OPENGL
#if (defined __APPLE__)
    config.setValue("opengl", CAST_S32(RENDER_NORMAL_OPENGL));
#elif (defined ANDROID)
    config.setValue("opengl", CAST_S32(RENDER_GLES_OPENGL));
#elif (defined WIN32)
    config.setValue("opengl", CAST_S32(RENDER_SAFE_OPENGL));
#else
    config.setValue("opengl", CAST_S32(RENDER_SOFTWARE));
#endif
#else
    config.setValue("opengl", CAST_S32(RENDER_SOFTWARE));
#endif
    config.setValue("screen", false);
    config.setValue("sound", true);
    config.setValue("guialpha", 0.8F);
//    config.setValue("remember", true);
    config.setValue("sfxVolume", 100);
    config.setValue("musicVolume", 60);
    config.setValue("fpslimit", 60);
    std::string defaultUpdateHost = branding.getValue("defaultUpdateHost", "");
    if (!checkPath(defaultUpdateHost))
        defaultUpdateHost.clear();
    config.setValue("updatehost", defaultUpdateHost);
    config.setValue("useScreenshotDirectorySuffix", true);
    config.setValue("ChatLogLength", 128);

    std::string configPath;

    if (settings.options.test.empty())
        configPath = settings.configDir + "/config.xml";
    else
        configPath = settings.configDir + "/test.xml";

    FILE *configFile = fopen(configPath.c_str(), "r");
    if (!configFile)
    {
        configFile = fopen(configPath.c_str(), "wt");
        logger->log1("Creating new config");
    }
    if (!configFile)
    {
        logger->log("Can't create %s. Using defaults.",
            configPath.c_str());
    }
    else
    {
        fclose(configFile);
        config.init(configPath);
        logger->log1("init 3");
        config.setDefaultValues(getConfigDefaults());
        logger->log("configPath: " + configPath);
    }
}
Example #23
0
void ConfigManager::checkConfigVersion()
{
    const int version = config.getIntValue("cfgver");
    if (version < 1)
    {
        if (config.getIntValue("fontSize") == 11)
            config.deleteKey("fontSize");
        if (config.getIntValue("npcfontSize") == 13)
            config.deleteKey("npcfontSize");
    }
    if (version < 2)
    {
        if (config.getIntValue("screenButtonsSize") == 1)
            config.deleteKey("screenButtonsSize");
        if (config.getIntValue("screenJoystickSize") == 1)
            config.deleteKey("screenJoystickSize");
    }
    if (version < 3)
    {
        config.setValue("audioFrequency", 44100);
#ifdef ANDROID
        config.setValue("customcursor", false);
#endif
    }
    if (version < 4)
    {
#ifdef ANDROID
        config.setValue("showDidYouKnow", false);
#endif
    }
    if (version < 5)
    {
        if (config.getIntValue("speech") == BeingSpeech::TEXT_OVERHEAD)
        {
            config.setValue("speech", CAST_S32(
                BeingSpeech::NO_NAME_IN_BUBBLE));
        }
    }
    if (version < 6)
        config.setValue("blur", false);

    if (version < 7)
        config.setValue("download-music", true);

    if (version < 9)
    {
        config.deleteKey("videodetected");
        config.setValue("moveToTargetType", 10);
    }
    if (version < 10)
        config.setValue("enableLazyScrolling", false);

    if (version < 11)
    {
#ifdef USE_SDL2
        const std::string prefix = std::string("sdl2");
#else
        const std::string prefix = std::string();
#endif
        unassignKey("keyDirectUp", "k108");
        unassignKey("keyDirectDown", "k59");
        unassignKey("keyDirectLeft", "k107");
        unassignKey("keyDirectRight", "k39");
    }
    if (version < 12)
    {
#ifdef USE_SDL2
        const std::string prefix = std::string("sdl2");
#else
        const std::string prefix = std::string();
#endif
        unassignKey("keyAttack", "k120");
    }

    if (version < 13)
        config.setValue("keyWindowBotChecker", -1);

    config.setValue("cfgver", 13);
}
Example #24
0
void ConfigManager::storeSafeParameters()
{
    bool tmpHwaccel;
    RenderType tmpOpengl;
    int tmpFpslimit;
    int tmpAltFpslimit;
    bool tmpSound;
    int width;
    int height;
    std::string font;
    std::string bFont;
    std::string particleFont;
    std::string helpFont;
    std::string secureFont;
    std::string npcFont;
    std::string japanFont;
    std::string chinaFont;
    bool showBackground;
    bool enableMumble;
    bool enableMapReduce;

    isSafeMode = config.getBoolValue("safemode");
    if (isSafeMode)
        logger->log1("Run in safe mode");

    tmpOpengl = intToRenderType(config.getIntValue("opengl"));

    width = config.getIntValue("screenwidth");
    height = config.getIntValue("screenheight");
    tmpHwaccel = config.getBoolValue("hwaccel");

    tmpFpslimit = config.getIntValue("fpslimit");
    tmpAltFpslimit = config.getIntValue("altfpslimit");
    tmpSound = config.getBoolValue("sound");

    font = config.getStringValue("font");
    bFont = config.getStringValue("boldFont");
    particleFont = config.getStringValue("particleFont");
    helpFont = config.getStringValue("helpFont");
    secureFont = config.getStringValue("secureFont");
    npcFont = config.getStringValue("npcFont");
    japanFont = config.getStringValue("japanFont");
    chinaFont = config.getStringValue("chinaFont");

    showBackground = config.getBoolValue("showBackground");
    enableMumble = config.getBoolValue("enableMumble");
    enableMapReduce = config.getBoolValue("enableMapReduce");

    if (!settings.options.safeMode && !tmpOpengl)
    {
        // if video mode configured reset most settings to safe
        config.setValue("hwaccel", false);
        config.setValue("altfpslimit", 3);
        config.setValue("sound", false);
        config.setValue("safemode", true);
        config.setValue("screenwidth", 640);
        config.setValue("screenheight", 480);
        config.setValue("font", "fonts/dejavusans.ttf");
        config.setValue("boldFont", "fonts/dejavusans-bold.ttf");
        config.setValue("particleFont", "fonts/dejavusans.ttf");
        config.setValue("helpFont", "fonts/dejavusansmono.ttf");
        config.setValue("secureFont", "fonts/dejavusansmono.ttf");
        config.setValue("npcFont", "fonts/dejavusans.ttf");
        config.setValue("japanFont", "fonts/mplus-1p-regular.ttf");
        config.setValue("chinaFont", "fonts/wqy-microhei.ttf");
        config.setValue("showBackground", false);
        config.setValue("enableMumble", false);
        config.setValue("enableMapReduce", false);
    }
    else
    {
        // if video mode not configured reset only video mode to safe
        config.setValue("screenwidth", 640);
        config.setValue("screenheight", 480);
    }
#if defined(__APPLE__)
    config.setValue("opengl", CAST_S32(RENDER_NORMAL_OPENGL));
#else
    config.setValue("opengl", CAST_S32(RENDER_SOFTWARE));
#endif

    config.write();

    if (settings.options.safeMode)
    {
        isSafeMode = true;
        return;
    }

    config.setValue("safemode", false);
    if (!tmpOpengl)
    {
        config.setValue("hwaccel", tmpHwaccel);
        config.setValue("opengl", CAST_S32(tmpOpengl));
        config.setValue("fpslimit", tmpFpslimit);
        config.setValue("altfpslimit", tmpAltFpslimit);
        config.setValue("sound", tmpSound);
        config.setValue("screenwidth", width);
        config.setValue("screenheight", height);
        config.setValue("font", font);
        config.setValue("boldFont", bFont);
        config.setValue("particleFont", particleFont);
        config.setValue("helpFont", helpFont);
        config.setValue("secureFont", secureFont);
        config.setValue("npcFont", npcFont);
        config.setValue("japanFont", japanFont);
        config.setValue("chinaFont", chinaFont);
        config.setValue("showBackground", showBackground);
        config.setValue("enableMumble", enableMumble);
        config.setValue("enableMapReduce", enableMapReduce);
    }
    else
    {
        config.setValue("opengl", CAST_S32(tmpOpengl));
        config.setValue("screenwidth", width);
        config.setValue("screenheight", height);
    }
}
Example #25
0
int ListBox::getSelectionByMouse(const int y) const
{
    if (y < mPadding)
        return -1;
    return (y - mPadding) / CAST_S32(getRowHeight());
}
Example #26
0
void ListBox::draw(Graphics *const graphics)
{
    if (!mListModel)
        return;

    BLOCK_START("ListBox::draw")
    updateAlpha();

    mHighlightColor.a = CAST_U32(mAlpha * 255.0F);
    graphics->setColor(mHighlightColor);
    Font *const font = getFont();
    const int rowHeight = CAST_S32(getRowHeight());
    const int width = mDimension.width;

    if (mCenterText)
    {
        // Draw filled rectangle around the selected list element
        if (mSelected >= 0)
        {
            graphics->fillRectangle(Rect(mPadding,
                                         rowHeight * mSelected + mPadding,
                                         mDimension.width - 2 * mPadding, rowHeight));

            const std::string str = mListModel->getElementAt(mSelected);
            font->drawString(graphics,
                             mForegroundSelectedColor,
                             mForegroundSelectedColor2,
                             str,
                             (width - font->getWidth(str)) / 2,
                             mSelected * rowHeight + mPadding + mItemPadding);
        }
        // Draw the list elements
        const int sz = mListModel->getNumberOfElements();
        for (int i = 0, y = mPadding + mItemPadding;
                i < sz; ++i, y += rowHeight)
        {
            if (i != mSelected)
            {
                const std::string str = mListModel->getElementAt(i);
                font->drawString(graphics,
                                 mForegroundColor,
                                 mForegroundColor2,
                                 str,
                                 (width - font->getWidth(str)) / 2, y);
            }
        }
    }
    else
    {
        // Draw filled rectangle around the selected list element
        if (mSelected >= 0)
        {
            graphics->fillRectangle(Rect(mPadding,
                                         rowHeight * mSelected + mPadding,
                                         mDimension.width - 2 * mPadding, rowHeight));

            const std::string str = mListModel->getElementAt(mSelected);
            font->drawString(graphics,
                             mForegroundSelectedColor,
                             mForegroundSelectedColor2,
                             str,
                             mPadding,
                             mSelected * rowHeight + mPadding + mItemPadding);
        }
        // Draw the list elements
        const int sz = mListModel->getNumberOfElements();
        for (int i = 0, y = mPadding + mItemPadding; i < sz;
                ++i, y += rowHeight)
        {
            if (i != mSelected)
            {
                const std::string str = mListModel->getElementAt(i);
                font->drawString(graphics,
                                 mForegroundColor,
                                 mForegroundColor2,
                                 str,
                                 mPadding, y);
            }
        }
    }
    BLOCK_END("ListBox::draw")
}
Example #27
0
void Setup_Video::action(const ActionEvent &event)
{
    const std::string &id = event.getId();

    if (id == "videomode")
    {
        std::string mode = mModeListModel->getElementAt(
            mModeList->getSelected());

        if (mode == "custom")
        {
            if (mDialog)
            {
                mode = mDialog->getText();
                mDialog = nullptr;
            }
            else
            {
                CREATEWIDGETV(mDialog, TextDialog,
                    // TRANSLATORS: resolution question dialog
                    _("Custom resolution (example: 1024x768)"),
                    // TRANSLATORS: resolution question dialog
                    _("Enter new resolution:                "));
                mDialog->setActionEventId("videomode");
                mDialog->addActionListener(this);
                return;
            }
        }
        const int width = atoi(mode.substr(0, mode.find("x")).c_str());
        const int height = atoi(mode.substr(mode.find("x") + 1).c_str());
        if (!width || !height)
            return;

        if (width != mainGraphics->mActualWidth
            || height != mainGraphics->mActualHeight)
        {
#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
            if (intToRenderType(config.getIntValue("opengl"))
                == RENDER_SOFTWARE)
            {
                WindowManager::doResizeVideo(width, height, false);
            }
            else
            {
                if (width < mainGraphics->mActualWidth
                    || height < mainGraphics->mActualHeight)
                {
                    CREATEWIDGET(OkDialog,
                        // TRANSLATORS: video settings warning
                        _("Screen Resolution Changed"),
                        // TRANSLATORS: video settings warning
                       _("Restart your client for the change to take effect.")
                        // TRANSLATORS: video settings warning
                       + std::string("\n") + _("Some windows may be moved to "
                        "fit the lowered resolution."),
                        // TRANSLATORS: ok dialog button
                        _("OK"),
                        DialogType::OK,
                        Modal_true,
                        ShowCenter_true,
                        nullptr,
                        260);
                }
                else
                {
                    CREATEWIDGET(OkDialog,
                        // TRANSLATORS: video settings warning
                        _("Screen Resolution Changed"),
                        // TRANSLATORS: video settings warning
                        _("Restart your client for the change"
                        " to take effect."),
                        // TRANSLATORS: ok dialog button
                        _("OK"),
                        DialogType::OK,
                        Modal_true,
                        ShowCenter_true,
                        nullptr,
                        260);
                }
            }
#else  // defined(WIN32) || defined(__APPLE__) || defined(ANDROID)

            mainGraphics->setWindowSize(width, height);
            WindowManager::doResizeVideo(width, height, false);
#endif  // defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
        }

        config.setValue("oldscreen", config.getBoolValue("screen"));
        config.setValue("oldscreenwidth", mainGraphics->mActualWidth);
        config.setValue("oldscreenheight", mainGraphics->mActualHeight);
        config.setValue("screenwidth", width);
        config.setValue("screenheight", height);
    }
    if (id == "~videomode")
    {
        mDialog = nullptr;
    }
    else if (id == "customcursor")
    {
        config.setValue("customcursor", mCustomCursorCheckBox->isSelected());
    }
    else if (id == "fpslimitcheckbox" || id == "fpslimitslider")
    {
        int tempFps = CAST_S32(mFpsSlider->getValue());
        if (id == "fpslimitcheckbox" && !mFpsSlider->isEnabled())
            tempFps = 60;
        else
            tempFps = tempFps > 0 ? tempFps : 60;
        mFps = mFpsCheckBox->isSelected() ? tempFps : 0;
        // TRANSLATORS: video settings label
        const std::string text = mFps > 0 ? toString(mFps) : _("None");

        mFpsLabel->setCaption(text);
        mFpsSlider->setEnabled(mFps > 0);
        mFpsSlider->setValue(mFps);
    }
    else if (id == "altfpslimitslider")
    {
        int tempFps = CAST_S32(mAltFpsSlider->getValue());
        tempFps = tempFps > 0 ? tempFps : CAST_S32(
            mAltFpsSlider->getScaleStart());
        mAltFps = tempFps;
        // TRANSLATORS: video settings label
        const std::string text = mAltFps > 0 ? toString(mAltFps) : _("None");

        // TRANSLATORS: video settings label
        mAltFpsLabel->setCaption(_("Alt FPS limit: ") + text);
        mAltFpsSlider->setEnabled(mAltFps > 0);
        mAltFpsSlider->setValue(mAltFps);
    }
    else if (id == "enableresize")
    {
        config.setValue("enableresize", mEnableResizeCheckBox->isSelected());
    }
    else if (id == "noframe")
    {
        config.setValue("noframe", mNoFrameCheckBox->isSelected());
    }
#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__APPLE__)
    else if (id == "detect")
    {
        TestMain *test = graphicsManager.startDetection();
        if (test)
        {
            Configuration &conf = test->getConfig();
            const int val = conf.getValueInt("opengl", -1);
            if (val >= 0 && CAST_U32(val)
                < sizeof(renderToIndex) / sizeof(int))
            {
                mOpenGLDropDown->setSelected(renderToIndex[val]);
            }
            config.setValue("textureSize",
                conf.getValue("textureSize", "1024,1024,1024,1024,1024,1024"));
            config.setValue("testInfo", conf.getValue("testInfo", ""));
            delete test;
        }
    }
#endif  // defined(USE_OPENGL) && !defined(ANDROID) && !defined(__APPLE__)
}
Example #28
0
void FloorItem::draw(Graphics *const graphics,
                     const int offsetX, const int offsetY) const
{
    if (!mMap)
        return;

    BLOCK_START("FloorItem::draw")
    const int x = mX * mMap->getTileWidth() + offsetX;
    const int y = mY * mMap->getTileHeight() + offsetY - mHeightPosDiff;
    Font *font = nullptr;

    if (mHighlight)
    {
        const time_t curTime = cur_time;
        font = gui->getFont();
        if (mDropTime < curTime)
        {
            const int dx = mapTileSize;
            const int dy = mapTileSize;

            if (curTime > mDropTime + 28 && curTime < mDropTime + 50)
            {
                graphics->setColor(Color(80, 200, 20, 200));
                graphics->fillRectangle(Rect(
                                            x, y, dx, dy));
            }
            else if (curTime > mDropTime + 19
                     && curTime < mDropTime + 28)
            {
                graphics->setColor(Color(200, 80, 20,
                                         80 + 10 * CAST_S32(curTime - mDropTime - 18)));
                graphics->fillRectangle(Rect(
                                            x, y, dx, dy));
            }
            else if (curTime > mDropTime && curTime < mDropTime + 20)
            {
                graphics->setColor(Color(20, 20, 255,
                                         7 * CAST_S32(curTime - mDropTime)));
                graphics->fillRectangle(Rect(x, y, dx, dy));
            }
        }
    }

    const int px = getActorX() + offsetX;
    const int py = getActorY() + offsetY;
    CompoundSprite::drawSimple(graphics, px, py);

    if (mHighlight)
    {
        if (font && mAmount > 1)
        {
            const Color &color = userPalette->getColor(
                                     UserColorId::FLOOR_ITEM_TEXT);
            font->drawString(graphics,
                             color, color,
                             toString(mAmount),
                             x, y);
        }
    }
    BLOCK_END("FloorItem::draw")
}
Example #29
0
void SkillRecv::processSkillFailed(Net::MessageIn &msg)
{
    // Action failed (ex. sit because you have not reached the
    // right level)
    const int skillId   = msg.readInt16("skill id");
    const int16_t bskill  = msg.readInt16("bskill");
    msg.readInt16("btype");
    const signed char success = msg.readUInt8("success");
    const signed char reason  = msg.readUInt8("reason");
    if (success != CAST_S32(SKILL_FAILED)
        && bskill == CAST_S32(BSKILL_EMOTE))
    {
        logger->log("Action: %d/%d", bskill, success);
    }

    std::string txt;
    if (success == CAST_S32(SKILL_FAILED)
        && skillId == CAST_S32(SKILL_BASIC))
    {
        if (localPlayer &&
            bskill == CAST_S32(BSKILL_EMOTE) &&
            reason == CAST_S32(RFAIL_SKILLDEP))
        {
            localPlayer->stopAdvert();
        }

        switch (bskill)
        {
            case BSKILL_TRADE:
                // TRANSLATORS: error message
                txt = _("Trade failed!");
                break;
            case BSKILL_EMOTE:
                // TRANSLATORS: error message
                txt = _("Emote failed!");
                break;
            case BSKILL_SIT:
                // TRANSLATORS: error message
                txt = _("Sit failed!");
                break;
            case BSKILL_CREATECHAT:
                // TRANSLATORS: error message
                txt = _("Chat creating failed!");
                break;
            case BSKILL_JOINPARTY:
                // TRANSLATORS: error message
                txt = _("Could not join party!");
                break;
            case BSKILL_SHOUT:
                // TRANSLATORS: error message
                txt = _("Cannot shout!");
                break;
            default:
                UNIMPLEMENTEDPACKETFIELD(bskill);
                break;
        }

        txt.append(" ");

        switch (reason)
        {
            case RFAIL_SKILLDEP:
                // TRANSLATORS: error message
                txt.append(_("You have not yet reached a high enough lvl!"));
                break;
            case RFAIL_INSUFHP:
                // TRANSLATORS: error message
                txt.append(_("Insufficient HP!"));
                break;
            case RFAIL_INSUFSP:
                // TRANSLATORS: error message
                txt.append(_("Insufficient SP!"));
                break;
            case RFAIL_NOMEMO:
                // TRANSLATORS: error message
                txt.append(_("You have no memos!"));
                break;
            case RFAIL_SKILLDELAY:
                // TRANSLATORS: error message
                txt.append(_("You cannot do that right now!"));
                break;
            case RFAIL_ZENY:
                // TRANSLATORS: error message
                txt.append(_("Seems you need more money... ;-)"));
                break;
            case RFAIL_WEAPON:
                // TRANSLATORS: error message
                txt.append(_("You cannot use this skill with that "
                    "kind of weapon!"));
                break;
            case RFAIL_REDGEM:
                // TRANSLATORS: error message
                txt.append(_("You need another red gem!"));
                break;
            case RFAIL_BLUEGEM:
                // TRANSLATORS: error message
                txt.append(_("You need another blue gem!"));
                break;
            case RFAIL_OVERWEIGHT:
                // TRANSLATORS: error message
                txt.append(_("You're carrying to much to do this!"));
                break;
            default:
                // TRANSLATORS: error message
                txt.append(_("Huh? What's that?"));
                UNIMPLEMENTEDPACKETFIELD(reason);
                break;
        }
    }
    else
    {
        switch (skillId)
        {
            case SKILL_WARP :
                // TRANSLATORS: error message
                txt = _("Warp failed...");
                break;
            case SKILL_STEAL :
                // TRANSLATORS: error message
                txt = _("Could not steal anything...");
                break;
            case SKILL_ENVENOM :
                // TRANSLATORS: error message
                txt = _("Poison had no effect...");
                break;
            default:
                UNIMPLEMENTEDPACKETFIELD(skillId);
                break;
        }
    }

    NotifyManager::notify(NotifyTypes::SKILL_FAIL_MESSAGE, txt);
}
Example #30
0
void Setup_Video::apply()
{
    // Full screen changes
    bool fullscreen = mFsCheckBox->isSelected();
    if (fullscreen != config.getBoolValue("screen"))
    {
        /* The OpenGL test is only necessary on Windows, since switching
         * to/from full screen works fine on Linux. On Windows we'd have to
         * reinitialize the OpenGL state and reload all textures.
         *
         * See http://libsdl.org/cgi/docwiki.cgi/SDL_SetVideoMode
         */

#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
        // checks for opengl usage
        if (intToRenderType(config.getIntValue("opengl")) == RENDER_SOFTWARE)
        {
#endif  // defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
            if (!WindowManager::setFullScreen(fullscreen))
            {
                fullscreen = !fullscreen;
                if (!WindowManager::setFullScreen(fullscreen))
                {
                    std::stringstream errorMsg;
                    if (fullscreen)
                    {
                        // TRANSLATORS: video error message
                        errorMsg << _("Failed to switch to windowed mode "
                            "and restoration of old mode also "
                            "failed!") << std::endl;
                    }
                    else
                    {
                        // TRANSLATORS: video error message
                        errorMsg << _("Failed to switch to fullscreen mode"
                            " and restoration of old mode also "
                            "failed!") << std::endl;
                    }
                    logger->safeError(errorMsg.str());
                }
            }
#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
        }
        else
        {
            CREATEWIDGET(OkDialog,
                // TRANSLATORS: video settings warning
                _("Switching to Full Screen"),
                // TRANSLATORS: video settings warning
                _("Restart needed for changes to take effect."),
                // TRANSLATORS: ok dialog button
                _("OK"),
                DialogType::OK,
                Modal_true,
                ShowCenter_true,
                nullptr,
                260);
        }
#endif  // defined(WIN32) || defined(__APPLE__) || defined(ANDROID)

        config.setValue("screen", fullscreen);
    }

    const int sel = mOpenGLDropDown->getSelected();
    RenderType mode = RENDER_SOFTWARE;
    if (sel >= 0 && CAST_U32(sel) < sizeof(indexToRender))
        mode = indexToRender[mOpenGLDropDown->getSelected()];

    // OpenGL change
    if (mode != mOpenGLEnabled)
    {
        config.setValue("opengl", CAST_S32(mode));

        // OpenGL can currently only be changed by restarting, notify user.
        CREATEWIDGET(OkDialog,
            // TRANSLATORS: video settings warning
            _("Changing to OpenGL"),
            // TRANSLATORS: video settings warning
            _("Applying change to OpenGL requires restart."),
            // TRANSLATORS: ok dialog button
            _("OK"),
            DialogType::OK,
            Modal_true,
            ShowCenter_true,
            nullptr,
            260);
    }

    mFps = mFpsCheckBox->isSelected() ?
        CAST_S32(mFpsSlider->getValue()) : 0;

    mAltFps = CAST_S32(mAltFpsSlider->getValue());

    mFpsSlider->setEnabled(mFps > 0);

    mAltFpsSlider->setEnabled(mAltFps > 0);

    // FPS change
    config.setValue("fpslimit", mFps);
    config.setValue("altfpslimit", mAltFps);

    // We sync old and new values at apply time
    mFullScreenEnabled = config.getBoolValue("screen");
    mCustomCursorEnabled = config.getBoolValue("customcursor");

    mOpenGLEnabled = intToRenderType(config.getIntValue("opengl"));
    mEnableResize = config.getBoolValue("enableresize");
    mNoFrame = config.getBoolValue("noframe");
}