Exemplo n.º 1
0
        private void OneLineDisassembler()
        {
            int i;

            if (this.ASMTextBox.Text.Length < 8)
            {//命令は最低でも8バイトでないとダメ.
                for (i = this.ASMTextBox.Text.Length; i < 8; i++)
                {
                    this.ASMTextBox.Text += "0";
                }
            }

            //文字列からバイト列に
            byte[] selectedByteData = U.convertStringDumpToByte(this.ASMTextBox.Text);
            if (selectedByteData.Length < 4)
            {
                return;
            }
            string hint = this.ScriptCodeName.Text;

            //バイト列をイベント命令としてDisassembler.
            EventScript.OneCode code = Program.ProcsScript.DisAseemble(selectedByteData, 0, hint);

            //命令を選択.
            this.ScriptCodeName.Text = EventScript.makeCommandComboText(code.Script, false);

            //引数
            int n = 0;

            for (i = 0; i < 2; i++, n++)
            {
                if (n >= code.Script.Args.Length)
                {
                    break;
                }
                EventScript.Arg arg = code.Script.Args[n];
                uint            v   = EventScript.GetArgValue(code, arg);

                if (EventScript.IsFixedArg(arg))
                {//固定長になっているところは入力できないようにする.
                    i--;
                    continue;
                }

                EventScriptForm.SetOneScriptEditSetTables(ScriptEditSetTables[i], arg, v);
            }

            for (; i < 2; i++)
            {
                //使わないパラメータはあっかりーんする
                EventScriptForm.HideOneScriptEditSetTables(ScriptEditSetTables[i]);
            }
            int y = ShowFloatingControlpanelInner(code, this.Script.SelectedIndex);

            ControlPanel.Location = new Point(ControlPanel.Location.X, y);
        }
Exemplo n.º 2
0
 public static uint GetScriptLabelID(EventScript.OneCode code)
 {
     for (int i = 0; i < code.Script.Args.Length; i++)
     {
         EventScript.Arg arg = code.Script.Args[i];
         if (arg.Type == EventScript.ArgType.LABEL_CONDITIONAL)
         {
             uint v = EventScript.GetArgValue(code, arg);
             return(v);
         }
     }
     return(U.NOT_FOUND);
 }
Exemplo n.º 3
0
 static uint GetScriptConditionalID(EventScript.OneCode code)
 {
     for (int i = 0; i < code.Script.Args.Length; i++)
     {
         EventScript.Arg arg = code.Script.Args[i];
         if (arg.Type == EventScript.ArgType.IF_CONDITIONAL ||
             arg.Type == EventScript.ArgType.GOTO_CONDITIONAL)
         {
             uint v = EventScript.GetArgValue(code, arg);
             return(v);
         }
     }
     return(U.NOT_FOUND);
 }
Exemplo n.º 4
0
        void ParamSrc_Focused(object sender, EventArgs e)
        {
            EventScript.OneCode code;
            int selectID;
            int argindex;

            if (!Get_Select_ParamSrc_Object(sender, out code, out selectID, out argindex))
            {
                return;
            }

            EventScript.Arg arg   = code.Script.Args[argindex];
            uint            value = EventScriptForm.GetValueOneScriptEditSetTables(ScriptEditSetTables[selectID], arg);

            if (arg.Type == EventScript.ArgType.MAPX || arg.Type == EventScript.ArgType.MAPY)
            {
                NumericUpDown xObj;
                NumericUpDown yObj;
                if (arg.Type == EventScript.ArgType.MAPX)
                {
                    xObj = (NumericUpDown)sender;
                    yObj = ScriptEditSetTables[selectID + 1].ParamSrc;
                }
                else
                {
                    xObj = ScriptEditSetTables[selectID - 1].ParamSrc;
                    yObj = (NumericUpDown)sender;
                }
                bool updateLock = false;

                Func <int, int, int> movecallback = (int x, int y) =>
                {
                    if (updateLock)
                    {
                        return(0);
                    }
                    updateLock = true;

                    U.ForceUpdate(xObj, x);
                    U.ForceUpdate(yObj, y);

                    updateLock = false;
                    return(0);
                };
            }
        }
Exemplo n.º 5
0
        private void ParamLabel_Clicked(object sender, EventArgs e)
        {
            EventScript.OneCode code;
            int selectID;
            int argindex;

            if (!Get_Select_ParamSrc_Object(sender, out code, out selectID, out argindex))
            {
                return;
            }

            NumericUpDown src_object = ScriptEditSetTables[selectID].ParamSrc;

            EventScript.Arg arg   = code.Script.Args[argindex];
            uint            value = EventScriptForm.GetValueOneScriptEditSetTables(ScriptEditSetTables[selectID], arg);

            if (arg.Type == EventScript.ArgType.POINTER_TEXT)
            {
                CStringForm f = (CStringForm)InputFormRef.JumpForm <CStringForm>();
                f.Init(src_object);
            }
            else if (arg.Type == EventScript.ArgType.POINTER_PROCS)
            {
                ProcsScriptForm f = (ProcsScriptForm)InputFormRef.JumpForm <ProcsScriptForm>(U.NOT_FOUND);
                f.JumpTo(value);
            }
            else if (arg.Type == EventScript.ArgType.POINTER_ASM)
            {
                DisASMForm f = (DisASMForm)InputFormRef.JumpForm <DisASMForm>(U.NOT_FOUND);
                f.JumpTo(DisassemblerTrumb.ProgramAddrToPlain(value));
            }
            else if (arg.Type == EventScript.ArgType.POINTER_AIUNIT)
            {
                AIUnitsForm f = (AIUnitsForm)InputFormRef.JumpFormLow <AIUnitsForm>();
                f.JumpTo(value);
                f.ShowDialog();
                U.SetActiveControl(src_object);
                U.ForceUpdate(src_object, f.GetBaseAddress());
            }
        }
Exemplo n.º 6
0
 static uint GetScriptSomeLabel(EventScript.OneCode code)
 {
     if (code.Script.Has == EventScript.ScriptHas.LABEL_CONDITIONAL ||
         code.Script.Has == EventScript.ScriptHas.IF_CONDITIONAL ||
         code.Script.Has == EventScript.ScriptHas.GOTO_CONDITIONAL
         )
     {
         for (int i = 0; i < code.Script.Args.Length; i++)
         {
             EventScript.Arg arg = code.Script.Args[i];
             if (arg.Type == EventScript.ArgType.LABEL_CONDITIONAL ||
                 arg.Type == EventScript.ArgType.IF_CONDITIONAL ||
                 arg.Type == EventScript.ArgType.GOTO_CONDITIONAL
                 )
             {
                 uint v = EventScript.GetArgValue(code, arg);
                 return(v);
             }
         }
     }
     return(U.NOT_FOUND);
 }
