Browse Source

reorganize modules

Eduardo Bart 9 years ago
parent
commit
cf0aab6d4d
90 changed files with 186 additions and 180 deletions
  1. 2
    2
      .gitmodules
  2. 4
    4
      CMakeLists.txt
  3. 1
    0
      TODO
  4. 0
    0
      modules/addon_console/console.lua
  5. 4
    0
      modules/addon_console/console.otmod
  6. 0
    0
      modules/addon_console/console.otui
  7. 1
    0
      modules/addon_playground/playground.lua
  8. 0
    3
      modules/addon_playground/playground.otmod
  9. 4
    4
      modules/client/client.lua
  10. 22
    0
      modules/client/client.otmod
  11. 0
    0
      modules/client/clienticon.png
  12. 4
    4
      modules/client_about/about.lua
  13. 1
    3
      modules/client_about/about.otmod
  14. 0
    0
      modules/client_about/about.otui
  15. 0
    0
      modules/client_background/background.lua
  16. 1
    3
      modules/client_background/background.otmod
  17. 1
    1
      modules/client_background/background.otui
  18. 0
    0
      modules/client_background/background.png
  19. 0
    0
      modules/client_entergame/characterlist.lua
  20. 0
    0
      modules/client_entergame/characterlist.otui
  21. 0
    0
      modules/client_entergame/entergame.lua
  22. 2
    1
      modules/client_entergame/entergame.otmod
  23. 0
    0
      modules/client_entergame/entergame.otui
  24. 0
    0
      modules/client_options/options.lua
  25. 2
    1
      modules/client_options/options.otmod
  26. 0
    0
      modules/client_options/options.otui
  27. 1
    0
      modules/client_tibiafiles
  28. 1
    1
      modules/client_topmenu/topmenu.lua
  29. 1
    7
      modules/client_topmenu/topmenu.otmod
  30. 0
    0
      modules/client_topmenu/topmenu.otui
  31. 7
    11
      modules/core/core.otmod
  32. BIN
      modules/core_fonts/sans-11px-antialised.png
  33. 0
    0
      modules/core_scripts/constants.lua
  34. 16
    0
      modules/core_scripts/core_scripts.otmod
  35. 0
    0
      modules/core_scripts/dispatcher.lua
  36. 0
    0
      modules/core_scripts/ext/color.lua
  37. 0
    0
      modules/core_scripts/ext/point.lua
  38. 0
    0
      modules/core_scripts/ext/rect.lua
  39. 0
    0
      modules/core_scripts/ext/size.lua
  40. 0
    0
      modules/core_scripts/ext/string.lua
  41. 0
    0
      modules/core_scripts/ext/table.lua
  42. 0
    0
      modules/core_scripts/gfx.lua
  43. 0
    0
      modules/core_scripts/ui.lua
  44. 6
    2
      modules/core_scripts/util.lua
  45. 0
    0
      modules/core_scripts/widget.lua
  46. 1
    3
      modules/core_styles/core_styles.otmod
  47. 10
    0
      modules/core_widgets/core_widgets.otmod
  48. 0
    0
      modules/core_widgets/messagebox/messagebox.lua
  49. 0
    0
      modules/core_widgets/messagebox/messagebox.otui
  50. 0
    0
      modules/core_widgets/tooltip/tooltip.lua
  51. 0
    0
      modules/core_widgets/tooltip/tooltip.otui
  52. 3
    3
      modules/game/game.lua
  53. 11
    1
      modules/game/game.otmod
  54. 0
    0
      modules/game_chat/chat.lua
  55. 1
    1
      modules/game_chat/chat.otmod
  56. 0
    0
      modules/game_chat/chat.otui
  57. 6
    6
      modules/game_healthbar/healthbar.lua
  58. 2
    2
      modules/game_healthbar/healthbar.otmod
  59. 0
    0
      modules/game_healthbar/healthbar.otui
  60. 0
    0
      modules/game_inventory/inventory.lua
  61. 1
    1
      modules/game_inventory/inventory.otmod
  62. 0
    0
      modules/game_inventory/inventory.otui
  63. 0
    0
      modules/game_inventory/itempopupmenu.otui
  64. 0
    0
      modules/game_outfit/outfit.lua
  65. 1
    1
      modules/game_outfit/outfit.otmod
  66. 0
    0
      modules/game_outfit/outfit.otui
  67. 0
    0
      modules/game_skills/skills.lua
  68. 1
    1
      modules/game_skills/skills.otmod
  69. 0
    0
      modules/game_skills/skills.otui
  70. 1
    1
      modules/game_textmessage/textmessage.lua
  71. 1
    1
      modules/game_textmessage/textmessage.otmod
  72. 0
    0
      modules/game_textmessage/textmessage.otui
  73. 0
    0
      modules/game_viplist/viplist.lua
  74. 1
    1
      modules/game_viplist/viplist.otmod
  75. 0
    0
      modules/game_viplist/viplist.otui
  76. 0
    12
      modules/messagebox/messagebox.otmod
  77. 0
    27
      modules/otclient/otclient.otmod
  78. 0
    23
      modules/playground/playground.lua
  79. 0
    1
      modules/tibiafiles
  80. 0
    13
      modules/tooltip/tooltip.otmod
  81. 4
    4
      src/framework/CMakeLists.txt
  82. 3
    24
      src/framework/application.cpp
  83. 0
    1
      src/framework/application.h
  84. 37
    3
      src/framework/core/modulemanager.cpp
  85. 5
    1
      src/framework/core/modulemanager.h
  86. 1
    1
      src/framework/graphics/font.cpp
  87. 5
    0
      src/framework/graphics/fontmanager.cpp
  88. 2
    0
      src/framework/graphics/fontmanager.h
  89. 1
    1
      src/otclient/CMakeLists.txt
  90. 7
    0
      src/otclient/otclient.cpp

