Skip to content

Commit

Permalink
Fixed fall trough when cancel file load
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiralynDev committed Jun 20, 2024
1 parent c96dede commit 31f0ec9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/filesystem/FilesystemFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ bool FileSystemFunctions::importFromFile(std::string& filename) { // move this/c

std::ifstream file;
file.open(filename);
if (!file.is_open()) {
return false;
}
std::string line;
int i = 0;
while (std::getline(file, line)) {
Expand Down
2 changes: 0 additions & 2 deletions src/menus/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ int RoomClass::mainMenu() {
}
if (it->first == "LoadGUIButton") {
std::string path = FileSystemFunctions::getSaveLocation();
std::cerr << path;
if(!FileSystemFunctions::importFromFile(path)) {
Rectangle rect = Rectangle{(float(GetScreenWidth()) / 2.0) - 200, (float(GetScreenHeight()) / 2.0) - 50, 400, 100};
BeginDrawing();
Expand All @@ -57,7 +56,6 @@ int RoomClass::mainMenu() {
WaitTime(2); // This is dumb, please fix
continue;
}
Room.setRoomID(1);
break;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/menus/MainRoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ int RoomClass::mainRoom() {

if (it->first == "SaveButton" && it->second.state == 2) {
std::string saveLocation = FileSystemFunctions::setSaveLocation();
if (saveLocation == "")
break;
FileSystemFunctions::exportToFile(rectangles[1], saveLocation);
}

Expand Down

0 comments on commit 31f0ec9

Please sign in to comment.