1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 17:44:56 +09:00

Spider: Port to the GML compiler

This commit is contained in:
david072 2023-11-12 10:17:00 +01:00 committed by Sam Atkins
parent b7bcdf7c53
commit 65b9cb63ee
Notes: sideshowbarker 2024-07-17 05:58:46 +09:00
4 changed files with 29 additions and 9 deletions

View file

@ -4,15 +4,12 @@ serenity_component(
TARGETS Spider
)
stringify_gml(Spider.gml SpiderGML.h spider_gml)
compile_gml(Spider.gml SpiderGML.cpp spider_gml)
set(SOURCES
Game.cpp
main.cpp
)
set(GENERATED_SOURCES
SpiderGML.h
SpiderGML.cpp
)
serenity_app(Spider ICON app-spider)

View file

@ -0,0 +1,23 @@
/*
* Copyright (c) 2023, the SerenityOS developers
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGUI/Widget.h>
namespace Spider {
class MainWidget : public GUI::Widget {
C_OBJECT_ABSTRACT(MainWidget)
public:
static ErrorOr<NonnullRefPtr<Spider::MainWidget>> try_create();
virtual ~MainWidget() override = default;
private:
MainWidget() = default;
};
}

View file

@ -1,4 +1,4 @@
@GUI::Widget {
@Spider::MainWidget {
fill_with_background_color: true
layout: @GUI::VerticalBoxLayout {}

View file

@ -7,9 +7,9 @@
*/
#include "Game.h"
#include "MainWidget.h"
#include <AK/NumberFormat.h>
#include <AK/URL.h>
#include <Games/Spider/SpiderGML.h>
#include <LibConfig/Client.h>
#include <LibCore/System.h>
#include <LibCore/Timer.h>
@ -116,8 +116,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (statistic_display >= StatisticDisplay::__Count)
update_statistic_display(StatisticDisplay::HighScore);
auto widget = window->set_main_widget<GUI::Widget>();
TRY(widget->load_from_gml(spider_gml));
auto widget = TRY(Spider::MainWidget::try_create());
window->set_main_widget(widget);
auto& game = *widget->find_descendant_of_type_named<Spider::Game>("game");
game.set_focus(true);