Browse Source

fix use with, improve move, change icons, improve topbar

Eduardo Bart 9 years ago
parent
commit
24aab00431
46 changed files with 185 additions and 108 deletions
  1. 2
    3
      BUGS
  2. 0
    4
      TODO
  3. 1
    1
      modules/addon_terminal/commands.lua
  4. 1
    1
      modules/addon_terminal/terminal.lua
  5. BIN
      modules/addon_terminal/terminal.png
  6. 1
    1
      modules/client_about/about.lua
  7. BIN
      modules/client_about/about.png
  8. 1
    1
      modules/client_options/options.lua
  9. BIN
      modules/client_options/options.png
  10. 2
    2
      modules/client_topmenu/topmenu.lua
  11. BIN
      modules/core_styles/images/tabbutton.png
  12. 1
    1
      modules/core_styles/styles/buttons.otui
  13. 1
    0
      modules/core_styles/styles/items.otui
  14. 1
    1
      modules/core_styles/styles/tabbars.otui
  15. 14
    4
      modules/core_widgets/uiitem.lua
  16. 33
    1
      modules/game/game.lua
  17. 3
    0
      modules/game/game.otui
  18. 4
    4
      modules/game/map.lua
  19. 14
    24
      modules/game/thing.lua
  20. 8
    0
      modules/game_combatcontrols/combatcontrols.lua
  21. 7
    0
      modules/game_combatcontrols/combatcontrols.otmod
  22. 0
    0
      modules/game_combatcontrols/combatcontrols.otui
  23. BIN
      modules/game_combatcontrols/combatcontrols.png
  24. 18
    8
      modules/game_healthbar/healthbar.lua
  25. BIN
      modules/game_healthbar/healthbar.png
  26. 18
    7
      modules/game_inventory/inventory.lua
  27. BIN
      modules/game_inventory/inventory.png
  28. 0
    0
      modules/game_miniwindow/miniwindow.lua
  29. 0
    0
      modules/game_miniwindow/miniwindow.otmod
  30. 0
    0
      modules/game_miniwindow/miniwindow.otui
  31. 1
    1
      modules/game_textmessage/textmessage.lua
  32. 1
    1
      modules/game_viplist/viplist.lua
  33. BIN
      modules/game_viplist/viplist.png
  34. 5
    1
      src/framework/graphics/framebuffer.cpp
  35. 4
    1
      src/framework/graphics/framebuffer.h
  36. 1
    1
      src/framework/graphics/graphics.cpp
  37. 1
    0
      src/framework/luafunctions.cpp
  38. 5
    0
      src/framework/math/color.h
  39. 1
    1
      src/framework/ui/uimanager.cpp
  40. 13
    9
      src/framework/ui/uiwidget.cpp
  41. 2
    2
      src/framework/ui/uiwidget.h
  42. 20
    21
      src/otclient/core/creature.cpp
  43. 0
    1
      src/otclient/core/game.cpp
  44. 0
    4
      src/otclient/core/game.h
  45. 1
    0
      src/otclient/core/map.cpp
  46. 0
    2
      src/otclient/luafunctions.cpp

+ 2
- 3
BUGS View File

@@ -11,11 +11,10 @@ hotkeys works while windows are locked, it shouldnt
11 11
 some animated hits are displayed as 2 hits instead of one
12 12
 numpad on windows doesn't work correctly
13 13
 skulls is rendering outside map bounds
14
-these are some issues when skill progressbar is 0% or 100%
15 14
 paste on x11 platform does not work correctly when doing ctrl+c in google chrome
15
+party options does not work when relogging inside a party
16 16
 
17
-walk animation doesnt reset when leaving invisible
18
-non tiles are no black
17
+chamaleon doesnt animate items
19 18
 drop items in container background
20 19
 can view ocean in underground floors
21 20
 

+ 0
- 4
TODO View File

@@ -12,13 +12,9 @@ adjust interface design
12 12
 display exit box when exiting from game
13 13
 attack modes
14 14
 player status icons (poison, etc)
15
-container windows
16
-move items
17
-use with
18 15
 
19 16
 
20 17
 move count itens
21
-open/close vip/skills
22 18
 move windows, go back in containers
23 19
 open private chat
24 20
 reopen channels

+ 1
- 1
modules/addon_terminal/commands.lua View File

@@ -32,4 +32,4 @@ end
32 32
 
33 33
 function quit()
34 34
   exit()
35
-end
35
+end

+ 1
- 1
modules/addon_terminal/terminal.lua View File

@@ -107,7 +107,7 @@ function Terminal.init()
107 107
   terminalWidget = displayUI('terminal.otui')
108 108
   terminalWidget:setVisible(false)
109 109
 
110
-  terminalButton = TopMenu.addButton('terminalButton', 'Terminal (Ctrl + T)', '/core_styles/icons/terminal.png', Terminal.toggle)
110
+  terminalButton = TopMenu.addButton('terminalButton', 'Terminal (Ctrl + T)', 'terminal.png', Terminal.toggle)
111 111
   Hotkeys.bindKeyDown('Ctrl+T', Terminal.toggle)
112 112
 
113 113
   commandHistory = Settings.getList('terminal-history')

BIN
modules/addon_terminal/terminal.png View File


+ 1
- 1
modules/client_about/about.lua View File

@@ -5,7 +5,7 @@ local aboutButton
5 5
 
6 6
 -- public functions
7 7
 function About.init()
8
-  aboutButton = TopMenu.addRightButton('aboutButton', 'About', '/core_styles/icons/about.png', About.display)
8
+  aboutButton = TopMenu.addRightButton('aboutButton', 'About', 'about.png', About.display)
9 9
 end
10 10
 
11 11
 function About.display()

BIN
modules/client_about/about.png View File


+ 1
- 1
modules/client_options/options.lua View File

@@ -24,7 +24,7 @@ function Options.init()
24 24
 
25 25
   optionsWindow = displayUI('options.otui')
26 26
   optionsWindow:setVisible(false)
27
-  optionsButton = TopMenu.addButton('settingsButton', 'Options (Ctrl+O)', '/core_styles/icons/settings.png', Options.toggle)
27
+  optionsButton = TopMenu.addButton('optionsButton', 'Options (Ctrl+O)', 'options.png', Options.toggle)
28 28
   Hotkeys.bindKeyDown('Ctrl+O', Options.toggle)
29 29
 end
30 30
 

BIN
modules/client_options/options.png View File


+ 2
- 2
modules/client_topmenu/topmenu.lua View File

@@ -63,11 +63,11 @@ function TopMenu.addGameButton(id, description, icon, callback)
63 63
 end
64 64
 
65 65
 function TopMenu.addLeftButton(id, description, icon, callback)
66
-  return TopMenu.addButton(id, description, icon, callback, false)
66
+  return TopMenu.addButton(id, description, resolvepath(icon, 2), callback, false)
67 67
 end
68 68
 
69 69
 function TopMenu.addRightButton(id, description, icon, callback)
70
-  return TopMenu.addButton(id, description, icon, callback, true)
70
+  return TopMenu.addButton(id, description, resolvepath(icon, 2), callback, true)
71 71
 end
72 72
 
73 73
 function TopMenu.removeButton(param)

BIN
modules/core_styles/images/tabbutton.png View File


+ 1
- 1
modules/core_styles/styles/buttons.otui View File

@@ -20,7 +20,7 @@ Button < UIButton
20 20
 
21 21
 ConsoleButton < UIButton
22 22
   size: 20 20
23
-  image-source: /core_styles/images/consolebutton.png
23
+  image-source: /core_styles/images/tabbutton.png
24 24
   image-color: white
25 25
   image-clip: 0 0 20 20
26 26
   image-border: 2

+ 1
- 0
modules/core_styles/styles/items.otui View File

@@ -2,3 +2,4 @@ Item < UIItem
2 2
   size: 34 34
3 3
   image-source: /core_styles/images/item.png
4 4
   font: verdana-11px-rounded
5
+  border-color: white

+ 1
- 1
modules/core_styles/styles/tabbars.otui View File

@@ -2,7 +2,7 @@ TabBar < UITabBar
2 2
 TabBarPanel < Panel
3 3
 TabBarButton < UIButton
4 4
   size: 20 20
5
-  image-source: /core_styles/images/consolebutton.png
5
+  image-source: /core_styles/images/tabbutton.png
6 6
   image-color: white
7 7
   image-clip: 0 0 20 20
8 8
   image-border: 2

+ 14
- 4
modules/core_widgets/uiitem.lua View File

@@ -1,9 +1,8 @@
1 1
 function UIItem:onDragEnter(mousePos)
2 2
   local item = self:getItem()
3 3
   if not item then return false end
4
-  
5
-  self:setBorderWidth('1')
6
-  self:setBorderColor('#ffffff')
4
+
5
+  self:setBorderWidth(1)
7 6
 
8 7
   self.currentDragThing = item
9 8
   setTargetCursor()
@@ -13,7 +12,7 @@ end
13 12
 function UIItem:onDragLeave(widget, mousePos)
14 13
   self.currentDragThing = nil
15 14
   restoreCursor()
16
-  self:setBorderWidth('0')
15
+  self:setBorderWidth(0)
17 16
   return true
18 17
 end
19 18
 
@@ -24,9 +23,20 @@ function UIItem:onDrop(widget, mousePos)
24 23
   local count = widget.currentDragThing:getData()
25 24
 
26 25
   Game.move(widget.currentDragThing, pos, count)
26
+  self:setBorderWidth(0)
27 27
   return true
28 28
 end
29 29
 
30
+function UIItem:onHoverChange(hovered)
31
+  if g_ui.getDraggingWidget() and self ~= g_ui.getDraggingWidget() then
32
+    if hovered then
33
+      self:setBorderWidth(1)
34
+    else
35
+      self:setBorderWidth(0)
36
+    end
37
+  end
38
+end
39
+
30 40
 function UIItem:onMouseRelease(mousePosition, mouseButton)
31 41
   local item = self:getItem()
32 42
   if not item or not self:containsPoint(mousePosition) then return false end

+ 33
- 1
modules/game/game.lua View File

@@ -1,3 +1,6 @@
1
+-- private variables
2
+local m_mouseGrabberWidget
3
+
1 4
 -- private functions
