Exemple #1
0
        public Control()
        {
            pBox=	new Box(Point.ORIGIN, Size.NO_SIZE);
            pParent=	null;
            children=	new List<Control>();
            oldMouse=	new MouseState();
            bHover=	false;
            click=	0;
            pVisible=	true;
            pEnabled=	true;
            pBackColors=	ColorPacket.DEFAULT;

            eonRelocate=	null;
            eonResize=	null;
            eonParentChanged=	null;
            eonBoxChanged=	null;
            eonWindowResize=	null;
            eonGuiAdded=	null;
            eonMouseEnter=	null;
            eonMouseLeave=	null;
            eonMouseClick=	null;
            eonMouseHover=	null;
            eonKeyPress=	null;
            eonEnabledChanged=	null;
            eonVisibleChanged=	null;
            eonGuiOpen=	null;
            eonGuiClose=	null;
        }
Exemple #2
0
 private void Toggle(GuiEvent e)
 {
     //toggle plugin list
     showList = !showList;
     if (showList == true) iTween.MoveTo(this.ToGameObject(), new Vector3(0, Screen.height >> 1, 0), 1);
     else iTween.MoveTo(this.ToGameObject(), new Vector3(0, 0, 0), 1);
 }
Exemple #3
0
 void enterFrameHandler(GuiEvent e)
 {
     if(_isRotate){
         s2.rotation++;
         //s.y++;
     }
 }
Exemple #4
0
 private void unselectHandler(GuiEvent e)
 {
     GuiMenuItem item = e.target as GuiMenuItem;
     if (!string.IsNullOrEmpty(item.iOSNativeCode)){
         typeof(UIBinding).InvokeMember("DeactivateUI"+item.iOSNativeCode, BindingFlags.Default | BindingFlags.InvokeMethod, null, null, new object[]{ });
     }
 }
Exemple #5
0
        public void ClickingTheTypeFieldOfTypeWithProvideSourceInfoShouldPingTheMonoScript()
        {
            var guiEvent   = new GuiEvent(EventType.MouseDown, Vector2.zero, 1, 0);
            var typeField  = new TypeField(Rect.zero, typeof(C), null, null, guiEvent);
            var monoScript = typeField.HandleTypeLabelClicked();

            Assert.IsNotNull(monoScript);
        }
Exemple #6
0
 public void dispatchEvent(GuiEvent e)
 {
     if(_dispatchList==null){
         _dispatchList	= new List<GuiEvent>();
     }
     e.target	= this;
     _dispatchList.Add(e);
 }
Exemple #7
0
 public void Subscribe(GuiEvent.EventHandler callback,GuiEventType type, SortedList parameter)
 {
     GuiKeyEvent e = new GuiKeyEvent(null ,type, parameter);
     e.Handler += callback;
     //
     if (_events == null) _events = new List<GuiKeyEvent>();
     _events.Add(e);
 }
Exemple #8
0
 public void ToggleList(GuiEvent e)
 {
     //toggle plugin list
     showList = !showList;
     if (showList == true)
         iTween.MoveTo (_pluginList.ToGameObject (), new Vector3 (-220, 0, 0), 1);
     else
         iTween.MoveTo (_pluginList.ToGameObject (), new Vector3 (0, 0, 0), 1);
 }
Exemple #9
0
        public void ClickingTheTypeFieldOfTypeWithoutProvideSourceInfoShouldLogWarning()
        {
            LogAssert.Expect(LogType.Warning, new Regex(nameof(ProvideSourceInfoAttribute)));
            var guiEvent   = new GuiEvent(EventType.MouseDown, Vector2.zero, 1, 0);
            var typeField  = new TypeField(Rect.zero, typeof(B), null, null, guiEvent);
            var monoScript = typeField.HandleTypeLabelClicked();

            Assert.IsNull(monoScript);
        }
Exemple #10
0
        /// <summary>
        /// Push event in the event queue. Replaces previous events so that only the latest event will be handled.
        /// </summary>
        /// <param name="e">Event type</param>
        /// <param name="widget">The widget calling the event.</param>
        public void RaiseEvent(GuiEvent e, Widget widget, object args = null)
        {
            var eventObj = Tuple.Create(widget, args);

            if(!Events.ContainsKey(e))
            {
                Events.Add(e, eventObj);
            }
            else
            {
                Events[e] = eventObj;
            }
        }
