コード例 #1
0
 public void ClientCodeCheck(GUIFactory creator)
 {
     // ...
     Console.WriteLine("Client: I'm not aware of the creator's class," +
                       "but it still works.\n" + creator.FactoryMethodCheck());
     // ...
 }
コード例 #2
0
        static void Main(string[] args)
        {
            Button button = GUIFactory.getFactory().createButton();

            button.paint();
            Console.Read();
        }
コード例 #3
0
ファイル: GUIManager.cs プロジェクト: d1ma1989/Planes
    public static GUIManager Create(UIRoot uiRoot)
    {
        _uiRoot     = uiRoot;
        _guiFactory = new GUIFactory();
        GUIManager manager = new GameObject("GUIManager").AddComponent <GUIManager>();

        manager.CheckResolution();
        return(manager);
    }
コード例 #4
0
        private GUIFactory CreateGUIFactory()
        {
            var defaultFont = this.Resourses.LoadAsset <Font>("Fonts\\Metro.fnt");

            var factory = new GUIFactory();

            factory.RegisterStandardObject <Label>(new Label(defaultFont, ""));

            return(factory);
        }
コード例 #5
0
        private void Setting_Bt(object sender, RoutedEventArgs e)
        {
            GUIFactory AcquisitionGUI = new GUIFactory();

            //AcquisitionGUI.ConnectGUILibrary(cam);

            CameraSelectionWindow camSelection = AcquisitionGUI.GetCameraSelectionWindow();

            camSelection.ShowModal(true);
        }
コード例 #6
0
ファイル: Client.cs プロジェクト: yenni1993/PatronesDise-o
        public void ClientMethod(GUIFactory guiFactory)
        {
            var button      = guiFactory.CreateButton();
            var checkbox    = guiFactory.CreateCheckBox();
            var radiobutton = guiFactory.CreateRadioButton();

            Console.WriteLine(button.UsefulFunctionButton());
            Console.WriteLine(checkbox.UsefulFunctionButtonCheckBox());
            Console.WriteLine(radiobutton.UsefulFunctionRadioButton());
        }
コード例 #7
0
ファイル: Client.cs プロジェクト: Zaoldyek/Patrones
        public void ClientMethod(GUIFactory factory)
        {
            var productA = factory.CreateButton();
            var productB = factory.CreateCheckBox();
            var productC = factory.CreateRadio();

            Console.WriteLine(productA.UsefulFunctionA());
            Console.WriteLine(productB.UsefulFunctionB());
            Console.WriteLine(productC.UsefulFunctionC());
            Console.ReadLine();
        }
コード例 #8
0
        void main()
        {
            config = ReadApplicationConfiFile();

            if (config.OS == "Windows")
            {
                factory = new WinFactory();
            }
            else if (config.OS == "Mac")
            {
                factory = new MacFactory();
            }
            else
            {
                throw new Exception("Error! Unknown operating system.");
            }
        }
コード例 #9
0
    public override void OnGUI(GameObject gameObject)
    {
        base.OnGUI(gameObject);

        GUIFactory f = new GUIFactory();

        GUIComponent c = f.CreateLabel("Total : " + total +
                                       "\n" +
                                       "Affected : " + affectedTally)
                         .SetBox(new Box()
                                 .SetMarginLeft(0.01f)
                                 .SetMarginTop(0.01f)
                                 .SetWidth(0.2f)
                                 .SetHeight(0.2f)
                                 );

        GUILabel l = (GUILabel)c;

        l.SetStyle(s);

        f.Build().OnGUI(gameObject);
    }
    public override void OnGUI(GameObject gameObject)
    {
        base.OnGUI(gameObject);

        GUIFactory f = new GUIFactory ();

        GUIComponent c = f.CreateLabel ("Total : " + total +
                                        "\n" +
                                        "Affected : " + affectedTally)
            .SetBox(new Box()
                    .SetMarginLeft(0.01f)
                    .SetMarginTop(0.01f)
                    .SetWidth(0.2f)
                    .SetHeight (0.2f)
                    );

        GUILabel l = (GUILabel) c;

        l.SetStyle(s);

        f.Build ().OnGUI (gameObject);
    }
コード例 #11
0
ファイル: MainWindow.xaml.cs プロジェクト: xiaopi3/camera3D
        public MainWindow()
        {
            InitializeComponent();

            ManagedSystem ms = new ManagedSystem();

            IList <IManagedCamera> camList = ms.GetCameras();

            IManagedCamera cam = camList[0];

            GUIFactory AcquisitionGUI = new GUIFactory();

            cam.Init();
            //AcquisitionGUI.ConnectGUILibrary(cam);

            ImageDrawingWindow AcquisitionDrawing = AcquisitionGUI.GetImageDrawingWindow();

            //AcquisitionDrawing.Connect(cam);

            //AcquisitionDrawing.Start();
            //AcquisitionDrawing.Stop();

            AcquisitionDrawing.ShowModal();
        }
    public Slides(string currentSceneName)
    {
        this.currentSceneName = currentSceneName;
        this.slides = new List<Slide>();

        // -------------------------   Build no background ------------------------ \\
        // Create Go Back to Menu Button
        GUIButton goBack = new GUIButton ();
        goBack
            .SetText(GUIConst.goBack)
            .OnClick(FlowControl.GoToLessonScreen)
                .SetBox((new Box())
                .SetMarginTop (0.0f)
                .SetMarginRight (0.0f)
                .SetMarginBottom (0.0f)
                .SetMarginLeft (0.0f));

        GUIFactory factory = new GUIFactory ();

        // Create "Help" Button
        GUIButton helpButton = new GUIButton ();
        helpButton
            .SetText(GUIConst.helpButtonText)
            .OnClick(FlowControl.ShowHelpMenu)
                .SetBox((new Box())
                .SetMarginTop (0.0f)
                .SetMarginRight (0.0f)
                .SetMarginBottom (0.0f)
                .SetMarginLeft (0.0f));

        factory.CreateContainer()
            .SetBox ((new Box())
                .SetMarginTop ("auto")
                .SetMarginLeft ("5px")
                .SetMarginBottom ("5px")
                .SetMarginRight ("auto")
                .SetHeight (0.08f)
                .SetWidth(0.4f)).Append (goBack);

        factory
            .CreateContainer ()
                .SetBox ((new Box())
                    .SetMarginTop ("auto")
                    .SetMarginLeft ("auto")
                    .SetMarginBottom ("5px")
                    .SetMarginRight ("5px")
                    .SetHeight (0.08f)
                    .SetWidth("32px"))
                .Append(helpButton);

        guiNoBackground = factory.Build();
        // ------------------------------------------------------------------------ //
        // -------------------------   Build Regular GUI -------------------------- \\
        // Create Go Back to Menu Button
        goBack = new GUIButton ();
        goBack
            .SetText(GUIConst.goBack)
            .OnClick(FlowControl.GoToLessonScreen)
                .SetBox((new Box())
                .SetMarginTop (0.0f)
                .SetMarginRight (0.0f)
                .SetMarginBottom (0.0f)
                .SetMarginLeft (0.0f));

        factory = new GUIFactory ();

        // Create "Help" Button
        helpButton = new GUIButton ();
        helpButton
            .SetText(GUIConst.helpButtonText)
            .OnClick(FlowControl.ShowHelpMenu)
                .SetBox((new Box())
                .SetMarginTop (0.0f)
                .SetMarginRight (0.0f)
                .SetMarginBottom (0.0f)
                .SetMarginLeft (0.0f));

        factory.CreateContainer()
            .SetBox ((new Box())
                .SetMarginTop ("auto")
                .SetMarginLeft ("5px")
                .SetMarginBottom ("5px")
                .SetMarginRight ("auto")
                .SetHeight (0.08f)
                .SetWidth(0.4f)).Append (goBack);

        factory
            .CreateContainer ()
                .SetBox ((new Box())
                    .SetMarginTop ("auto")
                    .SetMarginLeft ("auto")
                    .SetMarginBottom ("5px")
                    .SetMarginRight ("5px")
                    .SetHeight (0.08f)
                    .SetWidth("32px"))
                .Append(helpButton);

        factory
            .Prepend(new GUIImage("splash-background"));

        // Build
        gui = factory.Build();

        FlowControl.SetCurrentSlides(this);
    }
    static FlowControl()
    {
        // Draw Panel

        // Draw buttons:
        // Create "Start a Lesson" Button
        GUIButton startALessonButton = new GUIButton();

        startALessonButton
        .SetText("Pick A Lesson")
        .OnClick(FlowControl.GoToLessonScreen)
        .SetBox((new Box())
                .SetMarginTop(0.0f)
                .SetMarginRight(0.0f)
                .SetMarginBottom(0.80f)
                .SetMarginLeft(0.0f));

        // Create "Visit Mantaray AR Website" Button
        GUIButton getARTargets = new GUIButton();

        getARTargets
        .SetText(GUIConst.getARTargets)
        .OnClick(FlowControl.GetTargets)
        .SetBox((new Box())
                .SetMarginTop(0.25f)
                .SetMarginRight(0.0f)
                .SetMarginBottom(0.55f)
                .SetMarginLeft(0.0f));

        // Create "Visit Mantaray AR Website" Button
        GUIButton visitMantarayARWebsiteButton = new GUIButton();

        visitMantarayARWebsiteButton
        .SetText(GUIConst.visitMantarayARWebsiteText)
        .OnClick(FlowControl.GoToWebsite)
        .SetBox((new Box())
                .SetMarginTop(0.50f)
                .SetMarginRight(0.0f)
                .SetMarginBottom(0.30f)
                .SetMarginLeft(0.0f));

        // Create "Return" Button
        GUIButton exitMenuButton = new GUIButton();

        exitMenuButton
        .SetText("Go Back")
        .OnClick(FlowControl.ExitMenu)
        .SetBox((new Box())
                .SetMarginTop(0.75f)
                .SetMarginRight(0.0f)
                .SetMarginBottom(0.05f)
                .SetMarginLeft(0.0f));

        // Build the GUI
        GUIFactory factory = new GUIFactory();

        factory
        .Append(new GUIImage("dark-transparent-swatch").SetScaleMode(ScaleMode.StretchToFill));


        factory
        .CreateContainer()
        .SetBox((new Box())
                .SetMarginTop(0.2f)
                .SetMarginRight(0.2f)
                .SetMarginBottom(0.2f)
                .SetMarginLeft(0.2f))
        .Append(startALessonButton)
        .Append(getARTargets)
        .Append(visitMantarayARWebsiteButton)
        .Append(exitMenuButton);

        FlowControl.gui = factory.Build();
    }
コード例 #14
0
 public void SetFactory(GUIFactory fy)
 {
     factory = fy;
 }
コード例 #15
0
    // Use this for initialization
    void Start()
    {
        // Bootstrap Assets
        Assets.GetInstance();

        // Create "Start a Lesson" Button
        GUIButton startALessonButton = new GUIButton();

        startALessonButton
        .SetText(GUIConst.startALessonText)
        .OnClick(FlowControl.GoToLessonScreen)
        .SetBox((new Box())
                .SetMarginTop(0.0f)
                .SetMarginRight(0.0f)
                .SetMarginBottom(0.70f)
                .SetMarginLeft(0.0f));

        // Create "Visit Mantaray AR Website" Button
        GUIButton getARTargets = new GUIButton();

        getARTargets
        .SetText(GUIConst.getARTargets)
        .OnClick(FlowControl.GetTargets)
        .SetBox((new Box())
                .SetMarginTop(0.35f)
                .SetMarginRight(0.0f)
                .SetMarginBottom(0.35f)
                .SetMarginLeft(0.0f));

        // Create "Visit Mantaray AR Website" Button
        GUIButton visitMantarayARWebsiteButton = new GUIButton();

        visitMantarayARWebsiteButton
        .SetText(GUIConst.visitMantarayARWebsiteText)
        .OnClick(FlowControl.GoToWebsite)
        .SetBox((new Box())
                .SetMarginTop(0.70f)
                .SetMarginRight(0.0f)
                .SetMarginBottom(0.0f)
                .SetMarginLeft(0.0f));

        // Create "Help" Button
        GUIButton helpButton = new GUIButton();

        helpButton
        .SetText(GUIConst.helpButtonText)
        .OnClick(FlowControl.ShowHelpMenu)
        .SetBox((new Box())
                .SetMarginTop(0.0f)
                .SetMarginRight(0.0f)
                .SetMarginBottom(0.0f)
                .SetMarginLeft(0.0f));

        // Build the GUI
        GUIFactory factory = new GUIFactory();

        factory
        .Append(new GUIImage("splash-background"));

        ((GUILabel)factory
         .CreateLabel())
        .SetStyle(new GUIStyle())
        .SetBox((new Box())
                .SetMarginTop(0.1f)
                .SetMarginRight(0.05f)
                .SetMarginBottom("auto")
                .SetMarginLeft(0.05f)
                .SetHeight(0.45f))
        .Append((new GUIImage("splash-logo")).SetScaleMode(ScaleMode.ScaleToFit));

        factory
        .CreateContainer()
        .SetBox((new Box())
                .SetMarginTop("auto")
                .SetMarginRight(0.2f)
                .SetMarginBottom(0.1f)
                .SetMarginLeft(0.2f)
                .SetHeight(0.4f))
        .Append(startALessonButton)
        .Append(getARTargets)
        .Append(visitMantarayARWebsiteButton);

        factory
        .CreateContainer()
        .SetBox((new Box())
                .SetMarginTop("auto")
                .SetMarginLeft("auto")
                .SetMarginBottom("5px")
                .SetMarginRight("5px")
                .SetHeight(0.08f)
                .SetWidth("32px"))
        .Append(helpButton);

        gui = factory.Build();
    }
    public Slides(string currentSceneName)
    {
        this.currentSceneName = currentSceneName;
        this.slides           = new List <Slide>();



        // -------------------------   Build no background ------------------------ \\
        // Create Go Back to Menu Button
        GUIButton goBack = new GUIButton();

        goBack
        .SetText(GUIConst.goBack)
        .OnClick(FlowControl.GoToLessonScreen)
        .SetBox((new Box())
                .SetMarginTop(0.0f)
                .SetMarginRight(0.0f)
                .SetMarginBottom(0.0f)
                .SetMarginLeft(0.0f));

        GUIFactory factory = new GUIFactory();

        // Create "Help" Button
        GUIButton helpButton = new GUIButton();

        helpButton
        .SetText(GUIConst.helpButtonText)
        .OnClick(FlowControl.ShowHelpMenu)
        .SetBox((new Box())
                .SetMarginTop(0.0f)
                .SetMarginRight(0.0f)
                .SetMarginBottom(0.0f)
                .SetMarginLeft(0.0f));

        factory.CreateContainer()
        .SetBox((new Box())
                .SetMarginTop("auto")
                .SetMarginLeft("5px")
                .SetMarginBottom("5px")
                .SetMarginRight("auto")
                .SetHeight(0.08f)
                .SetWidth(0.4f)).Append(goBack);

        factory
        .CreateContainer()
        .SetBox((new Box())
                .SetMarginTop("auto")
                .SetMarginLeft("auto")
                .SetMarginBottom("5px")
                .SetMarginRight("5px")
                .SetHeight(0.08f)
                .SetWidth("32px"))
        .Append(helpButton);


        guiNoBackground = factory.Build();
        // ------------------------------------------------------------------------ //
        // -------------------------   Build Regular GUI -------------------------- \\
        // Create Go Back to Menu Button
        goBack = new GUIButton();
        goBack
        .SetText(GUIConst.goBack)
        .OnClick(FlowControl.GoToLessonScreen)
        .SetBox((new Box())
                .SetMarginTop(0.0f)
                .SetMarginRight(0.0f)
                .SetMarginBottom(0.0f)
                .SetMarginLeft(0.0f));

        factory = new GUIFactory();

        // Create "Help" Button
        helpButton = new GUIButton();
        helpButton
        .SetText(GUIConst.helpButtonText)
        .OnClick(FlowControl.ShowHelpMenu)
        .SetBox((new Box())
                .SetMarginTop(0.0f)
                .SetMarginRight(0.0f)
                .SetMarginBottom(0.0f)
                .SetMarginLeft(0.0f));

        factory.CreateContainer()
        .SetBox((new Box())
                .SetMarginTop("auto")
                .SetMarginLeft("5px")
                .SetMarginBottom("5px")
                .SetMarginRight("auto")
                .SetHeight(0.08f)
                .SetWidth(0.4f)).Append(goBack);

        factory
        .CreateContainer()
        .SetBox((new Box())
                .SetMarginTop("auto")
                .SetMarginLeft("auto")
                .SetMarginBottom("5px")
                .SetMarginRight("5px")
                .SetHeight(0.08f)
                .SetWidth("32px"))
        .Append(helpButton);

        factory
        .Prepend(new GUIImage("splash-background"));

        // Build
        gui = factory.Build();


        FlowControl.SetCurrentSlides(this);
    }
