public ContentOperationCallbackArgs(IAdditionalContent content, IVaultOperation activeOperation, bool success, params object[] args)
 {
     this.mArgs = null;
     this.mContent = content;
     this.mActiveOperation = activeOperation;
     this.mCompletedSuccessfully = success;
     this.mArgs = args;
 }
Пример #2
0
 public DlgContentDetailsView(IAdditionalContent content)
 {
     this.InitializeComponent();
     this.Text = string.Format(Loc.Get("<LOC>{0} Details"), content.ContentType.SingularDisplayName);
     this.mContent = content;
     this.mDetailView = new PnlContentDetailsView(this);
     this.mDetailView.Location = new Point(4, 4);
     this.gpgPanelContainer.Controls.Add(this.DetailView);
     this.mDetailView.BindToMyContent(this.Content);
     ActiveViews[this.Content.ID] = this;
 }
 public VaultFTPUploadOperation(IAdditionalContent content, long position)
 {
     this.mContent = null;
     this.mPosition = 0L;
     this.mWorkThread = null;
     this.mChksum = "";
     this.mOutCount = 0;
     this.StatusChanged = null;
     this.mContent = content;
     this.mPosition = position;
     VaultUploadOperation.ActiveOperations.Insert(0, this);
 }
Пример #4
0
 public static DlgContentDetailsView CreateOrGetExisting(IAdditionalContent content)
 {
     if (content == null)
     {
         return null;
     }
     if (ActiveViews.ContainsKey(content.ID))
     {
         return ActiveViews[content.ID];
     }
     return new DlgContentDetailsView(content);
 }
 public VaultDirectDownloadOperation(IAdditionalContent content, long position)
 {
     this.mDownloading = false;
     this.mWebClient = new WebClient();
     this.OperationFinished = null;
     this.mLastStatus = "";
     this.mContent = content;
     this.mPosition = position;
     VaultDownloadOperation.ActiveOperations.Insert(0, this);
     this.mWebClient.DownloadFileCompleted += new AsyncCompletedEventHandler(this.mWebClient_DownloadFileCompleted);
     this.mWebClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(this.mWebClient_DownloadProgressChanged);
 }
Пример #6
0
 public VaultUploadOperation(IAdditionalContent content, long position)
 {
     this.WS = new Service();
     this.mSessionID = Guid.NewGuid();
     this.mChunkSize = ConfigSettings.GetInt("VaultUpChunkSize", 0x7d000);
     this.Progress = 0;
     this.SubmittingChunk = false;
     this.UploadFile = null;
     this.ProgressChanged = null;
     this.Finished = null;
     this.StatusChanged = null;
     this.mIsDisposed = false;
     this.mLastStatus = "<LOC>Idle";
     this.mIsProgressFinished = false;
     this.mIsOperationFinished = false;
     this.OperationFinished = null;
     this.mContent = content;
     this.mPosition = position;
     ActiveOperations.Insert(0, this);
 }
Пример #7
0
 public ActivityMonitor(IAdditionalContent content, IVaultOperation operation)
 {
     this.InitializeComponent();
     this.mContent = content;
     this.mOperation = operation;
     this.SetStatus(this.Operation.LastStatus, new object[0]);
     if (this.Operation.IsProgressFinished)
     {
         this.OnProgressFinished();
     }
     if (this.Operation.IsOperationFinished)
     {
         this.OnOperationFinished();
     }
     this.Operation.OperationFinished += new ContentOperationCallback(this.Operation_OperationFinished);
     this.gpgLabelName.Text = content.Name;
     this.gpgPictureBoxContentType.Image = this.imageListContentTypes.Images[this.Content.ContentType.ImageIndex];
     this.progressMeter.Monitor = operation;
     operation.StatusChanged += new StatusProviderEventHandler(this.operation_StatusChanged);
     base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
 }
Пример #8
0
 public VaultUploadOperation(IAdditionalContent content) : this(content, 0L)
 {
 }
