public void CreateNewLevel( ) { if (Level != null) { if (OnBeforeUnloadingModel != null) { var args = new ModelUnloadingEventArgs(Level); OnBeforeUnloadingModel(this, args); if (args.Cancelled) { return; } } } var newLevel = new LevelEditor(); LoadLevel(newLevel); if (NewModelLoaded != null) { NewModelLoaded(this, EventArgs.Empty); } }
void drawFramesAroundSelectedEditors(RendererParams rendererParams) { LevelEditor level = IoC.Model.Level; IEnumerable <ItemEditor> selectedEditors = level.SelectedEditors.ToList( ); if (selectedEditors.Any( )) { Vector2 maincameraposition = rendererParams.Camera.Position; rendererParams.Camera.Position *= selectedEditors.First( ).ParentLayer.ScrollSpeed; _game.SpriteBatch.Begin( SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, rendererParams.Camera.Matrix); bool first = true; foreach (ItemEditor item in selectedEditors) { if (item.ItemProperties.Visible && item.ParentLayer.Visible && KeyboardStatus.IsKeyUp(Keys.Space)) { Color color = first ? Constants.Instance.ColorSelectionFirst : Constants.Instance.ColorSelectionRest; item.DrawSelectionFrame(_game.SpriteBatch, color); bool rotatingOrScaling = rendererParams.UserActionInEditor == UserActionInEditor.RotatingItems || rendererParams.UserActionInEditor == UserActionInEditor.ScalingItems; if (first && rotatingOrScaling) { //Vector2 center = Vector2.Transform( item.ItemProperties.Position, rendererParams.Camera.Matrix ) ; //Vector2 mouse = Vector2.Transform( MouseStatus.WorldPosition, rendererParams.Camera.Matrix ) ; //todo move the line drawing into each shape and remove the matrix parameter when drawing the frame //_drawing.DrawLine( _game.SpriteBatch, item.ItemProperties.Position, MouseStatus.WorldPosition, Constants.Instance.ColorSelectionFirst, 1 ) ; } } first = false; } _game.SpriteBatch.End( ); //restore main camera position rendererParams.Camera.Position = maincameraposition; } }
public static LayerEditor FromXml(LevelEditor level, XElement xml) { var layerProperties = xml.CertainElement(@"LayerProperties").DeserializedAs <LayerProperties>( ); var layer = new LayerEditor(level, xml.CertainAttribute(@"Name").Value) { _properties = layerProperties, _behaviours = new BehaviourCollection(layerProperties, xml) }; layer.Items = new List <ItemEditor>( xml.CertainElement(@"Editors").Elements(@"Editor").Select(x => createEditor(layer, x))); return(layer); }
public LayerEditor(LevelEditor parentLevel, string name) { _properties = new LayerProperties { Name = name, CustomProperties = new CustomProperties( ), Visible = true, ScrollSpeed = Vector2.One }; ParentLevel = parentLevel; Items = new List <ItemEditor>(); _behaviours = new BehaviourCollection( ); }
void populateEditorRelatedStuff(LevelEditor level, XElement xml) { var assemblyInformation = ObjectFactory.GetInstance <IGetAssemblyInformation>( ); XElement ourElement = xml.CertainElement(@"EditorRelated"); XElement cameraPositionElement = ourElement.CertainElement(@"CameraPosition"); var legacyEditorInfo = new LegacyEditorInfo { NextItemNumber = (int)ourElement.CertainElement(@"NextItemNumber"), ContentRootFolder = (string)ourElement.CertainElement(@"ContentRootFolder"), CameraPosition = new Vector2( (float)cameraPositionElement.CertainElement(@"X"), (float)cameraPositionElement.CertainElement(@"Y")), Version = assemblyInformation.Version }; level.SetLegacyEditorInfo(legacyEditorInfo); }
ConvertOldFileFormats( string path ) { LegacyLevel oldLevel=LegacyLevel.FromFile( path ) ; XElement d = XElement.Load( path ) ; var level = new LevelEditor { Name = oldLevel.Name, } ; populateEditorRelatedStuff( level, d ) ; convertCustomProperties( oldLevel.CustomProperties, level.CustomProperties ) ; level.Layers.AddRange( oldLevel.Layers.Select( copyLayer ) ) ; _path = Path.GetTempFileName( ) ; level.SaveAsXmlToDisk( _path ); }
ConvertOldFileFormats(string path) { LegacyLevel oldLevel = LegacyLevel.FromFile(path); XElement d = XElement.Load(path); var level = new LevelEditor { Name = oldLevel.Name, }; populateEditorRelatedStuff(level, d); convertCustomProperties(oldLevel.CustomProperties, level.CustomProperties); level.Layers.AddRange( oldLevel.Layers.Select(copyLayer)); _path = Path.GetTempFileName( ); level.SaveAsXmlToDisk(_path); }
public void LoadLevel(LevelEditor level) { if (!ObjectFactory.GetInstance <IDisk>().FolderExists(level.ContentRootFolder)) { MessageBox.Show( @"The directory '{0}' doesn't exist! Please adjust the XML file before trying again.".FormatWith(level.ContentRootFolder)); return; } Level = level; if (NewModelLoaded != null) { NewModelLoaded(this, EventArgs.Empty); } if (Level.Layers.Count > 0) { setActiveLayerIfItsDifferent(Level.Layers[0]); } _memento.Clear( ); }
void populateEditorRelatedStuff( LevelEditor level, XElement xml ) { var assemblyInformation = ObjectFactory.GetInstance<IGetAssemblyInformation>( ) ; XElement ourElement = xml.CertainElement( @"EditorRelated" ) ; XElement cameraPositionElement = ourElement.CertainElement( @"CameraPosition" ) ; var legacyEditorInfo = new LegacyEditorInfo { NextItemNumber = (int) ourElement.CertainElement( @"NextItemNumber" ), ContentRootFolder = (string) ourElement.CertainElement( @"ContentRootFolder" ), CameraPosition = new Vector2( (float) cameraPositionElement.CertainElement( @"X" ), (float) cameraPositionElement.CertainElement( @"Y" ) ), Version = assemblyInformation.Version } ; level.SetLegacyEditorInfo( legacyEditorInfo ) ; }
void loadLevel(string filename) { var level = new LevelEditor( XElement.Load( filename ) ); _model.LoadLevel(level); _levelFilename = filename; setDirtyFlag( false ); }
public void DeserialiseLevel(XElement xml) { ObjectFactory.GetInstance <IModelEventHub>().ClearAllSubscribers(); Level = new LevelEditor(xml); }
public ModelUnloadingEventArgs( LevelEditor level ) { Level = level ; }
public ModelUnloadingEventArgs(LevelEditor level) { Level = level; }
public void LoadLevel( LevelEditor level ) { if( !ObjectFactory.GetInstance<IDisk>().FolderExists(level.ContentRootFolder) ) { MessageBox.Show( @"The directory '{0}' doesn't exist! Please adjust the XML file before trying again.".FormatWith(level.ContentRootFolder) ) ; return ; } Level = level ; if( NewModelLoaded != null ) { NewModelLoaded( this, EventArgs.Empty ) ; } if( Level.Layers.Count > 0 ) { setActiveLayerIfItsDifferent( Level.Layers[ 0 ] ) ; } _memento.Clear( ) ; }
public void DeserialiseLevel(XElement xml) { ObjectFactory.GetInstance<IModelEventHub>().ClearAllSubscribers(); Level = new LevelEditor(xml); }
public void CreateNewLevel( ) { if( Level != null ) { if( OnBeforeUnloadingModel != null ) { var args = new ModelUnloadingEventArgs( Level ) ; OnBeforeUnloadingModel( this, args ) ; if( args.Cancelled ) { return ; } } } var newLevel = new LevelEditor(); LoadLevel( newLevel ) ; if( NewModelLoaded != null ) { NewModelLoaded( this, EventArgs.Empty ) ; } }