Exemple #1
0
int CMapFileIO::SaveMap(const CLevelMap &map, LPCWSTR szFileName) const
{
	HANDLE hFile = CreateFile(szFileName, GENERIC_WRITE, 0, 0,
		CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
	if(hFile == INVALID_HANDLE_VALUE)
		return 1;
	return SaveMap(map, hFile);
}
Exemple #2
0
 void SaveMap(const model::DynamicMap& map, const std::string& filename)
 {
     if (!utilities::IsFileWritable(filename))
     {
         throw utilities::SystemException(utilities::SystemExceptionErrors::fileNotWritable);
     }
     auto filestream = utilities::OpenOfstream(filename);
     SaveMap(map, filestream);
 }
Exemple #3
0
void DeleteMap::Push(QString undoMessage)
{
    DeleteMapUndoEntry entry(m_deleteMap, undoMessage);
    // Remove all "redo" entries
    while (m_undoStack.size() > m_undoStackPointer + 1)
        m_undoStack.pop_back();
    m_undoStack.append(entry);
    m_undoStackPointer ++;
    SaveMap(true);
}
Exemple #4
0
bool DeleteMap::Redo(void)
{
    if (!HasRedo())
        return false;
    m_undoStackPointer ++;
    m_deleteMap = m_undoStack[m_undoStackPointer].deleteMap;
    m_changed = true;
    SaveMap(true);
    return true;
}
Exemple #5
0
void DeleteMap::PushDeferred(const frm_dir_map_t &savedMap,
                             const QString &undoMessage)
{
    // Temporarily roll back to the initial state, push the undo
    // entry, then restore the correct state.
    frm_dir_map_t tmp = m_deleteMap;
    m_deleteMap = savedMap;
    Push(undoMessage);
    m_deleteMap = tmp;
    SaveMap(true);
}
Exemple #6
0
void main( void )
{
  appl_init();
  linea0();
  if (ReadScreen())
  {
    MakeMap();
    SaveMap();
  }
  appl_exit();
}
Exemple #7
0
bool DeleteMap::Undo(void)
{
    if (!HasUndo())
        return false;
    m_undoStackPointer --;
    frm_dir_map_t tmp = m_deleteMap;
    m_deleteMap = m_undoStack[m_undoStackPointer].deleteMap;
    m_undoStack[m_undoStackPointer].deleteMap = tmp;
    m_changed = true;
    SaveMap(true);
    return true;
}
Exemple #8
0
void SaveGame( game g ) {
    FILE* sf = fopen( "game.save", "w+" );
    SaveCharacter( sf, g->pc );
    creature Z = g->ZombieListHead;
    while( Z != NULL ) {
        chr z = Z->Character;
        SaveCharacter( sf, z );
        Z = Z->Next;
    }
    SaveMap(sf, g->gameMap);
    fclose( sf );
}
Exemple #9
0
	void Map::SaveMapDialog()
	{
		ALLEGRO_FILECHOOSER *saveDialog;
		saveDialog = al_create_native_file_dialog("..\\Maps\\", "Save Map", "*.*", ALLEGRO_FILECHOOSER_SAVE);
		al_show_native_file_dialog(display_, saveDialog);
		mapPath_ = al_create_path(al_get_native_file_dialog_path(saveDialog,0));
		if(strcmp(al_get_path_extension(mapPath_),"") == 0)
		{
			al_set_path_extension(mapPath_, ".mapa");
		}
		SaveMap();
		al_destroy_native_file_dialog(saveDialog);
	}
Exemple #10
0
int main(int argc, char **argv)
{
  struct s_map        map;
  struct s_lib_sprite libsprite;
  struct s_lib_event  libevent;

  printf("RPG 2D .:. Generateur de fichiers \n");
  printf("Games Creators Network - http://www.games-creators.org/\n");
  printf("Ce generateur permet de generer facilement les fichiers:\n");
  printf("o .event\n");
  printf("o .map\n");
  printf("o .sprite\n\n\n");
  printf("* SPRITES:\n");
  printf("- initialisation\n");
  InitSprite(&libsprite);
  printf("- chargement des donnees statiques\n");
  StaticSprite(&map,&libsprite,&libevent);
  printf("- sauvegarde\n");
  SaveSprite(&libsprite,SPRITE_IMG,SPRITEFILE);

  printf("* MAP:\n");
  printf("- génération aleatoire\n");
  RandomizeMap(&map,MAP_SIZE_X,MAP_SIZE_Y,CHIPSET);
  StaticMap(&map,&libsprite,&libevent);
  printf("- sauvegarde des donnees\n");
  SaveMap(&map, MAPFILE, MAP_MUSIQUE, CHIPSET);

  printf("* EVENEMENTS:\n");
  printf("- initialisation\n");
  InitLibEvent(&libevent,&map,&libsprite);
  printf("- chargement des donnees statiques\n");
  StaticEvent(&map,&libsprite,&libevent);
  printf("- sauvegarde des donnees\n");
  SaveEvent(&libevent,&map,&libsprite,EVENT_SON,EVENTFILE);

  printf("\n\n\nGénération des données réalisée avec succès...\n");
  return 0;
}
Exemple #11
0
   bool MapSystem::SaveScene(const std::string& path, bool saveAllMaps)
   {
      MapEncoder* enc = GetEncoderForScene(GetFileExtension(path));
      if(!enc)
      {
         LOG_ERROR("Could not save scene: Loader not found for extension " << GetFileExtension(path));
         return false;
      }
     bool success = enc->SaveSceneToFile(path);

      if(success && saveAllMaps)
      {
         for(LoadedMaps::const_iterator i = mLoadedMaps.begin(); i != mLoadedMaps.end(); ++i)
         {
            bool success = SaveMap(i->mMapPath);
            if(!success)
            {
               LOG_ERROR("Could not save map file " << i->mMapPath);
            }
         }
      }

      return success;
   }
Exemple #12
0
void Editor::ButtonClicked(std::string name)
{
	if (name == "save")
	{
		if (player == NULL)
		{
			this->gameWindow = new GameWindow(this, "needplayer", "ok", "", false);
		}
		else
		{
			this->gameWindow = new GameWindow(this, "savemap", "ok", "cancel", true);
		}
	}
	if (name == "close")
	{
		this->isEnded = true;
	}
	else if (name == "wall")
	{
		ChangeBrush(ObjectType::EWall);
	}
	else if (name == "box")
	{
		ChangeBrush(ObjectType::EBox);
	}
	else if (name == "destination")
	{
		ChangeBrush(ObjectType::EDestination);
	}
	else if (name == "floor")
	{
		ChangeBrush(ObjectType::EFloor);
	}
	else if (name == "player")
	{
		ChangeBrush(ObjectType::EPlayer);
	}
	else if (name == "empty")
	{
		ChangeBrush(ObjectType::EEmpty);
	}
	else if (name == "windows/ok")
	{
		if (this->gameWindow != NULL)
		{
			if (this->gameWindow->GetName() == "savemap")
			{
				std::string filename = this->gameWindow->GetText();
				delete this->gameWindow;
				this->gameWindow = NULL;

				if (!SaveMap(filename))
				{
					this->gameWindow = new GameWindow(this, "fileexists", "ok", "", false);
				}
			}
			else
			{
				delete this->gameWindow;
				this->gameWindow = NULL;
			}
		}
	}
	else if (name == "windows/cancel")
	{
		if (this->gameWindow != NULL)
		{
			delete this->gameWindow;
			this->gameWindow = NULL;
		}
	}
}
void Editor::Update()
{
	sf::Vector2f viewCenter = view->getCenter();
	sf::Vector2f viewChange = viewCenter;
	if (currentMapSizeX > (screenWidth - 200) / Tile::GetSize().x)
	{
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
		{
			viewCenter.x += 5;
		}
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
		{
			viewCenter.x -= 5;
		}
		if (viewCenter.x < screenWidth / 2)
			viewCenter.x = screenWidth / 2;
		if (viewCenter.x > (currentMapSizeX * Tile::GetSize().x) + 200 - screenWidth / 2)
			viewCenter.x = (currentMapSizeX * Tile::GetSize().x) + 200 - screenWidth / 2;

	}
	if (currentMapSizeY > screenHeight / Tile::GetSize().y)
	{
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
		{
			viewCenter.y += 5;
		}
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
		{
			viewCenter.y -= 5;
		}
		if (viewCenter.y < screenHeight / 2)
			viewCenter.y = screenHeight / 2;
		if (viewCenter.y >(currentMapSizeY * Tile::GetSize().y) - screenHeight / 2)
			viewCenter.y = (currentMapSizeY * Tile::GetSize().y) - screenHeight / 2;
	}
	if (viewCenter != view->getCenter())
		view->setCenter(viewCenter);
	window->setView(*view);
	viewChange -= viewCenter;

	mousePosition = sf::Mouse::getPosition(*window);
	mousePosition.x += viewCenter.x - (screenWidth / 2);
	mousePosition.y += viewCenter.y - (screenHeight / 2);

	sidebar->ChangePosition(sf::Vector2i(viewChange.x, viewChange.y));
	sidebar->Update(mousePosition);
	sidebarTiles->ChangePosition(sf::Vector2i(viewChange.x, viewChange.y));
	sidebarSelection->ChangePosition(sf::Vector2i(viewChange.x, viewChange.y));

	Tile::IDChangeInfo(selectedTileID, sidebar->GetMouseover());
	for (TileLayer::size_type y = 0; y < tileLayerBottom.size(); y++)
	{
		for (TileRow::size_type x = 0; x < tileLayerBottom[y].size(); x++)
		{
			tileLayerBottom[y][x]->Update(mousePosition);
			if (tileLayerBottom[y][x]->GetMouseover())
			{
				sf::Vector2i newSelectPos = tileLayerBottom[y][x]->GetPosition();
				newSelectPos += Tile::GetSize() / 2;
				selector->SetPosition(newSelectPos);
			}
		}
	}
	for (vector<vector<Button*>>::size_type y = 0; y < sidebarTilesY; y++)
	{
		for (vector<Button*>::size_type x = 0; x < sidebarTilesX; x++)
		{
			sidebarTileButtons[y][x]->ChangePosition(sf::Vector2i(viewChange.x, viewChange.y));
			sidebarTileButtons[y][x]->Update(mousePosition);
			if (sidebarTileButtons[y][x]->GetPressed())
			{
				sf::Vector2i newSelectPos = sidebarTileButtons[y][x]->GetPosition();
				newSelectPos += Tile::GetSize() / 2;
				sidebarSelection->SetPosition(newSelectPos);
				selectedTileID = sidebarTilesX * y + x;
			}
		}
	}
	saveUI->ChangePosition(sf::Vector2i(viewChange.x, viewChange.y));
	saveUI->Update(mousePosition);
	saveButton->ChangePosition(sf::Vector2i(viewChange.x, viewChange.y));
	saveButton->Update(mousePosition);
	if (saveButton->GetPressed())
	{
		SaveMap();
	}
}
Exemple #14
0
int main(int argc, char **argv)
{
    struct GModule *module;

    int DoMap, DoFilter, MapSeed;

    G_gisinit(argv[0]);

    module = G_define_module();
    G_add_keyword(_("raster"));
    G_add_keyword(_("random"));
    G_add_keyword(_("surface"));
    module->description =
	_("Generates random surface(s) with spatial dependence.");

    Output = G_define_option();
    Output->key = "output";
    Output->type = TYPE_STRING;
    Output->required = YES;
    Output->multiple = YES;
    Output->description = _("Name for output raster map(s)");
    Output->gisprompt = "new,cell,raster";

    Distance = G_define_option();
    Distance->key = "distance";
    Distance->type = TYPE_DOUBLE;
    Distance->required = NO;
    Distance->multiple = NO;
    Distance->description =
	_("Maximum distance of spatial correlation (value >= 0.0)");
    Distance->answer = "0.0";

    Exponent = G_define_option();
    Exponent->key = "exponent";
    Exponent->type = TYPE_DOUBLE;
    Exponent->multiple = NO;
    Exponent->required = NO;
    Exponent->description = _("Distance decay exponent (value > 0.0)");
    Exponent->answer = "1.0";

    Weight = G_define_option();
    Weight->key = "flat";
    Weight->type = TYPE_DOUBLE;
    Weight->multiple = NO;
    Weight->required = NO;
    Weight->description =
	_("Distance filter remains flat before beginning exponent");
    Weight->answer = "0.0";

    SeedStuff = G_define_option();
    SeedStuff->key = "seed";
    SeedStuff->type = TYPE_INTEGER;
    SeedStuff->required = NO;
    SeedStuff->description =
	_("Random seed (SEED_MIN >= value >= SEED_MAX), default [random]");

    range_high_stuff = G_define_option();
    range_high_stuff->key = "high";
    range_high_stuff->type = TYPE_INTEGER;
    range_high_stuff->required = NO;
    range_high_stuff->description = _("Maximum cell value of distribution");
    range_high_stuff->answer = "255";

    Uniform = G_define_flag();
    Uniform->key = 'u';
    Uniform->description = _("Uniformly distributed cell values");

    if (G_parser(argc, argv))
	exit(EXIT_FAILURE);

    Init();

    if (Uniform->answer)
	GenNorm();

    CalcSD();

    for (DoMap = 0; DoMap < NumMaps; DoMap++) {
	OutFD = Rast_open_c_new(OutNames[DoMap]);

	G_message(_("Generating raster map <%s>..."), OutNames[DoMap]);

	if (Seeds[DoMap] == SEED_MIN - 1)
	    Seeds[DoMap] = (int)(ran1() * SEED_MAX);

	MapSeed = Seed = Seeds[DoMap];
	ZeroMapCells();

	for (DoFilter = 0; DoFilter < NumFilters; DoFilter++) {
	    CopyFilter(&Filter, AllFilters[DoFilter]);
	    G_debug(1,
		    "Starting filter #%d, distance: %.*lf, exponent: %.*lf, flat: %.*lf",
		    DoFilter, Digits(2.0 * Filter.MaxDist, 6),
		    2.0 * Filter.MaxDist, Digits(1.0 / Filter.Exp, 6),
		    1.0 / Filter.Exp, Digits(Filter.Mult, 6), Filter.Mult);

	    MakeBigF();
	    CalcSurface();
	}

	SaveMap(DoMap, MapSeed);
    }

    G_done_msg(" ");

    exit(EXIT_SUCCESS);
}
Exemple #15
0
void RunBSP(const char* name)
{
  // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=503
  // make sure we don't attempt to region compile a map with the camera outside the region
  if (region_active && !Region_cameraValid())
  {
    globalErrorStream() << "The camera must be in the region to start a region compile.\n";
    return;
  }

  SaveMap();

  if(Map_Unnamed(g_map))
  {
    globalOutputStream() << "build cancelled\n";
    return;
  }

  if (g_SnapShots_Enabled && !Map_Unnamed(g_map) && Map_Modified(g_map))
  {
    Map_Snapshot();
  }

  if (region_active)
  {
    const char* mapname = Map_Name(g_map);
    StringOutputStream name(256);
    name << StringRange(mapname, path_get_filename_base_end(mapname)) << ".reg";
    Map_SaveRegion(name.c_str());
  }

  Pointfile_Delete();

  bsp_init();

  if (g_WatchBSP_Enabled)
  {
    ArrayCommandListener listener;
    build_run(name, listener);
    // grab the file name for engine running
    const char* fullname = Map_Name(g_map);
    StringOutputStream bspname(64);
    bspname << StringRange(path_get_filename_start(fullname), path_get_filename_base_end(fullname));
    BuildMonitor_Run( listener.array(), bspname.c_str() );
  }
  else
  {
    char junkpath[PATH_MAX];
    strcpy(junkpath, SettingsPath_get());
    strcat(junkpath, "junk.txt");

    char batpath[PATH_MAX];
#if defined(POSIX)
    strcpy(batpath, SettingsPath_get());
    strcat(batpath, "qe3bsp.sh");
#elif defined(WIN32)
    strcpy(batpath, SettingsPath_get());
    strcat(batpath, "qe3bsp.bat");
#else
#error "unsupported platform"
#endif
    bool written = false;
    {
      TextFileOutputStream batchFile(batpath);
      if(!batchFile.failed())
      {
#if defined (POSIX)
        batchFile << "#!/bin/sh \n\n";
#endif
        BatchCommandListener listener(batchFile, junkpath);
        build_run(name, listener);
        written = true;
      }
    }
    if(written)
    {
#if defined (POSIX)
      chmod (batpath, 0744);
#endif
      globalOutputStream() << "Writing the compile script to '" << batpath << "'\n";
      globalOutputStream() << "The build output will be saved in '" << junkpath << "'\n";
      Q_Exec(batpath, NULL, NULL, true);
    }
  }

  bsp_shutdown();
}
Exemple #16
0
/**
 * Constructs and displays the main UI for FortEdit
 * @param parent QWidget parent, typically null
 */
CFortEdit::CFortEdit(QWidget *parent) :
    QMainWindow(parent),
    DUi(new Ui::FortEdit),
    DActiveTool(0),
    DTerrainTool(0),
    DTerritoryTool(0),
    DObjectTool(0),
    DSelectTool(0),
    DSoundHandler(this),
    DLuaEditor(0)
{
    DUi->setupUi(this);
    DGraphicsScene = new QGraphicsScene();
    DUi->GraphicsView->setMouseTracking(true);
    DUi->GraphicsView->setScene(DGraphicsScene);
    DUi->GraphicsView->setUpdatesEnabled(true);

    // Ui connectivity / setup
    QObject::connect(DUi->ActionOpen, SIGNAL(triggered()), this, SLOT(OpenMap()));
    QObject::connect(DUi->ActionSaveAs, SIGNAL(triggered()), this, SLOT(SaveMapAs()));
    QObject::connect(DUi->ActionSave, SIGNAL(triggered()), this, SLOT(SaveMap()));
    QObject::connect(DUi->ActionNew, SIGNAL(triggered()), this, SLOT(NewMap()));
    QObject::connect(DUi->MapNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(UpdateSceneTitle(QString)));
    QObject::connect(DUi->MapWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(UpdateSceneWidth(int)));
    QObject::connect(DUi->MapHeightSpinBox, SIGNAL(valueChanged(int)), this, SLOT(UpdateSceneHeight(int)));
    QObject::connect(DUi->ObjectVisibilityToggle, SIGNAL(toggled(bool)), this, SLOT(UpdateSceneObjectVisibility(bool)));
    QObject::connect(DUi->GridCheckBox, SIGNAL(toggled(bool)), this, SLOT(UpdateSceneGridVisibility(bool)));
    QObject::connect(DUi->DisplayModeCombo, SIGNAL(currentIndexChanged(QString)), this, SLOT(UpdateSceneDisplayMode(QString)));

    QObject::connect(DUi->ToolTerrain, SIGNAL(clicked()), this, SLOT(UpdateActiveTool()));
    QObject::connect(DUi->ToolTerritory, SIGNAL(clicked()), this, SLOT(UpdateActiveTool()));
    QObject::connect(DUi->ToolObject, SIGNAL(clicked()), this, SLOT(UpdateActiveTool()));
    QObject::connect(DUi->ToolSelect, SIGNAL(clicked()), this, SLOT(UpdateActiveTool()));

    QObject::connect(DUi->AudioOptions, SIGNAL(clicked()), this, SLOT(UpdateActiveTool()));
    QObject::connect(DUi->ActionSaveSoundSet, SIGNAL(triggered()), this, SLOT(SaveSoundSet()));
    QObject::connect(DUi->ActionLoadSoundSet, SIGNAL(triggered()), &DSoundHandler, SLOT(LoadSoundSet()));

    QObject::connect(DUi->LuaEditorButton, SIGNAL(clicked()), this, SLOT(ToggleLuaEditor()));

    QObject::connect(DUi->PlayButton, SIGNAL(clicked()), this, SLOT(InvokeEngineDialog()));

    // Invocation dialog connectivity
    DInvocationDialog = new QDialog;
    DInvocationUi.setupUi(DInvocationDialog);

    LoadSettings();
    DInvocationUi.executablePath->setText(DEnginePath);
    DInvocationUi.modeCombo->setCurrentIndex(DInvocationMode);
    DInvocationUi.aiCombo->setCurrentIndex(DInvocationDifficulty);
    DInvocationUi.castleIndexCombo->setCurrentIndex(DInvocationIndex);
    DInvocationUi.windCheck->setChecked(DInvocationWind);

    QObject::connect(DInvocationUi.locateButton, SIGNAL(clicked()), this, SLOT(LocateEngine()));
    QObject::connect(DInvocationUi.modeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateInvocationConfig()));
    QObject::connect(DInvocationUi.aiCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateInvocationConfig()));
    QObject::connect(DInvocationUi.castleIndexCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateInvocationConfig()));
    QObject::connect(DInvocationUi.windCheck, SIGNAL(stateChanged(int)), this, SLOT(UpdateInvocationConfig()));
    QObject::connect(DInvocationUi.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(InvokeEngine(QAbstractButton*)));

    // TODO: Make sure this order is consistent... This is pretty bad as it stands
    DUi->PropertyPageStack->addWidget(DTerrainTool.GetPropertiesWidget());
    DUi->PropertyPageStack->addWidget(DTerritoryTool.GetPropertiesWidget());
    DUi->PropertyPageStack->addWidget(DSelectTool.GetPropertiesWidget());
    DUi->PropertyPageStack->addWidget(DSoundHandler.GetPropertiesWidget());
    DUi->PropertyPageStack->addWidget(DObjectTool.GetPropertiesWidget());

    DScene = new CScene(":/default-maps/res/new.map", DGraphicsScene, &DSoundHandler);
    DUi->ActionSave->setEnabled(false);
    UpdateUi();
}
Exemple #17
0
void Game::GameLoop()
{
    sf::Texture HideHack;
    HideHack.loadFromFile("Tiles/Hack.png");
    for(int y=0; y<24; ++y)
    {
        for(int x=0; x<32; ++x)
        {
            HideMapHack[y][x].setTexture(HideHack);
            HideMapHack[y][x].setPosition((float)x*32, (float)y*32);
        }
    }
    while(Window.isOpen()) 
    {
        sf::Event Event;
        while(Window.pollEvent(Event))
        {
            if((Event.type == sf::Event::Closed) || ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Escape)))
            {
                SaveMap(PathToMap);
                SavePlayer();
                return;
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Up))
            {
                switch(Move(NORTH))
                {
                case 0:
                    break;
                case 1:
                    RandomEncounter();
                    break;
                case 2:
                    Encounter(0, -1);
                    break;
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Down))
            {
                switch(Move(SOUTH))
                {
                case 0:
                    break;
                case 1:
                    RandomEncounter();
                    break;
                case 2:
                    Encounter(0, 1);
                    break;
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Right))
            {
                switch(Move(WEST))
                {
                case 0:
                    break;
                case 1:
                    RandomEncounter();
                    break;
                case 2:
                    Encounter(1, 0);
                    break;
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Left))
            {
                switch(Move(EAST))
                {
                case 0:
                    break;
                case 1:
                    RandomEncounter();
                    break;
                case 2:
                    Encounter(-1, 0);
                    break;
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::C))
            {
                CharacterScreen Screen(Player, Window);
                Screen.MainLoop();
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::S))
            {
                SaveMap(PathToMap);
                SavePlayer();
            }
        }
        Window.clear();
        DrawAll();
        Window.display();
    }
}
void EditorScreen::DrawToolBar(sf::RenderWindow &Window)
{
	sf::RectangleShape segmentShape;
	segmentShape.setPosition(0, 0);
	sf::Vector2<float> segmentSize(1280, 40);
	segmentShape.setSize(segmentSize);
	segmentShape.setFillColor(sf::Color(0,0,0,180));
	Window.draw(segmentShape);

	sf::Sprite toolbarSpacer;
	toolbarSpacer.setTexture(toolbarIconsTex);
	toolbarSpacer.setTextureRect(sf::Rect<int>(0, 2, 2, 30));

	int x = 5;

	if (DrawButton(Window, x, 5 , 0)) // New Map
		ResetMap();

	x = x + 35;
	if (DrawButton(Window, x, 5 , 2)) // Save Map
		SaveMap();

	x = x + 35;
	if (DrawButton(Window, x, 5 , 1)) // Load Map
		LoadMap();

	x = x + 35;
	if (DrawButton(Window, x, 5 , 3)) // Layer change
	{
		layerPane->minimized = !layerPane->minimized;
	}

	/*x = x + 35;
	if (DrawButton(Window, x, 5 , 4)) // Zoom out
	{
		map->zoomScale -= 0.05f;
		if (map->zoomScale < 0.1f) map->zoomScale = 0.1f;
	}

	x = x + 35;
	if (DrawButton(Window, x, 5 , 5)) // Zoom in
	{
		map->zoomScale += 0.05;
		if (map->zoomScale > 2.0f) map->zoomScale = 2.0f;
	}*/

	x = x + 40;
	toolbarSpacer.setPosition(x, 5);
	Window.draw(toolbarSpacer, sf::RenderStates::Default);
	
	x = x + 10;
	if (DrawButton(Window, x, 5 , 6)) // Segment drawing mode
	{
		drawingMode = (drawingMode_t)SEGMENT_SELECTION;
		ledgePane->minimized = true;
	}

	x = x + 35;
	if (DrawButton(Window, x, 5 , 7)) // Ledge drawing mode
	{
		drawingMode = (drawingMode_t)LEDGES;
		segmentPane->minimized = true;
		ledgePane->minimized = false;
	}

	x = x + 35;
	if (DrawButton(Window, x, 5 , 8)) // Collision drawing mode
	{
		
	}

	x = x + 40;
	toolbarSpacer.setPosition(x, 5);
	Window.draw(toolbarSpacer, sf::RenderStates::Default);

	x = x + 10;
	if (DrawButton(Window, x, 5 , 9)) // Test map
	{
		PlayTestScreen *screen = new PlayTestScreen;
		screen->SetMapData(map);
		ScreenManager::GetInstance().AddScreen(screen);
	}

}
Exemple #19
0
int CMapFileIO::SaveMap(const CLevelMap &map) const
{
	return SaveMap(map, m_fname);
}