Exemplo n.º 1
0
/// Remove the mark at the given frame.
void DeleteMap::Delete(uint64_t frame, QString undoMessage)
{
    EDIT_CHECK;
    if (m_deleteMap.isEmpty())
        return;

    uint64_t prev = GetNearestMark(frame, false);
    uint64_t next = GetNearestMark(frame, true);

    // If frame is a cut point, GetNearestMark() would return the previous/next
    // mark (not this frame), so check to see if we need to use frame, instead
    frm_dir_map_t::Iterator it = m_deleteMap.find(frame);
    if (it != m_deleteMap.end())
    {
        int type = it.value();
        if (MARK_PLACEHOLDER == type)
            next = prev = frame;
        else if (MARK_CUT_END == type)
            next  = frame;
        else if (MARK_CUT_START == type)
            prev = frame;
    }

    Delete(prev);
    if (prev != next)
        Delete(next);
    CleanMap();
    if (!undoMessage.isEmpty())
        Push(undoMessage);
}
Exemplo n.º 2
0
/// Saves the delete map to the database.
void DeleteMap::SaveMap(bool isAutoSave)
{
    if (!m_ctx || !m_ctx->playingInfo || gCoreContext->IsDatabaseIgnored())
        return;

    if (!isAutoSave)
    {
        // Remove temporary placeholder marks
        QMutableMapIterator<uint64_t, MarkTypes> it(m_deleteMap);
        while (it.hasNext())
        {
            it.next();
            if (MARK_PLACEHOLDER == it.value())
            {
                it.remove();
                m_changed = true;
            }
        }

        CleanMap();
    }
    m_ctx->LockPlayingInfo(__FILE__, __LINE__);
    m_ctx->playingInfo->SaveMarkupFlag(MARK_UPDATED_CUT);
    m_ctx->playingInfo->SaveCutList(m_deleteMap, isAutoSave);
    m_ctx->UnlockPlayingInfo(__FILE__, __LINE__);
}
Exemplo n.º 3
0
/// Loads the given commercial break map into the deleteMap.
void DeleteMap::LoadCommBreakMap(frm_dir_map_t &map)
{
    Clear();
    frm_dir_map_t::Iterator it = map.begin();
    for ( ; it != map.end(); ++it)
        Add(it.key(), it.value() == MARK_COMM_START ?
                MARK_CUT_START : MARK_CUT_END);
    CleanMap();
    Push(tr("Load Detected Commercials"));
}
Exemplo n.º 4
0
/// Reverses the direction of each mark in the map.
void DeleteMap::ReverseAll(void)
{
    EDIT_CHECK;
    frm_dir_map_t::Iterator it = m_deleteMap.begin();
    for ( ; it != m_deleteMap.end(); ++it)
        Add(it.key(), it.value() == MARK_CUT_END ? MARK_CUT_START :
                                                   MARK_CUT_END);
    CleanMap();
    Push(tr("Reverse Cuts"));
}
Exemplo n.º 5
0
/// Loads the delete map from the database.
void DeleteMap::LoadMap(QString undoMessage)
{
    if (!m_ctx || !m_ctx->playingInfo || gCoreContext->IsDatabaseIgnored())
        return;

    Clear();
    m_ctx->LockPlayingInfo(__FILE__, __LINE__);
    m_ctx->playingInfo->QueryCutList(m_deleteMap);
    m_ctx->UnlockPlayingInfo(__FILE__, __LINE__);
    CleanMap();
    if (!undoMessage.isEmpty())
        Push(undoMessage);
}
Exemplo n.º 6
0
/// Returns true if an auto-save map was loaded.
/// Does nothing and returns false if not.
bool DeleteMap::LoadAutoSaveMap(void)
{
    if (!m_ctx || !m_ctx->playingInfo || gCoreContext->IsDatabaseIgnored())
        return false;

    frm_dir_map_t tmpDeleteMap = m_deleteMap;
    Clear();
    m_ctx->LockPlayingInfo(__FILE__, __LINE__);
    bool result = m_ctx->playingInfo->QueryCutList(m_deleteMap, true);
    m_ctx->UnlockPlayingInfo(__FILE__, __LINE__);
    CleanMap();
    if (result)
        Push(tr("Load Auto-saved Cuts"));
    else
        m_deleteMap = tmpDeleteMap;

    return result;
}
Exemplo n.º 7
0
 /**
 * \brief Show and update the edit mode On Screen Display. The cut regions
 *        are only refreshed if the deleteMap has been updated.
 */
void DeleteMap::UpdateOSD(uint64_t frame, double frame_rate, OSD *osd)
{
    if (!osd || !m_ctx)
        return;
    CleanMap();

    InfoMap infoMap;
    m_ctx->LockPlayingInfo(__FILE__, __LINE__);
    if (m_ctx->playingInfo)
        m_ctx->playingInfo->ToMap(infoMap);
    infoMap.detach();
    m_ctx->UnlockPlayingInfo(__FILE__, __LINE__);

    QString cutmarker = " ";
    if (IsInDelete(frame))
        cutmarker = tr("cut");

    uint64_t total = m_ctx->player->GetTotalFrameCount();
    QString timestr = CreateTimeString(frame, false, frame_rate, true);
    QString relTimeDisplay;
    relTimeDisplay = CreateTimeString(frame, true, frame_rate, false);
    QString relLengthDisplay;
    relLengthDisplay = CreateTimeString(total, true, frame_rate, false);
    infoMap["timedisplay"]  = timestr;
    infoMap["framedisplay"] = QString::number(frame);
    infoMap["cutindicator"] = cutmarker;
    infoMap["title"]        = tr("Edit");
    infoMap["seekamount"]   = m_seekText;;
    infoMap["reltimedisplay"] = relTimeDisplay;
    infoMap["rellengthdisplay"] = relLengthDisplay;
    //: example: "13:24 (10:23 of 24:37)"
    infoMap["fulltimedisplay"] = tr("%3 (%1 of %2)").arg(relTimeDisplay)
        .arg(relLengthDisplay).arg(timestr);

    QHash<QString,float> posMap;
    posMap.insert("position", (float)((double)frame/(double)total));
    osd->SetValues("osd_program_editor", posMap, kOSDTimeout_None);
    osd->SetText("osd_program_editor", infoMap,  kOSDTimeout_None);
    if (m_changed || total != m_cachedTotalForOSD)
        osd->SetRegions("osd_program_editor", m_deleteMap, total);
    m_changed = false;
    m_cachedTotalForOSD = total;
}
void Deplacement(int hauteur,int largeur,ROBOT *robot,char **map,FEU *feu,QUEUE *q, char *type_affichage,GRAPH *graph,char arrive,char chemin,int stop){

int i;
char type_feu='0';
int continuer=1;

while(continuer){

	//conserve les dernieres coordonnees du robots avec le type de la case
    robot->pos_old=robot->pos;
	//suit le chemin du craractere envoyé en parametre et arrive au caractere de parametre envoyé
	
	if(map[robot->pos.y-1][robot->pos.x]==chemin||map[robot->pos.y-1][robot->pos.x]==arrive){
		robot->pos.y--;//NORD
	}
	else if(map[robot->pos.y][robot->pos.x-1]==chemin||map[robot->pos.y][robot->pos.x-1]==arrive){
		robot->pos.x--;//GAUCHE
	}
	else if(map[robot->pos.y+1][robot->pos.x]==chemin||map[robot->pos.y+1][robot->pos.x]==arrive){
		robot->pos.y++;//SUD
	}
	else if(map[robot->pos.y][robot->pos.x+1]==chemin||map[robot->pos.y][robot->pos.x+1]==arrive){
		robot->pos.x++;//DROITE
	}
	//arrive sur le caracteres envoye en parametre
	if(GetCase(map,robot->pos)==arrive){
		continuer=0;
	}
	//regarde si on est dans un feu quelle valeur du feu
	for(i=0;i<feu->pos;i++){
		if(robot->pos.y==feu->Tab[i].y&&robot->pos.x==feu->Tab[i].x){
			type_feu=feu->Tab[i].type;
		}
	}
	//si il est passé dans un feu il garde en memoire la derniere coordonnee et calcul le chemin le plus court
	if(type_feu=='1'){

		robot->vie--;
		//conserve les coordonnees du feu
		robot->feu=robot->pos;
		//si il arrive a un 1 pour la recherche du feu il se stop
		if(!stop){
			continuer=0;		
		}
	}
	//si il arrive dans le 2 il lance l'algo de pathfinding v2 pour reprendre le chemin le plus court tout en esquivant les 2 et 3
	if(type_feu=='2'){
			
		robot->vie-=2;
		//conserve les coordonnees du feu
		robot->feu=robot->pos;
		//netoit la map
		CleanMap(map,largeur,hauteur);
		//rajoute le feu pour le pathfinding
		AddFire (map,feu);
		//scan la map avec comme parametre de ne pas pouvoir aller dans le feu
		Scan(map,q,robot,1,'E');
		//trace le chemin le plus court
		Trace(map,q);
	}
	//regarde si on a 0 pdv
	if(robot->vie==0){

		system(CLEARSCREEN);
		printf("GAME OVER");
		exit(1);
	}
	//trace le passage du robot
	SetCase(map,robot->pos_old,'i');
	//si le robot est en mode pompier alors on ecrit p sinon r
	if(robot->pompier==0){
		SetCase(map,robot->pos,'R');
	}
	else{
		SetCase(map,robot->pos,'P');
	}
	
	//augemente le nb de deplacement
	robot->dep++;
	//affiche
	Affichage(map,hauteur,largeur,robot,type_affichage,graph,feu);
	type_feu='0';
}
return;
}
Exemplo n.º 9
0
/// Add a new cut marker (to start or end a cut region)
void DeleteMap::NewCut(uint64_t frame)
{
    EDIT_CHECK;

    // find any existing temporary marker to determine cut range
    int64_t existing = -1;
    frm_dir_map_t::Iterator it;
    for (it = m_deleteMap.begin() ; it != m_deleteMap.end(); ++it)
    {
        if (MARK_PLACEHOLDER == it.value())
        {
            existing = it.key();
            break;
        }
    }

    if (existing > -1)
    {
        uint64_t total = m_ctx->player->GetTotalFrameCount();
        uint64_t otherframe = static_cast<uint64_t>(existing);
        if (otherframe == frame)
            Delete(otherframe);
        else
        {
            uint64_t startframe;
            uint64_t endframe;
            int64_t cut_start = -1;
            int64_t cut_end = -1;
            if (IsInDelete(frame))
            {
                MarkTypes type = MARK_UNSET;
                cut_start = GetNearestMark(frame, false);
                cut_end = GetNearestMark(frame, true);
                frm_dir_map_t::Iterator it = m_deleteMap.find(frame);
                if (it != m_deleteMap.end())
                    type = it.value();
                if (MARK_CUT_START == type)
                {
                    cut_start = frame;
                }
                else if (MARK_CUT_END == type)
                {
                    cut_end = frame;
                }
            }

            if (otherframe < frame)
            {
                startframe = otherframe;
                endframe = cut_end != -1 ? static_cast<uint64_t>(cut_end)
                                         : frame;
            }
            else
            {
                startframe = cut_start != -1 ? static_cast<uint64_t>(cut_start)
                                             : frame;
                endframe = otherframe;
            }

            // Don't place a cut marker on first or last frame; instead cut
            // to beginning or end
            if (startframe == 1)
                startframe = 0;
            if (endframe >= total - 1)
                endframe = total;

            // Don't cut the entire recording
            if ((startframe == 0) && (endframe == total))
            {
                LOG(VB_GENERAL, LOG_CRIT, LOC +
                    "Refusing to cut entire recording.");
                return;
            }

            Delete(otherframe);
            Add(startframe, MARK_CUT_START);
            Add(endframe, MARK_CUT_END);
            // Clear out any markers between the start and end frames
            otherframe = 0;
            frm_dir_map_t::Iterator it = m_deleteMap.find(startframe);
            for ( ; it != m_deleteMap.end() && otherframe < endframe; ++it)
            {
                otherframe = it.key();
                if ((startframe < otherframe) && (endframe > otherframe))
                {
                    LOG(VB_PLAYBACK, LOG_INFO, LOC +
                        QString("Deleting bounded marker: %1").arg(otherframe));
                    Delete(otherframe);
                }
            }
        }
    }
    else
        Add(frame, MARK_PLACEHOLDER);

    CleanMap();
    Push(tr("New Cut"));
}
Exemplo n.º 10
0
/**
 * \brief Add a new mark of the given type. Before the new mark is added, any
 *        existing redundant mark of that type is removed. This simplifies
 *        the cleanup code.
 */
