Ejemplo n.º 1
0
        public void onInput(InputHandler input)
        {
            bool interacting = ui.onInput(input);

            if (interacting)
            {
                return;
            }

            if (input.isKeyPressed(Keys.T)) // title screen image
            {
                ui.pushElement(new UiTextInput("BG Filename: ").addCallback(element =>
                {
                    UiTextInput input = (UiTextInput)element;
                    if (input.text != "")
                    {
                        GameInfo.titleBackground = input.text;
                        titleScreen.updateBackground();
                    }
                }), Vector2.Zero);
            }
            else if (input.isKeyPressed(Keys.N)) // game name
            {
                ui.pushElement(new UiTextInput("Name: ").addCallback(element =>
                {
                    UiTextInput input = (UiTextInput)element;
                    if (input.text != "")
                    {
                        GameInfo.title = input.text;
                    }
                }), Vector2.Zero);
            }
            else if (input.isKeyPressed(Keys.S)) // game start
            {
                ui.pushElement(new UiOptionBox(Content, "Start game where?", "Overworld", "Map").addCallback(element =>
                {
                    UiOptionBox option = (UiOptionBox)element;
                    ui.pushElement(new UiTextInput("Filename: ").addCallback(element2 =>
                    {
                        UiTextInput filename = (UiTextInput)element2;
                        if (filename.text != "")
                        {
                            GameInfo.startMap       = filename.text;
                            GameInfo.startOverworld = (option.selected == 0);
                        }
                    }), new Vector2(0, 65));
                }), Vector2.Zero);
            }
            else if (input.isKeyPressed(Keys.F2)) // save
            {
                GameInfo.save();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Create a script node that represents a text box with two options
 /// </summary>
 /// <param name="text">The main text</param>
 /// <param name="option1">Text of option 1</param>
 /// <param name="option2">Text of option 2</param>
 /// <param name="f1">Lua function executed if option 1 is selected</param>
 /// <param name="f2">Lua function executed if option 2 is selected</param>
 /// <returns>a UiNode with the text box</returns>
 public ScriptNode SBranch(string text, string option1, string option2, LuaFunction f1, LuaFunction f2)
 {
     return(new UiNode(ui, new UiOptionBox(Content, text, option1, option2).addCallback(element =>
     {
         UiOptionBox option = (UiOptionBox)element;
         if (option.selected == 0 && f1 != null)
         {
             f1.Call(new object[0]);
         }
         else if (option.selected == 1 && f2 != null)
         {
             f2.Call(new object[0]);
         }
     })));
 }