private void LoadTreeView_Click(object sender, EventArgs e)
 {
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Load Tree View" });
     treeView1.Nodes.Clear();
     loadUnitTree();
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Load Tree View finished" });
 }
        private void MakroKeyEvent_Click(object sender, KeyEventArgs e)
        {
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Hotkey] Hotkey use started" });
            if (treeView1.SelectedNode != null)
            {
                switch (e.KeyCode)
                {
                case Keys.Delete:
                    if (treeView1.SelectedNode.Nodes.Count > 0)
                    {
                        UnitEditorDelete_Click(sender, e);
                    }
                    else
                    {
                        UnitEditorAttrDelete_Click(sender, e);
                    }
                    //MessageBox.Show("DELETE");
                    break;

                case Keys.F2:
                    UnitEditorEdit_Click(sender, e);
                    //MessageBox.Show("F2 EDIT");
                    break;

                case Keys.Insert:
                    break;
                }
            }
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Hotkey] Hotkey use finished" });
        }
        static void Main(string[] args)
        {
            if (args.Length != 0)
            {
                if (args[0] == "dev" || args[0] == "public_beta")
                {
                    debug = true;
                }
            }
            try
            {
                configData = File.ReadAllLines("config.txt");
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine();
                DebugHandling.logGUIStroke(new string[] { "[INIT] [FILE] Config File Not Found!" });
            }

            switch (configData[0])
            {
            case "de":
                string[] strings = File.ReadAllLines("./lang/de/de.txt");
                Language.loadLanguage(strings);
                break;

            default:
                // en
                break;
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
 private void UnitEditorEdit_Click(object sender, EventArgs e)
 {
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Unit Editor Edit finished" });
     //Console.WriteLine("HI");
     treeView1.SelectedNode.BeginEdit();
     treeView1.AfterLabelEdit -= TreeView1_AfterLabelEdit;
     treeView1.AfterLabelEdit += TreeView1_AfterLabelEdit;
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Unit Editor Edit finished" });
 }
Exemple #5
0
        private void UnitEditorButton_Click(object sender, EventArgs e)
        {
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Start Unit Editor" });
            UnitEditor unit = new UnitEditor();

            unit.Size = new Size(800, 600);
            unit.Show();
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Unit Editor start finished" });
        }
        private void editNode(TreeNode node)
        {
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Edit Node started" });
            int[] indexes = getID(node);

            SaveEditorAsALibrary.System.changeAttribute(indexes[0], indexes[1], node.Text);
            SaveEditorAsALibrary.Output.listAttributes((ArrayList)SaveEditorAsALibrary.System.unitList[indexes[0]], true);
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Edit Node finished" });
        }
 private void AttributeAdd_Click(object sender, EventArgs e)
 {
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Add Attribute" });
     //SaveEditorAsALibrary.System.addUnit(new ArrayList() { "newunit : _nameless.123.4567.890a {", "entry: value", "}" });
     int[] indexes = getID(treeView1.SelectedNode);
     SaveEditorAsALibrary.System.addAttribute(indexes[0], "value: new");
     treeView1.Nodes.Clear();
     loadUnitTree();
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Add Attribute finished" });
 }
 private void UnitEditorAttrDelete_Click(object sender, EventArgs e)
 {
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Unit Editor Attribute Delete finished" });
     int[] indexes = getID(treeView1.SelectedNode);
     SaveEditorAsALibrary.System.removeAttribute(indexes[0], indexes[1]);
     //treeView1.SelectedNode.Remove();
     treeView1.Nodes.Clear();
     loadUnitTree();
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Unit Editor Attribute Delete finished" });
 }
 private void AddUnitButton_Click(object sender, EventArgs e)
 {
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Add Unit started" });
     SaveEditorAsALibrary.System.addUnit(new ArrayList()
     {
         "newunit : _nameless.123.4567.890a {", "entry: value", "}"
     });
     treeView1.Nodes.Clear();
     loadUnitTree();
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Add Unit finished" });
 }
Exemple #10
0
 private void openScriptFileButton_Click(object sender, EventArgs e)
 {
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Automation Script Path" });
     afd.Filter = "SaveEditor Automation Language Files (*.txt)|*.txt";
     if (afd.ShowDialog() == DialogResult.OK)
     {
         ScriptPathBox.Text       = afd.FileName;
         loadScriptButton.Enabled = true;
     }
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Automation Script Path finished" });
 }
 private void jumpPreviousResultButton_Click(object sender, EventArgs e)
 {
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Jump Previous Result started" });
     if (nextResult < 0)
     {
         nextResult = resultsList.Count - 1;
     }
     treeView1.SelectedNode = treeView1.Nodes[(int)resultsList[nextResult]];
     treeView1.Focus();
     --nextResult;
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Jump Next Result finished" });
 }
Exemple #12
0
 private void BackUpButton_Click(object sender, EventArgs e)
 {
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Backup Path" });
     bfd.Filter = "ETS2 / ATS Savegames (*.sii)|*.sii";
     if (bfd.ShowDialog() == DialogResult.OK)
     {
         //dir = Directory.GetCurrentDirectory();
         BackupPathBox.Text = bfd.FileName;
         //saveOldFile(ofd.FileName);
     }
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Backup Path Button finished" });
 }
Exemple #13
0
        private void CommonUtils_Click(object sender, EventArgs e)
        {
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Start Common Utils" });
            //UnitEditor unit = new UnitEditor();
            //unit.Size = new Size(800, 600);
            //unit.Show();
            CommonUtilities utils = new CommonUtilities();

            utils.Size = new Size(800, 600);
            utils.Show();
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Common Utils start finished" });
        }
        private void loadUnitTree()
        {
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Load Unit Tree started" });
            int i = 0;

            foreach (ArrayList unitList in SaveEditorAsALibrary.System.unitList)
            {
                //treeView1.Nodes.Add("ROOT");
                treeView1.Nodes.Add(unitList[0].ToString());
                treeView1.Nodes[treeView1.Nodes.Count - 1].ContextMenu = menu;
                treeView1.Nodes[treeView1.Nodes.Count - 1].Tag         = new int[] { treeView1.Nodes.Count - 1, 0 };

                for (int j = 1; j < unitList.Count; ++j)
                {
                    treeView1.Nodes[i].Nodes.Add(unitList[j].ToString());
                    treeView1.Nodes[i].Nodes[treeView1.Nodes[i].Nodes.Count - 1].ContextMenu = menu;

                    treeView1.Nodes[i].Nodes[treeView1.Nodes[i].Nodes.Count - 1].Tag = new int[] { treeView1.Nodes.Count - 1, j };

                    /*string content = "";
                     * foreach(int tag in (int[]) treeView1.Nodes[i].Tag)
                     * {
                     *  content += tag.ToString() + " | ";
                     * }
                     * treeView1.Nodes[i].Nodes.Add(content);*/
                }

                /*foreach (string attribute in unitList)
                 * {
                 *
                 * }*/
                ++i;
                AddUnitButton.Enabled = true;
                seachTextBox.Enabled  = true;
                searchButton.Enabled  = true;
            }

            //foreach (TreeNode node in treeView1.Nodes)

            for (int k = 0; k < treeView1.Nodes.Count; ++k)
            {
                if (treeView1.Nodes[k].Nodes.Count > 0)
                {
                    treeView1.Nodes[k].ContextMenu = unitMenu;
                    //menu.MenuItems.Add("ADD ATTR");
                }
            }

            //InitializeComponent();
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Load Unit Tree finished" });
        }
Exemple #15
0
        private void AnalyzeSavegameButton_Click(object sender, EventArgs e)
        {
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Analyze Savegame" });

            try
            {
                SaveEditorAsALibrary.System.resetSystem();
            }
            catch (Exception)
            {
                // This one may throw an exception if the reset function is triggered on the first run of this function in a "session"
                // Don't worry, that is correct
            }

            MessageBox.Show("Editing a savegame while on an active World of Trucks Contract is not advised!" +
                            Environment.NewLine + "Editing a savegame before finishing the first mission may also cause the game to behave weird and crash randomly." +
                            Environment.NewLine + "", "NOTICE", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            try
            {
                //SaveEditorAsALibrary.Input.path = @"C:\users\rapha\desktop\game.sii";
                SaveEditorAsALibrary.Input.path = LoadSavegamePathBox.Text;
                SaveEditorAsALibrary.Input.readSavegame();
                if (SaveEditorAsALibrary.System.checkDecryptState() == false)
                {
                    MessageBox.Show("Savegame is not decrypted. Aborting!", "Encryption detected", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                SaveEditorAsALibrary.System.prepareUnits();
                this.Invoke(new Action(() =>
                {
                    MessageBox.Show("Savegame loaded successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }));

                UnitEditorButton.Enabled            = true;
                SaveSavegameWriteBackButton.Enabled = true;
                CommonUtils.Enabled = true;
            }
            catch (Exception)
            {
                this.Invoke(new Action(() =>
                {
                    MessageBox.Show("Savegame loading failed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }));
            }

            if (BackupPathBox.Text.Length > 0)
            {
                File.WriteAllLines(BackupPathBox.Text.ToString(), SaveEditorAsALibrary.System.lines);
            }
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Analyze Savegame finished" });
        }
Exemple #16
0
        public MainForm()
        {
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Form] Main Form init started" });
            MinimumSize = new Size(530, 334);
            //MinimumSize = new Size(530, 285);
            MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Right, 334);

            if (SaveEditorAsALibrary.System.checkNETVersion() == false)
            {
                MessageBox.Show("Unsupported .NET Framework Version detected");
                return;
            }

            InitializeComponent();
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Form] Main Form init finished" });
        }
Exemple #17
0
 private void SaveSavegameButton_Click(object sender, EventArgs e)
 {
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Save Savegame Path" });
     sfd.Filter = "ETS2 / ATS Savegames (*.sii)|*.sii";
     if (sfd.ShowDialog() == DialogResult.OK)
     {
         //dir = Directory.GetCurrentDirectory();
         SaveSavegamePathBox.Text = sfd.FileName;
         //saveOldFile(ofd.FileName);
         AnalyzeSavegameButton.Enabled = true;
         ScriptPathBox.Enabled         = true;
         //VariableBox.Enabled = true;       // TODO
         openScriptFileButton.Enabled = true;
         //loadScriptButton.Enabled = true;
         //CommonUtils.Enabled = true;
     }
     DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Save Savegame Path finsied" });
 }
        private void searchButton_Click(object sender, EventArgs e)
        {
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Search started" });
            resultsList = new ArrayList();
            nextResult  = 0;
            resultsList = SaveEditorAsALibrary.System.findTerm(seachTextBox.Text);

            /*foreach(string x in xx)
             * {
             *  Console.Write(count + " | ");
             *  Console.WriteLine(x);
             ++count;
             * }*/

            jumpNextResultButton.Enabled     = true;
            jumpPreviousResultButton.Enabled = true;
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Search finished" });
        }
Exemple #19
0
        private void SaveSavegameWriteBackButton_Click(object sender, EventArgs e)
        {
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Write Back" });
            ArrayList writeBackLines = new ArrayList();

            writeBackLines.Add("SiiNunit");
            writeBackLines.Add("{");

            foreach (ArrayList al in SaveEditorAsALibrary.System.unitList)
            {
                foreach (string s in al)
                {
                    writeBackLines.Add(s);
                }
                writeBackLines.Add("");
            }

            writeBackLines.Add("}");

            foreach (string s in writeBackLines)
            {
                //Console.WriteLine(s);
            }

            string[] writeBackLinesArray = (string[])writeBackLines.ToArray(typeof(string));

            string savepath = SaveSavegamePathBox.Text.ToString();

            File.WriteAllLines(SaveSavegamePathBox.Text.ToString(), writeBackLinesArray);

            LoadSavegamePathBox.Text = "";
            BackupPathBox.Text       = "";
            SaveSavegamePathBox.Text = "";
            SaveEditorAsALibrary.System.resetSystem();

            BackUpButton.Enabled                = false;
            SaveSavegameButton.Enabled          = false;
            AnalyzeSavegameButton.Enabled       = false;
            SaveSavegameWriteBackButton.Enabled = false;
            UnitEditorButton.Enabled            = false;

            this.Invoke(new Action(() => MessageBox.Show("Saving Savegame successful!", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information)));
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Write Back finished" });
        }
        public UnitEditor()
        {
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Form] Unit Editor init started" });
            menu.MenuItems.Add(Language.EditAttribute);
            menu.MenuItems[0].Click += UnitEditorEdit_Click;
            menu.MenuItems.Add(Language.DeleteAttribute);
            menu.MenuItems[1].Click += UnitEditorAttrDelete_Click;

            unitMenu.MenuItems.Add(Language.EditUnitHeader);
            unitMenu.MenuItems[0].Click += UnitEditorEdit_Click;
            unitMenu.MenuItems.Add(Language.DeleteUnit);
            unitMenu.MenuItems[1].Click += UnitEditorDelete_Click;
            unitMenu.MenuItems.Add(Language.AddAttribute);
            unitMenu.MenuItems[2].Click += AttributeAdd_Click;

            InitializeComponent();
            treeView1.LabelEdit = true;

            KeyPreview = true;
            KeyDown   += new KeyEventHandler(MakroKeyEvent_Click);
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Form] Unit Editor init finished" });
        }
Exemple #21
0
        private void loadScriptButton_Click(object sender, EventArgs e)
        {
            DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Run Script" });
            //SaveEditorAsALibrary.Input.path = @"C:\users\rapha\desktop\mmmmm.sii";
            SaveEditorAsALibrary.Input.path = LoadSavegamePathBox.Text;
            SaveEditorAsALibrary.Input.readSavegame();
            SaveEditorAsALibrary.System.prepareUnits();

            //string path = @"C:\users\rapha\desktop\money_change.txt";
            string path = ScriptPathBox.Text;

            string[] content = File.ReadAllLines(path);
            Console.WriteLine("content_script: ");
            foreach (string s in content)
            {
                Console.WriteLine(s);
            }

            /*
             * dynamic context = null;
             * int selectedUnit = 0;
             * int selectedAttr = 0;
             * int selectedLine = 0;
             *
             * for (int i = 0; i < content.Length; ++i)
             * {
             *  if (content[i].StartsWith(@"//"))
             *  {
             *      continue;
             *  }
             *
             *  switch(content[i])
             *  {
             *      case "findUnit":
             *          Console.WriteLine(content[++i]);
             *          ArrayList x = SaveEditorAsALibrary.System.findTerm(content[i]);
             *          Console.WriteLine(content[i]);
             *          foreach(var n in x)
             *          {
             *              Console.WriteLine("vv: " + n);
             *          }
             *
             *          dynamic nn = new ArrayList();
             *          nn.Add(x);
             *          context = nn;
             *
             *          selectedUnit = (int) x[0];
             *          selectedAttr = 0;
             *
             *          //selectedLine = 0;
             *          /*for(int a = 0; a < selectedUnit; ++a)
             *          {
             *              ArrayList aList = (ArrayList) SaveEditorAsALibrary.System.unitList[a];
             *              foreach(string aa in aList)
             *              {
             ++selectedLine;
             *              }
             *          }
             *          Console.WriteLine("LINE: " + selectedLine);//
             *          break;
             *      case "findAttr":
             *          int contentIndex = ++i;
             *
             *          ArrayList l = (ArrayList) context;
             *          //int res1 = (int) context[0];
             *
             *          for(int iiii = 0; iiii < l.Count; ++iiii)
             *          {
             *              ArrayList attrL = (ArrayList)SaveEditorAsALibrary.System.unitList[selectedUnit];
             *
             *              for (int j = 0; j < attrL.Count; ++j)
             *              {
             *                  //Console.WriteLine("connnn; " + content[contentIndex]);
             *                  if(attrL[j].ToString().Contains(content[contentIndex]))
             *                  {
             *                      Console.WriteLine("ATTR FOUND at " + contentIndex + " with value " + attrL[j] + " indexed at " + j);
             *
             *                      /*dynamic cc = new ArrayList();
             *                      cc.Add(selectedUnit);
             *                      cc.Add(j);//
             *                      selectedAttr = j;
             *                  }
             *              }
             *          }
             *          break;
             *      case "goto":
             *          /*dynamic query = context;
             *          ArrayList gotoList = (ArrayList) query;
             *          int i1 = (int)gotoList[0];
             *          int i2 = (int)gotoList[1];
             *          selectedUnit = i1;
             *          selectedAttr = i2;//
             *          Console.WriteLine("I1: " + selectedUnit + " I2: " + selectedAttr);
             *          break;
             *      case "jumpUnit":
             *          int jumperU = Int32.Parse(content[++i]);
             *          selectedUnit += jumperU;
             *          break;
             *      case "jumpAttr":
             *          int jumperA = Int32.Parse(content[++i]);
             *          selectedAttr += jumperA;
             *          break;
             *      case "addUnit":
             *          SaveEditorAsALibrary.System.addUnit(new ArrayList() { "newunit : _nameless.123.4567.890a {", "entry: SAL_automated_value", "}" });
             *          break;
             *      case "addAttr":
             *          ArrayList LList = (ArrayList) SaveEditorAsALibrary.System.unitList[selectedUnit];
             *          int attrCounter = LList.Count - 1;
             *          SaveEditorAsALibrary.System.insertAttribute(selectedUnit, "value: newer", attrCounter);
             *          break;
             *      case "change":
             *          SaveEditorAsALibrary.System.changeAttribute(selectedUnit, selectedAttr, content[++i]);
             *          break;
             *      case "save":
             *          /*foreach(string s in SaveEditorAsALibrary.System.lines)
             *          {
             *              SaveEditorAsALibrary.Output.debugOutput(s);
             *          }//
             *
             *          ////////
             *          ArrayList writeBackLines = new ArrayList();
             *          writeBackLines.Add("SiiNunit");
             *          writeBackLines.Add("{");
             *
             *          foreach (ArrayList al in SaveEditorAsALibrary.System.unitList)
             *          {
             *              foreach (string s in al)
             *              {
             *                  writeBackLines.Add(s);
             *              }
             *              writeBackLines.Add("");
             *          }
             *
             *          writeBackLines.Add("}");
             *
             *          foreach (string s in writeBackLines)
             *          {
             *              //Console.WriteLine(s);
             *          }
             *
             *          string[] writeBackLinesArray = (string[])writeBackLines.ToArray(typeof(string));
             *
             *          //string savepath = SaveSavegamePathBox.Text.ToString();
             *          string savepath = @"C:\users\rapha\desktop\eddddd.sii";
             *
             *          File.WriteAllLines(savepath, writeBackLinesArray);
             *          ///////
             *          break;
             *      case "selectUnit":
             *          selectedUnit = Int32.Parse(content[++i]);
             *          break;
             *      case "selectAttr":
             *          selectedAttr = Int32.Parse(content[++i]);
             *          break;
             *      default:
             *          break;
             *
             *  }
             * }*/
            //SaveEditorScriptingLanguage.Handler.handle(content, SaveSavegamePathBox.Text.ToString());
            //DebugHandling.logGUIStroke(new string[] { "[GUI] [Button] Script finished" });
        }