Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4c78a00b0706
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7632cc3dfbee
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Feb 4, 2018

  1. Copy the full SHA
    3b2857d View commit details
  2. Rect is a struct.

    pleroy committed Feb 4, 2018
    Copy the full SHA
    405ae60 View commit details
  3. Merge pull request #1713 from pleroy/1677

    Make sure that all windows stay on screen (a bit)
    pleroy authored Feb 4, 2018
    Copy the full SHA
    7632cc3 View commit details
Showing with 19 additions and 12 deletions.
  1. +1 −12 ksp_plugin_adapter/flight_planner.cs
  2. +2 −0 ksp_plugin_adapter/ksp_plugin_adapter.cs
  3. +1 −0 ksp_plugin_adapter/reference_frame_selector.cs
  4. +15 −0 ksp_plugin_adapter/window_renderer.cs
13 changes: 1 addition & 12 deletions ksp_plugin_adapter/flight_planner.cs
Original file line number Diff line number Diff line change
@@ -39,18 +39,7 @@ protected override void RenderWindow() {
func : RenderPlanner,
text : "Flight plan",
options : UnityEngine.GUILayout.MinWidth(500));
const float min_width_on_screen = 50;
const float min_height_on_screen = 50;
window_rectangle_.x =
UnityEngine.Mathf.Clamp(
window_rectangle_.x,
-window_rectangle_.width + min_width_on_screen,
UnityEngine.Screen.width - min_width_on_screen);
window_rectangle_.y =
UnityEngine.Mathf.Clamp(
window_rectangle_.y,
-window_rectangle_.height + min_height_on_screen,
UnityEngine.Screen.height - min_height_on_screen);
WindowUtilities.EnsureOnScreen(ref window_rectangle_);
window_rectangle_.InputLock(this);
} else {
WindowUtilities.ClearLock(this);
2 changes: 2 additions & 0 deletions ksp_plugin_adapter/ksp_plugin_adapter.cs
Original file line number Diff line number Diff line change
@@ -682,6 +682,7 @@ private void OnGUI() {
},
text : "Principia",
options : UnityEngine.GUILayout.MinWidth(500));
WindowUtilities.EnsureOnScreen(ref apocalypse_window_rectangle_);
apocalypse_window_x_ = (int)apocalypse_window_rectangle_.xMin;
apocalypse_window_y_ = (int)apocalypse_window_rectangle_.yMin;
}
@@ -722,6 +723,7 @@ private void OnGUI() {
func : DrawMainWindow,
text : "Principia",
options : UnityEngine.GUILayout.MinWidth(500));
WindowUtilities.EnsureOnScreen(ref main_window_rectangle_);
main_window_x_ = (int)main_window_rectangle_.xMin;
main_window_y_ = (int)main_window_rectangle_.yMin;
main_window_rectangle_.InputLock(this);
1 change: 1 addition & 0 deletions ksp_plugin_adapter/reference_frame_selector.cs
Original file line number Diff line number Diff line change
@@ -282,6 +282,7 @@ protected override void RenderWindow() {
func : RenderSelector,
text : name_ + " selection (" + Name() +
")");
WindowUtilities.EnsureOnScreen(ref window_rectangle_);
window_rectangle_.InputLock(this);
} else {
WindowUtilities.ClearLock(this);
15 changes: 15 additions & 0 deletions ksp_plugin_adapter/window_renderer.cs
Original file line number Diff line number Diff line change
@@ -15,6 +15,21 @@ public static bool ContainsMouse(this UnityEngine.Rect window_rectangle) {
return window_rectangle.Contains(mouse);
}

public static void EnsureOnScreen(ref UnityEngine.Rect window_rectangle) {
const float min_width_on_screen = 50;
const float min_height_on_screen = 50;
window_rectangle.x =
UnityEngine.Mathf.Clamp(
window_rectangle.x,
-window_rectangle.width + min_width_on_screen,
UnityEngine.Screen.width - min_width_on_screen);
window_rectangle.y =
UnityEngine.Mathf.Clamp(
window_rectangle.y,
-window_rectangle.height + min_height_on_screen,
UnityEngine.Screen.height - min_height_on_screen);
}

const ControlTypes PrincipiaLock = ControlTypes.ALLBUTCAMERAS &
~ControlTypes.ALL_SHIP_CONTROLS;