mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-17 20:10:23 +03:00
Options Logic Cleanup (#71)
* Output/Logging Overhaul * Added StandardOut class * Renamed LOGX macros to LOG_X * Removed LogMsg macros in favor of LOG_X * Added console window for debug Windows builds * Options Refactor * Moved options loading code from AppPlatform classes to Options class * Added AppPlatform::singleton() * Minecraft::m_options is now only accessible via Minecraft::getOptions() (as it should be) * Making this work with SDL2 next * Options Cleanup for SDL2 * Added AppPlatform::hasFileSystemAccess() * Options won't try to load if hasFileSystemAccess returns false. Emscripten build will be happy. --------- Co-authored-by: Brent Da Mage <BrentDaMage@users.noreply.github.com>
This commit is contained in:
@@ -176,47 +176,9 @@ Texture AppPlatform_windows::loadTexture(const std::string& str, bool b)
|
||||
return Texture(width, height, img2, 1, 0);
|
||||
}
|
||||
|
||||
std::vector<std::string> AppPlatform_windows::getOptionStrings()
|
||||
bool AppPlatform_windows::hasFileSystemAccess()
|
||||
{
|
||||
std::vector<std::string> o;
|
||||
|
||||
std::ifstream ifs("options.txt");
|
||||
if (!ifs.is_open())
|
||||
return o;
|
||||
|
||||
std::string str;
|
||||
while (true)
|
||||
{
|
||||
if (!std::getline(ifs, str, '\n'))
|
||||
break;
|
||||
|
||||
if (str.empty() || str[0] == '#')
|
||||
continue;
|
||||
|
||||
std::stringstream ss;
|
||||
ss << str;
|
||||
|
||||
std::string key, value;
|
||||
if (std::getline(ss, key, ':') && std::getline(ss, value))
|
||||
{
|
||||
o.push_back(key);
|
||||
o.push_back(value);
|
||||
}
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
void AppPlatform_windows::setOptionStrings(const std::vector<std::string>& str)
|
||||
{
|
||||
assert(str.size() % 2 == 0);
|
||||
|
||||
std::ofstream os("options.txt");
|
||||
|
||||
os << "#Config file for Minecraft PE. The # at the start denotes a comment, removing it makes it a command.\n\n";
|
||||
|
||||
for (int i = 0; i < int(str.size()); i += 2)
|
||||
os << str[i] << ':' << str[i + 1] << '\n';
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AppPlatform_windows::getPatchData()
|
||||
|
||||
Reference in New Issue
Block a user