mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:17:35 +00:00
Starfield: Port to LibMain
Simplified two pledge() by using TRY().
This commit is contained in:
parent
272f7c340e
commit
0ed3520ef5
2 changed files with 8 additions and 14 deletions
|
@ -8,4 +8,4 @@ set(SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_app(Starfield ICON app-screensaver)
|
serenity_app(Starfield ICON app-screensaver)
|
||||||
target_link_libraries(Starfield LibGUI LibCore LibGfx)
|
target_link_libraries(Starfield LibGUI LibCore LibGfx LibMain)
|
||||||
|
|
|
@ -13,9 +13,10 @@
|
||||||
#include <LibGUI/Widget.h>
|
#include <LibGUI/Widget.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
#include <LibGfx/Bitmap.h>
|
#include <LibGfx/Bitmap.h>
|
||||||
|
#include <LibMain/Main.h>
|
||||||
|
#include <LibSystem/Wrappers.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
struct Coordinate {
|
struct Coordinate {
|
||||||
int x;
|
int x;
|
||||||
|
@ -146,13 +147,9 @@ void Starfield::draw()
|
||||||
painter.fill_rect(m_bitmap->rect(), Color::Black);
|
painter.fill_rect(m_bitmap->rect(), Color::Black);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
|
TRY(System::pledge("stdio recvfd sendfd rpath unix", nullptr));
|
||||||
if (pledge("stdio recvfd sendfd rpath unix", nullptr) < 0) {
|
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned star_count = 1000;
|
unsigned star_count = 1000;
|
||||||
unsigned refresh_rate = 16;
|
unsigned refresh_rate = 16;
|
||||||
|
@ -163,14 +160,11 @@ int main(int argc, char** argv)
|
||||||
args_parser.add_option(star_count, "Number of stars to draw (default = 1000)", "stars", 'c', "number");
|
args_parser.add_option(star_count, "Number of stars to draw (default = 1000)", "stars", 'c', "number");
|
||||||
args_parser.add_option(refresh_rate, "Refresh rate (default = 16)", "rate", 'r', "milliseconds");
|
args_parser.add_option(refresh_rate, "Refresh rate (default = 16)", "rate", 'r', "milliseconds");
|
||||||
args_parser.add_option(speed, "Speed (default = 1)", "speed", 's', "number");
|
args_parser.add_option(speed, "Speed (default = 1)", "speed", 's', "number");
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(arguments.argc, arguments.argv);
|
||||||
|
|
||||||
auto app = GUI::Application::construct(argc, argv);
|
auto app = GUI::Application::construct(arguments.argc, arguments.argv);
|
||||||
|
|
||||||
if (pledge("stdio recvfd sendfd rpath", nullptr) < 0) {
|
TRY(System::pledge("stdio recvfd sendfd rpath", nullptr));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto app_icon = GUI::Icon::default_icon("app-screensaver");
|
auto app_icon = GUI::Icon::default_icon("app-screensaver");
|
||||||
auto window = GUI::Window::construct();
|
auto window = GUI::Window::construct();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue