Index: ps/trunk/source/gui/IGUIObject.h
===================================================================
--- ps/trunk/source/gui/IGUIObject.h (revision 22595)
+++ ps/trunk/source/gui/IGUIObject.h (revision 22596)
@@ -1,549 +1,553 @@
/* Copyright (C) 2019 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
/*
* The base class of an object.
* All objects are derived from this class.
* It's an abstract data type, so it can't be used per se.
* Also contains a Dummy object which is used for completely blank objects.
*/
#ifndef INCLUDED_IGUIOBJECT
#define INCLUDED_IGUIOBJECT
#include "GUIbase.h"
#include "GUItext.h"
#include "gui/scripting/JSInterface_IGUIObject.h"
#include "lib/input.h" // just for IN_PASS
#include "ps/XML/Xeromyces.h"
#include
#include
#include
struct SGUISetting;
struct SGUIStyle;
class CGUI;
class JSObject;
ERROR_TYPE(GUI, UnableToParse);
/**
* Setting Type
* @see SGUISetting
*
* For use of later macros, all names should be GUIST_ followed
* by the code name (case sensitive!).
*/
#define TYPE(T) GUIST_##T,
enum EGUISettingType
{
#include "GUItypes.h"
};
#undef TYPE
/**
* A GUI Setting is anything that can be inputted from XML as
* \-attributes (with exceptions). For instance:
* \
*
* "style" will be a SGUISetting.
*/
struct SGUISetting
{
SGUISetting() : m_pSetting(NULL) {}
/**
* Stores the instance of the setting type holding the setting data. Can be set from XML and JS.
*/
void *m_pSetting;
EGUISettingType m_Type;
template
void Init(IGUIObject& pObject, const CStr& Name);
/**
* Parses the given JS::Value using ScriptInterface::FromJSVal and assigns it to the setting data.
*/
std::function m_FromJSVal;
/**
* Converts the setting data to a JS::Value using ScriptInterface::ToJSVal.
*/
std::function m_ToJSVal;
};
/**
* GUI object such as a button or an input-box.
* Abstract data type !
*/
class IGUIObject
{
friend class CGUI;
friend class IGUIScrollBar;
friend class GUITooltip;
// Allow getProperty to access things like GetParent()
friend bool JSI_IGUIObject::getProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp);
friend bool JSI_IGUIObject::setProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool UNUSED(strict), JS::MutableHandleValue vp);
friend bool JSI_IGUIObject::getComputedSize(JSContext* cx, uint argc, JS::Value* vp);
- friend bool JSI_IGUIObject::getTextSize(JSContext* cx, uint argc, JS::Value* vp);
public:
IGUIObject(CGUI* pGUI);
virtual ~IGUIObject();
/**
* Checks if mouse is hovering this object.
* The mouse position is cached in CGUI.
*
* This function checks if the mouse is hovering the
* rectangle that the base setting "size" makes.
* Although it is virtual, so one could derive
* an object from CButton, which changes only this
* to checking the circle that "size" makes.
*
* @return true if mouse is hovering
*/
virtual bool MouseOver();
/**
* Test if mouse position is over an icon
*/
virtual bool MouseOverIcon();
//--------------------------------------------------------
/** @name Leaf Functions */
//--------------------------------------------------------
//@{
/// Get object name, name is unique
const CStr& GetName() const { return m_Name; }
/// Get object name
void SetName(const CStr& Name) { m_Name = Name; }
// Get Presentable name.
// Will change all internally set names to something like ""
CStr GetPresentableName() const;
/**
* Adds object and its children to the map, it's name being the
* first part, and the second being itself.
*
* @param ObjectMap Adds this to the map_pObjects.
*
* @throws PSERROR_GUI_ObjectNeedsName Name is missing
* @throws PSERROR_GUI_NameAmbiguity Name is already taken
*/
void AddToPointersMap(map_pObjects& ObjectMap);
/**
* Notice nothing will be returned or thrown if the child hasn't
* been inputted into the GUI yet. This is because that's were
* all is checked. Now we're just linking two objects, but
* it's when we're inputting them into the GUI we'll check
* validity! Notice also when adding it to the GUI this function
* will inevitably have been called by CGUI::AddObject which
* will catch the throw and return the error code.
* i.e. The user will never put in the situation wherein a throw
* must be caught, the GUI's internal error handling will be
* completely transparent to the interfacially sequential model.
*
* @param pChild Child to add
*
* @throws PSERROR_GUI from CGUI::UpdateObjects().
*/
void AddChild(IGUIObject* pChild);
//@}
//--------------------------------------------------------
/** @name Iterate
* Used to iterate over all children of this object.
*/
//--------------------------------------------------------
//@{
vector_pObjects::iterator begin() { return m_Children.begin(); }
vector_pObjects::iterator end() { return m_Children.end(); }
//@}
//--------------------------------------------------------
/** @name Settings Management */
//--------------------------------------------------------
//@{
/**
* Checks if settings exists, only available for derived
* classes that has this set up, that's why the base
* class just returns false
*
* @param Setting setting name
* @return True if settings exist.
*/
bool SettingExists(const CStr& Setting) const;
/**
* All sizes are relative to resolution, and the calculation
* is not wanted in real time, therefore it is cached, update
* the cached size with this function.
*/
virtual void UpdateCachedSize();
/**
* Reset internal state of this object.
*/
virtual void ResetStates();
/**
* Set a setting by string, regardless of what type it is.
*
* example a CRect(10,10,20,20) would be "10 10 20 20"
*
* @param Setting Setting by name
* @param Value Value to set to
* @param SkipMessage Does not send a GUIM_SETTINGS_UPDATED if true
*
* @return PSRETURN (PSRETURN_OK if successful)
*/
PSRETURN SetSetting(const CStr& Setting, const CStrW& Value, const bool& SkipMessage = false);
/**
* Retrieves the type of a named setting.
*
* @param Setting Setting by name
* @param Type Stores an EGUISettingType
* @return PSRETURN (PSRETURN_OK if successful)
*/
PSRETURN GetSettingType(const CStr& Setting, EGUISettingType& Type) const;
/**
* Set the script handler for a particular object-specific action
*
* @param Action Name of action
* @param Code Javascript code to execute when the action occurs
* @param pGUI GUI instance to associate the script with
*/
void RegisterScriptHandler(const CStr& Action, const CStr& Code, CGUI* pGUI);
/**
* Creates the JS Object representing this page upon first use.
* Can be overridden by derived classes to extend it.
*/
virtual void CreateJSObject();
/**
* Retrieves the JSObject representing this GUI object.
*/
JSObject* GetJSObject();
//@}
protected:
//--------------------------------------------------------
/** @name Called by CGUI and friends
*
* Methods that the CGUI will call using
* its friendship, these should not
* be called by user.
* These functions' security are a lot
* what constitutes the GUI's
*/
//--------------------------------------------------------
//@{
/**
* Add a setting to m_Settings
*
* @param Type Setting type
* @param Name Setting reference name
*/
void AddSetting(const EGUISettingType& Type, const CStr& Name);
/**
* Calls Destroy on all children, and deallocates all memory.
* MEGA TODO Should it destroy it's children?
*/
virtual void Destroy();
public:
/**
* This function is called with different messages
* for instance when the mouse enters the object.
*
* @param Message GUI Message
*/
virtual void HandleMessage(SGUIMessage& UNUSED(Message)) {}
protected:
/**
* Draws the object.
*
* @throws PSERROR if any. But this will mostlikely be
* very rare since if an object is drawn unsuccessfully
* it'll probably only output in the Error log, and not
* disrupt the whole GUI drawing.
*/
virtual void Draw() = 0;
/**
* Some objects need to handle the SDL_Event_ manually.
* For instance the input box.
*
* Only the object with focus will have this function called.
*
* Returns either IN_PASS or IN_HANDLED. If IN_HANDLED, then
* the key won't be passed on and processed by other handlers.
* This is used for keys that the GUI uses.
*/
virtual InReaction ManuallyHandleEvent(const SDL_Event_* UNUSED(ev)) { return IN_PASS; }
/**
* Loads a style.
*
* @param GUIinstance Reference to the GUI
* @param StyleName Style by name
*/
void LoadStyle(CGUI& GUIinstance, const CStr& StyleName);
/**
* Loads a style.
*
* @param Style The style object.
*/
void LoadStyle(const SGUIStyle& Style);
/**
* Returns not the Z value, but the actual buffered Z value, i.e. if it's
* defined relative, then it will check its parent's Z value and add
* the relativity.
*
* @return Actual Z value on the screen.
*/
virtual float GetBufferedZ() const;
/**
* Set parent of this object
*/
void SetParent(IGUIObject* pParent) { m_pParent = pParent; }
public:
CGUI* GetGUI() { return m_pGUI; }
const CGUI* GetGUI() const { return m_pGUI; }
/**
* Take focus!
*/
void SetFocus();
+ /**
+ * Workaround to avoid a dynamic_cast which can be 80 times slower than this.
+ */
+ virtual void* GetTextOwner() { return nullptr; }
+
protected:
/**
* Check if object is focused.
*/
bool IsFocused() const;
/**
* NOTE! This will not just return m_pParent, when that is
* need use it! There is one exception to it, when the parent is
* the top-node (the object that isn't a real object), this
* will return NULL, so that the top-node's children are
* seemingly parentless.
*
* @return Pointer to parent
*/
IGUIObject* GetParent() const;
/**
* Get Mouse from CGUI.
*/
CPos GetMousePos() const;
/**
* Handle additional children to the \-tag. In IGUIObject, this function does
* nothing. In CList and CDropDown, it handles the \- , used to build the data.
*
* Returning false means the object doesn't recognize the child. Should be reported.
* Notice 'false' is default, because an object not using this function, should not
* have any additional children (and this function should never be called).
*/
virtual bool HandleAdditionalChildren(const XMBElement& UNUSED(child), CXeromyces* UNUSED(pFile))
{
return false;
}
/**
* Cached size, real size m_Size is actually dependent on resolution
* and can have different *real* outcomes, this is the real outcome
* cached to avoid slow calculations in real time.
*/
CRect m_CachedActualSize;
/**
* Send event to this GUI object (HandleMessage and ScriptEvent)
*
* @param type Type of GUI message to be handled
* @param EventName String representation of event name
* @return IN_HANDLED if event was handled, or IN_PASS if skipped
*/
InReaction SendEvent(EGUIMessageType type, const CStr& EventName);
/**
* Execute the script for a particular action.
* Does nothing if no script has been registered for that action.
* The mouse coordinates will be passed as the first argument.
*
* @param Action Name of action
*/
void ScriptEvent(const CStr& Action);
/**
* Execute the script for a particular action.
* Does nothing if no script has been registered for that action.
*
* @param Action Name of action
* @param paramData JS::HandleValueArray arguments to pass to the event.
*/
void ScriptEvent(const CStr& Action, JS::HandleValueArray paramData);
void SetScriptHandler(const CStr& Action, JS::HandleObject Function);
/**
* Inputes the object that is currently hovered, this function
* updates this object accordingly (i.e. if it's the object
* being inputted one thing happens, and not, another).
*
* @param pMouseOver Object that is currently hovered,
* can OF COURSE be NULL too!
*/
void UpdateMouseOver(IGUIObject* const& pMouseOver);
//@}
private:
//--------------------------------------------------------
/** @name Internal functions */
//--------------------------------------------------------
//@{
/**
* Inputs a reference pointer, checks if the new inputted object
* if hovered, if so, then check if this's Z value is greater
* than the inputted object... If so then the object is closer
* and we'll replace the pointer with this.
* Also Notice input can be NULL, which means the Z value demand
* is out. NOTICE you can't input NULL as const so you'll have
* to set an object to NULL.
*
* @param pObject Object pointer, can be either the old one, or
* the new one.
*/
void ChooseMouseOverAndClosest(IGUIObject*& pObject);
// Is the object a Root object, in philosophy, this means it
// has got no parent, and technically, it's got the m_BaseObject
// as parent.
bool IsRootObject() const;
/**
* Logs an invalid setting search and returns the correct return result
*
* @return the error result
*/
PSRETURN LogInvalidSettings(const CStr8& Setting) const;
static void Trace(JSTracer* trc, void* data)
{
reinterpret_cast
(data)->TraceMember(trc);
}
void TraceMember(JSTracer* trc);
// Variables
protected:
// Name of object
CStr m_Name;
// Constructed on the heap, will be destroyed along with the the object
// TODO Gee: really the above?
vector_pObjects m_Children;
// Pointer to parent
IGUIObject *m_pParent;
//This represents the last click time for each mouse button
double m_LastClickTime[6];
/**
* This is an array of true or false, each element is associated with
* a string representing a setting. Number of elements is equal to
* number of settings.
*
* A true means the setting has been manually set in the file when
* read. This is important to know because I don't want to force
* the user to include its \-XML-files first, so somehow
* the GUI needs to know which settings were set, and which is meant
* to.
*/
// More variables
// Is mouse hovering the object? used with the function MouseOver()
bool m_MouseHovering;
/**
* Settings pool, all an object's settings are located here
* If a derived object has got more settings that the base
* settings, it's because they have a new version of the
* function SetupSettings().
*
* @see SetupSettings()
*/
public:
std::map m_Settings;
protected:
// An object can't function stand alone
CGUI* const m_pGUI;
// Internal storage for registered script handlers.
std::map > m_ScriptHandlers;
// Cached JSObject representing this GUI object
JS::PersistentRootedObject m_JSObject;
};
/**
* Dummy object used primarily for the root object
* or objects of type 'empty'
*/
class CGUIDummyObject : public IGUIObject
{
GUI_OBJECT(CGUIDummyObject)
public:
CGUIDummyObject(CGUI* pGUI) : IGUIObject(pGUI) {}
virtual void Draw() {}
// Empty can never be hovered. It is only a category.
virtual bool MouseOver() { return false; }
};
#endif // INCLUDED_IGUIOBJECT
Index: ps/trunk/source/gui/IGUITextOwner.cpp
===================================================================
--- ps/trunk/source/gui/IGUITextOwner.cpp (revision 22595)
+++ ps/trunk/source/gui/IGUITextOwner.cpp (revision 22596)
@@ -1,116 +1,142 @@
/* Copyright (C) 2019 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
#include "precompiled.h"
+#include "IGUITextOwner.h"
+
#include "gui/GUI.h"
+#include "gui/scripting/JSInterface_IGUITextOwner.h"
IGUITextOwner::IGUITextOwner(CGUI* pGUI)
: IGUIObject(pGUI), m_GeneratedTextsValid(false)
{
}
IGUITextOwner::~IGUITextOwner()
{
for (SGUIText* const& t : m_GeneratedTexts)
delete t;
}
+void IGUITextOwner::CreateJSObject()
+{
+ IGUIObject::CreateJSObject();
+
+ JSI_IGUITextOwner::RegisterScriptFunctions(
+ GetGUI()->GetScriptInterface()->GetContext(), m_JSObject);
+}
+
void IGUITextOwner::AddText(SGUIText* text)
{
m_GeneratedTexts.push_back(text);
}
void IGUITextOwner::HandleMessage(SGUIMessage& Message)
{
switch (Message.type)
{
case GUIM_SETTINGS_UPDATED:
// Everything that can change the visual appearance.
// it is assumed that the text of the object will be dependent on
// these. Although that is not certain, but one will have to manually
// change it and disregard this function.
// TODO Gee: (2004-09-07) Make sure this is all options that can affect the text.
if (Message.value == "size" || Message.value == "z" ||
Message.value == "absolute" || Message.value == "caption" ||
Message.value == "font" || Message.value == "textcolor" ||
Message.value == "text_align" || Message.value == "text_valign" ||
Message.value == "buffer_zone")
{
m_GeneratedTextsValid = false;
}
break;
default:
break;
}
}
void IGUITextOwner::UpdateCachedSize()
{
// If an ancestor's size changed, this will let us intercept the change and
// update our text positions
IGUIObject::UpdateCachedSize();
m_GeneratedTextsValid = false;
}
void IGUITextOwner::DrawText(size_t index, const CGUIColor& color, const CPos& pos, float z, const CRect& clipping)
{
if (!m_GeneratedTextsValid)
{
SetupText();
m_GeneratedTextsValid = true;
}
ENSURE(index < m_GeneratedTexts.size() && "Trying to draw a Text Index within a IGUITextOwner that doesn't exist");
if (GetGUI())
GetGUI()->DrawText(*m_GeneratedTexts[index], color, pos, z, clipping);
}
void IGUITextOwner::CalculateTextPosition(CRect& ObjSize, CPos& TextPos, SGUIText& Text)
{
EVAlign valign;
GUI::GetSetting(this, "text_valign", valign);
// The horizontal Alignment is now computed in GenerateText in order to not have to
// loop through all of the TextCall objects again.
TextPos.x = ObjSize.left;
switch (valign)
{
case EVAlign_Top:
TextPos.y = ObjSize.top;
break;
case EVAlign_Center:
// Round to integer pixel values, else the fonts look awful
TextPos.y = floorf(ObjSize.CenterPoint().y - Text.m_Size.cy/2.f);
break;
case EVAlign_Bottom:
TextPos.y = ObjSize.bottom - Text.m_Size.cy;
break;
default:
debug_warn(L"Broken EVAlign in CButton::SetupText()");
break;
}
}
+CSize IGUITextOwner::CalculateTextSize()
+{
+ if (!m_GeneratedTextsValid)
+ {
+ SetupText();
+ m_GeneratedTextsValid = true;
+ }
+
+ if (m_GeneratedTexts.empty())
+ return CSize();
+
+ // GUI Object types that use multiple texts may override this function.
+ return m_GeneratedTexts[0]->m_Size;
+}
+
bool IGUITextOwner::MouseOverIcon()
{
return false;
}
Index: ps/trunk/source/gui/IGUITextOwner.h
===================================================================
--- ps/trunk/source/gui/IGUITextOwner.h (revision 22595)
+++ ps/trunk/source/gui/IGUITextOwner.h (revision 22596)
@@ -1,106 +1,124 @@
/* Copyright (C) 2019 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
/*
GUI Object Base - Text Owner
--Overview--
Interface class that enhance the IGUIObject with
cached CGUIStrings. This class is not at all needed,
and many controls that will use CGUIStrings might
not use this, but does help for regular usage such
as a text-box, a button, a radio button etc.
--More info--
Check GUI.h
*/
#ifndef INCLUDED_IGUITEXTOWNER
#define INCLUDED_IGUITEXTOWNER
#include "GUI.h"
+#include "gui/scripting/JSInterface_IGUITextOwner.h"
/**
* Framework for handling Output text.
*
* @see IGUIObject
*/
class IGUITextOwner : virtual public IGUIObject
{
+ friend bool JSI_IGUITextOwner::GetTextSize(JSContext* cx, uint argc, JS::Value* vp);
+
public:
IGUITextOwner(CGUI* pGUI);
virtual ~IGUITextOwner();
/**
* Adds a text object.
*/
void AddText(SGUIText* text);
/**
+ * Subscribe the custom JS methods.
+ */
+ void CreateJSObject() override;
+
+ /**
* @see IGUIObject#HandleMessage()
*/
virtual void HandleMessage(SGUIMessage& Message);
/**
* @see IGUIObject#UpdateCachedSize()
*/
virtual void UpdateCachedSize();
/**
* Draws the Text.
*
* @param index Index value of text. Mostly this will be 0
* @param color
* @param pos Position
* @param z Z value
* @param clipping Clipping rectangle, don't even add a parameter
* to get no clipping.
*/
virtual void DrawText(size_t index, const CGUIColor& color, const CPos& pos, float z, const CRect& clipping = CRect());
/**
* Test if mouse position is over an icon
*/
virtual bool MouseOverIcon();
+ /**
+ * Workaround to avoid a dynamic_cast which can be 80 times slower than this.
+ */
+ virtual void* GetTextOwner() override { return this; }
+
protected:
/**
* Setup texts. Functions that sets up all texts when changes have been made.
*/
virtual void SetupText() = 0;
/**
* Whether the cached text is currently valid (if not then SetupText will be called by Draw)
*/
bool m_GeneratedTextsValid;
/**
* Texts that are generated and ready to be rendered.
*/
std::vector m_GeneratedTexts;
/**
* Calculate the position for the text, based on the alignment.
*/
void CalculateTextPosition(CRect& ObjSize, CPos& TextPos, SGUIText& Text);
+
+ /**
+ * Calculate the size of the first generated text.
+ */
+ CSize CalculateTextSize();
};
#endif // INCLUDED_IGUITEXTOWNER
Index: ps/trunk/source/gui/scripting/GuiScriptConversions.cpp
===================================================================
--- ps/trunk/source/gui/scripting/GuiScriptConversions.cpp (revision 22595)
+++ ps/trunk/source/gui/scripting/GuiScriptConversions.cpp (revision 22596)
@@ -1,333 +1,361 @@
/* Copyright (C) 2019 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
#include "precompiled.h"
#include "gui/CGUIColor.h"
#include "gui/CGUIList.h"
#include "gui/CGUISeries.h"
#include "gui/GUIbase.h"
#include "gui/IGUIObject.h"
#include "lib/external_libraries/libsdl.h"
#include "maths/Vector2D.h"
#include "ps/Hotkey.h"
#include "scriptinterface/ScriptConversions.h"
#define SET(obj, name, value) STMT(JS::RootedValue v_(cx); AssignOrToJSVal(cx, &v_, (value)); JS_SetProperty(cx, obj, (name), v_))
// ignore JS_SetProperty return value, because errors should be impossible
// and we can't do anything useful in the case of errors anyway
template<> void ScriptInterface::ToJSVal(JSContext* cx, JS::MutableHandleValue ret, SDL_Event_ const& val)
{
JSAutoRequest rq(cx);
const char* typeName;
switch (val.ev.type)
{
case SDL_WINDOWEVENT: typeName = "windowevent"; break;
case SDL_KEYDOWN: typeName = "keydown"; break;
case SDL_KEYUP: typeName = "keyup"; break;
case SDL_MOUSEMOTION: typeName = "mousemotion"; break;
case SDL_MOUSEBUTTONDOWN: typeName = "mousebuttondown"; break;
case SDL_MOUSEBUTTONUP: typeName = "mousebuttonup"; break;
case SDL_QUIT: typeName = "quit"; break;
case SDL_HOTKEYDOWN: typeName = "hotkeydown"; break;
case SDL_HOTKEYUP: typeName = "hotkeyup"; break;
default: typeName = "(unknown)"; break;
}
JS::RootedObject obj(cx, JS_NewPlainObject(cx));
if (!obj)
{
ret.setUndefined();
return;
}
SET(obj, "type", typeName);
switch (val.ev.type)
{
case SDL_KEYDOWN:
case SDL_KEYUP:
{
// SET(obj, "which", (int)val.ev.key.which); // (not in wsdl.h)
// SET(obj, "state", (int)val.ev.key.state); // (not in wsdl.h)
JS::RootedObject keysym(cx, JS_NewPlainObject(cx));
if (!keysym)
{
ret.setUndefined();
return;
}
JS::RootedValue keysymVal(cx, JS::ObjectValue(*keysym));
JS_SetProperty(cx, obj, "keysym", keysymVal);
// SET(keysym, "scancode", (int)val.ev.key.keysym.scancode); // (not in wsdl.h)
SET(keysym, "sym", (int)val.ev.key.keysym.sym);
// SET(keysym, "mod", (int)val.ev.key.keysym.mod); // (not in wsdl.h)
{
SET(keysym, "unicode", JS::UndefinedHandleValue);
}
// TODO: scripts have no idea what all the key/mod enum values are;
// we should probably expose them as constants if we expect scripts to use them
break;
}
case SDL_MOUSEMOTION:
{
// SET(obj, "which", (int)val.ev.motion.which); // (not in wsdl.h)
// SET(obj, "state", (int)val.ev.motion.state); // (not in wsdl.h)
SET(obj, "x", (int)val.ev.motion.x);
SET(obj, "y", (int)val.ev.motion.y);
// SET(obj, "xrel", (int)val.ev.motion.xrel); // (not in wsdl.h)
// SET(obj, "yrel", (int)val.ev.motion.yrel); // (not in wsdl.h)
break;
}
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
{
// SET(obj, "which", (int)val.ev.button.which); // (not in wsdl.h)
SET(obj, "button", (int)val.ev.button.button);
SET(obj, "state", (int)val.ev.button.state);
SET(obj, "x", (int)val.ev.button.x);
SET(obj, "y", (int)val.ev.button.y);
SET(obj, "clicks", (int)val.ev.button.clicks);
break;
}
case SDL_HOTKEYDOWN:
case SDL_HOTKEYUP:
{
SET(obj, "hotkey", static_cast(val.ev.user.data1));
break;
}
}
ret.setObject(*obj);
}
template<> void ScriptInterface::ToJSVal(JSContext* UNUSED(cx), JS::MutableHandleValue ret, IGUIObject* const& val)
{
if (val == NULL)
ret.setNull();
else
ret.setObject(*val->GetJSObject());
}
template<> void ScriptInterface::ToJSVal(JSContext* cx, JS::MutableHandleValue ret, const CGUIString& val)
{
ScriptInterface::ToJSVal(cx, ret, val.GetOriginalString());
}
template<> bool ScriptInterface::FromJSVal(JSContext* cx, JS::HandleValue v, CGUIString& out)
{
std::wstring val;
if (!FromJSVal(cx, v, val))
return false;
out.SetValue(val);
return true;
}
JSVAL_VECTOR(CVector2D)
JSVAL_VECTOR(std::vector)
JSVAL_VECTOR(CGUIString)
template<> void ScriptInterface::ToJSVal(JSContext* cx, JS::MutableHandleValue ret, const CGUIColor& val)
{
ToJSVal(cx, ret, val);
}
template<> bool ScriptInterface::FromJSVal(JSContext* cx, JS::HandleValue v, CGUIColor& out)
{
if (v.isString())
{
CStr name;
if (!FromJSVal(cx, v, name))
return false;
if (!out.ParseString(name))
{
JS_ReportError(cx, "Invalid color '%s'", name.c_str());
return false;
}
return true;
}
// Parse as object
return FromJSVal(cx, v, out);
}
+template<> void ScriptInterface::ToJSVal(JSContext* cx, JS::MutableHandleValue ret, const CSize& val)
+{
+ ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface->CreateObject(ret, "width", val.cx, "height", val.cy);
+}
+
+template<> bool ScriptInterface::FromJSVal(JSContext* cx, JS::HandleValue v, CSize& out)
+{
+ if (!v.isObject())
+ {
+ JS_ReportError(cx, "CSize value must be an object!");
+ return false;
+ }
+
+ if (!FromJSProperty(cx, v, "width", out.cx))
+ {
+ JS_ReportError(cx, "Failed to get CSize.cx property");
+ return false;
+ }
+
+ if (!FromJSProperty(cx, v, "height", out.cy))
+ {
+ JS_ReportError(cx, "Failed to get CSize.cy property");
+ return false;
+ }
+
+ return true;
+}
+
template<> void ScriptInterface::ToJSVal(JSContext* cx, JS::MutableHandleValue ret, const CPos& val)
{
ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface->CreateObject(ret, "x", val.x, "y", val.y);
}
template<> bool ScriptInterface::FromJSVal(JSContext* cx, JS::HandleValue v, CPos& out)
{
if (!v.isObject())
{
JS_ReportError(cx, "CPos value must be an object!");
return false;
}
if (!FromJSProperty(cx, v, "x", out.x))
{
JS_ReportError(cx, "Failed to get CPos.x property");
return false;
}
if (!FromJSProperty(cx, v, "y", out.y))
{
JS_ReportError(cx, "Failed to get CPos.y property");
return false;
}
return true;
}
template<> void ScriptInterface::ToJSVal(JSContext* cx, JS::MutableHandleValue ret, const CClientArea& val)
{
val.ToJSVal(cx, ret);
}
template<> bool ScriptInterface::FromJSVal(JSContext* cx, JS::HandleValue v, CClientArea& out)
{
return out.FromJSVal(cx, v);
}
template<> void ScriptInterface::ToJSVal(JSContext* cx, JS::MutableHandleValue ret, const CGUIList& val)
{
ToJSVal(cx, ret, val.m_Items);
}
template<> bool ScriptInterface::FromJSVal(JSContext* cx, JS::HandleValue v, CGUIList& out)
{
return FromJSVal(cx, v, out.m_Items);
}
template<> void ScriptInterface::ToJSVal(JSContext* cx, JS::MutableHandleValue ret, const CGUISeries& val)
{
ToJSVal(cx, ret, val.m_Series);
}
template<> bool ScriptInterface::FromJSVal(JSContext* cx, JS::HandleValue v, CGUISeries& out)
{
return FromJSVal(cx, v, out.m_Series);
}
template<> void ScriptInterface::ToJSVal(JSContext* cx, JS::MutableHandleValue ret, const EVAlign& val)
{
std::string word;
switch (val)
{
case EVAlign_Top:
word = "top";
break;
case EVAlign_Bottom:
word = "bottom";
break;
case EVAlign_Center:
word = "center";
break;
default:
word = "error";
JS_ReportError(cx, "Invalid EVAlign");
break;
}
ToJSVal(cx, ret, word);
}
template<> bool ScriptInterface::FromJSVal(JSContext* cx, JS::HandleValue v, EVAlign& out)
{
std::string word;
FromJSVal(cx, v, word);
if (word == "top")
out = EVAlign_Top;
else if (word == "bottom")
out = EVAlign_Bottom;
else if (word == "center")
out = EVAlign_Center;
else
{
out = EVAlign_Top;
JS_ReportError(cx, "Invalid alignment (should be 'left', 'right' or 'center')");
return false;
}
return true;
}
template<> void ScriptInterface::ToJSVal(JSContext* cx, JS::MutableHandleValue ret, const EAlign& val)
{
std::string word;
switch (val)
{
case EAlign_Left:
word = "left";
break;
case EAlign_Right:
word = "right";
break;
case EAlign_Center:
word = "center";
break;
default:
word = "error";
JS_ReportError(cx, "Invalid alignment (should be 'left', 'right' or 'center')");
break;
}
ToJSVal(cx, ret, word);
}
template<> bool ScriptInterface::FromJSVal(JSContext* cx, JS::HandleValue v, EAlign& out)
{
std::string word;
FromJSVal(cx, v, word);
if (word == "left")
out = EAlign_Left;
else if (word == "right")
out = EAlign_Right;
else if (word == "center")
out = EAlign_Center;
else
{
out = EAlign_Left;
JS_ReportError(cx, "Invalid alignment (should be 'left', 'right' or 'center')");
return false;
}
return true;
}
template<> void ScriptInterface::ToJSVal(JSContext* cx, JS::MutableHandleValue ret, const CGUISpriteInstance& val)
{
ToJSVal(cx, ret, val.GetName());
}
template<> bool ScriptInterface::FromJSVal(JSContext* cx, JS::HandleValue v, CGUISpriteInstance& out)
{
std::string name;
if (!FromJSVal(cx, v, name))
return false;
out.SetName(name);
return true;
}
#undef SET
Index: ps/trunk/source/gui/scripting/JSInterface_IGUIObject.cpp
===================================================================
--- ps/trunk/source/gui/scripting/JSInterface_IGUIObject.cpp (revision 22595)
+++ ps/trunk/source/gui/scripting/JSInterface_IGUIObject.cpp (revision 22596)
@@ -1,335 +1,263 @@
/* Copyright (C) 2019 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
#include "precompiled.h"
#include "JSInterface_IGUIObject.h"
#include "gui/CGUI.h"
#include "gui/CGUIColor.h"
#include "gui/CList.h"
#include "gui/GUIManager.h"
#include "gui/IGUIObject.h"
#include "gui/IGUIScrollBar.h"
#include "gui/scripting/JSInterface_GUITypes.h"
#include "ps/CLogger.h"
#include "scriptinterface/ScriptExtraHeaders.h"
#include "scriptinterface/ScriptInterface.h"
JSClass JSI_IGUIObject::JSI_class = {
"GUIObject", JSCLASS_HAS_PRIVATE,
nullptr, nullptr,
JSI_IGUIObject::getProperty, JSI_IGUIObject::setProperty,
nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr
};
JSFunctionSpec JSI_IGUIObject::JSI_methods[] =
{
JS_FN("toString", JSI_IGUIObject::toString, 0, 0),
JS_FN("focus", JSI_IGUIObject::focus, 0, 0),
JS_FN("blur", JSI_IGUIObject::blur, 0, 0),
JS_FN("getComputedSize", JSI_IGUIObject::getComputedSize, 0, 0),
- JS_FN("getTextSize", JSI_IGUIObject::getTextSize, 0, 0),
JS_FS_END
};
bool JSI_IGUIObject::getProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp)
{
JSAutoRequest rq(cx);
ScriptInterface* pScriptInterface = ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface;
IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, obj, &JSI_IGUIObject::JSI_class, NULL);
if (!e)
return false;
JS::RootedValue idval(cx);
if (!JS_IdToValue(cx, id, &idval))
return false;
std::string propName;
if (!ScriptInterface::FromJSVal(cx, idval, propName))
return false;
// Skip registered functions and inherited properties
+ // including JSInterfaces of derived classes
if (propName == "constructor" ||
propName == "prototype" ||
propName == "toString" ||
propName == "toJSON" ||
propName == "focus" ||
propName == "blur" ||
propName == "getTextSize" ||
propName == "getComputedSize"
)
return true;
// Use onWhatever to access event handlers
if (propName.substr(0, 2) == "on")
{
CStr eventName(CStr(propName.substr(2)).LowerCase());
std::map>::iterator it = e->m_ScriptHandlers.find(eventName);
if (it == e->m_ScriptHandlers.end())
vp.setNull();
else
vp.setObject(*it->second.get());
return true;
}
if (propName == "parent")
{
IGUIObject* parent = e->GetParent();
if (parent)
vp.set(JS::ObjectValue(*parent->GetJSObject()));
else
vp.set(JS::NullValue());
return true;
}
else if (propName == "children")
{
pScriptInterface->CreateArray(vp);
for (size_t i = 0; i < e->m_Children.size(); ++i)
pScriptInterface->SetPropertyInt(vp, i, e->m_Children[i]);
return true;
}
else if (propName == "name")
{
ScriptInterface::ToJSVal(cx, vp, e->GetName());
return true;
}
else if (e->SettingExists(propName))
{
e->m_Settings[propName].m_ToJSVal(cx, vp);
return true;
}
JS_ReportError(cx, "Property '%s' does not exist!", propName.c_str());
return false;
}
bool JSI_IGUIObject::setProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool UNUSED(strict), JS::MutableHandleValue vp)
{
IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, obj, &JSI_IGUIObject::JSI_class, NULL);
if (!e)
return false;
JSAutoRequest rq(cx);
JS::RootedValue idval(cx);
if (!JS_IdToValue(cx, id, &idval))
return false;
std::string propName;
if (!ScriptInterface::FromJSVal(cx, idval, propName))
return false;
if (propName == "name")
{
std::string value;
if (!ScriptInterface::FromJSVal(cx, vp, value))
return false;
e->SetName(value);
return true;
}
JS::RootedObject vpObj(cx);
if (vp.isObject())
vpObj = &vp.toObject();
// Use onWhatever to set event handlers
if (propName.substr(0, 2) == "on")
{
if (vp.isPrimitive() || vp.isNull() || !JS_ObjectIsFunction(cx, &vp.toObject()))
{
JS_ReportError(cx, "on- event-handlers must be functions");
return false;
}
CStr eventName(CStr(propName.substr(2)).LowerCase());
e->SetScriptHandler(eventName, vpObj);
return true;
}
if (e->SettingExists(propName))
return e->m_Settings[propName].m_FromJSVal(cx, vp);
JS_ReportError(cx, "Property '%s' does not exist!", propName.c_str());
return false;
}
void JSI_IGUIObject::init(ScriptInterface& scriptInterface)
{
scriptInterface.DefineCustomObjectType(&JSI_class, nullptr, 1, nullptr, JSI_methods, nullptr, nullptr);
}
bool JSI_IGUIObject::toString(JSContext* cx, uint UNUSED(argc), JS::Value* vp)
{
JSAutoRequest rq(cx);
JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp));
IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, NULL);
if (!e)
return false;
ScriptInterface::ToJSVal(cx, rec.rval(), "[GUIObject: " + e->GetName() + "]");
return true;
}
bool JSI_IGUIObject::focus(JSContext* cx, uint UNUSED(argc), JS::Value* vp)
{
JSAutoRequest rq(cx);
JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp));
IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, NULL);
if (!e)
return false;
e->GetGUI()->SetFocusedObject(e);
rec.rval().setUndefined();
return true;
}
bool JSI_IGUIObject::blur(JSContext* cx, uint UNUSED(argc), JS::Value* vp)
{
JSAutoRequest rq(cx);
JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp));
IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, NULL);
if (!e)
return false;
e->GetGUI()->SetFocusedObject(NULL);
rec.rval().setUndefined();
return true;
}
-bool JSI_IGUIObject::getTextSize(JSContext* cx, uint argc, JS::Value* vp)
-{
- JSAutoRequest rq(cx);
- JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
-
- JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
- JS::RootedObject thisObj(cx, &args.thisv().toObject());
-
- IGUIObject* obj = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, NULL);
-
- if (!obj || !obj->SettingExists("caption"))
- return false;
-
- CStrW font;
- if (GUI::GetSetting(obj, "font", font) != PSRETURN_OK || font.empty())
- font = L"default";
-
- CGUIString caption;
- EGUISettingType Type;
- obj->GetSettingType("caption", Type);
- if (Type == GUIST_CGUIString)
- // CText, CButton, CCheckBox, CRadioButton
- GUI::GetSetting(obj, "caption", caption);
- else if (Type == GUIST_CStrW)
- {
- // CInput
- CStrW captionStr;
- GUI::GetSetting(obj, "caption", captionStr);
- caption.SetValue(captionStr);
- }
- else
- return false;
-
- obj->UpdateCachedSize();
- float width = obj->m_CachedActualSize.GetWidth();
-
- if (obj->SettingExists("scrollbar"))
- {
- bool scrollbar;
- GUI::GetSetting(obj, "scrollbar", scrollbar);
- if (scrollbar)
- {
- CStr scrollbar_style;
- GUI::GetSetting(obj, "scrollbar_style", scrollbar_style);
- const SGUIScrollBarStyle* scrollbar_style_object = obj->GetGUI()->GetScrollBarStyle(scrollbar_style);
- if (scrollbar_style_object)
- width -= scrollbar_style_object->m_Width;
- }
- }
-
- float buffer_zone = 0.f;
- GUI::GetSetting(obj, "buffer_zone", buffer_zone);
- SGUIText text = obj->GetGUI()->GenerateText(caption, font, width, buffer_zone, obj);
-
- JS::RootedValue objVal(cx);
- try
- {
- ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface->CreateObject(
- &objVal,
- "width", text.m_Size.cx,
- "height", text.m_Size.cy);
- }
- catch (PSERROR_Scripting_ConversionFailed&)
- {
- debug_warn(L"Error creating size object!");
- return false;
- }
-
- rec.rval().set(objVal);
- return true;
-}
-
bool JSI_IGUIObject::getComputedSize(JSContext* cx, uint UNUSED(argc), JS::Value* vp)
{
JSAutoRequest rq(cx);
JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp));
IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, NULL);
if (!e)
return false;
e->UpdateCachedSize();
CRect size = e->m_CachedActualSize;
JS::RootedValue objVal(cx);
try
{
ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface->CreateObject(
&objVal,
"left", size.left,
"right", size.right,
"top", size.top,
"bottom", size.bottom);
}
catch (PSERROR_Scripting_ConversionFailed&)
{
debug_warn(L"Error creating size object!");
return false;
}
rec.rval().set(objVal);
return true;
}
Index: ps/trunk/source/gui/scripting/JSInterface_IGUITextOwner.cpp
===================================================================
--- ps/trunk/source/gui/scripting/JSInterface_IGUITextOwner.cpp (nonexistent)
+++ ps/trunk/source/gui/scripting/JSInterface_IGUITextOwner.cpp (revision 22596)
@@ -0,0 +1,59 @@
+/* Copyright (C) 2019 Wildfire Games.
+ * This file is part of 0 A.D.
+ *
+ * 0 A.D. is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 0 A.D. is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with 0 A.D. If not, see .
+ */
+
+#include "precompiled.h"
+
+#include "JSInterface_IGUITextOwner.h"
+
+#include "gui/IGUITextOwner.h"
+#include "scriptinterface/ScriptInterface.h"
+
+JSFunctionSpec JSI_IGUITextOwner::JSI_methods[] =
+{
+ JS_FN("getTextSize", GetTextSize, 0, 0),
+ JS_FS_END
+};
+
+void JSI_IGUITextOwner::RegisterScriptFunctions(JSContext* cx, JS::HandleObject obj)
+{
+ JS_DefineFunctions(cx, obj, JSI_methods);
+}
+
+bool JSI_IGUITextOwner::GetTextSize(JSContext* cx, uint UNUSED(argc), JS::Value* vp)
+{
+ JSAutoRequest rq(cx);
+ JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
+ JS::RootedObject thisObj(cx, &rec.thisv().toObject());
+
+ IGUIObject* obj = static_cast(JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, nullptr));
+ if (!obj)
+ {
+ JS_ReportError(cx, "This is not an IGUIObject!");
+ return false;
+ }
+
+ // Avoid dynamic_cast for performance reasons
+ IGUITextOwner* objText = static_cast(obj->GetTextOwner());
+ if (!objText)
+ {
+ JS_ReportError(cx, "This IGUIObject is not an IGUITextOwner!");
+ return false;
+ }
+
+ ScriptInterface::ToJSVal(cx, rec.rval(), objText->CalculateTextSize());
+ return true;
+}
Property changes on: ps/trunk/source/gui/scripting/JSInterface_IGUITextOwner.cpp
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: ps/trunk/source/gui/scripting/JSInterface_IGUITextOwner.h
===================================================================
--- ps/trunk/source/gui/scripting/JSInterface_IGUITextOwner.h (nonexistent)
+++ ps/trunk/source/gui/scripting/JSInterface_IGUITextOwner.h (revision 22596)
@@ -0,0 +1,32 @@
+/* Copyright (C) 2019 Wildfire Games.
+ * This file is part of 0 A.D.
+ *
+ * 0 A.D. is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 0 A.D. is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with 0 A.D. If not, see .
+ */
+
+#ifndef INCLUDED_JSI_IGUITEXTOWNER
+#define INCLUDED_JSI_IGUITEXTOWNER
+
+#include "scriptinterface/ScriptInterface.h"
+
+namespace JSI_IGUITextOwner
+{
+ extern JSFunctionSpec JSI_methods[];
+
+ void RegisterScriptFunctions(JSContext* cx, JS::HandleObject obj);
+
+ bool GetTextSize(JSContext* cx, uint argc, JS::Value* vp);
+}
+
+#endif // INCLUDED_JSI_IGUITEXTOWNER
Property changes on: ps/trunk/source/gui/scripting/JSInterface_IGUITextOwner.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property