Skip to content

Commit

Permalink
GH-345 Add landing page to main view
Browse files Browse the repository at this point in the history
  • Loading branch information
Naros committed May 11, 2024
1 parent 9ab48ea commit cbd5444
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "editor.h"

#include "about_dialog.h"
#include "editor/getting_started.h"
#include "editor/graph/actions/action_menu.h"
#include "editor/graph/actions/default_action_registrar.h"
#include "editor/graph/graph_edit.h"
Expand Down Expand Up @@ -70,6 +71,7 @@ void register_editor_classes()
ORCHESTRATOR_REGISTER_INTERNAL_CLASS(OrchestratorScreenSelect)
ORCHESTRATOR_REGISTER_INTERNAL_CLASS(OrchestratorWindowWrapper)
ORCHESTRATOR_REGISTER_INTERNAL_CLASS(OrchestratorMainView)
ORCHESTRATOR_REGISTER_INTERNAL_CLASS(OrchestratorGettingStarted)
ORCHESTRATOR_REGISTER_INTERNAL_CLASS(OrchestratorScriptConnectionsDialog)
ORCHESTRATOR_REGISTER_INTERNAL_CLASS(OrchestratorScriptView)
ORCHESTRATOR_REGISTER_INTERNAL_CLASS(OrchestratorScriptViewSection)
Expand Down
83 changes: 83 additions & 0 deletions src/editor/getting_started.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// This file is part of the Godot Orchestrator project.
//
// Copyright (c) 2023-present Vahera Studios LLC and its contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "editor/getting_started.h"

#include "common/scene_utils.h"
#include "common/version.h"
#include "plugin/plugin.h"

#include <godot_cpp/classes/button.hpp>
#include <godot_cpp/classes/label.hpp>
#include <godot_cpp/classes/texture_rect.hpp>

void OrchestratorGettingStarted::_notification(int p_what)
{
if (p_what == NOTIFICATION_READY)
{
set_alignment(ALIGNMENT_CENTER);
set_anchors_preset(PRESET_FULL_RECT);

TextureRect* logo = memnew(TextureRect);
logo->set_custom_minimum_size(Vector2(128, 128));
logo->set_texture(OrchestratorPlugin::get_singleton()->get_plugin_icon_hires());
logo->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED);
logo->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE);
logo->set_h_size_flags(SIZE_SHRINK_CENTER);
add_child(logo);

Label* plugin_version = memnew(Label);
plugin_version->set_text(vformat("Godot %s - %s", VERSION_NAME, VERSION_FULL_BUILD));
plugin_version->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
plugin_version->add_theme_font_size_override("font_size", 24);
plugin_version->add_theme_color_override("font_shadow_color", Color(0, 0, 0, 1));
plugin_version->add_theme_constant_override("shadow_outline_size", 3);
add_child(plugin_version);

VBoxContainer* button_container = memnew(VBoxContainer);
button_container->set_h_size_flags(SIZE_SHRINK_CENTER);
button_container->set_custom_minimum_size(Vector2(256, 0));
add_child(button_container);

Button* create_new = memnew(Button);
create_new->set_button_icon(SceneUtils::get_editor_icon("ScriptCreateDialog"));
create_new->set_text("Create New Orchestration");
create_new->set_focus_mode(FOCUS_NONE);
create_new->connect("pressed", callable_mp(this, &OrchestratorGettingStarted::_create_new));
button_container->add_child(create_new);

Button* open = memnew(Button);
open->set_button_icon(SceneUtils::get_editor_icon("Script"));
open->set_text("Open Orchestration");
open->set_focus_mode(FOCUS_NONE);
open->connect("pressed", callable_mp(this, &OrchestratorGettingStarted::_open));
button_container->add_child(open);

Button* open_docs = memnew(Button);
open_docs->set_button_icon(SceneUtils::get_editor_icon("ExternalLink"));
open_docs->set_text("Get Help");
open_docs->set_focus_mode(FOCUS_NONE);
open_docs->connect("pressed", callable_mp(this, &OrchestratorGettingStarted::_show_docs));
button_container->add_child(open_docs);
}
}

