You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-18 14:21:41 +00:00
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
This commit is contained in:
@@ -38,7 +38,6 @@ InputMap *InputMap::singleton = nullptr;
|
||||
int InputMap::ALL_DEVICES = -1;
|
||||
|
||||
void InputMap::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("has_action", "action"), &InputMap::has_action);
|
||||
ClassDB::bind_method(D_METHOD("get_actions"), &InputMap::_get_actions);
|
||||
ClassDB::bind_method(D_METHOD("add_action", "action", "deadzone"), &InputMap::add_action, DEFVAL(0.5f));
|
||||
@@ -55,7 +54,6 @@ void InputMap::_bind_methods() {
|
||||
}
|
||||
|
||||
void InputMap::add_action(const StringName &p_action, float p_deadzone) {
|
||||
|
||||
ERR_FAIL_COND_MSG(input_map.has(p_action), "InputMap already has action '" + String(p_action) + "'.");
|
||||
input_map[p_action] = Action();
|
||||
static int last_id = 1;
|
||||
@@ -65,20 +63,17 @@ void InputMap::add_action(const StringName &p_action, float p_deadzone) {
|
||||
}
|
||||
|
||||
void InputMap::erase_action(const StringName &p_action) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
|
||||
input_map.erase(p_action);
|
||||
}
|
||||
|
||||
Array InputMap::_get_actions() {
|
||||
|
||||
Array ret;
|
||||
List<StringName> actions = get_actions();
|
||||
if (actions.empty())
|
||||
return ret;
|
||||
|
||||
for (const List<StringName>::Element *E = actions.front(); E; E = E->next()) {
|
||||
|
||||
ret.push_back(E->get());
|
||||
}
|
||||
|
||||
@@ -86,7 +81,6 @@ Array InputMap::_get_actions() {
|
||||
}
|
||||
|
||||
List<StringName> InputMap::get_actions() const {
|
||||
|
||||
List<StringName> actions = List<StringName>();
|
||||
if (input_map.empty()) {
|
||||
return actions;
|
||||
@@ -100,9 +94,7 @@ List<StringName> InputMap::get_actions() const {
|
||||
}
|
||||
|
||||
List<Ref<InputEvent>>::Element *InputMap::_find_event(Action &p_action, const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength) const {
|
||||
|
||||
for (List<Ref<InputEvent>>::Element *E = p_action.inputs.front(); E; E = E->next()) {
|
||||
|
||||
const Ref<InputEvent> e = E->get();
|
||||
|
||||
//if (e.type != Ref<InputEvent>::KEY && e.device != p_event.device) -- unsure about the KEY comparison, why is this here?
|
||||
@@ -120,19 +112,16 @@ List<Ref<InputEvent>>::Element *InputMap::_find_event(Action &p_action, const Re
|
||||
}
|
||||
|
||||
bool InputMap::has_action(const StringName &p_action) const {
|
||||
|
||||
return input_map.has(p_action);
|
||||
}
|
||||
|
||||
void InputMap::action_set_deadzone(const StringName &p_action, float p_deadzone) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
|
||||
|
||||
input_map[p_action].deadzone = p_deadzone;
|
||||
}
|
||||
|
||||
void InputMap::action_add_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
|
||||
|
||||
ERR_FAIL_COND_MSG(p_event.is_null(), "It's not a reference to a valid InputEvent object.");
|
||||
ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
|
||||
if (_find_event(input_map[p_action], p_event))
|
||||
@@ -142,13 +131,11 @@ void InputMap::action_add_event(const StringName &p_action, const Ref<InputEvent
|
||||
}
|
||||
|
||||
bool InputMap::action_has_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!input_map.has(p_action), false, "Request for nonexistent InputMap action '" + String(p_action) + "'.");
|
||||
return (_find_event(input_map[p_action], p_event) != nullptr);
|
||||
}
|
||||
|
||||
void InputMap::action_erase_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
|
||||
|
||||
List<Ref<InputEvent>>::Element *E = _find_event(input_map[p_action], p_event);
|
||||
@@ -157,19 +144,16 @@ void InputMap::action_erase_event(const StringName &p_action, const Ref<InputEve
|
||||
}
|
||||
|
||||
void InputMap::action_erase_events(const StringName &p_action) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
|
||||
|
||||
input_map[p_action].inputs.clear();
|
||||
}
|
||||
|
||||
Array InputMap::_get_action_list(const StringName &p_action) {
|
||||
|
||||
Array ret;
|
||||
const List<Ref<InputEvent>> *al = get_action_list(p_action);
|
||||
if (al) {
|
||||
for (const List<Ref<InputEvent>>::Element *E = al->front(); E; E = E->next()) {
|
||||
|
||||
ret.push_back(E->get());
|
||||
}
|
||||
}
|
||||
@@ -178,7 +162,6 @@ Array InputMap::_get_action_list(const StringName &p_action) {
|
||||
}
|
||||
|
||||
const List<Ref<InputEvent>> *InputMap::get_action_list(const StringName &p_action) {
|
||||
|
||||
const Map<StringName, Action>::Element *E = input_map.find(p_action);
|
||||
if (!E)
|
||||
return nullptr;
|
||||
@@ -222,7 +205,6 @@ const Map<StringName, InputMap::Action> &InputMap::get_action_map() const {
|
||||
}
|
||||
|
||||
void InputMap::load_from_globals() {
|
||||
|
||||
input_map.clear();
|
||||
|
||||
List<PropertyInfo> pinfo;
|
||||
@@ -251,7 +233,6 @@ void InputMap::load_from_globals() {
|
||||
}
|
||||
|
||||
void InputMap::load_default() {
|
||||
|
||||
Ref<InputEventKey> key;
|
||||
|
||||
add_action("ui_accept");
|
||||
@@ -332,7 +313,6 @@ void InputMap::load_default() {
|
||||
}
|
||||
|
||||
InputMap::InputMap() {
|
||||
|
||||
ERR_FAIL_COND_MSG(singleton, "Singleton in InputMap already exist.");
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user