private void OnClickAsset(string AssetName)
    {
        CUtility.DestroyChildren(_propertiesContent);

        CAssetDeclaration decl = CGame.AssetManager.GetDeclaration(AssetName);

        mUI.CreateTextElement(_propertiesContent, "Selected " + decl.mName, "text", CToolkitUI.ETextStyle.TS_HEADING);

        GameObject foldContent;

        mUI.CreateFoldOut(_propertiesContent, "Asset Details", out foldContent);

        GameObject fieldEditor;

        mUI.CreateFieldElement(foldContent, "Name", out fieldEditor); mUI.CreateTextElement(fieldEditor, decl.mName);
        mUI.CreateFieldElement(foldContent, "File Path", out fieldEditor); mUI.CreateTextElement(fieldEditor, decl.mFileName);
        mUI.CreateFieldElement(foldContent, "Type", out fieldEditor); mUI.CreateTextElement(fieldEditor, decl.mType.ToString());
        //mUI.CreateFieldElement(foldContent, "Modified Date", out fieldEditor); mUI.CreateTextElement(fieldEditor, decl.mModifiedDate);

        GameObject btn = mUI.CreateButton(_propertiesContent, "Edit", () => { mToolkit.EditAsset(AssetName); });

        mUI.AddLayout(btn, -1, 20, 1.0f, -1);

        //btn = mUI.CreateButton(_propertiesContent, "Delete");
        mUI.AddLayout(btn, -1, 20, 1.0f, -1);
    }
Esempio n. 2
0
    public CAssetDeclaration GetDeclaration(string AssetName)
    {
        CAssetDeclaration decl = null;

        mAssetDeclarations.TryGetValue(AssetName, out decl);
        return(decl);
    }
Esempio n. 3
0
    private void _LoadAssetDeclarations()
    {
        mAssetDeclarations = new Dictionary <string, CAssetDeclaration>();

        string[] files = Directory.GetFiles(CGame.DataDirectory);

        for (int i = 0; i < files.Length; ++i)
        {
            if (Path.GetExtension(files[i]) == "." + ASSET_FILE_EXTENSION)
            {
                Debug.Log("Asset Decl: " + files[i]);

                string assetName = Path.GetFileNameWithoutExtension(files[i]);

                FileStream   file   = File.Open(files[i], FileMode.Open);
                BinaryReader reader = new BinaryReader(file);

                CAssetDeclaration decl = new CAssetDeclaration();
                decl.mFileName = files[i];
                decl.mName     = assetName;
                decl.mType     = (EAssetType)reader.ReadInt32();
                decl.mAsset    = null;
                mAssetDeclarations[assetName] = decl;
                file.Close();
            }
        }
    }
Esempio n. 4
0
    public T GetAsset <T>(CAssetDeclaration AssetDecl)
        where T : CAsset
    {
        if (AssetDecl.mAsset == null)
        {
            AssetDecl.LoadAsset();
        }

        return((T)AssetDecl.mAsset);
    }
    private void _OnClickCreateNewAssetWindow(GameObject Window, EAssetType Type, string AssetName)
    {
        string errorStr;

        if (CGame.AssetManager.IsAssetNameValid(AssetName, out errorStr))
        {
            GameObject.Destroy(Window);

            CTUITreeViewItem treeItem = null;
            CAsset           asset    = null;

            if (Type == EAssetType.AT_MODEL)
            {
                treeItem = _tviModels;
                asset    = new CModelAsset();
            }
            else if (Type == EAssetType.AT_BRUSH)
            {
                treeItem = _tviBrushes;
                asset    = new CBrushAsset();
            }
            else if (Type == EAssetType.AT_LEVEL)
            {
                treeItem = _tviLevels;
                asset    = new CLevelAsset();
            }
            else if (Type == EAssetType.AT_ITEM)
            {
                treeItem = _tviItems;
                asset    = new CItemAsset();
            }

            asset.mName     = AssetName;
            asset.mFileName = CGame.DataDirectory + asset.mName + "." + CAssetManager.ASSET_FILE_EXTENSION;
            Debug.Log("New Asset Path: " + asset.mFileName);
            asset.Save();

            CAssetDeclaration decl = CGame.AssetManager.CreateAssetDeclaration(asset);
            treeItem.AddItem(decl.mName, () => OnClickAsset(decl.mName), () => mToolkit.EditAsset(decl.mName));

            treeItem.RebuildEntireTree();
            mToolkit.EditAsset(AssetName);
        }
        else
        {
            Debug.Log("Asset creation failed: " + errorStr);
        }
    }
