| 1 |
#pragma once |
| 2 |
|
| 3 |
#include <string> |
| 4 |
#include <map> |
| 5 |
#include "wxutil/ModalProgressDialog.h" |
| 6 |
|
| 7 |
class FixupMap |
| 8 |
{ |
| 9 |
public: |
| 10 |
struct Result |
| 11 |
{ |
| 12 |
std::size_t replacedEntities; |
| 13 |
std::size_t replacedShaders; |
| 14 |
std::size_t replacedModels; |
| 15 |
std::size_t replacedMisc; |
| 16 |
|
| 17 |
// Errors, sorted by line |
| 18 |
typedef std::map<std::size_t, std::string> ErrorMap; |
| 19 |
ErrorMap errors; |
| 20 |
|
| 21 |
Result() : |
| 22 |
replacedEntities(0), |
| 23 |
replacedShaders(0), |
| 24 |
replacedModels(0), |
| 25 |
replacedMisc(0) |
| 26 |
{} |
| 27 |
}; |
| 28 |
|
| 29 |
private: |
| 30 |
// Path to fixup file |
| 31 |
std::string _filename; |
| 32 |
|
| 33 |
// Fixup contents |
| 34 |
std::string _contents; |
| 35 |
|
| 36 |
std::size_t _curLineNumber; |
| 37 |
|
| 38 |
Result _result; |
| 39 |
|
| 40 |
wxutil::ModalProgressDialog _progress; |
| 41 |
|
| 42 |
public: |
| 43 |
// Pass the fixup filename to the constructor |
| 44 |
FixupMap(const std::string& filename); |
| 45 |
|
| 46 |
// Run the fixup process |
| 47 |
Result perform(); |
| 48 |
|
| 49 |
private: |
| 50 |
void loadFixupFile(); |
| 51 |
void loadDeprecatedEntities(); |
| 52 |
|
| 53 |
void performFixup(const std::string& line); |
| 54 |
|
| 55 |
void replaceShader(const std::string& oldShader, const std::string& newShader); |
| 56 |
void replaceSpawnarg(const std::string& oldVal, const std::string& newVal); |
| 57 |
}; |