Fixed #12 #28 #51 issues

This commit is contained in:
Henrique Santiago 2012-08-17 18:36:53 -03:00
parent a91b7ed6be
commit 4d2bd54f6b
17 changed files with 108 additions and 38 deletions

View File

@ -138,6 +138,24 @@ function UIMiniWindow:onDragEnter(mousePos)
return true return true
end end
function UIMiniWindow:onDragLeave(droppedWidget, mousePos)
if self.movedWidget then
self.setMovedChildMargin(0)
self.movedWidget = nil
self.setMovedChildMargin = nil
self.movedIndex = nil
end
local parent = self:getParent()
if parent then
if parent:getClassName() == 'UIMiniWindowContainer' then
parent:saveChildren()
else
self:saveParentPosition(parent:getId(), self:getPosition())
end
end
end
function UIMiniWindow:onDragMove(mousePos, mouseMoved) function UIMiniWindow:onDragMove(mousePos, mouseMoved)
local oldMousePosY = mousePos.y - mouseMoved.y local oldMousePosY = mousePos.y - mouseMoved.y
local children = rootWidget:recursiveGetChildrenByMarginPos(mousePos) local children = rootWidget:recursiveGetChildrenByMarginPos(mousePos)
@ -188,24 +206,6 @@ function UIMiniWindow:onMousePress()
end end
end end
function UIMiniWindow:onDragLeave(droppedWidget, mousePos)
if self.movedWidget then
self.setMovedChildMargin(0)
self.movedWidget = nil
self.setMovedChildMargin = nil
self.movedIndex = nil
end
local parent = self:getParent()
if parent then
if parent:getClassName() == 'UIMiniWindowContainer' then
parent:saveChildren()
else
self:saveParentPosition(parent:getId(), self:getPosition())
end
end
end
function UIMiniWindow:onFocusChange(focused) function UIMiniWindow:onFocusChange(focused)
-- miniwindows only raises when its outside MiniWindowContainers -- miniwindows only raises when its outside MiniWindowContainers
if not focused then return end if not focused then return end
@ -253,3 +253,13 @@ end
function UIMiniWindow:disableResize() function UIMiniWindow:disableResize()
self:getChildById('bottomResizeBorder'):disable() self:getChildById('bottomResizeBorder'):disable()
end end
function UIMiniWindow:setMinimumHeight(height)
local resizeBorder = self:getChildById('bottomResizeBorder')
resizeBorder:setMinimum(height)
end
function UIMiniWindow:setMaximumHeight(height)
local resizeBorder = self:getChildById('bottomResizeBorder')
resizeBorder:setMaximum(height)
end

View File

@ -8,6 +8,10 @@ function UIWindow.create()
return window return window
end end
function UIWindow:getClassName()
return 'UIWindow'
end
function UIWindow:onKeyDown(keyCode, keyboardModifiers) function UIWindow:onKeyDown(keyCode, keyboardModifiers)
if keyboardModifiers == KeyboardNoModifier then if keyboardModifiers == KeyboardNoModifier then
if keyCode == KeyEnter then if keyCode == KeyEnter then

View File

@ -41,7 +41,7 @@ MiniWindow
!text: tr('Battle') !text: tr('Battle')
height: 166 height: 166
icon: battle.png icon: battle.png
@onClose: onMiniWindowClose() @onClose: modules.game_battle.onMiniWindowClose()
&save: true &save: true
MiniWindowContents MiniWindowContents

View File

@ -28,7 +28,7 @@ MiniWindow
icon: combatcontrols.png icon: combatcontrols.png
height: 48 height: 48
&save: true &save: true
@onClose: onMiniWindowClose() @onClose: modules.game_combatcontrols.onMiniWindowClose()
MiniWindowContents MiniWindowContents
FightOffensiveBox FightOffensiveBox

View File

@ -65,7 +65,7 @@ MiniWindow
id: healthInfoWindow id: healthInfoWindow
!text: tr('Health Info') !text: tr('Health Info')
height: 102 height: 102
@onClose: onMiniWindowClose() @onClose: modules.game_healthinfo.onMiniWindowClose()
&save: true &save: true
MiniWindowContents MiniWindowContents

View File