Exemple #11
0
        /// <summary>
        /// Handle a gui event (such as clicking the mouse)
        /// and follow up with respective actions
        /// </summary>
        /// <param name="e">E.</param>
        /// <param name="l">L.</param>
        public void HandleGuiEvent(GuiEvent e, Location l)
        {
            int   x = (l.X / Escapade.GetWorld().Size);
            int   y = (l.Y / Escapade.GetWorld().Size);
            Frame f = GetRenderer().GetActiveFrame(l);

            if (f == null)
            {
                if (e == GuiEvent.MouseLeft)
                {
                    if (l.Y < GlobalConstants.WORLD_HEIGHT) // IA - Make sure that the user clicks within the world map first, and not outside, which is supposed to be the space reserved for the panel containing the timer and game level information.
                    {
                        //if (Escapade.GetWorld().Map[x, y].Type == TileType.Air)
                        //Escapade.GetPlayer().NewPath(new Location(x, y));
                    }
                }
                if (e == GuiEvent.MouseRight)
                {
                    Escapade.GetWorld().ModifyTile(new Location(x, y));
                    Frame inv = GetRenderer().GetFrame("inventory");
                    if (inv != null)
                    {
                        List <string>            minerals     = Escapade.GetPlayer().Inventory.ItemList.Select(i => i.Name).ToList();
                        Dictionary <string, int> mineralCount = new Dictionary <string, int> ();
                        foreach (string s in minerals)
                        {
                            if (mineralCount.ContainsKey(s))
                            {
                                mineralCount [s]++;
                            }
                            else
                            {
                                mineralCount [s] = 1;
                            }
                        }
                        minerals    = mineralCount.Select(kvp => kvp.Key + " - " + kvp.Value).ToList();
                        inv.Content = minerals;
                    }
                }
            }
            else
            {
                Console.WriteLine(f.Id);
                Button b = f.GetButton(l);
                if (b != null)
                {
                    b.Do();
                }
            }
        }
Exemple #12
0
        public IEnumerator RightClickInGUIShouldDrawWithoutErrors()
        {
            var obj          = CreateInstance <ShowSerializeReferenceDrawerTest>();
            var so           = new SerializedObject(obj);
            var sp           = so.FindProperty(nameof(Field));
            var testWindow   = EditorWindow.GetWindow <TestEditorWindow>();
            var position     = new Rect(0, 0, 50, 50f);
            var currentEvent = new GuiEvent(EventType.MouseDown, position.center, 1, ShowSerializeReferenceDrawer.RightClickButton);

            testWindow.onGui = new EditorEvent(() => ShowSerializeReferenceDrawer.OnGUI(position, sp, GUIContent.none, currentEvent, GetType().GetField(nameof(Field))));
            yield return(new WaitUntil(testWindow.OnGUIInitialized).OrTimeout(2000));

            testWindow.Close();
        }
Exemple #13
0
        private RoutedEventArgs MakeKeyEventArgs(GuiEvent guiEvent)
        {
            var target      = Keyboard.FocusedElement;
            var routedEvent = Keyboard.KeyDownEvent;
            var vis         = target as Visual;

            var key  = (Key.A);
            var mods = Keyboard.Modifiers;
            var arg  = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, key)
            {
                RoutedEvent = routedEvent
            };

            return(arg);
        }
Exemple #14
0
//    private RectTransform RTThisIco;

    void Awake()
    {
        IcoNum = GOIco.Length;
        V3This = this.transform.TransformPoint(0, 0, 0);
        for (int i = 0; i < IcoNum; i++)
        {
            GameObject GOIcoClone = Instantiate(GOIco[i], V3This, new Quaternion(0, 0, 0, 0)) as GameObject;
            GOIcoClone.transform.SetParent(this.transform, false);
            RTIco.Add(GOIcoClone.GetComponent <RectTransform>());
            IcoScript.Add(GOIcoClone.GetComponent <IcoAnimation>());
        }
        GameName  = GameObject.Find("/Canvas/NameText").GetComponent <Text>();
        SceneName = GameObject.Find("/GUIEvent").GetComponent <GuiEvent>();
        NameNum   = 1;
    }
