Beispiel #1
0
        //============================================================
        public void LoadClip(FRsResourceClip clip)
        {
            chbReverse.CheckState    = CheckState.Unchecked;
            chbReverseDirection.Text = null;
            chbReverseCd.Text        = null;
            FRsResourcePicture pic = new FRsResourcePicture();

            _clip         = clip;
            _frameCurrent = 0;
            if (null != clip)
            {
                DirectionShow();
                int width  = (int)(_clip.ValidRectangle.Width * _clipScale);
                int height = (int)(_clip.ValidRectangle.Height * _clipScale);
                if (0 != width && 0 != height)
                {
                    ChangeSize(width, height);
                }
                pbxViewer.Visible = true;
            }
            else
            {
                pbxViewer.Visible = false;
            }
        }
Beispiel #2
0
        //============================================================
        // <T>配置资源处理。</T>
        //
        // @param resource 资源
        //============================================================
        public void SetupResource(FUiPicture resource)
        {
            if (!resource.IsValid())
            {
                resource.resource = null;
                return;
            }
            // 释放旧资源
            if (resource.bitmap != null)
            {
                resource.bitmap.Dispose();
                resource.bitmap = null;
            }
            // 选择新资源
            FRsResourcePicture picture = RContent2dManager.ResourceConsole.FindOpen(resource.Code) as FRsResourcePicture;

            if (picture != null)
            {
                resource.bitmap   = _context.Device.CreateBitmap(picture.Bitmap.Native);
                resource.resource = picture;
                // 设置属性
                //string padding = RString.SubStringLast(picture.Label, "(", ")");
                //if (!RString.IsEmpty(padding)) {
                //   if(_groundResource.Padding.Parse(padding)) {
                //      _groundResource.AlignCd = ERcPictureAlign.Square;
                //   }
                //}
            }
        }
Beispiel #3
0
        //============================================================
        // <T>资源点击事件。</T>
        //============================================================
        private void qrsResourceList_ResourceClick(object sender, EventArgs e)
        {
            FRsResource resource = qrsResourceList.SelectedResource;

            if (null != resource)
            {
                // 打开资源
                resource.Open();
                // 显示资源
                SuspendLayout();
                qrsClipViewer.Visible    = false;
                qrsPictureViewer.Visible = false;
                // 显示动画
                if (resource is FRsResourceAnimation)
                {
                    FRsResourceAnimation animation = resource as FRsResourceAnimation;
                    FRsResourceClip      clip      = animation.FristClip;
                    qrsClipViewer.LoadClip(clip);
                    qrsClipViewer.DoPlay();
                    qrsClipViewer.Visible = true;
                }
                // 显示图片
                if (resource is FRsResourcePicture)
                {
                    FRsResourcePicture picture = resource as FRsResourcePicture;
                    qrsPictureViewer.LoadPicture(picture);
                    qrsPictureViewer.Visible = true;
                    labInfo.Text             = picture.Format();
                }
                ResumeLayout();
            }
        }
Beispiel #4
0
        //============================================================
        // <T>创建资源对象。</T>
        //
        // @param typeCd 资源类型
        // @param code 代码
        //============================================================
        public FRsResource CreateResource(int typeCd, int code)
        {
            // 创建资源
            FRsResource resource = null;

            switch (typeCd)
            {
            case ERsResource.Picture:
                resource = new FRsResourcePicture();
                break;

            case ERsResource.Animation:
                resource = new FRsResourceAnimation();
                break;

            case ERsResource.Sound:
                resource = new FRsResourceSound();
                break;

            case ERsResource.Music:
                resource = new FRsResourceMusic();
                break;
            }
            // 检查存在性
            if (_resources.Contains(code))
            {
                RMoCore.TrackConsole.Write(this, "CreateResource", "Duplicate resource code. (code={0})", code);
            }
            // 设置对照表
            _resources.Set(code, resource);
            return(resource);
        }
