コード例 #1
0
ファイル: AtomicMain.cs プロジェクト: joorjoor/AtomicExamples
    public override void Start()
    {
        AtomicNET.GetSubsystem <Player> ().LoadScene("Scenes/Scene.scene");

        var ui = GetSubsystem <UI> ();

        ui.AddFont("Textures/BrokenGlass.ttf", "BrokenGlass"); // add a gooder font
        ui.LoadSkin("Textures/desktop.tb.txt");                // load in the app skin

        ResourceCache cache    = GetSubsystem <ResourceCache> ();
        Graphics      graphics = GetSubsystem <Graphics> ();

        graphics.SetWindowTitle("PeriodicApp");
        Image icon = cache.GetResource <Image> ("Textures/AtomicLogo32.png");

        graphics.SetWindowIcon(icon);

        myuivew  = new UIView();
        mylayout = new UILayout();                  // make the host widget for all visible ui
        mylayout.SetId("UIPeriodicTable");          // tag it, like a big game scientist
        mylayout.SetRect(myuivew.GetRect());        //size it to fill the screen area
        mylayout.SetLayoutConfig("YAGAC");          //all-in-one setting
        mylayout.SetSkinBg("background_solid");     // make it look gooder
        mylayout.Load("Scenes/main_layout.ui.txt"); // load the main layout
        myuivew.AddChild(mylayout);                 // And make it show up.

        UITabContainer maintb    = (UITabContainer)mylayout.GetWidget("maintabs");
        UITabContainer acttb     = (UITabContainer)mylayout.GetWidget("primarytabs");
        UITabContainer semitb    = (UITabContainer)mylayout.GetWidget("moretabs");
        UITabContainer viewtb    = (UITabContainer)mylayout.GetWidget("supporttabs");
        UITabContainer supporttb = (UITabContainer)mylayout.GetWidget("atomictabs");

        supporttb.SetCurrentPage(0);
        viewtb.SetCurrentPage(0);
        semitb.SetCurrentPage(0);
        acttb.SetCurrentPage(0);
        maintb.SetCurrentPage(0);  // do this or else the tab contents look like crap!
        mylog = (UITextField)mylayout.GetWidget("LogText");
        UIWidget ea = mylayout.GetWidget("exitapp");

        var cota = new code_table();

        cota.Setup(mylayout);
        var cobg = new code_uibargraph();

        cobg.Setup(mylayout.GetWidget("pageuibargraph"));
        var cobu = new code_uibutton();

        cobu.Setup(mylayout.GetWidget("pageuibutton"));
        var cocb = new code_uicheckbox();

        cocb.Setup(mylayout.GetWidget("pageuicheckbox"));
        var cocl = new code_uiclicklabel();

        cocl.Setup(mylayout.GetWidget("pageuiclicklabel"));
        var coch = new code_uicolorwheel();

        coch.Setup(mylayout.GetWidget("pageuicolorwheel"));
        var cocw = new code_uicolorwidget();

        cocw.Setup(mylayout.GetWidget("pageuicolorwidget"));
        var coco = new code_uicontainer();

        coco.Setup(mylayout.GetWidget("pageuicontainer"));
        var coef = new code_uieditfield();

        coef.Setup(mylayout.GetWidget("pageuieditfield"));
        var cofw = new code_uifinderwindow();

        cofw.Setup(mylayout.GetWidget("pageuifinderwindow"));
        var cofd = new code_uifontdescription();

        cofd.Setup(mylayout.GetWidget("pageuifontdescription"));
        var coiw = new code_uiimagewidget();

        coiw.Setup(mylayout.GetWidget("pageuiimagewidget"));
        var cois = new code_uiinlineselect();

        cois.Setup(mylayout.GetWidget("pageuiinlineselect"));
        var colo = new code_uilayout();

        colo.Setup(mylayout.GetWidget("pageuilayout"));
        var colp = new code_uilayoutparams();

        colp.Setup(mylayout.GetWidget("pageuilayoutparams"));
        var comi = new code_uimenuitem();

        comi.Setup(mylayout.GetWidget("pageuimenuitem"));
        var comw = new code_uimenuwindow();

        comw.Setup(mylayout.GetWidget("pageuimenuwindow"));
        var come = new code_uimessagewindow();

        come.Setup(mylayout.GetWidget("pageuimessagewindow"));
        var copw = new code_uipromptwindow();

        copw.Setup(mylayout.GetWidget("pageuipromptwindow"));
        var copd = new code_uipulldownmenu();

        copd.Setup(mylayout.GetWidget("pageuipulldownmenu"));
        var corb = new code_uiradiobutton();

        corb.Setup(mylayout.GetWidget("pageuiradiobutton"));
        var cosv = new code_uisceneview();

        cosv.Setup(mylayout.GetWidget("pageuisceneview"));
        var cosb = new code_uiscrollbar();

        cosb.Setup(mylayout.GetWidget("pageuiscrollbar"));
        var cosc = new code_uiscrollcontainer();

        cosc.Setup(mylayout.GetWidget("pageuiscrollcontainer"));
        var cose = new code_uisection();

        cose.Setup(mylayout.GetWidget("pageuisection"));
        var cosd = new code_uiselectdropdown();

        cosd.Setup(mylayout.GetWidget("pageuiselectdropdown"));
        var cosi = new code_uiselectitem();

        cosi.Setup(mylayout.GetWidget("pageuiselectitem"));
        var cosl = new code_uiselectlist();

        cosl.Setup(mylayout.GetWidget("pageuiselectlist"));
        var cosp = new code_uiseparator();

        cosp.Setup(mylayout.GetWidget("pageuiseparator"));
        var cosk = new code_uiskinimage();

        cosk.Setup(mylayout.GetWidget("pageuiskinimage"));
        var cosa = new code_uislider();

        cosa.Setup(mylayout.GetWidget("pageuislider"));
        var cotc = new code_uitabcontainer();

        cotc.Setup(mylayout.GetWidget("pageuitabcontainer"));
        var cotf = new code_uitextfield();

        cotf.Setup(mylayout.GetWidget("pageuitextfield"));
        var cotw = new code_uitexturewidget();

        cotw.Setup(mylayout.GetWidget("pageuitexturewidget"));
        var cowd = new code_uiwidget();

        cowd.Setup(mylayout.GetWidget("pageuiwidget"));
        var cowi = new code_uiwindow();

        cowi.Setup(mylayout.GetWidget("pageuiwindow"));

        SubscribeToEvent <WidgetEvent> (ea, ev => {
            if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
            {
                GetSubsystem <Engine> ().Exit();
            }
        });

        SubscribeToEvent <KeyDownEvent> (e => {
            if (e.Key == Constants.KEY_ESCAPE)
            {
                GetSubsystem <Engine> ().Exit();
            }
        });
    }
コード例 #2
0
    private static void HandleUilayoutEvent(WidgetEvent ev)
    {
        UIWidget widget = (UIWidget)ev.Target;

        if (widget.Equals(null))
        {
            return;
        }
        if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
        {
            if (widget.GetId() == "go_layout_config")    // its LAYOUT-O-MATIC time.
            {
                AtomicMain.AppLog("UILayout action : " + widget.GetId() + " was pressed, its LAYOUT-O-MATIC time");
                UIView   someview = widget.GetView();
                UIWindow window   = new UIWindow();
                window.SetSettings(UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_DEFAULT);
                window.SetText("LAYOUT-O-MATIC(tm)");
                window.Load("Scenes/view_layout.ui.txt");
                window.ResizeToFitContent();
                someview.AddChild(window);

                UIWidget okbutt = window.GetWidget("ok");
                okbutt.SubscribeToEvent <WidgetEvent> (okbutt, HandleUilayoutEvent);

                var lox = new AtomicEngine.Vector <AtomicEngine.UIWidget>();
                window.SearchWidgetClass("TBRadioButton", lox);
                for (var ii = 0; ii < lox.Size; ii++)
                {
                    lox[ii].SubscribeToEvent <WidgetEvent> (lox [ii], HandleUilayoutEvent);
                }
            }
            if (widget.GetId() == "ok")
            {
                UIWindow mywindow = (UIWindow)AtomicMain.FindTheWindowParent(widget);
                if (!mywindow.Equals(null))
                {
                    mywindow.Close();
                }
            }
            if (widget.GetId() == "set_ax")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(0, 'X');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_ay")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(0, 'Y');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }

            if (widget.GetId() == "set_sza")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(1, 'A');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_szg")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(1, 'G');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_szp")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(1, 'P');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }


            if (widget.GetId() == "set_posc")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(2, 'C');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_posg")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(2, 'G');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_posl")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(2, 'L');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_posr")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(2, 'R');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }

            if (widget.GetId() == "set_dista")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(3, 'A');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_distg")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(3, 'G');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_distp")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(3, 'P');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }

            if (widget.GetId() == "set_dpc")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(4, 'C');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_dpl")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(4, 'L');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_dpr")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(4, 'R');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
        }
    }
コード例 #3
0
    public void Setup(UIWidget layout)
    {
        layoutomaticstr = "XGCPC";

        var dest = new AtomicEngine.Vector <AtomicEngine.UIWidget>();

        layout.SearchWidgetClass("TBButton", dest);
        for (var ii = 0; ii < dest.Size; ii++)
        {
            dest[ii].SubscribeToEvent <WidgetEvent> (dest [ii], HandleUilayoutEvent);
        }

        UILayout myc = (UILayout)layout.GetWidget("uilayoutcontainer"); // get the container layout
        UIButton tf0 = new UIButton();                                  // the layout-o-matic spawner

        tf0.SetText("LAYOUT-O-MATIC");
        tf0.SetId("go_layout_config");
        UILayout lo0 = new UILayout();

        lo0.SetId("target_layout");
        lo0.SetLayoutConfig("-----");
        lo0.Load("Scenes/simp_button.ui.txt");
        lo0.AddChildBefore(tf0, lo0.GetFirstChild());
        myc.AddChild(lo0);  // drop it in
        tf0.SubscribeToEvent <WidgetEvent> (tf0, HandleUilayoutEvent);

        UITextField tf1 = new UITextField();

        tf1.SetText("layout config XACAC");
        UILayout lo1 = new UILayout();

        lo1.SetLayoutConfig("XACAC");
        lo1.Load("Scenes/simp_button.ui.txt");
        lo1.AddChildBefore(tf1, lo1.GetFirstChild());
        myc.AddChild(lo1);

        UITextField tf2 = new UITextField();

        tf2.SetText("layout config XGCAC");
        UILayout lo2 = new UILayout();

        lo2.SetLayoutConfig("XGCAC");
        lo2.Load("Scenes/simp_button.ui.txt");
        lo2.AddChildBefore(tf2, lo2.GetFirstChild());
        myc.AddChild(lo2);

        UITextField tf3 = new UITextField();

        tf3.SetText("layout config XPCAC");
        UILayout lo3 = new UILayout();

        lo3.SetLayoutConfig("XPCAC");
        lo3.Load("Scenes/simp_button.ui.txt");
        lo3.AddChildBefore(tf3, lo3.GetFirstChild());
        myc.AddChild(lo3);

        UITextField tf4 = new UITextField();

        tf4.SetText("layout config XACGC");
        UILayout lo4 = new UILayout();

        lo4.SetLayoutConfig("XACGC");
        lo4.Load("Scenes/simp_button.ui.txt");
        lo4.AddChildBefore(tf4, lo4.GetFirstChild());
        myc.AddChild(lo4);

        UITextField tf5 = new UITextField();

        tf5.SetText("layout config XGRGC");
        UILayout lo5 = new UILayout();

        lo5.SetLayoutConfig("XGRGC");
        lo5.Load("Scenes/simp_button.ui.txt");
        lo5.AddChildBefore(tf5, lo5.GetFirstChild());
        myc.AddChild(lo5);

        UITextField tf6 = new UITextField();

        tf6.SetText("layout config XPLGC");
        UILayout lo6 = new UILayout();

        lo6.SetLayoutConfig("XPLGC");
        lo6.Load("Scenes/simp_button.ui.txt");
        lo6.AddChildBefore(tf6, lo6.GetFirstChild());
        myc.AddChild(lo6);

        UITextField tf7 = new UITextField();

        tf7.SetText("layout config XACPC");
        UILayout lo7 = new UILayout();

        lo7.SetLayoutConfig("XACPC");
        lo7.Load("Scenes/simp_button.ui.txt");
        lo7.AddChildBefore(tf7, lo7.GetFirstChild());
        myc.AddChild(lo7);

        UITextField tf8 = new UITextField();

        tf8.SetText("layout config XGLPL");
        UILayout lo8 = new UILayout();

        lo8.SetLayoutConfig("XGLPL");
        lo8.Load("Scenes/simp_button.ui.txt");
        lo8.AddChildBefore(tf8, lo8.GetFirstChild());
        myc.AddChild(lo8);

        UITextField tf9 = new UITextField();

        tf9.SetText("layout config XPCPR");
        UILayout lo9 = new UILayout();

        lo9.SetLayoutConfig("XPCPR");
        lo9.Load("Scenes/simp_button.ui.txt");
        lo9.AddChildBefore(tf9, lo9.GetFirstChild());
        myc.AddChild(lo9);
    }
