MasterWord: Use GML compiler
This commit is contained in:
parent
18124a5611
commit
4e2e2027c3
Notes:
sideshowbarker
2024-07-17 02:05:41 +09:00
Author: https://github.com/toadkarter 🔰 Commit: https://github.com/SerenityOS/serenity/commit/4e2e2027c3 Pull-request: https://github.com/SerenityOS/serenity/pull/21221 Reviewed-by: https://github.com/circl-lastname Reviewed-by: https://github.com/gmta ✅ Reviewed-by: https://github.com/kleinesfilmroellchen ✅
5 changed files with 29 additions and 11 deletions
|
@ -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)
|
||||
|
|
23
Userland/Games/MasterWord/MainWidget.h
Normal file
23
Userland/Games/MasterWord/MainWidget.h
Normal 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;
|
||||
};
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
@GUI::Widget {
|
||||
@MasterWord::MainWidget {
|
||||
fill_with_background_color: true
|
||||
layout: @GUI::VerticalBoxLayout {}
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
#include <LibGfx/Font/FontDatabase.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
|
||||
REGISTER_WIDGET(MasterWord, WordGame)
|
||||
|
||||
// TODO: Add stats
|
||||
namespace MasterWord {
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue