diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 00000000..b4a36fbf --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1,3 @@ +*.yardoc +doc +!.gitignore diff --git a/doc/StylesOverview.md b/doc/StylesOverview.md new file mode 100644 index 00000000..e9eea3c5 --- /dev/null +++ b/doc/StylesOverview.md @@ -0,0 +1,222 @@ +# @title Style Tags Overview + +## Style Overview +This document describes how style tags can be specified, how they affect your +widgets, and how to use specific built-in style tags in otclient, as well +as how to define new custom style tags. + +## Style Value Types + +{valhead:Integer} +Integer number, used by most of style proprieties + +**Examples:** + +* 1 +* 9 +* 5 + +{valhead:Float} +Float number + +**Examples:** + +* 1.0 +* 9 +* 1.5 + +{valhead:String} +String containing a text + + +**Examples:** + +* this is a string +* it doesn't need quotes or escaping + +{valhead:Boolean} +Value with two states, **true** or **false** + +**Examples:** + +* true +* false + +{valhead:Size} +Size type, defined by 2 integers, width followed by height + + size: width height + + +**Examples:** + +* 10 20 +* 30 10 + +{valhead:Rect} + +Rect type, defined by 4 integers + + rect: x y width height + +**Examples:** + +* 0 0 32 32 +* 10 20 30 40 + +{valhead:Color} + +{valhead:Image} + +{valhead:Font} + + +## UIWidget + +{taghead:rect Rect} +Defines widget's rect + +**Examples:** + + !!!plain + rect: 32 32 32 32 + +**See also:** {tag:pos}, {tag:size} + +{taghead:size Size} +Defines size of a widget in pixels + +**Examples:** + + !!!plain + size: 32 32 + +{taghead:width Integer} +Defines width of a widget + +{taghead:height Integer} +Defines height of a widget + +{taghead:pos Point} +Defines absolute position of the widget relative to the window top left, this is generialy not used, +if you want to position relative to parent widget, use anchors and margins + + +**Examples:** + + !!!plain + pos: 32 32 + +{taghead:x Integer} +Defines x absolute position + +**See also:** {tag:pos} + +{taghead:y Integer} +Defines y absolute position + +**See also:** {tag:pos} + + +{taghead:color Color} +Foreground color, mostly used for coloring texts + +**Examples:** + + !!!plain + color: red + color: #ff0000 + color: #ff000080 + +{taghead:background Color} +Same as {tag:background-color} + +{taghead:background-color Color} +Defines background color + + +{taghead:background-rect Rect} +{taghead:background-offset Point} +{taghead:background-offset-x Integer} +{taghead:background-offset-y Integer} +{taghead:background-size Size} +{taghead:background-width Integer} +{taghead:background-height Integer} + + +{taghead:icon Image} +{taghead:icon-source Image} +{taghead:icon-color Color} +{taghead:icon-offset-x Integer} +{taghead:icon-offset-y Integer} +{taghead:icon-offset Point} +{taghead:icon-width Integer} +{taghead:icon-height Integer} +{taghead:icon-size Size} +{taghead:icon-rect Rect} +{taghead:opacity Float} +{taghead:enabled Boolean} +{taghead:visible Boolean} +{taghead:checked Boolean} +{taghead:dragable Boolean} +{taghead:on Boolean} +{taghead:focusable Boolean} +{taghead:phantom Boolean} +{taghead:fixed-size Boolean} +{taghead:clipping Boolean} +{taghead:border Integer} +{taghead:border-width Integer} +{taghead:border-width-top Integer} +{taghead:border-width-right Integer} +{taghead:border-width-bottom Integer} +{taghead:border-width-left Integer} +{taghead:border-color Color} +{taghead:border-color-top Color} +{taghead:border-color-right Color} +{taghead:border-color-bottom Color} +{taghead:border-color-left Color} +{taghead:margin-top Integer} +{taghead:margin-right Integer} +{taghead:margin-bottom Integer} +{taghead:margin-left Integer} +{taghead:margin Integer} +{taghead:padding-top Integer} +{taghead:padding-right Integer} +{taghead:padding-bottom Integer} +{taghead:padding-left Integer} +{taghead:padding Integer} +{taghead:layout Layout} + +{taghead:image-source} +{taghead:image-offset-x Integer} +{taghead:image-offset-y Integer} +{taghead:image-offset Point} +{taghead:image-width Integer} +{taghead:image-height Integer} +{taghead:image-size Size} +{taghead:image-rect Rect} +{taghead:image-clip Rect} +{taghead:image-fixed-ratio Boolean} +{taghead:image-repeated Boolean} +{taghead:image-smooth Boolean} +{taghead:image-color Color} +{taghead:image-border-top Integer} +{taghead:image-border-right Integer} +{taghead:image-border-bottom Integer} +{taghead:image-border-left Integer} +{taghead:image-border Integer} + +{taghead:text} +{taghead:text-align Align} +{taghead:text-offset Point} +{taghead:text-wrap Boolean} +{taghead:text-auto-resize Boolean} +{taghead:font Font} + +# UITextEdit +{taghead:text-margin} +{taghead:always-active} +{taghead:shift-navigation} +{taghead:multiline} +{taghead:max-length} + diff --git a/doc/luafunctions.rb b/doc/luafunctions.rb index 35d93683..444133a5 100644 --- a/doc/luafunctions.rb +++ b/doc/luafunctions.rb @@ -1,4 +1,18 @@ class UIWidget + # Declares the API that the object belongs to. Does not display in + # output, but useful for performing queries (+yardoc --query+). Any text is + # allowable in this tag, and there are no predefined values. + # + # @!macro yard.tag.transitive + # @note The special name +@api private+ does display a notice in + # documentation if it is listed, letting users know that the + # method is not to be used by external components. + # @example + # class Post + # # @api private + # def reset_table!; table.flush end + # end + define_tag "API Visibility", :api end class g_game diff --git a/doc/plugin.rb b/doc/plugin.rb new file mode 100644 index 00000000..14bdca1d --- /dev/null +++ b/doc/plugin.rb @@ -0,0 +1,27 @@ +include YARD +include Templates + +module MyTemplateHelper + def linkify(*args) + if args.first.is_a?(String) + case args.first + when /^taghead:(\S+)/ + tag_name = $1 + params = args[1] + return "

