Esempio n. 1
0
        private void loadRegionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!CheckChanges())
            {
                return;
            }

            WLDFileController wldc = FileDatabase.Instance.GetWLD();

            FableMod.WLD.WLDFile wld = wldc.WLD;

            FormRegionSelect form = new FormRegionSelect();

            for (int i = 0; i < wld.RegionCount; ++i)
            {
                form.listBoxRegions.Items.Add(
                    wld.GetRegion(i).RegionName);
            }

            if (form.ShowDialog() != DialogResult.OK)
            {
                // Cancel!
                return;
            }

            form.Dispose();

            Reset();

            FableMod.WLD.Region region = wld.GetRegion(
                form.listBoxRegions.Items[
                    form.listBoxRegions.SelectedIndex].ToString());

            LoadRegion(region);
        }
Esempio n. 2
0
        public FormEditor(string regionName)
        {
            InitializeComponent();

            Init();

            if (string.IsNullOrEmpty(regionName))
            {
                return;
            }

            WLDFileController wldc = FileDatabase.Instance.GetWLD();

            FableMod.WLD.WLDFile wld = wldc.WLD;

            FableMod.WLD.Region region = wld.GetRegion(regionName);

            if (region != null)
            {
                LoadRegion(region);
            }
            else
            {
                FormMain.Instance.ErrorMessage(
                    string.Format("Region {0} not found.", regionName));
            }
        }
Esempio n. 3
0
        public FileController Get(string fileName)
        {
            fileName = GetAbsoluteFileName(fileName);

            FileController c = Find(fileName);

            if (c != null)
            {
                // Already in the system.
                return(c);
            }

            FileInfo info = new FileInfo(fileName);

            string ext = info.Extension.ToUpper();

            if (ext == ".BIG")
            {
                c = new BIGFileController(this, fileName);
            }
            else if (ext == ".BIN")
            {
                if (info.Name.ToUpper() == "NAMES.BIN")
                {
                    c = new NamesBINController(this, fileName);
                }
                else
                {
                    c = new BINFileController(this, fileName);
                }
            }
            else if (ext == ".STB")
            {
                c = new BBBFileController(
                    this, new FableMod.STB.STBFile(), fileName);
            }
            else if (ext == ".WAD")
            {
                c = new BBBFileController(
                    this, new FableMod.BBB.BBBFile(), fileName);
            }
            else if (ext == ".WLD")
            {
                c = new WLDFileController(this, fileName);
            }

            if (c != null)
            {
                myFiles.Add(c);
            }

            return(c);
        }