void DeleteMap::Add(uint64_t frame, MarkTypes type, QString undoMessage)
{
    EDIT_CHECK;
    if ((MARK_CUT_START != type) && (MARK_CUT_END != type) &&
        (MARK_PLACEHOLDER != type))
        return;

    frm_dir_map_t::Iterator find_temporary = m_deleteMap.find(frame);
    if (find_temporary != m_deleteMap.end())
    {
        if (MARK_PLACEHOLDER == find_temporary.value())
        {
            // Delete the temporary mark before putting a real mark at its
            // location
            Delete(frame, "");
        }
        else // Don't add a mark on top of a mark
            return;
    }

    int       lasttype  = MARK_UNSET;
    long long lastframe = -1;
    long long remove    = -1;
    QMutableMapIterator<uint64_t, MarkTypes> it(m_deleteMap);

    if (type == MARK_CUT_END)
    {
        // remove curent end marker if it exists
        while (it.hasNext())
        {
            it.next();
            if (it.key() > frame)
            {
                if ((lasttype == MARK_CUT_END) && (lastframe > -1))
                    remove = lastframe;
                break;
            }
            lasttype  = it.value();
            lastframe = it.key();
        }
        if ((remove < 0) && (lasttype == MARK_CUT_END) &&
            (lastframe > -1) && (lastframe < (int64_t)frame))
            remove = lastframe;
    }
    else if (type == MARK_CUT_START)
    {
        // remove curent start marker if it exists
        it.toBack();
        while (it.hasPrevious())
        {
            it.previous();
            if (it.key() <= frame)
            {
                if (lasttype == MARK_CUT_START && (lastframe > -1))
                    remove = lastframe;
                break;
            }
            lasttype  = it.value();
            lastframe = it.key();
        }
        if ((remove < 0) && (lasttype == MARK_CUT_START) &&
            (lastframe > -1) && (lastframe > (int64_t)frame))
            remove = lastframe;
    }

    if (remove > -1)
        Delete((uint64_t)remove);
    Add(frame, type);
    CleanMap();
    if (!undoMessage.isEmpty())
        Push(undoMessage);
}