Skip to content

Commit

Permalink
Add editor hints to HullData
Browse files Browse the repository at this point in the history
  • Loading branch information
indubitablement2 committed Apr 18, 2024
1 parent cf3e67d commit 8e1b698
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
17 changes: 10 additions & 7 deletions godot_custom/hull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@
const f32 DT = 0.1;

void HullData::_bind_methods() {
DATA_PROP_BIND(linear_acceleration);
DATA_PROP_BIND(linear_velocity_max);
DATA_PROP_BIND(angular_acceleration);
DATA_PROP_BIND(angular_velocity_max);
DATA_PROP_BIND(linear_acceleration, "0,1000,or_greater,suffix:p/s²");
DATA_PROP_BIND(linear_velocity_max, "0,1000,or_greater,suffix:p/s");
DATA_PROP_BIND(angular_acceleration, "0,100,or_greater,suffix:rad/s²");
DATA_PROP_BIND(angular_velocity_max, "0,100,or_greater,suffix:rad/s");

SET_GET_BIND(armor_cells_max, PackedByteArray, HullData);
SET_GET_BIND(num_turrets, i32, HullData);
ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "armor_cells_max"), "set_armor_cells_max", "get_armor_cells_max");
DATA_PROP_BIND(armor_max);
DATA_PROP_BIND(hull_max);
DATA_PROP_BIND(armor_max, "");
DATA_PROP_BIND(hull_max, "");

SET_GET_BIND(num_turrets, i32, HullData);
ADD_PROPERTY(PropertyInfo(Variant::INT, "num_turrets"), "set_num_turrets", "get_num_turrets");
}

SET_GET_IMPL(armor_cells_max, PackedByteArray, HullData);
Expand Down
5 changes: 3 additions & 2 deletions godot_custom/hull.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@
void set_##name(f32 value); \
f32 get_##name() const;

#define DATA_PROP_BIND(name) \
// "min,max[,step][,or_greater][,or_less][,hide_slider][,radians_as_degrees][,degrees][,exp][,suffix:<keyword>]"
#define DATA_PROP_BIND(name, hint) \
ClassDB::bind_method(D_METHOD(STRINGIFY(set_##name), "value"), &HullData::set_##name); \
ClassDB::bind_method(D_METHOD(STRINGIFY(get_##name)), &HullData::get_##name); \
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, #name), STRINGIFY(set_##name), STRINGIFY(get_##name));
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, #name, PROPERTY_HINT_RANGE, hint), STRINGIFY(set_##name), STRINGIFY(get_##name));

#define DATA_PROP_IMPL(name) \
void HullData::set_##name(f32 value) { \
Expand Down
1 change: 0 additions & 1 deletion simulation/node_2d.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func _physics_process(delta: float) -> void:
[node name="Hull" type="Hull" parent="."]
position = Vector2(57, 68)
angular_velocity = 12.5664
data = SubResource("HullData_313hc")
wish_linear_velocity_type = 1
wish_linear_velocity = Vector2(100, 0)
Expand Down

0 comments on commit 8e1b698

Please sign in to comment.