Ejemplo n.º 1
0
        static void Init()
        {
            var font = new Font("Assets/NotoSans-Regular.ttf", FontCharSet.BasicLatin);
            var size = new FontSize(font, 128f);

            var builder = new AtlasBuilder(2048);

            builder.AddBitmap("Assets/star.png", true, true);
            builder.AddBitmap("Assets/face.png", true, true);
            builder.AddBitmap("Assets/maritte.png", true, true);
            builder.AddFont("font", size, true);

            atlas = builder.Build(1);
            if (atlas == null)
            {
                throw new Exception("Failed to build atlas.");
            }

            batch  = new DrawBatch2D();
            shader = new Shader(Shader.Basic2D);

            view = new GuiView(shader, Screen.DrawWidth, Screen.DrawHeight, LayoutMode.Horizontal);
            view.BackgroundColor = Color4.Grey;
            view.Spacing         = 16;
            view.SetPadding(16);

            var left = view.AddChild(new GuiContainer());

            left.BackgroundColor = Color4.Black * 0.25f;
            left.FlexX           = left.FlexY = true;
            left.Spacing         = 16;

            var right = view.AddChild(new GuiContainer());

            right.BackgroundColor = Color4.Blue;
            right.FlexX           = right.FlexY = true;

            var items = left.AddChild(new GuiContainer());

            items.BackgroundColor = Color4.Black * 0.25f;
            items.FlexX           = items.FlexY = true;
            items.Spacing         = 1;
            items.ScrollableY     = true;

            var padding = left.AddChild(new GuiContainer(100, 100, LayoutMode.Vertical));

            padding.BackgroundColor = Color4.White * 0.25f;
            padding.FlexX           = true;
            padding.FlexY           = false;

            for (int i = 0; i < 50; ++i)
            {
                var item = items.AddChild(new GuiElement(16, 40));
                item.FlexY     = false;
                item.OnRender += b => b.DrawRect(item.RectX, item.RectY, item.RectW, item.RectH, Color4.Red);
            }

            Screen.ClearColor = Color4.Black;
            Screen.OnResized += () => view.SetSize(Screen.DrawWidth, Screen.DrawHeight);
        }
Ejemplo n.º 2
0
    public virtual void Dispose()
    {
        _parent = null;

        foreach (GuiView child in _childs)
        {
            child.Dispose();
        }

        _childs.Clear();
    }
Ejemplo n.º 3
0
        private void InitializeGameState(GameSettings settings)
        {
            foreach (var playerMetadata in settings.Players)
            {
                players.Add(playerMetadata.CreatePlayer());
            }

            guiView = new GuiView(window, resources, worldMap, worldView);
            turnCycle.Start(players);
            worldMap.Mock(players);
            actionController = new ActionController(window, worldMap, turnCycle, worldView);
        }
Ejemplo n.º 4
0
    void WriteMessage()
    {
        GuiView view = Owner as GuiView;

        if (view == null)
        {
            return;
        }
        if (m_SendButton == null)
        {
            return;
        }

#if !UNITY_EDITOR && (UNITY_IPHONE || UNITY_ANDROID)
        view.ShowKeyboard(m_MessageButton, GuiScreen.E_KeyBoardMode.Default, Delegate_OnKeyboardClose, m_MessageToSend, MAX_MESSAGE_LENGTH);
#endif
    }
    private void InitView()
    {
        _view = new GuiView(new Rect(5, 5, 890, 590));

        GuiButton button = new GuiButton(new Rect(0, 0, 110, 20), "刷新资源数据库");

        button.RegisterHandler(RefreshAssets);
        _view.AddChild(button);

        button = new GuiButton(new Rect(340, 2, 16, 16), "?");
        button.RegisterHandler(ShowHelpInfo);
        _view.AddChild(button);

        _searchTextField = new GuiSearchTextField(new Rect(130, 1, 196, 20));
        _searchTextField.OnTextChange(OnSearchTextChange);
        _view.AddChild(_searchTextField);

        _timeLabel = new GuiLabel(new Rect(400, 0, 500, 20), "");
        _view.AddChild(_timeLabel);

        _assetDataSelectedGrid = new GuiSelectionGrid(new Rect(0, 35, 200, 20), new string[] { "资源列表", "无引用资源" }, new Action[] { ShowAllAssets, ShowUnusedAssets });
        _view.AddChild(_assetDataSelectedGrid);

        _dependenceSelectedGrid = new GuiSelectionGrid(new Rect(345, 35, 200, 20), new string[] { "资源依赖项", "反向引用" }, new Action[] { ShowDependencies, ShowRedependencies });
        _view.AddChild(_dependenceSelectedGrid);

        GuiScrollView scrollView = new GuiScrollView(new Rect(0, 60, 320, 530));

        _view.AddChild(scrollView);

        _assetDatafoldoutTree = new GuiFoldoutTree(new Rect(0, 60, 320, 3000));
        _assetDatafoldoutTree.AttachDrawer(new AssetDatasDrawer(_assetDatafoldoutTree));
        scrollView.AddChild(_assetDatafoldoutTree);

        scrollView = new GuiScrollView(new Rect(340, 60, 550, 530));
        _view.AddChild(scrollView);

        _dependencefoldoutTree = new GuiFoldoutTree(new Rect(340, 60, 320, 3000));
        _dependencefoldoutTree.AttachDrawer(new DependenceInfoDrawer(_dependencefoldoutTree));
        scrollView.AddChild(_dependencefoldoutTree);
    }
Ejemplo n.º 6
0
    GUIBase_Widget HitTest(GuiView view, ref Vector2 point)
    {
        if (view == null)
        {
            return(null);
        }
        if (view.IsInitialized == false)
        {
            return(null);
        }
        if (view.IsVisible == false)
        {
            return(null);
        }
        if (view.IsEnabled == false)
        {
            return(null);
        }

        return(view.HitTest(ref point));
    }
Ejemplo n.º 7
0
 public AssetDatasDrawer(GuiView view) : base(view)
 {
 }
Ejemplo n.º 8
0
 public DependenceInfoDrawer(GuiView view) : base(view)
 {
 }
 private void ShowHelpInfo(GuiView view)
 {
     EditorUtility.DisplayDialog("使用说明", HelpInformation.GetHelpInformation(), "确定");
 }
Ejemplo n.º 10
0
 private void RefreshAssets(GuiView view)
 {
     AssetDataManager.Instance.BuildAllDatas();
     RefreshView();
 }
Ejemplo n.º 11
0
    // OBJECT INTERFACE

    public override bool Equals(object other)
    {
        GuiView view = other as GuiView;

        return(view != null ? Layout == view.Layout : false);
    }
Ejemplo n.º 12
0
 public GuiDrawer(GuiView view)
 {
     _view = view;
 }
Ejemplo n.º 13
0
 public void AddChild(GuiView child)
 {
     child._parent = this;
     _childs.Add(child);
 }
Ejemplo n.º 14
0
 public bool IsTopView(GuiView inView)
 {
     return(activeScreen != null && activeScreen == inView ? true : false);
 }
Ejemplo n.º 15
0
 public bool IsTopView(GuiView inView)
 {
     return(Owner != null?Owner.IsTopView(inView) : false);
 }