forked from Kolyah35/minecraft-pe-0.6.1
Fixes and enhancements from my MCPE repository. (https://github.com/mschiller890/mcpe64)
This commit is contained in:
@@ -230,7 +230,6 @@ SelectWorldScreen::SelectWorldScreen()
|
||||
bBack (3, "Back"),
|
||||
bWorldView(4, ""),
|
||||
worldsList(NULL),
|
||||
_state(_STATE_DEFAULT),
|
||||
_hasStartedLevel(false)
|
||||
{
|
||||
bDelete.active = false;
|
||||
@@ -244,17 +243,11 @@ SelectWorldScreen::~SelectWorldScreen()
|
||||
void SelectWorldScreen::buttonClicked(Button* button)
|
||||
{
|
||||
if (button->id == bCreate.id) {
|
||||
//minecraft->setScreen( new CreateWorldScreen() );
|
||||
//minecraft->locateMultiplayer();
|
||||
//minecraft->setScreen(new JoinGameScreen());
|
||||
|
||||
//minecraft->hostMultiplayer();
|
||||
//minecraft->setScreen(new ProgressScreen());
|
||||
|
||||
if (_state == _STATE_DEFAULT && !_hasStartedLevel) {
|
||||
minecraft->platform()->createUserInput(DialogDefinitions::DIALOG_CREATE_NEW_WORLD);
|
||||
_state = _STATE_CREATEWORLD;
|
||||
}
|
||||
// open in-game world-creation screen instead of using platform dialog
|
||||
if (!_hasStartedLevel) {
|
||||
std::string name = getUniqueLevelName("world");
|
||||
minecraft->setScreen(new SimpleChooseLevelScreen(name));
|
||||
}
|
||||
}
|
||||
if (button->id == bDelete.id) {
|
||||
if (isIndexValid(worldsList->selectedItem)) {
|
||||
@@ -294,70 +287,6 @@ static char ILLEGAL_FILE_CHARACTERS[] = {
|
||||
|
||||
void SelectWorldScreen::tick()
|
||||
{
|
||||
if (_state == _STATE_CREATEWORLD) {
|
||||
#if defined(RPI)
|
||||
std::string levelId = getUniqueLevelName("world");
|
||||
LevelSettings settings(getEpochTimeS(), GameType::Creative);
|
||||
minecraft->selectLevel(levelId, levelId, settings);
|
||||
minecraft->hostMultiplayer();
|
||||
minecraft->setScreen(new ProgressScreen());
|
||||
_hasStartedLevel = true;
|
||||
#elif defined(WIN32)
|
||||
std::string name = getUniqueLevelName("perf");
|
||||
minecraft->setScreen(new SimpleChooseLevelScreen(name));
|
||||
#else
|
||||
int status = minecraft->platform()->getUserInputStatus();
|
||||
if (status > -1) {
|
||||
if (status == 1) {
|
||||
StringVector sv = minecraft->platform()->getUserInput();
|
||||
|
||||
// Read the level name.
|
||||
// 1) Trim name 2) Remove all bad chars 3) Append '-' chars 'til the name is unique
|
||||
std::string levelName = Util::stringTrim(sv[0]);
|
||||
std::string levelId = levelName;
|
||||
|
||||
for (int i = 0; i < sizeof(ILLEGAL_FILE_CHARACTERS) / sizeof(char); ++i)
|
||||
levelId = Util::stringReplace(levelId, std::string(1, ILLEGAL_FILE_CHARACTERS[i]), "");
|
||||
if ((int)levelId.length() == 0) {
|
||||
levelId = "no_name";
|
||||
}
|
||||
levelId = getUniqueLevelName(levelId);
|
||||
|
||||
// Read the seed
|
||||
int seed = getEpochTimeS();
|
||||
if (sv.size() >= 2) {
|
||||
std::string seedString = Util::stringTrim(sv[1]);
|
||||
if (seedString.length() > 0) {
|
||||
int tmpSeed;
|
||||
// Try to read it as an integer
|
||||
if (sscanf(seedString.c_str(), "%d", &tmpSeed) > 0) {
|
||||
seed = tmpSeed;
|
||||
} // Hash the "seed"
|
||||
else {
|
||||
seed = Util::hashCode(seedString);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Read the game mode
|
||||
bool isCreative = true;
|
||||
if (sv.size() >= 3 && sv[2] == "survival")
|
||||
isCreative = false;
|
||||
|
||||
// Start a new level with the given name and seed
|
||||
LevelSettings settings(seed, isCreative? GameType::Creative : GameType::Survival);
|
||||
LOGI("Creating a level with id '%s', name '%s' and seed '%d'\n", levelId.c_str(), levelName.c_str(), seed);
|
||||
minecraft->selectLevel(levelId, levelName, settings);
|
||||
minecraft->hostMultiplayer();
|
||||
minecraft->setScreen(new ProgressScreen());
|
||||
_hasStartedLevel = true;
|
||||
}
|
||||
_state = _STATE_DEFAULT;
|
||||
}
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
worldsList->tick();
|
||||
|
||||
if (worldsList->hasPickedLevel) {
|
||||
|
||||
Reference in New Issue
Block a user