From 23789681687a331f2160a5320b76b2361a24488b Mon Sep 17 00:00:00 2001 From: Shlomi Date: Sun, 17 Sep 2023 22:21:09 +0300 Subject: [PATCH] Add basic 'Game' button in editor plugins Adds 'Game' in the editor. The buttons will show: "2D", "3D", "Script", "Game", "AssetLib" (in this order). --- editor/editor_node.cpp | 2 ++ editor/plugins/game_plugin.cpp | 47 +++++++++++++++++++++++++++ editor/plugins/game_plugin.h | 58 ++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 editor/plugins/game_plugin.cpp create mode 100644 editor/plugins/game_plugin.h diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index df58f93bf462..23dad012d960 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -138,6 +138,7 @@ #include "editor/plugins/dedicated_server_export_plugin.h" #include "editor/plugins/editor_preview_plugins.h" #include "editor/plugins/editor_resource_conversion_plugin.h" +#include "editor/plugins/game_plugin.h" #include "editor/plugins/gdextension_export_plugin.h" #include "editor/plugins/material_editor_plugin.h" #include "editor/plugins/mesh_library_editor_plugin.h" @@ -7749,6 +7750,7 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(CanvasItemEditorPlugin)); add_editor_plugin(memnew(Node3DEditorPlugin)); add_editor_plugin(memnew(ScriptEditorPlugin)); + add_editor_plugin(memnew(GamePlugin)); EditorAudioBuses *audio_bus_editor = EditorAudioBuses::register_editor(); diff --git a/editor/plugins/game_plugin.cpp b/editor/plugins/game_plugin.cpp new file mode 100644 index 000000000000..729b5f0c9034 --- /dev/null +++ b/editor/plugins/game_plugin.cpp @@ -0,0 +1,47 @@ +/**************************************************************************/ +/* game_plugin.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#include "game_plugin.h" + +Game::Game() { + +} + +Game::~Game() { + +} + +GamePlugin::GamePlugin() { + WARN_PRINT("GamePlugin: OK"); +} + +GamePlugin::~GamePlugin() { + +} \ No newline at end of file diff --git a/editor/plugins/game_plugin.h b/editor/plugins/game_plugin.h new file mode 100644 index 000000000000..84035e4918f1 --- /dev/null +++ b/editor/plugins/game_plugin.h @@ -0,0 +1,58 @@ +/**************************************************************************/ +/* game_plugin.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef GAME_PLUGIN_H +#define GAME_PLUGIN_H + +#include "editor/editor_plugin.h" +#include "scene/gui/panel_container.h" + +class Game : public PanelContainer { + GDCLASS(Game, PanelContainer); + +public: + Game(); + ~Game(); +}; + +class GamePlugin : public EditorPlugin { + GDCLASS(GamePlugin, EditorPlugin); + + Game *game = nullptr; + +public: + virtual String get_name() const override { return "Game"; } + bool has_main_screen() const override { return true; } + + GamePlugin(); + ~GamePlugin(); +}; + +#endif //GAME_PLUGIN_H