예제 #1
0
        /// <summary>
        /// Determines whether the specified plugin is currently in use
        /// </summary>
        public bool IsUsed(Plugin plugin)
        {
            bool active = false;

            if (!plugin.IsUnregistered && plugin.RegistrationKey != Guid.Empty)
            {
                //check if any file extensions use it
                AssetTypeFileExtensionFinder atfeFinder = new AssetTypeFileExtensionFinder {
                    Plugin = plugin.RegistrationKey
                };
                AssetTypeFileExtension atfe = AssetTypeFileExtension.FindOne(atfeFinder);
                if (!atfe.IsNull)
                {
                    active = true;
                }
                else
                {
                    //check to see if in use by any assets
                    AssetFinder assetFinder = new AssetFinder {
                        Plugin = plugin.RegistrationKey
                    };
                    Asset asset = Asset.FindOne(assetFinder);
                    active = !asset.IsNull;
                }
            }

            return(active);
        }
예제 #2
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        IncludeConfiguration IncludeConfigurationEnum = (IncludeConfiguration)attribute;

        if (property.propertyType == SerializedPropertyType.Enum)
        {
            var targetEnum = SerializableObjectHelper.GetBaseProperty <Enum>(property);
            if (this.CachedConfigurationEditor == null || this.lastFrameEnum.ToString() != targetEnum.ToString())
            {
                var configuration = (IConfigurationSerialization)AssetFinder.SafeAssetFind("t:" + IncludeConfigurationEnum.ConfigurationType.Name)[0];
                var so            = configuration.GetEntry(targetEnum);
                this.CachedConfigurationEditor = DynamicEditorCreation.Get().CreateEditor(so);
                this.FoldableArea = new FoldableArea(false, so.name, false);
            }

            if (CachedConfigurationEditor != null)
            {
                this.FoldableArea.OnGUI(() =>
                {
                    this.CachedConfigurationEditor.OnInspectorGUI();
                });
            }
            this.lastFrameEnum = targetEnum;
        }
    }
예제 #3
0
        private void OnEnable()
        {
            //initialization
            this.levelHierarchyConfiguration  = AssetFinder.SafeSingleAssetFind <LevelHierarchyConfiguration>("t:" + typeof(LevelHierarchyConfiguration).Name);
            this.levelZonesSceneConfiguration = AssetFinder.SafeSingleAssetFind <LevelZonesSceneConfiguration>("t:" + typeof(LevelZonesSceneConfiguration).Name);
            this.chunkZonesSceneConfiguration = AssetFinder.SafeSingleAssetFind <ChunkZonesSceneConfiguration>("t:" + typeof(ChunkZonesSceneConfiguration).Name);
            //END

            var root = this.rootVisualElement;

            var searchBar = new ToolbarSearchField();

            searchBar.style.height         = 15;
            searchBar.style.justifyContent = Justify.Center;
            searchBar.RegisterValueChangedCallback(this.OnSearchChange);
            searchBar.focusable = true;
            searchBar.Focus();
            root.Add(searchBar);

            var scrollView = new ScrollView(ScrollViewMode.Vertical);

            root.Add(scrollView);
            var boundingBox = new Box();

            scrollView.Add(boundingBox);
            //HEADER
            Layout_HeadderLine(boundingBox, VisualElementWithStyle(new Label("Scene path"), HeaderLabelStyle()), VisualElementWithStyle(new Label("Scene ref"), HeaderLabelStyle()));
            //CONTENT
            this.DoDisplayLevels(boundingBox);
        }
예제 #4
0
        public static string GetUrlForSearch(SavedUserAssetSearch searchInfo)
        {
            AssetFinder finder = searchInfo.AssetFinder;

            StringBuilder sb = new StringBuilder();

            sb.Append("~/SearchRedirector.ashx?x=1");

            AppendSearchValue(sb, CATEGORY_ID, searchInfo.CurrentCategoryId);
            AppendSearchValue(sb, GENERAL_KEYWORD, finder.GeneralKeyword.Replace("&", " "));

            foreach (var ids in finder.MetadataIds)
            {//add all selected meta value ids for each meta under its
                //own param name
                foreach (var id in ids.Value)
                {
                    AppendSearchValue(sb, "md" + ids.Key, id);
                }
            }

            AppendSearchValue(sb, BRAND_ID, finder.BrandId);
            AppendSearchValue(sb, ASSET_TYPE_ID, finder.AssetTypeId);
            AppendSearchValue(sb, ORIENTATION_ID, m_OrientationDictionary[finder.Orientation]);

            ComplexCriteria criteria = finder.GetSingleComplexCriteria(Asset.Columns.FileSize);

            if (criteria != null)
            {
                sb.AppendFormat("&{0}={1}&{2}={3}", FILESIZE_COMPARETYPE, m_CompareTypeDictionary[criteria.CompareType], FILESIZE, criteria.Value);
            }

            criteria = finder.GetSingleComplexCriteria(Asset.Columns.ProductionMonth, CompareType.MoreThan);
            if (criteria != null)
            {
                sb.AppendFormat("&{0}={1}", FROM_PRODUCTION_MONTH, criteria.Value);
            }

            criteria = finder.GetSingleComplexCriteria(Asset.Columns.ProductionYear, CompareType.MoreThan);
            if (criteria != null)
            {
                sb.AppendFormat("&{0}={1}", FROM_PRODUCTION_YEAR, criteria.Value);
            }

            criteria = finder.GetSingleComplexCriteria(Asset.Columns.ProductionMonth, CompareType.LessThan);
            if (criteria != null)
            {
                sb.AppendFormat("&{0}={1}", TO_PRODUCTION_MONTH, criteria.Value);
            }

            criteria = finder.GetSingleComplexCriteria(Asset.Columns.ProductionYear, CompareType.LessThan);
            if (criteria != null)
            {
                sb.AppendFormat("&{0}={1}", TO_PRODUCTION_YEAR, criteria.Value);
            }

            sb.AppendFormat("&{0}={1}", PAGE, searchInfo.Page);
            sb.AppendFormat("&{0}={1}", PAGE_SIZE, searchInfo.PageSize);

            return(sb.ToString());
        }
예제 #5
0
        /// <summary>
        /// Creates an audit log entry for the specified search and
        /// returns the auditassetsearch (which is needed to track
        /// which assets are viewed for this search on a page-by-page basis)
        /// </summary>
        /// <param name="assetFinder">The asset finder being used for the search</param>
        /// <param name="user">The user performing the search</param>
        public static AuditAssetSearch LogSearch(AssetFinder assetFinder, User user)
        {
            if (user.IsNull)
            {
                m_Logger.WarnFormat("Unable to log search; user is null");
                return(AuditAssetSearch.Empty);
            }

            AuditAssetSearch aus = AuditAssetSearch.New();

            aus.SessionId = BusinessHelper.GetCurrentSessionId();
            aus.IpAddress = BusinessHelper.GetCurrentIpAddress();
            aus.UserId    = user.UserId.GetValueOrDefault();
            aus.Date      = DateTime.Now;
            AuditAssetSearch.Update(aus);

            AuditAssetSearchKeyword aask = AuditAssetSearchKeyword.New();

            aask.AuditAssetSearchId = aus.AuditAssetSearchId.GetValueOrDefault();
            aask.SearchKeyword      = assetFinder.GeneralKeyword;
            AuditAssetSearchKeyword.Update(aask);

            int assetCount = Asset.GetCount(assetFinder);

            string notes = string.Format("Searched for '{0}' (Criteria Count: {1}).  Found {2} assets.", assetFinder.GeneralKeyword, assetFinder.FindCriteriaCount, assetCount);

            LogUserAction(user, AuditUserAction.Search, notes);

            return(aus);
        }
예제 #6
0
        protected void ReassignButton_Click(object sender, EventArgs e)
        {
            AssetFinder finder = new AssetFinder();

            finder.AssetIdList.Add(0);
            finder.AssetIdList.AddRange(AssetIdList);
            List <Asset> assetList = Asset.FindMany(finder);

            foreach (Asset asset in assetList)
            {
                // Update internal permissions
                asset.InternalUsers_HideFromUsers            = (InternalUsersRestrictionsRadioButtonList.SelectedValue == "NotVisible");
                asset.InternalUsers_DownloadApprovalRequired = (InternalUsersRestrictionsRadioButtonList.SelectedValue == "ApprovalRequired");

                // Update external permissions
                asset.ExternalUsers_HideFromUsers            = (ExternalUsersRestrictionsRadioButtonList.SelectedValue == "NotVisible");
                asset.ExternalUsers_DownloadApprovalRequired = (ExternalUsersRestrictionsRadioButtonList.SelectedValue == "ApprovalRequired");

                // Save changes back to DB
                Asset.Update(asset);

                // Update log
                AuditLogManager.LogAssetAction(asset, CurrentUser, AuditAssetAction.SavedAsset, "Permissions changed via bulk permissions change tool");
                AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.EditAsset, "Permissions changed via bulk permissions change tool");
            }

            const string returnUrl = "AssetList.aspx?PostAction=BulkAssetPermissionChangeSuccessful";

            Response.Redirect(returnUrl);
        }
예제 #7
0
        /// <summary>
        /// Gets the base asset finder to be used for searching
        /// </summary>
        public static AssetFinder GetBaseAssetFinder(User user)
        {
            // Initialise asset finder.
            // Only return completely published assets (published and date in range)
            AssetFinder finder = new AssetFinder {
                IsCompletelyPublished = true
            };

            // Default to relevance ordering
            finder.OrderBy = OrderBy.Relevance;

            // Apply additional restrictions for non-superadmins
            if (user.UserRole != UserRole.SuperAdministrator)
            {
                // Non-superadmins users cannot see assets outside of their brand assignments
                user.Brands.ForEach(b => finder.BrandIdList.Add(b.BrandId.GetValueOrDefault()));

                if (user.IsEmployee)
                {
                    // Employees should not see assets flagged as hidden from internal users
                    finder.InternalUsers_HideFromUsers = false;
                }
                else
                {
                    // External users should not see assets flagged as hidden from non-employees
                    finder.ExternalUsers_HideFromUsers = false;
                }
            }

            // Favour newer assets
            finder.SortExpressions.Add(new DescendingSort(Asset.Columns.PublishDate));
            finder.SortExpressions.Add(new DescendingSort(Asset.Columns.AssetId));

            return(finder);
        }
예제 #8
0
        public override void    Find(AssetMatches assetMatches, Object asset, AssetFinder finder, SearchResult result)
        {
            SerializedObject   so       = new SerializedObject(asset);
            SerializedProperty property = so.FindProperty("m_DefaultReferences.Array");

            if (property != null)
            {
                string                 lastString = string.Empty;
                SerializedProperty     end        = property.GetEndProperty();
                SerializedPropertyType type       = property.propertyType;

                while (property.Next(type == SerializedPropertyType.Generic) == true &&
                       SerializedProperty.EqualContents(property, end) == false)
                {
                    type = property.propertyType;

                    if (type == SerializedPropertyType.String)
                    {
                        lastString = property.stringValue;
                    }
                    else if (type == SerializedPropertyType.ObjectReference)
                    {
                        ++result.potentialMatchesCount;
                        if (property.objectReferenceValue == this.window.TargetAsset)
                        {
                            assetMatches.matches.Add(new Match(asset, property.propertyPath)
                            {
                                nicifiedPath = Utility.NicifyVariableName(lastString)
                            });
                            ++result.effectiveMatchesCount;
                        }
                    }
                }
            }
        }
예제 #9
0
 public LayerRenderer(GameCoreRenderer renderer, GraphicsDevice gd, ContentManager content, AssetFinder finder)
 {
     Renderer       = renderer;
     Finder         = finder;
     GraphicsDevice = gd;
     Content        = content;
 }
예제 #10
0
 public FXAARenderer(GameCoreRenderer renderer, GraphicsDevice gd,
                     ContentManager content, AssetFinder finder)
     : base(renderer, gd, content, finder)
 {
     _fxaaEffect = Content.Load <Effect>("fxaa3");
     _sb         = new SpriteBatch(GraphicsDevice);
 }
예제 #11
0
        protected void SearchButton_Click(object sender, EventArgs e)
        {
            // Get base finder
            AssetFinder finder = SearchManager.GetBaseAssetFinder(CurrentUser);

            // Reset the category list if all brands are selected, or if the brand selector has changed
            if (BrandDropDownList1.SelectedId == 0 || finder.BrandId != BrandDropDownList1.SelectedId)
            {
                finder.CategoryIdList.Clear();
                SavedUserAssetSearch.CurrentCategoryId = -1;
            }

            // Set basic criteria
            finder.GeneralKeyword = KeywordsTextBox.Text.Trim();
            finder.BrandId        = BrandDropDownList1.SelectedId;
            finder.AssetTypeId    = AssetTypeDropDownList1.SelectedId;

            MetadataFilters.AddAdvancedSearchCriteria(ref finder);
            AddCategorySearchCriteria();

            // Log the search
            AuditAssetSearch aas = AuditLogManager.LogSearch(finder, CurrentUser);

            // Store the finder and clear the audit ID, as we dont want to audit advanced searches
            SavedUserAssetSearch.AssetFinder        = finder;
            SavedUserAssetSearch.AuditAssetSearchId = aas.AuditAssetSearchId.GetValueOrDefault();
            SavedUserAssetSearch.Page = 1;

            // Redirect to the search results
            // It will pick up the finder from the session to display results
            Response.Redirect("~/SearchResults.aspx", false);
        }
예제 #12
0
        public void InitEditorData(int instanceIndex)
        {
            if (this.GameDesignerEditorProfile == null)
            {
                var GameDesignerEditorProfiles = AssetFinder.SafeAssetFind <GameDesignerEditorProfile>("t:" + typeof(GameDesignerEditorProfile).Name);
                foreach (var GameDesignerEditorProfile in GameDesignerEditorProfiles)
                {
                    if (GameDesignerEditorProfile.GameDesignerProfileInstanceIndex == instanceIndex)
                    {
                        this.GameDesignerEditorProfile = GameDesignerEditorProfile;
                        break;
                    }
                }

                if (this.GameDesignerEditorProfile == null)
                {
                    var CreatedGameDesignerEditorProfile = (GameDesignerEditorProfile)GameDesignerEditorProfile.CreateInstance(typeof(GameDesignerEditorProfile));
                    CreatedGameDesignerEditorProfile.GameDesignerProfileInstanceIndex = instanceIndex;
                    AssetDatabase.CreateAsset(CreatedGameDesignerEditorProfile, GameDesignerProfilePath + "/GameDesignerEditorProfile_" + instanceIndex + ".asset");
                    this.GameDesignerEditorProfile = CreatedGameDesignerEditorProfile;
                }
            }
            if (this.GameDesignerEditorProfile != null)
            {
                if (this.ChoiceTree == null)
                {
                    this.ChoiceTree = new GameDesignerChoiceTree(this.GameDesignerEditorProfile);
                }
            }
        }
예제 #13
0
        public GameCoreRenderer(Game client, string[] assetPaths, int[] teamsToDisplayFor, ILogger logger)
        {
            Client = client;
            TeamsToDisplayLightsFor = teamsToDisplayFor;

            Finder = new AssetFinder(this, new AssetCache(client.GraphicsDevice,
                                                          new AssetLoader(this, client.GraphicsDevice, new AssetResolver(assetPaths, this)),
                                                          this));

            Logger = new ModuleLogger(logger, "Renderer");

            _fxaaRenderer = new FXAARenderer(
                this, client.GraphicsDevice, client.Content, Finder);
            FXAAEnabled   = true;
            _gameRenderer = new GameWorldRenderer(
                this, client.GraphicsDevice, client.Content, Finder);

            _renderers.Add(new MapBackgroundRenderer(
                               this, client.GraphicsDevice, client.Content, Finder));
            _renderers.Add(_gameRenderer);
            //For another time...
            //_renderers.Add(new LightRenderer(
            //    this, client.GraphicsDevice, client.Content, Finder));
            _renderers.Add(_fxaaRenderer);
        }
        private void SetupHiddenAssetOptions(AssetFinder finder)
        {
            // Update finder
            finder.IncludeUnpublishedExpiredAssets = IncludeUnpublishedExpiredAssets.Checked;

            // The option is not enabled, so no special logic is required
            if (!finder.IncludeUnpublishedExpiredAssets)
            {
                return;
            }

            // The option is enabled by a super admin so we simply reset the finder
            // so that it doesn't restrict the search just to completely published assets
            if (CurrentUser.UserRole == UserRole.SuperAdministrator)
            {
                finder.IsCompletelyPublished = false;
                return;
            }

            // Brand admins can only see unpublished & expired assets in their
            // own brand, so we need to restrict the search accordingly.
            if (CurrentUser.UserRole == UserRole.BrandAdministrator)
            {
                finder.IncludeUnpublishedExpiredAssets_BrandId = CurrentUser.PrimaryBrandId;
            }

            // Users can always see their own assets
            finder.IncludeUnpublishedExpiredAssets_UserId = CurrentUser.UserId.GetValueOrDefault();
        }
예제 #15
0
        /// <summary>
        /// Gets the number of assets assigned to the category with the specified ID (including it's child categories)
        /// </summary>
        public static int GetFullAssetCount(int categoryId)
        {
            AssetFinder finder = new AssetFinder();

            finder.CategoryIdList.Add(Int32.MinValue);
            finder.CategoryIdList.AddRange(GetCategoryIdsForSearch(categoryId));
            return(Asset.GetCount(finder));
        }
예제 #16
0
    public override void _Ready()
    {
        string res = AssetFinder.asignNonUsedResource(avaliableResourcesInMap);

        avaliableResourcesInMap.Add(res);
        GetNode <Sprite>("Sprite").Texture = (Texture)ResourceLoader.Load(AssetFinder.GetPathByResourceName(res));
        (GetNode <Area2D>("Area2D") as ResourceInfo).Kind = res;
    }
예제 #17
0
 public LightRenderer(GameCoreRenderer renderer, GraphicsDevice gd,
                      ContentManager content, AssetFinder finder)
     : base(renderer, gd, content, finder)
 {
     _sb                     = new SpriteBatch(GraphicsDevice);
     _lightRenderer          = Content.Load <Effect>("lightMaskRenderer");
     _lightMaskPreCompositor = Content.Load <Effect>("lightMaskPreCompositor");
 }
예제 #18
0
        private List <Asset> GetUploadedAssets()
        {
            AssetFinder finder = new AssetFinder();

            finder.AssetIdList.Add(0);
            finder.AssetIdList.AddRange(UploadedAssetIdList);
            return(Asset.FindMany(finder));
        }
예제 #19
0
    public bool GetValue()
    {
        if (EditorPersistantBoolDatabase == null)
        {
            EditorPersistantBoolDatabase = AssetFinder.SafeSingleAssetFind <EditorPersistantBoolDatabase>("t:" + typeof(EditorPersistantBoolDatabase));
        }

        return(EditorPersistantBoolDatabase.Get(key));
    }
        public void AddAdvancedSearchCriteria(ref AssetFinder finder)
        {
            // Don't add anything if filter search is disabled
            if (WebsiteBrandManager.GetBrand().HideFilterSearch)
            {
                return;
            }
            //-------------------------------------------------------------------
            // Metadata input selections
            //-------------------------------------------------------------------
            foreach (MetadataInputWrapper input in TemporaryMetaControlsPlaceHolder.Controls)
            {
                IEnumerable <int> metaIds;

                input.GetSelection(out metaIds);

                if (metaIds != null)
                {
                    finder.MetadataIds[input.GroupNumber] = metaIds.ToList();
                }
            }

            if (FileSizeDropDownList.SelectedValue != "any")
            {
                long parsedFileSize = ConvertUserInputToFileSize(FileSizeTextBox.Text);

                if (parsedFileSize > 0)
                {
                    CompareType compareType = GeneralUtils.ParseEnum(FileSizeDropDownList.SelectedValue, CompareType.Exact);
                    finder.AddComplexCriteria(Asset.Columns.FileSize, parsedFileSize, compareType);
                }
            }

            //-------------------------------------------------------------------
            // Production date criteria
            //-------------------------------------------------------------------
            finder.FromProductionDay   = FromDayDropDownList.SelectedId;
            finder.FromProductionMonth = FromMonthDropDownList.SelectedId;
            finder.FromProductionYear  = FromYearDropDownList.SelectedId;
            finder.ToProductionDay     = ToDayDropDownList.SelectedId;
            finder.ToProductionMonth   = ToMonthDropDownList.SelectedId;
            finder.ToProductionYear    = ToYearDropDownList.SelectedId;


            //-------------------------------------------------------------------
            // Asset type specific criteria
            //-------------------------------------------------------------------
            if (AssetTypeCache.Instance.GetById(finder.AssetTypeId).FileExtensionList.Select(extension => AssetTypeInfo.Get(extension)).Any(ati => ati.HasOrientation))
            {
                if (OrientationDropDownList.SelectedValue != "all")
                {
                    finder.Orientation = GeneralUtils.ParseEnum(OrientationDropDownList.SelectedValue, Data.Orientation.All);
                }
            }

            SetupHiddenAssetOptions(finder);
        }