#{tag_name}: #{params}

" + when /^valhead:(\S+)/ + tag_name = $1 + return "

#{tag_name}

" + when /^tag:(\S+)/ + tag_name = $1 + return "#{tag_name}" + else + super + end + end + super + end +end + +Template.extra_includes << MyTemplateHelper +Engine.register_template_path(File.dirname(__FILE__)) diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index c3f0de8d..73faee60 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -492,7 +492,7 @@ function Console.sendCurrentMessage() g_game.talkPrivate(speaktype.speakType, name, message) message = applyMessagePrefixies(player:getName(), player:getLevel(), message) - Console.addPrivateText(message, speaktype, name, isPrivateCommand, g_game:getLocalPlayer():getName()) + Console.addPrivateText(message, speaktype, name, isPrivateCommand, g_game.getLocalPlayer():getName()) end end diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index 2af0e3e1..035fd2f2 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -373,7 +373,6 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("setCursorPos", &UITextEdit::setCursorPos); g_lua.bindClassMemberFunction("setCursorEnabled", &UITextEdit::setCursorEnabled); g_lua.bindClassMemberFunction("setTextHidden", &UITextEdit::setTextHidden); - g_lua.bindClassMemberFunction("setAlwaysActive", &UITextEdit::setAlwaysActive); g_lua.bindClassMemberFunction("setValidCharacters", &UITextEdit::setValidCharacters); g_lua.bindClassMemberFunction("setShiftNavigation", &UITextEdit::setShiftNavigation); g_lua.bindClassMemberFunction("setMultiline", &UITextEdit::setMultiline); @@ -387,7 +386,6 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("getCursorPos", &UITextEdit::getCursorPos); g_lua.bindClassMemberFunction("getMaxLength", &UITextEdit::getMaxLength); g_lua.bindClassMemberFunction("isCursorEnabled", &UITextEdit::isCursorEnabled); - g_lua.bindClassMemberFunction("isAlwaysActive", &UITextEdit::isAlwaysActive); g_lua.bindClassMemberFunction("isTextHidden", &UITextEdit::isTextHidden); g_lua.bindClassMemberFunction("isShiftNavigation", &UITextEdit::isShiftNavigation); g_lua.bindClassMemberFunction("isMultiline", &UITextEdit::isMultiline); diff --git a/src/framework/ui/uitextedit.cpp b/src/framework/ui/uitextedit.cpp index 8a200d14..adf2e5bb 100644 --- a/src/framework/ui/uitextedit.cpp +++ b/src/framework/ui/uitextedit.cpp @@ -34,7 +34,6 @@ UITextEdit::UITextEdit() m_startRenderPos = 0; m_textHorizontalMargin = 0; m_textHidden = false; - m_alwaysActive = false; m_shiftNavigation = false; m_multiline = false; m_maxLength = 0; @@ -58,7 +57,7 @@ void UITextEdit::drawSelf() g_painter->drawTexturedRect(m_glyphsCoords[i], texture, m_glyphsTexCoords[i]); // render cursor - if(isExplicitlyEnabled() && (isActive() || m_alwaysActive) && m_cursorPos >= 0) { + if(isExplicitlyEnabled() && isActive() && m_cursorPos >= 0) { assert(m_cursorPos <= textLength); // draw every 333ms const int delay = 333; @@ -268,11 +267,6 @@ void UITextEdit::setTextHidden(bool hidden) update(); } -void UITextEdit::setAlwaysActive(bool enable) -{ - m_alwaysActive = enable; -} - void UITextEdit::appendText(std::string text) { if(m_cursorPos >= 0) { @@ -417,8 +411,6 @@ void UITextEdit::onStyleApply(const std::string& styleName, const OTMLNodePtr& s setTextHidden(node->value()); else if(node->tag() == "text-margin") setTextHorizontalMargin(node->value()); - else if(node->tag() == "always-active") - setAlwaysActive(node->value()); else if(node->tag() == "shift-navigation") setShiftNavigation(node->value()); else if(node->tag() == "multiline") @@ -436,7 +428,7 @@ void UITextEdit::onGeometryChange(const Rect& oldRect, const Rect& newRect) void UITextEdit::onFocusChange(bool focused, Fw::FocusReason reason) { - if(focused && !m_alwaysActive) { + if(focused) { if(reason == Fw::KeyboardFocusReason) setCursorPos(m_text.length()); else diff --git a/src/framework/ui/uitextedit.h b/src/framework/ui/uitextedit.h index e6ca15fb..2c7437fb 100644 --- a/src/framework/ui/uitextedit.h +++ b/src/framework/ui/uitextedit.h @@ -40,7 +40,6 @@ public: void setCursorPos(int pos); void setCursorEnabled(bool enable); void setTextHidden(bool hidden); - void setAlwaysActive(bool enable); void setValidCharacters(const std::string validCharacters) { m_validCharacters = validCharacters; } void setShiftNavigation(bool enable) { m_shiftNavigation = enable; } void setMultiline(bool enable) { m_multiline = enable; } @@ -57,7 +56,6 @@ public: int getCursorPos() { return m_cursorPos; } uint getMaxLength() { return m_maxLength; } bool isCursorEnabled() { return m_cursorPos != -1; } - bool isAlwaysActive() { return m_alwaysActive; } bool isTextHidden() { return m_textHidden; } bool isShiftNavigation() { return m_shiftNavigation; } bool isMultiline() { return m_multiline; } @@ -82,7 +80,6 @@ private: ticks_t m_cursorTicks; int m_textHorizontalMargin; bool m_textHidden; - bool m_alwaysActive; bool m_shiftNavigation; bool m_multiline; std::string m_validCharacters;