Exemplo n.º 1
0
ContainerGrid::ContainerGrid(size_t rows, size_t cols,
                             ClientItem::vect_t &linked, size_t serial, px_t x,
                             px_t y, px_t gap, bool solidBackground)
    : Element(
          {x, y, static_cast<px_t>(cols) * (Client::ICON_SIZE + gap + 2) + gap,
           static_cast<px_t>(rows) * (Client::ICON_SIZE + gap + 2) + gap + 1}),
      _rows(rows),
      _cols(cols),
      _linked(linked),
      _serial(serial),
      _mouseOverSlot(NO_SLOT),
      _leftMouseDownSlot(NO_SLOT),
      _rightMouseDownSlot(NO_SLOT),
      _gap(gap),
      _solidBackground(solidBackground) {
  if (!_highlight) {
    _highlight =
        Texture(std::string("Images/Items/highlight.png"), Color::MAGENTA);
    _highlightGood =
        Texture(std::string("Images/Items/highlightGood.png"), Color::MAGENTA);
    _highlightBad =
        Texture(std::string("Images/Items/highlightBad.png"), Color::MAGENTA);
  }

  for (size_t i = 0; i != _linked.size(); ++i) {
    const px_t x = i % cols, y = i / cols;
    const auto slotRect =
        ScreenRect{x * (Client::ICON_SIZE + _gap + 2),
                   y * (Client::ICON_SIZE + _gap + 2) + 1,
                   Client::ICON_SIZE + 2, Client::ICON_SIZE + 2};
    addChild(new ShadowBox(slotRect, true));
  }
  setLeftMouseDownFunction(leftMouseDown);
  setLeftMouseUpFunction(leftMouseUp);
  setRightMouseDownFunction(rightMouseDown);
  setRightMouseUpFunction(rightMouseUp);
  setMouseMoveFunction(mouseMove);
}
Exemplo n.º 2
0
TextBox::TextBox(const ScreenRect &rect, ValidInput validInput)
    : Element({rect.x, rect.y, rect.w, HEIGHT}), _validInput(validInput) {
  addChild(new ShadowBox({0, 0, rect.w, HEIGHT}, true));
  setLeftMouseDownFunction(&click);
}