Example #1
0
        public override void HandleMouse(bool mouseValid, int x, int y, Input input, GuiModule module)
        {
            base.HandleMouse(mouseValid, x, y, input, module);

            if (!mouseValid)
            {
                return;
            }

            if (input.MousePressed())
            {
                if (rect.Contains(x, y))
                {
                    var mouseOffset = y - rect.Y - (handle_size / 2);

                    mouseStart = y;

                    var hitPlace = mouseOffset + (spaceSize / 2);
                    var hitSpace = hitPlace / spaceSize;
                    position = minimum + (int)(hitSpace * step);

                    draggingHandle = true;
                    startPosition  = position;

                    var handler = GetSetting("on-change", null);
                    if (handler != null)
                    {
                        module.ButtonEvent(handler, this);
                    }
                }
            }

            if (input.MouseDown() && draggingHandle)
            {
                var mouseDelta = y - mouseStart;

                var stepsPassed = mouseDelta / spaceSize;
                position = startPosition + (int)(stepsPassed * step);

                if (position < minimum)
                {
                    position = minimum;
                }
                if (position > maximum)
                {
                    position = maximum;
                }

                var handler = GetSetting("on-change", null);
                if (handler != null)
                {
                    module.ButtonEvent(handler, this);
                }
            }

            if (input.MouseReleased())
            {
                draggingHandle = false;
            }
        }
Example #2
0
    private void SetupGuiModule(AgeTransform tableItem, GuiModule guiModule, int index)
    {
        ExternalModuleLine component = tableItem.GetComponent <ExternalModuleLine>();

        if (component == null)
        {
            Diagnostics.LogError("In the MenuModuleSetupScreen, trying to refresh a table item that is not a ExternalModuleLine");
            return;
        }
        if (index % 20 == 0)
        {
            tableItem.StartNewMesh = true;
        }
        if (guiModule.IsInvalid)
        {
            component.SetInvalidMode(guiModule);
        }
        else if (guiModule.IsDownloading)
        {
            component.SetDownloadingMode(guiModule);
        }
        else
        {
            component.RefreshContent(guiModule, base.gameObject, index, true);
        }
        guiModule.ModuleLine = component;
    }
 //释放函数
 public override void Dispose()
 {
     if (guiModule != null)
     {
         GameObject.DestroyImmediate(guiModule.gameObject);
         guiModule = null;
     }
 }
Example #4
0
 public virtual void HandleMouse(bool mouseValid, int x, int y, Input input, GuiModule module)
 {
     Hover = mouseValid && rect.Contains(x, y);
     if (Hover && input.MousePressed())
     {
         var handler = GetSetting("on-click", null);
         if (handler != null)
             module.ButtonEvent(handler, this);
         input.MouseHandled = true;
     }
     if (Visible)
         foreach (var child in children) child.HandleMouse(mouseValid, x, y, input, module);
 }
Example #5
0
        public override void HandleMouse(bool mouseValid, int x, int y, Input input, GuiModule module)
        {
            base.HandleMouse(mouseValid, x, y, input, module);

            if (!mouseValid) return;

            if (input.MousePressed())
            {
                if (rect.Contains(x, y))
                {
                    var mouseOffset = y - rect.Y - (handle_size / 2);

                    mouseStart = y;

                    var hitPlace = mouseOffset + (spaceSize / 2);
                    var hitSpace = hitPlace / spaceSize;
                    position = minimum + (int)(hitSpace * step);

                    draggingHandle = true;
                    startPosition = position;

                    var handler = GetSetting("on-change", null);
                    if (handler != null)
                        module.ButtonEvent(handler, this);
                }
            }

            if (input.MouseDown() && draggingHandle)
            {
                var mouseDelta = y - mouseStart;

                var stepsPassed = mouseDelta / spaceSize;
                position = startPosition + (int)(stepsPassed * step);

                if (position < minimum) position = minimum;
                if (position > maximum) position = maximum;

                var handler = GetSetting("on-change", null);
                if (handler != null)
                    module.ButtonEvent(handler, this);
            }

            if (input.MouseReleased())
            {
                draggingHandle = false;
            }
        }
    private void SetupUpGui()
    {
        // Initialize the loaders
        GuiModule.Initialize(this);
//        NetModule.Initialize(this);

        TweenSharkUnity3D.Initialize(this);

        _guiStage = GlobalGui.GetInstance();

        _guiStage.AddChild(
            _btn = new Button(new Rect(10, 10, 100, 25), "Click Me1")
                   .AddClickHandler(e => TweenButton())
                   .AddMouseOverHandler(e => Debug.Log("Over"))
                   .AddMouseOutHandler(e => Debug.Log("Out"))
            );
        _guiStage.AddChild(
            _btn2 = new Button(new Rect(100, 200, 100, 25), "Klick mich!")
                    .AddClickHandler(e => TweenButton2())
                    .AddMouseOverHandler(e => Debug.Log("Over"))
                    .AddMouseOutHandler(e => Debug.Log("Out"))
            );
    }
 //初始化函数
 public override void Initialization()
 {
     //首先在启动过程中先查看是否出现了错误,如果出现了错误需要显示错误信息
     //然后就不进行下面的过程了
     if (ErrMessageBox.IsShowErrMessageBox)
     {
         ErrMessageBox.ShowErrMessage("游戏启动发生错误,停止自检过程!");
         return;
     }
     //进入游戏待机画面
     base.Initialization();
     guiModule = GameRoot.gameResource.LoadResource_Prefabs("SelfCheckingWindows.prefab").GetComponent <GuiModule>();
     //创建出来自检画面
     guiModule.mainGroup.AutoWidth       = new GuiVector2(1.0f, 0.0f);
     guiModule.mainGroup.AutoHeight      = new GuiVector2(1.0f, 0.0f);
     guiModule.mainGroup.BackgroupSeting = new GuiBackgroup(guiModule.skin.box);
     textdoc            = guiModule.RegisterGuiLableTextDoc("", "", 0.1f, 0.1f, guiModule.skin.label, Color.white, int.MaxValue);
     textdoc.AutoWidth  = new GuiVector2(1.0f, 0.0f);
     textdoc.AutoHeight = new GuiVector2(1.0f, 0.0f);
     //再次加载游戏配置信息,因为从控制台退出后也是会重新开始这个过程的
     UniGameOptionsDefine.LoadGameOptionsDefine();
     //显示非致命错误
     if (GameRoot.non_fatal_error_list != null)
     {
         ShowMessage("发生非致命错误:");
         for (int i = 0; i < GameRoot.non_fatal_error_list.Count; i++)
         {
             ShowMessage(GameRoot.non_fatal_error_list[i]);
         }
         GameRoot.non_fatal_error_list = null;
         ShowMessage("");
         ShowMessage("");
     }
     checkedEvent = CheckedEvent.Eve_Start;
     SelfCheckingProcess(null);
 }
Example #8
0
 public virtual void Update(Input input, GuiModule module)
 {
     //Hover = input.MouseInside(rect);
     if (Hover && input.MousePressed())
     {
         if (settings["on-click"] != null)
             module.ButtonEvent(settings["on-click"], this);
         input.MouseHandled = true;
     }
     if (Visible)
         foreach (var child in children) child.Update(input, module);
 }
Example #9
0
    private void SortGuiModules()
    {
        List <GuiModule> list = new List <GuiModule>();
        int i     = 0;
        int count = this.guiModules.Count;

        if (this.RuntimeModuleNames != null && this.RuntimeModuleNames.Length != 0)
        {
            Diagnostics.Assert(count == this.RuntimeModuleNames.Length - 1, string.Format("ELCP: Module Length Mismatch: guiModules {0}, RuntimeModuleNames {1}", count, this.RuntimeModuleNames.Length - 1));
            string[] runtimeModuleNames = this.RuntimeModuleNames;
            for (int j = 0; j < runtimeModuleNames.Length; j++)
            {
                string    name      = runtimeModuleNames[j];
                GuiModule guiModule = this.guiModules.Find((GuiModule Module) => Module.Name == name);
                if (guiModule != null)
                {
                    list.Add(guiModule);
                }
            }
        }
        else
        {
            while (i < count)
            {
                if (this.guiModules[i].IsDownloading || this.guiModules[i].IsInvalid || this.guiModules[i].Module == null)
                {
                    list.Add(this.guiModules[i]);
                    break;
                }
                i++;
            }
            int k      = 0;
            int count2 = this.guiModules.Count;
            while (k < count2)
            {
                if (!this.guiModules[k].IsDownloading && !this.guiModules[k].IsInvalid && this.guiModules[k].Module != null && this.guiModules[k].Module.Type == RuntimeModuleType.Standalone)
                {
                    list.Add(this.guiModules[k]);
                    break;
                }
                k++;
            }
            int l      = 0;
            int count3 = this.guiModules.Count;
            while (l < count3)
            {
                if (!this.guiModules[l].IsDownloading && !this.guiModules[l].IsInvalid && this.guiModules[l].Module != null && this.guiModules[l].Module.Type == RuntimeModuleType.Conversion)
                {
                    list.Add(this.guiModules[l]);
                    break;
                }
                l++;
            }
            int m      = 0;
            int count4 = this.guiModules.Count;
            while (m < count4)
            {
                if (!this.guiModules[m].IsDownloading && !this.guiModules[m].IsInvalid && this.guiModules[m].Module != null && this.guiModules[m].Module.Type == RuntimeModuleType.Extension)
                {
                    list.Add(this.guiModules[m]);
                }
                m++;
            }
        }
        this.guiModules = list;
    }
    private void SetupUpGui()
    {
        // Initialize the loaders
        GuiModule.Initialize(this);
//        NetModule.Initialize(this);

        TweenSharkUnity3D.Initialize(this);

        _guiStage = GlobalGui.GetInstance();

        _guiStage.AddChild(
            new VGroup()
            .SetPos(10, 10)
            .SetPadding(5)
            .SetSpacing(5)
            .AddChild(
                new Box(new Rect(20, 50, 300, 300), "TweenShark")
                .SetAutoAdjustSize(true)
                .AddChild(
                    new VGroup()
                    .SetPos(0, 20)
                    .SetPadding(5)
                    .AddChild(
                        new Button(new Rect(5, 20, 100, 25), "SpinCube-X")
                        .AddClickHandler((e) => SpinCubeAroundX())
                        )
                    .AddChild(
                        new Button(new Rect(5, 20, 100, 25), "SpinCube-Y")
                        .AddClickHandler((e) => SpinCubeAroundY())
                        )
                    .AddChild(
                        new Button(new Rect(5, 20, 100, 25), "SpinCube-Z")
                        .AddClickHandler((e) => SpinCubeAroundZ())
                        )
                    )
                .AddChild(
                    // first column
                    new VGroup()
                    .SetPos(120, 20)
                    .SetPadding(5)
                    .AddChild(
                        new Button(new Rect(5, 20, 40, 25), "\\")
                        .AddClickHandler(e => BringCubeTo(_cube, 3, -3, 0, false))
                        )
                    .AddChild(
                        new Button(new Rect(5, 20, 40, 25), "-")
                        .AddClickHandler(e => BringCubeTo(_cube, 0, -3, 0, false))
                        )
                    .AddChild(
                        new Button(new Rect(5, 20, 40, 25), "/")
                        .AddClickHandler(e => BringCubeTo(_cube, -3, -3, 0, false))
                        )
                    )
                .AddChild(
                    // second column
                    new VGroup()
                    .SetPos(160, 20)
                    .SetPadding(5)
                    .AddChild(
                        new Button(new Rect(5, 20, 40, 25), "|")
                        .AddClickHandler((e) => BringCubeTo(_cube, 3, 0, 0, false))
                        )
                    .AddChild(
                        new Button(new Rect(5, 20, 40, 25), "+")
                        .AddClickHandler((e) => BringCubeTo(_cube, 0, 0, 0, false))
                        )
                    .AddChild(
                        new Button(new Rect(5, 20, 40, 25), "|")
                        .AddClickHandler((e) => BringCubeTo(_cube, -3, 0, 0, false))
                        )
                    )
                .AddChild(
                    // third column
                    new VGroup()
                    .SetPos(200, 20)
                    .SetPadding(5)
                    .AddChild(
                        new Button(new Rect(5, 20, 40, 25), "/")
                        .AddClickHandler((e) => BringCubeTo(_cube, 3, 3, 0, false))
                        )
                    .AddChild(
                        new Button(new Rect(5, 20, 40, 25), "-")
                        .AddClickHandler((e) => BringCubeTo(_cube, 0, 3, 0, false))
                        )
                    .AddChild(
                        new Button(new Rect(5, 20, 40, 25), "\\")
                        .AddClickHandler((e) => BringCubeTo(_cube, -3, 3, 0, false))
                        )
                    )
                .AddChild(
                    // 4th column
                    new VGroup()
                    .SetPos(250, 20)
                    .SetPadding(5)
                    .AddChild(
                        new Button(new Rect(5, 20, 40, 25), "/\\")
                        .AddClickHandler((e) => BringCubeVertical(0.5f))
                        )
                    .AddChild(
                        new Button(new Rect(5, 20, 40, 25), "-")
                        .AddClickHandler((e) => BringCubeVertical(0))
                        )
                    .AddChild(
                        new Button(new Rect(5, 20, 40, 25), "\\/")
                        .AddClickHandler((e) => BringCubeVertical(-0.5f))
                        )
                    )
                )
            .AddChild(
                _progressTextField = new TextField(new Rect(0, 0, 300, 20), "")
                )
            .AddChild(
                new Box(new Rect(20, 85, 300, 200), "Madness")
                .SetAutoAdjustSize(true)
                .SetPadding(5)
                .AddChild(
                    new Button(new Rect(0, 20, 290, 30), "Action!")
                    .AddClickHandler(e => StartTheMaddness())
                    )
                .AddChild(
                    _cubeCountTextField = new TextField(new Rect(0, 60, 290, 20), "")
                    )
                .AddChild(
                    _tweenerSelection = new SelectionGrid(new Rect(0, 90, 290, 25), new string[] { "TweenShark", "iTween" }, 2)
                    )
                )
            .AddChild(
                new Box(new Rect(20, 50, 350, 300), "Easing")
                .SetAutoAdjustSize(true)
                .SetPadding(5)
                .AddChild(
                    new Label(new Rect(0, 20, 140, 18), "Tween Duration in sec")
                    )
                .AddChild(
                    _tweenDuration = new TextField(new Rect(150, 20, 100, 20), "5")
                    )
                .AddChild(
                    _easingSelection = new SelectionGrid(new Rect(0, 50, 300, 200), _easingNames, 3).SetSelection(5)
                    )
                )
            .AddChild(
                new Box(new Rect(20, 50, 350, 300), "Material")
                .SetAutoAdjustSize(true)
                .SetPadding(5)
                .AddChild(
                    new Button(new Rect(0, 25, 100, 25), "Tween Mat")
                    .AddClickHandler(e => TweenMaterial())
                    )
                )

            );
    }
Example #11
0
    private void SetupUpGui()
    {
        // Initialize the loaders
        GuiModule.Initialize(this);
//        NetModule.Initialize(this);

        TweenSharkUnity3D.Initialize(this);

        _guiStage = GlobalGui.GetInstance();

        _guiStage.AddChild(
            new Button(new Rect(20, 20, 100, 20), "BUTTON")
            .AddClickHandler(OnButtonInListClicked)
            );

        _guiStage.AddChild(
            _youtubeBox = new Box(new Rect(600, 50, 20, 20), "Youtube Search")
                          .SetAutoAdjustSize(true)
                          .AddChild(
                _searchField = new TextField(new Rect(0, 30, 400, 20))
                               .AddMouseOverHandler(e => Debug.Log("mouse over on SearchField"))
                               .AddMouseOutHandler(e => Debug.Log("mouse out on SearchField"))
                               .AddLeftMouseDownHandler(e => Debug.Log("Left mouse down on SearchField"))
                               .AddLeftMouseUpHandler(e => Debug.Log("Left mouse up on SearchField"))
                )

                          .AddChild(
                new Button(new Rect(480, 30, 100, 20), "Search")
                .AddClickHandler(OnButton1)
                .AddMouseOverHandler(e => Debug.Log("MouseOver search " + e.Target + " " + e.CurrentTarget))
                .AddMouseOutHandler(e => Debug.Log("MouseOut search " + e.Target + " " + e.CurrentTarget))
                )

                          .AddChild(
                new ScrollView(new Rect(0, 100, 580, 350))
                .AddChild(
                    _listView = new VGroup()
                                .AddChild(new Label(new Rect(0, 0, 100, 20), "Text1"))
                                .AddChild(new Label(new Rect(0, 30, 100, 20), "Text2"))
                                .AddChild(new Label(new Rect(0, 60, 100, 20), "Text3"))
                                .AddChild(new Label(new Rect(0, 90, 100, 20), "Text4"))
                                .AddChild(new Label(new Rect(0, 120, 100, 20), "Text5"))
                                .AddChild(new Label(new Rect(0, 150, 100, 20), "Text6"))
                                .AddChild(new Label(new Rect(0, 180, 100, 20), "Text7"))
                                .AddChild(new Label(new Rect(0, 210, 100, 20), "Text8"))
                                .AddChild(new Label(new Rect(0, 240, 100, 20), "Text9"))
                                .SetPadding(20)
                    )
                )
            );

        _listView
        .AddLeftMouseDownHandler(e => Debug.Log("Left mouse down on ListView"))
        .AddLeftMouseUpHandler(e => Debug.Log("Left mouse up on ListView"))
        .AddRightMouseDownHandler(e => Debug.Log("Right mouse down on ListView"))
        .AddRightMouseUpHandler(e => Debug.Log("Right mouse up on ListView"))
        .AddMiddleMouseDownHandler(e => Debug.Log("Middle mouse down on ListView"))
        .AddMiddleMouseUpHandler(e => Debug.Log("Middle mouse up on ListView"))
        ;


        if (_youtubeBox != null)
        {
            _guiStage.AddChild(
                new Button(new Rect(200, 20, 100, 20), "Start Tween")
                .AddClickHandler((e) =>
            {
                var random = new System.Random();
                var opt    = new TweenOps(Ease.OutQuad)
                             .PropTo("X", random.Next(800))
                             .PropTo("Y", random.Next(500))
                             .PropTo("PaddingTop", random.Next(100))
                ;
                TweenShark.To(_youtubeBox, 1f + random.Next(2), opt);

                opt = new TweenOps(Ease.InOutQuad)
                      .PropTo("_sbyte", 100)
                      .PropTo("_byte", 100)
                      .PropTo("_short", 100)
                      .PropTo("_ushort", 100)
                      .PropTo("_int", 100)
                      .PropTo("_uint", 100)
                      .PropTo("_long", 100)
                      .PropTo("_ulong", 100)
                      .PropTo("_float", 100)
                      .PropTo("_double", 100)
                ;

                TweenShark.To(_tweenedObject, 10, opt);
            })
                );

            _youtubeBox.AddClickHandler(onBox1Clicked);
        }

        _guiStage.AddClickHandler(onStageClick);
    }