void OrchestratorGettingStarted::_bind_methods()
{
ADD_SIGNAL(MethodInfo("create_requested"));
ADD_SIGNAL(MethodInfo("open_requested"));
ADD_SIGNAL(MethodInfo("documentation_requested"));
}
42 changes: 42 additions & 0 deletions src/editor/getting_started.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// This file is part of the Godot Orchestrator project.
//
// Copyright (c) 2023-present Vahera Studios LLC and its contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef ORCHESTRATOR_GETTING_STARTED_H
#define ORCHESTRATOR_GETTING_STARTED_H

#include <godot_cpp/classes/v_box_container.hpp>

using namespace godot;

/// Simple landing page that is shown when the user has no open orchestrations
class OrchestratorGettingStarted : public VBoxContainer
{
GDCLASS(OrchestratorGettingStarted, VBoxContainer);
static void _bind_methods();

//~ Begin Signal Handlers
void _create_new() { emit_signal("create_requested"); }
void _open() { emit_signal("open_requested"); }
void _show_docs() { emit_signal("documentation_requested"); }
//~ End Signal Handlers

public:
//~ Begin Wrapped Interface
void _notification(int p_what);
//~ End Wrapped Interface
};

#endif
14 changes: 13 additions & 1 deletion src/editor/main_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "editor/graph/graph_edit.h"
#include "editor/updater.h"
#include "editor/window_wrapper.h"
#include "getting_started.h"
#include "plugin/plugin.h"
#include "plugin/settings.h"
#include "script/language.h"
Expand Down Expand Up @@ -236,8 +237,13 @@ void OrchestratorMainView::_notification(int p_what)

_script_editor_container = memnew(VBoxContainer);
_script_editor_container->set_v_size_flags(SIZE_EXPAND_FILL);
_script_editor_container->set_visible(false);

main_view_container->add_child(_script_editor_container);
_landing = memnew(OrchestratorGettingStarted);
main_view_container->add_child(_landing);
_landing->connect("create_requested", callable_mp(this, &OrchestratorMainView::_on_menu_option).bind(NEW));
_landing->connect("open_requested", callable_mp(this, &OrchestratorMainView::_on_menu_option).bind(OPEN));
_landing->connect("documentation_requested", callable_mp(this, &OrchestratorMainView::_on_menu_option).bind(ONLINE_DOCUMENTATION));

_about_window = memnew(OrchestratorAboutDialog);
add_child(_about_window);
Expand Down Expand Up @@ -425,6 +431,9 @@ void OrchestratorMainView::_open_script(const Ref<OScript>& p_script)
return;
}

_landing->hide();
_script_editor_container->show();

// Before we open the new file, an existing editors need to be hidden.
// Unlike GDScript, we don't use tabs but rather control which editor is visible manually.
for (const ScriptFile& file : _script_files)
Expand Down Expand Up @@ -520,6 +529,9 @@ void OrchestratorMainView::_close_script(int p_index, bool p_save)
{
// No more files are in the view.
_current_index = -1;

_script_editor_container->hide();
_landing->show();
}

_update_files_list();
Expand Down
2 changes: 2 additions & 0 deletions src/editor/main_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ using namespace godot;
/// Forward declarations
class OrchestratorPlugin;
class OScript;
class OrchestratorGettingStarted;
class OrchestratorScreenSelect;
class OrchestratorScriptView;
class OrchestratorWindowWrapper;
Expand Down Expand Up @@ -104,6 +105,7 @@ class OrchestratorMainView : public Control
Control* _select_separator{ nullptr }; //! Screen selection separator
OrchestratorScreenSelect* _select{ nullptr }; //! Screen selection
OrchestratorWindowWrapper* _wrapper{ nullptr }; //! Window wrapper
OrchestratorGettingStarted* _landing{ nullptr }; //! Landing page
PackedStringArray _recent_files; //! Recent files list

static void _bind_methods();
Expand Down

0 comments on commit cbd5444

Please sign in to comment.