Exemple #15
0
        public IEnumerator ClickingTypePickerShouldOpenTypePickerWindow()
        {
            var pickerArea = TypeField.GetPickerButtonArea(TypeFieldRect);
            var guiEvent   = new GuiEvent(
                EventType.MouseDown,
                pickerArea.center,
                1,
                0
                );
            var typeField  = new TypeField(TypeFieldRect, typeof(A), Types, null, guiEvent);
            var testWindow = EditorWindow.GetWindow <TestEditorWindow>();

            testWindow.onGui = new EditorEvent(typeField.DrawGui);
            yield return(new WaitUntil(testWindow.OnGUIInitialized).OrTimeout(2000));

            Assert.IsTrue(EditorWindow.HasOpenInstances <TypePickerWindow>());
            EditorWindow.GetWindow <TypePickerWindow>().Close();
        }
Exemple #16
0
    void mainMenuChangeHandler(GuiEvent e)
    {
        hidePage();
        hideSubMenu();

        _previousMenuElement = _currentMenuElement;
        if (_currentMenuElement != null){
            StartCoroutine(unloadSubMenuContent(_currentMenuElement));
        }

        XmlNode node = _xmlDoc.DocumentElement.SelectSingleNode("item["+(_mainmMenu.selectedItem.listIndex+1)+"]");
        if (node.Attributes["assetBundle"] != null){
            _currentMenuElement = MenuGenerator.GetMenuElement(node);
        }
        else
            _currentMenuElement = null;

        XmlNodeList nodes = _xmlDoc.DocumentElement.SelectNodes("item["+(_mainmMenu.selectedItem.listIndex+1)+"]/sub");
        if (_mainmMenu.selectedItem != null){
            _mainmMenu.selectedItem.tag = _currentMenuElement;
            if (nodes.Count > 0){
                _subMenu = new SubMenu(nodes);
                Stage.instance.addChildAt(0, _subMenu);
                _subMenu.y	= _mainMenuY;
                _subMenu.addEventListner(GuiEvent.CHANGE, new EventDispatcher.CallBack(subMenuChangeHandler));
                NanoTween.to(_subMenu, 0.3f, NanoTween.Pack("y", _mainMenuY-_subMenuHeight, "ease", Ease.easeOutExpo));

                // populate subMenu content
                StartCoroutine(loadSubMenuContent(_subMenu, _currentMenuElement));
            }
            else if (_currentMenuElement != null){
                _sceneScript.hideScene();

                // populate this menu content
                StartCoroutine(showMenuContent(node, _currentMenuElement));
            }
            else if (node.Attributes["iOSNativeCode"] != null){
                _sceneScript.hideScene();
            }
        }
    }
Exemple #17
0
    public void Update(GuiEvent e)
    {
        //Faking without sensor
        if(Application.platform != RuntimePlatform.Android){
            _cache[_x] = new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f)); ;
        }
        else
        {
            _cache[_x] = Input.acceleration;
        }

        //clear col
        for (int y = 0; y < _height; y++)
        {
            _tex.SetPixel(_x, y, Color.clear);
        }

        //Calc Position
        int currX = (int)(_cache[_x].x * _graphHeightHalf) + _graphHeightHalf - _borderBottom;
        int currY = (int)(_cache[_x].y * _graphHeightHalf) + _graphHeightHalf - _borderBottom;
        int currZ = (int)(_cache[_x].z * _graphHeightHalf) + _graphHeightHalf - _borderBottom;
        Vector3 currentVec = new Vector3(currX, currY, currZ);

        //draw sensor values
        drawLine(Math.Max(_x - 1, 0), (int)_preVector.x, _x, (int)currentVec.x, Color.green);
        drawLine(Math.Max(_x - 1, 0), (int)_preVector.y, _x, (int)currentVec.y, Color.red);
        drawLine(Math.Max(_x - 1, 0), (int)_preVector.z, _x, (int)currentVec.z, Color.blue);

        //draw jitter
        float jitterZ = Mathf.Abs(_cache[Math.Max(_x - 1, 0)].z - _cache[_x].z) / 2f;
        drawLine(_x, _height - _borderBottom, _x, (int)(_height - _borderBottom - (jitterZ * _borderBottom)), Color.blue);

        //draw line
        drawLine(0, _height - _borderBottom, _graphWidth, _height - _borderBottom, Color.white);

        _tex.Apply();

        _preVector = currentVec;

        _x = (_x + 1) % _graphWidth;
    }
