]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/item/inputcontainer.qc
Optimize vehicle impact code by only calling vlen() if damage would be taken
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / item / inputcontainer.qc
index 45f60854f9499308bb9dc8af1694fedc1a794195..cda342677262206dd8afb2bcdb011f136ed2edc9 100644 (file)
@@ -1,22 +1,5 @@
-#ifndef ITEM_INPUTCONTAINER_H
-       #define ITEM_INPUTCONTAINER_H
-       #include "container.qc"
-       CLASS(InputContainer, Container)
-               METHOD(InputContainer, keyDown, float(entity, float, float, float));
-               METHOD(InputContainer, mouseMove, float(entity, vector));
-               METHOD(InputContainer, mousePress, float(entity, vector));
-               METHOD(InputContainer, mouseRelease, float(entity, vector));
-               METHOD(InputContainer, mouseDrag, float(entity, vector));
-               METHOD(InputContainer, focusLeave, void(entity));
-               METHOD(InputContainer, resizeNotify, void(entity, vector, vector, vector, vector));
+#include "inputcontainer.qh"
 
-               METHOD(InputContainer, _changeFocusXY, bool(entity this, vector pos));
-               ATTRIB(InputContainer, mouseFocusedChild, entity, NULL)
-               ATTRIB(InputContainer, isTabRoot, float, 0)
-       ENDCLASS(InputContainer)
-#endif
-
-#ifdef IMPLEMENTATION
        void InputContainer_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
        {
                SUPER(InputContainer).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
@@ -37,7 +20,8 @@
        float InputContainer_keyDown(entity me, float scan, float ascii, float shift)
        {
                entity f, ff;
-               if (SUPER(InputContainer).keyDown(me, scan, ascii, shift)) return 1;
+               if (SUPER(InputContainer).keyDown(me, scan, ascii, shift))
+                       return 1;
                if (scan == K_ESCAPE)
                {
                        f = me.focusedChild;
                if (e && !e.focusable) e = NULL;
                entity prev = this.mouseFocusedChild;
                this.mouseFocusedChild = e;
-               if (!e) return false;  // keep focus when hovering over non-focusable elements
                if (e != prev)
                {
                        this.setFocus(this, e);
-                       if (e.instanceOfInputContainer)
+                       if (e && e.instanceOfInputContainer)
                        {
                                e.focusedChild = NULL;
                                e._changeFocusXY(e, globalToBox(pos, e.Container_origin, e.Container_size));
                if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return 1;
                return 0;
        }
-       float InputContainer_mousePress(entity me, vector pos)
+       METHOD(InputContainer, mousePress, bool(InputContainer this, vector pos))
        {
-               me.mouseFocusedChild = NULL;  // force focusing
-               if (me._changeFocusXY(me, pos))
-                       if (SUPER(InputContainer).mousePress(me, pos)) return 1;
-               if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return 1;
-               return 0;
+               this.mouseFocusedChild = NULL;  // force focusing
+               if (this._changeFocusXY(this, pos))
+                       if (SUPER(InputContainer).mousePress(this, pos)) return true;
+               if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return true;
+               return false;
        }
        float InputContainer_mouseRelease(entity me, vector pos)
        {
                if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return 1;
                return 0;
        }
-#endif