diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/bind/core_bind.cpp | 34 | ||||
-rw-r--r-- | core/bind/core_bind.h | 6 | ||||
-rw-r--r-- | core/command_queue_mt.h | 4 | ||||
-rw-r--r-- | core/global_constants.cpp | 15 | ||||
-rw-r--r-- | core/globals.cpp | 10 | ||||
-rw-r--r-- | core/io/packet_peer.cpp | 2 | ||||
-rw-r--r-- | core/method_bind.h | 1 | ||||
-rw-r--r-- | core/os/file_access.cpp | 6 | ||||
-rw-r--r-- | core/os/file_access.h | 2 | ||||
-rw-r--r-- | core/os/input_event.h | 2 | ||||
-rw-r--r-- | core/os/os.cpp | 4 | ||||
-rw-r--r-- | core/os/os.h | 11 | ||||
-rw-r--r-- | core/os/pc_joystick_map.h | 86 | ||||
-rw-r--r-- | core/os/thread.cpp | 4 | ||||
-rw-r--r-- | core/os/thread.h | 6 | ||||
-rw-r--r-- | core/script_language.cpp | 16 | ||||
-rw-r--r-- | core/script_language.h | 2 | ||||
-rw-r--r-- | core/variant_call.cpp | 14 | ||||
-rw-r--r-- | core/variant_parser.cpp | 7 |
19 files changed, 99 insertions, 133 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 94d9e22a1e..b291ee396b 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -390,6 +390,12 @@ bool _OS::is_ok_left_and_cancel_right() const { return OS::get_singleton()->get_swap_ok_cancel(); } +Error _OS::set_thread_name(const String& p_name) { + + return Thread::set_name(p_name); +}; + + /* enum Weekday { DAY_SUNDAY, @@ -877,6 +883,8 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("alert","text","title"),&_OS::alert,DEFVAL("Alert!")); + ObjectTypeDB::bind_method(_MD("set_thread_name","name"),&_OS::set_thread_name); + BIND_CONSTANT( DAY_SUNDAY ); BIND_CONSTANT( DAY_MONDAY ); @@ -1313,9 +1321,9 @@ String _File::get_line() const{ } -Vector<String> _File::get_csv_line() const { +Vector<String> _File::get_csv_line(String delim) const { ERR_FAIL_COND_V(!f,Vector<String>()); - return f->get_csv_line(); + return f->get_csv_line(delim); } /**< use this for files WRITTEN in _big_ endian machines (ie, amiga/mac) @@ -1498,7 +1506,7 @@ void _File::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_endian_swap","enable"),&_File::set_endian_swap); ObjectTypeDB::bind_method(_MD("get_error:Error"),&_File::get_error); ObjectTypeDB::bind_method(_MD("get_var"),&_File::get_var); - ObjectTypeDB::bind_method(_MD("get_csv_line"),&_File::get_csv_line); + ObjectTypeDB::bind_method(_MD("get_csv_line","delim"),&_File::get_csv_line,DEFVAL(",")); ObjectTypeDB::bind_method(_MD("store_8","value"),&_File::store_8); ObjectTypeDB::bind_method(_MD("store_16","value"),&_File::store_16); @@ -1895,13 +1903,7 @@ void _Thread::_start_func(void *ud) { Variant::CallError ce; const Variant* arg[1]={&t->userdata}; - // we don't know our thread pointer yet :( - if (t->name == "") { - // come up with a better name using maybe the filename on the Script? - //t->thread->set_name(t->target_method); - } else { - //t->thread->set_name(t->name); - }; + Thread::set_name(t->target_method); t->ret=t->target_instance->call(t->target_method,arg,1,ce); if (ce.error!=Variant::CallError::CALL_OK) { @@ -1992,24 +1994,12 @@ Variant _Thread::wait_to_finish() { return r; } -Error _Thread::set_name(const String &p_name) { - - name = p_name; - - if (thread) { - return thread->set_name(p_name); - }; - - return OK; -}; - void _Thread::_bind_methods() { ObjectTypeDB::bind_method(_MD("start:Error","instance","method","userdata","priority"),&_Thread::start,DEFVAL(Variant()),DEFVAL(PRIORITY_NORMAL)); ObjectTypeDB::bind_method(_MD("get_id"),&_Thread::get_id); ObjectTypeDB::bind_method(_MD("is_active"),&_Thread::is_active); ObjectTypeDB::bind_method(_MD("wait_to_finish:Variant"),&_Thread::wait_to_finish); - ObjectTypeDB::bind_method(_MD("set_name:Error", "name"),&_Thread::set_name); BIND_CONSTANT( PRIORITY_LOW ); BIND_CONSTANT( PRIORITY_NORMAL ); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index e03657f3a0..30cc93fa11 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -270,6 +270,8 @@ public: bool is_ok_left_and_cancel_right() const; + Error set_thread_name(const String& p_name); + static _OS *get_singleton() { return singleton; } _OS(); @@ -390,7 +392,7 @@ public: virtual void store_pascal_string(const String& p_string); virtual String get_pascal_string(); - Vector<String> get_csv_line() const; + Vector<String> get_csv_line(String delim=",") const; void store_buffer(const DVector<uint8_t>& p_buffer); ///< store an array of bytes @@ -512,7 +514,6 @@ protected: Object *target_instance; StringName target_method; Thread *thread; - String name; static void _bind_methods(); static void _start_func(void *ud); public: @@ -528,7 +529,6 @@ public: String get_id() const; bool is_active() const; Variant wait_to_finish(); - Error set_name(const String& p_name); _Thread(); ~_Thread(); diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h index 4fd33e3a55..142668f6f6 100644 --- a/core/command_queue_mt.h +++ b/core/command_queue_mt.h @@ -34,7 +34,6 @@ #include "os/mutex.h" #include "os/memory.h" #include "simple_type.h" -#include "print_string.h" /** @author Juan Linietsky <reduzio@gmail.com> */ @@ -175,7 +174,7 @@ class CommandQueueMT { R* ret; SyncSemaphore *sync; - virtual void call() { *ret = (instance->*method)(p1); sync->sem->post(); print_line("post"); sync->in_use=false; ; } + virtual void call() { *ret = (instance->*method)(p1); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1,class P2,class R> @@ -676,7 +675,6 @@ public: if (sync) sync->post(); ss->sem->wait(); - print_line("wait"); } template<class T, class M, class P1, class P2,class R> diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 92e50a8b96..c306744d35 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -317,16 +317,19 @@ static _GlobalConstant _global_constants[]={ BIND_GLOBAL_CONSTANT( KEY_MASK_KPAD ), BIND_GLOBAL_CONSTANT( KEY_MASK_GROUP_SWITCH ), - // joysticks + // mouse BIND_GLOBAL_CONSTANT( BUTTON_LEFT ), BIND_GLOBAL_CONSTANT( BUTTON_RIGHT ), BIND_GLOBAL_CONSTANT( BUTTON_MIDDLE ), BIND_GLOBAL_CONSTANT( BUTTON_WHEEL_UP ), BIND_GLOBAL_CONSTANT( BUTTON_WHEEL_DOWN ), + BIND_GLOBAL_CONSTANT( BUTTON_WHEEL_LEFT ), + BIND_GLOBAL_CONSTANT( BUTTON_WHEEL_RIGHT ), BIND_GLOBAL_CONSTANT( BUTTON_MASK_LEFT ), BIND_GLOBAL_CONSTANT( BUTTON_MASK_RIGHT ), BIND_GLOBAL_CONSTANT( BUTTON_MASK_MIDDLE ), + //joysticks BIND_GLOBAL_CONSTANT( JOY_BUTTON_0 ), BIND_GLOBAL_CONSTANT( JOY_BUTTON_1 ), BIND_GLOBAL_CONSTANT( JOY_BUTTON_2 ), @@ -476,6 +479,16 @@ static _GlobalConstant _global_constants[]={ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_EDITOR ), BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_NETWORK ), BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_DEFAULT ), + + BIND_GLOBAL_CONSTANT( METHOD_FLAG_NORMAL ), + BIND_GLOBAL_CONSTANT( METHOD_FLAG_EDITOR ), + BIND_GLOBAL_CONSTANT( METHOD_FLAG_NOSCRIPT ), + BIND_GLOBAL_CONSTANT( METHOD_FLAG_CONST ), + BIND_GLOBAL_CONSTANT( METHOD_FLAG_REVERSE ), + BIND_GLOBAL_CONSTANT( METHOD_FLAG_VIRTUAL ), + BIND_GLOBAL_CONSTANT( METHOD_FLAG_FROM_SCRIPT ), + BIND_GLOBAL_CONSTANT( METHOD_FLAGS_DEFAULT ), + {"TYPE_NIL",Variant::NIL}, {"TYPE_BOOL",Variant::BOOL}, {"TYPE_INT",Variant::INT}, diff --git a/core/globals.cpp b/core/globals.cpp index 1e60854f28..d63f9c1bb4 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -916,6 +916,14 @@ static String _encode_variant(const Variant& p_variant) { float val = p_variant; return rtos(val)+(val==int(val)?".0":""); } break; + case Variant::VECTOR2: { + Vector2 val = p_variant; + return String("Vector2(")+rtos(val.x)+String(", ")+rtos(val.y)+String(")"); + } break; + case Variant::VECTOR3: { + Vector3 val = p_variant; + return String("Vector3(")+rtos(val.x)+ String(", ") +rtos(val.y)+ String(", ") +rtos(val.z)+String(")"); + } break; case Variant::STRING: { String val = p_variant; return "\""+val.xml_escape()+"\""; @@ -1419,7 +1427,7 @@ Globals::Globals() { set("application/name","" ); set("application/main_scene",""); - custom_prop_info["application/main_scene"]=PropertyInfo(Variant::STRING,"application/main_scene",PROPERTY_HINT_FILE,"scn,res,xscn,xml"); + custom_prop_info["application/main_scene"]=PropertyInfo(Variant::STRING,"application/main_scene",PROPERTY_HINT_FILE,"scn,res,xscn,xml,tscn"); set("application/disable_stdout",false); set("application/use_shared_user_dir",true); diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index 6cb3daa7ac..973a2ec9a5 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -243,7 +243,7 @@ int PacketPeerStream::get_max_packet_size() const { void PacketPeerStream::set_stream_peer(const Ref<StreamPeer> &p_peer) { - ERR_FAIL_COND(p_peer.is_null()); + //ERR_FAIL_COND(p_peer.is_null()); if (p_peer.ptr() != peer.ptr()) { ring_buffer.advance_read(ring_buffer.data_left()); // reset the ring buffer diff --git a/core/method_bind.h b/core/method_bind.h index 4c2598e50c..da3d7c1062 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -50,6 +50,7 @@ enum MethodFlags { METHOD_FLAG_CONST=8, METHOD_FLAG_REVERSE=16, // used for events METHOD_FLAG_VIRTUAL=32, + METHOD_FLAG_FROM_SCRIPT=64, METHOD_FLAGS_DEFAULT=METHOD_FLAG_NORMAL, }; diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index d82d0b63c5..68c9dee84d 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -277,7 +277,9 @@ String FileAccess::get_line() const { return String::utf8(line.get_data()); } -Vector<String> FileAccess::get_csv_line() const { +Vector<String> FileAccess::get_csv_line(String delim) const { + + ERR_FAIL_COND_V(delim.length()!=1,Vector<String>()); String l; int qc=0; @@ -303,7 +305,7 @@ Vector<String> FileAccess::get_csv_line() const { CharType s[2]={0,0}; - if (!in_quote && c==',') { + if (!in_quote && c==delim[0]) { strings.push_back(current); current=String(); } else if (c=='"') { diff --git a/core/os/file_access.h b/core/os/file_access.h index 51cf839117..3249e21ffb 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -102,7 +102,7 @@ public: virtual int get_buffer(uint8_t *p_dst,int p_length) const; ///< get an array of bytes virtual String get_line() const; - virtual Vector<String> get_csv_line() const; + virtual Vector<String> get_csv_line(String delim=",") const; /**< use this for files WRITTEN in _big_ endian machines (ie, amiga/mac) * It's not about the current CPU type but file formats. diff --git a/core/os/input_event.h b/core/os/input_event.h index b601adc875..36c1556524 100644 --- a/core/os/input_event.h +++ b/core/os/input_event.h @@ -51,6 +51,8 @@ enum { BUTTON_MIDDLE=3, BUTTON_WHEEL_UP=4, BUTTON_WHEEL_DOWN=5, + BUTTON_WHEEL_LEFT=6, + BUTTON_WHEEL_RIGHT=7, BUTTON_MASK_LEFT=(1<<(BUTTON_LEFT-1)), BUTTON_MASK_RIGHT=(1<<(BUTTON_RIGHT-1)), BUTTON_MASK_MIDDLE=(1<<(BUTTON_MIDDLE-1)), diff --git a/core/os/os.cpp b/core/os/os.cpp index e93038f854..0bc06c8375 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -523,6 +523,10 @@ String OS::get_joy_guid(int p_device) const { return "Default Joystick"; } +void OS::set_context(int p_context) { + +} + OS::OS() { last_error=NULL; frames_drawn=0; diff --git a/core/os/os.h b/core/os/os.h index bc3fad302a..0d4edb035d 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -76,7 +76,7 @@ public: bool fullscreen; bool resizable; float get_aspect() const { return (float)width/(float)height; } - VideoMode(int p_width=1280,int p_height=720,bool p_fullscreen=false, bool p_resizable = true) {width=p_width; height=p_height; fullscreen=p_fullscreen; resizable = p_resizable; } + VideoMode(int p_width=1024,int p_height=600,bool p_fullscreen=false, bool p_resizable = true) {width=p_width; height=p_height; fullscreen=p_fullscreen; resizable = p_resizable; } }; protected: friend class Main; @@ -173,6 +173,8 @@ public: virtual bool is_window_maximized() const { return true; } + + virtual void set_iterations_per_second(int p_ips); virtual int get_iterations_per_second() const; @@ -402,6 +404,13 @@ public: virtual bool is_joy_known(int p_device); virtual String get_joy_guid(int p_device)const; + enum EngineContext { + CONTEXT_EDITOR, + CONTEXT_PROJECTMAN, + }; + + virtual void set_context(int p_context); + OS(); virtual ~OS(); diff --git a/core/os/pc_joystick_map.h b/core/os/pc_joystick_map.h deleted file mode 100644 index df123c5c1b..0000000000 --- a/core/os/pc_joystick_map.h +++ /dev/null @@ -1,86 +0,0 @@ -/*************************************************************************/ -/* pc_joystick_map.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef PC_JOYSTICK_MAP_H -#define PC_JOYSTICK_MAP_H - -#include "input_event.h" - -static const int _pc_joystick_button_remap[JOY_BUTTON_MAX]={ - - JOY_SELECT, - JOY_L3, - JOY_R3, - JOY_START, - - JOY_DPAD_UP, - JOY_DPAD_RIGHT, - JOY_DPAD_DOWN, - JOY_DPAD_LEFT, - - JOY_L2, - JOY_R2, - JOY_L, - JOY_R, - - JOY_SNES_X, - JOY_SNES_A, - JOY_SNES_B, - JOY_SNES_Y, - - // JOY_HOME = 16 -}; - - -static int _pc_joystick_get_native_button(int p_pc_button) { - - if (p_pc_button<0 || p_pc_button>=JOY_BUTTON_MAX) - return p_pc_button; - return _pc_joystick_button_remap[p_pc_button]; -} - -static const int _pc_joystick_axis_remap[JOY_AXIS_MAX]={ - JOY_ANALOG_0_X, - JOY_ANALOG_0_Y, - JOY_ANALOG_1_X, - JOY_ANALOG_1_Y, - JOY_ANALOG_2_X, - JOY_ANALOG_2_Y, - JOY_AXIS_6, - JOY_AXIS_7 -}; - - -static int _pc_joystick_get_native_axis(int p_pc_axis) { - - if (p_pc_axis<0 || p_pc_axis>=JOY_BUTTON_MAX) - return p_pc_axis; - return _pc_joystick_axis_remap[p_pc_axis]; -} - -#endif // PC_JOYSTICK_MAP_H diff --git a/core/os/thread.cpp b/core/os/thread.cpp index 7fb1e969d4..f5d984876d 100644 --- a/core/os/thread.cpp +++ b/core/os/thread.cpp @@ -32,6 +32,7 @@ Thread* (*Thread::create_func)(ThreadCreateCallback,void *,const Settings&)=NULL; Thread::ID (*Thread::get_thread_ID_func)()=NULL; void (*Thread::wait_to_finish_func)(Thread*)=NULL; +Error (*Thread::set_name_func)(const String&)=NULL; Thread::ID Thread::_main_thread_id=0; @@ -60,6 +61,9 @@ void Thread::wait_to_finish(Thread *p_thread) { Error Thread::set_name(const String &p_name) { + if (set_name_func) + return set_name_func(p_name); + return ERR_UNAVAILABLE; }; diff --git a/core/os/thread.h b/core/os/thread.h index 5711561809..4fead72b94 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -63,6 +63,7 @@ protected: static Thread* (*create_func)(ThreadCreateCallback p_callback,void *,const Settings&); static ID (*get_thread_ID_func)(); static void (*wait_to_finish_func)(Thread*); + static Error (*set_name_func)(const String&); friend class Main; @@ -73,10 +74,9 @@ protected: public: - virtual Error set_name(const String& p_name); - virtual ID get_ID() const=0; - + + static Error set_name(const String &p_name); _FORCE_INLINE_ static ID get_main_ID() { return _main_thread_id; } ///< get the ID of the main thread static ID get_caller_ID(); ///< get the ID of the caller function ID static void wait_to_finish(Thread *p_thread); ///< waits until thread is finished, and deallocates it. diff --git a/core/script_language.cpp b/core/script_language.cpp index 2ce3844ba3..0eac39e7d1 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -92,6 +92,22 @@ void ScriptServer::init_languages() { } } +void ScriptInstance::get_property_state(List<Pair<StringName, Variant> > &state) { + + List<PropertyInfo> pinfo; + get_property_list(&pinfo); + for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) { + + if (E->get().usage&PROPERTY_USAGE_STORAGE) { + Pair<StringName,Variant> p; + p.first=E->get().name; + if (get(p.first,p.second)) + state.push_back(p); + } + } +} + + Variant ScriptInstance::call(const StringName& p_method,VARIANT_ARG_DECLARE) { VARIANT_ARGPTRS; diff --git a/core/script_language.h b/core/script_language.h index 3138c88e8e..7e278b8555 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -113,6 +113,8 @@ public: virtual void get_property_list(List<PropertyInfo> *p_properties) const=0; virtual Variant::Type get_property_type(const StringName& p_name,bool *r_is_valid=NULL) const=0; + virtual void get_property_state(List<Pair<StringName,Variant> > &state); + virtual void get_method_list(List<MethodInfo> *p_list) const=0; virtual bool has_method(const StringName& p_method) const=0; virtual Variant call(const StringName& p_method,VARIANT_ARG_LIST); diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 90f868c866..78814c83e2 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -1451,7 +1451,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(RAW_ARRAY,INT,ByteArray,size,varray()); ADDFUNC2(RAW_ARRAY,NIL,ByteArray,set,INT,"idx",INT,"byte",varray()); - ADDFUNC1(RAW_ARRAY,INT,ByteArray,get,INT,"idx",varray()); + //ADDFUNC1(RAW_ARRAY,INT,ByteArray,get,INT,"idx",varray()); ADDFUNC1(RAW_ARRAY,NIL,ByteArray,push_back,INT,"byte",varray()); ADDFUNC1(RAW_ARRAY,NIL,ByteArray,resize,INT,"idx",varray()); @@ -1461,37 +1461,37 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(INT_ARRAY,INT,IntArray,size,varray()); ADDFUNC2(INT_ARRAY,NIL,IntArray,set,INT,"idx",INT,"integer",varray()); - ADDFUNC1(INT_ARRAY,INT,IntArray,get,INT,"idx",varray()); + //ADDFUNC1(INT_ARRAY,INT,IntArray,get,INT,"idx",varray()); ADDFUNC1(INT_ARRAY,NIL,IntArray,push_back,INT,"integer",varray()); ADDFUNC1(INT_ARRAY,NIL,IntArray,resize,INT,"idx",varray()); ADDFUNC0(REAL_ARRAY,INT,RealArray,size,varray()); ADDFUNC2(REAL_ARRAY,NIL,RealArray,set,INT,"idx",REAL,"value",varray()); - ADDFUNC1(REAL_ARRAY,REAL,RealArray,get,INT,"idx",varray()); + //ADDFUNC1(REAL_ARRAY,REAL,RealArray,get,INT,"idx",varray()); ADDFUNC1(REAL_ARRAY,NIL,RealArray,push_back,REAL,"value",varray()); ADDFUNC1(REAL_ARRAY,NIL,RealArray,resize,INT,"idx",varray()); ADDFUNC0(STRING_ARRAY,INT,StringArray,size,varray()); ADDFUNC2(STRING_ARRAY,NIL,StringArray,set,INT,"idx",STRING,"string",varray()); - ADDFUNC1(STRING_ARRAY,STRING,StringArray,get,INT,"idx",varray()); + //ADDFUNC1(STRING_ARRAY,STRING,StringArray,get,INT,"idx",varray()); ADDFUNC1(STRING_ARRAY,NIL,StringArray,push_back,STRING,"string",varray()); ADDFUNC1(STRING_ARRAY,NIL,StringArray,resize,INT,"idx",varray()); ADDFUNC0(VECTOR2_ARRAY,INT,Vector2Array,size,varray()); ADDFUNC2(VECTOR2_ARRAY,NIL,Vector2Array,set,INT,"idx",VECTOR2,"vector2",varray()); - ADDFUNC1(VECTOR2_ARRAY,VECTOR2,Vector2Array,get,INT,"idx",varray()); + //ADDFUNC1(VECTOR2_ARRAY,VECTOR2,Vector2Array,get,INT,"idx",varray()); ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,push_back,VECTOR2,"vector2",varray()); ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,resize,INT,"idx",varray()); ADDFUNC0(VECTOR3_ARRAY,INT,Vector3Array,size,varray()); ADDFUNC2(VECTOR3_ARRAY,NIL,Vector3Array,set,INT,"idx",VECTOR3,"vector3",varray()); - ADDFUNC1(VECTOR3_ARRAY,VECTOR3,Vector3Array,get,INT,"idx",varray()); + //ADDFUNC1(VECTOR3_ARRAY,VECTOR3,Vector3Array,get,INT,"idx",varray()); ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,push_back,VECTOR3,"vector3",varray()); ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,resize,INT,"idx",varray()); ADDFUNC0(COLOR_ARRAY,INT,ColorArray,size,varray()); ADDFUNC2(COLOR_ARRAY,NIL,ColorArray,set,INT,"idx",COLOR,"color",varray()); - ADDFUNC1(COLOR_ARRAY,COLOR,ColorArray,get,INT,"idx",varray()); + //ADDFUNC1(COLOR_ARRAY,COLOR,ColorArray,get,INT,"idx",varray()); ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,push_back,COLOR,"color",varray()); ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,resize,INT,"idx",varray()); diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 3efa87de80..a3775156ac 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -338,6 +338,8 @@ Error VariantParser::get_token(Stream *p_stream, Token& r_token, int &line, Stri exp_beg=true; } else if ((c=='-' || c=='+') && !exp_sign && !exp_beg) { + if (c=='-') + is_float=true; exp_sign=true; } else { @@ -358,6 +360,7 @@ Error VariantParser::get_token(Stream *p_stream, Token& r_token, int &line, Stri r_token.type=TK_NUMBER; + if (is_float) r_token.value=num.to_double(); else @@ -542,7 +545,7 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in value=true; else if (id=="false") value=false; - else if (id=="null") + else if (id=="null" || id=="nil") value=Variant(); else if (id=="Vector2"){ @@ -1282,7 +1285,7 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in arr.resize(len); DVector<Color>::Write w = arr.write(); for(int i=0;i<len;i++) { - w[i]=Color(args[i*3+0],args[i*3+1],args[i*3+2],args[i*3+3]); + w[i]=Color(args[i*4+0],args[i*4+1],args[i*4+2],args[i*4+3]); } } |