Beispiel #1
0
 // tooltip
 protected void DataGridView1_CellToolTipTextNeeded(object sender, DataGridViewCellToolTipTextNeededEventArgs e)
 {
     try {
         if (MissingItems == null)
         {
             return;
         }
         if (e.RowIndex < 0 || e.RowIndex >= MissingItems.Count)
         {
             return;
         }
         var item = MissingItems[e.RowIndex];
         if (e.ColumnIndex == cID.Index)
         {
             if (item.TryGetID(out var id))
             {
                 string url = ContentUtil.GetItemURL(id.ToString());
                 e.ToolTipText = url;
             }
             else
             {
                 e.ToolTipText = item.GetIncludedPath() ?? "";
             }
         }
     } catch (Exception ex) {
         Log.Exception(ex, $"rowIndex={e.RowIndex}");
     }
 }
Beispiel #2
0
 // tooltip
 protected override void OnCellToolTipTextNeeded(DataGridViewCellToolTipTextNeededEventArgs e)
 {
     base.OnCellToolTipTextNeeded(e);
     try {
         if (AssetList == null)
         {
             return;
         }
         if (e.RowIndex < 0 || e.RowIndex >= AssetList.Filtered.Count)
         {
             return;
         }
         var asset = AssetList.Filtered[e.RowIndex];
         if (e.ColumnIndex == cName.Index)
         {
             e.ToolTipText = AssetList.Filtered[e.RowIndex].Description;
         }
         else if (e.ColumnIndex == cAssetID.Index)
         {
             var    id  = asset.PublishedFileId;
             string url = ContentUtil.GetItemURL(asset.PublishedFileId);
             e.ToolTipText = url ?? asset.AssetPath;
         }
         else if (e.ColumnIndex == cStatus.Index)
         {
             e.ToolTipText = asset.SteamCache?.DownloadFailureReason;
         }
     } catch (Exception ex) {
         Log.Exception(ex, $"rowIndex={e.RowIndex}");
     }
 }
Beispiel #3
0
        // click link/button
        protected void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try {
                if (MissingItems == null)
                {
                    return;
                }
                if (e.RowIndex < 0 || e.RowIndex >= MissingItems.Count)
                {
                    return;
                }
                var item = MissingItems[e.RowIndex];

                if (e.ColumnIndex == cID.Index)
                {
                    if (item.TryGetID(out var id))
                    {
                        string url = ContentUtil.GetItemURL(id.ToString());
                        ContentUtil.OpenURL(url);
                    }
                    else
                    {
                        ContentUtil.OpenPath(item.GetIncludedPath());
                    }
                }
            } catch (Exception ex) {
                Log.Exception(ex);
            }
        }
Beispiel #4
0
        // click link/button
        protected override void OnCellContentClick(DataGridViewCellEventArgs e)
        {
            base.OnCellContentClick(e);
            try {
                if (AssetList == null)
                {
                    return;
                }
                if (e.RowIndex < 0 || e.RowIndex >= AssetList.Filtered.Count)
                {
                    return;
                }
                var asset = AssetList.Filtered[e.RowIndex];

                if (e.ColumnIndex == cAssetID.Index)
                {
                    var    id  = asset.PublishedFileId;
                    string url = ContentUtil.GetItemURL(asset.PublishedFileId);
                    if (url != null)
                    {
                        ContentUtil.OpenURL(url);
                    }
                    else
                    {
                        ContentUtil.OpenPath(asset.AssetPath);
                    }
                }
            } catch (Exception ex) {
                Log.Exception(ex);
            }
        }
Beispiel #5
0
        private async void TsmiReDownload_Click(object sender, EventArgs e)
        {
            try {
                var existingIDs = ContentUtil.GetSubscribedItems();
                var steamItems  = ConfigWrapper.instance.SteamCache.Items;
                var ids         = steamItems
                                  .Where(item => item.Status.IsBroken() && existingIDs.Contains(item.PublishedFileId))
                                  .Select(item => item.ID)
                                  .Concat(ContentUtil.GetMissingDirItems()) // missing root dir
                                  .Distinct()
                                  .ToArray();
                SteamUtil.ReDownload(ids);

                var res = MessageBox.Show(
                    "You can monitor download progress in steam client. Wait for steam to finish downloading. Then press OK to refresh everything.\n" +
                    "should this not work the first time please try again", "Wait for download");
                ConfigWrapper.instance.CSCache.MissingDir             = new ulong[0];
                LoadOrderWindow.Instance.DownloadWarningLabel.Visible = false;
                foreach (var item in steamItems)
                {
                    if (item.Status.IsBroken() && item.DTO != null)
                    {
                        item.RefreshIsUpToDate();
                    }
                }
                await LoadOrderWindow.Instance.ReloadAll(); // reload to fix included/excluded, paths, ...
            } catch (Exception ex) { ex.Log(); }
        }
