MasterWord: Use GML compiler

This commit is contained in:
toadkarter 2023-09-24 22:45:31 +01:00 committed by Jelle Raaijmakers
parent 18124a5611
commit 4e2e2027c3
5 changed files with 29 additions and 11 deletions

View file

@ -4,15 +4,12 @@ serenity_component(
TARGETS MasterWord
)
stringify_gml(MasterWord.gml MasterWordGML.h master_word_gml)
compile_gml(MasterWord.gml MasterWordGML.cpp master_word_gml)
set(SOURCES
main.cpp
WordGame.cpp
)
set(GENERATED_SOURCES
MasterWordGML.h
MasterWordGML.cpp
)
serenity_app(MasterWord ICON app-masterword)

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 MasterWord {
class MainWidget : public GUI::Widget {
C_OBJECT_ABSTRACT(MainWidget)
public:
static ErrorOr<NonnullRefPtr<MainWidget>> try_create();
virtual ~MainWidget() override = default;
private:
MainWidget() = default;
};
}

View file

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

View file

@ -18,8 +18,6 @@
#include <LibGfx/Font/FontDatabase.h>
#include <LibGfx/Palette.h>
REGISTER_WIDGET(MasterWord, WordGame)
// TODO: Add stats
namespace MasterWord {

View file

@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "MainWidget.h"
#include "WordGame.h"
#include <AK/URL.h>
#include <Games/MasterWord/MasterWordGML.h>
#include <LibConfig/Client.h>
#include <LibCore/System.h>
#include <LibDesktop/Launcher.h>
@ -47,8 +47,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_resizable(false);
window->set_auto_shrink(true);
auto main_widget = window->set_main_widget<GUI::Widget>();
TRY(main_widget->load_from_gml(master_word_gml));
auto main_widget = TRY(MasterWord::MainWidget::try_create());
window->set_main_widget(main_widget);
auto& game = *main_widget->find_descendant_of_type_named<MasterWord::WordGame>("word_game");
auto& statusbar = *main_widget->find_descendant_of_type_named<GUI::Statusbar>("statusbar");
GUI::Application::the()->on_action_enter = [&statusbar](GUI::Action& action) {