Path: blob/master/editor/shader/shader_create_dialog.h
9902 views
/**************************************************************************/1/* shader_create_dialog.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "editor/settings/editor_settings.h"33#include "scene/gui/check_box.h"34#include "scene/gui/dialogs.h"35#include "scene/gui/grid_container.h"36#include "scene/gui/line_edit.h"37#include "scene/gui/option_button.h"38#include "scene/gui/panel_container.h"3940class EditorFileDialog;41class EditorValidationPanel;4243class ShaderCreateDialog : public ConfirmationDialog {44GDCLASS(ShaderCreateDialog, ConfirmationDialog);4546enum {47MSG_ID_SHADER,48MSG_ID_PATH,49MSG_ID_BUILT_IN,50};5152struct ShaderTypeData {53List<String> extensions;54String default_extension;55bool use_templates = false;56};5758List<ShaderTypeData> type_data;5960GridContainer *gc = nullptr;61EditorValidationPanel *validation_panel = nullptr;62OptionButton *type_menu = nullptr;63OptionButton *mode_menu = nullptr;64OptionButton *template_menu = nullptr;65CheckBox *internal = nullptr;66LineEdit *file_path = nullptr;67Button *path_button = nullptr;68EditorFileDialog *file_browse = nullptr;69AcceptDialog *alert = nullptr;7071String initial_base_path;72String path_error;73bool is_new_shader_created = true;74bool is_path_valid = false;75bool is_built_in = false;76bool built_in_enabled = true;77bool load_enabled = false;78bool re_check_path = false;79int current_type = -1;80int default_type = -1;81int current_mode = 0;82int current_template = 0;8384virtual void _update_language_info();8586void _path_hbox_sorted();87void _path_changed(const String &p_path = String());88void _path_submitted(const String &p_path = String());89void _type_changed(int p_type = 0);90void _built_in_toggled(bool p_enabled);91void _template_changed(int p_template = 0);92void _mode_changed(int p_mode = 0);93void _browse_path();94void _file_selected(const String &p_file);95String _validate_path(const String &p_path);96virtual void ok_pressed() override;97void _create_new();98void _load_exist();99void _update_dialog();100101protected:102void _notification(int p_what);103static void _bind_methods();104105public:106void config(const String &p_base_path, bool p_built_in_enabled = true, bool p_load_enabled = true, int p_preferred_type = -1, int p_preferred_mode = -1);107ShaderCreateDialog();108};109110111