/**
     * Sets the new path for the paragraph. This method must be used only with
     * image paragraphs.
     */
    public void setImageParagraphContent()
    {
        // Get the list of assets from the ZIP file
        string[] assetFilenames = AssetsController.getAssetFilenames(AssetsConstants.CATEGORY_IMAGE);
        string[] assetPaths     = AssetsController.getAssetsList(AssetsConstants.CATEGORY_IMAGE);

        // If the list of assets is empty, show an error message
        if (assetFilenames.Length == 0)
        {
            controller.showErrorDialog(TC.get("Resources.EditAsset"), TC.get("Resources.ErrorNoAssets"));
        }

        // If not empty, select one of them
        else
        {
            // Let the user choose between the assets
            string selectedAsset = controller.showInputDialog(TC.get("Resources.EditAsset"), TC.get("Resources.EditAssetMessage"), assetFilenames);

            // If a file was selected
            if (selectedAsset != null)
            {
                // Take the index of the selected asset
                int assetIndex = -1;
                for (int i = 0; i < assetFilenames.Length; i++)
                {
                    if (assetFilenames[i].Equals(selectedAsset))
                    {
                        assetIndex = i;
                    }
                }

                Controller.getInstance().addTool(new ChangeParagraphContentTool(bookParagraph, assetPaths[assetIndex]));
            }
        }
    }
    /**
     * Shows a dialog to choose a new path for the given asset.
     *
     * @param index
     *            Index of the asset
     */
    public void editImagePath()
    {
        // Get the list of assets from the ZIP file
        string selectedAsset = null;

        //TODO: implement
        //AssetChooser chooser = AssetsController.getAssetChooser(AssetsConstants.CATEGORY_IMAGE, AssetsController.FILTER_NONE);
        //int option = chooser.showAssetChooser(controller.peekWindow());
        ////In case the asset was selected from the zip file
        //if (option == AssetChooser.ASSET_FROM_ZIP)
        //{
        //    selectedAsset = chooser.getSelectedAsset();
        //}

        ////In case the asset was not in the zip file: first add it
        //else if (option == AssetChooser.ASSET_FROM_OUTSIDE)
        //{
        //    bool added = AssetsController.addSingleAsset(AssetsConstants.CATEGORY_IMAGE, chooser.getSelectedFile().getAbsolutePath());
        //    if (added)
        //    {
        //        selectedAsset = chooser.getSelectedFile().getName();
        //    }
        //}

        // If a file was selected
        if (selectedAsset != null)
        {
            // Take the index of the selected asset
            string[] assetFilenames = AssetsController.getAssetFilenames(AssetsConstants.CATEGORY_IMAGE);
            string[] assetPaths     = AssetsController.getAssetsList(AssetsConstants.CATEGORY_IMAGE);
            int      assetIndex     = -1;
            for (int i = 0; i < assetFilenames.Length; i++)
            {
                if (assetFilenames[i].Equals(selectedAsset))
                {
                    assetIndex = i;
                }
            }

            Controller.getInstance().addTool(new ChangeParagraphContentTool(bookParagraph, assetPaths[assetIndex]));
        }
    }
Esempio n. 3
0
    public override bool doTool()
    {
        bool done = false;

        AssetsController.addSingleAsset(assetsInformation[index].category, filename, destinyAssetName, true);
        // Dirty fix?
        string selectedAsset = destinyAssetName == null ? (new FileInfo(filename)).FullName : destinyAssetName;

        // If a file was selected
        if (selectedAsset != null)
        {
            // Take the index of the selected asset
            string[] assetFilenames = AssetsController.getAssetFilenames(assetsInformation[index].category,
                                                                         assetsInformation[index].filter);
            string[] assetPaths = AssetsController.getAssetsList(assetsInformation[index].category,
                                                                 assetsInformation[index].filter);
            int assetIndex = -1;
            for (int i = 0; i < assetFilenames.Length; i++)
            {
                if (assetFilenames[i].Equals(selectedAsset))
                {
                    assetIndex = i;
                }
            }

            // check if the asset is "standright" or "standleft" in order to modify the attr assetNecessary
            // for the assetInformation
            if (assetsInformation[index].name.Equals("standright"))
            {
                // if "standright" asset is necessary, set the "standleft" as not necessary
                if (assetsInformation[index].assetNecessary)
                {
                    for (int i = 0; i < assetsInformation.Length; i++)
                    {
                        if (assetsInformation[i].name.Equals("standleft"))
                        {
                            assetsInformation[i].assetNecessary = false;
                        }
                    }
                }
                //if is not art necessary and is 3rd person game, look for "standleft", if this asset is
                // not necessary, set "standright as necessary"
                else if (!Controller.getInstance().isPlayTransparent())
                {
                    for (int i = 0; i < assetsInformation.Length; i++)
                    {
                        if (assetsInformation[i].name.Equals("standleft"))
                        {
                            assetsInformation[index].assetNecessary = true;
                            assetsInformation[i].assetNecessary     = false;
                        }
                    }
                }
            }
            else if (assetsInformation[index].name.Equals("standleft"))
            {
                // if "standleft" asset is necessary, set the "standright" as not necessary
                if (assetsInformation[index].assetNecessary)
                {
                    for (int i = 0; i < assetsInformation.Length; i++)
                    {
                        assetsInformation[i].assetNecessary = false;
                    }
                } //if is not art necessary and is 3rd person game, look for "standright", if this asset is
                // not necessary, set "standright as necessary"
                else if (!Controller.getInstance().isPlayTransparent())
                {
                    for (int i = 0; i < assetsInformation.Length; i++)
                    {
                        if (assetsInformation[i].name.Equals("standright"))
                        {
                            assetsInformation[index].assetNecessary = true;
                            assetsInformation[i].assetNecessary     = false;
                        }
                    }
                }
            }
            //The empty animation is, in fact, a special asset. When this asset is in an animation, it is considered as animation asset.
            // For this reason,at this point, assetIndex is = -1. So, if animation is emptyAnimation, change the path in addAsset method
            bool   changeFilter = false;
            string specialPath  = AssetsController.CATEGORY_SPECIAL_ASSETS + "/" + "EmptyAnimation.eaa";
            if (filename.Contains("EmptyAnimation"))
            {
                changeFilter = true;
            }

            resources.addAsset(assetsInformation[index].name, changeFilter ? specialPath : assetPaths[assetIndex]);
            done = true;
        }
        return(done);
    }