Beispiel #1
0
void MapEditor::refreshObjetsList()
{
    if(!isMapValid())
        return;
    refreshMapObjectsList(m_selectedCase);
    refreshGlobalObjetsList();
}
Beispiel #2
0
bool MapEditor::selectMapItem(int index)
{
    if(index<0 || !isMapValid())
        return true;

    const QList<MapItem>& itms = m_mapWidget->m_map->mapItems;

    if(index>=itms.size())
    {
        if(index>0)
            return true;

        m_currentItemIndex=index;
        m_mapItemRSID->setValue(0);
        m_mapItemName->setText(tr("Aucun objet sélectionné"));
        m_mapItemColorViewer->setColor(QColor(0,0,0,0));
        m_mapItemPos->setText(tr("Coordonnées : N/A"));

        return false;
    }

    const MapItem* it= &itms[index];

    m_currentItemIndex=index;
    m_mapItemRSID->setValue(it->rsid);
    m_mapItemName->setText(tr("Nom : \"%1\"").arg(it->text));
    m_mapItemColorViewer->setColor(it->color);
    m_mapItemPos->setText(tr("Coordonnées : (%1;%2)").arg(it->coords.x()).arg(it->coords.y()));

    return false;
}
mapper_t BuildUserViewMap(const char *buff, int size, map_input_type type) {

	mapper_t map = NULL;
        mapper_t res = NULL;
	char *mapSourceBuff = NULL;
	int inputSize;
	
	mapSourceBuff = getMapSourceBuff(buff, size, type, &inputSize);
	if(!mapSourceBuff)
		goto out;;

	map = mapperInit(0);
	if(!map)
		goto out;
	
	if(!build(map, mapSourceBuff, inputSize))
		goto out;
	
	// Checking map validity
	if(!isMapValid(map))
		return NULL;
	
	// Build is compleate so we finalize it
	mapperFinalizeBuild(map);
        res = map;
 out:
        if(!res) {
                if(map)
                        mapperDone(map);
        }
        if(mapSourceBuff)
                free(mapSourceBuff);
	return res;
}
Beispiel #4
0
void MapEditor::changeCurrentCase(QPoint newCase) //Selected
{
    if(!isMapValid())
        return;
    m_selectedCase=newCase;
    m_selectedCaseLabel->setText(tr("Case : (%1;%2)").arg(newCase.x()).arg(newCase.y()));
    m_selectedCaseRSID->setValue(m_mapWidget->m_map->map[newCase.x()][newCase.y()]);
    refreshMapObjectsList(newCase);
}
Beispiel #5
0
void MapEditor::unmodified()
{
    m_needSave=false;
    if(isMapValid())
    {
        setWindowTitle(tr("%1 - Editeur de carte", "1 i the map name").arg(m_mapName));
    }
    else
        setWindowTitle(tr("Editeur de carte"));
}
Beispiel #6
0
void MapEditor::changeCurrentCaseRSID(int n)
{
    if(!isMapValid())
        return;

    if(m_mapWidget->m_map->map[m_selectedCase.x()][ m_selectedCase.y()]!=static_cast<RSID>(n))
    {
        m_mapWidget->m_map->map[m_selectedCase.x()][ m_selectedCase.y()] = static_cast<RSID>(n);
        modified();
    }
}
Beispiel #7
0
void MapEditor::addMapObject()
{
    if(!isMapValid())
        return;

    AddObjectDialog dia(this, m_selectedCase, QPoint(m_mapWidget->m_map->mapSizeX(), m_mapWidget->m_map->mapSizeY()), tr("Nouvel objet"));
    if(dia.exec()==QDialog::Accepted)
    {
        m_mapWidget->m_map->mapItems.append(MapItem(dia.getCoords(), dia.getRSID(), dia.getText(), dia.getColor(), static_cast<qreal>(dia.getColorValue())/100.0f));
        refreshObjetsList();
    }
}
mapper_t BuildPartnersMap(const char *partnerDir, partner_map_t type) {
	
	mapper_t   map = NULL;
	int        fileNum = 0, res;
	char     **fileList = NULL;
	
	
	map = mapperInit(0);
	if(!map)
		return map;

	// Get all files from the directory
	if(!getAllDirFiles(partnerDir, &fileList, &fileNum))
		goto failed;
        
	if(fileNum == 0 )
                goto failed;
        
	switch(type) {
	    case PARTNER_SRC_TEXT:
		    res = buildFromText(map, fileList, fileNum);
		    break;
	    case PARTNER_SRC_BIN:
		    res = buildFromBin(map, fileList, fileNum);
		    break;
	    default:
		    debug_lr(MAP_DEBUG, "Error type %d no supported\n", type);
		    goto failed;
	}
	if(!res)
		goto failed;
	
	if(!isMapValid(map))
		goto failed;
	
	// Build is compleate so we finalize it
	mapperFinalizeBuild(map);
        for(int i=0 ; i<fileNum ; i++)
                if(fileList[i])
                        free(fileList[i]);
        free(fileList);
	return map;
	
 failed:
	mapperDone(map);
	if(fileList) {
                for(int i=0 ; i<fileNum ; i++)
                        if(fileList[i])
                                free(fileList[i]);
		free(fileList);
        }
	return NULL;
}
Beispiel #9
0
bool MapEditor::saveRessourcePackAs(QString fileName)
{
    if(!isMapValid())
        return true;

    if(fileName.isEmpty())
        fileName = QFileDialog::getSaveFileName(this, tr("Sauvegarder un pack de ressources..."),"./Ressources/",tr("Fichiers de liste de ressources (*.list);;Tous les fichiers (*.*)"));

    if(fileName.isEmpty())
        return true;

    return m_mapWidget->saveRessources(fileName);
}
Beispiel #10
0
bool MapEditor::saveMapAs(QString fileName)
{
    if(!isMapValid())
        return true;

    if(fileName.isEmpty())
        fileName = QFileDialog::getSaveFileName(this, tr("Sauvegarder une carte..."),"./Maps/",tr("Fichiers de carte (*.map);;Tous les fichiers (*.*)"));

    if(fileName.isEmpty())
        return true;

    if(m_mapWidget->saveMap(fileName))
        return true;

    m_mapName=fileName;

    return false;
}
Beispiel #11
0
bool MapEditor::replaceRSID(RSID before, RSID after)
{
    if(!isMapValid())
        return true;

    modified();

    MapInformations* map = m_mapWidget->m_map.get();
    for(int xi=0,mx=map->mapSizeX();xi<mx;++xi)
    {
        for(int yi=0,my=map->mapSizeY();yi<my;++yi)
        {
            if(map->map[xi][yi]==before)
                map->map[xi][yi]=after;
        }
    }

    return false;
}
Beispiel #12
0
bool MapEditor::replaceRSID()
{
    if(!isMapValid())
        return true;
    bool ok = false;
    RSID from = QInputDialog::getInt(this, tr("Remplacer"), tr("Valeur à changer :"), 0, 0, std::numeric_limits<int>::max()-1, 1, &ok);
    if(!ok)
        return true;

    RSID to = QInputDialog::getInt(this, tr("Remplacer"), tr("Valeur de remplacement :"), 0, 0, std::numeric_limits<int>::max()-1, 1, &ok);
    if(!ok)
        return true;
    if(replaceRSID(from, to))
    {
        QMessageBox::critical(this, tr("Erreur"), tr("Impossible d'effectuer le remplacement."));
        return true;
    }
    return false;
}
Beispiel #13
0
void MapEditor::changeCasePos(QPoint newCase) //Hovered
{
    if(!isMapValid())
        return;
    m_hoveredCaseLabel->setText(tr("Case : (%1;%2)").arg(newCase.x()).arg(newCase.y()));
}
Beispiel #14
0
void MapEditor::btnMapSend()
{
    if(isMapValid())
        emit mapSendingRequested(m_mapWidget->getMap(), m_mapWidget->loadedRessources());
}
Beispiel #15
0
bool MapEditor::needSave() const
{
    return m_needSave&&isMapValid();
}