mirror of
https://github.com/edubart/otclient.git
synced 2025-12-02 16:06:51 +01:00
basic charlist
This commit is contained in:
@@ -42,6 +42,7 @@ void LuaInterface::registerFunctions()
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getChildById", &UIWidget::getChildById);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getChildByIndex", &UIWidget::getChildByIndex);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getChildCount", &UIWidget::getChildCount);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getFocusedChild", &UIWidget::getFocusedChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("insertChild", &UIWidget::insertChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("removeChild", &UIWidget::removeChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("addChild", &UIWidget::addChild);
|
||||
|
||||
@@ -76,6 +76,13 @@ template<typename Ret, typename... Args>
|
||||
typename std::enable_if<!std::is_void<Ret>::value, bool>::type
|
||||
luavalue_cast(int index, std::function<Ret(Args...)>& func);
|
||||
|
||||
// vector
|
||||
template<typename T>
|
||||
void push_luavalue(const std::vector<T>& vec);
|
||||
|
||||
// tuple
|
||||
template<typename... Args>
|
||||
void push_luavalue(const std::tuple<Args...>& tuple);
|
||||
|
||||
// start definitions
|
||||
|
||||
@@ -181,4 +188,38 @@ luavalue_cast(int index, std::function<Ret(Args...)>& func) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
void push_luavalue(const std::vector<T>& vec) {
|
||||
g_lua.newTable();
|
||||
int i = 1;
|
||||
for(const T& v : vec) {
|
||||
push_luavalue(v);
|
||||
g_lua.rawSeti(i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
template<int N>
|
||||
struct push_tuple_luavalue {
|
||||
template<typename Tuple>
|
||||
static void call(const Tuple& tuple) {
|
||||
push_luavalue(std::get<N-1>(tuple));
|
||||
g_lua.rawSeti(N);
|
||||
push_tuple_luavalue<N-1>::call(tuple);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct push_tuple_luavalue<0> {
|
||||
template<typename Tuple>
|
||||
static void call(const Tuple& tuple) { }
|
||||
};
|
||||
|
||||
template<typename... Args>
|
||||
void push_luavalue(const std::tuple<Args...>& tuple) {
|
||||
g_lua.newTable();
|
||||
push_tuple_luavalue<sizeof...(Args)>::call(tuple);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,9 +20,7 @@ void UILabel::setText(const std::string& text)
|
||||
m_text = text;
|
||||
|
||||
// auto resize
|
||||
if(!m_fixedSize)
|
||||
resizeToText();
|
||||
else if(!m_rect.isValid()) {
|
||||
if(!m_fixedSize && !m_rect.isValid()) {
|
||||
Size textSize = m_font->calculateTextRectSize(m_text);
|
||||
if(m_rect.width() <= 0)
|
||||
m_rect.setWidth(textSize.width());
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <sstream>
|
||||
#include <exception>
|
||||
#include <cxxabi.h>
|
||||
#include "types.h"
|
||||
|
||||
namespace fw {
|
||||
|
||||
@@ -227,6 +228,12 @@ inline unsigned int hex2dec(const std::string& str) {
|
||||
return num;
|
||||
}
|
||||
|
||||
inline std::string ip2str(uint32 ip) {
|
||||
char host[16];
|
||||
sprintf(host, "%d.%d.%d.%d", (uint8)ip, (uint8)(ip >> 8), (uint8)(ip >> 16), (uint8)(ip >> 24));
|
||||
return std::string(host);
|
||||
}
|
||||
|
||||
// an empty string to use anywhere needed
|
||||
const static std::string empty_string;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user