Пример #9
0
 public bool FromLocalFile(string file, out IAdditionalContent content)
 {
     Exception exception;
     if (!base.ContentType.CurrentUserCanUpload)
     {
         content = null;
         return false;
     }
     try
     {
         byte[] buffer;
         int num2;
         string extension = Path.GetExtension(file);
         string contents = "";
         XmlDocument document = null;
         switch (extension)
         {
             case ".scd":
             case ".zip":
             {
                 ZipFile file2 = null;
                 try
                 {
                     file2 = new ZipFile(file);
                     Enumeration enumeration = file2.entries();
                     List<ZipEntry> list = new List<ZipEntry>();
                     while (enumeration.hasMoreElements())
                     {
                         list.Add(enumeration.nextElement() as ZipEntry);
                     }
                     bool flag = false;
                     foreach (ZipEntry entry in list)
                     {
                         if (entry.getName().EndsWith("_scenario.lua"))
                         {
                             string fileName = Path.GetFileName(entry.getName());
                             this.mMapName = fileName.Remove(fileName.IndexOf("_scenario.lua"), "_scenario.lua".Length);
                             InputStream stream = null;
                             try
                             {
                                 string str5;
                                 stream = file2.getInputStream(entry);
                                 buffer = new byte[0x1000];
                                 bool flag2 = false;
                                 while (!flag2)
                                 {
                                     num2 = 0;
                                     while (num2 < buffer.Length)
                                     {
                                         int num = stream.read();
                                         if (num < 0)
                                         {
                                             flag2 = true;
                                             break;
                                         }
                                         buffer[num2] = (byte) num;
                                         num2++;
                                     }
                                     contents = contents + Encoding.UTF8.GetString(buffer, 0, num2);
                                 }
                                 string tempFileName = Path.GetTempFileName();
                                 System.IO.File.WriteAllText(tempFileName, contents);
                                 if (!LuaUtil.VerifyScenario(tempFileName, out str5))
                                 {
                                     ErrorLog.WriteLine("Error loading custom map file {0}: {1}", new object[] { Path.GetFileName(tempFileName), str5 });
                                     content = null;
                                     return false;
                                 }
                                 new XmlDocument().LoadXml(LuaUtil.ScenarioToXml(tempFileName));
                                 System.IO.File.Delete(tempFileName);
                                 base.LocalFilePath = file;
                                 flag = true;
                                 break;
                             }
                             finally
                             {
                                 if (stream != null)
                                 {
                                     stream.close();
                                 }
                             }
                         }
                     }
                     if (!flag)
                     {
                         content = null;
                         return false;
                     }
                 }
                 finally
                 {
                     file2.close();
                 }
                 goto Label_03C3;
             }
             default:
             {
                 if (!(extension == ".lua"))
                 {
                     goto Label_03C3;
                 }
                 if (!file.EndsWith("_scenario.lua"))
                 {
                     content = null;
                     return false;
                 }
                 this.mMapName = Path.GetFileName(file);
                 this.mMapName = this.mMapName.Remove(this.mMapName.IndexOf("_scenario.lua"), "_scenario.lua".Length);
                 document = new XmlDocument();
                 document.LoadXml(LuaUtil.ScenarioToXml(file));
                 FileStream stream2 = null;
                 for (num2 = 0; num2 < 3; num2++)
                 {
                     try
                     {
                         bool flag4;
                         base.LocalFilePath = Path.GetDirectoryName(file);
                         stream2 = System.IO.File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read);
                         buffer = new byte[0x1000];
                         int count = 0;
                         goto Label_034E;
                     Label_0316:
                         count = stream2.Read(buffer, 0, buffer.Length);
                         if (count < 1)
                         {
                             break;
                         }
                         contents = contents + Encoding.UTF8.GetString(buffer, 0, count);
                     Label_034E:
                         flag4 = true;
                         goto Label_0316;
                     }
                     catch (Exception exception1)
                     {
                         exception = exception1;
                         ErrorLog.WriteLine(exception);
                         Thread.Sleep(0x3e8);
                     }
                     finally
                     {
                         if (stream2 != null)
                         {
                             stream2.Close();
                         }
                     }
                 }
                 break;
             }
         }
         if ((contents == null) || (contents.Length < 1))
         {
             content = null;
             return false;
         }
     Label_03C3:
         if (document == null)
         {
             content = null;
             return false;
         }
         base.Name = document["scenario"]["name"].InnerText;
         this.mMapDescription = document["scenario"]["description"].InnerText;
         this.mWidth = int.Parse(document["scenario"]["size"]["width"].InnerText);
         this.mHeight = int.Parse(document["scenario"]["size"]["height"].InnerText);
         this.mSize = (this.Width + this.Height) / 2;
         this.mMaxPlayers = int.Parse(document["scenario"]["max_players"].InnerText);
         string innerText = document["scenario"]["map"].InnerText;
         if ((extension == ".scd") || (extension == ".zip"))
         {
             this.mPreviewImage256 = ExtractZippedImage(file, innerText);
         }
         else
         {
             this.mPreviewImage256 = ExtractImage(file, innerText);
         }
         this.mPreviewImage50 = null;
         this.mPreviewImage128 = null;
         content = this;
         return true;
     }
     catch (Exception exception2)
     {
         exception = exception2;
         ErrorLog.WriteLine(exception);
         content = null;
         return false;
     }
 }
