Merge pull request #315 from Sergwest585/main
small ide stuff + search controls
This commit is contained in:
commit
5ca83a572b
1
compile_flags.txt
Normal file
1
compile_flags.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
-Isrc
|
||||||
@ -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
|
||||||
```
|
```
|
||||||
|
|||||||
@ -4,7 +4,10 @@
|
|||||||
min='0.1' max='10' value='2' step='0.1'
|
min='0.1' max='10' value='2' step='0.1'
|
||||||
consumer='change_sensitivity'>
|
consumer='change_sensitivity'>
|
||||||
</trackbar>
|
</trackbar>
|
||||||
<panel id='bindings_panel' size='380,204' padding='2' interval='1' max-length='350' color='#0000004C'>
|
<panel id='search_panel' size='380,60' padding='2' interval='1' color='#0000004C'>
|
||||||
|
<textbox id='search_textbox' multiline='false' size='300,20' consumer='function(x) search_text=x refresh_search() end'></textbox>
|
||||||
|
</panel>
|
||||||
|
<panel id='bindings_panel' size='380,204' padding='2' interval='1' max-length='300' color='#0000004C'>
|
||||||
<!-- content is generated in script -->
|
<!-- content is generated in script -->
|
||||||
</panel>
|
</panel>
|
||||||
</panel>
|
</panel>
|
||||||
|
|||||||
@ -1,3 +1,32 @@
|
|||||||
|
|
||||||
|
function refresh_search()
|
||||||
|
local search_text = document.search_textbox.text
|
||||||
|
local search_key = document.search_key_checkbox.checked
|
||||||
|
|
||||||
|
local panel = document.bindings_panel
|
||||||
|
local bindings = input.get_bindings()
|
||||||
|
panel:clear()
|
||||||
|
|
||||||
|
table.sort(bindings, function(a, b) return a > b end)
|
||||||
|
if search_text ~= "" then
|
||||||
|
for i,name in ipairs(bindings) do
|
||||||
|
local _name = gui.str(name)
|
||||||
|
if ((_name:lower():find(search_text:lower()) and not search_key) or
|
||||||
|
(input.get_binding_text(name):lower():find(search_text:lower()) and search_key)) then
|
||||||
|
panel:add(gui.template("binding", {
|
||||||
|
id=name, name=_name
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for i,name in ipairs(bindings) do
|
||||||
|
panel:add(gui.template("binding", {
|
||||||
|
id=name, name=gui.str(name)
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function refresh_sensitivity()
|
function refresh_sensitivity()
|
||||||
document.sensitivity_label.text = string.format(
|
document.sensitivity_label.text = string.format(
|
||||||
"%s: %s",
|
"%s: %s",
|
||||||
@ -15,6 +44,11 @@ function on_open()
|
|||||||
document.sensitivity_track.value = core.get_setting("camera.sensitivity")
|
document.sensitivity_track.value = core.get_setting("camera.sensitivity")
|
||||||
refresh_sensitivity()
|
refresh_sensitivity()
|
||||||
|
|
||||||
|
document.search_panel:add(string.format(
|
||||||
|
"<checkbox size='20,20' id='search_key_checkbox' consumer='function(x) refresh_search() end' tooltip='%s'>%s</checkbox>",
|
||||||
|
gui.str("controls.key.tooltip", "settings"), gui.str("Key", "settings")
|
||||||
|
))
|
||||||
|
|
||||||
local panel = document.bindings_panel
|
local panel = document.bindings_panel
|
||||||
local bindings = input.get_bindings()
|
local bindings = input.get_bindings()
|
||||||
table.sort(bindings, function(a, b) return a > b end)
|
table.sort(bindings, function(a, b) return a > b end)
|
||||||
|
|||||||
@ -14,6 +14,7 @@ world.generators.flat=Flat
|
|||||||
# Tooltips
|
# Tooltips
|
||||||
graphics.gamma.tooltip=Lighting brightness curve
|
graphics.gamma.tooltip=Lighting brightness curve
|
||||||
graphics.backlight.tooltip=Backlight to prevent total darkness
|
graphics.backlight.tooltip=Backlight to prevent total darkness
|
||||||
|
controls.key.tooltip=Search by attached button name
|
||||||
|
|
||||||
# Bindings
|
# Bindings
|
||||||
chunks.reload=Reload Chunks
|
chunks.reload=Reload Chunks
|
||||||
|
|||||||
@ -20,6 +20,7 @@ pack.remove-confirm=Удалить весь поставляемый паком/
|
|||||||
# Подсказки
|
# Подсказки
|
||||||
graphics.gamma.tooltip=Кривая яркости освещения
|
graphics.gamma.tooltip=Кривая яркости освещения
|
||||||
graphics.backlight.tooltip=Подсветка, предотвращающая полную темноту
|
graphics.backlight.tooltip=Подсветка, предотвращающая полную темноту
|
||||||
|
controls.key.tooltip=Поиск по привязвнной кнопки управления
|
||||||
|
|
||||||
# Меню
|
# Меню
|
||||||
menu.Apply=Применить
|
menu.Apply=Применить
|
||||||
@ -70,6 +71,7 @@ settings.Music=Музыка
|
|||||||
settings.Regular Sounds=Обычные Звуки
|
settings.Regular Sounds=Обычные Звуки
|
||||||
settings.UI Sounds=Звуки Интерфейса
|
settings.UI Sounds=Звуки Интерфейса
|
||||||
settings.V-Sync=Вертикальная Синхронизация
|
settings.V-Sync=Вертикальная Синхронизация
|
||||||
|
settings.Key=Кнопка
|
||||||
|
|
||||||
# Управление
|
# Управление
|
||||||
chunks.reload=Перезагрузить Чанки
|
chunks.reload=Перезагрузить Чанки
|
||||||
|
|||||||
2
run.sh
2
run.sh
@ -1,6 +1,6 @@
|
|||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||||
cmake --build . -j 16
|
cmake --build . -j$(nproc)
|
||||||
cd ..
|
cd ..
|
||||||
build/VoxelEngine
|
build/VoxelEngine
|
||||||
|
|||||||
@ -79,6 +79,7 @@ struct ContentPack {
|
|||||||
case ContentType::ENTITY: return ContentPack::ENTITIES_FOLDER;
|
case ContentType::ENTITY: return ContentPack::ENTITIES_FOLDER;
|
||||||
case ContentType::GENERATOR: return ContentPack::GENERATORS_FOLDER;
|
case ContentType::GENERATOR: return ContentPack::GENERATORS_FOLDER;
|
||||||
case ContentType::NONE: return fs::u8path("");
|
case ContentType::NONE: return fs::u8path("");
|
||||||
|
default: return fs::u8path("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -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