protected override void LoadContent() { //Nacteni pisma spriteFont = Content.Load<SpriteFont>(@"Fonts\startFont"); //Vytvoreni menu menu = new MenuComponent(spriteFont, menuItems, true); //Nastaveni pozice Vector2 menuPosition = new Vector2( (Game.Window.ClientBounds.Width - menu.Width) / 2, (Game.Window.ClientBounds.Height - menu.Height) / 2); menu.SetPostion(menuPosition); //Vytvoreni pozadi background = new BackgroundComponent(GameRef, Content.Load<Texture2D>(@"Backgrounds\startscreen"), DrawMode.Center); base.LoadContent(); }
protected override void LoadContent() { ram = new Rectangle(770, 250, 220, 220); //Nacteni fontu, ramecku pro tileset a pozadi font = Content.Load<SpriteFont>(@"Fonts\editorFont"); ramTexture = Content.Load<Texture2D>(@"Pictures\ram"); background = new BackgroundComponent(GameRef, Content.Load<Texture2D>(@"Backgrounds\editorscreen"), DrawMode.Center); #region ovladaci prvky spriteFont = Content.Load<SpriteFont>(@"Fonts\menuFont"); string[] LayermenuItems = { "Back Map", "Back Splatter", "Front Map", "Front Splatter" }; LayerMenu = new MenuComponent(font, LayermenuItems, false); LayerMenu.SetPostion(new Vector2(770, 30)); LayerMenu.SelectedColor = Color.Yellow; LayerMenu.HiliteColor = Color.White; spriteFont = Content.Load<SpriteFont>(@"Fonts\menuFont"); string[] ActionmenuItems = { "Add", "Move", "Pick", "Delete" }; ActionMenu = new MenuComponent(font, ActionmenuItems, false); ActionMenu.SetPostion(new Vector2(900, 30)); ActionMenu.SelectedColor = Color.Yellow; ActionMenu.HiliteColor = Color.White; spriteFont = Content.Load<SpriteFont>(@"Fonts\menuFont"); LinkLabel linkLabel1 = new LinkLabel(spriteFont); linkLabel1.Text = "Save"; linkLabel1.Size = linkLabel1.SpriteFont.MeasureString(linkLabel1.Text); linkLabel1.Position = new Vector2(770,720); linkLabel1.Selected += new EventHandler(linkLabel1_Selected); Controls.Add(linkLabel1); LinkLabel linkLabel2 = new LinkLabel(spriteFont); linkLabel2.Text = "Load"; linkLabel2.Size = linkLabel2.SpriteFont.MeasureString(linkLabel2.Text); linkLabel2.Position = new Vector2(940,720); linkLabel2.Selected += new EventHandler(linkLabel2_Selected); Controls.Add(linkLabel2); Controls.editor = true; label1 = new Label(spriteFont); label1.Position = new Vector2(845, 720); label1.Visible = false; Controls.Add(label1); Session.LoadMapAndTextures("map.xml"); string[] CharacterStrings = new string[Session.baseUnits.Keys.Count]; Session.baseUnits.Keys.CopyTo(CharacterStrings, 0); CharacterMenu = new MenuComponent(font, CharacterStrings, false); CharacterMenu.SetPostion(new Vector2(770, 200)); CharacterMenu.SelectedColor = Color.Yellow; CharacterMenu.HiliteColor = Color.White; int[] KeyInts = new int[Session.baseKeys.Keys.Count]; Session.baseKeys.Keys.CopyTo(KeyInts, 0); string[] KeyStrings = new string[Session.baseKeys.Keys.Count]; for (int i = 0; i < KeyInts.Length; i++) { KeyStrings[i] = KeyInts[i].ToString(); } KeyMenu = new MenuComponent(font, KeyStrings, false); KeyMenu.SetPostion(new Vector2(770, 200)); KeyMenu.SelectedColor = Color.Yellow; KeyMenu.HiliteColor = Color.White; string[] TileSetmenuItems = new string[Session.FrontMap.tilesets.Count + 2]; for (int i = 0; i < Session.FrontMap.tilesets.Count; i++) { TileSetmenuItems[i] = Session.FrontMap.tilesets[i].Texture.Name; //files[i].Name.Substring(0, files[i].Name.Length - 4); } TileSetmenuItems[TileSetmenuItems.Length - 2] = "Characters"; TileSetmenuItems[TileSetmenuItems.Length - 1] = "Keys"; TileSetMenu = new MenuComponent(font, TileSetmenuItems, false); TileSetMenu.SetPostion(new Vector2(770, 100)); TileSetMenu.SelectedColor = Color.Yellow; TileSetMenu.HiliteColor = Color.White; #endregion //Nastaveni prvniho itemu u LayerMenu switch (LayerMenu.clickedIndex) { case 0: CurrentMap = Session.BackMap; CurrentLayer = Session.BackMap.mapLayers[0]; break; case 1: CurrentMap = Session.BackMap; CurrentLayer = Session.BackMap.mapLayers[1]; break; case 2: CurrentMap = Session.FrontMap; CurrentLayer = Session.FrontMap.mapLayers[0]; break; case 3: CurrentMap = Session.FrontMap; CurrentLayer = Session.FrontMap.mapLayers[1]; break; } //Nastaveni bazoveho policka pro akce CurrentTile = new Tile(0, 0, -1, -1); CurrentTileSet = Session.FrontMap.tilesets[CurrentTile.Tileset]; //Nacteni vstupnich ramecku pro obraz TileSetu int tiles = CurrentTileSet.TilesWide * CurrentTileSet.TilesHigh; sourceRectangles = new Rectangle[tiles]; float Scale = (float)ram.Width / (float)Session.FrontMap.tilesets[CurrentTile.Tileset].Texture.Width; int tile = 0; for (int y = 0; y < CurrentTileSet.TilesHigh; y++) for (int x = 0; x < CurrentTileSet.TilesWide; x++) { sourceRectangles[tile] = new Rectangle( (int)(x * CurrentTileSet.TileWidth * Scale), (int)(y * CurrentTileSet.TileWidth * Scale), (int)(CurrentTileSet.TileWidth * Scale), (int)(CurrentTileSet.TileHeight * Scale)); tile++; } base.LoadContent(); }