quick check with linters
This commit is contained in:
@@ -44,10 +44,8 @@ void GUI::onAssetsLoad(Assets* assets) {
|
||||
), "core:root");
|
||||
}
|
||||
|
||||
/** Mouse related input and logic handling
|
||||
* @param delta delta time
|
||||
*/
|
||||
void GUI::actMouse(float delta) {
|
||||
// @brief Mouse related input and logic handling
|
||||
void GUI::actMouse() {
|
||||
auto hover = container->getAt(Events::cursor, nullptr);
|
||||
if (this->hover && this->hover != hover) {
|
||||
this->hover->setHover(false);
|
||||
@@ -125,7 +123,7 @@ void GUI::act(float delta, const Viewport& vp) {
|
||||
auto prevfocus = focus;
|
||||
|
||||
if (!Events::_cursor_locked) {
|
||||
actMouse(delta);
|
||||
actMouse();
|
||||
}
|
||||
|
||||
if (focus) {
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace gui {
|
||||
std::unique_ptr<Camera> uicamera;
|
||||
std::shared_ptr<Menu> menu;
|
||||
std::queue<runnable> postRunnables;
|
||||
void actMouse(float delta);
|
||||
void actMouse();
|
||||
void actFocused();
|
||||
public:
|
||||
GUI();
|
||||
|
||||
@@ -75,7 +75,7 @@ void Button::refresh() {
|
||||
}
|
||||
}
|
||||
|
||||
void Button::drawBackground(const DrawContext* pctx, Assets* assets) {
|
||||
void Button::drawBackground(const DrawContext* pctx, Assets*) {
|
||||
glm::vec2 pos = calcPos();
|
||||
auto batch = pctx->getBatch2D();
|
||||
batch->texture(nullptr);
|
||||
|
||||
@@ -10,7 +10,7 @@ CheckBox::CheckBox(bool checked) : UINode(glm::vec2(32.0f)), checked(checked) {
|
||||
setColor(glm::vec4(0.0f, 0.0f, 0.0f, 0.5f));
|
||||
}
|
||||
|
||||
void CheckBox::draw(const DrawContext* pctx, Assets* assets) {
|
||||
void CheckBox::draw(const DrawContext* pctx, Assets*) {
|
||||
if (supplier) {
|
||||
checked = supplier();
|
||||
}
|
||||
@@ -21,7 +21,7 @@ void CheckBox::draw(const DrawContext* pctx, Assets* assets) {
|
||||
batch->rect(pos.x, pos.y, size.x, size.y);
|
||||
}
|
||||
|
||||
void CheckBox::mouseRelease(GUI*, int x, int y) {
|
||||
void CheckBox::mouseRelease(GUI*, int, int) {
|
||||
checked = !checked;
|
||||
if (consumer) {
|
||||
consumer(checked);
|
||||
|
||||
@@ -93,7 +93,7 @@ void Container::draw(const DrawContext* pctx, Assets* assets) {
|
||||
}
|
||||
}
|
||||
|
||||
void Container::drawBackground(const DrawContext* pctx, Assets* assets) {
|
||||
void Container::drawBackground(const DrawContext* pctx, Assets*) {
|
||||
glm::vec4 color = calcColor();
|
||||
if (color.a <= 0.001f)
|
||||
return;
|
||||
|
||||
@@ -15,7 +15,7 @@ InputBindBox::InputBindBox(Binding& binding, glm::vec4 padding)
|
||||
setScrollable(false);
|
||||
}
|
||||
|
||||
void InputBindBox::drawBackground(const DrawContext* pctx, Assets* assets) {
|
||||
void InputBindBox::drawBackground(const DrawContext* pctx, Assets*) {
|
||||
glm::vec2 pos = calcPos();
|
||||
auto batch = pctx->getBatch2D();
|
||||
batch->texture(nullptr);
|
||||
|
||||
@@ -116,7 +116,7 @@ void SlotView::draw(const DrawContext* pctx, Assets* assets) {
|
||||
|
||||
const int slotSize = InventoryView::SLOT_SIZE;
|
||||
|
||||
ItemStack& stack = *bound;
|
||||
const ItemStack& stack = *bound;
|
||||
glm::vec4 tint(1.0f);
|
||||
glm::vec2 pos = calcPos();
|
||||
glm::vec4 color = getColor();
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace gui {
|
||||
};
|
||||
|
||||
class SlotView : public gui::UINode {
|
||||
const Content* content;
|
||||
const Content* content = nullptr;
|
||||
SlotLayout layout;
|
||||
bool highlighted = false;
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace gui {
|
||||
};
|
||||
|
||||
class InventoryView : public gui::Container {
|
||||
const Content* content;
|
||||
const Content* content = nullptr;
|
||||
|
||||
std::shared_ptr<Inventory> inventory;
|
||||
|
||||
|
||||
@@ -26,8 +26,9 @@ void LabelCache::update(const std::wstring& text, bool multiline, bool wrap) {
|
||||
if (font == nullptr) {
|
||||
wrap = false;
|
||||
}
|
||||
size_t len = 0;
|
||||
|
||||
if (multiline) {
|
||||
size_t len = 0;
|
||||
for (size_t i = 0; i < text.length(); i++, len++) {
|
||||
if (text[i] == L'\n') {
|
||||
lines.push_back(LineScheme {i+1, false});
|
||||
|
||||
@@ -56,13 +56,12 @@ void TextBox::draw(const DrawContext* pctx, Assets* assets) {
|
||||
batch->setColor(glm::vec4(0.8f, 0.9f, 1.0f, 0.25f));
|
||||
int start = font->calcWidth(input, selectionStart-label->getTextLineOffset(startLine));
|
||||
int end = font->calcWidth(input, selectionEnd-label->getTextLineOffset(endLine));
|
||||
int startY = label->getLineYOffset(startLine);
|
||||
int endY = label->getLineYOffset(startLine);
|
||||
int lineY = label->getLineYOffset(startLine);
|
||||
|
||||
if (startLine == endLine) {
|
||||
batch->rect(lcoord.x + start, lcoord.y+startY, end-start, lineHeight);
|
||||
batch->rect(lcoord.x + start, lcoord.y+lineY, end-start, lineHeight);
|
||||
} else {
|
||||
batch->rect(lcoord.x + start, lcoord.y+endY, label->getSize().x-start-padding.z-padding.x-2, lineHeight);
|
||||
batch->rect(lcoord.x + start, lcoord.y+lineY, label->getSize().x-start-padding.z-padding.x-2, lineHeight);
|
||||
for (uint i = startLine+1; i < endLine; i++) {
|
||||
batch->rect(lcoord.x, lcoord.y+label->getLineYOffset(i), label->getSize().x-padding.z-padding.x-2, lineHeight);
|
||||
}
|
||||
@@ -71,7 +70,7 @@ void TextBox::draw(const DrawContext* pctx, Assets* assets) {
|
||||
}
|
||||
}
|
||||
|
||||
void TextBox::drawBackground(const DrawContext* pctx, Assets* assets) {
|
||||
void TextBox::drawBackground(const DrawContext* pctx, Assets*) {
|
||||
glm::vec2 pos = calcPos();
|
||||
|
||||
auto batch = pctx->getBatch2D();
|
||||
|
||||
@@ -23,7 +23,7 @@ TrackBar::TrackBar(
|
||||
setHoverColor(glm::vec4(0.01f, 0.02f, 0.03f, 0.5f));
|
||||
}
|
||||
|
||||
void TrackBar::draw(const DrawContext* pctx, Assets* assets) {
|
||||
void TrackBar::draw(const DrawContext* pctx, Assets*) {
|
||||
if (supplier) {
|
||||
value = supplier();
|
||||
}
|
||||
@@ -48,7 +48,7 @@ void TrackBar::setConsumer(doubleconsumer consumer) {
|
||||
this->consumer = consumer;
|
||||
}
|
||||
|
||||
void TrackBar::mouseMove(GUI*, int x, int y) {
|
||||
void TrackBar::mouseMove(GUI*, int x, int) {
|
||||
glm::vec2 pos = calcPos();
|
||||
value = x - trackWidth/2;
|
||||
value -= pos.x;
|
||||
|
||||
@@ -64,7 +64,7 @@ UINode* UINode::listenAction(onaction action) {
|
||||
return this;
|
||||
}
|
||||
|
||||
void UINode::click(GUI*, int x, int y) {
|
||||
void UINode::click(GUI*, int, int) {
|
||||
pressed = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,25 +14,6 @@
|
||||
|
||||
using namespace gui;
|
||||
|
||||
std::shared_ptr<Button> guiutil::backButton(std::shared_ptr<Menu> menu) {
|
||||
return std::dynamic_pointer_cast<Button>(create(
|
||||
"<button padding='10' onclick='menu:back()'>@Back</button>"
|
||||
));
|
||||
}
|
||||
|
||||
std::shared_ptr<Button> guiutil::gotoButton(
|
||||
std::wstring text,
|
||||
const std::string& page,
|
||||
std::shared_ptr<Menu> menu
|
||||
) {
|
||||
text = langs::get(text, L"menu");
|
||||
return std::dynamic_pointer_cast<Button>(create(
|
||||
"<button onclick='menu.page=\""+page+"\"' padding='10'>"+
|
||||
util::wstr2str_utf8(text)+
|
||||
"</button>"
|
||||
));
|
||||
}
|
||||
|
||||
std::shared_ptr<gui::UINode> guiutil::create(const std::string& source, scriptenv env) {
|
||||
if (env == nullptr) {
|
||||
env = scripting::get_root_environment();
|
||||
@@ -52,7 +33,7 @@ void guiutil::alert(GUI* gui, const std::wstring& text, runnable on_hidden) {
|
||||
panel->add(label);
|
||||
panel->add(std::make_shared<Button>(
|
||||
langs::get(L"Ok"), glm::vec4(10.f),
|
||||
[=](GUI* gui) {
|
||||
[=](GUI*) {
|
||||
if (on_hidden) {
|
||||
on_hidden();
|
||||
}
|
||||
|
||||
@@ -1,27 +1,14 @@
|
||||
#ifndef FRONTEND_GUI_GUI_UTIL_HPP_
|
||||
#define FRONTEND_GUI_GUI_UTIL_HPP_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "GUI.hpp"
|
||||
#include "../../typedefs.hpp"
|
||||
#include "../../delegates.hpp"
|
||||
|
||||
namespace gui {
|
||||
class Button;
|
||||
}
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace guiutil {
|
||||
std::shared_ptr<gui::Button> backButton(
|
||||
std::shared_ptr<gui::Menu> menu
|
||||
);
|
||||
|
||||
std::shared_ptr<gui::Button> gotoButton(
|
||||
std::wstring text,
|
||||
const std::string& page,
|
||||
std::shared_ptr<gui::Menu> menu
|
||||
);
|
||||
|
||||
/// @brief Create element from XML
|
||||
/// @param source XML
|
||||
std::shared_ptr<gui::UINode> create(const std::string& source, scriptenv env=0);
|
||||
|
||||
@@ -395,7 +395,7 @@ static slotcallback readSlotFunc(InventoryView* view, UiXmlReader& reader, xml::
|
||||
reader.getEnvironment(),
|
||||
element->attr(attr).getText()
|
||||
);
|
||||
return [=](uint slot, ItemStack& stack) {
|
||||
return [=](uint slot, ItemStack&) {
|
||||
int args[] {int(view->getInventory()->getId()), int(slot)};
|
||||
consumer(args, 2);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user