Skip to content

Commit

Permalink
Merge branch 'default_terminal_size' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunbaratu committed Jul 27, 2019
2 parents 6357269 + 1ac78ee commit dd28b61
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 5 deletions.
36 changes: 36 additions & 0 deletions doc/source/structures/misc/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ Configuration of kOS
- :struct:`Scalar`
- 12 (from range [6 .. 20], integers only)
- Default font size in pixel height for new instances of the in-game terminal
* - :attr:`DEFAULTWIDTH`
- :struct:`Scalar`
- 50 (from range [15 .. 255], integers only)
- Default width (in characters, not pixels) for new instances of the in-game terminal.
* - :attr:`DEFAULTHEIGHT`
- :struct:`Scalar`
- 36 (from range [3 .. 160], integers only)
- Default height (in characters, not pixels) for new instances of the in-game terminal.
* - :attr:`DEBUGEACHOPCODE`
- :struct:`Boolean`
- false
Expand Down Expand Up @@ -312,6 +320,34 @@ Configuration of kOS
and no greater than 30 (very big). It will be rounded to the
nearest integer when setting the value.

.. attribute:: Config:DEFAULTWIDTH

:access: Get/Set
:type: :struct:`Scalar` integer-only. range = [15,255]

Configures the ``TerminalDefaultWidth`` setting.

This is the default starting width (in number of character cells,
not number of pixels) for all newly created kOS in-game terminals.
This is just the default for new terminals. Individual terminals
can have different settings, either by setting the value
:attr:`Terminal:WIDTH` in a script, or by manually dragging the
resize corner of the terminal with the mouse.

.. attribute:: Config:DEFAULTHEIGHT

:access: Get/Set
:type: :struct:`Scalar` integer-only. range = [3,160]

Configures the ``TerminalDefaultHeight`` setting.

This is the default starting height (in number of character cells,
not number of pixels) for all newly created kOS in-game terminals.
This is just the default for new terminals. Individual terminals
can have different settings, either by setting the value
:attr:`Terminal:HEIGHT` in a script, or by manually dragging the
resize corner of the terminal with the mouse.

.. attribute:: Config:DEBUGEACHOPCODE

:access: Get/Set
Expand Down
24 changes: 24 additions & 0 deletions src/kOS.Safe.Test/Execution/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,30 @@ public string TerminalFontName
}
}

public int TerminalDefaultWidth
{
get
{
return 0;
}

set
{
}
}

public int TerminalDefaultHeight
{
get
{
return 0;
}

set
{
}
}

