2014-10-15 19:14:34 +00:00
|
|
|
|
/*
|
|
|
|
|
* This file is part of the Colobot: Gold Edition source code
|
|
|
|
|
* Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
|
|
|
|
|
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see http://gnu.org/licenses
|
|
|
|
|
*/
|
2014-09-24 20:54:26 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \file object/level/parser.h
|
|
|
|
|
* \brief Parser for level files
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "object/level/parserline.h"
|
|
|
|
|
#include "object/level/parserparam.h"
|
|
|
|
|
#include "object/level/parserexceptions.h"
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
2015-06-21 18:59:23 +00:00
|
|
|
|
#include <memory>
|
2014-09-24 20:54:26 +00:00
|
|
|
|
|
|
|
|
|
class CLevelParser
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
//! Create an empty level file
|
|
|
|
|
CLevelParser();
|
|
|
|
|
//! Load level from file
|
|
|
|
|
CLevelParser(std::string filename);
|
|
|
|
|
//! Load given level
|
|
|
|
|
CLevelParser(std::string category, int chapter, int rank);
|
2015-06-21 18:59:23 +00:00
|
|
|
|
|
2015-03-22 12:51:14 +00:00
|
|
|
|
//! Build category path
|
|
|
|
|
static std::string BuildCategoryPath(std::string category);
|
2014-09-24 20:54:26 +00:00
|
|
|
|
//! Build level filename
|
2015-03-22 12:51:14 +00:00
|
|
|
|
static std::string BuildScenePath(std::string category, int chapter, int rank, bool sceneFile = true);
|
2015-06-21 18:59:23 +00:00
|
|
|
|
|
2014-10-25 10:01:21 +00:00
|
|
|
|
//! Check if level file exists
|
|
|
|
|
bool Exists();
|
2014-09-24 20:54:26 +00:00
|
|
|
|
//! Load file
|
|
|
|
|
void Load();
|
|
|
|
|
//! Save file
|
2014-11-10 10:41:05 +00:00
|
|
|
|
void Save();
|
2015-06-21 18:59:23 +00:00
|
|
|
|
|
2014-09-24 20:54:26 +00:00
|
|
|
|
//! Get filename
|
|
|
|
|
const std::string& GetFilename();
|
2015-06-21 18:59:23 +00:00
|
|
|
|
|
2014-09-24 20:54:26 +00:00
|
|
|
|
//! Get all lines from file
|
2015-06-21 18:59:23 +00:00
|
|
|
|
inline const std::vector<CLevelParserLineUPtr>& GetLines()
|
|
|
|
|
{
|
|
|
|
|
return m_lines;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-24 20:54:26 +00:00
|
|
|
|
//! Insert new line to file
|
2015-06-21 18:59:23 +00:00
|
|
|
|
void AddLine(CLevelParserLineUPtr line);
|
|
|
|
|
|
2014-09-24 20:54:26 +00:00
|
|
|
|
//! Find first line with given command
|
|
|
|
|
CLevelParserLine* Get(std::string command);
|
2015-06-21 18:59:23 +00:00
|
|
|
|
|
2014-09-24 20:54:26 +00:00
|
|
|
|
private:
|
|
|
|
|
std::string m_filename;
|
2015-06-21 18:59:23 +00:00
|
|
|
|
std::vector<CLevelParserLineUPtr> m_lines;
|
|
|
|
|
};
|