public SettingState(StateStack stack, Context context):base(stack,context) { mBindingButtons = new Button[(int)Player.Action.ActionCount]; mBindingLabels = new Label[(int)Player.Action.ActionCount]; mGUIContainer = new Container(); mBackgroundSprite = new Sprite(); mBackgroundSprite.Texture = mContext.textures.get(ResourceID.TitleScreen); addButtonLabels(Player.Action.MoveUp, 150, "Move Up", context); addButtonLabels(Player.Action.MoveLeft,200,"Move Left",context); addButtonLabels(Player.Action.MoveDown, 250, "Move Down", context); addButtonLabels(Player.Action.MoveRight,300,"Move Right",context); updateLabels(); Button backButton = new Button(context.fonts,context.textures); backButton.Position = new Vector2f(80,375); backButton.setText("Back"); backButton.setCallback(() => { requestStackPop(); }); mGUIContainer.pack(backButton); }
public MenuState(StateStack stack, Context context) : base(stack, context) { mGUIContainer = new Container(); mBackgroundSprite = new Sprite(context.textures.get(ResourceID.TitleScreen)); mViewBounds = new IntRect(0, 0, (int)mContext.window.Size.X, (int)mContext.window.Size.Y); Vector2f center = new Vector2f(mContext.window.Size.X / 2, mContext.window.Size.Y / 2); mView = mContext.window.DefaultView; mView.Center = center; Button playButton = new Button(context.fonts, context.textures); playButton.Position = new Vector2f(100, 250); playButton.setText("Play"); playButton.setCallback(() => { requestStackPop(); requestStackPush(StateID.Game); }); Button settingsButton = new Button(context.fonts, context.textures); settingsButton.Position = new Vector2f(100, 300); settingsButton.setText("Settings"); settingsButton.setCallback(() => { requestStackPush(StateID.Setting); }); Button exitButton = new Button(context.fonts, context.textures); exitButton.Position = new Vector2f(100, 350); exitButton.setText("Exit"); exitButton.setCallback(() => { requestStackPop(); }); mGUIContainer.pack(playButton); mGUIContainer.pack(settingsButton); mGUIContainer.pack(exitButton); }
private void addButtonLabels(Player.Action action, float y, string text, Context context) { mBindingButtons[(int)action] = new Button(context.fonts,context.textures); mBindingButtons[(int)action].Position = new Vector2f (80,y); mBindingButtons[(int)action].setText(text); mBindingButtons[(int)action].setToggle(true); mBindingButtons[(int)action].setCallback(() => { }); mBindingLabels[(int)action] = new Label("", context.fonts); mBindingLabels[(int)action].Position = new Vector2f(300, y+ 15); mGUIContainer.pack(mBindingButtons[(int)action]); mGUIContainer.pack(mBindingLabels[(int)action]); }