+ 2
- 2
.gitmodules View File

@@ -1,3 +1,3 @@
1
-[submodule "modules/tibiafiles"]
2
-	path = modules/tibiafiles
1
+[submodule "modules/client_tibiafiles"]
2
+	path = modules/client_tibiafiles
3 3
 	url = git://github.com/Baxnie/otclient-tibiafiles.git

+ 4
- 4
CMakeLists.txt View File

@@ -6,7 +6,7 @@ INCLUDE(src/otclient/CMakeLists.txt)
6 6
 
7 7
 OPTION(USE_PCH "Use precompiled header (speed up compile)" ON)
8 8
 
9
-SET(EXECUTABLE_SOURCES src/main.cpp)
9
+SET(executable_SOURCES src/main.cpp)
10 10
 
11 11
 # add executable icon for win32 platforms
12 12
 IF(WIN32)
@@ -15,14 +15,14 @@ IF(WIN32)
15 15
                        -I${CMAKE_CURRENT_SOURCE_DIR}/src
16 16
                        -i${CMAKE_CURRENT_SOURCE_DIR}/src/otcicon.rc
17 17
                        -o ${CMAKE_CURRENT_BINARY_DIR}/otcicon.o)
18
-    SET(${EXECUTABLE_SOURCES} ${EXECUTABLE_SOURCES} otcicon.o)
18
+    SET(executable_SOURCES ${executable_SOURCES} otcicon.o)
19 19
 ENDIF(WIN32)
20 20
 
21 21
 # add otclient executable
22
-ADD_EXECUTABLE(otclient ${FRAMEWORK_SOURCES} ${OTCLIENT_SOURCES} ${EXECUTABLE_SOURCES})
22
+ADD_EXECUTABLE(otclient ${framework_SOURCES} ${otclient_SOURCES} ${executable_SOURCES})
23 23
 
24 24
 # target link libraries
25
-TARGET_LINK_LIBRARIES(otclient ${FRAMEWORK_LIBRARIES})
25
+TARGET_LINK_LIBRARIES(otclient ${framework_LIBRARIES})
26 26
 
27 27
 IF(USE_PCH)
28 28
     FIND_PACKAGE(PCHSupport REQUIRED)

+ 1
- 0
TODO View File

@@ -29,3 +29,4 @@ bind every global lua function in a static class
29 29
 use metatable for Point,Rect,Color,Size lua classes
30 30
 lua binder generator
31 31
 restore win32 platform
32
+set special types for g_configs like lists/point/size

modules/console/console.lua → modules/addon_console/console.lua View File


modules/console/console.otmod → modules/addon_console/console.otmod View File

@@ -3,7 +3,11 @@ Module
3 3
   description: Console for executing lua functions
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
+
7
+  // console can be loaded after core
6 8
   autoLoad: true
9
+  autoLoadPriority: 20
10
+
7 11
   dependencies:
8 12
     - core
9 13
 

modules/console/console.otui → modules/addon_console/console.otui View File


+ 1
- 0
modules/addon_playground/playground.lua View File

@@ -0,0 +1 @@
1
+-- place any code for testing purposes here

modules/playground/playground.otmod → modules/addon_playground/playground.otmod View File

@@ -1,9 +1,6 @@
1 1
 Module
2 2
   name: playground
3 3
   autoLoad: true
4
-  dependencies:
5
-    - core
6
-
7 4
   onLoad: |
8 5
     require 'playground'
9 6
     return true

modules/otclient/otclient.lua → modules/client/client.lua View File

@@ -1,13 +1,13 @@
1
-OTClient = { }
1
+Client = { }
2 2
 
3 3
 -- TODO: load and save configurations
4
-function OTClient.init()
4
+function Client.init()
5 5
   g_window.move({ x=220, y=220 })
6 6
   g_window.resize({ width=800, height=600 })
7 7
   g_window.setTitle('OTClient')