Beispiel #5
0
 //============================================================
 public void LoadPicture(FRsResourcePicture picture)
 {
     if (null != picture)
     {
         _picture = picture;
         int w = (int)(picture.Size.Width * _pictureScale);
         int h = (int)(picture.Size.Height * _pictureScale);
         ChangeSize(w, h);
     }
 }
Beispiel #6
0
        //============================================================
        // <T>绘制出生点。</T>
        //============================================================
        public void DrawBirths()
        {
            FObjects <FMbMapBirth> births = _map.Births;

            if (!births.IsEmpty())
            {
                int count = births.Count;
                for (int n = 0; n < count; n++)
                {
                    FMbMapBirth birth    = births[n];
                    SIntPoint2  location = birth.Location;
                    // 获取敌机集合
                    FObjects <FMbMapBirthEnemy> enemys = birth.BirthEnemys;
                    int enemyCount = enemys.Count;
                    for (int x = 0; x < enemyCount; x++)
                    {
                        FMbMapBirthEnemy birthEnemy = enemys[x];
                        int         templateId      = birthEnemy.TemplateId;
                        FMbTplEnemy enemy           = RMobileManager.TemplateConsole.EnemyConsole.FingById(templateId);
                        int         resourceRid     = enemy.ResourceRid;
                        // 获取资源图片
                        FRsResourcePicture resource    = RContent2dManager.ResourceConsole.FindOpen(resourceRid) as FRsResourcePicture;
                        Bitmap             resourceMap = resource.Bitmap.Native;
                        // 创建绘制对象
                        FDxBitmap bitmap = null;
                        if (!_dxBitmapSet.Contains(resourceRid.ToString()))
                        {
                            bitmap = _context.Device.CreateBitmap(resourceMap);
                            _dxBitmapSet.Set(resourceRid.ToString(), bitmap);
                        }
                        else
                        {
                            bitmap = _dxBitmapSet.Get(resourceRid.ToString());
                        }
                        _context.DrawBitmap(bitmap, location.X - _location.X, location.Y - _location.Y);
                    }
                }
            }
        }
Beispiel #7
0
        //============================================================
        // <T>加载敌机列表。</T>
        //============================================================
        protected void InnerBuildEnemy()
        {
            // 找到敌机控制台
            FMbEnemyConsole enemyConsole = RMobileManager.TemplateConsole.EnemyConsole;
            int             index        = 0;

            imageEnemyList.Images.Clear();
            lvwFly.BeginUpdate();
            lvwFly.Items.Clear();
            foreach (FMbTplEnemy enemy in enemyConsole.Enemys)
            {
                int resourceRid                = enemy.ResourceRid;
                FRsResourcePicture resource    = RContent2dManager.ResourceConsole.FindOpen(resourceRid) as FRsResourcePicture;
                Bitmap             resourceMap = resource.Bitmap.Native;
                imageEnemyList.Images.Add(resourceMap);
                ListViewItem listViewItem = new ListViewItem();
                listViewItem.Text       = resourceRid.ToString();
                listViewItem.ImageIndex = index;
                listViewItem.Tag        = enemy;
                lvwFly.Items.Add(listViewItem);
                index++;
            }
            lvwFly.EndUpdate();
        }
Beispiel #8
0
 //============================================================
 // <T>选择资源。</T>
 //
 // @param resource 资源
 //============================================================
 public void SelectResource(FRsResource resource)
 {
     // 打开资源
     resource.Open();
     // 显示资源
     qrsClipViewer.Visible    = false;
     qrsPictureViewer.Visible = false;
     // 显示动画
     if (resource is FRsResourceAnimation)
     {
         FRsResourceAnimation animation = resource as FRsResourceAnimation;
         FRsResourceClip      clip      = animation.FristClip;
         qrsClipViewer.LoadClip(clip);
         qrsClipViewer.DoPlay();
         qrsClipViewer.Visible = true;
     }
     // 显示动画
     if (resource is FRsResourcePicture)
     {
         FRsResourcePicture picture = resource as FRsResourcePicture;
         qrsPictureViewer.LoadPicture(picture);
         qrsPictureViewer.Visible = true;
     }
 }
Beispiel #9
0
        //============================================================
        // <T>加载资源信息。</T>
        //
        // @param resource 资源对象
        //============================================================
        public override void LoadResource(FRsResource resource)
        {
            base.LoadResource(resource);
            // 设置资源
            _resourcePicture = resource as FRsResourcePicture;
            // 设置信息
            //if (null != _resourcePicture.Group) {
            //   txtGroupName.Text = _resourcePicture.Group.Code;
            //}
            //resourceCode = _resourcePicture.Code;
            txtLabel.Text       = _resourcePicture.Label;
            txtFileName.Text    = _resourcePicture.FileName;
            cbxAlpha.Checked    = _resourcePicture.OptionAlpha;
            chkPandding.Checked = _resourcePicture.OptionPadding;
            // 设置调色板类型
            switch (_resourcePicture.QualityPalette)
            {
            case 64:
                rbnPaletteColor64.Checked = true;
                break;;

            case 128:
                rbnPaletteColor128.Checked = true;
                break;;

            case 256:
                rbnPaletteColor256.Checked = true;
                break;;
            }
            // 设置超时类型
            switch (_resourcePicture.TimeoutCd)
            {
            case "none":
                radNull.Checked = true;
                break;

            case "short":
                radShort.Checked = true;
                break;

            case "middle":
                radMiddle.Checked = true;
                break;

            case "long":
                radLong.Checked = true;
                break;
            }
            // 设置质量类型
            switch (_resourcePicture.QualityCd)
            {
            case ERsResourceQuality.Max:
                ranPalettePixel5.Checked = true;
                break;

            case ERsResourceQuality.Middle:
                ranPalettePixel3.Checked = true;
                break;

            case ERsResourceQuality.Lower:
                ranPalettePixel2.Checked = true;
                break;

            case ERsResourceQuality.High:
                ranPalettePixel4.Checked = true;
                break;

            case ERsResourceQuality.Min:
                ranPalettePixel1.Checked = true;
                break;

            default:
                break;
            }
            // 设置预览
            qpbImage.ScaleMode = EPictureBoxMode.ScalePixel;
            qpbImage.LoadBitmap(_resourcePicture.Bitmap.Native);
            //int count = RDsResource.PicturePixelSplit;
            //if (_resourcePicture.QualityCd == 0 || _resourcePicture.QualityCd == count) {
            //   _resourcePicture.QualityCd = count;
            //   ranPalettePixel3.Checked = true;
            //   return;
            //}
            //if (_resourcePicture.QualityCd > count) {
            //   int sum = _resourcePicture.QualityCd / count;
            //   if (sum == 2) {
            //      ranPalettePixel2.Checked = true;
            //   }
            //   if (sum == 4) {
            //      ranPalettePixel1.Checked = true;
            //   }
            //}
            //if (_resourcePicture.QualityCd < count) {
            //   int sum = count / _resourcePicture.QualityCd;
            //   if (sum == 2) {
            //      ranPalettePixel4.Checked = true;
            //   }
            //   if (sum == 4) {
            //      ranPalettePixel5.Checked = true;
            //   }
            //}
        }
Beispiel #10
0
        //============================================================
        // <T>扫描文件夹。</T>
        //============================================================
        public void Scan()
        {
            // 处理所有子文件
            FStrings fileNames = RDirectory.ListFiles(_directory);

            foreach (string fileName in fileNames)
            {
                if (-1 != fileName.IndexOf(".svn"))
                {
                    continue;
                }
                // 解析资源
                string shortName = fileName.Substring(fileName.LastIndexOf("\\") + 1);
                string name      = shortName.Substring(3);
                // 解析图片资源
                if (shortName.StartsWith("RP-"))
                {
                    string fullName   = name;
                    string label      = name;
                    int    codeIndex  = name.IndexOf("-");
                    int    labelIndex = name.IndexOf(".png");
                    if (-1 != codeIndex)
                    {
                        label    = name.Substring(0, labelIndex);
                        fullName = name.Substring(codeIndex + 1, labelIndex - codeIndex);
                        name     = name.Substring(0, codeIndex);
                    }
                    if (11 == name.Length)
                    {
                        name = name.Replace(".", "");
                        // 创建图片资源
                        int code = RInt.Parse(name);
                        FRsResourcePicture picture = RContent2dManager.ResourceConsole.CreateResource(ERsResource.Picture, code) as FRsResourcePicture;
                        picture.Folder    = this;
                        picture.Code      = code;
                        picture.Name      = name;
                        picture.Label     = label;
                        picture.FullLabel = FullLabel + "\\" + label;
                        picture.Keyword   = label.Replace(".", "");
                        picture.FileName  = fileName;
                        picture.Directory = _directory;
                        picture.Scan();
                        _resources.Push(picture);
                    }
                }
                // 解析音乐资源
                if (shortName.StartsWith("RM-"))
                {
                    string fullName   = name;
                    string label      = name;
                    int    codeIndex  = name.IndexOf("-");
                    int    labelIndex = name.IndexOf(".mp3");
                    if (-1 != codeIndex)
                    {
                        label    = name.Substring(0, labelIndex);
                        fullName = name.Substring(codeIndex + 1, labelIndex - codeIndex);
                        name     = name.Substring(0, codeIndex);
                    }
                    if (11 == name.Length)
                    {
                        name = name.Replace(".", "");
                        // 创建音乐资源
                        int code = RInt.Parse(name);
                        FRsResourceMusic music = RContent2dManager.ResourceConsole.CreateResource(ERsResource.Music, code) as FRsResourceMusic;
                        music.Folder    = this;
                        music.Code      = code;
                        music.Name      = name;
                        music.Label     = label;
                        music.FullLabel = FullLabel + "\\" + label;
                        music.Keyword   = label.Replace(".", "");
                        music.FileName  = fileName;
                        music.Directory = _directory;
                        music.Scan();
                        _resources.Push(music);
                    }
                }
                // 解析声音资源
                if (shortName.StartsWith("RS-"))
                {
                    string fullName   = name;
                    string label      = name;
                    int    codeIndex  = name.IndexOf("-");
                    int    labelIndex = name.IndexOf(".mp3");
                    if (-1 != codeIndex)
                    {
                        label    = name.Substring(0, labelIndex);
                        fullName = name.Substring(codeIndex + 1, labelIndex - codeIndex);
                        name     = name.Substring(0, codeIndex);
                    }
                    if (11 == name.Length)
                    {
                        name = name.Replace(".", "");
                        // 创建声音资源
                        int code = RInt.Parse(name);
                        FRsResourceSound sound = RContent2dManager.ResourceConsole.CreateResource(ERsResource.Sound, code) as FRsResourceSound;
                        sound.Folder    = this;
                        sound.Code      = code;
                        sound.Name      = name;
                        sound.Label     = label;
                        sound.FullLabel = FullLabel + "\\" + label;
                        sound.Keyword   = label.Replace(".", "");
                        sound.FileName  = fileName;
                        sound.Directory = _directory;
                        sound.Scan();
                        _resources.Push(sound);
                    }
                }
            }
            // 加载设置信息
            //_configName = _directory + "\\config.xml";
            //if (RFile.Exists(_configName)) {
            //   FXmlDocument xdoc = new FXmlDocument();
            //   xdoc.LoadFile(_configName);
            //   foreach (FXmlNode xnode in xdoc.Root.Nodes) {
            //      if (xnode.IsName("Object")) {
            //         string code = null;
            //         if (xnode.Contains("code")) {
            //            code = xnode.Get("code");
            //         } else {
            //            code = xnode.Get("id", String.Empty);
            //         }
            //         if ("" == code) {
            //         }
            //         //FDsResource resource = FindResourceById(code);
            //         //if(null != resource) {
            //         //   resource.LoadConfig(xnode);
            //         //}
            //      }
            //   }
            //}
        }