public static void addInstructionLine(OpcodeRepository.OPCODE opcode) { if (instance == null) { Debug.Log("Null instance!"); return; } GameObject newLine = Instantiate(instance.instructionLinePrefab) as GameObject; ((RectTransform)newLine.transform).SetParent(instance.codeList.transform); CodeLine c = newLine.GetComponent <CodeLine>(); c.setupLine(opcode); }
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); }