示例#1
0
        private void LoadPrefab(int position)
        {
            loadingprefab = true;

            BuilderPlug.Prefab p = BuilderPlug.Me.Prefabs[position];

            prefabname.Text = p.name;

            NumberOfSectors       = (uint)p.numberofsectors;
            OuterVertexMultiplier = p.outervertexmultiplier;
            InnerVertexMultiplier = p.innervertexmultiplier;

            tabcontrol.SelectedIndex = p.stairtype;

            // Straight stairs
            SectorDepth                 = (uint)p.sectordepth;
            Spacing                     = p.spacing;
            SideFront                   = p.frontside;
            SingleSteps.Checked         = p.singlesteps;
            distinctsectors.Checked     = p.distinctsectors;
            SingleDirection.Checked     = p.singledirection;
            DistinctBaseHeights.Checked = p.distinctbaseheights;

            // Auto curve TODO
            Flipping = p.flipping;

            // Catmull Rom spline
            NumControlPoints = p.numberofcontrolpoints;

            // Height info
            FloorHeight             = p.applyfloormod;
            FloorHeightModification = p.floormod;
            //FloorBase = p.floorbase;
            CeilingHeight             = p.applyceilingmod;
            CeilingHeightModification = p.ceilingmod;
            //CeilingBase = p.ceilingbase;

            // Textures
            FloorFlat          = p.applyfloortexture;
            FloorFlatTexture   = p.floortexture;
            CeilingFlat        = p.applyceilingtexture;
            CeilingFlatTexture = p.ceilingtexture;

            UpperTexture        = p.applyuppertexture;
            UpperTextureTexture = p.uppertexture;
            UpperUnpegged       = p.upperunpegged;

            MiddleTexture        = p.applymiddletexture;
            MiddleTextureTexture = p.middletexture;

            LowerTexture        = p.applylowertexture;
            LowerTextureTexture = p.lowertexture;
            LowerUnpegged       = p.lowerunpegged;

            loadingprefab = false;
        }
示例#2
0
        private void SavePrefab(string name, bool forceoverwrite, int position)
        {
            int overwrite = -1;

            // Prefab name may not be empty
            if (name == "")
            {
                MessageBox.Show(this.Owner, "Please enter a name for the prefab", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Check if there's already a prefab with the given name
            for (int i = 0; i < BuilderPlug.Me.Prefabs.Count; i++)
            {
                BuilderPlug.Prefab p = BuilderPlug.Me.Prefabs[i];

                if (p.name == name)
                {
                    if (forceoverwrite == false && MessageBox.Show(this.Owner, "A prefab with that name already exists. Overwrite?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                    else
                    {
                        overwrite = i;
                    }
                }
            }

            ListViewItem lvi = new ListViewItem();

            ListViewItem.ListViewSubItem lvisi = new ListViewItem.ListViewSubItem();

            lvi.Text   = name;
            lvisi.Text = tabcontrol.TabPages[tabcontrol.SelectedIndex].Text;

            lvi.SubItems.Add(lvisi);

            BuilderPlug.Prefab pf = new BuilderPlug.Prefab();

            pf.name = name;

            pf.numberofsectors       = (int)NumberOfSectors;
            pf.outervertexmultiplier = OuterVertexMultiplier;
            pf.innervertexmultiplier = InnerVertexMultiplier;

            pf.stairtype = tabcontrol.SelectedIndex;

            // Straight stairs
            pf.sectordepth         = (int)SectorDepth;
            pf.spacing             = Spacing;
            pf.frontside           = SideFront;
            pf.singlesectors       = SingleSectors.Checked;
            pf.singledirection     = SingleDirection.Checked;
            pf.distinctbaseheights = DistinctBaseHeights.Checked;

            // Auto curve
            pf.flipping = Flipping;

            // Catmull Rom spline
            pf.numberofcontrolpoints = NumControlPoints - 2;

            // Height info
            pf.applyfloormod = FloorHeight;
            pf.floormod      = FloorHeightModification;
            //pf.floorbase = FloorBase;
            pf.applyceilingmod = CeilingHeight;
            pf.ceilingmod      = CeilingHeightModification;
            //pf.ceilingbase = CeilingBase;

            // Textures
            pf.applyfloortexture = FloorFlat;
            pf.floortexture      = FloorFlatTexture;

            pf.applyceilingtexture = CeilingFlat;
            pf.ceilingtexture      = CeilingFlatTexture;

            pf.applyuppertexture = UpperTexture;
            pf.uppertexture      = UpperTextureTexture;
            pf.upperunpegged     = UpperUnpegged;

            pf.applymiddletexture = MiddleTexture;
            pf.middletexture      = MiddleTextureTexture;

            pf.applylowertexture = LowerTexture;
            pf.lowertexture      = LowerTextureTexture;
            pf.lowerunpegged     = LowerUnpegged;

            if (overwrite == -1)
            {
                if (position == -1)
                {
                    BuilderPlug.Me.Prefabs.Add(pf);
                    prefabs.Items.Add(lvi);
                }
                else
                {
                    BuilderPlug.Me.Prefabs.Insert(position, pf);
                    prefabs.Items.Insert(position, lvi);
                }
            }
            else
            {
                BuilderPlug.Me.Prefabs.RemoveAt(overwrite);
                BuilderPlug.Me.Prefabs.Insert(overwrite, pf);

                prefabs.Items.RemoveAt(overwrite);
                prefabs.Items.Insert(overwrite, lvi);
            }
        }
		private void SavePrefab(string name, bool forceoverwrite, int position)
		{
            int overwrite = -1;

            // Prefab name may not be empty
            if (name == "")
            {
                MessageBox.Show(this.Owner, "Please enter a name for the prefab", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Check if there's already a prefab with the given name
			for (int i = 0; i < BuilderPlug.Me.Prefabs.Count; i++)
			{
				BuilderPlug.Prefab p = BuilderPlug.Me.Prefabs[i];

				if (p.name == name)
				{
					if (forceoverwrite == false && MessageBox.Show(this.Owner, "A prefab with that name already exists. Overwrite?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
						return;
					else
						overwrite = i;
				}
			}

            ListViewItem lvi = new ListViewItem();
            ListViewItem.ListViewSubItem lvisi = new ListViewItem.ListViewSubItem();

            lvi.Text = name;
            lvisi.Text = tabcontrol.TabPages[tabcontrol.SelectedIndex].Text;

            lvi.SubItems.Add(lvisi);

            BuilderPlug.Prefab pf = new BuilderPlug.Prefab();

            pf.name = name;

            pf.numberofsectors = (int)NumberOfSectors;
            pf.outervertexmultiplier = OuterVertexMultiplier;
            pf.innervertexmultiplier = InnerVertexMultiplier;

            pf.stairtype = tabcontrol.SelectedIndex;

            // Straight stairs
            pf.sectordepth = (int)SectorDepth;
            pf.spacing = (int)Spacing;
            pf.frontside = SideFront;
            pf.singlesectors = SingleSectors.Checked;
            pf.singledirection = SingleDirection.Checked;
			pf.removeredundantvertices = RemoveRedundantVertices.Checked;
			pf.distinctbaseheights = DistinctBaseHeights.Checked;

            // Auto curve
			pf.flipping = Flipping;

            // Catmull Rom spline
            pf.numberofcontrolpoints = NumControlPoints - 2;

            // Height info
            pf.applyfloormod = FloorHeight;
            pf.floormod = FloorHeightModification;
			//pf.floorbase = FloorBase;
            pf.applyceilingmod = CeilingHeight;
            pf.ceilingmod = CeilingHeightModification;
			//pf.ceilingbase = CeilingBase;

			// Lighting
			pf.applylightingmod = Lighting;
			pf.lightingmod = LightingModification;
			// pf.lightingbase = LightingBase;

            // Textures
            pf.applyfloortexture = FloorFlat;
            pf.floortexture = FloorFlatTexture;

            pf.applyceilingtexture = CeilingFlat;
            pf.ceilingtexture = CeilingFlatTexture;

            pf.applyuppertexture = UpperTexture;
            pf.uppertexture = UpperTextureTexture;
			pf.upperunpegged = UpperUnpegged;

			pf.applymiddletexture = MiddleTexture;
			pf.middletexture = MiddleTextureTexture;

            pf.applylowertexture = LowerTexture;
            pf.lowertexture = LowerTextureTexture;
			pf.lowerunpegged = LowerUnpegged;

			if (overwrite == -1)
			{
				if (position == -1)
				{
					BuilderPlug.Me.Prefabs.Add(pf);
					prefabs.Items.Add(lvi);
				}
				else
				{
					BuilderPlug.Me.Prefabs.Insert(position, pf);
					prefabs.Items.Insert(position, lvi);
				}
			}
			else
			{
				BuilderPlug.Me.Prefabs.RemoveAt(overwrite);
				BuilderPlug.Me.Prefabs.Insert(overwrite, pf);

				prefabs.Items.RemoveAt(overwrite);
				prefabs.Items.Insert(overwrite, lvi);
			}
        }
		private void LoadPrefab(string name)
		{
			BuilderPlug.Prefab p = new BuilderPlug.Prefab();

			for (int i = 0; i < BuilderPlug.Me.Prefabs.Count; i++)
			{
				if(BuilderPlug.Me.Prefabs[i].name == name)
					p = BuilderPlug.Me.Prefabs[i];
			}

			if (p.name == null) return;

			loadingprefab = true;

            prefabname.Text = name;

            NumberOfSectors = (uint)p.numberofsectors;
            OuterVertexMultiplier = p.outervertexmultiplier;
            InnerVertexMultiplier = p.innervertexmultiplier;

            tabcontrol.SelectedIndex = p.stairtype;

            // Straight stairs
            SectorDepth = (uint)p.sectordepth;
            Spacing = p.spacing;
            SideFront = p.frontside;
            SingleSectors.Checked = p.singlesectors;
            SingleDirection.Checked = p.singledirection;
			RemoveRedundantVertices.Checked = p.removeredundantvertices;
			DistinctBaseHeights.Checked = p.distinctbaseheights;

            // Auto curve TODO
			Flipping = p.flipping;

            // Catmull Rom spline
            NumControlPoints = p.numberofcontrolpoints;

            // Height info
            FloorHeight = p.applyfloormod;
            FloorHeightModification = p.floormod;
			//FloorBase = p.floorbase;
            CeilingHeight = p.applyceilingmod;
            CeilingHeightModification = p.ceilingmod;
			//CeilingBase = p.ceilingbase;

			// lighting
			Lighting = p.applylightingmod;
			LightingModification = p.lightingmod;
			// LightingBase = p.lightingbase;

            // Textures
            FloorFlat = p.applyfloortexture;
            FloorFlatTexture = p.floortexture;
            CeilingFlat = p.applyceilingtexture;
            CeilingFlatTexture = p.ceilingtexture;

            UpperTexture = p.applyuppertexture;
            UpperTextureTexture = p.uppertexture;
			UpperUnpegged = p.upperunpegged;

			MiddleTexture = p.applymiddletexture;
			MiddleTextureTexture = p.middletexture;

            LowerTexture = p.applylowertexture;
            LowerTextureTexture = p.lowertexture;
			LowerUnpegged = p.lowerunpegged;

			loadingprefab = false;

			DoRedrawDisplay();
        }
		private void LoadPrefabs()
		{
			ListDictionary prefabdata = new ListDictionary();

			// load the light info from the .dbs
			prefabdata = (ListDictionary)General.Map.Options.ReadPluginSetting("prefabs", new ListDictionary());

			BuilderPlug.Me.Prefabs.Clear();

			foreach (DictionaryEntry prefabentry in prefabdata)
			{
				BuilderPlug.Prefab p = new BuilderPlug.Prefab();

				foreach (DictionaryEntry entry in (ListDictionary)prefabentry.Value)
				{
					if ((string)entry.Key == "name") p.name = (string)entry.Value;
					if ((string)entry.Key == "numberofsectors") p.numberofsectors = (int)entry.Value;
					if ((string)entry.Key == "outervertexmultiplier") p.outervertexmultiplier = (int)entry.Value;
					if ((string)entry.Key == "innervertexmultiplier") p.innervertexmultiplier = (int)entry.Value;
					if ((string)entry.Key == "stairtype") p.stairtype = (int)entry.Value;
					if ((string)entry.Key == "sectordepth") p.sectordepth = (int)entry.Value;
					if ((string)entry.Key == "spacing") p.spacing = (int)entry.Value;
					if ((string)entry.Key == "frontside") p.frontside = (bool)entry.Value;
					if ((string)entry.Key == "singlesectors") p.singlesectors = (bool)entry.Value;
					if ((string)entry.Key == "singledirection") p.singledirection = (bool)entry.Value;
					if ((string)entry.Key == "removeredundantvertices") p.removeredundantvertices = (bool)entry.Value;
					if ((string)entry.Key == "distinctbaseheights") p.distinctbaseheights = (bool)entry.Value;
					if ((string)entry.Key == "flipping") p.flipping = (int)entry.Value;
					if ((string)entry.Key == "numberofcontrolpoints") p.numberofcontrolpoints = (int)entry.Value;
					if ((string)entry.Key == "applyfloormod") p.applyfloormod = (bool)entry.Value;
					if ((string)entry.Key == "floormod") p.floormod = (int)entry.Value;
					//if ((string)entry.Key == "floorbase") p.floorbase = (int)entry.Value;
					if ((string)entry.Key == "applyceilingmod") p.applyceilingmod = (bool)entry.Value;
					if ((string)entry.Key == "ceilingmod") p.ceilingmod = (int)entry.Value;
					//if ((string)entry.Key == "ceilingbase") p.ceilingbase = (int)entry.Value;
					if ((string)entry.Key == "applylightingmod") p.applylightingmod = (bool)entry.Value;
					if ((string)entry.Key == "lightingmod") p.lightingmod = (int)entry.Value;
					if ((string)entry.Key == "applyfloortexture") p.applyfloortexture = (bool)entry.Value;
					if ((string)entry.Key == "floortexture") p.floortexture = (string)entry.Value;
					if ((string)entry.Key == "applyceilingtexture") p.applyceilingtexture = (bool)entry.Value;
					if ((string)entry.Key == "ceilingtexture") p.ceilingtexture = (string)entry.Value;
					if ((string)entry.Key == "applyuppertexture") p.applyuppertexture = (bool)entry.Value;
					if ((string)entry.Key == "upperunpegged") p.upperunpegged = (bool)entry.Value;
					if ((string)entry.Key == "uppertexture") p.uppertexture = (string)entry.Value;
					if ((string)entry.Key == "applymiddletexture") p.applymiddletexture = (bool)entry.Value;
					if ((string)entry.Key == "middletexture") p.middletexture = (string)entry.Value;
					if ((string)entry.Key == "applylowertexture") p.applylowertexture = (bool)entry.Value;
					if ((string)entry.Key == "lowertexture") p.lowertexture = (string)entry.Value;
					if ((string)entry.Key == "lowerunpegged") p.lowerunpegged = (bool)entry.Value;
				}

				BuilderPlug.Me.Prefabs.Add(p);
			}
		}