示例#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() });
    }
示例#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 });

    }
示例#3
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);

      currentClientGameState = GameState.NotConnected;

      int scrWidth = 1024;
      int scrheight = 480;

      int idx = 0;

      // ***** Menu
      int heightNormal = 48;
      int heightSmall = 24;
      int heightTotal = heightNormal + heightSmall;
      int mainMenuStartYNormal = 90;// 80;
      int mainMenuStartYSmall = 90 + heightNormal;
      int mainMenuStartX = 30;// 50;
      int buttonWidth = 200;
      int tBoxHeight = 26;

      cm.AddControl(new Button("startServer", new Vector2(mainMenuStartX, mainMenuStartYNormal + heightTotal * idx), new Vector2(buttonWidth, heightNormal), "Start server [S]", ButtonSkin) { onLClickSubscriber = StartServer });
      cm.AddControl(new Button("stopServer", new Vector2(mainMenuStartX, mainMenuStartYSmall + heightTotal * idx++), new Vector2(buttonWidth, heightSmall), "Stop server", ButtonSkin) { onLClickSubscriber = StopServer, Enabled = false });

      cm.AddControl(new TextBox("ipTextbox", new Vector2(mainMenuStartX, mainMenuStartYNormal + heightTotal * idx), new Vector2(buttonWidth, tBoxHeight), "127.0.0.1", TextBoxSkin) { LoseFocusOnSubmit = true, callbackOnEnterSubscriber = UpdateIp, Enabled = true });

      cm.AddControl(new Button("joinServer", new Vector2(mainMenuStartX, mainMenuStartYNormal + heightTotal * idx + tBoxHeight), new Vector2(buttonWidth, heightNormal), "Join server [J]", ButtonSkin) { onLClickSubscriber = JoinServer });
      cm.AddControl(new Button("disconnect", new Vector2(mainMenuStartX, mainMenuStartYSmall + heightTotal * idx++ + tBoxHeight), new Vector2(buttonWidth, heightSmall), "Disconnect", ButtonSkin) { onLClickSubscriber = Disconnect, Enabled = false });

      cm.AddControl(new Button("exit", new Vector2(mainMenuStartX, mainMenuStartYNormal + heightTotal * idx + tBoxHeight), new Vector2(buttonWidth, heightNormal), "Exit", ButtonSkin) { onLClickSubscriber = _ => UI.Instance.Exit() });

      // ***** Chat
      int chatStartX = 270;
      int chatStartY = 270;

      int borderSpacing = 20;
      int chatWidth = scrWidth - borderSpacing - chatStartX;
      int chatTextboxY = scrheight - tBoxHeight - borderSpacing;
      int chatHeight = chatTextboxY - chatStartX - 16;
      int labelHeight = 16;

      cm.AddControl(new Label("chatLabel", new Vector2(chatStartX, chatStartY), "Messages:", LabelSkin));
      cm.AddControl(new MultilineLabel("chatHistory", new Vector2(chatStartX, chatStartY + labelHeight), new Vector2(chatWidth, chatHeight), TextBoxSkin) { StringDataSource = Network.Messages });
      cm.AddControl(new TextBox("chatTextBox", new Vector2(chatStartX, chatTextboxY), new Vector2(chatWidth, tBoxHeight), "", TextBoxSkin) { LoseFocusOnSubmit = false, callbackOnEnterSubscriber = SendMessage, Enabled = false });

      // ***** User list
      int userListStartX = chatStartX;
      int userListStartY = 80;
      int userListHeight = chatStartY - userListStartY - labelHeight;
      int userListWidth = 200;

      cm.AddControl(new Label("userListLabel", new Vector2(userListStartX, userListStartY), "List of users:", LabelSkin));
      cm.AddControl(new MultilineLabel("userList", new Vector2(userListStartX, userListStartY + labelHeight), new Vector2(userListWidth, userListHeight), TextBoxSkin));

      // ***** Properties
      int propStartX = userListStartX + userListWidth;
      int propStartY = userListStartY;
      int userNameWidth = userListWidth;
      int adjustButtonWidth = tBoxHeight;
      int adjustButtonHeight = tBoxHeight;
      int mapSizeTextboxWidth = userListWidth - 2 * adjustButtonWidth;

      cm.AddControl(new Label("userName", new Vector2(propStartX, propStartY), "Your nickname:", LabelSkin));
      cm.AddControl(new TextBox("userNameTextBox", new Vector2(propStartX, propStartY + labelHeight), new Vector2(userListWidth, tBoxHeight), currentUserName, TextBoxSkin) { LoseFocusOnSubmit = true, callbackOnEnterSubscriber = ChangeNick, onFocusLostSubscriber = ChangeNickFail });

      propStartY += labelHeight + tBoxHeight + 2;
      cm.AddControl(new Label("mapWidthLabel", new Vector2(propStartX, propStartY), "Map width:", LabelSkin));
      cm.AddControl(new Button("mapWidthSmallerButton", new Vector2(propStartX, propStartY + labelHeight), new Vector2(adjustButtonWidth, adjustButtonHeight), "-", ButtonSkin) { Enabled = false, onLClickSubscriber = _ => ChangeWidth(-16) });
      cm.AddControl(new TextBox("mapWidthTextBox", new Vector2(propStartX + adjustButtonWidth, propStartY + labelHeight), new Vector2(mapSizeTextboxWidth, tBoxHeight), "?", TextBoxSkin) { Enabled = false });
      cm.AddControl(new Button("mapWidthLargerButton", new Vector2(propStartX + adjustButtonWidth + mapSizeTextboxWidth, propStartY + labelHeight), new Vector2(adjustButtonWidth, adjustButtonHeight), "+", ButtonSkin) { Enabled = false, onLClickSubscriber = _ => ChangeWidth(16) });

      propStartY += labelHeight + tBoxHeight + 2;
      cm.AddControl(new Label("mapHeightLabel", new Vector2(propStartX, propStartY), "Map height:", LabelSkin));
      cm.AddControl(new Button("mapHeightSmallerButton", new Vector2(propStartX, propStartY + labelHeight), new Vector2(adjustButtonWidth, adjustButtonHeight), "-", ButtonSkin) { Enabled = false, onLClickSubscriber = _ => ChangeHeight(-16) });
      cm.AddControl(new TextBox("mapHeightTextBox", new Vector2(propStartX + adjustButtonWidth, propStartY + labelHeight), new Vector2(mapSizeTextboxWidth, tBoxHeight), "?", TextBoxSkin) { Enabled = false });
      cm.AddControl(new Button("mapHeightLargerButton", new Vector2(propStartX + adjustButtonWidth + mapSizeTextboxWidth, propStartY + labelHeight), new Vector2(adjustButtonWidth, adjustButtonHeight), "+", ButtonSkin) { Enabled = false, onLClickSubscriber = _ => ChangeHeight(16) });

      propStartY += labelHeight + tBoxHeight + 2;
      cm.AddControl(new Label("unitCapLabel", new Vector2(propStartX, propStartY), "Unit cap:", LabelSkin));
      cm.AddControl(new Button("unitCapSmallerButton", new Vector2(propStartX, propStartY + labelHeight), new Vector2(adjustButtonWidth, adjustButtonHeight), "-", ButtonSkin) { Enabled = false, onLClickSubscriber = _ => ChangeUnitCap(-10) });
      cm.AddControl(new TextBox("unitCapTextBox", new Vector2(propStartX + adjustButtonWidth, propStartY + labelHeight), new Vector2(mapSizeTextboxWidth, tBoxHeight), "?", TextBoxSkin) { Enabled = false });
      cm.AddControl(new Button("unitCapLargerButton", new Vector2(propStartX + adjustButtonWidth + mapSizeTextboxWidth, propStartY + labelHeight), new Vector2(adjustButtonWidth, adjustButtonHeight), "+", ButtonSkin) { Enabled = false, onLClickSubscriber = _ => ChangeUnitCap(10) });

      // ***** game control
      int controlStartX = scrWidth - borderSpacing - buttonWidth;
      int controlStartY = chatStartY - heightSmall;

      cm.AddControl(new Button("startGame", new Vector2(controlStartX, controlStartY), new Vector2(buttonWidth, heightSmall), "Start game [G]", ButtonSkin) { Enabled = false, onLClickSubscriber = StartGame });
    }
示例#4
0
文件: MapUI.cs 项目: arcticnw/Wildmen
    /// <summary>
    /// Initialization of the MapUI, the control variables and the control buttons
    /// </summary>
    public void Initialize()
    {
      screenOffset = new Vector2(-100, -60);

      mouseSelectingTexture = UI.Instance.GetGuiTex(DRAG_SELECTION_TEX_NAME);

      this.selectedObjects = new List<GameObject>();

      mouseoverTileTracking = false;
      gameObjectTracking = true;
      mouseSelecting = false;

      int i = 0;
      int width = 100;
      int height = 32;
      int spacing = 32;
      int starty = 40;

      var controlFont = UI.Instance.GetFont("verdana16b");
      var buttonSkin = new GUISkin(UI.Instance.GetGuiTex("blueOverlay2"), controlFont, Color.Black, false, true);

      cm = new ControlManager();
      cm.AddControl(new Button("objMove", new Vector2(5, starty + spacing * i++), new Vector2(width, height), "Move[M]", buttonSkin) { onLClickSubscriber = _ => ChangeIngameState(InGameStateEnum.Movement) });
      cm.AddControl(new Button("objCast", new Vector2(5, starty + spacing * i++), new Vector2(width, height), "Cast[P]", buttonSkin) { onLClickSubscriber = _ => ChangeIngameState(InGameStateEnum.Spell) });
      cm.AddControl(new Button("objAttack", new Vector2(5, starty + spacing * i++), new Vector2(width, height), "Attack[T]", buttonSkin) { onLClickSubscriber = _ => ChangeIngameState(InGameStateEnum.Attack) });
      cm.AddControl(new Button("objGather", new Vector2(5, starty + spacing * i++), new Vector2(width, height), "Gather[G]", buttonSkin) { onLClickSubscriber = _ => ChangeIngameState(InGameStateEnum.Gather) });
      cm.AddControl(new Button("objTrain", new Vector2(5, starty + spacing * i++), new Vector2(width, height), "Train[R]", buttonSkin) { onLClickSubscriber = _ => ChangeIngameState(InGameStateEnum.Train) });
      cm.AddControl(new Button("objBuild", new Vector2(5, starty + spacing * i++), new Vector2(width, height), "Build[B]", buttonSkin) { onLClickSubscriber = _ => ChangeIngameState(InGameStateEnum.BuildingPlacement) });
      cm.AddControl(new Button("objConstruct", new Vector2(5, starty + spacing * i++), new Vector2(width, height), "Construct[B]", buttonSkin) { onLClickSubscriber = _ => ChangeIngameState(InGameStateEnum.Building) });

      UpdateUserControls(inGameState);
    }