2 5
 local function onGameKeyPress(self, keyCode, keyboardModifiers, wouldFilter)
3 6
   if wouldFilter then return end
@@ -13,7 +16,34 @@ local function onGameKeyPress(self, keyCode, keyboardModifiers, wouldFilter)
13 16
   return false
14 17
 end
15 18
 
19
+local function onUseWithMouseRelease(self, mousePosition, mouseButton)
20
+  if Game.selectedThing == nil then return false end
21
+  if mouseButton == MouseLeftButton then
22
+    local clickedWidget = Game.gameUi:recursiveGetChildByPos(mousePosition)
23
+    if clickedWidget then
24
+      if clickedWidget.getTile then
25
+        local tile = clickedWidget:getTile(mousePosition)
26
+        if tile then
27
+          Game.useWith(Game.selectedThing, tile:getTopMultiUseThing())
28
+        end
29
+      elseif clickedWidget.getItem then
30
+        Game.useWith(Game.selectedThing, clickedWidget:getItem())
31
+      end
32
+    end
33
+  end
34
+  Game.selectedThing = nil
35
+  restoreCursor()
36
+  self:ungrabMouse()
37
+  return true
38
+end
39
+
16 40
 -- public functions
41
+function Game.startUseWith(thing)
42
+  Game.selectedThing = thing
43
+  m_mouseGrabberWidget:grabMouse()
44
+  setTargetCursor()
45
+end
46
+
17 47
 function Game.createInterface()
18 48
   Background.hide()
19 49
   CharacterList.destroyLoadBox()
@@ -33,7 +63,9 @@ function Game.createInterface()
33 63
   Game.gameMapPanel = Game.gameUi:getChildById('gameMapPanel')
34 64
   Game.gameRightPanel = Game.gameUi:getChildById('gameRightPanel')
35 65
   Game.gameBottomPanel = Game.gameUi:getChildById('gameBottomPanel')
36
-  Game.gameUi.onKeyPress = onGameKeyPress
66
+  m_mouseGrabberWidget = Game.gameUi:getChildById('mouseGrabber')
67
+  connect(Game.gameUi, { onKeyPress = onGameKeyPress })
68
+  connect(m_mouseGrabberWidget, { onMouseRelease = onUseWithMouseRelease })
37 69
 end
38 70
 
39 71
 function Game.destroyInterface()

+ 3
- 0
modules/game/game.otui View File

@@ -26,3 +26,6 @@ UIGame
26 26
     anchors.bottom: gameBottomPanel.top
27 27
     focusable: false
28 28
 
29
+  UIWidget
30
+    id: mouseGrabber
31
+    focusable: false

+ 4
- 4
modules/game/map.lua View File

@@ -1,7 +1,7 @@
1 1
 function UIMap:onDragEnter(mousePos)
2 2
   local tile = self:getTile(mousePos)
3 3
   if not tile then return false end
4
-  
4
+
5 5
   local thing = tile:getTopMoveThing()
6 6
   if not thing then return false end
7 7
 
@@ -18,11 +18,11 @@ end
18 18
 
19 19
 function UIMap:onDrop(widget, mousePos)
20 20
   if not widget or not widget.currentDragThing then return false end
21
-  
21
+
22 22
   local tile = self:getTile(mousePos)
23 23
   if not tile then return false end
24
-  local count = 1 -- todo make a window for it
25
-  
24
+  local count = widget.currentDragThing:getData()
25
+
26 26
   Game.move(widget.currentDragThing, tile:getPos(), count)
27 27
   return true
28 28
 end

+ 14
- 24
modules/game/thing.lua View File

@@ -14,24 +14,13 @@ end
14 14
 function Game.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing, useThing, creatureThing, multiUseThing)
15 15
   local keyboardModifiers = g_window.getKeyboardModifiers()
16 16
 
17
-  local selectedThing = Game.getSelectedThing()
18
-  if mouseButton == MouseRightButton and selectedThing then
19
-    Game.setSelectedThing(nil)
20
-    return true
21
-  end
22
-
23
-  if autoWalk and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton and not Game.getSelectedThing() then
17
+  if autoWalk and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
24 18
     -- todo auto walk
25 19
     return true
26 20
   end
27 21
 
28 22
   if not Options.classicControl then
29
-    if mouseButton == MouseLeftButton and selectedThing then
30
-      Game.useWith(Game.getSelectedThing(), multiUseThing)
31
-      Game.setSelectedThing(nil)
32
-      restoreCursor()
33
-      return true
34
-    elseif keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
23
+    if keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
35 24
       Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
36 25
       return true
37 26
     elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
@@ -41,14 +30,17 @@ function Game.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing,
41 30
       if useThing:isContainer() then
42 31
         if useThing:isInsideContainer() then
43 32
           Game.open(useThing, useThing:getContainerId())
33
+          return true
44 34
         else
45 35
           Game.open(useThing, Containers.getFreeContainerId())
36
+        return true
46 37
         end
47 38
       elseif useThing:isMultiUse() then
48
-        Game.setSelectedThing(useThing)
49
-        setTargetCursor()
39
+        Game.startUseWith(useThing)
40
+        return true
50 41
       else
51 42
         Game.use(useThing)
43
+        return true
52 44
       end
53 45
       return true
