improvements to skins

This commit is contained in:
Henrique Santiago 2012-06-19 05:46:49 -03:00
parent 5a048eb7ea
commit 4bdcae2f8b
74 changed files with 155 additions and 87 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

View File

@ -23,13 +23,11 @@ ModuleInfoLabel < Label
margin-top: 5 margin-top: 5
margin-bottom: 2 margin-bottom: 2
ModuleValueLabel < UILabel ModuleValueLabel < FlatLabel
font: verdana-11px-antialised font: verdana-11px-antialised
color: #aaaaaa color: #aaaaaa
text-offset: 2 3 text-offset: 2 3
padding-bottom: 5 padding-bottom: 5
image-source: /core_styles/styles/images/panel_flat.png
image-border: 1
height: 20 height: 20
MainWindow MainWindow

View File

@ -14,12 +14,20 @@ local function onSkinComboBoxOptionChange(self, optionText, optionData)
end end
end end
local function getSkinPath(name)
return g_modules.getModulesPath() .. g_lua.getCurrentSourcePath(0) .. '/skins/' .. string.lower(name) .. '/'
end
-- public functions -- public functions
function Skins.init() function Skins.init()
installedSkins = {} installedSkins = {}
Skins.installSkins('skins') Skins.installSkins('skins')
if installedSkins[defaultSkinName] then
g_resources.addToSearchPath(getSkinPath(defaultSkinName), 0)
end
local userSkinName = Settings.get('skin') local userSkinName = Settings.get('skin')
if userSkinName and Skins.setSkin(userSkinName) then if userSkinName and Skins.setSkin(userSkinName) then
info('Using configured skin: ' .. userSkinName) info('Using configured skin: ' .. userSkinName)
@ -40,6 +48,11 @@ function Skins.init()
end end
function Skins.terminate() function Skins.terminate()
g_resources.removeFromSearchPath(getSkinPath(defaultSkinName))
if currentSkin then
g_resources.removeFromSearchPath(getSkinPath(currentSkin.name))
end
installedSkins = nil installedSkins = nil
currentSkin = nil currentSkin = nil
skinComboBox = nil skinComboBox = nil
@ -51,8 +64,11 @@ function Skins.installSkin(skin)
return false return false
end end
if installedSkins[skin.name] then
warning(skin.name .. ' has been replaced.')
end
installedSkins[skin.name] = skin installedSkins[skin.name] = skin
-- todo: maybe combine styles if skin already exists
return true return true
end end
@ -67,11 +83,41 @@ function Skins.setSkin(name)
return false return false
end end
--g_ui.clearStyles() -- this is crashing g_fonts.clearFonts()
for i=1,#skin.styles do g_ui.clearStyles()
g_ui.importStyle('skins/' .. string.lower(name) .. '/' .. skin.styles[i])
if name ~= defaultSkinName then
local defaultSkin = installedSkins[defaultSkinName]
if not defaultSkin then
error("Default skin is not installed.")
return false
end end
Skins.loadSkin(defaultSkin)
end
if currentSkin then
g_resources.removeFromSearchPath(getSkinPath(currentSkin.name))
end
g_resources.addToSearchPath(getSkinPath(skin.name), true)
Skins.loadSkin(skin)
currentSkin = skin currentSkin = skin
return true return true
end end
function Skins.loadSkin(skin)
local lowerName = string.lower(skin.name)
for i=1,#skin.fonts do
g_fonts.importFont('skins/' .. lowerName .. '/fonts/' .. skin.fonts[i])
if i == 1 then
g_fonts.setDefaultFont(skin.fonts[i])
end
end
for i=1,#skin.styles do
g_ui.importStyle('skins/' .. lowerName .. '/styles/' .. skin.styles[i])
end
end

View File

@ -1,7 +1,32 @@
local skin = { local skin = {
name = 'Default', name = 'Default',
styles = {} -- first font is default
fonts = {
'verdana-11px-antialised',
'verdana-11px-monochrome',
'verdana-11px-rounded',
'terminus-14px-bold'
},
styles = {
'buttons.otui',
'labels.otui',
'panels.otui',
'separators.otui',
'textedits.otui',
'checkboxes.otui',
'progressbars.otui',
'tabbars.otui',
'windows.otui',
'listboxes.otui',
'popupmenus.otui',
'comboboxes.otui',
'spinboxes.otui',
'messageboxes.otui',
'scrollbars.otui',
'splitters.otui'
}
} }
Skins.installSkin(skin) Skins.installSkin(skin)

View File

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 230 B

View File

Before

Width:  |  Height:  |  Size: 266 B

After

Width:  |  Height:  |  Size: 266 B

View File

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 409 B

After

Width:  |  Height:  |  Size: 409 B

View File

Before

Width:  |  Height:  |  Size: 833 B

After

Width:  |  Height:  |  Size: 833 B

View File

Before

Width:  |  Height:  |  Size: 859 B

After

Width:  |  Height:  |  Size: 859 B

View File

Before

Width:  |  Height:  |  Size: 548 B

After

Width:  |  Height:  |  Size: 548 B

View File

Before

Width:  |  Height:  |  Size: 262 B

After

Width:  |  Height:  |  Size: 262 B

View File

Before

Width:  |  Height:  |  Size: 457 B

After

Width:  |  Height:  |  Size: 457 B

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 139 B

After

Width:  |  Height:  |  Size: 139 B

View File

Before

Width:  |  Height:  |  Size: 152 B

After

Width:  |  Height:  |  Size: 152 B

View File

Before

Width:  |  Height:  |  Size: 262 B

After

Width:  |  Height:  |  Size: 262 B

View File

Before

Width:  |  Height:  |  Size: 241 B

After

Width:  |  Height:  |  Size: 241 B

View File

Before

Width:  |  Height:  |  Size: 197 B

After

Width:  |  Height:  |  Size: 197 B

View File

Before

Width:  |  Height:  |  Size: 400 B

After

Width:  |  Height:  |  Size: 400 B

View File

Before

Width:  |  Height:  |  Size: 638 B

After

Width:  |  Height:  |  Size: 638 B

View File

Before

Width:  |  Height:  |  Size: 415 B

After

Width:  |  Height:  |  Size: 415 B

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -3,7 +3,7 @@ Button < UIButton
color: #f0ad4dff color: #f0ad4dff
size: 106 22 size: 106 22
text-offset: 0 0 text-offset: 0 0
image-source: /core_styles/styles/images/button.png image-source: /images/button.png
image-color: white image-color: white
image-clip: 0 0 20 20 image-clip: 0 0 20 20
image-border: 2 image-border: 2
@ -21,7 +21,7 @@ Button < UIButton
TabButton < UIButton TabButton < UIButton
size: 20 20 size: 20 20
image-source: /core_styles/styles/images/tabbutton.png image-source: /images/tabbutton.png
image-color: white image-color: white
image-clip: 0 0 20 20 image-clip: 0 0 20 20
image-border: 2 image-border: 2

View File

@ -1,12 +1,13 @@
CheckBox < UICheckBox CheckBox < UICheckBox
size: 16 16 size: 16 16
text-align: left text-align: left
text: aa
text-offset: 16 0 text-offset: 16 0
color: #aaaaaa color: #aaaaaa
image-color: #ffffffff image-color: #ffffffff
image-rect: 0 0 12 12 image-rect: 0 0 12 12
image-offset: 0 2 image-offset: 0 2
image-source: /core_styles/styles/images/checkbox.png image-source: /images/checkbox.png
$hover !disabled: $hover !disabled:
color: #cccccc color: #cccccc
@ -30,7 +31,7 @@ CheckBox < UICheckBox
ColorBox < UICheckBox ColorBox < UICheckBox
size: 16 16 size: 16 16
image-color: #ffffffff image-color: #ffffffff
image-source: /core_styles/styles/images/colorbox.png image-source: /images/colorbox.png
$checked: $checked:
image-clip: 16 0 16 16 image-clip: 16 0 16 16
@ -44,7 +45,7 @@ ButtonBox < UICheckBox
size: 106 22 size: 106 22
text-offset: 0 0 text-offset: 0 0
text-align: center text-align: center
image-source: /core_styles/styles/images/tabbutton.png image-source: /images/tabbutton.png
image-color: white image-color: white
image-clip: 0 0 20 20 image-clip: 0 0 20 20
image-border: 2 image-border: 2

