From beaba25af195f4e1f7829fc0109695d7f470d898 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Mon, 30 Apr 2012 13:40:12 -0300 Subject: [PATCH] UI tweaks --- BUGS | 22 ++++ TODO | 107 +++++++++++------- modules/client_locales/locales.lua | 2 +- .../client_modulemanager/modulemanager.otui | 38 +++++-- modules/core_styles/styles/buttons.otui | 1 + modules/game/gameinterface.otui | 13 +-- modules/game/styles/miniwindow.otui | 4 +- modules/game_battle/battle.otui | 3 + modules/game_console/console.lua | 2 +- modules/game_containers/container.otui | 7 +- modules/game_containers/containers.lua | 5 + modules/game_healthbar/healthbar.otui | 1 + modules/game_inventory/inventory.otui | 1 + src/framework/luafunctions.cpp | 1 + src/framework/ui/uigridlayout.cpp | 4 +- src/framework/ui/uiwidget.cpp | 7 ++ src/framework/ui/uiwidget.h | 1 + src/framework/ui/uiwidgettext.cpp | 2 +- src/otclient/ui/uiitem.cpp | 1 - 19 files changed, 148 insertions(+), 74 deletions(-) diff --git a/BUGS b/BUGS index e69de29b..aebdcf17 100644 --- a/BUGS +++ b/BUGS @@ -0,0 +1,22 @@ +== CRASHS +modules recursivity makes client crash, it should generate a warning + +== P1 BUGS (affects game play) +private channels are not closed when switching characters +sometimes minimap desync Z pos +follow and autowalk doesn't cancel when walking via hotkeys + +== P2 BUGS +battle sometimes doesn't clear attacked/followed creatures when they go out of range +if you move a backpack to left panel, and resize it, client will go into a infinite loop resizing the backpack switching 4,5 columns +when looking from floor 5 in floor 7, sometimes a tile have 2 invisible grounds in floor 6 that should be ignored + +== P3 BUGS +widgets may have been destroyed when adding event in onSetup (UIResizeBorder), generating invalid events +too many talk messages in game map make the messages boxes disappear +hotkeys works while windows are locked, it shouldn't +skulls is rendering outside map bounds +party options does not work when re-logging inside a party +sometimes we can still view hits from above/bottom floors from a fight that is not visible +must removeThing in protocol parseTileAdd when stackpos is greater than 11 + diff --git a/TODO b/TODO index 2732d603..2eb52bfe 100644 --- a/TODO +++ b/TODO @@ -1,51 +1,78 @@ -== Core -create a class for reading binary files -rework lua/c++ logger +== MODULES +game_shaders (with shader manager) +game_map (with save/load/options) +game_minimap (with all tibia functionality) +game_playertrade +game_textbooks +game_questlog +game_ruleviolations -== Graphics -map zoom rendering could be optimized using framebuffer caches -implement graphics options menu +== NOTABLE FEATURES +make left panel optional +must close last container when opening a new containers +add options "Copy Text", "Copy Name", "Message" in console labels with a popupmenu +move chat tabs +save/load mini windows states/location when restarting the client +graphics options menu +load modules from zip files +manual autoload setting in module manager +complete a smarter miniwindow moving/resizing +make miniwindow borderless on double click -== Modules -fix modules recursivity, it makes client crash +== BEFORE RELEASE +polish interface skin +new optional skin +send otclient/system information to a third party server + +== LATER FEATURES +reload spr/dat while ingame +create and bind new game events +text selection +login queue +port to MacOs and iphone +allow multiple Map and Game instances ? + +== MINOR FEATURES +display exit box when exiting from game +case insensitive npctrade load modules from zip packages +move up/down in lineedits +select characters in lineedits +scrolling multiline edit +mouse wheel lineedits -== Lua engine -make possible to bind non LuaObject derived classes on lua engine (for usage with Point,Rect,Color,Size) -review usage of x,y/width,height in lua instead of point/size +== OPTIMIZATIONS AND REWORKS +* game +do not redraw in MapView far zoom +map zoom rendering could be optimized using framebuffer caches +multisample option in map view +move redering of creatures names, skulls, etc to UI and scripts +clean sprites cache periodically +handle corrupt errors in dat/spr -== Platform -port to MacOs and iphone +* framework +rework Settings/g_configs +platform cursor cache +replace onKey events with Hotkeys.bind +add -no-sound option +rework lua/c++ logger -== UI -review anchors API, add possibility to get/remove anchors -multiline rich text widget -move layout proprieties to widget style -multiline text editor widget -fix style inheritance using a style translator -find a way to add new widgets without focusing them +* ui +rework hover => onWidgetVisibilityChange onWidgetEnableChange onWidgetMove onAppear onDisappear +reset dragging widget on destruction/visibility change/enable change +cancel layout changes on non visible widgets (acts like it doesn't exist) +add more anchors warnings to make creation of OTUIs easier review UI/style loader and make more error prone with more warnings +change Align/Anchors lua API from enum to text +review widgets rendering order, consider adding z-index reapply anchor styles when adding new childs +style inheritance using a style translator +find a way to add new widgets without focusing them make set of background/icon/image width alone work -check for recursive anchors and print a error instead of crashing make api to enable/disable capture of events like mouseMove to avoid massive event processing -review style apply system -review widgets rendering order, consider adding z-index -change Align/Anchors lua API from enum to text - -== Game -clean sprites cache periodically -create a shader manager -find a way to load map rendering styles -move redering of creatures names, skulls, etc to UI -handle corrupt errors in dat/spr -remake spr/dat using OTML and image files - -== Game modules -minimap window -login queue -questlog -edit texts -trade window -shop window +move layout proprieties to widget style +terminate rework of ui events propagation (for Key events) +* lua engine +make possible to bind non LuaObject derived classes on lua engine (for usage with Point,Rect,Color,Size) +review usage of x,y/width,height in lua instead of point/size diff --git a/modules/client_locales/locales.lua b/modules/client_locales/locales.lua index bf6a12e5..8ef03423 100644 --- a/modules/client_locales/locales.lua +++ b/modules/client_locales/locales.lua @@ -24,7 +24,7 @@ function Locales.init() local userLocaleName = Settings.get('locale') if userLocaleName and Locales.setLocale(userLocaleName)then - print('Using configurated locale: ' .. userLocaleName) + print('Using configured locale: ' .. userLocaleName) else print('Using default locale: ' .. defaultLocaleName) Locales.setLocale(defaultLocaleName) diff --git a/modules/client_modulemanager/modulemanager.otui b/modules/client_modulemanager/modulemanager.otui index f40ef722..69fe14e6 100644 --- a/modules/client_modulemanager/modulemanager.otui +++ b/modules/client_modulemanager/modulemanager.otui @@ -26,14 +26,15 @@ ModuleInfoLabel < Label ModuleValueLabel < UILabel font: verdana-11px-antialised color: #aaaaaa - text-offset: 3 0 + text-offset: 2 3 + padding-bottom: 5 image-source: /core_styles/styles/images/panel_flat.png image-border: 1 - height: 16 + height: 20 MainWindow id: moduleManagerWindow - size: 480 450 + size: 450 450 !text: tr('Module Manager') @onEscape: ModuleManager.hide() @@ -43,36 +44,47 @@ MainWindow anchors.top: parent.top anchors.left: parent.left anchors.bottom: parent.bottom - width: 180 + width: 190 padding: 1 focusable: false margin-bottom: 30 + vertical-scrollbar: moduleListScrollBar + + VerticalScrollBar + id: moduleListScrollBar + anchors.top: moduleList.top + anchors.bottom: moduleList.bottom + anchors.left: moduleList.right + step: 14 + pixels-scroll: true Button id: refreshModulesButton anchors.top: moduleList.bottom anchors.left: moduleList.left margin-top: 8 - width: 80 !text: tr('Refresh') + text-auto-resize: true @onClick: ModuleManager.refreshModules() Button id: reloadAllModulesButton anchors.top: moduleList.bottom - anchors.right: moduleList.right + anchors.right: moduleListScrollBar.right margin-top: 8 - width: 80 !text: tr('Reload All') + text-auto-resize: true @onClick: ModuleManager.reloadAllModules() Panel id: moduleInfo - anchors.left: moduleList.right + anchors.left: moduleListScrollBar.right anchors.top: parent.top anchors.right: parent.right margin: 0 5 5 15 - layout: verticalBox + layout: + type: verticalBox + fit-children: true height: 265 ModuleInfoLabel @@ -84,8 +96,8 @@ MainWindow !text: tr('Description') ModuleValueLabel id: moduleDescription - height: 100 text-wrap: true + height: 100 //ModuleInfoLabel // !text: tr('Autoload') @@ -105,7 +117,7 @@ MainWindow ModuleInfoLabel !text: tr('Website') - ModuleValueLabel + TextEdit id: moduleWebsite ModuleInfoLabel @@ -120,6 +132,7 @@ MainWindow margin-top: 8 !text: tr('Load') enabled: false + width: 90 @onClick: ModuleManager.reloadCurrentModule() Button @@ -130,6 +143,7 @@ MainWindow margin-top: 8 !text: tr('Unload') enabled: false + width: 90 @onClick: ModuleManager.unloadCurrentModule() Button @@ -137,6 +151,6 @@ MainWindow anchors.bottom: parent.bottom anchors.right: parent.right !text: tr('Close') - width: 60 + width: 90 @onClick: ModuleManager.hide() diff --git a/modules/core_styles/styles/buttons.otui b/modules/core_styles/styles/buttons.otui index f8b40464..81369099 100644 --- a/modules/core_styles/styles/buttons.otui +++ b/modules/core_styles/styles/buttons.otui @@ -6,6 +6,7 @@ Button < UIButton image-color: white image-source: /core_styles/styles/images/button.png image-border: 5 + padding: 5 10 5 10 $hover !disabled: image-source: /core_styles/styles/images/button_hover.png diff --git a/modules/game/gameinterface.otui b/modules/game/gameinterface.otui index 2c9c80ab..45ad54a8 100644 --- a/modules/game/gameinterface.otui +++ b/modules/game/gameinterface.otui @@ -44,7 +44,7 @@ UIWidget GameSidePanel id: gameRightPanel layout: verticalBox - anchors.left: rightSplitter.left + width: 190 anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom @@ -60,17 +60,6 @@ UIWidget @canUpdateMargin: function(self, newMargin) return math.max(math.min(newMargin, self:getParent():getHeight() - 300), 100) end @onGeometryChange: function(self) self:setMarginBottom(math.min(math.max(self:getParent():getHeight() - 300, 100), self:getMarginBottom())) end - Splitter - id: rightSplitter - anchors.right: parent.right - anchors.top: parent.top - anchors.bottom: parent.bottom - relative-margin: right - margin-right: 190 - enabled: false - @canUpdateMargin: function(self, newMargin) return math.max(math.min(newMargin, self:getParent():getWidth() - 300), 150) end - @onGeometryChange: function(self) self:setMarginRight(math.min(math.max(self:getParent():getWidth() - 300, 150), self:getMarginRight())) end - UIWidget id: mouseGrabber focusable: false diff --git a/modules/game/styles/miniwindow.otui b/modules/game/styles/miniwindow.otui index 12e5e249..45e86847 100644 --- a/modules/game/styles/miniwindow.otui +++ b/modules/game/styles/miniwindow.otui @@ -5,7 +5,6 @@ MiniWindow < UIMiniWindow height: 200 text-offset: 24 5 text-align: topLeft - margin-bottom: 2 image-source: /game/images/miniwindow.png image-border: 4 image-border-top: 23 @@ -84,7 +83,8 @@ MiniWindowContents < ScrollablePanel id: contentsPanel anchors.fill: parent anchors.right: miniwindowScrollBar.left - padding: 24 5 3 5 + margin-top: 19 + padding: 3 5 3 5 vertical-scrollbar: miniwindowScrollBar BorderlessGameWindow < UIWindow diff --git a/modules/game_battle/battle.otui b/modules/game_battle/battle.otui index 8039e1dd..74ab3114 100644 --- a/modules/game_battle/battle.otui +++ b/modules/game_battle/battle.otui @@ -50,6 +50,7 @@ MiniWindow anchors.top: parent.top anchors.right: next.left margin-right: 5 + margin-top: 3 BattleNPCs id: hideNPCs @@ -57,12 +58,14 @@ MiniWindow anchors.top: parent.top anchors.right: next.left margin-right: 5 + margin-top: 3 BattleMonsters id: hideMonsters !tooltip: tr('Hide monsters') anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter + margin-top: 3 BattleSkulls id: hideSkulls diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index 47a158b5..7f0545ed 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -99,7 +99,7 @@ local function onCreatureSpeak(name, level, speaktype, message, channelId, creat if channel then Console.addText(message, speaktype, channel) - elseif channelid ~= 0 then + elseif channelId ~= 0 then -- server sent a message on a channel that is not open warning('message in channel id ' .. channelId .. ' which is unknown, this is a server bug, relogin if you want to see messages in this channel') end diff --git a/modules/game_containers/container.otui b/modules/game_containers/container.otui index 6d1e44ad..324be73d 100644 --- a/modules/game_containers/container.otui +++ b/modules/game_containers/container.otui @@ -27,9 +27,10 @@ ContainerWindow < MiniWindow image-clip: 42 28 14 14 MiniWindowContents - padding: 27 6 6 8 + padding-right: 0 layout: type: grid - cell-size: 34 34 + cell-size: 40 40 flow: true - auto-spacing: true + cell-spacing: 0 + diff --git a/modules/game_containers/containers.lua b/modules/game_containers/containers.lua index f2643ace..a5d7c14c 100644 --- a/modules/game_containers/containers.lua +++ b/modules/game_containers/containers.lua @@ -24,6 +24,10 @@ local function onContainerOpen(container, previousContainer) containerWindow:hide() end + -- this disables scrollbar auto hiding + local scrollbar = containerWindow:getChildById('miniwindowScrollBar') + scrollbar:mergeStyle({ ['$disabled'] = { ['width'] = scrollbar:getWidth() } }) + local upButton = containerWindow:getChildById('upButton') upButton.onClick = function() g_game.openParent(container) @@ -41,6 +45,7 @@ local function onContainerOpen(container, previousContainer) local itemWidget = createWidget('Item', containerPanel) itemWidget:setId('item' .. slot) itemWidget:setItem(container:getItem(slot)) + itemWidget:setMargin(3) itemWidget.position = container:getSlotPosition(slot) end diff --git a/modules/game_healthbar/healthbar.otui b/modules/game_healthbar/healthbar.otui index fa1de388..81567b04 100644 --- a/modules/game_healthbar/healthbar.otui +++ b/modules/game_healthbar/healthbar.otui @@ -5,6 +5,7 @@ HealthBar < ProgressBar anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right + margin-top: 3 ManaBar < ProgressBar id: manaBar diff --git a/modules/game_inventory/inventory.otui b/modules/game_inventory/inventory.otui index 2a35fc37..df006978 100644 --- a/modules/game_inventory/inventory.otui +++ b/modules/game_inventory/inventory.otui @@ -11,6 +11,7 @@ MiniWindow id: slot1 anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter + margin-top: 4 &position: {x=65535, y=1, z=0} Item diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index 81090987..7d07c1bb 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -72,6 +72,7 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("moveChildToIndex", &UIWidget::moveChildToIndex); g_lua.bindClassMemberFunction("lockChild", &UIWidget::lockChild); g_lua.bindClassMemberFunction("unlockChild", &UIWidget::unlockChild); + g_lua.bindClassMemberFunction("mergeStyle", &UIWidget::mergeStyle); g_lua.bindClassMemberFunction("applyStyle", &UIWidget::applyStyle); g_lua.bindClassMemberFunction("addAnchor", &UIWidget::addAnchor); g_lua.bindClassMemberFunction("removeAnchor", &UIWidget::removeAnchor); diff --git a/src/framework/ui/uigridlayout.cpp b/src/framework/ui/uigridlayout.cpp index af572aa0..a630a5b7 100644 --- a/src/framework/ui/uigridlayout.cpp +++ b/src/framework/ui/uigridlayout.cpp @@ -101,8 +101,10 @@ bool UIGridLayout::internalUpdate() Point virtualPos = Point(column * (m_cellSize.width() + cellSpacing), line * (m_cellSize.height() + cellSpacing)); preferredHeight = virtualPos.y + m_cellSize.height(); Point pos = topLeft + virtualPos - parentWidget->getVirtualOffset(); + Rect dest = Rect(pos, m_cellSize); + dest.expand(-widget->getMarginTop(), -widget->getMarginRight(), -widget->getMarginBottom(), -widget->getMarginLeft()); - if(widget->setRect(Rect(pos, m_cellSize))) + if(widget->setRect(dest)) changed = true; index++; diff --git a/src/framework/ui/uiwidget.cpp b/src/framework/ui/uiwidget.cpp index e99f1693..606128a3 100644 --- a/src/framework/ui/uiwidget.cpp +++ b/src/framework/ui/uiwidget.cpp @@ -458,6 +458,13 @@ void UIWidget::unlockChild(const UIWidgetPtr& child) } } +void UIWidget::mergeStyle(const OTMLNodePtr& styleNode) +{ + applyStyle(styleNode); + m_style->merge(styleNode); + updateStyle(); +} + void UIWidget::applyStyle(const OTMLNodePtr& styleNode) { if(m_destroyed) diff --git a/src/framework/ui/uiwidget.h b/src/framework/ui/uiwidget.h index 30d54352..9c345a73 100644 --- a/src/framework/ui/uiwidget.h +++ b/src/framework/ui/uiwidget.h @@ -90,6 +90,7 @@ public: void moveChildToIndex(const UIWidgetPtr& child, int index); void lockChild(const UIWidgetPtr& child); void unlockChild(const UIWidgetPtr& child); + void mergeStyle(const OTMLNodePtr& styleNode); void applyStyle(const OTMLNodePtr& styleNode); void addAnchor(Fw::AnchorEdge anchoredEdge, const std::string& hookedWidgetId, Fw::AnchorEdge hookedEdge); void removeAnchor(Fw::AnchorEdge anchoredEdge); diff --git a/src/framework/ui/uiwidgettext.cpp b/src/framework/ui/uiwidgettext.cpp index 01095f04..9cd396a4 100644 --- a/src/framework/ui/uiwidgettext.cpp +++ b/src/framework/ui/uiwidgettext.cpp @@ -43,7 +43,7 @@ void UIWidget::updateText() // update rect size if(!m_rect.isValid() || m_textAutoResize) { Size textBoxSize = getTextSize(); - textBoxSize += Size(m_padding.left + m_padding.right, m_padding.top + m_padding.left); + textBoxSize += Size(m_padding.left + m_padding.right, m_padding.top + m_padding.bottom); Size size = getSize(); if(size.width() <= 0 || (m_textAutoResize && !m_textWrap)) size.setWidth(textBoxSize.width()); diff --git a/src/otclient/ui/uiitem.cpp b/src/otclient/ui/uiitem.cpp index a7057b3e..df553148 100644 --- a/src/otclient/ui/uiitem.cpp +++ b/src/otclient/ui/uiitem.cpp @@ -38,7 +38,6 @@ void UIItem::drawSelf() Rect drawRect = getClippingRect(); Point dest = drawRect.topLeft(); float scaleFactor = std::min(drawRect.width() / (float)m_item->getExactSize(), drawRect.height() / (float)m_item->getExactSize()); - dest += (1 - scaleFactor)*32; dest += m_item->getDisplacement() * scaleFactor; g_painter->setColor(Color::white);