private void DisplayMap() { maxMapHeight = Console.WindowHeight - 2; maxMapWidth = Console.WindowWidth - 32; MainMenuHelper.MakeFrame(); foreach (MapTemplate mt in EditorInstance.Templates) { Console.ForegroundColor = mt.Color; for (int i = currentTopMargin; i < currentTopMargin + maxMapHeight; i++) { for (int j = currentLeftMargin; j < currentLeftMargin + maxMapWidth; j++) { if (j < mt.MapWidth && i < mt.MapHeight && mt.Layout[j, i] != ' ') { Console.SetCursorPosition(j + mapStartLeftMargin - currentLeftMargin, i + mapStartTopMargin - currentTopMargin); Console.Write(mt.Layout[j, i]); } } } Console.SetCursorPosition(cursorLeftPosition + mapStartLeftMargin, cursorTopPosition + mapStartTopMargin); Console.ForegroundColor = ConsoleColor.Gray; } }
private void DisplayMapSelection() { //Load maps mainMaps = Helper.GetAndVerifyMaps(Environment.CurrentDirectory + "\\Map layouts\\Main"); customMaps = Helper.GetAndVerifyMaps(Environment.CurrentDirectory + "\\Map layouts\\Custom"); //New game top part MainMenuHelper.MakeEdges('|', 0); MainMenuHelper.MakeFrame(); MainMenuHelper.MakeEdges('|', Console.WindowHeight - 2); MainMenuHelper.WriteInCenter("New game", 2); MainMenuHelper.FillALine('=', 1, 4); for (int i = 5; i < Console.WindowHeight - 6; i++) { MainMenuHelper.WriteInCenter("|", Console.CursorTop); } //Display main maps MainMenuHelper.WriteText("Main maps", 3, 6); for (int i = 0; i < mainMaps.Count; i++) { if (currentTabIndex == 0 && currentCursorIndex == i) { MainMenuHelper.WriteText(mainMaps[i].Split('\\')[^ 1], 6, ConsoleColor.Gray, ConsoleColor.Blue);
// Menu where is a table with its products and available categories of products public ActionResult TableCategories(int?id, string order) { if (id != null) { try { // Joining list of categories and selected table to a single model mainPageModel.Categories = categoryData.GetAll().OrderBy(x => x.Name).ToList(); ITableModel table = tableData.FindById((int)id); if (table == null) { log.Error("Could't find a table in the Database - return null"); return(View("ErrorTable")); } // Selection of the order of the list table.SoldProducts = MainMenuHelper.OrderListSoldProducts(table.SoldProducts, order); mainPageModel.Tables.Add(table); } catch (Exception ex) { log.Error("Could't load categories or tables from Database", ex); return(View("ErrorRetriveData")); } return(View(mainPageModel)); } else { log.Error("The table ID was null while trying to access"); return(View("ErrorTable")); } }
public ActionResult PayPartial(int id, int[] Paid, string order) { if (Paid != null) { try { // Finding the sold products from the table that are selected to be paid List <ISoldProductModel> fullList = soldProductData.GetByTable(id); // Selection of the order of the list fullList = MainMenuHelper.OrderListSoldProducts(fullList, order); // Moving in the database the selected sold products to a table of all sold products accomplished MainMenuHelper.PaySelectedSoldProducts(fullList, Paid, soldProductData, soldProductAccomplishedData); //if the table is without any product set it to empty if (fullList.Count() < 1) { ITableModel table = tableData.FindById(id); table.Occupied = false; tableData.Update(table); } } catch (Exception ex) { log.Error("Could't load sold products or tables from Database", ex); return(View("ErrorRetriveData")); } } return(RedirectToAction("Tables")); }
// It shows a menu where is the list of all products on a table that can be selected for payment public ActionResult PayPartial(int?id, string order) { if (id != null) { try { // Finding the selected table is order to list the Sold Products on it ITableModel table = tableData.FindById((int)id); // Selection of the order of the list table.SoldProducts = MainMenuHelper.OrderListSoldProducts(table.SoldProducts, order); table.OrderSoldProducts = order; return(View(table)); } catch (Exception ex) { log.Error("Could't load tables from Database", ex); return(View("ErrorRetriveData")); } } else { log.Error("The table ID was null while trying to access"); return(View("ErrorTable")); } }
public void PaySelectedSoldProducts_ShouldWork() { List <ISoldProductModel> inputList = Factory.InstanceISoldProductModelList(); ISoldProductModel product1 = Factory.InstanceSoldProductModel(); ISoldProductModel product2 = Factory.InstanceSoldProductModel(); product1.ID = 23; product1.Name = "product1"; product1.Price = 1.5M; product1.Detail = ""; product2.ID = 12; product2.Name = "product2"; product2.Price = 3.5M; product2.Detail = "algo"; inputList.Add(product1); inputList.Add(product2); int[] elements = { 0 }; Mock <ISoldProductDataAccess> soldproductData = new Mock <ISoldProductDataAccess>(); Mock <ISoldProductAccomplishedDataAccess> soldproductDataAccomplished = new Mock <ISoldProductAccomplishedDataAccess>(); MainMenuHelper.PaySelectedSoldProducts(inputList, elements, soldproductData.Object, soldproductDataAccomplished.Object); Assert.NotEmpty(inputList); Assert.Single(inputList); inputList[0].Should().BeEquivalentTo(product2); }
public void PaySelectedSoldProducts_ShouldGiveException() { List <ISoldProductModel> inputList = Factory.InstanceISoldProductModelList(); ISoldProductModel product1 = Factory.InstanceSoldProductModel(); ISoldProductModel product2 = Factory.InstanceSoldProductModel(); product1.ID = 23; product1.Name = "product1"; product1.Price = 1.5M; product1.Detail = ""; product2.ID = 12; product2.Name = "product2"; product2.Price = 3.5M; product2.Detail = "algo"; inputList.Add(product1); inputList.Add(product2); int[] elements = { 0, 3 }; Mock <ISoldProductDataAccess> soldproductData = new Mock <ISoldProductDataAccess>(); Mock <ISoldProductAccomplishedDataAccess> soldproductDataAccomplished = new Mock <ISoldProductAccomplishedDataAccess>(); Action act = () => MainMenuHelper.PaySelectedSoldProducts(inputList, elements, soldproductData.Object, soldproductDataAccomplished.Object); Assert.Throws <ArgumentOutOfRangeException>(act); }
private void DisplayEscMenu() { MainMenuHelper.MakeFrame(); MainMenuHelper.WriteInCenter("What do you want to do?", 2); MainMenuHelper.WriteSelectableTextInCenter("Go back", 6, 0, currentCursorIndex); MainMenuHelper.WriteSelectableTextInCenter("Save and exit", 8, 1, currentCursorIndex); MainMenuHelper.WriteSelectableTextInCenter("Exit without saving", 10, 2, currentCursorIndex); }
private void DisplayNewMap() { while (true) { currentCursorIndexLimit = 2; Console.SetWindowSize(30, 14); Console.SetBufferSize(30, 14); MainMenuHelper.MakeFrame(); MainMenuHelper.WriteInCenter("New map", 2); MainMenuHelper.FillALine('=', 1, 4); MainMenuHelper.WriteInCenter("Map name: ", 6); MainMenuHelper.WriteText(mapNameInput.PadRight(14), 8, 8); MainMenuHelper.WriteInCenter("‾‾‾‾‾‾‾‾‾‾‾‾‾‾", 9); Console.SetCursorPosition(8 + mapNameInput.Length, 8); Console.CursorVisible = true; ConsoleKeyInfo input = Console.ReadKey(); switch (input.Key) { case ConsoleKey.Enter: StartEditor(); return; case ConsoleKey.Backspace: if (mapNameInput.Length > 0) { mapNameInput = mapNameInput.Remove(mapNameInput.Length - 1); } break; case ConsoleKey.Escape: currentSection = MapEditorSection.Menu; Console.Clear(); Console.CursorVisible = false; DisplayMenu(); //I need to display the menu here, or else the player will be on a blank screen. return; default: if (mapNameInput.Length < 14) { if (input.KeyChar == ' ') { mapNameInput += ' '; } else { //trim used for getting rid of characters like pgup, del, insert, tab mapNameInput += input.KeyChar.ToString().Trim(); } } break; } } }
private void DisplayEditMap() { foundMaps = Helper.GetAndVerifyMaps(Environment.CurrentDirectory + "\\Map layouts\\Main"); currentCursorIndexLimit = foundMaps.Count - 1; MainMenuHelper.MakeFrame(); MainMenuHelper.WriteInCenter("Edit a map", 2); for (int i = 0; i < foundMaps.Count; i++) { string mapName = foundMaps[i].Split('\\')[^ 1];
private void DisplayMainMenu() { CursorIndexLimit = 3; MainMenuHelper.MakeFrame(); //Title text DisplayMainTitle(); MainMenuHelper.FillALine('=', 1, 13); MainMenuHelper.WriteSelectableTextInCenter("Play", 15, 0, currentCursorIndex); MainMenuHelper.WriteSelectableTextInCenter("Editor", 18, 1, currentCursorIndex); MainMenuHelper.WriteSelectableTextInCenter("Settings", 21, 2, currentCursorIndex); MainMenuHelper.WriteSelectableTextInCenter("Exit", 24, 3, currentCursorIndex); }
private void DisplayMenu() { currentCursorIndexLimit = 2; Console.SetWindowSize(30, 14); Console.SetBufferSize(30, 14); MainMenuHelper.MakeFrame(); MainMenuHelper.WriteInCenter("Map editor", 2); MainMenuHelper.FillALine('=', 1, 4); MainMenuHelper.WriteSelectableTextInCenter("Create a new map", 6, 0, currentCursorIndex); MainMenuHelper.WriteSelectableTextInCenter("Edit an existing map", 8, 1, currentCursorIndex); MainMenuHelper.WriteSelectableTextInCenter("Back to main menu", 10, 2, currentCursorIndex); }
public ActionResult PayAllConfirm(int id) { try { // Finding the sold products from the table that are confirmed as paid List <ISoldProductModel> sold = soldProductData.GetByTable(id); // Moving in the database the sold products to a table of all sold products accomplished MainMenuHelper.PaySoldProducts(sold, soldProductData, soldProductAccomplishedData); //Set the table to empty ITableModel table = tableData.FindById(id); table.Occupied = false; tableData.Update(table); } catch (Exception ex) { log.Error("Could't load sold products or tables from Database", ex); return(View("ErrorRetriveData")); } return(RedirectToAction("Tables")); }
public void Initialize(string displayName, string levelName, bool isUnlocked, bool isCompleted, MainMenuHelper mainMenuHelper) { levelToLoad = levelName; if (displayText != null) { if (isUnlocked || Debug.isDebugBuild) { displayText.text = displayName; displayText.enabled = true; if (lockIcon != null) { lockIcon.enabled = false; } } else { displayText.enabled = false; if (lockIcon != null) { lockIcon.enabled = true; } } } if (buttonToUse != null) { buttonToUse.interactable = Debug.isDebugBuild || isUnlocked; savedColorBlock = buttonToUse.colors; savedColorBlock.disabledColor = lockedColor; buttonToUse.colors = savedColorBlock; if (buttonToUse.image != null) { buttonToUse.image.color = isCompleted ? alreadyCompletedColor : unlockedColor; } } if (mainMenuHelper != null && buttonToUse != null) { buttonToUse.onClick.AddListener(() => mainMenuHelper.PlayRandomButtonSound(true)); } }
private void DisplayRightPanel() { string color = StringToColor.ConvertToString(currentColor).PadRight(12); MainMenuHelper.MakeFrame(Console.WindowWidth - 31, 0); int textStart = Console.WindowWidth - 29; MainMenuHelper.WriteInCenter("Settings", 3, textStart, 2); MainMenuHelper.WriteText("Current X position: " + cursorLeftPosition.ToString().PadRight(4), textStart, 5); MainMenuHelper.WriteText("Current Y position: " + (EditorInstance.MapHeight - cursorTopPosition - 1).ToString().PadRight(4), textStart, 6); if (currentTabIndex == 0) { MainMenuHelper.WriteText("Current color: " + color, textStart, 8); MainMenuHelper.WriteText("Map height: " + EditorInstance.MapHeight.ToString().PadRight(4), textStart, 10); MainMenuHelper.WriteText("Map width: " + EditorInstance.MapWidth.ToString().PadRight(4), textStart, 11); } else if (currentTabIndex == 1) { //Current color if (currentCursorIndex == 0) { if (!enterPressed) { MainMenuHelper.WriteText("Current color: " + color, textStart, 8, ConsoleColor.Gray, ConsoleColor.Blue); } else if (enterPressed) { MainMenuHelper.WriteText("Current color: " + color, textStart, 8, ConsoleColor.Black, ConsoleColor.Cyan); } } else { MainMenuHelper.WriteText("Current color: " + color, textStart, 8); } //Map height string mapHeight = EditorInstance.MapHeight.ToString().PadRight(4); MainMenuHelper.WriteText("Map height: ", textStart, 10); if (currentCursorIndex == 1) { if (!enterPressed) { MainMenuHelper.WriteText(mapHeight, textStart + 12, 10, ConsoleColor.Gray, ConsoleColor.Blue); } else if (enterPressed) { MainMenuHelper.WriteText(mapHeight, textStart + 12, 10, ConsoleColor.Black, ConsoleColor.Cyan); } } else { MainMenuHelper.WriteText(mapHeight, textStart + 12, 10); } //Map width string mapWidth = EditorInstance.MapWidth.ToString().PadRight(4); MainMenuHelper.WriteText("Map width: ", textStart, 11); if (currentCursorIndex == 2) { if (!enterPressed) { MainMenuHelper.WriteText(mapWidth, textStart + 12, 11, ConsoleColor.Gray, ConsoleColor.Blue); } else if (enterPressed) { MainMenuHelper.WriteText(mapWidth, textStart + 12, 11, ConsoleColor.Black, ConsoleColor.Cyan); } } else { MainMenuHelper.WriteText(mapWidth, textStart + 12, 11); } } }
/// <summary> /// Returns the maximum length of an item in a list /// </summary> public int GetMaxItemLength() => MainMenuHelper.GetItemTextLength(popupContent.Items);
/// <inheritdoc cref="ListBoxBase{T}.GetItemTextLength"/> protected override int GetItemTextLength(MenuItemBase item) => MainMenuHelper.GetItemTextLength(item);