Browse Source

Fixed #12 #28 #51 issues

Henrique Santiago 8 years ago
parent
commit
4d2bd54f6b

+ 28
- 18
modules/corelib/ui/uiminiwindow.lua View File

@@ -138,6 +138,24 @@ function UIMiniWindow:onDragEnter(mousePos)
138 138
   return true
139 139
 end
140 140
 
141
+function UIMiniWindow:onDragLeave(droppedWidget, mousePos)
142
+  if self.movedWidget then
143
+    self.setMovedChildMargin(0)
144
+    self.movedWidget = nil
145
+    self.setMovedChildMargin = nil
146
+    self.movedIndex = nil
147
+  end
148
+
149
+  local parent = self:getParent()
150
+  if parent then
151
+    if parent:getClassName() == 'UIMiniWindowContainer' then
152
+      parent:saveChildren()
153
+    else
154
+      self:saveParentPosition(parent:getId(), self:getPosition())
155
+    end
156
+  end
157
+end
158
+
141 159
 function UIMiniWindow:onDragMove(mousePos, mouseMoved)
142 160
   local oldMousePosY = mousePos.y - mouseMoved.y
143 161
   local children = rootWidget:recursiveGetChildrenByMarginPos(mousePos)
@@ -188,24 +206,6 @@ function UIMiniWindow:onMousePress()
188 206
   end
189 207
 end
190 208
 
191
-function UIMiniWindow:onDragLeave(droppedWidget, mousePos)
192
-  if self.movedWidget then
193
-    self.setMovedChildMargin(0)
194
-    self.movedWidget = nil
195
-    self.setMovedChildMargin = nil
196
-    self.movedIndex = nil
197
-  end
198
-
199
-  local parent = self:getParent()
200
-  if parent then
201
-    if parent:getClassName() == 'UIMiniWindowContainer' then
202
-      parent:saveChildren()
203
-    else
204
-      self:saveParentPosition(parent:getId(), self:getPosition())
205
-    end
206
-  end
207
-end
208
-
209 209
 function UIMiniWindow:onFocusChange(focused)
210 210
   -- miniwindows only raises when its outside MiniWindowContainers
211 211
   if not focused then return end
@@ -253,3 +253,13 @@ end
253 253
 function UIMiniWindow:disableResize()
254 254
   self:getChildById('bottomResizeBorder'):disable()
255 255
 end
256
+
257
+function UIMiniWindow:setMinimumHeight(height)
258
+  local resizeBorder = self:getChildById('bottomResizeBorder')
259
+  resizeBorder:setMinimum(height)
260
+end
261
+
262
+function UIMiniWindow:setMaximumHeight(height)
263
+  local resizeBorder = self:getChildById('bottomResizeBorder')
264
+  resizeBorder:setMaximum(height)
265
+end

+ 4
- 0
modules/corelib/ui/uiwindow.lua View File

@@ -8,6 +8,10 @@ function UIWindow.create()
8 8
   return window
9 9
 end
10 10
 
11
+function UIWindow:getClassName()
12
+  return 'UIWindow'
13
+end
14
+
11 15
 function UIWindow:onKeyDown(keyCode, keyboardModifiers)
12 16
   if keyboardModifiers == KeyboardNoModifier then
13 17
     if keyCode == KeyEnter then

+ 1
- 1
modules/game_battle/battle.otui View File

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

+ 1
- 1
modules/game_combatcontrols/combatcontrols.otui View File

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

+ 1
- 1
modules/game_healthinfo/healthinfo.otui View File

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

+ 2
- 2
modules/game_interface/gameinterface.lua View File

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

+ 18
- 2
modules/game_interface/widgets/uigamemap.lua View File

@@ -7,7 +7,6 @@ function UIGameMap.create()
7 7
   return gameMap
8 8
 end
9 9
 
10
-
11 10
 function UIGameMap:onDragEnter(mousePos)
12 11
   local tile = self:getTile(mousePos)
13 12
   if not tile then return false end
@@ -28,7 +27,7 @@ function UIGameMap:onDragLeave(droppedWidget, mousePos)
28 27
 end
29 28
 
30 29
 function UIGameMap:onDrop(widget, mousePos)
31
-  if not widget or not widget.currentDragThing then return false end
30
+  if not self:canAcceptDrop(widget, mousePos) then return false end
32 31
 
33 32
   local tile = self:getTile(mousePos)
34 33
   if not tile then return false end
@@ -82,3 +81,20 @@ function UIGameMap:onMouseRelease(mousePosition, mouseButton)
82 81
 
83 82
   return ret
84 83
 end
84
+
85
+function UIGameMap:canAcceptDrop(widget, mousePos)
86
+  if not widget or not widget.currentDragThing then return false end
87
+
88
+  local children = rootWidget:recursiveGetChildrenByPos(mousePos)
89
+  for i=1,#children do
90
+    local child = children[i]
91
+    if child == self then
92
+      return true
93
+    elseif not child:isPhantom() then
94
+      return false
95
+    end
96
+  end
97
+
98
+  error('Widget ' .. self:getId() .. ' not in drop list.')
99
+  return false
100
+end