Esempio n. 6
0
    public CAssetDeclaration CreateAssetDeclaration(CAsset Asset)
    {
        string errorStr;

        if (!IsAssetNameValid(Asset.mName, out errorStr))
        {
            return(null);
        }

        CAssetDeclaration decl = new CAssetDeclaration();

        decl.mName     = Asset.mName;
        decl.mFileName = Asset.mFileName;
        decl.mType     = Asset.mType;
        decl.mAsset    = Asset;

        mAssetDeclarations[Asset.mName] = decl;

        return(decl);
    }
Esempio n. 7
0
    public void EditAsset(string AssetName)
    {
        for (int i = 0; i < _windows.Count; ++i)
        {
            if (_windows[i].mAssetName == AssetName)
            {
                ShowWindow(_windows[i]);
                return;
            }
        }

        CAssetDeclaration   decl   = CGame.AssetManager.GetDeclaration(AssetName);
        CAssetToolkitWindow window = null;

        if (decl.mType == EAssetType.AT_BRUSH)
        {
            window = new CBrushEditor(AssetName);
        }
        else if (decl.mType == EAssetType.AT_MODEL)
        {
            window = new CModelEditor(AssetName);
        }
        else if (decl.mType == EAssetType.AT_LEVEL)
        {
            window = new CLevelEditor(AssetName);
        }
        else if (decl.mType == EAssetType.AT_ITEM)
        {
            window = new CItemEditor(AssetName);
        }

        if (window != null)
        {
            CreateWindow(window);
            ShowWindow(window);
        }
        else
        {
            Debug.LogError("No editor for asset (" + AssetName + ") of type " + decl.mType);
        }
    }
