Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
allista committed Jul 22, 2020
2 parents 39c4358 + 10f580f commit 893ae74
Show file tree
Hide file tree
Showing 82 changed files with 19,993 additions and 22,779 deletions.
3 changes: 2 additions & 1 deletion AT_Utils.csproj
Expand Up @@ -123,6 +123,7 @@
<Compile Include="Extensions\VesselExtensions.cs" />
<Compile Include="Interfaces\IAnimator.cs" />
<Compile Include="Math\PhysicsUtils.cs" />
<Compile Include="MeshUtils\Utils.cs" />
<Compile Include="Orbital\OrbitalUtils.cs" />
<Compile Include="OrderedDict.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down Expand Up @@ -159,7 +160,6 @@
<Compile Include="GUI\TooltipManager.cs" />
<Compile Include="GUI\Dialogs\SimpleDialog.cs" />
<Compile Include="GUI\Dialogs\SimpleTextEntry.cs" />
<Compile Include="GUI\Dialogs\SimpleWarning.cs" />
<Compile Include="GUI\Windows\CrewTransferWindow.cs" />
<Compile Include="GUI\Windows\ResourceTransferWindow.cs" />
<Compile Include="GUI\Elements\FloatField.cs" />
Expand Down Expand Up @@ -207,6 +207,7 @@
<Compile Include="GUI\ToolbarWrapper.cs" />
<Compile Include="GUI\AppToolbar.cs" />
<Compile Include="Debugging\WorldSpaceTrace.cs" />
<Compile Include="UI\DialogController.cs" />
<Compile Include="UI\UIBundle.cs" />
<Compile Include="UI\UIWindowBase.cs" />
<Compile Include="UI\ColorListWindow.cs" />
Expand Down
12 changes: 5 additions & 7 deletions Addons/ShipConstructLoader.cs
Expand Up @@ -17,7 +17,6 @@ public class ShipConstructLoader : MonoBehaviour
PartSelector part_selector;
SubassemblySelector subassembly_selector;
CraftBrowserDialog vessel_selector;
public EditorFacility Facility { get; private set; }
public Action<ShipConstruct> process_construct = delegate { };

public void Awake()
Expand Down Expand Up @@ -45,19 +44,18 @@ void part_selected(AvailablePart part_info)
process_loaded_construct(construct);
}

