use dialog instead of using toast when a rom is failed to load

This commit is contained in:
Ishan09811 2024-02-11 16:57:38 +05:30 committed by GitHub
parent f5d3cc9fbf
commit f37bd9363f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,6 +9,7 @@ import android.opengl.GLSurfaceView;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import com.panda3ds.pandroid.AlberDriver; import com.panda3ds.pandroid.AlberDriver;
import com.panda3ds.pandroid.data.SMDH; import com.panda3ds.pandroid.data.SMDH;
import com.panda3ds.pandroid.data.config.GlobalConfig; import com.panda3ds.pandroid.data.config.GlobalConfig;
@ -90,28 +91,29 @@ public class PandaGlRenderer implements GLSurfaceView.Renderer, ConsoleRenderer
AlberDriver.Initialize(); AlberDriver.Initialize();
AlberDriver.setShaderJitEnabled(GlobalConfig.get(GlobalConfig.KEY_SHADER_JIT)); AlberDriver.setShaderJitEnabled(GlobalConfig.get(GlobalConfig.KEY_SHADER_JIT));
// If loading the ROM failed, display an error message and early exit // If loading the ROM failed, display an error message and early exit
if (!AlberDriver.LoadRom(romPath)) { if (!AlberDriver.LoadRom(romPath)) {
// Get a handler that can be used to post to the main thread // Get a handler that can be used to post to the main thread
Handler mainHandler = new Handler(context.getMainLooper()); Handler mainHandler = new Handler(context.getMainLooper());
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
public void run() { public void run() {
Toast AlertDialog.Builder builder = new AlertDialog.Builder(context);
.makeText( builder.setTitle("Failed to load ROM")
context, "Failed to load ROM! Make sure it's a valid 3DS ROM and that storage permissions are configured properly.", .setMessage("Make sure it's a valid 3DS ROM and that storage permissions are configured properly.")
Toast.LENGTH_LONG .setPositiveButton("OK", null)
) .setCancelable(false)
.show(); .show();
} }
}; };
mainHandler.post(runnable); mainHandler.post(runnable);
GameMetadata game = GameUtils.getCurrentGame();
GameUtils.removeGame(game);
return;
}
GameMetadata game = GameUtils.getCurrentGame();
GameUtils.removeGame(game);
return;
}
// Load the SMDH // Load the SMDH
byte[] smdhData = AlberDriver.GetSmdh(); byte[] smdhData = AlberDriver.GetSmdh();