Skip to content

Commit

Permalink
Code cleanup before release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad-00003 committed Jan 23, 2020
1 parent 51075bd commit c722e78
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 44 deletions.
14 changes: 6 additions & 8 deletions Classes/CustomSkin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@ namespace RustWorkshopUploader.Classes
internal class CustomSkin
{
public string Description;

[JsonIgnore] public string FilePath;

public ulong ItemId;
public string Title;

[JsonIgnore]
public string FilePath;

[JsonIgnore]
public string ItemIdString => ItemId.ToString();
[JsonIgnore] public string ItemIdString => ItemId.ToString();

[JsonIgnore]
public Manifest Manifest => Manifest.DefaultManifest.WithData(DateTime.UtcNow, SteamClient.SteamId);

[JsonIgnore]
public string ManifestText => JsonConvert.SerializeObject(Manifest, Formatting.Indented);
[JsonIgnore] public string ManifestText => JsonConvert.SerializeObject(Manifest, Formatting.Indented);

public override string ToString()
{
Expand All @@ -41,7 +39,7 @@ public void Save()
{
File.WriteAllText(FilePath, ToString());
}

public static CustomSkin FromFile(string path)
{
var text = File.ReadAllText(path);
Expand Down
6 changes: 3 additions & 3 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 23 additions & 24 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

namespace RustWorkshopUploader
{
public partial class frmMain : Form
public partial class FrmMain : Form
{
private CustomSkin _editing;
private string _folderPath;
private CustomSkin Editing;

public frmMain()
public FrmMain()
{
InitializeComponent();

Expand Down Expand Up @@ -85,8 +85,8 @@ private void btnSelectFolder_Click(object sender, EventArgs e)
File.Copy(openDialog.FileName, _folderPath + Path.DirectorySeparatorChar + "icon.png");

var dataPath = GetDataPath(_folderPath);
Editing = File.Exists(dataPath) ? CustomSkin.FromFile(dataPath) : new CustomSkin();
Editing.FilePath = dataPath;
_editing = File.Exists(dataPath) ? CustomSkin.FromFile(dataPath) : new CustomSkin();
_editing.FilePath = dataPath;
SetStatus(true);
UpdateTexts();
}
Expand Down Expand Up @@ -123,7 +123,7 @@ private void btnDo_Click(object sender, EventArgs e)
}

if (!File.Exists(ManifestPath))
File.WriteAllText(ManifestPath, Editing.ManifestText);
File.WriteAllText(ManifestPath, _editing.ManifestText);

PublishToSteam();
}
Expand All @@ -133,15 +133,14 @@ private async void PublishToSteam()
ProgressBar.Value = 0;
SetStatus(false);

var editor = default(Editor);
editor = Editing.ItemId == 0UL ? Editor.NewMicrotransactionFile : new Editor(Editing.ItemId);
var editor = _editing.ItemId == 0UL ? Editor.NewMicrotransactionFile : new Editor(_editing.ItemId);

ProgressBar.Value = 20;

editor = editor.ForAppId(Program.RustAppId).WithContent(_folderPath)
.WithPreviewFile(_folderPath + Path.DirectorySeparatorChar + "icon.png")
.WithTitle(Editing.Title).WithTag("Version3").WithTag("Skin")
.WithPublicVisibility().WithDescription(Editing.Description);
.WithTitle(_editing.Title).WithTag("Version3").WithTag("Skin")
.WithPublicVisibility().WithDescription(_editing.Description);

ProgressBar.Value = 40;
var publishResult = await editor.SubmitAsync();
Expand Down Expand Up @@ -169,15 +168,15 @@ private async void PublishToSteam()
}

ProgressBar.Value = 100;
Editing.Title = item.Value.Title;
Editing.Description = item.Value.Description;
Editing.ItemId = item.Value.Id;
Editing.Save();
_editing.Title = item.Value.Title;
_editing.Description = item.Value.Description;
_editing.ItemId = item.Value.Id;
_editing.Save();
UpdateTexts();
var result = MessageBox.Show(strings.Publish_OpenBrowser, strings.Message_Success, MessageBoxButtons.YesNo,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
if (result == DialogResult.Yes)
Process.Start("http://steamcommunity.com/sharedfiles/filedetails/?id=" + Editing.ItemIdString);
Process.Start("http://steamcommunity.com/sharedfiles/filedetails/?id=" + _editing.ItemIdString);
SetStatus(true);
}

Expand All @@ -195,9 +194,9 @@ private void button1_Click(object sender, EventArgs e)

private void btnDo_EnabledChanged(object sender, EventArgs e)
{
if (btnDo.Enabled && Editing != null)
if (btnDo.Enabled && _editing != null)
{
if (Editing.ItemId > 0)
if (_editing.ItemId > 0)
btnDo.Text = strings.BtnDo_Update;
else
btnDo.Text = strings.BtnDo_Upload;
Expand Down Expand Up @@ -237,12 +236,12 @@ private void quitToolStripMenuItem_Click(object sender, EventArgs e)
private void UpdateTexts()
{
_updating = true;
txtWorkshopId.Value = Editing.ItemId;
txtWorkshopName.Text = Editing.Title;
txtWorkshopDesc.Text = Editing.Description;
txtWorkshopId.Value = _editing.ItemId;
txtWorkshopName.Text = _editing.Title;
txtWorkshopDesc.Text = _editing.Description;
txtFolder.Text = _folderPath;

if (Editing.ItemId > 0)
if (_editing.ItemId > 0)
btnDo.Text = strings.BtnDo_Update;
else
btnDo.Text = strings.BtnDo_Upload;
Expand All @@ -263,19 +262,19 @@ private void txtWorkshopId_ValueChanged(object sender, EventArgs e)
}

if (!_updating)
Editing.ItemId = decimal.ToUInt64(txtWorkshopId.Value);
_editing.ItemId = decimal.ToUInt64(txtWorkshopId.Value);
}

private void txtWorkshopDesc_TextChanged(object sender, EventArgs e)
{
if (!_updating)
Editing.Description = txtWorkshopDesc.Text;
_editing.Description = txtWorkshopDesc.Text;
}

private void txtWorkshopName_TextChanged(object sender, EventArgs e)
{
if (!_updating)
Editing.Title = txtWorkshopName.Text;
_editing.Title = txtWorkshopName.Text;
}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ Vlad-00003 | OxideBro</value>
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>frmMain</value>
<value>FrmMain</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
Expand Down
4 changes: 1 addition & 3 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ internal static class Program
{
public static AppId RustAppId = 252490;
public static AppId SdkAppId = 391750;
private static frmMain Form;

/// <summary>
/// Главная точка входа для приложения.
Expand All @@ -29,7 +28,6 @@ private static void Main()
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Settings.Default.Culture.Name);
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(Settings.Default.Culture.Name);

Form = new frmMain();
DialogResult result;
do
{
Expand All @@ -50,7 +48,7 @@ private static void Main()

try
{
Application.Run(Form);
Application.Run(new FrmMain());
}
catch (Exception e)
{
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// Можно задать все значения или принять номер сборки и номер редакции по умолчанию.
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
5 changes: 2 additions & 3 deletions RustWorkshopUploader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
<Deterministic>false</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -24,7 +25,6 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
Expand Down Expand Up @@ -158,7 +158,6 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy $(SolutionDir)\Dependencies\steam_api64.dll $(TargetDir) /y
copy $(SolutionDir)\Dependencies\steam_appid.txt $(TargetDir) /y</PostBuildEvent>
<PostBuildEvent>copy $(SolutionDir)\Dependencies\steam_api64.dll $(TargetDir) /y</PostBuildEvent>
</PropertyGroup>
</Project>

0 comments on commit c722e78

Please sign in to comment.