1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:07:45 +00:00

Pong: Port to LibMain

Simplified two pledge() and two unveil() by using TRY().
This commit is contained in:
Pedro Pereira 2021-11-23 10:40:23 +00:00 committed by Andreas Kling
parent 3ca2f192af
commit d68196969d
2 changed files with 9 additions and 21 deletions

View file

@ -10,4 +10,4 @@ set(SOURCES
) )
serenity_app(Pong ICON app-pong) serenity_app(Pong ICON app-pong)
target_link_libraries(Pong LibGUI) target_link_libraries(Pong LibGUI LibMain)

View file

@ -5,37 +5,25 @@
*/ */
#include "Game.h" #include "Game.h"
#include <LibCore/System.h>
#include <LibGUI/Application.h> #include <LibGUI/Application.h>
#include <LibGUI/Icon.h> #include <LibGUI/Icon.h>
#include <LibGUI/Menu.h> #include <LibGUI/Menu.h>
#include <LibGUI/Menubar.h> #include <LibGUI/Menubar.h>
#include <LibGUI/Window.h> #include <LibGUI/Window.h>
#include <LibGfx/Bitmap.h> #include <LibGfx/Bitmap.h>
#include <unistd.h> #include <LibMain/Main.h>
int main(int argc, char** argv) ErrorOr<int> serenity_main(Main::Arguments arguments)
{ {
if (pledge("stdio rpath recvfd sendfd unix", nullptr) < 0) { TRY(Core::System::pledge("stdio rpath recvfd sendfd unix", nullptr));
perror("pledge");
return 1;
}
auto app = GUI::Application::construct(argc, argv); auto app = GUI::Application::construct(arguments);
if (pledge("stdio rpath recvfd sendfd", nullptr) < 0) { TRY(Core::System::pledge("stdio rpath recvfd sendfd", nullptr));
perror("pledge");
return 1;
}
if (unveil("/res", "r") < 0) { TRY(Core::System::unveil("/res", "r"));
perror("unveil"); TRY(Core::System::unveil(nullptr, nullptr));
return 1;
}
if (unveil(nullptr, nullptr) < 0) {
perror("unveil");
return 1;
}
auto window = GUI::Window::construct(); auto window = GUI::Window::construct();
window->resize(Pong::Game::game_width, Pong::Game::game_height); window->resize(Pong::Game::game_width, Pong::Game::game_height);