Exemple #18
0
        public IEnumerator ClickingTypeLabelTwiceForTypeDefinedInThisAssetShouldOpenThisAsset()
        {
            var guiEvent = new GuiEvent(
                EventType.MouseDown,
                TypeFieldRect.center,
                2,
                0
                );
            var typeField = new TypeField(
                TypeFieldRect,
                typeof(C),
                Types,
                null,
                guiEvent
                );

            thisScriptOpenedAtC = false;
            var testWindow = EditorWindow.GetWindow <TestEditorWindow>();

            testWindow.onGui = new EditorEvent(typeField.DrawGui);
            yield return(new WaitUntil(testWindow.OnGUIInitialized).OrTimeout(2000));

            Assert.IsTrue(thisScriptOpenedAtC);
        }
Exemple #19
0
    void subMenuChangeHandler(GuiEvent e)
    {
        //Debug.Log("sub menu changed");
        if (_lastPage != null){
            _lastPage.hide();
        }

        if (_subMenu.selectedItem != null){
            if (_lastPage == null){
                _sceneScript.hideScene();
                this.enabled = false;
            }
            _lastPage = _subMenu.GetPageAtIndex(_subMenu.selectedItem.listIndex);
            _lastPage.show();
        }
    }
Exemple #20
0
        /**
         * Creates a new timer.  Timer will execute every 'timespan' seconds
         * @param timespan the number of seconds between execution
         */

        public GuiTimer(GuiEvent onTimer, float timeSpan = 1.0f) : base(0, 0)
        {
            delay    = timeSpan;
            OnTimer  = onTimer;
            TimeSpan = timeSpan;
        }
Exemple #21
0
 void zoomHandler(GuiEvent e)
 {
     s.scaleX*= (e as GestureEvent).deltaScale;
     s.scaleY*= (e as GestureEvent).deltaScale;
     Debug.Log("zoom" + (e as GestureEvent).deltaScale);
 }
Exemple #22
0
 private void itemClickHandler(GuiEvent e)
 {
     selectItem(e.target as SelectableItem);
 }
Exemple #23
0
 void playableClicked(GuiEvent e)
 {
     Sprite sprite = e.target as Sprite;
     iPhoneUtils.PlayMovie((sprite.tag as  string), Color.clear, iPhoneMovieControlMode.Full, iPhoneMovieScalingMode.None);
 }
Exemple #24
0
 void toucheHandler(GuiEvent e)
 {
     Debug.Log("touched:"+ (e as TouchEvent).touch.position);
 }
Exemple #25
0
 void rotateHandler(GuiEvent e)
 {
     s.rotation+=(e as GestureEvent).deltaRotation;
     Debug.Log("rotate"+ (e as GestureEvent).deltaRotation);
 }
Exemple #26
0
 public void ButtonClicked(GuiEvent e)
 {
     PluginSelectedHandler ();
 }
Exemple #27
0
 private void unselectHandler(GuiEvent e)
 {
     NanoTween.to(_bg,0.6f,NanoTween.Pack("scaleY",0.4f,"x",80.0f,"y",-5.0f,"ease",Ease.easeOutExpo));
     NanoTween.to(_label,0.6f,NanoTween.Pack("scaleX",0.6f,"scaleY",0.6f,"x",0.0f,"y",-12.0f,"ease",Ease.easeOutExpo));
 }
Exemple #28
0
    void zoomableItemClickHandler(GuiEvent e)
    {
        InteractImageClip clip = e.target as InteractImageClip;

        Stage.instance.addChild(clip);
        if (!clip.isSelected){
            NanoTween.to(clip, .6f, NanoTween.Pack("x", 0.0f,
                                                   "y", 0.0f,
                                                   "width", 1024f,
                                                   "height", 768f,
                                                   "ease", Ease.easeOutExpo,
                                                   "onComplete", new NanoTween.CallBack(zoomOutComplete),
                                                   "onCompleteParams", NanoTween.Pack(clip)));
            selectItem(clip);
        }
        else{
            string tag = clip.tag as string;
            float w = float.Parse(tag.Split(',')[0]);
            float h = float.Parse(tag.Split(',')[1]);
            NanoTween.to(clip, .6f, NanoTween.Pack("x", _clipPos[clip.listIndex].x,
                                                   "y", _clipPos[clip.listIndex].y,
                                                   "width", w,
                                                   "height", h,
                                                   "ease",Ease.easeOutExpo));
            addChild(clip);
            unselectItem();
        }
    }
