mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:47:35 +00:00
Pong: Port to LibMain
Simplified two pledge() and two unveil() by using TRY().
This commit is contained in:
parent
3ca2f192af
commit
d68196969d
2 changed files with 9 additions and 21 deletions
|
@ -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)
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue