From d500de9aa003cdfbee1b3d4990ed2ded96e4d941 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Mon, 23 Jan 2012 11:47:15 -0200 Subject: [PATCH] change in topmenu and some fixes --- BUGS | 9 ++++- TODO | 14 ++++++- modules/client_topmenu/topmenu.lua | 12 ++++++ modules/client_topmenu/topmenu.otui | 50 ++++++++----------------- modules/core_widgets/uiitem.lua | 2 +- modules/game/game.otmod | 4 +- modules/game_skills/skills.lua | 21 ++++++----- modules/game_skills/skills.otui | 2 +- modules/game_viplist/viplist.lua | 17 +++++++-- src/framework/ui/uianchorlayout.cpp | 3 ++ src/framework/ui/uihorizontallayout.cpp | 2 + src/framework/ui/uiverticallayout.cpp | 3 ++ src/framework/ui/uiwidget.cpp | 3 ++ src/framework/util/utf8.cpp | 4 +- src/otclient/core/game.cpp | 1 - src/otclient/core/item.cpp | 2 +- src/otclient/core/map.h | 2 +- src/otclient/luafunctions.cpp | 1 + 18 files changed, 93 insertions(+), 59 deletions(-) diff --git a/BUGS b/BUGS index 1562fb74..bd464b09 100644 --- a/BUGS +++ b/BUGS @@ -12,4 +12,11 @@ some animated hits are displayed as 2 hits instead of one numpad on windows doesn't work correctly skulls is rendering outside map bounds these are some issues when skill progressbar is 0% or 100% -paste on x11 platform does not work correctly when doing ctrl+c in google chrome \ No newline at end of file +paste on x11 platform does not work correctly when doing ctrl+c in google chrome + +walk animation doesnt reset when leaving invisible +non tiles are no black +drop items in container background +can view ocean in underground floors + +render closets -> http://i.imgur.com/yooxD.jpg \ No newline at end of file diff --git a/TODO b/TODO index 34ccb900..a8a80815 100644 --- a/TODO +++ b/TODO @@ -17,6 +17,18 @@ move items use with +move count itens +open/close vip/skills +move windows, go back in containers +open private chat +reopen channels +fix use with +move windows +let windows open while playing +fix auto repeats in lineedit +trade +battlelist +offer window ==================================================== Low priority TODO @@ -25,8 +37,8 @@ Low priority TODO review directories loading search load modules from zip packages create a class for reading binary files -rework lua/c++ logger ake protocol class compatible with old tibia protocols +rework lua/c++ logger == Graphics use CoordsBuffer in font diff --git a/modules/client_topmenu/topmenu.lua b/modules/client_topmenu/topmenu.lua index c06b4f69..62ec86b4 100644 --- a/modules/client_topmenu/topmenu.lua +++ b/modules/client_topmenu/topmenu.lua @@ -80,6 +80,14 @@ function TopMenu.removeButton(param) button:destroy() end +function TopMenu.hideGameButtons() + gameButtonsPanel:hide() +end + +function TopMenu.showGameButtons() + gameButtonsPanel:show() +end + function TopMenu.getButton(id) return topMenu:recursiveGetChildById(id) end @@ -87,3 +95,7 @@ end function TopMenu:getLogoutButton(id) return TopMenu.getButton('logoutButton') end + + +connect(Game, { onLogin = TopMenu.showGameButtons, + onLogout = TopMenu.hideGameButtons}) \ No newline at end of file diff --git a/modules/client_topmenu/topmenu.otui b/modules/client_topmenu/topmenu.otui index fdd5cebe..e2e69b28 100644 --- a/modules/client_topmenu/topmenu.otui +++ b/modules/client_topmenu/topmenu.otui @@ -25,45 +25,13 @@ GameTopButton < UIButton icon-color: #ffffffff image-border: 3 - $hover: + $on: image-clip: 0 0 26 26 image-color: #ffffffff icon-color: #ffffffff - $first: - anchors.top: parent.top - anchors.left: parent.left - margin-top: 4 - margin-left: 6 - - $!first: - anchors.top: prev.top - anchors.left: prev.right - margin-left: 6 - TopLeftButton < TopButton - $first: - anchors.top: parent.top - anchors.left: parent.left - margin-top: 4 - margin-left: 6 - - $!first: - anchors.top: prev.top - anchors.left: prev.right - margin-left: 6 - TopRightButton < TopButton - $first: - anchors.top: parent.top - anchors.right: parent.right - margin-top: 4 - margin-right: 6 - - $!first: - anchors.top: prev.top - anchors.right: prev.left - margin-right: 6 TopPanel id: topMenu @@ -77,7 +45,11 @@ TopPanel anchors.top: parent.top anchors.bottom: parent.bottom anchors.left: parent.left - width: 150 + layout: + type: horizontalBox + spacing: 4 + fit-children: true + padding: 6 4 Panel id: gameButtonsPanel @@ -85,13 +57,21 @@ TopPanel anchors.bottom: parent.bottom anchors.left: prev.right anchors.right: next.left + layout: + type: horizontalBox + spacing: 4 + padding: 6 4 Panel id: rightButtonsPanel anchors.top: parent.top anchors.bottom: parent.bottom anchors.right: parent.right - width: 70 + layout: + type: horizontalBox + spacing: 4 + fit-children: true + padding: 6 4 FrameCounter id: frameCounter diff --git a/modules/core_widgets/uiitem.lua b/modules/core_widgets/uiitem.lua index 8719b1c7..5aca0a49 100644 --- a/modules/core_widgets/uiitem.lua +++ b/modules/core_widgets/uiitem.lua @@ -21,7 +21,7 @@ function UIItem:onDrop(widget, mousePos) if not widget or not widget.currentDragThing then return false end local pos = self.position - local count = 1 -- todo make a window for it + local count = widget.currentDragThing:getData() Game.move(widget.currentDragThing, pos, count) return true diff --git a/modules/game/game.otmod b/modules/game/game.otmod index 45533180..7187fcb1 100644 --- a/modules/game/game.otmod +++ b/modules/game/game.otmod @@ -7,9 +7,9 @@ Module dependencies: - game_healthbar - game_inventory - //- game_skills + - game_skills - game_textmessage - //- game_viplist + - game_viplist - game_console - game_outfit - game_containers diff --git a/modules/game_skills/skills.lua b/modules/game_skills/skills.lua index 52f00567..46350e54 100644 --- a/modules/game_skills/skills.lua +++ b/modules/game_skills/skills.lua @@ -1,7 +1,7 @@ Skills = {} -- private variables -local skillWindow +local skillsWindow local skillsButton -- private functions @@ -19,7 +19,7 @@ local function getNumberString(number) end local function setSkillValue(id, value) - local skill = skillWindow:recursiveGetChildById(id) + local skill = skillsWindow:recursiveGetChildById(id) if skill then local widget = skill:getChildById('value') @@ -28,7 +28,7 @@ local function setSkillValue(id, value) end local function setSkillPercent(id, percent, tooltip) - local skill = skillWindow:recursiveGetChildById(id) + local skill = skillsWindow:recursiveGetChildById(id) if skill then local widget = skill:getChildById('percent') @@ -42,19 +42,22 @@ end -- public functions function Skills.create() - skillWindow = displayUI('skills.otui', { parent = Game.gameRightPanel }) + skillsWindow = displayUI('skills.otui', { parent = Game.gameRightPanel }) + skillsWindow:hide() skillsButton = TopMenu.addGameButton('skillsButton', 'Skills (Ctrl+S)', '/core_styles/icons/skills.png', Skills.toggle) end function Skills.destroy() - --skillsButton:destroy() - --skillsButton = nil - skillWindow:destroy() - skillWindow = nil + skillsButton:destroy() + skillsButton = nil + skillsWindow:destroy() + skillsWindow = nil end function Skills.toggle() - + local visible = not skillsWindow:isExplicitlyVisible() + skillsWindow:setVisible(visible) + skillsButton:setOn(visible) end function Skills.onSkillButtonClick(button) diff --git a/modules/game_skills/skills.otui b/modules/game_skills/skills.otui index 8d66a7e9..a9909c56 100644 --- a/modules/game_skills/skills.otui +++ b/modules/game_skills/skills.otui @@ -33,7 +33,7 @@ SkillPercentPanel < ProgressBar MiniWindow id: skillWindow text: Skills - size: 200 350 + height: 350 Panel id: skillPanel diff --git a/modules/game_viplist/viplist.lua b/modules/game_viplist/viplist.lua index 20248f59..8e2f9a0f 100644 --- a/modules/game_viplist/viplist.lua +++ b/modules/game_viplist/viplist.lua @@ -1,19 +1,28 @@ VipList = {} -- private variables -local vipWindow = nil -local addVipWindow = nil +local vipWindow +local vipButton +local addVipWindow -- public functions function VipList.create() vipWindow = displayUI('viplist.otui', { parent = Game.gameRightPanel }) - --vipWindow:hide() - TopMenu.addGameButton('vipListButton', 'VIP list', '/core_styles/icons/viplist.png', VipList.toggle) + vipWindow:hide() + vipButton = TopMenu.addGameButton('vipListButton', 'VIP list', '/core_styles/icons/viplist.png', VipList.toggle) end function VipList.destroy() vipWindow:destroy() vipWindow = nil + vipButton:destroy() + vipButton = nil +end + +function VipList.toggle() + local visible = not vipWindow:isExplicitlyVisible() + vipWindow:setVisible(visible) + vipButton:setOn(visible) end function VipList.createAddWindow() diff --git a/src/framework/ui/uianchorlayout.cpp b/src/framework/ui/uianchorlayout.cpp index 102d164a..694e0197 100644 --- a/src/framework/ui/uianchorlayout.cpp +++ b/src/framework/ui/uianchorlayout.cpp @@ -84,6 +84,9 @@ void UIAnchorLayout::removeWidget(const UIWidgetPtr& widget) void UIAnchorLayout::updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anchorGroup) { UIWidgetPtr parentWidget = getParentWidget(); + if(!parentWidget) + return; + Rect newRect = widget->getRect(); bool verticalMoved = false; bool horizontalMoved = false; diff --git a/src/framework/ui/uihorizontallayout.cpp b/src/framework/ui/uihorizontallayout.cpp index f0d026ef..2bc50f84 100644 --- a/src/framework/ui/uihorizontallayout.cpp +++ b/src/framework/ui/uihorizontallayout.cpp @@ -38,6 +38,8 @@ void UIHorizontalLayout::applyStyle(const OTMLNodePtr& styleNode) void UIHorizontalLayout::internalUpdate() { UIWidgetPtr parentWidget = getParentWidget(); + if(!parentWidget) + return; UIWidgetList widgets = parentWidget->getChildren(); if(m_alignRight) diff --git a/src/framework/ui/uiverticallayout.cpp b/src/framework/ui/uiverticallayout.cpp index 5e50f2b5..718fc938 100644 --- a/src/framework/ui/uiverticallayout.cpp +++ b/src/framework/ui/uiverticallayout.cpp @@ -37,6 +37,9 @@ void UIVerticalLayout::applyStyle(const OTMLNodePtr& styleNode) void UIVerticalLayout::internalUpdate() { UIWidgetPtr parentWidget = getParentWidget(); + if(!parentWidget) + return; + UIWidgetList widgets = parentWidget->getChildren(); if(m_alignBottom) diff --git a/src/framework/ui/uiwidget.cpp b/src/framework/ui/uiwidget.cpp index a0f1d9a6..123f9e19 100644 --- a/src/framework/ui/uiwidget.cpp +++ b/src/framework/ui/uiwidget.cpp @@ -639,6 +639,9 @@ void UIWidget::setVisible(bool visible) parent->focusPreviousChild(Fw::ActiveFocusReason); } + // visibility can change can change parent layout + updateParentLayout(); + updateState(Fw::ActiveState); updateState(Fw::HoverState); } diff --git a/src/framework/util/utf8.cpp b/src/framework/util/utf8.cpp index 1ad64377..c0170e40 100644 --- a/src/framework/util/utf8.cpp +++ b/src/framework/util/utf8.cpp @@ -29,6 +29,7 @@ char Fw::utf8CharToLatin1(uchar *utf8, int *read) { char c = '?'; uchar opt1 = utf8[0]; + *read = 1; if(opt1 == 0xc3) { *read = 2; uchar opt2 = utf8[1]; @@ -39,7 +40,6 @@ char Fw::utf8CharToLatin1(uchar *utf8, int *read) if(opt2 > 0xa1 && opt2 < 0xbb) c = opt2; } else if(opt1 < 0xc2) { - *read = 1; c = opt1; } return c; @@ -49,7 +49,7 @@ std::string Fw::utf8StringToLatin1(uchar *utf8) { std::string out; int len = strlen((char*)utf8); for(int i=0; igetPos().x != 65535) { - dump << thing->getPos(); TilePtr tile = g_map.getTile(thing->getPos()); if(tile) return tile->getThingStackpos(thing); diff --git a/src/otclient/core/item.cpp b/src/otclient/core/item.cpp index c5744f86..3760f00b 100644 --- a/src/otclient/core/item.cpp +++ b/src/otclient/core/item.cpp @@ -29,7 +29,7 @@ Item::Item() : Thing() { - m_data = 0; + m_data = 1; } ItemPtr Item::create(int id) diff --git a/src/otclient/core/map.h b/src/otclient/core/map.h index 22d827ef..1782e555 100644 --- a/src/otclient/core/map.h +++ b/src/otclient/core/map.h @@ -37,7 +37,7 @@ public: MAP_SIZE_Z = 8, MAX_WIDTH = 24, MAX_HEIGHT = 24, - MAX_Z = 15, + MAX_Z = 16, NUM_TILE_PIXELS = 32 }; diff --git a/src/otclient/luafunctions.cpp b/src/otclient/luafunctions.cpp index db5f577f..7f6c9d81 100644 --- a/src/otclient/luafunctions.cpp +++ b/src/otclient/luafunctions.cpp @@ -133,6 +133,7 @@ void OTClient::registerLuaFunctions() g_lua.registerClass(); g_lua.bindClassStaticFunction("create", &Item::create); + g_lua.bindClassMemberFunction("getData", &Item::getData); g_lua.registerClass(); g_lua.registerClass();