Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const float PROGRAM_VERSION = 0.01f;
- string[] DataLoadedFromMemoryBank;
- string SelOpenBracket = "<";
- string SelCloseBracket = ">";
- const string NLCR = "\n\r";
- const string ITEM_PERFIX = "- ";
- const string ARG1 = "NEXT";
- const string ARG2 = "PREV";
- const string ARG3 = "OK";
- const string ARG4 = "CANCEL";
- const string ARG5 = "BACK";
- static string[] ConfirmSubMenu = new string[2] { "Confirm", "Cancel" };
- static string[] SelectMenu = new string[2] { "Select", "Cancel" };
- static string SecondSubMenu = "Back";
- static string[] MainMenu = new string[2] { "Login", "Power Off" };
- static string[] SecondMenu = new string[4] { "Ship Control Systems", "Installation", "Ship Data", "Logout" };
- static string[] InstallationMenu = new string[5] { "Install Ship Profile", "Remove Ship Profile", "Update Ship Profile", "Add User", "Remove User" };
- static string[] ShipProfiles = new string[5] { "Fighter", "Miner", "Transporter", "Builder", "Escape Pod" };
- static string[] FighterControlSystems = new string[8] { "Check Systems", "Dock", "Undock", "Trun Engines On", "Turn Engines Off", "Restock Ammo", "Activate Weapons", "Deactivate Weapons" };
- static string[] MTBControlSystems = new string[7] { "Check Systems", "Dock", "Undock", "Trun Engines On", "Turn Engines Off", "Load Cargo", "Unload Cargo" };
- static string[] EscapePodSystems = new string[6] { "Check Systems", "Turn Engines On", "Turn Engines Off", "Load Cargo", "Unload Cargo", "LAUNCH!" };
- static string[] Keyboard = new string[63]{
- "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
- "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
- "0","1","2","3","4","5","6","7","8","9"," "};
- static string[][] AllMenusArrayHolder;
- const float ESCAPE_POD_LAUNCH_TIME = 30f;
- bool UsingModdedCockpit = false;
- string ModdedCockpitName = "";
- string MenuTitle = "";
- string ShipName = "";
- bool UsingAlertMod = false;
- string AlertModProgBlockName = "";
- int MenuIndex = 0;
- int ItemIndex = 0;
- bool FirstRun = true;
- static Program()
- {
- AllMenusArrayHolder = new string[10][];
- AllMenusArrayHolder[0] = MainMenu;
- AllMenusArrayHolder[1] = SecondMenu;
- AllMenusArrayHolder[2] = InstallationMenu;
- AllMenusArrayHolder[3] = ShipProfiles;
- AllMenusArrayHolder[4] = FighterControlSystems;
- AllMenusArrayHolder[5] = MTBControlSystems;
- AllMenusArrayHolder[6] = EscapePodSystems;
- AllMenusArrayHolder[7] = ConfirmSubMenu;
- AllMenusArrayHolder[8] = SelectMenu;
- AllMenusArrayHolder[9] = Keyboard;
- }
- void Main(string argument)
- {
- if (FirstRun)
- {
- for (int i = 0; i < AllMenusArrayHolder.Length; i++)
- {
- for (int j = 0; j < AllMenusArrayHolder[i].Length; j++)
- {
- WriteToScreen("LCD Panel", AllMenusArrayHolder[i][j] + NLCR, true);
- }
- }
- TextBuilder(1, AllMenusArrayHolder[1]);
- }
- if (argument != "")
- ArgumentHandler(argument);
- }
- void ArgumentHandler(string args)
- {
- Echo("TEST 1");
- string[] SelectedArray = AllMenusArrayHolder[1];
- Echo("----------");
- switch (args)
- {
- case ARG1:
- {
- Echo("arg given: " + ARG1);
- if (ItemIndex == SelectedArray.Length - 1)
- {
- ItemIndex = 0;
- Echo("arg 1 condition 1 opt 1");
- }
- else
- {
- ItemIndex++;
- Echo("arg 1 condition 1 opt 2");
- }
- TextBuilder(1, SelectedArray);
- break;
- }
- case ARG2:
- {
- ItemIndex--;
- if (ItemIndex < 0) ItemIndex = SelectedArray.Length - 1;
- Echo("arg 2 condition 1 opt 2");
- Echo("arg given: " + ARG2);
- Echo("" + ItemIndex);
- TextBuilder(2, SelectedArray);
- break;
- }
- case ARG3:
- {
- Echo("arg given: " + ARG3);
- break;
- }
- case ARG4:
- {
- Echo("arg given: " + ARG4);
- break;
- }
- default:
- {
- Echo("Unknown command");
- break;
- }
- }
- }
- void TextBuilder(int Direction, string[] MenuArray)
- {
- string TextToDisp = "";
- string SelectedMenuItem = "";
- string[] TextArray = new string[MenuArray.Length];
- Echo("INIT VAR");
- if (Direction == 1)
- {
- if (ItemIndex != MenuArray.Length)
- {
- //Echo("Check Index");
- SelectedMenuItem = SelOpenBracket + MenuArray[ItemIndex] + SelCloseBracket;
- for (int i = 0; i < TextArray.Length; i++)
- {
- TextArray[i] = MenuArray[i]; //copy the array in preparation to display selected item
- }
- if (SelectedMenuItem != "" || SelectedMenuItem != "<>")
- {
- TextArray[ItemIndex] = SelectedMenuItem;
- }
- for (int i = 0; i < TextArray.Length; i++)
- {
- if (i != TextArray.Length - 1)
- {
- TextToDisp = TextToDisp + TextArray[i] + NLCR;
- }
- else
- {
- TextToDisp = TextToDisp + TextArray[TextArray.Length - 1];
- }
- }
- //TextToDisp = TextArray[0] + NLCR + TextArray[1] + NLCR + TextArray[2] + NLCR + TextArray[3] + NLCR + TextArray[4];
- WriteToScreen("LCD Panel", TextToDisp, false);
- }
- else
- {
- SelectedMenuItem = SelOpenBracket + MenuArray[0] + SelCloseBracket;
- TextArray[0] = SelectedMenuItem;
- TextToDisp = TextArray[0];
- for (int i = 1; i < MenuArray.Length; i++)
- {
- if (i != MenuArray.Length - 1)
- {
- TextToDisp = TextToDisp + MenuArray[i] + NLCR;
- }
- else
- {
- TextToDisp = TextToDisp + MenuArray[MenuArray.Length - 1];
- }
- }
- //TextToDisp = TextArray[0] + NLCR + MenuArray[1] + NLCR + MenuArray[2] + NLCR + MenuArray[3] + NLCR + MenuArray[4];
- WriteToScreen("LCD Panel", TextToDisp, false);
- }
- }
- else if (Direction == 2)
- {
- if (ItemIndex != -1)// && MenuIndex > 0)
- {
- SelectedMenuItem = SelOpenBracket + MenuArray[ItemIndex] + SelCloseBracket;
- for (int i = 0; i < TextArray.Length; i++)
- {
- TextArray[i] = MenuArray[i];
- }
- if (SelectedMenuItem != "" || SelectedMenuItem != "<>")
- {
- TextArray[ItemIndex] = SelectedMenuItem;
- }
- for (int i = 0; i < TextArray.Length; i++)
- {
- if (i != TextArray.Length - 1)
- {
- TextToDisp = TextToDisp + TextArray[i] + NLCR;
- }
- else
- {
- TextToDisp = TextToDisp + TextArray[TextArray.Length - 1];
- }
- }
- //TextToDisp = TextArray[0] + NLCR + TextArray[1] + NLCR + TextArray[2] + NLCR + TextArray[3] + NLCR + TextArray[4];
- WriteToScreen("LCD Panel", TextToDisp, false);
- }
- else if (ItemIndex == -1)
- {
- SelectedMenuItem = SelOpenBracket + MenuArray[MenuArray.Length - 1] + SelCloseBracket;
- TextArray[TextArray.Length - 1] = SelectedMenuItem;
- for (int i = 0; i < MenuArray.Length - 1; i++)
- {
- TextToDisp = TextToDisp + MenuArray[i] + NLCR;
- }
- TextToDisp = TextToDisp + TextArray[TextArray.Length - 1];
- //TextToDisp = MenuArray[0] + MenuArray[1] + MenuArray[2] + MenuArray[3] + TextArray[4];
- WriteToScreen("LCD Panel", TextToDisp, false);
- }
- }
- }
- // Write text to LCD screen
- void WriteToScreen(string ScreenName, string text, bool AppendToScreen)
- {
- IMyTextPanel LCD = GridTerminalSystem.GetBlockWithName(ScreenName) as IMyTextPanel;
- if (LCD != null)
- {
- LCD.ShowTextureOnScreen();
- LCD.WritePublicText(text, AppendToScreen);
- LCD.ShowPublicTextOnScreen();
- }
- }
- //Read text from LCD screen
- string ReadFromScreen(string ScreenName)
- {
- string TextFromPanel = "";
- IMyTextPanel LCD = GridTerminalSystem.GetBlockWithName(ScreenName) as IMyTextPanel;
- TextFromPanel = LCD.GetPublicText();
- return TextFromPanel;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement