void OnMappingChanged(Dictionary <string, DulibaWaitor.Command> newMap) { // If this happens twice per frame, the second occurance is the new black. leftButtons.ClearNewButtons(); rightButtons.ClearNewButtons(); foreach (var kvp in newMap) { string commandKey = kvp.Key; DulibaWaitor.Command newCommand = kvp.Value; Change change = Change.Create; ButtonGroup buttonsToChange = rightButtons; if (currentMap.ContainsKey(commandKey)) { DulibaWaitor.Command oldCommand = currentMap[commandKey]; if (oldCommand.disabled.HasValue != newCommand.disabled.HasValue) { change = Change.Nothing; } if (oldCommand.callback != newCommand.callback) { change = Change.Create; } } if (newCommand.leftHand) { buttonsToChange = leftButtons; } string quantity = ""; if (dulibaWaitor.workArea is Shelf import) { foreach (var action in dulibaWaitor.actions) { if (action.command == commandKey.ToLower()) { if (!import.items[action.pickupIndex].infinite) { quantity = import.items[action.pickupIndex].itemCount.ToString(); } break; } } } /* * switch (change) * { * * case Change.Nothing: * buttonsToChange.UpdateButton(new ButtonInfo() { name = newCommand.name, button = commandKey, enabled = !newCommand.disabled.HasValue, image = newCommand.image }); * break; * case Change.Create:*/ buttonsToChange.CreateButton(new ButtonInfo() { quantity = quantity, name = newCommand.name, button = commandKey, enabled = !newCommand.disabled.HasValue, image = newCommand.image }); /*break; * } */ //buttonsToChange.DisplayButton(new ButtonInfo() { name = command.name, button = commandKey, enabled = !command.disabled.HasValue, image = command.image }); } /* * foreach (var kvp in currentMap) * { * string commandKey = kvp.Key; * DulibaWaitor.Command command = kvp.Value; * ButtonGroup buttonsToChange = rightButtons; * * if (command.leftHand) * buttonsToChange = leftButtons; * * if (!newMap.ContainsKey(kvp.Key)) * buttonsToChange.DestroyButton(kvp.Key); * }*/ currentMap = newMap; }