View File

@ -14,14 +14,14 @@ ComboBoxPopupMenuButton < UIButton
color: #555555 color: #555555
ComboBoxPopupMenuSeparator < UIWidget ComboBoxPopupMenuSeparator < UIWidget
image-source: /core_styles/styles/images/combobox.png image-source: /images/combobox.png
image-repeated: true image-repeated: true
image-clip: 1 59 89 1 image-clip: 1 59 89 1
height: 1 height: 1
phantom: true phantom: true
ComboBoxPopupMenu < UIPopupMenu ComboBoxPopupMenu < UIPopupMenu
image-source: /core_styles/styles/images/combobox.png image-source: /images/combobox.png
image-clip: 0 60 89 20 image-clip: 0 60 89 20
image-border: 1 image-border: 1
image-border-top: 0 image-border-top: 0
@ -33,7 +33,7 @@ ComboBox < UIComboBox
size: 86 20 size: 86 20
text-offset: 3 0 text-offset: 3 0
text-align: left text-align: left
image-source: /core_styles/styles/images/combobox.png image-source: /images/combobox.png
image-border: 1 image-border: 1
image-border-right: 17 image-border-right: 17
image-clip: 0 0 89 20 image-clip: 0 0 89 20

View File

@ -11,7 +11,7 @@ FlatLabel < UILabel
size: 86 20 size: 86 20
text-offset: 3 3 text-offset: 3 3
text-margin: 3 text-margin: 3
image-source: /core_styles/styles/images/panel_flat.png image-source: /images/panel_flat.png
image-border: 1 image-border: 1
$disabled: $disabled:

View File

@ -5,9 +5,9 @@ ScrollablePanel < UIScrollArea
phantom: true phantom: true
FlatPanel < Panel FlatPanel < Panel
image-source: /core_styles/styles/images/panel_flat.png image-source: /images/panel_flat.png
image-border: 1 image-border: 1
ScrollableFlatPanel < ScrollablePanel ScrollableFlatPanel < ScrollablePanel
image-source: /core_styles/styles/images/panel_flat.png image-source: /images/panel_flat.png
image-border: 1 image-border: 1

View File

@ -17,7 +17,7 @@ PopupMenuButton < UIButton
PopupMenuSeparator < UIWidget PopupMenuSeparator < UIWidget
margin-left: 2 margin-left: 2
margin-right: 2 margin-right: 2
image-source: /core_styles/styles/images/menubox.png image-source: images/menubox.png
image-border-left: 1 image-border-left: 1
image-border-right: 1 image-border-right: 1
image-clip: 0 0 32 2 image-clip: 0 0 32 2
@ -26,7 +26,7 @@ PopupMenuSeparator < UIWidget
PopupMenu < UIPopupMenu PopupMenu < UIPopupMenu
width: 50 width: 50
image-source: /core_styles/styles/images/menubox.png image-source: images/menubox.png
image-border: 3 image-border: 3
padding-top: 3 padding-top: 3
padding-bottom: 3 padding-bottom: 3

View File

@ -2,7 +2,7 @@ ProgressBar < UIProgressBar
height: 16 height: 16
background-color: red background-color: red
border: 1 black border: 1 black
image-source: /core_styles/styles/images/progressbar.png image-source: /images/progressbar.png
image-border: 1 image-border: 1
ProgressRect < UIProgressRect ProgressRect < UIProgressRect

View File

@ -2,7 +2,7 @@ ScrollBarSlider < UIButton
id: sliderButton id: sliderButton
anchors.centerIn: parent anchors.centerIn: parent
size: 13 13 size: 13 13
image-source: images/scrollbar.png image-source: /images/scrollbar.png
image-clip: 0 26 13 13 image-clip: 0 26 13 13
image-border: 2 image-border: 2
image-color: #ffffffff image-color: #ffffffff
@ -17,7 +17,7 @@ VerticalScrollBar < UIScrollBar
orientation: vertical orientation: vertical
width: 13 width: 13
height: 39 height: 39
image-source: images/scrollbar.png image-source: /images/scrollbar.png
image-clip: 39 0 13 65 image-clip: 39 0 13 65
image-border: 1 image-border: 1
pixels-scroll: true pixels-scroll: true
@ -26,7 +26,7 @@ VerticalScrollBar < UIScrollBar
id: decrementButton id: decrementButton
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
image-source: images/scrollbar.png image-source: /images/scrollbar.png
image-clip: 0 0 13 13 image-clip: 0 0 13 13
image-color: #ffffffff image-color: #ffffffff
size: 13 13 size: 13 13
@ -42,7 +42,7 @@ VerticalScrollBar < UIScrollBar
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.right: parent.right anchors.right: parent.right
size: 13 13 size: 13 13
image-source: images/scrollbar.png image-source: /images/scrollbar.png
image-clip: 0 13 13 13 image-clip: 0 13 13 13
image-color: #ffffffff image-color: #ffffffff
$hover: $hover:
@ -58,7 +58,7 @@ HorizontalScrollBar < UIScrollBar
orientation: horizontal orientation: horizontal
height: 13 height: 13
width: 39 width: 39
image-source: images/scrollbar.png image-source: /images/scrollbar.png
image-clip: 0 65 52 13 image-clip: 0 65 52 13
image-border: 1 image-border: 1
@ -66,7 +66,7 @@ HorizontalScrollBar < UIScrollBar
id: decrementButton id: decrementButton
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
image-source: images/scrollbar.png image-source: /images/scrollbar.png
image-clip: 0 39 13 13 image-clip: 0 39 13 13
image-color: #ffffffff image-color: #ffffffff
size: 13 13 size: 13 13
@ -82,7 +82,7 @@ HorizontalScrollBar < UIScrollBar
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.right: parent.right anchors.right: parent.right
size: 13 13 size: 13 13
image-source: images/scrollbar.png image-source: /images/scrollbar.png
image-clip: 0 52 13 13 image-clip: 0 52 13 13
image-color: #ffffffff image-color: #ffffffff
$hover: $hover:

View File

@ -1,12 +1,12 @@
HorizontalSeparator < UIWidget HorizontalSeparator < UIWidget
image-source: /core_styles/styles/images/horizontal_separator.png image-source: /images/horizontal_separator.png
image-border-top: 2 image-border-top: 2
height: 2 height: 2
phantom: true phantom: true
focusable: false focusable: false
VerticalSeparator < UIWidget VerticalSeparator < UIWidget
image-source: /core_styles/styles/images/horizontal_separator.png image-source: /images/horizontal_separator.png
image-border-left: 2 image-border-left: 2
width: 2 width: 2
phantom: true phantom: true

View File

@ -4,7 +4,7 @@ SpinBox < UISpinBox
size: 86 20 size: 86 20
text-offset: 0 3 text-offset: 0 3
text-margin: 3 text-margin: 3
image-source: /core_styles/styles/images/panel_flat.png image-source: images/panel_flat.png
image-border: 1 image-border: 1
$disabled: $disabled:

View File

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

View File

@ -4,7 +4,7 @@ TextEdit < UITextEdit
size: 86 20 size: 86 20
text-offset: 0 3 text-offset: 0 3
text-margin: 3 text-margin: 3
image-source: /core_styles/styles/images/panel_flat.png image-source: /images/panel_flat.png
image-border: 1 image-border: 1
$disabled: $disabled:

View File

