mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Improve to_string() and add it to Resource
This commit is contained in:
parent
9a5d6d1049
commit
e6783dbdd1
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; }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue