mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Fix f78d3ddf71 - actually speed up MP/lobby chat.
f78d3ddf71 / D1781 would fix an important source of lag... If it
actually used the code.
Also clean up some comments.
Reported by: Vladislav
Differential Revision: https://code.wildfiregames.com/D3176
This was SVN commit r24312.
This commit is contained in:
parent
d38fde3682
commit
783e77cc8d
7 changed files with 56 additions and 55 deletions
|
|
@ -43,6 +43,7 @@ CList::CList(CGUI& pGUI)
|
|||
m_Font(),
|
||||
m_ScrollBar(),
|
||||
m_ScrollBarStyle(),
|
||||
m_ScrollBottom(false),
|
||||
m_SoundDisabled(),
|
||||
m_SoundSelected(),
|
||||
m_Sprite(),
|
||||
|
|
@ -102,8 +103,6 @@ void CList::SetupText(bool append)
|
|||
{
|
||||
m_Modified = true;
|
||||
|
||||
m_ItemsYPositions.resize(m_List.m_Items.size() + 1);
|
||||
|
||||
if (!append)
|
||||
// Delete all generated texts.
|
||||
// TODO: try to be cleverer if we want to update items before the end.
|
||||
|
|
@ -125,7 +124,9 @@ void CList::SetupText(bool append)
|
|||
float buffered_y = 0.f;
|
||||
|
||||
if (append)
|
||||
buffered_y = m_ItemsYPositions[m_List.m_Items.size() - 1];
|
||||
buffered_y = m_ItemsYPositions.back();
|
||||
|
||||
m_ItemsYPositions.resize(m_List.m_Items.size() + 1);
|
||||
|
||||
for (size_t i = append ? m_List.m_Items.size() - 1 : 0; i < m_List.m_Items.size(); ++i)
|
||||
{
|
||||
|
|
@ -406,8 +407,7 @@ void CList::AddItem(const CGUIString& str, const CGUIString& data)
|
|||
m_List.m_Items.push_back(str);
|
||||
m_ListData.m_Items.push_back(data);
|
||||
|
||||
// TODO Temp
|
||||
SetupText();
|
||||
SetupText(true);
|
||||
}
|
||||
|
||||
bool CList::HandleAdditionalChildren(const XMBElement& child, CXeromyces* pFile)
|
||||
|
|
@ -515,18 +515,3 @@ void CList::CreateJSObject()
|
|||
js::SetProxyReservedSlot(m_JSObject, 0, data);
|
||||
}
|
||||
|
||||
bool CList::Script_AddItem(JSContext* cx, uint argc, JS::Value* vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
CList* e = static_cast<CList*>(js::GetProxyPrivate(args.thisv().toObjectOrNull()).toPrivate());
|
||||
if (!e)
|
||||
return false;
|
||||
|
||||
ScriptInterface& scriptInterface = *ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface;
|
||||
ScriptRequest rq(scriptInterface);
|
||||
CGUIString text;
|
||||
if (!ScriptInterface::FromJSVal(rq, args.get(0), text))
|
||||
return false;
|
||||
e->AddItem(text, text);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,9 +60,6 @@ public:
|
|||
virtual void AddItem(const CGUIString& str, const CGUIString& data);
|
||||
|
||||
protected:
|
||||
|
||||
static bool Script_AddItem(JSContext* cx, uint argc, JS::Value* vp);
|
||||
|
||||
/**
|
||||
* Sets up text, should be called every time changes has been
|
||||
* made that can change the visual.
|
||||
|
|
|
|||
|
|
@ -32,19 +32,36 @@
|
|||
// Include the definition of the generic templates.
|
||||
#include "JSInterface_GUIProxy_impl.h"
|
||||
|
||||
namespace {
|
||||
struct SData
|
||||
{
|
||||
JS::PersistentRootedObject m_ToString;
|
||||
JS::PersistentRootedObject m_Focus;
|
||||
JS::PersistentRootedObject m_Blur;
|
||||
JS::PersistentRootedObject m_GetComputedSize;
|
||||
JS::PersistentRootedObject m_AddItem;
|
||||
};
|
||||
namespace
|
||||
{
|
||||
struct SData
|
||||
{
|
||||
JS::PersistentRootedObject m_ToString;
|
||||
JS::PersistentRootedObject m_Focus;
|
||||
JS::PersistentRootedObject m_Blur;
|
||||
JS::PersistentRootedObject m_GetComputedSize;
|
||||
JS::PersistentRootedObject m_AddItem;
|
||||
};
|
||||
|
||||
bool CList_AddItem(JSContext* cx, uint argc, JS::Value* vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
CList* e = static_cast<CList*>(js::GetProxyPrivate(args.thisv().toObjectOrNull()).toPrivate());
|
||||
if (!e)
|
||||
return false;
|
||||
|
||||
ScriptInterface& scriptInterface = *ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface;
|
||||
ScriptRequest rq(scriptInterface);
|
||||
CGUIString text;
|
||||
if (!ScriptInterface::FromJSVal(rq, args.get(0), text))
|
||||
return false;
|
||||
e->AddItem(text, text);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
bool JSI_GUIProxy<CList>::funcGetter(JS::HandleObject proxy, const std::string& propName, JS::MutableHandleValue vp) const
|
||||
bool JSI_GUIProxy<CList>::FuncGetter(JS::HandleObject proxy, const std::string& propName, JS::MutableHandleValue vp) const
|
||||
{
|
||||
const SData& data = *static_cast<const SData*>(js::GetProxyReservedSlot(proxy, 0).toPrivate());
|
||||
if (propName == "toString")
|
||||
|
|
@ -72,7 +89,7 @@ std::pair<const js::BaseProxyHandler*, void*> JSI_GUIProxy<CList>::CreateData(Sc
|
|||
data->m_Blur.init(rq.cx, JS_GetFunctionObject(JS_NewFunction(rq.cx, func(IGUIObject, blur), 0, 0, "blur")));
|
||||
data->m_GetComputedSize.init(rq.cx, JS_GetFunctionObject(JS_NewFunction(rq.cx, func(IGUIObject, getComputedSize), 0, 0, "getComputedSize")));
|
||||
#undef func
|
||||
data->m_AddItem.init(rq.cx, JS_GetFunctionObject(JS_NewFunction(rq.cx, CList::Script_AddItem, 0, 0, "addItem")));
|
||||
data->m_AddItem.init(rq.cx, JS_GetFunctionObject(JS_NewFunction(rq.cx, CList_AddItem, 1, 0, "addItem")));
|
||||
|
||||
return { &Singleton(), data };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,19 +32,20 @@
|
|||
// Include the definition of the generic templates.
|
||||
#include "JSInterface_GUIProxy_impl.h"
|
||||
|
||||
namespace {
|
||||
struct SData
|
||||
{
|
||||
JS::PersistentRootedObject m_ToString;
|
||||
JS::PersistentRootedObject m_Focus;
|
||||
JS::PersistentRootedObject m_Blur;
|
||||
JS::PersistentRootedObject m_GetComputedSize;
|
||||
JS::PersistentRootedObject m_GetTextSize;
|
||||
};
|
||||
namespace
|
||||
{
|
||||
struct SData
|
||||
{
|
||||
JS::PersistentRootedObject m_ToString;
|
||||
JS::PersistentRootedObject m_Focus;
|
||||
JS::PersistentRootedObject m_Blur;
|
||||
JS::PersistentRootedObject m_GetComputedSize;
|
||||
JS::PersistentRootedObject m_GetTextSize;
|
||||
};
|
||||
}
|
||||
|
||||
template <>
|
||||
bool JSI_GUIProxy<CText>::funcGetter(JS::HandleObject proxy, const std::string& propName, JS::MutableHandleValue vp) const
|
||||
bool JSI_GUIProxy<CText>::FuncGetter(JS::HandleObject proxy, const std::string& propName, JS::MutableHandleValue vp) const
|
||||
{
|
||||
const SData& data = *static_cast<const SData*>(js::GetProxyReservedSlot(proxy, 0).toPrivate());
|
||||
if (propName == "toString")
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ protected:
|
|||
|
||||
// This handles returning function properties.
|
||||
// Specialize this.
|
||||
bool funcGetter(JS::HandleObject proxy, const std::string& propName, JS::MutableHandleValue vp) const;
|
||||
bool FuncGetter(JS::HandleObject proxy, const std::string& propName, JS::MutableHandleValue vp) const;
|
||||
protected:
|
||||
// BaseProxyHandler interface below
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ bool JSI_GUIProxy<T>::get(JSContext* cx, JS::HandleObject proxy, JS::HandleValue
|
|||
return false;
|
||||
|
||||
// Return function properties. Specializable.
|
||||
if (funcGetter(proxy, propName, vp))
|
||||
if (FuncGetter(proxy, propName, vp))
|
||||
return true;
|
||||
|
||||
// Use onWhatever to access event handlers
|
||||
|
|
|
|||
|
|
@ -32,18 +32,19 @@
|
|||
// Include the definition of the generic templates.
|
||||
#include "JSInterface_GUIProxy_impl.h"
|
||||
|
||||
namespace {
|
||||
struct SData
|
||||
{
|
||||
JS::PersistentRootedObject m_ToString;
|
||||
JS::PersistentRootedObject m_Focus;
|
||||
JS::PersistentRootedObject m_Blur;
|
||||
JS::PersistentRootedObject m_GetComputedSize;
|
||||
};
|
||||
namespace
|
||||
{
|
||||
struct SData
|
||||
{
|
||||
JS::PersistentRootedObject m_ToString;
|
||||
JS::PersistentRootedObject m_Focus;
|
||||
JS::PersistentRootedObject m_Blur;
|
||||
JS::PersistentRootedObject m_GetComputedSize;
|
||||
};
|
||||
}
|
||||
|
||||
template <>
|
||||
bool JSI_GUIProxy<IGUIObject>::funcGetter(JS::HandleObject proxy, const std::string& propName, JS::MutableHandleValue vp) const
|
||||
bool JSI_GUIProxy<IGUIObject>::FuncGetter(JS::HandleObject proxy, const std::string& propName, JS::MutableHandleValue vp) const
|
||||
{
|
||||
const SData& data = *static_cast<const SData*>(js::GetProxyReservedSlot(proxy, 0).toPrivate());
|
||||
if (propName == "toString")
|
||||
|
|
|
|||
Loading…
Reference in a new issue