diff --git a/.gitignore b/.gitignore index 033177bc..a85eb9fe 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,9 @@ CMakeCache.txt CMakeFiles cmake_install.cmake Makefile -./otclient +/otclient +/*.h +/*.cxx *.o *.gch *.a @@ -13,6 +15,6 @@ Makefile *.kdev* *.cbp CMakeLists.txt.user -./modules/myconfig.otml -./modules/myotclientrc.lua +/modules/myconfig.otml +/modules/myotclientrc.lua !.gitignore diff --git a/modules/addon_playground/playground.lua b/modules/addon_playground/playground.lua deleted file mode 100644 index 380330d0..00000000 --- a/modules/addon_playground/playground.lua +++ /dev/null @@ -1,2 +0,0 @@ --- place any code for testing purposes here ---scheduleEvent(function() dumpWidgets() end, 100) \ No newline at end of file diff --git a/modules/addon_playground/playground.otmod b/modules/addon_playground/playground.otmod deleted file mode 100644 index 05a3d281..00000000 --- a/modules/addon_playground/playground.otmod +++ /dev/null @@ -1,7 +0,0 @@ -Module - name: playground - autoLoad: true - autoLoadAntecedence: 1000 - onLoad: | - require 'playground' - diff --git a/modules/client/client.lua b/modules/client/client.lua index 8c9b5492..60f1450f 100644 --- a/modules/client/client.lua +++ b/modules/client/client.lua @@ -15,9 +15,9 @@ function Client.init() -- window position, default is the screen center local displaySize = g_window.getDisplaySize() - local pos = { x = (displaySize.width - size.width)/2, - y = (displaySize.height - size.height)/2 } - pos = Settings.getPoint('window-pos', pos) + local defaultPos = { x = (displaySize.width - size.width)/2, + y = (displaySize.height - size.height)/2 } + local pos = Settings.getPoint('window-pos', defaultPos) g_window.move(pos) -- window maximized? diff --git a/modules/client_about/about.lua b/modules/client_about/about.lua index 1dd86699..41f54714 100644 --- a/modules/client_about/about.lua +++ b/modules/client_about/about.lua @@ -9,7 +9,7 @@ function About.init() end function About.display() - aboutWindow = displayUI('about.otui', { locked = true }) + displayUI('about.otui', { locked = true }) end function About.terminate() diff --git a/modules/client_about/about.otmod b/modules/client_about/about.otmod index d3c1f63a..7c934992 100644 --- a/modules/client_about/about.otmod +++ b/modules/client_about/about.otmod @@ -8,5 +8,5 @@ Module require 'about' About.init() - onUnload: + onUnload: | About.terminate() \ No newline at end of file diff --git a/modules/client_background/background.lua b/modules/client_background/background.lua index 6972898f..b184d6d4 100644 --- a/modules/client_background/background.lua +++ b/modules/client_background/background.lua @@ -6,6 +6,7 @@ local background -- public functions function Background.init() background = displayUI('background.otui') + background:lower() end function Background.terminate() diff --git a/modules/client_background/background.otmod b/modules/client_background/background.otmod index bb19c7ba..733586d2 100644 --- a/modules/client_background/background.otmod +++ b/modules/client_background/background.otmod @@ -8,6 +8,6 @@ Module require 'background' Background.init() - onUnload: + onUnload: | Background.terminate() diff --git a/modules/client_entergame/characterlist.lua b/modules/client_entergame/characterlist.lua index 942bb383..516c871b 100644 --- a/modules/client_entergame/characterlist.lua +++ b/modules/client_entergame/characterlist.lua @@ -54,6 +54,18 @@ local function tryLogin(charInfo, tries) end -- public functions +function CharacterList.terminate() + characterList = nil + if charactersWindow then + charactersWindow:destroy() + charactersWindow = nil + end + if loadBox then + loadBox:destroy() + loadBox = nil + end +end + function CharacterList.create(characters, premDays) if charactersWindow then charactersWindow:destroy() @@ -77,7 +89,7 @@ function CharacterList.create(characters, premDays) label.characterName = characterName label.worldHost = worldHost label.worldPort = worldIp - + connect(label, { onDoubleClick = function () CharacterList.doLogin() return true end } ) if i == 1 or Settings.get('lastUsedCharacter') == characterName then diff --git a/modules/client_entergame/entergame.otmod b/modules/client_entergame/entergame.otmod index 081ae34d..8a9e14e0 100644 --- a/modules/client_entergame/entergame.otmod +++ b/modules/client_entergame/entergame.otmod @@ -9,7 +9,8 @@ Module require 'characterlist' EnterGame.init() - onUnload: + onUnload: | EnterGame.terminate() + CharacterList.terminate() diff --git a/modules/client_entergame/entergame.otui b/modules/client_entergame/entergame.otui index c24498af..0da010c7 100644 --- a/modules/client_entergame/entergame.otui +++ b/modules/client_entergame/entergame.otui @@ -40,7 +40,7 @@ MainWindow LineEdit id: serverHostLineEdit - tooltip: Only protocol 8.62 is supported + tooltip: Only protocol 8.6 is supported anchors.left: serverLabel.left anchors.right: serverLabel.right anchors.top: serverLabel.bottom diff --git a/modules/client_topmenu/topmenu.lua b/modules/client_topmenu/topmenu.lua index e031a145..77862a42 100644 --- a/modules/client_topmenu/topmenu.lua +++ b/modules/client_topmenu/topmenu.lua @@ -30,6 +30,7 @@ function TopMenu.terminate() Hotkeys.unbindKeyDown('Ctrl+Q') leftButtonsPanel = nil rightButtonsPanel = nil + gameButtonsPanel = nil topMenu:destroy() topMenu = nil end diff --git a/modules/core_lib/core_lib.otmod b/modules/core_lib/core_lib.otmod index ad36808d..8a956237 100644 --- a/modules/core_lib/core_lib.otmod +++ b/modules/core_lib/core_lib.otmod @@ -20,3 +20,6 @@ Module require 'settings' require 'hotkeys' require 'cursor' + + onUnload: | + rootWidget = nil diff --git a/modules/core_widgets/tooltip/tooltip.lua b/modules/core_widgets/tooltip/tooltip.lua index 5637a3c0..2906767b 100644 --- a/modules/core_widgets/tooltip/tooltip.lua +++ b/modules/core_widgets/tooltip/tooltip.lua @@ -1,11 +1,12 @@ ToolTip = {} -- private variables -local currentToolTip +local toolTipLabel +local currentHoveredWidget -- private functions local function moveToolTip(tooltip) - local pos = g_window.getMousePos() + local pos = g_window.getMousePosition() pos.y = pos.y + 1 local xdif = g_window.getSize().width - (pos.x + tooltip:getWidth()) if xdif < 2 then @@ -18,34 +19,37 @@ end -- public functions function ToolTip.display(text) - if text then - ToolTip.hide() - currentToolTip = displayUI('tooltip.otui') - currentToolTip.onMouseMove = moveToolTip - local label = currentToolTip:getChildById('toolTipText') - label:setText(text) - label:resizeToText() - local size = label:getSize() - size.width = size.width + 4 - size.height = size.height + 4 - currentToolTip:setSize(size) - moveToolTip(currentToolTip) - end + if text == nil then return end + ToolTip.hide() + toolTipLabel = createWidget('Label', rootWidget) + toolTipLabel:setId('toolTip') + toolTipLabel:setBackgroundColor('#111111bb') + toolTipLabel:setText(text) + toolTipLabel:resizeToText() + toolTipLabel:resize(toolTipLabel:getWidth() + 4, toolTipLabel:getHeight() + 4) + toolTipLabel.onMouseMove = moveToolTip + moveToolTip(toolTipLabel) end function ToolTip.hide() - if currentToolTip then - currentToolTip:destroy() - currentToolTip = nil + if toolTipLabel then + toolTipLabel:destroy() + toolTipLabel = nil end end -- UIWidget hooks local function onWidgetHoverChange(widget, hovered) if hovered then - ToolTip.display(widget.tooltip) + if widget.tooltip then + ToolTip.display(widget.tooltip) + currentHoveredWidget = widget + end else - ToolTip:hide() + if widget == currentHoveredWidget then + ToolTip:hide() + currentHoveredWidget = nil + end end end diff --git a/modules/core_widgets/tooltip/tooltip.otui b/modules/core_widgets/tooltip/tooltip.otui index 7777ac88..61b91b35 100644 --- a/modules/core_widgets/tooltip/tooltip.otui +++ b/modules/core_widgets/tooltip/tooltip.otui @@ -1,9 +1,7 @@ -Panel +Label + id: toolTipText background-color: #111111bb size: 200 200 id: toolTip focusable: false - - Label - id: toolTipText - anchors.centerIn: parent \ No newline at end of file + anchors.centerIn: parent diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt index 54e7f30c..3f69765d 100644 --- a/src/framework/CMakeLists.txt +++ b/src/framework/CMakeLists.txt @@ -8,9 +8,8 @@ SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake;${CMAKE_MODULE_PATH}") # framework options OPTION(NO_CONSOLE "Disables console window on Windows platform" OFF) -OPTION(HANDLE_EXCEPTIONS "Generate crash reports" OFF) +OPTION(CRASH_HANDLER "Generate crash reports" OFF) OPTION(USE_OPENGL_ES2 "Use OpenGL ES 2.0 (for mobiles devices)" OFF) -OPTION(USE_GCC47 "Use experimental gcc 4.7" OFF) # set debug as default build type IF(NOT CMAKE_BUILD_TYPE) @@ -46,27 +45,22 @@ IF(CMAKE_COMPILER_IS_GNUCXX) ENDIF(CMAKE_COMPILER_IS_GNUCXX) IF(CMAKE_BUILD_TYPE STREQUAL "Debug") - ADD_DEFINITIONS(-D_DEBUG) + ADD_DEFINITIONS(-DDEBUG) ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug") MESSAGE(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) IF(USE_OPENGL_ES2) - MESSAGE(STATUS "Renderer: OpenGL ES 2") + MESSAGE(STATUS "Renderer: OpenGL ES 2.0") ELSE(USE_OPENGL_ES2) MESSAGE(STATUS "Renderer: OpenGL") ENDIF(USE_OPENGL_ES2) -IF(HANDLE_EXCEPTIONS) - ADD_DEFINITIONS(-DHANDLE_EXCEPTIONS) - MESSAGE(STATUS "Generate crash reports: ON") -ELSE(HANDLE_EXCEPTIONS) - MESSAGE(STATUS "Generate crash reports: OFF") -ENDIF(HANDLE_EXCEPTIONS) - -IF(USE_GCC47) - SET(CMAKE_C_COMPILER gcc-4.7) - SET(CMAKE_CXX_COMPILER g++-4.7) -ENDIF(USE_GCC47) +IF(CRASH_HANDLER) + ADD_DEFINITIONS(-DCRASH_HANDLER) + MESSAGE(STATUS "Crash handler: ON") +ELSE(CRASH_HANDLER) + MESSAGE(STATUS "Crash handler: OFF") +ENDIF(CRASH_HANDLER) IF(WIN32) SET(framework_SOURCES ${framework_SOURCES} @@ -88,9 +82,6 @@ IF(WIN32) ELSE(WIN32) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -rdynamic") - IF(USE_GCC47) - ADD_DEFINITIONS(-D_GLIBCXX__PTHREADS) - ENDIF(USE_GCC47) SET(ADDITIONAL_LIBRARIES X11 dl) SET(framework_SOURCES ${framework_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.cpp diff --git a/src/framework/application.cpp b/src/framework/application.cpp index e8b7c114..c9d73da7 100644 --- a/src/framework/application.cpp +++ b/src/framework/application.cpp @@ -73,7 +73,7 @@ void Application::init(const std::vector& args, int appFlags) signal(SIGTERM, exitSignalHandler); signal(SIGINT, exitSignalHandler); -#ifdef HANDLE_EXCEPTIONS +#ifdef CRASH_HANDLER installCrashHandler(); #endif @@ -119,6 +119,8 @@ void Application::init(const std::vector& args, int appFlags) void Application::terminate() { + g_lua.callGlobalField("g_app", "onTerminate"); + // hide the window because there is no render anymore if(m_appFlags & Fw::AppEnableGraphics) g_window.hide(); @@ -160,6 +162,8 @@ void Application::terminate() void Application::run() { + g_lua.callGlobalField("g_app", "onRun"); + ticks_t lastPollTicks = g_clock.updateTicks(); m_stopping = false; m_running = true; diff --git a/src/framework/core/eventdispatcher.cpp b/src/framework/core/eventdispatcher.cpp index 599115f1..649b0b91 100644 --- a/src/framework/core/eventdispatcher.cpp +++ b/src/framework/core/eventdispatcher.cpp @@ -45,8 +45,8 @@ void EventDispatcher::poll() scheduledEvent->execute(); } - int maxEvents = m_eventList.size(); - for(int i=0;iexecute(); @@ -64,9 +64,10 @@ ScheduledEventPtr EventDispatcher::scheduleEvent(const SimpleCallback& callback, EventPtr EventDispatcher::addEvent(const SimpleCallback& callback, bool pushFront) { EventPtr event(new Event(callback)); - if(pushFront) + if(pushFront) { m_eventList.push_front(event); - else + m_pollEventsSize++; + } else m_eventList.push_back(event); return event; } diff --git a/src/framework/core/eventdispatcher.h b/src/framework/core/eventdispatcher.h index 074c0034..f7afade3 100644 --- a/src/framework/core/eventdispatcher.h +++ b/src/framework/core/eventdispatcher.h @@ -80,6 +80,7 @@ public: private: std::list m_eventList; + int m_pollEventsSize; std::priority_queue, lessScheduledEvent> m_scheduledEventList; }; diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index 8068516b..1963b72e 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -60,7 +60,8 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("focusChild", &UIWidget::focusChild); g_lua.bindClassMemberFunction("focusNextChild", &UIWidget::focusNextChild); g_lua.bindClassMemberFunction("focusPreviousChild", &UIWidget::focusPreviousChild); - g_lua.bindClassMemberFunction("moveChildToTop", &UIWidget::moveChildToTop); + g_lua.bindClassMemberFunction("lowerChild", &UIWidget::lowerChild); + g_lua.bindClassMemberFunction("raiseChild", &UIWidget::raiseChild); g_lua.bindClassMemberFunction("moveChildToIndex", &UIWidget::moveChildToIndex); g_lua.bindClassMemberFunction("lockChild", &UIWidget::lockChild); g_lua.bindClassMemberFunction("unlockChild", &UIWidget::unlockChild); @@ -74,6 +75,8 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("lock", &UIWidget::lock); g_lua.bindClassMemberFunction("unlock", &UIWidget::unlock); g_lua.bindClassMemberFunction("focus", &UIWidget::focus); + g_lua.bindClassMemberFunction("lower", &UIWidget::lower); + g_lua.bindClassMemberFunction("raise", &UIWidget::raise); g_lua.bindClassMemberFunction("grabMouse", &UIWidget::grabMouse); g_lua.bindClassMemberFunction("ungrabMouse", &UIWidget::ungrabMouse); g_lua.bindClassMemberFunction("grabKeyboard", &UIWidget::grabKeyboard); @@ -355,6 +358,11 @@ void Application::registerLuaFunctions() g_lua.bindClassStaticFunction("create", []{ return UIFrameCounterPtr(new UIFrameCounter); } ); g_lua.bindClassMemberFunction("getFrameCount", &UIFrameCounter::getFrameCount); + // Protocol + g_lua.registerClass(); + + // network manipulation via lua is disabled for a while + /* // OutputMessage g_lua.registerClass(); g_lua.bindClassStaticFunction("new", []{ return OutputMessagePtr(new OutputMessage); }); @@ -365,9 +373,8 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("addU64", &OutputMessage::addU64); g_lua.bindClassMemberFunction("addString", (void(OutputMessage::*)(const std::string&))&OutputMessage::addString); - // Protocol - g_lua.registerClass(); g_lua.bindClassStaticFunction("send", [](const ProtocolPtr proto, OutputMessagePtr msg) { proto->send(*msg.get()); }); + */ // Application g_lua.registerStaticClass("g_app"); @@ -415,7 +422,7 @@ void Application::registerLuaFunctions() g_lua.bindClassStaticFunction("g_window", "getPosition", std::bind(&PlatformWindow::getPosition, &g_window)); g_lua.bindClassStaticFunction("g_window", "getX", std::bind(&PlatformWindow::getX, &g_window)); g_lua.bindClassStaticFunction("g_window", "getY", std::bind(&PlatformWindow::getY, &g_window)); - g_lua.bindClassStaticFunction("g_window", "getMousePos", std::bind(&PlatformWindow::getMousePos, &g_window)); + g_lua.bindClassStaticFunction("g_window", "getMousePosition", std::bind(&PlatformWindow::getMousePosition, &g_window)); g_lua.bindClassStaticFunction("g_window", "getKeyboardModifiers", std::bind(&PlatformWindow::getKeyboardModifiers, &g_window)); g_lua.bindClassStaticFunction("g_window", "isKeyPressed", std::bind(&PlatformWindow::isKeyPressed, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "isVisible", std::bind(&PlatformWindow::isVisible, &g_window)); diff --git a/src/framework/platform/platformwindow.h b/src/framework/platform/platformwindow.h index 21b32fdb..1b0f5bba 100644 --- a/src/framework/platform/platformwindow.h +++ b/src/framework/platform/platformwindow.h @@ -76,7 +76,7 @@ public: Point getPosition() { return m_position; } int getX() { return m_position.x; } int getY() { return m_position.y; } - Point getMousePos() { return m_inputEvent.mousePos; } + Point getMousePosition() { return m_inputEvent.mousePos; } int getKeyboardModifiers() { return m_inputEvent.keyboardModifiers; } bool isKeyPressed(Fw::Key keyCode) { return m_keysState[keyCode]; } diff --git a/src/framework/ui/uimanager.cpp b/src/framework/ui/uimanager.cpp index 0f46cf4e..2b33c407 100644 --- a/src/framework/ui/uimanager.cpp +++ b/src/framework/ui/uimanager.cpp @@ -40,9 +40,12 @@ void UIManager::init() void UIManager::terminate() { - // destroy root widget and its children' + // destroy root widget and its children m_rootWidget->destroy(); - m_rootWidget.reset(); + m_mouseReceiver = nullptr; + m_keyboardReceiver = nullptr; + m_rootWidget = nullptr; + m_draggingWidget = nullptr; } void UIManager::render() diff --git a/src/framework/ui/uiwidget.cpp b/src/framework/ui/uiwidget.cpp index a94dea8d..15a455e9 100644 --- a/src/framework/ui/uiwidget.cpp +++ b/src/framework/ui/uiwidget.cpp @@ -44,7 +44,10 @@ UIWidget::UIWidget() UIWidget::~UIWidget() { - // nothing to do +#ifdef DEBUG + if(!m_destroyed) + logWarning("widget '", m_id, "' was not explicitly destroyed"); +#endif } void UIWidget::draw() @@ -158,7 +161,7 @@ void UIWidget::insertChild(int index, const UIWidgetPtr& child) updateChildrenIndexStates(); } -void UIWidget::removeChild(const UIWidgetPtr& child) +void UIWidget::removeChild(UIWidgetPtr child) { // remove from children list if(hasChild(child)) { @@ -269,7 +272,20 @@ void UIWidget::focusPreviousChild(Fw::FocusReason reason) focusChild(toFocus, reason); } -void UIWidget::moveChildToTop(const UIWidgetPtr& child) +void UIWidget::lowerChild(UIWidgetPtr child) +{ + if(!child) + return; + + // remove and push child again + auto it = std::find(m_children.begin(), m_children.end(), child); + assert(it != m_children.end()); + m_children.erase(it); + m_children.push_front(child); + updateChildrenIndexStates(); +} + +void UIWidget::raiseChild(UIWidgetPtr child) { if(!child) return; @@ -320,7 +336,7 @@ void UIWidget::lockChild(const UIWidgetPtr& child) if(child->isFocusable()) focusChild(child, Fw::ActiveFocusReason); - moveChildToTop(child); + raiseChild(child); } void UIWidget::unlockChild(const UIWidgetPtr& child) @@ -360,7 +376,7 @@ void UIWidget::unlockChild(const UIWidgetPtr& child) if(lockedChild->isFocusable()) focusChild(lockedChild, Fw::ActiveFocusReason); - moveChildToTop(lockedChild); + raiseChild(lockedChild); } } @@ -460,6 +476,21 @@ void UIWidget::focus() parent->focusChild(asUIWidget(), Fw::ActiveFocusReason); } +void UIWidget::lower() +{ + UIWidgetPtr parent = getParent(); + if(parent) + parent->lowerChild(asUIWidget()); +} + +void UIWidget::raise() +{ + focus(); + UIWidgetPtr parent = getParent(); + if(parent) + parent->raiseChild(asUIWidget()); +} + void UIWidget::grabMouse() { g_ui.setMouseReceiver(asUIWidget()); @@ -515,8 +546,25 @@ void UIWidget::destroy() parent->removeChild(asUIWidget()); } + // destroy children + while(!m_children.empty()) + getFirstChild()->destroy(); + callLuaField("onDestroy"); +#ifdef DEBUG + auto self = asUIWidget(); + g_lua.collectGarbage(); + g_dispatcher.addEvent([self] { + g_lua.collectGarbage(); + g_dispatcher.addEvent([self] { + g_lua.collectGarbage(); + if(self->getUseCount() != 1) + logWarning("widget '", self->getId(), "' destroyed but still have ", self->getUseCount()-1, " reference(s) left"); + }); + }); +#endif + m_destroyed = true; } @@ -905,17 +953,11 @@ void UIWidget::updateState(Fw::WidgetState state) } case Fw::HoverState: { updateChildren = true; - Point mousePos = g_window.getMousePos(); - UIWidgetPtr widget = asUIWidget(); - UIWidgetPtr parent; - do { - parent = widget->getParent(); - if(!widget->isExplicitlyEnabled() || !widget->isExplicitlyVisible() || !widget->containsPoint(mousePos) || - (parent && widget != parent->getChildByPos(mousePos))) { - newStatus = false; - break; - } - } while(widget = parent); + Point mousePos = g_window.getMousePosition(); + UIWidgetPtr self = asUIWidget(); + UIWidgetPtr rootParent = self->getRootParent(); + if(!rootParent || rootParent->recursiveGetChildByPos(mousePos) != self) + newStatus = false; break; } case Fw::PressedState: { @@ -1273,7 +1315,7 @@ bool UIWidget::propagateOnMousePress(const Point& mousePos, Fw::MouseButton butt return true; } - // only non phatom widgets receives mouse press events + // only non phatom widgets receives mouse events if(!isPhantom()) { bool ret = onMousePress(mousePos, button); if(button == Fw::MouseLeftButton && !isPressed()) @@ -1302,12 +1344,15 @@ bool UIWidget::propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton bu return true; } - bool ret = onMouseRelease(mousePos, button); - - if(isPressed() && button == Fw::MouseLeftButton) - setPressed(false); + // only non phatom widgets receives mouse events + if(!isPhantom()) { + bool ret = onMouseRelease(mousePos, button); + if(isPressed() && button == Fw::MouseLeftButton) + setPressed(false); + return ret; + } - return ret; + return false; } bool UIWidget::propagateOnMouseMove(const Point& mousePos, const Point& mouseMoved) @@ -1328,10 +1373,7 @@ bool UIWidget::propagateOnMouseMove(const Point& mousePos, const Point& mouseMov return true; } - if(!isPhantom()) - return onMouseMove(mousePos, mouseMoved); - else - return false; + return onMouseMove(mousePos, mouseMoved); } bool UIWidget::propagateOnMouseWheel(const Point& mousePos, Fw::MouseWheelDirection direction) @@ -1353,6 +1395,7 @@ bool UIWidget::propagateOnMouseWheel(const Point& mousePos, Fw::MouseWheelDirect return true; } + // only non phatom widgets receives mouse events if(!isPhantom()) return onMouseWheel(mousePos, direction); else diff --git a/src/framework/ui/uiwidget.h b/src/framework/ui/uiwidget.h index f27a3d95..25c5875f 100644 --- a/src/framework/ui/uiwidget.h +++ b/src/framework/ui/uiwidget.h @@ -78,11 +78,12 @@ protected: public: void addChild(const UIWidgetPtr& child); void insertChild(int index, const UIWidgetPtr& child); - void removeChild(const UIWidgetPtr& child); + void removeChild(UIWidgetPtr child); void focusChild(const UIWidgetPtr& child, Fw::FocusReason reason); void focusNextChild(Fw::FocusReason reason); void focusPreviousChild(Fw::FocusReason reason); - void moveChildToTop(const UIWidgetPtr& child); + void lowerChild(UIWidgetPtr child); + void raiseChild(UIWidgetPtr child); void moveChildToIndex(const UIWidgetPtr& child, int index); void lockChild(const UIWidgetPtr& child); void unlockChild(const UIWidgetPtr& child); @@ -96,6 +97,8 @@ public: void lock(); void unlock(); void focus(); + void lower(); + void raise(); void grabMouse(); void ungrabMouse(); void grabKeyboard(); diff --git a/src/otclient/CMakeLists.txt b/src/otclient/CMakeLists.txt index 2c3ed0b5..946ef205 100644 --- a/src/otclient/CMakeLists.txt +++ b/src/otclient/CMakeLists.txt @@ -4,17 +4,17 @@ IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6) ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6) # otclient options -OPTION(NO_BOT_PROTECTION "Disables bot protection" OFF) -SET(PROTOCOL 862 CACHE "Protocol version" STRING) +OPTION(BOT_PROTECTION "Enable bot protection" ON) +SET(PROTOCOL 861 CACHE "Protocol version" STRING) ADD_DEFINITIONS(-DPROTOCOL=${PROTOCOL}) MESSAGE(STATUS "Protocol: " ${PROTOCOL}) -IF(NO_BOT_PROTECTION) - ADD_DEFINITIONS(-DNO_BOT_PROTECTION) - MESSAGE(STATUS "Bot protection: OFF") -ELSE(NO_BOT_PROTECTION) +IF(BOT_PROTECTION) + ADD_DEFINITIONS(-DBOT_PROTECTION) MESSAGE(STATUS "Bot protection: ON") -ENDIF(NO_BOT_PROTECTION) +ELSE(BOT_PROTECTION) + MESSAGE(STATUS "Bot protection: OFF") +ENDIF(BOT_PROTECTION) SET(otclient_SOURCES ${otclient_SOURCES} # otclient diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index 044b9a0b..a96dad6c 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -94,7 +94,7 @@ void Game::processLogout() m_protocolGame = nullptr; } - g_map.save(); + //g_map.save(); } void Game::processDeath() @@ -587,7 +587,7 @@ void Game::removeVip(int playerId) bool Game::checkBotProtection() { -#ifndef NO_BOT_PROTECTION +#ifdef BOT_PROTECTION if(g_lua.isInCppCallback() && !g_ui.isOnInputEvent()) { logError("caught a lua call to a bot protected game function, the call was canceled"); return false; diff --git a/src/otclient/otclient.cpp b/src/otclient/otclient.cpp index bc84d753..d068af43 100644 --- a/src/otclient/otclient.cpp +++ b/src/otclient/otclient.cpp @@ -41,7 +41,7 @@ void OTClient::init(const std::vector& args) g_modules.ensureModuleLoaded("client"); g_modules.autoLoadModules(1000); - g_map.load(); + //g_map.load(); // load otclientrc.lua if(g_resources.fileExists("/otclientrc.lua")) {