22 #include "precompiled.h"
79 const char* hotkey =
static_cast<const char*
>(ev->
ev.
user.
data1);
80 std::map<CStr, std::vector<IGUIObject*> >::iterator it =
m_HotkeyObjects.find(hotkey);
83 for (
size_t i = 0; i < it->second.size(); ++i)
167 #if !SDL_VERSION_ATLEAST(2, 0, 0)
182 #if SDL_VERSION_ATLEAST(2, 0, 0)
183 else if (ev->
ev.
type == SDL_MOUSEWHEEL)
185 if (ev->
ev.wheel.y < 0)
190 else if (ev->
ev.wheel.y > 0)
298 CStr action =
"tick";
332 return JS_GetPropertyById(cx,
g_ScriptingHost.GetGlobalObject(), id, vp);
337 return JS_SetPropertyById(cx,
g_ScriptingHost.GetGlobalObject(), id, vp);
350 if (flags & (JSRESOLVE_DECLARING | JSRESOLVE_ASSIGNING))
360 if (!JS_GetPropertyAttrsGetterAndSetterById(cx,
g_ScriptingHost.GetGlobalObject(), id, &attrs, &found, NULL, NULL))
372 if (!JS_GetPropertyById(cx,
g_ScriptingHost.GetGlobalObject(), id, &v))
385 "page_global", JSCLASS_GLOBAL_FLAGS | JSCLASS_NEW_RESOLVE,
386 JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
388 NULL, NULL, NULL, NULL,
389 NULL, NULL, NULL, NULL
392 CGUI::CGUI() : m_MouseButtons(0), m_FocusedObject(NULL), m_InternalNameNumber(0)
440 AddObjectType(
"radiobutton", &CRadioButton::ConstructObject);
441 AddObjectType(
"progressbar", &CProgressBar::ConstructObject);
453 glClear(GL_DEPTH_BUFFER_BIT);
486 map_pObjects::iterator it;
491 it->second->Destroy();
503 for (std::map<CStr, CGUISprite>::iterator it2 =
m_Sprites.begin(); it2 !=
m_Sprites.end(); ++it2)
504 for (std::vector<SGUIImage>::iterator it3 = it2->second.m_Images.begin(); it3 != it2->second.m_Images.end(); ++it3)
505 delete it3->m_Effects;
616 const float width,
const float y,
617 const CSize &Size,
const CStr& TextureName,
618 const float BufferZone,
const int CellID)
645 const CStrW& Font,
const float &Width,
const float &BufferZone,
650 if (
string.m_Words.size() == 0)
653 float x=BufferZone, y=BufferZone;
657 bool FirstLine =
true;
661 std::vector<SGenerateTextImage> Images[2];
666 bool WordWrapping = (Width != 0);
675 for (
int i=0; i<(int)
string.m_Words.size()-1 && !done; ++i)
684 float prelim_line_height=0.f;
687 string.GenerateTextCall(Feedback, Font,
688 string.m_Words[i],
string.m_Words[i+1],
695 if (WordWrapping && i > pos_last_img)
698 for (
int j=0; j<2; ++j)
700 for (std::vector<CStr>::const_iterator it = Feedback.
m_Images[j].begin();
710 if (!Images[j].empty())
711 _y = std::max(y, Images[j].back().m_YTo);
724 Images[j].push_back(Image);
730 pos_last_img = std::max(pos_last_img, i);
733 prelim_line_height = std::max(prelim_line_height, Feedback.
m_Size.
cy);
736 if ((WordWrapping && (x > Width-BufferZone || Feedback.
m_NewLine)) || i == (
int)
string.m_Words.size()-2)
739 int temp_from = from;
742 static const int From=0, To=1;
744 float width_range[2];
745 width_range[From] = BufferZone;
746 width_range[To] = Width - BufferZone;
759 for (
int j=0; j<2; ++j)
761 for (std::vector<SGenerateTextImage>::const_iterator it = Images[j].begin();
762 it != Images[j].end();
767 float union_from, union_to;
769 union_from = std::max(y, it->m_YFrom);
770 union_to = std::min(y+prelim_line_height, it->m_YTo);
773 if (union_to > union_from)
776 width_range[From] = std::max(width_range[From], it->m_Indentation);
778 width_range[To] = std::min(width_range[To], Width - it->m_Indentation);
785 x = width_range[From];
794 float line_height=0.f;
795 float line_width=0.f;
796 for (
int j=temp_from; j<=i; ++j)
805 string.GenerateTextCall(Feedback2, Font,
806 string.m_Words[j],
string.m_Words[j+1],
812 if (WordWrapping && x > width_range[To] && j!=temp_from && !Feedback2.
m_NewLine)
816 line_height = std::max(line_height, Feedback2.
m_Size.
cy);
834 dx = ((width_range[To] - width_range[From]) - line_width) / 2;
838 dx = width_range[To] - line_width;
842 debug_warn(L
"Broken EAlign in CGUI::GenerateText()");
846 x = width_range[From];
851 for (
int j=temp_from; j<=i; ++j)
858 string.GenerateTextCall(Feedback2, Font,
859 string.m_Words[j],
string.m_Words[j+1],
868 std::vector<SGUIText::STextCall>::iterator it;
871 it->m_Pos =
CPos(dx + x + x_pointer, y);
873 x_pointer += it->m_Size.cx;
875 if (it->m_pSpriteCall)
877 it->m_pSpriteCall->m_Area += it->m_Pos -
CSize(0,it->m_pSpriteCall->m_Area.GetHeight());
901 if (x > width_range[To] && j==temp_from)
907 if (x > width_range[To])
918 if (j == (
int)
string.m_Words.size()-2)
942 const CPos &pos,
const float &z,
const CRect &clipping)
948 if (clipping !=
CRect())
950 glEnable(GL_SCISSOR_TEST);
957 for (std::vector<SGUIText::STextCall>::const_iterator it = Text.
m_TextCalls.begin();
962 if (it->m_pSpriteCall)
965 CColor color = it->m_UseCustomColor ? it->m_Color : DefaultColor;
967 textRenderer.Color(color);
968 textRenderer.Font(it->m_Font);
969 textRenderer.Put((
float)(
int)(pos.
x+it->m_Pos.x), (
float)(
int)(pos.
y+it->m_Pos.y), it->m_String.c_str());
972 textRenderer.Render();
974 for (std::list<SGUIText::SSpriteCall>::iterator it=Text.
m_SpriteCalls.begin();
978 DrawSprite(it->m_Sprite, it->m_CellID, z, it->m_Area + pos);
981 if (clipping !=
CRect())
982 glDisable(GL_SCISSOR_TEST);
1005 Paths.insert(Filename);
1021 if (root_name ==
"objects")
1029 if (root_name ==
"sprites")
1034 if (root_name ==
"styles")
1039 if (root_name ==
"setup")
1064 std::vector<std::pair<CStr, CStr> > subst;
1069 for (
int i=0; i<children.
Count; ++i)
1088 for (
int i=0; i<children.
Count; ++i)
1102 for (
int i=0; i<children.
Count; ++i)
1116 for (
int i=0; i<children.
Count; ++i)
1124 if (name ==
"scrollbar")
1134 if (name ==
"tooltip")
1139 if (name ==
"color")
1145 debug_warn(L
"Invalid data - DTD shouldn't allow this");
1173 LOGERROR(L
"GUI: Unrecognized object type \"%hs\"", type.c_str());
1178 #define ELMT(x) int elmt_##x = pFile->GetElementID(#x)
1179 #define ATTR(x) int attr_##x = pFile->GetAttributeID(#x)
1200 if (
m_Styles.count(
"default") == 1)
1203 if (! argStyle.empty())
1208 LOGERROR(L
"GUI: Trying to use style '%hs' that doesn't exist.", argStyle.c_str());
1210 else object->LoadStyle(*
this, argStyle);
1218 bool NameSet =
false;
1219 bool ManuallySetZ =
false;
1224 for (i=0; i<attributes.
Count; ++i)
1229 if (CStr(attr.
Value) ==
"null")
1233 if (attr.
Name == attr_type || attr.
Name == attr_style)
1237 if (attr.
Name == attr_name)
1239 CStr name (attr.
Value);
1242 for (
size_t j = 0; j < NameSubst.size(); ++j)
1243 name.Replace(NameSubst[j].first, NameSubst[j].second);
1245 object->SetName(name);
1251 if (attr.
Name == attr_hotkey)
1252 hotkeyTag = attr.
Value;
1254 if (attr.
Name == attr_z)
1255 ManuallySetZ =
true;
1274 if (! hotkeyTag.empty())
1277 CStrW caption (Element.
GetText().FromUTF8());
1278 if (! caption.empty())
1281 object->SetSetting(
"caption", caption,
true);
1294 for (i=0; i<children.
Count; ++i)
1302 if (element_name == elmt_object)
1307 else if (element_name == elmt_action)
1317 if (! filename.empty())
1319 Paths.insert(filename);
1323 LOGERROR(L
"Error opening GUI script action file '%ls'", filename.c_str());
1331 code += CStr(child.
GetText());
1334 object->RegisterScriptHandler(action.LowerCase(), code,
this);
1336 else if (element_name == elmt_repeat)
1392 #define ELMT(x) int elmt_##x = pFile->GetElementID(#x)
1393 #define ATTR(x) int attr_##x = pFile->GetAttributeID(#x)
1399 int count = CStr(attributes.
GetNamedItem(attr_count)).ToInt();
1401 for (
int n = 0; n < count; ++n)
1403 std::vector<std::pair<CStr, CStr> > subst;
1404 subst.push_back(std::make_pair(CStr(
"[n]"),
"[" + CStr::FromInt(n) +
"]"));
1408 if (child.GetNodeName() == elmt_object)
1431 LOGERROR(L
"GUI: Error executing script %ls: %hs", file.c_str(), e.
what());
1438 CStr code (Element.
GetText());
1444 LOGERROR(L
"GUI: Error executing inline script: %hs", e.
what());
1464 LOGWARNING(L
"GUI sprite name '%hs' used more than once; first definition will be discarded", name.c_str());
1475 for (
int i=0; i<children.
Count; ++i)
1482 if (ElementName ==
"image")
1486 else if (ElementName ==
"effect")
1490 LOGERROR(L
"GUI <sprite> must not have more than one <effect>");
1500 debug_warn(L
"Invalid data - DTD shouldn't allow this");
1507 for (std::vector<SGUIImage>::iterator it = sprite.
m_Images.begin(); it != sprite.
m_Images.end(); ++it)
1508 if (! it->m_Effects)
1538 for (
int i=0; i<attributes.
Count; ++i)
1542 CStrW attr_value (attr.
Value.FromUTF8());
1544 if (attr_name ==
"texture")
1549 if (attr_name ==
"size")
1553 LOGERROR(L
"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
1557 if (attr_name ==
"texture_size")
1561 LOGERROR(L
"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
1565 if (attr_name ==
"real_texture_placement")
1569 LOGERROR(L
"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
1573 if (attr_name ==
"cell_size")
1577 LOGERROR(L
"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
1581 if (attr_name ==
"fixed_h_aspect_ratio")
1585 LOGERROR(L
"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
1589 if (attr_name ==
"round_coordinates")
1593 LOGERROR(L
"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
1597 if (attr_name ==
"wrap_mode")
1599 if (attr_value == L
"repeat")
1601 else if (attr_value == L
"mirrored_repeat")
1603 else if (attr_value == L
"clamp_to_edge")
1606 LOGERROR(L
"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
1609 if (attr_name ==
"z_level")
1613 LOGERROR(L
"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
1614 else image.
m_DeltaZ = z_level/100.f;
1617 if (attr_name ==
"backcolor")
1621 LOGERROR(L
"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
1625 if (attr_name ==
"bordercolor")
1629 LOGERROR(L
"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
1633 if (attr_name ==
"border")
1637 LOGERROR(L
"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
1642 debug_warn(L
"Invalid data - DTD shouldn't allow this");
1648 for (
int i=0; i<children.
Count; ++i)
1652 if (ElementName ==
"effect")
1656 LOGERROR(L
"GUI <image> must not have more than one <effect>");
1666 debug_warn(L
"Invalid data - DTD shouldn't allow this");
1680 for (
int i=0; i<attributes.
Count; ++i)
1684 CStrW attr_value (attr.
Value.FromUTF8());
1686 if (attr_name ==
"add_color")
1690 LOGERROR(L
"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
1693 else if (attr_name ==
"grayscale")
1699 debug_warn(L
"Invalid data - DTD shouldn't allow this");
1716 for (
int i=0; i<attributes.
Count; ++i)
1723 if (attr_name ==
"name")
1748 for (
int i=0; i<attributes.
Count; ++i)
1752 CStr attr_value (attr.
Value);
1754 if (attr_value ==
"null")
1757 if (attr_name ==
"name")
1760 if (attr_name ==
"width")
1764 LOGERROR(L
"GUI: Error parsing '%hs' (\"%hs\")", attr_name.c_str(), attr_value.c_str());
1769 if (attr_name ==
"minimum_bar_size")
1773 LOGERROR(L
"GUI: Error parsing '%hs' (\"%hs\")", attr_name.c_str(), attr_value.c_str());
1778 if (attr_name ==
"maximum_bar_size")
1782 LOGERROR(L
"GUI: Error parsing '%hs' (\"%hs\")", attr_name.c_str(), attr_value.c_str());
1787 if (attr_name ==
"sprite_button_top")
1790 if (attr_name ==
"sprite_button_top_pressed")
1793 if (attr_name ==
"sprite_button_top_disabled")
1796 if (attr_name ==
"sprite_button_top_over")
1799 if (attr_name ==
"sprite_button_bottom")
1802 if (attr_name ==
"sprite_button_bottom_pressed")
1805 if (attr_name ==
"sprite_button_bottom_disabled")
1808 if (attr_name ==
"sprite_button_bottom_over")
1811 if (attr_name ==
"sprite_back_vertical")
1814 if (attr_name ==
"sprite_bar_vertical")
1817 if (attr_name ==
"sprite_bar_vertical_over")
1820 if (attr_name ==
"sprite_bar_vertical_pressed")
1838 for (
int i=0; i<attributes.
Count; ++i)
1842 CStr attr_value (attr.
Value);
1844 if (attr_value ==
"null")
1847 if (attr_name ==
"name")
1850 if (attr_name ==
"sprite")
1853 if (attr_name ==
"size")
1857 LOGERROR(L
"Error parsing '%hs' (\"%hs\") inside <icon>.", attr_name.c_str(), attr_value.c_str());
1862 if (attr_name ==
"cell_id")
1866 LOGERROR(L
"GUI: Error parsing '%hs' (\"%hs\") inside <icon>.", attr_name.c_str(), attr_value.c_str());
1872 debug_warn(L
"Invalid data - DTD shouldn't allow this");
1886 for (
int i=0; i<attributes.
Count; ++i)
1890 CStr attr_value (attr.
Value);
1892 if (attr_name ==
"name")
1894 object->SetName(
"__tooltip_" + attr_value);
1898 object->SetSetting(attr_name, attr_value.FromUTF8());
1917 CStr value (Element.
GetText());
1918 if (! value.empty())
1923 LOGERROR(L
"GUI: Unable to create custom color '%hs'. Invalid color syntax.", name.c_str());
bool ObjectExists(const CStr &Name) const
Checks if object exists and return true or false accordingly.
void Xeromyces_ReadImage(XMBElement Element, CXeromyces *pFile, CGUISprite &parent)
Reads in the element <image> (the XMBElement) and stores the result within the CGUISprite.
std::map< CStr, CColor > m_PreDefinedColors
This is a bank of custom colors, it is simply a look up table that will return a color object when so...
virtual void ResetStates()
Reset internal state of this object.
CStr DecodeUTF8() const
Returns contents of a UTF-8 encoded file as a string with optional BOM removed.
void Translate(float x, float y, float z)
Made to represent a screen size, should in philosophy be made of unsigned ints, but for the sake of c...
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning. ...
Path VfsPath
VFS path of the form "(dir/)*file?".
void DrawSprite(const CGUISpriteInstance &Sprite, int CellID, const float &Z, const CRect &Rect, const CRect &Clipping=CRect())
Draw GUI Sprite.
void Xeromyces_ReadRootSprites(XMBElement Element, CXeromyces *pFile)
Reads in the root element <sprites> (the DOMElement).
std::map< CStr, CStrW > m_SettingsDefaults
PSRETURN Load(const PIVFS &vfs, const VfsPath &filename)
Load from an XML file (with invisible XMB caching).
float m_FixedHAspectRatio
If non-zero, then the image's width will be adjusted when rendering so that the width:height ratio eq...
void Xeromyces_ReadObject(XMBElement Element, CXeromyces *pFile, IGUIObject *pParent, const std::vector< std::pair< CStr, CStr > > &NameSubst, boost::unordered_set< VfsPath > &Paths)
Notice! Recursive function!
IGUIObject * m_FocusedObject
Focused object! Say an input box that is selected.
const PSRETURN PSRETURN_OK
void ScriptEvent(const CStr &Action)
Execute the script for a particular action.
Reads a file, then gives read-only access to the contents.
void Xeromyces_ReadScrollBarStyle(XMBElement Element, CXeromyces *pFile)
Reads in the element <scrollbar> (the XMBElement) and stores the result in m_ScrollBarStyles.
JSObject * m_ScriptObject
An JSObject* under which all GUI JavaScript things will be created, so that they can be garbage-colle...
Dummy object used primarily for the root object or objects of type 'empty'.
All data generated in GenerateTextCall()
std::vector< SGUIText::STextCall > m_TextCalls
Text and Sprite Calls.
int GetElementID(const char *Name) const
float left
Returning CPos representing each corner.
static PSRETURN GetSetting(const IGUIObject *pObject, const CStr &Setting, T &Value)
Retrieves a setting by name from object pointer.
IGUIObject * FindObjectUnderMouse() const
Returns the GUI object under the mouse, or NULL if none.
XMBAttributeList GetAttributes() const
XMBElementList GetChildNodes() const
#define XERO_ITER_EL(parent_element, child_element)
shared_ptr< CShaderTechnique > CShaderTechniquePtr
static JSBool GetGlobalProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
void SetGUI(CGUI *const &pGUI)
CSize m_Size
Width and Height feedback
CRect m_Area
Size and position of sprite.
Base settings, all objects possess these settings in their m_BaseSettings Instructions can be found i...
A sprite call to the CRenderer.
void Xeromyces_ReadRootObjects(XMBElement Element, CXeromyces *pFile, boost::unordered_set< VfsPath > &Paths)
Reads in the root element <objects> (the DOMElement).
CStr GetPresentableName() const
int GetLineNumber() const
void Xeromyces_ReadRootSetup(XMBElement Element, CXeromyces *pFile)
Reads in the root element <setup> (the DOMElement).
static JSBool SetGlobalProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
static JSClass page_global_class
std::map< CStr, std::vector< IGUIObject * > > m_HotkeyObjects
Map from hotkey names to objects that listen to the hotkey.
bool ParseString(const CStr8 &Value, float DefaultAlpha)
SDL_MouseMotionEvent motion
void Destroy()
Clean up, call this to clean up all memory allocated within the GUI.
virtual float GetBufferedZ() const
Returns not the Z value, but the actual buffered Z value, i.e.
virtual bool HandleAdditionalChildren(const XMBElement &child, CXeromyces *pFile)
Handle additional children to the <object>-tag.
virtual InReaction ManuallyHandleEvent(const SDL_Event_ *ev)
Some objects need to handle the SDL_Event_ manually.
void TickObjects()
Performs processing that should happen every frame (including sending the "Tick" event to scripts) ...
std::map< CStr, CGUISprite > m_Sprites
Includes static functions that needs one template argument.
bool m_RoundCoordinates
If true, the image's coordinates will be rounded to integer pixels when rendering, to avoid blurry filtering.
unsigned int m_MouseButtons
Indicates which buttons are pressed (bit 0 = LMB, bit 1 = RMB, bit 2 = MMB)
virtual void UpdateCachedSize()
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.
CPos m_MousePos
don't want to pass this around with the ChooseMouseOverAndClosest broadcast - we'd need to pack this ...
void Xeromyces_ReadRootStyles(XMBElement Element, CXeromyces *pFile)
Reads in the root element <styles> (the DOMElement).
virtual PSRETURN getCode() const =0
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
#define UNUSED2(param)
mark a function local variable or parameter as unused and avoid the corresponding compiler warning...
static JSBool ResolveGlobalProperty(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject **objp)
float m_DeltaZ
Z value modification of the image.
SDL_MouseButtonEvent button
IGUIObject * GetFocusedObject()
Get Focused Object.
static void ScriptingInit()
Initializes GUI script classes.
void UpdateObjects()
Updates the object pointers, needs to be called each time an object has been added or removed...
std::vector< CStr > m_Images[2]
Image stacks, for left and right floating images.
std::vector< SGUIImage > m_Images
List of images.
const String & string() const
void Xeromyces_ReadScript(XMBElement Element, CXeromyces *pFile, boost::unordered_set< VfsPath > &Paths)
Reads in the element <script> (the XMBElement) and executes the script's code.
CSize m_Size
Width and height of the whole output, used when setting up scrollbars and such.
virtual const char * what() const
XMBAttribute Item(const int id)
std::map< CStr, SGUIStyle > m_Styles
bool GetPreDefinedColor(const CStr &name, CColor &Output)
Get pre-defined color (if it exists) Returns false if it fails.
void AddImage(const SGUIImage &image)
Adds an image to the sprite collage.
IGUIObject * ConstructObject(const CStr &str)
You input the name of the object type, and let's say you input "button", then it will construct a CGU...
void AddChild(IGUIObject *pChild)
Notice nothing will be returned or thrown if the child hasn't been inputted into the GUI yet...
SGUIImageEffects * m_Effects
std::vector< STextCall > m_TextCalls
List of TextCalls, for instance "Hello", "there!".
void AddObjectType(const CStr &str, ConstructObjectFunction pFunc)
The GUI needs to have all object types inputted and their constructors.
CRect m_TexturePlacementInFile
CStr8 GetNamedItem(const int AttributeName) const
void ChooseMouseOverAndClosest(IGUIObject *&pObject)
Inputs a reference pointer, checks if the new inputted object if hovered, if so, then check if this's...
int m_InternalNameNumber
Number of object that has been given name automatically.
std::string GetElementString(const int ID) const
std::map< CStr, SGUIIcon > m_Icons
Made to represent screen positions and delta values.
InReaction SendEvent(EGUIMessageType type, const CStr &EventName)
Send event to this GUI object (HandleMessage and ScriptEvent)
void Xeromyces_ReadColor(XMBElement Element, CXeromyces *pFile)
Reads in the element <color> (the XMBElement) and stores the result in m_PreDefinedColors.
double m_LastClickTime[6]
std::map< CStr, IGUIObject * > map_pObjects
A CGUISprite is actually a collage of several real sprites, this struct represents is such real sprit...
virtual void Draw()=0
Draws the object.
The GUI sprite, is actually several real sprites (images) like a collage.
IGUIObject * m_BaseObject
Base Object, all its children are considered parentless because this is not a real object per se...
void Xeromyces_ReadStyle(XMBElement Element, CXeromyces *pFile)
Reads in the element <style> (the XMBElement) and stores the result in m_Styles.
map_pObjects m_pAllObjects
Just pointers for fast name access, each object is really constructed within its parent for easy recu...
void SetupSpriteCall(const bool Left, SGUIText::SSpriteCall &SpriteCall, const float width, const float y, const CSize &Size, const CStr &TextureName, const float BufferZone, const int CellID)
Wrapper class for OS paths used by the game.
void Initialize()
Initializes the GUI, needs to be called before the GUI is used.
XMBElement GetRoot() const
PSRETURN Load(const PIVFS &vfs, const VfsPath &filename)
Returns either PSRETURN_OK or PSRETURN_CVFSFile_LoadFailed.
void UpdateResolution()
Update Resolution, should be called every time the resolution of the OpenGL screen has been changed...
void UpdateMouseOver(IGUIObject *const &pMouseOver)
Inputes the object that is currently hovered, this function updates this object accordingly (i...
void DrawText(SGUIText &Text, const CColor &DefaultColor, const CPos &pos, const float &z, const CRect &clipping)
Draw a SGUIText object.
PSRETURN SetSetting(const CStr &Setting, const CStrW &Value, const bool &SkipMessage=false)
Set a setting by string, regardless of what type it is.
void LoadXmlFile(const VfsPath &Filename, boost::unordered_set< VfsPath > &Paths)
Load a GUI XML file into the GUI.
void Xeromyces_ReadEffects(XMBElement Element, CXeromyces *pFile, SGUIImageEffects &effects)
Reads in the element <effect> (the XMBElement) and stores the result within the SGUIImageEffects.
static PSRETURN SetSetting(IGUIObject *pObject, const CStr &Setting, const T &Value, const bool &SkipMessage=false)
Sets a value by name using a real datatype as input.
void AddObject(IGUIObject *pObject)
Adds an object to the GUI's object database Private, since you can only add objects through XML files...
void Xeromyces_ReadSprite(XMBElement Element, CXeromyces *pFile)
Reads in the element <sprite> (the XMBElement) and stores the result in a new CGUISprite.
std::list< SGUIText::SSpriteCall > m_SpriteCalls
std::map< CStr, SGUIScrollBarStyle > m_ScrollBarStyles
bool m_NewLine
If the word inputted was a new line.
void SendEventToAll(const CStr &EventName)
Sends a specified script event to every object.
#define debug_warn(expr)
display the error dialog with the given text.
void AddToPointersMap(map_pObjects &ObjectMap)
Adds object and its children to the map, it's name being the first part, and the second being itself...
void Draw(CRect Size, int CellID, std::map< CStr, CGUISprite > &Sprites, float Z) const
bool m_MouseHovering
This is an array of true or false, each element is associated with a string representing a setting...
int GetAttributeID(const char *Name) const
const double SELECT_DBLCLICK_RATE
void Xeromyces_ReadIcon(XMBElement Element, CXeromyces *pFile)
Reads in the element <icon> (the XMBElement) and stores the result in m_Icons.
std::string GetAttributeString(const int ID) const
static void RecurseObject(int RR, IGUIObject *pObject, void_Object_pFunction_argT pFunc, const T &Argument)
If you want to call a IGUIObject-function on not just an object, but also on ALL of their children yo...
Message send to IGUIObject::HandleMessage() in order to give life to Objects manually with a derived ...
XMBElement Item(const int id)
void Xeromyces_ReadTooltip(XMBElement Element, CXeromyces *pFile)
Reads in the element <tooltip> (the XMBElement) and stores the result as an object with the name __to...
std::map< CStr, ConstructObjectFunction > m_ObjectTypes
Function pointers to functions that constructs IGUIObjects by name...
IGUIObject * FindObjectByName(const CStr &Name) const
Returns the GUI object with the desired name, or NULL if no match is found,.
std::list< SSpriteCall > m_SpriteCalls
List of sprites, or "icons" that should be rendered along with the text.
virtual void HandleMessage(SGUIMessage &Message)
This function is called with different messages for instance when the mouse enters the object...
void LoadStyle(CGUI &GUIinstance, const CStr &StyleName)
Loads a style.
CGUISpriteInstance m_Sprite
Sprite from global GUI sprite database.
Contains a list of values for new defaults to objects.
String class, substitute for CStr, but that parses the tags and builds up a list of all text that wil...
CClientArea m_TextureSize
SGUIText GenerateText(const CGUIString &Text, const CStrW &Font, const float &Width, const float &BufferZone, const IGUIObject *pObject=NULL)
Generate a SGUIText object from the inputted string.
void Xeromyces_ReadRepeat(XMBElement Element, CXeromyces *pFile, IGUIObject *pParent, boost::unordered_set< VfsPath > &Paths)
Reads in the element <repeat>, which repeats its child <object>s 'count' times, replacing the string "[n...
GLint m_WrapMode
Texture wrapping mode (GL_REPEAT, GL_CLAMP_TO_EDGE, etc)
InReaction HandleEvent(const SDL_Event_ *ev)
The replacement of Process(), handles an SDL_Event_.
void SetFocusedObject(IGUIObject *pObject)
Change focus to new object.
std::map< int32_t, bool > g_keys
g_keys: Key states, indexed by SDLK* constants.
SGUIIcon GetIcon(const CStr &str) const
Get Icon (a copy, can never be changed)
An SGUIText object is a parsed string, divided into text-rendering components.
void Draw()
Displays the whole GUI.
Rectangle class used for screen rectangles.
Client Area is a rectangle relative to a parent rectangle.