コード例 #17
0
        private GUIFactory CreateGUIFactory()
        {
            var defaultFont = this.Resourses.LoadAsset<Font>("Fonts\\Metro.fnt");

            var factory = new GUIFactory();
            factory.RegisterStandardObject<Label>(new Label(defaultFont, ""));

            return factory;
        }
コード例 #18
0
    /**
     * Initialization code.
     *
     * Set up distances and origin points.
     */
    void Start()
    {
        controller = GetComponent <CharacterController>();

        // Adjust the collider size to fit a fish
        controller.height = colliderHeight;
        controller.radius = colliderRadius;

        model = this.GetComponent <ARModel>();
        cam   = Camera.main;

        float   componentMaxDistance = maxDistance / 2;
        float   x          = Random.Range(-componentMaxDistance, componentMaxDistance);
        float   y          = Random.Range(0, componentMaxDistance * 2);
        float   z          = Random.Range(-componentMaxDistance, componentMaxDistance);
        Vector3 startPoint = origin + new Vector3(x, y, z);

        transform.Translate(startPoint);
        centerPoint = origin;

        affected = gameObject.name.Contains("affected");

        //  ------------------------ Set up GUI ----------------------------------- \\
        // Create affected button
        GUIButton isAffected = new GUIButton();

        isAffected.SetText("Yes");
        isAffected.SetBox(new Box()
                          .SetMarginTop("auto")
                          .SetMarginRight(0.01f)
                          .SetMarginLeft("auto")
                          .SetMarginBottom(0.01f)
                          .SetWidth(Screen.width * 0.2 + "px")
                          .SetHeight(0.4f));

        isAffected.OnClick(this.IThinkItsAffected);

        // Create not affected button
        GUIButton isNotAffected = new GUIButton();

        isNotAffected.SetText("No");
        isNotAffected.SetBox(new Box()
                             .SetMarginTop("auto")
                             .SetMarginRight("auto")
                             .SetMarginLeft(0.01f)
                             .SetMarginBottom(0.01f)
                             .SetWidth(Screen.width * 0.2 + "px")
                             .SetHeight(0.4f));


        isNotAffected.OnClick(this.IThinkItsNotAffected);

        GUIFactory factory = new GUIFactory();

        factory.CreateLabel("Has this fish been affected by oil?")
        .SetBox(new Box()
                .SetMarginBottom(0.1f)
                .SetMarginTop(0.6f)
                .SetMarginLeft(0.1f)
                .SetMarginRight(0.1f))
        .Append(isAffected)
        .Append(isNotAffected);


        gui = factory.Build();

        // -------------------- Look closely GUI Set up ----------------------------------- \\
        // Create Confirm button
        GUIButton confirm = new GUIButton();

        confirm.SetText("Okay");
        confirm.SetBox(new Box()
                       .SetMarginTop("auto")
                       .SetMarginRight(0.01f)
                       .SetMarginLeft("auto")
                       .SetMarginBottom(0.01f)
                       .SetWidth(Screen.width * 0.2 + "px")
                       .SetHeight(0.4f));

        confirm.OnClick(this.Confirm);

        GUIFactory lookCloselyGUIFactory = new GUIFactory();

        GUIComponent gc = lookCloselyGUIFactory.CreateLabel("Look closely! Fish affected by pollution will have splotches of oil across their scales.")
                          .SetBox(new Box()
                                  .SetMarginBottom(0.1f)
                                  .SetMarginTop(0.6f)
                                  .SetMarginLeft(0.1f)
                                  .SetMarginRight(0.1f));

        GUILabel gl = (GUILabel)gc;
        GUIStyle gs = GUIStyles.GetInstance().DEFAULT_WHITE_STYLE;

        gs.wordWrap = true;
        gl.SetStyle(gs);
        gc.Append(confirm);


        lookCloselyGUI = lookCloselyGUIFactory.Build();

        // --------------------- alreadyExaminedGUI -------------------------------------- \\
        // Create Confirm button
        GUIButton confirmAlreadyExamined = new GUIButton();

        confirmAlreadyExamined.SetText("Okay");
        confirmAlreadyExamined.SetBox(new Box()
                                      .SetMarginTop("auto")
                                      .SetMarginRight(0.01f)
                                      .SetMarginLeft("auto")
                                      .SetMarginBottom(0.01f)
                                      .SetWidth(Screen.width * 0.2 + "px")
                                      .SetHeight(0.4f));

        confirmAlreadyExamined.OnClick(this.ConfirmAlreadyExamined);

        GUIFactory alreadyExaminedGUIFactory = new GUIFactory();

        alreadyExaminedGUIFactory.CreateLabel("You have already examined this fish.")
        .SetBox(new Box()
                .SetMarginBottom(0.1f)
                .SetMarginTop(0.6f)
                .SetMarginLeft(0.1f)
                .SetMarginRight(0.1f))
        .Append(confirmAlreadyExamined);


        alreadyExaminedGUI = alreadyExaminedGUIFactory.Build();
    }