8
-  g_window.setIcon('otcicon.png')
8
+  g_window.setIcon('clienticon.png')
9 9
   return true
10 10
 end
11 11
 
12
-function OTClient.terminate()
12
+function Client.terminate()
13 13
 end

+ 22
- 0
modules/client/client.otmod View File

@@ -0,0 +1,22 @@
1
+Module
2
+  name: client
3
+  description: Load all other otclient dependecies
4
+  author: OTClient team
5
+  website: https://github.com/edubart/otclient
6
+
7
+  // NOTE: order does matter
8
+  dependencies:
9
+    - client_background
10
+    - client_topmenu
11
+    - client_tibiafiles
12
+    - client_about
13
+    - client_options
14
+    - client_entergame
15
+    - game
16
+
17
+  onLoad: |
18
+    require 'client'
19
+    return Client.init()
20
+
21
+  onUnload: |
22
+    Client.terminate()

modules/otclient/otcicon.png → modules/client/clienticon.png View File


modules/about/about.lua → modules/client_about/about.lua View File

@@ -1,16 +1,16 @@
1 1
 About = {}
2 2
 
3 3
 -- private variables
4
-local about
4
+local aboutWindow
5 5
 
6 6
 -- public functions
7 7
 function About.create()
8
-  about = UI.display('about.otui', { locked = true })
8
+  aboutWindow = UI.display('about.otui', { locked = true })
9 9
 end
10 10
 
11 11
 function About.destroy()
12
-  about:destroy()
13
-  about = nil
12
+  aboutWindow:destroy()
13
+  aboutWindow = nil
14 14
 end
15 15
 
16 16
 function About.openWebpage()

modules/about/about.otmod → modules/client_about/about.otmod View File

@@ -1,10 +1,8 @@
1 1
 Module
2
-  name: about
2
+  name: client_about
3 3
   description: Create the about window
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  dependencies:
7
-    - core
8 6
 
9 7
   onLoad: |
10 8
     require 'about'

modules/about/about.otui → modules/client_about/about.otui View File


modules/background/background.lua → modules/client_background/background.lua View File


modules/background/background.otmod → modules/client_background/background.otmod View File

@@ -1,10 +1,8 @@
1 1
 Module
2
-  name: background
2
+  name: client_background
3 3
   description: Handles the background of the login screen
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  dependencies:
7
-    - core
8 6
 
9 7
   onLoad: |
10 8
     require 'background'

modules/background/background.otui → modules/client_background/background.otui View File

@@ -1,7 +1,7 @@
1 1
 Panel
2 2
   id: background
3 3
   image:
4
-    source: /background/background.png
4
+    source: /client_background/background.png
5 5
     smooth: true
6 6
     fixed ratio: true
7 7
   anchors.top: topMenu.bottom

modules/background/background.png → modules/client_background/background.png View File


modules/entergame/characterlist.lua → modules/client_entergame/characterlist.lua View File


modules/entergame/characterlist.otui → modules/client_entergame/characterlist.otui View File


modules/entergame/entergame.lua → modules/client_entergame/entergame.lua View File


modules/entergame/entergame.otmod → modules/client_entergame/entergame.otmod View File

@@ -1,8 +1,9 @@
1 1
 Module
2
-  name: entergame
2
+  name: client_entergame
3 3
   description: Manages enter game and character list windows
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
+
6 7
   onLoad: |
7 8
     require 'entergame'
8 9
     require 'characterlist'

modules/entergame/entergame.otui → modules/client_entergame/entergame.otui View File


modules/options/options.lua → modules/client_options/options.lua View File


modules/options/options.otmod → modules/client_options/options.otmod View File

@@ -1,8 +1,9 @@
1 1
 Module
2
-  name: options
2
+  name: client_options
3 3
   description: Create the options window
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
+
6 7
   onLoad: |
7 8
     require 'options'
8 9
     return true

modules/options/options.otui → modules/client_options/options.otui View File


+ 1
- 0
modules/client_tibiafiles

@@ -0,0 +1 @@
1
+Subproject commit e76fa2786e2a194375a110b700b7e2daa769f960

modules/topmenu/topmenu.lua → modules/client_topmenu/topmenu.lua View File

@@ -15,4 +15,4 @@ end
15 15
 
16 16
 function TopMenu.getButton(id)
17 17
   return topMenu:getChildById(id)
18
-end
18
+end

modules/topmenu/topmenu.otmod → modules/client_topmenu/topmenu.otmod View File

@@ -1,13 +1,8 @@
1 1
 Module
2
-  name: topmenu
2
+  name: client_topmenu
3 3
   description: Create the top menu
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  dependencies:
7
-    - core
8
-    - entergame
9
-    - options
10
-    - about
11 6
 
12 7
   onLoad: |
13 8
     require 'topmenu'
@@ -16,4 +11,3 @@ Module
16 11
 
17 12
   onUnload: |