Пример #10
0
 public DlgContentAdmin(IAdditionalContent content)
 {
     this.InitializeComponent();
     this.mContent = content;
 }
Пример #11
0
 public static string FormatLink(IAdditionalContent content)
 {
     return string.Format("content:\"{0}{1}{2}\"", content.ID, '\x0003', content.Name);
 }
Пример #12
0
 public bool FromID(int contentId, out IAdditionalContent content)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Пример #13
0
 public bool FromLocalFile(string file, out IAdditionalContent content)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Пример #14
0
 public bool FromLocalFile(string file, out IAdditionalContent content)
 {
     if (!base.ContentType.CurrentUserCanUpload)
     {
         content = null;
         return false;
     }
     string extension = Path.GetExtension(file);
     base.LocalFilePath = file;
     base.Name = Path.GetFileName(file);
     base.Name = base.Name.Remove(base.Name.Length - extension.Length, extension.Length);
     this.VideoFormat = extension;
     content = this;
     return true;
 }
Пример #15
0
 private void gvResults_MouseDown(object sender, MouseEventArgs e)
 {
     this.DlMouseDown = null;
     if ((this.MouseOverDownload != null) && !AdditionalContent.IsDownloadingContent(this.MouseOverDownload))
     {
         GridHitInfo info = this.gvResults.CalcHitInfo(e.Location);
         if ((info.InRowCell && ((!AdditionalContent.DownloadExistsLocal(this.MouseOverDownload) || !(info.Column.FieldName != "Version")) && ((info.Column.FieldName == "Download") || (info.Column.FieldName == "Version")))) && (this.Cursor == Cursors.Hand))
         {
             this.DlMouseDown = this.MouseOverDownload;
             if (!this.DownloadMouseUpHooked)
             {
                 this.HookMouseUpForDownloadButton(this);
                 this.DownloadMouseUpHooked = true;
             }
         }
     }
 }
Пример #16
0
 public void MergeWithLocalVersion(IAdditionalContent localVersion)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Пример #17