+ 18
- 3
modules/game_interface/widgets/uiitem.lua View File

@@ -20,9 +20,7 @@ function UIItem:onDragLeave(droppedWidget, mousePos)
20 20
 end
21 21
 
22 22
 function UIItem:onDrop(widget, mousePos)
23
-  if self:isVirtual() then return false end
24
-
25
-  if not widget or not widget.currentDragThing then return false end
23
+  if not self:canAcceptDrop(widget, mousePos) then return false end
26 24
 
27 25
   local item = widget.currentDragThing
28 26
   if not item:isItem() then return false end
@@ -94,3 +92,20 @@ function UIItem:onMouseRelease(mousePosition, mouseButton)
94 92
   return false
95 93
 end
96 94
 
95
+function UIItem:canAcceptDrop(widget, mousePos)
96
+  if self:isVirtual() then return false end
97
+  if not widget or not widget.currentDragThing then return false end
98
+
99
+  local children = rootWidget:recursiveGetChildrenByPos(mousePos)
100
+  for i=1,#children do
101
+    local child = children[i]
102
+    if child == self then
103
+      return true
104
+    elseif not child:isPhantom() then
105
+      return false
106
+    end
107
+  end
108
+
109
+  error('Widget ' .. self:getId() .. ' not in drop list.')
110
+  return false
111
+end

+ 1
- 1
modules/game_inventory/inventory.otui View File

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

+ 1
- 1
modules/game_minimap/minimap.otui View File

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

+ 1
- 2
modules/game_skills/skills.otui View File

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

+ 0
- 1
modules/game_viplist/viplist.lua View File

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

+ 1
- 0
modules/game_viplist/viplist.otui View File

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

+ 0
- 1
src/framework/ui/uiwidget.cpp View File

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

+ 25
- 1
src/otclient/creature.cpp View File

@@ -156,7 +156,7 @@ void Creature::internalDrawOutfit(Point dest, float scaleFactor, bool animateWal
156 156
         if(m_outfit.getCategory() == ThingCategoryEffect)
157 157
             animationPhase = std::min(animationPhase+1, getAnimationPhases());
158 158
 
159
-        rawGetThingType()->draw(dest, scaleFactor, 0, 0, 0, 0, animationPhase);
159
+        rawGetThingType()->draw(dest - (getDisplacement() * scaleFactor), scaleFactor, 0, 0, 0, 0, animationPhase);
160 160
     }
161 161
 }
162 162
 
@@ -632,6 +632,30 @@ int Creature::getStepDuration()
632 632
     return interval;
633 633
 }
634 634
 
635
+Point Creature::getDisplacement()
636
+{
637
+    Point displacement = Thing::getDisplacement();
638
+    if(m_outfit.getCategory() == ThingCategoryEffect)
639
+        displacement = Point(8, 8);
640
+    return displacement;
641
+}
642
+
643
+int Creature::getDisplacementX()
644
+{
645
+    int displacementX = Thing::getDisplacementX();
646
+    if(m_outfit.getCategory() == ThingCategoryEffect)
647
+        displacementX = 8;
648
+    return displacementX;
649
+}
650
+
651
+int Creature::getDisplacementY()
652
+{
653
+    int displacementY = Thing::getDisplacementY();
654
+    if(m_outfit.getCategory() == ThingCategoryEffect)
655
+        displacementY = 8;
656
+    return displacementY;
657
+}
658
+
635 659
 const ThingTypePtr& Creature::getThingType()
636 660
 {
637 661
     return g_things.getThingType(m_outfit.getId(), m_outfit.getCategory());

+ 3
- 0
src/otclient/creature.h View File

@@ -84,6 +84,9 @@ public:
84 84
     Point getDrawOffset();
85 85
     int getStepDuration();
86 86
     Point getWalkOffset() { return m_walkOffset; }
87
+    virtual Point getDisplacement();
88
+    virtual int getDisplacementX();
89
+    virtual int getDisplacementY();
87 90
 
88 91
     void updateShield();
89 92
 

+ 3
- 3
src/otclient/thing.h View File

@@ -65,9 +65,9 @@ public:
65 65
     Size getSize() { return rawGetThingType()->getSize(); }
66 66
     int getWidth() { return rawGetThingType()->getWidth(); }
67 67
     int getHeight() { return rawGetThingType()->getHeight(); }
68
-    Point getDisplacement() { return rawGetThingType()->getDisplacement(); }
69
-    int getDisplacementX() { return rawGetThingType()->getDisplacementX(); }
70
-    int getDisplacementY() { return rawGetThingType()->getDisplacementY(); }
68
+    virtual Point getDisplacement() { return rawGetThingType()->getDisplacement(); }
69
+    virtual int getDisplacementX() { return rawGetThingType()->getDisplacementX(); }
70
+    virtual int getDisplacementY() { return rawGetThingType()->getDisplacementY(); }
71 71
     int getExactSize() { return rawGetThingType()->getExactSize(); }
72 72
     int getLayers() { return rawGetThingType()->getLayers(); }
73 73
     int getNumPatternX() { return rawGetThingType()->getNumPatternX(); }

Loading…
Cancel
Save