mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-05 23:07:42 -05:00
Rename SVGTexture to DPITexture.
This commit is contained in:
@@ -31,14 +31,14 @@
|
||||
#include "resource_importer_svg.h"
|
||||
|
||||
#include "core/io/file_access.h"
|
||||
#include "scene/resources/svg_texture.h"
|
||||
#include "scene/resources/dpi_texture.h"
|
||||
|
||||
String ResourceImporterSVG::get_importer_name() const {
|
||||
return "svg";
|
||||
}
|
||||
|
||||
String ResourceImporterSVG::get_visible_name() const {
|
||||
return "SVGTexture";
|
||||
return "DPITexture";
|
||||
}
|
||||
|
||||
void ResourceImporterSVG::get_recognized_extensions(List<String> *p_extensions) const {
|
||||
@@ -46,11 +46,11 @@ void ResourceImporterSVG::get_recognized_extensions(List<String> *p_extensions)
|
||||
}
|
||||
|
||||
String ResourceImporterSVG::get_save_extension() const {
|
||||
return "svgtex";
|
||||
return "dpitex";
|
||||
}
|
||||
|
||||
String ResourceImporterSVG::get_resource_type() const {
|
||||
return "SVGTexture";
|
||||
return "DPITexture";
|
||||
}
|
||||
|
||||
bool ResourceImporterSVG::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
|
||||
@@ -73,8 +73,8 @@ void ResourceImporterSVG::get_import_options(const String &p_path, List<ImportOp
|
||||
}
|
||||
|
||||
Error ResourceImporterSVG::import(ResourceUID::ID p_source_id, const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
|
||||
Ref<SVGTexture> svg_tex;
|
||||
svg_tex.instantiate();
|
||||
Ref<DPITexture> dpi_tex;
|
||||
dpi_tex.instantiate();
|
||||
|
||||
String source = FileAccess::get_file_as_string(p_source_file);
|
||||
ERR_FAIL_COND_V_MSG(source.is_empty(), ERR_CANT_OPEN, vformat("Cannot open file from path \"%s\".", p_source_file));
|
||||
@@ -83,22 +83,22 @@ Error ResourceImporterSVG::import(ResourceUID::ID p_source_id, const String &p_s
|
||||
double saturation = p_options["saturation"];
|
||||
Dictionary color_map = p_options["color_map"];
|
||||
|
||||
svg_tex->set_base_scale(base_scale);
|
||||
svg_tex->set_saturation(saturation);
|
||||
svg_tex->set_color_map(color_map);
|
||||
svg_tex->set_source(source);
|
||||
dpi_tex->set_base_scale(base_scale);
|
||||
dpi_tex->set_saturation(saturation);
|
||||
dpi_tex->set_color_map(color_map);
|
||||
dpi_tex->set_source(source);
|
||||
|
||||
ERR_FAIL_COND_V_MSG(svg_tex->get_rid().is_null(), ERR_CANT_OPEN, vformat("Failed loading SVG, unsupported or invalid SVG data in \"%s\".", p_source_file));
|
||||
ERR_FAIL_COND_V_MSG(dpi_tex->get_rid().is_null(), ERR_CANT_OPEN, vformat("Failed loading SVG, unsupported or invalid SVG data in \"%s\".", p_source_file));
|
||||
|
||||
int flg = 0;
|
||||
if ((bool)p_options["compress"]) {
|
||||
flg |= ResourceSaver::SaverFlags::FLAG_COMPRESS;
|
||||
}
|
||||
|
||||
print_verbose("Saving to: " + p_save_path + ".svgtex");
|
||||
Error err = ResourceSaver::save(svg_tex, p_save_path + ".svgtex", flg);
|
||||
ERR_FAIL_COND_V_MSG(err != OK, err, vformat("Cannot save SVG texture to file \"%s.svgtex\".", p_save_path));
|
||||
print_verbose("Done saving to: " + p_save_path + ".svgtex");
|
||||
print_verbose("Saving to: " + p_save_path + ".dpitex");
|
||||
Error err = ResourceSaver::save(dpi_tex, p_save_path + ".dpitex", flg);
|
||||
ERR_FAIL_COND_V_MSG(err != OK, err, vformat("Cannot save DPI texture to file \"%s.dpitex\".", p_save_path));
|
||||
print_verbose("Done saving to: " + p_save_path + ".dpitex");
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
#include "editor/themes/editor_color_map.h"
|
||||
#include "editor/themes/editor_icons.gen.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
#include "scene/resources/dpi_texture.h"
|
||||
#include "scene/resources/image_texture.h"
|
||||
#include "scene/resources/svg_texture.h"
|
||||
|
||||
#include "modules/svg/image_loader_svg.h"
|
||||
|
||||
@@ -48,8 +48,8 @@ void editor_configure_icons(bool p_dark_theme) {
|
||||
}
|
||||
|
||||
// See also `generate_icon()` in `scene/theme/default_theme.cpp`.
|
||||
Ref<SVGTexture> editor_generate_icon(int p_index, float p_scale, float p_saturation, const Dictionary &p_convert_colors = Dictionary()) {
|
||||
return SVGTexture::create_from_string(editor_icons_sources[p_index], p_scale, p_saturation, p_convert_colors);
|
||||
Ref<DPITexture> editor_generate_icon(int p_index, float p_scale, float p_saturation, const Dictionary &p_convert_colors = Dictionary()) {
|
||||
return DPITexture::create_from_string(editor_icons_sources[p_index], p_scale, p_saturation, p_convert_colors);
|
||||
}
|
||||
|
||||
float get_gizmo_handle_scale(const String &p_gizmo_handle_name, float p_gizmo_handle_scale) {
|
||||
@@ -154,14 +154,14 @@ void editor_register_icons(const Ref<Theme> &p_theme, bool p_dark_theme, float p
|
||||
saturation = 1.0;
|
||||
}
|
||||
|
||||
Ref<SVGTexture> icon_dark = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map_dark);
|
||||
Ref<SVGTexture> icon_light = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map_light);
|
||||
Ref<DPITexture> icon_dark = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map_dark);
|
||||
Ref<DPITexture> icon_light = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map_light);
|
||||
|
||||
p_theme->set_icon(editor_icon_name + "Dark", EditorStringName(EditorIcons), icon_dark);
|
||||
p_theme->set_icon(editor_icon_name + "Light", EditorStringName(EditorIcons), icon_light);
|
||||
p_theme->set_icon(editor_icon_name, EditorStringName(EditorIcons), p_dark_theme ? icon_dark : icon_light);
|
||||
} else {
|
||||
Ref<SVGTexture> icon;
|
||||
Ref<DPITexture> icon;
|
||||
if (accent_color_icons.has(editor_icon_name)) {
|
||||
icon = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), 1.0, accent_color_map);
|
||||
} else {
|
||||
@@ -188,7 +188,7 @@ void editor_register_icons(const Ref<Theme> &p_theme, bool p_dark_theme, float p
|
||||
const float scale = (float)p_thumb_size / 64.0 * EDSCALE;
|
||||
for (int i = 0; i < editor_bg_thumbs_count; i++) {
|
||||
const int index = editor_bg_thumbs_indices[i];
|
||||
Ref<SVGTexture> icon;
|
||||
Ref<DPITexture> icon;
|
||||
|
||||
if (accent_color_icons.has(editor_icons_names[index])) {
|
||||
icon = editor_generate_icon(index, scale, 1.0, accent_color_map);
|
||||
@@ -211,7 +211,7 @@ void editor_register_icons(const Ref<Theme> &p_theme, bool p_dark_theme, float p
|
||||
const float scale = (float)p_thumb_size / 32.0 * EDSCALE;
|
||||
for (int i = 0; i < editor_md_thumbs_count; i++) {
|
||||
const int index = editor_md_thumbs_indices[i];
|
||||
Ref<SVGTexture> icon;
|
||||
Ref<DPITexture> icon;
|
||||
|
||||
if (accent_color_icons.has(editor_icons_names[index])) {
|
||||
icon = editor_generate_icon(index, scale, 1.0, accent_color_map);
|
||||
|
||||
@@ -41,11 +41,11 @@
|
||||
#include "editor/themes/editor_scale.h"
|
||||
#include "editor/themes/editor_theme.h"
|
||||
#include "scene/gui/graph_edit.h"
|
||||
#include "scene/resources/dpi_texture.h"
|
||||
#include "scene/resources/image_texture.h"
|
||||
#include "scene/resources/style_box_flat.h"
|
||||
#include "scene/resources/style_box_line.h"
|
||||
#include "scene/resources/style_box_texture.h"
|
||||
#include "scene/resources/svg_texture.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
// Theme configuration.
|
||||
@@ -1726,7 +1726,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_the
|
||||
p_theme->set_constant("port_h_offset", "GraphNode", 1);
|
||||
p_theme->set_constant("separation", "GraphNode", 1 * EDSCALE);
|
||||
|
||||
Ref<SVGTexture> port_icon = p_theme->get_icon(SNAME("GuiGraphNodePort"), EditorStringName(EditorIcons));
|
||||
Ref<DPITexture> port_icon = p_theme->get_icon(SNAME("GuiGraphNodePort"), EditorStringName(EditorIcons));
|
||||
// The true size is 24x24 This is necessary for sharp port icons at high zoom levels in GraphEdit (up to ~200%).
|
||||
port_icon->set_size_override(Size2(12, 12));
|
||||
p_theme->set_icon("port", "GraphNode", port_icon);
|
||||
|
||||
Reference in New Issue
Block a user