Beispiel #6
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //2 parte, carregar os valores nas propriedades.
            tecladoAntes = new KeyboardState();
            tecladoAgora = new KeyboardState();
            musicaFundo = Content.Load<Song>("mus_sonar");
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Play(musicaFundo);

            //fundo = Content.Load<Texture2D>("fig_fundo");
            gameOver = Content.Load<Texture2D>("fig_perdeu");
            vitoria = Content.Load<Texture2D>("fig_venceu");
            posicao = new Vector2(0,0);

            vida = Content.Load<Texture2D>("fig_vida");
            fonte = Content.Load<SpriteFont>("fonte");

            torpedos = new List<Torpedos>();

            //Texture2D i = Content.Load<Texture2D>("fig_subazul");
            //Vector2 p = new Vector2(0, 350);
            //Vector2 v = new Vector2(4, 4);
            //player = new Sub_final(i, p, v);

            //inimigo

            // Submarino azul
            fundo = ContentUtil
            submarines.Add(new Submarine(new List<Texture2D>(){ ContentUtil.LoadImage()

        }
Beispiel #7
0
        private static int RunComposite(CompositeOptions options)
        {
            Directory.CreateDirectory(options.TargetDir);
            ContentDefinition cd;

            using (var ifs = new FileStream(options.ContentDefinition, FileMode.Open, FileAccess.Read)) {
                cd = AuthoringUtil.JsonDeserialize <ContentDefinition>(ifs);
            }

            var rm = new DataManager();

            rm.RegisterDataProvider(
                new FileDataProvider(options.ContentDir ?? Path.GetDirectoryName(options.ContentDefinition)));
            var opts = new LiveLoadOptions(loadTextures: true);
            var lc   = ContentUtil.LoadLiveContent(cd, rm, opts);

            foreach (var(name, image) in lc.RenderedCoTextures)
            {
                using (var ofs = new FileStream(Path.Combine(options.TargetDir, name + ".png"), FileMode.Create,
                                                FileAccess.Write))
                    image.SaveAsPng(ofs);
            }

            return(0);
        }
        public DirectionalIndicator(
                ContentUtil content, 
                InputState.Move move,
                float beatTimeInMs,
                float travelSpeed)
        {
            this.recordings = new List<RecordedStart>();
            this.color = Color.White;
            this.move = move;
            this.beatTimeInMs = beatTimeInMs;
            this.travelSpeed = travelSpeed;
            String texName = "hud/arrow_" + move.ToString().ToLower();
            this.texture = new ScaledTexture(
                content.load<Texture2D>(texName), TEXTURE_SCALE);
            switch (move) {
                case InputState.Move.UP:
                    this.direction = new Vector2(0, 1);
                    break;
                case InputState.Move.DOWN:
                    this.direction = new Vector2(0, -1);
                    break;
                case InputState.Move.LEFT:
                    this.direction = new Vector2(1, 0);
                    break;
                case InputState.Move.RIGHT:
                    this.direction = new Vector2(-1, 0);
                    break;
            }

            this.isMoving = false;
        }
Beispiel #9
0
        public static VirtualFileInfo ToFileInfo(this ZipNode node)
        {
            Ensure.ArgumentNotNull(node, "node");

            if (node.IsDirectoryNode)
            {
                string msg = "ZIP entry [{0}] does not represent a file.";
                msg = String.Format(msg, node.FileEntry.FileName);
                throw new InvalidOperationException(msg);
            }

            var fi = new VirtualFileInfo
            {
                Name        = Path.GetFileName(node.FullName),
                ContentType = ContentUtil.ResolveContentType(Path.GetExtension(node.FullName)),
            };


            SetCommonProperties(fi, node);
            if (node.FileEntry != null)
            {
                fi.Length = node.FileEntry.UncompressedSize;
            }

            return(fi);
        }
Beispiel #10
0
        private RelatedLinkDto ConvertToLinkDto(int siteId, IContentLink link)
        {
            ISite        site      = this._siteRep.GetSiteById(link.RelatedSiteId);
            IBaseContent content   = this.GetContent(site.GetAggregaterootId(), ContentTypeIndent.Archive.ToString().ToLower(), link.RelatedContentId);
            String       thumbnail = null;
            IArchive     archive   = content as IArchive;

            if (archive != null)
            {
                thumbnail = archive.Get().Thumbnail;
            }

            return(new RelatedLinkDto
            {
                Id = link.Id,
                Enabled = link.Enabled,
                ContentId = link.ContentId,
                ContentType = link.ContentType,
                RelatedSiteId = link.RelatedSiteId,
                RelatedSiteName = site.Get().Name,
                RelatedContentId = link.RelatedContentId,
                RelatedIndent = link.RelatedIndent,
                Title = archive.Get().Title,
                Url = site.FullDomain + archive.Get().Path,
                Thumbnail = thumbnail,
                IndentName = ContentUtil.GetRelatedIndentName(link.RelatedIndent).Name,
            });
        }
Beispiel #11
0
        // tooltip
        void DgDLCs_OnCellToolTipTextNeeded(object sender, DataGridViewCellToolTipTextNeededEventArgs e)
        {
            try {
                if (DLCList == null)
                {
                    return;
                }
                if (e.RowIndex < 0 || e.RowIndex >= DLCList.Filtered.Count)
                {
                    return;
                }
                var dlc = DLCList.Filtered[e.RowIndex];

                if (e.ColumnIndex == CName.Index)
                {
                    var    id  = new PublishedFileId((ulong)dlc.DLC);
                    string url = ContentUtil.GetDLCURL(id);
                    if (url != null)
                    {
                        e.ToolTipText = url;
                    }
                }
            } catch (Exception ex) {
                Log.Exception(ex, $"rowIndex={e.RowIndex}");
                e.ToolTipText = ex.ToString();
            }
        }
Beispiel #12
0
        // click link/button
        void DgDLCs_OnCellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try {
                if (DLCList == null)
                {
                    return;
                }
                if (e.RowIndex < 0 || e.RowIndex >= DLCList.Filtered.Count)
                {
                    return;
                }
                var dlc = DLCList.Filtered[e.RowIndex];

                if (e.ColumnIndex == CName.Index)
                {
                    var    id  = new PublishedFileId((ulong)dlc.DLC);
                    string url = ContentUtil.GetDLCURL(id);
                    if (url != null)
                    {
                        ContentUtil.OpenURL(url);
                    }
                }
            } catch (Exception ex) {
                Log.Exception(ex);
            }
        }
Beispiel #13
0
 // click link/button
 protected override void OnCellContentClick(DataGridViewCellEventArgs e)
 {
     base.OnCellContentClick(e);
     try {
         Log.Info("OnCellContentClick");
         if (ModList == null)
         {
             return;
         }
         if (e.RowIndex < 0 || e.RowIndex >= ModList.Filtered.Count)
         {
             return;
         }
         var cell = Rows[e.RowIndex].Cells[e.ColumnIndex];
         if (e.ColumnIndex == CModID.Index)
         {
             var mod = ModList.Filtered[e.RowIndex];
             if (mod.IsWorkshop)
             {
                 string url = ContentUtil.GetItemURL(mod.PublishedFileId);
                 if (url != null)
                 {
                     ContentUtil.OpenURL(url);
                 }
             }
             else
             {
                 ContentUtil.OpenPath(ModList.Filtered[e.RowIndex].ModPath);
             }
         }
     } catch (Exception ex) {
         Log.Exception(ex);
     }
 }
Beispiel #14
0
        private void SubscribeAll_Click(object sender, EventArgs e)
        {
            CleanupTextBox();
            var ids = GetIDs(tbIDs.Text);

            ContentUtil.Subscribe(ids);
        }
Beispiel #15
0
 public void initialize(ContentUtil content, SceneActivationParameters parameters)
 {
     this.video = content.load<Video>(this.videoName);
     this.player = null;
     this.size = new Rectangle(0, 0, 0, 0);
     this.forceExit = false;
     this.firstUpdate = true;
 }
Beispiel #16
0
        private static void Upload()
        {
            Console.Out.WriteLine("Press key to start upload");
            Console.ReadLine();

            string sourceFilePath = @"D:\Downloads\1-Time Garbage\_VFS-SERVICE-ROOT\archive.zip";
            var    sourceFile     = new FileInfo(sourceFilePath);

            string uri = "http://localhost:8088/webfs/webupload/writefile?file=copy2.iso&overwrite=true&length={0}&contenttype={1}";

            uri = String.Format(uri, sourceFile.Length, ContentUtil.ResolveContentType(".zip"));
            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(uri);

            req.Method      = "POST";
            req.KeepAlive   = true;
            req.ContentType = ContentUtil.ResolveContentType(".zip"); // "application/octet-stream";

            //disable buffering in order to prevent loading everything to memory first
            req.AllowWriteStreamBuffering = false;
            req.SendChunked = false;

            req.ContentLength = sourceFile.Length;
            Stream reqStream = req.GetRequestStream();

            using (var sourceStream = File.OpenRead(sourceFilePath))
            {
                //use default byte sizes
                byte[] buffer = new byte[32768];

                int block = 0;
                while (true)
                {
                    int bytesRead = sourceStream.Read(buffer, 0, buffer.Length);
                    if (bytesRead > 0)
                    {
                        reqStream.Write(buffer, 0, bytesRead);
                        if (block++ % 500 == 0)
                        {
                            Console.Out.WriteLine("Wrote block {0} with size {1}", block, bytesRead);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            reqStream.Flush();
            reqStream.Close();
//      Console.Out.WriteLine("DONE");
//      return;

            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();

            Console.WriteLine("HTTP/{0} {1} {2}", resp.ProtocolVersion, (int)resp.StatusCode, resp.StatusDescription);
            Console.ReadLine();
        }
 public SpriteBatchWrapper(SpriteBatch wrapped, GraphicsDevice device, ContentUtil content)
 {
     this.wrapped = wrapped;
     this.wrappedDevice = device;
     this.viewport = device.Viewport.Bounds;
     this.fonts = new Dictionary<string, SpriteFont>();
     this.fonts["default"] = content.load<SpriteFont>("default");
     this.content = content;
 }
Beispiel #18
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            this.contentUti = new ContentUtil(this.Content);

            //this.scene = new DanceScene("eattherich");
            this.scene = new SceneManager();
            this.scene.initialize(this.contentUti, null);

            base.Initialize();
        }
Beispiel #19
0
        public RandomSound(String name, int count, ContentUtil content)
        {
            this.sounds = new Sound[count];
            for (int i = 0; i < count; i++) {
                String countStr = "" + (i + 1);
                if (i < 9)
                    countStr = "0" + countStr;

                sounds[i] = new Sound(name + "_" + countStr, content);
            }
        }
Beispiel #20
0
        // template FrameTransformMatrix
        // {
        //     Matrix4x4 frameMatrix;
        // }
        /// <summary>
        /// Imports a transform matrix attached to a ContentNode
        /// </summary>
        /// <returns>The transform matrix attached to the current ContentNode</returns>
        private Matrix ImportFrameTransformMatrix()
        {
            Matrix m = tokens.SkipName().NextMatrix();

            // Reflect the matrix across the Z axis to swap from left hand to right hand
            // coordinate system
            ContentUtil.ReflectMatrix(ref m);
            // skip the "}" at the end of the node
            tokens.SkipToken();
            return(m);
        }
 internal void loadTextures(ContentUtil content, params String[] names)
 {
     foreach (String name in names) {
         if (null == name)
             continue;
         try {
             this.textures[name] = content.load<Texture2D>(name);
         } catch (ContentLoadException e) {
             this.textures[name] = content.load<Texture2D>("missing_texture");
         }
     }
 }
Beispiel #22
0
 public void Load()
 {
     try {
         Log.Called();
         ContentUtil.EnsureSubscribedItems();
         foreach (IDataManager m in Managers)
         {
             m.EventLoaded += OnLoadCallBack;
             m.Load();
         }
     } catch (Exception ex) { ex.Log(); }
 }
Beispiel #23
0
        public void Token_Should_Provide_Proper_Initialization_State()
        {
            Assert.AreEqual(Token.ResourceName, Path.GetFileName(SourceFilePath));
            Assert.AreEqual(Token.ResourceIdentifier, SourceFileInfo.FullName);
            Assert.IsNotEmpty(Token.TransferId);

            Assert.AreEqual(SourceFile.Length, Token.ResourceLength);
            Assert.AreEqual(ContentUtil.ResolveContentType(SourceFile.Extension), Token.ContentType);
            Assert.Greater(Token.DownloadBlockSize, 0);

            Assert.IsNull(Token.ResourceEncoding);
            Assert.IsNull(Token.Md5FileHash);
        }
        public AnimatedCharacter(String name, ContentUtil content, long beatTimeInMs)
        {
            this.idleTexture  = this.loadTexture(content, name + "_idle",  beatTimeInMs);
            this.upTexture    = this.loadTexture(content, name + "_up",    beatTimeInMs);
            this.upTexture.repeat = false;
            this.leftTexture  = this.loadTexture(content, name + "_left",  beatTimeInMs);
            this.leftTexture.repeat = false;
            this.rightTexture = this.loadTexture(content, name + "_right", beatTimeInMs);
            this.rightTexture.repeat = false;
            this.downTexture  = this.loadTexture(content, name + "_down",  beatTimeInMs);
            this.downTexture.repeat = false;

            this.reset();
        }
Beispiel #25
0
        public ContextMenuItems(string path, PublishedFileId id)
        {
            path_ = path;
            var itemOpenFile = new ToolStripMenuItem("Open File Location");

            itemOpenFile.Click += ItemOpenFile_Click;
            Items.Add(itemOpenFile);

            if (id != PublishedFileId.invalid)
            {
                url_ = ContentUtil.GetItemURL(id);
                var itemOpenURL = new ToolStripMenuItem("Open In Workshop");
                itemOpenURL.Click += ItemOpenURL_Click;;
                Items.Add(itemOpenURL);
            }
        }
        /// <summary>
        /// Requests a download token for a given resource.
        /// </summary>
        /// <param name="resourceIdentifier"></param>
        /// <param name="includeFileHash">Whether a file hash for the
        /// requested resource should be calculated and assigned to the
        /// <see cref="DownloadToken.Md5FileHash"/> property of the returned
        /// <see cref="DownloadToken"/>.</param>
        /// <returns></returns>
        public DownloadToken RequestDownloadToken(string resourceIdentifier, bool includeFileHash)
        {
            FileInfo fileInfo = FileResolveFunc(resourceIdentifier);

            if (!fileInfo.Exists)
            {
                string msg = String.Format("Resource [{0}] not found.", resourceIdentifier);
                throw new VirtualResourceNotFoundException(msg);
            }

            string transferId = Guid.NewGuid().ToString();

            DownloadToken dt = new DownloadToken
            {
                TransferId         = transferId,
                ResourceIdentifier = resourceIdentifier,
                CreationTime       = SystemTime.Now(),
                ContentType        = ContentUtil.ResolveContentType(fileInfo.Extension),
                DownloadBlockSize  = 512 * 1024,           //TODO configure block size and expiration
                ResourceName       = fileInfo.Name,
                ResourceLength     = fileInfo.Length,
                ExpirationTime     = SystemTime.Now().AddHours(24),
                Status             = TransferStatus.Starting
            };

            //calculate number of blocks
            long count = dt.ResourceLength / dt.DownloadBlockSize.Value;

            if (dt.ResourceLength % dt.DownloadBlockSize != null)
            {
                count++;
            }
            dt.TotalBlockCount = count;

            if (includeFileHash)
            {
                dt.Md5FileHash = fileInfo.CalculateMd5Hash();
            }

            var transfer = new DownloadTransfer(dt)
            {
                File = fileInfo
            };

            Transfers.Add(transferId, transfer);
            return(dt);
        }
Beispiel #27
0
 // tooltip
 protected override void OnCellFormatting(DataGridViewCellFormattingEventArgs e)
 {
     base.OnCellFormatting(e);
     try {
         if (ModList == null)
         {
             return;
         }
         //Log.Info($"e.ColumnIndex={e.ColumnIndex} Description.Index={Description.Index}");
         if (e.RowIndex < 0)
         {
             return;
         }
         if (e.RowIndex >= ModList.Filtered.Count || e.RowIndex >= Rows.Count)
         {
             return;
         }
         var cell = Rows[e.RowIndex].Cells[e.ColumnIndex];
         if (e.ColumnIndex == CDescription.Index && e.Value != null)
         {
             cell.ToolTipText = ModList.Filtered[e.RowIndex].Description;
         }
         else if (e.ColumnIndex == CStatus.Index && e.Value != null)
         {
             var mod = ModList.Filtered[e.RowIndex];
             cell.ToolTipText = mod.SteamCache?.DownloadFailureReason;
         }
         else if (e.ColumnIndex == CModID.Index)
         {
             var mod = ModList.Filtered[e.RowIndex];
             if (mod.IsWorkshop)
             {
                 cell.ToolTipText = ContentUtil.GetItemURL(mod.PublishedFileId);
             }
             else
             {
                 cell.ToolTipText = ModList.Filtered[e.RowIndex].ModPath;
             }
         }
         else
         {
             cell.ToolTipText = null;
         }
     } catch (Exception ex) {
         Log.Exception(ex, $"e.ColumnIndex={e.ColumnIndex} e.RowIndex={e.RowIndex}");
     }
 }
Beispiel #28
0
        /// <summary>
        /// Creates meta information for a given file.
        /// </summary>
        /// <param name="localFile">The local file.</param>
        /// <returns>A <see cref="VirtualFileInfo"/> that matches the submitted file.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="localFile"/>
        /// is a null reference.</exception>
        public static VirtualFileInfo CreateFileResourceInfo(this FileInfo localFile)
        {
            if (localFile == null)
            {
                throw new ArgumentNullException("localFile");
            }
            localFile.Refresh();
            var item = new VirtualFileInfo
            {
                Length           = localFile.Exists ? localFile.Length : 0,
                ContentType      = ContentUtil.ResolveContentType(localFile.Extension),
                ParentFolderPath = localFile.DirectoryName,
            };

            MapProperties(localFile, item);
            return(item);
        }
Beispiel #29
0
            // "This template is instantiated on a per-mesh basis. Within a mesh, a sequence of n
            // instances of this template will appear, where n is the number of bones (X file frames)
            // that influence the vertices in the mesh. Each instance of the template basically defines
            // the influence of a particular bone on the mesh. There is a list of vertex indices, and a
            // corresponding list of weights.
            // template SkinWeights
            // {
            //     STRING transformNodeName;
            //     DWORD nWeights;
            //     array DWORD vertexIndices[nWeights];
            //     array float weights[nWeights];
            //     Matrix4x4 matrixOffset;
            // }
            // - The name of the bone whose influence is being defined is transformNodeName,
            // and nWeights is the number of vertices affected by this bone.
            // - The vertices influenced by this bone are contained in vertexIndices, and the weights for
            // each of the vertices influenced by this bone are contained in weights.
            // - The matrix matrixOffset transforms the mesh vertices to the space of the bone. When concatenated
            // to the bone's transform, this provides the world space coordinates of the mesh as affected by the bone."
            // (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/
            //  directx9_c/dx9_graphics_reference_x_file_format_templates.asp)
            //


            // Reads in a bone that contains skin weights.  It then adds one bone weight
            //  to every vertex that is influenced by ths bone, which contains the name of the bone and the
            //  weight.
            public void ImportSkinWeights()
            {
                isSkinned = true;
                string boneName = tokens.SkipName().NextString();
                // an influence is an index to a vertex that is affected by the current bone
                int          numInfluences = tokens.NextInt();
                List <int>   influences    = new List <int>();
                List <float> weights       = new List <float>();

                for (int i = 0; i < numInfluences; i++)
                {
                    influences.Add(tokens.NextInt());
                }
                for (int i = 0; i < numInfluences; i++)
                {
                    weights.Add(tokens.NextFloat());
                    if (weights[i] == 0)
                    {
                        influences[i] = -1;
                    }
                }
                influences.RemoveAll(delegate(int i) { return(i == -1); });
                weights.RemoveAll(delegate(float f) { return(f == 0); });

                // Add the matrix that transforms the vertices to the space of the bone.
                // we will need this for skinned animation.
                Matrix blendOffset = tokens.NextMatrix();

                ContentUtil.ReflectMatrix(ref blendOffset);
                skinTransformDictionary.Add(boneName, blendOffset);
                SkinTransformContent trans = new SkinTransformContent();

                trans.BoneName  = boneName;
                trans.Transform = blendOffset;
                skinTransforms.Add(trans);
                // end of skin weights
                tokens.SkipToken();

                // add a new name/weight pair to every vertex influenced by the bone
                for (int i = 0; i < influences.Count; i++)
                {
                    skinInfo[influences[i]].Add(new BoneWeight(boneName,
                                                               weights[i]));
                }
            }
        public void initialize(ContentUtil content, ContentScript script)
        {
            this.bakground = content.load<Texture2D>(script.get("background"));

            if (script.contains("beatlayers")){
                this.beatSigns = new BeatLayer[script["beatlayers"].Count];
                for (int i = 0; i < this.beatSigns.Length; i++){
                    this.beatSigns[i] = new BeatLayer(content, script["beatlayers"][i]);
                }
            }

            if (script.contains("countlayers")) {
                this.countSigns = new Texture2D[script["countlayers"].Count];
                for (int i = 0; i < this.countSigns.Length; i++) {
                    this.countSigns[i] = content.load<Texture2D>(script["countlayers"][i]);
                }
            }
        }
        public void initialize(ContentUtil content, SceneActivationParameters parameters)
        {
            this.exit = false;
            this.content = content;
            this.scenes = new Dictionary<string,IScene>();
            this.defaultScene = "menu";

            this.scenes["story_01"] = new VideoScene("video/story_01");
            this.scenes["story_02"] = new VideoScene("video/story_02");
            this.scenes["story_03"] = new VideoScene("video/story_03");
            this.scenes["story_04"] = new VideoScene("video/story_04");
            this.scenes["credits"] = new VideoScene("video/credits");

            SceneChain storyMode = new SceneChain();
            storyMode.addToChain(
                "story_01",
                "level_01",
                "story_02",
                "level_02",
                "story_03",
                "level_03",
                "story_04",
                "level_04",
                "credits");
            this.scenes["story_mode"] = storyMode;

            MenuScene menu = new MenuScene();
            this.scenes["menu"] = menu;
            //menu.add(new MenuItem("story_mode", "Story Mode", this));

            this.addDanceScene("level_01", menu);
            this.addDanceScene("level_02", menu);
            this.addDanceScene("level_03", menu);
            this.addDanceScene("level_04", menu);
            //menu.add(new MenuItem("highscore", "Highscore", new HighscoreParams("T-Bone the Steak")));
            this.scenes["highscore"] = new HighscoreScene();

            //menu.add(new MenuItem("exit", "Quit Game"));

            menu.buildMenuStructure(this);

            this.initIntroScenes();
        }
Beispiel #32
0
        public LiveContent LoadLiveContent(DataManager dataManager,
                                           LiveLoadOptions opts, CacheManager cacheManager = null)
        {
            if (_contentDefinition == null)
            {
                throw new InvalidOperationException();
            }
            if (dataManager == null)
            {
                throw new ArgumentNullException(nameof(dataManager));
            }
            var rp = GetResourceProvider();

            dataManager.RegisterDataProvider(rp);
            try {
                return(ContentUtil.LoadLiveContent(_contentDefinition, dataManager, opts, cacheManager));
            }
            finally {
                dataManager.DeregisterDataProvider(rp);
            }
        }
Beispiel #33
0
        public void initialize(
                ContentUtil content, 
                DanceSequenceProtocol protocol, 
                float beatTimeInMS,
                float uiSpeed)
        {
            this.beatTimeInMs = beatTimeInMS;
            this.initHud(content, uiSpeed);

            this.errorSound = new Sound("hud/error_move", content);
            this.successSound = null;// new Sound("hud/success_move");
            this.seqSuccessSound = new RandomSound("hud/perfect", 10, content);

            float bpms = 1 / beatTimeInMS;
            foreach (DanceSequence.Input input in protocol.handicaps) {
                if (!this.hud.ContainsKey(input.handicap))
                    continue;

                this.hud[input.handicap].prerecord(input.startTime(bpms), Color.Orange);
            }

            this.transitions.initialize(content, protocol, beatTimeInMS);
        }
Beispiel #34
0
        private void Launch()
        {
            if (!ConfigWrapper.AutoSave && ConfigWrapper.Dirty)
            {
                var result = MessageBox.Show(
                    caption: "Unsaved changes",
                    text:
                    "There are changes that are not saved to game and will not take effect. " +
                    "Save changes to game before launching it?",
                    buttons: MessageBoxButtons.YesNoCancel);
                switch (result)
                {
                case DialogResult.Cancel:
                    return;

                case DialogResult.Yes:
                    ConfigWrapper.SaveConfig();
                    CO.GameSettings.SaveAll();
                    break;

                case DialogResult.No:
                    break;

                default:
                    Log.Exception(new Exception("FormClosing: Unknown choice" + result));
                    break;
                }
            }
            var args = GetCommandArgs();

            UpdateFiles();

            string fileExe = radioButtonSteamExe.Checked ? DataLocation.SteamExe : DataLocation.CitiesExe;
            string dir     = radioButtonSteamExe.Checked ? DataLocation.SteamPath : DataLocation.GamePath;

            ContentUtil.Execute(dir, fileExe, string.Join(" ", args));
        }
        public void initialize(ContentUtil content, SceneActivationParameters parameters)
        {
            HighscoreParams stageParams = (HighscoreParams) parameters.parameters;
            this.stageName = stageParams.stage;
            this.nextScore = stageParams.newScore;

            this.showInputSound = new Sound("menu/select", content);
            this.createSound = new Sound("menu/click", content);

            this.background = content.load<Texture2D>(null == stageParams.background ?
                "bgr_highscore" : stageParams.background);

            this.lineBackground = new ScaledTexture(content.load<Texture2D>(
                null == stageParams.background ? "hud/highscore_line" : stageParams.background+"_line"),
                .4f);

            this.scores = new HighscoreList();
            this.scores.loadForScene(stageName);
            this.exit = false;

            this.nameInput = new TextInput();

            /*if (null == this.nextScore) {
                this.nextScore = new PlayerProgress();
                this.nextScore.score = 4321;
            }*/
            if (null != this.nextScore) {
                this.nameInput.setMessage("You scored "
                        + this.nextScore.score
                        + ". Please enter your name.");
                this.showInputSound.play();
                this.nameInput.startListening();
            }

            //this.scores.add(new Scoring("Batman", this.nextScore.score, true));
            this.initTime = Environment.TickCount;
        }
 private AnimatedTexture loadTexture(ContentUtil content, String name, long time)
 {
     Texture2D tex = content.load<Texture2D>(name);
     AnimatedTexture anim = new AnimatedTexture(tex, time);
     return anim;
 }
Beispiel #37
0
 private ScaledTexture[][] loadButtonTextures(ContentUtil content)
 {
     ScaledTexture[][] textures = new ScaledTexture[4][];
     for (int i = 0; i < textures.Length; i++) {
         textures[i] = new ScaledTexture[2];
         textures[i][0] = new ScaledTexture(
             content.load<Texture2D>("menu/button" + (i + 1) + "_deactivated"),
             .5f);
         textures[i][1] = new ScaledTexture(
             content.load<Texture2D>("menu/button" + (i + 1) + "_activated"),
             .5f);
     }
     return textures;
 }
Beispiel #38
0
 private void initHud(ContentUtil content, float uiSpeed)
 {
     this.hud.Clear();
     this.hud[InputState.Move.UP] = new DirectionalIndicator(content, InputState.Move.UP, this.beatTimeInMs, uiSpeed);
     this.hud[InputState.Move.DOWN] = new DirectionalIndicator(content, InputState.Move.DOWN, this.beatTimeInMs, uiSpeed);
     this.hud[InputState.Move.LEFT] = new DirectionalIndicator(content, InputState.Move.LEFT, this.beatTimeInMs, uiSpeed);
     this.hud[InputState.Move.RIGHT] = new DirectionalIndicator(content, InputState.Move.RIGHT, this.beatTimeInMs, uiSpeed);
 }
Beispiel #39
0
        /*
         * template Animation
         * {
         * [...]
         * }
         */
        /// <summary>
        /// Fills in all the channels of an animation.  Each channel refers to
        /// a single bone's role in the animation.
        /// </summary>
        /// <param name="boneName">The name of the bone associated with the channel</param>
        /// <returns>The imported animation channel</returns>
        private AnimationChannel ImportAnimationChannel(out string boneName)
        {
            AnimationChannel anim = new AnimationChannel();

            // Store the frames in an array, which acts as an intermediate data set
            // This will allow us to more easily provide support for non Matrix
            // animation keys at a later time
            AnimationKeyframe[]      rotFrames    = null;
            AnimationKeyframe[]      transFrames  = null;
            AnimationKeyframe[]      scaleFrames  = null;
            List <AnimationKeyframe> matrixFrames = null;

            boneName = null;
            tokens.SkipName();
            for (string next = tokens.NextToken(); next != "}"; next = tokens.NextToken())
            {
                // A set of animation keys
                if (next == "AnimationKey")
                {
                    // These keys can be rotation (0),scale(1),translation(2), or matrix(3 or 4) keys.
                    int keyType;
                    AnimationKeyframe[] frames = ImportAnimationKey(out keyType);
                    if (keyType == 0)
                    {
                        rotFrames = frames;
                    }
                    else if (keyType == 1)
                    {
                        scaleFrames = frames;
                    }
                    else if (keyType == 2)
                    {
                        transFrames = frames;
                    }
                    else
                    {
                        matrixFrames = new List <AnimationKeyframe>(frames);
                    }
                }
                // A possible bone name
                else if (next == "{")
                {
                    string token = tokens.NextToken();
                    if (tokens.NextToken() != "}")
                    {
                        tokens.SkipNode();
                    }
                    else
                    {
                        boneName = token;
                    }
                }
            }
            // Fill in the channel with the frames
            if (matrixFrames != null)
            {
                matrixFrames.Sort(new Comparison <AnimationKeyframe>(delegate(AnimationKeyframe one,
                                                                              AnimationKeyframe two)
                {
                    return(one.Time.CompareTo(two.Time));
                }));
                if (matrixFrames[0].Time != TimeSpan.Zero)
                {
                    matrixFrames.Insert(0, new AnimationKeyframe(new TimeSpan(),
                                                                 matrixFrames[0].Transform));
                }
                for (int i = 0; i < matrixFrames.Count; i++)
                {
                    Matrix m = matrixFrames[i].Transform;
                    ContentUtil.ReflectMatrix(ref m);
                    matrixFrames[i].Transform = m;
                    anim.Add(matrixFrames[i]);
                }
            }
            else
            {
                List <AnimationKeyframe> combinedFrames = ContentUtil.MergeKeyFrames(
                    scaleFrames, transFrames, rotFrames);
                for (int i = 0; i < combinedFrames.Count; i++)
                {
                    Matrix m = combinedFrames[i].Transform;
                    ContentUtil.ReflectMatrix(ref m);
                    combinedFrames[i].Transform = m; //* Matrix.CreateRotationX(MathHelper.PiOver2);
                    anim.Add(combinedFrames[i]);
                }
            }
            return(anim);
        }
Beispiel #40
0
        public void initialize(ContentUtil content, SceneActivationParameters parameters)
        {
            this.exit = false;
            this.paused = false;
            this.textures.clear();
            this.currentSequence = null;
            this.input = new ExplicitInputState();

            script.reload();
            this.textures.loadTextures(content,
                "player_character", "btn_up", "btn_down", "btn_left", "btn_right", "btn_fail");

            //this.backgroundTexture = this.script.get("background");
            //this.textures.loadTextures(content, this.backgroundTexture);
            this.background.initialize(content, this.script);

            this.song = new Song(this.script, content);

            this.progress = new PlayerProgress();

            this.sequences.initialize(this.script);

            float uiSpeed = 1.0f;
            if (this.script.contains("ui_speed"))
                uiSpeed = this.script.asFloat["ui_speed"][0];
            this.ui.initialize(content, this.sequences, this.song.beatTimeInMs, uiSpeed);

            long beatTimeMs = (long) this.song.beatTimeInMs;
            this.enemy = new AnimatedCharacter(this.script.get("enemy"), content, beatTimeMs);
            this.player = new AnimatedCharacter("toasty/toasty", content, beatTimeMs);

            this.lastTime = 0;
            this.song.play();
        }
Beispiel #41
0
 private void SubscribeAll_Click(object sender, EventArgs e)
 {
     ContentUtil.Subscribe(GetMissingIDs());
 }
 public void initialize(ContentUtil content, SceneActivationParameters parameters)
 {
     this.picture = content.load<Texture2D>(this.pictureName);
     this.fadeAmount = 0.0f;
     this.runningTime = null;
 }
Beispiel #43
0
 public bool TryGetID(out ulong id) => ContentUtil.TryGetModID(IncludedPathFinal, out id);
Beispiel #44
0
 public virtual void initialize(ContentUtil content, SceneActivationParameters parameters)
 {
     this.manager = (SceneManager) parameters.parameters;
     this.currentSceneIndex = -1;
     this.activateNext();
 }
Beispiel #45
0
        public void initialize(ContentUtil content, SceneActivationParameters parameters)
        {
            this.input = new ExplicitInputState();
            this.next = false;
            this.exit = false;
            this.firstUpdate = true;
            this.background = content.load<Texture2D>("menu/background01");
            this.clickSound = new Sound("menu/click", content);
            this.selectSound = new Sound("menu/select", content);
            if (null == this.backgroundSong || this.backgroundSong.stoppedPlaying())
                this.backgroundSong = new Song("menu/backgroundsong", content, 120f);

            ScaledTexture[][] buttonTextures = this.loadButtonTextures(content);

            foreach (MenuItem item in this.items) {
                int texIndex = SystemRef.nextRandomInt(0, 4);
                item.initialize(this.clickSound, this.selectSound,
                    buttonTextures[texIndex][0],
                    buttonTextures[texIndex][1]);
            }
            this.items[0].select();
        }
 public override void initialize(ContentUtil content, SceneActivationParameters parameters)
 {
     base.initialize(content, parameters);
     this.song = new Song(this.songName, content, this.bpm);
 }
Beispiel #47
0
 public Song(String contentName, ContentUtil content, float bpm)
 {
     this.bpm = bpm;
     this.content = content.load<Microsoft.Xna.Framework.Media.Song>(contentName);
 }
Beispiel #48
0
 public void SetRelatedIndents(IDictionary <int, RelateIndent> relatedIndents)
 {
     ContentUtil.SetRelatedIndents(relatedIndents);
 }
Beispiel #49
0
 public Song(ContentScript script, ContentUtil content)
     : this(script["song"][0], content, script.asFloat["tempo"][0])
 {
     if (null != script["startshift"])
         this.timeShift = this.beatTimeInMs * script.asFloat["startshift"][0];
 }
Beispiel #50
0
 public IDictionary <int, RelateIndent> GetRelatedIndents()
 {
     return(ContentUtil.GetRelatedIndents());
 }
            public BeatLayer(ContentUtil content, String loadString)
            {
                String[] cfg = loadString.Split(' ');
                this.texture = content.load<Texture2D>(cfg[0]);
                this.alpha = 0.0f;

                this.updateLengthInBeats = cfg.Length > 1 ? ParserUtil.toFloat(cfg[1]) : 1.0f;
                this.startInMeasure = cfg.Length > 2 ? ParserUtil.toFloat(cfg[2]) : 0.0f;
            }
Beispiel #52
0
 public Sound(String contentName, ContentUtil content)
 {
     this.sound = content.load<SoundEffect>(contentName);
 }
Beispiel #53
0
 private static void BtnLogFile_Click(object sender, EventArgs e) =>
 ContentUtil.OpenPath(Log.LogFilePath);