Example #1
0
int ded_s::getMaterialNum(de::Uri const &uri) const
{
    if(uri.isEmpty()) return -1;  // Not found.

    if(uri.scheme().isEmpty())
    {
        // Caller doesn't care which scheme - use a priority search order.
        de::Uri temp(uri);

        temp.setScheme("Sprites");
        int idx = getMaterialNum(temp);
        if(idx >= 0) return idx;

        temp.setScheme("Textures");
        idx = getMaterialNum(temp);
        if(idx >= 0) return idx;

        temp.setScheme("Flats");
        idx = getMaterialNum(temp);
        /*if(idx >= 0)*/ return idx;
    }

    if(Record const *def = materials.tryFind("id", uri.compose()))
    {
        return def->geti("__order__");
    }
    return -1;  // Not found.
}
Example #2
0
int ded_s::getMapInfoNum(de::Uri const &uri) const
{
    if(Record const *def = mapInfos.tryFind("id", uri.compose()))
    {
        return def->geti("__order__");
    }
    return -1;  // Not found.
}
bool TextureManifest::setResourceUri(de::Uri const &newUri)
{
    // Avoid resolving; compare as text.
    if (d->resourceUri.asText() != newUri.asText())
    {
        d->resourceUri = newUri;
        return true;
    }
    return false;
}
Example #4
0
GLuint GL_PrepareFlaremap(de::Uri const &resourceUri)
{
    if(resourceUri.path().length() == 1)
    {
        // Select a system flare by numeric identifier?
        int number = resourceUri.path().toStringRef().first().digitValue();
        if(number == 0) return 0; // automatic
        if(number >= 1 && number <= 4)
        {
            return GL_PrepareSysFlaremap(flaretexid_t(number - 1));
        }
    }
    if(Texture *tex = App_ResourceSystem().texture("Flaremaps", resourceUri))
    {
        if(TextureVariant const *variant = tex->prepareVariant(Rend_HaloTextureSpec()))
        {
            return variant->glName();
        }
        // Dang...
    }
    return 0;
}
Example #5
0
void Hu_DrawMapTitle(float alpha, dd_bool mapIdInsteadOfAuthor)
{
    de::Uri const mapUri    = COMMON_GAMESESSION->mapUri();
    de::String const title  = G_MapTitle(mapUri);
    de::String const author = G_MapAuthor(mapUri, CPP_BOOL(cfg.common.hideIWADAuthor));

    float y = 0;

    DGL_Enable(DGL_TEXTURE_2D);
    DGL_Color4f(1, 1, 1, alpha);

    FR_SetFont(FID(GF_FONTB));
    FR_LoadDefaultAttrib();
    FR_SetColorAndAlpha(defFontRGB[0], defFontRGB[1], defFontRGB[2], alpha);

#if __JDOOM__ || __JDOOM64__
    patchid_t patchId = 0;
    de::Uri const titleImage = G_MapTitleImage(mapUri);
    if(!titleImage.isEmpty())
    {
        if(!titleImage.scheme().compareWithoutCase("Patches"))
        {
            patchId = R_DeclarePatch(titleImage.path().toUtf8().constData());
        }
    }
    WI_DrawPatch(patchId, Hu_ChoosePatchReplacement(PRM_ALLOW_TEXT, patchId, title),
                 de::Vector2i(), ALIGN_TOP, 0, DTF_ONLY_SHADOW);

    // Following line of text placed according to patch height.
    y += Hu_MapTitleFirstLineHeight();

#elif __JHERETIC__ || __JHEXEN__
    if(!title.isEmpty())
    {
        FR_DrawTextXY3(title.toUtf8().constData(), 0, 0, ALIGN_TOP, DTF_ONLY_SHADOW);
        y += 20;
    }
#endif

    if(mapIdInsteadOfAuthor)
    {
        FR_SetFont(FID(GF_FONTA));
#if defined(__JHERETIC__) || defined(__JHEXEN__)
        FR_SetColorAndAlpha(.85f, .85f, .85f, alpha);
#else
        FR_SetColorAndAlpha(.6f, .6f, .6f, alpha);
#endif
        FR_DrawTextXY3(mapUri.path().toUtf8().constData(), 0, y, ALIGN_TOP, DTF_ONLY_SHADOW);
    }
    else if(!author.isEmpty())
    {
        FR_SetFont(FID(GF_FONTA));
        FR_SetColorAndAlpha(.5f, .5f, .5f, alpha);
        FR_DrawTextXY3(author.toUtf8().constData(), 0, y, ALIGN_TOP, DTF_ONLY_SHADOW);
    }

    DGL_Disable(DGL_TEXTURE_2D);
}
Example #6
0
static void NetSv_CycleToMapNum(de::Uri const &mapUri)
{
    de::String const warpCommand = de::String("warp ") + mapUri.compose(de::Uri::DecodePath);
    DD_Execute(false, warpCommand.toUtf8().constData());

    // In a couple of seconds, send everyone the rules of this map.
    for(int i = 0; i < MAXPLAYERS; ++i)
    {
        cycleRulesCounter[i] = 3 * TICSPERSEC;
    }

    cycleMode    = CYCLE_IDLE;
    cycleCounter = 0;
}
Example #7
0
static void readArchivedUri(de::Uri &uri, int version, reader_s &reader)
{
    if (version >= 4)
    {
        // A serialized, percent encoded URI.
        uri.readUri(&reader);
    }
    else if (version == 3)
    {
        // A percent encoded textual URI.
        ddstring_t *_uri = Str_NewFromReader(&reader);
        uri.setUri(Str_Text(_uri), RC_NULL);
        Str_Delete(_uri);
    }
    else if (version == 2)
    {
        // An unencoded textual URI.
        ddstring_t *_uri = Str_NewFromReader(&reader);
        uri.setUri(QString(QByteArray(Str_Text(_uri), Str_Length(_uri)).toPercentEncoding()), RC_NULL);
        Str_Delete(_uri);
    }
    else // ver 1
    {
        // A short textual path (unencoded).
        uri.setPath(readArchivedPath(reader));

        // Plus a legacy scheme id.
        int oldSchemeId = Reader_ReadByte(&reader);
        switch (oldSchemeId)
        {
        case 0: uri.setScheme("Textures"); break;
        case 1: uri.setScheme("Flats");    break;
        case 2: uri.setScheme("Sprites");  break;
        case 3: uri.setScheme("System");   break;
        default:
            throw Error("readArchiveUri", QString("Unknown old-scheme id #%1, expected [0..3)").arg(oldSchemeId));
        }
    }
}