public UIFilteredConstructorList( int width, int height, Vector2 position, UIActionListener listener ) : base(width, height, position) { player = Main.MainObject.GameManager.GameState.Player; inventarList = new UIList(260, height-40, new Vector2(0, 40), listener); Dictionary<int, int> tempDict = new Dictionary<int, int>(); foreach (KeyValuePair<int, int> keyValuePair in player.Inventar) { if (Item.Get(keyValuePair.Key).GetType() != typeof(Munition) && Item.Get(keyValuePair.Key).GetType() != typeof(Powerup)) { tempDict[keyValuePair.Key] = keyValuePair.Value; } } var inventarTitel = new UIButton(250, 40, new Vector2(0,0), "Inventar"); var filterTitel = new UIButton(120, 40, new Vector2(280, 0), "Filter") { BackgroundColor = Color.LightGray }; Add(inventarTitel); Add(inventarList); Add(filterTitel); inventarList.SetItems(tempDict); CreateCheckBoxPanel(); }
public UIList( int width, int height, Vector2 position, UIActionListener listener ) : base(width, height, position) { itemList = new Dictionary<int, int>(); buttonList = new List<UIElement>(); countItemsDict = new Dictionary<int, int>(); unscaledWidth = width; unscaledHeight = height; unscaledPos = position; var imgPreviousButton = Main.ContentManager.Load<Texture2D>( "images/gui/inventar/list_previous" ); var imgPreviousButtonHover = Main.ContentManager.Load<Texture2D>( "images/gui/inventar/list_previous_h" ); var imgNextButton = Main.ContentManager.Load<Texture2D>( "images/gui/inventar/list_next" ); var imgNextButtonHover = Main.ContentManager.Load<Texture2D>( "images/gui/inventar/list_next_h" ); btnPrevious = new UIButton(unscaledWidth, imgPreviousButton.Height, new Vector2(0, 0), imgPreviousButton, imgPreviousButtonHover, ""); btnNext = new UIButton(unscaledWidth, imgNextButton.Height, new Vector2(0, height - imgNextButton.Height), imgNextButton, imgNextButtonHover, ""); this.listener = listener; int listHeight = height - imgNextButton.Height*2; MAX_VISIBLE_BUTTON_COUNT = (listHeight - listHeight % DEFAULT_HEIGHT) / DEFAULT_HEIGHT; player = Main.MainObject.GameManager.GameState.Player; btnPrevious.AddActionListener( this ); btnNext.AddActionListener( this ); }
private void GenerateUiComponents() { var shortCutTitel = new UIButton( 240, 40, new Vector2( 20, 20 ), "Shortcuts" ) { BackgroundColor = Color.LightGray }; var inventarTitel = new UIButton( 250, 40, new Vector2( 340, 20 ), "Inventar" ) { BackgroundColor = Color.LightGray }; var filterTitel = new UIButton( 120, 40, new Vector2( 620, 20 ), "Filter" ) { BackgroundColor = Color.LightGray }; var ok = Main.ContentManager.Load<Texture2D>( "images/gui/inventar/btn_ok" ); var ok_h = Main.ContentManager.Load<Texture2D>( "images/gui/inventar/btn_ok_h" ); var cancel = Main.ContentManager.Load<Texture2D>( "images/gui/inventar/btn_cancel" ); var cancel_h = Main.ContentManager.Load<Texture2D>( "images/gui/inventar/btn_cancel_h" ); filteredInventarList = new UIFilteredInventarList( 260, height-20, new Vector2( 340, 60 ), this ); Add( filteredInventarList ); btnOk = new UIButton( new Vector2( 300, 306 ), ok, ok_h ); btnCancel = new UIButton( new Vector2( 350, 306 ), cancel, cancel_h ); btnOk.IsEnabled = false; btnCancel.IsEnabled = false; btnOk.AddActionListener( this ); btnCancel.AddActionListener( this ); Add( shortCutTitel ); Add( inventarTitel ); Add( filterTitel ); Add( btnOk ); Add( btnCancel ); }
// *************************************************************************** // Initialisierung von Variable, Laden der Texturen etc. private void LoadMenu() { Debug.WriteLine("Benötigter Content für Menu laden."); // Highscore Laden HighscoreHelper.LoadHighscore(); ContentManager content = Main.ContentManager; // Initialisierung UI.MouseCursor.CurrentCursor = UI.MouseCursor.DefaultCursor; drawSub = DrawIntro; updateSub = UpdateIntro; hdmPosition = new Rectangle(); textPosition = new Vector2(); text = "PROJEKT SS 2012 - MEDIENINFORMATIK "; LoadingText = ""; // Läd Texturen die bnötigt werden background = content.Load<Texture2D>("images/menu/background"); pixelWhite = content.Load<Texture2D>("images/pixelWhite"); hdmLogo = content.Load<Texture2D>("images/hdm_transparent"); Texture2D imgStart = content.Load<Texture2D>("images/menu/start"); Texture2D imgStartHover = content.Load<Texture2D>("images/menu/startH"); Texture2D imgExit = content.Load<Texture2D>("images/menu/exit"); Texture2D imgExitHover = content.Load<Texture2D>("images/menu/exitH"); Texture2D imgCredits = content.Load<Texture2D>("images/menu/credits"); Texture2D imgCreditsHover = content.Load<Texture2D>("images/menu/creditsH"); Texture2D imgOptions = content.Load<Texture2D>("images/menu/options"); Texture2D imgOptionsHover = content.Load<Texture2D>("images/menu/optionsH"); // Fonts laden fontDefault = content.Load<SpriteFont>("fonts/defaultMedium"); fontArialSmall = content.Load<SpriteFont>("fonts/arialSmall"); // Menü erzeugen menuPanel = new UIPanel(0, 0, new Vector2(0, 0)); btnStart = new UIButton(new Vector2(99, 152), imgStart, imgStartHover); btnExit = new UIButton(new Vector2(849, 490), imgExit, imgExitHover); btnCredits = new UIButton(new Vector2(0, 507), imgCredits, imgCreditsHover); btnHighscore = new UIButton(new Vector2(337, 209), imgOptions, imgOptionsHover); btnStart.AddActionListener(this); btnExit.AddActionListener(this); btnCredits.AddActionListener(this); btnHighscore.AddActionListener(this); menuPanel.Add(btnStart); menuPanel.Add(btnExit); menuPanel.Add(btnCredits); menuPanel.Add(btnHighscore); }
private void InitComponents() { var shortCutTitel = new UIButton(initWidth, 40, new Vector2(0, 0), "Konstruktor"); weaponPanel = new UIWeaponPanel(100, new Vector2(0, 40)); nameButton = new UIButton(initWidth, 30, new Vector2(0, 140), "Name der Waffe"); antriebButton = new UIButton(DEFAULT_HEIGHT, DEFAULT_HEIGHT, new Vector2(0, 180), ""); stabilisatorButton = new UIButton(DEFAULT_HEIGHT, DEFAULT_HEIGHT, new Vector2(0, 230), ""); visierButton = new UIButton(DEFAULT_HEIGHT, DEFAULT_HEIGHT, new Vector2(0, 280), ""); demageButton = new UIButton(120, DEFAULT_HEIGHT, new Vector2(50, 180), "Schaden : 5"); rateOfFireButton = new UIButton(120, DEFAULT_HEIGHT, new Vector2(50, 230), "Feuerate : 10"); accuracyButton = new UIButton(120, DEFAULT_HEIGHT, new Vector2(50, 280), "Genauigkeit : 13"); player.Liquids = new Vector3(14, 11, 22); bar1 = new UIVerticalProgressBar(40, 140, new Vector2(175, 180), 100, player.Liquids.X) {BackgroundColor = Color.Blue}; bar2 = new UIVerticalProgressBar(40, 140, new Vector2(215, 180), 100, player.Liquids.Y) {BackgroundColor = Color.Green}; bar3 = new UIVerticalProgressBar(40, 140, new Vector2(255, 180), 100, player.Liquids.Z) {BackgroundColor = Color.Red}; var okButtonTexture = Main.ContentManager.Load<Texture2D>("images/gui/inventar/craft_button"); var okButtonHoverTexture = Main.ContentManager.Load<Texture2D>("images/gui/inventar/craft_button_h"); okButton = new UIButton(initWidth, 30, new Vector2(0, 330), okButtonTexture, okButtonHoverTexture, ""); var pixelWhite = Main.ContentManager.Load<Texture2D>("images/pixelWhite"); nameButtonActiveTextur = Main.ContentManager.Load<Texture2D>("images/gui/inventar/name_button_a"); nameButtonTextur = Main.ContentManager.Load<Texture2D>("images/gui/inventar/name_button"); okButton.AddActionListener(listener); nameButton.AddActionListener(this); Add(shortCutTitel); Add(nameButton); Add(weaponPanel); Add(antriebButton); Add(stabilisatorButton); Add(visierButton); Add(demageButton); Add(rateOfFireButton); Add(accuracyButton); Add(bar1); Add(bar2); Add(bar3); Add(okButton); }