@ -5,7 +5,7 @@ Window < UIWindow
color: white color: white
text-offset: 0 4 text-offset: 0 4
text-align: top text-align: top
image-source: /core_styles/styles/images/window.png image-source: /images/window.png
image-border: 5 image-border: 5
image-border-top: 22 image-border-top: 22
opacity: 1 opacity: 1

View File

@ -1,6 +1,8 @@
local skin = { local skin = {
name = 'Example', name = 'Example',
fonts = {},
styles = { styles = {
'topmenu.otui' 'topmenu.otui'
} }

View File

@ -3,17 +3,17 @@ Mouse = {}
local cursorChanged = false local cursorChanged = false
function Mouse.setTargetCursor() function Mouse.setTargetCursor()
g_window.setMouseCursor('/core_styles/cursors/targetcursor.png', {x=9,y=9}) g_window.setMouseCursor('/cursors/targetcursor.png', {x=9,y=9})
cursorChanged = true cursorChanged = true
end end
function Mouse.setHorizontalCursor() function Mouse.setHorizontalCursor()
g_window.setMouseCursor('/core_styles/cursors/horizontal.png', {x=9,y=4}) g_window.setMouseCursor('/cursors/horizontal.png', {x=9,y=4})
cursorChanged = true cursorChanged = true
end end
function Mouse.setVerticalCursor() function Mouse.setVerticalCursor()
g_window.setMouseCursor('/core_styles/cursors/vertical.png', {x=4,y=9}) g_window.setMouseCursor('/cursors/vertical.png', {x=4,y=9})
cursorChanged = true cursorChanged = true
end end

View File

@ -1,32 +0,0 @@
Module
name: core_styles
description: Contains ui styles used by other modules
author: OTClient team
website: www.otclient.info
autoload: true
autoload-priority: 20
reloadable: false
@onLoad: |
importFont 'fonts/verdana-11px-antialised'
importFont 'fonts/verdana-11px-monochrome'
importFont 'fonts/verdana-11px-rounded'
importFont 'fonts/terminus-14px-bold'
setDefaultFont 'verdana-11px-antialised'
importStyle 'styles/buttons.otui'
importStyle 'styles/labels.otui'
importStyle 'styles/panels.otui'
importStyle 'styles/separators.otui'
importStyle 'styles/textedits.otui'
importStyle 'styles/checkboxes.otui'
importStyle 'styles/progressbars.otui'
importStyle 'styles/tabbars.otui'
importStyle 'styles/windows.otui'
importStyle 'styles/listboxes.otui'
importStyle 'styles/popupmenus.otui'
importStyle 'styles/comboboxes.otui'
importStyle 'styles/spinboxes.otui'
importStyle 'styles/messageboxes.otui'
importStyle 'styles/scrollbars.otui'
importStyle 'styles/splitters.otui'

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,5 +1,5 @@
Creature < UICreature Creature < UICreature
size: 80 80 size: 80 80
padding: 1 padding: 1
image-source: /core_styles/styles/images/panel_flat.png image-source: /images/panel_flat.png
image-border: 1 image-border: 1

View File

@ -1,6 +1,6 @@
Item < UIItem Item < UIItem
size: 34 34 size: 34 34
padding: 1 padding: 1
image-source: /core_styles/styles/images/item.png image-source: /game/images/item.png
font: verdana-11px-rounded font: verdana-11px-rounded
border-color: white border-color: white

View File

@ -37,9 +37,9 @@ local SpeakTypes = {
} }
local SayModes = { local SayModes = {
[1] = { speakTypeDesc = 'whisper', icon = '/core_styles/icons/whisper.png' }, [1] = { speakTypeDesc = 'whisper', icon = 'icons/whisper.png' },
[2] = { speakTypeDesc = 'say', icon = '/core_styles/icons/say.png' }, [2] = { speakTypeDesc = 'say', icon = 'icons/say.png' },
[3] = { speakTypeDesc = 'yell', icon = '/core_styles/icons/yell.png' } [3] = { speakTypeDesc = 'yell', icon = 'icons/yell.png' }
} }
local MAX_HISTORY = 1000 local MAX_HISTORY = 1000

View File

@ -40,7 +40,7 @@ Panel
TabButton TabButton
id: prevChannelButton id: prevChannelButton
icon: /core_styles/icons/leftarrow.png icon: icons/leftarrow.png
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
margin-left: 6 margin-left: 6
@ -56,7 +56,7 @@ Panel
TabButton TabButton
id: nextChannelButton id: nextChannelButton
icon: /core_styles/icons/rightarrow.png icon: icons/rightarrow.png
anchors.right: next.left anchors.right: next.left
anchors.top: parent.top anchors.top: parent.top
margin-right: 5 margin-right: 5
@ -65,7 +65,7 @@ Panel
TabButton TabButton
id: closeChannelButton id: closeChannelButton
!tooltip: tr('Close this channel') .. ' (Ctrl+E)' !tooltip: tr('Close this channel') .. ' (Ctrl+E)'
icon: /core_styles/icons/closechannel.png icon: icons/closechannel.png
anchors.right: next.left anchors.right: next.left
anchors.top: parent.top anchors.top: parent.top
enabled: false enabled: false
@ -76,7 +76,7 @@ Panel
TabButton TabButton
id: channelsButton id: channelsButton
!tooltip: tr('Open new channel') .. ' (Ctrl+O)' !tooltip: tr('Open new channel') .. ' (Ctrl+O)'
icon: /core_styles/icons/channels.png icon: icons/channels.png
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
margin-right: 5 margin-right: 5
@ -98,7 +98,7 @@ Panel
TabButton TabButton
id: sayModeButton id: sayModeButton
icon: /core_styles/icons/say.png icon: icons/say.png
!tooltip: tr('Adjust volume') !tooltip: tr('Adjust volume')
&sayMode: 2 &sayMode: 2
size: 20 20 size: 20 20

View File

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 245 B

View File

Before

Width:  |  Height:  |  Size: 300 B

After

Width:  |  Height:  |  Size: 300 B

View File

Before

Width:  |  Height:  |  Size: 271 B

After

Width:  |  Height:  |  Size: 271 B

View File

Before

Width:  |  Height:  |  Size: 285 B

After

Width:  |  Height:  |  Size: 285 B

View File

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 255 B

View File

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 255 B

View File

Before

Width:  |  Height:  |  Size: 266 B

After

Width:  |  Height:  |  Size: 266 B

View File

@ -57,14 +57,12 @@ MainWindow
margin-left: 5 margin-left: 5
margin-top: 5 margin-top: 5
Panel FlatPanel
height: 250 height: 250
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: prev.bottom anchors.top: prev.bottom
margin-top: 10 margin-top: 10
image-source: /core_styles/styles/images/panel_flat.png
image-border: 1
VerticalScrollBar VerticalScrollBar
id: itemsPanelListScrollBar id: itemsPanelListScrollBar

View File

@ -77,6 +77,7 @@ void ModuleManager::discoverModulesPath()
// try to add module directory // try to add module directory
if(g_resources.addToSearchPath(dir, false)) { if(g_resources.addToSearchPath(dir, false)) {
//g_logger.info(stdext::format("Using modules directory '%s'", dir.c_str())); //g_logger.info(stdext::format("Using modules directory '%s'", dir.c_str()));
m_modulesPath = dir;
found = true; found = true;
break; break;
} }

View File

@ -37,6 +37,7 @@ public:
void ensureModuleLoaded(const std::string& moduleName); void ensureModuleLoaded(const std::string& moduleName);
void unloadModules(); void unloadModules();
void reloadModules(); void reloadModules();
std::string getModulesPath() { return m_modulesPath; }
ModulePtr getModule(const std::string& moduleName); ModulePtr getModule(const std::string& moduleName);
std::deque<ModulePtr> getModules() { return m_modules; } std::deque<ModulePtr> getModules() { return m_modules; }
@ -47,6 +48,7 @@ protected:
friend class Module; friend class Module;
private: private:
std::string m_modulesPath;
std::deque<ModulePtr> m_modules; std::deque<ModulePtr> m_modules;
std::multimap<int, ModulePtr> m_autoLoadModules; std::multimap<int, ModulePtr> m_autoLoadModules;
}; };

