refactor: unglob std::wstring
This commit is contained in:
@@ -32,7 +32,7 @@ void DemoMode::tick()
|
||||
else if (day == 1)
|
||||
{
|
||||
Options *options = minecraft->options;
|
||||
wstring message;
|
||||
std::wstring message;
|
||||
|
||||
if (time == 100) {
|
||||
minecraft.gui.addMessage("Seed: " + minecraft.level.getSeed());
|
||||
|
||||
@@ -60,7 +60,7 @@ const Options::Option *Options::Option::getItem(int id)
|
||||
return &options[id];
|
||||
}
|
||||
|
||||
Options::Option::Option(const wstring& captionId, bool hasProgress, bool isBoolean) : _isProgress(hasProgress), _isBoolean(isBoolean), captionId(captionId)
|
||||
Options::Option::Option(const std::wstring& captionId, bool hasProgress, bool isBoolean) : _isProgress(hasProgress), _isBoolean(isBoolean), captionId(captionId)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -79,29 +79,29 @@ int Options::Option::getId() const
|
||||
return (int)(this-options);
|
||||
}
|
||||
|
||||
wstring Options::Option::getCaptionId() const
|
||||
std::wstring Options::Option::getCaptionId() const
|
||||
{
|
||||
return captionId;
|
||||
}
|
||||
|
||||
const wstring Options::RENDER_DISTANCE_NAMES[] =
|
||||
const std::wstring Options::RENDER_DISTANCE_NAMES[] =
|
||||
{
|
||||
L"options.renderDistance.far", L"options.renderDistance.normal", L"options.renderDistance.short", L"options.renderDistance.tiny"
|
||||
};
|
||||
const wstring Options::DIFFICULTY_NAMES[] =
|
||||
const std::wstring Options::DIFFICULTY_NAMES[] =
|
||||
{
|
||||
L"options.difficulty.peaceful", L"options.difficulty.easy", L"options.difficulty.normal", L"options.difficulty.hard"
|
||||
};
|
||||
const wstring Options::GUI_SCALE[] =
|
||||
const std::wstring Options::GUI_SCALE[] =
|
||||
{
|
||||
L"options.guiScale.auto", L"options.guiScale.small", L"options.guiScale.normal", L"options.guiScale.large"
|
||||
};
|
||||
const wstring Options::FRAMERATE_LIMITS[] =
|
||||
const std::wstring Options::FRAMERATE_LIMITS[] =
|
||||
{
|
||||
L"performance.max", L"performance.balanced", L"performance.powersaver"
|
||||
};
|
||||
|
||||
const wstring Options::PARTICLES[] = {
|
||||
const std::wstring Options::PARTICLES[] = {
|
||||
L"options.particles.all", L"options.particles.decreased", L"options.particles.minimal"
|
||||
};
|
||||
|
||||
@@ -184,13 +184,13 @@ Options::Options()
|
||||
init();
|
||||
}
|
||||
|
||||
wstring Options::getKeyDescription(int i)
|
||||
std::wstring Options::getKeyDescription(int i)
|
||||
{
|
||||
Language *language = Language::getInstance();
|
||||
return language->getElement(keyMappings[i]->name);
|
||||
}
|
||||
|
||||
wstring Options::getKeyMessage(int i)
|
||||
std::wstring Options::getKeyMessage(int i)
|
||||
{
|
||||
int key = keyMappings[i]->key;
|
||||
if (key < 0) {
|
||||
@@ -307,12 +307,12 @@ bool Options::getBooleanValue(const Options::Option *item)
|
||||
return false;
|
||||
}
|
||||
|
||||
wstring Options::getMessage(const Options::Option *item)
|
||||
std::wstring Options::getMessage(const Options::Option *item)
|
||||
{
|
||||
// 4J TODO, should these wstrings append rather than add?
|
||||
// 4J TODO, should these std::wstrings append rather than add?
|
||||
|
||||
Language *language = Language::getInstance();
|
||||
wstring caption = language->getElement(item->getCaptionId()) + L": ";
|
||||
std::wstring caption = language->getElement(item->getCaptionId()) + L": ";
|
||||
|
||||
if (item->isProgress())
|
||||
{
|
||||
@@ -411,14 +411,14 @@ void Options::load()
|
||||
// 4J - was new BufferedReader(new FileReader(optionsFile));
|
||||
BufferedReader *br = new BufferedReader(new InputStreamReader( new FileInputStream( optionsFile ) ) );
|
||||
|
||||
wstring line = L"";
|
||||
std::wstring line = L"";
|
||||
while ((line = br->readLine()) != L"") // 4J - was check against NULL - do we need to distinguish between empty lines and a fail here?
|
||||
{
|
||||
// 4J - removed try/catch
|
||||
// try {
|
||||
wstring cmds[2];
|
||||
std::wstring cmds[2];
|
||||
int splitpos = (int)line.find(L":");
|
||||
if( splitpos == wstring::npos )
|
||||
if( splitpos == std::wstring::npos )
|
||||
{
|
||||
cmds[0] = line;
|
||||
cmds[1] = L"";
|
||||
@@ -469,7 +469,7 @@ void Options::load()
|
||||
|
||||
}
|
||||
|
||||
float Options::readFloat(wstring string)
|
||||
float Options::readFloat(std::wstring string)
|
||||
{
|
||||
if (string == L"true") return 1;
|
||||
if (string == L"false") return 0;
|
||||
@@ -488,20 +488,20 @@ void Options::save()
|
||||
|
||||
dos.writeChars(L"music:" + _toString<float>(music) + L"\n");
|
||||
dos.writeChars(L"sound:" + _toString<float>(sound) + L"\n");
|
||||
dos.writeChars(L"invertYMouse:" + wstring(invertYMouse ? L"true" : L"false") + L"\n");
|
||||
dos.writeChars(L"invertYMouse:" + std::wstring(invertYMouse ? L"true" : L"false") + L"\n");
|
||||
dos.writeChars(L"mouseSensitivity:" + _toString<float>(sensitivity));
|
||||
dos.writeChars(L"fov:" + _toString<float>(fov));
|
||||
dos.writeChars(L"gamma:" + _toString<float>(gamma));
|
||||
dos.writeChars(L"viewDistance:" + _toString<int>(viewDistance));
|
||||
dos.writeChars(L"guiScale:" + _toString<int>(guiScale));
|
||||
dos.writeChars(L"particles:" + _toString<int>(particles));
|
||||
dos.writeChars(L"bobView:" + wstring(bobView ? L"true" : L"false"));
|
||||
dos.writeChars(L"anaglyph3d:" + wstring(anaglyph3d ? L"true" : L"false"));
|
||||
dos.writeChars(L"advancedOpengl:" + wstring(advancedOpengl ? L"true" : L"false"));
|
||||
dos.writeChars(L"bobView:" + std::wstring(bobView ? L"true" : L"false"));
|
||||
dos.writeChars(L"anaglyph3d:" + std::wstring(anaglyph3d ? L"true" : L"false"));
|
||||
dos.writeChars(L"advancedOpengl:" + std::wstring(advancedOpengl ? L"true" : L"false"));
|
||||
dos.writeChars(L"fpsLimit:" + _toString<int>(framerateLimit));
|
||||
dos.writeChars(L"difficulty:" + _toString<int>(difficulty));
|
||||
dos.writeChars(L"fancyGraphics:" + wstring(fancyGraphics ? L"true" : L"false"));
|
||||
dos.writeChars(L"ao:" + wstring(ambientOcclusion ? L"true" : L"false"));
|
||||
dos.writeChars(L"fancyGraphics:" + std::wstring(fancyGraphics ? L"true" : L"false"));
|
||||
dos.writeChars(L"ao:" + std::wstring(ambientOcclusion ? L"true" : L"false"));
|
||||
dos.writeChars(L"clouds:" + _toString<bool>(renderClouds));
|
||||
dos.writeChars(L"skin:" + skin);
|
||||
dos.writeChars(L"lastServer:" + lastMpIp);
|
||||
|
||||
@@ -37,24 +37,24 @@ public:
|
||||
private:
|
||||
const bool _isProgress;
|
||||
const bool _isBoolean;
|
||||
const wstring captionId;
|
||||
const std::wstring captionId;
|
||||
|
||||
public:
|
||||
static const Option *getItem(int id);
|
||||
|
||||
Option(const wstring& captionId, bool hasProgress, bool isBoolean);
|
||||
Option(const std::wstring& captionId, bool hasProgress, bool isBoolean);
|
||||
bool isProgress() const;
|
||||
bool isBoolean() const;
|
||||
int getId() const;
|
||||
wstring getCaptionId() const;
|
||||
std::wstring getCaptionId() const;
|
||||
};
|
||||
|
||||
private:
|
||||
static const wstring RENDER_DISTANCE_NAMES[];
|
||||
static const wstring DIFFICULTY_NAMES[];
|
||||
static const wstring GUI_SCALE[];
|
||||
static const wstring FRAMERATE_LIMITS[];
|
||||
static const wstring PARTICLES[];
|
||||
static const std::wstring RENDER_DISTANCE_NAMES[];
|
||||
static const std::wstring DIFFICULTY_NAMES[];
|
||||
static const std::wstring GUI_SCALE[];
|
||||
static const std::wstring FRAMERATE_LIMITS[];
|
||||
static const std::wstring PARTICLES[];
|
||||
|
||||
public:
|
||||
float music;
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
bool fancyGraphics;
|
||||
bool ambientOcclusion;
|
||||
bool renderClouds;
|
||||
wstring skin;
|
||||
std::wstring skin;
|
||||
|
||||
KeyMapping *keyUp;
|
||||
KeyMapping *keyLeft;
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
bool hideGui;
|
||||
bool thirdPersonView;
|
||||
bool renderDebug;
|
||||
wstring lastMpIp;
|
||||
std::wstring lastMpIp;
|
||||
|
||||
bool isFlying;
|
||||
bool smoothCamera;
|
||||
@@ -114,17 +114,17 @@ public:
|
||||
void init(); // 4J added
|
||||
Options(Minecraft *minecraft, File workingDirectory);
|
||||
Options();
|
||||
wstring getKeyDescription(int i);
|
||||
wstring getKeyMessage(int i);
|
||||
std::wstring getKeyDescription(int i);
|
||||
std::wstring getKeyMessage(int i);
|
||||
void setKey(int i, int key);
|
||||
void set(const Options::Option *item, float value);
|
||||
void toggle(const Options::Option *option, int dir);
|
||||
float getProgressValue(const Options::Option *item);
|
||||
bool getBooleanValue(const Options::Option *item);
|
||||
wstring getMessage(const Options::Option *item);
|
||||
std::wstring getMessage(const Options::Option *item);
|
||||
void load();
|
||||
private:
|
||||
float readFloat(wstring string);
|
||||
float readFloat(std::wstring string);
|
||||
public:
|
||||
void save();
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ void Settings::saveProperties()
|
||||
{
|
||||
}
|
||||
|
||||
wstring Settings::getString(const wstring& key, const wstring& defaultValue)
|
||||
std::wstring Settings::getString(const std::wstring& key, const std::wstring& defaultValue)
|
||||
{
|
||||
if(properties.find(key) == properties.end())
|
||||
{
|
||||
@@ -25,7 +25,7 @@ wstring Settings::getString(const wstring& key, const wstring& defaultValue)
|
||||
return properties[key];
|
||||
}
|
||||
|
||||
int Settings::getInt(const wstring& key, int defaultValue)
|
||||
int Settings::getInt(const std::wstring& key, int defaultValue)
|
||||
{
|
||||
if(properties.find(key) == properties.end())
|
||||
{
|
||||
@@ -35,7 +35,7 @@ int Settings::getInt(const wstring& key, int defaultValue)
|
||||
return _fromString<int>(properties[key]);
|
||||
}
|
||||
|
||||
bool Settings::getBoolean(const wstring& key, bool defaultValue)
|
||||
bool Settings::getBoolean(const std::wstring& key, bool defaultValue)
|
||||
{
|
||||
if(properties.find(key) == properties.end())
|
||||
{
|
||||
@@ -48,7 +48,7 @@ bool Settings::getBoolean(const wstring& key, bool defaultValue)
|
||||
return retval;
|
||||
}
|
||||
|
||||
void Settings::setBooleanAndSave(const wstring& key, bool value)
|
||||
void Settings::setBooleanAndSave(const std::wstring& key, bool value)
|
||||
{
|
||||
properties[key] = _toString<bool>(value);
|
||||
saveProperties();
|
||||
|
||||
@@ -7,15 +7,15 @@ class Settings
|
||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||
// private Properties properties = new Properties();
|
||||
private:
|
||||
std::unordered_map<wstring,wstring> properties; // 4J - TODO was Properties type, will need to implement something we can serialise/deserialise too
|
||||
std::unordered_map<std::wstring,std::wstring> properties; // 4J - TODO was Properties type, will need to implement something we can serialise/deserialise too
|
||||
//File *file;
|
||||
|
||||
public:
|
||||
Settings(File *file);
|
||||
void generateNewProperties();
|
||||
void saveProperties();
|
||||
wstring getString(const wstring& key, const wstring& defaultValue);
|
||||
int getInt(const wstring& key, int defaultValue);
|
||||
bool getBoolean(const wstring& key, bool defaultValue);
|
||||
void setBooleanAndSave(const wstring& key, bool value);
|
||||
std::wstring getString(const std::wstring& key, const std::wstring& defaultValue);
|
||||
int getInt(const std::wstring& key, int defaultValue);
|
||||
bool getBoolean(const std::wstring& key, bool defaultValue);
|
||||
void setBooleanAndSave(const std::wstring& key, bool value);
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ private:
|
||||
public:
|
||||
StatsSyncher(User *user, StatsCounter *statsCounter, File *dir);
|
||||
private:
|
||||
void attemptRename(File *dir, const wstring& name, File *to);
|
||||
void attemptRename(File *dir, const std::wstring& name, File *to);
|
||||
std::unordered_map<Stat *, int> *loadStatsFromDisk(File *file, File *tmp, File *old);
|
||||
std::unordered_map<Stat *, int> *loadStatsFromDisk(File *file);
|
||||
void doSend(std::unordered_map<Stat *, int> *stats);
|
||||
|
||||
Reference in New Issue
Block a user