18 13
     TopMenu.destroy()
19
-

modules/topmenu/topmenu.otui → modules/client_topmenu/topmenu.otui View File


+ 7
- 11
modules/core/core.otmod View File

@@ -3,19 +3,15 @@ Module
3 3
   description: Contains lua classes, functions and constants used by other modules
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
+
7
+  // core must be loaded before other modules
6 8
   autoLoad: true
9
+  autoLoadPriority: 10
10
+
11
+  // NOTE: order does matter
7 12
   dependencies:
8 13
     - core_fonts
9 14
     - core_styles
10
-
11
-  onLoad: |
12
-    require 'ext/table'
13
-    require 'ext/string'
14
-    require 'constants'
15
-    require 'util'
16
-    require 'dispatcher'
17
-    require 'widget'
18
-    require 'ui'
19
-    require 'gfx'
20
-    return true
15
+    - core_scripts
16
+    - core_widgets
21 17
 

BIN
modules/core_fonts/sans-11px-antialised.png View File


modules/core/constants.lua → modules/core_scripts/constants.lua View File


+ 16
- 0
modules/core_scripts/core_scripts.otmod View File

@@ -0,0 +1,16 @@
1
+Module
2
+  name: core_scripts
3
+  description: Contains core lua classes, functions and constants used by other modules
4
+  author: OTClient team
5
+  website: https://github.com/edubart/otclient
6
+
7
+  onLoad: |
8
+    require 'ext/table'
9
+    require 'ext/string'
10
+    require 'constants'
11
+    require 'util'
12
+    require 'dispatcher'
13
+    require 'widget'
14
+    require 'ui'
15
+    require 'gfx'
16
+    return true

modules/core/dispatcher.lua → modules/core_scripts/dispatcher.lua View File


modules/core/ext/color.lua → modules/core_scripts/ext/color.lua View File


modules/core/ext/point.lua → modules/core_scripts/ext/point.lua View File


modules/core/ext/rect.lua → modules/core_scripts/ext/rect.lua View File


modules/core/ext/size.lua → modules/core_scripts/ext/size.lua View File


modules/core/ext/string.lua → modules/core_scripts/ext/string.lua View File


modules/core/ext/table.lua → modules/core_scripts/ext/table.lua View File


modules/core/gfx.lua → modules/core_scripts/gfx.lua View File


modules/core/ui.lua → modules/core_scripts/ui.lua View File


modules/core/util.lua → modules/core_scripts/util.lua View File

@@ -12,14 +12,18 @@ function createEnvironment()
12 12
   return env
13 13
 end
14 14
 
15
-function connect(object, signalsAndSlots)
15
+function connect(object, signalsAndSlots, pushFront)
16 16
   for signal,slot in pairs(signalsAndSlots) do
17 17
     if not object[signal] then
18 18
         object[signal] = slot
19 19
     elseif type(object[signal]) == 'function' then
20 20
         object[signal] = { object[signal], slot }
21 21
     elseif type(object[signal]) == 'table' then
