Merge branch 'remove-short-string-hash'

Conflicts:
	Source/Engine/Script/CoreAPI.cpp
This commit is contained in:
aster 2014-06-30 10:59:49 +08:00
Родитель 413aa66b10 2f29b3a5c0
Коммит f9e555c19d
80 изменённых файлов: 1003 добавлений и 1331 удалений

Просмотреть файл

@ -10,7 +10,7 @@ local numSprites = 100
local sprites = {}
-- Custom variable identifier for storing sprite velocity within the UI element
local VAR_VELOCITY = ShortStringHash("Velocity")
local VAR_VELOCITY = StringHash("Velocity")
function Start()
-- Execute the common startup for samples

Просмотреть файл

@ -40,7 +40,7 @@ function CreateUI()
for i, v in ipairs(soundNames) do
local button = CreateButton((i - 1) * 140 + 20, 20, 120, 40, v)
-- Store the sound effect resource name as a custom variable into the button
button:SetVar(ShortStringHash("SoundResource"), Variant(soundResourceNames[i]))
button:SetVar(StringHash("SoundResource"), Variant(soundResourceNames[i]))
SubscribeToEvent(button, "Pressed", "HandlePlaySound")
end
@ -99,7 +99,7 @@ end
function HandlePlaySound(sender, eventType, eventData)
local button = tolua.cast(GetEventSender(), "Button")
local soundResourceName = button:GetVar(ShortStringHash("SoundResource")):GetString()
local soundResourceName = button:GetVar(StringHash("SoundResource")):GetString()
-- Get the sound resource
local sound = cache:GetResource("Sound", soundResourceName)

Просмотреть файл

