some cleanup in modules, fixes in tooltip, uiwidget warnings, disable map saving for a while
This commit is contained in:
parent
0471785d30
commit
a55e138002
|
@ -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
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
-- place any code for testing purposes here
|
||||
--scheduleEvent(function() dumpWidgets() end, 100)
|
|
@ -1,7 +0,0 @@
|
|||
Module
|
||||
name: playground
|
||||
autoLoad: true
|
||||
autoLoadAntecedence: 1000
|
||||
onLoad: |
|
||||
require 'playground'
|
||||
|
|
@ -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?
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -8,5 +8,5 @@ Module
|
|||
require 'about'
|
||||
About.init()
|
||||
|
||||
onUnload:
|
||||
onUnload: |
|
||||
About.terminate()
|
|
@ -6,6 +6,7 @@ local background
|
|||
-- public functions
|
||||
function Background.init()
|
||||
background = displayUI('background.otui')
|
||||
background:lower()
|
||||
end
|
||||
|
||||
function Background.terminate()
|
||||
|
|
|
@ -8,6 +8,6 @@ Module
|
|||
require 'background'
|
||||
Background.init()
|
||||
|
||||
onUnload:
|
||||
onUnload: |
|
||||
Background.terminate()
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -9,7 +9,8 @@ Module
|
|||
require 'characterlist'
|
||||
EnterGame.init()
|
||||
|
||||
onUnload:
|
||||
onUnload: |
|
||||
EnterGame.terminate()
|
||||
CharacterList.terminate()
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -30,6 +30,7 @@ function TopMenu.terminate()
|
|||
Hotkeys.unbindKeyDown('Ctrl+Q')
|
||||
leftButtonsPanel = nil
|
||||
rightButtonsPanel = nil
|
||||
gameButtonsPanel = nil
|
||||
topMenu:destroy()
|
||||
topMenu = nil
|
||||
end
|
||||
|
|
|
@ -20,3 +20,6 @@ Module
|
|||
require 'settings'
|
||||
require 'hotkeys'
|
||||
require 'cursor'
|
||||
|
||||
onUnload: |
|
||||
rootWidget = nil
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
Panel
|
||||
Label
|
||||
id: toolTipText
|
||||
background-color: #111111bb
|
||||
size: 200 200
|
||||
id: toolTip
|
||||
focusable: false
|
||||
|
||||
Label
|
||||
id: toolTipText
|
||||
anchors.centerIn: parent
|
||||
anchors.centerIn: parent
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -73,7 +73,7 @@ void Application::init(const std::vector<std::string>& 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<std::string>& 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;
|
||||
|
|
|
@ -45,8 +45,8 @@ void EventDispatcher::poll()
|
|||
scheduledEvent->execute();
|
||||
}
|
||||
|
||||
int maxEvents = m_eventList.size();
|
||||
for(int i=0;i<maxEvents;++i) {
|
||||
m_pollEventsSize = m_eventList.size();
|
||||
for(int i=0;i<m_pollEventsSize;++i) {
|
||||
EventPtr event = m_eventList.front();
|
||||
m_eventList.pop_front();
|
||||
event->execute();
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ public:
|
|||
|
||||
private:
|
||||
std::list<EventPtr> m_eventList;
|
||||
int m_pollEventsSize;
|
||||
std::priority_queue<ScheduledEventPtr, std::vector<ScheduledEventPtr>, lessScheduledEvent> m_scheduledEventList;
|
||||
};
|
||||
|
||||
|
|
|
@ -60,7 +60,8 @@ void Application::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<UIWidget>("focusChild", &UIWidget::focusChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("focusNextChild", &UIWidget::focusNextChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("focusPreviousChild", &UIWidget::focusPreviousChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("moveChildToTop", &UIWidget::moveChildToTop);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("lowerChild", &UIWidget::lowerChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("raiseChild", &UIWidget::raiseChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("moveChildToIndex", &UIWidget::moveChildToIndex);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("lockChild", &UIWidget::lockChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("unlockChild", &UIWidget::unlockChild);
|
||||
|
@ -74,6 +75,8 @@ void Application::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<UIWidget>("lock", &UIWidget::lock);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("unlock", &UIWidget::unlock);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("focus", &UIWidget::focus);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("lower", &UIWidget::lower);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("raise", &UIWidget::raise);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("grabMouse", &UIWidget::grabMouse);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("ungrabMouse", &UIWidget::ungrabMouse);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("grabKeyboard", &UIWidget::grabKeyboard);
|
||||
|
@ -355,6 +358,11 @@ void Application::registerLuaFunctions()
|
|||
g_lua.bindClassStaticFunction<UIFrameCounter>("create", []{ return UIFrameCounterPtr(new UIFrameCounter); } );
|
||||
g_lua.bindClassMemberFunction<UIFrameCounter>("getFrameCount", &UIFrameCounter::getFrameCount);
|
||||
|
||||
// Protocol
|
||||
g_lua.registerClass<Protocol>();
|
||||
|
||||
// network manipulation via lua is disabled for a while
|
||||
/*
|
||||
// OutputMessage
|
||||
g_lua.registerClass<OutputMessage>();
|
||||
g_lua.bindClassStaticFunction<OutputMessage>("new", []{ return OutputMessagePtr(new OutputMessage); });
|
||||
|
@ -365,9 +373,8 @@ void Application::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<OutputMessage>("addU64", &OutputMessage::addU64);
|
||||
g_lua.bindClassMemberFunction<OutputMessage>("addString", (void(OutputMessage::*)(const std::string&))&OutputMessage::addString);
|
||||
|
||||
// Protocol
|
||||
g_lua.registerClass<Protocol>();
|
||||
g_lua.bindClassStaticFunction<Protocol>("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));
|
||||
|
|
|
@ -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]; }
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
// only non phatom widgets receives mouse events
|
||||
if(!isPhantom()) {
|
||||
bool ret = onMouseRelease(mousePos, button);
|
||||
if(isPressed() && button == Fw::MouseLeftButton)
|
||||
setPressed(false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(isPressed() && button == Fw::MouseLeftButton)
|
||||
setPressed(false);
|
||||
|
||||
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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -41,7 +41,7 @@ void OTClient::init(const std::vector<std::string>& args)
|
|||
g_modules.ensureModuleLoaded("client");
|
||||
g_modules.autoLoadModules(1000);
|
||||
|
||||
g_map.load();
|
||||
//g_map.load();
|
||||
|
||||
// load otclientrc.lua
|
||||
if(g_resources.fileExists("/otclientrc.lua")) {
|
||||
|
|
Loading…
Reference in New Issue