mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Merge pull request #94047 from KoBeWi/resource_printer
Improve `to_string()` and add it to Resource
This commit is contained in:
commit
60710df3b6
13 changed files with 53 additions and 61 deletions
|
|
@ -277,7 +277,7 @@ String InputEventWithModifiers::as_text() const {
|
|||
}
|
||||
}
|
||||
|
||||
String InputEventWithModifiers::to_string() {
|
||||
String InputEventWithModifiers::_to_string() {
|
||||
return as_text();
|
||||
}
|
||||
|
||||
|
|
@ -488,7 +488,7 @@ String InputEventKey::as_text() const {
|
|||
return mods_text.is_empty() ? kc : mods_text + "+" + kc;
|
||||
}
|
||||
|
||||
String InputEventKey::to_string() {
|
||||
String InputEventKey::_to_string() {
|
||||
String p = is_pressed() ? "true" : "false";
|
||||
String e = is_echo() ? "true" : "false";
|
||||
|
||||
|
|
@ -848,7 +848,7 @@ String InputEventMouseButton::as_text() const {
|
|||
return full_string;
|
||||
}
|
||||
|
||||
String InputEventMouseButton::to_string() {
|
||||
String InputEventMouseButton::_to_string() {
|
||||
String p = is_pressed() ? "true" : "false";
|
||||
String canceled_state = is_canceled() ? "true" : "false";
|
||||
String d = double_click ? "true" : "false";
|
||||
|
|
@ -988,7 +988,7 @@ String InputEventMouseMotion::as_text() const {
|
|||
return vformat(RTR("Mouse motion at position (%s) with velocity (%s)"), String(get_position()), String(get_velocity()));
|
||||
}
|
||||
|
||||
String InputEventMouseMotion::to_string() {
|
||||
String InputEventMouseMotion::_to_string() {
|
||||
BitField<MouseButtonMask> mouse_button_mask = get_button_mask();
|
||||
String button_mask_string = itos((int64_t)mouse_button_mask);
|
||||
|
||||
|
|
@ -1184,7 +1184,7 @@ String InputEventJoypadMotion::as_text() const {
|
|||
return vformat(RTR("Joypad Motion on Axis %d (%s) with Value %.2f"), axis, desc, axis_value);
|
||||
}
|
||||
|
||||
String InputEventJoypadMotion::to_string() {
|
||||
String InputEventJoypadMotion::_to_string() {
|
||||
return vformat("InputEventJoypadMotion: axis=%d, axis_value=%.2f", axis, axis_value);
|
||||
}
|
||||
|
||||
|
|
@ -1303,7 +1303,7 @@ String InputEventJoypadButton::as_text() const {
|
|||
return text;
|
||||
}
|
||||
|
||||
String InputEventJoypadButton::to_string() {
|
||||
String InputEventJoypadButton::_to_string() {
|
||||
String p = is_pressed() ? "true" : "false";
|
||||
return vformat("InputEventJoypadButton: button_index=%d, pressed=%s, pressure=%.2f", button_index, p, pressure);
|
||||
}
|
||||
|
|
@ -1386,7 +1386,7 @@ String InputEventScreenTouch::as_text() const {
|
|||
return vformat(RTR("Screen %s at (%s) with %s touch points"), status, String(get_position()), itos(index));
|
||||
}
|
||||
|
||||
String InputEventScreenTouch::to_string() {
|
||||
String InputEventScreenTouch::_to_string() {
|
||||
String p = pressed ? "true" : "false";
|
||||
String canceled_state = canceled ? "true" : "false";
|
||||
String double_tap_string = double_tap ? "true" : "false";
|
||||
|
|
@ -1514,7 +1514,7 @@ String InputEventScreenDrag::as_text() const {
|
|||
return vformat(RTR("Screen dragged with %s touch points at position (%s) with velocity of (%s)"), itos(index), String(get_position()), String(get_velocity()));
|
||||
}
|
||||
|
||||
String InputEventScreenDrag::to_string() {
|
||||
String InputEventScreenDrag::_to_string() {
|
||||
return vformat("InputEventScreenDrag: index=%d, position=(%s), relative=(%s), velocity=(%s), pressure=%.2f, tilt=(%s), pen_inverted=(%s)", index, String(get_position()), String(get_relative()), String(get_velocity()), get_pressure(), String(get_tilt()), get_pen_inverted());
|
||||
}
|
||||
|
||||
|
|
@ -1656,7 +1656,7 @@ String InputEventAction::as_text() const {
|
|||
return String();
|
||||
}
|
||||
|
||||
String InputEventAction::to_string() {
|
||||
String InputEventAction::_to_string() {
|
||||
String p = is_pressed() ? "true" : "false";
|
||||
return vformat("InputEventAction: action=\"%s\", pressed=%s", action, p);
|
||||
}
|
||||
|
|
@ -1727,7 +1727,7 @@ String InputEventMagnifyGesture::as_text() const {
|
|||
return vformat(RTR("Magnify Gesture at (%s) with factor %s"), String(get_position()), rtos(get_factor()));
|
||||
}
|
||||
|
||||
String InputEventMagnifyGesture::to_string() {
|
||||
String InputEventMagnifyGesture::_to_string() {
|
||||
return vformat("InputEventMagnifyGesture: factor=%.2f, position=(%s)", factor, String(get_position()));
|
||||
}
|
||||
|
||||
|
|
@ -1769,7 +1769,7 @@ String InputEventPanGesture::as_text() const {
|
|||
return vformat(RTR("Pan Gesture at (%s) with delta (%s)"), String(get_position()), String(get_delta()));
|
||||
}
|
||||
|
||||
String InputEventPanGesture::to_string() {
|
||||
String InputEventPanGesture::_to_string() {
|
||||
return vformat("InputEventPanGesture: delta=(%s), position=(%s)", String(get_delta()), String(get_position()));
|
||||
}
|
||||
|
||||
|
|
@ -1850,7 +1850,7 @@ String InputEventMIDI::as_text() const {
|
|||
return vformat(RTR("MIDI Input on Channel=%s Message=%s"), itos(channel), itos((int64_t)message));
|
||||
}
|
||||
|
||||
String InputEventMIDI::to_string() {
|
||||
String InputEventMIDI::_to_string() {
|
||||
String ret;
|
||||
switch (message) {
|
||||
case MIDIMessage::NOTE_ON:
|
||||
|
|
@ -1926,7 +1926,7 @@ String InputEventShortcut::as_text() const {
|
|||
return vformat(RTR("Input Event with Shortcut=%s"), shortcut->get_as_text());
|
||||
}
|
||||
|
||||
String InputEventShortcut::to_string() {
|
||||
String InputEventShortcut::_to_string() {
|
||||
ERR_FAIL_COND_V(shortcut.is_null(), "None");
|
||||
|
||||
return vformat("InputEventShortcut: shortcut=%s", shortcut->get_as_text());
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ public:
|
|||
BitField<KeyModifierMask> get_modifiers_mask() const;
|
||||
|
||||
virtual String as_text() const override;
|
||||
virtual String to_string() override;
|
||||
virtual String _to_string() override;
|
||||
|
||||
InputEventWithModifiers() {}
|
||||
};
|
||||
|
|
@ -200,7 +200,7 @@ public:
|
|||
virtual String as_text_key_label() const;
|
||||
virtual String as_text_location() const;
|
||||
virtual String as_text() const override;
|
||||
virtual String to_string() override;
|
||||
virtual String _to_string() override;
|
||||
|
||||
static Ref<InputEventKey> create_reference(Key p_keycode_with_modifier_masks, bool p_physical = false);
|
||||
|
||||
|
|
@ -263,7 +263,7 @@ public:
|
|||
|
||||
virtual bool is_action_type() const override { return true; }
|
||||
virtual String as_text() const override;
|
||||
virtual String to_string() override;
|
||||
virtual String _to_string() override;
|
||||
|
||||
InputEventType get_type() const final override { return InputEventType::MOUSE_BUTTON; }
|
||||
|
||||
|
|
@ -308,7 +308,7 @@ public:
|
|||
|
||||
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const override;
|
||||
virtual String as_text() const override;
|
||||
virtual String to_string() override;
|
||||
virtual String _to_string() override;
|
||||
|
||||
virtual bool accumulate(const Ref<InputEvent> &p_event) override;
|
||||
|
||||
|
|
@ -337,7 +337,7 @@ public:
|
|||
|
||||
virtual bool is_action_type() const override { return true; }
|
||||
virtual String as_text() const override;
|
||||
virtual String to_string() override;
|
||||
virtual String _to_string() override;
|
||||
|
||||
// The default device ID is `InputMap::ALL_DEVICES`.
|
||||
static Ref<InputEventJoypadMotion> create_reference(JoyAxis p_axis, float p_value, int p_device = -1);
|
||||
|
|
@ -370,7 +370,7 @@ public:
|
|||
virtual bool is_action_type() const override { return true; }
|
||||
|
||||
virtual String as_text() const override;
|
||||
virtual String to_string() override;
|
||||
virtual String _to_string() override;
|
||||
|
||||
// The default device ID is `InputMap::ALL_DEVICES`.
|
||||
static Ref<InputEventJoypadButton> create_reference(JoyButton p_btn_index, int p_device = -1);
|
||||
|
|
@ -404,7 +404,7 @@ public:
|
|||
|
||||
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const override;
|
||||
virtual String as_text() const override;
|
||||
virtual String to_string() override;
|
||||
virtual String _to_string() override;
|
||||
|
||||
InputEventType get_type() const final override { return InputEventType::SCREEN_TOUCH; }
|
||||
|
||||
|
|
@ -456,7 +456,7 @@ public:
|
|||
|
||||
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const override;
|
||||
virtual String as_text() const override;
|
||||
virtual String to_string() override;
|
||||
virtual String _to_string() override;
|
||||
|
||||
virtual bool accumulate(const Ref<InputEvent> &p_event) override;
|
||||
|
||||
|
|
@ -495,7 +495,7 @@ public:
|
|||
virtual bool is_action_type() const override { return true; }
|
||||
|
||||
virtual String as_text() const override;
|
||||
virtual String to_string() override;
|
||||
virtual String _to_string() override;
|
||||
|
||||
InputEventType get_type() const final override { return InputEventType::ACTION; }
|
||||
|
||||
|
|
@ -528,7 +528,7 @@ public:
|
|||
|
||||
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const override;
|
||||
virtual String as_text() const override;
|
||||
virtual String to_string() override;
|
||||
virtual String _to_string() override;
|
||||
|
||||
InputEventType get_type() const final override { return InputEventType::MAGNIFY_GESTURE; }
|
||||
|
||||
|
|
@ -548,7 +548,7 @@ public:
|
|||
|
||||
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const override;
|
||||
virtual String as_text() const override;
|
||||
virtual String to_string() override;
|
||||
virtual String _to_string() override;
|
||||
|
||||
InputEventType get_type() const final override { return InputEventType::PAN_GESTURE; }
|
||||
|
||||
|
|
@ -596,7 +596,7 @@ public:
|
|||
int get_controller_value() const;
|
||||
|
||||
virtual String as_text() const override;
|
||||
virtual String to_string() override;
|
||||
virtual String _to_string() override;
|
||||
|
||||
InputEventType get_type() const final override { return InputEventType::MIDI; }
|
||||
|
||||
|
|
@ -616,7 +616,7 @@ public:
|
|||
Ref<Shortcut> get_shortcut();
|
||||
|
||||
virtual String as_text() const override;
|
||||
virtual String to_string() override;
|
||||
virtual String _to_string() override;
|
||||
|
||||
InputEventType get_type() const final override { return InputEventType::SHORTCUT; }
|
||||
|
||||
|
|
|
|||
|
|
@ -660,6 +660,10 @@ void Resource::reset_local_to_scene() {
|
|||
// Restores the state as if setup_local_to_scene() hadn't been called.
|
||||
}
|
||||
|
||||
String Resource::_to_string() {
|
||||
return (name.is_empty() ? "" : String(name) + " ") + "(" + path_cache + "):" + Object::_to_string();
|
||||
}
|
||||
|
||||
Node *(*Resource::_get_local_scene_func)() = nullptr;
|
||||
void (*Resource::_update_configuration_warning)() = nullptr;
|
||||
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ protected:
|
|||
GDVIRTUAL0(_reset_state);
|
||||
|
||||
virtual Ref<Resource> _duplicate(const DuplicateParams &p_params) const;
|
||||
virtual String _to_string() override;
|
||||
|
||||
public:
|
||||
static Node *(*_get_local_scene_func)(); // Used by the editor.
|
||||
|
|
|
|||
|
|
@ -1044,7 +1044,7 @@ String Object::to_string() {
|
|||
return ret;
|
||||
}
|
||||
}
|
||||
return "<" + get_class() + "#" + itos(get_instance_id()) + ">";
|
||||
return _to_string();
|
||||
}
|
||||
|
||||
void Object::set_script(const Variant &p_script) {
|
||||
|
|
@ -1839,6 +1839,10 @@ void Object::notify_property_list_changed() {
|
|||
emit_signal(CoreStringName(property_list_changed));
|
||||
}
|
||||
|
||||
String Object::_to_string() {
|
||||
return "<" + get_class() + "#" + itos(get_instance_id()) + ">";
|
||||
}
|
||||
|
||||
void Object::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_class"), &Object::get_class);
|
||||
ClassDB::bind_method(D_METHOD("is_class", "class"), &Object::is_class);
|
||||
|
|
|
|||
|
|
@ -738,6 +738,7 @@ protected:
|
|||
void _notification_backward(int p_notification);
|
||||
virtual void _notification_forwardv(int p_notification) {}
|
||||
virtual void _notification_backwardv(int p_notification) {}
|
||||
virtual String _to_string();
|
||||
|
||||
static void _bind_methods();
|
||||
static void _bind_compatibility_methods() {}
|
||||
|
|
@ -919,7 +920,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual String to_string();
|
||||
String to_string();
|
||||
|
||||
// Used mainly by script, get and set all INCLUDING string.
|
||||
virtual Variant getvar(const Variant &p_key, bool *r_valid = nullptr) const;
|
||||
|
|
|
|||
|
|
@ -84,5 +84,5 @@ public:
|
|||
Variant get_member_variable_value(int p_frame_index, int p_variable_index) const;
|
||||
|
||||
String format(int p_indent_all = 0, int p_indent_frames = 4) const;
|
||||
virtual String to_string() override { return format(); }
|
||||
virtual String _to_string() override { return format(); }
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue