Ejemplo n.º 1
0
        void InitializeUI() {
            // mainmenu
            //   label = new Label(ScreenWidth / 2 - 100, 50, 200, 30, "main title", renderer.Font);
            //    AddControl(label, GameState.MainMenu);

            //  AddControl(new Button(ScreenWidth / 2 - 75, 180, 75, 20, "test", renderer.Font), GameState.MainMenu);

            Button startButton = new Button(ScreenWidth / 2 - 100, 200, 200, 30, "start", renderer.Font);
            startButton.ButtonClick += SetSpaceState;
            AddControl(startButton, GameState.MainMenu);
            AddControl(new TextBox(ScreenWidth / 2 - 100, 300, 200, 30, "input", renderer.Font), GameState.MainMenu);

            Button inventoryButton = new Button(10, 10, 100, 50, "inv", renderer.Font);
            inventoryButton.ButtonClick += SetInvState;
            AddControl(inventoryButton, GameState.Space);

            //space

            Button turnButton = new Button(ScreenWidth - 100, ScreenHeight - 23, 100, 23, "turn", renderer.Font);
            turnButton.ButtonClick += TurnButton_ButtonClick;
            AddControl(turnButton, GameState.Space);

            //inventory
            inventoryListBox = new ListBox(new Point(100, 300), renderer.Font, "");
            inventoryListBox.ItemClick += Lb_ItemClick;
            AddControl(inventoryListBox, GameState.Inventory);

            imageBox = new ImageBox(new Rectangle(400, 250, 200, 200));
            AddControl(imageBox, GameState.Inventory);

            Button backButton = new Button(10, 10, 50, 30, "<-", renderer.Font);
            backButton.ButtonClick += BackButton;
            AddControl(backButton, GameState.Inventory);

            
        }
Ejemplo n.º 2
0
 internal void Update(object[] objects) {
     int w = 0;
     int h = 0;
     int hStep = 0;
     for(int i = 0; i < objects.Length; i++) {
         Vector2 size = Font.MeasureString(objects[i].ToString());
         w = Math.Max((int)size.X + 10, w);
         hStep = Math.Max((int)size.Y + 10, hStep);
         h += (int)size.Y + 10;
         Rectangle = new Rectangle(location, new Point(w, h));
     }
     buttons.Clear();
     for(int i = 0; i < objects.Length; i++) {
         Button b = new Button(location.X, location.Y + hStep * i, w, hStep, objects[i].ToString(), Font) { Tag = objects[i]};
         buttons.Add(b);
     }
 }