Merge branch 'master' of https://github.com/okamstudio/godot into add_sprintf
1
.gitignore
vendored
@ -259,3 +259,4 @@ Desktop.ini
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
logo.h
|
||||
*.autosave
|
||||
|
@ -116,6 +116,7 @@ opts.Add("CFLAGS", "Custom flags for the C compiler");
|
||||
opts.Add("LINKFLAGS", "Custom flags for the linker");
|
||||
opts.Add('disable_3d', 'Disable 3D nodes for smaller executable (yes/no)', "no")
|
||||
opts.Add('disable_advanced_gui', 'Disable advance 3D gui nodes and behaviors (yes/no)', "no")
|
||||
opts.Add('colored', 'Enable colored output for the compilation (yes/no)', 'no')
|
||||
|
||||
# add platform specific options
|
||||
|
||||
@ -299,6 +300,9 @@ if selected_platform in platform_list:
|
||||
if (env['xml']=='yes'):
|
||||
env.Append(CPPFLAGS=['-DXML_ENABLED'])
|
||||
|
||||
if (env['colored']=='yes'):
|
||||
methods.colored(sys,env)
|
||||
|
||||
|
||||
Export('env')
|
||||
|
||||
|
@ -642,7 +642,7 @@ void _OS::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("has_touchscreen_ui_hint"),&_OS::has_touchscreen_ui_hint);
|
||||
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_window_title","title"),&_OS::set_window_title);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_low_processor_usage_mode","enable"),&_OS::set_low_processor_usage_mode);
|
||||
ObjectTypeDB::bind_method(_MD("is_in_low_processor_usage_mode"),&_OS::is_in_low_processor_usage_mode);
|
||||
|
@ -225,7 +225,7 @@ Color Color::inverted() const {
|
||||
Color Color::contrasted() const {
|
||||
|
||||
Color c=*this;
|
||||
c.contrasted();
|
||||
c.contrast();
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ typedef signed short int16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef signed int int32_t;
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
@ -847,8 +847,15 @@ void ObjectTypeDB::set_type_enabled(StringName p_type,bool p_enable) {
|
||||
|
||||
bool ObjectTypeDB::is_type_enabled(StringName p_type) {
|
||||
|
||||
ERR_FAIL_COND_V(!types.has(p_type),false);
|
||||
return !types[p_type].disabled;
|
||||
TypeInfo *ti=types.getptr(p_type);
|
||||
if (!ti || !ti->creation_func) {
|
||||
if (compat_types.has(p_type)) {
|
||||
ti=types.getptr(compat_types[p_type]);
|
||||
}
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(!ti,false);
|
||||
return !ti->disabled;
|
||||
}
|
||||
|
||||
StringName ObjectTypeDB::get_category(const StringName& p_node) {
|
||||
|
@ -62,6 +62,8 @@ void Input::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("set_mouse_mode","mode"),&Input::set_mouse_mode);
|
||||
ObjectTypeDB::bind_method(_MD("get_mouse_mode"),&Input::get_mouse_mode);
|
||||
ObjectTypeDB::bind_method(_MD("warp_mouse_pos","to"),&Input::warp_mouse_pos);
|
||||
ObjectTypeDB::bind_method(_MD("action_press"),&Input::action_press);
|
||||
ObjectTypeDB::bind_method(_MD("action_release"),&Input::action_release);
|
||||
|
||||
BIND_CONSTANT( MOUSE_MODE_VISIBLE );
|
||||
BIND_CONSTANT( MOUSE_MODE_HIDDEN );
|
||||
|
@ -1701,6 +1701,19 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ie.type == InputEvent::ACTION) {
|
||||
|
||||
if (str =="action") {
|
||||
valid=true;
|
||||
ie.action.action=p_value;
|
||||
return;
|
||||
}
|
||||
else if (str == "pressed") {
|
||||
valid=true;
|
||||
ie.action.pressed=p_value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} break;
|
||||
case DICTIONARY: {
|
||||
@ -2379,6 +2392,17 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const {
|
||||
return Vector2(ie.screen_drag.speed_x,ie.screen_drag.speed_y);
|
||||
}
|
||||
}
|
||||
if (ie.type == InputEvent::ACTION) {
|
||||
|
||||
if (str =="action") {
|
||||
valid=true;
|
||||
return ie.action.action;
|
||||
}
|
||||
else if (str == "pressed") {
|
||||
valid=true;
|
||||
ie.action.pressed;
|
||||
}
|
||||
}
|
||||
|
||||
} break;
|
||||
case DICTIONARY: {
|
||||
|
@ -15,6 +15,7 @@ const GRAVITY = 500.0
|
||||
#consider "floor".
|
||||
const FLOOR_ANGLE_TOLERANCE = 40
|
||||
const WALK_FORCE = 600
|
||||
const WALK_MIN_SPEED=10
|
||||
const WALK_MAX_SPEED = 200
|
||||
const STOP_FORCE = 1300
|
||||
const JUMP_SPEED = 200
|
||||
@ -40,12 +41,12 @@ func _fixed_process(delta):
|
||||
var stop=true
|
||||
|
||||
if (walk_left):
|
||||
if (velocity.x<=0 and velocity.x > -WALK_MAX_SPEED):
|
||||
if (velocity.x<=WALK_MIN_SPEED and velocity.x > -WALK_MAX_SPEED):
|
||||
force.x-=WALK_FORCE
|
||||
stop=false
|
||||
|
||||
elif (walk_right):
|
||||
if (velocity.x>=0 and velocity.x < WALK_MAX_SPEED):
|
||||
if (velocity.x>=-WALK_MIN_SPEED and velocity.x < WALK_MAX_SPEED):
|
||||
force.x+=WALK_FORCE
|
||||
stop=false
|
||||
|
||||
|
4
demos/2d/polygon_path_finder_demo/.fscache
Normal file
@ -0,0 +1,4 @@
|
||||
::res://::1421147952
|
||||
icon.png::ImageTexture::1420046079::
|
||||
new_scene_poly_with_holes.scn::PackedScene::1421147952::
|
||||
polygonpathfinder.gd::GDScript::1421146502::
|
5
demos/2d/polygon_path_finder_demo/engine.cfg
Normal file
@ -0,0 +1,5 @@
|
||||
[application]
|
||||
|
||||
name="polygon_path_finder_demo"
|
||||
main_scene="res://new_scene_poly_with_holes.scn"
|
||||
icon="icon.png"
|
BIN
demos/2d/polygon_path_finder_demo/icon.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
1
demos/2d/polygon_path_finder_demo/icon.png.flags
Normal file
@ -0,0 +1 @@
|
||||
gen_mipmaps=true
|
BIN
demos/2d/polygon_path_finder_demo/new_scene_poly_with_holes.scn
Normal file
80
demos/2d/polygon_path_finder_demo/polygonpathfinder.gd
Normal file
@ -0,0 +1,80 @@
|
||||
|
||||
extends Spatial
|
||||
|
||||
func _ready():
|
||||
var pf = PolygonPathFinder.new()
|
||||
|
||||
var points = Vector2Array()
|
||||
var connections = IntArray()
|
||||
|
||||
# poly 1
|
||||
points.push_back(Vector2(0, 0)) #0
|
||||
points.push_back(Vector2(10, 0)) #1
|
||||
points.push_back(Vector2(10, 10)) #2
|
||||
points.push_back(Vector2(0, 10)) #3
|
||||
|
||||
connections.push_back(0) # connect vertex 0 ...
|
||||
connections.push_back(1) # ... to 1
|
||||
drawLine(points[0], points[1], get_node("/root/Spatial/Polys"))
|
||||
connections.push_back(1) # connect vertex 1 ...
|
||||
connections.push_back(2) # ... to 2
|
||||
drawLine(points[1], points[2], get_node("/root/Spatial/Polys"))
|
||||
connections.push_back(2) # etc.
|
||||
connections.push_back(3)
|
||||
drawLine(points[2], points[3], get_node("/root/Spatial/Polys"))
|
||||
connections.push_back(3) # connect vertex 3 ...
|
||||
connections.push_back(0) # back to vertex 0, to close the polygon
|
||||
drawLine(points[3], points[0], get_node("/root/Spatial/Polys"))
|
||||
|
||||
# poly 2, as obstacle inside poly 1
|
||||
points.push_back(Vector2(2, 0.5)) #4
|
||||
points.push_back(Vector2(4, 0.5)) #5
|
||||
points.push_back(Vector2(4, 9.5)) #6
|
||||
points.push_back(Vector2(2, 9.5)) #7
|
||||
|
||||
connections.push_back(4)
|
||||
connections.push_back(5)
|
||||
drawLine(points[4], points[5], get_node("/root/Spatial/Polys"))
|
||||
connections.push_back(5)
|
||||
connections.push_back(6)
|
||||
drawLine(points[5], points[6], get_node("/root/Spatial/Polys"))
|
||||
connections.push_back(6)
|
||||
connections.push_back(7)
|
||||
drawLine(points[6], points[7], get_node("/root/Spatial/Polys"))
|
||||
connections.push_back(7)
|
||||
connections.push_back(4)
|
||||
drawLine(points[7], points[4], get_node("/root/Spatial/Polys"))
|
||||
|
||||
|
||||
print("points: ",points)
|
||||
print("connections: ",connections)
|
||||
|
||||
pf.setup(points, connections)
|
||||
|
||||
var path = pf.find_path(Vector2(1, 5), Vector2(8, 5))
|
||||
|
||||
var lastStep = null
|
||||
print("path: ",path)
|
||||
for step in path:
|
||||
print("step: ",step)
|
||||
if (lastStep != null):
|
||||
var currPathSegment = Vector2Array()
|
||||
drawLine(lastStep, step, get_node("/root/Spatial/Path"))
|
||||
lastStep = step
|
||||
|
||||
|
||||
|
||||
func drawLine(pointA, pointB, immediateGeo):
|
||||
var drawPosY = 0.1
|
||||
var im = immediateGeo
|
||||
|
||||
im.begin(Mesh.PRIMITIVE_POINTS, null)
|
||||
im.add_vertex(Vector3(pointA.x, drawPosY, pointA.y))
|
||||
im.add_vertex(Vector3(pointB.x, drawPosY, pointB.y))
|
||||
im.end()
|
||||
im.begin(Mesh.PRIMITIVE_LINE_STRIP, null)
|
||||
im.add_vertex(Vector3(pointA.x, drawPosY, pointA.y))
|
||||
im.add_vertex(Vector3(pointB.x, drawPosY, pointB.y))
|
||||
im.end()
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "context_gl.h"
|
||||
|
||||
|
||||
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) || defined(GLES2_ENABLED) || defined(GLES1_ENABLED)
|
||||
#if defined(OPENGL_ENABLED) || defined(GLES2_ENABLED)
|
||||
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#ifndef CONTEXT_GL_H
|
||||
#define CONTEXT_GL_H
|
||||
|
||||
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) || defined(GLES2_ENABLED) || defined(GLES1_ENABLED)
|
||||
#if defined(OPENGL_ENABLED) || defined(GLES2_ENABLED)
|
||||
|
||||
#include "typedefs.h"
|
||||
|
||||
|
@ -1,5 +0,0 @@
|
||||
Import('env')
|
||||
Export('env');
|
||||
|
||||
env.add_source_files(env.drivers_sources,"*.cpp")
|
||||
|
@ -1411,6 +1411,9 @@ void RasterizerGLES2::shader_set_mode(RID p_shader,VS::ShaderMode p_mode) {
|
||||
case VS::SHADER_MATERIAL: {
|
||||
material_shader.free_custom_shader(shader->custom_code_id);
|
||||
} break;
|
||||
case VS::SHADER_CANVAS_ITEM: {
|
||||
canvas_shader.free_custom_shader(shader->custom_code_id);
|
||||
} break;
|
||||
}
|
||||
|
||||
shader->custom_code_id=0;
|
||||
@ -1422,6 +1425,9 @@ void RasterizerGLES2::shader_set_mode(RID p_shader,VS::ShaderMode p_mode) {
|
||||
case VS::SHADER_MATERIAL: {
|
||||
shader->custom_code_id=material_shader.create_custom_shader();
|
||||
} break;
|
||||
case VS::SHADER_CANVAS_ITEM: {
|
||||
shader->custom_code_id=canvas_shader.create_custom_shader();
|
||||
} break;
|
||||
}
|
||||
_shader_make_dirty(shader);
|
||||
|
||||
@ -1545,17 +1551,20 @@ void RasterizerGLES2::shader_set_default_texture_param(RID p_shader, const Strin
|
||||
|
||||
Shader *shader=shader_owner.get(p_shader);
|
||||
ERR_FAIL_COND(!shader);
|
||||
ERR_FAIL_COND(!texture_owner.owns(p_texture));
|
||||
ERR_FAIL_COND(p_texture.is_valid() && !texture_owner.owns(p_texture));
|
||||
|
||||
if (p_texture.is_valid())
|
||||
shader->default_textures[p_name]=p_texture;
|
||||
else
|
||||
shader->default_textures.erase(p_name);
|
||||
|
||||
_shader_make_dirty(shader);
|
||||
|
||||
}
|
||||
|
||||
RID RasterizerGLES2::shader_get_default_texture_param(RID p_shader, const StringName& p_name) const{
|
||||
const Shader *shader=shader_owner.get(p_shader);
|
||||
ERR_FAIL_COND_V(!shader,RID());
|
||||
|
||||
const Map<StringName,RID>::Element *E=shader->default_textures.find(p_name);
|
||||
if (!E)
|
||||
@ -1563,6 +1572,22 @@ RID RasterizerGLES2::shader_get_default_texture_param(RID p_shader, const String
|
||||
return E->get();
|
||||
}
|
||||
|
||||
Variant RasterizerGLES2::shader_get_default_param(RID p_shader, const StringName& p_name) {
|
||||
|
||||
Shader *shader=shader_owner.get(p_shader);
|
||||
ERR_FAIL_COND_V(!shader,Variant());
|
||||
|
||||
//update shader params if necesary
|
||||
//make sure the shader is compiled and everything
|
||||
//so the actual parameters can be properly retrieved!
|
||||
if (shader->dirty_list.in_list()) {
|
||||
_update_shader(shader);
|
||||
}
|
||||
if (shader->valid && shader->uniforms.has(p_name))
|
||||
return shader->uniforms[p_name].default_value;
|
||||
|
||||
return Variant();
|
||||
}
|
||||
|
||||
|
||||
/* COMMON MATERIAL API */
|
||||
@ -1606,6 +1631,7 @@ void RasterizerGLES2::material_set_param(RID p_material, const StringName& p_par
|
||||
material->shader_version=0; //get default!
|
||||
} else {
|
||||
E->get().value=p_value;
|
||||
E->get().inuse=true;
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -1613,6 +1639,7 @@ void RasterizerGLES2::material_set_param(RID p_material, const StringName& p_par
|
||||
ud.index=-1;
|
||||
ud.value=p_value;
|
||||
ud.istexture=p_value.get_type()==Variant::_RID; /// cache it being texture
|
||||
ud.inuse=true;
|
||||
material->shader_params[p_param]=ud; //may be got at some point, or erased
|
||||
|
||||
}
|
||||
@ -1644,7 +1671,7 @@ Variant RasterizerGLES2::material_get_param(RID p_material, const StringName& p_
|
||||
}
|
||||
|
||||
|
||||
if (material->shader_params.has(p_param))
|
||||
if (material->shader_params.has(p_param) && material->shader_params[p_param].inuse)
|
||||
return material->shader_params[p_param].value;
|
||||
else
|
||||
return Variant();
|
||||
@ -4430,6 +4457,13 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
|
||||
if (err) {
|
||||
return; //invalid
|
||||
}
|
||||
} else if (p_shader->mode==VS::SHADER_CANVAS_ITEM) {
|
||||
|
||||
Error err = shader_precompiler.compile(p_shader->vertex_code,ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX,vertex_code,vertex_globals,vertex_flags,&p_shader->uniforms);
|
||||
if (err) {
|
||||
return; //invalid
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//print_line("compiled vertex: "+vertex_code);
|
||||
@ -4439,9 +4473,16 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
|
||||
String fragment_code;
|
||||
String fragment_globals;
|
||||
|
||||
Error err = shader_precompiler.compile(p_shader->fragment_code,(p_shader->mode==VS::SHADER_MATERIAL?ShaderLanguage::SHADER_MATERIAL_FRAGMENT:ShaderLanguage::SHADER_POST_PROCESS),fragment_code,fragment_globals,fragment_flags,&p_shader->uniforms);
|
||||
if (err) {
|
||||
return; //invalid
|
||||
if (p_shader->mode==VS::SHADER_MATERIAL) {
|
||||
Error err = shader_precompiler.compile(p_shader->fragment_code,ShaderLanguage::SHADER_MATERIAL_FRAGMENT,fragment_code,fragment_globals,fragment_flags,&p_shader->uniforms);
|
||||
if (err) {
|
||||
return; //invalid
|
||||
}
|
||||
} else if (p_shader->mode==VS::SHADER_CANVAS_ITEM) {
|
||||
Error err = shader_precompiler.compile(p_shader->fragment_code,ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT,fragment_code,fragment_globals,fragment_flags,&p_shader->uniforms);
|
||||
if (err) {
|
||||
return; //invalid
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4454,6 +4495,11 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
|
||||
if (err) {
|
||||
return; //invalid
|
||||
}
|
||||
} else if (p_shader->mode==VS::SHADER_CANVAS_ITEM) {
|
||||
Error err = shader_precompiler.compile(p_shader->light_code,(ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT),light_code,light_globals,light_flags,&p_shader->uniforms);
|
||||
if (err) {
|
||||
return; //invalid
|
||||
}
|
||||
}
|
||||
|
||||
fragment_globals+=light_globals; //both fragment anyway
|
||||
@ -4514,7 +4560,39 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
|
||||
}
|
||||
|
||||
material_shader.set_custom_shader_code(p_shader->custom_code_id,vertex_code, vertex_globals,fragment_code, light_code, fragment_globals,uniform_names,enablers);
|
||||
} else {
|
||||
} else if (p_shader->mode==VS::SHADER_CANVAS_ITEM) {
|
||||
|
||||
Vector<const char*> enablers;
|
||||
|
||||
if (light_flags.uses_time || fragment_flags.uses_time || vertex_flags.uses_time) {
|
||||
enablers.push_back("#define USE_TIME\n");
|
||||
uses_time=true;
|
||||
}
|
||||
if (fragment_flags.uses_normal) {
|
||||
enablers.push_back("#define NORMAL_USED\n");
|
||||
}
|
||||
if (light_flags.uses_light) {
|
||||
enablers.push_back("#define USE_LIGHT_SHADER_CODE\n");
|
||||
}
|
||||
if (fragment_flags.use_var1_interp || vertex_flags.use_var1_interp)
|
||||
enablers.push_back("#define ENABLE_VAR1_INTERP\n");
|
||||
if (fragment_flags.use_var2_interp || vertex_flags.use_var2_interp)
|
||||
enablers.push_back("#define ENABLE_VAR2_INTERP\n");
|
||||
if (fragment_flags.uses_texscreen) {
|
||||
enablers.push_back("#define ENABLE_TEXSCREEN\n");
|
||||
}
|
||||
if (fragment_flags.uses_screen_uv) {
|
||||
enablers.push_back("#define ENABLE_SCREEN_UV\n");
|
||||
}
|
||||
if (fragment_flags.uses_texpixel_size) {
|
||||
enablers.push_back("#define USE_TEXPIXEL_SIZE\n");
|
||||
}
|
||||
|
||||
if (vertex_flags.uses_worldvec) {
|
||||
enablers.push_back("#define USE_WORLD_VEC\n");
|
||||
}
|
||||
canvas_shader.set_custom_shader_code(p_shader->custom_code_id,vertex_code, vertex_globals,fragment_code, light_code, fragment_globals,uniform_names,enablers);
|
||||
|
||||
//postprocess_shader.set_custom_shader_code(p_shader->custom_code_id,vertex_code, vertex_globals,fragment_code, fragment_globals,uniform_names);
|
||||
}
|
||||
|
||||
@ -4525,7 +4603,9 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
|
||||
p_shader->has_texscreen=fragment_flags.uses_texscreen;
|
||||
p_shader->has_screen_uv=fragment_flags.uses_screen_uv;
|
||||
p_shader->can_zpass=!fragment_flags.uses_discard && !vertex_flags.vertex_code_writes_vertex;
|
||||
p_shader->uses_normal=fragment_flags.uses_normal || light_flags.uses_normal;
|
||||
p_shader->uses_time=uses_time;
|
||||
p_shader->uses_texpixel_size=fragment_flags.uses_texpixel_size;
|
||||
p_shader->version++;
|
||||
|
||||
}
|
||||
@ -4876,31 +4956,58 @@ _FORCE_INLINE_ void RasterizerGLES2::_update_material_shader_params(Material *p_
|
||||
|
||||
Material::UniformData ud;
|
||||
|
||||
bool keep=true;
|
||||
bool keep=true; //keep material value
|
||||
|
||||
if (!old_mparams.has(E->key()))
|
||||
Map<StringName,Material::UniformData>::Element *OLD=old_mparams.find(E->key());
|
||||
bool has_old = OLD;
|
||||
bool old_inuse=has_old && old_mparams[E->key()].inuse;
|
||||
|
||||
ud.istexture=(E->get().type==ShaderLanguage::TYPE_TEXTURE || E->get().type==ShaderLanguage::TYPE_CUBEMAP);
|
||||
|
||||
if (!has_old || !old_inuse) {
|
||||
keep=false;
|
||||
else if (old_mparams[E->key()].value.get_type()!=E->value().default_value.get_type()) {
|
||||
}
|
||||
else if (OLD->get().value.get_type()!=E->value().default_value.get_type()) {
|
||||
|
||||
if (old_mparams[E->key()].value.get_type()==Variant::OBJECT) {
|
||||
if (OLD->get().value.get_type()==Variant::INT && E->get().type==ShaderLanguage::TYPE_FLOAT) {
|
||||
//handle common mistake using shaders (feeding ints instead of float)
|
||||
OLD->get().value=float(OLD->get().value);
|
||||
keep=true;
|
||||
} else if (!ud.istexture && E->value().default_value.get_type()!=Variant::NIL) {
|
||||
|
||||
keep=false;
|
||||
}
|
||||
//type changed between old and new
|
||||
/* if (old_mparams[E->key()].value.get_type()==Variant::OBJECT) {
|
||||
if (E->value().default_value.get_type()!=Variant::_RID) //hackfor textures
|
||||
keep=false;
|
||||
} else if (!old_mparams[E->key()].value.is_num() || !E->value().default_value.get_type())
|
||||
keep=false;
|
||||
keep=false;*/
|
||||
|
||||
//value is invalid because type differs and default is not null
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
if (keep) {
|
||||
ud.value=old_mparams[E->key()].value;
|
||||
|
||||
//print_line("KEEP: "+String(E->key()));
|
||||
} else {
|
||||
ud.value=E->value().default_value;
|
||||
if (ud.istexture && p_material->shader_cache->default_textures.has(E->key()))
|
||||
ud.value=p_material->shader_cache->default_textures[E->key()];
|
||||
else
|
||||
ud.value=E->value().default_value;
|
||||
old_inuse=false; //if reverted to default, obviously did not work
|
||||
|
||||
//print_line("NEW: "+String(E->key())+" because: hasold-"+itos(old_mparams.has(E->key())));
|
||||
//if (old_mparams.has(E->key()))
|
||||
// print_line(" told "+Variant::get_type_name(old_mparams[E->key()].value.get_type())+" tnew "+Variant::get_type_name(E->value().default_value.get_type()));
|
||||
}
|
||||
|
||||
ud.istexture=(E->get().type==ShaderLanguage::TYPE_TEXTURE || E->get().type==ShaderLanguage::TYPE_CUBEMAP);
|
||||
|
||||
ud.index=idx++;
|
||||
ud.inuse=old_inuse;
|
||||
mparams[E->key()]=ud;
|
||||
}
|
||||
|
||||
@ -5004,8 +5111,10 @@ bool RasterizerGLES2::_setup_material(const Geometry *p_geometry,const Material
|
||||
int texcoord=0;
|
||||
for (Map<StringName,Material::UniformData>::Element *E=p_material->shader_params.front();E;E=E->next()) {
|
||||
|
||||
|
||||
if (E->get().index<0)
|
||||
continue;
|
||||
// print_line(String(E->key())+": "+E->get().value);
|
||||
if (E->get().istexture) {
|
||||
//clearly a texture..
|
||||
RID rid = E->get().value;
|
||||
@ -5021,23 +5130,8 @@ bool RasterizerGLES2::_setup_material(const Geometry *p_geometry,const Material
|
||||
E->get().value=RID(); //nullify, invalid texture
|
||||
rid=RID();
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!rid.is_valid()) {
|
||||
//use from default textures
|
||||
Map<StringName,RID>::Element *F=p_material->shader_cache->default_textures.find(E->key());
|
||||
if (F) {
|
||||
t=texture_owner.get(F->get());
|
||||
if (!t) {
|
||||
p_material->shader_cache->default_textures.erase(E->key());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
glActiveTexture(GL_TEXTURE0+texcoord);
|
||||
glUniform1i(loc,texcoord); //TODO - this could happen automatically on compile...
|
||||
if (t) {
|
||||
@ -5061,15 +5155,10 @@ bool RasterizerGLES2::_setup_material(const Geometry *p_geometry,const Material
|
||||
|
||||
}
|
||||
|
||||
for (Map<StringName,RID>::Element *E=p_material->shader_cache->default_textures.front();E;E=E->next()) {
|
||||
if (p_material->shader_params.has(E->key()))
|
||||
continue;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (p_material->shader_cache->has_texscreen && framebuffer.active) {
|
||||
material_shader.set_uniform(MaterialShaderGLES2::TEXSCREEN_SCREEN_MULT,Vector2(float(viewport.width)/framebuffer.width,float(viewport.height)/framebuffer.height));
|
||||
material_shader.set_uniform(MaterialShaderGLES2::TEXSCREEN_SCREEN_CLAMP,Color(0,0,float(viewport.width)/framebuffer.width,float(viewport.height)/framebuffer.height));
|
||||
material_shader.set_uniform(MaterialShaderGLES2::TEXSCREEN_TEX,texcoord);
|
||||
glActiveTexture(GL_TEXTURE0+texcoord);
|
||||
glBindTexture(GL_TEXTURE_2D,framebuffer.sample_color);
|
||||
@ -7724,10 +7813,11 @@ void RasterizerGLES2::canvas_begin() {
|
||||
canvas_tex=RID();
|
||||
//material_shader.unbind();
|
||||
canvas_shader.unbind();
|
||||
canvas_shader.set_custom_shader(0);
|
||||
canvas_shader.bind();
|
||||
canvas_shader.set_uniform(CanvasShaderGLES2::TEXTURE, 0);
|
||||
_set_color_attrib(Color(1,1,1));
|
||||
Transform canvas_transform;
|
||||
canvas_transform=Transform();
|
||||
canvas_transform.translate(-(viewport.width / 2.0f), -(viewport.height / 2.0f), 0.0f);
|
||||
float csy = 1.0;
|
||||
if (current_rt && current_rt_vflip)
|
||||
@ -7741,6 +7831,9 @@ void RasterizerGLES2::canvas_begin() {
|
||||
canvas_opacity=1.0;
|
||||
canvas_blend_mode=VS::MATERIAL_BLEND_MODE_MIX;
|
||||
|
||||
canvas_texscreen_used=false;
|
||||
uses_texpixel_size=false;
|
||||
canvas_last_shader=RID();
|
||||
|
||||
}
|
||||
|
||||
@ -7823,7 +7916,7 @@ void RasterizerGLES2::canvas_end_rect() {
|
||||
|
||||
RasterizerGLES2::Texture* RasterizerGLES2::_bind_canvas_texture(const RID& p_texture) {
|
||||
|
||||
if (p_texture==canvas_tex) {
|
||||
if (p_texture==canvas_tex && !rebind_texpixel_size) {
|
||||
if (canvas_tex.is_valid()) {
|
||||
Texture*texture=texture_owner.get(p_texture);
|
||||
return texture;
|
||||
@ -7831,14 +7924,16 @@ RasterizerGLES2::Texture* RasterizerGLES2::_bind_canvas_texture(const RID& p_tex
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
rebind_texpixel_size=false;
|
||||
|
||||
if (p_texture.is_valid()) {
|
||||
|
||||
|
||||
Texture*texture=texture_owner.get(p_texture);
|
||||
if (!texture) {
|
||||
canvas_tex=RID();
|
||||
glBindTexture(GL_TEXTURE_2D,white_tex);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -7847,6 +7942,9 @@ RasterizerGLES2::Texture* RasterizerGLES2::_bind_canvas_texture(const RID& p_tex
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D,texture->tex_id);
|
||||
canvas_tex=p_texture;
|
||||
if (uses_texpixel_size) {
|
||||
canvas_shader.set_uniform(CanvasShaderGLES2::TEXPIXEL_SIZE,Size2(1.0/texture->width,1.0/texture->height));
|
||||
}
|
||||
return texture;
|
||||
|
||||
|
||||
@ -8217,6 +8315,342 @@ void RasterizerGLES2::canvas_set_transform(const Matrix32& p_transform) {
|
||||
//canvas_transform = Variant(p_transform);
|
||||
}
|
||||
|
||||
|
||||
void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list) {
|
||||
|
||||
|
||||
CanvasItem *current_clip=NULL;
|
||||
|
||||
canvas_opacity=1.0;
|
||||
while(p_item_list) {
|
||||
|
||||
CanvasItem *ci=p_item_list;
|
||||
|
||||
if (ci->vp_render) {
|
||||
if (draw_viewport_func) {
|
||||
draw_viewport_func(ci->vp_render->owner,ci->vp_render->udata,ci->vp_render->rect);
|
||||
}
|
||||
memdelete(ci->vp_render);
|
||||
ci->vp_render=NULL;
|
||||
canvas_last_shader=RID();
|
||||
}
|
||||
|
||||
if (current_clip!=ci->final_clip_owner) {
|
||||
|
||||
current_clip=ci->final_clip_owner;
|
||||
|
||||
//setup clip
|
||||
if (current_clip) {
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glScissor(viewport.x+current_clip->final_clip_rect.pos.x,viewport.y+ (viewport.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.height)),
|
||||
current_clip->final_clip_rect.size.width,current_clip->final_clip_rect.size.height);
|
||||
} else {
|
||||
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//begin rect
|
||||
CanvasItem *shader_owner = ci->shader_owner?ci->shader_owner:ci;
|
||||
|
||||
if (shader_owner->shader!=canvas_last_shader) {
|
||||
|
||||
Shader *shader = NULL;
|
||||
if (shader_owner->shader.is_valid()) {
|
||||
shader = this->shader_owner.get(shader_owner->shader);
|
||||
if (shader && !shader->valid) {
|
||||
shader=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (shader) {
|
||||
canvas_shader.set_custom_shader(shader->custom_code_id);
|
||||
if (canvas_shader.bind())
|
||||
rebind_texpixel_size=true;
|
||||
|
||||
if (shader_owner->shader_version!=shader->version) {
|
||||
//todo optimize uniforms
|
||||
shader_owner->shader_version=shader->version;
|
||||
}
|
||||
//this can be optimized..
|
||||
int tex_id=1;
|
||||
int idx=0;
|
||||
for(Map<StringName,ShaderLanguage::Uniform>::Element *E=shader->uniforms.front();E;E=E->next()) {
|
||||
|
||||
Map<StringName,Variant>::Element *F=shader_owner->shader_param.find(E->key());
|
||||
|
||||
if ((E->get().type==ShaderLanguage::TYPE_TEXTURE || E->get().type==ShaderLanguage::TYPE_CUBEMAP)) {
|
||||
|
||||
RID rid;
|
||||
if (F) {
|
||||
rid=F->get();
|
||||
}
|
||||
|
||||
if (!rid.is_valid()) {
|
||||
|
||||
Map<StringName,RID>::Element *DT=shader->default_textures.find(E->key());
|
||||
if (DT) {
|
||||
rid=DT->get();
|
||||
}
|
||||
}
|
||||
|
||||
if (rid.is_valid()) {
|
||||
|
||||
int loc = canvas_shader.get_custom_uniform_location(idx); //should be automatic..
|
||||
|
||||
glActiveTexture(GL_TEXTURE0+tex_id);
|
||||
Texture *t=texture_owner.get(rid);
|
||||
if (!t)
|
||||
glBindTexture(GL_TEXTURE_2D,white_tex);
|
||||
else
|
||||
glBindTexture(t->target,t->tex_id);
|
||||
|
||||
glUniform1i(loc,tex_id);
|
||||
tex_id++;
|
||||
}
|
||||
} else {
|
||||
Variant &v=F?F->get():E->get().default_value;
|
||||
canvas_shader.set_custom_uniform(idx,v);
|
||||
}
|
||||
|
||||
idx++;
|
||||
}
|
||||
|
||||
|
||||
if (shader->has_texscreen && framebuffer.active) {
|
||||
|
||||
int x = viewport.x;
|
||||
int y = window_size.height-(viewport.height+viewport.y);
|
||||
|
||||
canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_SCREEN_MULT,Vector2(float(viewport.width)/framebuffer.width,float(viewport.height)/framebuffer.height));
|
||||
canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_SCREEN_CLAMP,Color(float(x)/framebuffer.width,float(y)/framebuffer.height,float(x+viewport.width)/framebuffer.width,float(y+viewport.height)/framebuffer.height));
|
||||
canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_TEX,tex_id);
|
||||
glActiveTexture(GL_TEXTURE0+tex_id);
|
||||
glBindTexture(GL_TEXTURE_2D,framebuffer.sample_color);
|
||||
if (framebuffer.scale==1 && !canvas_texscreen_used) {
|
||||
#ifdef GLEW_ENABLED
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||
#endif
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D,0,x,y,x,y,viewport.width,viewport.height);
|
||||
if (current_clip) {
|
||||
// print_line(" a clip ");
|
||||
}
|
||||
|
||||
canvas_texscreen_used=true;
|
||||
}
|
||||
tex_id++;
|
||||
|
||||
}
|
||||
|
||||
if (tex_id>1) {
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
if (shader->has_screen_uv) {
|
||||
canvas_shader.set_uniform(CanvasShaderGLES2::SCREEN_UV_MULT,Vector2(1.0/viewport.width,1.0/viewport.height));
|
||||
}
|
||||
|
||||
if (shader->uses_time) {
|
||||
canvas_shader.set_uniform(CanvasShaderGLES2::TIME,Math::fmod(last_time,300.0));
|
||||
draw_next_frame=true;
|
||||
}
|
||||
//if uses TIME - draw_next_frame=true
|
||||
|
||||
uses_texpixel_size=shader->uses_texpixel_size;
|
||||
|
||||
} else {
|
||||
canvas_shader.set_custom_shader(0);
|
||||
canvas_shader.bind();
|
||||
uses_texpixel_size=false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
canvas_shader.set_uniform(CanvasShaderGLES2::PROJECTION_MATRIX,canvas_transform);
|
||||
canvas_last_shader=shader_owner->shader;
|
||||
}
|
||||
|
||||
canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX,ci->final_transform);
|
||||
canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX,Matrix32());
|
||||
|
||||
|
||||
bool reclip=false;
|
||||
|
||||
if (ci==p_item_list || ci->blend_mode!=canvas_blend_mode) {
|
||||
|
||||
switch(ci->blend_mode) {
|
||||
|
||||
case VS::MATERIAL_BLEND_MODE_MIX: {
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
} break;
|
||||
case VS::MATERIAL_BLEND_MODE_ADD: {
|
||||
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
|
||||
|
||||
} break;
|
||||
case VS::MATERIAL_BLEND_MODE_SUB: {
|
||||
|
||||
glBlendEquation(GL_FUNC_SUBTRACT);
|
||||
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
|
||||
} break;
|
||||
case VS::MATERIAL_BLEND_MODE_MUL: {
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_DST_COLOR,GL_ZERO);
|
||||
} break;
|
||||
case VS::MATERIAL_BLEND_MODE_PREMULT_ALPHA: {
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA);
|
||||
} break;
|
||||
|
||||
}
|
||||
|
||||
canvas_blend_mode=ci->blend_mode;
|
||||
}
|
||||
|
||||
int cc=ci->commands.size();
|
||||
CanvasItem::Command **commands = ci->commands.ptr();
|
||||
|
||||
canvas_opacity = ci->final_opacity;
|
||||
|
||||
for(int i=0;i<cc;i++) {
|
||||
|
||||
CanvasItem::Command *c=commands[i];
|
||||
|
||||
switch(c->type) {
|
||||
case CanvasItem::Command::TYPE_LINE: {
|
||||
|
||||
CanvasItem::CommandLine* line = static_cast<CanvasItem::CommandLine*>(c);
|
||||
canvas_draw_line(line->from,line->to,line->color,line->width);
|
||||
} break;
|
||||
case CanvasItem::Command::TYPE_RECT: {
|
||||
|
||||
CanvasItem::CommandRect* rect = static_cast<CanvasItem::CommandRect*>(c);
|
||||
// canvas_draw_rect(rect->rect,rect->region,rect->source,rect->flags&CanvasItem::CommandRect::FLAG_TILE,rect->flags&CanvasItem::CommandRect::FLAG_FLIP_H,rect->flags&CanvasItem::CommandRect::FLAG_FLIP_V,rect->texture,rect->modulate);
|
||||
#if 0
|
||||
int flags=0;
|
||||
|
||||
if (rect->flags&CanvasItem::CommandRect::FLAG_REGION) {
|
||||
flags|=Rasterizer::CANVAS_RECT_REGION;
|
||||
}
|
||||
if (rect->flags&CanvasItem::CommandRect::FLAG_TILE) {
|
||||
flags|=Rasterizer::CANVAS_RECT_TILE;
|
||||
}
|
||||
if (rect->flags&CanvasItem::CommandRect::FLAG_FLIP_H) {
|
||||
|
||||
flags|=Rasterizer::CANVAS_RECT_FLIP_H;
|
||||
}
|
||||
if (rect->flags&CanvasItem::CommandRect::FLAG_FLIP_V) {
|
||||
|
||||
flags|=Rasterizer::CANVAS_RECT_FLIP_V;
|
||||
}
|
||||
#else
|
||||
|
||||
int flags=rect->flags;
|
||||
#endif
|
||||
canvas_draw_rect(rect->rect,flags,rect->source,rect->texture,rect->modulate);
|
||||
|
||||
} break;
|
||||
case CanvasItem::Command::TYPE_STYLE: {
|
||||
|
||||
CanvasItem::CommandStyle* style = static_cast<CanvasItem::CommandStyle*>(c);
|
||||
canvas_draw_style_box(style->rect,style->texture,style->margin,style->draw_center,style->color);
|
||||
|
||||
} break;
|
||||
case CanvasItem::Command::TYPE_PRIMITIVE: {
|
||||
|
||||
CanvasItem::CommandPrimitive* primitive = static_cast<CanvasItem::CommandPrimitive*>(c);
|
||||
canvas_draw_primitive(primitive->points,primitive->colors,primitive->uvs,primitive->texture,primitive->width);
|
||||
} break;
|
||||
case CanvasItem::Command::TYPE_POLYGON: {
|
||||
|
||||
CanvasItem::CommandPolygon* polygon = static_cast<CanvasItem::CommandPolygon*>(c);
|
||||
canvas_draw_polygon(polygon->count,polygon->indices.ptr(),polygon->points.ptr(),polygon->uvs.ptr(),polygon->colors.ptr(),polygon->texture,polygon->colors.size()==1);
|
||||
|
||||
} break;
|
||||
|
||||
case CanvasItem::Command::TYPE_POLYGON_PTR: {
|
||||
|
||||
CanvasItem::CommandPolygonPtr* polygon = static_cast<CanvasItem::CommandPolygonPtr*>(c);
|
||||
canvas_draw_polygon(polygon->count,polygon->indices,polygon->points,polygon->uvs,polygon->colors,polygon->texture,false);
|
||||
} break;
|
||||
case CanvasItem::Command::TYPE_CIRCLE: {
|
||||
|
||||
CanvasItem::CommandCircle* circle = static_cast<CanvasItem::CommandCircle*>(c);
|
||||
static const int numpoints=32;
|
||||
Vector2 points[numpoints+1];
|
||||
points[numpoints]=circle->pos;
|
||||
int indices[numpoints*3];
|
||||
|
||||
for(int i=0;i<numpoints;i++) {
|
||||
|
||||
points[i]=circle->pos+Vector2( Math::sin(i*Math_PI*2.0/numpoints),Math::cos(i*Math_PI*2.0/numpoints) )*circle->radius;
|
||||
indices[i*3+0]=i;
|
||||
indices[i*3+1]=(i+1)%numpoints;
|
||||
indices[i*3+2]=numpoints;
|
||||
}
|
||||
canvas_draw_polygon(numpoints*3,indices,points,NULL,&circle->color,RID(),true);
|
||||
//canvas_draw_circle(circle->indices.size(),circle->indices.ptr(),circle->points.ptr(),circle->uvs.ptr(),circle->colors.ptr(),circle->texture,circle->colors.size()==1);
|
||||
} break;
|
||||
case CanvasItem::Command::TYPE_TRANSFORM: {
|
||||
|
||||
CanvasItem::CommandTransform* transform = static_cast<CanvasItem::CommandTransform*>(c);
|
||||
canvas_set_transform(transform->xform);
|
||||
} break;
|
||||
case CanvasItem::Command::TYPE_BLEND_MODE: {
|
||||
|
||||
CanvasItem::CommandBlendMode* bm = static_cast<CanvasItem::CommandBlendMode*>(c);
|
||||
canvas_set_blend_mode(bm->blend_mode);
|
||||
|
||||
} break;
|
||||
case CanvasItem::Command::TYPE_CLIP_IGNORE: {
|
||||
|
||||
CanvasItem::CommandClipIgnore* ci = static_cast<CanvasItem::CommandClipIgnore*>(c);
|
||||
if (current_clip) {
|
||||
|
||||
if (ci->ignore!=reclip) {
|
||||
if (ci->ignore) {
|
||||
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
reclip=true;
|
||||
} else {
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glScissor(viewport.x+current_clip->final_clip_rect.pos.x,viewport.y+ (viewport.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.height)),
|
||||
current_clip->final_clip_rect.size.width,current_clip->final_clip_rect.size.height);
|
||||
reclip=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (reclip) {
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glScissor(viewport.x+current_clip->final_clip_rect.pos.x,viewport.y+ (viewport.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.height)),
|
||||
current_clip->final_clip_rect.size.width,current_clip->final_clip_rect.size.height);
|
||||
}
|
||||
|
||||
|
||||
|
||||
p_item_list=p_item_list->next;
|
||||
}
|
||||
|
||||
if (current_clip) {
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ENVIRONMENT */
|
||||
|
||||
RID RasterizerGLES2::environment_create() {
|
||||
|
@ -191,6 +191,8 @@ class RasterizerGLES2 : public Rasterizer {
|
||||
bool writes_vertex;
|
||||
bool uses_discard;
|
||||
bool uses_time;
|
||||
bool uses_normal;
|
||||
bool uses_texpixel_size;
|
||||
|
||||
Map<StringName,ShaderLanguage::Uniform> uniforms;
|
||||
StringName first_texture;
|
||||
@ -214,6 +216,7 @@ class RasterizerGLES2 : public Rasterizer {
|
||||
writes_vertex=false;
|
||||
uses_discard=false;
|
||||
uses_time=false;
|
||||
uses_normal=false;
|
||||
}
|
||||
|
||||
|
||||
@ -241,8 +244,9 @@ class RasterizerGLES2 : public Rasterizer {
|
||||
|
||||
struct UniformData {
|
||||
|
||||
bool inuse;
|
||||
bool istexture;
|
||||
Variant value;
|
||||
Variant value;
|
||||
int index;
|
||||
};
|
||||
|
||||
@ -1168,6 +1172,13 @@ class RasterizerGLES2 : public Rasterizer {
|
||||
GLuint white_tex;
|
||||
RID canvas_tex;
|
||||
float canvas_opacity;
|
||||
bool uses_texpixel_size;
|
||||
bool rebind_texpixel_size;
|
||||
Transform canvas_transform;
|
||||
RID canvas_last_shader;
|
||||
bool canvas_texscreen_used;
|
||||
|
||||
|
||||
_FORCE_INLINE_ Texture* _bind_canvas_texture(const RID& p_texture);
|
||||
VS::MaterialBlendMode canvas_blend_mode;
|
||||
|
||||
@ -1198,7 +1209,7 @@ class RasterizerGLES2 : public Rasterizer {
|
||||
RID overdraw_material;
|
||||
|
||||
mutable MaterialShaderGLES2 material_shader;
|
||||
CanvasShaderGLES2 canvas_shader;
|
||||
mutable CanvasShaderGLES2 canvas_shader;
|
||||
BlurShaderGLES2 blur_shader;
|
||||
CopyShaderGLES2 copy_shader;
|
||||
|
||||
@ -1259,6 +1270,8 @@ public:
|
||||
virtual void shader_set_default_texture_param(RID p_shader, const StringName& p_name, RID p_texture);
|
||||
virtual RID shader_get_default_texture_param(RID p_shader, const StringName& p_name) const;
|
||||
|
||||
virtual Variant shader_get_default_param(RID p_shader, const StringName& p_name);
|
||||
|
||||
/* COMMON MATERIAL API */
|
||||
|
||||
virtual RID material_create();
|
||||
@ -1535,6 +1548,8 @@ public:
|
||||
virtual void canvas_draw_polygon(int p_vertex_count, const int* p_indices, const Vector2* p_vertices, const Vector2* p_uvs, const Color* p_colors,const RID& p_texture,bool p_singlecolor);
|
||||
virtual void canvas_set_transform(const Matrix32& p_transform);
|
||||
|
||||
virtual void canvas_render_items(CanvasItem *p_item_list);
|
||||
|
||||
/* ENVIRONMENT */
|
||||
|
||||
|
||||
|
@ -131,6 +131,7 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
|
||||
SL::BlockNode *bnode=(SL::BlockNode*)p_node;
|
||||
|
||||
//variables
|
||||
code+="{"ENDL;
|
||||
for(Map<StringName,SL::DataType>::Element *E=bnode->variables.front();E;E=E->next()) {
|
||||
|
||||
code+=_mktab(p_level)+_typestr(E->value())+" "+replace_string(E->key())+";"ENDL;
|
||||
@ -141,10 +142,12 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
|
||||
code+=_mktab(p_level)+dump_node_code(bnode->statements[i],p_level)+";"ENDL;
|
||||
}
|
||||
|
||||
code+="}"ENDL;
|
||||
|
||||
} break;
|
||||
case SL::Node::TYPE_VARIABLE: {
|
||||
SL::VariableNode *vnode=(SL::VariableNode*)p_node;
|
||||
|
||||
if (type==ShaderLanguage::SHADER_MATERIAL_VERTEX) {
|
||||
|
||||
if (vnode->name==vname_vertex && p_assign_left) {
|
||||
@ -171,6 +174,9 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (type==ShaderLanguage::SHADER_MATERIAL_FRAGMENT) {
|
||||
|
||||
if (vnode->name==vname_discard) {
|
||||
@ -211,6 +217,50 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
|
||||
uses_light=true;
|
||||
}
|
||||
|
||||
}
|
||||
if (type==ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX) {
|
||||
|
||||
if (vnode->name==vname_var1_interp) {
|
||||
flags->use_var1_interp=true;
|
||||
}
|
||||
if (vnode->name==vname_var2_interp) {
|
||||
flags->use_var2_interp=true;
|
||||
}
|
||||
if (vnode->name==vname_world_vec) {
|
||||
uses_worldvec=true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (type==ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT) {
|
||||
|
||||
|
||||
if (vnode->name==vname_texpixel_size) {
|
||||
uses_texpixel_size=true;
|
||||
}
|
||||
if (vnode->name==vname_normal) {
|
||||
uses_normal=true;
|
||||
}
|
||||
|
||||
if (vnode->name==vname_screen_uv) {
|
||||
uses_screen_uv=true;
|
||||
}
|
||||
|
||||
if (vnode->name==vname_var1_interp) {
|
||||
flags->use_var1_interp=true;
|
||||
}
|
||||
if (vnode->name==vname_var2_interp) {
|
||||
flags->use_var2_interp=true;
|
||||
}
|
||||
}
|
||||
|
||||
if (type==ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT) {
|
||||
|
||||
if (vnode->name==vname_light) {
|
||||
uses_light=true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (vnode->name==vname_time) {
|
||||
@ -260,13 +310,13 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
|
||||
|
||||
String mul_l=dump_node_code(onode->arguments[0],p_level,true);
|
||||
String mul_r=dump_node_code(onode->arguments[1],p_level);
|
||||
code=mul_l+"=(vec4("+mul_l+",1.0,1.0)*("+mul_r+")).xy";
|
||||
code=mul_l+"=(vec4("+mul_l+",0.0,1.0)*("+mul_r+")).xy";
|
||||
break;
|
||||
} else if (onode->arguments[0]->get_datatype()==SL::TYPE_MAT4 && onode->arguments[1]->get_datatype()==SL::TYPE_VEC2) {
|
||||
|
||||
String mul_l=dump_node_code(onode->arguments[0],p_level,true);
|
||||
String mul_r=dump_node_code(onode->arguments[1],p_level);
|
||||
code=mul_l+"=(("+mul_l+")*vec4("+mul_r+",1.0,1.0)).xy";
|
||||
code=mul_l+"=(("+mul_l+")*vec4("+mul_r+",0.0,1.0)).xy";
|
||||
break;
|
||||
} else if (onode->arguments[0]->get_datatype()==SL::TYPE_VEC2 && onode->arguments[1]->get_datatype()==SL::TYPE_MAT3) {
|
||||
String mul_l=dump_node_code(onode->arguments[0],p_level,true);
|
||||
@ -296,11 +346,11 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
|
||||
break;
|
||||
} else if (onode->arguments[0]->get_datatype()==SL::TYPE_MAT4 && onode->arguments[1]->get_datatype()==SL::TYPE_VEC2) {
|
||||
|
||||
code="("+dump_node_code(onode->arguments[0],p_level)+"*vec4("+dump_node_code(onode->arguments[1],p_level)+",1.0,1.0)).xyz";
|
||||
code="("+dump_node_code(onode->arguments[0],p_level)+"*vec4("+dump_node_code(onode->arguments[1],p_level)+",0.0,1.0)).xy";
|
||||
break;
|
||||
} else if (onode->arguments[0]->get_datatype()==SL::TYPE_VEC2 && onode->arguments[1]->get_datatype()==SL::TYPE_MAT4) {
|
||||
|
||||
code="(vec4("+dump_node_code(onode->arguments[0],p_level)+",1.0,1.0)*"+dump_node_code(onode->arguments[1],p_level)+").xyz";
|
||||
code="(vec4("+dump_node_code(onode->arguments[0],p_level)+",0.0,1.0)*"+dump_node_code(onode->arguments[1],p_level)+").xy";
|
||||
break;
|
||||
} else if (onode->arguments[0]->get_datatype()==SL::TYPE_MAT3 && onode->arguments[1]->get_datatype()==SL::TYPE_VEC2) {
|
||||
|
||||
@ -357,7 +407,7 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
|
||||
} else if (callfunc=="texscreen") {
|
||||
//create the call to sample the screen, and clamp it
|
||||
uses_texscreen=true;
|
||||
code="(texture2D( texscreen_tex, min(("+dump_node_code(onode->arguments[1],p_level)+").xy*texscreen_screen_mult,texscreen_screen_mult))).rgb";
|
||||
code="(texture2D( texscreen_tex, clamp(("+dump_node_code(onode->arguments[1],p_level)+").xy*texscreen_screen_mult,texscreen_screen_clamp.xy,texscreen_screen_clamp.zw))).rgb";
|
||||
//code="(texture2D( screen_texture, ("+dump_node_code(onode->arguments[1],p_level)+").xy).rgb";
|
||||
break;
|
||||
} else if (callfunc=="texpos") {
|
||||
@ -550,6 +600,9 @@ Error ShaderCompilerGLES2::compile(const String& p_code, ShaderLanguage::ShaderT
|
||||
uses_light=false;
|
||||
uses_time=false;
|
||||
uses_normalmap=false;
|
||||
uses_normal=false;
|
||||
uses_texpixel_size=false;
|
||||
uses_worldvec=false;
|
||||
vertex_code_writes_vertex=false;
|
||||
uniforms=r_uniforms;
|
||||
flags=&r_flags;
|
||||
@ -560,6 +613,7 @@ Error ShaderCompilerGLES2::compile(const String& p_code, ShaderLanguage::ShaderT
|
||||
r_flags.use_var1_interp=false;
|
||||
r_flags.use_var2_interp=false;
|
||||
r_flags.uses_normalmap=false;
|
||||
r_flags.uses_normal=false;
|
||||
|
||||
String error;
|
||||
int errline,errcol;
|
||||
@ -582,6 +636,9 @@ Error ShaderCompilerGLES2::compile(const String& p_code, ShaderLanguage::ShaderT
|
||||
r_flags.uses_light=uses_light;
|
||||
r_flags.uses_time=uses_time;
|
||||
r_flags.uses_normalmap=uses_normalmap;
|
||||
r_flags.uses_normal=uses_normalmap;
|
||||
r_flags.uses_texpixel_size=uses_texpixel_size;
|
||||
r_flags.uses_worldvec=uses_worldvec;
|
||||
r_code_line=code;
|
||||
r_globals_line=global_code;
|
||||
|
||||
@ -638,6 +695,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
|
||||
replace_table["cross" ]="cross";
|
||||
replace_table["normalize"]= "normalize";
|
||||
replace_table["reflect"]= "reflect";
|
||||
replace_table["refract"]= "refract";
|
||||
replace_table["tex"]= "tex";
|
||||
replace_table["texa"]= "texa";
|
||||
replace_table["tex2"]= "tex2";
|
||||
@ -676,6 +734,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
|
||||
//mode_replace_table[1]["POSITION"]="IN_POSITION";
|
||||
mode_replace_table[1]["NORMAL"]="normal";
|
||||
mode_replace_table[1]["TANGENT"]="tangent";
|
||||
mode_replace_table[1]["POSITION"]="gl_Position";
|
||||
mode_replace_table[1]["BINORMAL"]="binormal";
|
||||
mode_replace_table[1]["NORMALMAP"]="normalmap";
|
||||
mode_replace_table[1]["NORMALMAP_DEPTH"]="normaldepth";
|
||||
@ -718,6 +777,43 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
|
||||
mode_replace_table[2]["POINT_COORD"]="gl_PointCoord";
|
||||
mode_replace_table[2]["TIME"]="time";
|
||||
|
||||
mode_replace_table[3]["SRC_VERTEX"]="src_vtx";
|
||||
mode_replace_table[3]["VERTEX"]="outvec.xy";
|
||||
mode_replace_table[3]["WORLD_VERTEX"]="outvec.xy";
|
||||
mode_replace_table[3]["UV"]="uv_interp";
|
||||
mode_replace_table[3]["COLOR"]="color_interp";
|
||||
mode_replace_table[3]["VAR1"]="var1_interp";
|
||||
mode_replace_table[3]["VAR2"]="var2_interp";
|
||||
mode_replace_table[3]["POINT_SIZE"]="gl_PointSize";
|
||||
mode_replace_table[3]["WORLD_MATRIX"]="modelview_matrix";
|
||||
mode_replace_table[3]["PROJECTION_MATRIX"]="projection_matrix";
|
||||
mode_replace_table[3]["EXTRA_MATRIX"]="extra_matrix";
|
||||
mode_replace_table[3]["TIME"]="time";
|
||||
|
||||
mode_replace_table[4]["POSITION"]="gl_Position";
|
||||
mode_replace_table[4]["NORMAL"]="normal";
|
||||
mode_replace_table[4]["UV"]="uv_interp";
|
||||
mode_replace_table[4]["SRC_COLOR"]="color_interp";
|
||||
mode_replace_table[4]["COLOR"]="color";
|
||||
mode_replace_table[4]["TEXTURE"]="texture";
|
||||
mode_replace_table[4]["TEXTURE_PIXEL_SIZE"]="texpixel_size";
|
||||
mode_replace_table[4]["VAR1"]="var1_interp";
|
||||
mode_replace_table[4]["VAR2"]="var2_interp";
|
||||
mode_replace_table[4]["SCREEN_UV"]="screen_uv";
|
||||
mode_replace_table[4]["POINT_COORD"]="gl_PointCoord";
|
||||
mode_replace_table[4]["TIME"]="time";
|
||||
|
||||
mode_replace_table[5]["SRC_COLOR"]="color";
|
||||
mode_replace_table[5]["COLOR"]="color";
|
||||
mode_replace_table[5]["NORMAL"]="normal";
|
||||
mode_replace_table[5]["LIGHT_DIR"]="light_dir";
|
||||
mode_replace_table[5]["LIGHT_DISTANCE"]="light_distance";
|
||||
mode_replace_table[5]["LIGHT"]="light";
|
||||
mode_replace_table[5]["POINT_COORD"]="gl_PointCoord";
|
||||
mode_replace_table[5]["TIME"]="time";
|
||||
|
||||
|
||||
|
||||
//mode_replace_table[2]["SCREEN_POS"]="SCREEN_POS";
|
||||
//mode_replace_table[2]["SCREEN_TEXEL_SIZE"]="SCREEN_TEXEL_SIZE";
|
||||
|
||||
@ -738,5 +834,8 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
|
||||
vname_light="LIGHT";
|
||||
vname_time="TIME";
|
||||
vname_normalmap="NORMALMAP";
|
||||
vname_normal="NORMAL";
|
||||
vname_texpixel_size="TEXTURE_PIXEL_SIZE";
|
||||
vname_world_vec="WORLD_VERTEX";
|
||||
|
||||
}
|
||||
|
@ -51,6 +51,9 @@ private:
|
||||
bool uses_time;
|
||||
bool uses_screen_uv;
|
||||
bool uses_normalmap;
|
||||
bool uses_normal;
|
||||
bool uses_texpixel_size;
|
||||
bool uses_worldvec;
|
||||
bool vertex_code_writes_vertex;
|
||||
Flags *flags;
|
||||
|
||||
@ -68,6 +71,9 @@ private:
|
||||
StringName vname_light;
|
||||
StringName vname_time;
|
||||
StringName vname_normalmap;
|
||||
StringName vname_normal;
|
||||
StringName vname_texpixel_size;
|
||||
StringName vname_world_vec;
|
||||
|
||||
Map<StringName,ShaderLanguage::Uniform> *uniforms;
|
||||
|
||||
@ -79,7 +85,7 @@ private:
|
||||
|
||||
String replace_string(const StringName& p_string);
|
||||
|
||||
Map<StringName,StringName> mode_replace_table[3];
|
||||
Map<StringName,StringName> mode_replace_table[9];
|
||||
Map<StringName,StringName> replace_table;
|
||||
|
||||
public:
|
||||
@ -101,6 +107,9 @@ public:
|
||||
bool use_var2_interp;
|
||||
bool uses_light;
|
||||
bool uses_time;
|
||||
bool uses_normal;
|
||||
bool uses_texpixel_size;
|
||||
bool uses_worldvec;
|
||||
};
|
||||
|
||||
Error compile(const String& p_code, ShaderLanguage::ShaderType p_type, String& r_code_line, String& r_globals_line, Flags& r_flags, Map<StringName,ShaderLanguage::Uniform> *r_uniforms=NULL);
|
||||
|
@ -18,20 +18,60 @@ attribute highp vec2 uv_attrib; // attrib:4
|
||||
varying vec2 uv_interp;
|
||||
varying vec4 color_interp;
|
||||
|
||||
#if defined(USE_TIME)
|
||||
uniform float time;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_LIGHTING
|
||||
|
||||
uniform highp mat4 light_matrix;
|
||||
varying vec4 light_tex_pos;
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_VAR1_INTERP)
|
||||
varying vec4 var1_interp;
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_VAR2_INTERP)
|
||||
varying vec4 var2_interp;
|
||||
#endif
|
||||
|
||||
//uniform bool snap_pixels;
|
||||
|
||||
VERTEX_SHADER_GLOBALS
|
||||
|
||||
void main() {
|
||||
|
||||
color_interp = color_attrib;
|
||||
uv_interp = uv_attrib;
|
||||
highp vec4 outvec = vec4(vertex, 1.0);
|
||||
outvec = extra_matrix * outvec;
|
||||
outvec = modelview_matrix * outvec;
|
||||
highp vec4 outvec = vec4(vertex, 1.0);
|
||||
{
|
||||
vec2 src_vtx=outvec.xy;
|
||||
VERTEX_SHADER_CODE
|
||||
|
||||
}
|
||||
#if !defined(USE_WORLD_VEC)
|
||||
outvec = extra_matrix * outvec;
|
||||
outvec = modelview_matrix * outvec;
|
||||
#endif
|
||||
|
||||
#ifdef USE_PIXEL_SNAP
|
||||
|
||||
outvec.xy=floor(outvec.xy+0.5);
|
||||
outvec.xy=floor(outvec.xy+0.5);
|
||||
#endif
|
||||
|
||||
|
||||
gl_Position = projection_matrix * outvec;
|
||||
|
||||
#ifdef USE_LIGHTING
|
||||
|
||||
light_tex_pos.xy = light_matrix * gl_Position;
|
||||
light_tex_pos.zw=outvec.xy - light_matrix[4].xy; //likely wrong
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
[fragment]
|
||||
@ -54,17 +94,112 @@ varying vec4 color_interp;
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_SCREEN_UV)
|
||||
|
||||
uniform vec2 screen_uv_mult;
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_TEXSCREEN)
|
||||
|
||||
uniform vec2 texscreen_screen_mult;
|
||||
uniform vec4 texscreen_screen_clamp;
|
||||
uniform sampler2D texscreen_tex;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(ENABLE_VAR1_INTERP)
|
||||
varying vec4 var1_interp;
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_VAR2_INTERP)
|
||||
varying vec4 var2_interp;
|
||||
#endif
|
||||
|
||||
#if defined(USE_TIME)
|
||||
uniform float time;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_LIGHTING
|
||||
|
||||
uniform sampler2D light_texture;
|
||||
varying vec4 light_tex_pos;
|
||||
|
||||
#ifdef USE_SHADOWS
|
||||
|
||||
uniform sampler2D shadow_texture;
|
||||
uniform float shadow_attenuation;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(USE_TEXPIXEL_SIZE)
|
||||
uniform vec2 texpixel_size;
|
||||
#endif
|
||||
|
||||
|
||||
FRAGMENT_SHADER_GLOBALS
|
||||
|
||||
|
||||
void main() {
|
||||
|
||||
vec4 color = color_interp;
|
||||
|
||||
color *= texture2D( texture, uv_interp );
|
||||
#if defined(NORMAL_USED)
|
||||
vec3 normal = vec3(0,0,1);
|
||||
#endif
|
||||
|
||||
color *= texture2D( texture, uv_interp );
|
||||
#if defined(ENABLE_SCREEN_UV)
|
||||
vec2 screen_uv = gl_FragCoord.xy*screen_uv_mult;
|
||||
#endif
|
||||
|
||||
{
|
||||
FRAGMENT_SHADER_CODE
|
||||
}
|
||||
#ifdef DEBUG_ENCODED_32
|
||||
highp float enc32 = dot( color,highp vec4(1.0 / (256.0 * 256.0 * 256.0),1.0 / (256.0 * 256.0),1.0 / 256.0,1) );
|
||||
color = vec4(vec3(enc32),1.0);
|
||||
#endif
|
||||
|
||||
#ifdef USE_LIGHTING
|
||||
|
||||
float att=1.0;
|
||||
|
||||
vec3 light = texture2D(light_texture,light_tex_pos).rgb;
|
||||
#ifdef USE_SHADOWS
|
||||
//this might not be that great on mobile?
|
||||
float light_dist = length(light_texture.zw);
|
||||
float light_angle = atan2(light_texture.x,light_texture.z) + 1.0 * 0.5;
|
||||
float shadow_dist = texture2D(shadow_texture,vec2(light_angle,0));
|
||||
if (light_dist>shadow_dist) {
|
||||
light*=shadow_attenuation;
|
||||
}
|
||||
//use shadows
|
||||
#endif
|
||||
|
||||
#if defined(USE_LIGHT_SHADER_CODE)
|
||||
//light is written by the light shader
|
||||
{
|
||||
vec2 light_dir = normalize(light_tex_pos.zw);
|
||||
float light_distance = length(light_tex_pos.zw);
|
||||
LIGHT_SHADER_CODE
|
||||
}
|
||||
#else
|
||||
|
||||
#if defined(NORMAL_USED)
|
||||
vec2 light_normal = normalize(light_tex_pos.zw);
|
||||
light = color.rgb * light * max(dot(light_normal,normal),0);
|
||||
#endif
|
||||
|
||||
color.rgb=light;
|
||||
//light shader code
|
||||
#endif
|
||||
|
||||
//use lighting
|
||||
#endif
|
||||
// color.rgb*=color.a;
|
||||
gl_FragColor = color;
|
||||
|
||||
|
@ -779,6 +779,7 @@ uniform highp mat4 camera_inverse_transform;
|
||||
#if defined(ENABLE_TEXSCREEN)
|
||||
|
||||
uniform vec2 texscreen_screen_mult;
|
||||
uniform vec4 texscreen_screen_clamp;
|
||||
uniform sampler2D texscreen_tex;
|
||||
|
||||
#endif
|
||||
|
@ -64,10 +64,10 @@ Error ResourceSaverPNG::save(const String &p_path,const RES& p_resource,uint32_t
|
||||
text+=bool(texture->get_flags()&Texture::FLAG_FILTER)?"filter=true\n":"filter=false\n";
|
||||
}
|
||||
if (global_mipmaps!=bool(texture->get_flags()&Texture::FLAG_MIPMAPS)) {
|
||||
text+=bool(texture->get_flags()&Texture::FLAG_FILTER)?"gen_mipmaps=true\n":"gen_mipmaps=false\n";
|
||||
text+=bool(texture->get_flags()&Texture::FLAG_MIPMAPS)?"gen_mipmaps=true\n":"gen_mipmaps=false\n";
|
||||
}
|
||||
if (global_repeat!=bool(texture->get_flags()&Texture::FLAG_REPEAT)) {
|
||||
text+=bool(texture->get_flags()&Texture::FLAG_FILTER)?"repeat=true\n":"repeat=false\n";
|
||||
text+=bool(texture->get_flags()&Texture::FLAG_REPEAT)?"repeat=true\n":"repeat=false\n";
|
||||
}
|
||||
if (bool(texture->get_flags()&Texture::FLAG_ANISOTROPIC_FILTER)) {
|
||||
text+="anisotropic=true\n";
|
||||
|
@ -70,7 +70,7 @@ if env["platform"] == "iphone":
|
||||
env_theora.Append(CPPFLAGS=["-D_IOS", "-D__ARM_NEON__", "-fstrict-aliasing", "-fmessage-length=210", "-fdiagnostics-show-note-include-stack", "-fmacro-backtrace-limit=0", "-fcolor-diagnostics", "-Wno-trigraphs", "-fpascal-strings", "-fvisibility=hidden", "-fvisibility-inlines-hidden"])
|
||||
|
||||
env_theora.Append(CPPFLAGS=["-D_LIB", "-D__THEORA"]) # removed -D_YUV_C
|
||||
env_theora.Append(CPPFLAGS=["-D_YUV_LIBYUV", "-DLIBYUV_NEON"])
|
||||
env_theora.Append(CPPFLAGS=["-D_YUV_LIBYUV"])
|
||||
#env_theora.Append(CPPFLAGS=["-D_YUV_C"])
|
||||
|
||||
if env["platform"] == "iphone":
|
||||
|
36
methods.py
@ -1316,3 +1316,39 @@ def save_active_platforms(apnames,ap):
|
||||
logow = open(wf,"wb")
|
||||
logow.write(str)
|
||||
|
||||
|
||||
def colored(sys,env):
|
||||
|
||||
#If the output is not a terminal, do nothing
|
||||
if not sys.stdout.isatty():
|
||||
return
|
||||
|
||||
colors = {}
|
||||
colors['cyan'] = '\033[96m'
|
||||
colors['purple'] = '\033[95m'
|
||||
colors['blue'] = '\033[94m'
|
||||
colors['green'] = '\033[92m'
|
||||
colors['yellow'] = '\033[93m'
|
||||
colors['red'] = '\033[91m'
|
||||
colors['end'] = '\033[0m'
|
||||
|
||||
compile_source_message = '%sCompiling %s==> %s$SOURCE%s' % (colors['blue'], colors['purple'], colors['yellow'], colors['end'])
|
||||
java_compile_source_message = '%sCompiling %s==> %s$SOURCE%s' % (colors['blue'], colors['purple'], colors['yellow'], colors['end'])
|
||||
compile_shared_source_message = '%sCompiling shared %s==> %s$SOURCE%s' % (colors['blue'], colors['purple'], colors['yellow'], colors['end'])
|
||||
link_program_message = '%sLinking Program %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end'])
|
||||
link_library_message = '%sLinking Static Library %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end'])
|
||||
ranlib_library_message = '%sRanlib Library %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end'])
|
||||
link_shared_library_message = '%sLinking Shared Library %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end'])
|
||||
java_library_message = '%sCreating Java Archive %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end'])
|
||||
|
||||
env.Append( CXXCOMSTR=[compile_source_message] )
|
||||
env.Append( CCCOMSTR=[compile_source_message] )
|
||||
env.Append( SHCCCOMSTR=[compile_shared_source_message] )
|
||||
env.Append( SHCXXCOMSTR=[compile_shared_source_message] )
|
||||
env.Append( ARCOMSTR=[link_library_message] )
|
||||
env.Append( RANLIBCOMSTR=[ranlib_library_message] )
|
||||
env.Append( SHLINKCOMSTR=[link_shared_library_message] )
|
||||
env.Append( LINKCOMSTR=[link_program_message] )
|
||||
env.Append( JARCOMSTR=[java_library_message] )
|
||||
env.Append( JAVACCOMSTR=[java_compile_source_message] )
|
||||
|
||||
|
@ -37,77 +37,65 @@ class GDCompiler {
|
||||
|
||||
const GDParser *parser;
|
||||
struct CodeGen {
|
||||
|
||||
|
||||
GDScript *script;
|
||||
const GDParser::ClassNode *class_node;
|
||||
const GDParser::FunctionNode *function_node;
|
||||
bool debug_stack;
|
||||
|
||||
List< Map<StringName,int> > stack_id_stack;
|
||||
Map<StringName,int> stack_identifiers;
|
||||
|
||||
List<GDFunction::StackDebug> stack_debug;
|
||||
List< Map<StringName,int> > block_identifier_stack;
|
||||
Map<StringName,int> block_identifiers;
|
||||
|
||||
void add_stack_identifier(const StringName& p_id,int p_stackpos) {
|
||||
stack_identifiers[p_id]=p_stackpos;
|
||||
if (debug_stack) {
|
||||
block_identifiers[p_id]=p_stackpos;
|
||||
GDFunction::StackDebug sd;
|
||||
sd.added=true;
|
||||
sd.line=current_line;
|
||||
sd.identifier=p_id;
|
||||
sd.pos=p_stackpos;
|
||||
stack_debug.push_back(sd);
|
||||
}
|
||||
}
|
||||
|
||||
void push_stack_identifiers() {
|
||||
stack_id_stack.push_back( stack_identifiers );
|
||||
if (debug_stack) {
|
||||
|
||||
block_identifier_stack.push_back(block_identifiers);
|
||||
block_identifiers.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void pop_stack_identifiers() {
|
||||
stack_identifiers = stack_id_stack.back()->get();
|
||||
stack_id_stack.pop_back();
|
||||
|
||||
if (debug_stack) {
|
||||
for (Map<StringName,int>::Element *E=block_identifiers.front();E;E=E->next()) {
|
||||
|
||||
GDFunction::StackDebug sd;
|
||||
sd.added=false;
|
||||
sd.identifier=E->key();
|
||||
sd.line=current_line;
|
||||
sd.pos=E->get();
|
||||
stack_debug.push_back(sd);
|
||||
}
|
||||
block_identifiers=block_identifier_stack.back()->get();
|
||||
block_identifier_stack.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool debug_stack;
|
||||
|
||||
|
||||
List< Map<StringName,int> > stack_id_stack;
|
||||
Map<StringName,int> stack_identifiers;
|
||||
|
||||
List<GDFunction::StackDebug> stack_debug;
|
||||
List< Map<StringName,int> > block_identifier_stack;
|
||||
Map<StringName,int> block_identifiers;
|
||||
|
||||
|
||||
void add_stack_identifier(const StringName& p_id,int p_stackpos) {
|
||||
|
||||
stack_identifiers[p_id]=p_stackpos;
|
||||
if (debug_stack) {
|
||||
|
||||
block_identifiers[p_id]=p_stackpos;
|
||||
GDFunction::StackDebug sd;
|
||||
sd.added=true;
|
||||
sd.line=current_line;
|
||||
sd.identifier=p_id;
|
||||
sd.pos=p_stackpos;
|
||||
stack_debug.push_back(sd);
|
||||
}
|
||||
}
|
||||
|
||||
void push_stack_identifiers() {
|
||||
|
||||
stack_id_stack.push_back( stack_identifiers );
|
||||
if (debug_stack) {
|
||||
|
||||
block_identifier_stack.push_back(block_identifiers);
|
||||
block_identifiers.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void pop_stack_identifiers() {
|
||||
|
||||
stack_identifiers = stack_id_stack.back()->get();
|
||||
stack_id_stack.pop_back();
|
||||
|
||||
if (debug_stack) {
|
||||
for (Map<StringName,int>::Element *E=block_identifiers.front();E;E=E->next()) {
|
||||
|
||||
GDFunction::StackDebug sd;
|
||||
sd.added=false;
|
||||
sd.identifier=E->key();
|
||||
sd.line=current_line;
|
||||
sd.pos=E->get();
|
||||
stack_debug.push_back(sd);
|
||||
}
|
||||
block_identifiers=block_identifier_stack.back()->get();
|
||||
block_identifier_stack.pop_back();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// int get_identifier_pos(const StringName& p_dentifier) const;
|
||||
//int get_identifier_pos(const StringName& p_dentifier) const;
|
||||
HashMap<Variant,int,VariantHasher> constant_map;
|
||||
Map<StringName,int> name_map;
|
||||
|
||||
int get_name_map_pos(const StringName& p_identifier) {
|
||||
|
||||
int ret;
|
||||
if (!name_map.has(p_identifier)) {
|
||||
ret=name_map.size();
|
||||
@ -118,11 +106,7 @@ class GDCompiler {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int get_constant_pos(const Variant& p_constant) {
|
||||
|
||||
|
||||
if (constant_map.has(p_constant))
|
||||
return constant_map[p_constant];
|
||||
int pos = constant_map.size();
|
||||
@ -134,7 +118,7 @@ class GDCompiler {
|
||||
void alloc_stack(int p_level) { if (p_level >= stack_max) stack_max=p_level+1; }
|
||||
void alloc_call(int p_params) { if (p_params >= call_max) call_max=p_params; }
|
||||
|
||||
int current_line;
|
||||
int current_line;
|
||||
int stack_max;
|
||||
int call_max;
|
||||
};
|
||||
|
@ -1661,7 +1661,7 @@ Error GDScriptLanguage::complete_code(const String& p_code, const String& p_base
|
||||
//print_line( p_code.replace(String::chr(0xFFFF),"<cursor>"));
|
||||
|
||||
GDParser p;
|
||||
Error err = p.parse(p_code,p_base_path);
|
||||
Error err = p.parse(p_code,p_base_path,true);
|
||||
bool isfunction=false;
|
||||
Set<String> options;
|
||||
|
||||
|
@ -124,11 +124,11 @@ def configure(env):
|
||||
# env['CCFLAGS'] = string.split('-DNO_THREADS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -mthumb -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED ')
|
||||
|
||||
if env['x86']=='yes':
|
||||
env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__GLIBC__ -Wno-psabi -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED -DGLES1_ENABLED')
|
||||
env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__GLIBC__ -Wno-psabi -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
|
||||
elif env["armv6"]!="no":
|
||||
env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_6__ -D__GLIBC__ -Wno-psabi -march=armv6 -mfpu=vfp -mfloat-abi=softfp -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED -DGLES1_ENABLED')
|
||||
env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_6__ -D__GLIBC__ -Wno-psabi -march=armv6 -mfpu=vfp -mfloat-abi=softfp -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
|
||||
else:
|
||||
env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_7__ -D__GLIBC__ -Wno-psabi -march=armv6 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED -DGLES1_ENABLED')
|
||||
env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_7__ -D__GLIBC__ -Wno-psabi -march=armv6 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
|
||||
|
||||
env.Append(LDPATH=[ld_path])
|
||||
env.Append(LIBS=['OpenSLES'])
|
||||
|
@ -10,5 +10,5 @@ void register_android_global_defaults() {
|
||||
GLOBAL_DEF("display.Android/driver","GLES2");
|
||||
// GLOBAL_DEF("rasterizer.Android/trilinear_mipmap_filter",false);
|
||||
|
||||
Globals::get_singleton()->set_custom_property_info("display.Android/driver",PropertyInfo(Variant::STRING,"display.Android/driver",PROPERTY_HINT_ENUM,"GLES1,GLES2"));
|
||||
Globals::get_singleton()->set_custom_property_info("display.Android/driver",PropertyInfo(Variant::STRING,"display.Android/driver",PROPERTY_HINT_ENUM,"GLES2"));
|
||||
}
|
||||
|
@ -205,6 +205,7 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) {
|
||||
String name = _get_class_name(env, c, &array);
|
||||
//print_line("name is " + name + ", array "+Variant(array));
|
||||
|
||||
print_line("ARGNAME: "+name);
|
||||
if (name == "java.lang.String") {
|
||||
|
||||
return String::utf8(env->GetStringUTFChars( (jstring)obj, NULL ));
|
||||
@ -821,10 +822,7 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env,
|
||||
String vd = Globals::get_singleton()->get("display/driver");
|
||||
|
||||
|
||||
if (vd.to_upper()=="GLES1")
|
||||
env->CallVoidMethod(_godot_instance, _on_video_init, (jboolean)false);
|
||||
else
|
||||
env->CallVoidMethod(_godot_instance, _on_video_init, (jboolean)true);
|
||||
env->CallVoidMethod(_godot_instance, _on_video_init, (jboolean)true);
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO,"godot","**START");
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
/*************************************************************************/
|
||||
#include "os_android.h"
|
||||
#include "drivers/gles2/rasterizer_gles2.h"
|
||||
#include "drivers/gles1/rasterizer_gles1.h"
|
||||
|
||||
#include "core/io/file_access_buffered_fa.h"
|
||||
#include "drivers/unix/file_access_unix.h"
|
||||
#include "drivers/unix/dir_access_unix.h"
|
||||
@ -49,11 +49,11 @@
|
||||
|
||||
int OS_Android::get_video_driver_count() const {
|
||||
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
const char * OS_Android::get_video_driver_name(int p_driver) const {
|
||||
|
||||
return p_driver==0?"GLES2":"GLES1";
|
||||
return "GLES2";
|
||||
}
|
||||
|
||||
OS::VideoMode OS_Android::get_default_video_mode() const {
|
||||
@ -123,13 +123,13 @@ void OS_Android::initialize(const VideoMode& p_desired,int p_video_driver,int p_
|
||||
AudioDriverManagerSW::add_driver(&audio_driver_android);
|
||||
|
||||
|
||||
if (use_gl2) {
|
||||
if (true) {
|
||||
RasterizerGLES2 *rasterizer_gles22=memnew( RasterizerGLES2(false,use_reload_hooks,false,use_reload_hooks ) );
|
||||
if (gl_extensions)
|
||||
rasterizer_gles22->set_extensions(gl_extensions);
|
||||
rasterizer = rasterizer_gles22;
|
||||
} else {
|
||||
rasterizer = memnew( RasterizerGLES1(use_reload_hooks, use_reload_hooks) );
|
||||
//rasterizer = memnew( RasterizerGLES1(use_reload_hooks, use_reload_hooks) );
|
||||
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,6 @@ env_ios = env.Clone();
|
||||
if env['ios_gles22_override'] == "yes":
|
||||
env_ios.Append(CPPFLAGS=['-DGLES2_OVERRIDE'])
|
||||
|
||||
if env['ios_GLES1_override'] == "yes":
|
||||
env_ios.Append(CPPFLAGS=['-DGLES1_OVERRIDE'])
|
||||
|
||||
if env['ios_appirater'] == "yes":
|
||||
env_ios.Append(CPPFLAGS=['-DAPPIRATER_ENABLED'])
|
||||
|
@ -26,7 +26,6 @@ def get_opts():
|
||||
('game_center', 'Support for game center', 'yes'),
|
||||
('store_kit', 'Support for in-app store', 'yes'),
|
||||
('ios_gles22_override', 'Force GLES2.0 on iOS', 'yes'),
|
||||
('ios_GLES1_override', 'Force legacy GLES (1.1) on iOS', 'no'),
|
||||
('ios_appirater', 'Enable Appirater', 'no'),
|
||||
('ios_exceptions', 'Use exceptions when compiling on playbook', 'yes'),
|
||||
]
|
||||
@ -130,7 +129,7 @@ def configure(env):
|
||||
|
||||
|
||||
env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate'
|
||||
env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES1_ENABLED', '-DMPC_FIXED_POINT'])
|
||||
env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DMPC_FIXED_POINT'])
|
||||
if env['ios_exceptions'] == 'yes':
|
||||
env.Append(CPPFLAGS=['-fexceptions'])
|
||||
else:
|
||||
|
@ -307,11 +307,7 @@ static void clear_touches() {
|
||||
nil];
|
||||
|
||||
// Create our EAGLContext, and if successful make it current and create our framebuffer.
|
||||
#ifdef GLES1_OVERRIDE
|
||||
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
|
||||
#else
|
||||
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||
#endif
|
||||
|
||||
if(!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer])
|
||||
{
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "os_iphone.h"
|
||||
|
||||
#include "drivers/gles2/rasterizer_gles2.h"
|
||||
#include "drivers/gles1/rasterizer_gles1.h"
|
||||
|
||||
|
||||
#include "servers/visual/visual_server_raster.h"
|
||||
#include "servers/visual/visual_server_wrap_mt.h"
|
||||
@ -52,7 +52,7 @@ int OSIPhone::get_video_driver_count() const {
|
||||
|
||||
const char * OSIPhone::get_video_driver_name(int p_driver) const {
|
||||
|
||||
return "openglES";
|
||||
return "GLES2";
|
||||
};
|
||||
|
||||
OSIPhone* OSIPhone::get_singleton() {
|
||||
@ -106,13 +106,9 @@ void OSIPhone::initialize(const VideoMode& p_desired,int p_video_driver,int p_au
|
||||
supported_orientations |= ((GLOBAL_DEF("video_mode/allow_vertical", false)?1:0) << PortraitDown);
|
||||
supported_orientations |= ((GLOBAL_DEF("video_mode/allow_vertical_flipped", false)?1:0) << PortraitUp);
|
||||
|
||||
#ifdef GLES1_OVERRIDE
|
||||
rasterizer = memnew( RasterizerGLES1 );
|
||||
#else
|
||||
rasterizer_gles22 = memnew( RasterizerGLES2(false, false, false) );
|
||||
rasterizer = rasterizer_gles22;
|
||||
rasterizer_gles22->set_base_framebuffer(gl_view_base_fb);
|
||||
#endif
|
||||
|
||||
visual_server = memnew( VisualServerRaster(rasterizer) );
|
||||
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
|
||||
|
@ -28,6 +28,6 @@
|
||||
/*************************************************************************/
|
||||
#include <alloca.h>
|
||||
#define GLES2_INCLUDE_H <ES2/gl.h>
|
||||
#define GLES1_INCLUDE_H <ES1/gl.h>
|
||||
|
||||
|
||||
#define PLATFORM_REFCOUNT
|
||||
|
@ -25,8 +25,6 @@ env_ios = env.Clone();
|
||||
if env['ios_gles22_override'] == "yes":
|
||||
env_ios.Append(CPPFLAGS=['-DGLES2_OVERRIDE'])
|
||||
|
||||
if env['ios_GLES1_override'] == "yes":
|
||||
env_ios.Append(CPPFLAGS=['-DGLES1_OVERRIDE'])
|
||||
|
||||
if env['ios_appirater'] == "yes":
|
||||
env_ios.Append(CPPFLAGS=['-DAPPIRATER_ENABLED'])
|
||||
|
@ -64,7 +64,7 @@ int OSNacl::get_video_driver_count() const {
|
||||
};
|
||||
const char * OSNacl::get_video_driver_name(int p_driver) const {
|
||||
|
||||
return "gles2";
|
||||
return "GLES2";
|
||||
};
|
||||
|
||||
OS::VideoMode OSNacl::get_default_video_mode() const {
|
||||
|
@ -78,12 +78,15 @@ def configure(env):
|
||||
env.Append(LIBS=['pthread'])
|
||||
#env.Append(CPPFLAGS=['-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-mmacosx-version-min=10.4'])
|
||||
#env.Append(LINKFLAGS=['-mmacosx-version-min=10.4', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk'])
|
||||
env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit','-lz'])
|
||||
env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit','-lz'])
|
||||
|
||||
if (env["CXX"]=="clang++"):
|
||||
env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
|
||||
env["CC"]="clang"
|
||||
env["LD"]="clang++"
|
||||
if (env["colored"]=="yes"):
|
||||
if sys.stdout.isatty():
|
||||
env.Append(CPPFLAGS=["-fcolor-diagnostics"])
|
||||
|
||||
import methods
|
||||
|
||||
|
@ -156,6 +156,8 @@ public:
|
||||
|
||||
virtual String get_executable_path() const;
|
||||
|
||||
virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
|
||||
|
||||
virtual void move_window_to_foreground();
|
||||
|
||||
void run();
|
||||
|
@ -27,6 +27,8 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
#include <IOKit/IOKitLib.h>
|
||||
#include <IOKit/IOCFPlugIn.h>
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
@ -835,11 +837,24 @@ void OS_OSX::initialize_core() {
|
||||
|
||||
}
|
||||
|
||||
static bool keyboard_layout_dirty = true;
|
||||
static void keyboardLayoutChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
|
||||
keyboard_layout_dirty = true;
|
||||
}
|
||||
|
||||
void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) {
|
||||
|
||||
/*** OSX INITIALIZATION ***/
|
||||
/*** OSX INITIALIZATION ***/
|
||||
/*** OSX INITIALIZATION ***/
|
||||
|
||||
keyboard_layout_dirty = true;
|
||||
|
||||
// Register to be notified on keyboard layout changes
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(),
|
||||
NULL, keyboardLayoutChanged,
|
||||
kTISNotifySelectedKeyboardInputSourceChanged, NULL,
|
||||
CFNotificationSuspensionBehaviorDeliverImmediately);
|
||||
|
||||
window_delegate = [[GodotWindowDelegate alloc] init];
|
||||
|
||||
@ -1007,6 +1022,8 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
|
||||
}
|
||||
void OS_OSX::finalize() {
|
||||
|
||||
CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), NULL, kTISNotifySelectedKeyboardInputSourceChanged, NULL);
|
||||
|
||||
}
|
||||
|
||||
void OS_OSX::set_main_loop( MainLoop * p_main_loop ) {
|
||||
@ -1241,6 +1258,83 @@ String OS_OSX::get_executable_path() const {
|
||||
|
||||
}
|
||||
|
||||
// Returns string representation of keys, if they are printable.
|
||||
//
|
||||
static NSString *createStringForKeys(const CGKeyCode *keyCode, int length) {
|
||||
|
||||
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
|
||||
if (!currentKeyboard)
|
||||
return nil;
|
||||
|
||||
CFDataRef layoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData);
|
||||
if (!layoutData)
|
||||
return nil;
|
||||
|
||||
const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData);
|
||||
|
||||
OSStatus err;
|
||||
CFMutableStringRef output = CFStringCreateMutable(NULL, 0);
|
||||
|
||||
for (int i=0; i<length; ++i) {
|
||||
|
||||
UInt32 keysDown = 0;
|
||||
UniChar chars[4];
|
||||
UniCharCount realLength;
|
||||
|
||||
err = UCKeyTranslate(keyboardLayout,
|
||||
keyCode[i],
|
||||
kUCKeyActionDisplay,
|
||||
0,
|
||||
LMGetKbdType(),
|
||||
kUCKeyTranslateNoDeadKeysBit,
|
||||
&keysDown,
|
||||
sizeof(chars) / sizeof(chars[0]),
|
||||
&realLength,
|
||||
chars);
|
||||
|
||||
if (err != noErr) {
|
||||
CFRelease(output);
|
||||
return nil;
|
||||
}
|
||||
|
||||
CFStringAppendCharacters(output, chars, 1);
|
||||
}
|
||||
|
||||
//CFStringUppercase(output, NULL);
|
||||
|
||||
return (NSString *)output;
|
||||
}
|
||||
OS::LatinKeyboardVariant OS_OSX::get_latin_keyboard_variant() const {
|
||||
|
||||
static LatinKeyboardVariant layout = LATIN_KEYBOARD_QWERTY;
|
||||
|
||||
if (keyboard_layout_dirty) {
|
||||
|
||||
layout = LATIN_KEYBOARD_QWERTY;
|
||||
|
||||
CGKeyCode keys[] = {kVK_ANSI_Q, kVK_ANSI_W, kVK_ANSI_E, kVK_ANSI_R, kVK_ANSI_T, kVK_ANSI_Y};
|
||||
NSString *test = createStringForKeys(keys, 6);
|
||||
|
||||
if ([test isEqualToString:@"qwertz"]) {
|
||||
layout = LATIN_KEYBOARD_QWERTZ;
|
||||
} else if ([test isEqualToString:@"azerty"]) {
|
||||
layout = LATIN_KEYBOARD_AZERTY;
|
||||
} else if ([test isEqualToString:@"qzerty"]) {
|
||||
layout = LATIN_KEYBOARD_QZERTY;
|
||||
} else if ([test isEqualToString:@"',.pyf"]) {
|
||||
layout = LATIN_KEYBOARD_DVORAK;
|
||||
} else if ([test isEqualToString:@"xvlcwk"]) {
|
||||
layout = LATIN_KEYBOARD_NEO;
|
||||
}
|
||||
|
||||
[test release];
|
||||
|
||||
keyboard_layout_dirty = false;
|
||||
return layout;
|
||||
}
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
void OS_OSX::process_events() {
|
||||
|
||||
|
@ -40,6 +40,9 @@ def configure(env):
|
||||
env["CC"]="clang"
|
||||
env["CXX"]="clang++"
|
||||
env["LD"]="clang++"
|
||||
if (env["colored"]=="yes"):
|
||||
if sys.stdout.isatty():
|
||||
env.Append(CXXFLAGS=["-fcolor-diagnostics"])
|
||||
|
||||
is64=sys.maxsize > 2**32
|
||||
|
||||
|
@ -113,7 +113,7 @@ def configure(env):
|
||||
env.Append(CCFLAGS=['/DTYPED_METHOD_BIND'])
|
||||
|
||||
env.Append(CCFLAGS=['/DGLES2_ENABLED'])
|
||||
env.Append(CCFLAGS=['/DGLES1_ENABLED'])
|
||||
|
||||
env.Append(CCFLAGS=['/DGLEW_ENABLED'])
|
||||
LIBS=['winmm','opengl32','dsound','kernel32','ole32','user32','gdi32', 'IPHLPAPI', 'wsock32', 'shell32','advapi32']
|
||||
env.Append(LINKFLAGS=[p+env["LIBSUFFIX"] for p in LIBS])
|
||||
@ -228,7 +228,7 @@ def configure(env):
|
||||
|
||||
env.Append(CCFLAGS=['-DWINDOWS_ENABLED','-mwindows'])
|
||||
env.Append(CPPFLAGS=['-DRTAUDIO_ENABLED'])
|
||||
env.Append(CCFLAGS=['-DGLES2_ENABLED','-DGLES1_ENABLED','-DGLEW_ENABLED'])
|
||||
env.Append(CCFLAGS=['-DGLES2_ENABLED','-DGLEW_ENABLED'])
|
||||
env.Append(LIBS=['mingw32','opengl32', 'dsound', 'ole32', 'd3d9','winmm','gdi32','iphlpapi','wsock32','kernel32'])
|
||||
|
||||
if (env["bits"]=="32" and env["mingw64_for_32"]!="yes"):
|
||||
|
@ -27,7 +27,7 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#include "drivers/gles2/rasterizer_gles2.h"
|
||||
#include "drivers/gles1/rasterizer_gles1.h"
|
||||
|
||||
#include "os_windows.h"
|
||||
#include "drivers/nedmalloc/memory_pool_static_nedmalloc.h"
|
||||
#include "drivers/unix/memory_pool_static_malloc.h"
|
||||
@ -56,6 +56,13 @@
|
||||
#include "shlobj.h"
|
||||
static const WORD MAX_CONSOLE_LINES = 1500;
|
||||
|
||||
extern "C" {
|
||||
#ifdef _MSC_VER
|
||||
_declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
|
||||
#else
|
||||
__attribute__((visibility("default"))) DWORD NvOptimusEnablement = 0x00000001;
|
||||
#endif
|
||||
}
|
||||
|
||||
//#define STDOUT_FILE
|
||||
|
||||
@ -130,11 +137,11 @@ void RedirectIOToConsole() {
|
||||
|
||||
int OS_Windows::get_video_driver_count() const {
|
||||
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
const char * OS_Windows::get_video_driver_name(int p_driver) const {
|
||||
|
||||
return p_driver==0?"GLES2":"GLES1";
|
||||
return "GLES2";
|
||||
}
|
||||
|
||||
OS::VideoMode OS_Windows::get_default_video_mode() const {
|
||||
|
@ -31,5 +31,5 @@
|
||||
//#include <alloca.h>
|
||||
//#endif
|
||||
#define GLES2_INCLUDE_H "gl_context/glew.h"
|
||||
#define GLES1_INCLUDE_H "gl_context/glew.h"
|
||||
|
||||
|
||||
|
@ -47,6 +47,7 @@ def get_opts():
|
||||
return [
|
||||
('use_llvm','Use llvm compiler','no'),
|
||||
('use_sanitizer','Use llvm compiler sanitize address','no'),
|
||||
('pulseaudio','Detect & Use pulseaudio','yes'),
|
||||
]
|
||||
|
||||
def get_flags():
|
||||
@ -81,6 +82,9 @@ def configure(env):
|
||||
env.extra_suffix=".llvms"
|
||||
else:
|
||||
env.extra_suffix=".llvm"
|
||||
if (env["colored"]=="yes"):
|
||||
if sys.stdout.isatty():
|
||||
env.Append(CXXFLAGS=["-fcolor-diagnostics"])
|
||||
|
||||
|
||||
|
||||
@ -115,14 +119,15 @@ def configure(env):
|
||||
env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED'])
|
||||
env.Append(CPPFLAGS=["-DALSA_ENABLED"])
|
||||
|
||||
if not os.system("pkg-config --exists libpulse-simple"):
|
||||
print("Enabling PulseAudio")
|
||||
env.Append(CPPFLAGS=["-DPULSEAUDIO_ENABLED"])
|
||||
env.ParseConfig('pkg-config --cflags --libs libpulse-simple')
|
||||
else:
|
||||
print("PulseAudio development libraries not found, disabling driver")
|
||||
if (env["pulseaudio"]=="yes"):
|
||||
if not os.system("pkg-config --exists libpulse-simple"):
|
||||
print("Enabling PulseAudio")
|
||||
env.Append(CPPFLAGS=["-DPULSEAUDIO_ENABLED"])
|
||||
env.ParseConfig('pkg-config --cflags --libs libpulse-simple')
|
||||
else:
|
||||
print("PulseAudio development libraries not found, disabling driver")
|
||||
|
||||
env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES1_ENABLED','-DGLES_OVER_GL'])
|
||||
env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES_OVER_GL'])
|
||||
env.Append(LIBS=['GL', 'GLU', 'pthread','asound','z']) #TODO detect linux/BSD!
|
||||
#env.Append(CPPFLAGS=['-DMPC_FIXED_POINT'])
|
||||
|
||||
|
@ -11,7 +11,7 @@ void register_x11_exporter() {
|
||||
|
||||
{
|
||||
Ref<EditorExportPlatformPC> exporter = Ref<EditorExportPlatformPC>( memnew(EditorExportPlatformPC) );
|
||||
exporter->set_binary_extension("bin");
|
||||
exporter->set_binary_extension("");
|
||||
exporter->set_release_binary32("linux_x11_32_release");
|
||||
exporter->set_debug_binary32("linux_x11_32_debug");
|
||||
exporter->set_release_binary64("linux_x11_64_release");
|
||||
|
@ -28,7 +28,6 @@
|
||||
/*************************************************************************/
|
||||
#include "servers/visual/visual_server_raster.h"
|
||||
#include "drivers/gles2/rasterizer_gles2.h"
|
||||
#include "drivers/gles1/rasterizer_gles1.h"
|
||||
#include "os_x11.h"
|
||||
#include "key_mapping_x11.h"
|
||||
#include <stdio.h>
|
||||
@ -63,11 +62,11 @@
|
||||
|
||||
int OS_X11::get_video_driver_count() const {
|
||||
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
const char * OS_X11::get_video_driver_name(int p_driver) const {
|
||||
|
||||
return p_driver==0?"GLES2":"GLES1";
|
||||
return "GLES2";
|
||||
}
|
||||
OS::VideoMode OS_X11::get_default_video_mode() const {
|
||||
|
||||
@ -166,10 +165,10 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
|
||||
context_gl = memnew( ContextGL_X11( x11_display, x11_window,current_videomode, false ) );
|
||||
context_gl->initialize();
|
||||
|
||||
if (p_video_driver == 0) {
|
||||
if (true) {
|
||||
rasterizer = memnew( RasterizerGLES2 );
|
||||
} else {
|
||||
rasterizer = memnew( RasterizerGLES1 );
|
||||
//rasterizer = memnew( RasterizerGLES1 );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -34,5 +34,5 @@
|
||||
#endif
|
||||
|
||||
#define GLES2_INCLUDE_H "gl_context/glew.h"
|
||||
#define GLES1_INCLUDE_H "gl_context/glew.h"
|
||||
|
||||
|
||||
|
@ -720,6 +720,95 @@ bool CanvasItem::is_draw_behind_parent_enabled() const{
|
||||
return behind;
|
||||
}
|
||||
|
||||
void CanvasItem::set_shader(const Ref<Shader>& p_shader) {
|
||||
|
||||
ERR_FAIL_COND(p_shader.is_valid() && p_shader->get_mode()!=Shader::MODE_CANVAS_ITEM);
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
if (shader.is_valid()) {
|
||||
shader->disconnect("changed",this,"_shader_changed");
|
||||
}
|
||||
#endif
|
||||
shader=p_shader;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
if (shader.is_valid()) {
|
||||
shader->connect("changed",this,"_shader_changed");
|
||||
}
|
||||
#endif
|
||||
|
||||
RID rid;
|
||||
if (shader.is_valid())
|
||||
rid=shader->get_rid();
|
||||
VS::get_singleton()->canvas_item_set_shader(canvas_item,rid);
|
||||
_change_notify(); //properties for shader exposed
|
||||
}
|
||||
|
||||
void CanvasItem::set_use_parent_shader(bool p_use_parent_shader) {
|
||||
|
||||
use_parent_shader=p_use_parent_shader;
|
||||
VS::get_singleton()->canvas_item_set_use_parent_shader(canvas_item,p_use_parent_shader);
|
||||
}
|
||||
|
||||
bool CanvasItem::get_use_parent_shader() const{
|
||||
|
||||
return use_parent_shader;
|
||||
}
|
||||
|
||||
Ref<Shader> CanvasItem::get_shader() const{
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
void CanvasItem::set_shader_param(const StringName& p_param,const Variant& p_value) {
|
||||
|
||||
VS::get_singleton()->canvas_item_set_shader_param(canvas_item,p_param,p_value);
|
||||
}
|
||||
|
||||
Variant CanvasItem::get_shader_param(const StringName& p_param) const {
|
||||
|
||||
return VS::get_singleton()->canvas_item_get_shader_param(canvas_item,p_param);
|
||||
}
|
||||
|
||||
bool CanvasItem::_set(const StringName& p_name, const Variant& p_value) {
|
||||
|
||||
if (shader.is_valid()) {
|
||||
StringName pr = shader->remap_param(p_name);
|
||||
if (pr) {
|
||||
set_shader_param(pr,p_value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CanvasItem::_get(const StringName& p_name,Variant &r_ret) const{
|
||||
|
||||
if (shader.is_valid()) {
|
||||
StringName pr = shader->remap_param(p_name);
|
||||
if (pr) {
|
||||
r_ret=get_shader_param(pr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
void CanvasItem::_get_property_list( List<PropertyInfo> *p_list) const{
|
||||
|
||||
if (shader.is_valid()) {
|
||||
shader->get_param_list(p_list);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
void CanvasItem::_shader_changed() {
|
||||
|
||||
_change_notify();
|
||||
}
|
||||
#endif
|
||||
|
||||
void CanvasItem::_bind_methods() {
|
||||
|
||||
@ -761,7 +850,9 @@ void CanvasItem::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("_set_on_top","on_top"),&CanvasItem::_set_on_top);
|
||||
ObjectTypeDB::bind_method(_MD("_is_on_top"),&CanvasItem::_is_on_top);
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
ObjectTypeDB::bind_method(_MD("_shader_changed"),&CanvasItem::_shader_changed);
|
||||
#endif
|
||||
//ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("draw_line","from","to","color","width"),&CanvasItem::draw_line,DEFVAL(1.0));
|
||||
@ -786,15 +877,22 @@ void CanvasItem::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("get_world_2d"),&CanvasItem::get_world_2d);
|
||||
//ObjectTypeDB::bind_method(_MD("get_viewport"),&CanvasItem::get_viewport);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_shader","shader"),&CanvasItem::set_shader);
|
||||
ObjectTypeDB::bind_method(_MD("get_shader"),&CanvasItem::get_shader);
|
||||
ObjectTypeDB::bind_method(_MD("set_use_parent_shader","enable"),&CanvasItem::set_use_parent_shader);
|
||||
ObjectTypeDB::bind_method(_MD("get_use_parent_shader"),&CanvasItem::get_use_parent_shader);
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_draw"));
|
||||
|
||||
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"),_SCS("_is_visible_") );
|
||||
ADD_PROPERTY( PropertyInfo(Variant::REAL,"visibility/opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_opacity"),_SCS("get_opacity") );
|
||||
ADD_PROPERTY( PropertyInfo(Variant::REAL,"visibility/self_opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_self_opacity"),_SCS("get_self_opacity") );
|
||||
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/behind_parent"), _SCS("set_draw_behind_parent"),_SCS("is_draw_behind_parent_enabled") );
|
||||
ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"visibility/behind_parent"), _SCS("set_draw_behind_parent"),_SCS("is_draw_behind_parent_enabled") );
|
||||
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/on_top",PROPERTY_HINT_NONE,"",0), _SCS("_set_on_top"),_SCS("_is_on_top") ); //compatibility
|
||||
|
||||
ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"visibility/blend_mode",PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul,PMAlpha"), _SCS("set_blend_mode"),_SCS("get_blend_mode") );
|
||||
ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"shader/shader",PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemShader,CanvasItemShaderGraph"), _SCS("set_shader"),_SCS("get_shader") );
|
||||
ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"shader/use_parent"), _SCS("set_use_parent_shader"),_SCS("get_use_parent_shader") );
|
||||
//exporting these two things doesn't really make much sense i think
|
||||
//ADD_PROPERTY( PropertyInfo(Variant::BOOL,"transform/toplevel"), _SCS("set_as_toplevel"),_SCS("is_set_as_toplevel") );
|
||||
//ADD_PROPERTY(PropertyInfo(Variant::BOOL,"transform/notify"),_SCS("set_transform_notify"),_SCS("is_transform_notify_enabled"));
|
||||
@ -871,6 +969,7 @@ CanvasItem::CanvasItem() : xform_change(this) {
|
||||
block_transform_notify=false;
|
||||
// viewport=NULL;
|
||||
canvas_layer=NULL;
|
||||
use_parent_shader=false;
|
||||
global_invalid=true;
|
||||
|
||||
C=NULL;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "scene/main/scene_main_loop.h"
|
||||
#include "scene/resources/shader.h"
|
||||
|
||||
class CanvasLayer;
|
||||
class Viewport;
|
||||
@ -80,6 +81,9 @@ private:
|
||||
bool block_transform_notify;
|
||||
bool behind;
|
||||
|
||||
bool use_parent_shader;
|
||||
Ref<Shader> shader;
|
||||
|
||||
mutable Matrix32 global_transform;
|
||||
mutable bool global_invalid;
|
||||
|
||||
@ -99,8 +103,9 @@ private:
|
||||
void _queue_sort_children();
|
||||
void _sort_children();
|
||||
|
||||
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
void _shader_changed();
|
||||
#endif
|
||||
void _notify_transform(CanvasItem *p_node);
|
||||
|
||||
void _set_on_top(bool p_on_top) { set_draw_behind_parent(!p_on_top); }
|
||||
@ -108,6 +113,9 @@ private:
|
||||
|
||||
protected:
|
||||
|
||||
bool _set(const StringName& p_name, const Variant& p_value);
|
||||
bool _get(const StringName& p_name,Variant &r_ret) const;
|
||||
void _get_property_list( List<PropertyInfo> *p_list) const;
|
||||
|
||||
|
||||
_FORCE_INLINE_ void _notify_transform() { if (!is_inside_tree()) return; _notify_transform(this); if (!block_transform_notify) notification(NOTIFICATION_LOCAL_TRANSFORM_CHANGED); }
|
||||
@ -204,7 +212,14 @@ public:
|
||||
RID get_canvas() const;
|
||||
Ref<World2D> get_world_2d() const;
|
||||
|
||||
void set_shader(const Ref<Shader>& p_shader);
|
||||
Ref<Shader> get_shader() const;
|
||||
|
||||
void set_use_parent_shader(bool p_use_parent_shader);
|
||||
bool get_use_parent_shader() const;
|
||||
|
||||
void set_shader_param(const StringName& p_param,const Variant& p_value);
|
||||
Variant get_shader_param(const StringName& p_param) const;
|
||||
|
||||
CanvasItem();
|
||||
~CanvasItem();
|
||||
|
@ -289,6 +289,35 @@ void Node2D::set_global_transform(const Matrix32& p_transform) {
|
||||
|
||||
}
|
||||
|
||||
void Node2D::set_z(int p_z) {
|
||||
|
||||
ERR_FAIL_COND(p_z<VS::CANVAS_ITEM_Z_MIN);
|
||||
ERR_FAIL_COND(p_z>VS::CANVAS_ITEM_Z_MAX);
|
||||
z=p_z;
|
||||
VS::get_singleton()->canvas_item_set_z(get_canvas_item(),z);
|
||||
|
||||
}
|
||||
|
||||
void Node2D::set_z_as_relative(bool p_enabled) {
|
||||
|
||||
if (z_relative==p_enabled)
|
||||
return;
|
||||
z_relative=p_enabled;
|
||||
VS::get_singleton()->canvas_item_set_z_as_relative_to_parent(get_canvas_item(),p_enabled);
|
||||
}
|
||||
|
||||
bool Node2D::is_z_relative() const {
|
||||
|
||||
return z_relative;
|
||||
}
|
||||
|
||||
|
||||
int Node2D::get_z() const{
|
||||
|
||||
return z;
|
||||
}
|
||||
|
||||
|
||||
void Node2D::_bind_methods() {
|
||||
|
||||
|
||||
@ -308,18 +337,25 @@ void Node2D::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("move_local_x","delta","scaled"),&Node2D::move_x,DEFVAL(false));
|
||||
ObjectTypeDB::bind_method(_MD("move_local_y","delta","scaled"),&Node2D::move_y,DEFVAL(false));
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_global_pos","pos"),&Node2D::set_global_pos);
|
||||
ObjectTypeDB::bind_method(_MD("get_global_pos"),&Node2D::get_global_pos);
|
||||
ObjectTypeDB::bind_method(_MD("set_global_pos"),&Node2D::set_global_pos);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_transform","xform"),&Node2D::set_transform);
|
||||
ObjectTypeDB::bind_method(_MD("set_global_transform","xform"),&Node2D::set_global_transform);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_z","z"),&Node2D::set_z);
|
||||
ObjectTypeDB::bind_method(_MD("get_z"),&Node2D::get_z);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_z_as_relative","enable"),&Node2D::set_z_as_relative);
|
||||
ObjectTypeDB::bind_method(_MD("is_z_relative"),&Node2D::is_z_relative);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("edit_set_pivot"),&Node2D::edit_set_pivot);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"transform/pos"),_SCS("set_pos"),_SCS("get_pos"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL,"transform/rot",PROPERTY_HINT_RANGE,"-1440,1440,0.1"),_SCS("_set_rotd"),_SCS("_get_rotd"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"transform/scale"),_SCS("set_scale"),_SCS("get_scale"));
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"z/z",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z"),_SCS("get_z"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"z/relative"),_SCS("set_z_as_relative"),_SCS("is_z_relative"));
|
||||
|
||||
|
||||
}
|
||||
@ -331,6 +367,8 @@ Node2D::Node2D() {
|
||||
angle=0;
|
||||
scale=Vector2(1,1);
|
||||
_xform_dirty=false;
|
||||
z=0;
|
||||
z_relative=true;
|
||||
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,8 @@ class Node2D : public CanvasItem {
|
||||
Point2 pos;
|
||||
float angle;
|
||||
Size2 scale;
|
||||
int z;
|
||||
bool z_relative;
|
||||
|
||||
Matrix32 _mat;
|
||||
|
||||
@ -85,6 +87,11 @@ public:
|
||||
void set_global_transform(const Matrix32& p_transform);
|
||||
void set_global_pos(const Point2& p_pos);
|
||||
|
||||
void set_z(int p_z);
|
||||
int get_z() const;
|
||||
|
||||
void set_z_as_relative(bool p_enabled);
|
||||
bool is_z_relative() const;
|
||||
|
||||
Matrix32 get_transform() const;
|
||||
|
||||
|
@ -43,13 +43,44 @@ void PhysicsBody2D::_notification(int p_what) {
|
||||
*/
|
||||
}
|
||||
|
||||
void PhysicsBody2D::set_one_way_collision_direction(const Vector2& p_dir) {
|
||||
|
||||
one_way_collision_direction=p_dir;
|
||||
Physics2DServer::get_singleton()->body_set_one_way_collision_direction(get_rid(),p_dir);
|
||||
}
|
||||
|
||||
Vector2 PhysicsBody2D::get_one_way_collision_direction() const{
|
||||
|
||||
return one_way_collision_direction;
|
||||
}
|
||||
|
||||
|
||||
void PhysicsBody2D::set_one_way_collision_max_depth(float p_depth) {
|
||||
|
||||
one_way_collision_max_depth=p_depth;
|
||||
Physics2DServer::get_singleton()->body_set_one_way_collision_max_depth(get_rid(),p_depth);
|
||||
|
||||
}
|
||||
|
||||
float PhysicsBody2D::get_one_way_collision_max_depth() const{
|
||||
|
||||
return one_way_collision_max_depth;
|
||||
}
|
||||
|
||||
|
||||
void PhysicsBody2D::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody2D::set_layer_mask);
|
||||
ObjectTypeDB::bind_method(_MD("get_layer_mask"),&PhysicsBody2D::get_layer_mask);
|
||||
ObjectTypeDB::bind_method(_MD("set_one_way_collision_direction","dir"),&PhysicsBody2D::set_one_way_collision_direction);
|
||||
ObjectTypeDB::bind_method(_MD("get_one_way_collision_direction"),&PhysicsBody2D::get_one_way_collision_direction);
|
||||
ObjectTypeDB::bind_method(_MD("set_one_way_collision_max_depth","depth"),&PhysicsBody2D::set_one_way_collision_max_depth);
|
||||
ObjectTypeDB::bind_method(_MD("get_one_way_collision_max_depth"),&PhysicsBody2D::get_one_way_collision_max_depth);
|
||||
ObjectTypeDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::add_collision_exception_with);
|
||||
ObjectTypeDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::remove_collision_exception_with);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
|
||||
ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"one_way_collision/direction"),_SCS("set_one_way_collision_direction"),_SCS("get_one_way_collision_direction"));
|
||||
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"one_way_collision/max_depth"),_SCS("set_one_way_collision_max_depth"),_SCS("get_one_way_collision_max_depth"));
|
||||
}
|
||||
|
||||
void PhysicsBody2D::set_layer_mask(uint32_t p_mask) {
|
||||
@ -66,6 +97,7 @@ uint32_t PhysicsBody2D::get_layer_mask() const {
|
||||
PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) : CollisionObject2D( Physics2DServer::get_singleton()->body_create(p_mode), false) {
|
||||
|
||||
mask=1;
|
||||
set_one_way_collision_max_depth(0);
|
||||
|
||||
}
|
||||
|
||||
@ -932,7 +964,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) {
|
||||
|
||||
//if (d<margin)
|
||||
/// continue;
|
||||
recover_motion+=(b-a)*0.2;
|
||||
recover_motion+=(b-a)*0.4;
|
||||
}
|
||||
|
||||
if (recover_motion==Vector2()) {
|
||||
@ -963,6 +995,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) {
|
||||
bool valid = dss->cast_motion(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i), p_motion, 0,lsafe,lunsafe,exclude,get_layer_mask(),mask);
|
||||
//print_line("shape: "+itos(i)+" travel:"+rtos(ltravel));
|
||||
if (!valid) {
|
||||
|
||||
safe=0;
|
||||
unsafe=0;
|
||||
best_shape=i; //sadly it's the best
|
||||
@ -994,9 +1027,11 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) {
|
||||
bool c2 = dss->rest_info(get_shape(best_shape)->get_rid(), ugt*get_shape_transform(best_shape), Vector2(), margin,&rest_info,exclude,get_layer_mask(),mask);
|
||||
if (!c2) {
|
||||
//should not happen, but floating point precision is so weird..
|
||||
|
||||
colliding=false;
|
||||
} else {
|
||||
|
||||
|
||||
//print_line("Travel: "+rtos(travel));
|
||||
colliding=true;
|
||||
collision=rest_info.point;
|
||||
|
@ -39,6 +39,8 @@ class PhysicsBody2D : public CollisionObject2D {
|
||||
OBJ_TYPE(PhysicsBody2D,CollisionObject2D);
|
||||
|
||||
uint32_t mask;
|
||||
Vector2 one_way_collision_direction;
|
||||
float one_way_collision_max_depth;
|
||||
protected:
|
||||
|
||||
void _notification(int p_what);
|
||||
@ -53,6 +55,12 @@ public:
|
||||
void add_collision_exception_with(Node* p_node); //must be physicsbody
|
||||
void remove_collision_exception_with(Node* p_node);
|
||||
|
||||
void set_one_way_collision_direction(const Vector2& p_dir);
|
||||
Vector2 get_one_way_collision_direction() const;
|
||||
|
||||
void set_one_way_collision_max_depth(float p_dir);
|
||||
float get_one_way_collision_max_depth() const;
|
||||
|
||||
PhysicsBody2D();
|
||||
|
||||
};
|
||||
|
@ -92,6 +92,7 @@ void PhysicsBody::remove_collision_exception_with(Node* p_node) {
|
||||
PhysicsServer::get_singleton()->body_remove_collision_exception(get_rid(),physics_body->get_rid());
|
||||
}
|
||||
|
||||
|
||||
void PhysicsBody::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody::set_layer_mask);
|
||||
ObjectTypeDB::bind_method(_MD("get_layer_mask"),&PhysicsBody::get_layer_mask);
|
||||
|
@ -56,6 +56,8 @@ public:
|
||||
void add_collision_exception_with(Node* p_node); //must be physicsbody
|
||||
void remove_collision_exception_with(Node* p_node);
|
||||
|
||||
|
||||
|
||||
PhysicsBody();
|
||||
|
||||
};
|
||||
|
@ -138,7 +138,8 @@ void Tween::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("interpolate_property","object","property","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_property, DEFVAL(0) );
|
||||
ObjectTypeDB::bind_method(_MD("interpolate_method","object","method","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_method, DEFVAL(0) );
|
||||
ObjectTypeDB::bind_method(_MD("interpolate_callback","object","times_in_sec","callback","args"),&Tween::interpolate_callback, DEFVAL(Variant()) );
|
||||
ObjectTypeDB::bind_method(_MD("interpolate_callback","object","times_in_sec","callback","arg1", "arg2","arg3","arg4","arg5"),&Tween::interpolate_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()) );
|
||||
ObjectTypeDB::bind_method(_MD("interpolate_deferred_callback","object","times_in_sec","callback","arg1","arg2","arg3","arg4","arg5"),&Tween::interpolate_deferred_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()) );
|
||||
ObjectTypeDB::bind_method(_MD("follow_property","object","property","initial_val","target","target_property","times_in_sec","trans_type","ease_type","delay"),&Tween::follow_property, DEFVAL(0) );
|
||||
ObjectTypeDB::bind_method(_MD("follow_method","object","method","initial_val","target","target_method","times_in_sec","trans_type","ease_type","delay"),&Tween::follow_method, DEFVAL(0) );
|
||||
ObjectTypeDB::bind_method(_MD("targeting_property","object","property","initial","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::targeting_property, DEFVAL(0) );
|
||||
@ -513,11 +514,33 @@ void Tween::_tween_process(float p_delta) {
|
||||
if(data.finish) {
|
||||
|
||||
Variant::CallError error;
|
||||
if (data.arg.get_type() != Variant::NIL) {
|
||||
Variant *arg[1] = { &data.arg };
|
||||
object->call(data.key, (const Variant **) arg, 1, error);
|
||||
} else {
|
||||
object->call(data.key, NULL, 0, error);
|
||||
if (data.call_deferred) {
|
||||
|
||||
switch (data.args) {
|
||||
case 0:
|
||||
object->call_deferred(data.key); break;
|
||||
case 1:
|
||||
object->call_deferred(data.key, data.arg[0]); break;
|
||||
case 2:
|
||||
object->call_deferred(data.key, data.arg[0], data.arg[1]); break;
|
||||
case 3:
|
||||
object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2]); break;
|
||||
case 4:
|
||||
object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2], data.arg[3]); break;
|
||||
case 5:
|
||||
object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2], data.arg[3], data.arg[4]); break;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
Variant *arg[5] = {
|
||||
&data.arg[0],
|
||||
&data.arg[1],
|
||||
&data.arg[2],
|
||||
&data.arg[3],
|
||||
&data.arg[4],
|
||||
};
|
||||
object->call(data.key, (const Variant **) arg, data.args, error);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
@ -1003,7 +1026,7 @@ bool Tween::interpolate_method(Object *p_object
|
||||
bool Tween::interpolate_callback(Object *p_object
|
||||
, real_t p_times_in_sec
|
||||
, String p_callback
|
||||
, Variant p_arg
|
||||
, VARIANT_ARG_DECLARE
|
||||
) {
|
||||
|
||||
ERR_FAIL_COND_V(pending_update != 0, false);
|
||||
@ -1016,13 +1039,85 @@ bool Tween::interpolate_callback(Object *p_object
|
||||
data.active = true;
|
||||
data.type = INTER_CALLBACK;
|
||||
data.finish = false;
|
||||
data.call_deferred = false;
|
||||
data.elapsed = 0;
|
||||
|
||||
data.id = p_object->get_instance_ID();
|
||||
data.key = p_callback;
|
||||
data.times_in_sec = p_times_in_sec;
|
||||
data.delay = 0;
|
||||
data.arg = p_arg;
|
||||
|
||||
int args=0;
|
||||
if (p_arg5.get_type()!=Variant::NIL)
|
||||
args=5;
|
||||
else if (p_arg4.get_type()!=Variant::NIL)
|
||||
args=4;
|
||||
else if (p_arg3.get_type()!=Variant::NIL)
|
||||
args=3;
|
||||
else if (p_arg2.get_type()!=Variant::NIL)
|
||||
args=2;
|
||||
else if (p_arg1.get_type()!=Variant::NIL)
|
||||
args=1;
|
||||
else
|
||||
args=0;
|
||||
|
||||
data.args = args;
|
||||
data.arg[0] = p_arg1;
|
||||
data.arg[1] = p_arg2;
|
||||
data.arg[2] = p_arg3;
|
||||
data.arg[3] = p_arg4;
|
||||
data.arg[4] = p_arg5;
|
||||
|
||||
pending_update ++;
|
||||
interpolates.push_back(data);
|
||||
pending_update --;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tween::interpolate_deferred_callback(Object *p_object
|
||||
, real_t p_times_in_sec
|
||||
, String p_callback
|
||||
, VARIANT_ARG_DECLARE
|
||||
) {
|
||||
|
||||
ERR_FAIL_COND_V(pending_update != 0, false);
|
||||
ERR_FAIL_COND_V(p_object == NULL, false);
|
||||
ERR_FAIL_COND_V(p_times_in_sec < 0, false);
|
||||
|
||||
ERR_FAIL_COND_V(!p_object->has_method(p_callback), false);
|
||||
|
||||
InterpolateData data;
|
||||
data.active = true;
|
||||
data.type = INTER_CALLBACK;
|
||||
data.finish = false;
|
||||
data.call_deferred = true;
|
||||
data.elapsed = 0;
|
||||
|
||||
data.id = p_object->get_instance_ID();
|
||||
data.key = p_callback;
|
||||
data.times_in_sec = p_times_in_sec;
|
||||
data.delay = 0;
|
||||
|
||||
int args=0;
|
||||
if (p_arg5.get_type()!=Variant::NIL)
|
||||
args=5;
|
||||
else if (p_arg4.get_type()!=Variant::NIL)
|
||||
args=4;
|
||||
else if (p_arg3.get_type()!=Variant::NIL)
|
||||
args=3;
|
||||
else if (p_arg2.get_type()!=Variant::NIL)
|
||||
args=2;
|
||||
else if (p_arg1.get_type()!=Variant::NIL)
|
||||
args=1;
|
||||
else
|
||||
args=0;
|
||||
|
||||
data.args = args;
|
||||
data.arg[0] = p_arg1;
|
||||
data.arg[1] = p_arg2;
|
||||
data.arg[2] = p_arg3;
|
||||
data.arg[3] = p_arg4;
|
||||
data.arg[4] = p_arg5;
|
||||
|
||||
pending_update ++;
|
||||
interpolates.push_back(data);
|
||||
|
@ -83,6 +83,7 @@ private:
|
||||
bool active;
|
||||
InterpolateType type;
|
||||
bool finish;
|
||||
bool call_deferred;
|
||||
real_t elapsed;
|
||||
ObjectID id;
|
||||
StringName key;
|
||||
@ -95,7 +96,8 @@ private:
|
||||
TransitionType trans_type;
|
||||
EaseType ease_type;
|
||||
real_t delay;
|
||||
Variant arg;
|
||||
int args;
|
||||
Variant arg[5];
|
||||
};
|
||||
|
||||
String autoplay;
|
||||
@ -178,10 +180,16 @@ public:
|
||||
, real_t p_delay = 0
|
||||
);
|
||||
|
||||
bool interpolate_callback(Object *p_node
|
||||
bool interpolate_callback(Object *p_object
|
||||
, real_t p_times_in_sec
|
||||
, String p_callback
|
||||
, Variant p_arg = Variant()
|
||||
, VARIANT_ARG_DECLARE
|
||||
);
|
||||
|
||||
bool interpolate_deferred_callback(Object *p_object
|
||||
, real_t p_times_in_sec
|
||||
, String p_callback
|
||||
, VARIANT_ARG_DECLARE
|
||||
);
|
||||
|
||||
bool follow_property(Object *p_node
|
||||
|
@ -156,7 +156,6 @@ void FileDialog::_action_pressed() {
|
||||
|
||||
if (mode==MODE_SAVE_FILE) {
|
||||
|
||||
String ext = f.extension();
|
||||
bool valid=false;
|
||||
|
||||
if (filter->get_selected()==filter->get_item_count()-1) {
|
||||
@ -184,7 +183,8 @@ void FileDialog::_action_pressed() {
|
||||
if (idx>=0 && idx<filters.size()) {
|
||||
|
||||
String flt=filters[idx].get_slice(";",0);
|
||||
for (int j=0;j<flt.get_slice_count(",");j++) {
|
||||
int filterSliceCount=flt.get_slice_count(",");
|
||||
for (int j=0;j<filterSliceCount;j++) {
|
||||
|
||||
String str = (flt.get_slice(",",j).strip_edges());
|
||||
if (f.match(str)) {
|
||||
@ -192,6 +192,13 @@ void FileDialog::_action_pressed() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid && filterSliceCount>0) {
|
||||
String str = (flt.get_slice(",",0).strip_edges());
|
||||
f+=str.substr(1, str.length()-1);
|
||||
file->set_text(f.get_file());
|
||||
valid=true;
|
||||
}
|
||||
} else {
|
||||
valid=true;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "graph_edit.h"
|
||||
|
||||
#include "os/input.h"
|
||||
#include "os/keyboard.h"
|
||||
bool GraphEditFilter::has_point(const Point2& p_point) const {
|
||||
|
||||
return ge->_filter_input(p_point);
|
||||
@ -53,7 +54,7 @@ void GraphEdit::disconnect_node(const StringName& p_from, int p_from_port,const
|
||||
}
|
||||
}
|
||||
|
||||
void GraphEdit::get_connection_list(List<Connection> *r_connections) {
|
||||
void GraphEdit::get_connection_list(List<Connection> *r_connections) const {
|
||||
|
||||
*r_connections=connections;
|
||||
}
|
||||
@ -88,7 +89,6 @@ void GraphEdit::_update_scroll() {
|
||||
|
||||
updating=true;
|
||||
Rect2 screen;
|
||||
screen.size=get_size();
|
||||
for(int i=0;i<get_child_count();i++) {
|
||||
|
||||
GraphNode *gn=get_child(i)->cast_to<GraphNode>();
|
||||
@ -101,6 +101,10 @@ void GraphEdit::_update_scroll() {
|
||||
screen = screen.merge(r);
|
||||
}
|
||||
|
||||
screen.pos-=get_size();
|
||||
screen.size+=get_size()*2.0;
|
||||
|
||||
|
||||
h_scroll->set_min(screen.pos.x);
|
||||
h_scroll->set_max(screen.pos.x+screen.size.x);
|
||||
h_scroll->set_page(get_size().x);
|
||||
@ -265,6 +269,37 @@ void GraphEdit::_top_layer_input(const InputEvent& p_ev) {
|
||||
Vector2 pos = gn->get_connection_input_pos(j)+gn->get_pos();
|
||||
|
||||
if (pos.distance_to(mpos)<grab_r) {
|
||||
|
||||
if (right_disconnects) {
|
||||
//check disconnect
|
||||
for (List<Connection>::Element*E=connections.front();E;E=E->next()) {
|
||||
|
||||
if (E->get().to==gn->get_name() && E->get().to_port==j) {
|
||||
|
||||
Node*fr = get_node(String(E->get().from));
|
||||
if (fr && fr->cast_to<GraphNode>()) {
|
||||
|
||||
connecting_from=E->get().from;
|
||||
connecting_index=E->get().from_port;
|
||||
connecting_out=true;
|
||||
connecting_type=fr->cast_to<GraphNode>()->get_connection_output_type(E->get().from_port);
|
||||
connecting_color=fr->cast_to<GraphNode>()->get_connection_output_color(E->get().from_port);
|
||||
connecting_target=false;
|
||||
connecting_to=pos;
|
||||
|
||||
emit_signal("disconnection_request",E->get().from,E->get().from_port,E->get().to,E->get().to_port);
|
||||
fr = get_node(String(connecting_from)); //maybe it was erased
|
||||
if (fr && fr->cast_to<GraphNode>()) {
|
||||
connecting=true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
connecting=true;
|
||||
connecting_from=gn->get_name();
|
||||
connecting_index=j;
|
||||
@ -461,7 +496,7 @@ void GraphEdit::_top_layer_draw() {
|
||||
|
||||
void GraphEdit::_input_event(const InputEvent& p_ev) {
|
||||
|
||||
if (p_ev.type==InputEvent::MOUSE_MOTION && p_ev.mouse_motion.button_mask&BUTTON_MASK_MIDDLE) {
|
||||
if (p_ev.type==InputEvent::MOUSE_MOTION && (p_ev.mouse_motion.button_mask&BUTTON_MASK_MIDDLE || (p_ev.mouse_motion.button_mask&BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE)))) {
|
||||
h_scroll->set_val( h_scroll->get_val() - p_ev.mouse_motion.relative_x );
|
||||
v_scroll->set_val( v_scroll->get_val() - p_ev.mouse_motion.relative_y );
|
||||
}
|
||||
@ -474,11 +509,41 @@ void GraphEdit::clear_connections() {
|
||||
}
|
||||
|
||||
|
||||
void GraphEdit::set_right_disconnects(bool p_enable) {
|
||||
|
||||
right_disconnects=p_enable;
|
||||
}
|
||||
|
||||
bool GraphEdit::is_right_disconnects_enabled() const{
|
||||
|
||||
return right_disconnects;
|
||||
}
|
||||
|
||||
Array GraphEdit::_get_connection_list() const {
|
||||
|
||||
List<Connection> conns;
|
||||
get_connection_list(&conns);
|
||||
Array arr;
|
||||
for(List<Connection>::Element *E=conns.front();E;E=E->next()) {
|
||||
Dictionary d;
|
||||
d["from"]=E->get().from;
|
||||
d["from_port"]=E->get().from_port;
|
||||
d["to"]=E->get().to;
|
||||
d["to_port"]=E->get().to_port;
|
||||
arr.push_back(d);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
void GraphEdit::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("connect_node:Error","from","from_port","to","to_port"),&GraphEdit::connect_node);
|
||||
ObjectTypeDB::bind_method(_MD("is_node_connected","from","from_port","to","to_port"),&GraphEdit::is_node_connected);
|
||||
ObjectTypeDB::bind_method(_MD("disconnect_node","from","from_port","to","to_port"),&GraphEdit::disconnect_node);
|
||||
ObjectTypeDB::bind_method(_MD("get_connection_list"),&GraphEdit::_get_connection_list);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_right_disconnects","enable"),&GraphEdit::set_right_disconnects);
|
||||
ObjectTypeDB::bind_method(_MD("is_right_disconnects_enabled"),&GraphEdit::is_right_disconnects_enabled);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("_graph_node_moved"),&GraphEdit::_graph_node_moved);
|
||||
ObjectTypeDB::bind_method(_MD("_graph_node_raised"),&GraphEdit::_graph_node_raised);
|
||||
|
||||
@ -489,9 +554,12 @@ void GraphEdit::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("_input_event"),&GraphEdit::_input_event);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("connection_request",PropertyInfo(Variant::STRING,"from"),PropertyInfo(Variant::INT,"from_slot"),PropertyInfo(Variant::STRING,"to"),PropertyInfo(Variant::INT,"to_slot")));
|
||||
ADD_SIGNAL(MethodInfo("disconnection_request",PropertyInfo(Variant::STRING,"from"),PropertyInfo(Variant::INT,"from_slot"),PropertyInfo(Variant::STRING,"to"),PropertyInfo(Variant::INT,"to_slot")));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
GraphEdit::GraphEdit() {
|
||||
top_layer=NULL;
|
||||
top_layer=memnew(GraphEditFilter(this));
|
||||
@ -511,6 +579,7 @@ GraphEdit::GraphEdit() {
|
||||
top_layer->add_child(v_scroll);
|
||||
updating=false;
|
||||
connecting=false;
|
||||
right_disconnects=false;
|
||||
|
||||
h_scroll->connect("value_changed", this,"_scroll_moved");
|
||||
v_scroll->connect("value_changed", this,"_scroll_moved");
|
||||
|
@ -51,6 +51,7 @@ private:
|
||||
|
||||
|
||||
|
||||
bool right_disconnects;
|
||||
bool updating;
|
||||
List<Connection> connections;
|
||||
|
||||
@ -68,6 +69,8 @@ private:
|
||||
void _top_layer_draw();
|
||||
void _update_scroll_offset();
|
||||
|
||||
Array _get_connection_list() const;
|
||||
|
||||
friend class GraphEditFilter;
|
||||
bool _filter_input(const Point2& p_point);
|
||||
protected:
|
||||
@ -84,7 +87,11 @@ public:
|
||||
void disconnect_node(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port);
|
||||
void clear_connections();
|
||||
|
||||
void get_connection_list(List<Connection> *r_connections);
|
||||
GraphEditFilter *get_top_layer() const { return top_layer; }
|
||||
void get_connection_list(List<Connection> *r_connections) const;
|
||||
|
||||
void set_right_disconnects(bool p_enable);
|
||||
bool is_right_disconnects_enabled() const;
|
||||
|
||||
|
||||
GraphEdit();
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "graph_node.h"
|
||||
#include "method_bind_ext.inc"
|
||||
|
||||
|
||||
bool GraphNode::_set(const StringName& p_name, const Variant& p_value) {
|
||||
@ -38,9 +39,8 @@ bool GraphNode::_set(const StringName& p_name, const Variant& p_value) {
|
||||
bool GraphNode::_get(const StringName& p_name,Variant &r_ret) const{
|
||||
|
||||
|
||||
print_line("get "+p_name.operator String());
|
||||
if (!p_name.operator String().begins_with("slot/")) {
|
||||
print_line("no begins");
|
||||
|
||||
if (!p_name.operator String().begins_with("slot/")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -68,7 +68,6 @@ bool GraphNode::_get(const StringName& p_name,Variant &r_ret) const{
|
||||
else
|
||||
return false;
|
||||
|
||||
print_line("ask for: "+p_name.operator String()+" get: "+String(r_ret));
|
||||
return true;
|
||||
}
|
||||
void GraphNode::_get_property_list( List<PropertyInfo> *p_list) const{
|
||||
@ -540,6 +539,30 @@ void GraphNode::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("get_title"),&GraphNode::get_title);
|
||||
ObjectTypeDB::bind_method(_MD("_input_event"),&GraphNode::_input_event);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_slot","idx","enable_left","type_left","color_left","enable_right","type_right","color_right"),&GraphNode::set_slot);
|
||||
ObjectTypeDB::bind_method(_MD("clear_slot","idx"),&GraphNode::clear_slot);
|
||||
ObjectTypeDB::bind_method(_MD("clear_all_slots","idx"),&GraphNode::clear_all_slots);
|
||||
ObjectTypeDB::bind_method(_MD("is_slot_enabled_left","idx"),&GraphNode::is_slot_enabled_left);
|
||||
ObjectTypeDB::bind_method(_MD("get_slot_type_left","idx"),&GraphNode::get_slot_type_left);
|
||||
ObjectTypeDB::bind_method(_MD("get_slot_color_left","idx"),&GraphNode::get_slot_color_left);
|
||||
ObjectTypeDB::bind_method(_MD("is_slot_enabled_right","idx"),&GraphNode::is_slot_enabled_right);
|
||||
ObjectTypeDB::bind_method(_MD("get_slot_type_right","idx"),&GraphNode::get_slot_type_right);
|
||||
ObjectTypeDB::bind_method(_MD("get_slot_color_right","idx"),&GraphNode::get_slot_color_right);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_offset","offset"),&GraphNode::set_offset);
|
||||
ObjectTypeDB::bind_method(_MD("get_offset"),&GraphNode::get_offset);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("get_connection_output_count"),&GraphNode::get_connection_output_count);
|
||||
ObjectTypeDB::bind_method(_MD("get_connection_input_count"),&GraphNode::get_connection_input_count);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("get_connection_output_pos","idx"),&GraphNode::get_connection_output_pos);
|
||||
ObjectTypeDB::bind_method(_MD("get_connection_output_type","idx"),&GraphNode::get_connection_output_type);
|
||||
ObjectTypeDB::bind_method(_MD("get_connection_output_color","idx"),&GraphNode::get_connection_output_color);
|
||||
ObjectTypeDB::bind_method(_MD("get_connection_input_pos","idx"),&GraphNode::get_connection_input_pos);
|
||||
ObjectTypeDB::bind_method(_MD("get_connection_input_type","idx"),&GraphNode::get_connection_input_type);
|
||||
ObjectTypeDB::bind_method(_MD("get_connection_input_color","idx"),&GraphNode::get_connection_input_color);
|
||||
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_show_close_button","show"),&GraphNode::set_show_close_button);
|
||||
ObjectTypeDB::bind_method(_MD("is_close_button_visible"),&GraphNode::is_close_button_visible);
|
||||
|
||||
|
@ -226,5 +226,6 @@ Size2 GridContainer::get_minimum_size() const {
|
||||
|
||||
GridContainer::GridContainer() {
|
||||
|
||||
set_stop_mouse(false);
|
||||
columns=1;
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ void TextEdit::_update_scrollbars() {
|
||||
|
||||
int hscroll_rows = ((hmin.height-1)/get_row_height())+1;
|
||||
int visible_rows = get_visible_rows();
|
||||
int total_rows = text.size() * cache.line_spacing;
|
||||
int total_rows = text.size();
|
||||
|
||||
int vscroll_pixels = v_scroll->get_combined_minimum_size().width;
|
||||
int visible_width = size.width - cache.style_normal->get_minimum_size().width;
|
||||
|
@ -2472,6 +2472,10 @@ void Tree::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
|
||||
if (p_what==NOTIFICATION_THEME_CHANGED) {
|
||||
update_cache();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -272,7 +272,7 @@ void register_scene_types() {
|
||||
|
||||
ObjectTypeDB::register_type<Control>();
|
||||
// ObjectTypeDB::register_type<EmptyControl>();
|
||||
ObjectTypeDB::add_compatibility_type("EmptyControl","control");
|
||||
ObjectTypeDB::add_compatibility_type("EmptyControl","Control");
|
||||
ObjectTypeDB::register_type<Button>();
|
||||
ObjectTypeDB::register_type<Label>();
|
||||
ObjectTypeDB::register_type<HScrollBar>();
|
||||
@ -496,16 +496,17 @@ void register_scene_types() {
|
||||
|
||||
/* REGISTER RESOURCES */
|
||||
|
||||
ObjectTypeDB::register_virtual_type<Shader>();
|
||||
ObjectTypeDB::register_virtual_type<ShaderGraph>();
|
||||
ObjectTypeDB::register_type<CanvasItemShader>();
|
||||
ObjectTypeDB::register_type<CanvasItemShaderGraph>();
|
||||
|
||||
#ifndef _3D_DISABLED
|
||||
ObjectTypeDB::register_type<Mesh>();
|
||||
ObjectTypeDB::register_virtual_type<Material>();
|
||||
ObjectTypeDB::register_type<FixedMaterial>();
|
||||
//ObjectTypeDB::register_type<ParticleSystemMaterial>();
|
||||
//ObjectTypeDB::register_type<UnshadedMaterial>();
|
||||
ObjectTypeDB::register_type<ShaderMaterial>();
|
||||
ObjectTypeDB::register_type<RoomBounds>();
|
||||
ObjectTypeDB::register_virtual_type<Shader>();
|
||||
ObjectTypeDB::register_virtual_type<ShaderGraph>();
|
||||
ObjectTypeDB::register_type<MaterialShaderGraph>();
|
||||
ObjectTypeDB::register_type<MaterialShader>();
|
||||
ObjectTypeDB::add_compatibility_type("Shader","MaterialShader");
|
||||
|
@ -541,19 +541,12 @@ void Curve2D::_bake() const {
|
||||
|
||||
|
||||
Vector2 pos=points[0].pos;
|
||||
int point=0;
|
||||
float ofs=0;
|
||||
List<Vector2> pointlist;
|
||||
|
||||
|
||||
for(int i=0;i<points.size()-1;i++) {
|
||||
|
||||
float slen=points[i].pos.distance_to(points[i+1].pos);
|
||||
float divs = slen / bake_interval;
|
||||
if (divs>1)
|
||||
divs=1;
|
||||
|
||||
float step = divs*0.1; // 10 substeps ought to be enough?
|
||||
float step = 0.1; // at least 10 substeps ought to be enough?
|
||||
float p = 0;
|
||||
|
||||
while(p<1.0) {
|
||||
@ -1014,19 +1007,12 @@ void Curve3D::_bake() const {
|
||||
|
||||
|
||||
Vector3 pos=points[0].pos;
|
||||
int point=0;
|
||||
float ofs=0;
|
||||
List<Plane> pointlist;
|
||||
pointlist.push_back(Plane(pos,points[0].tilt));
|
||||
|
||||
for(int i=0;i<points.size()-1;i++) {
|
||||
|
||||
float slen=points[i].pos.distance_to(points[i+1].pos);
|
||||
float divs = slen / bake_interval;
|
||||
if (divs>1)
|
||||
divs=1;
|
||||
|
||||
float step = divs*0.1; // 10 substeps ought to be enough?
|
||||
float step = 0.1; // at least 10 substeps ought to be enough?
|
||||
float p = 0;
|
||||
|
||||
while(p<1.0) {
|
||||
|
Before Width: | Height: | Size: 260 B After Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 275 B After Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 388 B After Width: | Height: | Size: 333 B |
Before Width: | Height: | Size: 531 B After Width: | Height: | Size: 338 B |
Before Width: | Height: | Size: 527 B After Width: | Height: | Size: 333 B |
Before Width: | Height: | Size: 491 B After Width: | Height: | Size: 351 B |
Before Width: | Height: | Size: 616 B After Width: | Height: | Size: 597 B |
Before Width: | Height: | Size: 562 B After Width: | Height: | Size: 412 B |
@ -168,8 +168,6 @@ void make_default_theme() {
|
||||
|
||||
tex_cache = memnew( TexCacheMap );
|
||||
|
||||
uint32_t last=OS::get_singleton()->get_ticks_msec();
|
||||
|
||||
Ref<Theme> t( memnew( Theme ) );
|
||||
|
||||
//Ref<Font> default_font = make_font(_bi_font_normal_height,_bi_font_normal_ascent,_bi_font_normal_valign,_bi_font_normal_charcount,_bi_font_normal_characters,make_icon(font_normal_png));
|
||||
@ -177,167 +175,240 @@ void make_default_theme() {
|
||||
Ref<Font> source_font=make_font2(_builtin_source_font_height,_builtin_source_font_ascent,_builtin_source_font_charcount,&_builtin_source_font_charrects[0][0],_builtin_source_font_kerning_pair_count,&_builtin_source_font_kerning_pairs[0][0],_builtin_source_font_img_width,_builtin_source_font_img_height,_builtin_source_font_img_data);
|
||||
Ref<Font> large_font=make_font2(_builtin_large_font_height,_builtin_large_font_ascent,_builtin_large_font_charcount,&_builtin_large_font_charrects[0][0],_builtin_large_font_kerning_pair_count,&_builtin_large_font_kerning_pairs[0][0],_builtin_large_font_img_width,_builtin_large_font_img_height,_builtin_large_font_img_data);
|
||||
|
||||
// Font Colors
|
||||
|
||||
Color control_font_color = Color::html("e0e0e0");
|
||||
Color control_font_color_low = Color::html("b0b0b0");
|
||||
Color control_font_color_hover = Color::html("f0f0f0");
|
||||
Color control_font_color_disabled = Color(0.9,0.9,0.9,0.2);
|
||||
Color control_font_color_pressed = Color::html("ffffff");
|
||||
Color font_color_selection = Color::html("7d7d7d");
|
||||
|
||||
|
||||
// Panel
|
||||
|
||||
t->set_stylebox("panel","Panel", make_stylebox( panel_bg_png,0,0,0,0) );
|
||||
|
||||
Color control_font_color = Color::html("cfc9d5");
|
||||
Color control_font_color_low = Color::html("bab4c1");
|
||||
Color control_font_color_hover = Color::html("ffffff");
|
||||
Color control_font_color_disabled = Color(0.9,0.9,0.9,0.6);
|
||||
Color control_font_color_pressed = Color::html("bfb9c5");
|
||||
Color font_color_selection = Color::html("715e7d");
|
||||
Ref<Texture> empty_icon = memnew( ImageTexture );
|
||||
|
||||
t->set_stylebox("normal","Button", make_stylebox( button_normal_png,5,5,5,5,8,3,8,4) );
|
||||
t->set_stylebox("pressed","Button", make_stylebox( button_pressed_png,5,5,5,5,3,3,3,3) );
|
||||
t->set_stylebox("hover","Button", make_stylebox( button_hover_png,5,5,5,5,3,0,3,0) );
|
||||
t->set_stylebox("disabled","Button", make_stylebox( button_disabled_png,5,5,5,5,3,3,3,3) );
|
||||
Ref<StyleBoxTexture> focus = make_stylebox( focus_png,6,6,6,6,3,3,3,3);
|
||||
|
||||
// Focus
|
||||
|
||||
Ref<StyleBoxTexture> focus = make_stylebox( focus_png,5,5,5,5);
|
||||
for(int i=0;i<4;i++) {
|
||||
focus->set_expand_margin_size(Margin(i),2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Button
|
||||
|
||||
t->set_stylebox("normal","Button", make_stylebox( button_normal_png,4,4,4,4,8,4,8,4) );
|
||||
t->set_stylebox("pressed","Button", make_stylebox( button_pressed_png,4,4,4,4) );
|
||||
t->set_stylebox("hover","Button", make_stylebox( button_hover_png,4,4,4,4) );
|
||||
t->set_stylebox("disabled","Button", make_stylebox( button_disabled_png,4,4,4,4) );
|
||||
t->set_stylebox("focus","Button", focus );
|
||||
|
||||
t->set_font("font","Button", default_font );
|
||||
|
||||
t->set_color("font_color","Button", control_font_color );
|
||||
t->set_color("font_color_pressed","Button", control_font_color_pressed );
|
||||
t->set_color("font_color_hover","Button", control_font_color_hover );
|
||||
t->set_color("font_color_disabled","Button", control_font_color_disabled );
|
||||
t->set_constant("hseparation","Button", 2 );
|
||||
|
||||
t->set_constant("hseparation","Button", 2);
|
||||
|
||||
|
||||
t->set_stylebox("normal","ColorPickerButton", make_stylebox( button_normal_png,7,7,7,7,8,3,8,3) );
|
||||
t->set_stylebox("pressed","ColorPickerButton", make_stylebox( button_pressed_png,5,5,5,5,3,3,3,3) );
|
||||
t->set_stylebox("hover","ColorPickerButton", make_stylebox( button_hover_png,4,4,4,4,3,3,3,3) );
|
||||
t->set_stylebox("disabled","ColorPickerButton", make_stylebox( button_disabled_png,4,4,4,4,3,3,3,3) );
|
||||
t->set_stylebox("focus","ColorPickerButton", make_stylebox( focus_png,5,5,5,5,3,3,3,3) );
|
||||
|
||||
// ColorPickerButton
|
||||
|
||||
t->set_stylebox("normal","ColorPickerButton", make_stylebox( button_normal_png,4,4,4,4) );
|
||||
t->set_stylebox("pressed","ColorPickerButton", make_stylebox( button_pressed_png,4,4,4,4) );
|
||||
t->set_stylebox("hover","ColorPickerButton", make_stylebox( button_hover_png,4,4,4,4) );
|
||||
t->set_stylebox("disabled","ColorPickerButton", make_stylebox( button_disabled_png,4,4,4,4) );
|
||||
t->set_stylebox("focus","ColorPickerButton", focus );
|
||||
|
||||
t->set_font("font","ColorPickerButton", default_font );
|
||||
|
||||
t->set_color("font_color","ColorPickerButton", Color(1,1,1,1) );
|
||||
t->set_color("font_color_pressed","ColorPickerButton", Color(0.8,0.8,0.8,1) );
|
||||
t->set_color("font_color_hover","ColorPickerButton", Color(1,1,1,1) );
|
||||
t->set_color("font_color_disabled","ColorPickerButton", Color(0.9,0.9,0.9,0.6) );
|
||||
t->set_color("font_color_disabled","ColorPickerButton", Color(0.9,0.9,0.9,0.3) );
|
||||
|
||||
t->set_constant("hseparation","ColorPickerButton", 2 );
|
||||
|
||||
t->set_stylebox("normal","ToolButton", make_empty_stylebox(5,3,5,3) );
|
||||
t->set_stylebox("pressed","ToolButton", make_stylebox( button_pressed_png,5,5,5,5,3,3,3,3) );
|
||||
|
||||
t->set_stylebox("hover","ToolButton", make_stylebox( button_normal_png,5,5,5,5,3,3,3,3) );
|
||||
//t->set_stylebox("disabled","ToolButton", make_stylebox( button_disabled_png,5,5,5,5,3,3,3,3) );
|
||||
t->set_stylebox("disabled","ToolButton", make_empty_stylebox(3,3,3,3) );
|
||||
t->set_stylebox("focus","ToolButton", make_stylebox( focus_png,5,5,5,5,3,3,3,3) );
|
||||
// ToolButton
|
||||
|
||||
Ref<StyleBox> tb_empty = memnew( StyleBoxEmpty );
|
||||
tb_empty->set_default_margin(MARGIN_LEFT,8);
|
||||
tb_empty->set_default_margin(MARGIN_RIGHT,8);
|
||||
tb_empty->set_default_margin(MARGIN_TOP,4);
|
||||
tb_empty->set_default_margin(MARGIN_BOTTOM,4);
|
||||
|
||||
t->set_stylebox("normal","ToolButton", tb_empty);
|
||||
t->set_stylebox("pressed","ToolButton", make_stylebox( button_pressed_png,4,4,4,4) );
|
||||
t->set_stylebox("hover","ToolButton", make_stylebox( button_normal_png,4,4,4,4) );
|
||||
t->set_stylebox("disabled","ToolButton", make_empty_stylebox(4,4,4,4) );
|
||||
t->set_stylebox("focus","ToolButton", focus );
|
||||
|
||||
t->set_font("font","ToolButton", default_font );
|
||||
|
||||
t->set_color("font_color","ToolButton", control_font_color );
|
||||
t->set_color("font_color_pressed","ToolButton", control_font_color_pressed );
|
||||
t->set_color("font_color_hover","ToolButton", control_font_color_hover );
|
||||
t->set_color("font_color_disabled","ToolButton", Color(0.9,0.95,1,0.6) );
|
||||
t->set_constant("hseparation","ToolButton", 2 );
|
||||
t->set_color("font_color_disabled","ToolButton", Color(0.9,0.95,1,0.3) );
|
||||
|
||||
t->set_stylebox("normal","OptionButton", make_stylebox( option_button_normal_png,4,4,20,5,8,3,20,4) );
|
||||
t->set_stylebox("pressed","OptionButton", make_stylebox( option_button_pressed_png,4,4,20,5,3,3,3,3) );
|
||||
t->set_stylebox("hover","OptionButton", make_stylebox( option_button_hover_png,4,4,20,5,3,3,3,3) );
|
||||
t->set_stylebox("disabled","OptionButton", make_stylebox( option_button_disabled_png,4,4,20,5,3,3,3,3) );
|
||||
t->set_constant("hseparation","ToolButton", 0 );
|
||||
|
||||
|
||||
|
||||
// OptionButton
|
||||
|
||||
t->set_stylebox("normal","OptionButton", make_stylebox( option_button_normal_png,5,5,21,5,8,4,8,4) );
|
||||
t->set_stylebox("pressed","OptionButton", make_stylebox( option_button_pressed_png,5,5,21,5) );
|
||||
t->set_stylebox("hover","OptionButton", make_stylebox( option_button_hover_png,5,5,21,5) );
|
||||
t->set_stylebox("disabled","OptionButton", make_stylebox( option_button_disabled_png,5,5,21,5) );
|
||||
t->set_stylebox("focus","OptionButton", focus );
|
||||
t->set_constant("arrow_margin","OptionButton", 1 );
|
||||
|
||||
t->set_icon("arrow","OptionButton", make_icon( option_arrow_png ) );
|
||||
|
||||
t->set_font("font","OptionButton", default_font );
|
||||
|
||||
t->set_color("font_color","OptionButton", control_font_color );
|
||||
t->set_color("font_color_pressed","OptionButton", control_font_color_pressed );
|
||||
t->set_color("font_color_hover","OptionButton", control_font_color_hover );
|
||||
t->set_color("font_color_disabled","OptionButton", control_font_color_disabled );
|
||||
|
||||
t->set_constant("hseparation","OptionButton", 2 );
|
||||
t->set_constant("arrow_margin","OptionButton", 2 );
|
||||
|
||||
t->set_stylebox("normal","MenuButton", make_stylebox( button_normal_png,6,6,6,6,3,3,3,3) );
|
||||
t->set_stylebox("pressed","MenuButton", make_stylebox( tool_button_pressed_png ,6,6,6,6,3,3,3,3) );
|
||||
t->set_stylebox("hover","MenuButton", make_stylebox( button_normal_png,6,6,6,6,3,3,3,3) );
|
||||
|
||||
|
||||
// MenuButton
|
||||
|
||||
t->set_stylebox("normal","MenuButton", make_stylebox( button_normal_png,4,4,4,4,8,4,8,4) );
|
||||
t->set_stylebox("pressed","MenuButton", make_stylebox( tool_button_pressed_png ,4,4,4,4) );
|
||||
t->set_stylebox("hover","MenuButton", make_stylebox( button_normal_png,4,4,4,4) );
|
||||
t->set_stylebox("disabled","MenuButton", make_empty_stylebox(0,0,0,0) );
|
||||
|
||||
t->set_font("font","MenuButton", default_font );
|
||||
|
||||
t->set_color("font_color","MenuButton", control_font_color );
|
||||
t->set_color("font_color_pressed","MenuButton", control_font_color_pressed );
|
||||
t->set_color("font_color_hover","MenuButton", control_font_color_hover );
|
||||
t->set_color("font_color_disabled","MenuButton", Color(1,1,1,0.3) );
|
||||
t->set_stylebox("focus","OptionButton", Ref<StyleBox>( memnew( StyleBoxEmpty )) );
|
||||
|
||||
t->set_constant("hseparation","MenuButton", 2 );
|
||||
t->set_constant("hseparation","MenuButton", 0 );
|
||||
|
||||
|
||||
|
||||
// CheckButton
|
||||
|
||||
Ref<StyleBox> cb_empty = memnew( StyleBoxEmpty );
|
||||
cb_empty->set_default_margin(MARGIN_LEFT,6);
|
||||
cb_empty->set_default_margin(MARGIN_RIGHT,70);
|
||||
cb_empty->set_default_margin(MARGIN_TOP,4);
|
||||
cb_empty->set_default_margin(MARGIN_BOTTOM,4);
|
||||
|
||||
t->set_stylebox("normal","CheckButton", cb_empty );
|
||||
t->set_stylebox("pressed","CheckButton", cb_empty );
|
||||
t->set_stylebox("disabled","CheckButton", cb_empty );
|
||||
t->set_stylebox("hover","CheckButton", cb_empty );
|
||||
//t->set_stylebox("hover","CheckButton", make_stylebox( button_hover_png,5,5,5,5,3,3,3,3) );
|
||||
t->set_stylebox("focus","CheckButton", focus );
|
||||
|
||||
t->set_icon("on","CheckButton", make_icon(toggle_on_png) );
|
||||
t->set_icon("off","CheckButton", make_icon(toggle_off_png));
|
||||
|
||||
t->set_font("font","CheckButton", default_font );
|
||||
|
||||
t->set_color("font_color","CheckButton", control_font_color );
|
||||
t->set_color("font_color_pressed","CheckButton", control_font_color_pressed );
|
||||
t->set_color("font_color_hover","CheckButton", control_font_color_hover );
|
||||
t->set_color("font_color_disabled","CheckButton", control_font_color_disabled );
|
||||
t->set_icon("on","CheckButton", make_icon(toggle_on_png) );
|
||||
t->set_icon("off","CheckButton", make_icon(toggle_off_png));
|
||||
t->set_stylebox("focus","CheckButton", focus );
|
||||
|
||||
t->set_constant("hseparation","CheckButton",4);
|
||||
t->set_constant("check_vadjust","CheckButton",0);
|
||||
|
||||
|
||||
|
||||
// Label
|
||||
|
||||
t->set_font("font","Label", default_font );
|
||||
|
||||
t->set_color("font_color","Label", Color(1,1,1) );
|
||||
t->set_color("font_color_shadow","Label", Color(0,0,0,0) );
|
||||
|
||||
t->set_constant("shadow_offset_x","Label", 1 );
|
||||
t->set_constant("shadow_offset_y","Label", 1 );
|
||||
t->set_constant("shadow_as_outline","Label", 0 );
|
||||
|
||||
t->set_stylebox("normal","LineEdit", make_stylebox( line_edit_png,4,4,4,4,3,4,3,4) );
|
||||
|
||||
|
||||
// LineEdit
|
||||
|
||||
t->set_stylebox("normal","LineEdit", make_stylebox( line_edit_png,5,5,5,5) );
|
||||
t->set_stylebox("focus","LineEdit", focus );
|
||||
t->set_stylebox("read_only","LineEdit", make_stylebox( line_edit_disabled_png,6,6,6,6,4,4,4,4) );
|
||||
Image n(line_edit_png);
|
||||
Image nf(line_edit_focus_png);
|
||||
|
||||
|
||||
t->set_stylebox("read_only","LineEdit", make_stylebox( line_edit_disabled_png,6,6,6,6) );
|
||||
|
||||
t->set_font("font","LineEdit", default_font );
|
||||
|
||||
t->set_color("font_color","LineEdit", control_font_color );
|
||||
t->set_color("font_color_selected","LineEdit", Color(0,0,0) );
|
||||
t->set_color("cursor_color","LineEdit", control_font_color_hover );
|
||||
t->set_color("selection_color","LineEdit", font_color_selection );
|
||||
t->set_constant("minimum_spaces","LineEdit", 8 );
|
||||
|
||||
t->set_stylebox("bg","ProgressBar", make_stylebox( progress_bar_png,5,5,5,5,0,0,0,0) );
|
||||
t->set_stylebox("fg","ProgressBar", make_stylebox( progress_fill_png,5,5,5,5,2,2,2,2) );
|
||||
t->set_constant("minimum_spaces","LineEdit", 12 );
|
||||
|
||||
|
||||
|
||||
// ProgressBar
|
||||
|
||||
t->set_stylebox("bg","ProgressBar", make_stylebox( progress_bar_png,4,4,4,4,0,0,0,0) );
|
||||
t->set_stylebox("fg","ProgressBar", make_stylebox( progress_fill_png,6,6,6,6,2,1,2,1) );
|
||||
|
||||
t->set_font("font","ProgressBar", default_font );
|
||||
t->set_color("font_color","ProgressBar", control_font_color );
|
||||
|
||||
t->set_color("font_color","ProgressBar", control_font_color_hover );
|
||||
t->set_color("font_color_shadow","ProgressBar", Color(0,0,0) );
|
||||
|
||||
|
||||
|
||||
// TextEdit
|
||||
|
||||
t->set_stylebox("normal","TextEdit", make_stylebox( tree_bg_png,3,3,3,3) );
|
||||
t->set_stylebox("focus","TextEdit", focus );
|
||||
t->set_stylebox("completion","TextEdit", make_stylebox( tree_bg_png,3,3,3,3) );
|
||||
|
||||
t->set_icon("tab","TextEdit", make_icon( tab_png) );
|
||||
|
||||
t->set_stylebox("normal","TextEdit", make_stylebox( tree_bg_png,12,12,12,12,3,3,3,3) );
|
||||
t->set_stylebox("focus","TextEdit", focus );
|
||||
t->set_font("font","TextEdit", default_font );
|
||||
|
||||
t->set_stylebox("completion","TextEdit", make_stylebox( tree_bg_png,4,4,4,5,3,3,3,3) );
|
||||
t->set_constant("completion_lines","TextEdit", 7 );
|
||||
t->set_constant("completion_max_width","TextEdit", 50 );
|
||||
t->set_constant("completion_scroll_width","TextEdit", 3 );
|
||||
t->set_color("completion_scroll_color","TextEdit", control_font_color_pressed );
|
||||
t->set_color("completion_existing","TextEdit", control_font_color );
|
||||
|
||||
//t->set_font("font","TextEdit", mono_font );
|
||||
|
||||
t->set_font("font","TextEdit", default_font );
|
||||
t->set_color("font_color","TextEdit", control_font_color );
|
||||
t->set_color("font_color_selected","TextEdit", Color(0,0,0) );
|
||||
t->set_color("selection_color","TextEdit", font_color_selection );
|
||||
t->set_color("mark_color","TextEdit", Color(1.0,0.4,0.4,0.4) );
|
||||
t->set_color("breakpoint_color","TextEdit", Color(0.8,0.8,0.4,0.4) );
|
||||
t->set_color("current_line_color","TextEdit", Color(0.3,0.5,0.8,0.15) );
|
||||
t->set_color("breakpoint_color","TextEdit", Color(0.8,0.8,0.4,0.2) );
|
||||
t->set_color("current_line_color","TextEdit", Color(0.25,0.25,0.26,0.8) );
|
||||
t->set_color("cursor_color","TextEdit", control_font_color );
|
||||
t->set_color("symbol_color","TextEdit", control_font_color_hover );
|
||||
t->set_color("brace_mismatch_color","TextEdit", Color(1,0.2,0.2) );
|
||||
t->set_constant("line_spacing","TextEdit",1 );
|
||||
|
||||
t->set_stylebox("scroll","HScrollBar", make_stylebox( hscroll_bg_png,3,3,3,3,0,0,0,0) );
|
||||
t->set_stylebox("scroll_focus","HScrollBar", make_stylebox( hscroll_bg_png,3,3,3,3,0,0,0,0) );
|
||||
t->set_stylebox("grabber","HScrollBar", make_stylebox( hscroll_grabber_png,3,3,3,3,2,2,2,2) );
|
||||
t->set_stylebox("grabber_hilite","HScrollBar", make_stylebox( hscroll_grabber_hl_png,3,3,3,3,2,2,2,2) );
|
||||
t->set_constant("completion_lines","TextEdit", 7 );
|
||||
t->set_constant("completion_max_width","TextEdit", 50 );
|
||||
t->set_constant("completion_scroll_width","TextEdit", 3 );
|
||||
t->set_constant("line_spacing","TextEdit",4 );
|
||||
|
||||
|
||||
Ref<Texture> empty_icon = memnew( ImageTexture );
|
||||
|
||||
// HScrollBar
|
||||
|
||||
t->set_stylebox("scroll","HScrollBar", make_stylebox( scroll_bg_png,3,3,3,3,0,0,0,0) );
|
||||
t->set_stylebox("scroll_focus","HScrollBar", make_stylebox( scroll_bg_png,3,3,3,3,0,0,0,0) );
|
||||
t->set_stylebox("grabber","HScrollBar", make_stylebox( scroll_grabber_png,3,3,3,3,2,2,2,2) );
|
||||
t->set_stylebox("grabber_hilite","HScrollBar", make_stylebox( scroll_grabber_hl_png,3,3,3,3,2,2,2,2) );
|
||||
|
||||
t->set_icon("increment","HScrollBar",empty_icon);
|
||||
t->set_icon("increment_hilite","HScrollBar",empty_icon);
|
||||
@ -345,77 +416,112 @@ void make_default_theme() {
|
||||
t->set_icon("decrement_hilite","HScrollBar",empty_icon);
|
||||
|
||||
|
||||
t->set_stylebox("scroll","VScrollBar", make_stylebox( vscroll_bg_png,3,3,3,3,0,0,0,0) );
|
||||
t->set_stylebox("scroll_focus","VScrollBar", make_stylebox( vscroll_bg_png,3,3,3,3,0,0,0,0) );
|
||||
t->set_stylebox("grabber","VScrollBar", make_stylebox( vscroll_grabber_png,3,3,3,3,2,2,2,2) );
|
||||
t->set_stylebox("grabber_hilite","VScrollBar", make_stylebox( vscroll_grabber_hl_png,3,3,3,3,2,2,2,2) );
|
||||
|
||||
// VScrollBar
|
||||
|
||||
t->set_stylebox("scroll","VScrollBar", make_stylebox( scroll_bg_png,3,3,3,3,0,0,0,0) );
|
||||
t->set_stylebox("scroll_focus","VScrollBar", make_stylebox( scroll_bg_png,3,3,3,3,0,0,0,0) );
|
||||
t->set_stylebox("grabber","VScrollBar", make_stylebox( scroll_grabber_png,3,3,3,3,2,2,2,2) );
|
||||
t->set_stylebox("grabber_hilite","VScrollBar", make_stylebox( scroll_grabber_hl_png,3,3,3,3,2,2,2,2) );
|
||||
|
||||
t->set_icon("increment","VScrollBar",empty_icon);
|
||||
t->set_icon("increment_hilite","VScrollBar",empty_icon);
|
||||
t->set_icon("decrement","VScrollBar",empty_icon);
|
||||
t->set_icon("decrement_hilite","VScrollBar",empty_icon);
|
||||
|
||||
t->set_stylebox("slider","HSlider", make_stylebox( hslider_bg_png,5,5,5,5,1,1,1,1) );
|
||||
t->set_stylebox("focus","HSlider", make_stylebox( focus_png,3,3,3,3,1,1,1,1) );
|
||||
//t->set_stylebox("slider_focus","HSlider", make_stylebox( hslider_bg_focus_png,6,6,6,6,2,2,2,2) );
|
||||
|
||||
|
||||
// HSlider
|
||||
|
||||
t->set_stylebox("slider","HSlider", make_stylebox( hslider_bg_png,4,4,4,4) );
|
||||
t->set_stylebox("grabber_hilite","HSlider", make_stylebox( hslider_grabber_hl_png,6,6,6,6) );
|
||||
t->set_stylebox("focus","HSlider", focus );
|
||||
|
||||
t->set_icon("grabber","HSlider", make_icon( hslider_grabber_png ) );
|
||||
t->set_icon("grabber_hilite","HSlider", make_icon( hslider_grabber_hl_png ) );
|
||||
t->set_icon("tick","HSlider", make_icon( hslider_tick_png ) );
|
||||
t->set_stylebox("grabber_hilite","HSlider", make_stylebox( hslider_grabber_hl_png,6,6,6,6,2,2,2,2) );
|
||||
|
||||
t->set_stylebox("slider","VSlider", make_stylebox( vslider_bg_png,5,5,5,5,1,1,1,1) );
|
||||
t->set_stylebox("focus","HSlider", make_stylebox( focus_png,3,3,3,3,1,1,1,1) );
|
||||
//t->set_stylebox("slider_focus","VSlider", make_stylebox( vslider_bg_focus_png,6,6,6,6,2,2,2,2) );
|
||||
|
||||
|
||||
|
||||
// VSlider
|
||||
|
||||
t->set_stylebox("slider","VSlider", make_stylebox( vslider_bg_png,4,4,4,4) );
|
||||
t->set_stylebox("grabber_hilite","VSlider", make_stylebox( vslider_grabber_hl_png,6,6,6,6) );
|
||||
t->set_stylebox("focus","HSlider", focus );
|
||||
|
||||
t->set_icon("grabber","VSlider", make_icon( vslider_grabber_png) );
|
||||
t->set_icon("grabber_hilite","VSlider", make_icon( vslider_grabber_hl_png ) );
|
||||
t->set_icon("tick","VSlider", make_icon( vslider_tick_png ) );
|
||||
t->set_stylebox("grabber_hilite","VSlider", make_stylebox( vslider_grabber_hl_png,6,6,6,6,2,2,2,2) );
|
||||
|
||||
|
||||
|
||||
// SpinBox
|
||||
|
||||
t->set_icon("updown","SpinBox",make_icon(spinbox_updown_png));
|
||||
|
||||
|
||||
Ref<StyleBoxTexture> style_pp_win = make_stylebox( popup_window_png,6,28,6,7,8,8,8,8);
|
||||
|
||||
// WindowDialog
|
||||
|
||||
Ref<StyleBoxTexture> style_pp_win = make_stylebox( popup_window_png,6,28,6,7);
|
||||
for(int i=0;i<4;i++)
|
||||
style_pp_win->set_expand_margin_size((Margin)i,3);
|
||||
style_pp_win->set_expand_margin_size(MARGIN_TOP,26);
|
||||
|
||||
t->set_stylebox("panel","WindowDialog", style_pp_win );
|
||||
t->set_constant("titlebar_height","WindowDialog", 18 );
|
||||
t->set_constant("title_height","WindowDialog", 20 );
|
||||
t->set_font("title_font","WindowDialog", large_font );
|
||||
t->set_color("title_color","WindowDialog", Color(0,0,0) );
|
||||
|
||||
t->set_icon("close","WindowDialog", make_icon( close_png ) );
|
||||
t->set_icon("close_hilite","WindowDialog", make_icon( close_hl_png ) );
|
||||
|
||||
t->set_font("title_font","WindowDialog", large_font );
|
||||
|
||||
t->set_color("title_color","WindowDialog", Color(0,0,0) );
|
||||
|
||||
t->set_constant("close_h_ofs","WindowDialog", 22 );
|
||||
t->set_constant("close_v_ofs","WindowDialog", 20 );
|
||||
t->set_constant("titlebar_height","WindowDialog", 18 );
|
||||
t->set_constant("title_height","WindowDialog", 20 );
|
||||
|
||||
|
||||
Ref<StyleBoxTexture> style_pp = make_stylebox( popup_bg_png,6,19,6,7,8,8,8,8);
|
||||
style_pp->set_expand_margin_size(MARGIN_LEFT,2);
|
||||
style_pp->set_expand_margin_size(MARGIN_TOP,3);
|
||||
style_pp->set_expand_margin_size(MARGIN_RIGHT,2);
|
||||
style_pp->set_expand_margin_size(MARGIN_BOTTOM,3);
|
||||
|
||||
// Popup
|
||||
|
||||
t->set_stylebox("panel","PopupMenu", style_pp );
|
||||
t->set_stylebox("panel","PopupPanel", style_pp );
|
||||
Ref<StyleBoxTexture> style_pp = make_stylebox( popup_bg_png,4,4,4,4,8,8,8,8);
|
||||
|
||||
Ref<StyleBoxTexture> selected = make_stylebox( selection_png,6,6,6,6);
|
||||
for(int i=0;i<4;i++) {
|
||||
selected->set_expand_margin_size(Margin(i),2);
|
||||
}
|
||||
|
||||
t->set_stylebox("panel_disabled","PopupMenu", make_stylebox( popup_bg_disabled_png,5,5,5,5) );
|
||||
t->set_stylebox("panel","PopupPanel", style_pp );
|
||||
|
||||
|
||||
|
||||
|
||||
// PopupMenu
|
||||
|
||||
t->set_stylebox("panel","PopupMenu", make_stylebox( popup_bg_png,4,4,4,4,10,10,10,10) );
|
||||
t->set_stylebox("panel_disabled","PopupMenu", make_stylebox( popup_bg_disabled_png,4,4,4,4) );
|
||||
t->set_stylebox("hover","PopupMenu", selected );
|
||||
t->set_stylebox("separator","PopupMenu", make_stylebox( vseparator_png,3,3,3,3) );
|
||||
t->set_icon("checked","PopupMenu", make_icon(popup_checked_png) );
|
||||
t->set_icon("unchecked","PopupMenu", make_icon(popup_unchecked_png) );
|
||||
|
||||
t->set_icon("checked","PopupMenu", make_icon(checked_png) );
|
||||
t->set_icon("unchecked","PopupMenu", make_icon(unchecked_png) );
|
||||
t->set_icon("submenu","PopupMenu", make_icon(submenu_png) );
|
||||
|
||||
t->set_font("font","PopupMenu", default_font );
|
||||
|
||||
t->set_color("font_color","PopupMenu", control_font_color );
|
||||
t->set_color("font_color_accel","PopupMenu", Color(0.7,0.7,0.7,0.8) );
|
||||
t->set_color("font_color_disabled","PopupMenu", Color(0.4,0.4,0.4,0.8) );
|
||||
t->set_color("font_color_hover","PopupMenu", control_font_color );
|
||||
t->set_constant("hseparation","PopupMenu",2);
|
||||
t->set_constant("vseparation","PopupMenu",1);
|
||||
|
||||
t->set_constant("hseparation","PopupMenu",4);
|
||||
t->set_constant("vseparation","PopupMenu",4);
|
||||
|
||||
|
||||
// GraphNode
|
||||
|
||||
Ref<StyleBoxTexture> graphsb = make_stylebox(graph_node_png,6,24,6,5,16,24,16,5);
|
||||
//graphsb->set_expand_margin_size(MARGIN_LEFT,10);
|
||||
@ -431,40 +537,21 @@ void make_default_theme() {
|
||||
t->set_constant("port_offset","GraphNode", 3);
|
||||
|
||||
|
||||
t->set_stylebox("bg","Tree", make_stylebox( tree_bg_png,4,4,4,5,3,3,3,3) );
|
||||
// Tree
|
||||
|
||||
Ref<StyleBoxTexture> tree_selected = make_stylebox( selection_png,4,4,4,4,8,0,8,0);
|
||||
Ref<StyleBoxTexture> tree_selected_oof = make_stylebox( selection_oof_png,4,4,4,4,8,0,8,0);
|
||||
|
||||
t->set_stylebox("bg","Tree", make_stylebox( tree_bg_png,4,4,4,5) );
|
||||
t->set_stylebox("bg_focus","Tree", focus );
|
||||
Ref<StyleBoxTexture> tree_selected = make_stylebox( selection_png,4,4,4,4);
|
||||
Ref<StyleBoxTexture> tree_selected_oof = make_stylebox( selection_oof_png,4,4,4,4);
|
||||
for(int i=0;i<4;i++) {
|
||||
tree_selected->set_expand_margin_size(Margin(i),2);
|
||||
tree_selected_oof->set_expand_margin_size(Margin(i),2);
|
||||
}
|
||||
t->set_stylebox("selected","Tree", tree_selected_oof );
|
||||
t->set_stylebox("selected_focus","Tree", tree_selected );
|
||||
t->set_stylebox("completion_selected","TextEdit", tree_selected );
|
||||
|
||||
|
||||
t->set_stylebox("cursor","Tree", focus );
|
||||
t->set_stylebox("cursor_unfocused","Tree", focus );
|
||||
t->set_stylebox("button_pressed","Tree",make_stylebox( button_pressed_png,5,5,5,5,3,3,3,3));
|
||||
t->set_font("font","Tree", default_font );
|
||||
t->set_color("font_color","Tree", control_font_color_low );
|
||||
t->set_color("font_color_selected","Tree", control_font_color );
|
||||
t->set_color("selection_color","Tree", Color(0.1,0.1,1,0.8) );
|
||||
t->set_color("cursor_color","Tree", Color(0,0,0) );
|
||||
t->set_color("guide_color","Tree", Color(0,0,0,0.1) );
|
||||
t->set_constant("hseparation","Tree",2);
|
||||
t->set_constant("vseparation","Tree",1);
|
||||
t->set_constant("guide_width","Tree",1);
|
||||
t->set_constant("item_margin","Tree",12);
|
||||
t->set_constant("button_margin","Tree",2);
|
||||
|
||||
t->set_stylebox("title_button_normal","Tree", make_stylebox( tree_title_png,4,4,4,4,3,3,3,3) );
|
||||
t->set_stylebox("title_button_pressed","Tree", make_stylebox( tree_title_pressed_png,4,4,4,4,3,3,3,3) );
|
||||
t->set_stylebox("title_button_hover","Tree", make_stylebox( tree_title_png,4,4,4,4,3,3,3,3) );
|
||||
t->set_color("title_button_color","Tree", control_font_color );
|
||||
t->set_font("title_button_font","Tree", default_font );
|
||||
|
||||
t->set_stylebox("button_pressed","Tree",make_stylebox( button_pressed_png,4,4,4,4));
|
||||
t->set_stylebox("title_button_normal","Tree", make_stylebox( tree_title_png,4,4,4,4) );
|
||||
t->set_stylebox("title_button_pressed","Tree", make_stylebox( tree_title_pressed_png,4,4,4,4) );
|
||||
t->set_stylebox("title_button_hover","Tree", make_stylebox( tree_title_png,4,4,4,4) );
|
||||
|
||||
t->set_icon("checked","Tree",make_icon(checked_png));
|
||||
t->set_icon("unchecked","Tree",make_icon(unchecked_png));
|
||||
@ -473,15 +560,42 @@ void make_default_theme() {
|
||||
t->set_icon("arrow","Tree",make_icon(arrow_down_png));
|
||||
t->set_icon("arrow_collapsed","Tree",make_icon(arrow_right_png));
|
||||
|
||||
t->set_stylebox("tab_fg","TabContainer", make_stylebox( tab_current_png,5,5,5,5,8,3,8,3) );
|
||||
t->set_stylebox("tab_bg","TabContainer", make_stylebox( tab_behind_png,5,5,5,5,8,4,8,3) );
|
||||
Ref<StyleBoxTexture> tc_sb = make_stylebox( tab_container_bg_png,6,19,6,7);
|
||||
t->set_font("title_button_font","Tree", default_font );
|
||||
t->set_font("font","Tree", default_font );
|
||||
|
||||
t->set_color("title_button_color","Tree", control_font_color );
|
||||
t->set_color("font_color","Tree", control_font_color_low );
|
||||
t->set_color("font_color_selected","Tree", control_font_color_pressed );
|
||||
t->set_color("selection_color","Tree", Color(0.1,0.1,1,0.8) );
|
||||
t->set_color("cursor_color","Tree", Color(0,0,0) );
|
||||
t->set_color("guide_color","Tree", Color(0,0,0,0.1) );
|
||||
|
||||
t->set_constant("hseparation","Tree",4);
|
||||
t->set_constant("vseparation","Tree",2);
|
||||
t->set_constant("guide_width","Tree",2);
|
||||
t->set_constant("item_margin","Tree",12);
|
||||
t->set_constant("button_margin","Tree",4);
|
||||
|
||||
|
||||
|
||||
// TextEdit
|
||||
|
||||
t->set_stylebox("completion_selected","TextEdit", tree_selected );
|
||||
|
||||
|
||||
|
||||
// TabContainer
|
||||
|
||||
Ref<StyleBoxTexture> tc_sb = make_stylebox( tab_container_bg_png,4,4,4,4);
|
||||
for(int i=0;i<4;i++) {
|
||||
tc_sb->set_default_margin(Margin(i),7);
|
||||
tc_sb->set_default_margin(Margin(i),4);
|
||||
tc_sb->set_expand_margin_size(Margin(i),2);
|
||||
}
|
||||
//tc_sb->set_expand_margin_size(MARGIN_TOP,2);
|
||||
//tc_sb->set_default_margin(MARGIN_TOP,6);
|
||||
tc_sb->set_expand_margin_size(MARGIN_TOP,2);
|
||||
tc_sb->set_default_margin(MARGIN_TOP,8);
|
||||
|
||||
t->set_stylebox("tab_fg","TabContainer", make_stylebox( tab_current_png,4,4,4,4,16,4,16,4) );
|
||||
t->set_stylebox("tab_bg","TabContainer", make_stylebox( tab_behind_png,4,4,4,4,16,6,16,4) );
|
||||
t->set_stylebox("panel","TabContainer", tc_sb );
|
||||
|
||||
t->set_icon("increment","TabContainer",make_icon( scroll_button_right_png));
|
||||
@ -490,116 +604,178 @@ void make_default_theme() {
|
||||
t->set_icon("decrement_hilite","TabContainer",make_icon( scroll_button_left_hl_png));
|
||||
|
||||
t->set_font("font","TabContainer", default_font );
|
||||
t->set_color("font_color_fg","TabContainer", control_font_color_hover );
|
||||
t->set_color("font_color_bg","TabContainer", control_font_color );
|
||||
t->set_constant("side_margin","TabContainer", 5 );
|
||||
t->set_constant("top_margin","TabContainer", 24);
|
||||
t->set_constant("label_valign_fg","TabContainer", 4);
|
||||
t->set_constant("label_valign_bg","TabContainer", 5);
|
||||
t->set_constant("hseparation","TabContainer", 2);
|
||||
|
||||
t->set_stylebox("tab_fg","Tabs", make_stylebox( tab_current_png,5,5,5,5,8,3,8,3) );
|
||||
t->set_stylebox("tab_bg","Tabs", make_stylebox( tab_behind_png,5,5,5,5,8,4,8,3) );
|
||||
t->set_stylebox("panel","Tabs", make_stylebox( tab_container_bg_png,3,3,3,3) );
|
||||
t->set_color("font_color_fg","TabContainer", control_font_color_hover );
|
||||
t->set_color("font_color_bg","TabContainer", control_font_color_low );
|
||||
|
||||
t->set_constant("side_margin","TabContainer", 8 );
|
||||
t->set_constant("top_margin","TabContainer", 24);
|
||||
t->set_constant("label_valign_fg","TabContainer", 0);
|
||||
t->set_constant("label_valign_bg","TabContainer", 2);
|
||||
t->set_constant("hseparation","TabContainer", 4);
|
||||
|
||||
|
||||
|
||||
// Tabs
|
||||
|
||||
t->set_stylebox("tab_fg","Tabs", make_stylebox( tab_current_png,4,4,4,4,16,4,16,4) );
|
||||
t->set_stylebox("tab_bg","Tabs", make_stylebox( tab_behind_png,4,4,4,4,16,6,16,4) );
|
||||
t->set_stylebox("panel","Tabs", make_stylebox( tab_container_bg_png,4,4,4,4) );
|
||||
|
||||
t->set_font("font","Tabs", default_font );
|
||||
|
||||
t->set_color("font_color_fg","Tabs", control_font_color_hover );
|
||||
t->set_color("font_color_bg","Tabs", control_font_color );
|
||||
t->set_color("font_color_bg","Tabs", control_font_color_low );
|
||||
|
||||
t->set_constant("top_margin","Tabs", 24);
|
||||
t->set_constant("label_valign_fg","Tabs", 4);
|
||||
t->set_constant("label_valign_bg","Tabs", 5);
|
||||
t->set_constant("hseparation","Tabs", 2);
|
||||
t->set_constant("label_valign_fg","Tabs", 0);
|
||||
t->set_constant("label_valign_bg","Tabs", 2);
|
||||
t->set_constant("hseparation","Tabs", 4);
|
||||
|
||||
|
||||
|
||||
// Separators
|
||||
|
||||
t->set_stylebox("separator","HSeparator", make_stylebox( vseparator_png,3,3,3,3) );
|
||||
t->set_constant("separation","HSeparator", 7);
|
||||
t->set_stylebox("separator","VSeparator", make_stylebox( hseparator_png,3,3,3,3) );
|
||||
t->set_constant("separation","VSeparator", 7);
|
||||
|
||||
t->set_icon("close","Icons", make_icon(icon_close_png));
|
||||
t->set_font("source","Fonts", source_font);
|
||||
t->set_font("normal","Fonts", default_font );
|
||||
t->set_font("large","Fonts", large_font );
|
||||
|
||||
t->set_constant("separation","HSeparator", 4);
|
||||
t->set_constant("separation","VSeparator", 4);
|
||||
|
||||
|
||||
t->set_constant("margin","Dialogs",10);
|
||||
// Dialogs
|
||||
|
||||
t->set_constant("margin","Dialogs",8);
|
||||
t->set_constant("button_margin","Dialogs",32);
|
||||
|
||||
|
||||
|
||||
// FileDialog
|
||||
|
||||
t->set_icon("folder","FileDialog",make_icon(icon_folder_png));
|
||||
|
||||
t->set_color("files_disabled","FileDialog",Color(0,0,0,0.7));
|
||||
|
||||
|
||||
|
||||
// colorPicker
|
||||
|
||||
t->set_constant("value_height","ColorPicker", 23 );
|
||||
t->set_constant("value_width","ColorPicker", 50);
|
||||
t->set_constant("color_width","ColorPicker", 100);
|
||||
t->set_constant("label_width","ColorPicker", 15);
|
||||
t->set_constant("label_width","ColorPicker", 20);
|
||||
t->set_constant("hseparator","ColorPicker", 4);
|
||||
|
||||
Ref<StyleBoxTexture> style_tt = make_stylebox( tooltip_bg_png,9,9,9,9,8,8,8,8);
|
||||
|
||||
|
||||
// TooltipPanel
|
||||
|
||||
Ref<StyleBoxTexture> style_tt = make_stylebox( tooltip_bg_png,4,4,4,4);
|
||||
for(int i=0;i<4;i++)
|
||||
style_tt->set_expand_margin_size((Margin)i,4);
|
||||
|
||||
t->set_stylebox("panel","TooltipPanel", style_tt );
|
||||
|
||||
t->set_font("font","TooltipLabel", default_font );
|
||||
|
||||
t->set_color("font_color","TooltipLabel", Color(0,0,0) );
|
||||
t->set_color("font_color_shadow","TooltipLabel", Color(0,0,0,0.1) );
|
||||
|
||||
t->set_constant("shadow_offset_x","TooltipLabel", 1 );
|
||||
t->set_constant("shadow_offset_y","TooltipLabel", 1 );
|
||||
|
||||
|
||||
|
||||
// RichTextLabel
|
||||
|
||||
t->set_stylebox("focus","RichTextLabel", focus );
|
||||
|
||||
t->set_font("default_font","RichTextLabel", default_font );
|
||||
|
||||
t->set_color("default_color","RichTextLabel", control_font_color );
|
||||
t->set_color("font_color_selected","RichTextLabel", font_color_selection );
|
||||
t->set_color("selection_color","RichTextLabel", Color(0.1,0.1,1,0.8) );
|
||||
|
||||
t->set_constant("line_separation","RichTextLabel", 1 );
|
||||
t->set_stylebox("focus","RichTextLabel", focus );
|
||||
|
||||
|
||||
t->set_constant("separation","HBoxContainer",4);
|
||||
t->set_constant("separation","VBoxContainer",4);
|
||||
t->set_constant("margin","MarginContainer",15);
|
||||
|
||||
t->set_constant("separation","GridContainer",4);
|
||||
// Containers
|
||||
|
||||
t->set_stylebox("bg","VSplitContainer", make_stylebox( vsplit_bg_png,1,1,1,1) );
|
||||
t->set_stylebox("bg","HSplitContainer", make_stylebox( hsplit_bg_png,1,1,1,1) );
|
||||
|
||||
t->set_constant("separation","HSplitContainer",8);
|
||||
t->set_constant("separation","VSplitContainer",8);
|
||||
t->set_constant("autohide","HSplitContainer",1);
|
||||
t->set_constant("autohide","VSplitContainer",1);
|
||||
t->set_icon("grabber","VSplitContainer",make_icon(vsplitter_png));
|
||||
t->set_icon("grabber","HSplitContainer",make_icon(hsplitter_png));
|
||||
|
||||
t->set_stylebox("bg","VSplitContainer", make_stylebox( vsplit_bg_png,1,1,1,1,1,1,1,1) );
|
||||
t->set_stylebox("bg","HSplitContainer", make_stylebox( hsplit_bg_png,1,1,1,1,1,1,1,1) );
|
||||
t->set_constant("separation","HBoxContainer",4);
|
||||
t->set_constant("separation","VBoxContainer",4);
|
||||
t->set_constant("margin","MarginContainer",8);
|
||||
t->set_constant("separation","GridContainer",4);
|
||||
t->set_constant("separation","HSplitContainer",12);
|
||||
t->set_constant("separation","VSplitContainer",12);
|
||||
t->set_constant("autohide","HSplitContainer",1);
|
||||
t->set_constant("autohide","VSplitContainer",1);
|
||||
|
||||
|
||||
|
||||
// HButtonArray
|
||||
|
||||
t->set_stylebox("normal","HButtonArray", make_stylebox( button_normal_png,4,4,4,4,0,4,22,4) );
|
||||
t->set_stylebox("selected","HButtonArray", make_stylebox( button_pressed_png,4,4,4,4,0,4,22,4) );
|
||||
t->set_stylebox("hover","HButtonArray", make_stylebox( button_hover_png,4,4,4,4) );
|
||||
|
||||
t->set_stylebox("normal","HButtonArray", make_stylebox( button_normal_png,2,2,2,2,3,3,3,3) );
|
||||
t->set_stylebox("selected","HButtonArray", make_stylebox( button_pressed_png,5,5,5,5,3,3,3,3) );
|
||||
t->set_stylebox("hover","HButtonArray", make_stylebox( button_hover_png,5,5,5,5,3,3,3,3) );
|
||||
t->set_stylebox("focus","HButtonArray", make_stylebox( focus_png,5,5,5,5,3,3,3,3) );
|
||||
t->set_font("font","HButtonArray", default_font);
|
||||
t->set_font("font_selected","HButtonArray", default_font);
|
||||
t->set_color("font_color","HButtonArray", Color(1,1,1,1) );
|
||||
t->set_color("font_color_selected","HButtonArray", Color(0.7,0.7,0.7,1) );
|
||||
t->set_constant("icon_separator","HButtonArray", 2 );
|
||||
t->set_constant("button_separator","HButtonArray", 3 );
|
||||
|
||||
t->set_stylebox("normal","VButtonArray", make_stylebox( button_normal_png,2,2,2,2,3,3,3,3) );
|
||||
t->set_stylebox("selected","VButtonArray", make_stylebox( button_pressed_png,5,5,5,5,3,3,3,3) );
|
||||
t->set_stylebox("hover","VButtonArray", make_stylebox( button_hover_png,5,5,5,5,3,3,3,3) );
|
||||
t->set_stylebox("focus","VButtonArray", make_stylebox( focus_png,5,5,5,5,3,3,3,3) );
|
||||
t->set_color("font_color","HButtonArray", control_font_color_low );
|
||||
t->set_color("font_color_selected","HButtonArray", control_font_color_hover );
|
||||
|
||||
t->set_constant("icon_separator","HButtonArray", 4 );
|
||||
t->set_constant("button_separator","HButtonArray", 8 );
|
||||
|
||||
t->set_stylebox("focus","HButtonArray", focus );
|
||||
|
||||
|
||||
// VButtonArray
|
||||
|
||||
t->set_stylebox("normal","VButtonArray", make_stylebox( button_normal_png,4,4,4,4,0,4,22,4) );
|
||||
t->set_stylebox("selected","VButtonArray", make_stylebox( button_pressed_png,4,4,4,4,0,4,22,4) );
|
||||
t->set_stylebox("hover","VButtonArray", make_stylebox( button_hover_png,4,4,4,4) );
|
||||
|
||||
t->set_font("font","VButtonArray", default_font);
|
||||
t->set_font("font_selected","VButtonArray", default_font);
|
||||
t->set_color("font_color","VButtonArray", Color(1,1,1,1) );
|
||||
t->set_color("font_color_selected","VButtonArray", Color(0.7,0.7,0.7,1) );
|
||||
t->set_constant("icon_separator","VButtonArray", 2 );
|
||||
t->set_constant("button_separator","VButtonArray", 3 );
|
||||
|
||||
t->set_stylebox("border","ReferenceFrame", make_stylebox( reference_border_png,5,5,5,5,3,3,3,3) );
|
||||
t->set_color("font_color","VButtonArray", control_font_color_low );
|
||||
t->set_color("font_color_selected","VButtonArray", control_font_color_hover );
|
||||
|
||||
t->set_constant("icon_separator","VButtonArray", 4);
|
||||
t->set_constant("button_separator","VButtonArray", 8);
|
||||
|
||||
t->set_stylebox("focus","VButtonArray", focus );
|
||||
|
||||
|
||||
// ReferenceFrame
|
||||
|
||||
Ref<StyleBoxTexture> ttnc = make_stylebox( full_panel_bg_png,8,8,8,8);
|
||||
ttnc->set_draw_center(false);
|
||||
|
||||
t->set_stylebox("border","ReferenceFrame", make_stylebox( reference_border_png,4,4,4,4) );
|
||||
t->set_stylebox("panelnc","Panel", ttnc );
|
||||
t->set_stylebox("panelf","Panel", tc_sb );
|
||||
|
||||
t->set_stylebox("panel","PanelContainer", tc_sb );
|
||||
|
||||
t->set_icon( "logo","Icons", make_icon(logo_png) );
|
||||
|
||||
|
||||
|
||||
// Theme
|
||||
|
||||
Theme::set_default( t );
|
||||
Theme::set_default_icon( make_icon(error_icon_png) );
|
||||
Theme::set_default_style( make_stylebox( error_icon_png,2,2,2,2) );
|
||||
@ -626,8 +802,8 @@ void make_default_theme() {
|
||||
style->set_texture(texture);
|
||||
|
||||
for(int i=0;i<4;i++) {
|
||||
style->set_margin_size( Margin(),2);
|
||||
style->set_default_margin( Margin(),2);
|
||||
style->set_margin_size( Margin(),8);
|
||||
style->set_default_margin( Margin(),8);
|
||||
}
|
||||
|
||||
Ref<Font> f = make_default_font();
|
||||
|
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 254 B |
Before Width: | Height: | Size: 473 B After Width: | Height: | Size: 459 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 366 B |
Before Width: | Height: | Size: 235 B |
Before Width: | Height: | Size: 235 B |
Before Width: | Height: | Size: 299 B |
Before Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 361 B After Width: | Height: | Size: 229 B |
Before Width: | Height: | Size: 624 B After Width: | Height: | Size: 483 B |
Before Width: | Height: | Size: 625 B After Width: | Height: | Size: 456 B |
Before Width: | Height: | Size: 227 B After Width: | Height: | Size: 216 B |
Before Width: | Height: | Size: 290 B After Width: | Height: | Size: 173 B |
Before Width: | Height: | Size: 225 B After Width: | Height: | Size: 212 B |
Before Width: | Height: | Size: 471 B After Width: | Height: | Size: 462 B |
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 295 B |
Before Width: | Height: | Size: 167 B After Width: | Height: | Size: 172 B |