mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 15:26:49 +01:00
introduce virtual items for UIItem
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
function UIItem:onDragEnter(mousePos)
|
||||
if self:isVirtual() then return false end
|
||||
|
||||
local item = self:getItem()
|
||||
if not item then return false end
|
||||
if not item then return true end
|
||||
|
||||
self:setBorderWidth(1)
|
||||
|
||||
@@ -11,17 +13,21 @@ function UIItem:onDragEnter(mousePos)
|
||||
end
|
||||
|
||||
function UIItem:onDragLeave(widget, mousePos)
|
||||
if self:isVirtual() then return false end
|
||||
|
||||
if not self.parsed then
|
||||
self.currentDragThing = nil
|
||||
end
|
||||
|
||||
|
||||
restoreCursor()
|
||||
self:setBorderWidth(0)
|
||||
return true
|
||||
end
|
||||
|
||||
function UIItem:onDrop(widget, mousePos)
|
||||
if not widget or not widget.currentDragThing then return false end
|
||||
if self:isVirtual() then return false end
|
||||
|
||||
if not widget or not widget.currentDragThing then return true end
|
||||
|
||||
local pos = self.position
|
||||
local data = widget.currentDragThing:getData()
|
||||
@@ -32,7 +38,7 @@ function UIItem:onDrop(widget, mousePos)
|
||||
spinbox:setMaximum(data)
|
||||
spinbox:setMinimum(1)
|
||||
spinbox:setCurrentIndex(data)
|
||||
|
||||
|
||||
local okButton = moveWindow:getChildById('buttonOk')
|
||||
okButton.onClick = function() Game.move(widget.currentDragThing, pos, spinbox:getCurrentIndex()) okButton:getParent():destroy() widget.currentDragThing = nil end
|
||||
moveWindow.onEnter = okButton.onClick
|
||||
@@ -45,6 +51,8 @@ function UIItem:onDrop(widget, mousePos)
|
||||
end
|
||||
|
||||
function UIItem:onHoverChange(hovered)
|
||||
if self:isVirtual() then return end
|
||||
|
||||
if g_ui.getDraggingWidget() and self ~= g_ui.getDraggingWidget() then
|
||||
if hovered then
|
||||
self:setBorderWidth(1)
|
||||
@@ -55,6 +63,8 @@ function UIItem:onHoverChange(hovered)
|
||||
end
|
||||
|
||||
function UIItem:onMouseRelease(mousePosition, mouseButton)
|
||||
if self:isVirtual() then return false end
|
||||
|
||||
local item = self:getItem()
|
||||
if not item or not self:containsPoint(mousePosition) then return false end
|
||||
return Game.processMouseAction(mousePosition, mouseButton, nil, item, item, nil, item)
|
||||
|
||||
@@ -26,7 +26,7 @@ local function onUseWithMouseRelease(self, mousePosition, mouseButton)
|
||||
if tile then
|
||||
Game.useWith(Game.selectedThing, tile:getTopMultiUseThing())
|
||||
end
|
||||
elseif clickedWidget.getItem then
|
||||
elseif clickedWidget.getItem and not clickedWidget:isVirtual() then
|
||||
Game.useWith(Game.selectedThing, clickedWidget:getItem())
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,19 +7,5 @@ varying vec2 textureCoords; // map texture coords
|
||||
void main()
|
||||
{
|
||||
vec4 outColor = texture2D(texture, textureCoords) * opacity;
|
||||
/*
|
||||
float refinement = 0;
|
||||
if(refinement > 0) {
|
||||
vec4 sum = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
for(int i=-1;i<=1;++i) {
|
||||
for(int j=-1;j<=1;++j) {
|
||||
vec4 pixel = texture2D(texture, textureCoords + vec2(i,j)*(1.0/32.0));
|
||||
sum += pixel * (1.0/9.0) * pixel.a * (0.5 + (pixel.r + pixel.g + pixel.b)/3.0);
|
||||
}
|
||||
}
|
||||
float factor = refinement*((1.0 + sin(time*2))/2.0);
|
||||
outColor += sum * sum * factor;
|
||||
}
|
||||
*/
|
||||
gl_FragColor = outColor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user