Reverse Camera2D.rotating
to ignore_rotation
`rotating` is misleading, as Camera2D is affected by `rotation` and `global_rotation` like any other Node2D Updates description in the docs, as well.
This commit is contained in:
parent
658bfb0395
commit
ee16de583f
4 changed files with 54 additions and 15 deletions
|
@ -124,6 +124,9 @@
|
|||
<member name="editor_draw_screen" type="bool" setter="set_screen_drawing_enabled" getter="is_screen_drawing_enabled" default="true">
|
||||
If [code]true[/code], draws the camera's screen rectangle in the editor.
|
||||
</member>
|
||||
<member name="ignore_rotation" type="bool" setter="set_ignore_rotation" getter="is_ignoring_rotation" default="true">
|
||||
If [code]true[/code], the camera's rendered view is not affected by its [member Node2D.rotation] and [member Node2D.global_rotation].
|
||||
</member>
|
||||
<member name="limit_bottom" type="int" setter="set_limit" getter="get_limit" default="10000000">
|
||||
Bottom scroll limit in pixels. The camera stops moving when reaching this value, but [member offset] can push the view past the limit.
|
||||
</member>
|
||||
|
@ -147,9 +150,6 @@
|
|||
<member name="process_callback" type="int" setter="set_process_callback" getter="get_process_callback" enum="Camera2D.Camera2DProcessCallback" default="1">
|
||||
The camera's process callback. See [enum Camera2DProcessCallback].
|
||||
</member>
|
||||
<member name="rotating" type="bool" setter="set_rotating" getter="is_rotating" default="false">
|
||||
If [code]true[/code], the camera view rotates with the target.
|
||||
</member>
|
||||
<member name="smoothing_enabled" type="bool" setter="set_enable_follow_smoothing" getter="is_follow_smoothing_enabled" default="false">
|
||||
If [code]true[/code], the camera smoothly moves towards the target at [member smoothing_speed].
|
||||
</member>
|
||||
|
|
|
@ -419,6 +419,7 @@ static const char *gdscript_function_renames[][2] = {
|
|||
{ "is_normalmap", "is_normal_map" }, // NoiseTexture
|
||||
{ "is_refusing_new_network_connections", "is_refusing_new_connections" }, // Multiplayer API
|
||||
{ "is_region", "is_region_enabled" }, // Sprite2D
|
||||
{ "is_rotating", "is_ignoring_rotation" }, // Camera2D
|
||||
{ "is_scancode_unicode", "is_keycode_unicode" }, // OS
|
||||
{ "is_selectable_when_hidden", "_is_selectable_when_hidden" }, // EditorNode3DGizmoPlugin
|
||||
{ "is_set_as_toplevel", "is_set_as_top_level" }, // CanvasItem
|
||||
|
@ -841,6 +842,7 @@ static const char *csharp_function_renames[][2] = {
|
|||
{ "IsNormalmap", "IsNormalMap" }, // NoiseTexture
|
||||
{ "IsRefusingNewNetworkConnections", "IsRefusingNewConnections" }, // Multiplayer API
|
||||
{ "IsRegion", "IsRegionEnabled" }, // Sprite2D
|
||||
{ "IsRotating", "IsIgnoringRotation" }, // Camera2D
|
||||
{ "IsScancodeUnicode", "IsKeycodeUnicode" }, // OS
|
||||
{ "IsSelectableWhenHidden", "_IsSelectableWhenHidden" }, // EditorNode3DGizmoPlugin
|
||||
{ "IsSetAsToplevel", "IsSetAsTopLevel" }, // CanvasItem
|
||||
|
@ -3492,6 +3494,20 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set_rotating(true) -> set_ignore_rotation(false)
|
||||
if (line.contains("set_rotating(")) {
|
||||
int start = line.find("set_rotating(");
|
||||
int end = get_end_parenthesis(line.substr(start)) + 1;
|
||||
if (end > -1) {
|
||||
Vector<String> parts = parse_arguments(line.substr(start, end));
|
||||
if (parts.size() == 1) {
|
||||
String opposite = parts[0] == "true" ? "false" : "true";
|
||||
line = line.substr(0, start) + "set_ignore_rotation(" + opposite + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// OS.get_window_safe_area() -> DisplayServer.get_display_safe_area()
|
||||
if (line.contains("OS.get_window_safe_area(")) {
|
||||
int start = line.find("OS.get_window_safe_area(");
|
||||
|
@ -3539,6 +3555,29 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|||
}
|
||||
}
|
||||
|
||||
// rotating = true -> ignore_rotation = false # reversed "rotating" for Camera2D
|
||||
if (line.contains("rotating")) {
|
||||
int start = line.find("rotating");
|
||||
bool foundNextEqual = false;
|
||||
String line_to_check = line.substr(start + String("rotating").length());
|
||||
String assigned_value;
|
||||
for (int current_index = 0; line_to_check.length() > current_index; current_index++) {
|
||||
char32_t chr = line_to_check.get(current_index);
|
||||
if (chr == '\t' || chr == ' ') {
|
||||
continue;
|
||||
} else if (chr == '=') {
|
||||
foundNextEqual = true;
|
||||
assigned_value = line.right(current_index).strip_edges();
|
||||
assigned_value = assigned_value == "true" ? "false" : "true";
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundNextEqual) {
|
||||
line = line.substr(0, start) + "ignore_rotation =" + assigned_value + " # reversed \"rotating\" for Camera2D";
|
||||
}
|
||||
}
|
||||
|
||||
// OS -> Time functions
|
||||
if (line.contains("OS.get_ticks_msec")) {
|
||||
line = line.replace("OS.get_ticks_msec", "Time.get_ticks_msec");
|
||||
|
|
|
@ -172,7 +172,7 @@ Transform2D Camera2D::get_camera_transform() {
|
|||
Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5 * zoom_scale) : Point2());
|
||||
|
||||
real_t angle = get_global_rotation();
|
||||
if (rotating) {
|
||||
if (!ignore_rotation) {
|
||||
screen_offset = screen_offset.rotated(angle);
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ Transform2D Camera2D::get_camera_transform() {
|
|||
|
||||
Transform2D xform;
|
||||
xform.scale_basis(zoom_scale);
|
||||
if (rotating) {
|
||||
if (!ignore_rotation) {
|
||||
xform.set_rotation(angle);
|
||||
}
|
||||
xform.set_origin(screen_rect.position);
|
||||
|
@ -363,15 +363,15 @@ Camera2D::AnchorMode Camera2D::get_anchor_mode() const {
|
|||
return anchor_mode;
|
||||
}
|
||||
|
||||
void Camera2D::set_rotating(bool p_rotating) {
|
||||
rotating = p_rotating;
|
||||
void Camera2D::set_ignore_rotation(bool p_ignore) {
|
||||
ignore_rotation = p_ignore;
|
||||
Point2 old_smoothed_camera_pos = smoothed_camera_pos;
|
||||
_update_scroll();
|
||||
smoothed_camera_pos = old_smoothed_camera_pos;
|
||||
}
|
||||
|
||||
bool Camera2D::is_rotating() const {
|
||||
return rotating;
|
||||
bool Camera2D::is_ignoring_rotation() const {
|
||||
return ignore_rotation;
|
||||
}
|
||||
|
||||
void Camera2D::set_process_callback(Camera2DProcessCallback p_mode) {
|
||||
|
@ -668,8 +668,8 @@ void Camera2D::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_anchor_mode", "anchor_mode"), &Camera2D::set_anchor_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_anchor_mode"), &Camera2D::get_anchor_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_rotating", "rotating"), &Camera2D::set_rotating);
|
||||
ClassDB::bind_method(D_METHOD("is_rotating"), &Camera2D::is_rotating);
|
||||
ClassDB::bind_method(D_METHOD("set_ignore_rotation", "ignore"), &Camera2D::set_ignore_rotation);
|
||||
ClassDB::bind_method(D_METHOD("is_ignoring_rotation"), &Camera2D::is_ignoring_rotation);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_update_scroll"), &Camera2D::_update_scroll);
|
||||
|
||||
|
@ -733,7 +733,7 @@ void Camera2D::_bind_methods() {
|
|||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset", PROPERTY_HINT_NONE, "suffix:px"), "set_offset", "get_offset");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "anchor_mode", PROPERTY_HINT_ENUM, "Fixed TopLeft,Drag Center"), "set_anchor_mode", "get_anchor_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "rotating"), "set_rotating", "is_rotating");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ignore_rotation"), "set_ignore_rotation", "is_ignoring_rotation");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "current"), "set_current", "is_current");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "zoom", PROPERTY_HINT_LINK), "set_zoom", "get_zoom");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_viewport", PROPERTY_HINT_RESOURCE_TYPE, "Viewport", PROPERTY_USAGE_NONE), "set_custom_viewport", "get_custom_viewport");
|
||||
|
|
|
@ -63,7 +63,7 @@ protected:
|
|||
Vector2 zoom = Vector2(1, 1);
|
||||
Vector2 zoom_scale = Vector2(1, 1);
|
||||
AnchorMode anchor_mode = ANCHOR_MODE_DRAG_CENTER;
|
||||
bool rotating = false;
|
||||
bool ignore_rotation = true;
|
||||
bool current = false;
|
||||
real_t smoothing = 5.0;
|
||||
bool smoothing_enabled = false;
|
||||
|
@ -109,8 +109,8 @@ public:
|
|||
void set_anchor_mode(AnchorMode p_anchor_mode);
|
||||
AnchorMode get_anchor_mode() const;
|
||||
|
||||
void set_rotating(bool p_rotating);
|
||||
bool is_rotating() const;
|
||||
void set_ignore_rotation(bool p_ignore);
|
||||
bool is_ignoring_rotation() const;
|
||||
|
||||
void set_limit(Side p_side, int p_limit);
|
||||
int get_limit(Side p_side) const;
|
||||
|
|
Loading…
Reference in a new issue