Esempio n. 8
0
    public T GetAsset <T>(string AssetName)
        where T : CAsset
    {
        // TODO: Ensure that this is really thread safe to call.

        CAssetDeclaration decl = null;

        mAssetDeclarations.TryGetValue(AssetName, out decl);

        if (decl != null)
        {
            if (decl.mAsset == null)
            {
                decl.LoadAsset();
            }

            return((T)decl.mAsset);
        }

        return(null);
    }
    public override void Init(CAssetToolkit Toolkit)
    {
        base.Init(Toolkit);

        mPrimaryContent = mUI.CreateElement(Toolkit.mPrimaryContent, "horzLayout");
        mPrimaryContent.SetActive(false);
        mUI.AddLayout(mPrimaryContent, -1, -1, 1.0f, 1.0f);
        mUI.AddVerticalLayout(mPrimaryContent);
        mPrimaryContent.GetComponent <VerticalLayoutGroup>().spacing = 4;

        GameObject toolbar = mUI.CreateElement(mPrimaryContent, "toolbarView");

        mUI.AddLayout(toolbar, -1, 48, 1.0f, 0.0f);
        mUI.AddImage(toolbar, mUI.WindowPanelBackground);
        mUI.AddHorizontalLayout(toolbar);
        toolbar.GetComponent <HorizontalLayoutGroup>().spacing = 4;

        mUI.CreateToolbarButton(toolbar, "Sheet", mUI.SheetImage);
        mUI.CreateToolbarButton(toolbar, "Level", mUI.LevelImage, () => _OnClickNewModel(EAssetType.AT_LEVEL));
        mUI.CreateToolbarButton(toolbar, "Brush", mUI.BrushImage, () => _OnClickNewModel(EAssetType.AT_BRUSH));
        mUI.CreateToolbarButton(toolbar, "Model", mUI.ModelImage, () => _OnClickNewModel(EAssetType.AT_MODEL));
        mUI.CreateToolbarButton(toolbar, "Item", mUI.ItemImage, () => _OnClickNewModel(EAssetType.AT_ITEM));

        mUI.CreateToolbarSeparator(toolbar);
        mUI.CreateToolbarButton(toolbar, "Character", mUI.BrushImage, mToolkit.EditCharacter);

        GameObject hSplit = mUI.CreateElement(mPrimaryContent, "horzLayout");

        mUI.AddLayout(hSplit, -1, -1, 1.0f, 1.0f);
        mUI.AddHorizontalLayout(hSplit);
        hSplit.GetComponent <HorizontalLayoutGroup>().spacing = 4;

        GameObject w1 = mUI.CreateElement(hSplit, "split1");

        mUI.AddLayout(w1, -1, -1, 1.0f, 1.0f);
        mUI.AddVerticalLayout(w1);

        GameObject w2 = mUI.CreateElement(hSplit, "split2");

        mUI.AddLayout(w2, 300, -1, 0.0f, 1.0f);
        mUI.AddVerticalLayout(w2);

        // Split 1
        GameObject w1pContent;
        GameObject w1p = mUI.CreateWindowPanel(w1, out w1pContent, "Tools");

        mUI.AddLayout(w1p, -1, -1, 1.0f, 1.0f);

        //mUI.CreateTextElement(w1pContent, "Create New Asset", "text", CToolkitUI.ETextStyle.TS_HEADING);

        /*toolbar = mUI.CreateElement(w1pContent, "toolbarView");
         * mUI.AddLayout(toolbar, -1, 48, 1.0f, -1);
         * mUI.AddImage(toolbar, mUI.WindowPanelBackground);
         * mUI.AddHorizontalLayout(toolbar);
         * toolbar.GetComponent<HorizontalLayoutGroup>().spacing = 4;
         */

        //mUI.CreateToolbarButton(toolbar, "Company", mUI.CompanyImage);
        //mUI.CreateToolbarButton(toolbar, "Sheet", mUI.SheetImage);

        mUI.CreateTextElement(w1pContent, "Asset Directory", "text", CToolkitUI.ETextStyle.TS_HEADING);

        GameObject scrollContent;
        GameObject scrollV1 = mUI.CreateScrollView(w1pContent, out scrollContent, true);

        mUI.AddLayout(scrollV1, -1, -1, 1.0f, 1.0f);

        CTUITreeView treeView;
        GameObject   treeViewGob = mUI.CreateTreeView(scrollContent, out treeView);

        mUI.AddLayout(treeViewGob, -1, -1, 1.0f, 1.0f);

        _tviBrushes = treeView.mRootItem.AddItem("Brushes");
        _tviModels  = treeView.mRootItem.AddItem("Models");
        _tviItems   = treeView.mRootItem.AddItem("Items");
        _tviLevels  = treeView.mRootItem.AddItem("Levels");
        _tviSheets  = treeView.mRootItem.AddItem("Sheets");

        //item.AddItem(entry.Value.mName);
        //item = treeView.mRootItem.AddItem("Models");
        //item.AddItem(entry.Value.mName, () => OnClickAsset(0, guid), () => mToolkit.EditAsset(guid));

        foreach (KeyValuePair <string, CAssetDeclaration> entry in CGame.AssetManager.mAssetDeclarations)
        {
            CAssetDeclaration decl = entry.Value;
            CTUITreeViewItem  item = null;

            if (decl.mType == EAssetType.AT_BRUSH)
            {
                item = _tviBrushes;
            }
            else if (decl.mType == EAssetType.AT_MODEL)
            {
                item = _tviModels;
            }
            else if (decl.mType == EAssetType.AT_LEVEL)
            {
                item = _tviLevels;
            }
            else if (decl.mType == EAssetType.AT_ITEM)
            {
                item = _tviItems;
            }

            if (item != null)
            {
                item.AddItem(decl.mName, () => OnClickAsset(decl.mName), () => mToolkit.EditAsset(decl.mName));
            }
        }

        treeView.Rebuild();

        // Split 2
        GameObject w2p = mUI.CreateWindowPanel(w2, out _propertiesContent, "Properties");

        mUI.AddLayout(w2p, -1, -1, 1.0f, 1.0f);

        mUI.CreateTextElement(_propertiesContent, "(No Asset Selected)", "text", CToolkitUI.ETextStyle.TS_HEADING);
    }