0
 public void BindToMyContent(IAdditionalContent content)
 {
     int num = 6;
     this.mContent = content;
     this.LoadDependencies();
     this.skinButtonRun.Visible = content.CanRun;
     this.gpgGroupBoxMyContentGeneral.Visible = true;
     this.gpgLabelContentDesc.Text = content.Description;
     this.gpgLabelContentDownloads.Text = content.Downloads.ToString();
     this.gpgLabelContentName.Text = content.Name;
     this.gpgLabelContentOwnerName.Text = content.OwnerName;
     this.gpgLabelContentVDate.Text = content.VersionDate.ToShortDateString();
     this.gpgLabelContentVersion.Text = content.Version.ToString();
     this.gpgLabelContentVNotes.Text = content.VersionNotes;
     this.pictureBoxContentRating.Image = content.RatingImageSmall;
     this.SetDownloadsLabel();
     this.pictureBoxHeader.Image = VaultImages.ResourceManager.GetObject("header_" + content.ContentType.Name.ToLower()) as Image;
     this.gpgLabelHeader.Text = content.ContentType.DisplayName;
     this.skinButtonRun.SkinBasePath = content.RunImagePath;
     if (content.CanRun)
     {
         base.ttDefault.SetToolTip(this.skinButtonRun, Loc.Get(content.RunTooltip));
     }
     else
     {
         base.ttDefault.SetToolTip(this.skinButtonRun, "");
     }
     if (this.CurrentDetailView != null)
     {
         this.gpgGroupBoxMyContentGeneral.Controls.Remove(this.CurrentDetailView);
         this.gpgGroupBoxMyContentGeneral.Height -= this.CurrentDetailView.Height + (num * 2);
     }
     ContentOptions detailsView = content.GetDetailsView();
     if (detailsView.HasOptions)
     {
         detailsView.OptionsControl.Top = this.gpgPanelMyContentGeneral.Bottom + num;
         detailsView.OptionsControl.Left = this.gpgPanelMyContentGeneral.Left;
         this.gpgGroupBoxMyContentGeneral.Controls.Add(detailsView.OptionsControl);
         this.gpgGroupBoxMyContentGeneral.Height += detailsView.OptionsControl.Height + (num * 2);
         this.CurrentDetailView = detailsView.OptionsControl;
         if (this.CurrentDetailView.Width > this.gpgPanelMyContentGeneral.Width)
         {
             this.CurrentDetailView.Width = this.gpgPanelMyContentGeneral.Width;
         }
     }
     this.RefreshActionButtons();
     PictureBox[] boxArray = new PictureBox[] { this.pictureBoxRate1, this.pictureBoxRate2, this.pictureBoxRate3, this.pictureBoxRate4, this.pictureBoxRate5 };
     for (int i = 0; i < boxArray.Length; i++)
     {
         if (!AdditionalContent.RatingEnabled)
         {
             boxArray[i].Image = VaultImages.star_gray;
         }
         else if (this.UserRating.HasValue && (i < this.UserRating.Value))
         {
             boxArray[i].Image = VaultImages.star;
         }
         else
         {
             boxArray[i].Image = VaultImages.star_empty;
         }
     }
     this.skinButtonDeleteRating.Visible = this.UserRating.HasValue;
     this.CommentCount = -1;
     this.DeletedComment = -1;
     this.UpdateComments();
     this.skinButtonPostCommentTop.Top = this.gpgGroupBoxMyContentGeneral.Bottom + num;
     this.gpgPanelComments.Top = this.skinButtonPostCommentTop.Bottom + num;
     this.gpgLabelNoComments.Top = this.skinButtonPostCommentTop.Bottom + num;
     this.skinButtonPostCommentBottom.Top = this.gpgPanelComments.Bottom + num;
     base.Height = this.skinButtonPostCommentBottom.Bottom;
 }
Пример #18
0
 public bool FromID(int contentId, out IAdditionalContent content)
 {
     if (!base.ContentType.CurrentUserCanUpload)
     {
         content = null;
         return false;
     }
     content = this.CreateEmptyInstance();
     return true;
 }
Пример #19
0
 public bool FromID(int contentId, out IAdditionalContent content)
 {
     CustomMap map;
     if (!base.ContentType.CurrentUserCanUpload)
     {
         content = null;
         return false;
     }
     bool flag = new QuazalQuery("GetMapById", new object[] { contentId }).GetObject<CustomMap>(out map);
     content = map;
     return flag;
 }
Пример #20
0
 private void BindToDownloadType()
 {
     if (this.SelectedDownloadOptions != null)
     {
         this.gpgPanelSearchCriteria.Controls.Remove(this.SelectedDownloadOptions);
     }
     if (this.ResultColumns != null)
     {
         foreach (GridColumn column in this.ResultColumns)
         {
             this.gvResults.Columns.Remove(column);
         }
     }
     if (((this.treeViewDownloadType.SelectedNode != null) && (this.treeViewDownloadType.SelectedNode.Tag != null)) && (this.treeViewDownloadType.SelectedNode.Tag is ContentType))
     {
         Program.Settings.Content.Download.SearchType = this.treeViewDownloadType.SelectedNode.Name;
         ContentType tag = this.treeViewDownloadType.SelectedNode.Tag as ContentType;
         this.SelectedDownloadContent = tag.CreateInstance().CreateEmptyInstance();
         this.RefreshContentLists();
         ContentOptions downloadOptions = this.SelectedDownloadContent.GetDownloadOptions();
         if (this.CurrentSearchView == SearchViews.Advanced)
         {
             if (downloadOptions.HasOptions)
             {
                 if (this.SelectedDownloadOptions != null)
                 {
                     int num = downloadOptions.OptionsControl.Height - this.SelectedDownloadOptions.Height;
                     this.gpgGroupBoxCriteria.Height += num;
                     this.gpgGroupBoxResults.Top += num;
                     this.gpgGroupBoxResults.Height -= num;
                 }
             }
             else
             {
                 this.ToggleSearchView();
             }
         }
         else if (downloadOptions.HasOptions)
         {
             downloadOptions.OptionsControl.Visible = false;
         }
         if (downloadOptions.HasOptions)
         {
             int num2 = 4;
             this.SelectedDownloadOptions = downloadOptions.OptionsControl;
             this.SelectedDownloadOptions.Location = new Point(this.gpgTextBoxSearchName.Left, this.gpgTextBoxSearchName.Bottom + num2);
             this.gpgPanelSearchCriteria.Controls.Add(this.SelectedDownloadOptions);
             this.skinButtonSearchType.Enabled = true;
         }
         else
         {
             this.SelectedDownloadOptions = null;
             this.skinButtonSearchType.Enabled = false;
         }
         this.gvResults.Columns.Clear();
         this.gvResults.Columns.AddRange(this.DefaultGridColumns);
         this.gvResults.PreviewFieldName = "Description";
         this.dataGridSearchResults.DataSource = null;
         this.skinLabelSearchPage.Text = Loc.Get("<LOC>No Results");
         this.SelectedDownloadContent.SetGridView(this.gvResults);
         this.gvResults.BestFitColumns();
     }
 }