예제 #21
0
        /// <summary>
        /// Gets the number of fully published assets assigned to the category with the specified ID (including it's child categories)
        /// </summary>
        public static int GetPublishedAssetCount(int categoryId)
        {
            AssetFinder finder = new AssetFinder();

            finder.CategoryIdList.Add(Int32.MinValue);
            finder.CategoryIdList.AddRange(GetCategoryIdsForSearch(categoryId));
            finder.IsCompletelyPublished = true;
            return(Asset.GetCount(finder));
        }
예제 #22
0
        public void Refresh()
        {
            var fields = this.gameConfiguration.GetType().GetFields();

            foreach (var field in fields)
            {
                field.SetValue(this.gameConfiguration, AssetFinder.SafeSingleAssetFind <UnityEngine.Object>("t:" + field.FieldType.Name));
            }
            EditorUtility.SetDirty(this.gameConfiguration);
        }
예제 #23
0
    public void OnGUI()
    {
        this.editorProfile = (T)EditorGUILayout.ObjectField(this.editorProfile, typeof(T), false);

        if (this.editorProfile == null)
        {
            this.editorProfile = AssetFinder.SafeSingleAssetFind <T>("t:" + typeof(T).Name);
        }

        if (this.editorProfile != null)
        {
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent("R", "Reset creation wzard."), EditorStyles.miniButtonLeft, GUILayout.Width(20)))
            {
                this.editorProfile.ResetEditor();
            }
            if (GUILayout.Button(new GUIContent(".", "Collapse all."), EditorStyles.miniButtonMid, GUILayout.Width(20)))
            {
                this.editorProfile.ColapseAll();
            }
            if (GUILayout.Button(new GUIContent("*", "Create all."), EditorStyles.miniButtonMid, GUILayout.Width(20)))
            {
                this.editorProfile.CreateAll();
            }
            EditorGUILayout.EndHorizontal();

            editorProfile.WizardScrollPosition = EditorGUILayout.BeginScrollView(editorProfile.WizardScrollPosition);
            this.OnWizardGUI();

            if (GUILayout.Button("GENERATE"))
            {
                if (this.editorProfile.ContainsError())
                {
                    if (EditorUtility.DisplayDialog("Proceed generation ?", "There are errors. Do you want to proceed generation ?", "YES", "NO"))
                    {
                        DoGeneration();
                    }
                }
                else if (this.editorProfile.ContainsWarn())
                {
                    if (EditorUtility.DisplayDialog("Proceed generation ?", "There are warnings. Do you want to proceed generation ?", "YES", "NO"))
                    {
                        DoGeneration();
                    }
                }
                else
                {
                    DoGeneration();
                }
            }

            this.DoGenereatedObject();
            EditorGUILayout.EndScrollView();
        }
    }
예제 #24
0
            protected override void ComputeParameterHash(BinarySerializationWriter writer)
            {
                base.ComputeParameterHash(writer);

                var prefabAsset = AssetFinder.FindAssetFromProxyObject(Parameters.Prefab);

                if (prefabAsset != null)
                {
                    writer.Write(prefabAsset.Version);
                }
            }
예제 #25
0
 public static void ConvertToToon()
 {
     foreach (var selectedObject in Selection.objects)
     {
         if (selectedObject is Material selectedMaterial)
         {
             selectedMaterial.shader = Shader.Find("Unlit/ToonShader");
             selectedMaterial.SetColor("_BaseColor", Color.white);
             selectedMaterial.SetTexture("_DiffuseRamp", AssetFinder.SafeSingleAssetFind <Texture2D>("ToonRamp"));
         }
     }
 }
        private void TestContext(ContextType contextType)
        {
            Plugin         plugin  = GetCurrentPlugin();
            IPluginContext context = PluginManager.GetContext(plugin, contextType);

            if (context != null)
            {
                //get the asset for testing
                Asset asset   = Asset.Empty;
                int   assetId = CurrentAssetID;

                if (assetId > 0)
                {
                    asset = Asset.Get(assetId);
                }

                if (asset.IsNull)
                {
                    if (plugin.HasPluginFile)
                    {
                        //no asset currently selected so find a suitable
                        //one to display in the asset preview control
                        foreach (string extension in plugin.PluginFile.FileExtensions)
                        {
                            AssetFinder finder = new AssetFinder {
                                FileExtension = extension
                            };
                            asset = Asset.FindOne(finder);
                            if (!asset.IsNull)
                            {
                                break; //asset found
                            }
                        }
                    }
                }

                //set asset in testing panel
                ContextTesterAssetIDTextbox.Text = asset.AssetId.GetValueOrDefault().ToString();

                //set the asset, context and pluginid for the viewer to use
                ContextTesterAssetPreview.ContextType = contextType;
                ContextTesterAssetPreview.PluginId    = plugin.PluginId.GetValueOrDefault();
                ContextTesterAssetPreview.Asset       = asset;

                ContextTesterPlaceHolder.Visible = true;
                ContextEditorPlaceHolder.Visible = false;

                CurrentContextType = contextType;
                CurrentAssetID     = asset.AssetId.GetValueOrDefault();
            }
        }
