Ejemplo n.º 1
0
 private void GLControl_DragDrop(object sender, DragEventArgs e)
 {
     if (_BlockEvents)
     {
         return;
     }
     if (e.Data != null)
     {
         object LVData = e.Data.GetData("System.Windows.Forms.ListView+SelectedListViewItemCollection");
         ListView.SelectedListViewItemCollection Collection = (ListView.SelectedListViewItemCollection)LVData;
         foreach (ListViewItem Item in Collection)
         {
             object[] Info = (object[])Item.Tag;
             if (Info[0].ToString() == "Asset")
             {
                 int         Index = (int)Info[1];
                 SceneObject New   = null;
                 if (_Interface.CurrentGame.Assets[Index].Type == SceneObjectType.DrawnSceneObject)
                 {
                     New = new DrawnSceneObject((DrawnSceneObject)_Interface.CurrentGame.Assets[Index], _Interface.CurrentScene);
                 }
                 else if (_Interface.CurrentGame.Assets[Index].Type == SceneObjectType.ScriptSceneObject)
                 {
                     New = new ScriptSceneObject((ScriptSceneObject)_Interface.CurrentGame.Assets[Index], _Interface.CurrentScene);
                 }
                 if (New != null)
                 {
                     _Interface.CurrentScene.Objects.Add(New);
                     _Interface.ForceUpdate(InterfaceUpdateMessage.SceneObjectsUpdated);
                 }
                 else
                 {
                     MessageBox.Show("File type not supported for this scene type", "Not Supported");
                 }
             }
             if (Info[0].ToString() == "Library")
             {
                 string      Path = (string)Info[1];
                 SceneObject New  = SceneObject.FromFile(Path, _Interface.CurrentScene);
                 if (New != null)
                 {
                     _Interface.CurrentScene.Objects.Add(New);
                     _Interface.ForceUpdate(InterfaceUpdateMessage.SceneObjectsUpdated);
                 }
                 else
                 {
                     MessageBox.Show("File type not supported for this scene type", "Not Supported");
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        public GameLogic()
        {
            ResourceManager _ResMan = new ResourceManager();

            _ResMan.Init();
            this._EFX                = new EFXInterface();
            this._Game               = new Game();
            this._Runner             = new ExternRunner(1024, 600, new GraphicsMode(32, 24, 0, 8), "Death de sombre!");
            this._Runner.WindowState = OpenTK.WindowState.Normal;
            Engineer.Engine.Settings.GraphicsQuality = Quality.High;
            this._Current = new Scene2D("Test");
            this._Game.Scenes.Add(this._Current);
            DrawnSceneObject Dragon = (DrawnSceneObject)this._EFX.Load("Data/Dragon.efx");

            this._Current.AddSceneObject(Dragon);
        }
Ejemplo n.º 3
0
 private void createToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (_BlockEvents)
     {
         return;
     }
     if (_Interface.CurrentSceneObject != null)
     {
         string Path = "Library\\Objects\\" + _Interface.CurrentSceneObject.Name + ".sco";
         if (File.Exists(Path))
         {
             Path = "Library\\Objects\\" + _Interface.CurrentSceneObject.Name + Guid.NewGuid().ToString() + ".sco";
         }
         try
         {
             if (_Interface.CurrentSceneObject.Type == SceneObjectType.DrawnSceneObject)
             {
                 DrawnSceneObject.Serialize((DrawnSceneObject)_Interface.CurrentSceneObject, Path);
             }
             else if (_Interface.CurrentSceneObject.Type == SceneObjectType.ScriptSceneObject)
             {
                 ScriptSceneObject.Serialize((ScriptSceneObject)_Interface.CurrentSceneObject, Path);
             }
         }
         catch (Exception ex)
         {
             if (ex.InnerException != null)
             {
                 MessageBox.Show(ex.InnerException.ToString(), ex.Message);
             }
             else
             {
                 MessageBox.Show(ex.Message, "Error");
             }
         }
     }
     else
     {
         MessageBox.Show("No SceneObject Selected", " Warning");
     }
 }
Ejemplo n.º 4
0
 private void addCurrentItemToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (_BlockEvents)
     {
         return;
     }
     if (_Interface.CurrentSceneObject != null)
     {
         SceneObject NewAsset = null;
         if (_Interface.CurrentSceneObject.Type == SceneObjectType.DrawnSceneObject)
         {
             NewAsset = new DrawnSceneObject((DrawnSceneObject)_Interface.CurrentSceneObject, null);
         }
         else if (_Interface.CurrentSceneObject.Type == SceneObjectType.ScriptSceneObject)
         {
             NewAsset = new ScriptSceneObject((ScriptSceneObject)_Interface.CurrentSceneObject, null);
         }
         _Interface.AddAsset(NewAsset);
     }
     else
     {
         MessageBox.Show("No SceneObject Selected", " Warning");
     }
 }
Ejemplo n.º 5
0
        protected override object LoadObject(string DirPath, Type FileType)
        {
            if (FileType == null)
            {
                object[] Config         = ReadConfig(DirPath + "data.conf");
                string   FileTypeString = Config[1] as string;
                Assembly ASM            = typeof(Game).Assembly;
                FileType = ASM.GetType(FileTypeString);
            }
            XmlSerializer Deserializer  = new XmlSerializer(FileType);
            TextReader    Reader        = new StreamReader(DirPath + "data.xml");
            object        CurrentObject = Deserializer.Deserialize(Reader);

            Reader.Close();
            List <string> Files       = new List <string>(Directory.EnumerateFiles(DirPath));
            List <string> Directories = new List <string>(Directory.EnumerateDirectories(DirPath));

            if (FileType == typeof(Actor))
            {
                Actor Current = CurrentObject as Actor;
                for (int i = 0; Files.Contains(DirPath + "Geometries_" + i + ".obj"); i++)
                {
                    OBJContainer OBJ = new OBJContainer();
                    OBJ.Load(DirPath + "Geometries_" + i + ".obj", null);
                    for (int j = 0; j < OBJ.Geometries.Count; j++)
                    {
                        Current.Geometries.Add(OBJ.Geometries[j]);
                    }
                }
            }
            if (FileType == typeof(SpriteSet))
            {
                SpriteSet Current = CurrentObject as SpriteSet;
                for (int i = 0; Files.Contains(DirPath + "Sprite_" + i + ".png"); i++)
                {
                    Bitmap SpriteImage = null;
                    using (Image Img = Image.FromFile(DirPath + "Sprite_" + i + ".png"))
                    {
                        SpriteImage = new Bitmap(Img);
                    }
                    Current.Sprite.Add(SpriteImage);
                }
            }
            if (FileType == typeof(Sprite))
            {
                Sprite Current = CurrentObject as Sprite;
                for (int i = 0; Directories.Contains(DirPath + "SpriteSets_" + i); i++)
                {
                    SpriteSet Child = (SpriteSet)LoadObject(DirPath + "SpriteSets_" + i + "/", typeof(SpriteSet));
                    Current.SpriteSets.Add(Child);
                }
                for (int i = 0; Directories.Contains(DirPath + "SubSprites_" + i); i++)
                {
                    Sprite Child = (Sprite)LoadObject(DirPath + "SubSprites_" + i + "/", typeof(Sprite));
                    Current.SubSprites.Add(Child);
                }
            }
            if (FileType == typeof(DrawnSceneObject))
            {
                DrawnSceneObject Current = CurrentObject as DrawnSceneObject;
                Current.Visual = (DrawObject)LoadObject(DirPath + "Visual/", null);
            }
            if (FileType == typeof(Scene2D) || FileType == typeof(Scene3D))
            {
                Scene Current = CurrentObject as Scene;
                for (int i = 0; Directories.Contains(DirPath + "Objects_" + i); i++)
                {
                    SceneObject Child = (SceneObject)LoadObject(DirPath + "Objects_" + i + "/", null);
                    Current.Objects.Add(Child);
                }
            }
            if (FileType == typeof(Game))
            {
                Game Current = CurrentObject as Game;
                for (int i = 0; Directories.Contains(DirPath + "Scenes_" + i); i++)
                {
                    Scene Child = (Scene)LoadObject(DirPath + "Scenes_" + i + "/", null);
                    Current.Scenes.Add(Child);
                }
            }
            return(CurrentObject);
        }
Ejemplo n.º 6
0
        protected override void SaveObject(object ObjectToSave, string FilePath, bool Head)
        {
            string        FileName   = Path.GetFileNameWithoutExtension(FilePath);
            string        DirPath    = FilePath.Replace(Path.GetFileName(FilePath), "");
            XmlSerializer Serializer = new XmlSerializer(ObjectToSave.GetType());

            DirPath = DirPath + FileName + "/";
            Directory.CreateDirectory(DirPath);
            if (Head)
            {
                WriteConfig(ObjectToSave.GetType(), DirPath + "data.conf");
            }
            using (TextWriter Writer = new StreamWriter(DirPath + "data.xml"))
            {
                Serializer.Serialize(Writer, ObjectToSave);
            }
            if (ObjectToSave.GetType() == typeof(Actor))
            {
                Actor Current = ObjectToSave as Actor;
                for (int i = 0; i < Current.Geometries.Count; i++)
                {
                    OBJContainer OBJ = new OBJContainer();
                    OBJ.Geometries.Add(Current.Geometries[i]);
                    OBJ.Save(DirPath + "Geometries_" + i + ".obj", null);
                }
            }
            if (ObjectToSave.GetType() == typeof(SpriteSet))
            {
                SpriteSet Current = ObjectToSave as SpriteSet;
                for (int i = 0; i < Current.Sprite.Count; i++)
                {
                    Current.Sprite[i].Save(DirPath + "Sprite_" + i + ".png", System.Drawing.Imaging.ImageFormat.Png);
                }
            }
            if (ObjectToSave.GetType() == typeof(Sprite))
            {
                Sprite Current = ObjectToSave as Sprite;
                for (int i = 0; i < Current.SpriteSets.Count; i++)
                {
                    SaveObject(Current.SpriteSets[i], DirPath + "SpriteSets_" + i + ".efx", false);
                }
                for (int i = 0; i < Current.SubSprites.Count; i++)
                {
                    SaveObject(Current.SubSprites[i], DirPath + "SubSprites_" + i + ".efx", false);
                }
            }
            if (ObjectToSave.GetType() == typeof(DrawnSceneObject))
            {
                DrawnSceneObject Current = ObjectToSave as DrawnSceneObject;
                SaveObject(Current.Visual, DirPath + "Visual.efx", true);
            }
            if (ObjectToSave.GetType() == typeof(Scene2D) || ObjectToSave.GetType() == typeof(Scene3D))
            {
                Scene Current = ObjectToSave as Scene;
                for (int i = 0; i < Current.Objects.Count; i++)
                {
                    SaveObject(Current.Objects[i], DirPath + "Objects_" + i + ".efx", true);
                }
            }
            if (ObjectToSave.GetType() == typeof(Game))
            {
                Game Current = ObjectToSave as Game;
                for (int i = 0; i < Current.Scenes.Count; i++)
                {
                    SaveObject(Current.Scenes[i], DirPath + "Scenes_" + i + ".efx", true);
                }
            }
        }
Ejemplo n.º 7
0
 //Events
 private void Tree_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (_BlockEvents)
     {
         return;
     }
     if (this._View == LibraryViewType.Library)
     {
         FileList.Items.Clear();
         string        FileRoot = e.Node.Tag as string;
         List <string> Files    = new List <string>();
         Files = GetFiles(Files, FileRoot);
         for (int i = 0; i < Files.Count; i++)
         {
             ListViewItem NewItem = new ListViewItem(Path.GetFileName(Files[i]), FindImageIndex(Files[i]));
             NewItem.Tag = new object[2] {
                 "Library", Files[i]
             };
             FileList.Items.Add(NewItem);
         }
     }
     else if (this._View == LibraryViewType.Assets)
     {
         FileList.Items.Clear();
         int Index = Convert.ToInt32(Tree.SelectedNode.Tag);
         for (int i = 0; i < _Interface.CurrentGame.Assets.Count; i++)
         {
             if (_Interface.CurrentGame.Assets[i].Type == SceneObjectType.DrawnSceneObject && (Index == -1 || Index == 0 || Index < 6))
             {
                 DrawnSceneObject DSO = (DrawnSceneObject)_Interface.CurrentGame.Assets[i];
                 if (DSO.Visual.Type == DrawObjectType.Actor && (Index == -1 || Index == 0))
                 {
                     ListViewItem NewListViewItem = new ListViewItem(_Interface.CurrentGame.Assets[i].Name, 0);
                     NewListViewItem.Tag = new object[] { "Asset", i };
                     FileList.Items.Add(NewListViewItem);
                 }
                 else if (DSO.Visual.Type == DrawObjectType.Camera && (Index == -1 || Index == 1))
                 {
                     ListViewItem NewListViewItem = new ListViewItem(_Interface.CurrentGame.Assets[i].Name, 1);
                     NewListViewItem.Tag = new object[] { "Asset", i };
                     FileList.Items.Add(NewListViewItem);
                 }
                 else if (DSO.Visual.Type == DrawObjectType.Light && (Index == -1 || Index == 2))
                 {
                     ListViewItem NewListViewItem = new ListViewItem(_Interface.CurrentGame.Assets[i].Name, 2);
                     NewListViewItem.Tag = new object[] { "Asset", i };
                     FileList.Items.Add(NewListViewItem);
                 }
                 else if (DSO.Visual.Type == DrawObjectType.Background && (Index == -1 || Index == 3))
                 {
                     ListViewItem NewListViewItem = new ListViewItem(_Interface.CurrentGame.Assets[i].Name, 3);
                     NewListViewItem.Tag = new object[] { "Asset", i };
                     FileList.Items.Add(NewListViewItem);
                 }
                 else if (DSO.Visual.Type == DrawObjectType.Sprite && (Index == -1 || Index == 4))
                 {
                     ListViewItem NewListViewItem = new ListViewItem(_Interface.CurrentGame.Assets[i].Name, 4);
                     NewListViewItem.Tag = new object[] { "Asset", i };
                     FileList.Items.Add(NewListViewItem);
                 }
                 else if (DSO.Visual.Type == DrawObjectType.Figure && (Index == -1 || Index == 5))
                 {
                     ListViewItem NewListViewItem = new ListViewItem(_Interface.CurrentGame.Assets[i].Name, 5);
                     NewListViewItem.Tag = new object[] { "Asset", i };
                     FileList.Items.Add(NewListViewItem);
                 }
             }
             else if (_Interface.CurrentGame.Assets[i].Type == SceneObjectType.ScriptSceneObject && (Index == -1 || Index == 6))
             {
                 ListViewItem NewListViewItem = new ListViewItem(_Interface.CurrentGame.Assets[i].Name, 6);
                 NewListViewItem.Tag = new object[] { "Asset", i };
                 FileList.Items.Add(NewListViewItem);
             }
             else if (_Interface.CurrentGame.Assets[i].Type == SceneObjectType.SoundSceneObject && (Index == -1 || Index == 7))
             {
                 ListViewItem NewListViewItem = new ListViewItem(_Interface.CurrentGame.Assets[i].Name, 7);
                 NewListViewItem.Tag = new object[] { "Asset", i };
                 FileList.Items.Add(NewListViewItem);
             }
         }
     }
 }
Ejemplo n.º 8
0
 private void InitAssets()
 {
     if (this._Options == null)
     {
         this._Options = new List <Button>();
     }
     this.ContentPanel.Controls.Clear();
     this.ContentPanel.Controls.Add(this.FilterPanel);
     this._Options.Clear();
     for (int i = 0; i < this._Interface.Library.Groups[this._SelectedFilter].Objects.Count; i++)
     {
         Button Option = new Button();
         Option.Name      = "Option_" + i;
         Option.Text      = this._Interface.Library.Groups[this._SelectedFilter].Objects[i].Name;
         Option.TextAlign = ContentAlignment.MiddleLeft;
         Option.Padding   = new Padding(50, 0, 0, 0);
         Option.FlatStyle = FlatStyle.Flat;
         Option.Tag       = i;
         Option.Dock      = DockStyle.Top;
         Option.Size      = new Size(100, 50);
         Option.ForeColor = Color.White;
         Option.BackColor = Color.FromArgb(30, 30, 30);
         Option.FlatAppearance.BorderSize = 0;
         Option.BackgroundImageLayout     = ImageLayout.None;
         if (this._Interface.Library.Groups[this._SelectedFilter].Objects[i].Type == SceneObjectType.SoundSceneObject)
         {
             Option.BackgroundImage = global::Engineer.Editor.Properties.Resources.G12_Music_icon;
         }
         else if (this._Interface.Library.Groups[this._SelectedFilter].Objects[i].Type == SceneObjectType.ScriptSceneObject)
         {
             Option.BackgroundImage = global::Engineer.Editor.Properties.Resources.G12_Clock_icon;
         }
         else if (this._Interface.Library.Groups[this._SelectedFilter].Objects[i].Type == SceneObjectType.DrawnSceneObject)
         {
             DrawnSceneObject DSO = this._Interface.Library.Groups[this._SelectedFilter].Objects[i] as DrawnSceneObject;
             if (DSO.Visual.Type == DrawObjectType.Tile)
             {
                 Option.BackgroundImage = global::Engineer.Editor.Properties.Resources.G12_Flower_Lotus_icon;
             }
             else if (DSO.Visual.Type == DrawObjectType.Sprite)
             {
                 Option.BackgroundImage = global::Engineer.Editor.Properties.Resources.G12_Photos_2_icon;
             }
             else if (DSO.Visual.Type == DrawObjectType.Figure)
             {
                 Option.BackgroundImage = global::Engineer.Editor.Properties.Resources.G12_Turtle_icon;
             }
             else if (DSO.Visual.Type == DrawObjectType.Actor)
             {
                 Option.BackgroundImage = global::Engineer.Editor.Properties.Resources.G12_3D_icon;
             }
             else
             {
                 Option.BackgroundImage = global::Engineer.Editor.Properties.Resources.G12_Document_icon;
             }
         }
         Option.MouseEnter += new EventHandler(this.MouseEnterOption);
         Option.MouseLeave += new EventHandler(this.MouseLeaveOption);
         Option.Click      += new EventHandler(this.MouseClickOption);
         ContentPanel.Controls.Add(Option);
         this._Options.Add(Option);
         Option.BringToFront();
     }
 }