Guest User

Untitled

a guest
Nov 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.13 KB | None | 0 0
  1. /*
  2.     Hoorah, my first progam. What a fucking mess.
  3. */
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Windows.Forms;
  12. using System.IO;
  13.  
  14. namespace WindowsFormsApplication1
  15. {
  16.     public partial class ARUI : Form
  17.     {
  18.         //Default settings for RAIL in a very ugly array. Gotta be a better way to do this.
  19.         string[] whatToWrite = new string[] {
  20. /*   0    */"rail_state = {}",
  21.             "rail_state[\"DebugLevel\"] = 50",
  22.             "rail_state[\"AssistOptions\"] = {}",
  23.             "rail_state[\"AssistOptions\"][\"Other\"] = \"indifferent\"",
  24.             "rail_state[\"AssistOptions\"][\"Owner\"] = \"indifferent\"",
  25. /*   5    */"rail_state[\"AssistOptions\"][\"Friend\"] = \"indifferent\"",
  26.             "rail_state[\"ActorOptions\"] = {}",
  27.             "rail_state[\"ActorOptions\"][\"ByID\"] = {}",
  28.             "rail_state[\"ActorOptions\"][\"Default\"] = {}",
  29.             "rail_state[\"ActorOptions\"][\"Default\"][\"Name\"] = \"unknown\"",
  30. /*   10   */"rail_state[\"ActorOptions\"][\"Default\"][\"KiteDistance\"] = -1",
  31.             "rail_state[\"ActorOptions\"][\"Default\"][\"Priority\"] = 1",
  32.             "rail_state[\"ActorOptions\"][\"Default\"][\"KiteMode\"] = \"always\"",
  33.             "rail_state[\"ActorOptions\"][\"Default\"][\"DefendOnly\"] = false",
  34.             "rail_state[\"ActorOptions\"][\"ByType\"] = {}",
  35. /*   15   */"rail_state[\"DelayFirstAction\"] = 0",
  36.             "rail_state[\"MobIDMode\"] = \"automatic\"",
  37.             "rail_state[\"DefendOptions\"] = {}",
  38.             "rail_state[\"DefendOptions\"][\"DefendWhilePassive\"] = true",
  39.             "rail_state[\"DefendOptions\"][\"FriendThreshold\"] = 4",
  40. /*   20   */"rail_state[\"IdleMovement\"] = {}",
  41.             "rail_state[\"IdleMovement\"][\"MoveType\"] = \"none\"",
  42.             "rail_state[\"MaintainTargetsWhilePassive\"] = true",
  43.             "rail_state[\"ProfileMark\"] = 20000",
  44.             "rail_state[\"RunAhead\"] = false",
  45. /*   25   */"rail_state[\"MaxDistance\"] = 13",
  46.             "rail_state[\"AttackWhileChasing\"] = false",
  47.             "rail_state[\"Aggressive\"] = false",
  48.             "rail_state[\"AutoPassive\"] = {}",
  49.             "rail_state[\"AutoPassive\"][\"HPEnter\"] = 0",
  50. /*   30   */"rail_state[\"AutoPassive\"][\"OwnerSPisPercent\"] = false",
  51.             "rail_state[\"AutoPassive\"][\"OwnerHPisPercent\"] = false",
  52.             "rail_state[\"AutoPassive\"][\"OwnerHPEnter\"] = 0",
  53.             "rail_state[\"AutoPassive\"][\"HPisPercent\"] = false",
  54.             "rail_state[\"AutoPassive\"][\"SPisPercent\"] = false",
  55. /*   35   */"rail_state[\"AutoPassive\"][\"OwnerSPEnter\"] = 0",
  56.             "rail_state[\"AttackAllowed\"] = true",
  57.             "rail_state[\"SkillsAllowed\"] = true",
  58.             "rail_state[\"DefendOnly\"] = false",
  59.             "rail_state[\"DisableChase\"] = false",
  60. /*   40   */"rail_state[\"update\"] = false",
  61.         };
  62.  
  63.         public ARUI()
  64.         {
  65.             InitializeComponent();
  66.         }
  67.  
  68.         private void ApplyChanges(object sender, EventArgs e)
  69.         {
  70.             StreamWriter SW;
  71.             SW = File.CreateText("RAIL_State.homu.lua");
  72.             foreach (string x in whatToWrite)
  73.             {
  74.                 SW.WriteLine(x);
  75.             }
  76.             SW.Close();
  77.             this.Close();
  78.         }
  79.         // Checkbox checker that checks is the checkbox is checked
  80.         private void boxCheckar(object sender, EventArgs e)
  81.         {
  82.            
  83.             CheckBox box = (CheckBox)sender;
  84.             int boxID = Convert.ToInt16(box.AccessibleName);
  85.             if (box.Checked)
  86.             {   // Yes I know I could have used radio buttons for this but I didn't want to
  87.                 if (box == AggressiveStance)
  88.                 {
  89.                     DefendOnlyCheck.Checked = false;
  90.                     whatToWrite[boxID] = whatToWrite[boxID].Replace("false", "true");
  91.                 }
  92.                 if (box == DefendOnlyCheck)
  93.                 {
  94.                     AggressiveStance.Checked = false;
  95.                     whatToWrite[boxID] = whatToWrite[boxID].Replace("false", "true");
  96.                 }
  97.                 whatToWrite[boxID] = whatToWrite[boxID].Replace("false", "true");
  98.             }
  99.             else
  100.             {
  101.                 whatToWrite[boxID] = whatToWrite[boxID].Replace("true", "false");
  102.             }
  103.             // for testing purposes
  104.             InfoText.Text = whatToWrite[boxID];
  105.         }
  106.  
  107.         // Tooltip function - remember to add it to all mouseovers... D:
  108.         private void itxt_MouseHover(object sender, EventArgs e)
  109.         {
  110.             Control rawr = (Control)sender;
  111.             InfoText.Text = rawr.AccessibleDescription;
  112.         }
  113.  
  114.         private void readTheFile()
  115.         {
  116.             int counter = 0;
  117.             string line;
  118.  
  119.             // Read the file and display it line by line.
  120.             System.IO.StreamReader file =
  121.                new System.IO.StreamReader("MyFile.lua");
  122.             while ((line = file.ReadLine()) != null)
  123.             {
  124.                 Console.WriteLine(line);
  125.                 counter++;
  126.             }
  127.             InfoText.Text = line;
  128.             file.Close();
  129.  
  130.             // Suspend the screen.
  131.             Console.ReadLine();
  132.         }
  133.  
  134.         private void clickedOnBrowse(object sender, EventArgs e)
  135.         {
  136.             string[] lines = System.IO.File.ReadAllLines(@"myFile.lua");
  137.             string[] configArr = new string[lines.Count()];
  138.             int count = 0;
  139.             foreach (string line in lines)
  140.             {
  141.                 configArr[count] = "\t" + line;
  142.                 InfoText.Text = configArr[count];
  143.                 count++;
  144.             }
  145.         }
  146.  
  147.         public static string[] GetStringInBetween(string strBegin,
  148.     string strEnd, string strSource,
  149.     bool includeBegin, bool includeEnd)
  150.         {
  151.             string[] result = { "", "" };
  152.             int iIndexOfBegin = strSource.IndexOf(strBegin);
  153.             if (iIndexOfBegin != -1)
  154.             {
  155.                 // include the Begin string if desired
  156.                 if (includeBegin)
  157.                     iIndexOfBegin -= strBegin.Length;
  158.                 strSource = strSource.Substring(iIndexOfBegin
  159.                     + strBegin.Length);
  160.                 int iEnd = strSource.IndexOf(strEnd);
  161.                 if (iEnd != -1)
  162.                 {
  163.                     // include the End string if desired
  164.                     if (includeEnd)
  165.                         iEnd += strEnd.Length;
  166.                     result[0] = strSource.Substring(0, iEnd);
  167.                     // advance beyond this segment
  168.                     if (iEnd + strEnd.Length < strSource.Length)
  169.                         result[1] = strSource.Substring(iEnd
  170.                             + strEnd.Length);
  171.                 }
  172.             }
  173.             else
  174.                 // stay where we are
  175.                 result[1] = strSource;
  176.             return result;
  177.         }
  178.  
  179.         private void browseDialog_FileOk(object sender, CancelEventArgs e)
  180.         {
  181.  
  182.         }
  183.     }
  184. }
Add Comment
Please, Sign In to add comment