@ -179,9 +179,9 @@ function onUseWith(clickedWidget, mousePosition)
local tile = clickedWidget:getTile(mousePosition) local tile = clickedWidget:getTile(mousePosition)
if tile then if tile then
g_game.useWith(selectedThing, tile:getTopMultiUseThing()) g_game.useWith(selectedThing, tile:getTopMultiUseThing())
elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
g_game.useWith(selectedThing, clickedWidget:getItem())
end end
elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
g_game.useWith(selectedThing, clickedWidget:getItem())
end end
end end

View File

@ -7,7 +7,6 @@ function UIGameMap.create()
return gameMap return gameMap
end end
function UIGameMap:onDragEnter(mousePos) function UIGameMap:onDragEnter(mousePos)
local tile = self:getTile(mousePos) local tile = self:getTile(mousePos)
if not tile then return false end if not tile then return false end
@ -28,7 +27,7 @@ function UIGameMap:onDragLeave(droppedWidget, mousePos)
end end
function UIGameMap:onDrop(widget, mousePos) function UIGameMap:onDrop(widget, mousePos)
if not widget or not widget.currentDragThing then return false end if not self:canAcceptDrop(widget, mousePos) then return false end
local tile = self:getTile(mousePos) local tile = self:getTile(mousePos)
if not tile then return false end if not tile then return false end
@ -82,3 +81,20 @@ function UIGameMap:onMouseRelease(mousePosition, mouseButton)
return ret return ret
end end
function UIGameMap:canAcceptDrop(widget, mousePos)
if not widget or not widget.currentDragThing then return false end
local children = rootWidget:recursiveGetChildrenByPos(mousePos)
for i=1,#children do
local child = children[i]
if child == self then
return true
elseif not child:isPhantom() then
return false
end
end
error('Widget ' .. self:getId() .. ' not in drop list.')
return false
end

View File

@ -20,9 +20,7 @@ function UIItem:onDragLeave(droppedWidget, mousePos)
end end
function UIItem:onDrop(widget, mousePos) function UIItem:onDrop(widget, mousePos)
if self:isVirtual() then return false end if not self:canAcceptDrop(widget, mousePos) then return false end
if not widget or not widget.currentDragThing then return false end
local item = widget.currentDragThing local item = widget.currentDragThing
if not item:isItem() then return false end if not item:isItem() then return false end
@ -94,3 +92,20 @@ function UIItem:onMouseRelease(mousePosition, mouseButton)
return false return false
end end
function UIItem:canAcceptDrop(widget, mousePos)
if self:isVirtual() then return false end
if not widget or not widget.currentDragThing then return false end
local children = rootWidget:recursiveGetChildrenByPos(mousePos)
for i=1,#children do
local child = children[i]
if child == self then
return true
elseif not child:isPhantom() then
return false
end
end
error('Widget ' .. self:getId() .. ' not in drop list.')
return false
end

View File

@ -56,7 +56,7 @@ MiniWindow
!text: tr('Inventory') !text: tr('Inventory')
icon: inventory.png icon: inventory.png
height: 95 height: 95
@onClose: onMiniWindowClose() @onClose: modules.game_inventory.onMiniWindowClose()
&save: true &save: true
MiniWindowContents MiniWindowContents

View File

@ -25,7 +25,7 @@ MiniWindow
!text: tr('Minimap') !text: tr('Minimap')
height: 150 height: 150
icon: minimap.png icon: minimap.png
@onClose: onMiniWindowClose() @onClose: modules.game_minimap.onMiniWindowClose()
&save: true &save: true
Label Label

View File

@ -35,7 +35,7 @@ MiniWindow
!text: tr('Skills') !text: tr('Skills')
height: 150 height: 150
icon: skills.png icon: skills.png
@onClose: onMiniWindowClose() @onClose: modules.game_skills.onMiniWindowClose()
&save: true &save: true
MiniWindowContents MiniWindowContents
@ -149,4 +149,3 @@ MiniWindow
!text: tr('Fishing') !text: tr('Fishing')
SkillValueLabel SkillValueLabel
SkillPercentPanel SkillPercentPanel

View File

@ -11,7 +11,6 @@ function init()
g_keyboard.bindKeyDown('Ctrl+P', toggle) g_keyboard.bindKeyDown('Ctrl+P', toggle)
vipWindow = g_ui.loadUI('viplist.otui', modules.game_interface.getRightPanel()) vipWindow = g_ui.loadUI('viplist.otui', modules.game_interface.getRightPanel())
vipWindow.onClose = onMiniWindowClose
vipButton = TopMenu.addRightGameToggleButton('vipListButton', tr('VIP list') .. ' (Ctrl+P)', 'viplist.png', toggle) vipButton = TopMenu.addRightGameToggleButton('vipListButton', tr('VIP list') .. ' (Ctrl+P)', 'viplist.png', toggle)
vipButton:setOn(true) vipButton:setOn(true)

View File

@ -7,6 +7,7 @@ MiniWindow
!text: tr('VIP List') !text: tr('VIP List')
height: 100 height: 100
icon: viplist.png icon: viplist.png
@onClose: modules.game_viplist.onMiniWindowClose()
&save: true &save: true
MiniWindowContents MiniWindowContents

View File

@ -1198,7 +1198,6 @@ UIWidgetPtr UIWidget::backwardsGetWidgetById(const std::string& id)
return widget; return widget;
} }
bool UIWidget::setState(Fw::WidgetState state, bool on) bool UIWidget::setState(Fw::WidgetState state, bool on)
{ {
if(state == Fw::InvalidState) if(state == Fw::InvalidState)

View File

@ -156,7 +156,7 @@ void Creature::internalDrawOutfit(Point dest, float scaleFactor, bool animateWal
if(m_outfit.getCategory() == ThingCategoryEffect) if(m_outfit.getCategory() == ThingCategoryEffect)
animationPhase = std::min(animationPhase+1, getAnimationPhases()); animationPhase = std::min(animationPhase+1, getAnimationPhases());
rawGetThingType()->draw(dest, scaleFactor, 0, 0, 0, 0, animationPhase); rawGetThingType()->draw(dest - (getDisplacement() * scaleFactor), scaleFactor, 0, 0, 0, 0, animationPhase);
} }
} }
@ -632,6 +632,30 @@ int Creature::getStepDuration()
return interval; return interval;
} }
Point Creature::getDisplacement()
{
Point displacement = Thing::getDisplacement();
if(m_outfit.getCategory() == ThingCategoryEffect)
displacement = Point(8, 8);
return displacement;
}
int Creature::getDisplacementX()
{
int displacementX = Thing::getDisplacementX();
if(m_outfit.getCategory() == ThingCategoryEffect)
displacementX = 8;
return displacementX;
}
int Creature::getDisplacementY()
{
int displacementY = Thing::getDisplacementY();
if(m_outfit.getCategory() == ThingCategoryEffect)
displacementY = 8;
return displacementY;
}
const ThingTypePtr& Creature::getThingType() const ThingTypePtr& Creature::getThingType()
{ {
return g_things.getThingType(m_outfit.getId(), m_outfit.getCategory()); return g_things.getThingType(m_outfit.getId(), m_outfit.getCategory());

View File

@ -84,6 +84,9 @@ public:
Point getDrawOffset(); Point getDrawOffset();
int getStepDuration(); int getStepDuration();
Point getWalkOffset() { return m_walkOffset; } Point getWalkOffset() { return m_walkOffset; }
virtual Point getDisplacement();
virtual int getDisplacementX();
virtual int getDisplacementY();
void updateShield(); void updateShield();

View File

@ -65,9 +65,9 @@ public:
Size getSize() { return rawGetThingType()->getSize(); } Size getSize() { return rawGetThingType()->getSize(); }
int getWidth() { return rawGetThingType()->getWidth(); } int getWidth() { return rawGetThingType()->getWidth(); }
int getHeight() { return rawGetThingType()->getHeight(); } int getHeight() { return rawGetThingType()->getHeight(); }
Point getDisplacement() { return rawGetThingType()->getDisplacement(); } virtual Point getDisplacement() { return rawGetThingType()->getDisplacement(); }
int getDisplacementX() { return rawGetThingType()->getDisplacementX(); } virtual int getDisplacementX() { return rawGetThingType()->getDisplacementX(); }
int getDisplacementY() { return rawGetThingType()->getDisplacementY(); } virtual int getDisplacementY() { return rawGetThingType()->getDisplacementY(); }
int getExactSize() { return rawGetThingType()->getExactSize(); } int getExactSize() { return rawGetThingType()->getExactSize(); }
int getLayers() { return rawGetThingType()->getLayers(); } int getLayers() { return rawGetThingType()->getLayers(); }
int getNumPatternX() { return rawGetThingType()->getNumPatternX(); } int getNumPatternX() { return rawGetThingType()->getNumPatternX(); }