Cleanup tons of obsolete commented out code

Mostly in EditorNode, dropping some obsolete editor plugins and also a
cleanup of ProjectSettings/EditorSettings.
This commit is contained in:
Rémi Verschelde 2017-08-26 17:46:49 +02:00
parent dd7145b778
commit 565600e844
39 changed files with 338 additions and 4386 deletions

View file

@ -28,12 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_format_binary.h"
#include "image.h"
#include "io/file_access_compressed.h"
#include "io/marshalls.h"
#include "os/dir_access.h"
#include "project_settings.h"
#include "version.h"
#include "core/image.h"
#include "core/io/file_access_compressed.h"
#include "core/io/marshalls.h"
#include "core/os/dir_access.h"
#include "core/project_settings.h"
#include "core/version.h"
//#define print_bl(m_what) print_line(m_what)
#define print_bl(m_what)
@ -1798,7 +1800,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
}
ERR_FAIL_COND_V(err, err);
FileAccessRef _fref(f);
relative_paths = p_flags & ResourceSaver::FLAG_RELATIVE_PATHS;
skip_editor = p_flags & ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;
@ -1810,7 +1811,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
takeover_paths = false;
local_path = p_path.get_base_dir();
//bin_meta_idx = get_string_index("__bin_meta__"); //is often used, so create
_find_resources(p_resource, true);
@ -1836,7 +1836,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
return ERR_CANT_CREATE;
}
//f->store_32(saved_resources.size()+external_resources.size()); // load steps -not needed
save_unicode_string(p_resource->get_class());
uint64_t md_at = f->get_pos();
f->store_64(0); //offset to impoty metadata
@ -1875,7 +1874,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
f->store_32(strings.size()); //string table size
for (int i = 0; i < strings.size(); i++) {
//print_bl("saving string: "+strings[i]);
save_unicode_string(strings[i]);
}
@ -1944,9 +1942,8 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
}
Vector<uint64_t> ofs_table;
//int saved_idx=0;
//now actually save the resources
//now actually save the resources
for (List<ResourceData>::Element *E = resources.front(); E; E = E->next()) {
ResourceData &rd = E->get();

View file

@ -1228,7 +1228,6 @@ CodeTextEditor::CodeTextEditor() {
error->set_valign(Label::VALIGN_CENTER);
error->add_color_override("font_color", Color(1, 0.7, 0.6, 0.9));
error->set_h_size_flags(SIZE_EXPAND_FILL); //required for it to display, given now it's clipping contents, do not touch
//status_bar->add_spacer();
Label *line_txt = memnew(Label);
status_bar->add_child(line_txt);

File diff suppressed because it is too large Load diff

View file

@ -35,16 +35,35 @@
#include "editor/create_dialog.h"
#include "editor/editor_about.h"
#include "editor/editor_data.h"
#include "editor/editor_export.h"
#include "editor/editor_log.h"
#include "editor/editor_name_dialog.h"
#include "editor/editor_path.h"
#include "editor/editor_plugin.h"
#include "editor/editor_reimport_dialog.h"
#include "editor/editor_resource_preview.h"
#include "editor/editor_run.h"
#include "editor/editor_run_native.h"
#include "editor/editor_run_script.h"
#include "editor/editor_scale.h"
#include "editor/editor_sub_scene.h"
#include "editor/export_template_manager.h"
#include "editor/fileserver/editor_file_server.h"
#include "editor/filesystem_dock.h"
#include "editor/groups_editor.h"
#include "editor/import_dock.h"
#include "editor/node_dock.h"
#include "editor/pane_drag.h"
#include "editor/progress_dialog.h"
#include "editor/project_export.h"
#include "editor/project_settings_editor.h"
#include "editor/property_editor.h"
#include "editor/quick_open.h"
#include "editor/reparent_dialog.h"
#include "editor/run_settings_dialog.h"
#include "editor/scene_tree_dock.h"
#include "editor/scene_tree_editor.h"
#include "editor/script_create_dialog.h"
#include "editor/settings_config_dialog.h"
#include "scene/gui/center_container.h"
#include "scene/gui/control.h"
@ -56,38 +75,12 @@
#include "scene/gui/separator.h"
#include "scene/gui/split_container.h"
#include "scene/gui/tab_container.h"
#include "scene/gui/tabs.h"
#include "scene/gui/texture_progress.h"
#include "scene/gui/tool_button.h"
#include "scene/gui/tree.h"
#include "editor/pane_drag.h"
#include "editor/editor_log.h"
#include "editor/editor_run_script.h"
#include "editor/project_export.h"
#include "editor/project_settings_editor.h"
#include "editor/resources_dock.h"
#include "editor/run_settings_dialog.h"
#include "editor/scene_tree_dock.h"
#include "editor/script_create_dialog.h"
#include "editor/editor_name_dialog.h"
#include "editor/editor_plugin.h"
#include "editor/editor_run_native.h"
#include "editor/editor_sub_scene.h"
#include "editor/project_export.h"
#include "editor/quick_open.h"
#include "editor_export.h"
#include "editor_reimport_dialog.h"
#include "scene/gui/tabs.h"
#include "editor_resource_preview.h"
#include "fileserver/editor_file_server.h"
#include "scene/gui/viewport_container.h"
#include "progress_dialog.h"
#include "editor_scale.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@ -170,7 +163,6 @@ private:
RUN_SETTINGS,
RUN_PROJECT_MANAGER,
RUN_FILE_SERVER,
//RUN_DEPLOY_DUMB_CLIENTS,
RUN_LIVE_DEBUG,
RUN_DEBUG_COLLISONS,
RUN_DEBUG_NAVIGATION,
@ -181,7 +173,6 @@ private:
SETTINGS_UPDATE_SPINNER_HIDE,
SETTINGS_EXPORT_PREFERENCES,
SETTINGS_PREFERENCES,
SETTINGS_OPTIMIZED_PRESETS,
SETTINGS_LAYOUT_SAVE,
SETTINGS_LAYOUT_DELETE,
SETTINGS_LAYOUT_DEFAULT,
@ -189,9 +180,6 @@ private:
SETTINGS_PICK_MAIN_SCENE,
SETTINGS_TOGGLE_FULLSCREN,
SETTINGS_HELP,
SOURCES_REIMPORT,
DEPENDENCY_LOAD_CHANGED_IMAGES,
DEPENDENCY_UPDATE_IMPORTED,
SCENE_TAB_CLOSE,
HELP_CLASSES,
@ -209,11 +197,8 @@ private:
TOOL_MENU_BASE = 1000
};
//Node *edited_scene; //scene being edited
Viewport *scene_root; //root of the scene being edited
//Ref<ResourceImportMetadata> scene_import_metadata;
PanelContainer *scene_root_parent;
Control *theme_base;
Control *gui_base;
@ -247,7 +232,6 @@ private:
HBoxContainer *bottom_hb;
Control *vp_base;
PaneDrag *pd;
//PaneDrag *pd_anim;
CenterContainer *play_cc;
HBoxContainer *menu_hb;
@ -269,19 +253,16 @@ private:
ToolButton *play_custom_scene_button;
ToolButton *search_button;
TextureProgress *audio_vu;
//MenuButton *fileserver_menu;
RichTextLabel *load_errors;
AcceptDialog *load_error_dialog;
//Control *scene_root_base;
Ref<Theme> theme;
PopupMenu *recent_scenes;
Button *property_back;
Button *property_forward;
SceneTreeDock *scene_tree_dock;
//ResourcesDock *resources_dock;
PropertyEditor *property_editor;
NodeDock *node_dock;
ImportDock *import_dock;
@ -294,7 +275,6 @@ private:
CreateDialog *create_dialog;
//CallDialog *call_dialog;
ConfirmationDialog *confirmation;
ConfirmationDialog *save_confirmation;
ConfirmationDialog *import_confirmation;
@ -308,7 +288,6 @@ private:
PopupMenu *editor_layouts;
EditorNameDialog *layout_dialog;
//OptimizedPresetsDialog *optimized_presets;
EditorSettingsDialog *settings_config_dialog;
RunSettingsDialog *run_settings_dialog;
ProjectSettingsEditor *project_settings;
@ -343,8 +322,6 @@ private:
Vector<ToolButton *> main_editor_buttons;
Vector<EditorPlugin *> editor_table;
// EditorReImportDialog *reimport_dialog;
ProgressDialog *progress_dialog;
BackgroundProgress *progress_hb;
@ -402,7 +379,6 @@ private:
EditorData editor_data;
EditorRun editor_run;
EditorSelection *editor_selection;
// ProjectExport *project_export;
ProjectExportDialog *project_export;
EditorResourcePreview *resource_preview;
@ -434,7 +410,6 @@ private:
void _dialog_display_file_error(String p_file, Error p_error);
int current_option;
//void _animation_visibility_toggle();
void _resource_created();
void _resource_selected(const RES &p_res, const String &p_property = "");
void _menu_option(int p_option);
@ -450,7 +425,6 @@ private:
void _fs_changed();
void _sources_changed(bool p_exist);
void _imported(Node *p_node);
void _node_renamed();
void _editor_select_next();
@ -491,7 +465,6 @@ private:
void _update_recent_scenes();
void _open_recent_scene(int p_idx);
void _dropped_files(const Vector<String> &p_files, int p_screen);
//void _open_recent_scene_confirm();
String _recent_scene;
bool convert_old;
@ -502,8 +475,6 @@ private:
bool has_main_screen() const { return true; }
bool _find_editing_changed_scene(Node *p_from);
String import_reload_fn;
Set<FileDialog *> file_dialogs;
@ -580,7 +551,6 @@ private:
void _save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section);
void _load_docks_from_config(Ref<ConfigFile> p_layout, const String &p_section);
void _update_dock_slots_visibility();
void _update_top_menu_visibility();
void _update_layouts_menu();
void _layout_menu_option(int p_id);
@ -701,10 +671,6 @@ public:
static EditorLog *get_log() { return singleton->log; }
Control *get_viewport();
//void animation_editor_make_visible(bool p_visible);
//void hide_animation_player_editors();
//void animation_panel_make_visible(bool p_visible);
void set_edited_scene(Node *p_scene);
Node *get_edited_scene() { return editor_data.get_edited_scene_root(); }
@ -860,4 +826,4 @@ struct EditorProgressBG {
~EditorProgressBG() { EditorNode::progress_end_task_bg(task); }
};
#endif
#endif // EDITOR_NODE_H

View file

@ -29,23 +29,23 @@
/*************************************************************************/
#include "editor_settings.h"
#include "editor_node.h"
#include "io/compression.h"
#include "io/config_file.h"
#include "io/file_access_memory.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "io/translation_loader_po.h"
#include "os/dir_access.h"
#include "os/file_access.h"
#include "os/keyboard.h"
#include "os/os.h"
#include "project_settings.h"
#include "core/io/compression.h"
#include "core/io/config_file.h"
#include "core/io/file_access_memory.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/io/translation_loader_po.h"
#include "core/os/dir_access.h"
#include "core/os/file_access.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#include "core/version.h"
#include "editor/editor_node.h"
#include "editor/translations.gen.h"
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
#include "scene/main/viewport.h"
#include "translations.gen.h"
#include "version.h"
Ref<EditorSettings> EditorSettings::singleton = NULL;
@ -93,6 +93,7 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) {
emit_signal("settings_changed");
return true;
}
bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const {
_THREAD_SAFE_METHOD_
@ -272,7 +273,6 @@ void EditorSettings::create() {
String config_path;
String config_dir;
//String config_file="editor_settings.xml";
Ref<ConfigFile> extra_config = memnew(ConfigFile);
String exe_path = OS::get_singleton()->get_executable_path().get_base_dir();
@ -644,7 +644,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("text_editor/files/maximum_recent_files", 20);
hints["text_editor/files/maximum_recent_files"] = PropertyInfo(Variant::INT, "text_editor/files/maximum_recent_files", PROPERTY_HINT_RANGE, "1, 200, 0");
//set("docks/scene_tree/display_old_action_buttons",false);
set("docks/scene_tree/start_create_dialog_fully_expanded", false);
set("docks/scene_tree/draw_relationship_lines", false);
set("docks/scene_tree/relationship_line_color", Color::html("464646"));
@ -705,8 +704,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("filesystem/on_save/compress_binary_resources", true);
set("filesystem/on_save/save_modified_external_resources", true);
//set("filesystem/on_save/save_paths_as_relative",false);
//set("filesystem/on_save/save_paths_without_extension",false);
set("text_editor/tools/create_signal_callbacks", true);
@ -1151,7 +1148,6 @@ void EditorSettings::_bind_methods() {
EditorSettings::EditorSettings() {
//singleton=this;
last_order = 0;
optimize_save = true;
save_changed_setting = true;
@ -1181,8 +1177,6 @@ EditorSettings::EditorSettings() {
}
EditorSettings::~EditorSettings() {
//singleton=NULL;
}
Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path) {

View file

@ -2095,14 +2095,6 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
return p_node;
}
#if 0
Error EditorImport::import_scene(const String& p_path,const String& p_dest_path,const String& p_resource_path,uint32_t p_flags,ImageFormat p_image_format,ImageCompression p_image_compression,uint32_t p_image_flags,float p_quality,uint32_t animation_flags,Node **r_scene,Ref<EditorPostImport> p_post_import) {
}
#endif
void EditorSceneImportPlugin::_tag_import_paths(Node *p_scene,Node *p_node) {
if (p_scene!=p_node && p_node->get_owner()!=p_scene)

View file

@ -367,10 +367,6 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resou
int flg = 0;
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
flg |= ResourceSaver::FLAG_COMPRESS;
/*
if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
flg |= ResourceSaver::FLAG_RELATIVE_PATHS;
*/
String path = ProjectSettings::get_singleton()->localize_path(p_path);
Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
@ -380,7 +376,6 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resou
accept->popup_centered_minsize();
return;
}
//EditorFileSystem::get_singleton()->update_file(path,p_resource->get_type());
((Resource *)p_resource.ptr())->set_path(path);
editor->emit_signal("resource_saved", p_resource);

View file

@ -29,14 +29,13 @@
/*************************************************************************/
#include "editor_preview_plugins.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "io/file_access_memory.h"
#include "io/resource_loader.h"
#include "os/os.h"
#include "scene/resources/material.h"
//#include "scene/resources/sample.h"
#include "editor/editor_scale.h"
#include "scene/resources/bit_mask.h"
#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
bool EditorTexturePreviewPlugin::handles(const String &p_type) const {
@ -239,7 +238,6 @@ Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES &p_from) {
VS::get_singleton()->mesh_surface_set_material(sphere, 0, material->get_rid());
VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture
//print_line("queue capture!");
preview_done = false;
VS::get_singleton()->request_frame_drawn_callback(this, "_preview_done", Variant());
@ -454,9 +452,7 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES &p_from) {
while (_is_text_char(code[pos])) {
pos++;
}
///print_line("from "+itos(i)+" to "+itos(pos));
String word = code.substr(i, pos - i);
//print_line("found word: "+word);
if (keywords.has(word))
in_keyword = true;
@ -502,6 +498,8 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES &p_from) {
EditorScriptPreviewPlugin::EditorScriptPreviewPlugin() {
}
///////////////////////////////////////////////////////////////////
// FIXME: Needs to be rewritten for AudioStream in Godot 3.0+
#if 0
bool EditorSamplePreviewPlugin::handles(const String& p_type) const {
@ -766,10 +764,9 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) {
}
EditorSamplePreviewPlugin::EditorSamplePreviewPlugin() {
}
#endif
///////////////////////////////////////////////////////////////////////////
void EditorMeshPreviewPlugin::_preview_done(const Variant &p_udata) {
@ -788,14 +785,12 @@ bool EditorMeshPreviewPlugin::handles(const String &p_type) const {
Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from) {
print_line("**Generating for mesh finally??");
Ref<Mesh> mesh = p_from;
ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture>());
VS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid());
Rect3 aabb = mesh->get_aabb();
print_line("mesh aabb: " + aabb);
Vector3 ofs = aabb.position + aabb.size * 0.5;
aabb.position -= ofs;
Transform xform;
@ -807,14 +802,12 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from) {
return Ref<Texture>();
m = 1.0 / m;
m *= 0.5;
//print_line("scale: "+rtos(m));
xform.basis.scale(Vector3(m, m, m));
xform.origin = -xform.basis.xform(ofs); //-ofs*m;
xform.origin.z -= rot_aabb.size.z * 2;
VS::get_singleton()->instance_set_transform(mesh_instance, xform);
VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture
//print_line("queue capture!");
preview_done = false;
VS::get_singleton()->request_frame_drawn_callback(this, "_preview_done", Variant());
@ -826,7 +819,6 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from) {
Ref<Image> img = VS::get_singleton()->VS::get_singleton()->texture_get_data(viewport_texture);
ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>());
print_line("captured! " + itos(img->get_width()) + "x" + itos(img->get_height()));
VS::get_singleton()->instance_set_base(mesh_instance, RID());
int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");

View file

@ -97,6 +97,7 @@ public:
EditorScriptPreviewPlugin();
};
// FIXME: Needs to be rewritten for AudioStream in Godot 3.0+
#if 0
class EditorSamplePreviewPlugin : public EditorResourcePreviewGenerator {
public:
@ -106,8 +107,8 @@ public:
EditorSamplePreviewPlugin();
};
#endif
class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator {
GDCLASS(EditorMeshPreviewPlugin, EditorResourcePreviewGenerator)

View file

@ -27,12 +27,14 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
// FIXME: Disabled as (according to reduz) users were complaining that it gets in the way
// Waiting for PropertyEditor rewrite (planned for 3.1) to be refactored.
#if 0
#include "material_editor_plugin.h"
#include "scene/main/viewport.h"
#if 0
void MaterialEditor::_gui_input(InputEvent p_event) {

View file

@ -30,6 +30,10 @@
#ifndef MATERIAL_EDITOR_PLUGIN_H
#define MATERIAL_EDITOR_PLUGIN_H
// FIXME: Disabled as (according to reduz) users were complaining that it gets in the way
// Waiting for PropertyEditor rewrite (planned for 3.1) to be refactored.
#if 0
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/3d/camera.h"
@ -37,7 +41,6 @@
#include "scene/3d/mesh_instance.h"
#include "scene/resources/material.h"
#if 0
class MaterialEditor : public Control {
GDCLASS(MaterialEditor, Control);
@ -97,5 +100,5 @@ public:
};
#endif // MATERIAL_EDITOR_PLUGIN_H
#endif
#endif // MATERIAL_EDITOR_PLUGIN_H

View file

@ -1,151 +0,0 @@
/*************************************************************************/
/* rich_text_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* 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 "rich_text_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
#include "os/file_access.h"
void RichTextEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_FIXED_PROCESS: {
} break;
}
}
void RichTextEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = NULL;
hide();
}
}
void RichTextEditor::_file_selected(const String &p_path) {
CharString cs;
FileAccess *fa = FileAccess::open(p_path, FileAccess::READ);
if (!fa) {
ERR_FAIL();
}
while (!fa->eof_reached())
cs.push_back(fa->get_8());
cs.push_back(0);
memdelete(fa);
String bbcode;
bbcode.parse_utf8(&cs[0]);
node->parse_bbcode(bbcode);
}
void RichTextEditor::_menu_option(int p_option) {
switch (p_option) {
case PARSE_BBCODE: {
file_dialog->popup_centered_ratio();
} break;
case CLEAR: {
node->clear();
} break;
}
}
void RichTextEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_menu_option"), &RichTextEditor::_menu_option);
ClassDB::bind_method(D_METHOD("_file_selected"), &RichTextEditor::_file_selected);
}
void RichTextEditor::edit(Node *p_rich_text) {
node = Object::cast_to<RichTextLabel>(p_rich_text);
}
RichTextEditor::RichTextEditor() {
options = memnew(MenuButton);
//add_child(options);
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options);
options->set_area_as_parent_rect();
options->set_text("RichText");
options->get_popup()->add_item(TTR("Parse BBCode"), PARSE_BBCODE);
options->get_popup()->add_item(TTR("Clear"), CLEAR);
options->get_popup()->connect("id_pressed", this, "_menu_option");
file_dialog = memnew(EditorFileDialog);
add_child(file_dialog);
file_dialog->add_filter("*.txt");
file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
file_dialog->connect("file_selected", this, "_file_selected");
}
void RichTextEditorPlugin::edit(Object *p_object) {
rich_text_editor->edit(Object::cast_to<Node>(p_object));
}
bool RichTextEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("RichTextLabel");
}
void RichTextEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
rich_text_editor->options->show();
} else {
rich_text_editor->options->hide();
rich_text_editor->edit(NULL);
}
}
RichTextEditorPlugin::RichTextEditorPlugin(EditorNode *p_node) {
editor = p_node;
rich_text_editor = memnew(RichTextEditor);
editor->get_viewport()->add_child(rich_text_editor);
rich_text_editor->set_margin(MARGIN_LEFT, 184);
rich_text_editor->set_margin(MARGIN_RIGHT, 230);
rich_text_editor->set_margin(MARGIN_TOP, 0);
rich_text_editor->set_margin(MARGIN_BOTTOM, 10);
rich_text_editor->options->hide();
}
RichTextEditorPlugin::~RichTextEditorPlugin() {
}

View file

@ -1,90 +0,0 @@
/*************************************************************************/
/* rich_text_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* 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 RICH_TEXT_EDITOR_PLUGIN_H
#define RICH_TEXT_EDITOR_PLUGIN_H
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/gui/file_dialog.h"
#include "scene/gui/rich_text_label.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class RichTextEditor : public Control {
GDCLASS(RichTextEditor, Control);
friend class RichTextEditorPlugin;
enum {
PARSE_BBCODE,
CLEAR
};
Panel *panel;
MenuButton *options;
RichTextLabel *node;
EditorFileDialog *file_dialog;
void _file_selected(const String &p_path);
void _menu_option(int p_option);
protected:
void _notification(int p_what);
void _node_removed(Node *p_node);
static void _bind_methods();
public:
void edit(Node *p_rich_text);
RichTextEditor();
};
class RichTextEditorPlugin : public EditorPlugin {
GDCLASS(RichTextEditorPlugin, EditorPlugin);
RichTextEditor *rich_text_editor;
EditorNode *editor;
public:
virtual String get_name() const { return "RichText"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
RichTextEditorPlugin(EditorNode *p_node);
~RichTextEditorPlugin();
};
#endif // RICH_TEXT_EDITOR_PLUGIN_H

View file

@ -1,452 +0,0 @@
/*************************************************************************/
/* sample_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* 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 "sample_editor_plugin.h"
#if 0
#include "editor/editor_settings.h"
#include "io/resource_loader.h"
#include "project_settings.h"
void SampleEditor::_gui_input(InputEvent p_event) {
}
void SampleEditor::_notification(int p_what) {
if (p_what==NOTIFICATION_FIXED_PROCESS) {
}
if (p_what==NOTIFICATION_ENTER_TREE) {
play->set_icon( get_icon("Play","EditorIcons") );
stop->set_icon( get_icon("Stop","EditorIcons") );
}
if (p_what==NOTIFICATION_READY) {
//get_scene()->connect("node_removed",this,"_node_removed");
}
if (p_what==NOTIFICATION_DRAW) {
}
}
void SampleEditor::_play_pressed() {
player->play("default",true);
stop->set_pressed(false);
play->set_pressed(true);
}
void SampleEditor::_stop_pressed() {
player->stop_all();
play->set_pressed(false);
}
void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<ImageTexture> &p_texture) {
PoolVector<uint8_t> data = p_sample->get_data();
PoolVector<uint8_t> img;
int w = p_texture->get_width();
int h = p_texture->get_height();
img.resize(w*h*3);
PoolVector<uint8_t>::Write imgdata = img.write();
uint8_t * imgw = imgdata.ptr();
PoolVector<uint8_t>::Read sampledata = data.read();
const uint8_t *sdata=sampledata.ptr();
bool stereo = p_sample->is_stereo();
bool _16=p_sample->get_format()==Sample::FORMAT_PCM16;
int len = p_sample->get_length();
if (len<1)
return;
if (p_sample->get_format()==Sample::FORMAT_IMA_ADPCM) {
struct IMA_ADPCM_State {
int16_t step_index;
int32_t predictor;
/* values at loop point */
int16_t loop_step_index;
int32_t loop_predictor;
int32_t last_nibble;
int32_t loop_pos;
int32_t window_ofs;
const uint8_t *ptr;
} ima_adpcm;
ima_adpcm.step_index=0;
ima_adpcm.predictor=0;
ima_adpcm.loop_step_index=0;
ima_adpcm.loop_predictor=0;
ima_adpcm.last_nibble=-1;
ima_adpcm.loop_pos=0x7FFFFFFF;
ima_adpcm.window_ofs=0;
ima_adpcm.ptr=NULL;
for(int i=0;i<w;i++) {
float max[2]={-1e10,-1e10};
float min[2]={1e10,1e10};
int from = i*len/w;
int to = (i+1)*len/w;
if (to>=len)
to=len-1;
for(int j=from;j<to;j++) {
while(j>ima_adpcm.last_nibble) {
static const int16_t _ima_adpcm_step_table[89] = {
7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
};
static const int8_t _ima_adpcm_index_table[16] = {
-1, -1, -1, -1, 2, 4, 6, 8,
-1, -1, -1, -1, 2, 4, 6, 8
};
int16_t nibble,diff,step;
ima_adpcm.last_nibble++;
const uint8_t *src_ptr=sdata;
int ofs = ima_adpcm.last_nibble>>1;
if (stereo)
ofs*=2;
nibble = (ima_adpcm.last_nibble&1)?
(src_ptr[ofs]>>4):(src_ptr[ofs]&0xF);
step=_ima_adpcm_step_table[ima_adpcm.step_index];
ima_adpcm.step_index += _ima_adpcm_index_table[nibble];
if (ima_adpcm.step_index<0)
ima_adpcm.step_index=0;
if (ima_adpcm.step_index>88)
ima_adpcm.step_index=88;
diff = step >> 3 ;
if (nibble & 1)
diff += step >> 2 ;
if (nibble & 2)
diff += step >> 1 ;
if (nibble & 4)
diff += step ;
if (nibble & 8)
diff = -diff ;
ima_adpcm.predictor+=diff;
if (ima_adpcm.predictor<-0x8000)
ima_adpcm.predictor=-0x8000;
else if (ima_adpcm.predictor>0x7FFF)
ima_adpcm.predictor=0x7FFF;
/* store loop if there */
if (ima_adpcm.last_nibble==ima_adpcm.loop_pos) {
ima_adpcm.loop_step_index = ima_adpcm.step_index;
ima_adpcm.loop_predictor = ima_adpcm.predictor;
}
}
float v=ima_adpcm.predictor/32767.0;
if (v>max[0])
max[0]=v;
if (v<min[0])
min[0]=v;
}
for(int j=0;j<h;j++) {
float v = (j/(float)h) * 2.0 - 1.0;
uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3];
if (v>min[0] && v<max[0]) {
imgofs[0]=255;
imgofs[1]=150;
imgofs[2]=80;
} else {
imgofs[0]=0;
imgofs[1]=0;
imgofs[2]=0;
}
}
}
} else {
for(int i=0;i<w;i++) {
// i trust gcc will optimize this loop
float max[2]={-1e10,-1e10};
float min[2]={1e10,1e10};
int c=stereo?2:1;
int from = uint64_t(i)*len/w;
int to = (uint64_t(i)+1)*len/w;
if (to>=len)
to=len-1;
if (_16) {
const int16_t*src =(const int16_t*)sdata;
for(int j=0;j<c;j++) {
for(int k=from;k<=to;k++) {
float v = src[uint64_t(k)*c+j]/32768.0;
if (v>max[j])
max[j]=v;
if (v<min[j])
min[j]=v;
}
}
} else {
const int8_t*src =(const int8_t*)sdata;
for(int j=0;j<c;j++) {
for(int k=from;k<=to;k++) {
float v = src[uint64_t(k)*c+j]/128.0;
if (v>max[j])
max[j]=v;
if (v<min[j])
min[j]=v;
}
}
}
if (!stereo) {
for(int j=0;j<h;j++) {
float v = (j/(float)h) * 2.0 - 1.0;
uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3];
if (v>min[0] && v<max[0]) {
imgofs[0]=255;
imgofs[1]=150;
imgofs[2]=80;
} else {
imgofs[0]=0;
imgofs[1]=0;
imgofs[2]=0;
}
}
} else {
for(int j=0;j<h;j++) {
int half;
float v;
if (j<(h/2)) {
half=0;
v = (j/(float)(h/2)) * 2.0 - 1.0;
} else {
half=1;
v = ((j-(h/2))/(float)(h/2)) * 2.0 - 1.0;
}
uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3];
if (v>min[half] && v<max[half]) {
imgofs[0]=255;
imgofs[1]=150;
imgofs[2]=80;
} else {
imgofs[0]=0;
imgofs[1]=0;
imgofs[2]=0;
}
}
}
}
}
imgdata = PoolVector<uint8_t>::Write();
p_texture->set_data(Image(w,h,0,Image::FORMAT_RGB8,img));
}
void SampleEditor::_update_sample() {
player->stop_all();
generate_preview_texture(sample,peakdisplay);
info_label->set_text(TTR("Length:")+" "+String::num(sample->get_length()/(float)sample->get_mix_rate(),2)+"s");
if (library->has_sample("default"))
library->remove_sample("default");
library->add_sample("default",sample);
}
void SampleEditor::edit(Ref<Sample> p_sample) {
sample=p_sample;
if (!sample.is_null())
_update_sample();
else {
hide();
set_fixed_process(false);
}
}
void SampleEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"),&SampleEditor::_gui_input);
ClassDB::bind_method(D_METHOD("_play_pressed"),&SampleEditor::_play_pressed);
ClassDB::bind_method(D_METHOD("_stop_pressed"),&SampleEditor::_stop_pressed);
}
SampleEditor::SampleEditor() {
player = memnew(SamplePlayer);
add_child(player);
add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel","Panel"));
library = Ref<SampleLibrary>(memnew(SampleLibrary));
player->set_sample_library(library);
sample_texframe = memnew( TextureRect );
add_child(sample_texframe);
sample_texframe->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
sample_texframe->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,-5);
sample_texframe->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,30);
sample_texframe->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,-5);
info_label = memnew( Label );
sample_texframe->add_child(info_label);
info_label->set_area_as_parent_rect();
info_label->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,-15);
info_label->set_margin(MARGIN_BOTTOM,-4);
info_label->set_margin(MARGIN_RIGHT,-4);
info_label->set_align(Label::ALIGN_RIGHT);
play = memnew( Button );
play->set_position(Point2( 5, 5 ));
play->set_size( Size2(1,1 ) );
play->set_toggle_mode(true);
add_child(play);
stop = memnew( Button );
stop->set_position(Point2( 35, 5 ));
stop->set_size( Size2(1,1 ) );
stop->set_toggle_mode(true);
add_child(stop);
peakdisplay=Ref<ImageTexture>( memnew( ImageTexture) );
peakdisplay->create( EDITOR_DEF("editors/sample_editor/preview_width",512),EDITOR_DEF("editors/sample_editor/preview_height",128),Image::FORMAT_RGB8);
sample_texframe->set_expand(true);
sample_texframe->set_texture(peakdisplay);
play->connect("pressed", this,"_play_pressed");
stop->connect("pressed", this,"_stop_pressed");
set_custom_minimum_size(Size2(1,150)*EDSCALE);
}
void SampleEditorPlugin::edit(Object *p_object) {
Sample * s = Object::cast_to<Sample>(p_object);
if (!s)
return;
sample_editor->edit(Ref<Sample>(s));
}
bool SampleEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("Sample");
}
void SampleEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
sample_editor->show();
//sample_editor->set_process(true);
} else {
sample_editor->hide();
//sample_editor->set_process(false);
}
}
SampleEditorPlugin::SampleEditorPlugin(EditorNode *p_node) {
editor=p_node;
sample_editor = memnew( SampleEditor );
add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM,sample_editor);
sample_editor->hide();
}
SampleEditorPlugin::~SampleEditorPlugin()
{
}
#endif

View file

@ -1,93 +0,0 @@
/*************************************************************************/
/* sample_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* 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 SAMPLE_EDITOR_PLUGIN_H
#define SAMPLE_EDITOR_PLUGIN_H
#if 0
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/audio/sample_player.h"
#include "scene/resources/sample.h"
#include "scene/resources/sample_library.h"
class SampleEditor : public Panel {
GDCLASS(SampleEditor, Panel );
SamplePlayer *player;
Label *info_label;
Ref<ImageTexture> peakdisplay;
Ref<Sample> sample;
Ref<SampleLibrary> library;
TextureRect *sample_texframe;
Button *stop;
Button *play;
void _play_pressed();
void _stop_pressed();
void _update_sample();
protected:
void _notification(int p_what);
void _gui_input(InputEvent p_event);
static void _bind_methods();
public:
static void generate_preview_texture(const Ref<Sample>& p_sample,Ref<ImageTexture> &p_texture);
void edit(Ref<Sample> p_sample);
SampleEditor();
};
class SampleEditorPlugin : public EditorPlugin {
GDCLASS( SampleEditorPlugin, EditorPlugin );
SampleEditor *sample_editor;
EditorNode *editor;
public:
virtual String get_name() const { return "Sample"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
virtual bool handles(Object *p_node) const;
virtual void make_visible(bool p_visible);
SampleEditorPlugin(EditorNode *p_node);
~SampleEditorPlugin();
};
#endif
#endif // SAMPLE_EDITOR_PLUGIN_H

View file

@ -1,547 +0,0 @@
/*************************************************************************/
/* sample_library_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* 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. */
/*************************************************************************/
#if 0
#include "sample_library_editor_plugin.h"
#include "editor/editor_settings.h"
#include "io/resource_loader.h"
#include "project_settings.h"
#include "sample_editor_plugin.h"
#include "scene/main/viewport.h"
void SampleLibraryEditor::_gui_input(InputEvent p_event) {
}
void SampleLibraryEditor::_notification(int p_what) {
if (p_what==NOTIFICATION_PROCESS) {
if (is_playing && !player->is_active()) {
TreeItem *tl=Object::cast_to<TreeItem>(last_sample_playing);
tl->set_button(0,0,get_icon("Play","EditorIcons"));
is_playing = false;
set_process(false);
}
}
if (p_what==NOTIFICATION_ENTER_TREE) {
load->set_icon( get_icon("Folder","EditorIcons") );
load->set_tooltip(TTR("Open Sample File(s)"));
}
if (p_what==NOTIFICATION_READY) {
//NodePath("/root")->connect("node_removed", this,"_node_removed",Vector<Variant>(),true);
}
if (p_what==NOTIFICATION_DRAW) {
}
}
void SampleLibraryEditor::_file_load_request(const PoolVector<String>& p_path) {
for(int i=0;i<p_path.size();i++) {
String path = p_path[i];
Ref<Sample> sample = ResourceLoader::load(path,"Sample");
if (sample.is_null()) {
dialog->set_text(TTR("ERROR: Couldn't load sample!"));
dialog->set_title(TTR("Error!"));
//dialog->get_cancel()->set_text("Close");
dialog->get_ok()->set_text(TTR("Close"));
dialog->popup_centered_minsize();
return; ///beh should show an error i guess
}
String basename = path.get_file().get_basename();
String name=basename;
int counter=0;
while(sample_library->has_sample(name)) {
counter++;
name=basename+"_"+itos(counter);
}
undo_redo->create_action(TTR("Add Sample"));
undo_redo->add_do_method(sample_library.operator->(),"add_sample",name,sample);
undo_redo->add_undo_method(sample_library.operator->(),"remove_sample",name);
undo_redo->add_do_method(this,"_update_library");
undo_redo->add_undo_method(this,"_update_library");
undo_redo->commit_action();
}
}
void SampleLibraryEditor::_load_pressed() {
file->popup_centered_ratio();
}
void SampleLibraryEditor::_button_pressed(Object *p_item,int p_column, int p_id) {
TreeItem *ti=Object::cast_to<TreeItem>(p_item);
String name = ti->get_text(0);
if (p_column==0) { // Play/Stop
String btn_type;
if(!is_playing) {
is_playing = true;
btn_type = TTR("Stop");
player->play(name,true);
last_sample_playing = p_item;
set_process(true);
} else {
player->stop_all();
if(last_sample_playing != p_item){
TreeItem *tl=Object::cast_to<TreeItem>(last_sample_playing);
tl->set_button(p_column,0,get_icon("Play","EditorIcons"));
btn_type = TTR("Stop");
player->play(name,true);
last_sample_playing = p_item;
} else {
btn_type = TTR("Play");
is_playing = false;
}
}
ti->set_button(p_column,0,get_icon(btn_type,"EditorIcons"));
} else if (p_column==1) { // Edit
get_tree()->get_root()->get_child(0)->call("_resource_selected",sample_library->get_sample(name));
} else if (p_column==5) { // Delete
ti->select(0);
_delete_pressed();
}
}
void SampleLibraryEditor::_item_edited() {
if (!tree->get_selected())
return;
TreeItem *s = tree->get_selected();
if (tree->get_selected_column()==0) { // Name
// renamed
String old_name=s->get_metadata(0);
String new_name=s->get_text(0);
if (old_name==new_name)
return;
if (new_name=="" || new_name.find("\\")!=-1 || new_name.find("/")!=-1 || sample_library->has_sample(new_name)) {
s->set_text(0,old_name);
return;
}
Ref<Sample> samp = sample_library->get_sample(old_name);
undo_redo->create_action(TTR("Rename Sample"));
undo_redo->add_do_method(sample_library.operator->(),"remove_sample",old_name);
undo_redo->add_do_method(sample_library.operator->(),"add_sample",new_name,samp);
undo_redo->add_undo_method(sample_library.operator->(),"remove_sample",new_name);
undo_redo->add_undo_method(sample_library.operator->(),"add_sample",old_name,samp);
undo_redo->add_do_method(this,"_update_library");
undo_redo->add_undo_method(this,"_update_library");
undo_redo->commit_action();
} else if (tree->get_selected_column()==3) { // Volume dB
StringName n = s->get_text(0);
sample_library->sample_set_volume_db(n,s->get_range(3));
} else if (tree->get_selected_column()==4) { // Pitch scale
StringName n = s->get_text(0);
sample_library->sample_set_pitch_scale(n,s->get_range(4));
}
}
void SampleLibraryEditor::_delete_pressed() {
if (!tree->get_selected())
return;
String to_remove = tree->get_selected()->get_text(0);
undo_redo->create_action(TTR("Delete Sample"));
undo_redo->add_do_method(sample_library.operator->(),"remove_sample",to_remove);
undo_redo->add_undo_method(sample_library.operator->(),"add_sample",to_remove,sample_library->get_sample(to_remove));
undo_redo->add_do_method(this,"_update_library");
undo_redo->add_undo_method(this,"_update_library");
undo_redo->commit_action();
}
void SampleLibraryEditor::_update_library() {
player->stop_all();
tree->clear();
tree->set_hide_root(true);
TreeItem *root = tree->create_item(NULL);
List<StringName> names;
sample_library->get_sample_list(&names);
names.sort_custom<StringName::AlphCompare>();
for(List<StringName>::Element *E=names.front();E;E=E->next()) {
TreeItem *ti = tree->create_item(root);
// Name + Play/Stop
ti->set_cell_mode(0,TreeItem::CELL_MODE_STRING);
ti->set_editable(0,true);
ti->set_selectable(0,true);
ti->set_text(0,E->get());
ti->set_metadata(0,E->get());
ti->add_button(0,get_icon("Play","EditorIcons"));
Ref<Sample> smp = sample_library->get_sample(E->get());
// Preview/edit
Ref<ImageTexture> preview( memnew( ImageTexture ));
preview->create(128,16,Image::FORMAT_RGB8);
SampleEditor::generate_preview_texture(smp,preview);
ti->set_cell_mode(1,TreeItem::CELL_MODE_ICON);
ti->set_selectable(1,false);
ti->set_editable(1,false);
ti->set_icon(1,preview);
ti->add_button(1,get_icon("Edit","EditorIcons"));
// Format
ti->set_cell_mode(2,TreeItem::CELL_MODE_STRING);
ti->set_editable(2,false);
ti->set_selectable(2,false);
ti->set_text(2,String()+(smp->get_format()==Sample::FORMAT_PCM16?TTR("16 Bits")+", ":(smp->get_format()==Sample::FORMAT_PCM8?TTR("8 Bits")+", ":"IMA-ADPCM,"))+(smp->is_stereo()?TTR("Stereo"):TTR("Mono")));
// Volume dB
ti->set_cell_mode(3,TreeItem::CELL_MODE_RANGE);
ti->set_range_config(3,-60,24,0.01);
ti->set_selectable(3,true);
ti->set_editable(3,true);
ti->set_range(3,sample_library->sample_get_volume_db(E->get()));
// Pitch scale
ti->set_cell_mode(4,TreeItem::CELL_MODE_RANGE);
ti->set_range_config(4,0.01,100,0.01);
ti->set_selectable(4,true);
ti->set_editable(4,true);
ti->set_range(4,sample_library->sample_get_pitch_scale(E->get()));
// Delete
ti->set_cell_mode(5,TreeItem::CELL_MODE_STRING);
ti->add_button(5,get_icon("Remove","EditorIcons"));
}
//player->add_sample("default",sample);
}
void SampleLibraryEditor::edit(Ref<SampleLibrary> p_sample_library) {
sample_library=p_sample_library;
if (!sample_library.is_null()) {
player->set_sample_library(sample_library);
_update_library();
} else {
hide();
}
}
Variant SampleLibraryEditor::get_drag_data_fw(const Point2& p_point,Control* p_from) {
TreeItem*ti =tree->get_item_at_pos(p_point);
if (!ti)
return Variant();
String name = ti->get_metadata(0);
RES res = sample_library->get_sample(name);
if (!res.is_valid())
return Variant();
return EditorNode::get_singleton()->drag_resource(res,p_from);
}
bool SampleLibraryEditor::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const {
Dictionary d = p_data;
if (!d.has("type"))
return false;
if (d.has("from") && (Object*)(d["from"])==tree)
return false;
if (String(d["type"])=="resource" && d.has("resource")) {
RES r=d["resource"];
Ref<Sample> sample = r;
if (sample.is_valid()) {
return true;
}
}
if (String(d["type"])=="files") {
Vector<String> files = d["files"];
if (files.size()==0)
return false;
for(int i=0;i<files.size();i++) {
String file = files[0];
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
if (ftype!="Sample") {
return false;
}
}
return true;
}
return false;
}
void SampleLibraryEditor::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) {
if (!can_drop_data_fw(p_point,p_data,p_from))
return;
Dictionary d = p_data;
if (!d.has("type"))
return;
if (String(d["type"])=="resource" && d.has("resource")) {
RES r=d["resource"];
Ref<Sample> sample = r;
if (sample.is_valid()) {
String basename;
if (sample->get_name()!="") {
basename=sample->get_name();
} else if (sample->get_path().is_resource_file()) {
basename = sample->get_path().get_basename();
} else {
basename="Sample";
}
String name=basename;
int counter=0;
while(sample_library->has_sample(name)) {
counter++;
name=basename+"_"+itos(counter);
}
undo_redo->create_action(TTR("Add Sample"));
undo_redo->add_do_method(sample_library.operator->(),"add_sample",name,sample);
undo_redo->add_undo_method(sample_library.operator->(),"remove_sample",name);
undo_redo->add_do_method(this,"_update_library");
undo_redo->add_undo_method(this,"_update_library");
undo_redo->commit_action();
}
}
if (String(d["type"])=="files") {
PoolVector<String> files = d["files"];
_file_load_request(files);
}
}
void SampleLibraryEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"),&SampleLibraryEditor::_gui_input);
ClassDB::bind_method(D_METHOD("_load_pressed"),&SampleLibraryEditor::_load_pressed);
ClassDB::bind_method(D_METHOD("_item_edited"),&SampleLibraryEditor::_item_edited);
ClassDB::bind_method(D_METHOD("_delete_pressed"),&SampleLibraryEditor::_delete_pressed);
ClassDB::bind_method(D_METHOD("_file_load_request"),&SampleLibraryEditor::_file_load_request);
ClassDB::bind_method(D_METHOD("_update_library"),&SampleLibraryEditor::_update_library);
ClassDB::bind_method(D_METHOD("_button_pressed"),&SampleLibraryEditor::_button_pressed);
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &SampleLibraryEditor::get_drag_data_fw);
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &SampleLibraryEditor::can_drop_data_fw);
ClassDB::bind_method(D_METHOD("drop_data_fw"), &SampleLibraryEditor::drop_data_fw);
}
SampleLibraryEditor::SampleLibraryEditor() {
player = memnew(SamplePlayer);
add_child(player);
add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel","Panel"));
load = memnew( Button );
load->set_position(Point2( 5, 5 ));
load->set_size( Size2(1,1 ) );
add_child(load);
file = memnew( EditorFileDialog );
add_child(file);
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("Sample",&extensions);
for(int i=0;i<extensions.size();i++)
file->add_filter("*."+extensions[i]);
file->set_mode(EditorFileDialog::MODE_OPEN_FILES);
tree = memnew( Tree );
tree->set_columns(6);
add_child(tree);
tree->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
tree->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,-5);
tree->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,30);
tree->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,-5);
tree->set_column_titles_visible(true);
tree->set_column_title(0,TTR("Name"));
tree->set_column_title(1,TTR("Preview"));
tree->set_column_title(2,TTR("Format"));
tree->set_column_title(3,"dB");
tree->set_column_title(4,TTR("Pitch"));
tree->set_column_title(5,"");
tree->set_column_min_width(1,150);
tree->set_column_min_width(2,100);
tree->set_column_min_width(3,50);
tree->set_column_min_width(4,50);
tree->set_column_min_width(5,32);
tree->set_column_expand(1,false);
tree->set_column_expand(2,false);
tree->set_column_expand(3,false);
tree->set_column_expand(4,false);
tree->set_column_expand(5,false);
tree->set_drag_forwarding(this);
dialog = memnew( ConfirmationDialog );
add_child( dialog );
tree->connect("button_pressed",this,"_button_pressed");
load->connect("pressed", this,"_load_pressed");
file->connect("files_selected", this,"_file_load_request");
tree->connect("item_edited", this,"_item_edited");
is_playing = false;
}
void SampleLibraryEditorPlugin::edit(Object *p_object) {
sample_library_editor->set_undo_redo(&get_undo_redo());
SampleLibrary * s = Object::cast_to<SampleLibrary>(p_object);
if (!s)
return;
sample_library_editor->edit(Ref<SampleLibrary>(s));
}
bool SampleLibraryEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("SampleLibrary");
}
void SampleLibraryEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
//sample_library_editor->show();
button->show();
editor->make_bottom_panel_item_visible(sample_library_editor);
//sample_library_editor->set_process(true);
} else {
if (sample_library_editor->is_visible_in_tree())
editor->hide_bottom_panel();
button->hide();
//sample_library_editor->set_process(false);
}
}
SampleLibraryEditorPlugin::SampleLibraryEditorPlugin(EditorNode *p_node) {
editor=p_node;
sample_library_editor = memnew( SampleLibraryEditor );
//editor->get_viewport()->add_child(sample_library_editor);
sample_library_editor->set_custom_minimum_size(Size2(0,250));
button=p_node->add_bottom_panel_item("SampleLibrary",sample_library_editor);
button->hide();
//sample_library_editor->set_area_as_parent_rect();
//sample_library_editor->set_anchor( MARGIN_TOP, Control::ANCHOR_END);
//sample_library_editor->set_margin( MARGIN_TOP, 120 );
//sample_library_editor->hide();
}
SampleLibraryEditorPlugin::~SampleLibraryEditorPlugin()
{
}
#endif

View file

@ -1,108 +0,0 @@
/*************************************************************************/
/* sample_library_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* 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 SAMPLE_LIBRARY_EDITOR_PLUGIN_H
#define SAMPLE_LIBRARY_EDITOR_PLUGIN_H
#if 0
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/audio/sample_player.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/file_dialog.h"
#include "scene/gui/tree.h"
#include "scene/resources/sample.h"
class SampleLibraryEditor : public Panel {
GDCLASS(SampleLibraryEditor, Panel );
SamplePlayer *player;
Ref<SampleLibrary> sample_library;
Button *load;
Tree *tree;
bool is_playing;
Object *last_sample_playing;
EditorFileDialog *file;
ConfirmationDialog *dialog;
void _load_pressed();
void _file_load_request(const PoolVector<String>& p_path);
void _delete_pressed();
void _update_library();
void _item_edited();
UndoRedo *undo_redo;
void _button_pressed(Object *p_item,int p_column, int p_id);
Variant get_drag_data_fw(const Point2& p_point,Control* p_from);
bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const;
void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
protected:
void _notification(int p_what);
void _gui_input(InputEvent p_event);
static void _bind_methods();
public:
void set_undo_redo(UndoRedo *p_undo_redo) {undo_redo=p_undo_redo; }
void edit(Ref<SampleLibrary> p_sample);
SampleLibraryEditor();
};
class SampleLibraryEditorPlugin : public EditorPlugin {
GDCLASS( SampleLibraryEditorPlugin, EditorPlugin );
SampleLibraryEditor *sample_library_editor;
EditorNode *editor;
Button *button;
public:
virtual String get_name() const { return "SampleLibrary"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
virtual bool handles(Object *p_node) const;
virtual void make_visible(bool p_visible);
SampleLibraryEditorPlugin(EditorNode *p_node);
~SampleLibraryEditorPlugin();
};
#endif
#endif // SAMPLE_LIBRARY_EDITOR_PLUGIN_H

View file

@ -1,202 +0,0 @@
/*************************************************************************/
/* sample_player_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* 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. */
/*************************************************************************/
#if 0
#include "sample_player_editor_plugin.h"
#include "scene/resources/sample_library.h"
void SamplePlayerEditor::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
play->set_icon( get_icon("Play","EditorIcons") );
stop->set_icon( get_icon("Stop","EditorIcons") );
}
}
void SamplePlayerEditor::_node_removed(Node *p_node) {
if(p_node==node) {
node=NULL;
hide();
}
}
void SamplePlayerEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_play"),&SamplePlayerEditor::_play);
ClassDB::bind_method(D_METHOD("_stop"),&SamplePlayerEditor::_stop);
}
void SamplePlayerEditor::_play() {
if (!node)
return;
if (samples->get_item_count()<=0)
return;
node->call("play",samples->get_item_text( samples->get_selected() ));
stop->set_pressed(false);
play->set_pressed(true);
}
void SamplePlayerEditor::_stop() {
if (!node)
return;
if (samples->get_item_count()<=0)
return;
node->call("stop_all");
print_line("STOP ALL!!");
stop->set_pressed(true);
play->set_pressed(false);
}
void SamplePlayerEditor::_update_sample_library() {
samples->clear();
Ref<SampleLibrary> sl = node->call("get_sample_library");
if (sl.is_null()) {
samples->add_item("<NO SAMPLE LIBRARY>");
return; //no sample library;
}
List<StringName> samplenames;
sl->get_sample_list(&samplenames);
samplenames.sort_custom<StringName::AlphCompare>();
for(List<StringName>::Element *E=samplenames.front();E;E=E->next()) {
samples->add_item(E->get());
}
}
void SamplePlayerEditor::edit(Node *p_sample_player) {
node=p_sample_player;
if (node) {
_update_sample_library();
}
}
SamplePlayerEditor::SamplePlayerEditor() {
play = memnew( Button );
play->set_position(Point2( 5, 5 ));
play->set_toggle_mode(true);
play->set_anchor_and_margin(MARGIN_LEFT,Control::ANCHOR_END,-250);
play->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,-230);
play->set_anchor_and_margin(MARGIN_TOP,Control::ANCHOR_BEGIN,0);
play->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_BEGIN,0);
add_child(play);
stop = memnew( Button );
stop->set_position(Point2( 35, 5 ));
stop->set_toggle_mode(true);
stop->set_anchor_and_margin(MARGIN_LEFT,Control::ANCHOR_END,-220);
stop->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,-200);
stop->set_anchor_and_margin(MARGIN_TOP,Control::ANCHOR_BEGIN,0);
stop->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_BEGIN,0);
add_child(stop);
samples = memnew( OptionButton );
samples->set_anchor_and_margin(MARGIN_LEFT,Control::ANCHOR_END,-190);
samples->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,-5);
samples->set_anchor_and_margin(MARGIN_TOP,Control::ANCHOR_BEGIN,0);
samples->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_BEGIN,0);
add_child(samples);
play->connect("pressed", this,"_play");
stop->connect("pressed", this,"_stop");
}
void SamplePlayerEditorPlugin::edit(Object *p_object) {
sample_player_editor->edit(Object::cast_to<Node>(p_object));
}
bool SamplePlayerEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("SamplePlayer2D") || p_object->is_class("SamplePlayer") || p_object->is_class("SpatialSamplePlayer");
}
void SamplePlayerEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
sample_player_editor->show();
sample_player_editor->set_fixed_process(true);
} else {
sample_player_editor->hide();
sample_player_editor->set_fixed_process(false);
sample_player_editor->edit(NULL);
}
}
SamplePlayerEditorPlugin::SamplePlayerEditorPlugin(EditorNode *p_node) {
editor=p_node;
sample_player_editor = memnew( SamplePlayerEditor );
editor->get_viewport()->add_child(sample_player_editor);
sample_player_editor->set_anchor(MARGIN_LEFT,Control::ANCHOR_END);
sample_player_editor->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END);
sample_player_editor->set_margin(MARGIN_LEFT,-250);
sample_player_editor->set_margin(MARGIN_RIGHT,0);
sample_player_editor->set_margin(MARGIN_TOP,0);
sample_player_editor->set_margin(MARGIN_BOTTOM,10);
sample_player_editor->hide();
}
SamplePlayerEditorPlugin::~SamplePlayerEditorPlugin()
{
}
#endif

