| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- /*
- * Copyright (C) 2022 The V-Gears Team
- *
- * This file is part of V-Gears
- *
- * V-Gears is free software: you can redistribute it and/or modify it under
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, version 3.0 (GPLv3) of the License.
- *
- * V-Gears 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.
- */
- #pragma once
- #include <OgreColourValue.h>
- #include <OgreMatrix4.h>
- #include <OgreString.h>
- #include <OgreStringVector.h>
- #include <Ogre.h>
- #include <Overlay/OgreUTFString.h>
- #include <OIS/OIS.h>
- #include <tinyxml.h>
- // TODO: All the methods defined here that refer to XML files are implemented
- // as methods of XmlFile. Can they be deleted from here?
- /**
- * Retrieves a boolean from an XMl tag.
- *
- * @param node[in] The XML node.
- * @param tag[in] The name of the tag.
- * @param def[in] Default value, in case the tag is not found or it's not a
- * boolean value.
- * @return Boolean value of the tag. If it's not found or it's not a boolean,
- * def is returned.
- */
- bool GetBool(TiXmlNode* node, const Ogre::String& tag, bool def = false);
- /**
- * Retrieves an integer from an XMl tag.
- *
- * @param node[in] The XML node.
- * @param tag[in] The name of the tag.
- * @param def[in] Default value, in case the tag is not found or it's not a
- * numeric value.
- * @return Integer value of the tag. If it's not found or it's not a number,
- * def is returned.
- */
- int GetInt(TiXmlNode* node, const Ogre::String& tag, int def = 0);
- /**
- * Retrieves a decimal from an XMl tag.
- *
- * @param node[in] The XML node.
- * @param tag[in] The name of the tag.
- * @param def[in] Default value, in case the tag is not found or it's not a
- * numeric value.
- * @return Floating value of the tag. If it's not found or it's not a number,
- * def is returned.
- */
- float GetFloat(TiXmlNode* node, const Ogre::String& tag, float def = 0.0f);
- /**
- * Retrieves a string from an XMl tag.
- *
- * @param node[in] The XML node.
- * @param tag[in] The name of the tag.
- * @param def[in] Default value, in case the tag is not found.
- * @return String value of the tag. If it's not found, def is returned.
- */
- const Ogre::String GetString(
- TiXmlNode* node, const Ogre::String& tag, const Ogre::String& def = ""
- );
- /**
- * Retrieves a string from an XMl tag.
- *
- * @param node[in] The XML node.
- * @param tag[in] The name of the tag.
- * @param def[in] Default value, in case the tag is not found.
- * @return String value of the tag, in UFT8. If not found, def is returned.
- */
- const Ogre::UTFString GetUTFString(
- TiXmlNode* node, const Ogre::String& tag, const Ogre::UTFString& def = ""
- );
- /**
- * Retrieves a 2-dimensional vector from an XMl tag.
- *
- * @param node[in] The XML node.
- * @param tag[in] The name of the tag.
- * @param def[in] Default value, in case the tag is not found.
- * @return Vector in the tag. If it's not found, def is returned.
- */
- const Ogre::Vector2 GetVector2(
- TiXmlNode* node, const Ogre::String& tag,
- const Ogre::Vector2& def = Ogre::Vector2::ZERO
- );
- /**
- * Retrieves a 3-dimensional vector from an XMl tag.
- *
- * @param node[in] The XML node.
- * @param tag[in] The name of the tag.
- * @param def[in] Default value, in case the tag is not found.
- * @return Vector in the tag. If it's not found, def is returned.
- */
- const Ogre::Vector3 GetVector3(
- TiXmlNode* node, const Ogre::String& tag,
- const Ogre::Vector3& def = Ogre::Vector3::ZERO
- );
- /**
- * Retrieves a 4-dimensional vector from an XMl tag.
- *
- * @param node[in] The XML node.
- * @param tag[in] The name of the tag.
- * @param def[in] Default value, in case the tag is not found.
- * @return Vector in the tag. If it's not found, def is returned.
- */
- const Ogre::Vector4 GetVector4(
- TiXmlNode* node, const Ogre::String& tag,
- const Ogre::Vector4& def = Ogre::Vector4::ZERO
- );
- /**
- * Retrieves a 4-dimensional matrix from an XMl tag.
- *
- * @param node[in] The XML node.
- * @param tag[in] The name of the tag.
- * @param def[in] Default value, in case the tag is not found.
- * @return Martix in the tag. If it's not found, def is returned.
- */
- const Ogre::Matrix4 GetMatrix4(
- TiXmlNode* node, const Ogre::String& tag,
- const Ogre::Matrix4& def = Ogre::Matrix4::IDENTITY
- );
- /**
- * Retrieves a quaternion from an XMl tag.
- *
- * @param node[in] The XML node.
- * @param tag[in] The name of the tag.
- * @param def[in] Default value, in case the tag is not found.
- * @return quaternion in the tag. If it's not found, def is returned.
- */
- const Ogre::Quaternion GetQuaternion(
- TiXmlNode* node, const Ogre::String& tag,
- const Ogre::Quaternion& def = Ogre::Quaternion::IDENTITY
- );
- /**
- * Retrieves a colour from an XMl tag.
- *
- * @param node[in] The XML node.
- * @param tag[in] The name of the tag.
- * @param def[in] Default value, in case the tag is not found.
- * @return Colour in the tag. If it's not found, def is returned.
- */
- const Ogre::ColourValue GetColourValue(
- TiXmlNode* node, const Ogre::String& tag,
- const Ogre::ColourValue& def = Ogre::ColourValue::ZERO
- );
- /**
- * Parses percentage strings
- *
- * Accepts strings in the formats "A" "A%" "A%B", where A and B are real
- * values.
- *
- * @param value_percent[out] Percent value
- * @param value[out] String numeric value.
- * @param string[in] Input string.
- * @example "80.4%" -> value = 0, percent_value = 80.4
- * @example "80.4%20.6" -> value = 20.6, percent_value = 80.4
- * @example "80.4" -> value = 80.4, percent_value = 0
- *
- */
- void ParsePercent(
- float& value_percent, float& value, const Ogre::String& string
- );
- /**
- * Parses a keyframe time string.
- *
- * It acceps input string of numeric values and numeric values followed by a
- * percentage sign
- *
- * @param length[in] Keyframe duration, used only for percentages.
- * @param string[in] Input string
- * @return Keyframe time.
- * @example "7.2" -> 7.2
- * @example "7.2%" -> length * 7.2
- */
- float ParseKeyFrameTime(const float length, const Ogre::String& string);
- /**
- * Creates a name.
- *
- * @prefix[in] Name prefix.
- * @return PREFIX + "0".
- * @todo This seems so simple, am I missing something?
- */
- const Ogre::String CreateAutoName(const Ogre::String prefix);
- /**
- * Obtains a name from a key code.
- *
- * @param key[in] Key code.
- * @return Human readable name assigned to the key code. "UNASSIGNED" if there
- * is no name for the key code.
- */
- Ogre::String KeyToString(OIS::KeyCode key);
- /**
- * Obtains a key code from a name.
- *
- * @param str[in] Key name.
- * @return Key code assigned to the name. OIS::KC_UNASSIGNED if there is no
- * keycode with the specified name.
- */
- OIS::KeyCode StringToKey(const Ogre::String& str);
- /**
- * Tokenizes a string.
- *
- * @param str[in] Input string.
- * @param delimiters[in] Token delimiters. They will be stripped from the
- * string.
- * @param delimiters_preserve[in] More token delimiters. They will be returned
- * as individual tokens.
- * @param quote[in] @todo Understand and document.
- * @param esc[in] Accepted escape characters. Escaped characters won't be
- * considered delimiters of any kind.
- * @return Tokens of the original string.
- */
- Ogre::StringVector StringTokenise(
- const Ogre::String& str, const Ogre::String& delimiters = "\t\n ",
- const Ogre::String& delimiters_preserve = "",
- const Ogre::String& quote = "\"", const Ogre::String& esc = "\\"
- );
|