Пример #21
0
 private void gvResults_MouseUp(object sender, MouseEventArgs e)
 {
     if (this.MouseOverDownload == null)
     {
         this.DlMouseDown = null;
     }
     else
     {
         GridHitInfo info = this.gvResults.CalcHitInfo(e.Location);
         if (info.InRowCell)
         {
             if (info.Column.FieldName == "Download")
             {
                 if ((this.Cursor == Cursors.Hand) && (this.DlMouseDown == this.MouseOverDownload))
                 {
                     this.DlMouseDown = null;
                     this.DownloadContent(this.MouseOverDownload);
                     return;
                 }
             }
             else if (info.Column.FieldName == "Version")
             {
                 if (this.ViewingVersionHistory)
                 {
                     return;
                 }
                 if (this.Cursor == Cursors.Hand)
                 {
                     IAdditionalContent row = this.gvResults.GetRow(info.RowHandle) as IAdditionalContent;
                     if (row.CurrentVersion != 1)
                     {
                         this.ExecuteVersionSearch(row);
                     }
                 }
             }
             this.DlMouseDown = null;
             this.gvResults.InvalidateRows();
         }
     }
 }
Пример #22
0
 private void gvResults_MouseMove(object sender, MouseEventArgs e)
 {
     this.MouseOverDownload = null;
     this.LastMouseLoc = e.Location;
     GridHitInfo hitInfo = this.gvResults.CalcHitInfo(e.Location);
     if (!hitInfo.InRowCell)
     {
         this.Cursor = Cursors.Default;
     }
     else
     {
         this.MouseOverDownload = this.gvResults.GetRow(hitInfo.RowHandle) as IAdditionalContent;
         this.gvResults.InvalidateHitObject(hitInfo);
         if (this.LastDownloadHit != null)
         {
             this.gvResults.InvalidateHitObject(this.LastDownloadHit);
         }
         if ((hitInfo.Column.FieldName != "Version") && (hitInfo.Column.FieldName != "Download"))
         {
             this.Cursor = Cursors.Default;
         }
         this.LastDownloadHit = hitInfo;
     }
 }
Пример #23
0
 public bool FromLocalFile(string file, out IAdditionalContent content)
 {
     if (!base.ContentType.CurrentUserCanUpload)
     {
         content = null;
         return false;
     }
     try
     {
         string extension = Path.GetExtension(file);
         string str2 = Path.GetFileName(file).Replace(extension, "");
         base.Name = str2;
         base.LocalFilePath = file;
         content = this;
         return true;
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
         content = null;
         return false;
     }
 }
Пример #24
0
 public void MergeWithLocalVersion(IAdditionalContent localVersion)
 {
     if (base.ContentType.CurrentUserCanUpload && (localVersion is CustomMap))
     {
         CustomMap map = localVersion as CustomMap;
         base.LocalFilePath = map.LocalFilePath;
         this.mHeight = map.Height;
         this.mMaxPlayers = map.MaxPlayers;
         this.mPreviewImage256 = map.mPreviewImage256;
         this.mPreviewImage50 = null;
         this.mPreviewImage128 = null;
         this.mSize = map.Size;
         this.mWidth = map.Width;
         this.MapDescription = map.MapDescription;
         if (base.ID < 1)
         {
             base.Name = map.Name;
         }
     }
 }
Пример #25
0
 public PnlContentDetailsView(DlgBase parentForm, IAdditionalContent content)
 {
     this.components = null;
     this.CurrentDetailView = null;
     this.CommentCount = -1;
     this.DeletedComment = -1;
     this.InitializeComponent();
     base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
     this.mParentDialog = parentForm;
     this.BindToMyContent(content);
 }
Пример #26
0
 public bool FromID(int contentId, out IAdditionalContent content)
 {
     Mod mod;
     if (!base.ContentType.CurrentUserCanUpload)
     {
         content = null;
         return false;
     }
     bool flag = new QuazalQuery("GetModById", new object[] { contentId }).GetObject<Mod>(out mod);
     content = mod;
     return flag;
 }
Пример #27
0
 public bool FromID(int contentId, out IAdditionalContent content)
 {
     Video video;
     if (!base.ContentType.CurrentUserCanDownload)
     {
         content = null;
         return false;
     }
     bool flag = new QuazalQuery("GetVideoById", new object[] { contentId }).GetObject<Video>(out video);
     content = video;
     return flag;
 }
Пример #28
0
 public bool FromLocalFile(string file, out IAdditionalContent content)
 {
     if (!base.ContentType.CurrentUserCanUpload)
     {
         content = null;
         return false;
     }
     try
     {
         string tempFileName;
         string str6;
         string str7;
         string extension = Path.GetExtension(file);
         XmlDocument document = null;
         switch (extension)
         {
             case ".scd":
             case ".zip":
             {
                 ZipFile file2 = null;
                 try
                 {
                     file2 = new ZipFile(file);
                     Enumeration enumeration = file2.entries();
                     List<ZipEntry> list = new List<ZipEntry>();
                     while (enumeration.hasMoreElements())
                     {
                         list.Add(enumeration.nextElement() as ZipEntry);
                     }
                     foreach (ZipEntry entry in list)
                     {
                         if (!entry.isDirectory())
                         {
                             this.NumberOfFiles++;
                         }
                         if (entry.getName().ToLower().EndsWith("mod_info.lua"))
                         {
                             string path = entry.getName();
                             string directoryName = Path.GetDirectoryName(path);
                             if ((directoryName == null) || (directoryName.Length < 1))
                             {
                                 directoryName = Path.GetDirectoryName(file);
                             }
                             this.mModName = new DirectoryInfo(directoryName).Name;
                             path = Path.GetFileName(path);
                             InputStream stream = null;
                             try
                             {
                                 stream = file2.getInputStream(entry);
                                 byte[] bytes = new byte[0x1000];
                                 bool flag = false;
                                 string contents = "";
                                 while (!flag)
                                 {
                                     int index = 0;
                                     while (index < bytes.Length)
                                     {
                                         int num = stream.read();
                                         if (num < 0)
                                         {
                                             flag = true;
                                             break;
                                         }
                                         bytes[index] = (byte) num;
                                         index++;
                                     }
                                     contents = contents + Encoding.UTF8.GetString(bytes, 0, index);
                                 }
                                 tempFileName = Path.GetTempFileName();
                                 System.IO.File.WriteAllText(tempFileName, contents);
                                 str7 = LuaUtil.ModToXml(tempFileName, out str6);
                                 if ((str6 != null) && (str6.Length > 0))
                                 {
                                     ErrorLog.WriteLine("Error parsing Mod file: {0}", new object[] { str6 });
                                     content = null;
                                     return false;
                                 }
                                 document = new XmlDocument();
                                 document.LoadXml(str7);
                                 base.LocalFilePath = file;
                                 System.IO.File.Delete(tempFileName);
                             }
                             finally
                             {
                                 if (stream != null)
                                 {
                                     stream.close();
                                 }
                             }
                         }
                     }
                 }
                 finally
                 {
                     file2.close();
                 }
                 break;
             }
             default:
                 if (extension == ".lua")
                 {
                     if (!file.EndsWith("mod_info.lua"))
                     {
                         content = null;
                         return false;
                     }
                     str7 = LuaUtil.ModToXml(file, out str6);
                     if ((str6 != null) && (str6.Length > 0))
                     {
                         ErrorLog.WriteLine("Error parsing Mod file: {0}", new object[] { str6 });
                         content = null;
                         return false;
                     }
                     document = new XmlDocument();
                     document.LoadXml(str7);
                     base.LocalFilePath = Path.GetDirectoryName(file);
                     this.mNumberOfFiles = Directory.GetFiles(base.LocalFilePath, "*.*", SearchOption.AllDirectories).Length;
                     this.mModName = new DirectoryInfo(Path.GetDirectoryName(file)).Name;
                 }
                 break;
         }
         if (document == null)
         {
             content = null;
             return false;
         }
         base.Name = document["mod"]["name"].InnerText;
         base.Description = document["mod"]["description"].InnerText;
         if (document["mod"]["copyright"] != null)
         {
             this.Copyright = document["mod"]["copyright"].InnerText.Replace("\x00a9", "").Replace("\x00ef\x00bf\x00bd", "");
         }
         if (document["mod"]["author"] != null)
         {
             this.DeveloperName = document["mod"]["author"].InnerText;
         }
         if (document["mod"]["url"] != null)
         {
             this.Website = document["mod"]["url"].InnerText;
         }
         this.Exclusive = this.ParseBool(document["mod"]["exclusive"].InnerText);
         this.UIOnly = new bool?(this.ParseBool(document["mod"]["ui_only"].InnerText));
         this.Guid = document["mod"]["uid"].InnerText;
         if (document["mod"]["requires"] != null)
         {
             this.mRequirements = document["mod"]["requires"].InnerText;
         }
         if (document["mod"]["requiresNames"] != null)
         {
             this.mRequirementNames = document["mod"]["requiresNames"].InnerText;
         }
         if (document["mod"]["conflicts"] != null)
         {
             this.mConflicts = document["mod"]["conflicts"].InnerText;
         }
         if (((document["mod"]["icon"] != null) && (document["mod"]["icon"].InnerText != null)) && (document["mod"]["icon"].InnerText.Length > 0))
         {
             string targetFile = document["mod"]["icon"].InnerText.Replace("/", @"\");
             if (extension == ".lua")
             {
                 if (targetFile.IndexOf(this.ModName) >= 0)
                 {
                     targetFile = targetFile.Remove(0, targetFile.IndexOf(this.ModName)).TrimStart(@"\".ToCharArray());
                 }
                 string str9 = Path.GetDirectoryName(base.LocalFilePath);
                 string str10 = targetFile;
                 string str11 = Path.Combine(str9, str10);
                 if (Path.GetExtension(str11) == ".dds")
                 {
                     this.mPreviewImage50 = ConvertDDS.ToBitmap(str11);
                 }
                 else
                 {
                     this.mPreviewImage50 = Image.FromFile(str11);
                 }
             }
             else
             {
                 tempFileName = Path.GetTempFileName();
                 Compression.Unzip(file, targetFile, tempFileName);
                 if (Path.GetExtension(targetFile) == ".dds")
                 {
                     this.mPreviewImage50 = ConvertDDS.ToBitmap(tempFileName);
                 }
                 else
                 {
                     this.mPreviewImage50 = Image.FromFile(tempFileName);
                 }
                 System.IO.File.Delete(tempFileName);
             }
             this.mHasPreview = true;
         }
         else
         {
             this.mPreviewImage50 = null;
         }
         content = this;
         return true;
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
         content = null;
         return false;
     }
 }
Пример #29
0
 public void MergeWithLocalVersion(IAdditionalContent localVersion)
 {
     Video video = localVersion as Video;
     base.LocalFilePath = localVersion.LocalFilePath;
     this.VideoFormat = video.VideoFormat;
 }
Пример #30
0
 public void MergeWithLocalVersion(IAdditionalContent localVersion)
 {
     if (base.ContentType.CurrentUserCanUpload && (localVersion is Mod))
     {
         Mod mod = localVersion as Mod;
         base.LocalFilePath = mod.LocalFilePath;
         this.ModName = mod.ModName;
         this.mPreviewImage50 = mod.PreviewImage50;
         this.Copyright = mod.Copyright;
         this.DeveloperName = mod.DeveloperName;
         this.Website = mod.Website;
         this.UIOnly = mod.UIOnly;
         this.Exclusive = mod.Exclusive;
         this.Guid = mod.Guid;
         this.mRequirements = mod.mRequirements;
         this.mConflicts = mod.mConflicts;
         if (base.ID < 1)
         {
             base.Name = mod.Name;
         }
     }
 }