54 46
     elseif creatureThing and keyboardModifiers == KeyboardAltModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
@@ -56,23 +48,21 @@ function Game.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing,
56 48
       return true
57 49
     end
58 50
   else
59
-    if mouseButton == MouseLeftButton and selectedThing then
60
-      Game.useWith(Game.getSelectedThing(), multiUseThing)
61
-      Game.setSelectedThing(nil)
62
-      restoreCursor()
63
-      return true
64
-    elseif multiUseThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
51
+    if multiUseThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
65 52
       if multiUseThing:asCreature() then
66 53
         Game.attack(multiUseThing:asCreature())
54
+        return true
67 55
       elseif multiUseThing:isContainer() then
68 56
         if multiUseThing:isInsideContainer() then
69 57
           Game.open(multiUseThing, multiUseThing:getContainerId())
58
+          return true
70 59
         else
71 60
           Game.open(multiUseThing, Containers.getFreeContainerId())
61
+          return true
72 62
         end
73 63
       elseif multiUseThing:isMultiUse() then
74
-        Game.setSelectedThing(multiUseThing)
75
-        setTargetCursor()
64
+        Game.startUseWith(multiUseThing)
65
+        return true
76 66
       else
77 67
         Game.use(multiUseThing)
78 68
       end
@@ -110,7 +100,7 @@ function Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
110 100
       end
111 101
     else
112 102
       if useThing:isMultiUse() then
113
-        menu:addOption('Use with ...', function() Game.setSelectedThing(useThing) setTargetCursor() end)
103
+        menu:addOption('Use with ...', function() Game.startUseWith(useThing) end)
114 104
       else
115 105
         menu:addOption('Use', function() Game.use(useThing) end)
116 106
       end

+ 8
- 0
modules/game_combatcontrols/combatcontrols.lua View File

@@ -0,0 +1,8 @@
1
+CombatControls = {}
2
+
3
+function CombatControls.init()
4
+end
5
+
6
+
7
+function CombatControls.terminate()
8
+end

+ 7
- 0
modules/game_combatcontrols/combatcontrols.otmod View File

@@ -0,0 +1,7 @@
1
+Module
2
+  name: game_combatcontrols
3
+  description: Combat controls window
4
+  author: OTClient team
5
+  website: https://github.com/edubart/otclient
6
+  onLoad: |
7
+    require 'combatcontrols'

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


BIN
modules/game_combatcontrols/combatcontrols.png View File


+ 18
- 8
modules/game_healthbar/healthbar.lua View File

@@ -1,7 +1,7 @@
1 1
 HealthBar = {}
2 2
 
3 3
 -- private variables
4
-local healthManaPanel
4
+local healthBarWindow
5 5
 local healthBar
6 6
 local manaBar
7 7
 local healthLabel
@@ -9,22 +9,32 @@ local manaLabel
9 9
 
10 10
 -- public functions
11 11
 function HealthBar.create()
12
-  healthManaPanel = displayUI('healthbar.otui', { parent = Game.gameRightPanel })
13
-  healthBar = healthManaPanel:getChildById('healthBar')
14
-  manaBar = healthManaPanel:getChildById('manaBar')
15
-  healthLabel = healthManaPanel:getChildById('healthLabel')
16
-  manaLabel = healthManaPanel:getChildById('manaLabel')
12
+  healthBarWindow = displayUI('healthbar.otui', { parent = Game.gameRightPanel })
13
+  healthBarButton = TopMenu.addGameButton('healthBarButton', 'Healh Bar', 'healthbar.png', HealthBar.toggle)
14
+  healthBarButton:setOn(true)
15
+  healthBar = healthBarWindow:getChildById('healthBar')
16
+  manaBar = healthBarWindow:getChildById('manaBar')
17
+  healthLabel = healthBarWindow:getChildById('healthLabel')
18
+  manaLabel = healthBarWindow:getChildById('manaLabel')
17 19
 end
18 20
 
19 21
 function HealthBar.destroy()
20
-  healthManaPanel:destroy()
21
-  healthManaPanel = nil
22
+  healthBarWindow:destroy()
23
+  healthBarWindow = nil
24
+  healthBarButton:destroy()
25
+  healthBarButton = nil
22 26
   healthBar = nil
23 27
   manaBar = nil
24 28
   healthLabel = nil
25 29
   manaLabel = nil
26 30
 end
27 31
 
32
+function HealthBar.toggle()
33
+  local visible = not healthBarWindow:isExplicitlyVisible()
34
+  healthBarWindow:setVisible(visible)
35
+  healthBarButton:setOn(visible)
36
+end
37
+
28 38
 -- hooked events
29 39
 function HealthBar.onHealthChange(health, maxHealth)
30 40
   healthLabel:setText(health .. ' / ' .. maxHealth)

BIN
modules/game_healthbar/healthbar.png View File


+ 18
- 7
modules/game_inventory/inventory.lua View File

@@ -1,31 +1,42 @@
1 1
 Inventory = {}
2 2
 
3 3
 -- private variables
4
-local window = nil
4
+local inventoryWindow
5
+local inventoryButton
5 6
 
6 7
 -- public functions
7 8
 function Inventory.create()
8
-  window = displayUI('inventory.otui', { parent = Game.gameRightPanel })
9
+  inventoryWindow = displayUI('inventory.otui', { parent = Game.gameRightPanel })
10
+  inventoryButton = TopMenu.addGameButton('inventoryButton', 'Skills (Ctrl+I)', 'inventory.png', Inventory.toggle)
11
+  inventoryButton:setOn(true)
9 12
 end
10 13
 
11 14
 function Inventory.destroy()
12
-  window:destroy()
13
-  window = nil
15
+  inventoryWindow:destroy()
16
+  inventoryWindow = nil
17
+  inventoryButton:destroy()
18
+  inventoryButton = nil
19
+end
20
+
21
+function Inventory.toggle()
22
+  local visible = not inventoryWindow:isExplicitlyVisible()
23
+  inventoryWindow:setVisible(visible)
24
+  inventoryButton:setOn(visible)
14 25
 end
15 26
 
16 27
 -- hooked events
17 28
 function Inventory.onInventoryChange(slot, item)
18
-  local itemWidget = window:getChildById('slot' .. slot)
29
+  local itemWidget = inventoryWindow:getChildById('slot' .. slot)
19 30
   itemWidget:setItem(item)
20 31
 end
21 32
 
22 33
 function Inventory.onFreeCapacityChange(freeCapacity)
23
-  local widget = window:getChildById('capacity')
34
+  local widget = inventoryWindow:getChildById('capacity')
24 35
   widget:setText("Cap:\n" .. freeCapacity)
25 36
 end
26 37
 
27 38
 function Inventory.onSoulChange(soul)
28
-  local widget = window:getChildById('soul')
39
+  local widget = inventoryWindow:getChildById('soul')
29 40
   widget:setText("Soul:\n" .. soul)
30 41
 end
31 42
 

BIN
modules/game_inventory/inventory.png View File


+ 0
- 0
modules/game_miniwindow/miniwindow.lua View File


+ 0
- 0
modules/game_miniwindow/miniwindow.otmod View File


+ 0
- 0
modules/game_miniwindow/miniwindow.otui View File


+ 1
- 1
modules/game_textmessage/textmessage.lua View File

@@ -6,7 +6,7 @@ importStyle 'textmessage.otui'
6 6
 -- private variables
7 7
 local MessageTypes = {
8 8
   consoleRed = { color = '#F55E5E', consoleTab = 'Server Log' },
9
-  eventOrange = { color = '#FE6500', consoleTab = 'Default' , windowLocation = 'center', consoleOption = 'showEventMessagesInConsole' },
9
+  eventOrange = { color = '#FE6500', consoleTab = 'Default' },
10 10
   consoleOrange = { color = '#FE6500', consoleTab = 'Default' },
11 11
   warning = { color = '#F55E5E', consoleTab = 'Server Log', windowLocation = 'center' },
12 12
   eventAdvance = { color = '#FFFFFF', consoleTab = 'Server Log', windowLocation = 'center', consoleOption = 'showEventMessagesInConsole' },

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

@@ -9,7 +9,7 @@ local addVipWindow
9 9
 function VipList.create()
10 10
   vipWindow = displayUI('viplist.otui', { parent = Game.gameRightPanel })
11 11
   vipWindow:hide()
12
-  vipButton = TopMenu.addGameButton('vipListButton', 'VIP list', '/core_styles/icons/viplist.png', VipList.toggle)
12
+  vipButton = TopMenu.addGameButton('vipListButton', 'VIP list', 'viplist.png', VipList.toggle)
13 13
 end
14 14
 
15 15
 function VipList.destroy()

BIN
modules/game_viplist/viplist.png View File


+ 5
- 1
src/framework/graphics/framebuffer.cpp View File

@@ -28,6 +28,8 @@ uint FrameBuffer::boundFbo = 0;
28 28
 
29 29
 FrameBuffer::FrameBuffer(const Size& size)
30 30
 {
31
+    m_clearColor = Fw::alpha;
32
+
31 33
     glGenFramebuffers(1, &m_fbo);
32 34
     if(!m_fbo)
33 35
         logFatal("Unable to create framebuffer object");
@@ -68,8 +70,10 @@ void FrameBuffer::bind(bool clear)
68 70
     g_painter.setProjectionMatrix(projectionMatrix);
69 71
     g_graphics.setViewportSize(m_texture->getSize());
70 72
 
71
-    if(clear)
73
+    if(clear) {
74
+        glClearColor(m_clearColor.rF(), m_clearColor.gF(), m_clearColor.bF(), m_clearColor.aF());
72 75
         glClear(GL_COLOR_BUFFER_BIT);
76
+    }
73 77
 }
74 78
 
75 79
 void FrameBuffer::release()

+ 4
- 1
src/framework/graphics/framebuffer.h View File

@@ -30,12 +30,14 @@ class FrameBuffer
30 30
 public:
31 31
     FrameBuffer(const Size& size);
32 32
     virtual ~FrameBuffer();
33
-    
33
+
34 34
     void resize(const Size& size);
35 35
     void bind(bool clear = true);
36 36
     void release();
37 37
     void draw(const Rect& dest);
38 38
 
39
+    void setClearColor(const Color& color) { m_clearColor = color; }
40
+
39 41
     TexturePtr getTexture() { return m_texture; }
40 42
 
41 43
 private:
@@ -48,6 +50,7 @@ private:
48 50
     Size m_oldViewportSize;
49 51
     uint m_fbo;
50 52
     uint m_prevBoundFbo;
53
+    Color m_clearColor;
51 54
 
52 55
     static uint boundFbo;
53 56
 };

