Skip to content

Commit

Permalink
UIGraph improved with new features
Browse files Browse the repository at this point in the history
UIGraph widget got massive update including:

Multiple graphs in a single widget
Showing value of a closest point on a line when widget is hovered
Better performance due to A LOT of caching

author: Oen
  • Loading branch information
InnerCircleTFS committed Dec 7, 2024
1 parent 0700333 commit 6e1f04b
Show file tree
Hide file tree
Showing 6 changed files with 485 additions and 101 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ Beyond of it's flexibility with scripts, otclient comes with tons of other featu
- Module Shop
- Module Oufit
- Placeholder
- UIGraph
## <a name="themobileproject"><img height="32" src="https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/android/android.png" alt="Android"> The Mobile Project </a>
The Mobile Project
Expand Down
7 changes: 6 additions & 1 deletion mods/game_bot/default_configs/vBot_4.8/vBot/analyzer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ local toggle = function()
end

local drawGraph = function(graph, value)
graph:addValue(value)
if graph:getGraphsCount() == 0 then
graph:createGraph()
graph:setLineWidth(1, 1)
graph:setLineColor(1, "#FF0000")
end
graph:addValue(1, value)
end

local toggleAnalyzer = function(window)
Expand Down
2 changes: 0 additions & 2 deletions mods/game_bot/default_configs/vBot_4.8/vBot/analyzer.otui
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ AnalyzerLootItem < UIItem
AnalyzerGraph < UIGraph
height: 140
capacity: 400
line-width: 1
color: red
margin-top: 5
margin-left: 5
margin-right: 5
Expand Down
14 changes: 11 additions & 3 deletions src/client/luafunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1063,13 +1063,21 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<UIProgressRect>("getPercent", &UIProgressRect::getPercent);

g_lua.registerClass<UIGraph, UIWidget>();
g_lua.bindClassStaticFunction<UIGraph>("create", [] { return UIGraphPtr(new UIGraph); });
g_lua.bindClassMemberFunction<UIGraph>("addValue", &UIGraph::addValue);
g_lua.bindClassStaticFunction<UIGraph>("create", [] { return std::make_shared<UIGraph>(); });
g_lua.bindClassMemberFunction<UIGraph>("clear", &UIGraph::clear);
g_lua.bindClassMemberFunction<UIGraph>("setLineWidth", &UIGraph::setLineWidth);
g_lua.bindClassMemberFunction<UIGraph>("createGraph", &UIGraph::createGraph);
g_lua.bindClassMemberFunction<UIGraph>("getGraphsCount", &UIGraph::getGraphsCount);
g_lua.bindClassMemberFunction<UIGraph>("addValue", &UIGraph::addValue);
g_lua.bindClassMemberFunction<UIGraph>("setCapacity", &UIGraph::setCapacity);
g_lua.bindClassMemberFunction<UIGraph>("setTitle", &UIGraph::setTitle);
g_lua.bindClassMemberFunction<UIGraph>("setShowLabels", &UIGraph::setShowLabels);
g_lua.bindClassMemberFunction<UIGraph>("setShowInfo", &UIGraph::setShowInfo);
g_lua.bindClassMemberFunction<UIGraph>("setLineWidth", &UIGraph::setLineWidth);
g_lua.bindClassMemberFunction<UIGraph>("setLineColor", &UIGraph::setLineColor);
g_lua.bindClassMemberFunction<UIGraph>("setInfoText", &UIGraph::setInfoText);
g_lua.bindClassMemberFunction<UIGraph>("setInfoLineColor", &UIGraph::setInfoLineColor);
g_lua.bindClassMemberFunction<UIGraph>("setTextBackground", &UIGraph::setTextBackground);
g_lua.bindClassMemberFunction<UIGraph>("setGraphVisible", &UIGraph::setGraphVisible);

g_lua.registerClass<UIMapAnchorLayout, UIAnchorLayout>();
}
Loading

0 comments on commit 6e1f04b

Please sign in to comment.