add get_binding_text() for script api
This commit is contained in:
parent
9628068faf
commit
67f7006ad0
@ -60,6 +60,12 @@ input.get_bindings() -> strings array
|
|||||||
|
|
||||||
Returns all binding names.
|
Returns all binding names.
|
||||||
|
|
||||||
|
```python
|
||||||
|
input.get_binding_text(bindname: str) -> str
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns text representation of button by binding name.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
input.is_pressed(code: str) -> bool
|
input.is_pressed(code: str) -> bool
|
||||||
```
|
```
|
||||||
|
|||||||
@ -58,6 +58,12 @@ input.get_bindings() -> массив строк
|
|||||||
|
|
||||||
Возвращает названия всех доступных привязок.
|
Возвращает названия всех доступных привязок.
|
||||||
|
|
||||||
|
```python
|
||||||
|
input.get_binding_text(bindname: str) -> str
|
||||||
|
```
|
||||||
|
|
||||||
|
Возвращает текстовое представление кнопки по имени привязки.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
input.is_active(bindname: str) -> bool
|
input.is_active(bindname: str) -> bool
|
||||||
```
|
```
|
||||||
|
|||||||
@ -64,6 +64,20 @@ static int l_get_bindings(lua::State* L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_get_binding_text(lua::State* L) {
|
||||||
|
auto bindname = lua::require_string(L, 1);
|
||||||
|
auto index = Events::bindings.find(bindname);
|
||||||
|
|
||||||
|
if (index == Events::bindings.end()) {
|
||||||
|
throw std::runtime_error("unknown binding " + util::quote(bindname));
|
||||||
|
lua::pushstring(L, "");
|
||||||
|
} else {
|
||||||
|
lua::pushstring(L, index->second.text());
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int l_is_active(lua::State* L) {
|
static int l_is_active(lua::State* L) {
|
||||||
auto bindname = lua::require_string(L, 1);
|
auto bindname = lua::require_string(L, 1);
|
||||||
const auto& bind = Events::bindings.find(bindname);
|
const auto& bind = Events::bindings.find(bindname);
|
||||||
@ -101,6 +115,7 @@ const luaL_Reg inputlib[] = {
|
|||||||
{"add_callback", lua::wrap<l_add_callback>},
|
{"add_callback", lua::wrap<l_add_callback>},
|
||||||
{"get_mouse_pos", lua::wrap<l_get_mouse_pos>},
|
{"get_mouse_pos", lua::wrap<l_get_mouse_pos>},
|
||||||
{"get_bindings", lua::wrap<l_get_bindings>},
|
{"get_bindings", lua::wrap<l_get_bindings>},
|
||||||
|
{"get_binding_text", lua::wrap<l_get_binding_text>},
|
||||||
{"is_active", lua::wrap<l_is_active>},
|
{"is_active", lua::wrap<l_is_active>},
|
||||||
{"is_pressed", lua::wrap<l_is_pressed>},
|
{"is_pressed", lua::wrap<l_is_pressed>},
|
||||||
{NULL, NULL}};
|
{NULL, NULL}};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user