Exemple #29
0
 protected void itemMouseDownHandler(GuiEvent e)
 {
     SelectableItem item = e.target as SelectableItem;
     selectItem(item);
     _subMenuBg.show(item.x, item.width);
 }
Exemple #30
0
    void rightArrowClicked(GuiEvent e)
    {
        if (_currentGallaryItemIndex == _gallaryItems.Length-1) return;

        NanoTween.to(getGallaryItem(_currentGallaryItemIndex), .6f, NanoTween.Pack("x", -_screenWidth, "ease", Ease.easeOutExpo));
        _currentGallaryItemIndex++;
        NanoTween.to(getGallaryItem(_currentGallaryItemIndex), .6f, NanoTween.Pack("x", 0f, "ease", Ease.easeOutExpo));

        if (_currentGallaryItemIndex == _gallaryItems.Length-1)
            NanoTween.to(_right, .6f, NanoTween.Pack("alpha", 0f, "ease", Ease.easeOutExpo));
        if (_currentGallaryItemIndex == 1)
            NanoTween.to(_left, .6f, NanoTween.Pack("alpha", 1f, "ease", Ease.easeOutExpo));

        // preload next image
        getGallaryItem(_currentGallaryItemIndex+1);
        // clean far away image
        //cleanFarItems();
    }
Exemple #31
0
 protected void unselectHandler(GuiEvent e)
 {
     NanoTween.to(_selectedBg,.3f,NanoTween.Pack("alpha",0.0f));
     NanoTween.to(_defaultBg,.3f,NanoTween.Pack("alpha",1.0f));
 }
Exemple #32
0
 private void selectChangeHandler(GuiEvent e)
 {
     if (_lastSelectedItem != null){
         Sprite txt	= _itemTxtAry[_lastSelectedItem.listIndex] as Sprite;
         NanoTween.to(txt,0.6f,NanoTween.Pack("alpha",0.0f,"y",640f,"ease",Ease.easeOutExpo));
     }
     Sprite currenttxt	= _itemTxtAry[_selectedItem.listIndex] as Sprite;
     NanoTween.to(currenttxt,0.6f,NanoTween.Pack("alpha",1.0f,"y",600f,"ease",Ease.easeOutExpo));
 }
Exemple #33
0
 void clickHandler(GuiEvent e)
 {
     _isRotate= !_isRotate;
     //s.rotation+=20;
 }
Exemple #34
0
 private void enterFrameHandler(GuiEvent e)
 {
     /*if(stage!=null){
         if(stage.mouseX!=0 && stage.mouseY!=0){
             foreach(SelectableItem item in _itemAry){
                 if(item.hittest()
             }
         }
     }*/
 }
Exemple #35
0
 void panHandler(GuiEvent e)
 {
     Debug.Log("s pan");
     s.x	+= (e as GestureEvent).deltaPan.x;
     s.y	+= (e as GestureEvent).deltaPan.y;
 }
Exemple #36
0
 public void Subscribe(GuiEvent.EventHandler callback,GuiEventType type)
 {
     Subscribe(callback,type,null);
 }
Exemple #37
0
 void swipeHandler(GuiEvent e)
 {
     Debug.Log("s swiped");
 }
Exemple #38
0
 protected void itemMouseDownHandler(GuiEvent e)
 {
     selectItem(e.target as SelectableItem);
 }
Exemple #39
0
 public static void InvokeGuiEvent(GuiEvent evt)
 {
     guiEvent?.Invoke(evt);
 }
Exemple #40
0
 void hotspotSceneClicked(GuiEvent e)
 {
     if (_selectedSpotIndex > -1){
         if (e == null){
             Sprite spot = _spots[_selectedSpotIndex];
             PopupImageClip image = _spotImages[_selectedSpotIndex];
             NanoTween.to(image, .6f, NanoTween.Pack("alpha", 0f, "scaleX", 0f, "scaleY", 0f, "x", spot.x, "y", spot.y, "ease", Ease.easeOutExpo));
         }
     }
 }