示例#1
0
        //Load ScriptView
        private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                try
                {
                    dataGridView1.Rows[e.RowIndex].Selected = true;
                    if (e.Button == MouseButtons.Left && !contextMenuOpen)
                    {
                        string  result = Networking.GetScriptById(form, dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());
                        JObject script = JObject.Parse(result);

                        ShowScript ss = new ShowScript(form, script["ID"].ToString(), script["Name"].ToString(), script["Version"].ToString(), script["Username"].ToString(), script["Alias"].ToString(), script["ShortDescription"].ToString(), script["LongDescription"].ToString(), script["Rating"].ToString(), script["Ratings"].ToString(), script["Downloads"].ToString());
                        ss.pictureBox1.MouseClick += new MouseEventHandler(unloadScript);
                        ss.Dock          = DockStyle.Fill;
                        panelScript.Size = this.Size;
                        panelScript.Controls.Add(ss);
                        ss.Size = panelScript.Size;

                        int slidecoeff = -1 * (int)(this.Width * 0.002);
                        if (slidecoeff >= 0)
                        {
                            slidecoeff = -1;
                        }

                        animatorScript.DefaultAnimation.SlideCoeff = new PointF(slidecoeff, 0);
                        animatorScript.ShowSync(panelScript);
                        panel1.Visible = false;
                    }
                }
                catch (WebException) { MetroFramework.MetroMessageBox.Show(form, "There was an unexpected network error!\nPlease make sure you have an internet connection.", "Network error", MessageBoxButtons.OK, MessageBoxIcon.Error, 125); }
                catch (Exception ex) { MetroFramework.MetroMessageBox.Show(form, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, 150); Console.WriteLine(ex.StackTrace); }
                contextMenuOpen = false;
            }
        }
示例#2
0
    public static ScriptCmd CreateDefault(int index)
    {
        string text = string.Empty;

        switch (index)
        {
        case 0:
            text = EnableScript.GetDefaultDescription();
            break;

        case 1:
            text = ShowDialog.GetDefaultDescription();
            break;

        case 2:
            text = PlaySound.GetDefaultDescription();
            break;

        case 3:
            text = Sleep.GetDefaultDescription();
            break;

        case 4:
            text = Exit.GetDefaultDescription();
            break;

        case 5:
            text = ShowScript.GetDefaultDescription();
            break;

        case 6:
            text = GiveWeapon.GetDefaultDescription();
            break;

        case 7:
            text = TakeAwayAll.GetDefaultDescription();
            break;

        case 8:
            text = SetMission.GetDefaultDescription();
            break;
        }
        if (text.Length <= 0)
        {
            return(null);
        }
        return(Create(text));
    }
示例#3
0
 private void DoShowScript(ShowScript showScript)
 {
     BrickProperty[] allScriptables = BrickManager.Instance.GetAllScriptables();
     if (allScriptables != null)
     {
         int            num  = -1;
         List <Texture> list = new List <Texture>();
         for (int i = 0; i < allScriptables.Length; i++)
         {
             Brick brick = BrickManager.Instance.GetBrick(allScriptables[i].Index);
             if (brick != null)
             {
                 list.Add(brick.Icon);
             }
             else
             {
                 Debug.LogError("Fail to get scriptables icon ");
             }
             if (showScript.Id == allScriptables[i].Seq)
             {
                 num = i;
             }
         }
         if (num < 0)
         {
             num = 0;
         }
         Texture[] array    = list.ToArray();
         int       num2     = array.Length;
         Rect      rect     = new Rect(0f, 0f, 48f, (float)(num2 * 48));
         Rect      position = new Rect(size.x / 2f + 4f, 112f, size.x / 2f - 8f, 192f);
         spId          = GUI.BeginScrollView(position, spId, rect);
         num           = GUI.SelectionGrid(rect, num, array, 1);
         showScript.Id = allScriptables[num].Seq;
         Color   color  = GUI.color;
         Vector2 vector = new Vector2(52f, 0f);
         for (int j = 0; j < allScriptables.Length; j++)
         {
             if (j == num)
             {
                 GUI.color = new Color(0.83f, 0.49f, 0.29f);
             }
             else
             {
                 GUI.color = Color.white;
             }
             BrickInst brickInst = BrickManager.Instance.GetBrickInst(allScriptables[j].Seq);
             if (brickInst == null || brickInst.BrickForceScript == null || brickInst.BrickForceScript.Alias.Length <= 0)
             {
                 GUI.Label(new Rect(vector.x, vector.y, size.x / 2f - 60f, 48f), allScriptables[j].Seq.ToString(), "MiniLabel");
             }
             else
             {
                 string text = (allScriptables[j].Seq != prop.Seq) ? brickInst.BrickForceScript.Alias : alias;
                 GUI.Label(new Rect(vector.x, vector.y, size.x / 2f - 60f, 48f), text, "MiniLabel");
             }
             vector.y += 48f;
         }
         GUI.color = color;
         GUI.EndScrollView();
     }
     showScript.Visible = GUI.Toggle(new Rect(size.x / 2f + 4f, 310f, 128f, 13f), showScript.Visible, StringMgr.Instance.Get("VISIBLE_OR"));
 }