public DateTime TimeStamp
{
get
Expand Down
2 changes: 2 additions & 0 deletions src/kOS.Safe/Encapsulation/IConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public interface IConfig: ISuffixed
int TerminalFontDefaultSize {get; set; }
string TerminalFontName {get; set; }
double TerminalBrightness {get; set; }
int TerminalDefaultWidth { get; set; }
int TerminalDefaultHeight { get; set; }


/// <summary>
Expand Down
17 changes: 13 additions & 4 deletions src/kOS/Screen/KOSToolbarWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class KOSToolbarWindow : MonoBehaviour
private static GUIStyle vesselNameStyle;
private static GUIStyle partNameStyle;
private static GUIStyle tooltipLabelStyle;
private static GUIStyle smallLabelStyle;
private static GUIStyle boxDisabledStyle;
private static GUIStyle boxOffStyle;
private static GUIStyle boxOnStyle;
Expand Down Expand Up @@ -447,9 +448,9 @@ public void DrawWindow(int windowID)

CountBeginVertical("", 150);
GUILayout.Label("CONFIG VALUES", headingLabelStyle);
GUILayout.Label("To access other settings, see the kOS section in KSP's difficulty settings.", tooltipLabelStyle);
GUILayout.Label("To access other settings, see the kOS section in KSP's difficulty settings.", smallLabelStyle);
GUILayout.Label("Global VALUES", headingLabelStyle);
GUILayout.Label("Changes to these settings are saved and globally affect all saved games.", tooltipLabelStyle);
GUILayout.Label("Changes to these settings are saved and globally affect all saved games.", smallLabelStyle);

int whichInt = 0; // increments only when an integer field is encountered in the config keys, else stays put.

Expand Down Expand Up @@ -619,7 +620,7 @@ private int DrawConfigIntField(int keyVal, int whichInt)
string fieldValue = (backInt == 0) ? "" : backInt.ToString(); // this lets the user temporarily delete the whole value instead of having it become a zero.

GUI.SetNextControlName(fieldName);
fieldValue = GUILayout.TextField(fieldValue, 6, panelSkin.textField, GUILayout.MinWidth(60));
fieldValue = GUILayout.TextField(fieldValue, 4, panelSkin.textField, GUILayout.MinWidth(60));

fieldValue = fieldValue.Trim(' ');
int newInt = -99; // Nonzero value to act as a flag to detect if the following line got triggered:
Expand Down Expand Up @@ -913,7 +914,15 @@ private static GUISkin BuildPanelSkin()
{
fontSize = 11,
padding = new RectOffset(0, 2, 0, 2),
normal = { textColor = Color.white }
normal = { textColor = Color.white },
wordWrap = false
};
smallLabelStyle = new GUIStyle(theSkin.label)
{
fontSize = 11,
padding = new RectOffset(0, 2, 0, 2),
normal = { textColor = Color.white },
wordWrap = true
};
partNameStyle = new GUIStyle(theSkin.box)
{
Expand Down
1 change: 1 addition & 0 deletions src/kOS/Screen/TermWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,7 @@ internal void AttachTo(SharedObjects sharedObj)
shared.Screen.Brightness = SafeHouse.Config.TerminalBrightness;
formerCharPixelWidth = shared.Screen.CharacterPixelWidth;
formerCharPixelHeight = shared.Screen.CharacterPixelHeight;
shared.Screen.SetSize(SafeHouse.Config.TerminalDefaultHeight, SafeHouse.Config.TerminalDefaultWidth);

NotifyOfScreenResize(shared.Screen);
shared.Screen.AddResizeNotifier(NotifyOfScreenResize);
Expand Down
10 changes: 9 additions & 1 deletion src/kOS/Suffixed/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class Config : Structure, IConfig
public string TelnetIPAddrString { get { return GetPropValue<string>(PropId.TelnetIPAddrString); } set { SetPropValue(PropId.TelnetIPAddrString, value); } }
public int TerminalFontDefaultSize {get { return GetPropValue<int>(PropId.TerminalFontDefaultSize); } set { SetPropValue(PropId.TerminalFontDefaultSize, value); } }
public string TerminalFontName {get { return GetPropValue<string>(PropId.TerminalFontName); } set { SetPropValue(PropId.TerminalFontName, value); } }
public int TerminalDefaultWidth { get { return GetPropValue<int>(PropId.TerminalDefaultWidth); } set { SetPropValue(PropId.TerminalDefaultWidth, value); } }
public int TerminalDefaultHeight { get { return GetPropValue<int>(PropId.TerminalDefaultHeight); } set { SetPropValue(PropId.TerminalDefaultHeight, value); } }
public bool UseBlizzyToolbarOnly { get { return kOSCustomParameters.Instance.useBlizzyToolbarOnly; } set { kOSCustomParameters.Instance.useBlizzyToolbarOnly = value; } }
public bool DebugEachOpcode { get { return kOSCustomParameters.Instance.debugEachOpcode; } set { kOSCustomParameters.Instance.debugEachOpcode = value; } }

Expand Down Expand Up @@ -61,6 +63,8 @@ private void InitializeSuffixes()
AddSuffix("BLIZZY", new SetSuffix<BooleanValue>(() => UseBlizzyToolbarOnly, value => UseBlizzyToolbarOnly = value));
AddSuffix("BRIGHTNESS", new ClampSetSuffix<ScalarValue>(() => TerminalBrightness, value => TerminalBrightness = value, 0f, 1f, 0.01f));
AddSuffix("DEFAULTFONTSIZE", new ClampSetSuffix<ScalarValue>(() => TerminalFontDefaultSize, value => TerminalFontDefaultSize = value, 6f, 30f, 1f));
AddSuffix("DEFAULTWIDTH", new ClampSetSuffix<ScalarValue>(() => TerminalDefaultWidth, value => TerminalDefaultWidth = value, 15f, 255f, 1f));
AddSuffix("DEFAULTHEIGHT", new ClampSetSuffix<ScalarValue>(() => TerminalDefaultHeight, value => TerminalDefaultHeight = value, 3f, 160f, 1f));
}

private void BuildValuesDictionary()
Expand All @@ -71,6 +75,8 @@ private void BuildValuesDictionary()
AddConfigKey(PropId.TerminalFontDefaultSize, new ConfigKey("TerminalFontDefaultSize", "DEFAULTFONTSIZE", "Initial Terminal:CHARHEIGHT when a terminal is first opened", 12, 6, 20, typeof(int)));
AddConfigKey(PropId.TerminalFontName, new ConfigKey("TerminalFontName", "FONTNAME", "Font Name for terminal window", "_not_chosen_yet_", "n/a", "n/a", typeof(string)));
AddConfigKey(PropId.TerminalBrightness, new ConfigKey("TerminalBrightness", "BRIGHTNESS", "Initial brightness setting for new terminals", 0.7d, 0d, 1d, typeof(double)));
AddConfigKey(PropId.TerminalDefaultWidth, new ConfigKey("TerminalDefaultWidth", "DEFAULTWIDTH", "Initial Terminal:WIDTH when a terminal is first opened", 50, 15, 255, typeof(int)));
AddConfigKey(PropId.TerminalDefaultHeight, new ConfigKey("TerminalDefaultHeight", "DEFAULTHEIGHT", "Initial Terminal:HEIGHT when a terminal is first opened", 36, 3, 160, typeof(int)));
}

private void AddConfigKey(PropId id, ConfigKey key)
Expand Down Expand Up @@ -232,7 +238,9 @@ private enum PropId
DebugEachOpcode = 14,
TerminalFontDefaultSize = 15,
TerminalFontName = 16,
TerminalBrightness = 17
TerminalBrightness = 17,
TerminalDefaultWidth = 18,
TerminalDefaultHeight = 19
}
}
}

0 comments on commit dd28b61

Please sign in to comment.