예제 #27
0
        public void SwitchImageTick(object source, EventArgs args)
        {
            var moveTop  = 0;
            var moveLeft = 0;

            var usingImageIndex = _currentBackgroundStage % 2;
            var otherImageIndex = usingImageIndex ^ 1;

            switch (_currentBackgroundStage)
            {
            case 1:
                moveLeft = 1;
                break;

            case 2:
                moveTop  = 1;
                moveLeft = 1;
                break;

            case 3:
                moveTop = 1;
                break;

            default:
                break;
            }

            var newTop       = -(moveTop * (_backgroundImages[usingImageIndex].Height - ActualHeight));
            var oppositeTop  = -((moveTop ^ 1) * (_backgroundImages[usingImageIndex].Height - ActualHeight));
            var newLeft      = -(moveLeft * (_backgroundImages[usingImageIndex].Width - ActualWidth));
            var oppositeLeft = -((moveLeft ^ 1) * (_backgroundImages[usingImageIndex].Width - ActualWidth));

            _backgroundImages[usingImageIndex].Source =
                new BitmapImage(
                    AssetFinder.PathToUri(
                        _lastUsedBackgroundSource = GetRandomBackgroundImageAssetPath(_lastUsedBackgroundSource)));

            _backgroundImages[usingImageIndex].BeginAnimation(OpacityProperty,
                                                              new DoubleAnimation(0, 1.0, TimeSpan.FromSeconds(BackgroundTransitionDuration)));
            _backgroundImages[otherImageIndex].BeginAnimation(OpacityProperty,
                                                              new DoubleAnimation(1.0, 0, TimeSpan.FromSeconds(BackgroundTransitionDuration)));

            StartImageMovement(_backgroundImages[usingImageIndex], newTop, oppositeTop, newLeft, oppositeLeft);

            _currentBackgroundStage++;
            if (_currentBackgroundStage == 4)
            {
                _currentBackgroundStage = 0;
            }
        }
예제 #28
0
        private static bool IsDuplicateFile(ZipFile zipFile, ZipEntry zipEntry, out Asset asset)
        {
            using (Stream stream = zipFile.GetInputStream(zipEntry))
            {
                string hash = FileUtils.GetHash(stream);

                AssetFinder finder = new AssetFinder {
                    FileHash = hash, IsProcessed = true
                };
                finder.SortExpressions.Add(new DescendingSort("AssetId"));
                asset = Asset.FindOne(finder);

                return(!asset.IsNull);
            }
        }
예제 #29
0
파일: Crack.cs 프로젝트: Arce11/Dome
    public void reSprite(int size)
    {
        for (int i = 0; i < sprites.Count; i++)
        {
            sprites[i].QueueFree();
        }
        for (int i = 0; i < size; i++)
        {
            var sprite = new Sprite();
            sprite.Texture = ResourceLoader.Load <Texture>(AssetFinder.GetPathByResourceName(resourceList[i]));

            _resourcesPanel.AddChild(sprite);
            sprite.Position = new Vector2(iconMargin + (iconSize + iconMargin) * i, iconMargin);
        }
    }
        protected void BindToList(List <int> assetIdList)
        {
            AssetIdList = assetIdList;

            AssetFinder finder = new AssetFinder();

            finder.AssetIdList.Add(0);
            finder.AssetIdList.AddRange(assetIdList);
            EntityList <Asset> assetList = Asset.FindMany(finder);

            AssetList AssetList = (AssetList)SiteUtils.FindControlRecursive(Page, "AssetList1");

            AssetList.Repeater.DataSource = assetList;
            AssetList.Repeater.DataBind();
        }