示例#4
0
    public static ScriptCmd Create(string description)
    {
        ScriptCmd result = null;

        string[] array = description.Split(ScriptCmd.ArgDelimeters, StringSplitOptions.RemoveEmptyEntries);
        if (array != null && array.Length > 0)
        {
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = array[i].Trim();
            }
            string text = array[0].ToLower();
            switch (text)
            {
            case "enablescript":
                if (array.Length >= 3)
                {
                    EnableScript enableScript = new EnableScript();
                    enableScript.Id     = int.Parse(array[1]);
                    enableScript.Enable = bool.Parse(array[2]);
                    result = enableScript;
                }
                break;

            case "showdialog":
                if (array.Length >= 2)
                {
                    ShowDialog showDialog = new ShowDialog();
                    showDialog.Speaker = int.Parse(array[1]);
                    showDialog.Dialog  = ((array.Length < 3) ? string.Empty : array[2]);
                    result             = showDialog;
                }
                break;

            case "playsound":
                if (array.Length >= 2)
                {
                    PlaySound playSound = new PlaySound();
                    playSound.Index = int.Parse(array[1]);
                    result          = playSound;
                }
                break;

            case "sleep":
                if (array.Length >= 2)
                {
                    Sleep sleep = new Sleep();
                    sleep.Howlong = float.Parse(array[1]);
                    result        = sleep;
                }
                break;

            case "exit":
            {
                Exit exit = new Exit();
                result = exit;
                break;
            }

            case "showscript":
                if (array.Length >= 3)
                {
                    ShowScript showScript = new ShowScript();
                    showScript.Id      = int.Parse(array[1]);
                    showScript.Visible = bool.Parse(array[2]);
                    result             = showScript;
                }
                break;

            case "giveweapon":
            {
                GiveWeapon giveWeapon = new GiveWeapon();
                giveWeapon.WeaponCode = ((array.Length < 2) ? string.Empty : array[1]);
                result = giveWeapon;
                break;
            }

            case "takeawayall":
            {
                TakeAwayAll takeAwayAll = new TakeAwayAll();
                result = takeAwayAll;
                break;
            }

            case "setmission":
            {
                SetMission setMission = new SetMission();
                if (array.Length >= 2)
                {
                    setMission.Progress = array[1];
                    setMission.Title    = array[2];
                    setMission.SubTitle = array[3];
                    if (array.Length > 4 && array[4].Length > 0)
                    {
                        setMission.Tag = array[4];
                    }
                }
                else
                {
                    setMission.Progress = string.Empty;
                    setMission.Title    = string.Empty;
                    setMission.SubTitle = string.Empty;
                    setMission.Tag      = string.Empty;
                }
                result = setMission;
                break;
            }
            }
        }
        return(result);
    }