add console on_open 'mode' argument
This commit is contained in:
parent
e80b10dbda
commit
78ea12aa26
@ -194,7 +194,7 @@ function set_mode(mode)
|
|||||||
console_mode = mode
|
console_mode = mode
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_open()
|
function on_open(mode)
|
||||||
if modes == nil then
|
if modes == nil then
|
||||||
modes = RadioGroup({
|
modes = RadioGroup({
|
||||||
chat=document.s_chat,
|
chat=document.s_chat,
|
||||||
@ -204,4 +204,7 @@ function on_open()
|
|||||||
set_mode(mode)
|
set_mode(mode)
|
||||||
end, "console")
|
end, "console")
|
||||||
end
|
end
|
||||||
|
if mode then
|
||||||
|
modes:set(mode)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -86,6 +86,9 @@ end
|
|||||||
|
|
||||||
local _RadioGroup = {}
|
local _RadioGroup = {}
|
||||||
function _RadioGroup.set(self, key)
|
function _RadioGroup.set(self, key)
|
||||||
|
if type(self) ~= 'table' then
|
||||||
|
error("called as non-OOP via '.', use radiogroup:set")
|
||||||
|
end
|
||||||
if self.current then
|
if self.current then
|
||||||
self.elements[self.current].enabled = true
|
self.elements[self.current].enabled = true
|
||||||
end
|
end
|
||||||
|
|||||||
@ -230,7 +230,11 @@ void Hud::processInput(bool visible) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!pause && Events::jactive(BIND_DEVTOOLS_CONSOLE)) {
|
if (!pause && Events::jactive(BIND_DEVTOOLS_CONSOLE)) {
|
||||||
showOverlay(assets->get<UiDocument>("core:console"), false);
|
showOverlay(
|
||||||
|
assets->get<UiDocument>("core:console"),
|
||||||
|
false,
|
||||||
|
std::string("console")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (!Window::isFocused() && !pause && !isInventoryOpen()) {
|
if (!Window::isFocused() && !pause && !isInventoryOpen()) {
|
||||||
setPause(true);
|
setPause(true);
|
||||||
@ -465,7 +469,9 @@ void Hud::showExchangeSlot() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hud::showOverlay(UiDocument* doc, bool playerInventory) {
|
void Hud::showOverlay(
|
||||||
|
UiDocument* doc, bool playerInventory, const dv::value& arg
|
||||||
|
) {
|
||||||
if (isInventoryOpen()) {
|
if (isInventoryOpen()) {
|
||||||
closeInventory();
|
closeInventory();
|
||||||
}
|
}
|
||||||
@ -476,7 +482,8 @@ void Hud::showOverlay(UiDocument* doc, bool playerInventory) {
|
|||||||
showExchangeSlot();
|
showExchangeSlot();
|
||||||
inventoryOpen = true;
|
inventoryOpen = true;
|
||||||
}
|
}
|
||||||
add(HudElement(hud_element_mode::inventory_bound, doc, secondUI, false));
|
add(HudElement(hud_element_mode::inventory_bound, doc, secondUI, false),
|
||||||
|
arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hud::openPermanent(UiDocument* doc) {
|
void Hud::openPermanent(UiDocument* doc) {
|
||||||
@ -508,13 +515,13 @@ void Hud::closeInventory() {
|
|||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hud::add(const HudElement& element) {
|
void Hud::add(const HudElement& element, const dv::value& arg) {
|
||||||
gui->add(element.getNode());
|
gui->add(element.getNode());
|
||||||
auto document = element.getDocument();
|
auto document = element.getDocument();
|
||||||
if (document) {
|
if (document) {
|
||||||
auto invview = std::dynamic_pointer_cast<InventoryView>(element.getNode());
|
auto invview = std::dynamic_pointer_cast<InventoryView>(element.getNode());
|
||||||
auto inventory = invview ? invview->getInventory() : nullptr;
|
auto inventory = invview ? invview->getInventory() : nullptr;
|
||||||
std::vector<dv::value> args;
|
std::vector<dv::value> args {arg};
|
||||||
args.emplace_back(inventory ? inventory.get()->getId() : 0);
|
args.emplace_back(inventory ? inventory.get()->getId() : 0);
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
args.emplace_back(static_cast<integer_t>(blockPos[i]));
|
args.emplace_back(static_cast<integer_t>(blockPos[i]));
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "typedefs.hpp"
|
#include "typedefs.hpp"
|
||||||
#include "util/ObjectsKeeper.hpp"
|
#include "util/ObjectsKeeper.hpp"
|
||||||
|
#include "data/dv.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -173,7 +174,10 @@ public:
|
|||||||
/// @brief Show element in inventory-mode
|
/// @brief Show element in inventory-mode
|
||||||
/// @param doc element layout
|
/// @param doc element layout
|
||||||
/// @param playerInventory show player inventory too
|
/// @param playerInventory show player inventory too
|
||||||
void showOverlay(UiDocument* doc, bool playerInventory);
|
/// @param arg first argument passing to on_open
|
||||||
|
void showOverlay(
|
||||||
|
UiDocument* doc, bool playerInventory, const dv::value& arg = nullptr
|
||||||
|
);
|
||||||
|
|
||||||
/// @brief Close all open inventories and overlay
|
/// @brief Close all open inventories and overlay
|
||||||
void closeInventory();
|
void closeInventory();
|
||||||
@ -182,7 +186,7 @@ public:
|
|||||||
/// @param doc element layout
|
/// @param doc element layout
|
||||||
void openPermanent(UiDocument* doc);
|
void openPermanent(UiDocument* doc);
|
||||||
|
|
||||||
void add(const HudElement& element);
|
void add(const HudElement& element, const dv::value& arg=nullptr);
|
||||||
void onRemove(const HudElement& element);
|
void onRemove(const HudElement& element);
|
||||||
void remove(const std::shared_ptr<gui::UINode>& node);
|
void remove(const std::shared_ptr<gui::UINode>& node);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user