1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:27:45 +00:00

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 TARGETS MasterWord
) )
stringify_gml(MasterWord.gml MasterWordGML.h master_word_gml) compile_gml(MasterWord.gml MasterWordGML.cpp master_word_gml)
set(SOURCES set(SOURCES
main.cpp main.cpp
WordGame.cpp WordGame.cpp
) MasterWordGML.cpp
set(GENERATED_SOURCES
MasterWordGML.h
) )
serenity_app(MasterWord ICON app-masterword) 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 fill_with_background_color: true
layout: @GUI::VerticalBoxLayout {} layout: @GUI::VerticalBoxLayout {}

View file

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

View file

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