I cant edit pathfile in Dialog Box in my program. What could be the cause of this?
Code: Select all
IGUIFileOpenDialog* dialog = (IGUIFileOpenDialog*)event.GUIEvent.Caller;
Code: Select all
IGUIFileOpenDialog* dialog = (IGUIFileOpenDialog*)event.GUIEvent.Caller;
Code: Select all
bool MyEventReceiver::OnEvent(const SEvent& event)
{
if (event.EventType == EET_GUI_EVENT)
{
switch (event.GUIEvent.EventType)
{
case EGET_FILE_CHOOSE_DIALOG_CANCELLED:
openDialog = nullptr;
openDialogState = openDialogStates::none;
break;
case EGET_FILE_SELECTED: // open dialog box
{
if (openDialogState == openDialogStates::load)
{
IGUIFileOpenDialog* dialog = (IGUIFileOpenDialog*)event.GUIEvent.Caller;
io::path extension;
core::getFileNameExtension(extension, dialog->getFileName());
extension.make_lower();
if (extension == ".hexmap")
{
hexMap->destroy();
hexMap->loadFromFile(stringc(dialog->getFileName()).c_str());
}
}
if (openDialogState == openDialogStates::save)
{
IGUIFileOpenDialog* dialog = (IGUIFileOpenDialog*)event.GUIEvent.Caller;
std::string filename = stringc(dialog->getFileName()).c_str();
io::path extension;
core::getFileNameExtension(extension, dialog->getFileName());
extension.make_lower();
if (extension != ".hexmap")
filename = filename + ".hexmap";
hexMap->saveAsFile(filename);
}
openDialogState = openDialogStates::none;
openDialog = nullptr;
}
break;
case EGET_MENU_ITEM_SELECTED: // main menu events
{
IGUIContextMenu* menu = (IGUIContextMenu*)event.GUIEvent.Caller;
s32 id = menu->getItemCommandId(menu->getSelectedItem());
switch (id)
{
case GUI_CREATEWORLD:
if (hexMap != nullptr)
hexMap->destroy();
hexMap->createEmpty(40, 40);
std::cout << "created new Empty world" << std::endl;
break;
case GUI_LOADWORLD:
openDialog = GUI->addFileOpenDialog(L"Please select a map file to open");
openDialogState = openDialogStates::load;
break;
case GUI_SAVEWORLD:
openDialog = GUI->addFileOpenDialog(L"Please select a map file to save");
openDialogState = openDialogStates::save;
break;
case GUI_GENERATEWORLD:
generateWorld();
break;
case GUI_TUTORIAL:
tutorial();
break;
case GUI_INFO:
info();
break;
} // switch(id)
}
break;
case EGET_BUTTON_CLICKED: // buttons: terrain etc ..
{
s32 buttonID = event.GUIEvent.Caller->getID();
switch (buttonID)
{
case BUTTON_DARKNESS:
brushTerrain = terrainType::darkness;
std::cout << "setted a darkness to paint" << std::endl;
break;
case BUTTON_BEACH:
brushTerrain = terrainType::beach;
std::cout << "setted a beach to paint" << std::endl;
break;
case BUTTON_LOWLANDS:
brushTerrain = terrainType::lowlands;
std::cout << "setted a grass to paint" << std::endl;
break;
case BUTTON_STEPS:
brushTerrain = terrainType::steps;
std::cout << "setted a steps to paint" << std::endl;
break;
case BUTTON_HIGHLANDS:
brushTerrain = terrainType::highlands;
std::cout << "setted a highlands to paint" << std::endl;
break;
case BUTTON_ROCKS:
brushTerrain = terrainType::rocks;
std::cout << "setted a rocks to paint" << std::endl;
break;
case BUTTON_SWAMP:
brushTerrain = terrainType::swamp;
std::cout << "setted a swamp to paint" << std::endl;
break;
case BUTTON_DESERT:
brushTerrain = terrainType::desert;
std::cout << "setted a desert to paint" << std::endl;
break;
case BUTTON_PERMAFROST:
brushTerrain = terrainType::permafrost;
std::cout << "setted a permafrost to paint" << std::endl;
break;
case BUTTON_INCREASE:
if (brushSize < maxBrushSize)
brushSize++;
break;
case BUTTON_DECREASE:
if (brushSize > 0)
brushSize--;
break;
case BUTTON_RISE:
if (brushHeight < maxBrushHeight)
brushHeight++;
break;
case BUTTON_FALL:
if (brushHeight > 0)
brushHeight--;
break;
} // buttonID
}
break;
default:
break;
}
}
if (event.EventType == irr::EET_MOUSE_INPUT_EVENT)
{
switch (event.MouseInput.Event)
{
case EMIE_LMOUSE_PRESSED_DOWN:
mousePress = true;
break;
case EMIE_LMOUSE_LEFT_UP:
mousePress = false;
break;
}
}
// Remember whether each key is down or up
if (event.EventType == irr::EET_KEY_INPUT_EVENT)
{
KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
return true;
}
return false;
}
bool MyEventReceiver::IsKeyDown(EKEY_CODE keyCode)
{
return KeyIsDown[keyCode];
}
Code: Select all
if (event.EventType == irr::EET_KEY_INPUT_EVENT)
{
KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
}
Code: Select all
// UPDATE
if (openDialog == nullptr)
{
if (receiver.IsKeyDown(irr::KEY_KEY_A))
cam_x -= cameraMovementSpeed;
if (receiver.IsKeyDown(irr::KEY_KEY_D))
cam_x += cameraMovementSpeed;
if (receiver.IsKeyDown(irr::KEY_KEY_W))
cam_z += cameraMovementSpeed;
if (receiver.IsKeyDown(irr::KEY_KEY_S))
cam_z -= cameraMovementSpeed;
}
[code]