Skip to content
This repository has been archived by the owner on Mar 2, 2024. It is now read-only.

Commit

Permalink
Prepare for initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
Aceba1 committed Jun 24, 2019
1 parent d2406bb commit ff3740f
Show file tree
Hide file tree
Showing 25 changed files with 1,090 additions and 43 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,7 @@ ASALocalRun/

# Local History for Visual Studio
.localhistory/
Build/TTMM/*.xml
Build/TTMM/config.json
Build/TTMM/*.config
*.json
Binary file added Build/TTMM/Mono.Posix.dll
Binary file not shown.
Binary file added Build/TTMM/Newtonsoft.Json.dll
Binary file not shown.
Binary file added Build/TTMM/TerraTechModManager-GTK.exe
Binary file not shown.
Binary file added Build/TTMM/atk-sharp.dll
Binary file not shown.
Binary file added Build/TTMM/pango-sharp.dll
Binary file not shown.
Binary file added TTMM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 4 additions & 5 deletions TerraTechModManager-GTK/ConfigHandler.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Newtonsoft.Json;

namespace TerraTechModManagerGTK
Expand All @@ -12,28 +11,28 @@ public static class ConfigHandler

public static void ResetConfig()
{
string path = AppDomain.CurrentDomain.BaseDirectory + "config.json";
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"config.json");
File.Delete(path);
}

public static void LoadConfig()
{
string path = AppDomain.CurrentDomain.BaseDirectory + "config.json";
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"config.json");
if (File.Exists(path))
try
{
config = JsonConvert.DeserializeObject<Dictionary<string, object>>(File.ReadAllText(path));
}
catch (Exception E)
{
Console.WriteLine("There was an ERROR READING THE FRICKING CONFIG FILE WHAT THE HECK");
Console.WriteLine("There was an error reading the config file!");
Console.WriteLine(E);
//NewMain.StartMessage += "There is a problem with the config.json file\n";
}
}
public static void SaveConfig()
{
string path = AppDomain.CurrentDomain.BaseDirectory + "config.json";
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"config.json");
File.WriteAllText(path, JsonConvert.SerializeObject(config));
}

Expand Down
92 changes: 92 additions & 0 deletions TerraTechModManager-GTK/DialogDescription.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using System;
using System.Diagnostics;
namespace TerraTechModManagerGTK
{
public partial class DialogDescription : Gtk.Dialog
{
public int Return = 0;

public string Site, Folder, CloudName;

public enum DescType { NoButtons, LocalModInfo, ServerModInfo, UpdateInfo }

public DialogDescription()
{
this.Build();
entry3.Visible = false;
}

public void Set(DescType WindowType, string Title, string Message, string WindowTitle = null)
{
LocalModInfoArea.Visible = false;
ServerModInfoArea.Visible = false;
UpdateInfoArea.Visible = false;
switch (WindowType)
{
case DescType.LocalModInfo: LocalModInfoArea.Visible = true; break;
case DescType.ServerModInfo: ServerModInfoArea.Visible = true; break;
case DescType.UpdateInfo: UpdateInfoArea.Visible = true; break;
}
labelTitle.Markup = "<b>" + Title + "</b>";
labelTextView.Text = "";
labelTextView.Markup = MarkdownConvert.ToPangoString(Message);
if (string.IsNullOrWhiteSpace(labelTextView.Text))
{
labelTextView.Text = Message;
}
if (string.IsNullOrWhiteSpace(WindowTitle))
{
this.Title = "TTMM - " + Title;
}
else
{
this.Title = "TTMM - " + WindowTitle;
}
}

protected void OpenFolderEvent(object sender, EventArgs e)
{
if (Tools.IsLinux)
{
Process.Start("xdg-open", Folder);
}
else
{
Process.Start(Folder);
}
}

protected void OpenSiteEvent(object sender, EventArgs e)
{
Process.Start(Site);
}

protected void InstallModEvent(object sender, EventArgs e)
{
}

protected void InstallUpdateEvent(object sender, EventArgs e)
{
this.Destroy();
UpdateProgram.UpdateAccepted();
}

protected void OnCloseEvent(object sender, EventArgs e)
{
this.Destroy();
}

protected void OnChanged(object sender, EventArgs e)
{
labelTextView.Markup = MarkdownConvert.ToPangoString(entry3.Text.Replace("\\n","\n"));
}

protected void OnTextview1InsertAtCursor(object o, Gtk.InsertAtCursorArgs args)
{
}

protected void OnTextview1PopulatePopup(object o, Gtk.PopulatePopupArgs args)
{
}
}
}
21 changes: 12 additions & 9 deletions TerraTechModManager-GTK/GithubDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Downloader
{
public static class GetUpdateInfo
{
public static GithubReleaseItem GetReleases(string CloudName)
public static GithubReleaseItem GetRelease(string CloudName)
{
return WebClientHandler.DeserializeApiCall<GithubReleaseItem>("https://api.github.com/repos/" + CloudName + "/releases/latest");
}
Expand Down Expand Up @@ -190,14 +190,14 @@ private static List<string> RecursiveDownload(IEnumerable<GithubItem> entries, s
return result;
}

private class GithubItem
public class GithubItem
{
public string name;
public string url;
public string download_url;
public string path;
public long size;
public string type;
public string name = null;
public string url = null;
public string download_url = null;
public string path = null;
public long size = 0;
public string type = null;
}
}

Expand Down Expand Up @@ -306,7 +306,10 @@ private static void Download_Internal(object Params)
serverMod.GetDescription();
System.IO.File.WriteAllText(System.IO.Path.Combine(Folder, "ttmm.json"), JsonConvert.SerializeObject(serverMod, Formatting.Indented));
ModInfoTools.GetLocalMod_Internal(Folder, false, true);
MainWindow.ModListStoreGithub.SetValue(serverMod.TreeIter, (int)TreeColumnInfo.State, true);
Tools.invoke.Add(delegate
{
MainWindow.ModListStoreGithub.SetValue(serverMod.TreeIter, (int)TreeColumnInfo.State, true);
});
MainWindow.inst.Log("Done!");
}
catch (Exception e)
Expand Down
45 changes: 37 additions & 8 deletions TerraTechModManager-GTK/MainWindow.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.Net;
using System.Threading.Tasks;
using Gtk;
using TerraTechModManagerGTK;
using TerraTechModManagerGTK.Downloader;
Expand All @@ -15,6 +16,7 @@ public partial class MainWindow : Gtk.Window
public static MainWindow inst;

private DialogGithubToken _dialogGithubToken;
private DialogDescription _dialogDescription;

public MainWindow() : base(Gtk.WindowType.Toplevel)
{
Expand All @@ -23,13 +25,21 @@ public MainWindow() : base(Gtk.WindowType.Toplevel)

Build();
SetupTree();

SkipStartAction.Active = ConfigHandler.CacheValue("skipstart", false);
inst = this;
ServicePointManager.SecurityProtocol = (System.Net.SecurityProtocolType)0x0FF0; //System.Net.SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

Tasks.AddToTaskQueue(new System.Threading.Tasks.Task(InstallModLoader));
Tasks.AddToTaskQueue(new System.Threading.Tasks.Task(GetLocalMods));
Tasks.AddToTaskQueue(new System.Threading.Tasks.Task(GetGithubMods));
Tasks.AddToTaskQueue(new Task(SleepForTime));
Tasks.AddToTaskQueue(new Task(GetLocalMods));
Tasks.AddToTaskQueue(new Task(UpdateProgram.V_LookForProgramUpdate));
Tasks.AddToTaskQueue(new Task(InstallModLoader));
Tasks.AddToTaskQueue(new Task(GetGithubMods));
}

private void SleepForTime()
{
System.Threading.Thread.Sleep(500);
}

private void InstallModLoader()
Expand Down Expand Up @@ -144,24 +154,27 @@ TreeView CurrentTreeView
}
}

protected void OnDeleteEvent(object sender, DeleteEventArgs a)
public void CloseAll()
{
ConfigHandler.SaveConfig();
Tasks.ClearTasks();
DownloadFolder.KillDownload = 1;
Application.Quit();
Tools.AllowedToRun = false;

//Kill running QModManager processes, if there are any
foreach (var k in System.Diagnostics.Process.GetProcessesByName("QModManager")) k.Kill();
}

protected void OnDeleteEvent(object sender, DeleteEventArgs a)
{
CloseAll();
a.RetVal = true;
}



public void Log(string CurrentState)
{
labelCurrentTask.Text = CurrentState;
Tools.invoke.Add(delegate { labelCurrentTask.Text = CurrentState; });
Console.WriteLine(CurrentState);
}

Expand Down Expand Up @@ -441,12 +454,28 @@ protected void UserUpdatePatch(object sender, EventArgs e)
ConfigHandler.SetValue("lastpatchversion", Tools.Version_Number);
}



protected void UserUpdateTTMM(object sender, EventArgs e)
{
Log("That button doesn't do anything yet, sorry");
if (!UpdateProgram.LookForProgramUpdate())
Log("No program update is available");
}

protected void ModDescPreviewer(object sender, EventArgs e)
{
if (_dialogDescription == null) _dialogDescription = new DialogDescription();
else _dialogDescription.ActivateFocus();
_dialogDescription.Destroyed += Description_Clear;
_dialogDescription.Show();
var modInfo = GetModInfoFromSelected();
_dialogDescription.Site = modInfo.Site;
_dialogDescription.Folder = modInfo.FilePath;
_dialogDescription.Set(TabPagerMods.CurrentPage != 0? DialogDescription.DescType.ServerModInfo : DialogDescription.DescType.LocalModInfo, modInfo.FancyName(), modInfo.GetDescription());
}

private void Description_Clear(object sender, EventArgs e)
{
_dialogDescription = null;
}
}
Loading

0 comments on commit ff3740f

Please sign in to comment.