Esempio n. 4
0
        private void myView_ThingCreated(
            float x, float y, float z,
            float nx, float ny, float nz)
        {
            ThingMap selectedMap = null;

            for (int i = 0; i < myMaps.Count; ++i)
            {
                if (myMaps[i].IsOver(x, y, z))
                {
                    selectedMap = myMaps[i];
                    break;
                }
            }

            if (selectedMap == null)
            {
                FormMain.Instance.ErrorMessage("Click over a map, please.");
                return;
            }

            if (myCreateMode == CreateMode.SelectTeleporterDst)
            {
                float dstx = x - myTeleporterMap.X;
                float dsty = y - myTeleporterMap.Y;

                CTCBlock block =
                    myTeleporter.get_CTCs("CTCPhysicsStandard");

                if (MessageBox.Show(
                        "Create a two-way teleporter?",
                        "ChocolateBox",
                        MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    FableMod.TNG.Thing myOriginal = myCreatedThing;

                    if (SetupForTeleporter())
                    {
                        selectedMap.AddThing(
                            myController,
                            myCreatedThing,
                            "NULL",
                            x, y, z,
                            nx, ny, nz);

                        CTCBlock blockSrc =
                            myOriginal.get_CTCs("CTCPhysicsStandard");

                        CTCBlock blockDst =
                            myTeleporter.get_CTCs("CTCPhysicsStandard");

                        blockDst.get_Variables("PositionX").Value =
                            (myTeleporterMap.X +
                             (float)blockSrc.get_Variables("PositionX").Value) -
                            selectedMap.X;

                        blockDst.get_Variables("PositionY").Value =
                            (myTeleporterMap.Y +
                             (float)blockSrc.get_Variables("PositionY").Value) -
                            selectedMap.Y;

                        blockDst.get_Variables("PositionZ").Value =
                            ((float)blockSrc.get_Variables(
                                 "PositionZ").Value) + 0.5f;

                        selectedMap.AddThing(
                            myController,
                            myTeleporter,
                            "NULL");

                        // So we spawn over the thing.
                        z += 0.5f;
                    }
                }
                else if (MessageBox.Show(
                             "Create a teleportation platform?\r\n" +
                             "This object is a visual que only.",
                             "ChocolateBox",
                             MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    FableMod.TNG.Thing platform =
                        new FableMod.TNG.Thing("Object");

                    platform.Create(
                        FileDatabase.Instance.TNGDefinitions,
                        "OBJECT_GUILD_PEDESTAL_TELEPORT_01");

                    platform.UID    = FableMod.TNG.UIDManager.Generate();
                    platform.Player = 4;

                    selectedMap.AddThing(
                        myController,
                        platform,
                        "NULL",
                        x, y, z,
                        nx, ny, nz);

                    // So we spawn over the thing.
                    z += 0.5f;
                }

                // Set the jump coordinates.
                block.get_Variables("PositionX").Value = dstx;
                block.get_Variables("PositionY").Value = dsty;
                block.get_Variables("PositionZ").Value = z;

                FormMain.Instance.InfoMessage(string.Format(
                                                  "Teleporter created from map \"{0}\" to map \"{1}\".",
                                                  myTeleporterMap.Name,
                                                  selectedMap.Name));

                myCreateMode = CreateMode.None;
                myView.Mode  = EditorMode.Normal;

                //Close();

                return;
            }
            else if (myCreateMode == CreateMode.SelectTeleporterSrc)
            {
                try
                {
                    selectedMap.AddThing(
                        myController,
                        myCreatedThing,
                        "NULL",
                        x, y, z,
                        nx, ny, nz);

                    selectedMap.AddThing(
                        myController,
                        myTeleporter,
                        "NULL");
                }
                catch (Exception ex)
                {
                    FormMain.Instance.ErrorMessage(ex.Message);
                    return;
                }

                WLDFileController wldc =
                    FileDatabase.Instance.GetWLD();
                FableMod.WLD.WLDFile wld = wldc.WLD;

                FormRegionSelect form = new FormRegionSelect();

                form.Text = "Select Destination Region";

                for (int i = 0; i < wld.RegionCount; ++i)
                {
                    form.listBoxRegions.Items.Add(
                        wld.GetRegion(i).RegionName);
                }

                if (form.ShowDialog() == DialogResult.OK)
                {
                    FableMod.WLD.Region region = wld.GetRegion(
                        form.listBoxRegions.Items[
                            form.listBoxRegions.SelectedIndex].
                        ToString());

                    if (region.RegionName != myRegion)
                    {
                        FormEditor formEditor = new FormEditor(
                            region,
                            myCreatedThing,
                            myTeleporter,
                            selectedMap);

                        FormMain.Instance.AddMDI(formEditor);
                    }
                    else
                    {
                        // Use this window.
                        SelectTeleporterDestination(
                            myCreatedThing, myTeleporter, selectedMap);

                        return;
                    }
                }
                else
                {
                    myController.RemoveThing(myCreatedThing);
                    myController.RemoveThing(myTeleporter);
                }

                form.Dispose();

                myCreatedThing = null;

                // Reset variable.
                myTeleporter = null;
            }
            else if (myCreateMode == CreateMode.CreateNew)
            {
                try
                {
                    selectedMap.AddThing(
                        myController,
                        myCreatedThing,
                        "NULL",
                        x, y, z,
                        nx, ny, nz);
                }
                catch (Exception ex)
                {
                    FormMain.Instance.ErrorMessage(ex.Message);
                }

                myCreatedThing = null;
            }
            else if (myCreateMode == CreateMode.Import)
            {
                for (int i = 0; i < myImports.Count; ++i)
                {
                    FableMod.TNG.Thing thing = myImports[i];

                    selectedMap.AddThing(
                        myController, thing, "NULL");
                }
            }

            myImports.Clear();
            myCreateMode = CreateMode.None;
            myView.Mode  = EditorMode.Normal;
        }
Esempio n. 5
0
        private void LoadRegion(FableMod.WLD.Region region)
        {
            myView.Activate(false);

            WLDFileController wldc = FileDatabase.Instance.GetWLD();

            FableMod.WLD.WLDFile wld = wldc.WLD;

            string directory = Path.GetDirectoryName(wldc.FileName) + "\\";

            RegionLoader loader = new RegionLoader(
                directory,
                myController,
                region,
                null,
                Settings.GetBool("Editor", "SeesMaps", false));

            FormProcess formProcess = new FormProcess(loader);

            formProcess.ShowDialog();

            formProcess.Dispose();

            myMaps = loader.Maps;

            myView.Name = region.RegionName;

            formProcess.Dispose();

            myView.IsometricCamera();

            comboBoxMap.Items.Clear();

            if (myMaps != null)
            {
                FillMapComboBox(comboBoxMap);
                FillMapComboBox(comboBoxEditMap);
            }

            Text = "Region Editor - " + region.RegionName;

            myView.Maps        = myMaps;
            myView.EditSection = "NULL";
            myView.EditMap     = myMaps[0];

            panelGeneral.Visible = true;

            if (trackBarDrawDistance.Maximum == 0)
            {
                trackBarDrawDistance.Minimum = 1;
                trackBarDrawDistance.Maximum = (int)myView.DrawDistance;
            }

            trackBarDrawDistance.Value = (int)myView.DrawDistance;

            toolStripMain.Enabled = true;

            thingsToolStripMenuItem.Enabled           = true;
            editToolStripMenuItem.Enabled             = true;
            viewToolStripMenuItem.Enabled             = true;
            saveScreenshotAsToolStripMenuItem.Enabled = true;

            // Set the active region name.
            myRegion = region.RegionName;

            myController.ShowOfType(
                "Marker", markersToolStripMenuItem.Checked);
            myController.ShowOfType(
                "AICreature", creaturesToolStripMenuItem.Checked);
            myController.ShowOfType(
                "Object", objectsToolStripMenuItem.Checked);

            myView.Activate(true);

            myView.STBDebugFlora  = sTBDebugFloraToolStripMenuItem.Checked;
            myView.STBDebugBlocks = sTBDebugBlocksToolStripMenuItem.Checked;
        }