コード例 #19
0
        protected override void Load(GUIFactory factory)
        {
            var font = this.Resourses.LoadAsset<Font>("Fonts\\Consolas.fnt"); // Load the default font.
            var bigfont = this.Resourses.LoadAsset<Font>("Fonts\\BigMetro.fnt"); // Load another font.

            this.Panel.BackgroundColor = Color.White;

            //Left aligned golden label.
            Label left = new Label(font, "A left aligned label.");
            left.TextColor = Color.Gold;
            left.Position = new Vector2(50, 50);
            left.Size = new Vector2(300, font.Size);

            //Adds the label to the root panel. Now it will exsist in the window.
            this.Panel.AddControl(left);

            //Center aligned orange halfopaqe label.
            Label center = new Label(font, "Center aligned label:");
            center.Alignment = TextAlignment.Center;
            center.TextColor = Color.Orange * 0.5f; //Creates the color orange and premultiplies it by 0.5f alpha.
            center.Position = new Vector2(50, left.Bounds.Bottom + 10);
            center.Size = new Vector2(300, font.Size);

            this.Panel.AddControl(center);

            //Right Aligned label.
            Label right = new Label(font,"Right Aligned Label:");
            right.Alignment = TextAlignment.Right;
            right.TextColor = Color.Magenta;
            right.Position = new Vector2(50, center.Bounds.Bottom + 10);
            right.Size = new Vector2(300, font.Size);

            this.Panel.AddControl(right);

            //Multi line label.
            Label multiLine = new Label(font, "This is a \nmulti-line label");
            multiLine.TextColor = Color.Black;
            multiLine.Position = new Vector2(50, right.Bounds.Bottom + 10);
            multiLine.Size = new Vector2(300, font.Size * 2);

            this.Panel.AddControl(multiLine);

            //Label with a non transparent background.
            Label backgroundLabel = new Label(font, "This is a label with non transparent background color.");
            backgroundLabel.BackgroundColor = Color.Purple;
            backgroundLabel.TextColor = Color.White;
            backgroundLabel.Position = new Vector2(50, multiLine.Bounds.Bottom + 10);
            backgroundLabel.Size = new Vector2(450, font.Size);

            this.Panel.AddControl(backgroundLabel);

            //Label with a big font.
            Label bigLabel = new Label(bigfont, "This is a label with a BIG font.");
            bigLabel.TextColor = Color.Black;
            bigLabel.Position = new Vector2(50, backgroundLabel.Bounds.Bottom + 10);
            bigLabel.Size = new Vector2(400, bigfont.Size);

            this.Panel.AddControl(bigLabel);

            //Window centered label.
            Label windowCenter = new Label(bigfont, "Window Center Label");
            windowCenter.TextColor = Color.Black;
            windowCenter.Position = new Vector2(this.Width / 2, 50);
            windowCenter.Size = new Vector2(400, bigfont.Size);
            windowCenter.Origin = Origin.Center;
            windowCenter.Alignment = TextAlignment.Center;

            //Registers a lambda to the resize event and correctly reposition the windowCenter label.
            this.Resize += ()=>
            {
                windowCenter.Position = new Vector2(this.Width / 2, 50);
            };

            this.Panel.AddControl(windowCenter);
        }
    public Slide(string text)
    {
        state = SlideState.TEXT;
        this.text = text;
        GUIFactory factory = new GUIFactory();

        // Go Back Button
        GUIButton backButton = new GUIButton();

        backButton.SetText("Go Back");
        backButton.SetBox(new Box()
            .SetMarginTop("auto")
            .SetMarginRight("auto")
            .SetMarginLeft(0.01f)
            .SetMarginBottom(0.01f)
            .SetWidth(Screen.width * 0.2 + "px")
            .SetHeight (0.1f));

        backButton.OnClick(FlowControl.PreviousSlide);

        // Go Forward Button
        GUIButton nextButton = new GUIButton();

        nextButton.SetText("Continue");
        nextButton.SetBox(new Box()
            .SetMarginTop("auto")
            .SetMarginLeft("auto")
            .SetMarginRight(0.01f)
            .SetMarginBottom(0.01f)
            .SetWidth(Screen.width * 0.2 + "px")
            .SetHeight (0.1f));

        nextButton.OnClick(FlowControl.NextSlide);

        GUIComponent c = factory
            .CreateLabel (text)
                .SetBox ((new Box ())
                    .SetMarginTop (0.1f)
                    .SetMarginRight (0.1f)
                    .SetMarginBottom (0.1f)
                    .SetMarginLeft (0.1f));

        GUILabel l = (GUILabel) c;

        l.SetStyle(GUIStyles.GetInstance().DEFAULT_SLIDE_STYLE);

        l.Append (nextButton);
        l.Append (backButton);

        gui = factory.Build();

        questionBoxes = new Box[4];

        questionBoxes [0] = new Box ();
        questionBoxes [0]
                .SetMarginTop (0.55f)
                .SetMarginRight (0.51f)
                .SetMarginBottom ("auto")
                .SetMarginLeft (0.01f)
                .SetHeight (0.1f);

        questionBoxes [1] = new Box ();
        questionBoxes [1]
                .SetMarginTop (0.55f)
                .SetMarginRight (0.01f)
                .SetMarginBottom ("auto")
                .SetMarginLeft (0.51f)
                .SetHeight (0.1f);

        questionBoxes [2] = new Box ();
        questionBoxes [2]
                .SetMarginTop (0.7f)
                .SetMarginRight (0.51f)
                .SetMarginBottom ("auto")
                .SetMarginLeft (0.01f)
                .SetHeight (0.1f);

        questionBoxes [3] = new Box ();
        questionBoxes [3]
                .SetMarginTop (0.7f)
                .SetMarginRight (0.01f)
                .SetMarginBottom ("auto")
                .SetMarginLeft (0.51f)
                .SetHeight (0.1f);
    }
    public void DoGUI(GameObject gameObject)
    {
        switch (this.state) {
        case SlideState.AR:
            this.experience.OnGUI (gameObject);

            // Check if we have found a target!
            GameObject targetGameObject = this.experience.GetTarget ();
            bool found = false;
            TrackableBehaviour mTrackableBehaviour = targetGameObject.GetComponent<TrackableBehaviour> ();

            ImageTargetAbstractBehaviour b = this.experience.GetTarget ().GetComponent<ImageTargetAbstractBehaviour> ();
            if (b != null && b.ImageTarget != null) {
                String name = b.ImageTarget.Name;

                foreach (GameObject o in this.experience.GetGameObjects()) {
                    foreach (Renderer component in targetGameObject.GetComponentsInChildren<Renderer>(true)) {
                        if (component.enabled && mTrackableBehaviour.TrackableName == name)
                            found = true;
                    }

                    foreach (Collider component in targetGameObject.GetComponentsInChildren<Collider>(true)) {
                        if (component.enabled && mTrackableBehaviour.TrackableName == name)
                            found = true;
                    }
                }
            }

            // If NOT found, show GUI text
            if (!found) {
                GUIFactory factory = new GUIFactory ();
                factory.CreateLabel (this.text)
                    .SetBox (new Box ()
                            .SetMarginTop (0.01f)
                            .SetMarginLeft (0.3f)
                            .SetMarginRight (0.3f)
                            .SetHeight (0.1f));

                                factory.Build ().OnGUI (gameObject);
                        }

                        break;
                case SlideState.QUESTION:
            // ------------------- Construct GUI for Question ---------------------- \\

            // -------------------------------- QUESTION GUI --------------------------------- \\
                        GUIFactory qFactory = new GUIFactory ();

            // Go Back Button
            GUIButton backButton = new GUIButton ();

            backButton.SetText ("Go Back");
            backButton.SetBox (new Box ()
                  .SetMarginTop ("auto")
                  .SetMarginRight ("auto")
                  .SetMarginLeft (0.01f)
                  .SetMarginBottom (0.01f)
                  .SetWidth (Screen.width * 0.2 + "px")
                  .SetHeight (0.1f));

            backButton.OnClick (FlowControl.PreviousSlide);

            GUIComponent c;
            if (this.showDescriptionOfRightAnswer) {
                    c = new GUILabel (question.GetDescriptionOfRightAnswer ());
                    qFactory.Append (c);
                    c.SetBox ((new Box ())
              .SetMarginTop (0.1f)
              .SetMarginRight (0.1f)
              .SetMarginBottom (0.1f)
              .SetMarginLeft (0.1f));

                    GUILabel z = (GUILabel)c;
                    z.SetStyle (GUIStyles.GetInstance ().DEFAULT_SLIDE_STYLE);

                    GUIButton continueButton = new GUIButton ();
                    continueButton.SetText ("Continue");
                    continueButton.SetBox (new Box ()
                          .SetMarginTop ("auto")
                          .SetMarginLeft ("auto")
                          .SetMarginRight (0.01f)
                          .SetMarginBottom (0.01f)
                          .SetWidth (Screen.width * 0.2 + "px")
                          .SetHeight (0.1f));

                    continueButton.OnClick (Continue);

                    c.Append (continueButton);

            } else {
                    if (this.showHint) {
                            c = new GUIButton ();
                            qFactory.Append (c);
                            c.SetBox ((new Box ())
                  .SetMarginTop (0.1f)
                  .SetMarginRight (0.1f)
                  .SetMarginBottom (0.1f)
                  .SetMarginLeft (0.1f));

                            GUIButton z = (GUIButton)c;
                            z.SetStyle (GUIStyles.GetInstance ().DEFAULT_SLIDE_STYLE);
                            z.SetText (question.GetHint () + "\n\n(Click to hide hint)");
                            z.OnClick (HideHint);

                    } else {
                            c = qFactory
            .CreateLabel (question.GetText ())
                .SetBox ((new Box ())
                         .SetMarginTop (0.1f)
                         .SetMarginRight (0.1f)
                         .SetMarginBottom (0.1f)
                         .SetMarginLeft (0.1f));

                            GUILabel l = (GUILabel)c;

                            l.SetStyle (GUIStyles.GetInstance ().DEFAULT_SLIDE_STYLE);
                    }
                    if (currentAnswer != -1) {
                            // We have a selected answer, show the "next" button
                            GUIButton submitAnswerButton = new GUIButton ();
                            submitAnswerButton.SetText ("Submit Answer");
                            submitAnswerButton.SetBox (new Box ()
                                  .SetMarginTop ("auto")
                                  .SetMarginLeft ("auto")
                                  .SetMarginRight (0.01f)
                                  .SetMarginBottom (0.01f)
                                  .SetWidth (Screen.width * 0.2 + "px")
                                  .SetHeight (0.1f));

                            submitAnswerButton.OnClick (SubmitAnswer);

                            c.Append (submitAnswerButton);
                    }

                    for (int i = 0; i < this.question.GetAnswers().Length; i++) {

                            GUIButton button = new GUIButton ();

                            button.SetText (this.question.GetAnswers () [i]);
                            button.SetBox (questionBoxes [i]);

                            if (currentAnswer == i) {
                                    button.SetPressed (true);
                            }

                            switch (i) {
                            case 0:
                                    button.OnClick (QuestionAnswerA);
                                    break;
                            case 1:
                                    button.OnClick (QuestionAnswerB);
                                    break;
                            case 2:
                                    button.OnClick (QuestionAnswerC);
                                    break;
                            case 3:
                                    button.OnClick (QuestionAnswerD);
                                    break;
                            default:
                                    break;
                            }

                            c.Append (button);
                    }

                    c.Append (backButton);
            }

            GUIStructure questionGUI = qFactory.Build ();
            questionGUI.OnGUI (gameObject);

            break;
        case SlideState.TEXT:
            gui.OnGUI (gameObject);
            break;
        case SlideState.DONE:
            FlowControl.NextSlide ();
            break;
        default:
            break;
        }
    }
コード例 #22
0
        protected override void Load(GUIFactory factory)
        {
            var font    = this.Resourses.LoadAsset <Font>("Fonts\\Consolas.fnt"); // Load the default font.
            var bigfont = this.Resourses.LoadAsset <Font>("Fonts\\BigMetro.fnt"); // Load another font.

            this.Panel.BackgroundColor = Color.White;

            //Left aligned golden label.
            Label left = new Label(font, "A left aligned label.");

            left.TextColor = Color.Gold;
            left.Position  = new Vector2(50, 50);
            left.Size      = new Vector2(300, font.Size);

            //Adds the label to the root panel. Now it will exsist in the window.
            this.Panel.AddControl(left);

            //Center aligned orange halfopaqe label.
            Label center = new Label(font, "Center aligned label:");

            center.Alignment = TextAlignment.Center;
            center.TextColor = Color.Orange * 0.5f; //Creates the color orange and premultiplies it by 0.5f alpha.
            center.Position  = new Vector2(50, left.Bounds.Bottom + 10);
            center.Size      = new Vector2(300, font.Size);

            this.Panel.AddControl(center);

            //Right Aligned label.
            Label right = new Label(font, "Right Aligned Label:");

            right.Alignment = TextAlignment.Right;
            right.TextColor = Color.Magenta;
            right.Position  = new Vector2(50, center.Bounds.Bottom + 10);
            right.Size      = new Vector2(300, font.Size);

            this.Panel.AddControl(right);

            //Multi line label.
            Label multiLine = new Label(font, "This is a \nmulti-line label");

            multiLine.TextColor = Color.Black;
            multiLine.Position  = new Vector2(50, right.Bounds.Bottom + 10);
            multiLine.Size      = new Vector2(300, font.Size * 2);

            this.Panel.AddControl(multiLine);


            //Label with a non transparent background.
            Label backgroundLabel = new Label(font, "This is a label with non transparent background color.");

            backgroundLabel.BackgroundColor = Color.Purple;
            backgroundLabel.TextColor       = Color.White;
            backgroundLabel.Position        = new Vector2(50, multiLine.Bounds.Bottom + 10);
            backgroundLabel.Size            = new Vector2(450, font.Size);

            this.Panel.AddControl(backgroundLabel);

            //Label with a big font.
            Label bigLabel = new Label(bigfont, "This is a label with a BIG font.");

            bigLabel.TextColor = Color.Black;
            bigLabel.Position  = new Vector2(50, backgroundLabel.Bounds.Bottom + 10);
            bigLabel.Size      = new Vector2(400, bigfont.Size);

            this.Panel.AddControl(bigLabel);


            //Window centered label.
            Label windowCenter = new Label(bigfont, "Window Center Label");

            windowCenter.TextColor = Color.Black;
            windowCenter.Position  = new Vector2(this.Width / 2, 50);
            windowCenter.Size      = new Vector2(400, bigfont.Size);
            windowCenter.Origin    = Origin.Center;
            windowCenter.Alignment = TextAlignment.Center;

            //Registers a lambda to the resize event and correctly reposition the windowCenter label.
            this.Resize += () =>
            {
                windowCenter.Position = new Vector2(this.Width / 2, 50);
            };

            this.Panel.AddControl(windowCenter);
        }
    // Use this for initialization
    void Start()
    {
        // Bootstrap Assets
        Assets.GetInstance();

        // Create "Start a Lesson" Button
        GUIButton startALessonButton = new GUIButton();
        startALessonButton
            .SetText(GUIConst.startALessonText)
            .OnClick(FlowControl.GoToLessonScreen)
            .SetBox((new Box())
                .SetMarginTop (0.0f)
                .SetMarginRight (0.0f)
                .SetMarginBottom (0.70f)
                .SetMarginLeft (0.0f));

        // Create "Visit Mantaray AR Website" Button
        GUIButton getARTargets = new GUIButton();
        getARTargets
            .SetText(GUIConst.getARTargets)
            .OnClick(FlowControl.GetTargets)
            .SetBox((new Box())
                .SetMarginTop (0.35f)
                .SetMarginRight (0.0f)
                .SetMarginBottom (0.35f)
                .SetMarginLeft (0.0f));

        // Create "Visit Mantaray AR Website" Button
        GUIButton visitMantarayARWebsiteButton = new GUIButton();
        visitMantarayARWebsiteButton
            .SetText(GUIConst.visitMantarayARWebsiteText)
            .OnClick(FlowControl.GoToWebsite)
            .SetBox((new Box())
                .SetMarginTop (0.70f)
                .SetMarginRight (0.0f)
                .SetMarginBottom (0.0f)
                .SetMarginLeft (0.0f));

        // Create "Help" Button
        GUIButton helpButton = new GUIButton ();
        helpButton
            .SetText(GUIConst.helpButtonText)
            .OnClick(FlowControl.ShowHelpMenu)
                .SetBox((new Box())
                .SetMarginTop (0.0f)
                .SetMarginRight (0.0f)
                .SetMarginBottom (0.0f)
                .SetMarginLeft (0.0f));

        // Build the GUI
        GUIFactory factory = new GUIFactory ();

        factory
            .Append(new GUIImage("splash-background"));

        ((GUILabel)factory
            .CreateLabel ())
                .SetStyle (new GUIStyle())
                .SetBox ((new Box ())
                    .SetMarginTop (0.1f)
                    .SetMarginRight (0.05f)
                    .SetMarginBottom ("auto")
                    .SetMarginLeft (0.05f)
                    .SetHeight (0.45f))
                .Append ((new GUIImage("splash-logo")).SetScaleMode(ScaleMode.ScaleToFit));

        factory
            .CreateContainer ()
                .SetBox ((new Box ())
                    .SetMarginTop ("auto")
                    .SetMarginRight (0.2f)
                    .SetMarginBottom (0.1f)
                    .SetMarginLeft (0.2f)
                    .SetHeight (0.4f))
                .Append (startALessonButton)
                .Append (getARTargets)
                .Append (visitMantarayARWebsiteButton);

        factory
            .CreateContainer ()
                .SetBox ((new Box())
                    .SetMarginTop ("auto")
                    .SetMarginLeft ("auto")
                    .SetMarginBottom ("5px")
                    .SetMarginRight ("5px")
                    .SetHeight (0.08f)
                    .SetWidth("32px"))
                .Append(helpButton);

        gui = factory.Build();
    }
    /**
     * Initialization code.
     *
     * Set up distances and origin points.
     */
    void Start()
    {
        controller = GetComponent<CharacterController>();

        // Adjust the collider size to fit a fish
        controller.height = colliderHeight;
        controller.radius = colliderRadius;

        model = this.GetComponent<ARModel>();
        cam = Camera.main;

        float componentMaxDistance = maxDistance / 2;
        float x = Random.Range(-componentMaxDistance, componentMaxDistance);
        float y = Random.Range(0, componentMaxDistance * 2);
        float z = Random.Range(-componentMaxDistance, componentMaxDistance);
        Vector3 startPoint = origin + new Vector3(x, y, z);

        transform.Translate(startPoint);
        centerPoint = origin;

        affected = gameObject.name.Contains("affected");

        //  ------------------------ Set up GUI ----------------------------------- \\
        // Create affected button
        GUIButton isAffected = new GUIButton ();
        isAffected.SetText("Yes");
        isAffected.SetBox (new Box()
            .SetMarginTop("auto")
            .SetMarginRight(0.01f)
            .SetMarginLeft("auto")
            .SetMarginBottom(0.01f)
            .SetWidth(Screen.width * 0.2 + "px")
            .SetHeight (0.4f));

        isAffected.OnClick (this.IThinkItsAffected);

        // Create not affected button
        GUIButton isNotAffected = new GUIButton ();
        isNotAffected.SetText("No");
        isNotAffected.SetBox (new Box()
            .SetMarginTop("auto")
            .SetMarginRight("auto")
            .SetMarginLeft(0.01f)
            .SetMarginBottom(0.01f)
            .SetWidth(Screen.width * 0.2 + "px")
            .SetHeight (0.4f));

        isNotAffected.OnClick (this.IThinkItsNotAffected);

        GUIFactory factory = new GUIFactory ();

        factory.CreateLabel ("Has this fish been affected by oil?")
            .SetBox(new Box()
                .SetMarginBottom(0.1f)
                .SetMarginTop(0.6f)
                .SetMarginLeft(0.1f)
                .SetMarginRight(0.1f))
                        .Append(isAffected)
                        .Append(isNotAffected);

        gui = factory.Build ();

        // -------------------- Look closely GUI Set up ----------------------------------- \\
        // Create Confirm button
        GUIButton confirm = new GUIButton ();
        confirm.SetText("Okay");
        confirm.SetBox (new Box()
                           .SetMarginTop("auto")
                           .SetMarginRight(0.01f)
                           .SetMarginLeft("auto")
                           .SetMarginBottom(0.01f)
                           .SetWidth(Screen.width * 0.2 + "px")
                           .SetHeight (0.4f));

        confirm.OnClick (this.Confirm);

        GUIFactory lookCloselyGUIFactory = new GUIFactory ();

        GUIComponent gc = lookCloselyGUIFactory.CreateLabel ("Look closely! Fish affected by pollution will have splotches of oil across their scales.")
            .SetBox (new Box ()
                    .SetMarginBottom (0.1f)
                    .SetMarginTop (0.6f)
                    .SetMarginLeft (0.1f)
                     .SetMarginRight (0.1f));

        GUILabel gl = (GUILabel)gc;
        GUIStyle gs = GUIStyles.GetInstance ().DEFAULT_WHITE_STYLE;
        gs.wordWrap = true;
        gl.SetStyle (gs);
        gc.Append (confirm);

        lookCloselyGUI = lookCloselyGUIFactory.Build ();

        // --------------------- alreadyExaminedGUI -------------------------------------- \\
        // Create Confirm button
        GUIButton confirmAlreadyExamined = new GUIButton ();
        confirmAlreadyExamined.SetText("Okay");
        confirmAlreadyExamined.SetBox (new Box()
                           .SetMarginTop("auto")
                           .SetMarginRight(0.01f)
                           .SetMarginLeft("auto")
                           .SetMarginBottom(0.01f)
                           .SetWidth(Screen.width * 0.2 + "px")
                           .SetHeight (0.4f));

        confirmAlreadyExamined.OnClick (this.ConfirmAlreadyExamined);

        GUIFactory alreadyExaminedGUIFactory = new GUIFactory ();

        alreadyExaminedGUIFactory.CreateLabel ("You have already examined this fish.")
            .SetBox (new Box ()
                     .SetMarginBottom (0.1f)
                     .SetMarginTop (0.6f)
                     .SetMarginLeft (0.1f)
                     .SetMarginRight (0.1f))
                .Append (confirmAlreadyExamined);

        alreadyExaminedGUI = alreadyExaminedGUIFactory.Build ();
    }
    public void DoGUI(GameObject gameObject)
    {
        switch (this.state)
        {
        case SlideState.AR:
            this.experience.OnGUI(gameObject);

            // Check if we have found a target!
            GameObject         targetGameObject    = this.experience.GetTarget();
            bool               found               = false;
            TrackableBehaviour mTrackableBehaviour = targetGameObject.GetComponent <TrackableBehaviour> ();

            ImageTargetAbstractBehaviour b = this.experience.GetTarget().GetComponent <ImageTargetAbstractBehaviour> ();
            if (b != null && b.ImageTarget != null)
            {
                String name = b.ImageTarget.Name;

                foreach (GameObject o in this.experience.GetGameObjects())
                {
                    foreach (Renderer component in targetGameObject.GetComponentsInChildren <Renderer>(true))
                    {
                        if (component.enabled && mTrackableBehaviour.TrackableName == name)
                        {
                            found = true;
                        }
                    }

                    foreach (Collider component in targetGameObject.GetComponentsInChildren <Collider>(true))
                    {
                        if (component.enabled && mTrackableBehaviour.TrackableName == name)
                        {
                            found = true;
                        }
                    }
                }
            }

            // If NOT found, show GUI text
            if (!found)
            {
                GUIFactory factory = new GUIFactory();
                factory.CreateLabel(this.text)
                .SetBox(new Box()
                        .SetMarginTop(0.01f)
                        .SetMarginLeft(0.3f)
                        .SetMarginRight(0.3f)
                        .SetHeight(0.1f));

                factory.Build().OnGUI(gameObject);
            }

            break;

        case SlideState.QUESTION:
            // ------------------- Construct GUI for Question ---------------------- \\

            // -------------------------------- QUESTION GUI --------------------------------- \\
            GUIFactory qFactory = new GUIFactory();

            // Go Back Button
            GUIButton backButton = new GUIButton();

            backButton.SetText("Go Back");
            backButton.SetBox(new Box()
                              .SetMarginTop("auto")
                              .SetMarginRight("auto")
                              .SetMarginLeft(0.01f)
                              .SetMarginBottom(0.01f)
                              .SetWidth(Screen.width * 0.2 + "px")
                              .SetHeight(0.1f));

            backButton.OnClick(FlowControl.PreviousSlide);

            GUIComponent c;
            if (this.showDescriptionOfRightAnswer)
            {
                c = new GUILabel(question.GetDescriptionOfRightAnswer());
                qFactory.Append(c);
                c.SetBox((new Box())
                         .SetMarginTop(0.1f)
                         .SetMarginRight(0.1f)
                         .SetMarginBottom(0.1f)
                         .SetMarginLeft(0.1f));

                GUILabel z = (GUILabel)c;
                z.SetStyle(GUIStyles.GetInstance().DEFAULT_SLIDE_STYLE);

                GUIButton continueButton = new GUIButton();
                continueButton.SetText("Continue");
                continueButton.SetBox(new Box()
                                      .SetMarginTop("auto")
                                      .SetMarginLeft("auto")
                                      .SetMarginRight(0.01f)
                                      .SetMarginBottom(0.01f)
                                      .SetWidth(Screen.width * 0.2 + "px")
                                      .SetHeight(0.1f));

                continueButton.OnClick(Continue);

                c.Append(continueButton);
            }
            else
            {
                if (this.showHint)
                {
                    c = new GUIButton();
                    qFactory.Append(c);
                    c.SetBox((new Box())
                             .SetMarginTop(0.1f)
                             .SetMarginRight(0.1f)
                             .SetMarginBottom(0.1f)
                             .SetMarginLeft(0.1f));

                    GUIButton z = (GUIButton)c;
                    z.SetStyle(GUIStyles.GetInstance().DEFAULT_SLIDE_STYLE);
                    z.SetText(question.GetHint() + "\n\n(Click to hide hint)");
                    z.OnClick(HideHint);
                }
                else
                {
                    c = qFactory
                        .CreateLabel(question.GetText())
                        .SetBox((new Box())
                                .SetMarginTop(0.1f)
                                .SetMarginRight(0.1f)
                                .SetMarginBottom(0.1f)
                                .SetMarginLeft(0.1f));

                    GUILabel l = (GUILabel)c;

                    l.SetStyle(GUIStyles.GetInstance().DEFAULT_SLIDE_STYLE);
                }
                if (currentAnswer != -1)
                {
                    // We have a selected answer, show the "next" button
                    GUIButton submitAnswerButton = new GUIButton();
                    submitAnswerButton.SetText("Submit Answer");
                    submitAnswerButton.SetBox(new Box()
                                              .SetMarginTop("auto")
                                              .SetMarginLeft("auto")
                                              .SetMarginRight(0.01f)
                                              .SetMarginBottom(0.01f)
                                              .SetWidth(Screen.width * 0.2 + "px")
                                              .SetHeight(0.1f));

                    submitAnswerButton.OnClick(SubmitAnswer);

                    c.Append(submitAnswerButton);
                }

                for (int i = 0; i < this.question.GetAnswers().Length; i++)
                {
                    GUIButton button = new GUIButton();

                    button.SetText(this.question.GetAnswers() [i]);
                    button.SetBox(questionBoxes [i]);

                    if (currentAnswer == i)
                    {
                        button.SetPressed(true);
                    }

                    switch (i)
                    {
                    case 0:
                        button.OnClick(QuestionAnswerA);
                        break;

                    case 1:
                        button.OnClick(QuestionAnswerB);
                        break;

                    case 2:
                        button.OnClick(QuestionAnswerC);
                        break;

                    case 3:
                        button.OnClick(QuestionAnswerD);
                        break;

                    default:
                        break;
                    }

                    c.Append(button);
                }

                c.Append(backButton);
            }

            GUIStructure questionGUI = qFactory.Build();
            questionGUI.OnGUI(gameObject);

            break;

        case SlideState.TEXT:
            gui.OnGUI(gameObject);
            break;

        case SlideState.DONE:
            FlowControl.NextSlide();
            break;

        default:
            break;
        }
    }
    // Use this for initialization
    void Start()
    {
        // Create a list of lessons
        List<Lesson> lessons = CustomLessons.GetInstance().GetLessons();

        // Create Go Back to Menu Button
        GUIButton goBack = new GUIButton ();
        goBack
            .SetText("Go Back to Main Menu")
            .OnClick(FlowControl.ShowMainMenu)
                .SetBox((new Box())
                .SetMarginTop (0.0f)
                .SetMarginRight (0.0f)
                .SetMarginBottom (0.0f)
                .SetMarginLeft (0.0f));

        // Create "Help" Button
        GUIButton helpButton = new GUIButton ();
        helpButton
            .SetText(GUIConst.helpButtonText)
            .OnClick(FlowControl.ShowHelpMenu)
                .SetBox((new Box())
                .SetMarginTop (0.0f)
                .SetMarginRight (0.0f)
                .SetMarginBottom (0.0f)
                .SetMarginLeft (0.0f));

        GUIFactory factory = new GUIFactory ();

        factory
            .Append(new GUIImage("splash-background"));

        // Attach them to a "Lesson Scroll Area"
        factory
            .CreateScrollArea ()
                .SetBox((new Box())
                    .SetMarginBottom(0.1f)
                    .SetMarginTop(0.1f)
                    .SetMarginLeft(0.1f)
                    .SetMarginRight(0.1f))
                .Append(new GUILessonList(lessons));

        factory.CreateContainer()
            .SetBox ((new Box())
                .SetMarginTop ("auto")
                .SetMarginLeft ("5px")
                .SetMarginBottom ("5px")
                .SetMarginRight ("auto")
                .SetHeight (0.08f)
                .SetWidth(0.4f)).Append (goBack);

        factory
            .CreateContainer ()
                .SetBox ((new Box())
                    .SetMarginTop ("auto")
                    .SetMarginLeft ("auto")
                    .SetMarginBottom ("5px")
                    .SetMarginRight ("5px")
                    .SetHeight (0.08f)
                    .SetWidth("32px"))
                .Append(helpButton);

        // Build
        gui = factory.Build();
    }
    // Use this for initialization
    void Start()
    {
        // Create a list of lessons
        List <Lesson> lessons = CustomLessons.GetInstance().GetLessons();

        // Create Go Back to Menu Button
        GUIButton goBack = new GUIButton();

        goBack
        .SetText("Go Back to Main Menu")
        .OnClick(FlowControl.ShowMainMenu)
        .SetBox((new Box())
                .SetMarginTop(0.0f)
                .SetMarginRight(0.0f)
                .SetMarginBottom(0.0f)
                .SetMarginLeft(0.0f));

        // Create "Help" Button
        GUIButton helpButton = new GUIButton();

        helpButton
        .SetText(GUIConst.helpButtonText)
        .OnClick(FlowControl.ShowHelpMenu)
        .SetBox((new Box())
                .SetMarginTop(0.0f)
                .SetMarginRight(0.0f)
                .SetMarginBottom(0.0f)
                .SetMarginLeft(0.0f));

        GUIFactory factory = new GUIFactory();

        factory
        .Append(new GUIImage("splash-background"));

        // Attach them to a "Lesson Scroll Area"
        factory
        .CreateScrollArea()
        .SetBox((new Box())
                .SetMarginBottom(0.1f)
                .SetMarginTop(0.1f)
                .SetMarginLeft(0.1f)
                .SetMarginRight(0.1f))
        .Append(new GUILessonList(lessons));

        factory.CreateContainer()
        .SetBox((new Box())
                .SetMarginTop("auto")
                .SetMarginLeft("5px")
                .SetMarginBottom("5px")
                .SetMarginRight("auto")
                .SetHeight(0.08f)
                .SetWidth(0.4f)).Append(goBack);

        factory
        .CreateContainer()
        .SetBox((new Box())
                .SetMarginTop("auto")
                .SetMarginLeft("auto")
                .SetMarginBottom("5px")
                .SetMarginRight("5px")
                .SetHeight(0.08f)
                .SetWidth("32px"))
        .Append(helpButton);

        // Build
        gui = factory.Build();
    }
コード例 #28
0
 /// <summary>
 /// Called once upon load.
 /// </summary>
 protected abstract void Load(GUIFactory factory);
    public Slide(string text)
    {
        state     = SlideState.TEXT;
        this.text = text;
        GUIFactory factory = new GUIFactory();

        // Go Back Button
        GUIButton backButton = new GUIButton();

        backButton.SetText("Go Back");
        backButton.SetBox(new Box()
                          .SetMarginTop("auto")
                          .SetMarginRight("auto")
                          .SetMarginLeft(0.01f)
                          .SetMarginBottom(0.01f)
                          .SetWidth(Screen.width * 0.2 + "px")
                          .SetHeight(0.1f));

        backButton.OnClick(FlowControl.PreviousSlide);

        // Go Forward Button
        GUIButton nextButton = new GUIButton();

        nextButton.SetText("Continue");
        nextButton.SetBox(new Box()
                          .SetMarginTop("auto")
                          .SetMarginLeft("auto")
                          .SetMarginRight(0.01f)
                          .SetMarginBottom(0.01f)
                          .SetWidth(Screen.width * 0.2 + "px")
                          .SetHeight(0.1f));

        nextButton.OnClick(FlowControl.NextSlide);

        GUIComponent c = factory
                         .CreateLabel(text)
                         .SetBox((new Box())
                                 .SetMarginTop(0.1f)
                                 .SetMarginRight(0.1f)
                                 .SetMarginBottom(0.1f)
                                 .SetMarginLeft(0.1f));

        GUILabel l = (GUILabel)c;

        l.SetStyle(GUIStyles.GetInstance().DEFAULT_SLIDE_STYLE);


        l.Append(nextButton);
        l.Append(backButton);

        gui = factory.Build();

        questionBoxes = new Box[4];

        questionBoxes [0] = new Box();
        questionBoxes [0]
        .SetMarginTop(0.55f)
        .SetMarginRight(0.51f)
        .SetMarginBottom("auto")
        .SetMarginLeft(0.01f)
        .SetHeight(0.1f);

        questionBoxes [1] = new Box();
        questionBoxes [1]
        .SetMarginTop(0.55f)
        .SetMarginRight(0.01f)
        .SetMarginBottom("auto")
        .SetMarginLeft(0.51f)
        .SetHeight(0.1f);

        questionBoxes [2] = new Box();
        questionBoxes [2]
        .SetMarginTop(0.7f)
        .SetMarginRight(0.51f)
        .SetMarginBottom("auto")
        .SetMarginLeft(0.01f)
        .SetHeight(0.1f);

        questionBoxes [3] = new Box();
        questionBoxes [3]
        .SetMarginTop(0.7f)
        .SetMarginRight(0.01f)
        .SetMarginBottom("auto")
        .SetMarginLeft(0.51f)
        .SetHeight(0.1f);
    }
    static FlowControl()
    {
        // Draw Panel

        // Draw buttons:
        // Create "Start a Lesson" Button
        GUIButton startALessonButton = new GUIButton();
        startALessonButton
            .SetText("Pick A Lesson")
                .OnClick(FlowControl.GoToLessonScreen)
                .SetBox((new Box())
                        .SetMarginTop (0.0f)
                        .SetMarginRight (0.0f)
                        .SetMarginBottom (0.80f)
                        .SetMarginLeft (0.0f));

        // Create "Visit Mantaray AR Website" Button
        GUIButton getARTargets = new GUIButton();
        getARTargets
            .SetText(GUIConst.getARTargets)
                .OnClick(FlowControl.GetTargets)
                .SetBox((new Box())
                        .SetMarginTop (0.25f)
                        .SetMarginRight (0.0f)
                        .SetMarginBottom (0.55f)
                        .SetMarginLeft (0.0f));

        // Create "Visit Mantaray AR Website" Button
        GUIButton visitMantarayARWebsiteButton = new GUIButton();
        visitMantarayARWebsiteButton
            .SetText(GUIConst.visitMantarayARWebsiteText)
                .OnClick(FlowControl.GoToWebsite)
                .SetBox((new Box())
                        .SetMarginTop (0.50f)
                        .SetMarginRight (0.0f)
                        .SetMarginBottom (0.30f)
                        .SetMarginLeft (0.0f));

        // Create "Return" Button
        GUIButton exitMenuButton = new GUIButton();
        exitMenuButton
            .SetText("Go Back")
                .OnClick(FlowControl.ExitMenu)
                .SetBox((new Box())
                        .SetMarginTop (0.75f)
                        .SetMarginRight (0.0f)
                        .SetMarginBottom (0.05f)
                        .SetMarginLeft (0.0f));

        // Build the GUI
        GUIFactory factory = new GUIFactory ();

        factory
            .Append(new GUIImage("dark-transparent-swatch").SetScaleMode(ScaleMode.StretchToFill));

        factory
            .CreateContainer ()
                .SetBox ((new Box ())
                         .SetMarginTop (0.2f)
                         .SetMarginRight (0.2f)
                         .SetMarginBottom (0.2f)
                         .SetMarginLeft (0.2f))
                .Append (startALessonButton)
                .Append (getARTargets)
                .Append (visitMantarayARWebsiteButton)
                .Append (exitMenuButton);

        FlowControl.gui = factory.Build();
    }
コード例 #31
0
 public Application(GUIFactory factory)
 {
     this.factory = factory;
 }
コード例 #32
0
        public Application(GUIFactory factory)
        {
            Button button = factory.createButton();

            button.paint();
        }
コード例 #33
0
 /// <summary>
 /// Called once upon load.
 /// </summary>
 protected abstract void Load(GUIFactory factory);