From f8b7f7abd64993c8862426b66c38fba759e005de Mon Sep 17 00:00:00 2001 From: Danilo Date: Tue, 28 May 2024 14:43:56 -0300 Subject: [PATCH] Implementa bloco try/catch em Game --- framework/platform-dx/game.cpp | 17 +++++++++++------ samples/01_blank/xna.cpp | 5 +---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/framework/platform-dx/game.cpp b/framework/platform-dx/game.cpp index 8c544d6..442e2ff 100644 --- a/framework/platform-dx/game.cpp +++ b/framework/platform-dx/game.cpp @@ -68,14 +68,19 @@ namespace xna { } int Game::Run() { - Initialize(); + try { + Initialize(); - if (graphicsDevice == nullptr) { - MessageBox(nullptr, "O dispositivo gráfico não foi inicializado corretamente", "XN65", MB_OK); - return EXIT_FAILURE; + if (graphicsDevice == nullptr) { + MessageBox(nullptr, "O dispositivo gráfico não foi inicializado corretamente", "XN65", MB_OK); + return EXIT_FAILURE; + } + + return StartGameLoop(); } - - return StartGameLoop(); + catch (std::exception& e) { + MessageBox(nullptr, e.what(), "XN65", MB_OK); + } } void Game::Initialize() { diff --git a/samples/01_blank/xna.cpp b/samples/01_blank/xna.cpp index a613eb4..8affb70 100644 --- a/samples/01_blank/xna.cpp +++ b/samples/01_blank/xna.cpp @@ -25,10 +25,7 @@ namespace xna { } void LoadContent() override { - spriteBatch = New(*graphicsDevice); - - auto effect = Content()->Load("ExitReached"); - + spriteBatch = New(*graphicsDevice); Game::LoadContent(); }