コード例 #1
0
        void Core_LoadEventSyntax()
        {
            try
            {
                if (!EA.Program.CodesLoaded || LanguageProcessor == null)
                {
                    string folder =
#if (DEBUG)
                        "D:\\Lexou\\Projects\\EmblemMagic\\EventAssembler\\Event Assembler\\Event Assembler";
#else
                        Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(EA.Program)).Location);
#endif
                    LanguageProcessor = EA.Program.LoadCodes(folder + "\\Language Raws", ".txt", true, true);
                }
                Language = EA.Program.Languages[Core.CurrentROM.GetIdentifier().Substring(0, 3)];
                string keywords            = "";
                IEnumerable <string> codes = Language.GetCodeNames();
                foreach (string code in codes)
                {
                    keywords += code;
                    keywords += "( |\r\n)|";
                }
                Event_CodeBox.AddSyntax("(//).*", SystemColors.ControlDark);
                Event_CodeBox.AddSyntax("#.* ", System.Drawing.Color.LimeGreen, FontStyle.Italic);
                Event_CodeBox.AddSyntax(keywords.TrimEnd('|'), SystemColors.Highlight, FontStyle.Bold);
                Event_CodeBox.AddSyntax(@"((\b[0-9]+)|((\b0x|\$)[0-9a-fA-F]+))\b", System.Drawing.Color.SlateBlue);
                Event_CodeBox.AddCollapse(":\r\n", "\r\n\r\n");
            }
            catch (Exception ex)
            {
                Program.ShowError("There has been an error while loading the EventAssembler language codes.", ex);
            }
        }
コード例 #2
0
        private void MapViewBox_SelectionChanged(object sender, EventArgs e)
        {
            if (MapViewBox.SelectionIsSingle())
            {
                Point selection = MapViewBox.GetSelectionCoords();
                MapSelection_Label.Text = "X: " + selection.X + ", Y: " + selection.Y;
            }
            else
            {
                MapSelection_Label.Text = "X: __, Y: __";
            }

            int width  = MapViewBox.Selection.GetLength(0);
            int height = MapViewBox.Selection.GetLength(1);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    if (MapViewBox.Selection[x, y])
                    {
                        for (int i = 0; i < EventList.Count; i++)
                        {
                            if (EventList[i].Command == "UNIT" &&
                                EventList[i].Arguments[UNIT_argX] == x &&
                                EventList[i].Arguments[UNIT_argY] == y)
                            {
                                int index = UnitEvents_ListBox.Items.IndexOf(EventList[i].Label);
                                if (index == -1)
                                {
                                    continue;
                                }
                                else if (UnitEvents_ListBox.GetItemChecked(index))
                                {
                                    index = Event.GetCodeIndex(Event_CodeBox.Text, EventList[i].CodeLineNumber);
                                    Event_CodeBox.SelectionStart  = index;
                                    Event_CodeBox.SelectionLength = 4;
                                    Event_CodeBox.DoSelectionVisible();
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
        private void HoverTick(object sender, EventArgs e)
        {
            Help_ToolTip_Timer.Enabled = false;
            MouseHoverFinished         = true;
            try
            {
                int    code_index = Event_CodeBox.GetIndexFromPosition(MouseHoverLocation);
                string command    = Event.GetWord(Event_CodeBox.Text, code_index);

                if (command.Length > 0)
                {
                    string caption = "";

                    if (command.EndsWith(":"))
                    {
                        command = command.Substring(0, command.Length - 1);
                        caption = "Pointer label";
                    }
                    else if (command.StartsWith("#"))
                    {
                        caption = "C preprocessor directive";
                    }
                    else if (command.StartsWith("$"))
                    {
                        caption = "Pointer/Address number";
                    }
                    else if (command.StartsWith("0x"))
                    {
                        caption = "Hexadecimal number";
                    }
                    if (caption == "")
                    {
                        caption = LanguageProcessor.GetDoc(command,
                                                           Core.CurrentROM.GetIdentifier().Substring(0, 3));
                        if (caption.StartsWith("command:"))
                        {
                            int length = caption.IndexOf('\n');
                            command = command + " - " + caption.Substring(8, length - 8);
                            caption = caption.Substring(length + 1);
                        }
                    }
                    if (caption == "")
                    {
                        //caption = ;
                    }

                    if (caption.Length > 0)
                    {
                        if (Help_ToolTip.Active && Help_ToolTip.ToolTipTitle == command)
                        {
                            return;
                        }
                        Help_ToolTip.Active       = true;
                        Help_ToolTip.ToolTipTitle = command;
                        Help_ToolTip.Show(caption, this,
                                          Event_CodeBox.Location.X + MouseHoverLocation.X,
                                          Event_CodeBox.Location.Y + MouseHoverLocation.Y + 40);
                    }
                    else
                    {
                        Help_ToolTip.Hide(this);
                        Help_ToolTip.Active = false;
                    }
                }
                else
                {
                    Help_ToolTip.Hide(this);
                    Help_ToolTip.Active = false;
                }
            }
            catch (Exception ex)
            {
                //Program.ShowError("There has been an error while loading the mousehover tooltip documentation.", ex);
            }
        }