@@ -1710,20 +1710,20 @@ void VisualShaderEditor::_get_current_mode_limits(int &r_begin_type, int &r_end_
17101710 switch (visual_shader->get_mode ()) {
17111711 case Shader::MODE_CANVAS_ITEM:
17121712 case Shader::MODE_SPATIAL: {
1713- r_begin_type = 0 ;
1714- r_end_type = 3 ;
1713+ r_begin_type = VisualShader::TYPE_VERTEX ;
1714+ r_end_type = VisualShader::TYPE_START ;
17151715 } break ;
17161716 case Shader::MODE_PARTICLES: {
1717- r_begin_type = 3 ;
1718- r_end_type = 5 + r_begin_type ;
1717+ r_begin_type = VisualShader::TYPE_START ;
1718+ r_end_type = VisualShader::TYPE_SKY ;
17191719 } break ;
17201720 case Shader::MODE_SKY: {
1721- r_begin_type = 8 ;
1722- r_end_type = 1 + r_begin_type ;
1721+ r_begin_type = VisualShader::TYPE_SKY ;
1722+ r_end_type = VisualShader::TYPE_FOG ;
17231723 } break ;
17241724 case Shader::MODE_FOG: {
1725- r_begin_type = 9 ;
1726- r_end_type = 1 + r_begin_type ;
1725+ r_begin_type = VisualShader::TYPE_FOG ;
1726+ r_end_type = VisualShader::TYPE_MAX ;
17271727 } break ;
17281728 default : {
17291729 } break ;
@@ -2500,8 +2500,30 @@ void VisualShaderEditor::_set_mode(int p_which) {
25002500
25012501 const String id_string = _get_cache_id_string ();
25022502
2503- int saved_type = vs_editor_cache->get_value (id_string, " edited_type" , 0 );
2504- edit_type->select (saved_type);
2503+ int default_type = VisualShader::TYPE_VERTEX;
2504+ int upper_type = VisualShader::TYPE_START;
2505+ if (mode & MODE_FLAGS_PARTICLES) {
2506+ default_type = VisualShader::TYPE_START;
2507+ upper_type = VisualShader::TYPE_SKY;
2508+ } else if (mode & MODE_FLAGS_SKY) {
2509+ default_type = VisualShader::TYPE_SKY;
2510+ upper_type = VisualShader::TYPE_FOG;
2511+ } else if (mode & MODE_FLAGS_FOG) {
2512+ default_type = VisualShader::TYPE_FOG;
2513+ upper_type = VisualShader::TYPE_MAX;
2514+ }
2515+
2516+ int saved_type = vs_editor_cache->get_value (id_string, " edited_type" , default_type);
2517+ if (saved_type >= upper_type || saved_type < default_type) {
2518+ saved_type = default_type;
2519+ }
2520+
2521+ if (mode & MODE_FLAGS_PARTICLES && saved_type - default_type >= 3 ) {
2522+ edit_type->select (saved_type - default_type - 3 );
2523+ custom_mode_box->set_pressed (true );
2524+ } else {
2525+ edit_type->select (saved_type - default_type);
2526+ }
25052527 set_current_shader_type ((VisualShader::Type)saved_type);
25062528}
25072529
@@ -5612,9 +5634,9 @@ void VisualShaderEditor::_paste_nodes(bool p_use_custom_position, const Vector2
56125634}
56135635
56145636void VisualShaderEditor::_type_selected (int p_id) {
5615- int offset = 0 ;
5637+ int offset = VisualShader::TYPE_VERTEX ;
56165638 if (mode & MODE_FLAGS_PARTICLES) {
5617- offset = 3 ;
5639+ offset = VisualShader::TYPE_START ;
56185640 if (p_id + offset > VisualShader::TYPE_PROCESS) {
56195641 custom_mode_box->set_visible (false );
56205642 custom_mode_enabled = false ;
@@ -5626,9 +5648,9 @@ void VisualShaderEditor::_type_selected(int p_id) {
56265648 }
56275649 }
56285650 } else if (mode & MODE_FLAGS_SKY) {
5629- offset = 8 ;
5651+ offset = VisualShader::TYPE_SKY ;
56305652 } else if (mode & MODE_FLAGS_FOG) {
5631- offset = 9 ;
5653+ offset = VisualShader::TYPE_FOG ;
56325654 }
56335655
56345656 set_current_shader_type (VisualShader::Type (p_id + offset));
0 commit comments