예제 #1
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;
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        void Core_LoadMap()
        {
            Pointer address         = Core.GetPointer("Map Data Array");
            Pointer poin_palette    = Core.ReadPointer(address + 4 * (byte)Current["Palette"]);
            Pointer poin_tileset1   = Core.ReadPointer(address + 4 * (byte)Current["Tileset1"]);
            Pointer poin_tileset2   = Core.ReadPointer(address + 4 * (byte)Current["Tileset2"]);
            Pointer poin_tsa        = Core.ReadPointer(address + 4 * (byte)Current["TSA"]);
            Pointer poin_mapdata    = Core.ReadPointer(address + 4 * (byte)Current["Map"]);
            Pointer poin_mapchanges = Core.ReadPointer(address + 4 * (byte)Current["MapChanges"]);

            MapTileset map_tileset;

            try
            {
                map_tileset = new MapTileset(
                    Core.ReadData(poin_palette, Map.PALETTES * Palette.LENGTH),
                    Core.ReadData(poin_tileset1, 0),
                    Core.ReadData(poin_tileset2, 0),
                    Core.ReadData(poin_tsa, 0));
            }
            catch (Exception ex)
            {
                map_tileset = null;
                Program.ShowError("Could not load the the tileset for this chapter.", ex);
            }

            try
            {
                CurrentMap = new Map(map_tileset,
                                     Core.ReadData(poin_mapdata, 0),
                                     poin_mapchanges, false);
            }
            catch (Exception ex)
            {
                CurrentMap = null;
                Program.ShowError("Could not load the map for this chapter.", ex);
            }

            if (CurrentMap.Changes != null)
            {
                MapChanges_ListBox.ItemCheck -= MapChanges_ListBox_ItemCheck;
                if (MapChanges_ListBox.Items.Count > 0)
                {
                    for (int i = 0; i < CurrentMap.ShowChanges.Length; i++)
                    {
                        CurrentMap.ShowChanges[i] = MapChanges_ListBox.GetItemChecked(i);
                    }
                    MapChanges_ListBox.Items.Clear();
                }
                for (int i = 0; i < CurrentMap.Changes.Count; i++)
                {
                    MapChanges_ListBox.Items.Add(
                        "0x" + Util.ByteToHex(CurrentMap.Changes.GetNumber(i)),
                        CurrentMap.ShowChanges[i]);
                }
                MapChanges_ListBox.ItemCheck += MapChanges_ListBox_ItemCheck;
            }

            GBA.Bitmap result = new GBA.Bitmap(CurrentMap);

            if (View_Units.Checked)
            {
                Core_LoadMap_Units(result);
            }

            MapViewBox.Size = new Size(CurrentMap.Width, CurrentMap.Height);
            MapViewBox.Load(result);
        }