public void DeletePreset(OrderPreset preset) { DispensaryManager dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); dm.currentCompany.RemovePreset(vendor.vendorName, preset); ActivatePresetsPanel(); }
public override bool Equals(object obj) { OrderPreset param = (OrderPreset)obj; bool allProductsMatch = true; foreach (ProductOrder_s productOrder in productList) { bool productMatched = false; foreach (ProductOrder_s paramProductOrder in param.productList) { if (paramProductOrder.ID == productOrder.ID) { if (paramProductOrder.quantity == productOrder.quantity) { productMatched = true; } } } if (!productMatched) { allProductsMatch = false; break; } } if (allProductsMatch) { return(true); } else { return(false); } }
public void SelectOrderPreset(OrderPreset newOrderPreset) { selectedOrderPresetItems.gameObject.SetActive(true); notSelectedOrderPresetItems.gameObject.SetActive(false); selectedOrderPreset = newOrderPreset; deliveryEventTitleText.text = newOrderPreset.presetName; }
// Button Callbacks public void OnOrderPresetClick(OrderPreset preset) { selectedType = SelectedType.orderPreset; selectedOrderPreset = preset; selectedPlacedOrder = null; DisplayOrderPreset(); }
public void CreateOrderPresetsList() { foreach (Image displayed in displayedOrderPresets) { Destroy(displayed.gameObject); } displayedOrderPresets.Clear(); List <OrderPreset> orderPresets = dm.currentCompany.GetOrderPresets(string.Empty); float prefabHeight = orderPresetPrefab.rectTransform.rect.height; for (int i = 0; i < orderPresets.Count; i++) { int temp = i; OrderPreset thisPreset = orderPresets[temp]; Image newOrderPresetDisplay = Instantiate(orderPresetPrefab); Button thisButton = newOrderPresetDisplay.GetComponent <Button>(); thisButton.onClick.AddListener(() => SelectOrderPreset(thisPreset)); newOrderPresetDisplay.gameObject.SetActive(true); Text[] childText = newOrderPresetDisplay.GetComponentsInChildren <Text>(); childText[0].text = thisPreset.presetName; try { childText[1].text = thisPreset.vendor.vendorName; } catch (System.NullReferenceException) { childText[1].text = "Vendor error"; } childText[2].text = "$" + thisPreset.totalCost; newOrderPresetDisplay.transform.SetParent(orderPresetsContentPanel.transform.parent, false); newOrderPresetDisplay.rectTransform.anchoredPosition = new Vector2(0, -i * prefabHeight); displayedOrderPresets.Add(newOrderPresetDisplay); newOrderPresetDisplay.transform.SetParent(orderPresetsContentPanel.transform); } }
public void OnPlacedOrderClick(Order order) { selectedType = SelectedType.placedOrder; selectedOrderPreset = null; selectedPlacedOrder = order; DisplayPlacedOrder(); }
private void Preset_Test(int OrderID) { using (var orderPreset = new OrderPreset(Session, db.Orders.Find(OrderID))) { orderPreset.Save(); } }
public void NewPreset(OrderPreset newPreset) { if (orderPresets == null) { orderPresets = new List <OrderPreset>(); } orderPresets.Add(newPreset); }
public void NewOrderPreset(string vendorName, OrderPreset newPreset) { foreach (Vendor_s vendor in hiredVendors) { if (vendor.vendorName.Equals(vendorName)) { vendor.NewPreset(newPreset); } } }
public void RemovePreset(OrderPreset toRemove) { List <OrderPreset> newList = new List <OrderPreset>(); foreach (OrderPreset orderPreset in orderPresets) { if (!orderPreset.presetName.Equals(toRemove.presetName)) { newList.Add(orderPreset); } } orderPresets = newList; }
public bool CheckAgainstList(OrderPreset orderPreset) { List <OrderPreset> orderPresets = GetOrderPresets(string.Empty); foreach (OrderPreset preset in orderPresets) { if (orderPreset.Equals(preset)) { return(true); } } return(false); }
public void CreateOrderPresetList() { Start(); DispensaryManager dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); List <OrderPreset> orders = dm.currentCompany.GetOrderPresets(vendor.vendorName); if (orders != null) { if (orders.Count == 0) { noPresetsText.gameObject.SetActive(true); } else { noPresetsText.gameObject.SetActive(false); } foreach (OrderPresetDisplayObject disp in displayedPresetObjects) { Destroy(disp.gameObject); } displayedPresetObjects.Clear(); //orders = SortList(panel.sortMode, vendors); RectTransform rectTransform = orderPresetContentPanel.GetComponent <RectTransform>(); //rectTransform.sizeDelta = new Vector2(contentPanel.rectTransform.sizeDelta.x, 0); float prefabHeight = orderPresetPrefab.gameObject.GetComponent <RectTransform>().rect.height; float contentPanelHeight = orders.Count * prefabHeight + (prefabHeight * .5f); //print("Prefab Height: " + prefabHeight + "\nContent Panel Height(Old): " + contentPanel.rectTransform.sizeDelta.y // + "\nContent Panel Height(New): " + contentPanelHeight + "\nPrefab Height, New: " + displayPrefab.gameObject.GetComponent<RectTransform>().rect.height); rectTransform.sizeDelta = new Vector2(orderPresetContentPanel.rectTransform.sizeDelta.x, contentPanelHeight); for (int i = 0; i < orders.Count; i++) { Image orderPresetGO = Instantiate(orderPresetPrefab); Button[] buttonComponents = orderPresetGO.GetComponentsInChildren <Button>(); int temp = i; OrderPreset order = orders[temp]; buttonComponents[0].onClick.AddListener(() => LoadOrderFormPreset(order)); Text[] textComponents = orderPresetGO.GetComponentsInChildren <Text>(); textComponents[0].text = orders[i].presetName; orderPresetGO.transform.SetParent(orderPresetContentPanel.transform.parent, false); orderPresetGO.gameObject.SetActive(true); orderPresetGO.rectTransform.anchoredPosition = new Vector2(0, -prefabHeight * i); OrderPresetDisplayObject orderDisplayObject = orderPresetGO.gameObject.AddComponent <OrderPresetDisplayObject>(); displayedPresetObjects.Add(orderDisplayObject); //newStaffDisplayObject } foreach (OrderPresetDisplayObject obj in displayedPresetObjects) { obj.transform.SetParent(orderPresetContentPanel.transform); } } }
public void DisplayPresetsList() { ClearPresetsList(); ClearDisplayingPresetOrderList(); ClearDisplayingPlacedOrderList(); mainImage.sprite = SpriteManager.orderDisplayPanel_DisplayingPresetsSprite; displayingPresetsListContents.gameObject.SetActive(true); displayingPlacedOrderContents.gameObject.SetActive(false); displayingOrderPresetContents.gameObject.SetActive(false); // Create List List <OrderPreset> orderPresets = dm.currentCompany.GetOrderPresets(string.Empty); if (orderPresets.Count > 0) { orderPresetsScrollbar.value = 1; foreach (OrderPresetDisplayObject disp in presetsDisplayed) { Destroy(disp.gameObject); } presetsDisplayed.Clear(); RectTransform rectTransform = presetsContentPanel.GetComponent <RectTransform>(); float prefabHeight = presetPrefab.gameObject.GetComponent <RectTransform>().rect.height; float contentPanelHeight = orderPresets.Count * prefabHeight + (prefabHeight * .5f); rectTransform.sizeDelta = new Vector2(presetsContentPanel.rectTransform.sizeDelta.x, contentPanelHeight); for (int i = 0; i < orderPresets.Count; i++) { Image orderDisplayGO = Instantiate(presetPrefab); Button[] buttonComponents = orderDisplayGO.GetComponents <Button>(); OrderPreset orderPreset = orderPresets[i]; //buttonComponents[0].onClick.AddListener(() => dm.uiManagerObject.GetComponent<UIManager_v3>().CreateOrderPreviewPanel(order)); Text[] textComponents = orderDisplayGO.GetComponentsInChildren <Text>(); textComponents[0].text = orderPresets[i].presetName; orderDisplayGO.transform.SetParent(presetsContentPanel.transform.parent, false); orderDisplayGO.gameObject.SetActive(true); orderDisplayGO.rectTransform.anchoredPosition = new Vector2(0, -prefabHeight * i); OrderPresetDisplayObject presetDisplayObject = orderDisplayGO.gameObject.GetComponent <OrderPresetDisplayObject>(); presetsDisplayed.Add(presetDisplayObject); //newStaffDisplayObject } foreach (OrderPresetDisplayObject obj in presetsDisplayed) { obj.transform.SetParent(presetsContentPanel.transform); } } }
public void SetupOrderPreset(OrderPreset preset) { orderNameText.text = preset.presetName; vendorNameText.text = preset.vendor.vendorName; // Figure quantity int quantity = 0; foreach (ProductOrder_s productOrder in preset.productList) { quantity++; } foreach (BudOrder_s budOrder in preset.budList) { quantity++; } orderQuantityText.text = "Products: " + quantity; }
public void LoadOrderFormPreset(OrderPreset preset) { Order newOrder = new Order(vendor, this); newOrder.orderName = preset.presetName; foreach (ProductOrder_s product_s in preset.productList) { StoreObjectReference reference = database.GetProduct(product_s.ID); newOrder.AddProduct(reference, product_s.quantity); } foreach (BudOrder_s bud_s in preset.budList) { Strain strain = database.GetStrain(bud_s.name); newOrder.AddBud(strain, bud_s.weight); } orderFormPanel.deleteOrderPresetButton.onClick.RemoveAllListeners(); orderFormPanel.deleteOrderPresetButton.onClick.AddListener(() => DeletePreset(preset)); OpenOrderForm(newOrder); }
public void Checkout() { DispensaryManager dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); string orderName = orderNameInputField.currentOrderName; if (!currentOrder.savedAsPreset) { if (orderName != "" || orderName != string.Empty) { if (saveAsPresetToggle.toggle.isOn) { OrderPreset newPreset = new OrderPreset(orderName, currentOrder.GetTotalCost(), currentOrder.productList, currentOrder.budList); if (dm.dispensary.CheckAgainstList(orderName)) { orderFormErrorPopup.ActivateError("Order name already taken"); return; } else { if (dm.currentCompany.CheckAgainstList(orderName, false)) { orderFormErrorPopup.ActivateError("Order preset already exists with this name"); return; } else { Order toAdd = currentOrder; toAdd.orderName = orderName; dm.dispensary.AddOrder(toAdd); dm.currentCompany.NewOrderPreset(vendorSelectionPanel.vendor.vendorName, newPreset); currentOrder = null; CreateOrderFormList(); GetComponentInParent <VendorsUISubPanel>().ChangeTab(1); } } } else { if (dm.dispensary.CheckAgainstList(orderName)) { orderFormErrorPopup.ActivateError("An order with this name is pending delivery"); return; } else { Order toAdd = currentOrder; toAdd.orderName = orderName; dm.dispensary.AddOrder(toAdd); currentOrder = null; CreateOrderFormList(); GetComponentInParent <VendorsUISubPanel>().ChangeTab(1); } } } else { orderFormErrorPopup.ActivateError("No order name entered"); return; } } else { if (dm.dispensary.CheckAgainstList(orderName)) { orderFormErrorPopup.ActivateError("An order with this name is pending delivery"); return; } else { Order toAdd = currentOrder; toAdd.orderName = orderName; dm.dispensary.AddOrder(toAdd); currentOrder = null; CreateOrderFormList(); GetComponentInParent <VendorsUISubPanel>().ChangeTab(1); } } /*bool saveAsPreset = false; * if (saveAsPresetToggle.toggle.isOn || currentOrder.savedAsPreset) // if already saved as preset, keep it * { * saveAsPreset = true; * } * if (orderNameInputField.currentOrderName != "" || orderNameInputField.currentOrderName != string.Empty) * { * string orderName = orderNameInputField.currentOrderName; * if (!dm.dispensary.CheckAgainstList(orderName)) * { * Order toAdd = currentOrder; * toAdd.orderName = orderName; * dm.dispensary.AddOrder(toAdd); * if (saveAsPreset) * { * OrderPreset newPreset = new OrderPreset(orderName, 0, currentOrder.productList, currentOrder.budList); * dm.company.NewOrderPreset(vendorSelectionPanel.vendor.vendorName, newPreset); * } * currentOrder = null; * CreateOrderFormList(); * GetComponentInParent<VendorsUISubPanel>().ChangeTab(1); * } * else * { * orderFormErrorPopup.ActivateError("Name already taken"); * } * } * else * { * orderFormErrorPopup.ActivateError("Input an order name"); * }*/ }
public void SelectEventType(string newSelectedTypeString) { HideEventTypeDescriptions(); ClearEventSchedulerPanel(); switch (newSelectedTypeString) { case "delivery": if (deliveryEventTypeDisplay.selected) { deliveryEventTypeDisplay.Deselect(); LoadEventScheduler(); } else { selectedOrderPreset = null; deliveryEventItems.gameObject.SetActive(true); deliveryEventTypeDisplay.SetToSelected(); smokeLoungeEventTypeDisplay.Deselect(); glassShopEventTypeDisplay.Deselect(); growroomEventTypeDisplay.Deselect(); if (selectedOrderPreset != null) { selectedOrderPresetItems.gameObject.SetActive(true); notSelectedOrderPresetItems.gameObject.SetActive(false); } else { selectedOrderPresetItems.gameObject.SetActive(false); notSelectedOrderPresetItems.gameObject.SetActive(true); } deliveryEventTitleText.text = "Schedule a Delivery Event"; CreateOrderPresetsList(); } break; case "smokeLounge": if (smokeLoungeEventTypeDisplay.selected) { smokeLoungeEventTypeDisplay.Deselect(); LoadEventScheduler(); } else { selectedSmokeLoungeEvent = null; smokeLoungeEventItems.gameObject.SetActive(true); deliveryEventTypeDisplay.Deselect(); smokeLoungeEventTypeDisplay.SetToSelected(); glassShopEventTypeDisplay.Deselect(); growroomEventTypeDisplay.Deselect(); if (selectedSmokeLoungeEvent != null) { selectedSmokeLoungeItems.gameObject.SetActive(true); notSelectedSmokeLoungeItems.gameObject.SetActive(false); } else { selectedSmokeLoungeItems.gameObject.SetActive(false); notSelectedSmokeLoungeItems.gameObject.SetActive(true); } smokeLoungeEventTitleText.text = "Schedule a Smoke Lounge Event"; CreateSmokeLoungeEventsList(); } break; case "glassShop": if (glassShopEventTypeDisplay.selected) { glassShopEventTypeDisplay.Deselect(); LoadEventScheduler(); } else { selectedGlassShopEvent = null; glassShopEventItems.gameObject.SetActive(true); deliveryEventTypeDisplay.Deselect(); smokeLoungeEventTypeDisplay.Deselect(); glassShopEventTypeDisplay.SetToSelected(); growroomEventTypeDisplay.Deselect(); if (selectedGlassShopEvent != null) { selectedGlassShopItems.gameObject.SetActive(true); notSelectedGlassShopItems.gameObject.SetActive(false); } else { selectedGlassShopItems.gameObject.SetActive(false); notSelectedGlassShopItems.gameObject.SetActive(true); } glassShopEventTitleText.text = "Schedule a Glass Shop Event"; CreateGlassShopEventsList(); } break; case "growroom": if (growroomEventTypeDisplay.selected) { growroomEventTypeDisplay.Deselect(); LoadEventScheduler(); } else { selectedGrowroomEvent = null; growroomEventItems.gameObject.SetActive(true); deliveryEventTypeDisplay.Deselect(); smokeLoungeEventTypeDisplay.Deselect(); glassShopEventTypeDisplay.Deselect(); growroomEventTypeDisplay.SetToSelected(); if (selectedGrowroomEvent != null) { selectedGrowroomItems.gameObject.SetActive(true); notSelectedGrowroomItems.gameObject.SetActive(false); } else { selectedGrowroomItems.gameObject.SetActive(false); notSelectedGrowroomItems.gameObject.SetActive(true); } growroomEventTitleText.text = "Schedule a Growroom Event"; CreateGrowroomEventsList(); } break; } UpdateEventTypeButtons(); }
public void RemovePreset(string vendorName, OrderPreset toRemove) { Vendor_s toRemoveFrom = GetVendor(vendorName); toRemoveFrom.RemovePreset(toRemove); }