@ -5,7 +5,7 @@
// - bool PreEditAttribute(Array<Serializable@>@ serializables, uint index);
// - void PostEditAttribute(Array<Serializable@>@ serializables, uint index, const Array<Variant>& oldValues);
// - Array<Serializable@>@ GetAttributeEditorTargets(UIElement@ attrEdit);
// - String GetVariableName(ShortStringHash hash);
// - String GetVariableName(StringHash hash);
const uint MIN_NODE_ATTRIBUTES = 4;
const uint MAX_NODE_ATTRIBUTES = 8;
@ -229,7 +229,7 @@ UIElement@ CreateIntAttributeEditor(ListView@ list, Array<Serializable@>@ serial
UIElement@ CreateResourceRefAttributeEditor(ListView@ list, Array<Serializable@>@ serializables, const AttributeInfo&in info, uint index, uint subIndex, bool suppressedSeparatedLabel = false)
{
UIElement@ parent;
ShortStringHash resourceType;
StringHash resourceType;
// Get the real attribute info from the serializable for the correct resource type
AttributeInfo attrInfo = serializables[0].attributeInfos[index];
@ -350,7 +350,7 @@ UIElement@ CreateAttributeEditor(ListView@ list, Array<Serializable@>@ serializa
else if (type == VAR_VARIANTMAP)
{
VariantMap map = serializables[0].attributes[index].GetVariantMap();
Array<ShortStringHash>@ keys = map.keys;
Array<StringHash>@ keys = map.keys;
for (uint i = 0; i < keys.length; ++i)
{
String varName = GetVariableName(keys[i]);
@ -552,7 +552,7 @@ void LoadAttributeEditor(UIElement@ parent, const Variant&in value, const Attrib
{
UIElement@ list = parent.parent;
VariantMap map = value.GetVariantMap();
Array<ShortStringHash>@ keys = map.keys;
Array<StringHash>@ keys = map.keys;
for (uint subIndex = 0; subIndex < keys.length; ++subIndex)
{
parent = GetAttributeEditorParent(list, index, subIndex);
@ -653,7 +653,7 @@ void StoreAttributeEditor(UIElement@ parent, Array<Serializable@>@ serializables
else if (info.type == VAR_VARIANTMAP)
{
VariantMap map = serializables[0].attributes[index].GetVariantMap();
ShortStringHash key(parent.vars["Key"].GetUInt());
StringHash key(parent.vars["Key"].GetUInt());
for (uint i = 0; i < serializables.length; ++i)
{
VariantMap map = serializables[i].attributes[index].GetVariantMap();
@ -726,7 +726,7 @@ void GetEditorValue(UIElement@ parent, VariantType type, Array<String>@ enumName
LineEdit@ attrEdit = parent.children[0];
ResourceRef ref;
ref.name = attrEdit.text.Trimmed();
ref.type = ShortStringHash(attrEdit.vars[TYPE_VAR].GetUInt());
ref.type = StringHash(attrEdit.vars[TYPE_VAR].GetUInt());
FillValue(values, Variant(ref));
}
else
@ -841,7 +841,7 @@ const uint ACTION_TEST = 8;
class ResourcePicker
{
String typeName;
ShortStringHash type;
StringHash type;
String lastPath;
uint lastFilter;
Array<String> filters;
@ -850,7 +850,7 @@ class ResourcePicker
ResourcePicker(const String&in typeName_, const String&in filter_, uint actions_ = ACTION_PICK | ACTION_OPEN)
{
typeName = typeName_;
type = ShortStringHash(typeName_);
type = StringHash(typeName_);
actions = actions_;
filters.Push(filter_);
filters.Push("*.*");
@ -860,7 +860,7 @@ class ResourcePicker
ResourcePicker(const String&in typeName_, const Array<String>@ filters_, uint actions_ = ACTION_PICK | ACTION_OPEN)
{
typeName = typeName_;
type = ShortStringHash(typeName_);
type = StringHash(typeName_);
filters = filters_;
actions = actions_;
filters.Push("*.*");
@ -904,7 +904,7 @@ void InitResourcePicker()
resourcePickers.Push(ResourcePicker("ParticleEffect2D", pexFilters, ACTION_PICK | ACTION_OPEN));
}
ResourcePicker@ GetResourcePicker(ShortStringHash resourceType)
ResourcePicker@ GetResourcePicker(StringHash resourceType)
{
for (uint i = 0; i < resourcePickers.length; ++i)
{
@ -927,7 +927,7 @@ void PickResource(StringHash eventType, VariantMap& eventData)
resourcePickSubIndex = attrEdit.vars["SubIndex"].GetUInt();
AttributeInfo info = targets[0].attributeInfos[resourcePickIndex];
ShortStringHash resourceType;
StringHash resourceType;
if (info.type == VAR_RESOURCEREF)
resourceType = targets[0].attributes[resourcePickIndex].GetResourceRef().type;
else if (info.type == VAR_RESOURCEREFLIST)
@ -1091,7 +1091,7 @@ void EditResource(StringHash eventType, VariantMap& eventData)
if (fileName.empty)
return;
ShortStringHash resourceType(attrEdit.vars[TYPE_VAR].GetUInt());
StringHash resourceType(attrEdit.vars[TYPE_VAR].GetUInt());
Resource@ resource = cache.GetResource(resourceType, fileName);
if (resource !is null)
@ -1107,10 +1107,10 @@ void TestResource(StringHash eventType, VariantMap& eventData)
UIElement@ button = eventData["Element"].GetPtr();
LineEdit@ attrEdit = button.parent.children[0];
ShortStringHash resourceType(attrEdit.vars[TYPE_VAR].GetUInt());
StringHash resourceType(attrEdit.vars[TYPE_VAR].GetUInt());
// For now only Animations can be tested
ShortStringHash animType("Animation");
StringHash animType("Animation");
if (resourceType == animType)
TestAnimation(attrEdit);
}

Просмотреть файл

@ -362,7 +362,7 @@ class ResetAttributesAction : EditAction
{
// Special handling for UIElement to preserve the internal variables containing the element's generated ID among others
UIElement@ element = target;
Array<ShortStringHash> keys = element.vars.keys;
Array<StringHash> keys = element.vars.keys;
for (uint i = 0; i < keys.length; ++i)
{
// If variable name is empty (or unregistered) then it is an internal variable and should be preserved
@ -391,7 +391,7 @@ class ResetAttributesAction : EditAction
void SetInternalVars(UIElement@ element)
{
// Revert back internal variables
Array<ShortStringHash> keys = internalVars.keys;
Array<StringHash> keys = internalVars.keys;
for (uint i = 0; i < keys.length; ++i)
element.vars[keys[i]] = internalVars[keys[i]];

Просмотреть файл

@ -5,20 +5,20 @@ const int ITEM_NODE = 1;
const int ITEM_COMPONENT = 2;
const int ITEM_UI_ELEMENT = 3;
const uint NO_ITEM = M_MAX_UNSIGNED;
const ShortStringHash SCENE_TYPE("Scene");
const ShortStringHash NODE_TYPE("Node");
const ShortStringHash STATICMODEL_TYPE("StaticModel");
const ShortStringHash ANIMATEDMODEL_TYPE("AnimatedModel");
const ShortStringHash STATICMODELGROUP_TYPE("StaticModelGroup");
const ShortStringHash SPLINEPATH_TYPE("SplinePath");
const ShortStringHash CONSTRAINT_TYPE("Constraint");
const StringHash SCENE_TYPE("Scene");
const StringHash NODE_TYPE("Node");
const StringHash STATICMODEL_TYPE("StaticModel");
const StringHash ANIMATEDMODEL_TYPE("AnimatedModel");
const StringHash STATICMODELGROUP_TYPE("StaticModelGroup");
const StringHash SPLINEPATH_TYPE("SplinePath");
const StringHash CONSTRAINT_TYPE("Constraint");
const String NO_CHANGE(uint8(0));
const ShortStringHash TYPE_VAR("Type");
const ShortStringHash NODE_ID_VAR("NodeID");
const ShortStringHash COMPONENT_ID_VAR("ComponentID");
const ShortStringHash UI_ELEMENT_ID_VAR("UIElementID");
const ShortStringHash DRAGDROPCONTENT_VAR("DragDropContent");
const ShortStringHash[] ID_VARS = { ShortStringHash(""), NODE_ID_VAR, COMPONENT_ID_VAR, UI_ELEMENT_ID_VAR };
const StringHash TYPE_VAR("Type");
const StringHash NODE_ID_VAR("NodeID");
const StringHash COMPONENT_ID_VAR("ComponentID");
const StringHash UI_ELEMENT_ID_VAR("UIElementID");
const StringHash DRAGDROPCONTENT_VAR("DragDropContent");
const StringHash[] ID_VARS = { StringHash(""), NODE_ID_VAR, COMPONENT_ID_VAR, UI_ELEMENT_ID_VAR };
Color nodeTextColor(1.0f, 1.0f, 1.0f);
Color componentTextColor(0.7f, 1.0f, 0.7f);
@ -664,7 +664,7 @@ void HandleHierarchyListSelectionChange()
{
if (editNode is null)
{
ShortStringHash compType = selectedComponents[0].type;
StringHash compType = selectedComponents[0].type;
bool sameType = true;
for (uint i = 1; i < selectedComponents.length; ++i)
{
@ -690,7 +690,7 @@ void HandleHierarchyListSelectionChange()
uint count = 0;
for (uint j = 0; j < selectedNodes[0].numComponents; ++j)
{
ShortStringHash compType = selectedNodes[0].components[j].type;
StringHash compType = selectedNodes[0].components[j].type;
bool sameType = true;
for (uint i = 1; i < selectedNodes.length; ++i)
{
@ -1166,19 +1166,19 @@ bool TestDragDrop(UIElement@ source, UIElement@ target, int& itemType)
LineEdit@ lineEdit = cast<LineEdit>(target);
if (lineEdit !is null)
{
ShortStringHash resourceType = GetResourceTypeFromPickerLineEdit(lineEdit);
if (resourceType == ShortStringHash("Material") && type == RESOURCE_TYPE_MATERIAL)
StringHash resourceType = GetResourceTypeFromPickerLineEdit(lineEdit);
if (resourceType == StringHash("Material") && type == RESOURCE_TYPE_MATERIAL)
return true;
else if (resourceType == ShortStringHash("Model") && type == RESOURCE_TYPE_MODEL)
else if (resourceType == StringHash("Model") && type == RESOURCE_TYPE_MODEL)
return true;
else if (resourceType == ShortStringHash("Animation") && type == RESOURCE_TYPE_ANIMATION)
else if (resourceType == StringHash("Animation") && type == RESOURCE_TYPE_ANIMATION)
return true;
}
}
return true;
}
ShortStringHash GetResourceTypeFromPickerLineEdit(UIElement@ lineEdit)
StringHash GetResourceTypeFromPickerLineEdit(UIElement@ lineEdit)
{
Array<Serializable@>@ targets = GetAttributeEditorTargets(lineEdit);
if (!targets.empty)
@ -1186,7 +1186,7 @@ ShortStringHash GetResourceTypeFromPickerLineEdit(UIElement@ lineEdit)
resourcePickIndex = lineEdit.vars["Index"].GetUInt();
resourcePickSubIndex = lineEdit.vars["SubIndex"].GetUInt();
AttributeInfo info = targets[0].attributeInfos[resourcePickIndex];
ShortStringHash resourceType;
StringHash resourceType;
if (info.type == VAR_RESOURCEREF)
return targets[0].attributes[resourcePickIndex].GetResourceRef().type;
else if (info.type == VAR_RESOURCEREFLIST)
@ -1194,7 +1194,7 @@ ShortStringHash GetResourceTypeFromPickerLineEdit(UIElement@ lineEdit)
else if (info.type == VAR_VARIANTVECTOR)
return targets[0].attributes[resourcePickIndex].GetVariantVector()[resourcePickSubIndex].GetResourceRef().type;
}
return ShortStringHash();
return StringHash();
}
void FocusNode(Node@ node)

Просмотреть файл

@ -9,9 +9,9 @@ bool attributesDirty = false;
bool attributesFullDirty = false;
const String STRIKED_OUT = "——"; // Two unicode EM DASH (U+2014)
const ShortStringHash NODE_IDS_VAR("NodeIDs");
const ShortStringHash COMPONENT_IDS_VAR("ComponentIDs");
const ShortStringHash UI_ELEMENT_IDS_VAR("UIElementIDs");
const StringHash NODE_IDS_VAR("NodeIDs");
const StringHash COMPONENT_IDS_VAR("ComponentIDs");
const StringHash UI_ELEMENT_IDS_VAR("UIElementIDs");
const int LABEL_WIDTH = 30;
// Constants for accessing xmlResources
@ -695,8 +695,8 @@ Variant ExtractVariantType(VariantMap& eventData)
return Variant(); // This should not happen
}
/// Get back the human-readable variable name from the ShortStringHash.
String GetVariableName(ShortStringHash hash)
/// Get back the human-readable variable name from the StringHash.
String GetVariableName(StringHash hash)
{
// First try to get it from scene
String name = editorScene.GetVarName(hash);

Просмотреть файл

@ -351,7 +351,7 @@ void EditMaterialName(StringHash eventType, VariantMap& eventData)
void PickEditMaterial()
{
@resourcePicker = GetResourcePicker(ShortStringHash("Material"));
@resourcePicker = GetResourcePicker(StringHash("Material"));
if (resourcePicker is null)
return;
@ -417,7 +417,7 @@ void SaveMaterialAs()
if (editMaterial is null)
return;
@resourcePicker = GetResourcePicker(ShortStringHash("Material"));
@resourcePicker = GetResourcePicker(StringHash("Material"));
if (resourcePicker is null)
return;
@ -552,7 +552,7 @@ void PickMaterialTexture(StringHash eventType, VariantMap& eventData)
UIElement@ button = eventData["Element"].GetPtr();
resourcePickIndex = button.vars["Index"].GetUInt();
@resourcePicker = GetResourcePicker(ShortStringHash("Texture2D"));
@resourcePicker = GetResourcePicker(StringHash("Texture2D"));
if (resourcePicker is null)
return;
@ -646,7 +646,7 @@ void PickMaterialTechnique(StringHash eventType, VariantMap& eventData)
UIElement@ button = eventData["Element"].GetPtr();
resourcePickIndex = button.vars["Index"].GetUInt();
@resourcePicker = GetResourcePicker(ShortStringHash("Technique"));
@resourcePicker = GetResourcePicker(StringHash("Technique"));
if (resourcePicker is null)
return;

Просмотреть файл

@ -50,53 +50,53 @@ const int RESOURCE_TYPE_2D_PARTICLE_EFFECT = 18;
const int RESOURCE_TYPE_TEXTURE_3D = 19;
const int RESOURCE_TYPE_CUBEMAP = 20;
const ShortStringHash XML_TYPE_SCENE("scene");
const ShortStringHash XML_TYPE_NODE("node");
const ShortStringHash XML_TYPE_MATERIAL("material");
const ShortStringHash XML_TYPE_TECHNIQUE("technique");
const ShortStringHash XML_TYPE_PARTICLEEFFECT("particleeffect");
const ShortStringHash XML_TYPE_TEXTURE("texture");
const ShortStringHash XML_TYPE_ELEMENT("element");
const ShortStringHash XML_TYPE_ELEMENTS("elements");
const ShortStringHash XML_TYPE_ANIMATION_SETTINGS("animation");
const ShortStringHash XML_TYPE_RENDERPATH("renderpath");
const ShortStringHash XML_TYPE_TEXTURE_ATLAS("TextureAtlas");
const ShortStringHash XML_TYPE_2D_PARTICLE_EFFECT("particleEmitterConfig");
const ShortStringHash XML_TYPE_TEXTURE_3D("texture3d");
const ShortStringHash XML_TYPE_CUBEMAP("cubemap");
const StringHash XML_TYPE_SCENE("scene");
const StringHash XML_TYPE_NODE("node");
const StringHash XML_TYPE_MATERIAL("material");
const StringHash XML_TYPE_TECHNIQUE("technique");
const StringHash XML_TYPE_PARTICLEEFFECT("particleeffect");
const StringHash XML_TYPE_TEXTURE("texture");
const StringHash XML_TYPE_ELEMENT("element");
const StringHash XML_TYPE_ELEMENTS("elements");
const StringHash XML_TYPE_ANIMATION_SETTINGS("animation");
const StringHash XML_TYPE_RENDERPATH("renderpath");
const StringHash XML_TYPE_TEXTURE_ATLAS("TextureAtlas");
const StringHash XML_TYPE_2D_PARTICLE_EFFECT("particleEmitterConfig");
const StringHash XML_TYPE_TEXTURE_3D("texture3d");
const StringHash XML_TYPE_CUBEMAP("cubemap");
const ShortStringHash BINARY_TYPE_SCENE("USCN");
const ShortStringHash BINARY_TYPE_PACKAGE("UPAK");
const ShortStringHash BINARY_TYPE_COMPRESSED_PACKAGE("ULZ4");
const ShortStringHash BINARY_TYPE_ANGLESCRIPT("ASBC");
const ShortStringHash BINARY_TYPE_MODEL("UMDL");
const ShortStringHash BINARY_TYPE_SHADER("USHD");
const ShortStringHash BINARY_TYPE_ANIMATION("UANI");
const StringHash BINARY_TYPE_SCENE("USCN");
const StringHash BINARY_TYPE_PACKAGE("UPAK");
const StringHash BINARY_TYPE_COMPRESSED_PACKAGE("ULZ4");
const StringHash BINARY_TYPE_ANGLESCRIPT("ASBC");
const StringHash BINARY_TYPE_MODEL("UMDL");
const StringHash BINARY_TYPE_SHADER("USHD");
const StringHash BINARY_TYPE_ANIMATION("UANI");
const ShortStringHash EXTENSION_TYPE_TTF(".ttf");
const ShortStringHash EXTENSION_TYPE_OGG(".ogg");
const ShortStringHash EXTENSION_TYPE_WAV(".wav");
const ShortStringHash EXTENSION_TYPE_DDS(".dds");
const ShortStringHash EXTENSION_TYPE_PNG(".png");
const ShortStringHash EXTENSION_TYPE_JPG(".jpg");
const ShortStringHash EXTENSION_TYPE_JPEG(".jpeg");
const ShortStringHash EXTENSION_TYPE_TGA(".tga");
const ShortStringHash EXTENSION_TYPE_OBJ(".obj");
const ShortStringHash EXTENSION_TYPE_FBX(".fbx");
const ShortStringHash EXTENSION_TYPE_COLLADA(".dae");
const ShortStringHash EXTENSION_TYPE_BLEND(".blend");
const ShortStringHash EXTENSION_TYPE_ANGELSCRIPT(".as");
const ShortStringHash EXTENSION_TYPE_LUASCRIPT(".lua");
const ShortStringHash EXTENSION_TYPE_HLSL(".hlsl");
const ShortStringHash EXTENSION_TYPE_GLSL(".glsl");
const ShortStringHash EXTENSION_TYPE_FRAGMENTSHADER(".frag");
const ShortStringHash EXTENSION_TYPE_VERTEXSHADER(".vert");
const ShortStringHash EXTENSION_TYPE_HTML(".html");
const StringHash EXTENSION_TYPE_TTF(".ttf");
const StringHash EXTENSION_TYPE_OGG(".ogg");
const StringHash EXTENSION_TYPE_WAV(".wav");
const StringHash EXTENSION_TYPE_DDS(".dds");
const StringHash EXTENSION_TYPE_PNG(".png");
const StringHash EXTENSION_TYPE_JPG(".jpg");
const StringHash EXTENSION_TYPE_JPEG(".jpeg");
const StringHash EXTENSION_TYPE_TGA(".tga");
const StringHash EXTENSION_TYPE_OBJ(".obj");
const StringHash EXTENSION_TYPE_FBX(".fbx");
const StringHash EXTENSION_TYPE_COLLADA(".dae");
const StringHash EXTENSION_TYPE_BLEND(".blend");
const StringHash EXTENSION_TYPE_ANGELSCRIPT(".as");
const StringHash EXTENSION_TYPE_LUASCRIPT(".lua");
const StringHash EXTENSION_TYPE_HLSL(".hlsl");
const StringHash EXTENSION_TYPE_GLSL(".glsl");
const StringHash EXTENSION_TYPE_FRAGMENTSHADER(".frag");
const StringHash EXTENSION_TYPE_VERTEXSHADER(".vert");
const StringHash EXTENSION_TYPE_HTML(".html");
const ShortStringHash TEXT_VAR_FILE_ID("browser_file_id");
const ShortStringHash TEXT_VAR_DIR_ID("browser_dir_id");
const ShortStringHash TEXT_VAR_RESOURCE_TYPE("resource_type");
const ShortStringHash TEXT_VAR_RESOURCE_DIR_ID("resource_dir_id");
const StringHash TEXT_VAR_FILE_ID("browser_file_id");
const StringHash TEXT_VAR_DIR_ID("browser_dir_id");
const StringHash TEXT_VAR_RESOURCE_TYPE("resource_type");
const StringHash TEXT_VAR_RESOURCE_DIR_ID("resource_dir_id");
const int BROWSER_FILE_SOURCE_RESOURCE_DIR = 1;
@ -982,11 +982,11 @@ Menu@ CreateBrowserFileActionMenu(String text, String handler, BrowserFile@ brow
int GetResourceType(String path)
{
ShortStringHash fileType;
StringHash fileType;
return GetResourceType(path, fileType);
}
int GetResourceType(String path, ShortStringHash &out fileType, bool useCache = false)
int GetResourceType(String path, StringHash &out fileType, bool useCache = false)
{
if (GetExtensionType(path, fileType) || GetBinaryType(path, fileType, useCache) || GetXmlType(path, fileType, useCache))
return GetResourceType(fileType);
@ -995,7 +995,7 @@ int GetResourceType(String path, ShortStringHash &out fileType, bool useCache =
}
int GetResourceType(ShortStringHash fileType)
int GetResourceType(StringHash fileType)
{
// binary fileTypes
if (fileType == BINARY_TYPE_SCENE)
@ -1086,9 +1086,9 @@ int GetResourceType(ShortStringHash fileType)
return RESOURCE_TYPE_UNKNOWN;
}
bool GetExtensionType(String path, ShortStringHash &out fileType)
bool GetExtensionType(String path, StringHash &out fileType)
{
ShortStringHash type = ShortStringHash(GetExtension(path));
StringHash type = StringHash(GetExtension(path));
if (type == EXTENSION_TYPE_TTF)
fileType = EXTENSION_TYPE_TTF;
else if (type == EXTENSION_TYPE_OGG)
@ -1133,9 +1133,9 @@ bool GetExtensionType(String path, ShortStringHash &out fileType)
return true;
}
bool GetBinaryType(String path, ShortStringHash &out fileType, bool useCache = false)
bool GetBinaryType(String path, StringHash &out fileType, bool useCache = false)
{
ShortStringHash type;
StringHash type;
if (useCache)
{
File@ file = cache.GetFile(path);
@ -1145,7 +1145,7 @@ bool GetBinaryType(String path, ShortStringHash &out fileType, bool useCache = f
if (file.size == 0)
return false;
type = ShortStringHash(file.ReadFileID());
type = StringHash(file.ReadFileID());
}
else
{
@ -1156,7 +1156,7 @@ bool GetBinaryType(String path, ShortStringHash &out fileType, bool useCache = f
if (file.size == 0)
return false;
type = ShortStringHash(file.ReadFileID());
type = StringHash(file.ReadFileID());
}
if (type == BINARY_TYPE_SCENE)
@ -1179,7 +1179,7 @@ bool GetBinaryType(String path, ShortStringHash &out fileType, bool useCache = f
return true;
}
bool GetXmlType(String path, ShortStringHash &out fileType, bool useCache = false)
bool GetXmlType(String path, StringHash &out fileType, bool useCache = false)
{
String name;
if (useCache)
@ -1210,7 +1210,7 @@ bool GetXmlType(String path, ShortStringHash &out fileType, bool useCache = fals
if (!name.empty)
{
found = true;
ShortStringHash type = ShortStringHash(name);
StringHash type = StringHash(name);
if (type == XML_TYPE_SCENE)
fileType = XML_TYPE_SCENE;
else if (type == XML_TYPE_NODE)
@ -1337,7 +1337,7 @@ class BrowserFile
String name;
String fullname;
String extension;
ShortStringHash fileType;
StringHash fileType;
int resourceType = 0;
int sourceType = 0;
int sortScore = 0;

Просмотреть файл

@ -88,7 +88,7 @@ void HideSpawnEditor()
void PickSpawnObject()
{
@resourcePicker = GetResourcePicker(ShortStringHash("Node"));
@resourcePicker = GetResourcePicker(StringHash("Node"));
if (resourcePicker is null)
return;

Просмотреть файл

@ -3,7 +3,7 @@ bool subscribedToEditorToolBar = false;
bool toolBarDirty = true;
UIElement@ toolBar;
const ShortStringHash VIEW_MODE("VIEW_MODE");
const StringHash VIEW_MODE("VIEW_MODE");
void CreateToolBar()
{

Просмотреть файл

@ -11,18 +11,18 @@ FileSelector@ uiFileSelector;
String consoleCommandInterpreter;
Window@ contextMenu;
const ShortStringHash UI_ELEMENT_TYPE("UIElement");
const ShortStringHash WINDOW_TYPE("Window");
const ShortStringHash MENU_TYPE("Menu");
const ShortStringHash TEXT_TYPE("Text");
const ShortStringHash CURSOR_TYPE("Cursor");
const StringHash UI_ELEMENT_TYPE("UIElement");
const StringHash WINDOW_TYPE("Window");
const StringHash MENU_TYPE("Menu");
const StringHash TEXT_TYPE("Text");
const StringHash CURSOR_TYPE("Cursor");
const String AUTO_STYLE(""); // Empty string means auto style, i.e. applying style according to UI-element's type automatically
const String TEMP_SCENE_NAME("_tempscene_.xml");
const ShortStringHash CALLBACK_VAR("Callback");
const ShortStringHash INDENT_MODIFIED_BY_ICON_VAR("IconIndented");
const StringHash CALLBACK_VAR("Callback");
const StringHash INDENT_MODIFIED_BY_ICON_VAR("IconIndented");
const ShortStringHash VAR_CONTEXT_MENU_HANDLER("ContextMenuHandler");
const StringHash VAR_CONTEXT_MENU_HANDLER("ContextMenuHandler");
const int SHOW_POPUP_INDICATOR = -1;
const uint MAX_QUICK_MENU_ITEMS = 10;

Просмотреть файл

@ -15,9 +15,9 @@ bool suppressUIElementChanges = false;
// Registered UIElement user variable reverse mappings
VariantMap uiElementVarNames;
const ShortStringHash FILENAME_VAR("FileName");
const ShortStringHash MODIFIED_VAR("Modified");
const ShortStringHash CHILD_ELEMENT_FILENAME_VAR("ChildElemFileName");
const StringHash FILENAME_VAR("FileName");
const StringHash MODIFIED_VAR("Modified");
const StringHash CHILD_ELEMENT_FILENAME_VAR("ChildElemFileName");
void ClearUIElementSelection()
{

Просмотреть файл

@ -627,7 +627,7 @@ void SetViewportMode(uint mode = VIEWPORT_SINGLE)
void UpdateCameraPreview()
{
previewCamera = null;
ShortStringHash cameraType("Camera");
StringHash cameraType("Camera");
for (uint i = 0; i < selectedComponents.length; ++i)
{
@ -1394,8 +1394,8 @@ Ray GetActiveViewportCameraRay()
float(ui.cursorPosition.x - view.left) / view.width,
float(ui.cursorPosition.y - view.top) / view.height
);
}
}
void ViewMouseClickEnd()
{
// checks to close open popup windows

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -894,7 +894,7 @@ Methods:
- Scene* GetScene() const
- bool IsEnabled() const
- bool IsEnabledEffective() const
- Component* GetComponent(ShortStringHash type) const
- Component* GetComponent(StringHash type) const
- Component* GetComponent(const String type) const
### Connection : Object
@ -1319,7 +1319,7 @@ Methods:
- Object* GetEventSender() const
- EventHandler* GetEventHandler() const
- const String GetTypeName(ShortStringHash objectType) const
- const String GetTypeName(StringHash objectType) const
### Controls
@ -1509,7 +1509,6 @@ Methods:
- String ReadString()
- String ReadFileID()
- StringHash ReadStringHash()
- ShortStringHash ReadShortStringHash()
- VectorBuffer ReadBuffer()
- ResourceRef ReadResourceRef()
- ResourceRefList ReadResourceRefList()
@ -1732,7 +1731,6 @@ Methods:
- String ReadString()
- String ReadFileID()
- StringHash ReadStringHash()
- ShortStringHash ReadShortStringHash()
- VectorBuffer ReadBuffer()
- ResourceRef ReadResourceRef()
- ResourceRefList ReadResourceRefList()
@ -1769,7 +1767,6 @@ Methods:
- bool WriteString(const String value)
- bool WriteFileID(const String value)
- bool WriteStringHash(const StringHash& value)
- bool WriteShortStringHash(const ShortStringHash& value)
- bool WriteBuffer(const VectorBuffer& buffer)
- bool WriteResourceRef(const ResourceRef& value)
- bool WriteResourceRefList(const ResourceRefList& value)
@ -3062,14 +3059,14 @@ Methods:
- void RemoveAllChildren()
- void RemoveChildren(bool removeReplicated, bool removeLocal, bool recursive)
- void RemoveComponent(Component* component)
- void RemoveComponent(ShortStringHash type)
- void RemoveComponent(StringHash type)
- void RemoveComponent(const String type)
- void RemoveAllComponents()
- void RemoveComponents(bool removeReplicated, bool removeLocal)
- Node* Clone(CreateMode mode = REPLICATED)
- void Remove()
- void SetParent(Node* parent)
- void SetVar(ShortStringHash key, const Variant& value)
- void SetVar(StringHash key, const Variant& value)
- void AddListener(Component* component)
- void RemoveListener(Component* component)
- Component* CreateComponent(const String type, CreateMode mode = REPLICATED, unsigned id = 0)
@ -3119,9 +3116,9 @@ Methods:
- Node* GetChild(unsigned index) const
- unsigned GetNumComponents() const
- unsigned GetNumNetworkComponents() const
- bool HasComponent(ShortStringHash type) const
- bool HasComponent(StringHash type) const
- bool HasComponent(const String type) const
- const Variant& GetVar(ShortStringHash key) const
- const Variant& GetVar(StringHash key) const
- const VariantMap& GetVars() const
- Component* GetComponent(const String type) const
- void SetID(unsigned id)
@ -3169,16 +3166,16 @@ Properties:
Methods:
- ShortStringHash GetType() const
- ShortStringHash GetBaseType() const
- StringHash GetType() const
- StringHash GetBaseType() const
- const String GetTypeName() const
- const String GetCategory() const
- void SendEvent(const String eventName, VariantMap* eventData = 0)
Properties:
- ShortStringHash type (readonly)
- ShortStringHash baseType (readonly)
- StringHash type (readonly)
- StringHash baseType (readonly)
- const String typeName (readonly)
- const String category (readonly)
@ -3979,7 +3976,7 @@ Methods:
- void ReleaseAllResources(bool force = false)
- bool ReloadResource(Resource* resource)
- void SetMemoryBudget(ShortStringHash type, unsigned budget)
- void SetMemoryBudget(StringHash type, unsigned budget)
- void SetMemoryBudget(const String type, unsigned budget)
- void SetAutoReloadResources(bool enable)
- void SetReturnFailedResources(bool enable)
@ -3987,8 +3984,8 @@ Methods:
- File* GetFile(const String name)
- Resource* GetResource(const String type, const String name, bool SendEventOnFailure = true)
- bool Exists(const String name) const
- unsigned GetMemoryBudget(ShortStringHash type) const
- unsigned GetMemoryUse(ShortStringHash type) const
- unsigned GetMemoryBudget(StringHash type) const
- unsigned GetMemoryUse(StringHash type) const
- unsigned GetTotalMemoryUse() const
- String GetResourceFileName(const String name) const
- bool GetAutoReloadResources() const
@ -4012,10 +4009,10 @@ Methods:
- ResourceRef() (GC)
- ResourceRef* new()
- ResourceRef(ShortStringHash type) (GC)
- ResourceRef* new(ShortStringHash type)
- ResourceRef(ShortStringHash type, String name) (GC)
- ResourceRef* new(ShortStringHash type, String name)
- ResourceRef(StringHash type) (GC)
- ResourceRef* new(StringHash type)
- ResourceRef(StringHash type, String name) (GC)
- ResourceRef* new(StringHash type, String name)
- ResourceRef(const ResourceRef& rhs) (GC)
- ResourceRef* new(const ResourceRef& rhs)
- void delete()
@ -4023,7 +4020,7 @@ Methods:
Properties:
- ShortStringHash type
- StringHash type
- String name
### ResourceRefList
@ -4033,14 +4030,14 @@ Methods:
- ResourceRefList() (GC)
- ResourceRefList* new()
- ResourceRefList(ShortStringHash type) (GC)
- ResourceRefList* new(ShortStringHash type)
- ResourceRefList(StringHash type) (GC)
- ResourceRefList* new(StringHash type)
- void delete()
- bool operator==(const ResourceRefList& rhs) const
Properties:
- ShortStringHash type
- StringHash type
### RigidBody : Component
@ -4238,7 +4235,7 @@ Methods:
- float GetElapsedTime() const
- float GetSmoothingConstant() const
- float GetSnapThreshold() const
- const String GetVarName(ShortStringHash hash) const
- const String GetVarName(StringHash hash) const
- void Update(float timeStep)
- void BeginThreadedUpdate()
- void EndThreadedUpdate()
@ -4385,7 +4382,6 @@ Methods:
- bool WriteString(const String value)
- bool WriteFileID(const String value)
- bool WriteStringHash(const StringHash& value)
- bool WriteShortStringHash(const ShortStringHash& value)
- bool WriteBuffer(const VectorBuffer& buffer)
- bool WriteResourceRef(const ResourceRef& value)
- bool WriteResourceRefList(const ResourceRefList& value)
@ -4397,33 +4393,6 @@ Methods:
- bool WriteNetID(unsigned value)
- bool WriteLine(const String value)
### ShortStringHash
Methods:
- ShortStringHash() (GC)
- ShortStringHash* new()
- ShortStringHash(const ShortStringHash& rhs) (GC)
- ShortStringHash* new(const ShortStringHash& rhs)
- ShortStringHash(const StringHash& rhs) (GC)
- ShortStringHash* new(const StringHash& rhs)
- ShortStringHash(short value) (GC)
- ShortStringHash* new(short value)
- ShortStringHash(const String str) (GC)
- ShortStringHash* new(const String str)
- void delete()
- ShortStringHash operator+(const ShortStringHash& rhs) const
- bool operator==(const ShortStringHash& rhs) const
- bool operator<(const ShortStringHash& rhs) const
- short Value() const
- short Calculate(const char* str)
Properties:
- const ShortStringHash ZERO
- short value (readonly)
### Skeleton
@ -5340,7 +5309,7 @@ Methods:
- void Remove()
- unsigned FindChild(UIElement* element) const
- void SetParent(UIElement* parent, unsigned index = M_MAX_UNSIGNED)
- void SetVar(ShortStringHash key, const Variant& value)
- void SetVar(StringHash key, const Variant& value)
- void SetInternal(bool enable)
- void SetTraversalMode(TraversalMode traversalMode)
- void SetElementEventSender(bool flag)
@ -5392,7 +5361,7 @@ Methods:
- UIElement* GetParent() const
- UIElement* GetRoot() const
- const Color& GetDerivedColor() const
- const Variant& GetVar(ShortStringHash key) const
- const Variant& GetVar(StringHash key) const
- const VariantMap& GetVars() const
- IntVector2 ScreenToElement(const IntVector2& screenPosition)
- IntVector2 ElementToScreen(const IntVector2& position)
@ -5504,8 +5473,6 @@ Methods:
- Variant* new(unsigned value)
- Variant(const StringHash& value) (GC)
- Variant* new(const StringHash& value)
- Variant(const ShortStringHash& value) (GC)
- Variant* new(const ShortStringHash& value)
- Variant(bool value) (GC)
- Variant* new(bool value)
- Variant(float value) (GC)
@ -5564,14 +5531,12 @@ Methods:
- bool operator==(const IntRect& rhs) const
- bool operator==(const IntVector2& rhs) const
- bool operator==(const StringHash& rhs) const
- bool operator==(const ShortStringHash& rhs) const
- bool operator==(const Matrix3& rhs) const
- bool operator==(const Matrix3x4& rhs) const
- bool operator==(const Matrix4& rhs) const
- void SetInt(int value)
- void SetUint(unsigned value)
- void SetStringHash(const StringHash& value)
- void SetShortStringHash(const ShortStringHash& value)
- void SetBool(bool value)
- void SetFloat(float value)
- void SetVector2(const Vector2& value)
@ -5591,7 +5556,6 @@ Methods:
- int GetInt() const
- int GetUInt() const
- StringHash GetStringHash()
- ShortStringHash GetShortStringHash()
- bool GetBool() const
- float GetFloat() const
- const Vector2& GetVector2() const
@ -5632,7 +5596,6 @@ Methods:
- void SetInt(const String key, int value)
- void SetUInt(const String key, unsigned value)
- void SetStringHash(const String key, const StringHash& value)
- void SetShortStringHash(const String key, const ShortStringHash& value)
- void SetBool(const String key, bool value)
- void SetFloat(const String key, float value)
- void SetVector2(const String key, const Vector2 value)
@ -5653,7 +5616,6 @@ Methods:
- int GetInt(const String key)
- int GetUInt(const String key)
- StringHash GetStringHash(const String key)
- ShortStringHash GetShortStringHash(const String key)
- bool GetBool(const String key)
- float GetFloat(const String key)
- const Vector2& GetVector2(const String key)
@ -5857,7 +5819,6 @@ Methods:
- String ReadString()
- String ReadFileID()
- StringHash ReadStringHash()
- ShortStringHash ReadShortStringHash()
- VectorBuffer ReadBuffer()
- ResourceRef ReadResourceRef()
- ResourceRefList ReadResourceRefList()
@ -5894,7 +5855,6 @@ Methods:
- bool WriteString(const String value)
- bool WriteFileID(const String value)
- bool WriteStringHash(const StringHash& value)
- bool WriteShortStringHash(const ShortStringHash& value)
- bool WriteBuffer(const VectorBuffer& buffer)
- bool WriteResourceRef(const ResourceRef& value)
- bool WriteResourceRefList(const ResourceRefList& value)

Просмотреть файл

@ -18,7 +18,7 @@ The classes in question are String, Vector, PODVector, List, HashSet and HashMap
The list, set and map classes use a fixed-size allocator internally. This can also be used by the application, either by using the procedural functions AllocatorInitialize(), AllocatorUninitialize(), AllocatorReserve() and AllocatorFree(), or through the template class Allocator.
In script, the String class is exposed as it is. The template containers can not be directly exposed to script, but instead a template Array type exists, which behaves like a Vector, but does not expose iterators. In addition the VariantMap is available, which is a HashMap<ShortStringHash, Variant>.
In script, the String class is exposed as it is. The template containers can not be directly exposed to script, but instead a template Array type exists, which behaves like a Vector, but does not expose iterators. In addition the VariantMap is available, which is a HashMap<StringHash, Variant>.
\page ObjectTypes %Object types and factories
@ -27,7 +27,7 @@ Classes that derive from Object contain type-identification, they can be created
%Object factory registration and object creation through factories are directly accessible only in C++, not in script.
The definition of an Object subclass must contain the OBJECT(className) macro. Type identification is available both as text (GetTypeName() or GetTypeNameStatic()) and as a 16-bit hash of the type name (GetType() or GetTypeStatic()).
The definition of an Object subclass must contain the OBJECT(className) macro. Type identification is available both as text (GetTypeName() or GetTypeNameStatic()) and as a 32-bit hash of the type name (GetType() or GetTypeStatic()).
To register an object factory for a specific type, call the \ref Context::RegisterFactory "RegisterFactory()" template function on Context. You can get its pointer from any Object either via the \ref Object::context_ "context_" member variable, or by calling \ref Object::GetContext "GetContext()". An example:
@ -35,7 +35,7 @@ To register an object factory for a specific type, call the \ref Context::Regist
context_->RegisterFactory<MyClass>();
\endcode
To create an object using a factory, call Context's \ref Context::CreateObject "CreateObject()" function. This takes the 16-bit hash of the type name as a parameter. The created object (or null if there was no matching factory registered) will be returned inside a SharedPtr<Object>. For example:
To create an object using a factory, call Context's \ref Context::CreateObject "CreateObject()" function. This takes the 32-bit hash of the type name as a parameter. The created object (or null if there was no matching factory registered) will be returned inside a SharedPtr<Object>. For example:
\code
SharedPtr<Object> newComponent = context_->CreateObject(type));
@ -76,7 +76,7 @@ time, fileSystem, log, cache, network, input, ui, audio, engine, graphics, rende
The Urho3D event system allows for data transport and function invocation without the sender and receiver having to explicitly know of each other. Both the event sender and receiver must derive from Object. An event receiver must subscribe to each event type it wishes to receive: one can either subscribe to the event coming from any sender, or from a specific sender. The latter is useful for example when handling events from the user interface elements.
Events themselves do not need to be registered. They are identified by 32-bit hashes of their names. Event parameters (the data payload) are optional and are contained inside a VariantMap, identified by 16-bit parameter name hashes. For the inbuilt Urho3D events, event type (E_UPDATE, E_KEYDOWN, E_MOUSEMOVE etc.) and parameter hashes (P_TIMESTEP, P_DX, P_DY etc.) are defined as constants inside include files such as CoreEvents.h or InputEvents.h.
Events themselves do not need to be registered. They are identified by 32-bit hashes of their names. Event parameters (the data payload) are optional and are contained inside a VariantMap, identified by 32-bit parameter name hashes. For the inbuilt Urho3D events, event type (E_UPDATE, E_KEYDOWN, E_MOUSEMOVE etc.) and parameter hashes (P_TIMESTEP, P_DX, P_DY etc.) are defined as constants inside include files such as CoreEvents.h or InputEvents.h.
When subscribing to an event, a handler function must be specified. In C++ these must have the signature void HandleEvent(StringHash eventType, VariantMap& eventData). The HANDLER(className, function) macro helps in defining the required class-specific function pointers. For example:
@ -342,7 +342,7 @@ Resources include most things in Urho3D that are loaded from mass storage during
- TextureCube
- XMLFile
They are managed and loaded by the ResourceCache subsystem. Like with all other \ref ObjectTypes "typed objects", resource types are identified by 16-bit type name hashes (C++) or type names (script). An object factory must be registered for each resource type.
They are managed and loaded by the ResourceCache subsystem. Like with all other \ref ObjectTypes "typed objects", resource types are identified by 32-bit type name hashes (C++) or type names (script). An object factory must be registered for each resource type.
The resources themselves are identified by their file paths, relative to the registered resource directories or \ref PackageFile "package files". By default, the engine registers the resource directories Data and CoreData, or the packages Data.pak and CoreData.pak if they exist.
@ -504,7 +504,7 @@ Much of the Urho3D classes are exposed to scripts, however things that require l
- Printing raw output to the log is simply called Print(). The rest of the logging functions are accessed by calling log.Debug(), log.Info(), log.Warning() and log.Error().
- Functions that would take a StringHash or ShortStringHash parameter usually take a string instead. For example sending events, requesting resources and accessing components.
- Functions that would take a StringHash parameter usually take a string instead. For example sending events, requesting resources and accessing components.
- Most of StringUtils have been exposed as methods of the string class. For example String.ToBool().

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -28,9 +28,9 @@
namespace Urho3D
{
void RemoveNamedAttribute(HashMap<ShortStringHash, Vector<AttributeInfo> >& attributes, ShortStringHash objectType, const char* name)
void RemoveNamedAttribute(HashMap<StringHash, Vector<AttributeInfo> >& attributes, StringHash objectType, const char* name)
{
HashMap<ShortStringHash, Vector<AttributeInfo> >::Iterator i = attributes.Find(objectType);
HashMap<StringHash, Vector<AttributeInfo> >::Iterator i = attributes.Find(objectType);
if (i == attributes.End())
return;
@ -78,9 +78,9 @@ Context::~Context()
eventDataMaps_.Clear();
}
SharedPtr<Object> Context::CreateObject(ShortStringHash objectType)
SharedPtr<Object> Context::CreateObject(StringHash objectType)
{
HashMap<ShortStringHash, SharedPtr<ObjectFactory> >::ConstIterator i = factories_.Find(objectType);
HashMap<StringHash, SharedPtr<ObjectFactory> >::ConstIterator i = factories_.Find(objectType);
if (i != factories_.End())
return i->second_->CreateObject();
else
@ -113,14 +113,14 @@ void Context::RegisterSubsystem(Object* object)
subsystems_[object->GetType()] = object;
}
void Context::RemoveSubsystem(ShortStringHash objectType)
void Context::RemoveSubsystem(StringHash objectType)
{
HashMap<ShortStringHash, SharedPtr<Object> >::Iterator i = subsystems_.Find(objectType);
HashMap<StringHash, SharedPtr<Object> >::Iterator i = subsystems_.Find(objectType);
if (i != subsystems_.End())
subsystems_.Erase(i);
}
void Context::RegisterAttribute(ShortStringHash objectType, const AttributeInfo& attr)
void Context::RegisterAttribute(StringHash objectType, const AttributeInfo& attr)
{
// None or pointer types can not be supported
if (attr.type_ == VAR_NONE || attr.type_ == VAR_VOIDPTR || attr.type_ == VAR_PTR)
@ -132,13 +132,13 @@ void Context::RegisterAttribute(ShortStringHash objectType, const AttributeInfo&
networkAttributes_[objectType].Push(attr);
}
void Context::RemoveAttribute(ShortStringHash objectType, const char* name)
void Context::RemoveAttribute(StringHash objectType, const char* name)
{
RemoveNamedAttribute(attributes_, objectType, name);
RemoveNamedAttribute(networkAttributes_, objectType, name);
}
void Context::UpdateAttributeDefaultValue(ShortStringHash objectType, const char* name, const Variant& defaultValue)
void Context::UpdateAttributeDefaultValue(StringHash objectType, const char* name, const Variant& defaultValue)
{
AttributeInfo* info = GetAttribute(objectType, name);
if (info)
@ -157,7 +157,7 @@ VariantMap& Context::GetEventDataMap()
}
void Context::CopyBaseAttributes(ShortStringHash baseType, ShortStringHash derivedType)
void Context::CopyBaseAttributes(StringHash baseType, StringHash derivedType)
{
const Vector<AttributeInfo>* baseAttributes = GetAttributes(baseType);
if (baseAttributes)
@ -172,9 +172,9 @@ void Context::CopyBaseAttributes(ShortStringHash baseType, ShortStringHash deriv
}
}
Object* Context::GetSubsystem(ShortStringHash type) const
Object* Context::GetSubsystem(StringHash type) const
{
HashMap<ShortStringHash, SharedPtr<Object> >::ConstIterator i = subsystems_.Find(type);
HashMap<StringHash, SharedPtr<Object> >::ConstIterator i = subsystems_.Find(type);
if (i != subsystems_.End())
return i->second_;
else
@ -189,16 +189,16 @@ Object* Context::GetEventSender() const
return 0;
}
const String& Context::GetTypeName(ShortStringHash objectType) const
const String& Context::GetTypeName(StringHash objectType) const
{
// Search factories to find the hash-to-name mapping
HashMap<ShortStringHash, SharedPtr<ObjectFactory> >::ConstIterator i = factories_.Find(objectType);
HashMap<StringHash, SharedPtr<ObjectFactory> >::ConstIterator i = factories_.Find(objectType);
return i != factories_.End() ? i->second_->GetTypeName() : String::EMPTY;
}
AttributeInfo* Context::GetAttribute(ShortStringHash objectType, const char* name)
AttributeInfo* Context::GetAttribute(StringHash objectType, const char* name)
{
HashMap<ShortStringHash, Vector<AttributeInfo> >::Iterator i = attributes_.Find(objectType);
HashMap<StringHash, Vector<AttributeInfo> >::Iterator i = attributes_.Find(objectType);
if (i == attributes_.End())
return 0;

Просмотреть файл

@ -41,7 +41,7 @@ public:
~Context();
/// Create an object by type hash. Return pointer to it or null if no factory found.
SharedPtr<Object> CreateObject(ShortStringHash objectType);
SharedPtr<Object> CreateObject(StringHash objectType);
/// Register a factory for an object type.
void RegisterFactory(ObjectFactory* factory);
/// Register a factory for an object type and specify the object category.
@ -49,18 +49,18 @@ public:
/// Register a subsystem.
void RegisterSubsystem(Object* subsystem);
/// Remove a subsystem.
void RemoveSubsystem(ShortStringHash objectType);
void RemoveSubsystem(StringHash objectType);
/// Register object attribute.
void RegisterAttribute(ShortStringHash objectType, const AttributeInfo& attr);
void RegisterAttribute(StringHash objectType, const AttributeInfo& attr);
/// Remove object attribute.
void RemoveAttribute(ShortStringHash objectType, const char* name);
void RemoveAttribute(StringHash objectType, const char* name);
/// Update object attribute's default value.
void UpdateAttributeDefaultValue(ShortStringHash objectType, const char* name, const Variant& defaultValue);
void UpdateAttributeDefaultValue(StringHash objectType, const char* name, const Variant& defaultValue);
/// Return a preallocated map for event data. Used for optimization to avoid constant re-allocation of event data maps.
VariantMap& GetEventDataMap();
/// Copy base class attributes to derived class.
void CopyBaseAttributes(ShortStringHash baseType, ShortStringHash derivedType);
void CopyBaseAttributes(StringHash baseType, StringHash derivedType);
/// Template version of registering an object factory.
template <class T> void RegisterFactory();
/// Template version of registering an object factory with category.
@ -77,42 +77,42 @@ public:
template <class T> void UpdateAttributeDefaultValue(const char* name, const Variant& defaultValue);
/// Return subsystem by type.
Object* GetSubsystem(ShortStringHash type) const;
Object* GetSubsystem(StringHash type) const;
/// Return all subsystems.
const HashMap<ShortStringHash, SharedPtr<Object> >& GetSubsystems() const { return subsystems_; }
const HashMap<StringHash, SharedPtr<Object> >& GetSubsystems() const { return subsystems_; }
/// Return all object factories.
const HashMap<ShortStringHash, SharedPtr<ObjectFactory> >& GetObjectFactories() const { return factories_; }
const HashMap<StringHash, SharedPtr<ObjectFactory> >& GetObjectFactories() const { return factories_; }
/// Return all object categories.
const HashMap<String, Vector<ShortStringHash> >& GetObjectCategories() const { return objectCategories_; }
const HashMap<String, Vector<StringHash> >& GetObjectCategories() const { return objectCategories_; }
/// Return active event sender. Null outside event handling.
Object* GetEventSender() const;
/// Return active event handler. Set by Object. Null outside event handling.
EventHandler* GetEventHandler() const { return eventHandler_; }
/// Return object type name from hash, or empty if unknown.
const String& GetTypeName(ShortStringHash objectType) const;
const String& GetTypeName(StringHash objectType) const;
/// Return a specific attribute description for an object, or null if not found.
AttributeInfo* GetAttribute(ShortStringHash objectType, const char* name);
AttributeInfo* GetAttribute(StringHash objectType, const char* name);
/// Template version of returning a subsystem.
template <class T> T* GetSubsystem() const;
/// Template version of returning a specific attribute description.
template <class T> AttributeInfo* GetAttribute(const char* name);
/// Return attribute descriptions for an object type, or null if none defined.
const Vector<AttributeInfo>* GetAttributes(ShortStringHash type) const
const Vector<AttributeInfo>* GetAttributes(StringHash type) const
{
HashMap<ShortStringHash, Vector<AttributeInfo> >::ConstIterator i = attributes_.Find(type);
HashMap<StringHash, Vector<AttributeInfo> >::ConstIterator i = attributes_.Find(type);
return i != attributes_.End() ? &i->second_ : 0;
}
/// Return network replication attribute descriptions for an object type, or null if none defined.
const Vector<AttributeInfo>* GetNetworkAttributes(ShortStringHash type) const
const Vector<AttributeInfo>* GetNetworkAttributes(StringHash type) const
{
HashMap<ShortStringHash, Vector<AttributeInfo> >::ConstIterator i = networkAttributes_.Find(type);
HashMap<StringHash, Vector<AttributeInfo> >::ConstIterator i = networkAttributes_.Find(type);
return i != networkAttributes_.End() ? &i->second_ : 0;
}
/// Return all registered attributes.
const HashMap<ShortStringHash, Vector<AttributeInfo> >& GetAllAttributes() const { return attributes_; }
const HashMap<StringHash, Vector<AttributeInfo> >& GetAllAttributes() const { return attributes_; }
/// Return event receivers for a sender and event type, or null if they do not exist.
HashSet<Object*>* GetEventReceivers(Object* sender, StringHash eventType)
@ -153,13 +153,13 @@ private:
void EndSendEvent() { eventSenders_.Pop(); }
/// Object factories.
HashMap<ShortStringHash, SharedPtr<ObjectFactory> > factories_;
HashMap<StringHash, SharedPtr<ObjectFactory> > factories_;
/// Subsystems.
HashMap<ShortStringHash, SharedPtr<Object> > subsystems_;
HashMap<StringHash, SharedPtr<Object> > subsystems_;
/// Attribute descriptions per object type.
HashMap<ShortStringHash, Vector<AttributeInfo> > attributes_;
HashMap<StringHash, Vector<AttributeInfo> > attributes_;
/// Network replication attribute descriptions per object type.
HashMap<ShortStringHash, Vector<AttributeInfo> > networkAttributes_;
HashMap<StringHash, Vector<AttributeInfo> > networkAttributes_;
/// Event receivers for non-specific events.
HashMap<StringHash, HashSet<Object*> > eventReceivers_;
/// Event receivers for specific senders' events.
@ -171,7 +171,7 @@ private:
/// Active event handler. Not stored in a stack for performance reasons; is needed only in esoteric cases.
EventHandler* eventHandler_;
/// Object categories.
HashMap<String, Vector<ShortStringHash> > objectCategories_;
HashMap<String, Vector<StringHash> > objectCategories_;
};
template <class T> void Context::RegisterFactory() { RegisterFactory(new ObjectFactoryImpl<T>(this)); }

Просмотреть файл

@ -324,7 +324,7 @@ VariantMap& Object::GetEventDataMap() const
return context_->GetEventDataMap();
}
Object* Object::GetSubsystem(ShortStringHash type) const
Object* Object::GetSubsystem(StringHash type) const
{
return context_->GetSubsystem(type);
}
@ -354,8 +354,8 @@ bool Object::HasSubscribedToEvent(Object* sender, StringHash eventType) const
const String& Object::GetCategory() const
{
const HashMap<String, Vector<ShortStringHash> >& objectCategories = context_->GetObjectCategories();
for (HashMap<String, Vector<ShortStringHash> >::ConstIterator i = objectCategories.Begin(); i != objectCategories.End(); ++i)
const HashMap<String, Vector<StringHash> >& objectCategories = context_->GetObjectCategories();
for (HashMap<String, Vector<StringHash> >::ConstIterator i = objectCategories.Begin(); i != objectCategories.End(); ++i)
{
if (i->second_.Contains(GetType()))
return i->first_;

Просмотреть файл

@ -33,15 +33,15 @@ class EventHandler;
#define OBJECT(typeName) \
public: \
virtual Urho3D::ShortStringHash GetType() const { return GetTypeStatic(); } \
virtual Urho3D::ShortStringHash GetBaseType() const { return GetBaseTypeStatic(); } \
virtual Urho3D::StringHash GetType() const { return GetTypeStatic(); } \
virtual Urho3D::StringHash GetBaseType() const { return GetBaseTypeStatic(); } \
virtual const Urho3D::String& GetTypeName() const { return GetTypeNameStatic(); } \
static Urho3D::ShortStringHash GetTypeStatic() { static const Urho3D::ShortStringHash typeStatic(#typeName); return typeStatic; } \
static Urho3D::StringHash GetTypeStatic() { static const Urho3D::StringHash typeStatic(#typeName); return typeStatic; } \
static const Urho3D::String& GetTypeNameStatic() { static const Urho3D::String typeNameStatic(#typeName); return typeNameStatic; } \
#define BASEOBJECT(typeName) \
public: \
static Urho3D::ShortStringHash GetBaseTypeStatic() { static const Urho3D::ShortStringHash baseTypeStatic(#typeName); return baseTypeStatic; } \
static Urho3D::StringHash GetBaseTypeStatic() { static const Urho3D::StringHash baseTypeStatic(#typeName); return baseTypeStatic; } \
/// Base class for objects with type identification, subsystem access and event sending/receiving capability.
class URHO3D_API Object : public RefCounted
@ -57,9 +57,9 @@ public:
virtual ~Object();
/// Return type hash.
virtual ShortStringHash GetType() const = 0;
virtual StringHash GetType() const = 0;
/// Return base class type hash.
virtual ShortStringHash GetBaseType() const = 0;
virtual StringHash GetBaseType() const = 0;
/// Return type name.
virtual const String& GetTypeName() const = 0;
/// Handle event.
@ -89,7 +89,7 @@ public:
/// Return execution context.
Context* GetContext() const { return context_; }
/// Return subsystem by type.
Object* GetSubsystem(ShortStringHash type) const;
Object* GetSubsystem(StringHash type) const;
/// Return active event sender. Null outside event handling.
Object* GetEventSender() const;
/// Return active event handler. Null outside event handling.
@ -142,9 +142,9 @@ public:
/// Return execution context.
Context* GetContext() const { return context_; }
/// Return type hash of objects created by this factory.
ShortStringHash GetType() const { return type_; }
StringHash GetType() const { return type_; }
/// Return base type hash of objects created by this factory.
ShortStringHash GetBaseType() const { return baseType_; }
StringHash GetBaseType() const { return baseType_; }
/// Return type name of objects created by this factory.
const String& GetTypeName() const { return typeName_; }
@ -152,9 +152,9 @@ protected:
/// Execution context.
Context* context_;
/// Object type.
ShortStringHash type_;
StringHash type_;
/// Object base type.
ShortStringHash baseType_;
StringHash baseType_;
/// Object type name.
String typeName_;
};
@ -266,7 +266,7 @@ private:
};
#define EVENT(eventID, eventName) static const Urho3D::StringHash eventID(#eventName); namespace eventName
#define PARAM(paramID, paramName) static const Urho3D::ShortStringHash paramID(#paramName)
#define PARAM(paramID, paramName) static const Urho3D::StringHash paramID(#paramName)
#define HANDLER(className, function) (new Urho3D::EventHandlerImpl<className>(this, &className::function))
#define HANDLER_USERDATA(className, function, userData) (new Urho3D::EventHandlerImpl<className>(this, &className::function, userData))

Просмотреть файл

@ -590,11 +590,6 @@ template<> StringHash Variant::Get<StringHash>() const
return GetStringHash();
}
template<> ShortStringHash Variant::Get<ShortStringHash>() const
{
return GetShortStringHash();
}
template<> bool Variant::Get<bool>() const
{
return GetBool();

Просмотреть файл

@ -103,13 +103,13 @@ struct URHO3D_API ResourceRef
}
/// Construct with type only and empty id.
ResourceRef(ShortStringHash type) :
ResourceRef(StringHash type) :
type_(type)
{
}
/// Construct with type and resource name.
ResourceRef(ShortStringHash type, const String& name) :
ResourceRef(StringHash type, const String& name) :
type_(type),
name_(name)
{
@ -123,7 +123,7 @@ struct URHO3D_API ResourceRef
}
/// Object type.
ShortStringHash type_;
StringHash type_;
/// Object name.
String name_;
@ -142,19 +142,19 @@ struct URHO3D_API ResourceRefList
}
/// Construct with type only.
ResourceRefList(ShortStringHash type) :
ResourceRefList(StringHash type) :
type_(type)
{
}
/// Construct with type and id list.
ResourceRefList(ShortStringHash type, const Vector<String>& names) :
ResourceRefList(StringHash type, const Vector<String>& names) :
type_(type),
names_(names)
{
}
/// Object type.
ShortStringHash type_;
StringHash type_;
/// List of object names.
Vector<String> names_;
@ -170,7 +170,7 @@ class Variant;
typedef Vector<Variant> VariantVector;
/// Map of variants.
typedef HashMap<ShortStringHash, Variant> VariantMap;
typedef HashMap<StringHash, Variant> VariantMap;
/// Variable that supports a fixed set of types.
class URHO3D_API Variant
@ -203,13 +203,6 @@ public:
*this = (int)value.Value();
}
/// Construct from a short string hash (convert to integer.)
Variant(const ShortStringHash& value) :
type_(VAR_NONE)
{
*this = (int)value.Value();
}
/// Construct from a bool.
Variant(bool value) :
type_(VAR_NONE)
@ -431,14 +424,6 @@ public:
return *this;
}
/// Assign from a ShortStringHash (convert to integer)
Variant& operator = (const ShortStringHash& rhs)
{
SetType(VAR_INT);
value_.int_ = (int)rhs.Value();
return *this;
}
/// Assign from a bool.
Variant& operator = (bool rhs)
{
@ -657,8 +642,6 @@ public:
bool operator == (const IntVector2& rhs) const { return type_ == VAR_INTVECTOR2 ? *(reinterpret_cast<const IntVector2*>(&value_)) == rhs : false; }
/// Test for equality with a StringHash. To return true, both the type and value must match.
bool operator == (const StringHash& rhs) const { return type_ == VAR_INT ? (unsigned)value_.int_ == rhs.Value() : false; }
/// Test for equality with a ShortStringHash. To return true, both the type and value must match.
bool operator == (const ShortStringHash& rhs) const { return type_ == VAR_INT ? value_.int_ == rhs.Value() : false; }
/// Test for equality with a RefCounted pointer. To return true, both the type and value must match, with the exception that void pointer is also allowed.
bool operator == (RefCounted* rhs) const
@ -716,8 +699,6 @@ public:
bool operator != (const IntVector2& rhs) const { return !(*this == rhs); }
/// Test for inequality with a StringHash.
bool operator != (const StringHash& rhs) const { return !(*this == rhs); }
/// Test for inequality with a ShortStringHash.
bool operator != (const ShortStringHash& rhs) const { return !(*this == rhs); }
/// Test for inequality with a RefCounted pointer.
bool operator != (RefCounted* rhs) const { return !(*this == rhs); }
/// Test for inequality with a Matrix3.
@ -744,8 +725,6 @@ public:
int GetUInt() const { return type_ == VAR_INT ? (unsigned)value_.int_ : 0; }
/// Return StringHash or zero on type mismatch.
StringHash GetStringHash() const { return StringHash(GetUInt()); }
/// Return ShortStringHash or zero on type mismatch.
ShortStringHash GetShortStringHash() const { return ShortStringHash(GetUInt()); }
/// Return bool or false on type mismatch.
bool GetBool() const { return type_ == VAR_BOOL ? value_.bool_ : false; }
/// Return float or zero on type mismatch.

Просмотреть файл

@ -370,8 +370,8 @@ bool Engine::Initialize(const VariantMap& parameters)
// In debug mode, check now that all factory created objects can be created without crashing
#ifdef _DEBUG
const HashMap<ShortStringHash, SharedPtr<ObjectFactory> >& factories = context_->GetObjectFactories();
for (HashMap<ShortStringHash, SharedPtr<ObjectFactory> >::ConstIterator i = factories.Begin(); i != factories.End(); ++i)
const HashMap<StringHash, SharedPtr<ObjectFactory> >& factories = context_->GetObjectFactories();
for (HashMap<StringHash, SharedPtr<ObjectFactory> >::ConstIterator i = factories.Begin(); i != factories.End(); ++i)
SharedPtr<Object> object = i->second_->CreateObject();
#endif
@ -513,10 +513,10 @@ void Engine::DumpResources()
{
#ifdef URHO3D_LOGGING
ResourceCache* cache = GetSubsystem<ResourceCache>();
const HashMap<ShortStringHash, ResourceGroup>& resourceGroups = cache->GetAllResources();
const HashMap<StringHash, ResourceGroup>& resourceGroups = cache->GetAllResources();
LOGRAW("\n");
for (HashMap<ShortStringHash, ResourceGroup>::ConstIterator i = resourceGroups.Begin();
for (HashMap<StringHash, ResourceGroup>::ConstIterator i = resourceGroups.Begin();
i != resourceGroups.End(); ++i)
{
unsigned num = i->second_.resources_.Size();
@ -816,13 +816,13 @@ VariantMap Engine::ParseParameters(const Vector<String>& arguments)
bool Engine::HasParameter(const VariantMap& parameters, const String& parameter)
{
ShortStringHash nameHash(parameter);
StringHash nameHash(parameter);
return parameters.Find(nameHash) != parameters.End();
}
const Variant& Engine::GetParameter(const VariantMap& parameters, const String& parameter, const Variant& defaultValue)
{
ShortStringHash nameHash(parameter);
StringHash nameHash(parameter);
VariantMap::ConstIterator i = parameters.Find(nameHash);
return i != parameters.End() ? i->second_ : defaultValue;
}

Просмотреть файл

@ -302,7 +302,7 @@ void Texture::LoadParameters(const XMLElement& element)
}
}
void Texture::CheckTextureBudget(ShortStringHash type)
void Texture::CheckTextureBudget(StringHash type)
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
unsigned textureBudget = cache->GetMemoryBudget(type);

Просмотреть файл

@ -107,7 +107,7 @@ public:
protected:
/// Check whether texture memory budget has been exceeded. Free unused materials in that case to release the texture references.
void CheckTextureBudget(ShortStringHash type);
void CheckTextureBudget(StringHash type);
/// Texture format.
unsigned format_;

Просмотреть файл

@ -491,7 +491,7 @@ unsigned Texture::GetSRGBFormat(unsigned format)
#endif
}
void Texture::CheckTextureBudget(ShortStringHash type)
void Texture::CheckTextureBudget(StringHash type)
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
unsigned textureBudget = cache->GetMemoryBudget(type);

Просмотреть файл

@ -125,7 +125,7 @@ public:
protected:
/// Check whether texture memory budget has been exceeded. Free unused materials in that case to release the texture references.
void CheckTextureBudget(ShortStringHash type);
void CheckTextureBudget(StringHash type);
/// Create texture.
virtual bool Create() { return true; }

Просмотреть файл

@ -244,11 +244,6 @@ StringHash Deserializer::ReadStringHash()
return StringHash(ReadUInt());
}
ShortStringHash Deserializer::ReadShortStringHash()
{
return ShortStringHash(ReadUShort());
}
PODVector<unsigned char> Deserializer::ReadBuffer()
{
PODVector<unsigned char> ret(ReadVLE());
@ -260,7 +255,7 @@ PODVector<unsigned char> Deserializer::ReadBuffer()
ResourceRef Deserializer::ReadResourceRef()
{
ResourceRef ret;
ret.type_ = ReadShortStringHash();
ret.type_ = ReadStringHash();
ret.name_ = ReadString();
return ret;
}
@ -268,7 +263,7 @@ ResourceRef Deserializer::ReadResourceRef()
ResourceRefList Deserializer::ReadResourceRefList()
{
ResourceRefList ret;
ret.type_ = ReadShortStringHash();
ret.type_ = ReadStringHash();
ret.names_.Resize(ReadVLE());
for (unsigned i = 0; i < ret.names_.Size(); ++i)
ret.names_[i] = ReadString();
@ -368,7 +363,7 @@ VariantMap Deserializer::ReadVariantMap()
for (unsigned i = 0; i < num; ++i)
{
ShortStringHash key = ReadShortStringHash();
StringHash key = ReadStringHash();
ret[key] = ReadVariant();
}

Просмотреть файл

@ -105,8 +105,6 @@ public:
String ReadFileID();
/// Read a 32-bit StringHash.
StringHash ReadStringHash();
/// Read a 16-bit ShortStringHash.
ShortStringHash ReadShortStringHash();
/// Read a buffer with size encoded as VLE.
PODVector<unsigned char> ReadBuffer();
/// Read a resource reference.

Просмотреть файл

@ -186,11 +186,6 @@ bool Serializer::WriteStringHash(const StringHash& value)
return WriteUInt(value.Value());
}
bool Serializer::WriteShortStringHash(const ShortStringHash& value)
{
return WriteUShort(value.Value());
}
bool Serializer::WriteBuffer(const PODVector<unsigned char>& value)
{
bool success = true;
@ -205,7 +200,7 @@ bool Serializer::WriteBuffer(const PODVector<unsigned char>& value)
bool Serializer::WriteResourceRef(const ResourceRef& value)
{
bool success = true;
success &= WriteShortStringHash(value.type_);
success &= WriteStringHash(value.type_);
success &= WriteString(value.name_);
return success;
}
@ -215,7 +210,7 @@ bool Serializer::WriteResourceRefList(const ResourceRefList& value)
bool success = true;
unsigned size = value.names_.Size() * sizeof(StringHash);
success &= WriteShortStringHash(value.type_);
success &= WriteStringHash(value.type_);
success &= WriteVLE(value.names_.Size());
for (unsigned i = 0; i < value.names_.Size(); ++i)
success &= WriteString(value.names_[i]);
@ -322,7 +317,7 @@ bool Serializer::WriteVariantMap(const VariantMap& value)
success &= WriteVLE(value.Size());
for (VariantMap::ConstIterator i = value.Begin(); i != value.End(); ++i)
{
WriteShortStringHash(i->first_);
WriteStringHash(i->first_);
WriteVariant(i->second_);
}
return success;

Просмотреть файл

@ -98,8 +98,6 @@ public:
bool WriteFileID(const String& value);
/// Write a 32-bit StringHash.
bool WriteStringHash(const StringHash& value);
/// Write a 16-bit ShortStringHash.
bool WriteShortStringHash(const ShortStringHash& value);
/// Write a buffer, with size encoded as VLE.
bool WriteBuffer(const PODVector<unsigned char>& buffer);
/// Write a resource reference.

Просмотреть файл

@ -56,10 +56,10 @@ namespace Urho3D
{
const int SCREEN_JOYSTICK_START_ID = 0x40000000;
const ShortStringHash VAR_BUTTON_KEY_BINDING("VAR_BUTTON_KEY_BINDING");
const ShortStringHash VAR_BUTTON_MOUSE_BUTTON_BINDING("VAR_BUTTON_MOUSE_BUTTON_BINDING");
const ShortStringHash VAR_LAST_KEYSYM("VAR_LAST_KEYSYM");
const ShortStringHash VAR_SCREEN_JOYSTICK_ID("VAR_SCREEN_JOYSTICK_ID");
const StringHash VAR_BUTTON_KEY_BINDING("VAR_BUTTON_KEY_BINDING");
const StringHash VAR_BUTTON_MOUSE_BUTTON_BINDING("VAR_BUTTON_MOUSE_BUTTON_BINDING");
const StringHash VAR_LAST_KEYSYM("VAR_LAST_KEYSYM");
const StringHash VAR_SCREEN_JOYSTICK_ID("VAR_SCREEN_JOYSTICK_ID");
/// Convert SDL keycode if necessary.
int ConvertSDLKeyCode(int keySym, int scanCode)

Просмотреть файл

@ -4,7 +4,7 @@ class Context
{
Object* GetEventSender() const;
EventHandler* GetEventHandler() const;
const String GetTypeName(ShortStringHash objectType) const;
const String GetTypeName(StringHash objectType) const;
};
Context* GetContext();

Просмотреть файл

@ -2,15 +2,15 @@ $#include "Object.h"
class Object : public RefCounted
{
ShortStringHash GetType() const;
ShortStringHash GetBaseType() const;
StringHash GetType() const;
StringHash GetBaseType() const;
const String GetTypeName() const;
const String GetCategory() const;
tolua_outside void ObjectSendEvent @ SendEvent(const String eventName, VariantMap* eventData = 0);
tolua_readonly tolua_property__get_set ShortStringHash type;
tolua_readonly tolua_property__get_set ShortStringHash baseType;
tolua_readonly tolua_property__get_set StringHash type;
tolua_readonly tolua_property__get_set StringHash baseType;
tolua_readonly tolua_property__get_set const String typeName;
tolua_readonly tolua_property__get_set const String category;
};

Просмотреть файл

@ -30,12 +30,12 @@ enum VariantType
struct ResourceRef
{
ResourceRef();
ResourceRef(ShortStringHash type);
ResourceRef(ShortStringHash type, String name);
ResourceRef(StringHash type);
ResourceRef(StringHash type, String name);
ResourceRef(const ResourceRef& rhs);
~ResourceRef();
ShortStringHash type_ @ type;
StringHash type_ @ type;
String name_ @ name;
bool operator == (const ResourceRef& rhs) const;
@ -44,10 +44,10 @@ struct ResourceRef
struct ResourceRefList
{
ResourceRefList();
ResourceRefList(ShortStringHash type);
ResourceRefList(StringHash type);
~ResourceRefList();
ShortStringHash type_ @ type;
StringHash type_ @ type;
bool operator == (const ResourceRefList& rhs) const;
};
@ -58,7 +58,6 @@ class Variant
Variant(int value);
Variant(unsigned value);
Variant(const StringHash& value);
Variant(const ShortStringHash& value);
Variant(bool value);
Variant(float value);
Variant(const Vector2& value);
@ -99,7 +98,6 @@ class Variant
bool operator == (const IntRect& rhs) const;
bool operator == (const IntVector2& rhs) const;
bool operator == (const StringHash& rhs) const;
bool operator == (const ShortStringHash& rhs) const;
bool operator == (const Matrix3& rhs) const;
bool operator == (const Matrix3x4& rhs) const;
bool operator == (const Matrix4& rhs) const;
@ -107,7 +105,6 @@ class Variant
tolua_outside void VariantSetInt @ SetInt(int value);
tolua_outside void VariantSetUint @ SetUint(unsigned value);
tolua_outside void VariantSetStringHash @ SetStringHash(const StringHash& value);
tolua_outside void VariantSetShortStringHash @ SetShortStringHash(const ShortStringHash& value);
tolua_outside void VariantSetBool @ SetBool(bool value);
tolua_outside void VariantSetFloat @ SetFloat(float value);
tolua_outside void VariantSetVector2 @ SetVector2(const Vector2& value);
@ -128,7 +125,6 @@ class Variant
int GetInt() const;
int GetUInt() const;
StringHash GetStringHash();
ShortStringHash GetShortStringHash();
bool GetBool() const;
float GetFloat() const;
const Vector2& GetVector2() const;
@ -166,7 +162,6 @@ class VariantMap
tolua_outside void VariantMapSetInt @ SetInt(const String key, int value);
tolua_outside void VariantMapSetUInt @ SetUInt(const String key, unsigned value);
tolua_outside void VariantMapSetStringHash @ SetStringHash(const String key, const StringHash& value);
tolua_outside void VariantMapSetShortStringHash @ SetShortStringHash(const String key, const ShortStringHash& value);
tolua_outside void VariantMapSetBool @ SetBool(const String key, bool value);
tolua_outside void VariantMapSetFloat @ SetFloat(const String key, float value);
tolua_outside void VariantMapSetVector2 @ SetVector2(const String key, const Vector2 value);
@ -188,7 +183,6 @@ class VariantMap
tolua_outside int VariantMapGetInt @ GetInt(const String key);
tolua_outside int VariantMapGetUInt @ GetUInt(const String key);
tolua_outside StringHash VariantMapGetStringHash @ GetStringHash(const String key);
tolua_outside ShortStringHash VariantMapGetShortStringHash @ GetShortStringHash(const String key);
tolua_outside bool VariantMapGetBool @ GetBool(const String key);
tolua_outside float VariantMapGetFloat @ GetFloat(const String key);
tolua_outside const Vector2& VariantMapGetVector2 @ GetVector2(const String key);
@ -224,11 +218,6 @@ static void VariantSetStringHash(Variant* variant, const StringHash& value)
*variant = value;
}
static void VariantSetShortStringHash(Variant* variant, const ShortStringHash& value)
{
*variant = value;
}
static void VariantSetBool(Variant* variant, bool value)
{
*variant = value;
@ -316,112 +305,107 @@ static VectorBuffer VariantGetBuffer(const Variant* variant)
static void VariantMapSetInt(VariantMap* vmap, const String& key, int value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetUInt(VariantMap* vmap, const String& key, unsigned value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetStringHash(VariantMap* vmap, const String& key, const StringHash& value)
{
(*vmap)[ShortStringHash(key)] = value;
}
static void VariantMapSetShortStringHash(VariantMap* vmap, const String& key, const ShortStringHash& value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetBool(VariantMap* vmap, const String& key, bool value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetFloat(VariantMap* vmap, const String& key, float value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetVector2(VariantMap* vmap, const String& key, const Vector2& value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetVector3(VariantMap* vmap, const String& key, const Vector3& value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetVector4(VariantMap* vmap, const String& key, const Vector4& value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetQuaternion(VariantMap* vmap, const String& key, const Quaternion& value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetColor(VariantMap* vmap, const String& key, const Color& value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetString(VariantMap* vmap, const String& key, const String& value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetBuffer(VariantMap* vmap, const String& key, const VectorBuffer& value)
{
(*vmap)[ShortStringHash(key)] = value.GetData();
(*vmap)[StringHash(key)] = value.GetData();
}
static void VariantMapSetResourceRef(VariantMap* vmap, const String& key, const ResourceRef& value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetResourceRefList(VariantMap* vmap, const String& key, const ResourceRefList& value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetIntRect(VariantMap* vmap, const String& key, const IntRect& value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetIntVector2(VariantMap* vmap, const String& key, const IntVector2& value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetPtr(VariantMap* vmap, const String& key, void* value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetMatrix3(VariantMap* vmap, const String& key, const Matrix3& value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetMatrix3x4(VariantMap* vmap, const String& key, const Matrix3x4& value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static void VariantMapSetMatrix4(VariantMap* vmap, const String& key, const Matrix4& value)
{
(*vmap)[ShortStringHash(key)] = value;
(*vmap)[StringHash(key)] = value;
}
static const Variant& FindVariant(const VariantMap* vmap, const String& key)
{
VariantMap::ConstIterator i = vmap->Find(ShortStringHash(key));
VariantMap::ConstIterator i = vmap->Find(StringHash(key));
return i != vmap->End() ? i->second_ : Variant::EMPTY;
}
@ -440,11 +424,6 @@ static StringHash VariantMapGetStringHash(const VariantMap* vmap, const String&
return FindVariant(vmap, key).GetStringHash();
}
static ShortStringHash VariantMapGetShortStringHash(const VariantMap* vmap, const String& key)
{
return FindVariant(vmap, key).GetShortStringHash();
}
static bool VariantMapGetBool(const VariantMap* vmap, const String& key)
{
return FindVariant(vmap, key).GetBool();

Просмотреть файл

@ -36,7 +36,6 @@ class Deserializer
String ReadString();
String ReadFileID();
StringHash ReadStringHash();
ShortStringHash ReadShortStringHash();
// PODVector<unsigned char> ReadBuffer();
VectorBuffer ReadBuffer();

Просмотреть файл

@ -60,7 +60,6 @@ class File : public Object
String ReadString();
String ReadFileID();
StringHash ReadStringHash();
ShortStringHash ReadShortStringHash();
// PODVector<unsigned char> ReadBuffer();
VectorBuffer ReadBuffer();
@ -104,7 +103,6 @@ class File : public Object
bool WriteString(const String value);
bool WriteFileID(const String value);
bool WriteStringHash(const StringHash& value);
bool WriteShortStringHash(const ShortStringHash& value);
// bool WriteBuffer(const PODVector<unsigned char>& buffer);
tolua_outside bool SerializerWriteBuffer @ WriteBuffer(const VectorBuffer& buffer);

Просмотреть файл

@ -30,7 +30,6 @@ class Serializer
bool WriteString(const String value);
bool WriteFileID(const String value);
bool WriteStringHash(const StringHash& value);
bool WriteShortStringHash(const ShortStringHash& value);
// bool WriteBuffer(const PODVector<unsigned char>& buffer);
tolua_outside bool SerializerWriteBuffer @ WriteBuffer(const VectorBuffer& buffer);

Просмотреть файл

@ -53,7 +53,6 @@ class VectorBuffer
String ReadString();
String ReadFileID();
StringHash ReadStringHash();
ShortStringHash ReadShortStringHash();
// PODVector<unsigned char> ReadBuffer();
VectorBuffer ReadBuffer();
@ -97,7 +96,6 @@ class VectorBuffer
bool WriteString(const String value);
bool WriteFileID(const String value);
bool WriteStringHash(const StringHash& value);
bool WriteShortStringHash(const ShortStringHash& value);
// bool WriteBuffer(const PODVector<unsigned char>& buffer);
tolua_outside bool SerializerWriteBuffer @ WriteBuffer(const VectorBuffer& buffer);

Просмотреть файл

@ -21,23 +21,3 @@ class StringHash
tolua_readonly tolua_property__no_prefix unsigned value;
};
class ShortStringHash
{
ShortStringHash();
ShortStringHash(const ShortStringHash& rhs);
explicit ShortStringHash(const StringHash& rhs);
explicit ShortStringHash(unsigned short value);
ShortStringHash(const String str);
~ShortStringHash();
ShortStringHash operator + (const ShortStringHash& rhs) const;
bool operator == (const ShortStringHash& rhs) const;
bool operator < (const ShortStringHash& rhs) const;
unsigned short Value() const;
static unsigned short Calculate(const char* str);
static const ShortStringHash ZERO;
tolua_readonly tolua_property__no_prefix unsigned short value;
};

Просмотреть файл

@ -5,7 +5,7 @@ class ResourceCache
void ReleaseAllResources(bool force = false);
bool ReloadResource(Resource* resource);
void SetMemoryBudget(ShortStringHash type, unsigned budget);
void SetMemoryBudget(StringHash type, unsigned budget);
void SetMemoryBudget(const String type, unsigned budget);
void SetAutoReloadResources(bool enable);
@ -17,8 +17,8 @@ class ResourceCache
Resource* GetResource(const String type, const String name, bool SendEventOnFailure = true);
bool Exists(const String name) const;
unsigned GetMemoryBudget(ShortStringHash type) const;
unsigned GetMemoryUse(ShortStringHash type) const;
unsigned GetMemoryBudget(StringHash type) const;
unsigned GetMemoryUse(StringHash type) const;
unsigned GetTotalMemoryUse() const;
String GetResourceFileName(const String name) const;

Просмотреть файл

@ -11,6 +11,6 @@ class Component : public Animatable
bool IsEnabled() const;
bool IsEnabledEffective() const;
Component* GetComponent(ShortStringHash type) const;
Component* GetComponent(StringHash type) const;
Component* GetComponent(const String type) const;
};

Просмотреть файл

@ -90,7 +90,7 @@ class Node : public Animatable
void RemoveAllChildren();
void RemoveChildren(bool removeReplicated, bool removeLocal, bool recursive);
void RemoveComponent(Component* component);
void RemoveComponent(ShortStringHash type);
void RemoveComponent(StringHash type);
void RemoveComponent(const String type);
void RemoveAllComponents();
@ -100,7 +100,7 @@ class Node : public Animatable
void Remove();
void SetParent(Node* parent);
void SetVar(ShortStringHash key, const Variant& value);
void SetVar(StringHash key, const Variant& value);
void AddListener(Component* component);
void RemoveListener(Component* component);
@ -161,10 +161,10 @@ class Node : public Animatable
unsigned GetNumComponents() const;
unsigned GetNumNetworkComponents() const;
bool HasComponent(ShortStringHash type) const;
bool HasComponent(StringHash type) const;
bool HasComponent(const String type) const;
const Variant& GetVar(ShortStringHash key) const;
const Variant& GetVar(StringHash key) const;
const VariantMap& GetVars() const;
// template <class T> T* GetComponent() const;

Просмотреть файл

@ -47,7 +47,7 @@ class Scene : public Node
float GetElapsedTime() const;
float GetSmoothingConstant() const;
float GetSnapThreshold() const;
const String GetVarName(ShortStringHash hash) const;
const String GetVarName(StringHash hash) const;
void Update(float timeStep);
void BeginThreadedUpdate();

Просмотреть файл

@ -139,7 +139,7 @@ class UIElement : public Animatable
void Remove();
unsigned FindChild(UIElement* element) const;
void SetParent(UIElement* parent, unsigned index = M_MAX_UNSIGNED);
void SetVar(ShortStringHash key, const Variant& value);
void SetVar(StringHash key, const Variant& value);
void SetInternal(bool enable);
void SetTraversalMode(TraversalMode traversalMode);
void SetElementEventSender(bool flag);
@ -194,7 +194,7 @@ class UIElement : public Animatable
UIElement* GetParent() const;
UIElement* GetRoot() const;
const Color& GetDerivedColor() const;
const Variant& GetVar(ShortStringHash key) const;
const Variant& GetVar(StringHash key) const;
const VariantMap& GetVars() const;
IntVector2 ScreenToElement(const IntVector2& screenPosition);
IntVector2 ElementToScreen(const IntVector2& position);

Просмотреть файл

@ -32,7 +32,6 @@ namespace Urho3D
{
const StringHash StringHash::ZERO;
const ShortStringHash ShortStringHash::ZERO;
StringHash::StringHash(const char* str) :
value_(Calculate(str))
@ -69,26 +68,4 @@ String StringHash::ToString() const
return String(tempBuffer);
}
ShortStringHash::ShortStringHash(const char* str) :
value_(Calculate(str))
{
}
ShortStringHash::ShortStringHash(const String& str) :
value_(Calculate(str.CString()))
{
}
unsigned short ShortStringHash::Calculate(const char* str)
{
return StringHash::Calculate(str);
}
String ShortStringHash::ToString() const
{
char tempBuffer[CONVERSION_BUFFER_LENGTH];
sprintf(tempBuffer, "%04X", value_);
return String(tempBuffer);
}
}

Просмотреть файл

@ -104,87 +104,4 @@ private:
unsigned value_;
};
/// 16-bit hash value for a string.
class URHO3D_API ShortStringHash
{
public:
/// Construct with zero hash value.
ShortStringHash() :
value_(0)
{
}
/// Copy-construct from another hash value.
ShortStringHash(const ShortStringHash& rhs) :
value_(rhs.value_)
{
}
/// Copy-construct from another 32-bit hash value (ignore the high bits.)
explicit ShortStringHash(const StringHash& rhs) :
value_(rhs.Value())
{
}
/// Construct with an initial value.
explicit ShortStringHash(unsigned short value) :
value_(value)
{
}
/// Construct from a C string case-insensitively.
ShortStringHash(const char* str);
/// Construct from a string case-insensitively.
ShortStringHash(const String& str);
/// Assign from another hash.
ShortStringHash& operator = (const ShortStringHash& rhs)
{
value_ = rhs.value_;
return *this;
}
/// Add a hash.
ShortStringHash operator + (const ShortStringHash& rhs) const
{
ShortStringHash ret;
ret.value_ = value_ + rhs.value_;
return ret;
}
// Add-assign a hash.
ShortStringHash& operator += (const ShortStringHash& rhs)
{
value_ += rhs.value_;
return *this;
}
/// Test for equality with another hash.
bool operator == (const ShortStringHash& rhs) const { return value_ == rhs.value_; }
/// Test for inequality with another hash.
bool operator != (const ShortStringHash& rhs) const { return value_ != rhs.value_; }
/// Test if less than another hash.
bool operator < (const ShortStringHash& rhs) const { return value_ < rhs.value_; }
/// Test if greater than another hash.
bool operator > (const ShortStringHash& rhs) const { return value_ > rhs.value_; }
/// Return true if nonzero hash value.
operator bool () const { return value_ != 0; }
/// Return hash value.
unsigned short Value() const { return value_; }
/// Return as string.
String ToString() const;
/// Return hash value for HashSet & HashMap.
unsigned ToHash() const { return value_; }
/// Calculate hash value case-insensitively from a C string.
static unsigned short Calculate(const char* str);
/// Zero hash.
static const ShortStringHash ZERO;
private:
/// Hash value.
unsigned short value_;
};
}

Просмотреть файл

@ -557,7 +557,7 @@ void Connection::ProcessSceneUpdate(int msgID, MemoryBuffer& msg)
unsigned numVars = msg.ReadVLE();
while (numVars)
{
ShortStringHash key = msg.ReadShortStringHash();
StringHash key = msg.ReadStringHash();
node->SetVar(key, msg.ReadVariant());
--numVars;
}
@ -568,7 +568,7 @@ void Connection::ProcessSceneUpdate(int msgID, MemoryBuffer& msg)
{
--numComponents;
ShortStringHash type = msg.ReadShortStringHash();
StringHash type = msg.ReadStringHash();
unsigned componentID = msg.ReadNetID();
// Check if the component by this ID and type already exists in this node
@ -606,7 +606,7 @@ void Connection::ProcessSceneUpdate(int msgID, MemoryBuffer& msg)
unsigned changedVars = msg.ReadVLE();
while (changedVars)
{
ShortStringHash key = msg.ReadShortStringHash();
StringHash key = msg.ReadStringHash();
node->SetVar(key, msg.ReadVariant());
--changedVars;
}
@ -652,7 +652,7 @@ void Connection::ProcessSceneUpdate(int msgID, MemoryBuffer& msg)
Node* node = scene_->GetNode(nodeID);
if (node)
{
ShortStringHash type = msg.ReadShortStringHash();
StringHash type = msg.ReadStringHash();
unsigned componentID = msg.ReadNetID();
// Check if the component by this ID and type already exists in this node
@ -1117,7 +1117,7 @@ void Connection::ProcessNewNode(Node* node)
msg_.WriteVLE(vars.Size());
for (VariantMap::ConstIterator i = vars.Begin(); i != vars.End(); ++i)
{
msg_.WriteShortStringHash(i->first_);
msg_.WriteStringHash(i->first_);
msg_.WriteVariant(i->second_);
}
@ -1137,7 +1137,7 @@ void Connection::ProcessNewNode(Node* node)
componentState.component_ = component;
component->AddReplicationState(&componentState);
msg_.WriteShortStringHash(component->GetType());
msg_.WriteStringHash(component->GetType());
msg_.WriteNetID(component->GetID());
component->WriteInitialDeltaUpdate(msg_);
}
@ -1205,19 +1205,19 @@ void Connection::ProcessExistingNode(Node* node, NodeReplicationState& nodeState
// Write changed variables
msg_.WriteVLE(nodeState.dirtyVars_.Size());
const VariantMap& vars = node->GetVars();
for (HashSet<ShortStringHash>::ConstIterator i = nodeState.dirtyVars_.Begin(); i != nodeState.dirtyVars_.End(); ++i)
for (HashSet<StringHash>::ConstIterator i = nodeState.dirtyVars_.Begin(); i != nodeState.dirtyVars_.End(); ++i)
{
VariantMap::ConstIterator j = vars.Find(*i);
if (j != vars.End())
{
msg_.WriteShortStringHash(j->first_);
msg_.WriteStringHash(j->first_);
msg_.WriteVariant(j->second_);
}
else
{
// Variable has been marked dirty, but is removed (which is unsupported): send a dummy variable in place
LOGWARNING("Sending dummy user variable as original value was removed");
msg_.WriteShortStringHash(ShortStringHash());
msg_.WriteStringHash(StringHash());
msg_.WriteVariant(Variant::EMPTY);
}
}
@ -1311,7 +1311,7 @@ void Connection::ProcessExistingNode(Node* node, NodeReplicationState& nodeState
msg_.Clear();
msg_.WriteNetID(node->GetID());
msg_.WriteShortStringHash(component->GetType());
msg_.WriteStringHash(component->GetType());
msg_.WriteNetID(component->GetID());
component->WriteInitialDeltaUpdate(msg_);

Просмотреть файл

@ -78,12 +78,12 @@ inline const String& GetResourceName(Resource* resource)
return resource ? resource->GetName() : String::EMPTY;
}
inline ShortStringHash GetResourceType(Resource* resource, ShortStringHash defaultType)
inline StringHash GetResourceType(Resource* resource, StringHash defaultType)
{
return resource ? resource->GetType() : defaultType;
}
inline ResourceRef GetResourceRef(Resource* resource, ShortStringHash defaultType)
inline ResourceRef GetResourceRef(Resource* resource, StringHash defaultType)
{
return ResourceRef(GetResourceType(resource, defaultType), GetResourceName(resource));
}

Просмотреть файл

@ -203,7 +203,7 @@ void ResourceCache::RemovePackageFile(const String& fileName, bool releaseResour
}
}
void ResourceCache::ReleaseResource(ShortStringHash type, const String& name, bool force)
void ResourceCache::ReleaseResource(StringHash type, const String& name, bool force)
{
StringHash nameHash(name);
const SharedPtr<Resource>& existingRes = FindResource(type, nameHash);
@ -218,11 +218,11 @@ void ResourceCache::ReleaseResource(ShortStringHash type, const String& name, bo
}
}
void ResourceCache::ReleaseResources(ShortStringHash type, bool force)
void ResourceCache::ReleaseResources(StringHash type, bool force)
{
bool released = false;
HashMap<ShortStringHash, ResourceGroup>::Iterator i = resourceGroups_.Find(type);
HashMap<StringHash, ResourceGroup>::Iterator i = resourceGroups_.Find(type);
if (i != resourceGroups_.End())
{
for (HashMap<StringHash, SharedPtr<Resource> >::Iterator j = i->second_.resources_.Begin();
@ -242,11 +242,11 @@ void ResourceCache::ReleaseResources(ShortStringHash type, bool force)
UpdateResourceGroup(type);
}
void ResourceCache::ReleaseResources(ShortStringHash type, const String& partialName, bool force)
void ResourceCache::ReleaseResources(StringHash type, const String& partialName, bool force)
{
bool released = false;
HashMap<ShortStringHash, ResourceGroup>::Iterator i = resourceGroups_.Find(type);
HashMap<StringHash, ResourceGroup>::Iterator i = resourceGroups_.Find(type);
if (i != resourceGroups_.End())
{
for (HashMap<StringHash, SharedPtr<Resource> >::Iterator j = i->second_.resources_.Begin();
@ -277,7 +277,7 @@ void ResourceCache::ReleaseResources(const String& partialName, bool force)
while (repeat--)
{
for (HashMap<ShortStringHash, ResourceGroup>::Iterator i = resourceGroups_.Begin(); i != resourceGroups_.End(); ++i)
for (HashMap<StringHash, ResourceGroup>::Iterator i = resourceGroups_.Begin(); i != resourceGroups_.End(); ++i)
{
bool released = false;
@ -307,7 +307,7 @@ void ResourceCache::ReleaseAllResources(bool force)
while (repeat--)
{
for (HashMap<ShortStringHash, ResourceGroup>::Iterator i = resourceGroups_.Begin();
for (HashMap<StringHash, ResourceGroup>::Iterator i = resourceGroups_.Begin();
i != resourceGroups_.End(); ++i)
{
bool released = false;
@ -355,7 +355,7 @@ bool ResourceCache::ReloadResource(Resource* resource)
return false;
}
void ResourceCache::SetMemoryBudget(ShortStringHash type, unsigned budget)
void ResourceCache::SetMemoryBudget(StringHash type, unsigned budget)
{
resourceGroups_[type].memoryBudget_ = budget;
}
@ -425,12 +425,12 @@ SharedPtr<File> ResourceCache::GetFile(const String& nameIn, bool sendEventOnFai
return SharedPtr<File>();
}
Resource* ResourceCache::GetResource(ShortStringHash type, const String& name, bool sendEventOnFailure)
Resource* ResourceCache::GetResource(StringHash type, const String& name, bool sendEventOnFailure)
{
return GetResource(type, name.CString(), sendEventOnFailure);
}
Resource* ResourceCache::GetResource(ShortStringHash type, const char* nameIn, bool sendEventOnFailure)
Resource* ResourceCache::GetResource(StringHash type, const char* nameIn, bool sendEventOnFailure)
{
String name = SanitateResourceName(nameIn);
@ -488,10 +488,10 @@ Resource* ResourceCache::GetResource(ShortStringHash type, const char* nameIn, b
return resource;
}
void ResourceCache::GetResources(PODVector<Resource*>& result, ShortStringHash type) const
void ResourceCache::GetResources(PODVector<Resource*>& result, StringHash type) const
{
result.Clear();
HashMap<ShortStringHash, ResourceGroup>::ConstIterator i = resourceGroups_.Find(type);
HashMap<StringHash, ResourceGroup>::ConstIterator i = resourceGroups_.Find(type);
if (i != resourceGroups_.End())
{
for (HashMap<StringHash, SharedPtr<Resource> >::ConstIterator j = i->second_.resources_.Begin();
@ -526,18 +526,18 @@ bool ResourceCache::Exists(const String& nameIn) const
return false;
}
unsigned ResourceCache::GetMemoryBudget(ShortStringHash type) const
unsigned ResourceCache::GetMemoryBudget(StringHash type) const
{
HashMap<ShortStringHash, ResourceGroup>::ConstIterator i = resourceGroups_.Find(type);
HashMap<StringHash, ResourceGroup>::ConstIterator i = resourceGroups_.Find(type);
if (i != resourceGroups_.End())
return i->second_.memoryBudget_;
else
return 0;
}
unsigned ResourceCache::GetMemoryUse(ShortStringHash type) const
unsigned ResourceCache::GetMemoryUse(StringHash type) const
{
HashMap<ShortStringHash, ResourceGroup>::ConstIterator i = resourceGroups_.Find(type);
HashMap<StringHash, ResourceGroup>::ConstIterator i = resourceGroups_.Find(type);
if (i != resourceGroups_.End())
return i->second_.memoryUse_;
else
@ -547,7 +547,7 @@ unsigned ResourceCache::GetMemoryUse(ShortStringHash type) const
unsigned ResourceCache::GetTotalMemoryUse() const
{
unsigned total = 0;
for (HashMap<ShortStringHash, ResourceGroup>::ConstIterator i = resourceGroups_.Begin(); i != resourceGroups_.End(); ++i)
for (HashMap<StringHash, ResourceGroup>::ConstIterator i = resourceGroups_.Begin(); i != resourceGroups_.End(); ++i)
total += i->second_.memoryUse_;
return total;
}
@ -673,9 +673,9 @@ void ResourceCache::ResetDependencies(Resource* resource)
}
}
const SharedPtr<Resource>& ResourceCache::FindResource(ShortStringHash type, StringHash nameHash)
const SharedPtr<Resource>& ResourceCache::FindResource(StringHash type, StringHash nameHash)
{
HashMap<ShortStringHash, ResourceGroup>::Iterator i = resourceGroups_.Find(type);
HashMap<StringHash, ResourceGroup>::Iterator i = resourceGroups_.Find(type);
if (i == resourceGroups_.End())
return noResource;
HashMap<StringHash, SharedPtr<Resource> >::Iterator j = i->second_.resources_.Find(nameHash);
@ -687,7 +687,7 @@ const SharedPtr<Resource>& ResourceCache::FindResource(ShortStringHash type, Str
const SharedPtr<Resource>& ResourceCache::FindResource(StringHash nameHash)
{
for (HashMap<ShortStringHash, ResourceGroup>::Iterator i = resourceGroups_.Begin(); i != resourceGroups_.End(); ++i)
for (HashMap<StringHash, ResourceGroup>::Iterator i = resourceGroups_.Begin(); i != resourceGroups_.End(); ++i)
{
HashMap<StringHash, SharedPtr<Resource> >::Iterator j = i->second_.resources_.Find(nameHash);
if (j != i->second_.resources_.End())
@ -699,7 +699,7 @@ const SharedPtr<Resource>& ResourceCache::FindResource(StringHash nameHash)
void ResourceCache::ReleasePackageResources(PackageFile* package, bool force)
{
HashSet<ShortStringHash> affectedGroups;
HashSet<StringHash> affectedGroups;
const HashMap<String, PackageEntry>& entries = package->GetEntries();
for (HashMap<String, PackageEntry>::ConstIterator i = entries.Begin(); i != entries.End(); ++i)
@ -707,7 +707,7 @@ void ResourceCache::ReleasePackageResources(PackageFile* package, bool force)
StringHash nameHash(i->first_);
// We do not know the actual resource type, so search all type containers
for (HashMap<ShortStringHash, ResourceGroup>::Iterator j = resourceGroups_.Begin();
for (HashMap<StringHash, ResourceGroup>::Iterator j = resourceGroups_.Begin();
j != resourceGroups_.End(); ++j)
{
HashMap<StringHash, SharedPtr<Resource> >::Iterator k = j->second_.resources_.Find(nameHash);
@ -724,13 +724,13 @@ void ResourceCache::ReleasePackageResources(PackageFile* package, bool force)
}
}
for (HashSet<ShortStringHash>::Iterator i = affectedGroups.Begin(); i != affectedGroups.End(); ++i)
for (HashSet<StringHash>::Iterator i = affectedGroups.Begin(); i != affectedGroups.End(); ++i)
UpdateResourceGroup(*i);
}
void ResourceCache::UpdateResourceGroup(ShortStringHash type)
void ResourceCache::UpdateResourceGroup(StringHash type)
{
HashMap<ShortStringHash, ResourceGroup>::Iterator i = resourceGroups_.Find(type);
HashMap<StringHash, ResourceGroup>::Iterator i = resourceGroups_.Find(type);
if (i == resourceGroups_.End())
return;

Просмотреть файл

@ -77,11 +77,11 @@ public:
/// Remove a package file by name. Optionally release the resources loaded from it.
void RemovePackageFile(const String& fileName, bool releaseResources = true, bool forceRelease = false);
/// Release a resource by name.
void ReleaseResource(ShortStringHash type, const String& name, bool force = false);
void ReleaseResource(StringHash type, const String& name, bool force = false);
/// Release all resources of a specific type.
void ReleaseResources(ShortStringHash type, bool force = false);
void ReleaseResources(StringHash type, bool force = false);
/// Release resources of a specific type and partial name.
void ReleaseResources(ShortStringHash type, const String& partialName, bool force = false);
void ReleaseResources(StringHash type, const String& partialName, bool force = false);
/// Release resources of all types by partial name.
void ReleaseResources(const String& partialName, bool force = false);
/// Release all resources. When called with the force flag false, releases all currently unused resources.
@ -89,7 +89,7 @@ public:
/// Reload a resource. Return true on success. The resource will not be removed from the cache in case of failure.
bool ReloadResource(Resource* resource);
/// Set memory budget for a specific resource type, default 0 is unlimited.
void SetMemoryBudget(ShortStringHash type, unsigned budget);
void SetMemoryBudget(StringHash type, unsigned budget);
/// Enable or disable automatic reloading of resources as files are modified. Default false.
void SetAutoReloadResources(bool enable);
/// Enable or disable returning resources that failed to load. Default false. This may be useful in editing to not lose resource ref attributes.
@ -100,13 +100,13 @@ public:
/// Open and return a file from the resource load paths or from inside a package file. If not found, use a fallback search with absolute path. Return null if fails.
SharedPtr<File> GetFile(const String& name, bool sendEventOnFailure = true);
/// Return a resource by type and name. Load if not loaded yet. Return null if not found or if fails, unless SetReturnFailedResources(true) has been called.
Resource* GetResource(ShortStringHash type, const String& name, bool sendEventOnFailure = true);
Resource* GetResource(StringHash type, const String& name, bool sendEventOnFailure = true);
/// Return a resource by type and name. Load if not loaded yet. Return null if not found or if fails, unless SetReturnFailedResources(true) has been called.
Resource* GetResource(ShortStringHash type, const char* name, bool sendEventOnFailure = true);
Resource* GetResource(StringHash type, const char* name, bool sendEventOnFailure = true);
/// Return all loaded resources of a specific type.
void GetResources(PODVector<Resource*>& result, ShortStringHash type) const;
void GetResources(PODVector<Resource*>& result, StringHash type) const;
/// Return all loaded resources.
const HashMap<ShortStringHash, ResourceGroup>& GetAllResources() const { return resourceGroups_; }
const HashMap<StringHash, ResourceGroup>& GetAllResources() const { return resourceGroups_; }
/// Return added resource load directories.
const Vector<String>& GetResourceDirs() const { return resourceDirs_; }
/// Return added package files.
@ -120,9 +120,9 @@ public:
/// Return whether a file exists by name.
bool Exists(const String& name) const;
/// Return memory budget for a resource type.
unsigned GetMemoryBudget(ShortStringHash type) const;
unsigned GetMemoryBudget(StringHash type) const;
/// Return total memory use for a resource type.
unsigned GetMemoryUse(ShortStringHash type) const;
unsigned GetMemoryUse(StringHash type) const;
/// Return total memory use for all resources.
unsigned GetTotalMemoryUse() const;
/// Return full absolute file name of resource if possible.
@ -147,13 +147,13 @@ public:
private:
/// Find a resource.
const SharedPtr<Resource>& FindResource(ShortStringHash type, StringHash nameHash);
const SharedPtr<Resource>& FindResource(StringHash type, StringHash nameHash);
/// Find a resource by name only. Searches all type groups.
const SharedPtr<Resource>& FindResource(StringHash nameHash);
/// Release resources loaded from a package file.
void ReleasePackageResources(PackageFile* package, bool force = false);
/// Update a resource group. Recalculate memory use and release resources if over memory budget.
void UpdateResourceGroup(ShortStringHash type);
void UpdateResourceGroup(StringHash type);
/// Handle begin frame event. Automatic resource reloads are processed here.
void HandleBeginFrame(StringHash eventType, VariantMap& eventData);
/// Search FileSystem for File.
@ -162,7 +162,7 @@ private:
File* SearchPackages(const String& nameIn);
/// Resources by type.
HashMap<ShortStringHash, ResourceGroup> resourceGroups_;
HashMap<StringHash, ResourceGroup> resourceGroups_;
/// Resource load directories.
Vector<String> resourceDirs_;
/// File watchers for resource directories, if automatic reloading enabled.
@ -181,20 +181,20 @@ private:
template <class T> T* ResourceCache::GetResource(const String& name, bool sendEventOnFailure)
{
ShortStringHash type = T::GetTypeStatic();
StringHash type = T::GetTypeStatic();
return static_cast<T*>(GetResource(type, name, sendEventOnFailure));
}
template <class T> T* ResourceCache::GetResource(const char* name, bool sendEventOnFailure)
{
ShortStringHash type = T::GetTypeStatic();
StringHash type = T::GetTypeStatic();
return static_cast<T*>(GetResource(type, name, sendEventOnFailure));
}
template <class T> void ResourceCache::GetResources(PODVector<T*>& result) const
{
PODVector<Resource*>& resources = reinterpret_cast<PODVector<Resource*>&>(result);
ShortStringHash type = T::GetTypeStatic();
StringHash type = T::GetTypeStatic();
GetResources(resources, type);
// Perform conversion of the returned pointers

Просмотреть файл

@ -64,7 +64,7 @@ EVENT(E_RESOURCENOTFOUND, ResourceNotFound)
/// Unknown resource type.
EVENT(E_UNKNOWNRESOURCETYPE, UnknownResourceType)
{
PARAM(P_RESOURCETYPE, ResourceType); // ShortStringHash
PARAM(P_RESOURCETYPE, ResourceType); // StringHash
}
}

Просмотреть файл

@ -812,7 +812,7 @@ VariantMap XMLElement::GetVariantMap() const
XMLElement variantElem = GetChild("variant");
while (variantElem)
{
ShortStringHash key(variantElem.GetInt("hash"));
StringHash key(variantElem.GetInt("hash"));
ret[key] = variantElem.GetVariant();
variantElem = variantElem.GetNext("variant");
}

Просмотреть файл

@ -48,7 +48,7 @@ Component::~Component()
bool Component::Save(Serializer& dest) const
{
// Write type and ID
if (!dest.WriteShortStringHash(GetType()))
if (!dest.WriteStringHash(GetType()))
return false;
if (!dest.WriteUInt(id_))
return false;
@ -216,7 +216,7 @@ void Component::SetNode(Node* node)
OnNodeSet(node_);
}
Component* Component::GetComponent(ShortStringHash type) const
Component* Component::GetComponent(StringHash type) const
{
return node_ ? node_->GetComponent(type) : 0;
}
@ -226,7 +226,7 @@ bool Component::IsEnabledEffective() const
return enabled_ && node_ && node_->IsEnabled();
}
void Component::GetComponents(PODVector<Component*>& dest, ShortStringHash type) const
void Component::GetComponents(PODVector<Component*>& dest, StringHash type) const
{
if (node_)
node_->GetComponents(dest, type);

Просмотреть файл

@ -77,9 +77,9 @@ public:
/// Return whether is effectively enabled (node is also enabled.)
bool IsEnabledEffective() const;
/// Return component in the same scene node by type. If there are several, returns the first.
Component* GetComponent(ShortStringHash type) const;
Component* GetComponent(StringHash type) const;
/// Return components in the same scene node by type.
void GetComponents(PODVector<Component*>& dest, ShortStringHash type) const;
void GetComponents(PODVector<Component*>& dest, StringHash type) const;
/// Template version of returning a component in the same scene node by type.
template <class T> T* GetComponent() const;
/// Template version of returning components in the same scene node by type.

Просмотреть файл

@ -706,7 +706,7 @@ void Node::RemoveChildren(bool removeReplicated, bool removeLocal, bool recursiv
MarkReplicationDirty();
}
Component* Node::CreateComponent(ShortStringHash type, CreateMode mode, unsigned id)
Component* Node::CreateComponent(StringHash type, CreateMode mode, unsigned id)
{
// Check that creation succeeds and that the object in fact is a component
SharedPtr<Component> newComponent = DynamicCast<Component>(context_->CreateObject(type));
@ -720,7 +720,7 @@ Component* Node::CreateComponent(ShortStringHash type, CreateMode mode, unsigned
return newComponent;
}
Component* Node::GetOrCreateComponent(ShortStringHash type, CreateMode mode, unsigned id)
Component* Node::GetOrCreateComponent(StringHash type, CreateMode mode, unsigned id)
{
Component* oldComponent = GetComponent(type);
if (oldComponent)
@ -794,7 +794,7 @@ void Node::RemoveComponent(Component* component)
}
}
void Node::RemoveComponent(ShortStringHash type)
void Node::RemoveComponent(StringHash type)
{
for (Vector<SharedPtr<Component> >::Iterator i = components_.Begin(); i != components_.End(); ++i)
{
@ -885,7 +885,7 @@ void Node::SetParent(Node* parent)
}
}
void Node::SetVar(ShortStringHash key, const Variant& value)
void Node::SetVar(StringHash key, const Variant& value)
{
vars_[key] = value;
MarkNetworkUpdate();
@ -980,7 +980,7 @@ void Node::GetChildren(PODVector<Node*>& dest, bool recursive) const
GetChildrenRecursive(dest);
}
void Node::GetChildrenWithComponent(PODVector<Node*>& dest, ShortStringHash type, bool recursive) const
void Node::GetChildrenWithComponent(PODVector<Node*>& dest, StringHash type, bool recursive) const
{
dest.Clear();
@ -1041,7 +1041,7 @@ unsigned Node::GetNumNetworkComponents() const
return num;
}
void Node::GetComponents(PODVector<Component*>& dest, ShortStringHash type, bool recursive) const
void Node::GetComponents(PODVector<Component*>& dest, StringHash type, bool recursive) const
{
dest.Clear();
@ -1057,7 +1057,7 @@ void Node::GetComponents(PODVector<Component*>& dest, ShortStringHash type, bool
GetComponentsRecursive(dest, type);
}
bool Node::HasComponent(ShortStringHash type) const
bool Node::HasComponent(StringHash type) const
{
for (Vector<SharedPtr<Component> >::ConstIterator i = components_.Begin(); i != components_.End(); ++i)
{
@ -1067,13 +1067,13 @@ bool Node::HasComponent(ShortStringHash type) const
return false;
}
const Variant& Node::GetVar(ShortStringHash key) const
const Variant& Node::GetVar(StringHash key) const
{
VariantMap::ConstIterator i = vars_.Find(key);
return i != vars_.End() ? i->second_ : Variant::EMPTY;
}
Component* Node::GetComponent(ShortStringHash type) const
Component* Node::GetComponent(StringHash type) const
{
for (Vector<SharedPtr<Component> >::ConstIterator i = components_.Begin(); i != components_.End(); ++i)
{
@ -1209,7 +1209,7 @@ bool Node::Load(Deserializer& source, SceneResolver& resolver, bool readChildren
for (unsigned i = 0; i < numComponents; ++i)
{
VectorBuffer compBuffer(source, source.ReadVLE());
ShortStringHash compType = compBuffer.ReadShortStringHash();
StringHash compType = compBuffer.ReadStringHash();
unsigned compID = compBuffer.ReadUInt();
Component* newComponent = SafeCreateComponent(String::EMPTY, compType,
@ -1253,7 +1253,7 @@ bool Node::LoadXML(const XMLElement& source, SceneResolver& resolver, bool readC
{
String typeName = compElem.GetAttribute("type");
unsigned compID = compElem.GetInt("id");
Component* newComponent = SafeCreateComponent(typeName, ShortStringHash(typeName),
Component* newComponent = SafeCreateComponent(typeName, StringHash(typeName),
(mode == REPLICATED && compID < FIRST_LOCAL_ID) ? REPLICATED : LOCAL, rewriteIDs ? 0 : compID);
if (newComponent)
{
@ -1515,7 +1515,7 @@ void Node::OnAttributeAnimationRemoved()
UnsubscribeFromEvent(GetScene(), E_ATTRIBUTEANIMATIONUPDATE);
}
Component* Node::SafeCreateComponent(const String& typeName, ShortStringHash type, CreateMode mode, unsigned id)
Component* Node::SafeCreateComponent(const String& typeName, StringHash type, CreateMode mode, unsigned id)
{
// First check if factory for type exists
if (!context_->GetTypeName(type).Empty())
@ -1586,7 +1586,7 @@ void Node::GetChildrenRecursive(PODVector<Node*>& dest) const
}
}
void Node::GetChildrenWithComponentRecursive(PODVector<Node*>& dest, ShortStringHash type) const
void Node::GetChildrenWithComponentRecursive(PODVector<Node*>& dest, StringHash type) const
{
for (Vector<SharedPtr<Node> >::ConstIterator i = children_.Begin(); i != children_.End(); ++i)
{
@ -1598,7 +1598,7 @@ void Node::GetChildrenWithComponentRecursive(PODVector<Node*>& dest, ShortString
}
}
void Node::GetComponentsRecursive(PODVector<Component*>& dest, ShortStringHash type) const
void Node::GetComponentsRecursive(PODVector<Component*>& dest, StringHash type) const
{
for (Vector<SharedPtr<Component> >::ConstIterator i = components_.Begin(); i != components_.End(); ++i)
{

Просмотреть файл

@ -197,9 +197,9 @@ public:
/// Remove child scene nodes that match criteria.
void RemoveChildren(bool removeReplicated, bool removeLocal, bool recursive);
/// Create a component to this node (with specified ID if provided).
Component* CreateComponent(ShortStringHash type, CreateMode mode = REPLICATED, unsigned id = 0);
Component* CreateComponent(StringHash type, CreateMode mode = REPLICATED, unsigned id = 0);
/// Create a component to this node if it does not exist already.
Component* GetOrCreateComponent(ShortStringHash type, CreateMode mode = REPLICATED, unsigned id = 0);
Component* GetOrCreateComponent(StringHash type, CreateMode mode = REPLICATED, unsigned id = 0);
/// Clone a component from another node using its create mode. Return the clone if successful or null on failure.
Component* CloneComponent(Component* component, unsigned id = 0);
/// Clone a component from another node and specify the create mode. Return the clone if successful or null on failure.
@ -207,7 +207,7 @@ public:
/// Remove a component from this node.
void RemoveComponent(Component* component);
/// Remove the first component of specific type from this node.
void RemoveComponent(ShortStringHash type);
void RemoveComponent(StringHash type);
/// Remove all components from this node.
void RemoveAllComponents();
/// Remove components that match criteria.
@ -219,7 +219,7 @@ public:
/// Set parent scene node. Retains the world transform.
void SetParent(Node* parent);
/// Set a user variable.
void SetVar(ShortStringHash key, const Variant& value);
void SetVar(StringHash key, const Variant& value);
/// Add listener component that is notified of node being dirtied. Can either be in the same node or another.
void AddListener(Component* component);
/// Remove listener component.
@ -371,7 +371,7 @@ public:
/// Return child scene nodes, optionally recursive.
void GetChildren(PODVector<Node*>& dest, bool recursive = false) const;
/// Return child scene nodes with a specific component.
void GetChildrenWithComponent(PODVector<Node*>& dest, ShortStringHash type, bool recursive = false) const;
void GetChildrenWithComponent(PODVector<Node*>& dest, StringHash type, bool recursive = false) const;
/// Return child scene node by index.
Node* GetChild(unsigned index) const;
/// Return child scene node by name.
@ -387,15 +387,15 @@ public:
/// Return all components.
const Vector<SharedPtr<Component> >& GetComponents() const { return components_; }
/// Return all components of type. Optionally recursive.
void GetComponents(PODVector<Component*>& dest, ShortStringHash type, bool recursive = false) const;
void GetComponents(PODVector<Component*>& dest, StringHash type, bool recursive = false) const;
/// Return component by type. If there are several, returns the first.
Component* GetComponent(ShortStringHash type) const;
Component* GetComponent(StringHash type) const;
/// Return whether has a specific component.
bool HasComponent(ShortStringHash type) const;
bool HasComponent(StringHash type) const;
/// Return listener components.
const Vector<WeakPtr<Component> > GetListeners() const { return listeners_; }
/// Return a user variable.
const Variant& GetVar(ShortStringHash key) const;
const Variant& GetVar(StringHash key) const;
/// Return all user variables.
const VariantMap& GetVars() const { return vars_; }
/// Return first component derived from class.
@ -463,7 +463,7 @@ protected:
private:
/// Create component, allowing UnknownComponent if actual type is not supported. Leave typeName empty if not known.
Component* SafeCreateComponent(const String& typeName, ShortStringHash type, CreateMode mode, unsigned id);
Component* SafeCreateComponent(const String& typeName, StringHash type, CreateMode mode, unsigned id);
/// Recalculate the world transform.
void UpdateWorldTransform() const;
/// Remove child node by iterator.
@ -471,9 +471,9 @@ private:
/// Return child nodes recursively.
void GetChildrenRecursive(PODVector<Node*>& dest) const;
/// Return child nodes with a specific component recursively.
void GetChildrenWithComponentRecursive(PODVector<Node*>& dest, ShortStringHash type) const;
void GetChildrenWithComponentRecursive(PODVector<Node*>& dest, StringHash type) const;
/// Return specific components recursively.
void GetComponentsRecursive(PODVector<Component*>& dest, ShortStringHash type) const;
void GetComponentsRecursive(PODVector<Component*>& dest, StringHash type) const;
/// Clone node recursively.
Node* CloneRecursive(Node* parent, SceneResolver& resolver, CreateMode mode);
/// Remove a component from this node with the specified iterator.

Просмотреть файл

@ -172,7 +172,7 @@ struct URHO3D_API NodeReplicationState : public ReplicationState
/// Dirty attribute bits.
DirtyBits dirtyAttributes_;
/// Dirty user vars.
HashSet<ShortStringHash> dirtyVars_;
HashSet<StringHash> dirtyVars_;
/// Components by ID.
HashMap<unsigned, ComponentReplicationState> componentStates_;
/// Interest management priority accumulator.

Просмотреть файл

@ -520,9 +520,9 @@ float Scene::GetAsyncProgress() const
return (float)asyncProgress_.loadedNodes_ / (float)asyncProgress_.totalNodes_;
}
const String& Scene::GetVarName(ShortStringHash hash) const
const String& Scene::GetVarName(StringHash hash) const
{
HashMap<ShortStringHash, String>::ConstIterator i = varNames_.Find(hash);
HashMap<StringHash, String>::ConstIterator i = varNames_.Find(hash);
return i != varNames_.End() ? i->second_ : String::EMPTY;
}
@ -799,7 +799,7 @@ String Scene::GetVarNamesAttr() const
if (!varNames_.Empty())
{
for (HashMap<ShortStringHash, String>::ConstIterator i = varNames_.Begin(); i != varNames_.End(); ++i)
for (HashMap<StringHash, String>::ConstIterator i = varNames_.Begin(); i != varNames_.End(); ++i)
ret += i->second_ + ';';
ret.Resize(ret.Length() - 1);

Просмотреть файл

@ -145,7 +145,7 @@ public:
/// Return required package files.
const Vector<SharedPtr<PackageFile> >& GetRequiredPackageFiles() const { return requiredPackageFiles_; }
/// Return a node user variable name, or empty if not registered.
const String& GetVarName(ShortStringHash hash) const;
const String& GetVarName(StringHash hash) const;
/// Update scene. Called by HandleUpdate.
void Update(float timeStep);
@ -213,7 +213,7 @@ private:
/// Required package files for networking.
Vector<SharedPtr<PackageFile> > requiredPackageFiles_;
/// Registered node user variable reverse mappings.
HashMap<ShortStringHash, String> varNames_;
HashMap<StringHash, String> varNames_;
/// Nodes to check for attribute changes on the next network update.
HashSet<unsigned> networkUpdateNodes_;
/// Components to check for attribute changes on the next network update.

Просмотреть файл

@ -61,7 +61,7 @@ void SceneResolver::AddComponent(unsigned oldID, Component* component)
void SceneResolver::Resolve()
{
// Nodes do not have component or node ID attributes, so only have to go through components
HashSet<ShortStringHash> noIDAttributes;
HashSet<StringHash> noIDAttributes;
for (HashMap<unsigned, WeakPtr<Component> >::ConstIterator i = components_.Begin(); i != components_.End(); ++i)
{
Component* component = i->second_;

Просмотреть файл

@ -33,10 +33,10 @@
namespace Urho3D
{
static HashMap<ShortStringHash, String> unknownTypeToName;
static HashMap<StringHash, String> unknownTypeToName;
static String letters("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static String GenerateNameFromType(ShortStringHash typeHash)
static String GenerateNameFromType(StringHash typeHash)
{
if (unknownTypeToName.Contains(typeHash))
return unknownTypeToName[typeHash];
@ -62,7 +62,7 @@ static String GenerateNameFromType(ShortStringHash typeHash)
current /= numLetters;
}
if (ShortStringHash(test) == typeHash)
if (StringHash(test) == typeHash)
{
found = true;
break;
@ -141,7 +141,7 @@ bool UnknownComponent::Save(Serializer& dest) const
LOGWARNING("UnknownComponent loaded in XML mode, attributes will be empty for binary save");
// Write type and ID
if (!dest.WriteShortStringHash(GetType()))
if (!dest.WriteStringHash(GetType()))
return false;
if (!dest.WriteUInt(id_))
return false;
@ -185,7 +185,7 @@ void UnknownComponent::SetTypeName(const String& typeName)
typeHash_ = typeName;
}
void UnknownComponent::SetType(ShortStringHash typeHash)
void UnknownComponent::SetType(StringHash typeHash)
{
typeName_ = GenerateNameFromType(typeHash);
typeHash_ = typeHash;

Просмотреть файл

@ -38,7 +38,7 @@ public:
static void RegisterObject(Context* context);
/// Return type of the stored component.
virtual ShortStringHash GetType() const { return typeHash_; }
virtual StringHash GetType() const { return typeHash_; }
/// Return type name of the stored component.
virtual const String& GetTypeName() const { return typeName_; }
/// Return attribute descriptions, or null if none defined.
@ -55,7 +55,7 @@ public:
/// Initialize the type name. Called by Node when loading.
void SetTypeName(const String& typeName);
/// Initialize the type hash only when type name not known. Called by Node when loading.
void SetType(ShortStringHash typeHash);
void SetType(StringHash typeHash);
/// Return the XML format attributes. Empty when loaded with binary serialization.
const Vector<String>& GetXMLAttributes() const { return xmlAttributes_; }
@ -65,13 +65,13 @@ public:
bool GetUseXML() const { return useXML_; }
/// Return static type.
static Urho3D::ShortStringHash GetTypeStatic() { static const ShortStringHash typeStatic("UnknownComponent"); return typeStatic; } \
static Urho3D::StringHash GetTypeStatic() { static const StringHash typeStatic("UnknownComponent"); return typeStatic; } \
/// Return static type name.
static const Urho3D::String& GetTypeNameStatic() { static const String typeNameStatic("UnknownComponent"); return typeNameStatic; } \
private:
/// Type of stored component.
ShortStringHash typeHash_;
StringHash typeHash_;
/// Type name of the stored component.
String typeName_;
/// XML format attribute infos.

Просмотреть файл

@ -254,7 +254,6 @@ template <class T> void RegisterSerializer(asIScriptEngine* engine, const char*
engine->RegisterObjectMethod(className, "bool WriteString(const String&in)", asMETHODPR(T, WriteString, (const String&), bool), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "bool WriteFileID(const String&in)", asMETHODPR(T, WriteFileID, (const String&), bool), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "bool WriteStringHash(const StringHash&in)", asMETHODPR(T, WriteStringHash, (const StringHash&), bool), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "bool WriteShortStringHash(const ShortStringHash&in)", asMETHODPR(T, WriteShortStringHash, (const ShortStringHash&), bool), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "bool WriteVariant(const Variant&in)", asMETHODPR(T, WriteVariant, (const Variant&), bool), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "bool WriteVariantMap(const VariantMap&in)", asMETHODPR(T, WriteVariantMap, (const VariantMap&), bool), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "bool WriteVLE(uint)", asMETHODPR(T, WriteVLE, (unsigned), bool), asCALL_THISCALL);
@ -299,7 +298,6 @@ template <class T> void RegisterDeserializer(asIScriptEngine* engine, const char
engine->RegisterObjectMethod(className, "String ReadString()", asMETHODPR(T, ReadString, (), String), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "String ReadFileID()", asMETHODPR(T, ReadFileID, (), String), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "StringHash ReadStringHash()", asMETHODPR(T, ReadStringHash, (), StringHash), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "ShortStringHash ReadShortStringHash()", asMETHODPR(T, ReadShortStringHash, (), ShortStringHash), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "Variant ReadVariant()", asMETHODPR(T, ReadVariant, (), Variant), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "VariantMap ReadVariantMap()", asMETHODPR(T, ReadVariantMap, (), VariantMap), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "uint ReadVLE()", asMETHODPR(T, ReadVLE, (), unsigned), asCALL_THISCALL);
@ -334,8 +332,8 @@ template <class T> void ObjectSendEvent(const String& eventType, VariantMap& eve
template <class T> void RegisterObject(asIScriptEngine* engine, const char* className)
{
RegisterRefCounted<T>(engine, className);
engine->RegisterObjectMethod(className, "ShortStringHash get_type() const", asMETHODPR(T, GetType, () const, ShortStringHash), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "ShortStringHash get_baseType() const", asMETHODPR(T, GetBaseType, () const, ShortStringHash), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "StringHash get_type() const", asMETHODPR(T, GetType, () const, StringHash), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "StringHash get_baseType() const", asMETHODPR(T, GetBaseType, () const, StringHash), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "const String& get_typeName() const", asMETHODPR(T, GetTypeName, () const, const String&), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "const String& get_category() const", asMETHODPR(T, GetCategory, () const, const String&), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "void SendEvent(const String&in, VariantMap& eventData = VariantMap())", asFUNCTION(ObjectSendEvent<T>), asCALL_CDECL_OBJLAST);
@ -993,10 +991,10 @@ template <class T> void RegisterUIElement(asIScriptEngine* engine, const char* c
engine->RegisterObjectMethod(className, "uint FindChild(UIElement@+) const", asMETHOD(T, FindChild), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "void SetParent(UIElement@+, uint index = M_MAX_UNSIGNED)", asMETHOD(T, SetParent), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "UIElement@+ GetChild(const String&in, bool recursive = false) const", asMETHODPR(T, GetChild, (const String&, bool) const, UIElement*), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "UIElement@+ GetChild(const ShortStringHash&in, const Variant&in value = Variant(), bool recursive = false) const", asMETHODPR(T, GetChild, (const ShortStringHash&, const Variant&, bool) const, UIElement*), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "UIElement@+ GetChild(const StringHash&in, const Variant&in value = Variant(), bool recursive = false) const", asMETHODPR(T, GetChild, (const StringHash&, const Variant&, bool) const, UIElement*), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "Array<UIElement@>@ GetChildren(bool recursive = false) const", asFUNCTION(UIElementGetChildren), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod(className, "UIElement@+ GetElementEventSender() const", asMETHOD(T, GetElementEventSender), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "const Variant& GetVar(const ShortStringHash&in)", asMETHOD(T, GetVar), asCALL_THISCALL);
engine->RegisterObjectMethod(className, "const Variant& GetVar(const StringHash&in)", asMETHOD(T, GetVar), asCALL_THISCALL);
if (!isSprite)
{
engine->RegisterObjectMethod(className, "IntVector2 ScreenToElement(const IntVector2&in)", asMETHOD(T, ScreenToElement), asCALL_THISCALL);

Просмотреть файл

@ -60,41 +60,6 @@ static int StringHashCmp(const StringHash& lhs, const StringHash& rhs)
return cmp;
}
static void ConstructShortStringHash(ShortStringHash* ptr)
{
new(ptr) ShortStringHash();
}
static void ConstructShortStringHashCopyShort(const ShortStringHash& hash, ShortStringHash* ptr)
{
new(ptr) ShortStringHash(hash);
}
static void ConstructShortStringHashCopyLong(const StringHash& hash, ShortStringHash* ptr)
{
new(ptr) ShortStringHash(hash);
}
static void ConstructShortStringHashInit(const String& str, ShortStringHash* ptr)
{
new(ptr) ShortStringHash(str);
}
static void ConstructShortStringHashInitUInt(unsigned value, ShortStringHash* ptr)
{
new(ptr) ShortStringHash(value);
}
static int ShortStringHashCmp(const ShortStringHash& lhs, const ShortStringHash& rhs)
{
int cmp = 0;
if (lhs < rhs)
cmp = -1;
else if (lhs > rhs)
cmp = 1;
return cmp;
}
static void RegisterStringHash(asIScriptEngine* engine)
{
engine->RegisterObjectType("StringHash", sizeof(StringHash), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CAK);
@ -109,18 +74,6 @@ static void RegisterStringHash(asIScriptEngine* engine)
engine->RegisterObjectMethod("StringHash", "StringHash opAdd(const StringHash&in) const", asMETHOD(StringHash, operator +), asCALL_THISCALL);
engine->RegisterObjectMethod("StringHash", "String ToString() const", asMETHOD(StringHash, ToString), asCALL_THISCALL);
engine->RegisterObjectMethod("StringHash", "uint get_value()", asMETHOD(StringHash, Value), asCALL_THISCALL);
engine->RegisterObjectType("ShortStringHash", sizeof(ShortStringHash), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CAK);
engine->RegisterObjectBehaviour("ShortStringHash", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructShortStringHash), asCALL_CDECL_OBJLAST);
engine->RegisterObjectBehaviour("ShortStringHash", asBEHAVE_CONSTRUCT, "void f(const ShortStringHash&in)", asFUNCTION(ConstructShortStringHashCopyShort), asCALL_CDECL_OBJLAST);
engine->RegisterObjectBehaviour("ShortStringHash", asBEHAVE_CONSTRUCT, "void f(const StringHash&in)", asFUNCTION(ConstructShortStringHashCopyLong), asCALL_CDECL_OBJLAST);
engine->RegisterObjectBehaviour("ShortStringHash", asBEHAVE_CONSTRUCT, "void f(const String&in)", asFUNCTION(ConstructShortStringHashInit), asCALL_CDECL_OBJLAST);
engine->RegisterObjectBehaviour("ShortStringHash", asBEHAVE_CONSTRUCT, "void f(uint)", asFUNCTION(ConstructShortStringHashInitUInt), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("ShortStringHash", "ShortStringHash& opAssign(const ShortStringHash&in)", asMETHODPR(ShortStringHash, operator =, (const ShortStringHash&), ShortStringHash&), asCALL_THISCALL);
engine->RegisterObjectMethod("ShortStringHash", "bool opEquals(const ShortStringHash&in) const", asMETHOD(ShortStringHash, operator ==), asCALL_THISCALL);
engine->RegisterObjectMethod("ShortStringHash", "int opCmp(const ShortStringHash&in) const", asFUNCTION(ShortStringHashCmp), asCALL_CDECL_OBJFIRST);
engine->RegisterObjectMethod("ShortStringHash", "String ToString() const", asMETHOD(ShortStringHash, ToString), asCALL_THISCALL);
engine->RegisterObjectMethod("ShortStringHash", "uint16 get_value()", asMETHOD(ShortStringHash, Value), asCALL_THISCALL);
}
static void ConstructResourceRef(ResourceRef* ptr)
@ -223,11 +176,6 @@ static void ConstructVariantStringHash(const StringHash& value, Variant* ptr)
new(ptr) Variant(value);
}
static void ConstructVariantShortStringHash(const ShortStringHash& value, Variant* ptr)
{
new(ptr) Variant(value);
}
static void ConstructVariantBool(bool value, Variant* ptr)
{
new(ptr) Variant(value);
@ -375,7 +323,7 @@ static Variant& VariantMapAt(const String& key, VariantMap& map)
return map[key];
}
static Variant& VariantMapAtHash(ShortStringHash key, VariantMap& map)
static Variant& VariantMapAtHash(StringHash key, VariantMap& map)
{
return map[key];
}
@ -390,19 +338,19 @@ static bool VariantMapErase(const String& key, VariantMap& map)
return map.Erase(key);
}
static bool VariantMapContainsHash(ShortStringHash key, VariantMap& map)
static bool VariantMapContainsHash(StringHash key, VariantMap& map)
{
return map.Contains(key);
}
static bool VariantMapEraseHash(ShortStringHash key, VariantMap& map)
static bool VariantMapEraseHash(StringHash key, VariantMap& map)
{
return map.Erase(key);
}
static CScriptArray* VariantMapGetKeys(const VariantMap& map)
{
return VectorToArray<ShortStringHash>(map.Keys(), "Array<ShortStringHash>");
return VectorToArray<StringHash>(map.Keys(), "Array<StringHash>");
}
static void RegisterVariant(asIScriptEngine* engine)
@ -437,7 +385,7 @@ static void RegisterVariant(asIScriptEngine* engine)
engine->RegisterObjectBehaviour("ResourceRef", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(DestructResourceRef), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("ResourceRef", "ResourceRef& opAssign(const ResourceRef&in)", asMETHOD(ResourceRef, operator =), asCALL_THISCALL);
engine->RegisterObjectMethod("ResourceRef", "bool opEquals(const ResourceRef&in) const", asMETHOD(ResourceRef, operator ==), asCALL_THISCALL);
engine->RegisterObjectProperty("ResourceRef", "ShortStringHash type", offsetof(ResourceRef, type_));
engine->RegisterObjectProperty("ResourceRef", "StringHash type", offsetof(ResourceRef, type_));
engine->RegisterObjectProperty("ResourceRef", "String name", offsetof(ResourceRef, name_));
engine->RegisterObjectType("ResourceRefList", sizeof(ResourceRefList), asOBJ_VALUE | asOBJ_APP_CLASS_C);
@ -451,7 +399,7 @@ static void RegisterVariant(asIScriptEngine* engine)
engine->RegisterObjectMethod("ResourceRefList", "bool get_empty() const", asFUNCTION(ResourceRefListIsEmpty), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("ResourceRefList", "void set_names(uint, const String&in) const", asFUNCTION(ResourceRefListSetName), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("ResourceRefList", "const String& get_names(uint) const", asFUNCTION(ResourceRefListGetName), asCALL_CDECL_OBJLAST);
engine->RegisterObjectProperty("ResourceRefList", "ShortStringHash type", offsetof(ResourceRef, type_));
engine->RegisterObjectProperty("ResourceRefList", "StringHash type", offsetof(ResourceRef, type_));
RegisterRefCounted<RefCounted>(engine, "RefCounted");
@ -462,7 +410,6 @@ static void RegisterVariant(asIScriptEngine* engine)
engine->RegisterObjectBehaviour("Variant", asBEHAVE_CONSTRUCT, "void f(int)", asFUNCTION(ConstructVariantInt), asCALL_CDECL_OBJLAST);
engine->RegisterObjectBehaviour("Variant", asBEHAVE_CONSTRUCT, "void f(uint)", asFUNCTION(ConstructVariantUInt), asCALL_CDECL_OBJLAST);
engine->RegisterObjectBehaviour("Variant", asBEHAVE_CONSTRUCT, "void f(const StringHash&in)", asFUNCTION(ConstructVariantStringHash), asCALL_CDECL_OBJLAST);
engine->RegisterObjectBehaviour("Variant", asBEHAVE_CONSTRUCT, "void f(const ShortStringHash&in)", asFUNCTION(ConstructVariantShortStringHash), asCALL_CDECL_OBJLAST);
engine->RegisterObjectBehaviour("Variant", asBEHAVE_CONSTRUCT, "void f(bool)", asFUNCTION(ConstructVariantBool), asCALL_CDECL_OBJLAST);
engine->RegisterObjectBehaviour("Variant", asBEHAVE_CONSTRUCT, "void f(float)", asFUNCTION(ConstructVariantFloat), asCALL_CDECL_OBJLAST);
engine->RegisterObjectBehaviour("Variant", asBEHAVE_CONSTRUCT, "void f(const Vector2&in)", asFUNCTION(ConstructVariantVector2), asCALL_CDECL_OBJLAST);
@ -489,7 +436,6 @@ static void RegisterVariant(asIScriptEngine* engine)
engine->RegisterObjectMethod("Variant", "Variant& opAssign(int)", asMETHODPR(Variant, operator =, (int), Variant&), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "Variant& opAssign(uint)", asMETHODPR(Variant, operator =, (unsigned), Variant&), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "Variant& opAssign(const StringHash&in)", asMETHODPR(Variant, operator =, (const StringHash&), Variant&), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "Variant& opAssign(const ShortStringHash&in)", asMETHODPR(Variant, operator =, (const ShortStringHash&), Variant&), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "Variant& opAssign(bool)", asMETHODPR(Variant, operator =, (bool), Variant&), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "Variant& opAssign(float)", asMETHODPR(Variant, operator =, (float), Variant&), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "Variant& opAssign(const Vector2&in)", asMETHODPR(Variant, operator =, (const Vector2&), Variant&), asCALL_THISCALL);
@ -512,7 +458,6 @@ static void RegisterVariant(asIScriptEngine* engine)
engine->RegisterObjectMethod("Variant", "bool opEquals(int) const", asMETHODPR(Variant, operator ==, (int) const, bool), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "bool opEquals(uint) const", asMETHODPR(Variant, operator ==, (unsigned) const, bool), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "bool opEquals(const StringHash&in) const", asMETHODPR(Variant, operator ==, (const StringHash&) const, bool), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "bool opEquals(const ShortStringHash&in) const", asMETHODPR(Variant, operator ==, (const ShortStringHash&) const, bool), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "bool opEquals(bool) const", asMETHODPR(Variant, operator ==, (bool) const, bool), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "bool opEquals(float) const", asMETHODPR(Variant, operator ==, (float) const, bool), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "bool opEquals(const Vector2&in) const", asMETHODPR(Variant, operator ==, (const Vector2&) const, bool), asCALL_THISCALL);
@ -534,7 +479,6 @@ static void RegisterVariant(asIScriptEngine* engine)
engine->RegisterObjectMethod("Variant", "int GetInt() const", asMETHOD(Variant, GetInt), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "uint GetUInt() const", asMETHOD(Variant, GetUInt), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "StringHash GetStringHash() const", asMETHOD(Variant, GetStringHash), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "ShortStringHash GetShortStringHash() const", asMETHOD(Variant, GetShortStringHash), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "bool GetBool() const", asMETHOD(Variant, GetBool), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "float GetFloat() const", asMETHOD(Variant, GetFloat), asCALL_THISCALL);
engine->RegisterObjectMethod("Variant", "const Vector2& GetVector2() const", asMETHOD(Variant, GetVector2), asCALL_THISCALL);
@ -567,15 +511,15 @@ static void RegisterVariant(asIScriptEngine* engine)
engine->RegisterObjectMethod("VariantMap", "VariantMap& opAssign(const VariantMap&in)", asMETHODPR(VariantMap, operator =, (const VariantMap&), VariantMap&), asCALL_THISCALL);
engine->RegisterObjectMethod("VariantMap", "Variant& opIndex(const String&in)", asFUNCTION(VariantMapAt), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("VariantMap", "const Variant& opIndex(const String&in) const", asFUNCTION(VariantMapAt), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("VariantMap", "Variant& opIndex(ShortStringHash)", asFUNCTION(VariantMapAtHash), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("VariantMap", "const Variant& opIndex(ShortStringHash) const", asFUNCTION(VariantMapAtHash), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("VariantMap", "Variant& opIndex(StringHash)", asFUNCTION(VariantMapAtHash), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("VariantMap", "const Variant& opIndex(StringHash) const", asFUNCTION(VariantMapAtHash), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("VariantMap", "bool Contains(const String&in) const", asFUNCTION(VariantMapContains), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("VariantMap", "bool Erase(const String&in)", asFUNCTION(VariantMapErase), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("VariantMap", "bool Contains(ShortStringHash) const", asFUNCTION(VariantMapContainsHash), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("VariantMap", "bool Erase(ShortStringHash)", asFUNCTION(VariantMapEraseHash), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("VariantMap", "bool Contains(StringHash) const", asFUNCTION(VariantMapContainsHash), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("VariantMap", "bool Erase(StringHash)", asFUNCTION(VariantMapEraseHash), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("VariantMap", "void Clear()", asMETHOD(VariantMap, Clear), asCALL_THISCALL);
engine->RegisterObjectMethod("VariantMap", "uint get_length() const", asMETHOD(VariantMap, Size), asCALL_THISCALL);
engine->RegisterObjectMethod("VariantMap", "Array<ShortStringHash>@ get_keys() const", asFUNCTION(VariantMapGetKeys), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("VariantMap", "Array<StringHash>@ get_keys() const", asFUNCTION(VariantMapGetKeys), asCALL_CDECL_OBJLAST);
}
static void ConstructSpline(Spline* ptr)
@ -829,7 +773,7 @@ static Object* GetEventSender()
return GetScriptContext()->GetEventSender();
}
static const String& GetTypeName(ShortStringHash type)
static const String& GetTypeName(StringHash type)
{
return GetScriptContext()->GetTypeName(type);
}
@ -878,7 +822,7 @@ void RegisterObject(asIScriptEngine* engine)
engine->RegisterGlobalFunction("void UnsubscribeFromAllEvents()", asFUNCTION(UnsubscribeFromAllEvents), asCALL_CDECL);
engine->RegisterGlobalFunction("void UnsubscribeFromAllEventsExcept(Array<String>@+)", asFUNCTION(UnsubscribeFromAllEventsExcept), asCALL_CDECL);
engine->RegisterGlobalFunction("Object@+ GetEventSender()", asFUNCTION(GetEventSender), asCALL_CDECL);
engine->RegisterGlobalFunction("const String& GetTypeName(ShortStringHash)", asFUNCTION(GetTypeName), asCALL_CDECL);
engine->RegisterGlobalFunction("const String& GetTypeName(StringHash)", asFUNCTION(GetTypeName), asCALL_CDECL);
engine->RegisterObjectType("WeakHandle", sizeof(WeakPtr<RefCounted>), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK);
engine->RegisterObjectBehaviour("WeakHandle", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructWeakHandle), asCALL_CDECL_OBJLAST);

Просмотреть файл

@ -40,7 +40,7 @@ void RegisterResource(asIScriptEngine* engine)
static Resource* ResourceCacheGetResource(const String& type, const String& name, bool sendEventOnFailure, ResourceCache* ptr)
{
return ptr->GetResource(ShortStringHash(type), name, sendEventOnFailure);
return ptr->GetResource(StringHash(type), name, sendEventOnFailure);
}
static File* ResourceCacheGetFile(const String& name, ResourceCache* ptr)
@ -103,7 +103,7 @@ static void RegisterResourceCache(asIScriptEngine* engine)
engine->RegisterObjectMethod("ResourceCache", "void RemovePackageFile(PackageFile@+, bool releaseResources = true, bool forceRelease = false)", asMETHODPR(ResourceCache, RemovePackageFile, (PackageFile*, bool, bool), void), asCALL_THISCALL);
engine->RegisterObjectMethod("ResourceCache", "void RemovePackageFile(const String&in, bool releaseResources = true, bool forceRelease = false)", asMETHODPR(ResourceCache, RemovePackageFile, (const String&, bool, bool), void), asCALL_THISCALL);
engine->RegisterObjectMethod("ResourceCache", "void ReleaseResource(const String&in, const String&in, bool force = false)", asFUNCTION(ResourceCacheReleaseResource), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("ResourceCache", "void ReleaseResources(ShortStringHash, bool force = false)", asMETHODPR(ResourceCache, ReleaseResources, (ShortStringHash, bool), void), asCALL_THISCALL);
engine->RegisterObjectMethod("ResourceCache", "void ReleaseResources(StringHash, bool force = false)", asMETHODPR(ResourceCache, ReleaseResources, (StringHash, bool), void), asCALL_THISCALL);
engine->RegisterObjectMethod("ResourceCache", "void ReleaseResources(const String&in, const String&in, bool force = false)", asFUNCTION(ResourceCacheReleaseResourcesPartial), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("ResourceCache", "void ReleaseResources(const String&in, bool force = false)", asMETHODPR(ResourceCache, ReleaseResources, (const String&, bool), void), asCALL_THISCALL);
engine->RegisterObjectMethod("ResourceCache", "void ReleaseAllResources(bool force = false)", asMETHOD(ResourceCache, ReleaseAllResources), asCALL_THISCALL);
@ -115,7 +115,7 @@ static void RegisterResourceCache(asIScriptEngine* engine)
engine->RegisterObjectMethod("ResourceCache", "String SanitateResourceDirName(const String&in) const", asMETHOD(ResourceCache, SanitateResourceDirName), asCALL_THISCALL);
engine->RegisterObjectMethod("ResourceCache", "String GetResourceFileName(const String&in) const", asMETHOD(ResourceCache, GetResourceFileName), asCALL_THISCALL);
engine->RegisterObjectMethod("ResourceCache", "Resource@+ GetResource(const String&in, const String&in, bool sendEventOnFailure = true)", asFUNCTION(ResourceCacheGetResource), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("ResourceCache", "Resource@+ GetResource(ShortStringHash, const String&in, bool sendEventOnFailure = true)", asMETHODPR(ResourceCache, GetResource, (ShortStringHash, const String&, bool), Resource*), asCALL_THISCALL);
engine->RegisterObjectMethod("ResourceCache", "Resource@+ GetResource(StringHash, const String&in, bool sendEventOnFailure = true)", asMETHODPR(ResourceCache, GetResource, (StringHash, const String&, bool), Resource*), asCALL_THISCALL);
engine->RegisterObjectMethod("ResourceCache", "void set_memoryBudget(const String&in, uint)", asFUNCTION(ResourceCacheSetMemoryBudget), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("ResourceCache", "uint get_memoryBudget(const String&in) const", asFUNCTION(ResourceCacheGetMemoryBudget), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("ResourceCache", "uint get_memoryUse(const String&in) const", asFUNCTION(ResourceCacheGetMemoryUse), asCALL_CDECL_OBJLAST);

Просмотреть файл

@ -194,19 +194,19 @@ static CScriptArray* GetObjectCategories()
static CScriptArray* GetObjectsByCategory(const String& category)
{
const HashMap<String, Vector<ShortStringHash> >& categories = GetScriptContext()->GetObjectCategories();
const HashMap<String, Vector<StringHash> >& categories = GetScriptContext()->GetObjectCategories();
Vector<String> components;
HashMap<String, Vector<ShortStringHash> >::ConstIterator i = categories.Find(category);
HashMap<String, Vector<StringHash> >::ConstIterator i = categories.Find(category);
if (i != categories.End())
{
const HashMap<ShortStringHash, SharedPtr<ObjectFactory> >& factories = GetScriptContext()->GetObjectFactories();
const Vector<ShortStringHash>& factoryHashes = i->second_;
const HashMap<StringHash, SharedPtr<ObjectFactory> >& factories = GetScriptContext()->GetObjectFactories();
const Vector<StringHash>& factoryHashes = i->second_;
components.Reserve(factoryHashes.Size());
for (unsigned j = 0; j < factoryHashes.Size(); ++j)
{
HashMap<ShortStringHash, SharedPtr<ObjectFactory> >::ConstIterator k = factories.Find(factoryHashes[j]);
HashMap<StringHash, SharedPtr<ObjectFactory> >::ConstIterator k = factories.Find(factoryHashes[j]);
if (k != factories.End())
components.Push(k->second_->GetTypeName());
}
@ -282,7 +282,7 @@ static void RegisterScene(asIScriptEngine* engine)
engine->RegisterObjectMethod("Scene", "void UnregisterAllVars(const String&in)", asMETHOD(Scene, UnregisterAllVars), asCALL_THISCALL);
engine->RegisterObjectMethod("Scene", "Component@+ GetComponent(uint)", asMETHODPR(Scene, GetComponent, (unsigned) const, Component*), asCALL_THISCALL);
engine->RegisterObjectMethod("Scene", "Node@+ GetNode(uint)", asMETHOD(Scene, GetNode), asCALL_THISCALL);
engine->RegisterObjectMethod("Scene", "const String& GetVarName(ShortStringHash) const", asMETHOD(Scene, GetVarName), asCALL_THISCALL);
engine->RegisterObjectMethod("Scene", "const String& GetVarName(StringHash) const", asMETHOD(Scene, GetVarName), asCALL_THISCALL);
engine->RegisterObjectMethod("Scene", "void Update(float)", asMETHOD(Scene, Update), asCALL_THISCALL);
engine->RegisterObjectMethod("Scene", "void set_updateEnabled(bool)", asMETHOD(Scene, SetUpdateEnabled), asCALL_THISCALL);
engine->RegisterObjectMethod("Scene", "bool get_updateEnabled() const", asMETHOD(Scene, IsUpdateEnabled), asCALL_THISCALL);

Просмотреть файл

@ -244,10 +244,10 @@ void Script::DumpAPI(DumpMode mode)
Log::WriteRaw("\n\\page AttributeList Attribute list\n");
const HashMap<ShortStringHash, Vector<AttributeInfo> >& attributes = context_->GetAllAttributes();
const HashMap<StringHash, Vector<AttributeInfo> >& attributes = context_->GetAllAttributes();
Vector<String> objectTypes;
for (HashMap<ShortStringHash, Vector<AttributeInfo> >::ConstIterator i = attributes.Begin(); i != attributes.End();
for (HashMap<StringHash, Vector<AttributeInfo> >::ConstIterator i = attributes.Begin(); i != attributes.End();
++i)
objectTypes.Push(context_->GetTypeName(i->first_));

Просмотреть файл

@ -580,13 +580,13 @@ void ScriptInstance::GetScriptAttributes()
else
{
// For a handle type, check if it's an Object subclass with a registered factory
ShortStringHash typeHash(typeName);
const HashMap<ShortStringHash, SharedPtr<ObjectFactory> >& factories = context_->GetObjectFactories();
HashMap<ShortStringHash, SharedPtr<ObjectFactory> >::ConstIterator j = factories.Find(typeHash);
StringHash typeHash(typeName);
const HashMap<StringHash, SharedPtr<ObjectFactory> >& factories = context_->GetObjectFactories();
HashMap<StringHash, SharedPtr<ObjectFactory> >::ConstIterator j = factories.Find(typeHash);
if (j != factories.End())
{
// Check base class type. Node & Component are supported as ID attributes, Resource as a resource reference
ShortStringHash baseType = j->second_->GetBaseType();
StringHash baseType = j->second_->GetBaseType();
if (baseType == Node::GetTypeStatic())
{
info.mode_ |= AM_NODEID;

Просмотреть файл

@ -33,7 +33,7 @@
namespace Urho3D
{
ShortStringHash VAR_DRAGDROPCONTENT("DragDropContent");
StringHash VAR_DRAGDROPCONTENT("DragDropContent");
extern const char* UI_CATEGORY;
@ -159,7 +159,7 @@ bool LineEdit::OnDragDropTest(UIElement* source)
{
if (source)
{
ShortStringHash sourceType = source->GetType();
StringHash sourceType = source->GetType();
return sourceType == LineEdit::GetTypeStatic() || sourceType == Text::GetTypeStatic();
}
@ -177,7 +177,7 @@ bool LineEdit::OnDragDropFinish(UIElement* source)
return true;
}
ShortStringHash sourceType = source->GetType();
StringHash sourceType = source->GetType();
if (sourceType == LineEdit::GetTypeStatic())
{
LineEdit* sourceLineEdit = static_cast<LineEdit*>(source);

Просмотреть файл

@ -49,7 +49,7 @@ template<> HighlightMode Variant::Get<HighlightMode>() const
return (HighlightMode)GetInt();
}
static const ShortStringHash expandedHash("Expanded");
static const StringHash expandedHash("Expanded");
extern const char* UI_CATEGORY;
@ -63,7 +63,7 @@ void SetItemExpanded(UIElement* item, bool enable)
item->SetVar(expandedHash, enable);
}
static const ShortStringHash hierarchyParentHash("HierarchyParent");
static const StringHash hierarchyParentHash("HierarchyParent");
bool GetItemHierarchyParent(UIElement* item)
{

Просмотреть файл

@ -34,8 +34,8 @@
namespace Urho3D
{
const ShortStringHash VAR_SHOW_POPUP("ShowPopup");
extern ShortStringHash VAR_ORIGIN;
const StringHash VAR_SHOW_POPUP("ShowPopup");
extern StringHash VAR_ORIGIN;
extern const char* UI_CATEGORY;

Просмотреть файл

@ -62,10 +62,10 @@
namespace Urho3D
{
ShortStringHash VAR_ORIGIN("Origin");
const ShortStringHash VAR_ORIGINAL_PARENT("OriginalParent");
const ShortStringHash VAR_ORIGINAL_CHILD_INDEX("OriginalChildIndex");
const ShortStringHash VAR_PARENT_CHANGED("ParentChanged");
StringHash VAR_ORIGIN("Origin");
const StringHash VAR_ORIGINAL_PARENT("OriginalParent");
const StringHash VAR_ORIGINAL_CHILD_INDEX("OriginalChildIndex");
const StringHash VAR_PARENT_CHANGED("ParentChanged");
const float DEFAULT_DOUBLECLICK_INTERVAL = 0.5f;
const float DEFAULT_DRAGBEGIN_INTERVAL = 0.5f;

Просмотреть файл

@ -1107,7 +1107,7 @@ void UIElement::BringToFront()
}
}
UIElement* UIElement::CreateChild(ShortStringHash type, const String& name, unsigned index)
UIElement* UIElement::CreateChild(StringHash type, const String& name, unsigned index)
{
// Check that creation succeeds and that the object in fact is a UI element
SharedPtr<UIElement> newElement = DynamicCast<UIElement>(context_->CreateObject(type));
@ -1278,7 +1278,7 @@ void UIElement::SetParent(UIElement* parent, unsigned index)
parent->InsertChild(index, this);
}
void UIElement::SetVar(ShortStringHash key, const Variant& value)
void UIElement::SetVar(StringHash key, const Variant& value)
{
vars_[key] = value;
}
@ -1398,7 +1398,7 @@ UIElement* UIElement::GetChild(const String& name, bool recursive) const
return 0;
}
UIElement* UIElement::GetChild(const ShortStringHash& key, const Variant& value, bool recursive) const
UIElement* UIElement::GetChild(const StringHash& key, const Variant& value, bool recursive) const
{
for (Vector<SharedPtr<UIElement> >::ConstIterator i = children_.Begin(); i != children_.End(); ++i)
{
@ -1439,7 +1439,7 @@ const Color& UIElement::GetDerivedColor() const
return derivedColor_;
}
const Variant& UIElement::GetVar(const ShortStringHash& key) const
const Variant& UIElement::GetVar(const StringHash& key) const
{
VariantMap::ConstIterator i = vars_.Find(key);
return i != vars_.End() ? i->second_ : Variant::EMPTY;

Просмотреть файл

@ -292,7 +292,7 @@ public:
/// Bring UI element to front.
void BringToFront();
/// Create and add a child element and return it.
UIElement* CreateChild(ShortStringHash type, const String& name = String::EMPTY, unsigned index = M_MAX_UNSIGNED);
UIElement* CreateChild(StringHash type, const String& name = String::EMPTY, unsigned index = M_MAX_UNSIGNED);
/// Add a child element.
void AddChild(UIElement* element);
/// Insert a child element into a specific position in the child list.
@ -310,7 +310,7 @@ public:
/// Set parent element. Same as parent->InsertChild(index, this).
void SetParent(UIElement* parent, unsigned index = M_MAX_UNSIGNED);
/// Set a user variable.
void SetVar(ShortStringHash key, const Variant& value);
void SetVar(StringHash key, const Variant& value);
/// Mark as internally (programmatically) created. Used when an element composes itself out of child elements.
void SetInternal(bool enable);
/// Set traversal mode for rendering. The default traversal mode is TM_BREADTH_FIRST for non-root element. Root element should be set to TM_DEPTH_FIRST to avoid artifacts during rendering.
@ -412,7 +412,7 @@ public:
/// Return child element by name.
UIElement* GetChild(const String& name, bool recursive = false) const;
/// Return child element by variable. If only key is provided, return the first child having the matching variable key. If value is also provided then the actual variable value would also be checked against.
UIElement* GetChild(const ShortStringHash& key, const Variant& value = Variant::EMPTY, bool recursive = false) const;
UIElement* GetChild(const StringHash& key, const Variant& value = Variant::EMPTY, bool recursive = false) const;
/// Return immediate child elements.
const Vector<SharedPtr<UIElement> >& GetChildren() const { return children_; }
/// Return child elements either recursively or non-recursively.
@ -424,7 +424,7 @@ public:
/// Return derived color. Only valid when no gradient.
const Color& GetDerivedColor() const;
/// Return a user variable.
const Variant& GetVar(const ShortStringHash& key) const;
const Variant& GetVar(const StringHash& key) const;
/// Return all user variables.
const VariantMap& GetVars() const { return vars_; }

Просмотреть файл

@ -36,7 +36,7 @@
static const unsigned NUM_SPRITES = 100;
// Custom variable identifier for storing sprite velocity within the UI element
static const ShortStringHash VAR_VELOCITY("Velocity");
static const StringHash VAR_VELOCITY("Velocity");
DEFINE_APPLICATION_MAIN(Sprites)

Просмотреть файл

@ -40,7 +40,7 @@
#include "DebugNew.h"
// Custom variable identifier for storing sound effect name within the UI element
static const ShortStringHash VAR_SOUNDRESOURCE("SoundResource");
static const StringHash VAR_SOUNDRESOURCE("SoundResource");
static const unsigned NUM_SOUNDS = 3;
static String soundNames[] = {

Просмотреть файл

@ -61,7 +61,7 @@ static const unsigned short SERVER_PORT = 2345;
// Identifier for our custom remote event we use to tell the client which object they control
static const StringHash E_CLIENTOBJECTID("ClientObjectID");
// Identifier for the node ID parameter in the event data
static const ShortStringHash P_ID("ID");
static const StringHash P_ID("ID");
// Control bits we define
static const unsigned CTRL_FORWARD = 1;

Просмотреть файл

@ -42,8 +42,8 @@
// Number of static sprites to draw
static const unsigned NUM_SPRITES = 200;
static const ShortStringHash VAR_MOVESPEED("MoveSpeed");
static const ShortStringHash VAR_ROTATESPEED("RotateSpeed");
static const StringHash VAR_MOVESPEED("MoveSpeed");
static const StringHash VAR_ROTATESPEED("RotateSpeed");
DEFINE_APPLICATION_MAIN(Urho2DSprite)