示例#1
0
        public CroppingAdorner(UIElement adornedElement) : base(adornedElement)
        {
            _visualCollection   = new VisualCollection(this);
            _originalCanvas     = (Canvas)adornedElement;
            _canvasOverlay      = new Canvas();
            _rectangleManager   = new RectangleManager(_canvasOverlay);
            _overlayManager     = new OverlayManager(_canvasOverlay, _rectangleManager);
            _thumbManager       = new ThumbManager(_canvasOverlay, _rectangleManager);
            _displayTextManager = new DisplayTextManager(_canvasOverlay, _rectangleManager);
            _visualCollection.Add(_canvasOverlay);

            MouseLeftButtonDown += MouseLeftButtonDownEventHandler;
            MouseMove           += MouseMoveEventHandler;
            MouseLeftButtonUp   += MouseLeftButtonUpEventHandler;

            //add overlay
            Loaded += (sender, args) => { _overlayManager.UpdateOverlay(); };

            //if rectangle size chanhed, re-draw overlay
            _rectangleManager.RectangleSizeChanged += (sender, args) =>
            {
                _overlayManager.UpdateOverlay();
                _displayTextManager.UpdateSizeText();
            };
            _rectangleManager.OnRectangleDoubleClickEvent += (sender, args) =>
            {
                if (OnRectangleDoubleClickEvent != null)
                {
                    OnRectangleDoubleClickEvent(sender, new DoubleClickEventArgs()
                    {
                        BitmapFrame = GetCroppedBitmapFrame()
                    });
                }
            };
        }
示例#2
0
    private static bool Prefix
    (
        SteeringWheel __instance,
        ref bool ___hasBeenPlaced,
        ref bool ___isDisplayingText,
        DisplayTextManager ___displayText,
        ref Network_Player ___localPlayer,
        ref Semih_Network ___network
    )
    {
        if (!___hasBeenPlaced)
        {
            return(true);
        }
        if (MyInput.GetButton("Sprint"))
        {
            ___isDisplayingText = true;
            ___displayText.ShowText("Toggle Engines", MyInput.Keybinds["Interact"].MainKey, 1, "Toggle Engine Direction", MyInput.Keybinds["Rotate"].MainKey, 2);

            if (MyInput.GetButtonDown("Interact"))
            {
                MoreSailsMoreSpeed.ToggleAllEngines();
            }
            if (MyInput.GetButtonDown("Rotate"))
            {
                MoreSailsMoreSpeed.ToggleAllEnginesDir();
            }
        }
        else
        {
            ___isDisplayingText = true;
            ___displayText.ShowText("Hold for more options", MyInput.Keybinds["Sprint"].MainKey, 1, Helper.GetTerm("Game/RotateSmooth2", false), MyInput.Keybinds["Rotate"].MainKey, 2);
            if (MyInput.GetButtonDown("Rotate"))
            {
                ___localPlayer.PlayerScript.SetMouseLookScripts(false);
            }
            if (MyInput.GetButtonUp("Rotate"))
            {
                ___localPlayer.PlayerScript.SetMouseLookScripts(true);
            }
            if (MyInput.GetButton("Rotate"))
            {
                float axis = Input.GetAxis("Mouse X");
                Message_SteeringWheel_Rotate message = new Message_SteeringWheel_Rotate(Messages.SteeringWheelRotate, ___network.NetworkIDManager, __instance.ObjectIndex, axis);
                if (Semih_Network.IsHost)
                {
                    AccessTools.Method("SteeringWheel:Rotate").Invoke(__instance, new object[] { axis });
                    return(false);
                }
                ___network.SendP2P(___network.HostID, message, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game);
            }
        }
        return(false);
    }
    public void OnIsRayed()
    {
        if (IsKill)
        {
            return;
        }

        wasRayed = true;

        if (displayText == null)
        {
            displayText = ComponentManager <DisplayTextManager> .Value;
            if (displayText == null)
            {
                return;
            }
        }

        if (CanvasHelper.ActiveMenu != MenuType.None || PlayerItemManager.IsBusy || !Helper.LocalPlayerIsWithinDistance(transform.position, Player.UseDistance))
        {
            displayText.HideDisplayTexts();
            return;
        }

        var recipeName = recipeUI.Recipe.Result.settings_Inventory.DisplayName;

        if (cookingPot == null)
        {
            displayText.ShowText($"{recipeName}\nNo cookingpot in proximity", 0, true, 0);
            return;
        }

        if (!preparationCalculated)
        {
            CalculatePreparation();
        }

        var missingItems = originalTMPLabelColors.Count + originalLabelColors.Count;

        if (missingItems > 0)
        {
            displayText.ShowText($"{recipeName}\nMissing {missingItems} ingredients", 0, true, 0);
            return;
        }

        if (wrongOrFreeSlots.Count != unpreparedIngredients.Count)
        {
            Debug.Log($"{recipeName}: There are {wrongOrFreeSlots.Count} slots that should be replaced, but there is actually {unpreparedIngredients.Count} items that needs to be placed");
            displayText.ShowText($"{recipeName}\nUnable to auto-prepare, check logs", 0, true, 0);
            return;
        }

        if (unpreparedIngredients.Count == 0)
        {
            if (cookingPot.CurrentRecipe != null)
            {
                displayText.ShowText($"{recipeName}\nPrepared, but cookingpot is busy", 0, true, 0);
            }
            else if (cookingPot.Fuel.GetFuelCount() == 0)
            {
                displayText.ShowText($"{recipeName}\nNo fuel in cookingpot", 0, true, 0);
            }
            else
            {
                displayText.ShowText($"{recipeName}\nStart cooking", MyInput.Keybinds["Interact"].MainKey, 0, 0, true);
                if (MyInput.GetButtonDown("Interact"))
                {
                    Traverse.Create(cookingPot).Method("HandleStartCooking").GetValue();
                    ClearPreparation();
                }
            }
            return;
        }

        displayText.ShowText($"{recipeName}\nPrepare", MyInput.Keybinds["Interact"].MainKey, 0, 0, true);
        if (MyInput.GetButtonDown("Interact"))
        {
            // ToList() because our SetItem()/ClearItem() hooks will trigger
            // OrderBy() because it's fun to have the ingredients shuffled :)
            foreach ((var slot, var item) in wrongOrFreeSlots.Zip(unpreparedIngredients.OrderBy(_ => Guid.NewGuid()), (slot, item) => (slot, item)).ToList())
            {
                if (slot.HasItem)
                {
                    slot.OnPickupItem(cookingPot.localPlayer, slot, slot.CurrentItem);
                }

                if (!Traverse.Create(slot).Field <ItemObjectEnabler>("objectEnabler").Value.DoesAcceptItem(item))
                {
                    Debug.Log($"{recipeName}: The item \"{item.UniqueName}\" can not be placed in cooking pot slot");
                }
                else
                {
                    var itemInstance = new ItemInstance(item, 1, item.MaxUses);
                    slot.OnInsertItem(cookingPot.localPlayer, slot, itemInstance);
                }
            }
            ClearPreparation();
        }
    }
示例#4
0
        //private static bool cheatsActivated = false;

        public void Awake()
        {
            textManager = FindObjectOfType <DisplayTextManager>();
        }
示例#5
0
 void Awake()
 {
     displayTextManager = GetComponent <DisplayTextManager>();
     Debug.Log("DisplayTextController mounted");
     inputField.onEndEdit.AddListener(displayTextManager.AcceptStringInput);
 }