コード例 #4
0
    private static void HandleUitabcontainerEvent(WidgetEvent ev)
    {
        UIWidget widget = (UIWidget)ev.Target;
        string   refid  = (string)ev.RefID;

        if (widget.Equals(null))
        {
            return;
        }
        if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
        {
            if (widget.GetId() == "uitabcontainercode")
            {
                AtomicMain.AppLog("UITabContainer support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uitabcontainer.cs", widget.GetParent());
            }
            if (widget.GetId() == "uitabcontainerlayout")
            {
                AtomicMain.AppLog("UITabContainer support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uitabcontainer.ui.txt", widget.GetParent());
            }


            if (widget.GetId() == "uitabcontainerremove")
            {
                AtomicMain.AppLog("UITabContainer action : " + widget.GetId() + " was pressed ");
                UITabContainer tcx     = (UITabContainer)widget.FindWidget("UITabContainerDemo");
                int            current = tcx.GetCurrentPage();
                tcx.DeletePage(current);
            }
            if (widget.GetId() == "uitabcontaineradd")
            {
                AtomicMain.AppLog("UITabContainer action : " + widget.GetId() + " was pressed ");
                UITabContainer tcx = (UITabContainer)widget.FindWidget("UITabContainerDemo");
                tcx.AddTabPageFile("New File", "Scenes/sheet.ui.txt");
            }
            if (widget.GetId() == "uitabcontainermake")
            {
                AtomicMain.AppLog("UITabContainer action : " + widget.GetId() + " was pressed ");
                var            cache = GetSubsystem <ResourceCache>();
                UITabContainer tcx   = (UITabContainer)widget.FindWidget("UITabContainerDemo");
                UILayout       lo    = new UILayout();
                lo.SetLayoutConfig("YAGAC");     // YACAC!
                UIEditField myeditfield = new UIEditField();
                myeditfield.SetGravity(UI_GRAVITY.UI_GRAVITY_ALL);
                myeditfield.SetMultiline(true);
                File   filex = cache.GetFile("Components/code_uitabcontainer.cs");
                String textx = filex.ReadText();
                filex.Close();
                myeditfield.SetText(textx);
                UIFontDescription myfont = new UIFontDescription();  // put in a coder font
                myfont.SetSize(16);
                myfont.SetId("Vera");
                myeditfield.SetFontDescription(myfont);
                lo.AddChild(myeditfield);
                tcx.AddTabPageWidget("New Code", lo);
            }
            if (widget.GetId() == "uitabcontainerundock")
            {
                AtomicMain.AppLog("UITabContainer action : " + widget.GetId() + " was pressed ");
                UITabContainer tcx     = (UITabContainer)widget.FindWidget("UITabContainerDemo");
                int            current = tcx.GetCurrentPage();
                tcx.UndockPage(current);
            }
            if (widget.GetId() == "uitabcontainerredock")
            {
                AtomicMain.AppLog("UITabContainer action : " + widget.GetId() + " was pressed ");
                UITabContainer tcx = (UITabContainer)widget.FindWidget("UITabContainerDemo");
                if (!tcx.DockWindow("tab1"))
                {
                    if (!tcx.DockWindow("tab2"))
                    {
                        if (!tcx.DockWindow("tab3"))
                        {
                            if (!tcx.DockWindow("New File"))
                            {
                                if (!tcx.DockWindow("New Code"))
                                {
                                    AtomicMain.AppLog("UITabContainer action : no more windows to dock.");
                                }
                            }
                        }
                    }
                }
            }
        }
    }