View file

@ -1,91 +0,0 @@
/*************************************************************************/
/* sample_player_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* 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 SAMPLE_PLAYER_EDITOR_PLUGIN_H
#define SAMPLE_PLAYER_EDITOR_PLUGIN_H
#if 0
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/3d/spatial_sample_player.h"
#include "scene/audio/sample_player.h"
#include "scene/gui/option_button.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class SamplePlayerEditor : public Control {
GDCLASS(SamplePlayerEditor, Control );
Panel *panel;
Button * play;
Button * stop;
OptionButton *samples;
Node *node;
void _update_sample_library();
void _play();
void _stop();
protected:
void _notification(int p_what);
void _node_removed(Node *p_node);
static void _bind_methods();
public:
void edit(Node *p_sample_player);
SamplePlayerEditor();
};
class SamplePlayerEditorPlugin : public EditorPlugin {
GDCLASS( SamplePlayerEditorPlugin, EditorPlugin );
SamplePlayerEditor *sample_player_editor;
EditorNode *editor;
public:
virtual String get_name() const { return "SamplePlayer"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
virtual bool handles(Object *p_node) const;
virtual void make_visible(bool p_visible);
SamplePlayerEditorPlugin(EditorNode *p_node);
~SamplePlayerEditorPlugin();
};
#endif
#endif // SAMPLE_PLAYER_EDITOR_PLUGIN_H

View file

@ -29,18 +29,19 @@
/*************************************************************************/
#include "script_editor_plugin.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/os/file_access.h"
#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/node_dock.h"
#include "editor/script_editor_debugger.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "node_dock.h"
#include "os/file_access.h"
#include "os/input.h"
#include "os/keyboard.h"
#include "os/os.h"
#include "project_settings.h"
#include "scene/main/viewport.h"
/*** SCRIPT EDITOR ****/
void ScriptEditorBase::_bind_methods() {

View file

@ -29,20 +29,17 @@
/*************************************************************************/
#include "shader_editor_plugin.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/property_editor.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/keyboard.h"
#include "os/os.h"
#include "scene/resources/shader_graph.h"
#include "servers/visual/shader_types.h"
#include "spatial_editor_plugin.h"
/*** SETTINGS EDITOR ****/
/*** SCRIPT EDITOR ****/
/*** SHADER SCRIPT EDITOR ****/
Ref<Shader> ShaderTextEditor::get_edited_shader() const {

View file

@ -27,9 +27,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "shader_graph_editor_plugin.h"
// FIXME: Godot 3.0 broke compatibility with ShaderGraphEditorPlugin,
// it needs to be ported to the new shader language.
#if 0
#include "shader_graph_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
#include "os/keyboard.h"

View file

@ -30,6 +30,10 @@
#ifndef SHADER_GRAPH_EDITOR_PLUGIN_H
#define SHADER_GRAPH_EDITOR_PLUGIN_H
// FIXME: Godot 3.0 broke compatibility with ShaderGraphEditorPlugin,
// it needs to be ported to the new shader language.
#if 0
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "editor/property_editor.h"
@ -39,11 +43,11 @@
#include "scene/gui/tree.h"
#include "scene/resources/shader.h"
#include "scene/resources/shader_graph.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
#if 0
class GraphColorRampEdit : public Control {
GDCLASS(GraphColorRampEdit,Control);
@ -238,5 +242,6 @@ public:
~ShaderGraphEditorPlugin();
};
#endif
#endif
#endif // SHADER_GRAPH_EDITOR_PLUGIN_H

View file

@ -30,7 +30,7 @@
#ifndef PROJECT_MANAGER_H
#define PROJECT_MANAGER_H
#include "editor/asset_library_editor_plugin.h"
#include "editor/plugins/asset_library_editor_plugin.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/file_dialog.h"
#include "scene/gui/scroll_container.h"

View file

@ -29,13 +29,13 @@
/*************************************************************************/
#include "project_settings_editor.h"
#include "editor_node.h"
#include "global_constants.h"
#include "os/keyboard.h"
#include "project_settings.h"
#include "core/global_constants.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "core/translation.h"
#include "editor/editor_node.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/tab_container.h"
#include "translation.h"
ProjectSettingsEditor *ProjectSettingsEditor::singleton = NULL;
@ -184,8 +184,6 @@ void ProjectSettingsEditor::_device_input_add() {
int idx = edit_idx;
Variant old_val = ProjectSettings::get_singleton()->get(name);
Array arr = old_val;
// ie.device = device_id->get_value();
// ie.type = add_type;
switch (add_type) {
@ -619,7 +617,6 @@ void ProjectSettingsEditor::_update_actions() {
continue;
TreeItem *item = input_editor->create_item(root);
//item->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
item->set_text(0, name);
item->add_button(0, get_icon("Add", "EditorIcons"), 1, false, TTR("Add Event"));
if (!ProjectSettings::get_singleton()->get_input_presets().find(pi.name)) {
@ -627,7 +624,6 @@ void ProjectSettingsEditor::_update_actions() {
item->set_editable(0, true);
}
item->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
//item->set_checked(0,pi.usage&PROPERTY_USAGE_CHECKED);
Array actions = ProjectSettings::get_singleton()->get(pi.name);
@ -748,19 +744,7 @@ void ProjectSettingsEditor::_item_add() {
}
String catname = category->get_text().strip_edges();
/*if (!catname.is_valid_identifier()) {
message->set_text("Invalid Category.\nValid characters: a-z,A-Z,0-9 or _");
message->popup_centered(Size2(300,100));
return;
}*/
String propname = property->get_text().strip_edges();
/*if (!propname.is_valid_identifier()) {
message->set_text("Invalid Property.\nValid characters: a-z,A-Z,0-9 or _");
message->popup_centered(Size2(300,100));
return;
}*/
String name = catname != "" ? catname + "/" + propname : propname;
undo_redo->create_action(TTR("Add Global Property"));
@ -882,13 +866,6 @@ void ProjectSettingsEditor::_save() {
message->popup_centered(Size2(300, 100) * EDSCALE);
}
void ProjectSettingsEditor::_settings_prop_edited(const String &p_name) {
String full_item = globals_editor->get_full_item_path(p_name);
_settings_changed();
}
void ProjectSettingsEditor::_settings_changed() {
timer->start();
@ -1357,7 +1334,6 @@ void ProjectSettingsEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_add_item"), &ProjectSettingsEditor::_add_item, DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("_device_input_add"), &ProjectSettingsEditor::_device_input_add);
ClassDB::bind_method(D_METHOD("_press_a_key_confirm"), &ProjectSettingsEditor::_press_a_key_confirm);
ClassDB::bind_method(D_METHOD("_settings_prop_edited"), &ProjectSettingsEditor::_settings_prop_edited);
ClassDB::bind_method(D_METHOD("_copy_to_platform"), &ProjectSettingsEditor::_copy_to_platform);
ClassDB::bind_method(D_METHOD("_update_translations"), &ProjectSettingsEditor::_update_translations);
ClassDB::bind_method(D_METHOD("_translation_delete"), &ProjectSettingsEditor::_translation_delete);
@ -1391,12 +1367,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
tab_container = memnew(TabContainer);
tab_container->set_tab_align(TabContainer::ALIGN_LEFT);
add_child(tab_container);
//set_child_rect(tab_container);
//tab_container->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN, 15 );
//tab_container->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END, 15 );
//tab_container->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN, 15 );
//tab_container->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 35 );
VBoxContainer *props_base = memnew(VBoxContainer);
props_base->set_alignment(BoxContainer::ALIGN_BEGIN);
@ -1478,21 +1448,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
globals_editor->register_search_box(search_box);
globals_editor->get_property_editor()->get_scene_tree()->connect("cell_selected", this, "_item_selected");
globals_editor->get_property_editor()->connect("property_toggled", this, "_item_checked", varray(), CONNECT_DEFERRED);
globals_editor->get_property_editor()->connect("property_edited", this, "_settings_prop_edited");
/*
Button *save = memnew( Button );
props_base->add_child(save);
save->set_anchor(MARGIN_LEFT,ANCHOR_END);
save->set_anchor(MARGIN_RIGHT,ANCHOR_END);
save->set_anchor(MARGIN_TOP,ANCHOR_END);
save->set_anchor(MARGIN_BOTTOM,ANCHOR_END);
save->set_begin( Point2(80,28) );
save->set_end( Point2(10,20) );
save->set_text("Save");
save->connect("pressed",this,"_save");
*/
globals_editor->get_property_editor()->connect("property_edited", this, "_settings_changed");
Button *del = memnew(Button);
hbc->add_child(del);
@ -1506,16 +1462,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
popup_copy_to_feature->set_disabled(true);
add_prop_bar->add_child(popup_copy_to_feature);
/*List<StringName> ep;
EditorImportExport::get_singleton()->get_export_platforms(&ep);
ep.sort_custom<StringName::AlphCompare>();
for(List<StringName>::Element *E=ep.front();E;E=E->next()) {
popup_copy_to_feature->get_popup()->add_item( E->get() );
}*/
popup_copy_to_feature->get_popup()->connect("id_pressed", this, "_copy_to_platform");
popup_copy_to_feature->get_popup()->connect("about_to_show", this, "_copy_to_platform_about_to_show");
@ -1524,7 +1470,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
message = memnew(ConfirmationDialog);
add_child(message);
//message->get_cancel()->hide();
message->set_hide_on_ok(true);
Control *input_base = memnew(Control);
@ -1591,7 +1536,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
hbc = memnew(HBoxContainer);
device_input->add_child(hbc);
//device_input->set_child_rect(hbc);
VBoxContainer *vbc_left = memnew(VBoxContainer);
hbc->add_child(vbc_left);
@ -1616,18 +1560,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
device_index = memnew(OptionButton);
vbc_right->add_child(device_index);
/*
save = memnew( Button );
input_base->add_child(save);
save->set_anchor(MARGIN_LEFT,ANCHOR_END);
save->set_anchor(MARGIN_RIGHT,ANCHOR_END);
save->set_anchor(MARGIN_TOP,ANCHOR_END);
save->set_anchor(MARGIN_BOTTOM,ANCHOR_END);
save->set_begin( Point2(80,28) );
save->set_end( Point2(10,20) );
save->set_text("Save");
save->connect("pressed",this,"_save");
*/
setting = false;
//translations
@ -1739,14 +1671,4 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
add_child(timer);
updating_translations = false;
/*
Control * es = memnew( Control );
es->set_name("Export");
tab_container->add_child(es);
export_settings = memnew( ProjectExportSettings );
es->add_child(export_settings);
export_settings->set_area_as_parent_rect();
export_settings->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 35 );
*/
}

View file

@ -30,17 +30,16 @@
#ifndef PROJECT_SETTINGS_H
#define PROJECT_SETTINGS_H
#include "editor_autoload_settings.h"
#include "editor_data.h"
#include "editor_plugin_settings.h"
#include "property_editor.h"
#include "core/undo_redo.h"
#include "editor/editor_autoload_settings.h"
#include "editor/editor_data.h"
#include "editor/editor_plugin_settings.h"
#include "editor/property_editor.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/tab_container.h"
#include "undo_redo.h"
//#include "project_export_settings.h"
class ProjectSettingsEditor : public AcceptDialog {
GDCLASS(ProjectSettingsEditor, AcceptDialog);
enum InputType {
@ -122,10 +121,8 @@ class ProjectSettingsEditor : public AcceptDialog {
void _press_a_key_confirm();
void _show_last_added(const Ref<InputEvent> &p_event, const String &p_name);
void _settings_prop_edited(const String &p_name);
void _settings_changed();
//ProjectExportSettings *export_settings;
void _copy_to_platform(int p_which);
void _translation_file_open();

View file

@ -29,24 +29,24 @@
/*************************************************************************/
#include "property_editor.h"
#include "array_property_edit.h"
#include "class_db.h"
#include "create_dialog.h"
#include "editor_export.h"
#include "editor_file_system.h"
#include "editor_help.h"
#include "editor_node.h"
#include "editor_settings.h"
#include "io/image_loader.h"
#include "io/marshalls.h"
#include "io/resource_loader.h"
#include "multi_node_edit.h"
#include "os/input.h"
#include "os/keyboard.h"
#include "pair.h"
#include "print_string.h"
#include "project_settings.h"
#include "property_selector.h"
#include "core/class_db.h"
#include "core/io/image_loader.h"
#include "core/io/marshalls.h"
#include "core/io/resource_loader.h"
#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/pair.h"
#include "core/print_string.h"
#include "core/project_settings.h"
#include "editor/array_property_edit.h"
#include "editor/create_dialog.h"
#include "editor/editor_export.h"
#include "editor/editor_file_system.h"
#include "editor/editor_help.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/multi_node_edit.h"
#include "editor/property_selector.h"
#include "scene/gui/label.h"
#include "scene/main/viewport.h"
#include "scene/resources/font.h"
@ -59,11 +59,6 @@ void CustomPropertyEditor::_notification(int p_what) {
RID ci = get_canvas_item();
get_stylebox("panel", "PopupMenu")->draw(ci, Rect2(Point2(), get_size()));
/*
if (v.get_type()==Variant::COLOR) {
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2( 10,10,60, get_size().height-20 ), v );
}*/
}
if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST) {
hide();
@ -202,17 +197,6 @@ void CustomPropertyEditor::_menu_option(int p_which) {
emit_signal("variant_changed");
} break;
case OBJ_MENU_REIMPORT: {
RES r = v;
/* if (r.is_valid() && r->get_import_metadata().is_valid()) {
Ref<ResourceImportMetadata> rimd = r->get_import_metadata();
Ref<EditorImportPlugin> eip = EditorImportExport::get_singleton()->get_import_plugin_by_name(rimd->get_editor());
if (eip.is_valid()) {
eip->import_dialog(r->get_path());
}
}*/
} break;
case OBJ_MENU_NEW_SCRIPT: {
if (Object::cast_to<Node>(owner))
@ -515,8 +499,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
text_edit->show();
text_edit->set_text(v);
//action_buttons[0];
int button_margin = get_constant("button_margin", "Dialogs");
int margin = get_constant("margin", "Dialogs");
@ -531,7 +513,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_TYPE_STRING) {
/* FIXME: This is repeated twice, with slightly different behavior! Which one? Check line 644 */
if (!create_dialog) {
create_dialog = memnew(CreateDialog);
create_dialog->connect("create", this, "_create_dialog_callback");
@ -648,14 +629,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
updating = false;
return false;
} else if (hint == PROPERTY_HINT_TYPE_STRING) {
if (!create_dialog) {
/* FIXME: ... and here. See line 529 */
create_dialog = memnew(CreateDialog);
create_dialog->connect("create", this, "_create_dialog_callback");
add_child(create_dialog);
}
} else {
List<String> names;
names.push_back("string:");
@ -822,39 +795,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
color_picker->set_edit_alpha(hint != PROPERTY_HINT_COLOR_NO_ALPHA);
color_picker->set_pick_color(v);
color_picker->set_focus_on_line_edit();
/*
int ofs=80;
int m=10;
int h=20;
Color c=v;
float values[4]={c.r,c.g,c.b,c.a};
for (int i=0;i<4;i++) {
int y=m+i*h;
value_editor[i]->show();
value_label[i]->show();
value_label[i]->set_position(Point2(ofs,y));
scroll[i]->set_min(0);
scroll[i]->set_max(1.0);
scroll[i]->set_page(0);
scroll[i]->set_position(Point2(ofs+15,y+Math::floor((h-scroll[i]->get_minimum_size().height)/2.0)));
scroll[i]->set_val(values[i]);
scroll[i]->set_size(Size2(120,1));
scroll[i]->show();
value_editor[i]->set_position(Point2(ofs+140,y));
value_editor[i]->set_size(Size2(40,h));
value_editor[i]->set_text( String::num(values[i],2 ));
}
value_label[0]->set_text("R");
value_label[1]->set_text("G");
value_label[2]->set_text("B");
value_label[3]->set_text("A");
Size2 new_size = value_editor[3]->get_position() + value_editor[3]->get_size() + Point2(10,10);
set_size( new_size );
*/
} break;
@ -930,18 +870,9 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), "Make Unique", OBJ_MENU_MAKE_UNIQUE);
RES r = v;
if (r.is_valid() && r->get_path().is_resource_file()) {
/*if (r->get_import_metadata().is_valid()) {
menu->add_separator();
menu->add_icon_item(get_icon("ReloadSmall","EditorIcons"),"Re-Import",OBJ_MENU_REIMPORT);
}*/
menu->add_separator();
menu->add_item(TTR("Show in File System"), OBJ_MENU_SHOW_IN_FILE_SYSTEM);
}
/*if (r.is_valid() && r->get_path().is_resource_file()) {
menu->set_item_tooltip(1,r->get_path());
} else if (r.is_valid()) {
menu->set_item_tooltip(1,r->get_name()+" ("+r->get_type()+")");
}*/
} else {
}
@ -1007,14 +938,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
return true;
}
////void CustomPropertyEditor::_save_properties_values(List<String> p_names) {
////
//// field_names=p_names;
//// for (int i=0;i<p_names.size();i++) {
//// field_values.push_back(v.get(p_names[i]));
//// }
////}
void CustomPropertyEditor::_file_selected(String p_file) {
switch (type) {
@ -1093,11 +1016,6 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) {
ERR_FAIL_INDEX(p_idx, inheritors_array.size());
//List<String> inheritors;
//ClassDB::get_inheriters_from(hint_text,&inheritors);
//inheritors.push_front(hint_text);
//ERR_FAIL_INDEX( p_idx, inheritors.size() );
String intype = inheritors_array[p_idx];
Object *obj = ClassDB::instance(intype);
@ -1382,33 +1300,6 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
}
}
void CustomPropertyEditor::_scroll_modified(double p_value) {
if (updating)
return;
/*
switch(type) {
case Variant::COLOR: {
for (int i=0;i<4;i++) {
value_editor[i]->set_text( String::num(scroll[i]->get_val(),2) );
}
Color c;
c.r=scroll[0]->get_val();
c.g=scroll[1]->get_val();
c.b=scroll[2]->get_val();
c.a=scroll[3]->get_val();
v=c;
update();
emit_signal("variant_changed");
} break;
default: {}
}
*/
}
void CustomPropertyEditor::_drag_easing(const Ref<InputEvent> &p_ev) {
Ref<InputEventMouseMotion> mm = p_ev;
@ -1433,7 +1324,6 @@ void CustomPropertyEditor::_drag_easing(const Ref<InputEvent> &p_ev) {
val = Math::log(val) / Math::log((float)2.0);
//logspace
val += rel * 0.05;
//
val = Math::pow(2.0f, val);
if (sg)
@ -1441,11 +1331,8 @@ void CustomPropertyEditor::_drag_easing(const Ref<InputEvent> &p_ev) {
v = val;
easing_draw->update();
//emit_signal("variant_changed");
emit_signal("variant_changed");
}
// if (p_ev.type == Ref<InputEvent>::MOUSE_BUTTON && p_ev->get_button_index() == BUTTON_LEFT) {
// }
}
void CustomPropertyEditor::_draw_easing() {
@ -1456,7 +1343,6 @@ void CustomPropertyEditor::_draw_easing() {
Rect2 r(Point2(), s);
r = r.grow(3);
get_stylebox("normal", "LineEdit")->draw(ci, r);
//VisualServer::get_singleton()->canvas_item_add
int points = 48;
@ -1508,6 +1394,7 @@ void CustomPropertyEditor::_modified(String p_string) {
if (updating)
return;
updating = true;
switch (type) {
case Variant::INT: {
@ -1704,20 +1591,7 @@ void CustomPropertyEditor::_modified(String p_string) {
} break;
case Variant::COLOR: {
/*
for (int i=0;i<4;i++) {
scroll[i]->set_val( value_editor[i]->get_text().to_double() );
}
Color c;
c.r=value_editor[0]->get_text().to_double();
c.g=value_editor[1]->get_text().to_double();
c.b=value_editor[2]->get_text().to_double();
c.a=value_editor[3]->get_text().to_double();
v=c;
update();
emit_signal("variant_changed");
*/
} break;
case Variant::NODE_PATH: {
@ -1870,7 +1744,6 @@ void CustomPropertyEditor::_bind_methods() {
ClassDB::bind_method("_focus_exit", &CustomPropertyEditor::_focus_exit);
ClassDB::bind_method("_modified", &CustomPropertyEditor::_modified);
ClassDB::bind_method("_range_modified", &CustomPropertyEditor::_range_modified);
ClassDB::bind_method("_scroll_modified", &CustomPropertyEditor::_scroll_modified);
ClassDB::bind_method("_action_pressed", &CustomPropertyEditor::_action_pressed);
ClassDB::bind_method("_file_selected", &CustomPropertyEditor::_file_selected);
ClassDB::bind_method("_type_create_selected", &CustomPropertyEditor::_type_create_selected);
@ -1914,7 +1787,6 @@ CustomPropertyEditor::CustomPropertyEditor() {
scroll[i]->set_max(1.0);
scroll[i]->set_step(0.01);
add_child(scroll[i]);
scroll[i]->connect("value_changed", this, "_scroll_modified");
}
checks20gc = memnew(GridContainer);
@ -1968,7 +1840,6 @@ CustomPropertyEditor::CustomPropertyEditor() {
error = memnew(ConfirmationDialog);
error->set_title(TTR("Error!"));
add_child(error);
//error->get_cancel()->hide();
scene_tree = memnew(SceneTreeDialog);
add_child(scene_tree);
@ -1984,7 +1855,6 @@ CustomPropertyEditor::CustomPropertyEditor() {
easing_draw->hide();
easing_draw->connect("draw", this, "_draw_easing");
easing_draw->connect("gui_input", this, "_drag_easing");
//easing_draw->emit_signal(SceneStringNames::get_singleton()->input_event,InputEvent());
easing_draw->set_default_cursor_shape(Control::CURSOR_MOVE);
type_button = memnew(MenuButton);
@ -2056,8 +1926,6 @@ bool PropertyEditor::_get_instanced_node_original_property(const StringName &p_p
bool found = false;
//print_line("for prop - "+String(p_prop));
while (node) {
Ref<SceneState> ss;
@ -2068,13 +1936,11 @@ bool PropertyEditor::_get_instanced_node_original_property(const StringName &p_p
} else {
ss = node->get_scene_instance_state();
}
//print_line("at - "+String(edited_scene->get_path_to(node)));
if (ss.is_valid()) {
NodePath np = node->get_path_to(orig);
int node_idx = ss->find_node_by_path(np);
//print_line("\t valid, nodeidx "+itos(node_idx));
if (node_idx >= 0) {
bool lfound = false;
Variant lvar;
@ -2083,7 +1949,6 @@ bool PropertyEditor::_get_instanced_node_original_property(const StringName &p_p
found = true;
value = lvar;
//print_line("\t found value "+String(value));
}
}
}
@ -2107,8 +1972,6 @@ bool PropertyEditor::_is_property_different(const Variant &p_current, const Vari
Node *edited_scene = EditorNode::get_singleton()->get_edited_scene();
bool found_state = false;
//print_line("for prop - "+String(p_prop));
while (node) {
Ref<SceneState> ss;
@ -2247,8 +2110,6 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p
break;
}
//p_item->set_cell_mode( 1, TreeItem::CELL_MODE_RANGE );
if (p_type == Variant::REAL) {
p_item->set_range(1, obj->get(p_name));
@ -2310,7 +2171,6 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p
case Variant::COLOR: {
tree->update();
//p_item->set_text(1,obj->get(p_name));
} break;
case Variant::NODE_PATH: {
@ -2424,17 +2284,7 @@ void PropertyEditor::_check_reload_status(const String &p_name, TreeItem *item)
if (_get_instanced_node_original_property(p_name, vorig) || usage) {
Variant v = obj->get(p_name);
bool changed = _is_property_different(v, vorig, usage);
//if ((found!=-1 && !is_disabled)!=changed) {
if (changed) {
has_reload = true;
} else {
}
//}
bool has_reload = _is_property_different(v, vorig, usage);
}
}
@ -2453,7 +2303,6 @@ void PropertyEditor::_check_reload_status(const String &p_name, TreeItem *item)
}
}
//print_line("found: "+itos(found)+" has reload: "+itos(has_reload)+" is_disabled "+itos(is_disabled));
if (found != -1 && !has_reload) {
if (!is_disabled) {
@ -2481,14 +2330,11 @@ bool PropertyEditor::_is_drop_valid(const Dictionary &p_drag_data, const Diction
String allowed_type = d["hint_text"];
print_line("allowed type " + allowed_type);
Dictionary drag_data = p_drag_data;
if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
Ref<Resource> res = drag_data["resource"];
for (int i = 0; i < allowed_type.get_slice_count(","); i++) {
String at = allowed_type.get_slice(",", i).strip_edges();
print_line("RES vs " + at);
if (res.is_valid() && ClassDB::is_parent_class(res->get_class(), at)) {
return true;
}
@ -2499,18 +2345,14 @@ bool PropertyEditor::_is_drop_valid(const Dictionary &p_drag_data, const Diction
Vector<String> files = drag_data["files"];
print_line("fileS: " + String(Variant(files)));
if (files.size() == 1) {
String file = files[0];
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
print_line("file: " + file);
print_line("type: " + ftype);
if (ftype != "") {
for (int i = 0; i < allowed_type.get_slice_count(","); i++) {
String at = allowed_type.get_slice(",", i).strip_edges();
print_line("FILE vs " + at);
if (ClassDB::is_parent_class(ftype, at)) {
return true;
}
@ -2733,7 +2575,6 @@ TreeItem *PropertyEditor::get_parent_node(String p_path, HashMap<String, TreeIte
item = item_paths.get(p_path);
} else {
//printf("path %s parent path %s - item name %s\n",p_path.ascii().get_data(),p_path.left( p_path.find_last("/") ).ascii().get_data(),p_path.right( p_path.find_last("/") ).ascii().get_data() );
TreeItem *parent = get_parent_node(p_path.left(p_path.find_last("/")), item_paths, root, NULL);
item = tree->create_item(parent);
@ -2783,64 +2624,6 @@ void PropertyEditor::_refresh_item(TreeItem *p_item) {
if (name != String()) {
_check_reload_status(name, p_item);
#if 0
bool has_reload=false;
int found=-1;
for(int i=0;i<p_item->get_button_count(1);i++) {
if (p_item->get_button_id(1,i)==3) {
found=i;
break;
}
}
if (_might_be_in_instance()) {
Variant vorig;
Dictionary d=p_item->get_metadata(0);
int usage = d.has("usage")?int(int(d["usage"])&(PROPERTY_USAGE_STORE_IF_NONONE|PROPERTY_USAGE_STORE_IF_NONZERO)):0;
if (_get_instanced_node_original_property(name,vorig) || usage) {
Variant v = obj->get(name);
bool changed = _is_property_different(v,vorig,usage);
if ((found!=-1)!=changed) {
if (changed) {
has_reload=true;
} else {
//p_item->erase_button(1,found);
}
}
}
}
if (!has_reload && !obj->get_script().is_null()) {
Ref<Script> scr = obj->get_script();
Variant orig_value;
if (scr->get_property_default_value(name,orig_value)) {
if (orig_value!=obj->get(name)) {
has_reload=true;
}
}
}
if (!has_reload && found!=-1) {
p_item->erase_button(1,found);
} else if (has_reload && found==-1) {
p_item->add_button(1,get_icon("ReloadSmall","EditorIcons"),3);
}
#endif
Dictionary d = p_item->get_metadata(0);
set_item_text(p_item, d["type"], d["name"], d["hint"], d["hint_text"]);
}
@ -2874,45 +2657,6 @@ void PropertyEditor::update_tree() {
TreeItem *root = tree->create_item(NULL);
tree->set_hide_root(true);
/*
TreeItem *title = tree->create_item(root);
title->set_custom_bg_color(0,get_color("prop_section","Editor"));
title->set_text(0,"Property"); // todo, fetch name if ID exists in database
title->set_editable(0,false);
title->set_selectable(0,false);
title->set_custom_bg_color(1,get_color("prop_section","Editor"));
title->set_text(1,"Value"); // todo, fetch name if ID exists in database
title->set_editable(1,false);
title->set_selectable(1,false);
*/
/*
if (Object::cast_to<Node>() || Object::cast_to<Resource>(obj)) {
TreeItem *type = tree->create_item(root);
type->set_text(0,"Type"); // todo, fetch name if ID exists in database
type->set_text(1,obj->get_type()); // todo, fetch name if ID exists in database
if (has_icon(obj->get_type(),"EditorIcons"))
type->set_icon(1,get_icon(obj->get_type(),"EditorIcons") );
else
type->set_icon(1,get_icon("Object","EditorIcons") );
type->set_selectable(0,false);
type->set_selectable(1,false);
TreeItem *name = tree->create_item(root);
name->set_text(0,"Name"); // todo, fetch name if ID exists in database
if (obj->is_type("Resource"))
name->set_text(1,Object::cast_to<Resource>(obj)->get_name());
else if (obj->is_type("Node"))
name->set_text(1,Object::cast_to<Node>(obj)->get_name());
name->set_selectable(0,false);
name->set_selectable(1,false);
}
*/
List<PropertyInfo> plist;
obj->get_property_list(&plist, true);
@ -3003,9 +2747,8 @@ void PropertyEditor::update_tree() {
sep->set_tooltip(0, TTR("Class:") + " " + p.name + ":\n\n" + class_descr_cache[type]);
}
//sep->set_custom_color(0,Color(1,1,1));
continue;
} else if (!(p.usage & PROPERTY_USAGE_EDITOR))
continue;
@ -3057,12 +2800,7 @@ void PropertyEditor::update_tree() {
continue;
}
//printf("property %s\n",basename.ascii().get_data());
TreeItem *parent = get_parent_node(path, item_path, root, current_category);
/*
if (parent->get_parent()==root)
parent=root;
*/
int level = 0;
if (parent != root) {
level++;
@ -3082,7 +2820,6 @@ void PropertyEditor::update_tree() {
if (level > 0) {
item->set_custom_bg_color(0, col);
//item->set_custom_bg_color(1,col);
}
item->set_editable(0, false);
item->set_selectable(0, property_selectable);
@ -3144,7 +2881,6 @@ void PropertyEditor::update_tree() {
item->set_tooltip(0, TTR("Property:") + " " + p.name + "\n\n" + descr);
}
}
//EditorHelp::get_doc_data();
Dictionary d;
d["name"] = p.name;
@ -3164,7 +2900,6 @@ void PropertyEditor::update_tree() {
item->select(1);
}
//printf("property %s type %i\n",p.name.ascii().get_data(),p.type);
switch (p.type) {
case Variant::BOOL: {
@ -3204,7 +2939,6 @@ void PropertyEditor::update_tree() {
item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
item->set_editable(1, !read_only);
//item->set_icon( 0, get_icon("Curve","EditorIcons"));
Vector<String> values = p.hint_string.split(",");
String flags;
@ -3251,7 +2985,6 @@ void PropertyEditor::update_tree() {
item->set_range_config(1, min, max, step, p.hint == PROPERTY_HINT_EXP_RANGE);
} else if (p.hint == PROPERTY_HINT_ENUM) {
//int c = p.hint_string.get_slice_count(",");
item->set_text(1, p.hint_string);
if (show_type_icons)
item->set_icon(0, get_icon("Enum", "EditorIcons"));
@ -3260,7 +2993,6 @@ void PropertyEditor::update_tree() {
break;
} else if (p.hint == PROPERTY_HINT_OBJECT_ID) {
//int c = p.hint_string.get_slice_count(",");
item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
String type = p.hint_string;
@ -3591,7 +3323,6 @@ void PropertyEditor::update_tree() {
item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
item->set_editable(1, !read_only);
//item->set_text(1,obj->get(p.name));
item->set_custom_draw(1, this, "_draw_transparency");
if (show_type_icons)
item->set_icon(0, get_icon("Color", "EditorIcons"));
@ -3610,7 +3341,6 @@ void PropertyEditor::update_tree() {
item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
item->set_editable(1, !read_only);
//item->add_button(1, get_icon("EditResource", "EditorIcons"));
String type;
if (p.hint == PROPERTY_HINT_RESOURCE_TYPE)
type = p.hint_string;
@ -3675,15 +3405,12 @@ void PropertyEditor::update_tree() {
if (type != String()) {
if (type.find(",") != -1)
type = type.get_slice(",", 0);
//printf("prop %s , type %s\n",p.name.ascii().get_data(),p.hint_string.ascii().get_data());
if (has_icon(type, "EditorIcons"))
item->set_icon(0, get_icon(type, "EditorIcons"));
else
item->set_icon(0, get_icon("Object", "EditorIcons"));
}
//item->double_click_signal.connect( Method1<int>( Method2<int,String>( this, &Editoritem_obj_edited ), p.name ) );
} break;
default: {};
}
@ -3710,7 +3437,6 @@ void PropertyEditor::update_tree() {
Variant v = obj->get(p.name);
if (_is_property_different(v, vorig, usage)) {
//print_line("FOR "+String(p.name)+" RELOAD WITH: "+String(v)+"("+Variant::get_type_name(v.get_type())+")=="+String(vorig)+"("+Variant::get_type_name(vorig.get_type())+")");
item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3);
has_reload = true;
}
@ -3942,9 +3668,8 @@ void PropertyEditor::_item_edited() {
case Variant::TRANSFORM: {
} break;
case Variant::COLOR: {
//_edit_set(name,item->get_custom_bg_color(0));
} break;
case Variant::NODE_PATH: {
@ -4030,7 +3755,6 @@ void PropertyEditor::_custom_editor_request(bool p_arrow) {
ERR_FAIL_COND(!item);
Dictionary d = item->get_metadata(0);
//int type=d["type"];
String name = d["name"];
Variant::Type type = Variant::NIL;
if (d.has("type"))
@ -4078,6 +3802,7 @@ void PropertyEditor::_set_range_def(Object *p_item, String prop, float p_frame)
}
void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti);
@ -4095,7 +3820,6 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
return;
String prop = d["name"];
emit_signal("property_keyed", prop, obj->get(prop), true);
//set_range(p_column, ti->get_range(p_column)+1.0 );
call_deferred("_set_range_def", ti, prop, ti->get_range(p_column) + 1.0);
} else if (p_button == 3) {
@ -4156,7 +3880,6 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
Variant v = obj->get(n);
custom_editor->edit(obj, n, (Variant::Type)t, v, h, ht);
//Rect2 where=tree->get_custom_popup_rect();
if (h == PROPERTY_HINT_FILE || h == PROPERTY_HINT_DIR || h == PROPERTY_HINT_GLOBAL_DIR || h == PROPERTY_HINT_GLOBAL_FILE) {
Rect2 where = tree->get_item_rect(ti, 1);
@ -4178,7 +3901,6 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
} else if (t == Variant::INT && h == PROPERTY_HINT_OBJECT_ID) {
emit_signal("object_id_selected", obj->get(n));
print_line("OBJ ID SELECTED");
} else if (t == Variant::ARRAY || t == Variant::POOL_INT_ARRAY || t == Variant::POOL_REAL_ARRAY || t == Variant::POOL_STRING_ARRAY || t == Variant::POOL_VECTOR2_ARRAY || t == Variant::POOL_VECTOR3_ARRAY || t == Variant::POOL_COLOR_ARRAY || t == Variant::POOL_BYTE_ARRAY) {
@ -4200,7 +3922,6 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
void PropertyEditor::_node_removed(Node *p_node) {
if (p_node == obj) {
edit(NULL);
}
}
@ -4432,8 +4153,6 @@ PropertyEditor::PropertyEditor() {
tree->set_column_min_width(0, 30);
tree->set_column_expand(1, true);
tree->set_column_min_width(1, 18);
//tree->set_hide_root(true);
add_child(tree);
tree->connect("item_edited", this, "_item_edited", varray(), CONNECT_DEFERRED);
@ -4502,7 +4221,6 @@ class SectionedPropertyEditorFilter : public Object {
bool valid;
edited->set(name, p_value, &valid);
//_change_notify(p_name.operator String().utf8().get_data());
return valid;
}
@ -4819,8 +4537,7 @@ void PropertyValueEvaluator::edit(Object *p_obj) {
}
String PropertyValueEvaluator::_build_script(const String &p_text) {
String script_text =
"tool\nextends Object\nfunc eval(s):\n\tself = s\n\treturn " + p_text.strip_edges() + "\n";
String script_text = "tool\nextends Object\nfunc eval(s):\n\tself = s\n\treturn " + p_text.strip_edges() + "\n";
return script_text;
}

View file

@ -31,6 +31,7 @@
#define PROPERTY_EDITOR_H
#include "editor/editor_file_dialog.h"
#include "editor/scene_tree_editor.h"
#include "scene/gui/button.h"
#include "scene/gui/check_box.h"
#include "scene/gui/check_button.h"
@ -43,7 +44,6 @@
#include "scene/gui/text_edit.h"
#include "scene/gui/texture_rect.h"
#include "scene/gui/tree.h"
#include "scene_tree_editor.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@ -66,9 +66,8 @@ class CustomPropertyEditor : public Popup {
OBJ_MENU_MAKE_UNIQUE = 3,
OBJ_MENU_COPY = 4,
OBJ_MENU_PASTE = 5,
OBJ_MENU_REIMPORT = 6,
OBJ_MENU_NEW_SCRIPT = 7,
OBJ_MENU_SHOW_IN_FILE_SYSTEM = 8,
OBJ_MENU_NEW_SCRIPT = 6,
OBJ_MENU_SHOW_IN_FILE_SYSTEM = 7,
TYPE_BASE_ID = 100
};
@ -120,7 +119,6 @@ class CustomPropertyEditor : public Popup {
void _text_edit_changed();
void _file_selected(String p_file);
void _scroll_modified(double p_value);
void _modified(String p_string);
void _range_modified(double p_value);
void _focus_enter();
@ -168,7 +166,6 @@ class PropertyEditor : public Control {
Tree *tree;
Label *top_label;
//Object *object;
LineEdit *search_box;
PropertyValueEvaluator *evaluator;

View file

@ -1,378 +0,0 @@
/*************************************************************************/
/* resources_dock.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* 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 "resources_dock.h"
#include "editor_file_system.h"
#include "editor_node.h"
#include "editor_settings.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "project_settings.h"
#include "project_settings_editor.h"
void ResourcesDock::_tool_selected(int p_tool) {
current_action = p_tool;
switch (p_tool) {
case TOOL_NEW: {
create_dialog->popup_centered_ratio();
} break;
case TOOL_OPEN: {
editor->open_resource();
} break;
case TOOL_SAVE: {
TreeItem *ti = resources->get_selected();
if (!ti)
break;
Ref<Resource> current_res = ti->get_metadata(0);
if (current_res->get_path() != "" && current_res->get_path().find("::") == -1) {
_file_action(current_res->get_path());
break;
};
}; /* fallthrough */
case TOOL_SAVE_AS: {
TreeItem *ti = resources->get_selected();
if (!ti)
break;
save_resource_as(ti->get_metadata(0));
} break;
case TOOL_MAKE_LOCAL: {
TreeItem *ti = resources->get_selected();
if (!ti)
break;
Ref<Resource> current_res = ti->get_metadata(0);
current_res->set_path("");
_update_name(ti);
} break;
case TOOL_COPY: {
TreeItem *ti = resources->get_selected();
if (!ti)
break;
Ref<Resource> current_res = ti->get_metadata(0);
EditorSettings::get_singleton()->set_resource_clipboard(current_res);
} break;
case TOOL_PASTE: {
add_resource(EditorSettings::get_singleton()->get_resource_clipboard());
} break;
}
}
void ResourcesDock::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
button_new->set_icon(get_icon("New", "EditorIcons"));
button_open->set_icon(get_icon("Folder", "EditorIcons"));
button_save->set_icon(get_icon("Save", "EditorIcons"));
button_tools->set_icon(get_icon("Tools", "EditorIcons"));
} break;
}
}
void ResourcesDock::save_resource(const String &p_path, const Ref<Resource> &p_resource) {
editor->get_editor_data().apply_changes_in_editors();
int flg = 0;
if (EditorSettings::get_singleton()->get("on_save/compress_binary_resources"))
flg |= ResourceSaver::FLAG_COMPRESS;
/*
if (EditorSettings::get_singleton()->get("on_save/save_paths_as_relative"))
flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
*/
String path = ProjectSettings::get_singleton()->localize_path(p_path);
Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
if (err != OK) {
accept->set_text(TTR("Error saving resource!"));
accept->popup_centered_minsize();
return;
}
//EditorFileSystem::get_singleton()->update_file(path,p_resource->get_type());
((Resource *)p_resource.ptr())->set_path(path);
editor->emit_signal("resource_saved", p_resource);
}
void ResourcesDock::save_resource_as(const Ref<Resource> &p_resource) {
current_action = TOOL_SAVE_AS;
RES res(p_resource);
List<String> extensions;
ResourceSaver::get_recognized_extensions(res, &extensions);
file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
if (p_resource->get_path() != "" && p_resource->get_path().find("::") == -1) {
file->set_current_path(p_resource->get_path());
} else {
String existing;
if (extensions.size()) {
existing = "new_" + res->get_class().to_lower() + "." + extensions.front()->get().to_lower();
}
file->set_current_file(existing);
}
file->clear_filters();
for (int i = 0; i < extensions.size(); i++) {
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
file->popup_centered_ratio();
}
void ResourcesDock::_file_action(const String &p_path) {
switch (current_action) {
case TOOL_OPEN: {
} break;
case TOOL_SAVE:
case TOOL_SAVE_AS: {
TreeItem *ti = resources->get_selected();
if (!ti)
break;
Ref<Resource> current_res = ti->get_metadata(0);
RES res(current_res);
save_resource(p_path, res);
_update_name(ti);
} break;
}
}
void ResourcesDock::_update_name(TreeItem *item) {
Ref<Resource> res = item->get_metadata(0);
if (res->get_name() != "")
item->set_text(0, res->get_name());
else if (res->get_path() != "" && res->get_path().find("::") == -1)
item->set_text(0, res->get_path().get_file());
else
item->set_text(0, res->get_class() + " (" + itos(res->get_instance_id()) + ")");
}
void ResourcesDock::remove_resource(const Ref<Resource> &p_resource) {
TreeItem *root = resources->get_root();
ERR_FAIL_COND(!root);
TreeItem *existing = root->get_children();
while (existing) {
Ref<Resource> r = existing->get_metadata(0);
if (r == p_resource) {
//existing->move_to_top();
memdelete(existing);
return;
}
existing = existing->get_next();
}
}
void ResourcesDock::add_resource(const Ref<Resource> &p_resource) {
if (block_add)
return;
if (!p_resource.is_valid())
return;
TreeItem *root = resources->get_root();
ERR_FAIL_COND(!root);
TreeItem *existing = root->get_children();
while (existing) {
Ref<Resource> r = existing->get_metadata(0);
if (r == p_resource) {
//existing->move_to_top();
existing->select(0);
resources->ensure_cursor_is_visible();
return; // existing
}
existing = existing->get_next();
}
TreeItem *res = resources->create_item(root);
res->set_metadata(0, p_resource);
if (has_icon(p_resource->get_class(), "EditorIcons")) {
res->set_icon(0, get_icon(p_resource->get_class(), "EditorIcons"));
}
_update_name(res);
res->add_button(0, get_icon("Del", "EditorIcons"));
res->move_to_top();
res->select(0);
resources->ensure_cursor_is_visible();
}
void ResourcesDock::_resource_selected() {
TreeItem *sel = resources->get_selected();
ERR_FAIL_COND(!sel);
Ref<Resource> r = sel->get_metadata(0);
if (r.is_null())
return;
block_add = true;
editor->push_item(r.ptr());
block_add = false;
}
void ResourcesDock::_delete(Object *p_item, int p_column, int p_id) {
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti);
call_deferred("remove_resource", ti->get_metadata(0));
}
void ResourcesDock::_create() {
Object *c = create_dialog->instance_selected();
ERR_FAIL_COND(!c);
Resource *r = Object::cast_to<Resource>(c);
ERR_FAIL_COND(!r);
REF res(r);
editor->push_item(c);
}
void ResourcesDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_tool_selected"), &ResourcesDock::_tool_selected);
ClassDB::bind_method(D_METHOD("_create"), &ResourcesDock::_create);
ClassDB::bind_method(D_METHOD("_resource_selected"), &ResourcesDock::_resource_selected);
ClassDB::bind_method(D_METHOD("_delete"), &ResourcesDock::_delete);
ClassDB::bind_method(D_METHOD("remove_resource"), &ResourcesDock::remove_resource);
ClassDB::bind_method(D_METHOD("_file_action"), &ResourcesDock::_file_action);
}
void ResourcesDock::cleanup() {
resources->clear();
resources->create_item(); //root
}
ResourcesDock::ResourcesDock(EditorNode *p_editor) {
editor = p_editor;
VBoxContainer *vbc = this;
HBoxContainer *hbc = memnew(HBoxContainer);
vbc->add_child(hbc);
Button *b;
b = memnew(ToolButton);
b->set_tooltip(TTR("Create New Resource"));
b->connect("pressed", this, "_tool_selected", make_binds(TOOL_NEW));
hbc->add_child(b);
button_new = b;
b = memnew(ToolButton);
b->set_tooltip(TTR("Open Resource"));
b->connect("pressed", this, "_tool_selected", make_binds(TOOL_OPEN));
hbc->add_child(b);
button_open = b;
MenuButton *mb = memnew(MenuButton);
mb->set_tooltip(TTR("Save Resource"));
mb->get_popup()->add_item(TTR("Save Resource"), TOOL_SAVE);
mb->get_popup()->add_item(TTR("Save Resource As.."), TOOL_SAVE_AS);
mb->get_popup()->connect("id_pressed", this, "_tool_selected");
hbc->add_child(mb);
button_save = mb;
hbc->add_spacer();
mb = memnew(MenuButton);
mb->set_tooltip(TTR("Resource Tools"));
mb->get_popup()->add_item(TTR("Make Local"), TOOL_MAKE_LOCAL);
mb->get_popup()->add_item(TTR("Copy"), TOOL_COPY);
mb->get_popup()->add_item(TTR("Paste"), TOOL_PASTE);
mb->get_popup()->connect("id_pressed", this, "_tool_selected");
hbc->add_child(mb);
button_tools = mb;
resources = memnew(Tree);
vbc->add_child(resources);
resources->set_v_size_flags(SIZE_EXPAND_FILL);
resources->create_item(); //root
resources->set_hide_root(true);
resources->connect("cell_selected", this, "_resource_selected");
resources->connect("button_pressed", this, "_delete");
create_dialog = memnew(CreateDialog);
add_child(create_dialog);
create_dialog->set_base_type("Resource");
create_dialog->connect("create", this, "_create");
accept = memnew(AcceptDialog);
add_child(accept);
file = memnew(EditorFileDialog);
add_child(file);
file->connect("file_selected", this, "_file_action");
block_add = false;
}

View file

@ -1,99 +0,0 @@
/*************************************************************************/
/* resources_dock.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* 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 RESOURCES_DOCK_H
#define RESOURCES_DOCK_H
#include "create_dialog.h"
#include "editor_file_dialog.h"
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
#include "scene/gui/control.h"
#include "scene/gui/file_dialog.h"
#include "scene/gui/label.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/tool_button.h"
#include "scene/gui/tree.h"
class EditorNode;
class ResourcesDock : public VBoxContainer {
GDCLASS(ResourcesDock, VBoxContainer);
enum {
TOOL_NEW,
TOOL_OPEN,
TOOL_SAVE,
TOOL_SAVE_AS,
TOOL_MAKE_LOCAL,
TOOL_COPY,
TOOL_PASTE,
TOOL_MAX
};
EditorNode *editor;
Button *button_new;
Button *button_open;
Button *button_save;
Button *button_tools;
CreateDialog *create_dialog;
AcceptDialog *accept;
EditorFileDialog *file;
Tree *resources;
bool block_add;
int current_action;
void _file_action(const String &p_path);
void _delete(Object *p_item, int p_column, int p_id);
void _resource_selected();
void _update_name(TreeItem *item);
void _tool_selected(int p_tool);
void _create();
protected:
void _notification(int p_what);
static void _bind_methods();
public:
void add_resource(const Ref<Resource> &p_resource);
void remove_resource(const Ref<Resource> &p_resource);
void save_resource(const String &p_path, const Ref<Resource> &p_resource);
void save_resource_as(const Ref<Resource> &p_resource);
void cleanup();
ResourcesDock(EditorNode *p_editor);
};
#endif // RESOURCES_DOCK_H

View file

@ -29,20 +29,20 @@
/*************************************************************************/
#include "scene_tree_dock.h"
#include "animation_editor.h"
#include "core/io/resource_saver.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "editor/animation_editor.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/multi_node_edit.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
#include "editor/plugins/script_editor_plugin.h"
#include "editor/plugins/spatial_editor_plugin.h"
#include "editor_node.h"
#include "editor_settings.h"
#include "multi_node_edit.h"
#include "os/keyboard.h"
#include "project_settings.h"
#include "editor/script_editor_debugger.h"
#include "scene/main/viewport.h"
#include "scene/resources/packed_scene.h"
#include "script_editor_debugger.h"
void SceneTreeDock::_nodes_drag_begin() {
@ -106,7 +106,6 @@ void SceneTreeDock::instance(const String &p_file) {
if (!parent || !edited_scene) {
current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("OK :("));
accept->set_text(TTR("No parent to instance a child at."));
accept->popup_centered_minsize();
@ -152,7 +151,6 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
Ref<PackedScene> sdata = ResourceLoader::load(p_files[i]);
if (!sdata.is_valid()) {
current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("Ugh"));
accept->set_text(vformat(TTR("Error loading scene from %s"), p_files[i]));
accept->popup_centered_minsize();
@ -163,7 +161,6 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
if (!instanced_scene) {
current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("Ugh"));
accept->set_text(vformat(TTR("Error instancing scene from %s"), p_files[i]));
accept->popup_centered_minsize();
@ -195,8 +192,6 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
return;
}
//instanced_scene->generate_instance_state();
editor_data->get_undo_redo().create_action(TTR("Instance Scene(s)"));
for (int i = 0; i < instances.size(); i++) {
@ -275,10 +270,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
switch (p_tool) {
case TOOL_NEW: {
/*
if (!_validate_no_foreign())
break;
*/
create_dialog->popup_create(true);
} break;
case TOOL_INSTANCE: {
@ -286,24 +277,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
Node *scene = edited_scene;
if (!scene) {
EditorNode::get_singleton()->new_inherited_scene();
/* should be legal now
current_option=-1;
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("This operation can't be done without a tree root.");
accept->popup_centered_minsize();
*/
break;
}
/*
if (!_validate_no_foreign())
break;
*/
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions);
@ -313,7 +289,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
//file->set_current_path(current_path);
file->popup_centered_ratio();
} break;
@ -321,43 +296,12 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
create_dialog->popup_create(false);
} break;
case TOOL_CONNECT: {
Node *current = scene_tree->get_selected();
if (!current)
break;
/*
if (!_validate_no_foreign())
break;
connect_dialog->popup_centered_ratio();
connect_dialog->set_node(current);
*/
} break;
case TOOL_GROUP: {
Node *current = scene_tree->get_selected();
if (!current)
break;
/*
if (!_validate_no_foreign())
break;
groups_editor->set_current(current);
groups_editor->popup_centered_ratio();
*/
} break;
case TOOL_ATTACH_SCRIPT: {
Node *selected = scene_tree->get_selected();
if (!selected)
break;
/*
if (!_validate_no_foreign())
break;
*/
Ref<Script> existing = selected->get_script();
if (existing.is_valid())
editor->push_item(existing.ptr());
@ -391,7 +335,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (scene_tree->get_selected() == edited_scene) {
current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("This operation can't be done on the tree root."));
accept->popup_centered_minsize();
@ -467,8 +410,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (selection.size() == 0)
break;
List<Node *> reselect;
editor_data->get_undo_redo().create_action(TTR("Duplicate Node(s)"));
editor_data->get_undo_redo().add_do_method(editor_selection, "clear");
@ -510,9 +451,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().add_do_method(sed, "live_debug_duplicate_node", edited_scene->get_path_to(node), dup->get_name());
editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)) + "/" + dup->get_name()));
//parent->add_child(dup);
//reselect.push_back(dup);
}
editor_data->get_undo_redo().commit_action();
@ -529,7 +467,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (editor_selection->is_selected(edited_scene)) {
current_option = -1;
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("This operation can't be done on the tree root."));
accept->popup_centered_minsize();
@ -860,7 +797,6 @@ Node *SceneTreeDock::_duplicate(Node *p_node, Map<Node *, Node *> &duplimap) {
node = sd->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
ERR_FAIL_COND_V(!node, NULL);
node->set_scene_instance_load_placeholder(p_node->get_scene_instance_load_placeholder());
//node->generate_instance_state();
} else {
Object *obj = ClassDB::instance(p_node->get_class());
ERR_FAIL_COND_V(!obj, NULL);
@ -1149,8 +1085,6 @@ void SceneTreeDock::_node_reparent(NodePath p_path, bool p_keep_global_xform) {
Node *new_parent = scene_root->get_node(p_path);
ERR_FAIL_COND(!new_parent);
//ok all valid
List<Node *> selection = editor_selection->get_selected_node_list();
if (selection.empty())
@ -1180,11 +1114,8 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
}
validate = validate->get_parent();
}
//ok all valid
List<Node *> selection = editor_selection->get_selected_node_list();
if (p_nodes.size() == 0)
return; //nothing to reparent
@ -1285,7 +1216,6 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
perform_node_renames(NULL, &path_renames);
editor_data->get_undo_redo().commit_action();
//node->set_owner(owner);
}
void SceneTreeDock::_script_created(Ref<Script> p_script) {
@ -1361,7 +1291,6 @@ void SceneTreeDock::_delete_confirm() {
if (AnimationPlayerEditor::singleton->get_key_editor()->get_root() == n)
editor_data->get_undo_redo().add_undo_method(AnimationPlayerEditor::singleton->get_key_editor(), "set_root", n);
editor_data->get_undo_redo().add_undo_method(this, "_set_owners", edited_scene, owners);
//editor_data->get_undo_redo().add_undo_method(n,"set_owner",n->get_owner());
editor_data->get_undo_redo().add_undo_reference(n);
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
@ -1392,8 +1321,6 @@ void SceneTreeDock::_selection_changed() {
button_create_script->hide();
button_clear_script->hide();
}
//tool_buttons[TOOL_MULTI_EDIT]->set_disabled(EditorNode::get_singleton()->get_editor_selection()->get_selection().size()<2);
}
void SceneTreeDock::_create() {
@ -1557,16 +1484,6 @@ void SceneTreeDock::_import_subscene() {
import_subscene_dialog->move(parent, edited_scene);
editor_data->get_undo_redo().clear_history(); //no undo for now..
/*
editor_data->get_undo_redo().create_action("Import Subscene");
editor_data->get_undo_redo().add_do_method(parent,"add_child",ss);
//editor_data->get_undo_redo().add_do_method(editor_selection,"clear");
//editor_data->get_undo_redo().add_do_method(editor_selection,"add_node",child);
editor_data->get_undo_redo().add_do_reference(ss);
editor_data->get_undo_redo().add_undo_method(parent,"remove_child",ss);
editor_data->get_undo_redo().commit_action();
*/
}
void SceneTreeDock::_new_scene_from(String p_file) {
@ -1601,10 +1518,6 @@ void SceneTreeDock::_new_scene_from(String p_file) {
int flg = 0;
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
flg |= ResourceSaver::FLAG_COMPRESS;
/*
if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
*/
err = ResourceSaver::save(p_file, sdata, flg);
if (err != OK) {
@ -1704,7 +1617,6 @@ void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) {
if (_has_visible_children(to_node)) {
to_pos = 0;
} else {
for (int i = to_node->get_index() + 1; i < to_node->get_parent()->get_child_count(); i++) {
Node *c = to_node->get_parent()->get_child(i);
if (_is_node_visible(c)) {
@ -1718,26 +1630,6 @@ void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) {
to_node = to_node->get_parent();
}
#if 0
//quite complicated, look for next visible in tree
upper_sibling=_find_last_visible(upper_sibling);
if (upper_sibling->get_parent()==to_node->get_parent()) {
//just insert over this node because nothing is above at an upper level
to_pos=to_node->get_index();
to_node=to_node->get_parent();
} else {
to_pos=-1; //insert last in whathever is up
to_node=upper_sibling->get_parent(); //insert at a parent of whathever is up
}
} else {
//just insert over this node because nothing is above at the same level
to_pos=to_node->get_index();
to_node=to_node->get_parent();
}
#endif
}
}
@ -1857,9 +1749,6 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
menu->add_icon_shortcut(get_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE);
menu->add_separator();
menu->add_icon_shortcut(get_icon("Reload", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE);
//menu->add_separator(); moved to their own dock
//menu->add_icon_item(get_icon("Groups","EditorIcons"),TTR("Edit Groups"),TOOL_GROUP);
//menu->add_icon_item(get_icon("Connect","EditorIcons"),TTR("Edit Connections"),TOOL_CONNECT);
menu->add_separator();
menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT);
menu->add_icon_shortcut(get_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT);
@ -1945,7 +1834,6 @@ void SceneTreeDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_tool_selected"), &SceneTreeDock::_tool_selected, DEFVAL(false));
ClassDB::bind_method(D_METHOD("_create"), &SceneTreeDock::_create);
//ClassDB::bind_method(D_METHOD("_script_created"),&SceneTreeDock::_script_created);
ClassDB::bind_method(D_METHOD("_node_reparent"), &SceneTreeDock::_node_reparent);
ClassDB::bind_method(D_METHOD("_set_owners"), &SceneTreeDock::_set_owners);
ClassDB::bind_method(D_METHOD("_node_selected"), &SceneTreeDock::_node_selected);
@ -2062,14 +1950,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
add_child(create_dialog);
create_dialog->connect("create", this, "_create");
//groups_editor = memnew( GroupsEditor );
//add_child(groups_editor);
//groups_editor->set_undo_redo(&editor_data->get_undo_redo());
//connect_dialog = memnew( ConnectionsDialog(p_editor) );
//add_child(connect_dialog);
//connect_dialog->set_undoredo(&editor_data->get_undo_redo());
script_create_dialog = memnew(ScriptCreateDialog);
add_child(script_create_dialog);
script_create_dialog->connect("script_created", this, "_script_created");

View file

@ -30,12 +30,13 @@
#ifndef SCENE_TREE_DOCK_H
#define SCENE_TREE_DOCK_H
#include "connections_dialog.h"
#include "create_dialog.h"
#include "editor_data.h"
#include "editor_sub_scene.h"
#include "groups_editor.h"
#include "reparent_dialog.h"
#include "editor/connections_dialog.h"
#include "editor/create_dialog.h"
#include "editor/editor_data.h"
#include "editor/editor_sub_scene.h"
#include "editor/groups_editor.h"
#include "editor/reparent_dialog.h"
#include "editor/script_create_dialog.h"
#include "scene/animation/animation_player.h"
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
@ -45,7 +46,7 @@
#include "scene/gui/tool_button.h"
#include "scene/gui/tree.h"
#include "scene_tree_editor.h"
#include "script_create_dialog.h"
class EditorNode;
class SceneTreeDock : public VBoxContainer {
@ -57,8 +58,6 @@ class SceneTreeDock : public VBoxContainer {
TOOL_NEW,
TOOL_INSTANCE,
TOOL_REPLACE,
TOOL_CONNECT,
TOOL_GROUP,
TOOL_ATTACH_SCRIPT,
TOOL_CLEAR_SCRIPT,
TOOL_MOVE_UP,
@ -104,8 +103,6 @@ class SceneTreeDock : public VBoxContainer {
EditorData *editor_data;
EditorSelection *editor_selection;
//GroupsEditor *groups_editor;
//ConnectionsDialog *connect_dialog;
ScriptCreateDialog *script_create_dialog;
AcceptDialog *accept;
ConfirmationDialog *delete_dialog;

View file

@ -3557,14 +3557,6 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
listener_line_mesh->surface_set_material(0, mat);
}
sample_player_icon = Ref<SpatialMaterial>(memnew(SpatialMaterial));
sample_player_icon->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
sample_player_icon->set_cull_mode(SpatialMaterial::CULL_DISABLED);
sample_player_icon->set_depth_draw_mode(SpatialMaterial::DEPTH_DRAW_DISABLED);
sample_player_icon->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
sample_player_icon->set_albedo(Color(1, 1, 1, 0.9));
sample_player_icon->set_texture(SpatialMaterial::TEXTURE_ALBEDO, SpatialEditor::get_singleton()->get_icon("GizmoSpatialSamplePlayer", "EditorIcons"));
room_material = create_line_material(Color(1.0, 0.6, 0.9));
portal_material = create_line_material(Color(1.0, 0.8, 0.6));
raycast_material = create_line_material(Color(1.0, 0.8, 0.6));

View file

@ -28,21 +28,44 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_scene_types.h"
#include "os/os.h"
#include "project_settings.h"
#include "scene/io/resource_format_image.h"
#include "scene/io/resource_format_wav.h"
//#include "scene/io/scene_format_script.h"
#include "class_db.h"
#include "resources/default_theme/default_theme.h"
#include "core/class_db.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#include "scene/2d/animated_sprite.h"
#include "scene/2d/area_2d.h"
#include "scene/2d/audio_stream_player_2d.h"
#include "scene/2d/back_buffer_copy.h"
#include "scene/2d/camera_2d.h"
#include "scene/2d/canvas_item.h"
#include "scene/2d/canvas_modulate.h"
#include "scene/2d/collision_polygon_2d.h"
#include "scene/2d/collision_shape_2d.h"
#include "scene/2d/joints_2d.h"
#include "scene/2d/light_2d.h"
#include "scene/2d/light_occluder_2d.h"
#include "scene/2d/line_2d.h"
#include "scene/2d/navigation2d.h"
#include "scene/2d/parallax_background.h"
#include "scene/2d/parallax_layer.h"
#include "scene/2d/particles_2d.h"
#include "scene/2d/path_2d.h"
#include "scene/2d/physics_body_2d.h"
#include "scene/2d/polygon_2d.h"
#include "scene/2d/position_2d.h"
#include "scene/2d/ray_cast_2d.h"
#include "scene/2d/remote_transform_2d.h"
#include "scene/2d/screen_button.h"
#include "scene/2d/sprite.h"
#include "scene/2d/tile_map.h"
#include "scene/2d/visibility_notifier_2d.h"
#include "scene/2d/y_sort.h"
#include "scene/animation/animation_player.h"
#include "scene/animation/animation_tree_player.h"
#include "scene/animation/tween.h"
#include "scene/audio/audio_player.h"
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
#include "scene/gui/button_group.h"
#include "scene/gui/center_container.h"
#include "scene/gui/check_box.h"
@ -85,157 +108,90 @@
#include "scene/gui/tree.h"
#include "scene/gui/video_player.h"
#include "scene/gui/viewport_container.h"
#include "scene/io/resource_format_image.h"
#include "scene/io/resource_format_wav.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/http_request.h"
#include "scene/main/instance_placeholder.h"
#include "scene/main/viewport.h"
#include "scene/resources/audio_stream_sample.h"
#include "scene/resources/video_stream.h"
#include "scene/2d/animated_sprite.h"
#include "scene/2d/back_buffer_copy.h"
#include "scene/2d/canvas_item.h"
#include "scene/2d/polygon_2d.h"
#include "scene/2d/sprite.h"
#include "scene/2d/visibility_notifier_2d.h"
#include "scene/2d/area_2d.h"
#include "scene/2d/camera_2d.h"
#include "scene/2d/collision_polygon_2d.h"
#include "scene/2d/collision_shape_2d.h"
#include "scene/2d/joints_2d.h"
#include "scene/2d/parallax_background.h"
#include "scene/2d/parallax_layer.h"
#include "scene/2d/physics_body_2d.h"
#include "scene/2d/ray_cast_2d.h"
//#include "scene/2d/sound_player_2d.h"
//#include "scene/2d/sample_player_2d.h"
#include "scene/2d/audio_stream_player_2d.h"
#include "scene/2d/canvas_modulate.h"
#include "scene/2d/navigation2d.h"
#include "scene/2d/remote_transform_2d.h"
#include "scene/2d/screen_button.h"
#include "scene/2d/y_sort.h"
#include "scene/2d/position_2d.h"
#include "scene/2d/tile_map.h"
//#include "scene/2d/tile_map.h"
#include "scene/2d/line_2d.h"
#include "scene/resources/tile_set.h"
#include "scene/animation/animation_player.h"
#include "scene/animation/animation_tree_player.h"
#include "scene/animation/tween.h"
#include "scene/main/resource_preloader.h"
#include "scene/main/scene_tree.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/mesh_data_tool.h"
#include "scene/resources/surface_tool.h"
#include "scene/resources/dynamic_font.h"
#include "scene/resources/dynamic_font_stb.h"
#include "scene/main/timer.h"
#include "scene/audio/audio_player.h"
//#include "scene/audio/event_player.h"
//#include "scene/audio/sound_room_params.h"
#include "scene/main/viewport.h"
#include "scene/resources/audio_stream_sample.h"
#include "scene/resources/bit_mask.h"
#include "scene/resources/box_shape.h"
#include "scene/resources/capsule_shape.h"
#include "scene/resources/concave_polygon_shape.h"
#include "scene/resources/convex_polygon_shape.h"
#include "scene/resources/plane_shape.h"
#include "scene/resources/ray_shape.h"
#include "scene/resources/sphere_shape.h"
#include "scene/resources/capsule_shape_2d.h"
#include "scene/resources/circle_shape_2d.h"
#include "scene/resources/color_ramp.h"
#include "scene/resources/concave_polygon_shape.h"
#include "scene/resources/concave_polygon_shape_2d.h"
#include "scene/resources/convex_polygon_shape.h"
#include "scene/resources/convex_polygon_shape_2d.h"
#include "scene/resources/rectangle_shape_2d.h"
#include "scene/resources/segment_shape_2d.h"
#include "scene/resources/shape_line_2d.h"
#include "scene/resources/mesh_library.h"
#include "scene/resources/polygon_path_finder.h"
//#include "scene/resources/sample.h"
#include "scene/3d/audio_stream_player_3d.h"
#include "scene/resources/default_theme/default_theme.h"
#include "scene/resources/dynamic_font.h"
#include "scene/resources/dynamic_font_stb.h"
#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
#include "scene/resources/sky_box.h"
#include "scene/resources/texture.h"
#include "scene/resources/mesh_data_tool.h"
#include "scene/resources/mesh_library.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/plane_shape.h"
#include "scene/resources/polygon_path_finder.h"
#include "scene/resources/primitive_meshes.h"
#include "scene/resources/ray_shape.h"
#include "scene/resources/rectangle_shape_2d.h"
#include "scene/resources/scene_format_text.h"
#include "scene/resources/segment_shape_2d.h"
#include "scene/resources/shader_graph.h"
#include "scene/resources/shape_line_2d.h"
#include "scene/resources/sky_box.h"
#include "scene/resources/sphere_shape.h"
#include "scene/resources/surface_tool.h"
#include "scene/resources/texture.h"
#include "scene/resources/tile_set.h"
#include "scene/resources/video_stream.h"
#include "scene/resources/world.h"
#include "scene/resources/world_2d.h"
//#include "scene/resources/sample_library.h"
//#include "scene/resources/audio_stream.h"
#include "scene/resources/bit_mask.h"
#include "scene/resources/color_ramp.h"
#include "scene/resources/gibberish_stream.h"
#include "scene/scene_string_names.h"
#ifndef _3D_DISABLED
#include "scene/3d/area.h"
#include "scene/3d/arvr_nodes.h"
#include "scene/3d/audio_stream_player_3d.h"
#include "scene/3d/bone_attachment.h"
#include "scene/3d/camera.h"
#include "scene/3d/collision_polygon.h"
#include "scene/3d/collision_shape.h"
#include "scene/3d/gi_probe.h"
#include "scene/3d/immediate_geometry.h"
#include "scene/3d/interpolated_camera.h"
#include "scene/3d/light.h"
#include "scene/3d/listener.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/multimesh_instance.h"
#include "scene/3d/navigation.h"
#include "scene/3d/navigation_mesh.h"
#include "scene/3d/particles.h"
#include "scene/3d/path.h"
#include "scene/3d/physics_body.h"
#include "scene/3d/physics_joint.h"
#include "scene/3d/portal.h"
#include "scene/3d/position_3d.h"
#include "scene/3d/proximity_group.h"
#include "scene/3d/ray_cast.h"
#include "scene/3d/reflection_probe.h"
#include "scene/3d/remote_transform.h"
#include "scene/3d/room_instance.h"
#include "scene/3d/scenario_fx.h"
#include "scene/3d/skeleton.h"
#include "scene/3d/spatial.h"
#include "scene/3d/visibility_notifier.h"
#ifndef _3D_DISABLED
#include "scene/3d/camera.h"
#include "scene/3d/listener.h"
#include "scene/3d/arvr_nodes.h"
#include "scene/3d/gi_probe.h"
#include "scene/3d/interpolated_camera.h"
#include "scene/3d/light.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/particles.h"
#include "scene/3d/physics_body.h"
#include "scene/3d/portal.h"
#include "scene/3d/position_3d.h"
#include "scene/3d/reflection_probe.h"
#include "scene/resources/environment.h"
#include "scene/3d/area.h"
#include "scene/3d/collision_shape.h"
#include "scene/3d/immediate_geometry.h"
#include "scene/3d/multimesh_instance.h"
#include "scene/3d/physics_joint.h"
#include "scene/3d/ray_cast.h"
#include "scene/3d/sprite_3d.h"
#include "scene/3d/vehicle_body.h"
//#include "scene/3d/spatial_sample_player.h"
//#include "scene/3d/spatial_stream_player.h"
#include "scene/3d/collision_polygon.h"
#include "scene/3d/navigation.h"
#include "scene/3d/navigation_mesh.h"
#include "scene/3d/proximity_group.h"
#include "scene/3d/visibility_notifier.h"
#include "scene/resources/environment.h"
#endif
#include "scene/resources/scene_format_text.h"
//static ResourceFormatLoaderWAV *resource_loader_wav=NULL;
#ifdef TOOLS_ENABLED
#endif
static ResourceFormatLoaderTheme *resource_loader_theme = NULL;
static ResourceFormatSaverText *resource_saver_text = NULL;
@ -245,8 +201,6 @@ static ResourceFormatLoaderDynamicFont *resource_loader_dynamic_font = NULL;
static ResourceFormatLoaderStreamTexture *resource_loader_stream_texture = NULL;
//static SceneStringNames *string_names;
void register_scene_types() {
SceneStringNames::create();
@ -255,20 +209,12 @@ void register_scene_types() {
Node::init_node_hrcr();
//resource_loader_wav = memnew( ResourceFormatLoaderWAV );
//ResourceLoader::add_resource_format_loader( resource_loader_wav );
resource_loader_dynamic_font = memnew(ResourceFormatLoaderDynamicFont);
ResourceLoader::add_resource_format_loader(resource_loader_dynamic_font);
resource_loader_stream_texture = memnew(ResourceFormatLoaderStreamTexture);
ResourceLoader::add_resource_format_loader(resource_loader_stream_texture);
#ifdef TOOLS_ENABLED
//scene first!
#endif
resource_loader_theme = memnew(ResourceFormatLoaderTheme);
ResourceLoader::add_resource_format_loader(resource_loader_theme);
@ -316,7 +262,6 @@ void register_scene_types() {
ClassDB::register_class<ShortCut>();
ClassDB::register_class<Control>();
//ClassDB::register_type<EmptyControl>();
ClassDB::register_class<Button>();
ClassDB::register_class<Label>();
ClassDB::register_class<HScrollBar>();
@ -424,7 +369,6 @@ void register_scene_types() {
ClassDB::register_class<GIProbe>();
ClassDB::register_class<GIProbeData>();
ClassDB::register_class<AnimationTreePlayer>();
//ClassDB::register_class<Portal>();
ClassDB::register_class<Particles>();
ClassDB::register_class<Position3D>();
ClassDB::register_class<NavigationMeshInstance>();
@ -452,8 +396,6 @@ void register_scene_types() {
ClassDB::register_class<PathFollow>();
ClassDB::register_class<VisibilityNotifier>();
ClassDB::register_class<VisibilityEnabler>();
// ClassDB::register_class<BakedLight>();
//ClassDB::register_type<BakedLightSampler>();
ClassDB::register_class<WorldEnvironment>();
ClassDB::register_class<RemoteTransform>();
@ -464,8 +406,6 @@ void register_scene_types() {
ClassDB::register_class<ConeTwistJoint>();
ClassDB::register_class<Generic6DOFJoint>();
//scenariofx
OS::get_singleton()->yield(); //may take time to init
#endif
@ -545,7 +485,6 @@ void register_scene_types() {
SceneTree::add_idle_callback(ParticlesMaterial::flush_changes);
ParticlesMaterial::init_shaders();
//ClassDB::register_type<ShaderMaterial>();
ClassDB::register_class<MultiMesh>();
ClassDB::register_class<MeshLibrary>();
@ -561,7 +500,6 @@ void register_scene_types() {
ClassDB::register_class<SurfaceTool>();
ClassDB::register_class<MeshDataTool>();
//ClassDB::register_type<BakedLight>();
OS::get_singleton()->yield(); //may take time to init
@ -660,14 +598,8 @@ void unregister_scene_types() {
clear_default_theme();
// memdelete( resource_loader_wav );
memdelete(resource_loader_dynamic_font);
memdelete(resource_loader_stream_texture);
#ifdef TOOLS_ENABLED
#endif
memdelete(resource_loader_theme);
if (resource_saver_text) {

View file

@ -1,337 +0,0 @@
/*************************************************************************/
/* gibberish_stream.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* 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 "gibberish_stream.h"
#include "servers/audio_server.h"
//TODO: This class needs to be adapted to the new AudioStream API,
// or dropped if nobody cares about fixing it :) (GH-3307)
#if 0
int AudioStreamGibberish::get_channel_count() const {
return 1;
}
static float _get_vol_at_pos(int p_pos, int p_len, int p_x_fade) {
if (p_pos < p_x_fade)
return float(p_pos)/p_x_fade;
else if (p_pos>(p_len-p_x_fade))
return float(p_len-p_pos)/p_x_fade;
else
return 1.0;
}
int AudioStreamGibberish::randomize() {
if (rand_idx==_rand_pool.size()) {
for(int i=0;i<_rand_pool.size();i++) {
SWAP(_rand_pool[i],_rand_pool[Math::rand()%_rand_pool.size()]);
}
rand_idx=0;
}
return _rand_pool[rand_idx++];
}
bool AudioStreamGibberish::mix(int32_t *p_buffer, int p_frames) {
if (!active)
return false;
zeromem(p_buffer,p_frames*sizeof(int32_t));
if (!paused && active_voices==0) {
active_voices=1;
playback[0].idx=randomize();
playback[0].fp_pos=0;
playback[0].scale=Math::random(1,1+pitch_random_scale);
}
for(int i=0;i<active_voices;i++) {
RID s = _samples[playback[i].idx]->get_rid();
uint64_t fp_pos=playback[i].fp_pos;
const void *data = AudioServer::get_singleton()->sample_get_data_ptr(s);
bool is16 = AudioServer::get_singleton()->sample_get_format(s)==AudioServer::SAMPLE_FORMAT_PCM16;
int skip = AudioServer::get_singleton()->sample_is_stereo(s) ? 1: 0;
uint64_t max = AudioServer::get_singleton()->sample_get_length(s) * uint64_t(FP_LEN);
int mrate = AudioServer::get_singleton()->sample_get_mix_rate(s) * pitch_scale * playback[i].scale;
uint64_t increment = uint64_t(mrate) * uint64_t(FP_LEN) / get_mix_rate();
float vol_begin = _get_vol_at_pos(fp_pos>>FP_BITS,max>>FP_BITS,xfade_time*mrate);
float vol_end = _get_vol_at_pos((fp_pos+p_frames*increment)>>FP_BITS,max>>FP_BITS,xfade_time*mrate);
int32_t vol = CLAMP(int32_t(vol_begin * 65535),0,65535);
int32_t vol_to = CLAMP(int32_t(vol_end * 65535),0,65535);
int32_t vol_inc = (vol_to-vol)/p_frames;
bool done=false;
if (is16) {
const int16_t *smp = (int16_t*)data;
for(int i=0;i<p_frames;i++) {
if (fp_pos >= max) {
done=true;
break;
}
int idx = (fp_pos>>FP_BITS)<<skip;
p_buffer[i]+=int32_t(smp[idx])*vol;
vol+=vol_inc;
fp_pos+=increment;
}
} else {
const int8_t *smp = (int8_t*)data;
for(int i=0;i<p_frames;i++) {
if (fp_pos >= max) {
done=true;
break;
}
int idx = (fp_pos>>FP_BITS)<<skip;
p_buffer[i]+=(int32_t(smp[idx])<<8)*vol;
vol+=vol_inc;
fp_pos+=increment;
}
}
playback[i].fp_pos=fp_pos;
if (!paused && active_voices==1 && (vol_end < vol_begin || done)) {
//xfade to something else i gues
active_voices=2;
playback[1].idx=randomize();
playback[1].fp_pos=0;
playback[1].scale=Math::random(1,1+pitch_random_scale);
}
if (done) {
if (i==0 && active_voices==2) {
playback[0]=playback[1];
i--;
}
active_voices--;
}
}
return true;
}
void AudioStreamGibberish::play() {
if (active)
stop();
if (!phonemes.is_valid())
return;
List<StringName> slist;
phonemes->get_sample_list(&slist);
if (slist.size()==0)
return;
_samples.resize(slist.size());
_rand_pool.resize(slist.size());
int i=0;
for(List<StringName>::Element *E=slist.front();E;E=E->next()) {
_rand_pool[i]=i;
_samples[i++]=phonemes->get_sample(E->get());
}
rand_idx=0;
active_voices=0;
active=true;
}
void AudioStreamGibberish::stop(){
active=false;
}
bool AudioStreamGibberish::is_playing() const {
return active;
}
void AudioStreamGibberish::set_paused(bool p_paused){
paused=p_paused;
}
bool AudioStreamGibberish::is_paused(bool p_paused) const{
return paused;
}
void AudioStreamGibberish::set_loop(bool p_enable){
}
bool AudioStreamGibberish::has_loop() const{
return false;
}
float AudioStreamGibberish::get_length() const{
return 0;
}
String AudioStreamGibberish::get_stream_name() const{
return "Gibberish";
}
int AudioStreamGibberish::get_loop_count() const{
return 0;
}
float AudioStreamGibberish::get_pos() const{
return 0;
}
void AudioStreamGibberish::seek_pos(float p_time){
}
AudioStream::UpdateMode AudioStreamGibberish::get_update_mode() const{
return AudioStream::UPDATE_NONE;
}
void AudioStreamGibberish::update(){
}
void AudioStreamGibberish::set_phonemes(const Ref<SampleLibrary>& p_phonemes) {
phonemes=p_phonemes;
}
Ref<SampleLibrary> AudioStreamGibberish::get_phonemes() const {
return phonemes;
}
void AudioStreamGibberish::set_xfade_time(float p_xfade) {
xfade_time=p_xfade;
}
float AudioStreamGibberish::get_xfade_time() const {
return xfade_time;
}
void AudioStreamGibberish::set_pitch_scale(float p_scale) {
pitch_scale=p_scale;
}
float AudioStreamGibberish::get_pitch_scale() const {
return pitch_scale;
}
void AudioStreamGibberish::set_pitch_random_scale(float p_random_scale) {
pitch_random_scale=p_random_scale;
}
float AudioStreamGibberish::get_pitch_random_scale() const {
return pitch_random_scale;
}
void AudioStreamGibberish::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_phonemes","phonemes"),&AudioStreamGibberish::set_phonemes);
ClassDB::bind_method(D_METHOD("get_phonemes"),&AudioStreamGibberish::get_phonemes);
ClassDB::bind_method(D_METHOD("set_pitch_scale","pitch_scale"),&AudioStreamGibberish::set_pitch_scale);
ClassDB::bind_method(D_METHOD("get_pitch_scale"),&AudioStreamGibberish::get_pitch_scale);
ClassDB::bind_method(D_METHOD("set_pitch_random_scale","pitch_random_scale"),&AudioStreamGibberish::set_pitch_random_scale);
ClassDB::bind_method(D_METHOD("get_pitch_random_scale"),&AudioStreamGibberish::get_pitch_random_scale);
ClassDB::bind_method(D_METHOD("set_xfade_time","sec"),&AudioStreamGibberish::set_xfade_time);
ClassDB::bind_method(D_METHOD("get_xfade_time"),&AudioStreamGibberish::get_xfade_time);
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"phonemes",PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),"set_phonemes","get_phonemes");
ADD_PROPERTY( PropertyInfo(Variant::REAL,"pitch_scale",PROPERTY_HINT_RANGE,"0.01,64,0.01"),"set_pitch_scale","get_pitch_scale");
ADD_PROPERTY( PropertyInfo(Variant::REAL,"pitch_random_scale",PROPERTY_HINT_RANGE,"0,64,0.01"),"set_pitch_random_scale","get_pitch_random_scale");
ADD_PROPERTY( PropertyInfo(Variant::REAL,"xfade_sec",PROPERTY_HINT_RANGE,"0.001,0.5,0.001"),"set_xfade_time","get_xfade_time");
}
AudioStreamGibberish::AudioStreamGibberish() {
xfade_time=0.1;
pitch_scale=1;
pitch_random_scale=0;
active=false;
paused=false;
active_voices=0;
}
#endif

View file

@ -1,118 +0,0 @@
/*************************************************************************/
/* gibberish_stream.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* 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 GIBBERISH_STREAM_H
#define GIBBERISH_STREAM_H
//TODO: This class needs to be adapted to the new AudioStream API,
// or dropped if nobody cares about fixing it :) (GH-3307)
#if 0
#include "scene/resources/audio_stream.h"
#include "scene/resources/sample_library.h"
class AudioStreamGibberish : public AudioStream {
GDCLASS( AudioStreamGibberish, AudioStream );
enum {
FP_BITS = 12,
FP_LEN = (1<<12),
};
bool active;
bool paused;
float xfade_time;
float pitch_scale;
float pitch_random_scale;
Vector<Ref<Sample> > _samples;
Vector<int> _rand_pool;
int rand_idx;
_FORCE_INLINE_ int randomize();
struct Playback {
int idx;
uint64_t fp_pos;
float scale;
};
Playback playback[2];
int active_voices;
Ref<SampleLibrary> phonemes;
protected:
virtual int get_channel_count() const;
virtual bool mix(int32_t *p_buffer, int p_frames);
static void _bind_methods();
public:
void set_phonemes(const Ref<SampleLibrary>& p_phonemes);
Ref<SampleLibrary> get_phonemes() const;
virtual void play();
virtual void stop();
virtual bool is_playing() const;
virtual void set_paused(bool p_paused);
virtual bool is_paused(bool p_paused) const;
virtual void set_loop(bool p_enable);
virtual bool has_loop() const;
virtual float get_length() const;
virtual String get_stream_name() const;
virtual int get_loop_count() const;
virtual float get_pos() const;
virtual void seek_pos(float p_time);
virtual UpdateMode get_update_mode() const;
virtual void update();
void set_xfade_time(float p_xfade);
float get_xfade_time() const;
void set_pitch_scale(float p_scale);
float get_pitch_scale() const;
void set_pitch_random_scale(float p_random_scale);
float get_pitch_random_scale() const;
AudioStreamGibberish();
};
#endif
#endif // GIBBERISH_STREAM_H

View file

@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "material.h"
#include "scene/scene_string_names.h"
void Material::set_next_pass(const Ref<Material> &p_pass) {