22
-        table.insert(object[signal], #object[signal]+1, slot)
22
+        if pushFront then
23
+          table.insert(object[signal], 1, slot)
24
+        else
25
+          table.insert(object[signal], #object[signal]+1, slot)
26
+        end
23 27
     end
24 28
   end
25 29
 end

modules/core/widget.lua → modules/core_scripts/widget.lua View File


+ 1
- 3
modules/core_styles/core_styles.otmod View File

@@ -3,8 +3,7 @@ Module
3 3
   description: Contains ui styles used by other modules
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  dependencies:
7
-    - core_fonts
6
+
8 7
   onLoad: |
9 8
     importStyles 'styles/buttons.otui'
10 9
     importStyles 'styles/labels.otui'
@@ -17,4 +16,3 @@ Module
17 16
     importStyles 'styles/items.otui'
18 17
     importStyles 'styles/creatures.otui'
19 18
     return true
20
-

+ 10
- 0
modules/core_widgets/core_widgets.otmod View File

@@ -0,0 +1,10 @@
1
+Module
2
+  name: core_widgets
3
+  description: Contains widgets used by other modules
4
+  author: OTClient team
5
+  website: https://github.com/edubart/otclient
6
+
7
+  onLoad: |
8
+    require 'tooltip/tooltip'
9
+    require 'messagebox/messagebox'
10
+    return true

modules/messagebox/messagebox.lua → modules/core_widgets/messagebox/messagebox.lua View File


modules/messagebox/messagebox.otui → modules/core_widgets/messagebox/messagebox.otui View File


modules/tooltip/tooltip.lua → modules/core_widgets/tooltip/tooltip.lua View File


modules/tooltip/tooltip.otui → modules/core_widgets/tooltip/tooltip.otui View File


+ 3
- 3
modules/game/game.lua View File

@@ -16,7 +16,7 @@ end
16 16
 function Game.createInterface()
17 17
   Background.hide()
18 18
   CharacterList.destroyLoadBox()
19
-  Game.gameUi = UI.display('/game/game.otui')
19
+  Game.gameUi = UI.display('game.otui')
20 20
   UI.root:moveChildToIndex(Game.gameUi, 1)
21 21
   Game.gameMapPanel = Game.gameUi:getChildById('mapPanel')
22 22
   Game.gameRightPanel = Game.gameUi:getChildById('rightPanel')
@@ -56,5 +56,5 @@ function Game.onConnectionError(message)
56 56
   errorBox.onOk = CharacterList.show
57 57
 end
58 58
 
59
-connect(Game, { onLogin = Game.createInterface,
60
-                onLogout = Game.destroyInterface })
59
+connect(Game, { onLogin = Game.createInterface }, true)
60
+connect(Game, { onLogout = Game.destroyInterface })

+ 11
- 1
modules/game/game.otmod View File

@@ -3,6 +3,16 @@ Module
3 3
   description: Create the game interface, where the ingame stuff starts
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
+
7
+  dependencies:
8
+    - game_healthbar
9
+    - game_inventory
10
+    - game_skills
11
+    - game_textmessage
12
+    - game_viplist
13
+    - game_chat
14
+    - game_outfit
15
+
6 16
   onLoad: |
7 17
     require 'game'
8
-    return true
18
+    return true

modules/chat/chat.lua → modules/game_chat/chat.lua View File


modules/chat/chat.otmod → modules/game_chat/chat.otmod View File

@@ -1,5 +1,5 @@
1 1
 Module
2
-  name: chat
2
+  name: game_chat
3 3
   description: Manage chat window
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient

modules/chat/chat.otui → modules/game_chat/chat.otui View File


modules/health_mana/health_mana.lua → modules/game_healthbar/healthbar.lua View File

@@ -1,11 +1,11 @@
1
-HealthMana = {}
1
+HealthBar = {}
2 2
 
3 3
 -- private variables
4 4
 local healthManaPanel = nil
5 5
 
6 6
 -- public functions
7
-function HealthMana.create()
8
-  healthManaPanel = UI.display('health_mana.otui', { parent = Game.gameRightPanel })
7
+function HealthBar.create()
8
+  healthManaPanel = UI.display('healthbar.otui', { parent = Game.gameRightPanel })
9 9
 
10 10
   local healthBar = UIProgressBar.create()
11 11
   healthManaPanel:addChild(healthBar)
@@ -32,7 +32,7 @@ function HealthMana.create()
32 32
   healthManaPanel:setHeight(healthBar:getHeight() + manaBar:getHeight() + 4)
33 33
 end
34 34
 
35
-function HealthMana.destroy()
35
+function HealthBar.destroy()
36 36
   healthManaPanel:destroy()
37 37
   healthManaPanel = nil
38 38
 end
@@ -61,5 +61,5 @@ function Game.onManaChange(mana, maxMana)
61 61
   manaBar:setPercent(percent)
62 62
 end
63 63
 
64
-connect(Game, { onLogin = HealthMana.create,
65
-                onLogout = HealthMana.destroy })
64
+connect(Game, { onLogin = HealthBar.create,
65
+                onLogout = HealthBar.destroy })

modules/health_mana/health_mana.otmod → modules/game_healthbar/healthbar.otmod View File

@@ -1,10 +1,10 @@
1 1
 Module
2
-  name: health_mana
2
+  name: game_healthbar
3 3
   description: Displays health and mana points
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6 6
   onLoad: |
7
-    require 'health_mana'
7
+    require 'healthbar'
8 8
     return true
9 9
 
10 10
 

modules/health_mana/health_mana.otui → modules/game_healthbar/healthbar.otui View File


modules/inventory/inventory.lua → modules/game_inventory/inventory.lua View File


modules/inventory/inventory.otmod → modules/game_inventory/inventory.otmod View File

@@ -1,5 +1,5 @@
1 1
 Module
2
-  name: inventory
2
+  name: game_inventory
3 3
   description: View local player equipments window
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient

modules/inventory/inventory.otui → modules/game_inventory/inventory.otui View File


modules/inventory/itempopupmenu.otui → modules/game_inventory/itempopupmenu.otui View File


modules/outfit/outfit.lua → modules/game_outfit/outfit.lua View File


modules/outfit/outfit.otmod → modules/game_outfit/outfit.otmod View File

@@ -1,5 +1,5 @@
1 1
 Module
2
-  name: outfit
2
+  name: game_outfit
3 3
   description: Change local player outfit
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient

modules/outfit/outfit.otui → modules/game_outfit/outfit.otui View File


modules/skills/skills.lua → modules/game_skills/skills.lua View File


modules/skills/skills.otmod → modules/game_skills/skills.otmod View File

@@ -1,5 +1,5 @@
1 1
 Module
2
-  name: skills
2
+  name: game_skills
3 3
   description: Manage skills window
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient

modules/skills/skills.otui → modules/game_skills/skills.otui View File


modules/textmessage/textmessage.lua → modules/game_textmessage/textmessage.lua View File

@@ -1,7 +1,7 @@
1 1
 TextMessage = {}
2 2
 
3 3
 -- require styles
4
-importStyles '/textmessage/textmessage.otui'
4
+importStyles 'textmessage.otui'
5 5
 
6 6
 -- private variables
7 7
 local bottomLabelWidget, centerLabelWidget

modules/textmessage/textmessage.otmod → modules/game_textmessage/textmessage.otmod View File

@@ -1,5 +1,5 @@
1 1
 Module
2
-  name: textmessage
2
+  name: game_textmessage
3 3
   description: Manage game text messages
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient

modules/textmessage/textmessage.otui → modules/game_textmessage/textmessage.otui View File


modules/viplist/viplist.lua → modules/game_viplist/viplist.lua View File


modules/viplist/viplist.otmod → modules/game_viplist/viplist.otmod View File

@@ -1,5 +1,5 @@
1 1
 Module
2
-  name: viplist
2
+  name: game_viplist
3 3
   description: Manage vip list window
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient

modules/viplist/viplist.otui → modules/game_viplist/viplist.otui View File


+ 0
- 12
modules/messagebox/messagebox.otmod View File

@@ -1,12 +0,0 @@
1
-Module
2
-  name: messagebox
3
-  description: Manages message boxes
4
-  author: OTClient team
5
-  website: https://github.com/edubart/otclient
6
-  autoLoad: true
7
-  dependencies:
8
-    - core
9
-
10
-  onLoad: |
11
-    require 'messagebox'
12
-    return true

+ 0
- 27
modules/otclient/otclient.otmod View File

@@ -1,27 +0,0 @@
1
-Module
2
-  name: otclient
3
-  description: Load all other otclient modules
4
-  author: OTClient team
5
-  website: https://github.com/edubart/otclient
6
-  autoLoad: true
7
-  autoLoadPriority: 10
8
-  dependencies:
9
-    - core
10
-    - background
11
-    - topmenu
12
-    - game
13
-    - health_mana
14
-    - inventory
15
-    - skills
16
-    - viplist
17
-    - textmessage
18
-    - chat
19
-    - outfit
20
-    - tibiafiles
21
-
22
-  onLoad: |
23
-    require 'otclient'
24
-    return OTClient.init()
25
-
26
-  onUnload: |
27
-    OTClient.terminate()

+ 0
- 23
modules/playground/playground.lua View File

@@ -1,24 +0,0 @@
1
-
2
-function UIItem.onMouseRelease(self, mousePos, mouseButton)
3
-  if mouseButton ~= MouseRightButton then return end
4
-  local top = self:getY()
5
-  local bottom = self:getY() + self:getHeight()
6
-  local left = self:getX()
7
-  local right = self:getX() + self:getWidth()
8
-  if not (mousePos.y >= top and mousePos.y <= bottom and mousePos.x >= left and mousePos.x <= right) then return end
9
-
10
-  local menuFile = self:getStyle()['popup menu']
11
-  if not menuFile then return end
12
-
13
-  local popupMenu = UI.display(menuFile)
14
-  if not popupMenu then return end
15
-
16
-  popupMenu:moveTo(mousePos)
17
-  popupMenu.onMouseRelease = function(self) self:destroy() end
18
-end
19
-
20
-local function init()
21
-end
22
-
23
-addEvent(init)

+ 0
- 1
modules/tibiafiles

@@ -1 +0,0 @@
1
-Subproject commit 8bb3b7d6d86e561be4622fbe7dbef208446a0319

+ 0
- 13
modules/tooltip/tooltip.otmod View File

@@ -1,13 +0,0 @@
1
-Module
2
-  name: tooltip
3
-  description: Enable tooltips on any button
4
-  author: OTClient team
5
-  website: https://github.com/edubart/otclient
6
-  autoLoad: true
7
-  autoLoadPriority: 2
8
-  dependencies:
9
-    - core
10
-
11
-  onLoad: |
12
-    require 'tooltip'
13
-    return true

+ 4
- 4
src/framework/CMakeLists.txt View File

@@ -62,7 +62,7 @@ ENDIF(HANDLE_EXCEPTIONS)
62 62
 
63 63
 
64 64
 IF(WIN32)
65
-    SET(FRAMEWORK_SOURCES ${FRAMEWORK_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/platform/win32window.cpp)
65
+    SET(framework_SOURCES ${framework_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/platform/win32window.cpp)
66 66
     SET(ADDITIONAL_LIBRARIES ws2_32 mswsock)
67 67
 
68 68
     IF(CMAKE_COMPILER_IS_GNUCXX)
@@ -80,7 +80,7 @@ IF(WIN32)
80 80
 ELSE(WIN32)
81 81
     SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -rdynamic")
82 82
     SET(ADDITIONAL_LIBRARIES pthread)
83
-    SET(FRAMEWORK_SOURCES ${FRAMEWORK_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.cpp)
83
+    SET(framework_SOURCES ${framework_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.cpp)
84 84
 ENDIF(WIN32)
85 85
 
86 86
 
@@ -94,7 +94,7 @@ INCLUDE_DIRECTORIES(
94 94
     "${CMAKE_CURRENT_LIST_DIR}/.."
95 95
 )
96 96
 
97
-SET(FRAMEWORK_LIBRARIES
97
+SET(framework_LIBRARIES
98 98
     ${Boost_LIBRARIES}
99 99
     ${OPENGL_LIBRARIES}
100 100
     ${LUA_LIBRARIES}
@@ -105,7 +105,7 @@ SET(FRAMEWORK_LIBRARIES
105 105
 )
106 106
 
107 107
 
108
-SET(FRAMEWORK_SOURCES ${FRAMEWORK_SOURCES}
108
+SET(framework_SOURCES ${framework_SOURCES}
109 109
     # framework
110 110
     ${CMAKE_CURRENT_LIST_DIR}/application.cpp
111 111
     ${CMAKE_CURRENT_LIST_DIR}/luafunctions.cpp

+ 3
- 24
src/framework/application.cpp View File

@@ -103,33 +103,12 @@ void Application::init(const std::vector<std::string>& args, int appFlags)
103 103
         resize(g_window.getSize());
104 104
     }
105 105
 
106
-    if(m_appFlags & Fw::AppEnableModules) {
107
-        // search for modules directory
108
-        std::string baseDir = g_resources.getBaseDir();
109
-        std::string possibleDirs[] = { "modules",
110
-                                       baseDir + "modules",
111
-                                       baseDir + "../modules",
112
-                                       baseDir + "../share/" + m_appName + "/modules",
113
-                                       "" };
114
-        bool found = false;
115
-        for(const std::string& dir : possibleDirs) {
116
-            // try to add module directory
117
-            if(g_resources.addToSearchPath(dir)) {
118
-                logInfo("Using modules directory '", dir.c_str(), "'");
119
-                found = true;
120
-                break;
121
-            }
122
-        }
123
-
124
-        if(!found)
125
-            logFatal("Could not find modules directory");
126
-
127
-        g_modules.discoverAndLoadModules();
128
-    }
129
-
130 106
     // finally show the window
131 107
     if(m_appFlags & Fw::AppEnableGraphics)
132 108
         g_window.show();
109
+
110
+    if(m_appFlags & Fw::AppEnableModules)
111
+        g_modules.discoverModulesPath();
133 112
 }
134 113
 
135 114
 

+ 0
- 1
src/framework/application.h View File

@@ -54,7 +54,6 @@ protected:
54 54
     virtual void resize(const Size& size);
55 55
     virtual void inputEvent(const InputEvent& event);
56 56
 
57
-private:
58 57
     std::string m_appName;
59 58
     int m_appFlags;
60 59
     int m_pollCycleDelay;

+ 37
- 3
src/framework/core/modulemanager.cpp View File

@@ -24,13 +24,12 @@
24 24
 #include "resourcemanager.h"
25 25
 
26 26
 #include <framework/otml/otml.h>
27
+#include <framework/application.h>
27 28
 
28 29
 ModuleManager g_modules;
29 30
 
30
-void ModuleManager::discoverAndLoadModules()
31
+void ModuleManager::discoverModules()
31 32
 {
32
-    std::multimap<int, ModulePtr> m_autoLoadModules;
33
-
34 33
     auto moduleDirs = g_resources.listDirectoryFiles("/");
35 34
     for(const std::string& moduleDir : moduleDirs) {
36 35
         auto moduleFiles = g_resources.listDirectoryFiles("/" + moduleDir);
@@ -42,14 +41,42 @@ void ModuleManager::discoverAndLoadModules()
42 41
             }
43 42
         }
44 43
     }
44
+}
45 45
 
46
+void ModuleManager::autoLoadModules(int maxPriority)
47
+{
46 48
     for(auto& pair : m_autoLoadModules) {
49
+        int priority = pair.first;
50
+        if(priority > maxPriority)
51
+            break;
47 52
         ModulePtr module = pair.second;
48 53
         if(!module->isLoaded() && !module->load())
49 54
             logFatal("A required module has failed to load, cannot continue to run.");
50 55
     }
51 56
 }
52 57
 
58
+void ModuleManager::discoverModulesPath()
59
+{
60
+    // search for modules directory
61
+    std::string possibleDirs[] = { "modules",
62
+                                    g_resources.getBaseDir() + "modules",
63
+                                    g_resources.getBaseDir() + "../modules",
64
+                                    g_resources.getBaseDir() + "../share/" + g_app->getAppName() + "/modules",
65
+                                    "" };
66
+    bool found = false;
67
+    for(const std::string& dir : possibleDirs) {
68
+        // try to add module directory
69
+        if(g_resources.addToSearchPath(dir)) {
70
+            logInfo("Using modules directory '", dir.c_str(), "'");
71
+            found = true;
72
+            break;
73
+        }
74
+    }
75
+
76
+    if(!found)
77
+        logFatal("Could not find modules directory");
78
+}
79
+
53 80
 ModulePtr ModuleManager::discoverModule(const std::string& moduleFile)
54 81
 {
55 82
     ModulePtr module;
@@ -70,6 +97,13 @@ ModulePtr ModuleManager::discoverModule(const std::string& moduleFile)
70 97
     return module;
71 98
 }
72 99
 
100
+void ModuleManager::ensureModuleLoaded(const std::string& moduleName)
101
+{
102
+    ModulePtr module = g_modules.getModule(moduleName);
103
+    if(!module || !module->load())
104
+        logFatal("Unable to load '", moduleName, "' module");
105
+}
106
+
73 107
 void ModuleManager::unloadModules()
74 108
 {
75 109
     for(const ModulePtr& module : m_modules)

+ 5
- 1
src/framework/core/modulemanager.h View File

@@ -28,14 +28,18 @@
28 28
 class ModuleManager
29 29
 {
30 30
 public:
31
-    void discoverAndLoadModules();
31
+    void discoverModulesPath();
32
+    void discoverModules();
33
+    void autoLoadModules(int maxPriority);
32 34
     ModulePtr discoverModule(const std::string& moduleFile);
35
+    void ensureModuleLoaded(const std::string& moduleName);
33 36
     void unloadModules();
34 37
 
35 38
     ModulePtr getModule(const std::string& moduleName);
36 39
 
37 40
 private:
38 41
     std::vector<ModulePtr> m_modules;
42
+    std::multimap<int, ModulePtr> m_autoLoadModules;
39 43
 };
40 44
 
41 45
 extern ModuleManager g_modules;

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

@@ -76,7 +76,7 @@ void Font::renderText(const std::string& text,
76 76
                       const Color& color)
77 77
 {
78 78
     // prevent glitches from invalid rects
79
-    if(!screenCoords.isValid())
79
+    if(!screenCoords.isValid() || !m_texture)
80 80
         return;
81 81
 
82 82
     int textLenght = text.length();

+ 5
- 0
src/framework/graphics/fontmanager.cpp View File

@@ -27,6 +27,11 @@
27 27
 
28 28
 FontManager g_fonts;
29 29
 
30
+FontManager::FontManager()
31
+{
32
+    m_defaultFont = FontPtr(new Font("emptyfont"));
33
+}
34
+
30 35
 void FontManager::releaseFonts()
31 36
 {
32 37
     m_defaultFont.reset();

+ 2
- 0
src/framework/graphics/fontmanager.h View File

@@ -28,6 +28,8 @@
28 28
 class FontManager
29 29
 {
30 30
 public:
31
+    FontManager();
32
+
31 33
     /// Release fonts references, thus making possible to destruct them
32 34
     void releaseFonts();
33 35
 

+ 1
- 1
src/otclient/CMakeLists.txt View File

@@ -8,7 +8,7 @@ ELSE(FORBIDDEN_FUNCTIONS)
8 8
     MESSAGE(STATUS "Lua forbidden functions: OFF")
9 9
 ENDIF(FORBIDDEN_FUNCTIONS)
10 10
 
11
-SET(OTCLIENT_SOURCES ${OTCLIENT_SOURCES}
11
+SET(otclient_SOURCES ${otclient_SOURCES}
12 12
     # otclient
13 13
     ${CMAKE_CURRENT_LIST_DIR}/otclient.cpp
14 14
     ${CMAKE_CURRENT_LIST_DIR}/luafunctions.cpp

+ 7
- 0
src/otclient/otclient.cpp View File

@@ -21,6 +21,7 @@
21 21
  */
22 22
 
23 23
 #include "otclient.h"
24
+#include <framework/core/modulemanager.h>
24 25
 
25 26
 OTClient::OTClient() : Application(Otc::AppCompactName)
26 27
 {
@@ -31,4 +32,10 @@ void OTClient::init(const std::vector<std::string>& args)
31 32
 {
32 33
     logInfo(Otc::AppName, " ", Otc::AppVersion);
33 34
     Application::init(args, Fw::AppEnableAll);
35
+
36
+    g_modules.discoverModules();
37
+    g_modules.autoLoadModules(100);
38
+    g_modules.ensureModuleLoaded("client");
39
+    g_modules.ensureModuleLoaded("game");
40
+    g_modules.autoLoadModules(1000);
34 41
 }

Loading…
Cancel
Save