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
Notes: sideshowbarker 2024-07-18 00:46:54 +09:00
2 changed files with 9 additions and 21 deletions

View file

@ -10,4 +10,4 @@ set(SOURCES
)
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 <LibCore/System.h>
#include <LibGUI/Application.h>
#include <LibGUI/Icon.h>
#include <LibGUI/Menu.h>
#include <LibGUI/Menubar.h>
#include <LibGUI/Window.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) {
perror("pledge");
return 1;
}
TRY(Core::System::pledge("stdio rpath recvfd sendfd unix", nullptr));
auto app = GUI::Application::construct(argc, argv);
auto app = GUI::Application::construct(arguments);
if (pledge("stdio rpath recvfd sendfd", nullptr) < 0) {
perror("pledge");
return 1;
}
TRY(Core::System::pledge("stdio rpath recvfd sendfd", nullptr));
if (unveil("/res", "r") < 0) {
perror("unveil");
return 1;
}
if (unveil(nullptr, nullptr) < 0) {
perror("unveil");
return 1;
}
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto window = GUI::Window::construct();
window->resize(Pong::Game::game_width, Pong::Game::game_height);