diff --git a/modules/client_locales/locales/en-us.png b/modules/client_locales/locales/en-us.png new file mode 100644 index 00000000..66e86a15 Binary files /dev/null and b/modules/client_locales/locales/en-us.png differ diff --git a/modules/client_locales/locales/pt-br.png b/modules/client_locales/locales/pt-br.png new file mode 100644 index 00000000..60a5ffc8 Binary files /dev/null and b/modules/client_locales/locales/pt-br.png differ diff --git a/modules/client_modulemanager/modulemanager.otui b/modules/client_modulemanager/modulemanager.otui index 69fe14e6..e4a97812 100644 --- a/modules/client_modulemanager/modulemanager.otui +++ b/modules/client_modulemanager/modulemanager.otui @@ -23,13 +23,11 @@ ModuleInfoLabel < Label margin-top: 5 margin-bottom: 2 -ModuleValueLabel < UILabel +ModuleValueLabel < FlatLabel font: verdana-11px-antialised color: #aaaaaa text-offset: 2 3 padding-bottom: 5 - image-source: /core_styles/styles/images/panel_flat.png - image-border: 1 height: 20 MainWindow diff --git a/modules/client_skins/skins.lua b/modules/client_skins/skins.lua index 2956d284..93f0d841 100644 --- a/modules/client_skins/skins.lua +++ b/modules/client_skins/skins.lua @@ -14,12 +14,20 @@ local function onSkinComboBoxOptionChange(self, optionText, optionData) end end +local function getSkinPath(name) + return g_modules.getModulesPath() .. g_lua.getCurrentSourcePath(0) .. '/skins/' .. string.lower(name) .. '/' +end + -- public functions function Skins.init() installedSkins = {} Skins.installSkins('skins') + if installedSkins[defaultSkinName] then + g_resources.addToSearchPath(getSkinPath(defaultSkinName), 0) + end + local userSkinName = Settings.get('skin') if userSkinName and Skins.setSkin(userSkinName) then info('Using configured skin: ' .. userSkinName) @@ -40,6 +48,11 @@ function Skins.init() end function Skins.terminate() + g_resources.removeFromSearchPath(getSkinPath(defaultSkinName)) + if currentSkin then + g_resources.removeFromSearchPath(getSkinPath(currentSkin.name)) + end + installedSkins = nil currentSkin = nil skinComboBox = nil @@ -51,8 +64,11 @@ function Skins.installSkin(skin) return false end + if installedSkins[skin.name] then + warning(skin.name .. ' has been replaced.') + end + installedSkins[skin.name] = skin - -- todo: maybe combine styles if skin already exists return true end @@ -67,11 +83,41 @@ function Skins.setSkin(name) return false end - --g_ui.clearStyles() -- this is crashing - for i=1,#skin.styles do - g_ui.importStyle('skins/' .. string.lower(name) .. '/' .. skin.styles[i]) + g_fonts.clearFonts() + g_ui.clearStyles() + + if name ~= defaultSkinName then + local defaultSkin = installedSkins[defaultSkinName] + if not defaultSkin then + error("Default skin is not installed.") + return false + 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 return true 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 diff --git a/modules/client_skins/skins/default.lua b/modules/client_skins/skins/default.lua index 4d326003..b00a4bb9 100644 --- a/modules/client_skins/skins/default.lua +++ b/modules/client_skins/skins/default.lua @@ -1,7 +1,32 @@ 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) diff --git a/modules/core_styles/cursors/horizontal.png b/modules/client_skins/skins/default/cursors/horizontal.png similarity index 100% rename from modules/core_styles/cursors/horizontal.png rename to modules/client_skins/skins/default/cursors/horizontal.png diff --git a/modules/core_styles/cursors/targetcursor.png b/modules/client_skins/skins/default/cursors/targetcursor.png similarity index 100% rename from modules/core_styles/cursors/targetcursor.png rename to modules/client_skins/skins/default/cursors/targetcursor.png diff --git a/modules/core_styles/cursors/vertical.png b/modules/client_skins/skins/default/cursors/vertical.png similarity index 100% rename from modules/core_styles/cursors/vertical.png rename to modules/client_skins/skins/default/cursors/vertical.png diff --git a/modules/core_styles/fonts/terminus-14px-bold.otfont b/modules/client_skins/skins/default/fonts/terminus-14px-bold.otfont similarity index 100% rename from modules/core_styles/fonts/terminus-14px-bold.otfont rename to modules/client_skins/skins/default/fonts/terminus-14px-bold.otfont diff --git a/modules/core_styles/fonts/terminus-14px-bold.png b/modules/client_skins/skins/default/fonts/terminus-14px-bold.png similarity index 100% rename from modules/core_styles/fonts/terminus-14px-bold.png rename to modules/client_skins/skins/default/fonts/terminus-14px-bold.png diff --git a/modules/core_styles/fonts/verdana-11px-antialised.otfont b/modules/client_skins/skins/default/fonts/verdana-11px-antialised.otfont similarity index 100% rename from modules/core_styles/fonts/verdana-11px-antialised.otfont rename to modules/client_skins/skins/default/fonts/verdana-11px-antialised.otfont diff --git a/modules/core_styles/fonts/verdana-11px-antialised.png b/modules/client_skins/skins/default/fonts/verdana-11px-antialised.png similarity index 100% rename from modules/core_styles/fonts/verdana-11px-antialised.png rename to modules/client_skins/skins/default/fonts/verdana-11px-antialised.png diff --git a/modules/core_styles/fonts/verdana-11px-monochrome.otfont b/modules/client_skins/skins/default/fonts/verdana-11px-monochrome.otfont similarity index 100% rename from modules/core_styles/fonts/verdana-11px-monochrome.otfont rename to modules/client_skins/skins/default/fonts/verdana-11px-monochrome.otfont diff --git a/modules/core_styles/fonts/verdana-11px-monochrome.png b/modules/client_skins/skins/default/fonts/verdana-11px-monochrome.png similarity index 100% rename from modules/core_styles/fonts/verdana-11px-monochrome.png rename to modules/client_skins/skins/default/fonts/verdana-11px-monochrome.png diff --git a/modules/core_styles/fonts/verdana-11px-rounded.otfont b/modules/client_skins/skins/default/fonts/verdana-11px-rounded.otfont similarity index 100% rename from modules/core_styles/fonts/verdana-11px-rounded.otfont rename to modules/client_skins/skins/default/fonts/verdana-11px-rounded.otfont diff --git a/modules/core_styles/fonts/verdana-11px-rounded.png b/modules/client_skins/skins/default/fonts/verdana-11px-rounded.png similarity index 100% rename from modules/core_styles/fonts/verdana-11px-rounded.png rename to modules/client_skins/skins/default/fonts/verdana-11px-rounded.png diff --git a/modules/core_styles/styles/images/button.png b/modules/client_skins/skins/default/images/button.png similarity index 100% rename from modules/core_styles/styles/images/button.png rename to modules/client_skins/skins/default/images/button.png diff --git a/modules/core_styles/styles/images/button_down.png b/modules/client_skins/skins/default/images/button_down.png similarity index 100% rename from modules/core_styles/styles/images/button_down.png rename to modules/client_skins/skins/default/images/button_down.png diff --git a/modules/core_styles/styles/images/button_hover.png b/modules/client_skins/skins/default/images/button_hover.png similarity index 100% rename from modules/core_styles/styles/images/button_hover.png rename to modules/client_skins/skins/default/images/button_hover.png diff --git a/modules/core_styles/styles/images/checkbox.png b/modules/client_skins/skins/default/images/checkbox.png similarity index 100% rename from modules/core_styles/styles/images/checkbox.png rename to modules/client_skins/skins/default/images/checkbox.png diff --git a/modules/core_styles/styles/images/colorbox.png b/modules/client_skins/skins/default/images/colorbox.png similarity index 100% rename from modules/core_styles/styles/images/colorbox.png rename to modules/client_skins/skins/default/images/colorbox.png diff --git a/modules/core_styles/styles/images/combobox.png b/modules/client_skins/skins/default/images/combobox.png similarity index 100% rename from modules/core_styles/styles/images/combobox.png rename to modules/client_skins/skins/default/images/combobox.png diff --git a/modules/core_styles/styles/images/container_bg.png b/modules/client_skins/skins/default/images/container_bg.png similarity index 100% rename from modules/core_styles/styles/images/container_bg.png rename to modules/client_skins/skins/default/images/container_bg.png diff --git a/modules/core_styles/styles/images/horizontal_separator.png b/modules/client_skins/skins/default/images/horizontal_separator.png similarity index 100% rename from modules/core_styles/styles/images/horizontal_separator.png rename to modules/client_skins/skins/default/images/horizontal_separator.png diff --git a/modules/core_styles/styles/images/horizotal_separator.png b/modules/client_skins/skins/default/images/horizotal_separator.png similarity index 100% rename from modules/core_styles/styles/images/horizotal_separator.png rename to modules/client_skins/skins/default/images/horizotal_separator.png diff --git a/modules/core_styles/styles/images/menu.png b/modules/client_skins/skins/default/images/menu.png similarity index 100% rename from modules/core_styles/styles/images/menu.png rename to modules/client_skins/skins/default/images/menu.png diff --git a/modules/core_styles/styles/images/menubox.png b/modules/client_skins/skins/default/images/menubox.png similarity index 100% rename from modules/core_styles/styles/images/menubox.png rename to modules/client_skins/skins/default/images/menubox.png diff --git a/modules/core_styles/styles/images/panel_flat.png b/modules/client_skins/skins/default/images/panel_flat.png similarity index 100% rename from modules/core_styles/styles/images/panel_flat.png rename to modules/client_skins/skins/default/images/panel_flat.png diff --git a/modules/core_styles/styles/images/progressbar.png b/modules/client_skins/skins/default/images/progressbar.png similarity index 100% rename from modules/core_styles/styles/images/progressbar.png rename to modules/client_skins/skins/default/images/progressbar.png diff --git a/modules/core_styles/styles/images/scrollbar.png b/modules/client_skins/skins/default/images/scrollbar.png similarity index 100% rename from modules/core_styles/styles/images/scrollbar.png rename to modules/client_skins/skins/default/images/scrollbar.png diff --git a/modules/core_styles/styles/images/tabbutton.png b/modules/client_skins/skins/default/images/tabbutton.png similarity index 100% rename from modules/core_styles/styles/images/tabbutton.png rename to modules/client_skins/skins/default/images/tabbutton.png diff --git a/modules/core_styles/styles/images/window.png b/modules/client_skins/skins/default/images/window.png similarity index 100% rename from modules/core_styles/styles/images/window.png rename to modules/client_skins/skins/default/images/window.png diff --git a/modules/core_styles/styles/buttons.otui b/modules/client_skins/skins/default/styles/buttons.otui similarity index 82% rename from modules/core_styles/styles/buttons.otui rename to modules/client_skins/skins/default/styles/buttons.otui index 4d41f58f..ec6fe756 100644 --- a/modules/core_styles/styles/buttons.otui +++ b/modules/client_skins/skins/default/styles/buttons.otui @@ -3,7 +3,7 @@ Button < UIButton color: #f0ad4dff size: 106 22 text-offset: 0 0 - image-source: /core_styles/styles/images/button.png + image-source: /images/button.png image-color: white image-clip: 0 0 20 20 image-border: 2 @@ -21,7 +21,7 @@ Button < UIButton TabButton < UIButton size: 20 20 - image-source: /core_styles/styles/images/tabbutton.png + image-source: /images/tabbutton.png image-color: white image-clip: 0 0 20 20 image-border: 2 diff --git a/modules/core_styles/styles/checkboxes.otui b/modules/client_skins/skins/default/styles/checkboxes.otui similarity index 84% rename from modules/core_styles/styles/checkboxes.otui rename to modules/client_skins/skins/default/styles/checkboxes.otui index bc054c25..96144653 100644 --- a/modules/core_styles/styles/checkboxes.otui +++ b/modules/client_skins/skins/default/styles/checkboxes.otui @@ -1,12 +1,13 @@ CheckBox < UICheckBox size: 16 16 text-align: left + text: aa text-offset: 16 0 color: #aaaaaa image-color: #ffffffff image-rect: 0 0 12 12 image-offset: 0 2 - image-source: /core_styles/styles/images/checkbox.png + image-source: /images/checkbox.png $hover !disabled: color: #cccccc @@ -30,7 +31,7 @@ CheckBox < UICheckBox ColorBox < UICheckBox size: 16 16 image-color: #ffffffff - image-source: /core_styles/styles/images/colorbox.png + image-source: /images/colorbox.png $checked: image-clip: 16 0 16 16 @@ -44,7 +45,7 @@ ButtonBox < UICheckBox size: 106 22 text-offset: 0 0 text-align: center - image-source: /core_styles/styles/images/tabbutton.png + image-source: /images/tabbutton.png image-color: white image-clip: 0 0 20 20 image-border: 2 diff --git a/modules/core_styles/styles/comboboxes.otui b/modules/client_skins/skins/default/styles/comboboxes.otui similarity index 81% rename from modules/core_styles/styles/comboboxes.otui rename to modules/client_skins/skins/default/styles/comboboxes.otui index b6759ac8..77530a5d 100644 --- a/modules/core_styles/styles/comboboxes.otui +++ b/modules/client_skins/skins/default/styles/comboboxes.otui @@ -14,14 +14,14 @@ ComboBoxPopupMenuButton < UIButton color: #555555 ComboBoxPopupMenuSeparator < UIWidget - image-source: /core_styles/styles/images/combobox.png + image-source: /images/combobox.png image-repeated: true image-clip: 1 59 89 1 height: 1 phantom: true ComboBoxPopupMenu < UIPopupMenu - image-source: /core_styles/styles/images/combobox.png + image-source: /images/combobox.png image-clip: 0 60 89 20 image-border: 1 image-border-top: 0 @@ -33,7 +33,7 @@ ComboBox < UIComboBox size: 86 20 text-offset: 3 0 text-align: left - image-source: /core_styles/styles/images/combobox.png + image-source: /images/combobox.png image-border: 1 image-border-right: 17 image-clip: 0 0 89 20 diff --git a/modules/core_styles/styles/labels.otui b/modules/client_skins/skins/default/styles/labels.otui similarity index 85% rename from modules/core_styles/styles/labels.otui rename to modules/client_skins/skins/default/styles/labels.otui index fdd8e639..64fa16c7 100644 --- a/modules/core_styles/styles/labels.otui +++ b/modules/client_skins/skins/default/styles/labels.otui @@ -11,7 +11,7 @@ FlatLabel < UILabel size: 86 20 text-offset: 3 3 text-margin: 3 - image-source: /core_styles/styles/images/panel_flat.png + image-source: /images/panel_flat.png image-border: 1 $disabled: diff --git a/modules/core_styles/styles/listboxes.otui b/modules/client_skins/skins/default/styles/listboxes.otui similarity index 100% rename from modules/core_styles/styles/listboxes.otui rename to modules/client_skins/skins/default/styles/listboxes.otui diff --git a/modules/core_styles/styles/messageboxes.otui b/modules/client_skins/skins/default/styles/messageboxes.otui similarity index 100% rename from modules/core_styles/styles/messageboxes.otui rename to modules/client_skins/skins/default/styles/messageboxes.otui diff --git a/modules/core_styles/styles/panels.otui b/modules/client_skins/skins/default/styles/panels.otui similarity index 54% rename from modules/core_styles/styles/panels.otui rename to modules/client_skins/skins/default/styles/panels.otui index 9646dced..5c73110c 100644 --- a/modules/core_styles/styles/panels.otui +++ b/modules/client_skins/skins/default/styles/panels.otui @@ -5,9 +5,9 @@ ScrollablePanel < UIScrollArea phantom: true FlatPanel < Panel - image-source: /core_styles/styles/images/panel_flat.png + image-source: /images/panel_flat.png image-border: 1 ScrollableFlatPanel < ScrollablePanel - image-source: /core_styles/styles/images/panel_flat.png + image-source: /images/panel_flat.png image-border: 1 \ No newline at end of file diff --git a/modules/core_styles/styles/popupmenus.otui b/modules/client_skins/skins/default/styles/popupmenus.otui similarity index 82% rename from modules/core_styles/styles/popupmenus.otui rename to modules/client_skins/skins/default/styles/popupmenus.otui index cacf56c3..ced01968 100644 --- a/modules/core_styles/styles/popupmenus.otui +++ b/modules/client_skins/skins/default/styles/popupmenus.otui @@ -17,7 +17,7 @@ PopupMenuButton < UIButton PopupMenuSeparator < UIWidget margin-left: 2 margin-right: 2 - image-source: /core_styles/styles/images/menubox.png + image-source: images/menubox.png image-border-left: 1 image-border-right: 1 image-clip: 0 0 32 2 @@ -26,7 +26,7 @@ PopupMenuSeparator < UIWidget PopupMenu < UIPopupMenu width: 50 - image-source: /core_styles/styles/images/menubox.png + image-source: images/menubox.png image-border: 3 padding-top: 3 padding-bottom: 3 diff --git a/modules/core_styles/styles/progressbars.otui b/modules/client_skins/skins/default/styles/progressbars.otui similarity index 80% rename from modules/core_styles/styles/progressbars.otui rename to modules/client_skins/skins/default/styles/progressbars.otui index 0793c354..4ab1dd35 100644 --- a/modules/core_styles/styles/progressbars.otui +++ b/modules/client_skins/skins/default/styles/progressbars.otui @@ -2,7 +2,7 @@ ProgressBar < UIProgressBar height: 16 background-color: red border: 1 black - image-source: /core_styles/styles/images/progressbar.png + image-source: /images/progressbar.png image-border: 1 ProgressRect < UIProgressRect diff --git a/modules/core_styles/styles/scrollbars.otui b/modules/client_skins/skins/default/styles/scrollbars.otui similarity index 86% rename from modules/core_styles/styles/scrollbars.otui rename to modules/client_skins/skins/default/styles/scrollbars.otui index 5649330b..62c9111b 100644 --- a/modules/core_styles/styles/scrollbars.otui +++ b/modules/client_skins/skins/default/styles/scrollbars.otui @@ -2,7 +2,7 @@ ScrollBarSlider < UIButton id: sliderButton anchors.centerIn: parent size: 13 13 - image-source: images/scrollbar.png + image-source: /images/scrollbar.png image-clip: 0 26 13 13 image-border: 2 image-color: #ffffffff @@ -17,7 +17,7 @@ VerticalScrollBar < UIScrollBar orientation: vertical width: 13 height: 39 - image-source: images/scrollbar.png + image-source: /images/scrollbar.png image-clip: 39 0 13 65 image-border: 1 pixels-scroll: true @@ -26,7 +26,7 @@ VerticalScrollBar < UIScrollBar id: decrementButton anchors.top: parent.top anchors.left: parent.left - image-source: images/scrollbar.png + image-source: /images/scrollbar.png image-clip: 0 0 13 13 image-color: #ffffffff size: 13 13 @@ -42,7 +42,7 @@ VerticalScrollBar < UIScrollBar anchors.bottom: parent.bottom anchors.right: parent.right size: 13 13 - image-source: images/scrollbar.png + image-source: /images/scrollbar.png image-clip: 0 13 13 13 image-color: #ffffffff $hover: @@ -58,7 +58,7 @@ HorizontalScrollBar < UIScrollBar orientation: horizontal height: 13 width: 39 - image-source: images/scrollbar.png + image-source: /images/scrollbar.png image-clip: 0 65 52 13 image-border: 1 @@ -66,7 +66,7 @@ HorizontalScrollBar < UIScrollBar id: decrementButton anchors.top: parent.top anchors.left: parent.left - image-source: images/scrollbar.png + image-source: /images/scrollbar.png image-clip: 0 39 13 13 image-color: #ffffffff size: 13 13 @@ -82,7 +82,7 @@ HorizontalScrollBar < UIScrollBar anchors.bottom: parent.bottom anchors.right: parent.right size: 13 13 - image-source: images/scrollbar.png + image-source: /images/scrollbar.png image-clip: 0 52 13 13 image-color: #ffffffff $hover: diff --git a/modules/core_styles/styles/separators.otui b/modules/client_skins/skins/default/styles/separators.otui similarity index 59% rename from modules/core_styles/styles/separators.otui rename to modules/client_skins/skins/default/styles/separators.otui index bb0a83bf..0e8132c9 100644 --- a/modules/core_styles/styles/separators.otui +++ b/modules/client_skins/skins/default/styles/separators.otui @@ -1,12 +1,12 @@ HorizontalSeparator < UIWidget - image-source: /core_styles/styles/images/horizontal_separator.png + image-source: /images/horizontal_separator.png image-border-top: 2 height: 2 phantom: true focusable: false VerticalSeparator < UIWidget - image-source: /core_styles/styles/images/horizontal_separator.png + image-source: /images/horizontal_separator.png image-border-left: 2 width: 2 phantom: true diff --git a/modules/core_styles/styles/spinboxes.otui b/modules/client_skins/skins/default/styles/spinboxes.otui similarity index 74% rename from modules/core_styles/styles/spinboxes.otui rename to modules/client_skins/skins/default/styles/spinboxes.otui index 64a69321..8da463df 100644 --- a/modules/core_styles/styles/spinboxes.otui +++ b/modules/client_skins/skins/default/styles/spinboxes.otui @@ -4,7 +4,7 @@ SpinBox < UISpinBox size: 86 20 text-offset: 0 3 text-margin: 3 - image-source: /core_styles/styles/images/panel_flat.png + image-source: images/panel_flat.png image-border: 1 $disabled: diff --git a/modules/core_styles/styles/splitters.otui b/modules/client_skins/skins/default/styles/splitters.otui similarity index 100% rename from modules/core_styles/styles/splitters.otui rename to modules/client_skins/skins/default/styles/splitters.otui diff --git a/modules/core_styles/styles/tabbars.otui b/modules/client_skins/skins/default/styles/tabbars.otui similarity index 90% rename from modules/core_styles/styles/tabbars.otui rename to modules/client_skins/skins/default/styles/tabbars.otui index 4afee7f4..1f4f35bb 100644 --- a/modules/core_styles/styles/tabbars.otui +++ b/modules/client_skins/skins/default/styles/tabbars.otui @@ -3,7 +3,7 @@ TabBar < UITabBar TabBarPanel < Panel TabBarButton < UIButton size: 20 20 - image-source: /core_styles/styles/images/tabbutton.png + image-source: /images/tabbutton.png image-color: white image-clip: 0 0 20 20 image-border: 2 diff --git a/modules/core_styles/styles/textedits.otui b/modules/client_skins/skins/default/styles/textedits.otui similarity index 82% rename from modules/core_styles/styles/textedits.otui rename to modules/client_skins/skins/default/styles/textedits.otui index a3e2fe60..c70aa6d4 100644 --- a/modules/core_styles/styles/textedits.otui +++ b/modules/client_skins/skins/default/styles/textedits.otui @@ -4,7 +4,7 @@ TextEdit < UITextEdit size: 86 20 text-offset: 0 3 text-margin: 3 - image-source: /core_styles/styles/images/panel_flat.png + image-source: /images/panel_flat.png image-border: 1 $disabled: diff --git a/modules/core_styles/styles/windows.otui b/modules/client_skins/skins/default/styles/windows.otui similarity index 87% rename from modules/core_styles/styles/windows.otui rename to modules/client_skins/skins/default/styles/windows.otui index b265cf0e..5ba2a60c 100644 --- a/modules/core_styles/styles/windows.otui +++ b/modules/client_skins/skins/default/styles/windows.otui @@ -5,7 +5,7 @@ Window < UIWindow color: white text-offset: 0 4 text-align: top - image-source: /core_styles/styles/images/window.png + image-source: /images/window.png image-border: 5 image-border-top: 22 opacity: 1 diff --git a/modules/client_skins/skins/example.lua b/modules/client_skins/skins/example.lua index 3f43ecea..a4eef558 100644 --- a/modules/client_skins/skins/example.lua +++ b/modules/client_skins/skins/example.lua @@ -1,6 +1,8 @@ local skin = { name = 'Example', + fonts = {}, + styles = { 'topmenu.otui' } diff --git a/modules/client_skins/skins/example/topmenu.otui b/modules/client_skins/skins/example/styles/topmenu.otui similarity index 100% rename from modules/client_skins/skins/example/topmenu.otui rename to modules/client_skins/skins/example/styles/topmenu.otui diff --git a/modules/core_lib/mouse.lua b/modules/core_lib/mouse.lua index fbc48396..0d10efc4 100644 --- a/modules/core_lib/mouse.lua +++ b/modules/core_lib/mouse.lua @@ -3,17 +3,17 @@ Mouse = {} local cursorChanged = false 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 end 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 end 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 end diff --git a/modules/core_styles/core_styles.otmod b/modules/core_styles/core_styles.otmod deleted file mode 100644 index 67b2ad03..00000000 --- a/modules/core_styles/core_styles.otmod +++ /dev/null @@ -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' diff --git a/modules/core_styles/styles/images/item.png b/modules/game/images/item.png similarity index 100% rename from modules/core_styles/styles/images/item.png rename to modules/game/images/item.png diff --git a/modules/game/styles/creatures.otui b/modules/game/styles/creatures.otui index 73ca8cd3..4f303beb 100644 --- a/modules/game/styles/creatures.otui +++ b/modules/game/styles/creatures.otui @@ -1,5 +1,5 @@ Creature < UICreature size: 80 80 padding: 1 - image-source: /core_styles/styles/images/panel_flat.png + image-source: /images/panel_flat.png image-border: 1 diff --git a/modules/game/styles/items.otui b/modules/game/styles/items.otui index 0e24d455..740fc269 100644 --- a/modules/game/styles/items.otui +++ b/modules/game/styles/items.otui @@ -1,6 +1,6 @@ Item < UIItem size: 34 34 padding: 1 - image-source: /core_styles/styles/images/item.png + image-source: /game/images/item.png font: verdana-11px-rounded border-color: white diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index 27f4e82a..004eca74 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -37,9 +37,9 @@ local SpeakTypes = { } local SayModes = { - [1] = { speakTypeDesc = 'whisper', icon = '/core_styles/icons/whisper.png' }, - [2] = { speakTypeDesc = 'say', icon = '/core_styles/icons/say.png' }, - [3] = { speakTypeDesc = 'yell', icon = '/core_styles/icons/yell.png' } + [1] = { speakTypeDesc = 'whisper', icon = 'icons/whisper.png' }, + [2] = { speakTypeDesc = 'say', icon = 'icons/say.png' }, + [3] = { speakTypeDesc = 'yell', icon = 'icons/yell.png' } } local MAX_HISTORY = 1000 diff --git a/modules/game_console/console.otui b/modules/game_console/console.otui index cd257707..fdc15796 100644 --- a/modules/game_console/console.otui +++ b/modules/game_console/console.otui @@ -40,7 +40,7 @@ Panel TabButton id: prevChannelButton - icon: /core_styles/icons/leftarrow.png + icon: icons/leftarrow.png anchors.left: parent.left anchors.top: parent.top margin-left: 6 @@ -56,7 +56,7 @@ Panel TabButton id: nextChannelButton - icon: /core_styles/icons/rightarrow.png + icon: icons/rightarrow.png anchors.right: next.left anchors.top: parent.top margin-right: 5 @@ -65,7 +65,7 @@ Panel TabButton id: closeChannelButton !tooltip: tr('Close this channel') .. ' (Ctrl+E)' - icon: /core_styles/icons/closechannel.png + icon: icons/closechannel.png anchors.right: next.left anchors.top: parent.top enabled: false @@ -76,7 +76,7 @@ Panel TabButton id: channelsButton !tooltip: tr('Open new channel') .. ' (Ctrl+O)' - icon: /core_styles/icons/channels.png + icon: icons/channels.png anchors.right: parent.right anchors.top: parent.top margin-right: 5 @@ -98,7 +98,7 @@ Panel TabButton id: sayModeButton - icon: /core_styles/icons/say.png + icon: icons/say.png !tooltip: tr('Adjust volume') &sayMode: 2 size: 20 20 diff --git a/modules/core_styles/icons/channels.png b/modules/game_console/icons/channels.png similarity index 100% rename from modules/core_styles/icons/channels.png rename to modules/game_console/icons/channels.png diff --git a/modules/core_styles/icons/closechannel.png b/modules/game_console/icons/closechannel.png similarity index 100% rename from modules/core_styles/icons/closechannel.png rename to modules/game_console/icons/closechannel.png diff --git a/modules/core_styles/icons/leftarrow.png b/modules/game_console/icons/leftarrow.png similarity index 100% rename from modules/core_styles/icons/leftarrow.png rename to modules/game_console/icons/leftarrow.png diff --git a/modules/core_styles/icons/rightarrow.png b/modules/game_console/icons/rightarrow.png similarity index 100% rename from modules/core_styles/icons/rightarrow.png rename to modules/game_console/icons/rightarrow.png diff --git a/modules/core_styles/icons/say.png b/modules/game_console/icons/say.png similarity index 100% rename from modules/core_styles/icons/say.png rename to modules/game_console/icons/say.png diff --git a/modules/core_styles/icons/whisper.png b/modules/game_console/icons/whisper.png similarity index 100% rename from modules/core_styles/icons/whisper.png rename to modules/game_console/icons/whisper.png diff --git a/modules/core_styles/icons/yell.png b/modules/game_console/icons/yell.png similarity index 100% rename from modules/core_styles/icons/yell.png rename to modules/game_console/icons/yell.png diff --git a/modules/game_npctrade/npctrade.otui b/modules/game_npctrade/npctrade.otui index ab6bb018..91fbc2a8 100644 --- a/modules/game_npctrade/npctrade.otui +++ b/modules/game_npctrade/npctrade.otui @@ -57,14 +57,12 @@ MainWindow margin-left: 5 margin-top: 5 - Panel + FlatPanel height: 250 anchors.left: parent.left anchors.right: parent.right anchors.top: prev.bottom margin-top: 10 - image-source: /core_styles/styles/images/panel_flat.png - image-border: 1 VerticalScrollBar id: itemsPanelListScrollBar diff --git a/src/framework/core/modulemanager.cpp b/src/framework/core/modulemanager.cpp index 54671d2d..f00e691d 100644 --- a/src/framework/core/modulemanager.cpp +++ b/src/framework/core/modulemanager.cpp @@ -77,6 +77,7 @@ void ModuleManager::discoverModulesPath() // try to add module directory if(g_resources.addToSearchPath(dir, false)) { //g_logger.info(stdext::format("Using modules directory '%s'", dir.c_str())); + m_modulesPath = dir; found = true; break; } diff --git a/src/framework/core/modulemanager.h b/src/framework/core/modulemanager.h index 4d908948..8804b851 100644 --- a/src/framework/core/modulemanager.h +++ b/src/framework/core/modulemanager.h @@ -37,6 +37,7 @@ public: void ensureModuleLoaded(const std::string& moduleName); void unloadModules(); void reloadModules(); + std::string getModulesPath() { return m_modulesPath; } ModulePtr getModule(const std::string& moduleName); std::deque getModules() { return m_modules; } @@ -47,6 +48,7 @@ protected: friend class Module; private: + std::string m_modulesPath; std::deque m_modules; std::multimap m_autoLoadModules; }; diff --git a/src/framework/core/resourcemanager.cpp b/src/framework/core/resourcemanager.cpp index 7831016a..ec7a1da3 100644 --- a/src/framework/core/resourcemanager.cpp +++ b/src/framework/core/resourcemanager.cpp @@ -66,6 +66,13 @@ bool ResourceManager::addToSearchPath(const std::string& path, bool insertInFron 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) { auto files = listDirectoryFiles(resolvePath(packagesDir)); diff --git a/src/framework/core/resourcemanager.h b/src/framework/core/resourcemanager.h index a24691a7..ac5882e7 100644 --- a/src/framework/core/resourcemanager.h +++ b/src/framework/core/resourcemanager.h @@ -34,6 +34,7 @@ public: bool setupWriteDir(const std::string& appWriteDirName); 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); bool fileExists(const std::string& fileName); diff --git a/src/framework/graphics/fontmanager.cpp b/src/framework/graphics/fontmanager.cpp index 01dbb01d..786f069f 100644 --- a/src/framework/graphics/fontmanager.cpp +++ b/src/framework/graphics/fontmanager.cpp @@ -38,6 +38,12 @@ void FontManager::terminate() m_defaultFont = nullptr; } +void FontManager::clearFonts() +{ + m_fonts.clear(); + m_defaultFont = BitmapFontPtr(new BitmapFont("emptyfont")); +} + bool FontManager::importFont(std::string fontFile) { try { diff --git a/src/framework/graphics/fontmanager.h b/src/framework/graphics/fontmanager.h index 7a47725f..724d126a 100644 --- a/src/framework/graphics/fontmanager.h +++ b/src/framework/graphics/fontmanager.h @@ -31,6 +31,7 @@ public: FontManager(); void terminate(); + void clearFonts(); bool importFont(std::string fontFile); diff --git a/src/framework/graphics/painterogl2.cpp b/src/framework/graphics/painterogl2.cpp index 6906cc2b..097d0dde 100644 --- a/src/framework/graphics/painterogl2.cpp +++ b/src/framework/graphics/painterogl2.cpp @@ -120,7 +120,7 @@ void PainterOGL2::drawCoords(CoordsBuffer& coordsBuffer, DrawMode drawMode) void PainterOGL2::drawTextureCoords(CoordsBuffer& coordsBuffer, const TexturePtr& texture) { - if(texture->isEmpty()) + if(texture && texture->isEmpty()) return; setDrawProgram(m_shaderProgram ? m_shaderProgram : m_drawTexturedProgram.get()); diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index 8228c62e..505336cb 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -34,6 +34,7 @@ #include #include #include +#include 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", "getModule", &ModuleManager::getModule, &g_modules); g_lua.bindSingletonFunction("g_modules", "getModules", &ModuleManager::getModules, &g_modules); + g_lua.bindSingletonFunction("g_modules", "getModulesPath", &ModuleManager::getModulesPath, &g_modules); // FontManager 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", "fontExists", &FontManager::fontExists, &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", "scheduleEvent", &EventDispatcher::scheduleEvent, &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); + } diff --git a/src/otclient/core/thingtype.h b/src/otclient/core/thingtype.h index acb6f2a4..f8305010 100644 --- a/src/otclient/core/thingtype.h +++ b/src/otclient/core/thingtype.h @@ -112,8 +112,6 @@ public: 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); - 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); bool getProperty(Property property) { return m_properties[property]; }