Example #1
0
 private static void OnFiles(IEnumerable <string> aFiles, POINT aPos)
 {
     try {
         foreach (string path in aFiles)
         {
             if (!RegImageSuffix.IsMatch(path))
             {
                 continue;
             }
             Vector2 pos = Utils.GetRealPositionInContainer(new Vector2(aPos.x, aPos.y), 1);
             DisplayObjectUtil.AddDisplayObject(path, pos, Vector2.zero);
         }
     } catch (Exception e) {
         DialogManager.ShowError(e.ToString());
     }
 }
 void IBeginDragHandler.OnBeginDrag(PointerEventData eventData)
 {
     _isDrag = true;
     if (KeyboardEventManager.GetAlt() && _copying == null)
     {
         List <string>  removeElements   = GlobalData.CurrentSelectDisplayObjectDic.KeyList();
         List <Element> copiedElements   = new List <Element>();
         List <string>  addElements      = new List <string>();
         List <Element> selectedElements = GlobalData.ModuleDic[GlobalData.CurrentModule]
                                           .Where(element => GlobalData.CurrentSelectDisplayObjectDic.ContainsKey(element.Name))
                                           .ToList();
         GameObject selfReplisome = null;
         int        count         = selectedElements.Count;
         for (int idx = 0; idx < count; ++idx)
         {
             Element element = selectedElements[idx];
             if (element == null)
             {
                 continue;
             }
             string    key               = $"{GlobalData.CurrentModule}_{element.Name}";
             string    imageUrl          = GlobalData.DisplayObjectPathDic.ContainsKey(element.Name) ? imageUrl = GlobalData.DisplayObjectPathDic[key] : null;
             Vector2   pos               = new Vector2(element.X, element.Y) + Element.InvConvertTo(GlobalData.OriginPoint);
             Vector2   size              = new Vector2(element.Width, element.Height);
             Transform copyDisplayObject = DisplayObjectUtil.AddDisplayObject(imageUrl,
                                                                              pos,
                                                                              size,
                                                                              element.Name + "_copy",
                                                                              false,
                                                                              false);
             if (copyDisplayObject == null)
             {
                 continue;
             }
             copiedElements.Add(new Element {
                 Name    = copyDisplayObject.name,
                 X       = pos.x,
                 Y       = pos.y,
                 Width   = size.x,
                 Height  = size.y,
                 Visible = true
             });
             addElements.Add(copyDisplayObject.name);
             if (!element.Name.Equals(transform.name))
             {
                 continue;
             }
             selfReplisome = copyDisplayObject.gameObject;
             DisplayObjectManager dom = copyDisplayObject.GetComponent <DisplayObjectManager>();
             if (dom)
             {
                 dom._offset = _offset;
             }
         }
         HistoryManager.Do(BehaviorFactory.GetCopyDisplayObjectsBehavior(GlobalData.CurrentModule, copiedElements, false, CombineType.Next), true);
         HistoryManager.Do(BehaviorFactory.GetUpdateSelectDisplayObjectBehavior(GlobalData.CurrentModule, addElements, removeElements, CombineType.Next));
         ExecuteEvents.Execute(gameObject, eventData, ExecuteEvents.endDragHandler);
         if (selfReplisome == null)
         {
             return;
         }
         eventData.pointerDrag = selfReplisome;
     }
     else
     {
         _startPos = selfRect.anchoredPosition;
     }
 }
Example #3
0
    private void UpdateShortcut()
    {
        bool isFocusOnInputText = Utils.IsFocusOnInputText();
        bool isControlDown      = GetControl();
        bool isShiftDown        = GetShift();
        bool isAltDown          = GetAlt();

        if (isControlDown)
        {
            if (Input.GetKeyDown(KeyCode.M))
            {
                functionButtonHandler.OnCreateModuleButtonClick();
            }
            else if (Input.GetKeyDown(KeyCode.N))
            {
                Vector2 pos = Utils.GetRealPositionInContainer(Input.mousePosition);
                DisplayObjectUtil.AddDisplayObject(null, pos, GlobalData.DefaultSize, null, true);
            }
            else if (Input.GetKeyDown(KeyCode.Backspace))
            {
                functionButtonHandler.OnRemoveButtonClick();
            }
            else if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                functionButtonHandler.OnUpButtonClick();
            }
            else if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                functionButtonHandler.OnDownButtonClick();
            }
            else if (Input.GetKeyDown(KeyCode.P))
            {
                functionButtonHandler.OnCopyButtonClick();
            }
            else if (Input.GetKeyDown(KeyCode.I))
            {
                functionButtonHandler.OnImportButtonClick();
            }
            else if (Input.GetKeyDown(KeyCode.E))
            {
                functionButtonHandler.OnExportButtonClick();
            }
            else if (Input.GetKeyDown(KeyCode.H))
            {
                functionButtonHandler.OnHelpButtonClick();
            }
            else if (Input.GetKeyDown(KeyCode.T) && GlobalData.FrameToggle)
            {
                functionButtonHandler.OnToggleTrigger(!GlobalData.FrameToggle.isOn);
            }
        }

        if (Input.GetKeyDown(KeyCode.Delete) && !isFocusOnInputText)
        {
            functionButtonHandler.OnRemoveButtonClick();
        }

        if (Input.GetKeyDown(KeyCode.Escape) && GlobalData.CurrentSelectDisplayObjectDic.Count != 0 && !isFocusOnInputText)
        {
            List <string> removeElements = GlobalData.CurrentSelectDisplayObjectDic.KeyList();
            if (removeElements != null)
            {
                HistoryManager.Do(BehaviorFactory.GetUpdateSelectDisplayObjectBehavior(GlobalData.CurrentModule, null, removeElements));
            }
        }

        if (isControlDown && !isFocusOnInputText)
        {
            if (Input.GetKeyDown(KeyCode.C))
            {
                DisplayObjectUtil.CopySelectDisplayObjects();
            }
            else if (Input.GetKeyDown(KeyCode.V))
            {
                containerManager.PasteDisplayObjects();
            }
        }

        if (isControlDown)
        {
            if (Input.GetKeyDown(KeyCode.Z))
            {
                HistoryManager.Undo();
            }
            else if (Input.GetKeyDown(KeyCode.Y))
            {
                HistoryManager.Do();
            }
        }

        if (isControlDown && Input.GetKeyDown(KeyCode.S))
        {
            if (string.IsNullOrWhiteSpace(GlobalData.CurrentFilePath))
            {
                functionButtonHandler.OnExportButtonClick();
            }
            else
            {
                ModuleUtil.ExportModules(GlobalData.CurrentFilePath, true);
            }
        }

        if (isControlDown && isShiftDown && isAltDown && Input.GetKeyDown(KeyCode.D))
        {
            Debugger.ShowDebugging = !Debugger.ShowDebugging;
        }

        if (isControlDown && isShiftDown && isAltDown && Input.GetKeyDown(KeyCode.F))
        {
            Screen.fullScreen = !Screen.fullScreen;
        }

        if (Input.GetKeyDown(KeyCode.Q))
        {
            Debug.Log($"pos: {Utils.GetRealPosition(Input.mousePosition)}");
        }
    }
 public void OnAddButtonClick()
 {
     DisplayObjectUtil.AddDisplayObject(null, Element.InvConvertTo(GlobalData.OriginPoint), GlobalData.DefaultSize, null, true);
 }