Exemple #1
0
    void UpdateChip()
    {
        Chip updatedChip = TryPackageAndReplaceChip(activeChipEditor.chipName);

        ChipSaver.Update(activeChipEditor, updatedChip);
        LoadNewEditor();
    }
    // Select signal (starts dragging, shows rename field)
    void SelectSignal(ChipSignal signalToDrag)
    {
        // Dragging
        selectedSignals.Clear();

        for (int i = 0; i < signals.Count; i++)
        {
            if (signals[i] == signalToDrag || ChipSignal.InSameGroup(signals[i], signalToDrag))
            {
                selectedSignals.Add(signals[i]);
            }
        }
        bool isGroup = selectedSignals.Count > 1;

        isDragging = true;

        var wireType = Pin.WireType.Simple;

        if (selectedSignals[0] is InputSignal)
        {
            var signal = selectedSignals[0];
            var pin    = signal.outputPins[0];
            wireType = pin.wireType;
        }
        if (selectedSignals[0] is OutputSignal)
        {
            var signal = selectedSignals[0];
            var pin    = signal.inputPins[0];
            wireType = pin.wireType;
        }

        dragMouseStartY = InputHelper.MouseWorldPos.y;
        if (selectedSignals.Count % 2 == 0)
        {
            int indexA = Mathf.Max(0, selectedSignals.Count / 2 - 1);
            int indexB = selectedSignals.Count / 2;
            dragHandleStartY = (selectedSignals[indexA].transform.position.y + selectedSignals[indexB].transform.position.y) / 2f;
        }
        else
        {
            dragHandleStartY = selectedSignals[selectedSignals.Count / 2].transform.position.y;
        }

        // Enable UI:
        propertiesUI.gameObject.SetActive(true);
        propertiesUI.sizeDelta = new Vector2(propertiesUI.sizeDelta.x, (isGroup) ? propertiesHeightMinMax.y : propertiesHeightMinMax.x);
        nameField.text         = selectedSignals[0].signalName;
        nameField.Select();
        nameField.caretPosition = nameField.text.Length;
        twosComplementToggle.gameObject.SetActive(isGroup);
        twosComplementToggle.isOn = selectedSignals[0].useTwosComplement;
        modeDropdown.gameObject.SetActive(!isGroup);
        deleteButton.interactable = ChipSaver.IsSignalSafeToDelete(currentEditorName, signalToDrag.signalName);
        UpdateUIProperties();

        modeDropdown.SetValueWithoutNotify((int)wireType);
        UpdateUIProperties();
    }
    public void ExportChip()
    {
        string path = StandaloneFileBrowser.SaveFilePanel("Export chip design", "", currentChip.chipName + ".dls", "dls");

        if (path.Length != 0)
        {
            ChipSaver.Export(currentChip, path);
        }
    }
Exemple #4
0
 public void FinishCreation()
 {
     if (chipNameField.text != nameBeforeChanging)
     {
         // Chip has been renamed
         ChipSaver.Rename(nameBeforeChanging, chipNameField.text.Trim());
         EditChipBar();
     }
     CloseEditChipMenu();
 }
Exemple #5
0
    public void EditChip(Chip chip)
    {
        panel.gameObject.SetActive(true);
        GameObject chipUI = GameObject.Find("Create (" + chip.chipName + ")");

        this.gameObject.transform.position = chipUI.transform.position + new Vector3(7.5f, -1.2f, 0);
        float xVal = Math.Min(this.gameObject.transform.position.x, 13.9f);

        xVal = Math.Max(xVal, -0.1f);
        this.gameObject.transform.position = new Vector3(xVal, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
        chipNameField.text        = chip.chipName;
        nameBeforeChanging        = chip.chipName;
        doneButton.interactable   = true;
        deleteButton.interactable = ChipSaver.IsSafeToDelete(nameBeforeChanging);
    }
Exemple #6
0
 void SaveAndPackageChip()
 {
     ChipSaver.Save(activeChipEditor);
     PackageChip();
     LoadNewEditor();
 }
Exemple #7
0
 public void DeleteChip()
 {
     ChipSaver.Delete(nameBeforeChanging);
     CloseEditChipMenu();
     EditChipBar();
 }