Example #1
0
 new void Start()
 {
     base.Start();
     instance            = this;
     buttonToDelegateMap = new Dictionary <Button, HighlightAsLabelSlot>();
     panel = GetComponentInChildren <GridLayoutGroup>();
     RefreshPanel();
     panelHideButton.onClick.AddListener(() => ClearLabelHighlighting());
 }
Example #2
0
 public void cleanup()
 {
     for (int i = 0; i < 3; i++)
     {
         Button opBtn = getButtonForOperandIndex(i);
         RegisterPanelManager.DeregisterAsRegisterSlot(opBtn);
         LabelPanelManager.DeregisterAsLabelSlot(opBtn);
         ImmediatePanelManager.DeregisterAsImmediateSlot(opBtn);
     }
 }
Example #3
0
    public static void RegisterAsLabelSlot(CodeLine line, Button labelSlot, Text labelText)
    {
        HighlightAsLabelSlot temp = (string label, Color c) =>
        {
            labelText.color = c;
            labelSlot.onClick.AddListener(() =>
            {
                line.SetLabel(label);
                LabelPanelManager.ClearLabelHighlighting();
            });
        };

        instance.buttonToDelegateMap.Add(labelSlot, temp);
        instance.registerSlotHighlighter += temp;
        instance.disableHighlighting     += (Color n) =>
        {
            labelSlot.onClick.RemoveAllListeners();
            labelText.color = n;
        };
    }
Example #4
0
    public CodeLine setupLine(OpcodeRepository.OPCODE code)
    {
        instr.code = code;
        if (instrText != null)
        {
            instrText.text = code.ToString();
        }
        lineAdjustButton.onClick.AddListener(() => LineAdjuster.ShowAdjusterForLine(this));

        //Register each of the operands to their appropriate listeners.
        for (int i = 0; i < 3; i++)
        {
            if (OpcodeRepository.indexUnused(code, i))
            {
                disableOperandText(i);
                continue;
            }
            if (OpcodeRepository.canPlaceRegister(code, i))
            {
                RegisterPanelManager.RegisterAsRegisterSlot(this, getButtonForOperandIndex(i), getTextForOperandIndex(i), i);
                getTextForOperandIndex(i).text = "register";
            }
            if (OpcodeRepository.canPlaceImmediate(code, i))
            {
                ImmediatePanelManager.RegisterAsRegisterSlot(this, getButtonForOperandIndex(i), getTextForOperandIndex(i), i);
                getTextForOperandIndex(i).text = "immediate";
            }
            if (OpcodeRepository.canPlaceLabel(code, i))
            {
                LabelPanelManager.RegisterAsLabelSlot(this, getButtonForOperandIndex(i), getTextForOperandIndex(i), i);
                getTextForOperandIndex(i).text = "label";
            }

            //TOOD add in the ability to place memory locations
        }
        LabelPanelManager.RegisterAsLabelSlot(this, labelButton, labelText);
        return(this);
    }
Example #5
0
    public static void RegisterAsLabelSlot(CodeLine line, Button labelSlot, Text labelText, int operandIndex)
    {
        HighlightAsLabelSlot temp = (string label, Color c) =>
        {
            labelText.color = c;
            labelSlot.onClick.AddListener(() =>
            {
                Label r = new Label(label);
                switch (operandIndex)
                {
                case 0:
                    line.setOperand1(r);
                    break;

                case 1:
                    line.setOperand2(r);
                    break;

                case 2:
                    line.setOperand3(r);
                    break;

                default:
                    break;
                }
                LabelPanelManager.ClearLabelHighlighting();
            });
        };

        instance.buttonToDelegateMap.Add(labelSlot, temp);
        instance.registerSlotHighlighter += temp;
        instance.disableHighlighting     += (Color n) =>
        {
            labelSlot.onClick.RemoveAllListeners();
            labelText.color = n;
        };
    }