ソースを参照

Replacing a magic number with a constant.

Adam Blake 12 年 前
コミット
67f6222915
2 ファイル変更5 行追加4 行削除
  1. 2 3
      gameplay/src/Container.cpp
  2. 3 1
      gameplay/src/Container.h

+ 2 - 3
gameplay/src/Container.cpp

@@ -41,7 +41,7 @@ static bool sortControlsByZOrder(Control* c1, Control* c2);
 
 void Container::clearContacts()
 {
-	for (int i = 0; i < 10; ++i)
+	for (int i = 0; i < MAX_CONTACT_INDICES; ++i)
 		_contactIndices[i] = false;
 }
 
@@ -1644,7 +1644,7 @@ bool Container::mouseEventScroll(Mouse::MouseEvent evt, int x, int y, int wheelD
 
 bool Container::inContact()
 {
-	for (int i = 0; i < 10; ++i)
+	for (int i = 0; i < MAX_CONTACT_INDICES; ++i)
 	{
 		if (_contactIndices[i])
 			return true;
@@ -1743,7 +1743,6 @@ bool Container::pointerEvent(bool mouse, char evt, int x, int y, int data)
             release();
             return false;
         }
-		//_contactIndices++;
         if (!mouse)
         	_contactIndices[data] = true;
         break;

+ 3 - 1
gameplay/src/Container.h

@@ -585,6 +585,8 @@ private:
         NEXT = 0x10
     };
 
+    static const int MAX_CONTACT_INDICES = 10;
+
     // Returns true on success; false if there are no controls to focus on,
     // in which case scrolling can be initiated.
     bool moveFocus(Direction direction, Control* outsideControl = NULL);
@@ -616,7 +618,7 @@ private:
 
     float _totalWidth;
     float _totalHeight;
-    bool _contactIndices[10];
+    bool _contactIndices[MAX_CONTACT_INDICES];
     bool _initializedWithScroll;
     bool _scrollWheelRequiresFocus;
 };