Esempio n. 1
0
    /// <summary>
    /// Initializes the screen, places the user controls
    /// </summary>
    /// <param id="sm">ScreenManager that handles this screen</param>
    public override void Initialize(ScreenManager sm)
    {
      cm = new ControlManager();
      base.Initialize(sm);

      int idx = 0;
      int starty = 90;
      int startx = 30;
      int width = 200;
      int height = 48;

      cm.AddControl(new Button("multiplayer", new Vector2(startx, starty + height * idx++), new Vector2(width, height), "Start game [M]", ButtonSkin) { onLClickSubscriber = _ => sm.SwitchScreen("creategame") });
      cm.AddControl(new Button("exit", new Vector2(startx, starty + height * idx++), new Vector2(width, height), "Exit [E]", ButtonSkin) { onLClickSubscriber = _ => UI.Instance.Exit() });
    }
Esempio n. 2
0
    /// <summary>
    /// Initializes the screen, places the user controls
    /// </summary>
    /// <param id="sm">ScreenManager that handles this screen</param>
    public override void Initialize(ScreenManager sm)
    {
      cm = new ControlManager();
      base.Initialize(sm);

      Vector2 clientBounds = UI.Instance.ScreenBounds;
      int clientWidth = (int)clientBounds.X;
      int clientHeight = (int)clientBounds.Y;

      int starty = 108;
      int startx = 143;
      int width = 200;
      int height = 48;
      int chatWidth = clientWidth - startx * 2;
      int chatHeight = clientHeight - 40 * 2 - starty - height;
      int tBoxHeight = 26;

      cm.AddControl(new Button("mainmenu", new Vector2(startx, starty + chatHeight + tBoxHeight + 4), new Vector2(width, height), "Main menu", ButtonSkin) { onLClickSubscriber = _ => { sm.CloseSubscreen(); sm.SwitchScreen("main"); } });
      cm.AddControl(new Button("back", new Vector2(startx + chatWidth - width, starty + chatHeight + tBoxHeight + 4), new Vector2(width, height), "Back to game", ButtonSkin) { onLClickSubscriber = _ => sm.CloseSubscreen() });

      cm.AddControl(new MultilineLabel("chatHistory", new Vector2(startx, starty), new Vector2(chatWidth, chatHeight), TextBoxSkin) { StringDataSource = Network.Messages });
      cm.AddControl(new TextBox("chatTextBox", new Vector2(startx, starty + chatHeight), new Vector2(chatWidth, tBoxHeight), "", TextBoxSkin) { LoseFocusOnSubmit = false, callbackOnEnterSubscriber = SendMessage });

    }