View File

@ -66,6 +66,13 @@ bool ResourceManager::addToSearchPath(const std::string& path, bool insertInFron
return true; return true;
} }
bool ResourceManager::removeFromSearchPath(const std::string& path)
{
if(!PHYSFS_removeFromSearchPath(path.c_str()))
return false;
return true;
}
void ResourceManager::searchAndAddPackages(const std::string& packagesDir, const std::string& packageExt, bool append) void ResourceManager::searchAndAddPackages(const std::string& packagesDir, const std::string& packageExt, bool append)
{ {
auto files = listDirectoryFiles(resolvePath(packagesDir)); auto files = listDirectoryFiles(resolvePath(packagesDir));

View File

@ -34,6 +34,7 @@ public:
bool setupWriteDir(const std::string& appWriteDirName); bool setupWriteDir(const std::string& appWriteDirName);
bool addToSearchPath(const std::string& path, bool insertInFront = true); bool addToSearchPath(const std::string& path, bool insertInFront = true);
bool removeFromSearchPath(const std::string& path);
void searchAndAddPackages(const std::string& packagesDir, const std::string& packagesExt, bool append); void searchAndAddPackages(const std::string& packagesDir, const std::string& packagesExt, bool append);
bool fileExists(const std::string& fileName); bool fileExists(const std::string& fileName);

View File

@ -38,6 +38,12 @@ void FontManager::terminate()
m_defaultFont = nullptr; m_defaultFont = nullptr;
} }
void FontManager::clearFonts()
{
m_fonts.clear();
m_defaultFont = BitmapFontPtr(new BitmapFont("emptyfont"));
}
bool FontManager::importFont(std::string fontFile) bool FontManager::importFont(std::string fontFile)
{ {
try { try {

View File

@ -31,6 +31,7 @@ public:
FontManager(); FontManager();
void terminate(); void terminate();
void clearFonts();
bool importFont(std::string fontFile); bool importFont(std::string fontFile);

View File

@ -120,7 +120,7 @@ void PainterOGL2::drawCoords(CoordsBuffer& coordsBuffer, DrawMode drawMode)
void PainterOGL2::drawTextureCoords(CoordsBuffer& coordsBuffer, const TexturePtr& texture) void PainterOGL2::drawTextureCoords(CoordsBuffer& coordsBuffer, const TexturePtr& texture)
{ {
if(texture->isEmpty()) if(texture && texture->isEmpty())
return; return;
setDrawProgram(m_shaderProgram ? m_shaderProgram : m_drawTexturedProgram.get()); setDrawProgram(m_shaderProgram ? m_shaderProgram : m_drawTexturedProgram.get());

View File

@ -34,6 +34,7 @@
#include <framework/core/module.h> #include <framework/core/module.h>
#include <framework/sound/soundmanager.h> #include <framework/sound/soundmanager.h>
#include <framework/util/crypt.h> #include <framework/util/crypt.h>
#include <framework/core/resourcemanager.h>
void Application::registerLuaFunctions() void Application::registerLuaFunctions()
{ {
@ -601,9 +602,11 @@ void Application::registerLuaFunctions()
g_lua.bindSingletonFunction("g_modules", "reloadModules", &ModuleManager::reloadModules, &g_modules); g_lua.bindSingletonFunction("g_modules", "reloadModules", &ModuleManager::reloadModules, &g_modules);
g_lua.bindSingletonFunction("g_modules", "getModule", &ModuleManager::getModule, &g_modules); g_lua.bindSingletonFunction("g_modules", "getModule", &ModuleManager::getModule, &g_modules);
g_lua.bindSingletonFunction("g_modules", "getModules", &ModuleManager::getModules, &g_modules); g_lua.bindSingletonFunction("g_modules", "getModules", &ModuleManager::getModules, &g_modules);
g_lua.bindSingletonFunction("g_modules", "getModulesPath", &ModuleManager::getModulesPath, &g_modules);
// FontManager // FontManager
g_lua.registerSingletonClass("g_fonts"); g_lua.registerSingletonClass("g_fonts");
g_lua.bindSingletonFunction("g_fonts", "clearFonts", &FontManager::clearFonts, &g_fonts);
g_lua.bindSingletonFunction("g_fonts", "importFont", &FontManager::importFont, &g_fonts); g_lua.bindSingletonFunction("g_fonts", "importFont", &FontManager::importFont, &g_fonts);
g_lua.bindSingletonFunction("g_fonts", "fontExists", &FontManager::fontExists, &g_fonts); g_lua.bindSingletonFunction("g_fonts", "fontExists", &FontManager::fontExists, &g_fonts);
g_lua.bindSingletonFunction("g_fonts", "setDefaultFont", &FontManager::setDefaultFont, &g_fonts); g_lua.bindSingletonFunction("g_fonts", "setDefaultFont", &FontManager::setDefaultFont, &g_fonts);
@ -626,4 +629,15 @@ void Application::registerLuaFunctions()
g_lua.bindSingletonFunction("g_eventDispatcher", "addEvent", &EventDispatcher::addEvent, &g_eventDispatcher); g_lua.bindSingletonFunction("g_eventDispatcher", "addEvent", &EventDispatcher::addEvent, &g_eventDispatcher);
g_lua.bindSingletonFunction("g_eventDispatcher", "scheduleEvent", &EventDispatcher::scheduleEvent, &g_eventDispatcher); g_lua.bindSingletonFunction("g_eventDispatcher", "scheduleEvent", &EventDispatcher::scheduleEvent, &g_eventDispatcher);
g_lua.bindSingletonFunction("g_eventDispatcher", "cycleEvent", &EventDispatcher::cycleEvent, &g_eventDispatcher); g_lua.bindSingletonFunction("g_eventDispatcher", "cycleEvent", &EventDispatcher::cycleEvent, &g_eventDispatcher);
// ResourceManager
g_lua.registerSingletonClass("g_resources");
g_lua.bindSingletonFunction("g_resources", "addToSearchPath", &ResourceManager::addToSearchPath, &g_resources);
g_lua.bindSingletonFunction("g_resources", "removeFromSearchPath", &ResourceManager::removeFromSearchPath, &g_resources);
g_lua.bindSingletonFunction("g_resources", "fileExists", &ResourceManager::fileExists, &g_resources);
// LuaInterface
g_lua.registerSingletonClass("g_lua");
g_lua.bindSingletonFunction("g_lua", "getCurrentSourcePath", &LuaInterface::getCurrentSourcePath, &g_lua);
} }

View File

@ -112,8 +112,6 @@ public:
void draw(const Point& dest, float scaleFactor, int layer, int xPattern, int yPattern, int zPattern, int animationPhase); void draw(const Point& dest, float scaleFactor, int layer, int xPattern, int yPattern, int zPattern, int animationPhase);
void drawMask(const Point& dest, float scaleFactor, int w, int h, int xPattern, int yPattern, int zPattern, int layer, int animationPhase, SpriteMask mask); void drawMask(const Point& dest, float scaleFactor, int w, int h, int xPattern, int yPattern, int zPattern, int layer, int animationPhase, SpriteMask mask);
TexturePtr& getSprite(int w, int h, int l, int x, int y, int z, int a);
TexturePtr& getSpriteMask(int w, int h, int l, int x, int y, int z, int a, SpriteMask mask);
TexturePtr& getTexture(int animationPhase); TexturePtr& getTexture(int animationPhase);
bool getProperty(Property property) { return m_properties[property]; } bool getProperty(Property property) { return m_properties[property]; }