...
 
Commits (2)
......@@ -59,15 +59,14 @@ namespace Glitterworld_Prime
}
floatMenuOptions = new List<FloatMenuOption>();
var tradeship = mapComponent.GetTradeShip();
var communicable = (ICommunicable) tradeship; // Cast trader as ICommunicable;
var tradeShip = mapComponent.GetTradeShip();
var communicable = (ICommunicable) tradeShip; // Cast trader as ICommunicable;
Action action = delegate
{
if (!Building_PrimeUplink.HasUplink(myPawn.Map))
{
Messages.Message("GWPNeedUplink".Translate(), this,
MessageTypeDefOf.RejectInput);
Messages.Message("GWPNeedUplink".Translate(), this, MessageTypeDefOf.RejectInput);
return;
}
......@@ -86,7 +85,12 @@ namespace Glitterworld_Prime
#if DEBUG
floatMenuOptions.Add(FloatMenuUtility.DecoratePrioritizedTask(
new FloatMenuOption("Dump Thing data", DumpThingData.DumpData, MenuOptionPriority.InitiateSocial, null,
new FloatMenuOption("Dump Thing data", DumpThingData.DumpData, MenuOptionPriority.Low, null,
null, 0f,
null, null), myPawn, this, "ReservedBy"));
floatMenuOptions.Add(FloatMenuUtility.DecoratePrioritizedTask(
new FloatMenuOption("Throw an error!", Utilities.SendTestException, MenuOptionPriority.High, null,
null, 0f,
null, null), myPawn, this, "ReservedBy"));
#endif
......@@ -94,6 +98,9 @@ namespace Glitterworld_Prime
if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
{
Action reactivateAction = delegate { Find.WindowStack.Add(new DialogPrimeReactivate()); };
{
Find.WindowStack.Add(new DialogPrimeReactivate());
}
floatMenuOptions.Add(FloatMenuUtility.DecoratePrioritizedTask(
new FloatMenuOption("Reactivate", reactivateAction, MenuOptionPriority.InitiateSocial, null, null, 0f,
......@@ -101,17 +108,17 @@ namespace Glitterworld_Prime
}
floatMenuOptions.Add(FloatMenuUtility.DecoratePrioritizedTask(
new FloatMenuOption(tradeship.TraderName, action, MenuOptionPriority.InitiateSocial, null, null, 0f,
new FloatMenuOption(tradeShip.TraderName, action, MenuOptionPriority.InitiateSocial, null, null, 0f,
null, null), myPawn, this, "ReservedBy"));
return floatMenuOptions;
}
public override void SpawnSetup(Map map, bool respawningAfterLoad)
{
base.SpawnSetup(map, respawningAfterLoad);
}
// public override void SpawnSetup(Map map, bool respawningAfterLoad)
// {
// base.SpawnSetup(map, respawningAfterLoad);
// }
#endregion
}
......
......@@ -24,7 +24,7 @@ namespace Glitterworld_Prime
private readonly GlitterWorld_MapComponent _mapComponent;
private readonly Pawn _player;
private readonly bool _shouldClose = false;
private bool _shouldClose = false;
private readonly ITrader _trader;
private Stopwatch _apiStopwatch;
......@@ -78,73 +78,84 @@ namespace Glitterworld_Prime
public override void DoWindowContents(Rect inRect)
{
GUI.color = Color.white;
if (_shouldClose)
try
{
Close();
return;
}
Text.Font = GameFont.Small;
GUI.color = Color.white;
switch (_status)
{
case DownloadStatus.Incomplete:
if (_previousStatus != DownloadStatus.Incomplete)
{
_previousStatus = DownloadStatus.Incomplete;
_downloadMessage = "GWPSendingThingList".Translate();
}
break;
case DownloadStatus.DoneSendingSupportedThings:
if (_previousStatus != DownloadStatus.DoneSendingSupportedThings)
{
// Now send the mods
_previousStatus = DownloadStatus.DoneSendingSupportedThings;
_downloadMessage = "GWPSendingModList".Translate();
_apiStopwatch = new Stopwatch();
LogWriter.WriteMessage("Starting request to server");
_apiStopwatch.Start();
GlitterWorldApi.PutModListAsync(_mapComponent, PutModListComplete_Callback);
}
break;
case DownloadStatus.DoneSendingMods:
if (_previousStatus != DownloadStatus.DoneSendingMods)
{
// Download Goods from Server
_previousStatus = DownloadStatus.DoneSendingMods;
_downloadMessage = "GWPGetMarketData".Translate();
_apiStopwatch = new Stopwatch();
LogWriter.WriteMessage("Starting request to server");
_apiStopwatch.Start();
GlitterWorldApi.GetServerGoodsAsync(_mapComponent, DownloadThingsComplete_Callback);
}
break;
case DownloadStatus.Complete:
// Mark that we've sent all the metadata, so not to do it again.
_mapComponent.HasSentThingListYet = true;
// We're done, close and go to the trade screen.
var dt = new DialogPrimeTrade(_player, _trader);
Find.WindowStack.Add(dt);
if (_shouldClose)
{
Close();
break;
return;
}
case DownloadStatus.Failed:
Messages.Message("GWPCantGetMarketData".Translate(), MessageTypeDefOf.NegativeEvent);
Close();
break;
Text.Font = GameFont.Small;
default:
throw new ArgumentOutOfRangeException();
switch (_status)
{
case DownloadStatus.Incomplete:
if (_previousStatus != DownloadStatus.Incomplete)
{
_previousStatus = DownloadStatus.Incomplete;
_downloadMessage = "GWPSendingThingList".Translate();
}
break;
case DownloadStatus.DoneSendingSupportedThings:
if (_previousStatus != DownloadStatus.DoneSendingSupportedThings)
{
// Now send the mods
_previousStatus = DownloadStatus.DoneSendingSupportedThings;
_downloadMessage = "GWPSendingModList".Translate();
_apiStopwatch = new Stopwatch();
LogWriter.WriteMessage("Starting request to server");
_apiStopwatch.Start();
GlitterWorldApi.PutModListAsync(_mapComponent, PutModListComplete_Callback);
}
break;
case DownloadStatus.DoneSendingMods:
if (_previousStatus != DownloadStatus.DoneSendingMods)
{
// Download Goods from Server
_previousStatus = DownloadStatus.DoneSendingMods;
_downloadMessage = "GWPGetMarketData".Translate();
_apiStopwatch = new Stopwatch();
LogWriter.WriteMessage("Starting request to server");
_apiStopwatch.Start();
GlitterWorldApi.GetServerGoodsAsync(_mapComponent, DownloadThingsComplete_Callback);
}
break;
case DownloadStatus.Complete:
// Mark that we've sent all the metadata, so not to do it again.
_mapComponent.HasSentThingListYet = true;
// We're done, close and go to the trade screen.
var dt = new DialogPrimeTrade(_player, _trader);
Find.WindowStack.Add(dt);
Close();
break;
case DownloadStatus.Failed:
Messages.Message("GWPCantGetMarketData".Translate(), MessageTypeDefOf.NegativeEvent);
Close();
break;
default:
throw new ArgumentOutOfRangeException();
}
}
catch (Exception exception)
{
Utilities.CaptureError(exception);
Close();
_shouldClose = true;
return;
}
var textWidth = Text.CalcSize(_downloadMessage);
......
......@@ -24,15 +24,9 @@ namespace Glitterworld_Prime
this.closeOnClickedOutside = true;
}
protected virtual int MaxCodeLength
{
get { return 8; }
}
protected virtual int MaxCodeLength => 8;
public override Vector2 InitialSize
{
get { return new Vector2(280f, 175f); }
}
public override Vector2 InitialSize => new Vector2(280f, 175f);
public override void DoWindowContents(Rect inRect)
{
......
This diff is collapsed.
......@@ -29,7 +29,7 @@ namespace Glitterworld_Prime
private static readonly float ClientVersion = 1.0f;
#if LOCALSERVER
private static readonly string BaseUrl = "http://127.0.0.1:5000";
private static readonly string BaseUrl = "https://prime-dev.thecodecache.net";
#else
private static readonly string BaseUrl = "https://prime.thecodecache.net";
#endif
......@@ -146,13 +146,11 @@ namespace Glitterworld_Prime
if (response.StatusCode == HttpStatusCode.OK)
{
if (response.Data.IsSet() && response.Data.IsSoon())
{
var d = new Dialog_MessageBox(
$"The server will be starting maintenance at {response.Data.StartTime().ToString(CultureInfo.CurrentCulture)} and will last {response.Data.DurationInHours()} hour(s).",
title: "GlitterWorldPrime");
Find.WindowStack.Add(d);
}
if (!response.Data.IsSet() || !response.Data.IsSoon()) return true;
var d = new Dialog_MessageBox(
$"The server will be starting maintenance at {response.Data.StartTime().ToString(CultureInfo.CurrentCulture)} and will last {response.Data.DurationInHours()} hour(s).",
title: "GlitterWorldPrime");
Find.WindowStack.Add(d);
return true;
}
......@@ -169,6 +167,15 @@ namespace Glitterworld_Prime
if (response.ResponseStatus == ResponseStatus.Completed) return;
try
{
throw new Exception($"Unexpected API response: {response.ResponseStatus}, {response.ErrorMessage}");
}
catch (Exception e)
{
Utilities.CaptureError(e);
}
LogWriter.DumpObjectToLog(response);
}
......@@ -522,4 +529,4 @@ namespace Glitterworld_Prime
#endregion
}
}
}
\ No newline at end of file
......@@ -13,10 +13,11 @@ namespace Glitterworld_Prime
}
private string _hasSpawned = "false";
internal bool HasSpawned
{
get { return _hasSpawned == "true"; }
set { _hasSpawned = value ? "true" : "false"; }
}
}
}
}
\ No newline at end of file
......@@ -12,6 +12,7 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......@@ -51,22 +52,26 @@
<HintPath>.\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>E:\Games\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>D:\Games\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>E:\Games\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<HintPath>D:\Games\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MiniSentrySDK, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\MiniSentrySDK\MiniSentrySDK\bin\Debug\MiniSentrySDK.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath>F:\Code\C#\RestSharp\RestSharp\bin\Debug\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>E:\Games\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>D:\Games\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
......@@ -99,7 +104,14 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="..\build.cake">
<Link>build.cake</Link>
</Content>
<Content Include="..\build.ps1">
<Link>build.ps1</Link>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
......
......@@ -20,6 +20,7 @@ using Steamworks;
using Verse;
using Verse.Steam;
using Version = System.Version;
using MiniSentrySDK;
namespace Glitterworld_Prime
{
......@@ -29,6 +30,10 @@ namespace Glitterworld_Prime
private static readonly Assembly Reference = typeof(Utilities).Assembly;
public static readonly Version Version = Reference.GetName().Version;
private static readonly MiniSentrySDK.Client sentry =
new MiniSentrySDK.Client("https://e428e7077f1c426893a3c27814014201@sentry.thecodecache.net/4");
private static string _steamId;
private static string _userId;
......@@ -39,6 +44,50 @@ namespace Glitterworld_Prime
#region Methods
internal static void CaptureError(Exception exception)
{
LogWriter.WriteMessage("Not forcing stacktrace");
var e = new SentryEvent(exception);
// Get User ID / Type
try
{
e.Tags.Add("UserID", GetUserId());
e.Tags.Add("UserType", GetUserType());
}
catch (Exception e1)
{
e.Breadcrumbs.Add(new Breadcrumb("Error") {message = "Unable to get User Data"});
}
// Get Colony ID if any
try
{
e.Tags.Add("ColonyID", GetMapComponent(Find.CurrentMap).ColonyId);
}
catch (Exception e1)
{
e.Breadcrumbs.Add(new Breadcrumb("Error") {message = "Unable to get Colony ID"});
}
sentry.Capture(e);
LogWriter.WriteErrorMessage("An error occurred and has been reported.");
}
internal static void SendTestException()
{
try
{
throw new Exception("Test Exception!");
}
catch (Exception e)
{
CaptureError(e);
}
}
internal static string GetUserType()
{
#if DISABLESTEAM
......@@ -423,7 +472,8 @@ namespace Glitterworld_Prime
try
{
if (thing.tradeability != Tradeability.None && thing.GetStatValueAbstract(StatDefOf.MarketValue) > 0.0 &&
if (thing.tradeability != Tradeability.None &&
thing.GetStatValueAbstract(StatDefOf.MarketValue) > 0.0 &&
(thing.category == ThingCategory.Item || thing.category == ThingCategory.Building) &&
(thing.category != ThingCategory.Building || thing.Minifiable))
thingsToRequestFromMarket.AddRange(ComputeThingDef(thing, stuffCategories));
......@@ -460,4 +510,4 @@ namespace Glitterworld_Prime
#endregion
}
}
}
\ No newline at end of file
......@@ -15,7 +15,7 @@ var mod_base_path = "./mod_package";
var mod_path = $"./{mod_base_path}/{modname} [{version}]";
var git_hash = "";
var asm_version = "";
var steam_folder = @"E:\Games\Steam\steamapps\common\RimWorld\Mods";
var steam_folder = @"D:\Games\Steam\steamapps\common\RimWorld\Mods";
///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
......@@ -44,12 +44,21 @@ Task("CopyDataFolders")
CopyDirectory("./Defs", mod_path+"/Defs");
CopyDirectory("./Languages", mod_path+"/Languages");
CopyDirectory("./Textures", mod_path+"/Textures");
CreateDirectory(mod_path+"/Assemblies");
DeleteDirectory(mod_path+"/Assemblies", new DeleteDirectorySettings {
Recursive = true,
Force = true
});
CreateDirectory(mod_path+"/Assemblies");
});
Task("CopyDLLs")
.IsDependentOn("Compile")
.Does(() => {
CopyFiles("./Assemblies/*.dll", mod_path+"/Assemblies");
CopyFile("./Assemblies/0Harmony.dll", mod_path+"/Assemblies/0Harmony.dll");
CopyFile("./Assemblies/RestSharp.dll", mod_path+"/Assemblies/1RestSharp.dll");
CopyFile("./Assemblies/MiniSentrySDK.dll", mod_path+"/Assemblies/2MiniSentrySDK.dll");
CopyFile("./Assemblies/Glitterworld Prime.dll", mod_path+"/Assemblies/3GlitterWorldPrime.dll");
});
Task("GetGitVersion")
......