Exemplo n.º 7
0
        private void ParamSrc_ValueChanged(object sender, EventArgs e)
        {
            EventScript.OneCode code;
            int selectID;
            int argindex;

            if (!Get_Select_ParamSrc_Object(sender, out code, out selectID, out argindex))
            {
                return;
            }
            if (selectID < 0 || selectID > ScriptEditSetTables.Length)
            {
                return;
            }

            EventScript.Arg arg   = code.Script.Args[argindex];
            uint            value = EventScriptForm.WriteOneScriptEditSetTables(ScriptEditSetTables[selectID], arg, code);

            EventScriptForm.WriteAliasScriptEditSetTables(ScriptEditSetTables[selectID], arg, code);

            bool   isOrderOfHuman  = (this.ActiveControl == sender); //人間の操作によるものか
            string text            = "";
            Bitmap backgroundImage = null;
            string errorMessage    = "";

            if (arg.Type == EventScript.ArgType.TEXT ||
                arg.Type == EventScript.ArgType.CONVERSATION_TEXT ||
                arg.Type == EventScript.ArgType.SYSTEM_TEXT ||
                arg.Type == EventScript.ArgType.ONELINE_TEXT
                )
            {
                text = TextForm.DirectAndStripAllCode((value));
            }
            else if (arg.Type == EventScript.ArgType.POINTER_TEXT)
            {
                text = TextForm.Direct(value);
            }
            else if (arg.Type == EventScript.ArgType.POINTER_PROCS)
            {
                text = Program.AsmMapFileAsmCache.GetASMName(value, AsmMapFileAsmCache.ASMTYPE.NONE, out errorMessage);
            }
            else if (arg.Type == EventScript.ArgType.POINTER_ASM)
            {
                text = Program.AsmMapFileAsmCache.GetASMName(value, AsmMapFileAsmCache.ASMTYPE.THUMB, out errorMessage);
            }
            else if (arg.Type == EventScript.ArgType.FSEC)
            {//FSEC
                text = InputFormRef.GetFSEC(value);
            }
            else if (arg.Type == EventScript.ArgType.MAPXY)
            {//MAPXY
                if (arg.Size == 4)
                {
                    text = InputFormRef.GetMAPXY32(value);
                }
                else
                {
                    text = InputFormRef.GetMAPXY16(value);
                }
            }

            ScriptEditSetTables[selectID].ParamValue.Text            = text;
            ScriptEditSetTables[selectID].ParamValue.BackgroundImage = backgroundImage;
            ScriptEditSetTables[selectID].ParamValue.ErrorMessage    = errorMessage;

            if (isOrderOfHuman)
            {//現在このコントロールから値を入力している場合は、他のコントロールも連動して変更する
                this.ASMTextBox.Text = U.convertByteToStringDump(code.ByteData);

                //変更があったので、変更ボタンを光らせる.
                InputFormRef.WriteButtonToYellow(this.UpdateButton, true);
                InputFormRef.WriteButtonToYellow(this.NewButton, true);
            }
        }
        private string EventToTextOne(int number)
        {
            StringBuilder sb = new StringBuilder();

            EventScript.OneCode code = this.ProcsScript[number];
            for (int n = 0; n < code.ByteData.Length; n++)
            {
                sb.Append(U.ToHexString(code.ByteData[n]));
            }
            sb.Append("\t//");

            //スクリプト名.
            sb.Append(code.Script.Info[0]);

            for (int i = 1; i < code.Script.Info.Length; i += 2)
            {
                char symbol = ' ';
                if (code.Script.Info[i].Length > 2)
                {// [X みたいな文字列が入る. 2文字目のXが シンボル名.
                    symbol = code.Script.Info[i][1];
                }

                for (int n = 0; n < code.Script.Args.Length; n++)
                {
                    EventScript.Arg arg = code.Script.Args[n];
                    if (EventScript.IsFixedArg(arg))
                    {
                        continue;
                    }
                    if (symbol != arg.Symbol)
                    {
                        continue;
                    }

                    sb.Append("[");

                    uint   v;
                    string hexstring = EventScript.GetArg(code, n, out v);
                    sb.Append(arg.Name);
                    sb.Append(":");

                    sb.Append(hexstring);

                    if (arg.Type == EventScript.ArgType.TEXT ||
                        arg.Type == EventScript.ArgType.CONVERSATION_TEXT ||
                        arg.Type == EventScript.ArgType.SYSTEM_TEXT ||
                        arg.Type == EventScript.ArgType.ONELINE_TEXT ||
                        arg.Type == EventScript.ArgType.POINTER_TEXT
                        )
                    {
                        sb.Append(" ");
                        string text = TextForm.DirectAndStripAllCode((v));
                        if (text.Length > 30)
                        {//長いテキストは省略
                            sb.Append(U.escape_return(U.strimwidth(text, 0, 20)));
                        }
                        else
                        {//長くないテキストはすぐ横に表示
                            sb.Append(U.escape_return(text));
                        }
                    }
                    else if (arg.Type == EventScript.ArgType.UNIT)
                    {
                        sb.Append(" ");
                        sb.Append(UnitForm.GetUnitName(v));
                    }
                    else if (arg.Type == EventScript.ArgType.CLASS)
                    {
                        sb.Append(" ");
                        sb.Append(ClassForm.GetClassName(v));
                    }
                    else if (arg.Type == EventScript.ArgType.POINTER_PROCS)
                    {
                        sb.Append(" ");
                        string dummy;
                        sb.Append(Program.AsmMapFileAsmCache.GetASMName(v, true, out dummy));
                    }
                    else if (arg.Type == EventScript.ArgType.POINTER_ASM)
                    {
                        sb.Append(" ");
                        string dummy;
                        sb.Append(Program.AsmMapFileAsmCache.GetASMName(v, false, out dummy));
                    }
                    else if (arg.Type == EventScript.ArgType.FSEC)
                    {//FSEC
                        sb.Append(" ");
                        sb.Append(InputFormRef.GetFSEC(v));
                    }
                    sb.Append("]");
                    break;
                }
            }
            sb.AppendLine("");

            return(sb.ToString());
        }