+ 1
- 1
src/framework/graphics/graphics.cpp View File

@@ -43,7 +43,6 @@ void Graphics::init()
43 43
 #endif
44 44
 
45 45
     glEnable(GL_BLEND);
46
-    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
47 46
 
48 47
     logInfo("GPU ", glGetString(GL_RENDERER));
49 48
     logInfo("OpenGL ", glGetString(GL_VERSION));
@@ -93,6 +92,7 @@ void Graphics::resize(const Size& size)
93 92
 
94 93
 void Graphics::beginRender()
95 94
 {
95
+    glClearColor(0, 0, 0, 1);
96 96
     glClear(GL_COLOR_BUFFER_BIT);
97 97
 }
98 98
 

+ 1
- 0
src/framework/luafunctions.cpp View File

@@ -435,6 +435,7 @@ void Application::registerLuaFunctions()
435 435
     g_lua.bindClassStaticFunction("g_ui", "getStyleClass", std::bind(&UIManager::getStyleClass, &g_ui, _1));
436 436
     g_lua.bindClassStaticFunction("g_ui", "loadUI", std::bind(&UIManager::loadUI, &g_ui, _1, _2));
437 437
     g_lua.bindClassStaticFunction("g_ui", "getRootWidget", std::bind(&UIManager::getRootWidget, &g_ui));
438
+    g_lua.bindClassStaticFunction("g_ui", "getDraggingWidget", std::bind(&UIManager::getDraggingWidget, &g_ui));
438 439
     g_lua.bindClassStaticFunction("g_ui", "setDebugBoxesDrawing", std::bind(&UIManager::setDebugBoxesDrawing, &g_ui, _1));
439 440
     g_lua.bindClassStaticFunction("g_ui", "isDrawingDebugBoxes", std::bind(&UIManager::setDebugBoxesDrawing, &g_ui, _1));
440 441
 

+ 5
- 0
src/framework/math/color.h View File

@@ -40,6 +40,11 @@ public:
40 40
     uint8 g() const { return m_g; }
41 41
     uint8 r() const { return m_r; }
42 42
 
43
+    float aF() const { return m_a/255.0f; }
44
+    float bF() const { return m_b/255.0f; }
45
+    float gF() const { return m_g/255.0f; }
46
+    float rF() const { return m_r/255.0f; }
47
+
43 48
     uint32 rgba() const { return m_rgba; }
44 49
 
45 50
     const uint8* rgbaPtr() const { return (const uint8*)&m_rgba; }

+ 1
- 1
src/framework/ui/uimanager.cpp View File

@@ -72,7 +72,7 @@ void UIManager::inputEvent(const InputEvent& event)
72 72
             m_keyboardReceiver->propagateOnKeyUp(event.keyCode, event.keyboardModifiers);
73 73
             break;
74 74
         case Fw::MousePressInputEvent:
75
-            m_keyboardReceiver->propagateOnMousePress(event.mousePos, event.mouseButton);
75
+            m_mouseReceiver->propagateOnMousePress(event.mousePos, event.mouseButton);
76 76
             break;
77 77
         case Fw::MouseReleaseInputEvent:
78 78
             m_mouseReceiver->propagateOnMouseRelease(event.mousePos, event.mouseButton);

+ 13
- 9
src/framework/ui/uiwidget.cpp View File

@@ -830,10 +830,11 @@ UIWidgetPtr UIWidget::recursiveGetChildById(const std::string& id)
830 830
 UIWidgetPtr UIWidget::recursiveGetChildByPos(const Point& childPos)
831 831
 {
832 832
     for(const UIWidgetPtr& child : m_children) {
833
-        if(child->containsPoint(childPos)) {
833
+        if(child->isExplicitlyVisible() && child->containsPoint(childPos)) {
834 834
             if(UIWidgetPtr subChild = child->recursiveGetChildByPos(childPos))
835 835
                 return subChild;
836
-            return child;
836
+            else if(!child->isPhantom())
837
+                return child;
837 838
         }
838 839
     }
839 840
     return nullptr;
@@ -1113,7 +1114,7 @@ bool UIWidget::onMousePress(const Point& mousePos, Fw::MouseButton button)
1113 1114
     return callLuaField<bool>("onMousePress", mousePos, button);
1114 1115
 }
1115 1116
 
1116
-void UIWidget::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
1117
+bool UIWidget::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
1117 1118
 {
1118 1119
     if(isPressed() && getRect().contains(mousePos))
1119 1120
         callLuaField("onClick");
@@ -1125,7 +1126,7 @@ void UIWidget::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
1125 1126
         draggedWidget->setDragging(false);
1126 1127
     }
1127 1128
 
1128
-    callLuaField("onMouseRelease", mousePos, button);
1129
+    return callLuaField<bool>("onMouseRelease", mousePos, button);
1129 1130
 }
1130 1131
 
1131 1132
 bool UIWidget::onMouseMove(const Point& mousePos, const Point& mouseMoved)
@@ -1260,16 +1261,16 @@ bool UIWidget::propagateOnMousePress(const Point& mousePos, Fw::MouseButton butt
1260 1261
 
1261 1262
     // only non phatom widgets receives mouse press events
1262 1263
     if(!isPhantom()) {
1263
-        onMousePress(mousePos, button);
1264
+        bool ret = onMousePress(mousePos, button);
1264 1265
         if(button == Fw::MouseLeftButton && !isPressed())
1265 1266
             setPressed(true);
1266
-        return true;
1267
+        return ret;
1267 1268
     }
1268 1269
 
1269 1270
     return false;
1270 1271
 }
1271 1272
 
1272
-void UIWidget::propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton button)
1273
+bool UIWidget::propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton button)
1273 1274
 {
1274 1275
     // do a backup of children list, because it may change while looping it
1275 1276
     UIWidgetList children;
@@ -1283,13 +1284,16 @@ void UIWidget::propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton bu
1283 1284
     }
1284 1285
 
1285 1286
     for(const UIWidgetPtr& child : children) {
1286
-        child->propagateOnMouseRelease(mousePos, button);
1287
+        if(child->propagateOnMouseRelease(mousePos, button))
1288
+            return true;
1287 1289
     }
1288 1290
 
1289
-    onMouseRelease(mousePos, button);
1291
+    bool ret = onMouseRelease(mousePos, button);
1290 1292
 
1291 1293
     if(isPressed() && button == Fw::MouseLeftButton)
1292 1294
         setPressed(false);
1295
+
1296
+    return ret;
1293 1297
 }
1294 1298
 
1295 1299
 bool UIWidget::propagateOnMouseMove(const Point& mousePos, const Point& mouseMoved)

+ 2
- 2
src/framework/ui/uiwidget.h View File

@@ -173,7 +173,7 @@ protected:
173 173
     virtual bool onKeyPress(uchar keyCode, int keyboardModifiers, bool wouldFilter);
174 174
     virtual bool onKeyUp(uchar keyCode, int keyboardModifiers);
175 175
     virtual bool onMousePress(const Point& mousePos, Fw::MouseButton button);
176
-    virtual void onMouseRelease(const Point& mousePos, Fw::MouseButton button);
176
+    virtual bool onMouseRelease(const Point& mousePos, Fw::MouseButton button);
177 177
     virtual bool onMouseMove(const Point& mousePos, const Point& mouseMoved);
178 178
     virtual bool onMouseWheel(const Point& mousePos, Fw::MouseWheelDirection direction);
179 179
 
@@ -182,7 +182,7 @@ protected:
182 182
     bool propagateOnKeyPress(uchar keyCode, int keyboardModifiers, bool wouldFilter);
183 183
     bool propagateOnKeyUp(uchar keyCode, int keyboardModifiers);
184 184
     bool propagateOnMousePress(const Point& mousePos, Fw::MouseButton button);
185
-    void propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton button);
185
+    bool propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton button);
186 186
     bool propagateOnMouseMove(const Point& mousePos, const Point& mouseMoved);
187 187
     bool propagateOnMouseWheel(const Point& mousePos, Fw::MouseWheelDirection direction);
188 188
 

+ 20
- 21
src/otclient/core/creature.cpp View File

@@ -245,12 +245,13 @@ void Creature::stopWalk()
245 245
 void Creature::updateWalkAnimation(int totalPixelsWalked)
246 246
 {
247 247
     // update outfit animation
248
-    if(m_outfit.getCategory() == ThingsType::Creature) {
249
-        if(totalPixelsWalked == 32 || totalPixelsWalked == 0 || m_type->dimensions[ThingType::AnimationPhases] <= 1)
250
-            m_animation = 0;
251
-        else if(m_type->dimensions[ThingType::AnimationPhases] > 1)
252
-            m_animation = 1 + ((totalPixelsWalked * 4) / Map::NUM_TILE_PIXELS) % (m_type->dimensions[ThingType::AnimationPhases] - 1);
253
-    }
248
+    if(m_outfit.getCategory() != ThingsType::Creature)
249
+        return;
250
+
251
+    if(totalPixelsWalked == 32 || totalPixelsWalked == 0 || m_type->dimensions[ThingType::AnimationPhases] <= 1)
252
+        m_animation = 0;
253
+    else if(m_type->dimensions[ThingType::AnimationPhases] > 1)
254
+        m_animation = 1 + ((totalPixelsWalked * 4) / Map::NUM_TILE_PIXELS) % (m_type->dimensions[ThingType::AnimationPhases] - 1);
254 255
 }
255 256
 
256 257
 void Creature::updateWalkOffset(int totalPixelsWalked)
@@ -373,11 +374,12 @@ void Creature::setDirection(Otc::Direction direction)
373 374
 
374 375
 void Creature::setOutfit(const Outfit& outfit)