void vessel_selected(string filename, CraftBrowserDialog.LoadType t)
void vessel_selected(ConfigNode node, CraftBrowserDialog.LoadType t)
{
vessel_selector = null;
//load vessel config
var node = ConfigNode.Load(filename);
if(node == null) return;
var construct = new ShipConstruct();
if(!construct.LoadShip(node))
{
Utils.Log("Unable to load ShipConstruct from {}. " +
var shipName = node.GetValue("ship");
Utils.Error($"Unable to load ShipConstruct '{shipName}'. " +
"This usually means that some parts are missing " +
"or some modules failed to initialize.", filename);
Utils.Message("Unable to load {0}", filename);
"or some modules failed to initialize.");
Utils.Message("Unable to load {0}", shipName);
return;
}
//check if it's possible to launch such vessel
Expand Down
2 changes: 1 addition & 1 deletion AnimatedConverters
Submodule AnimatedConverters updated 0 files
2 changes: 1 addition & 1 deletion AnisotropicPartResizer
59 changes: 57 additions & 2 deletions ChangeLog.md
@@ -1,6 +1,61 @@
#AT Utils ChangeLog
# AT Utils ChangeLog

* **v1.9.4.1**

* **v1.9.5**
* Fixed and refactored `HSVPicker`
* Fixed `AddonWindowBase.Toggle/ShowWithButton` logic
* GUIWindowBase.Show only executes when the state is changing
* UI
* Added ButtonIcon prefab with an Image instead of Text as content
* **Replaced the old SimpleDialog with DialogFactory.Danger**
* **UIBundles are singletons and load synchronously on creation**
* `UIWindowBase`
* does not try to calculate central position of the
new window; instead, relying on the prefab anchor+pivot.
* added protected `onClose` hook
* automatically saving and loading config options
* *added input locking on mouse enter/exit, close, destroy*
* added optional bool `condition` argument to `Toggle` method
* `FloatController`
* added `onDoneEditing FloatEvent` that is called on click of the
_optional_ `doneButton`
* added `suffix` text
* increment/decrement buttons display formatted step
* added `SetStep` and `SetDecimals` methods
* fixed value clamping in case of no decimals
* Added `Dropdown.SetOptionsSafe` extension
* Added `DialogFactory:SimpleDialog` uGUI framework to replace the old
dialogs
* Added InfoPane prefab
* Added ScrollView prefab
* Reimplemented from scratch the Dropdown prefab
* Updated Button, LRChooser and Text prefabs
* Made `Utils` class static
* Added `namesToOptions` method for Dropdown options creation
* `DebugWindow`: using `ScreenBoundRect` rather than `DragableRect` as
ancestor class
* Added `TooltipTrigger.SetText` method
* Added `BaseColorizer.SetColor` method that accepts
either `name` or `ColorSetting`
* `Colors`
* added `ColorSetting.ToString`
* operator `ColorSetting=>Color` always returns a `Color`
* `FractionGradient` is initialized in static constructor
* removed unused `Instance` prop+field
* Added all prefabs to CommonUI scene
* `FormatUtils`
* `formatMass` calls `formatBigValue` for mass > 1t
* `formatBigValue` calls `formatSmallValue` for values smaller
than 1k
* added `ParseCamelCase` method
* Added `MeshUtils` part of `Utils` class with utility methods for creation
of `Meshes` and corresponding `GameObjects`.
* `PluginState`: fixed possible NRE in `get_config`
* Fixed `ShipConstructLoader`: using `CraftBrowserDialog.Spawn` variant
with `onConfigNodeSelected` callback
* Fixed `ATGroundAnchor.Update` in Editor

* v1.9.4.1
* Compiled against KSP-1.10

* v1.9.4
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Globals.cs
Expand Up @@ -24,7 +24,7 @@ public class AT_UtilsGlobals : PluginGlobals<AT_UtilsGlobals>
public List<string> MeshesToSkipList = new List<string>();
public List<string> BadPartsList = new List<string>();

public UIBundle AssetBundle = new UIBundle("000_AT_Utils/at_utils_ui.ksp");
public UIBundle AssetBundle = UIBundle.Create("000_AT_Utils/at_utils_ui.ksp");

public override void Save(ConfigNode node)
{
Expand Down
25 changes: 12 additions & 13 deletions Configuration/PluginState.cs
Expand Up @@ -31,26 +31,25 @@ public interface ICachedState

public static class PluginState
{
static Dictionary<string, PluginConfiguration> configs = new Dictionary<string, PluginConfiguration>();
private static readonly Dictionary<string, PluginConfiguration> configs = new Dictionary<string, PluginConfiguration>();

static PluginConfiguration get_config(Type object_type)
private static PluginConfiguration get_config(Type object_type)
{
PluginConfiguration cfg;
var config_path = AssemblyLoader.GetPathByType(object_type);
if(!configs.TryGetValue(config_path, out cfg))
{
var create_for_type = typeof(PluginConfiguration).GetMethod("CreateForType");
create_for_type = create_for_type.MakeGenericMethod(new[] { object_type });
cfg = create_for_type.Invoke(null, new object[] { null }) as PluginConfiguration;
configs[config_path] = cfg;
}
if(configs.TryGetValue(config_path, out var cfg))
return cfg;
var create_for_type = typeof(PluginConfiguration).GetMethod("CreateForType");
if(create_for_type == null)
return null;
create_for_type = create_for_type.MakeGenericMethod(object_type);
cfg = create_for_type.Invoke(null, new object[] { null }) as PluginConfiguration;
configs[config_path] = cfg;
return cfg;
}

static readonly MethodInfo get_value = typeof(PluginConfiguration)
private static readonly MethodInfo get_value = typeof(PluginConfiguration)
.GetMethods(BindingFlags.Public | BindingFlags.Instance)
.Where(mi => mi.Name == "GetValue" && mi.GetParameters().Length == 2)
.SingleOrDefault();
.SingleOrDefault(mi => mi.Name == "GetValue" && mi.GetParameters().Length == 2);

public static void LoadState(this object obj, string basename = "")
{
Expand Down
1 change: 1 addition & 0 deletions Debugging/DebugWindowController.cs
Expand Up @@ -25,6 +25,7 @@ public void SetContent(string content, MonoBehaviour host)

protected override void init_controller()
{
base.init_controller();
Controller.title.text = title;
Controller.closeButton.onClick.AddListener(Close);
Controller.SetContent(contentCache);
Expand Down
34 changes: 0 additions & 34 deletions GUI/Dialogs/SimpleWarning.cs

This file was deleted.

31 changes: 11 additions & 20 deletions GUI/WindowsFramework/AddonWindowBase.cs
Expand Up @@ -18,39 +18,30 @@ abstract public class AddonWindowBase<T> : GUIWindowBase where T : AddonWindowBa
public static T Instance { get; private set; }

public static bool InstanceEnabled
{ get { return Instance && Instance.window_enabled; } }
{ get { return Instance != null && Instance.window_enabled; } }

public static void ShowInstance(bool show)
{ if(Instance) Instance.Show(show); }
{ if(Instance != null) Instance.Show(show); }

public static void ToggleInstance()
{ if(Instance) Instance.Show(!Instance.window_enabled); }
{ if(Instance != null) Instance.Show(!Instance.window_enabled); }

public static void ShowWithButton(bool show, ApplicationLauncherButton button)
{
if(Instance == null) return;
if(button == null) ShowInstance(show);
Instance.Show(show);
if(button == null)
return;
if(Instance.window_enabled)
button.SetTrue(false);
else
{
if(show)
{
if(!Instance.window_enabled)
Instance.Show(true);
button.SetTrue(false);
}
else
{
if(Instance.window_enabled)
Instance.Show(false);
button.SetFalse(false);
}
}
button.SetFalse(false);
}

public static void ToggleWithButton(ApplicationLauncherButton button)
{
if(button == null) ToggleInstance();
else if(Instance) ShowWithButton(!Instance.window_enabled, button);
if(Instance != null)
ShowWithButton(!Instance.window_enabled, button);
}

readonly ActionDamper save_timer = new ActionDamper(10);
Expand Down
2 changes: 2 additions & 0 deletions GUI/WindowsFramework/GUIWindowBase.cs
Expand Up @@ -62,6 +62,8 @@ void init_subwindows()

public virtual void Show(bool show)
{
if(window_enabled == show)
return;
window_enabled = show;
if(!show) UnlockControls();
update_content();
Expand Down
4 changes: 2 additions & 2 deletions GameData/000_AT_Utils/000_AT_Utils.version
Expand Up @@ -7,8 +7,8 @@
{
"MAJOR":1,
"MINOR":9,
"PATCH":4,
"BUILD":1
"PATCH":5,
"BUILD":0
},
"KSP_VERSION_MIN":
{
Expand Down
1 change: 1 addition & 0 deletions GameData/000_AT_Utils/cc_ui.bundle
6 changes: 2 additions & 4 deletions Math/ConvexHull3D.cs
Expand Up @@ -435,13 +435,11 @@ public Mesh MakeMesh()
triangles[vi+1] = lookup[f.v1];
triangles[vi+2] = lookup[f.v2];
}
var mesh = new Mesh();
mesh.vertices = Points.ToArray();
mesh.triangles = triangles;
var mesh = new Mesh { vertices = Points.ToArray(), triangles = triangles };
mesh.RecalculateNormals();
mesh.RecalculateTangents();
mesh.RecalculateBounds();
return mesh;
}
}
}
}

0 comments on commit 893ae74

Please sign in to comment.