Skip to content

Commit

Permalink
GetUInt() etc -> GetU32() | Add color32 type alias
Browse files Browse the repository at this point in the history
  • Loading branch information
1vanK committed Oct 31, 2022
1 parent b6058dc commit 544ce6a
Show file tree
Hide file tree
Showing 121 changed files with 709 additions and 679 deletions.
4 changes: 2 additions & 2 deletions Source/Samples/02_HelloGUI/HelloGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ void HelloGUI::CreateDraggableFish()
void HelloGUI::HandleDragBegin(StringHash eventType, VariantMap& eventData)
{
// Get UIElement relative position where input (touch or click) occurred (top-left = IntVector2(0,0))
dragBeginPosition_ = IntVector2(eventData["ElementX"].GetInt(), eventData["ElementY"].GetInt());
dragBeginPosition_ = IntVector2(eventData["ElementX"].GetI32(), eventData["ElementY"].GetI32());
}

void HelloGUI::HandleDragMove(StringHash eventType, VariantMap& eventData)
{
IntVector2 dragCurrentPosition = IntVector2(eventData["X"].GetInt(), eventData["Y"].GetInt());
IntVector2 dragCurrentPosition = IntVector2(eventData["X"].GetI32(), eventData["Y"].GetI32());
UIElement* draggedElement = static_cast<UIElement*>(eventData["Element"].GetPtr());
draggedElement->SetPosition(dragCurrentPosition - dragBeginPosition_);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Samples/16_Chat/Chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void Chat::HandleNetworkMessage(StringHash /*eventType*/, VariantMap& eventData)

using namespace NetworkMessage;

int msgID = eventData[P_MESSAGEID].GetInt();
int msgID = eventData[P_MESSAGEID].GetI32();
if (msgID == MSG_CHAT)
{
const Vector<byte>& data = eventData[P_DATA].GetBuffer();
Expand Down
2 changes: 1 addition & 1 deletion Source/Samples/17_SceneReplication/SceneReplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,5 +510,5 @@ void SceneReplication::HandleClientDisconnected(StringHash eventType, VariantMap

void SceneReplication::HandleClientObjectID(StringHash eventType, VariantMap& eventData)
{
clientObjectID_ = eventData[P_ID].GetUInt();
clientObjectID_ = eventData[P_ID].GetU32();
}
4 changes: 2 additions & 2 deletions Source/Samples/25_Urho2DParticle/Urho2DParticle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ void Urho2DParticle::HandleMouseMove(StringHash eventType, VariantMap& eventData
if (particleNode_)
{
using namespace MouseMove;
auto x = (float)eventData[P_X].GetInt();
auto y = (float)eventData[P_Y].GetInt();
auto x = (float)eventData[P_X].GetI32();
auto y = (float)eventData[P_Y].GetI32();
auto* graphics = GetSubsystem<Graphics>();
auto* camera = cameraNode_->GetComponent<Camera>();
particleNode_->SetPosition(camera->ScreenToWorldPoint(Vector3(x / graphics->GetWidth(), y / graphics->GetHeight(), 10.0f)));
Expand Down
2 changes: 1 addition & 1 deletion Source/Samples/26_ConsoleInput/ConsoleInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void ConsoleInput::HandleUpdate(StringHash eventType, VariantMap& eventData)
void ConsoleInput::HandleEscKeyDown(StringHash eventType, VariantMap& eventData)
{
// Unlike the other samples, exiting the engine when ESC is pressed instead of just closing the console
if (eventData[KeyDown::P_KEY].GetInt() == KEY_ESCAPE && GetPlatform() != "Web")
if (eventData[KeyDown::P_KEY].GetI32() == KEY_ESCAPE && GetPlatform() != "Web")
engine_->Exit();
}

Expand Down
6 changes: 3 additions & 3 deletions Source/Samples/32_Physics2DConstraints/Urho2DConstraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ void Urho2DConstraints::HandleTouchBegin3(StringHash eventType, VariantMap& even
auto* graphics = GetSubsystem<Graphics>();
auto* physicsWorld = scene_->GetComponent<PhysicsWorld2D>();
using namespace TouchBegin;
RigidBody2D* rigidBody = physicsWorld->GetRigidBody(eventData[P_X].GetInt(), eventData[P_Y].GetInt()); // Raycast for RigidBody2Ds to pick
RigidBody2D* rigidBody = physicsWorld->GetRigidBody(eventData[P_X].GetI32(), eventData[P_Y].GetI32()); // Raycast for RigidBody2Ds to pick
if (rigidBody)
{
pickedNode = rigidBody->GetNode();
Expand All @@ -544,7 +544,7 @@ void Urho2DConstraints::HandleTouchBegin3(StringHash eventType, VariantMap& even

// Create a ConstraintMouse2D - Temporary apply this constraint to the pickedNode to allow grasping and moving with touch
auto* constraintMouse = pickedNode->CreateComponent<ConstraintMouse2D>();
Vector3 pos = camera_->ScreenToWorldPoint(Vector3((float)eventData[P_X].GetInt() / graphics->GetWidth(), (float)eventData[P_Y].GetInt() / graphics->GetHeight(), 0.0f));
Vector3 pos = camera_->ScreenToWorldPoint(Vector3((float)eventData[P_X].GetI32() / graphics->GetWidth(), (float)eventData[P_Y].GetI32() / graphics->GetHeight(), 0.0f));
constraintMouse->SetTarget(Vector2(pos.x_, pos.y_));
constraintMouse->SetMaxForce(1000 * rigidBody->GetMass());
constraintMouse->SetCollideConnected(true);
Expand All @@ -562,7 +562,7 @@ void Urho2DConstraints::HandleTouchMove3(StringHash eventType, VariantMap& event
auto* graphics = GetSubsystem<Graphics>();
auto* constraintMouse = pickedNode->GetComponent<ConstraintMouse2D>();
using namespace TouchMove;
Vector3 pos = camera_->ScreenToWorldPoint(Vector3(float(eventData[P_X].GetInt()) / graphics->GetWidth(), float(eventData[P_Y].GetInt()) / graphics->GetHeight(), 0.0f));
Vector3 pos = camera_->ScreenToWorldPoint(Vector3(float(eventData[P_X].GetI32()) / graphics->GetWidth(), float(eventData[P_Y].GetI32()) / graphics->GetHeight(), 0.0f));
constraintMouse->SetTarget(Vector2(pos.x_, pos.y_));
}
}
Expand Down
16 changes: 8 additions & 8 deletions Source/Samples/37_UIDrag/UIDrag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,32 +123,32 @@ void UIDrag::HandleDragBegin(StringHash eventType, VariantMap& eventData)
using namespace DragBegin;
auto* element = (Button*)eventData[P_ELEMENT].GetVoidPtr();

int lx = eventData[P_X].GetInt();
int ly = eventData[P_Y].GetInt();
int lx = eventData[P_X].GetI32();
int ly = eventData[P_Y].GetI32();

IntVector2 p = element->GetPosition();
element->SetVar("START", p);
element->SetVar("DELTA", IntVector2(p.x_ - lx, p.y_ - ly));

int buttons = eventData[P_BUTTONS].GetInt();
int buttons = eventData[P_BUTTONS].GetI32();
element->SetVar("BUTTONS", buttons);

auto* t = element->GetChildStaticCast<Text>("Text", false);
t->SetText("Drag Begin Buttons: " + String(buttons));

t = element->GetChildStaticCast<Text>("Num Touch", false);
t->SetText("Number of buttons: " + String(eventData[P_NUMBUTTONS].GetInt()));
t->SetText("Number of buttons: " + String(eventData[P_NUMBUTTONS].GetI32()));
}

void UIDrag::HandleDragMove(StringHash eventType, VariantMap& eventData)
{
using namespace DragBegin;
auto* element = (Button*)eventData[P_ELEMENT].GetVoidPtr();
int buttons = eventData[P_BUTTONS].GetInt();
int buttons = eventData[P_BUTTONS].GetI32();
IntVector2 d = element->GetVar("DELTA").GetIntVector2();
int X = eventData[P_X].GetInt() + d.x_;
int Y = eventData[P_Y].GetInt() + d.y_;
int BUTTONS = element->GetVar("BUTTONS").GetInt();
int X = eventData[P_X].GetI32() + d.x_;
int Y = eventData[P_Y].GetI32() + d.y_;
int BUTTONS = element->GetVar("BUTTONS").GetI32();

auto* t = element->GetChildStaticCast<Text>("Event Touch", false);
t->SetText("Drag Move Buttons: " + String(buttons));
Expand Down
6 changes: 3 additions & 3 deletions Source/Samples/39_CrowdNavigation/CrowdNavigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ void CrowdNavigation::HandleCrowdAgentFailure(StringHash eventType, VariantMap&
using namespace CrowdAgentFailure;

auto* node = static_cast<Node*>(eventData[P_NODE].GetPtr());
auto agentState = (CrowdAgentState)eventData[P_CROWD_AGENT_STATE].GetInt();
auto agentState = (CrowdAgentState)eventData[P_CROWD_AGENT_STATE].GetI32();

// If the agent's state is invalid, likely from spawning on the side of a box, find a point in a larger area
if (agentState == CA_STATE_INVALID)
Expand Down Expand Up @@ -615,8 +615,8 @@ void CrowdNavigation::HandleCrowdAgentFormation(StringHash eventType, VariantMap
{
using namespace CrowdAgentFormation;

unsigned index = eventData[P_INDEX].GetUInt();
unsigned size = eventData[P_SIZE].GetUInt();
unsigned index = eventData[P_INDEX].GetU32();
unsigned size = eventData[P_SIZE].GetU32();
Vector3 position = eventData[P_POSITION].GetVector3();

// The first agent will always move to the exact position, all other agents will select a random point nearby
Expand Down
4 changes: 2 additions & 2 deletions Source/Samples/41_DatabaseDemo/DatabaseDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void DatabaseDemo::HandleUpdate(StringHash eventType, VariantMap& eventData)
void DatabaseDemo::HandleEscKeyDown(StringHash eventType, VariantMap& eventData)
{
// Unlike the other samples, exiting the engine when ESC is pressed instead of just closing the console
if (eventData[KeyDown::P_KEY].GetInt() == KEY_ESCAPE)
if (eventData[KeyDown::P_KEY].GetI32() == KEY_ESCAPE)
engine_->Exit();
}

Expand All @@ -130,7 +130,7 @@ void DatabaseDemo::HandleDbCursor(StringHash eventType, VariantMap& eventData)

// In a real application the P_SQL can be used to do the logic branching in a shared event handler
// However, this is not required in this sample demo
unsigned numCols = eventData[P_NUMCOLS].GetUInt();
unsigned numCols = eventData[P_NUMCOLS].GetU32();
const VariantVector& colValues = eventData[P_COLVALUES].GetVariantVector();
const Vector<String>& colHeaders = eventData[P_COLHEADERS].GetStringVector();

Expand Down
4 changes: 2 additions & 2 deletions Source/Samples/48_Hello3DUI/Hello3DUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ void Hello3DUI::CreateDraggableFish()
void Hello3DUI::HandleDragBegin(StringHash eventType, VariantMap& eventData)
{
// Get UIElement relative position where input (touch or click) occurred (top-left = IntVector2(0,0))
dragBeginPosition_ = IntVector2(eventData["ElementX"].GetInt(), eventData["ElementY"].GetInt());
dragBeginPosition_ = IntVector2(eventData["ElementX"].GetI32(), eventData["ElementY"].GetI32());
}

void Hello3DUI::HandleDragMove(StringHash eventType, VariantMap& eventData)
{
IntVector2 dragCurrentPosition = IntVector2(eventData["X"].GetInt(), eventData["Y"].GetInt());
IntVector2 dragCurrentPosition = IntVector2(eventData["X"].GetI32(), eventData["Y"].GetI32());
UIElement* draggedElement = static_cast<UIElement*>(eventData["Element"].GetPtr());
draggedElement->SetPosition(dragCurrentPosition - dragBeginPosition_);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void Urho2DStretchableSprite::OnKeyUp(StringHash /*eventType*/, VariantMap& even
{
using namespace KeyUp;

const auto key = eventData[P_KEY].GetInt();
const auto key = eventData[P_KEY].GetI32();

if (key == KEY_TAB)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Samples/53_LANDiscovery/LANDiscovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void LANDiscovery::HandleNetworkHostDiscovered(StringHash eventType, VariantMap&
URHO3D_LOGINFO("Server discovered!");
String text = serverList_->GetText();
VariantMap data = eventData[P_BEACON].GetVariantMap();
text += "\n" + data["Name"].GetString() + "(" + String(data["Players"].GetInt()) + ")" + eventData[P_ADDRESS].GetString() + ":" + String(eventData[P_PORT].GetInt());
text += "\n" + data["Name"].GetString() + "(" + String(data["Players"].GetI32()) + ")" + eventData[P_ADDRESS].GetString() + ":" + String(eventData[P_PORT].GetI32());
serverList_->SetText(text);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Samples/55_Clicker/Clicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void Clicker::HandleMouseButtonDown(StringHash eventType, VariantMap& eventData)
{
using namespace MouseButtonDown;

MouseButton button = (MouseButton)eventData[P_BUTTON].GetUInt();
MouseButton button = (MouseButton)eventData[P_BUTTON].GetU32();

if (button == MOUSEB_RIGHT)
{
Expand Down
4 changes: 2 additions & 2 deletions Source/Samples/Sample.inl
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void Sample::HandleKeyUp(StringHash /*eventType*/, VariantMap& eventData)
{
using namespace KeyUp;

int key = eventData[P_KEY].GetInt();
int key = eventData[P_KEY].GetI32();

// Close console (if open) or exit when ESC is pressed
if (key == KEY_ESCAPE)
Expand All @@ -227,7 +227,7 @@ void Sample::HandleKeyDown(StringHash /*eventType*/, VariantMap& eventData)
{
using namespace KeyDown;

int key = eventData[P_KEY].GetInt();
int key = eventData[P_KEY].GetI32();

// Toggle console with F1
if (key == KEY_F1)
Expand Down
2 changes: 1 addition & 1 deletion Source/Tools/AssetImporter/AssetImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2424,7 +2424,7 @@ void WriteVertex(float*& dest, aiMesh* mesh, unsigned index, bool isSkinned, Bou
for (unsigned i = 0; i < mesh->GetNumColorChannels() && i < MAX_CHANNELS; ++i)
{
*((unsigned*)dest) = Color(mesh->mColors[i][index].r, mesh->mColors[i][index].g, mesh->mColors[i][index].b,
mesh->mColors[i][index].a).ToUInt();
mesh->mColors[i][index].a).ToU32();
++dest;
}

Expand Down
30 changes: 28 additions & 2 deletions Source/Tools/BindingGenerator/ASUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ string CppPrimitiveTypeToAS(const string& cppType)
if (cppType == "flagset32")
return "flagset32";

if (cppType == "color32")
return "color32";

throw Exception(cppType + " not a primitive type");
}

Expand Down Expand Up @@ -169,6 +172,8 @@ shared_ptr<EnumAnalyzer> FindEnum(const string& name)
return shared_ptr<EnumAnalyzer>();
}

// TODO: Not all usings detect as using https://github.com/doxygen/doxygen/issues/9654
// id32, hash32 never checked because not detected as using because not in Urho3D namespace and not parsed
static bool IsUsing(const string& identifier)
{
for (xml_node memberdef : SourceData::usings_)
Expand All @@ -182,6 +187,25 @@ static bool IsUsing(const string& identifier)
return false;
}

// TODO: Not all usings detect as using https://github.com/doxygen/doxygen/issues/9654
static bool IsKnownUsing(const string& identifier)
{
if (!IsUsing(identifier))
return false;

if (identifier == "VariantMap"
|| identifier == "color32"
|| identifier == "NodeId" // Never checked https://github.com/doxygen/doxygen/issues/9654
|| identifier == "ComponentId") // Never checked https://github.com/doxygen/doxygen/issues/9654
{
return true;
}

// id32, hash32 never checked because not detected as using because not in Urho3D namespace and not parsed

return false;
}

bool IsKnownCppType(const string& name)
{
static vector<string> _knownTypes = {
Expand Down Expand Up @@ -485,7 +509,8 @@ ConvertedVariable CppVariableToAS(const TypeAnalyzer& type, VariableUsage usage,
// TODO add to type info "IsUsing"
// TODO add description to TypeAnalyzer::GetClass()

if (IsUsing(cppTypeName) && cppTypeName != "VariantMap")
// TODO: Not all usings detect as using https://github.com/doxygen/doxygen/issues/9654
if (IsUsing(cppTypeName) && !IsKnownUsing(cppTypeName))
throw Exception("Using \"" + cppTypeName + "\" can not automatically bind");

string asTypeName;
Expand Down Expand Up @@ -590,7 +615,8 @@ string CppTypeToAS(const TypeAnalyzer& type, TypeUsage typeUsage)
// TODO add to type info "IsUsing"
// TODO add description to TypeAnalyzer::GetClass()

if (IsUsing(cppTypeName) && cppTypeName != "VariantMap")
// TODO: Not all usings detect as using https://github.com/doxygen/doxygen/issues/9654
if (IsUsing(cppTypeName) && !IsKnownUsing(cppTypeName))
throw Exception("Using \"" + cppTypeName + "\" can not automatically bind");

string asTypeName;
Expand Down
1 change: 1 addition & 0 deletions Source/Tools/BindingGenerator/XmlSourceData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ static void LoadXml(const string& fullPath)
{
string definition = ExtractDefinition(memberdef);

// TODO: using can be typedef https://github.com/doxygen/doxygen/issues/9654
if (StartsWith(definition, "using "))
SourceData::usings_.push_back(memberdef);
}
Expand Down
Loading

0 comments on commit 544ce6a

Please sign in to comment.