375 376
 {
376
-    if(m_outfit.getCategory() != ThingsType::Effect && outfit.getCategory() == ThingsType::Effect) {
377
-        auto self = asCreature();
378
-        g_dispatcher.scheduleEvent([self]() {
379
-            self->updateInvisibleAnimation();
380
-        }, INVISIBLE_TICKS);
377
+    m_outfit = outfit;
378
+    m_type = getType();
379
+    m_animation = 0;
380
+
381
+    if(m_outfit.getCategory() == ThingsType::Effect) {
382
+        updateInvisibleAnimation();
381 383
 
382 384
         m_xPattern = 0;
383 385
         m_yPattern = 0;
@@ -387,11 +389,7 @@ void Creature::setOutfit(const Outfit& outfit)
387 389
         m_yPattern = 0;
388 390
     }
389 391
 
390
-    m_outfit = outfit;
391
-    m_type = getType();
392
-
393 392
     if(m_outfit.getCategory() == ThingsType::Creature && m_type->dimensions[ThingType::Layers] == 1) {
394
-        m_animation = 0;
395 393
         m_outfit.resetClothes();
396 394
     }
397 395
 }
@@ -453,6 +451,9 @@ void Creature::addVolatileSquare(uint8 color)
453 451
 
454 452
 void Creature::updateInvisibleAnimation()
455 453
 {
454
+    if(!g_game.isOnline() || m_outfit.getCategory() != ThingsType::Effect)
455
+        return;
456
+
456 457
     if(m_animation == 1)
457 458
         m_animation = 2;
458 459
     else if(m_animation == 2)
@@ -462,12 +463,10 @@ void Creature::updateInvisibleAnimation()
462 463
     else
463 464
         m_animation = 1;
464 465
 
465
-    if(g_game.isOnline() && m_outfit.getCategory() == ThingsType::Effect) {
466
-        auto self = asCreature();
467
-        g_dispatcher.scheduleEvent([self]() {
468
-            self->updateInvisibleAnimation();
469
-        }, INVISIBLE_TICKS);
470
-    }
466
+    auto self = asCreature();
467
+    g_dispatcher.scheduleEvent([self]() {
468
+        self->updateInvisibleAnimation();
469
+    }, INVISIBLE_TICKS);
471 470
 }
472 471
 
473 472
 void Creature::updateShield()

+ 0
- 1
src/otclient/core/game.cpp View File

@@ -36,7 +36,6 @@ Game g_game;
36 36
 void Game::loginWorld(const std::string& account, const std::string& password, const std::string& worldHost, int worldPort, const std::string& characterName)
37 37
 {
38 38
     m_dead = false;
39
-    m_selectedThing = nullptr;
40 39
     m_protocolGame = ProtocolGamePtr(new ProtocolGame);
41 40
     m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName);
42 41
 }

+ 0
- 4
src/otclient/core/game.h View File

@@ -107,9 +107,6 @@ public:
107 107
     bool isOnline() { return !!m_localPlayer; }
108 108
     bool isDead() { return m_dead; }
109 109
 
110
-    void setSelectedThing(const ThingPtr& thing) { m_selectedThing = thing; }
111
-    ThingPtr getSelectedThing() { return m_selectedThing; }
112
-
113 110
     void setServerBeat(int serverBeat) { m_serverBeat = serverBeat; }
114 111
     int getServerBeat() { return m_serverBeat; }
115 112
 
@@ -122,7 +119,6 @@ private:
122 119
     ProtocolGamePtr m_protocolGame;
123 120
     bool m_dead;
124 121
     int m_serverBeat;
125
-    ThingPtr m_selectedThing;
126 122
 };
127 123
 
128 124
 extern Game g_game;

+ 1
- 0
src/otclient/core/map.cpp View File

@@ -46,6 +46,7 @@ void Map::draw(const Rect& rect)
46 46
     if(!m_framebuffer) {
47 47
         Size fboSize(m_visibleSize.width() * NUM_TILE_PIXELS, m_visibleSize.height() * NUM_TILE_PIXELS);
48 48
         m_framebuffer = FrameBufferPtr(new FrameBuffer(fboSize));
49
+        m_framebuffer->setClearColor(Fw::black);
49 50
 
50 51
 
51 52
         m_shaderProgram = PainterShaderProgramPtr(new PainterShaderProgram);

+ 0
- 2
src/otclient/luafunctions.cpp View File

@@ -224,8 +224,6 @@ void OTClient::registerLuaFunctions()
224 224
     g_lua.bindClassStaticFunction<Game>("getLocalPlayer", std::bind(&Game::getLocalPlayer, &g_game));
225 225
     g_lua.bindClassStaticFunction<Game>("getProtocolVersion", std::bind(&Game::getProtocolVersion, &g_game));
226 226
     g_lua.bindClassStaticFunction<Game>("getProtocolGame", std::bind(&Game::getProtocolGame, &g_game));
227
-    g_lua.bindClassStaticFunction<Game>("setSelectedThing", std::bind(&Game::setSelectedThing, &g_game, _1));
228
-    g_lua.bindClassStaticFunction<Game>("getSelectedThing", std::bind(&Game::getSelectedThing, &g_game));
229 227
 
230 228
     g_lua.registerClass<UIItem, UIWidget>();
231 229
     g_lua.bindClassStaticFunction<UIItem>("create", []{ return UIItemPtr(new UIItem); } );

Loading…
Cancel
Save