reorganize modules
This commit is contained in:
parent
ffeb34e0e7
commit
cf0aab6d4d
|
@ -1,3 +1,3 @@
|
||||||
[submodule "modules/tibiafiles"]
|
[submodule "modules/client_tibiafiles"]
|
||||||
path = modules/tibiafiles
|
path = modules/client_tibiafiles
|
||||||
url = git://github.com/Baxnie/otclient-tibiafiles.git
|
url = git://github.com/Baxnie/otclient-tibiafiles.git
|
||||||
|
|
|
@ -6,7 +6,7 @@ INCLUDE(src/otclient/CMakeLists.txt)
|
||||||
|
|
||||||
OPTION(USE_PCH "Use precompiled header (speed up compile)" ON)
|
OPTION(USE_PCH "Use precompiled header (speed up compile)" ON)
|
||||||
|
|
||||||
SET(EXECUTABLE_SOURCES src/main.cpp)
|
SET(executable_SOURCES src/main.cpp)
|
||||||
|
|
||||||
# add executable icon for win32 platforms
|
# add executable icon for win32 platforms
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
|
@ -15,14 +15,14 @@ IF(WIN32)
|
||||||
-I${CMAKE_CURRENT_SOURCE_DIR}/src
|
-I${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||||
-i${CMAKE_CURRENT_SOURCE_DIR}/src/otcicon.rc
|
-i${CMAKE_CURRENT_SOURCE_DIR}/src/otcicon.rc
|
||||||
-o ${CMAKE_CURRENT_BINARY_DIR}/otcicon.o)
|
-o ${CMAKE_CURRENT_BINARY_DIR}/otcicon.o)
|
||||||
SET(${EXECUTABLE_SOURCES} ${EXECUTABLE_SOURCES} otcicon.o)
|
SET(executable_SOURCES ${executable_SOURCES} otcicon.o)
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
|
||||||
# add otclient executable
|
# add otclient executable
|
||||||
ADD_EXECUTABLE(otclient ${FRAMEWORK_SOURCES} ${OTCLIENT_SOURCES} ${EXECUTABLE_SOURCES})
|
ADD_EXECUTABLE(otclient ${framework_SOURCES} ${otclient_SOURCES} ${executable_SOURCES})
|
||||||
|
|
||||||
# target link libraries
|
# target link libraries
|
||||||
TARGET_LINK_LIBRARIES(otclient ${FRAMEWORK_LIBRARIES})
|
TARGET_LINK_LIBRARIES(otclient ${framework_LIBRARIES})
|
||||||
|
|
||||||
IF(USE_PCH)
|
IF(USE_PCH)
|
||||||
FIND_PACKAGE(PCHSupport REQUIRED)
|
FIND_PACKAGE(PCHSupport REQUIRED)
|
||||||
|
|
1
TODO
1
TODO
|
@ -29,3 +29,4 @@ bind every global lua function in a static class
|
||||||
use metatable for Point,Rect,Color,Size lua classes
|
use metatable for Point,Rect,Color,Size lua classes
|
||||||
lua binder generator
|
lua binder generator
|
||||||
restore win32 platform
|
restore win32 platform
|
||||||
|
set special types for g_configs like lists/point/size
|
|
@ -3,7 +3,11 @@ Module
|
||||||
description: Console for executing lua functions
|
description: Console for executing lua functions
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
|
|
||||||
|
// console can be loaded after core
|
||||||
autoLoad: true
|
autoLoad: true
|
||||||
|
autoLoadPriority: 20
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- core
|
- core
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
-- place any code for testing purposes here
|
|
@ -1,9 +1,6 @@
|
||||||
Module
|
Module
|
||||||
name: playground
|
name: playground
|
||||||
autoLoad: true
|
autoLoad: true
|
||||||
dependencies:
|
|
||||||
- core
|
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'playground'
|
require 'playground'
|
||||||
return true
|
return true
|
|
@ -1,13 +1,13 @@
|
||||||
OTClient = { }
|
Client = { }
|
||||||
|
|
||||||
-- TODO: load and save configurations
|
-- TODO: load and save configurations
|
||||||
function OTClient.init()
|
function Client.init()
|
||||||
g_window.move({ x=220, y=220 })
|
g_window.move({ x=220, y=220 })
|
||||||
g_window.resize({ width=800, height=600 })
|
g_window.resize({ width=800, height=600 })
|
||||||
g_window.setTitle('OTClient')
|
g_window.setTitle('OTClient')
|
||||||
g_window.setIcon('otcicon.png')
|
g_window.setIcon('clienticon.png')
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function OTClient.terminate()
|
function Client.terminate()
|
||||||
end
|
end
|
|
@ -0,0 +1,22 @@
|
||||||
|
Module
|
||||||
|
name: client
|
||||||
|
description: Load all other otclient dependecies
|
||||||
|
author: OTClient team
|
||||||
|
website: https://github.com/edubart/otclient
|
||||||
|
|
||||||
|
// NOTE: order does matter
|
||||||
|
dependencies:
|
||||||
|
- client_background
|
||||||
|
- client_topmenu
|
||||||
|
- client_tibiafiles
|
||||||
|
- client_about
|
||||||
|
- client_options
|
||||||
|
- client_entergame
|
||||||
|
- game
|
||||||
|
|
||||||
|
onLoad: |
|
||||||
|
require 'client'
|
||||||
|
return Client.init()
|
||||||
|
|
||||||
|
onUnload: |
|
||||||
|
Client.terminate()
|
Before Width: | Height: | Size: 518 B After Width: | Height: | Size: 518 B |
|
@ -1,16 +1,16 @@
|
||||||
About = {}
|
About = {}
|
||||||
|
|
||||||
-- private variables
|
-- private variables
|
||||||
local about
|
local aboutWindow
|
||||||
|
|
||||||
-- public functions
|
-- public functions
|
||||||
function About.create()
|
function About.create()
|
||||||
about = UI.display('about.otui', { locked = true })
|
aboutWindow = UI.display('about.otui', { locked = true })
|
||||||
end
|
end
|
||||||
|
|
||||||
function About.destroy()
|
function About.destroy()
|
||||||
about:destroy()
|
aboutWindow:destroy()
|
||||||
about = nil
|
aboutWindow = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function About.openWebpage()
|
function About.openWebpage()
|
|
@ -1,10 +1,8 @@
|
||||||
Module
|
Module
|
||||||
name: about
|
name: client_about
|
||||||
description: Create the about window
|
description: Create the about window
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
dependencies:
|
|
||||||
- core
|
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'about'
|
require 'about'
|
|
@ -1,10 +1,8 @@
|
||||||
Module
|
Module
|
||||||
name: background
|
name: client_background
|
||||||
description: Handles the background of the login screen
|
description: Handles the background of the login screen
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
dependencies:
|
|
||||||
- core
|
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'background'
|
require 'background'
|
|
@ -1,7 +1,7 @@
|
||||||
Panel
|
Panel
|
||||||
id: background
|
id: background
|
||||||
image:
|
image:
|
||||||
source: /background/background.png
|
source: /client_background/background.png
|
||||||
smooth: true
|
smooth: true
|
||||||
fixed ratio: true
|
fixed ratio: true
|
||||||
anchors.top: topMenu.bottom
|
anchors.top: topMenu.bottom
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 1.9 MiB |
|
@ -1,8 +1,9 @@
|
||||||
Module
|
Module
|
||||||
name: entergame
|
name: client_entergame
|
||||||
description: Manages enter game and character list windows
|
description: Manages enter game and character list windows
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'entergame'
|
require 'entergame'
|
||||||
require 'characterlist'
|
require 'characterlist'
|
|
@ -1,8 +1,9 @@
|
||||||
Module
|
Module
|
||||||
name: options
|
name: client_options
|
||||||
description: Create the options window
|
description: Create the options window
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'options'
|
require 'options'
|
||||||
return true
|
return true
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit e76fa2786e2a194375a110b700b7e2daa769f960
|
|
@ -1,13 +1,8 @@
|
||||||
Module
|
Module
|
||||||
name: topmenu
|
name: client_topmenu
|
||||||
description: Create the top menu
|
description: Create the top menu
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
dependencies:
|
|
||||||
- core
|
|
||||||
- entergame
|
|
||||||
- options
|
|
||||||
- about
|
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'topmenu'
|
require 'topmenu'
|
||||||
|
@ -16,4 +11,3 @@ Module
|
||||||
|
|
||||||
onUnload: |
|
onUnload: |
|
||||||
TopMenu.destroy()
|
TopMenu.destroy()
|
||||||
|
|
|
@ -3,19 +3,15 @@ Module
|
||||||
description: Contains lua classes, functions and constants used by other modules
|
description: Contains lua classes, functions and constants used by other modules
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
|
|
||||||
|
// core must be loaded before other modules
|
||||||
autoLoad: true
|
autoLoad: true
|
||||||
|
autoLoadPriority: 10
|
||||||
|
|
||||||
|
// NOTE: order does matter
|
||||||
dependencies:
|
dependencies:
|
||||||
- core_fonts
|
- core_fonts
|
||||||
- core_styles
|
- core_styles
|
||||||
|
- core_scripts
|
||||||
onLoad: |
|
- core_widgets
|
||||||
require 'ext/table'
|
|
||||||
require 'ext/string'
|
|
||||||
require 'constants'
|
|
||||||
require 'util'
|
|
||||||
require 'dispatcher'
|
|
||||||
require 'widget'
|
|
||||||
require 'ui'
|
|
||||||
require 'gfx'
|
|
||||||
return true
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 9.7 KiB |
|
@ -0,0 +1,16 @@
|
||||||
|
Module
|
||||||
|
name: core_scripts
|
||||||
|
description: Contains core lua classes, functions and constants used by other modules
|
||||||
|
author: OTClient team
|
||||||
|
website: https://github.com/edubart/otclient
|
||||||
|
|
||||||
|
onLoad: |
|
||||||
|
require 'ext/table'
|
||||||
|
require 'ext/string'
|
||||||
|
require 'constants'
|
||||||
|
require 'util'
|
||||||
|
require 'dispatcher'
|
||||||
|
require 'widget'
|
||||||
|
require 'ui'
|
||||||
|
require 'gfx'
|
||||||
|
return true
|
|
@ -12,16 +12,20 @@ function createEnvironment()
|
||||||
return env
|
return env
|
||||||
end
|
end
|
||||||
|
|
||||||
function connect(object, signalsAndSlots)
|
function connect(object, signalsAndSlots, pushFront)
|
||||||
for signal,slot in pairs(signalsAndSlots) do
|
for signal,slot in pairs(signalsAndSlots) do
|
||||||
if not object[signal] then
|
if not object[signal] then
|
||||||
object[signal] = slot
|
object[signal] = slot
|
||||||
elseif type(object[signal]) == 'function' then
|
elseif type(object[signal]) == 'function' then
|
||||||
object[signal] = { object[signal], slot }
|
object[signal] = { object[signal], slot }
|
||||||
elseif type(object[signal]) == 'table' then
|
elseif type(object[signal]) == 'table' then
|
||||||
|
if pushFront then
|
||||||
|
table.insert(object[signal], 1, slot)
|
||||||
|
else
|
||||||
table.insert(object[signal], #object[signal]+1, slot)
|
table.insert(object[signal], #object[signal]+1, slot)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function dumpWidgets()
|
function dumpWidgets()
|
|
@ -3,8 +3,7 @@ Module
|
||||||
description: Contains ui styles used by other modules
|
description: Contains ui styles used by other modules
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
dependencies:
|
|
||||||
- core_fonts
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
importStyles 'styles/buttons.otui'
|
importStyles 'styles/buttons.otui'
|
||||||
importStyles 'styles/labels.otui'
|
importStyles 'styles/labels.otui'
|
||||||
|
@ -17,4 +16,3 @@ Module
|
||||||
importStyles 'styles/items.otui'
|
importStyles 'styles/items.otui'
|
||||||
importStyles 'styles/creatures.otui'
|
importStyles 'styles/creatures.otui'
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
Module
|
||||||
|
name: core_widgets
|
||||||
|
description: Contains widgets used by other modules
|
||||||
|
author: OTClient team
|
||||||
|
website: https://github.com/edubart/otclient
|
||||||
|
|
||||||
|
onLoad: |
|
||||||
|
require 'tooltip/tooltip'
|
||||||
|
require 'messagebox/messagebox'
|
||||||
|
return true
|
|
@ -16,7 +16,7 @@ end
|
||||||
function Game.createInterface()
|
function Game.createInterface()
|
||||||
Background.hide()
|
Background.hide()
|
||||||
CharacterList.destroyLoadBox()
|
CharacterList.destroyLoadBox()
|
||||||
Game.gameUi = UI.display('/game/game.otui')
|
Game.gameUi = UI.display('game.otui')
|
||||||
UI.root:moveChildToIndex(Game.gameUi, 1)
|
UI.root:moveChildToIndex(Game.gameUi, 1)
|
||||||
Game.gameMapPanel = Game.gameUi:getChildById('mapPanel')
|
Game.gameMapPanel = Game.gameUi:getChildById('mapPanel')
|
||||||
Game.gameRightPanel = Game.gameUi:getChildById('rightPanel')
|
Game.gameRightPanel = Game.gameUi:getChildById('rightPanel')
|
||||||
|
@ -56,5 +56,5 @@ function Game.onConnectionError(message)
|
||||||
errorBox.onOk = CharacterList.show
|
errorBox.onOk = CharacterList.show
|
||||||
end
|
end
|
||||||
|
|
||||||
connect(Game, { onLogin = Game.createInterface,
|
connect(Game, { onLogin = Game.createInterface }, true)
|
||||||
onLogout = Game.destroyInterface })
|
connect(Game, { onLogout = Game.destroyInterface })
|
||||||
|
|
|
@ -3,6 +3,16 @@ Module
|
||||||
description: Create the game interface, where the ingame stuff starts
|
description: Create the game interface, where the ingame stuff starts
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
- game_healthbar
|
||||||
|
- game_inventory
|
||||||
|
- game_skills
|
||||||
|
- game_textmessage
|
||||||
|
- game_viplist
|
||||||
|
- game_chat
|
||||||
|
- game_outfit
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'game'
|
require 'game'
|
||||||
return true
|
return true
|
|
@ -1,5 +1,5 @@
|
||||||
Module
|
Module
|
||||||
name: chat
|
name: game_chat
|
||||||
description: Manage chat window
|
description: Manage chat window
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
|
@ -1,11 +1,11 @@
|
||||||
HealthMana = {}
|
HealthBar = {}
|
||||||
|
|
||||||
-- private variables
|
-- private variables
|
||||||
local healthManaPanel = nil
|
local healthManaPanel = nil
|
||||||
|
|
||||||
-- public functions
|
-- public functions
|
||||||
function HealthMana.create()
|
function HealthBar.create()
|
||||||
healthManaPanel = UI.display('health_mana.otui', { parent = Game.gameRightPanel })
|
healthManaPanel = UI.display('healthbar.otui', { parent = Game.gameRightPanel })
|
||||||
|
|
||||||
local healthBar = UIProgressBar.create()
|
local healthBar = UIProgressBar.create()
|
||||||
healthManaPanel:addChild(healthBar)
|
healthManaPanel:addChild(healthBar)
|
||||||
|
@ -32,7 +32,7 @@ function HealthMana.create()
|
||||||
healthManaPanel:setHeight(healthBar:getHeight() + manaBar:getHeight() + 4)
|
healthManaPanel:setHeight(healthBar:getHeight() + manaBar:getHeight() + 4)
|
||||||
end
|
end
|
||||||
|
|
||||||
function HealthMana.destroy()
|
function HealthBar.destroy()
|
||||||
healthManaPanel:destroy()
|
healthManaPanel:destroy()
|
||||||
healthManaPanel = nil
|
healthManaPanel = nil
|
||||||
end
|
end
|
||||||
|
@ -61,5 +61,5 @@ function Game.onManaChange(mana, maxMana)
|
||||||
manaBar:setPercent(percent)
|
manaBar:setPercent(percent)
|
||||||
end
|
end
|
||||||
|
|
||||||
connect(Game, { onLogin = HealthMana.create,
|
connect(Game, { onLogin = HealthBar.create,
|
||||||
onLogout = HealthMana.destroy })
|
onLogout = HealthBar.destroy })
|
|
@ -1,10 +1,10 @@
|
||||||
Module
|
Module
|
||||||
name: health_mana
|
name: game_healthbar
|
||||||
description: Displays health and mana points
|
description: Displays health and mana points
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'health_mana'
|
require 'healthbar'
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Module
|
Module
|
||||||
name: inventory
|
name: game_inventory
|
||||||
description: View local player equipments window
|
description: View local player equipments window
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
|
@ -1,5 +1,5 @@
|
||||||
Module
|
Module
|
||||||
name: outfit
|
name: game_outfit
|
||||||
description: Change local player outfit
|
description: Change local player outfit
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
|
@ -1,5 +1,5 @@
|
||||||
Module
|
Module
|
||||||
name: skills
|
name: game_skills
|
||||||
description: Manage skills window
|
description: Manage skills window
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
|
@ -1,7 +1,7 @@
|
||||||
TextMessage = {}
|
TextMessage = {}
|
||||||
|
|
||||||
-- require styles
|
-- require styles
|
||||||
importStyles '/textmessage/textmessage.otui'
|
importStyles 'textmessage.otui'
|
||||||
|
|
||||||
-- private variables
|
-- private variables
|
||||||
local bottomLabelWidget, centerLabelWidget
|
local bottomLabelWidget, centerLabelWidget
|
|
@ -1,5 +1,5 @@
|
||||||
Module
|
Module
|
||||||
name: textmessage
|
name: game_textmessage
|
||||||
description: Manage game text messages
|
description: Manage game text messages
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
|
@ -1,5 +1,5 @@
|
||||||
Module
|
Module
|
||||||
name: viplist
|
name: game_viplist
|
||||||
description: Manage vip list window
|
description: Manage vip list window
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
|
@ -1,12 +0,0 @@
|
||||||
Module
|
|
||||||
name: messagebox
|
|
||||||
description: Manages message boxes
|
|
||||||
author: OTClient team
|
|
||||||
website: https://github.com/edubart/otclient
|
|
||||||
autoLoad: true
|
|
||||||
dependencies:
|
|
||||||
- core
|
|
||||||
|
|
||||||
onLoad: |
|
|
||||||
require 'messagebox'
|
|
||||||
return true
|
|
|
@ -1,27 +0,0 @@
|
||||||
Module
|
|
||||||
name: otclient
|
|
||||||
description: Load all other otclient modules
|
|
||||||
author: OTClient team
|
|
||||||
website: https://github.com/edubart/otclient
|
|
||||||
autoLoad: true
|
|
||||||
autoLoadPriority: 10
|
|
||||||
dependencies:
|
|
||||||
- core
|
|
||||||
- background
|
|
||||||
- topmenu
|
|
||||||
- game
|
|
||||||
- health_mana
|
|
||||||
- inventory
|
|
||||||
- skills
|
|
||||||
- viplist
|
|
||||||
- textmessage
|
|
||||||
- chat
|
|
||||||
- outfit
|
|
||||||
- tibiafiles
|
|
||||||
|
|
||||||
onLoad: |
|
|
||||||
require 'otclient'
|
|
||||||
return OTClient.init()
|
|
||||||
|
|
||||||
onUnload: |
|
|
||||||
OTClient.terminate()
|
|
|
@ -1,24 +0,0 @@
|
||||||
-- place any code for testing purposes here
|
|
||||||
|
|
||||||
function UIItem.onMouseRelease(self, mousePos, mouseButton)
|
|
||||||
if mouseButton ~= MouseRightButton then return end
|
|
||||||
local top = self:getY()
|
|
||||||
local bottom = self:getY() + self:getHeight()
|
|
||||||
local left = self:getX()
|
|
||||||
local right = self:getX() + self:getWidth()
|
|
||||||
if not (mousePos.y >= top and mousePos.y <= bottom and mousePos.x >= left and mousePos.x <= right) then return end
|
|
||||||
|
|
||||||
local menuFile = self:getStyle()['popup menu']
|
|
||||||
if not menuFile then return end
|
|
||||||
|
|
||||||
local popupMenu = UI.display(menuFile)
|
|
||||||
if not popupMenu then return end
|
|
||||||
|
|
||||||
popupMenu:moveTo(mousePos)
|
|
||||||
popupMenu.onMouseRelease = function(self) self:destroy() end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function init()
|
|
||||||
end
|
|
||||||
|
|
||||||
addEvent(init)
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 8bb3b7d6d86e561be4622fbe7dbef208446a0319
|
|
|
@ -1,13 +0,0 @@
|
||||||
Module
|
|
||||||
name: tooltip
|
|
||||||
description: Enable tooltips on any button
|
|
||||||
author: OTClient team
|
|
||||||
website: https://github.com/edubart/otclient
|
|
||||||
autoLoad: true
|
|
||||||
autoLoadPriority: 2
|
|
||||||
dependencies:
|
|
||||||
- core
|
|
||||||
|
|
||||||
onLoad: |
|
|
||||||
require 'tooltip'
|
|
||||||
return true
|
|
|
@ -62,7 +62,7 @@ ENDIF(HANDLE_EXCEPTIONS)
|
||||||
|
|
||||||
|
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
SET(FRAMEWORK_SOURCES ${FRAMEWORK_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/platform/win32window.cpp)
|
SET(framework_SOURCES ${framework_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/platform/win32window.cpp)
|
||||||
SET(ADDITIONAL_LIBRARIES ws2_32 mswsock)
|
SET(ADDITIONAL_LIBRARIES ws2_32 mswsock)
|
||||||
|
|
||||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
@ -80,7 +80,7 @@ IF(WIN32)
|
||||||
ELSE(WIN32)
|
ELSE(WIN32)
|
||||||
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -rdynamic")
|
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -rdynamic")
|
||||||
SET(ADDITIONAL_LIBRARIES pthread)
|
SET(ADDITIONAL_LIBRARIES pthread)
|
||||||
SET(FRAMEWORK_SOURCES ${FRAMEWORK_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.cpp)
|
SET(framework_SOURCES ${framework_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.cpp)
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ INCLUDE_DIRECTORIES(
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/.."
|
"${CMAKE_CURRENT_LIST_DIR}/.."
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(FRAMEWORK_LIBRARIES
|
SET(framework_LIBRARIES
|
||||||
${Boost_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
${LUA_LIBRARIES}
|
${LUA_LIBRARIES}
|
||||||
|
@ -105,7 +105,7 @@ SET(FRAMEWORK_LIBRARIES
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
SET(FRAMEWORK_SOURCES ${FRAMEWORK_SOURCES}
|
SET(framework_SOURCES ${framework_SOURCES}
|
||||||
# framework
|
# framework
|
||||||
${CMAKE_CURRENT_LIST_DIR}/application.cpp
|
${CMAKE_CURRENT_LIST_DIR}/application.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/luafunctions.cpp
|
${CMAKE_CURRENT_LIST_DIR}/luafunctions.cpp
|
||||||
|
|
|
@ -103,33 +103,12 @@ void Application::init(const std::vector<std::string>& args, int appFlags)
|
||||||
resize(g_window.getSize());
|
resize(g_window.getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_appFlags & Fw::AppEnableModules) {
|
|
||||||
// search for modules directory
|
|
||||||
std::string baseDir = g_resources.getBaseDir();
|
|
||||||
std::string possibleDirs[] = { "modules",
|
|
||||||
baseDir + "modules",
|
|
||||||
baseDir + "../modules",
|
|
||||||
baseDir + "../share/" + m_appName + "/modules",
|
|
||||||
"" };
|
|
||||||
bool found = false;
|
|
||||||
for(const std::string& dir : possibleDirs) {
|
|
||||||
// try to add module directory
|
|
||||||
if(g_resources.addToSearchPath(dir)) {
|
|
||||||
logInfo("Using modules directory '", dir.c_str(), "'");
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!found)
|
|
||||||
logFatal("Could not find modules directory");
|
|
||||||
|
|
||||||
g_modules.discoverAndLoadModules();
|
|
||||||
}
|
|
||||||
|
|
||||||
// finally show the window
|
// finally show the window
|
||||||
if(m_appFlags & Fw::AppEnableGraphics)
|
if(m_appFlags & Fw::AppEnableGraphics)
|
||||||
g_window.show();
|
g_window.show();
|
||||||
|
|
||||||
|
if(m_appFlags & Fw::AppEnableModules)
|
||||||
|
g_modules.discoverModulesPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,6 @@ protected:
|
||||||
virtual void resize(const Size& size);
|
virtual void resize(const Size& size);
|
||||||
virtual void inputEvent(const InputEvent& event);
|
virtual void inputEvent(const InputEvent& event);
|
||||||
|
|
||||||
private:
|
|
||||||
std::string m_appName;
|
std::string m_appName;
|
||||||
int m_appFlags;
|
int m_appFlags;
|
||||||
int m_pollCycleDelay;
|
int m_pollCycleDelay;
|
||||||
|
|
|
@ -24,13 +24,12 @@
|
||||||
#include "resourcemanager.h"
|
#include "resourcemanager.h"
|
||||||
|
|
||||||
#include <framework/otml/otml.h>
|
#include <framework/otml/otml.h>
|
||||||
|
#include <framework/application.h>
|
||||||
|
|
||||||
ModuleManager g_modules;
|
ModuleManager g_modules;
|
||||||
|
|
||||||
void ModuleManager::discoverAndLoadModules()
|
void ModuleManager::discoverModules()
|
||||||
{
|
{
|
||||||
std::multimap<int, ModulePtr> m_autoLoadModules;
|
|
||||||
|
|
||||||
auto moduleDirs = g_resources.listDirectoryFiles("/");
|
auto moduleDirs = g_resources.listDirectoryFiles("/");
|
||||||
for(const std::string& moduleDir : moduleDirs) {
|
for(const std::string& moduleDir : moduleDirs) {
|
||||||
auto moduleFiles = g_resources.listDirectoryFiles("/" + moduleDir);
|
auto moduleFiles = g_resources.listDirectoryFiles("/" + moduleDir);
|
||||||
|
@ -42,14 +41,42 @@ void ModuleManager::discoverAndLoadModules()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModuleManager::autoLoadModules(int maxPriority)
|
||||||
|
{
|
||||||
for(auto& pair : m_autoLoadModules) {
|
for(auto& pair : m_autoLoadModules) {
|
||||||
|
int priority = pair.first;
|
||||||
|
if(priority > maxPriority)
|
||||||
|
break;
|
||||||
ModulePtr module = pair.second;
|
ModulePtr module = pair.second;
|
||||||
if(!module->isLoaded() && !module->load())
|
if(!module->isLoaded() && !module->load())
|
||||||
logFatal("A required module has failed to load, cannot continue to run.");
|
logFatal("A required module has failed to load, cannot continue to run.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModuleManager::discoverModulesPath()
|
||||||
|
{
|
||||||
|
// search for modules directory
|
||||||
|
std::string possibleDirs[] = { "modules",
|
||||||
|
g_resources.getBaseDir() + "modules",
|
||||||
|
g_resources.getBaseDir() + "../modules",
|
||||||
|
g_resources.getBaseDir() + "../share/" + g_app->getAppName() + "/modules",
|
||||||
|
"" };
|
||||||
|
bool found = false;
|
||||||
|
for(const std::string& dir : possibleDirs) {
|
||||||
|
// try to add module directory
|
||||||
|
if(g_resources.addToSearchPath(dir)) {
|
||||||
|
logInfo("Using modules directory '", dir.c_str(), "'");
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!found)
|
||||||
|
logFatal("Could not find modules directory");
|
||||||
|
}
|
||||||
|
|
||||||
ModulePtr ModuleManager::discoverModule(const std::string& moduleFile)
|
ModulePtr ModuleManager::discoverModule(const std::string& moduleFile)
|
||||||
{
|
{
|
||||||
ModulePtr module;
|
ModulePtr module;
|
||||||
|
@ -70,6 +97,13 @@ ModulePtr ModuleManager::discoverModule(const std::string& moduleFile)
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModuleManager::ensureModuleLoaded(const std::string& moduleName)
|
||||||
|
{
|
||||||
|
ModulePtr module = g_modules.getModule(moduleName);
|
||||||
|
if(!module || !module->load())
|
||||||
|
logFatal("Unable to load '", moduleName, "' module");
|
||||||
|
}
|
||||||
|
|
||||||
void ModuleManager::unloadModules()
|
void ModuleManager::unloadModules()
|
||||||
{
|
{
|
||||||
for(const ModulePtr& module : m_modules)
|
for(const ModulePtr& module : m_modules)
|
||||||
|
|
|
@ -28,14 +28,18 @@
|
||||||
class ModuleManager
|
class ModuleManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void discoverAndLoadModules();
|
void discoverModulesPath();
|
||||||
|
void discoverModules();
|
||||||
|
void autoLoadModules(int maxPriority);
|
||||||
ModulePtr discoverModule(const std::string& moduleFile);
|
ModulePtr discoverModule(const std::string& moduleFile);
|
||||||
|
void ensureModuleLoaded(const std::string& moduleName);
|
||||||
void unloadModules();
|
void unloadModules();
|
||||||
|
|
||||||
ModulePtr getModule(const std::string& moduleName);
|
ModulePtr getModule(const std::string& moduleName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<ModulePtr> m_modules;
|
std::vector<ModulePtr> m_modules;
|
||||||
|
std::multimap<int, ModulePtr> m_autoLoadModules;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ModuleManager g_modules;
|
extern ModuleManager g_modules;
|
||||||
|
|
|
@ -76,7 +76,7 @@ void Font::renderText(const std::string& text,
|
||||||
const Color& color)
|
const Color& color)
|
||||||
{
|
{
|
||||||
// prevent glitches from invalid rects
|
// prevent glitches from invalid rects
|
||||||
if(!screenCoords.isValid())
|
if(!screenCoords.isValid() || !m_texture)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int textLenght = text.length();
|
int textLenght = text.length();
|
||||||
|
|
|
@ -27,6 +27,11 @@
|
||||||
|
|
||||||
FontManager g_fonts;
|
FontManager g_fonts;
|
||||||
|
|
||||||
|
FontManager::FontManager()
|
||||||
|
{
|
||||||
|
m_defaultFont = FontPtr(new Font("emptyfont"));
|
||||||
|
}
|
||||||
|
|
||||||
void FontManager::releaseFonts()
|
void FontManager::releaseFonts()
|
||||||
{
|
{
|
||||||
m_defaultFont.reset();
|
m_defaultFont.reset();
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
class FontManager
|
class FontManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
FontManager();
|
||||||
|
|
||||||
/// Release fonts references, thus making possible to destruct them
|
/// Release fonts references, thus making possible to destruct them
|
||||||
void releaseFonts();
|
void releaseFonts();
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ ELSE(FORBIDDEN_FUNCTIONS)
|
||||||
MESSAGE(STATUS "Lua forbidden functions: OFF")
|
MESSAGE(STATUS "Lua forbidden functions: OFF")
|
||||||
ENDIF(FORBIDDEN_FUNCTIONS)
|
ENDIF(FORBIDDEN_FUNCTIONS)
|
||||||
|
|
||||||
SET(OTCLIENT_SOURCES ${OTCLIENT_SOURCES}
|
SET(otclient_SOURCES ${otclient_SOURCES}
|
||||||
# otclient
|
# otclient
|
||||||
${CMAKE_CURRENT_LIST_DIR}/otclient.cpp
|
${CMAKE_CURRENT_LIST_DIR}/otclient.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/luafunctions.cpp
|
${CMAKE_CURRENT_LIST_DIR}/luafunctions.cpp
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "otclient.h"
|
#include "otclient.h"
|
||||||
|
#include <framework/core/modulemanager.h>
|
||||||
|
|
||||||
OTClient::OTClient() : Application(Otc::AppCompactName)
|
OTClient::OTClient() : Application(Otc::AppCompactName)
|
||||||
{
|
{
|
||||||
|
@ -31,4 +32,10 @@ void OTClient::init(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
logInfo(Otc::AppName, " ", Otc::AppVersion);
|
logInfo(Otc::AppName, " ", Otc::AppVersion);
|
||||||
Application::init(args, Fw::AppEnableAll);
|
Application::init(args, Fw::AppEnableAll);
|
||||||
|
|
||||||
|
g_modules.discoverModules();
|
||||||
|
g_modules.autoLoadModules(100);
|
||||||
|
g_modules.ensureModuleLoaded("client");
|
||||||
|
g_modules.ensureModuleLoaded("game");
|
||||||
|
g_modules.autoLoadModules(1000);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue