Changeset View
Changeset View
Standalone View
Standalone View
source/gui/ObjectBases/IGUIObject.cpp
Show All 15 Lines | |||||
*/ | */ | ||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "IGUIObject.h" | #include "IGUIObject.h" | ||||
#include "gui/CGUI.h" | #include "gui/CGUI.h" | ||||
#include "gui/CGUISetting.h" | #include "gui/CGUISetting.h" | ||||
#include "gui/Scripting/JSInterface_GUIProxy.h" | |||||
#include "js/Conversions.h" | #include "js/Conversions.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/GameSetup/Config.h" | #include "ps/GameSetup/Config.h" | ||||
#include "ps/Profile.h" | #include "ps/Profile.h" | ||||
#include "scriptinterface/ScriptContext.h" | #include "scriptinterface/ScriptContext.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
#include "soundmanager/ISoundManager.h" | #include "soundmanager/ISoundManager.h" | ||||
▲ Show 20 Lines • Show All 415 Lines • ▼ Show 20 Lines | bool IGUIObject::ScriptEventWithReturn(const CStr& eventName, const JS::HandleValueArray& paramData) | ||||
} | } | ||||
return JS::ToBoolean(result); | return JS::ToBoolean(result); | ||||
} | } | ||||
void IGUIObject::CreateJSObject() | void IGUIObject::CreateJSObject() | ||||
{ | { | ||||
ScriptRequest rq(m_pGUI.GetScriptInterface()); | ScriptRequest rq(m_pGUI.GetScriptInterface()); | ||||
m_JSObject.init(rq.cx, m_pGUI.GetScriptInterface()->CreateCustomObject("GUIObject")); | js::ProxyOptions options; | ||||
JS_SetPrivate(m_JSObject.get(), this); | options.setClass(&JSI_GUIProxy<IGUIObject>::ClassDefinition()); | ||||
RegisterScriptFunctions(); | JS::RootedValue cppObj(rq.cx); | ||||
m_JSObject.init(rq.cx, js::NewProxyObject(rq.cx, &JSI_GUIProxy<IGUIObject>::Singleton(), cppObj, nullptr, options)); | |||||
JS_SetPrivate(m_JSObject.get(), this); | |||||
} | } | ||||
JSObject* IGUIObject::GetJSObject() | JSObject* IGUIObject::GetJSObject() | ||||
{ | { | ||||
// Cache the object when somebody first asks for it, because otherwise | // Cache the object when somebody first asks for it, because otherwise | ||||
// we end up doing far too much object allocation. | // we end up doing far too much object allocation. | ||||
if (!m_JSObject.initialized()) | if (!m_JSObject.initialized()) | ||||
CreateJSObject(); | CreateJSObject(); | ||||
return m_JSObject.get(); | return m_JSObject.get(); | ||||
} | } | ||||
bool IGUIObject::toString(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) | |||||
{ | |||||
ScriptRequest rq(scriptInterface); | |||||
ScriptInterface::ToJSVal(rq, ret, "[GUIObject: " + GetName() + "]"); | |||||
return true; | |||||
Stan: How can one know? Does it warrant for a test? | |||||
Done Inline ActionsNeeds to dig deeper into C++ and what happens with pointers. It's either necessary or it's useless. wraitii: Needs to dig deeper into C++ and what happens with pointers. It's either necessary or it's… | |||||
} | |||||
Not Done Inline ActionsWhat is this? Itms: What is this? | |||||
Done Inline ActionsThis is a function to set the private value for a proxy. Upstream, it becomes SetProxyPrivate. The private slot fo the proxy must hold a pointer to the C++ GUI object (it already did, it still does). wraitii: This is a function to set the private value for a proxy. Upstream, it becomes SetProxyPrivate. | |||||
bool IGUIObject::focus(ScriptInterface& UNUSED(scriptInterface), JS::MutableHandleValue ret) | |||||
{ | |||||
GetGUI().SetFocusedObject(this); | |||||
ret.setUndefined(); | |||||
return true; | |||||
StanUnsubmitted Not Done Inline ActionsCan we return something more meaningfull? Stan: Can we return something more meaningfull? | |||||
wraitiiAuthorUnsubmitted Done Inline ActionsMh, should probably return void at the moment, you're right. wraitii: Mh, should probably return void at the moment, you're right. | |||||
} | |||||
bool IGUIObject::blur(ScriptInterface& UNUSED(scriptInterface), JS::MutableHandleValue ret) | |||||
{ | |||||
GetGUI().SetFocusedObject(nullptr); | |||||
ret.setUndefined(); | |||||
return true; | |||||
} | |||||
bool IGUIObject::getComputedSize(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) | |||||
{ | |||||
UpdateCachedSize(); | |||||
ScriptRequest rq(scriptInterface); | |||||
ScriptInterface::ToJSVal(rq, ret, m_CachedActualSize); | |||||
return true; | |||||
} | |||||
bool IGUIObject::IsEnabled() const | bool IGUIObject::IsEnabled() const | ||||
{ | { | ||||
return m_Enabled; | return m_Enabled; | ||||
} | } | ||||
bool IGUIObject::IsHidden() const | bool IGUIObject::IsHidden() const | ||||
{ | { | ||||
return m_Hidden; | return m_Hidden; | ||||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
How can one know? Does it warrant for a test?