Ejemplo n.º 1
0
    void OnPreImportClosed(bool proceed, string name, string fullPath)
    {
        if (!proceed)
        {
            return;
        }
        name = (name == null || name.Trim().Length == 0) ? "Untitled Image" : name;
        string ext     = Path.GetExtension(fullPath).ToLowerInvariant();
        string tempDir = Util.CreateTempDirectory();

        File.Copy(fullPath, Path.Combine(tempDir, "image" + ext));

        string id = System.Guid.NewGuid().ToString();
        ProgressBlockStyleUI listItem = Instantiate(progressItemPrefab, settingsUI.textureParent);

        listItem.transform.SetAsFirstSibling();
        listItem.name = id;
        listItem.SetThumbnail(Util.ReadPngToTexture(fullPath));
        listItem.gameObject.SetActive(true);
        importingListItems[id] = new Util.Tuple <ProgressBlockStyleUI, WorkshopAssetSource.GetUploadProgress>(
            listItem,
            () => { return(0); });

        workshopAssetSource.Put(
            tempDir, name, name, GameBuilder.SteamUtil.GameBuilderTags.BlockStyle,
            null, null, result => OnUploadComplete(name, result, id), (getProgress) =>
        {
            importingListItems[id].second = getProgress;
        });

        settingsUI.scrollRect.verticalNormalizedPosition = 1;
    }
Ejemplo n.º 2
0
        public void updateResultsForJob(bool forceUpdate = true)
        {
            // Chooses the best model for a given job.
            //Parameters
            //---------------------------------------------------------------------- -
            //forceUpdate:  (True / False).If True, the update will ignore all the
            //restrictions on the minimum time to update and the minimum
            //number of records to update.This should typically only be
            //set to true if the model has completed running
            var updateInterval = (DateTime.Now - _lastUpdateAttemptTime).TotalSeconds;

            if (updateInterval < _MIN_UPDATE_INTERVAL && !forceUpdate)
            {
                return;
            }

            LOGGER.Info(string.Format("Attempting model selection for jobID={0}: time={1}lastUpdate={2}", _jobID,
                                      DateTime.Now, _lastUpdateAttemptTime));

            bool timestampUpdated = _cjDB.jobUpdateSelectionSweep(_jobID, _MIN_UPDATE_INTERVAL);

            if (!timestampUpdated)
            {
                LOGGER.Info(string.Format("Unable to update selection sweep timestamp: jobID={0} updateTime={1}",
                                          _jobID, _lastUpdateAttemptTime));
            }
            if (!forceUpdate)
            {
                return;
            }

            _lastUpdateAttemptTime = DateTime.Now;
            LOGGER.Info(string.Format("Succesfully updated selection sweep timestamp jobid={0} updateTime={1}",
                                      _jobID, _lastUpdateAttemptTime));

            int minUpdateRecords = _MIN_UPDATE_THRESHOLD;

            object jobResults = _getJobResults();

            if (forceUpdate || jobResults == null)
            {
                minUpdateRecords = 0;
            }

            //candidateIDs, bestMetric = this._cjDB.modelsGetCandidates(this._jobID, minUpdateRecords);
            Util.Tuple tuple        = this._cjDB.modelsGetCandidates(this._jobID, minUpdateRecords);
            List <int> candidateIDs = (List <int>)tuple.Item1;
            double     bestMetric   = (double)tuple.Item2;

            LOGGER.Info(string.Format("Candidate models={0}, metric={1}, jobID={2}", Arrays.ToString(candidateIDs), bestMetric, _jobID));

            if (candidateIDs.Count == 0)
            {
                return;
            }

            _jobUpdateCandidate(candidateIDs[0], bestMetric, resultsObj: jobResults);
        }
Ejemplo n.º 3
0
    void OnSoundUploadComplete(string name, Util.Maybe <ulong> result, string id)
    {
        Util.Tuple <ProgressItemUI, WorkshopAssetSource.GetUploadProgress> tuple = importingListItems[id];
        importingListItems.Remove(id);
        Destroy(tuple.first.gameObject);

        if (result.IsEmpty())
        {
            popups.Show("Error uploading sound to Steam Workshop:\n" + result.GetErrorMessage(), "OK", () => { });
            return;
        }
        SoundEffect soundEffect = new SoundEffect(
            id, name, SoundEffectContent.NewWithSteamWorkshopId(result.Value));

        soundEffectSystem.PutSoundEffect(soundEffect);
        // TODO: maybe immediately open the just-created sound effect?
    }
Ejemplo n.º 4
0
    void OnPreImportClosed(bool proceed, string soundName, string fullPath)
    {
        if (!proceed)
        {
            return;
        }
        soundName = (soundName == null || soundName.Trim().Length == 0) ? "Untitled Sound" : soundName;
        string ext     = Path.GetExtension(fullPath).ToLowerInvariant();
        string tempDir = Util.CreateTempDirectory();

        File.Copy(fullPath, Path.Combine(tempDir, "audio" + ext));

        string id = System.Guid.NewGuid().ToString();

        ui.soundsList.noneText.gameObject.SetActive(false);
        ProgressItemUI listItem = Instantiate(ui.progressSoundItemPrefab, ui.soundsList.contentRect.transform);

        listItem.name       = id;
        listItem.label.text = soundName;
        listItem.gameObject.SetActive(true);
        importingListItems[id] = new Util.Tuple <ProgressItemUI, WorkshopAssetSource.GetUploadProgress>(
            listItem,
            () => { return(0); });
#if USE_STEAMWORKS
        workshopAssetSource.Put(tempDir, soundName, soundName, GameBuilder.SteamUtil.GameBuilderTags.WAV, null, null,
                                result => OnSoundUploadComplete(soundName, result, id), (getProgress) =>
        {
            importingListItems[id].second = getProgress;
        });
#else
        workshopAssetSource.Put(tempDir, soundName, soundName, GameBuilder.SteamUtil.GameBuilderTags.WAV,
                                result => OnSoundUploadComplete(soundName, result, id), (getProgress) =>
        {
            importingListItems[id].second = getProgress;
        });
#endif
    }
Ejemplo n.º 5
0
 void DestroyImportFeedback(string id)
 {
     Util.Tuple <ProgressBlockStyleUI, WorkshopAssetSource.GetUploadProgress> tuple = importingListItems[id];
     importingListItems.Remove(id);
     Destroy(tuple.first.gameObject);
 }