mirror of
https://github.com/celisej567/mcpe.git
synced 2025-12-31 17:49:17 +03:00
* Add writeable configuration.
This commit is contained in:
@@ -209,6 +209,18 @@ std::vector<std::string> AppPlatform_windows::getOptionStrings()
|
||||
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';
|
||||
}
|
||||
|
||||
void AppPlatform_windows::setScreenSize(int width, int height)
|
||||
{
|
||||
m_ScreenWidth = width;
|
||||
|
||||
@@ -47,6 +47,9 @@ public:
|
||||
// Also add these to allow proper text input within the game.
|
||||
bool shiftPressed() override;
|
||||
void setShiftPressed(bool b);
|
||||
|
||||
// Also add these to allow saving options.
|
||||
void setOptionStrings(const std::vector <std::string>& str) override;
|
||||
|
||||
void setScreenSize(int width, int height);
|
||||
|
||||
|
||||
@@ -276,6 +276,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLin
|
||||
}
|
||||
|
||||
_cleanup:
|
||||
g_pApp->saveOptions();
|
||||
|
||||
// disable OpenGL for the window
|
||||
DisableOpenGL(hWnd, hDC, hRC);
|
||||
|
||||
|
||||
@@ -122,3 +122,7 @@ bool AppPlatform::shiftPressed()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void AppPlatform::setOptionStrings(const std::vector<std::string>& vec)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
virtual void showDialog(eDialogType);
|
||||
virtual void uploadPlatformDependentData(int, void*);
|
||||
virtual Texture loadTexture(const std::string&, bool);
|
||||
virtual std::vector<std::string> getOptionStrings();
|
||||
virtual std::vector<std::string> getOptionStrings();
|
||||
|
||||
#ifndef ORIGINAL_CODE
|
||||
// Also add these to allow proper turning within the game.
|
||||
@@ -50,6 +50,8 @@ public:
|
||||
virtual void updateFocused(bool focused);
|
||||
// Also add this to allow proper text input within the game.
|
||||
virtual bool shiftPressed();
|
||||
// Also add this to allow option saving.
|
||||
virtual void setOptionStrings(const std::vector<std::string>& vec);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -152,6 +152,11 @@ void Minecraft::reloadOptions()
|
||||
m_pUser->field_0 = m_options.m_playerName;
|
||||
}
|
||||
|
||||
void Minecraft::saveOptions()
|
||||
{
|
||||
platform()->setOptionStrings(m_options.getOptionStrings());
|
||||
}
|
||||
|
||||
bool Minecraft::isLevelGenerated()
|
||||
{
|
||||
if (m_pLevel)
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
void tick();
|
||||
void tickInput();
|
||||
void reloadOptions();
|
||||
void saveOptions();
|
||||
void handleMouseClick(int type);
|
||||
void handleMouseDown(int type, bool b);
|
||||
bool isLevelGenerated();
|
||||
|
||||
@@ -133,7 +133,6 @@ bool Options::readBool(const std::string& str)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifndef ORIGINAL_CODE
|
||||
int Options::readInt(const std::string& str)
|
||||
{
|
||||
int f;
|
||||
@@ -143,7 +142,18 @@ int Options::readInt(const std::string& str)
|
||||
|
||||
return f;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string Options::saveBool(bool b)
|
||||
{
|
||||
return b ? "true" : "false";
|
||||
}
|
||||
|
||||
std::string Options::saveInt(int i)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << i;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void Options::update(const std::vector<std::string>& strings)
|
||||
{
|
||||
@@ -159,11 +169,25 @@ void Options::update(const std::vector<std::string>& strings)
|
||||
m_bFancyGraphics = readBool(value);
|
||||
else if (key == "mp_server_visible_default")
|
||||
m_bServerVisibleDefault = readBool(value);
|
||||
#ifndef ORIGINAL_CODE
|
||||
else if (key == "gfx_smoothlighting")
|
||||
Minecraft::useAmbientOcclusion = field_18 = readBool(value);
|
||||
else if (key == "gfx_viewdistance")
|
||||
field_10 = readInt(value);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> Options::getOptionStrings()
|
||||
{
|
||||
std::vector<std::string> vec;
|
||||
|
||||
#define SO(optname, value) do { vec.push_back(optname); vec.push_back(value); } while (0)
|
||||
|
||||
SO("mp_username", m_playerName);
|
||||
SO("ctrl_invertmouse", saveBool(m_bInvertMouse));
|
||||
SO("gfx_fancygraphics", saveBool(m_bFancyGraphics));
|
||||
SO("mp_server_visible_default", saveBool(m_bServerVisibleDefault));
|
||||
SO("gfx_smoothlighting", saveBool(field_18));
|
||||
SO("gfx_viewdistance", saveInt (field_10));
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
@@ -23,12 +23,13 @@ public:
|
||||
void save();
|
||||
std::string getMessage(const Options::Option&);
|
||||
void update(const std::vector<std::string>& string);
|
||||
std::vector<std::string> getOptionStrings();
|
||||
|
||||
public:
|
||||
static bool readBool(const std::string& str);
|
||||
#ifndef ORIGINAL_CODE
|
||||
static int readInt(const std::string& str);
|
||||
#endif
|
||||
static std::string saveBool(bool b);
|
||||
static std::string saveInt(int i);
|
||||
|
||||
public:
|
||||
enum KeyBindIndex
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
#Config file for Minecraft PE. The # at the start denotes a comment, removing it makes it a command.
|
||||
|
||||
# Multiplayer
|
||||
mp_username|ReMinecraftPE
|
||||
mp_server_visible_default|true
|
||||
|
||||
# Controls
|
||||
#ctrl_invertmouse|true
|
||||
|
||||
# Graphics Options
|
||||
ctrl_invertmouse|false
|
||||
gfx_fancygraphics|true
|
||||
gfx_smoothlighting|false
|
||||
mp_server_visible_default|true
|
||||
gfx_smoothlighting|true
|
||||
gfx_viewdistance|2
|
||||
#gfx_viewdistance|0
|
||||
|
||||
Reference in New Issue
Block a user