diff --git a/modules/client_options/options.lua b/modules/client_options/options.lua index bd469ace..5b724ee2 100644 --- a/modules/client_options/options.lua +++ b/modules/client_options/options.lua @@ -284,3 +284,7 @@ end function addTab(name, panel, icon) optionsTabBar:addTab(name, panel, icon) end + +function addButton(name, func, icon) + optionsTabBar:addButton(name, func, icon) +end diff --git a/modules/corelib/ui/uitabbar.lua b/modules/corelib/ui/uitabbar.lua index 79c67d53..f2a5d0ab 100644 --- a/modules/corelib/ui/uitabbar.lua +++ b/modules/corelib/ui/uitabbar.lua @@ -60,6 +60,18 @@ function UITabBar:addTab(text, panel, icon) return tab end +function UITabBar:addButton(text, func, icon) + local button = g_ui.createWidget(self:getStyleName() .. 'Button', self.buttonsPanel) + button:setText(text) + + local style = {} + style['icon-source'] = icon + button:mergeStyle(style) + + button.onClick = func + return button +end + function UITabBar:removeTab(tab) local index = table.find(self.tabs, tab) if index == nil then return end diff --git a/modules/game_textwindow/textwindow.lua b/modules/game_textwindow/textwindow.lua index 2754654f..ca01f319 100644 --- a/modules/game_textwindow/textwindow.lua +++ b/modules/game_textwindow/textwindow.lua @@ -40,7 +40,7 @@ function onGameEditText(id, itemId, maxLength, text, writter, time) textEdit:setText(text) textEdit:setEditable(writeable) textEdit:setCursorVisible(writeable) - + local desc = '' if #writter > 0 then desc = tr('You read the following, written by \n%s\n', writter) @@ -71,6 +71,10 @@ function onGameEditText(id, itemId, maxLength, text, writter, time) textWindow:setText(tr('Edit Text')) end + if description:getHeight() < 64 then + description:setHeight(64) + end + local function destroy() textWindow:destroy() table.removevalue(windows, textWindow) @@ -109,20 +113,22 @@ function onGameEditList(id, doorId, text) description:setText(tr('Enter one name per line.')) textWindow:setText(tr('Edit List')) + if description:getHeight() < 64 then + description:setHeight(64) + end + local function destroy() textWindow:destroy() table.removevalue(windows, textWindow) end - doneFunc = function() + local doneFunc = function() g_game.editList(id, doorId, textEdit:getText()) destroy() end okButton.onClick = doneFunc cancelButton.onClick = destroy - - textWindow.onEnter = doneFunc textWindow.onEscape = destroy table.insert(windows, textWindow) diff --git a/src/client/position.h b/src/client/position.h index 82f7114c..0e2cb1b3 100644 --- a/src/client/position.h +++ b/src/client/position.h @@ -166,7 +166,7 @@ public: return Otc::InvalidDirection; } - bool isMapPosition() const { return (x < 65535 && y < 65535 && z <= Otc::MAX_Z); } + bool isMapPosition() const { return (x >=0 && y >= 0 && z >= 0 && x < 65535 && y < 65535 && z <= Otc::MAX_Z); } bool isValid() const { return !(x == 65535 && y == 65535 && z == 255); } float distance(const Position& pos) const { return sqrt(pow((pos.x - x), 2) + pow((pos.y - y), 2)); } int manhattanDistance(const Position& pos) const { return std::abs(pos.x - x) + std::abs(pos.y - y); } @@ -226,9 +226,9 @@ public: return false; } - uint16 x; - uint16 y; - uint8 z; + int x; + int y; + short z; }; struct PositionHasher : std::unary_function { diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt index 8a12183b..b65c9e57 100644 --- a/src/framework/CMakeLists.txt +++ b/src/framework/CMakeLists.txt @@ -136,9 +136,11 @@ option(LUAJIT "Use lua jit" OFF) if(NOT APPLE) option(CRASH_HANDLER "Generate crash reports" ON) option(USE_STATIC_LIBS "Don't use shared libraries (dlls)" ON) + option(USE_LIBCPP "Use the new libc++ library instead of stdc++" OFF) else() set(CRASH_HANDLER OFF) set(USE_STATIC_LIBS OFF) + set(USE_LIBCPP ON) endif() set(BUILD_COMMIT "devel" CACHE "Git commit string (intended for releases)" STRING) set(BUILD_REVISION "0" CACHE "Git revision string (intended for releases)" STRING) @@ -242,6 +244,10 @@ else() message(STATUS "Crash handler: OFF") endif() +if(USE_LIBCPP) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -Wno-deprecated-declarations") +endif() + if(WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthreads") set(framework_DEFINITIONS ${framework_DEFINITIONS} -D_WIN32_WINNT=0x0501) @@ -249,7 +255,6 @@ if(WIN32) set(SYSTEM_LIBRARIES "") else() if(APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -Wno-deprecated-declarations") set(framework_DEFINITIONS ${framework_DEFINITIONS} -D_REENTRANT) # enable thread safe code set(SYSTEM_LIBRARIES "") else() diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index c5b0e731..159711a2 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -479,6 +479,7 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("setIconSize", &UIWidget::setIconSize); g_lua.bindClassMemberFunction("setIconRect", &UIWidget::setIconRect); g_lua.bindClassMemberFunction("setIconClip", &UIWidget::setIconClip); + g_lua.bindClassMemberFunction("setIconAlign", &UIWidget::setIconAlign); g_lua.bindClassMemberFunction("setBorderWidth", &UIWidget::setBorderWidth); g_lua.bindClassMemberFunction("setBorderWidthTop", &UIWidget::setBorderWidthTop); g_lua.bindClassMemberFunction("setBorderWidthRight", &UIWidget::setBorderWidthRight); @@ -530,6 +531,7 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("getIconSize", &UIWidget::getIconSize); g_lua.bindClassMemberFunction("getIconRect", &UIWidget::getIconRect); g_lua.bindClassMemberFunction("getIconClip", &UIWidget::getIconClip); + g_lua.bindClassMemberFunction("getIconAlign", &UIWidget::getIconAlign); g_lua.bindClassMemberFunction("getBorderTopColor", &UIWidget::getBorderTopColor); g_lua.bindClassMemberFunction("getBorderRightColor", &UIWidget::getBorderRightColor); g_lua.bindClassMemberFunction("getBorderBottomColor", &UIWidget::getBorderBottomColor); diff --git a/src/framework/ui/uiwidget.h b/src/framework/ui/uiwidget.h index 805677cb..1fa734b0 100644 --- a/src/framework/ui/uiwidget.h +++ b/src/framework/ui/uiwidget.h @@ -374,6 +374,7 @@ public: Size getIconSize() { return m_iconRect.size(); } Rect getIconRect() { return m_iconRect; } Rect getIconClip() { return m_iconClipRect; } + Fw::AlignmentFlag getIconAlign() { return m_iconAlign; } Color getBorderTopColor() { return m_borderColor.top; } Color getBorderRightColor() { return m_borderColor.right; } Color getBorderBottomColor() { return m_borderColor.bottom; } diff --git a/src/framework/ui/uiwidgetbasestyle.cpp b/src/framework/ui/uiwidgetbasestyle.cpp index 59d0537a..dc52e3eb 100644 --- a/src/framework/ui/uiwidgetbasestyle.cpp +++ b/src/framework/ui/uiwidgetbasestyle.cpp @@ -401,7 +401,10 @@ void UIWidget::drawIcon(const Rect& screenCoords) void UIWidget::setIcon(const std::string& iconFile) { - m_icon = g_textures.getTexture(iconFile); + if(iconFile.empty()) + m_icon = nullptr; + else + m_icon = g_textures.getTexture(iconFile); if(m_icon && !m_iconClipRect.isValid()) m_iconClipRect = Rect(0, 0, m_icon->getSize()); } \ No newline at end of file diff --git a/src/framework/ui/uiwidgetimage.cpp b/src/framework/ui/uiwidgetimage.cpp index 29a96302..f4ff8ce2 100644 --- a/src/framework/ui/uiwidgetimage.cpp +++ b/src/framework/ui/uiwidgetimage.cpp @@ -176,7 +176,10 @@ void UIWidget::drawImage(const Rect& screenCoords) void UIWidget::setImageSource(const std::string& source) { - m_imageTexture = g_textures.getTexture(source); + if(source.empty()) + m_imageTexture = nullptr; + else + m_imageTexture = g_textures.getTexture(source); m_imageMustRecache = true; } diff --git a/src/framework/util/color.cpp b/src/framework/util/color.cpp index 0f801af9..483291af 100644 --- a/src/framework/util/color.cpp +++ b/src/framework/util/color.cpp @@ -23,7 +23,7 @@ #include "color.h" // NOTE: AABBGGRR order -const Color Color::alpha = 0x00000000; +const Color Color::alpha = 0x00000000U; const Color Color::white = 0xffffffff; const Color Color::black = 0xff000000; const Color Color::red = 0xff0000ff; @@ -42,3 +42,9 @@ const Color Color::gray = 0xffa0a0a0; const Color Color::darkGray = 0xff808080; const Color Color::lightGray = 0xffc0c0c0; const Color Color::orange = 0xffff8c00; + +Color::Color(const std::string& coltext) +{ + std::stringstream ss(coltext); + ss >> *this; +} diff --git a/src/framework/util/color.h b/src/framework/util/color.h index 3ba38732..666876cc 100644 --- a/src/framework/util/color.h +++ b/src/framework/util/color.h @@ -37,6 +37,7 @@ public: Color(uint8 r, uint8 g, uint8 b, uint8 a = 0xFF) : m_r(r/255.0f), m_g(g/255.0f), m_b(b/255.0f), m_a(a/255.0f) { } Color(int r, int g, int b, int a = 0xFF) : m_r(r/255.0f), m_g(g/255.0f), m_b(b/255.0f), m_a(a/255.0f) { } Color(float r, float g, float b, float a = 1.0f) : m_r(r), m_g(g), m_b(b), m_a(a) { } + Color(const std::string& coltext); uint8 a() const { return m_a*255.0f; } uint8 b() const { return m_b*255.0f; } @@ -76,6 +77,14 @@ public: bool operator==(const Color& other) const { return other.rgba() == rgba(); } bool operator!=(const Color& other) const { return other.rgba() != rgba(); } + static uint8 to8bit(const Color& color) { + uint8 c = 0; + c += (color.r() / 51) * 36; + c += (color.g() / 51) * 6; + c += (color.b() / 51); + return c; + }; + static Color from8bit(int color) { if(color >= 216 || color <= 0) return Color(0, 0, 0);