Various api cleanups.

This commit is contained in:
Relintai 2023-05-29 18:45:14 +02:00
parent ed21dace22
commit 85c9e13d06
9 changed files with 15 additions and 121 deletions

View File

@ -42,9 +42,7 @@ typedef enum {
PANDEMONIUM_METHOD_RPC_MODE_REMOTE,
PANDEMONIUM_METHOD_RPC_MODE_MASTER,
PANDEMONIUM_METHOD_RPC_MODE_PUPPET,
PANDEMONIUM_METHOD_RPC_MODE_SLAVE = PANDEMONIUM_METHOD_RPC_MODE_PUPPET,
PANDEMONIUM_METHOD_RPC_MODE_REMOTESYNC,
PANDEMONIUM_METHOD_RPC_MODE_SYNC = PANDEMONIUM_METHOD_RPC_MODE_REMOTESYNC,
PANDEMONIUM_METHOD_RPC_MODE_MASTERSYNC,
PANDEMONIUM_METHOD_RPC_MODE_PUPPETSYNC,
} pandemonium_method_rpc_mode;
@ -54,9 +52,9 @@ typedef enum {
PANDEMONIUM_PROPERTY_HINT_RANGE, ///< hint_text = "min,max,step,slider; //slider is optional"
PANDEMONIUM_PROPERTY_HINT_EXP_RANGE, ///< hint_text = "min,max,step", exponential edit
PANDEMONIUM_PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc"
PANDEMONIUM_PROPERTY_HINT_EXP_EASING, /// exponential easing function (Math::ease)
PANDEMONIUM_PROPERTY_HINT_EXP_EASING, /// exponential easing function (Math::ease) use "attenuation" hint string to revert (flip h), "full" to also include in/out. (ie: "attenuation,inout")
PANDEMONIUM_PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer)
PANDEMONIUM_PROPERTY_HINT_SPRITE_FRAME, // FIXME: Obsolete: drop whenever we can break compat
PANDEMONIUM_PROPERTY_HINT_BUTTON, // Use a button in the inspector for this property. The property's type has to be Variant::NIL. hint_text="call_func:name/theme_type" -> calls call_func on press, optional: ":name/theme_type" -> get_theme_icon("name", "theme_type")
PANDEMONIUM_PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer)
PANDEMONIUM_PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags)
PANDEMONIUM_PROPERTY_HINT_LAYERS_2D_RENDER,
@ -90,7 +88,7 @@ typedef enum {
PANDEMONIUM_PROPERTY_HINT_NODE_PATH_VALID_TYPES,
PANDEMONIUM_PROPERTY_HINT_SAVE_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,". This opens a save dialog
PANDEMONIUM_PROPERTY_HINT_ENUM_SUGGESTION, ///< hint_text= "val1,val2,val3,etc"
PANDEMONIUM_PROPERTY_HINT_LOCALE_ID,
PANDEMONIUM_PROPERTY_HINT_LINK,
PANDEMONIUM_PROPERTY_HINT_MAX,
} pandemonium_property_hint;
@ -105,14 +103,21 @@ typedef enum {
PANDEMONIUM_PROPERTY_USAGE_INTERNATIONALIZED = 64, //hint for internationalized strings
PANDEMONIUM_PROPERTY_USAGE_GROUP = 128, //used for grouping props in the editor
PANDEMONIUM_PROPERTY_USAGE_CATEGORY = 256,
PANDEMONIUM_PROPERTY_USAGE_STORE_IF_NONZERO = 512, // FIXME: Obsolete: drop whenever we can break compat
PANDEMONIUM_PROPERTY_USAGE_STORE_IF_NONONE = 1024, // FIXME: Obsolete: drop whenever we can break compat
PANDEMONIUM_PROPERTY_USAGE_NO_INSTANCE_STATE = 2048,
PANDEMONIUM_PROPERTY_USAGE_RESTART_IF_CHANGED = 4096,
PANDEMONIUM_PROPERTY_USAGE_SCRIPT_VARIABLE = 8192,
PANDEMONIUM_PROPERTY_USAGE_STORE_IF_NULL = 16384,
PANDEMONIUM_PROPERTY_USAGE_ANIMATE_AS_TRIGGER = 32768,
PANDEMONIUM_PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED = 65536,
PANDEMONIUM_PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE = 1 << 17,
PANDEMONIUM_PROPERTY_USAGE_CLASS_IS_ENUM = 1 << 18,
PANDEMONIUM_PROPERTY_USAGE_NIL_IS_VARIANT = 1 << 19,
PANDEMONIUM_PROPERTY_USAGE_INTERNAL = 1 << 20,
PANDEMONIUM_PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE = 1 << 21, // If the object is duplicated also this property will be duplicated
PANDEMONIUM_PROPERTY_USAGE_HIGH_END_GFX = 1 << 22,
PANDEMONIUM_PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT = 1 << 23,
PANDEMONIUM_PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT = 1 << 24,
PANDEMONIUM_PROPERTY_USAGE_KEYING_INCREMENTS = 1 << 25, // Used in inspector to increment property when keyed in animation player
PANDEMONIUM_PROPERTY_USAGE_DEFAULT = PANDEMONIUM_PROPERTY_USAGE_STORAGE | PANDEMONIUM_PROPERTY_USAGE_EDITOR | PANDEMONIUM_PROPERTY_USAGE_NETWORK,
PANDEMONIUM_PROPERTY_USAGE_DEFAULT_INTL = PANDEMONIUM_PROPERTY_USAGE_STORAGE | PANDEMONIUM_PROPERTY_USAGE_EDITOR | PANDEMONIUM_PROPERTY_USAGE_NETWORK | PANDEMONIUM_PROPERTY_USAGE_INTERNATIONALIZED,
@ -197,14 +202,6 @@ void GDAPI pandemonium_nativescript_register_signal(void *p_gdnative_handle, con
void GDAPI *pandemonium_nativescript_get_userdata(pandemonium_object *p_instance);
/*
*
*
* NativeScript 1.1
*
*
*/
// method registering with argument names
typedef struct {

View File

@ -41,8 +41,8 @@ extern "C" {
// version info to detect whether a call is available
// Use these to populate version in your plugin
#define PANDEMONIUM_NET_API_MAJOR 3
#define PANDEMONIUM_NET_API_MINOR 1
#define PANDEMONIUM_NET_API_MAJOR 1
#define PANDEMONIUM_NET_API_MINOR 0
typedef struct {
pandemonium_gdnative_api_version version; /* version of our API */

View File

@ -57,9 +57,6 @@ typedef struct {
int p_argcount, pandemonium_variant_call_error *r_error);
void (*notification)(pandemonium_pluginscript_instance_data *p_data, int p_notification);
// TODO: could this rpc mode stuff be moved to the pandemonium_pluginscript_script_manifest ?
pandemonium_method_rpc_mode (*get_rpc_mode)(pandemonium_pluginscript_instance_data *p_data, const pandemonium_string *p_method);
pandemonium_method_rpc_mode (*get_rset_mode)(pandemonium_pluginscript_instance_data *p_data, const pandemonium_string *p_variable);
//this is used by script languages that keep a reference counter of their own
//you can make make Ref<> not die when it reaches zero, so deleting the reference

View File

@ -815,70 +815,6 @@ Ref<Script> NativeScriptInstance::get_script() const {
return script;
}
MultiplayerAPI::RPCMode NativeScriptInstance::get_rpc_mode(const StringName &p_method) const {
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
while (script_data) {
RBMap<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method);
if (E) {
switch (E->get().rpc_mode) {
case PANDEMONIUM_METHOD_RPC_MODE_DISABLED:
return MultiplayerAPI::RPC_MODE_DISABLED;
case PANDEMONIUM_METHOD_RPC_MODE_REMOTE:
return MultiplayerAPI::RPC_MODE_REMOTE;
case PANDEMONIUM_METHOD_RPC_MODE_MASTER:
return MultiplayerAPI::RPC_MODE_MASTER;
case PANDEMONIUM_METHOD_RPC_MODE_PUPPET:
return MultiplayerAPI::RPC_MODE_PUPPET;
case PANDEMONIUM_METHOD_RPC_MODE_REMOTESYNC:
return MultiplayerAPI::RPC_MODE_REMOTESYNC;
case PANDEMONIUM_METHOD_RPC_MODE_MASTERSYNC:
return MultiplayerAPI::RPC_MODE_MASTERSYNC;
case PANDEMONIUM_METHOD_RPC_MODE_PUPPETSYNC:
return MultiplayerAPI::RPC_MODE_PUPPETSYNC;
default:
return MultiplayerAPI::RPC_MODE_DISABLED;
}
}
script_data = script_data->base_data;
}
return MultiplayerAPI::RPC_MODE_DISABLED;
}
MultiplayerAPI::RPCMode NativeScriptInstance::get_rset_mode(const StringName &p_variable) const {
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
while (script_data) {
OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.find(p_variable);
if (E) {
switch (E.get().rset_mode) {
case PANDEMONIUM_METHOD_RPC_MODE_DISABLED:
return MultiplayerAPI::RPC_MODE_DISABLED;
case PANDEMONIUM_METHOD_RPC_MODE_REMOTE:
return MultiplayerAPI::RPC_MODE_REMOTE;
case PANDEMONIUM_METHOD_RPC_MODE_MASTER:
return MultiplayerAPI::RPC_MODE_MASTER;
case PANDEMONIUM_METHOD_RPC_MODE_PUPPET:
return MultiplayerAPI::RPC_MODE_PUPPET;
case PANDEMONIUM_METHOD_RPC_MODE_REMOTESYNC:
return MultiplayerAPI::RPC_MODE_REMOTESYNC;
case PANDEMONIUM_METHOD_RPC_MODE_MASTERSYNC:
return MultiplayerAPI::RPC_MODE_MASTERSYNC;
case PANDEMONIUM_METHOD_RPC_MODE_PUPPETSYNC:
return MultiplayerAPI::RPC_MODE_PUPPETSYNC;
default:
return MultiplayerAPI::RPC_MODE_DISABLED;
}
}
script_data = script_data->base_data;
}
return MultiplayerAPI::RPC_MODE_DISABLED;
}
ScriptLanguage *NativeScriptInstance::get_language() {
return NativeScriptLanguage::get_singleton();
}

View File

@ -209,8 +209,6 @@ public:
virtual void notification(int p_notification);
String to_string(bool *r_valid);
virtual Ref<Script> get_script() const;
virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
virtual ScriptLanguage *get_language();
virtual void call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount);

View File

@ -95,14 +95,6 @@ void PluginScriptInstance::notification(int p_notification) {
_desc->notification(_data, p_notification);
}
MultiplayerAPI::RPCMode PluginScriptInstance::get_rpc_mode(const StringName &p_method) const {
return _script->get_rpc_mode(p_method);
}
MultiplayerAPI::RPCMode PluginScriptInstance::get_rset_mode(const StringName &p_variable) const {
return _script->get_rset_mode(p_variable);
}
void PluginScriptInstance::refcount_incremented() {
if (_desc->refcount_decremented) {
_desc->refcount_incremented(_data);

View File

@ -73,10 +73,7 @@ public:
virtual Ref<Script> get_script() const;
virtual ScriptLanguage *get_language();
virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
virtual void refcount_incremented();
virtual bool refcount_decremented();

View File

@ -465,26 +465,6 @@ int PluginScript::get_member_line(const StringName &p_member) const {
return -1;
}
MultiplayerAPI::RPCMode PluginScript::get_rpc_mode(const StringName &p_method) const {
ASSERT_SCRIPT_VALID_V(MultiplayerAPI::RPC_MODE_DISABLED);
const RBMap<StringName, MultiplayerAPI::RPCMode>::Element *e = _methods_rpc_mode.find(p_method);
if (e != nullptr) {
return e->get();
} else {
return MultiplayerAPI::RPC_MODE_DISABLED;
}
}
MultiplayerAPI::RPCMode PluginScript::get_rset_mode(const StringName &p_variable) const {
ASSERT_SCRIPT_VALID_V(MultiplayerAPI::RPC_MODE_DISABLED);
const RBMap<StringName, MultiplayerAPI::RPCMode>::Element *e = _variables_rset_mode.find(p_variable);
if (e != nullptr) {
return e->get();
} else {
return MultiplayerAPI::RPC_MODE_DISABLED;
}
}
PluginScript::PluginScript() :
_data(nullptr),
_desc(nullptr),

View File

@ -119,9 +119,6 @@ public:
virtual int get_member_line(const StringName &p_member) const;
MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
PluginScript();
void init(PluginScriptLanguage *language);
virtual ~PluginScript();