Skip to content

Commit 3f7acd5

Browse files
committed
Crew/maximum crew information, wet mass and cost now take into account crew mass and crew inventories mass/cost (KSP 1.11+), engine information overhaul, code cleanup and optimizations
1 parent 2a18bbe commit 3f7acd5

22 files changed

Lines changed: 1281 additions & 990 deletions

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
0.3.0
2+
-----
3+
- Added buttons "Open CFG node in editor" and "Open orig. CFG in editor" to PAW menu. Both buttons open corresponding file in system default editor for .cfg files.
4+
- Added crew / maximum crew information to PAW menu.
5+
- For KSP 1.11+ displayed wet part mass and cost takes into account kerbonauts mass and their inventories mass/cost.
6+
- Engine information in PAW menu was completely overhauled. Now it also contains gimbal information, as well as other useful parameters, depending on engine type. Near/Far Future, KSPIE, RealFuels/RO are supported.
7+
- New button "MM patches history" opens window with tree-like structure of all module manager patches, applied to part, in order of appliance. Information about patches is parsed from module manager cache.
8+
- Mod menu options and buttons are now fully configurable in game difficulty settings ("Part Info in PAW" section).
9+
- PartInfoInPAW adds itself to each and every part during game load. MM patch, adding partmodule to all parts, is no longer needed and is deprecated.
10+
- Mod now only works in VAB/Hangar and is no more available in flight scene.
11+
- Perfomance improvements and code cleanup.
12+
113
0.2.3
214
-----
315
- Fixed "Copy Part CFG to Clipboard" not working for parts, having spaces in their cfg-file path (for example, Coatl Aerospace mod).
@@ -26,4 +38,4 @@
2638

2739
0.1.0
2840
-----
29-
- Initial release.
41+
- Initial release.

GameData/PartInfoInPAW/Localization/en-us.cfg

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Localization
22
{
33
en-us
44
{
5+
#LOC_PartInfoInPAW_PartModuleName = Part Info in PAW
56
#LOC_PartInfoInPAW_PartInfo_GroupTitle = Part info
67
#LOC_PartInfoInPAW_Engine1Info_GroupTitle = Engine #1 info
78
#LOC_PartInfoInPAW_Engine2Info_GroupTitle = Engine #2 info
@@ -13,10 +14,10 @@ Localization
1314
#LOC_PartInfoInPAW_PartCost_Title = Cost
1415
#LOC_PartInfoInPAW_PartEmptyCostFullCost_Title = Empty / full cost
1516
#LOC_PartInfoInPAW_PartEntryCost_Title = Entry cost
16-
#LOC_PartInfoInPAW_PartTemperature_Title = Temperature (cur./max.)
17-
#LOC_PartInfoInPAW_PartSkinTemperature_Title = Skin Temp. (cur./max.)
17+
#LOC_PartInfoInPAW_PartCrewInfo_Title = Crew / max. crew
1818
#LOC_PartInfoInPAW_EnginePropellants_Title = Propellants
1919
#LOC_PartInfoInPAW_EnginePropellantFlow_Format = <<1>>: <<2>>/sec.
20+
#LOC_PartInfoInPAW_EnginePropellantFlowFull_Format = <<1>>: <<2>>/sec.\n(<<3>>)
2021
#LOC_PartInfoInPAW_EngineThrust_Title = Thrust
2122
#LOC_PartInfoInPAW_EngineThrust_Format = <<1>> <<3>> (Vac.) / <<2>> <<3>> (ASL)
2223
#LOC_PartInfoInPAW_EngineThrust_FormatAirBreathing = <<1>> <<3>> (mach 0) / <<2>> <<3>> (mach <<4>>)
@@ -93,8 +94,7 @@ Localization
9394
#LOC_PartInfoInPAW_Settings_OpenPartCFGInEditor_ShowBtn = Open CFG node in editor
9495
#LOC_PartInfoInPAW_Settings_OpenPartCFGInEditor_ShowBtn_Tooltip = Button saves part config\n(textual in-game representation, with all MM patches applied to it)\nto temporary file, and opens file in system default editor for .cfg files
9596
#LOC_PartInfoInPAW_Settings_OpenOrigPartCFGInEditor_ShowBtn = Open orig. CFG in editor
96-
#LOC_PartInfoInPAW_Settings_OpenOrigPartCFGInEditor_ShowBtn_Tooltip = Button saves content of original part config file to temporary file,
97-
nand opens file in system default editor for .cfg files.\nIf part is copy of another part, original part config will be saved to temp file and opened
97+
#LOC_PartInfoInPAW_Settings_OpenOrigPartCFGInEditor_ShowBtn_Tooltip = Button opens original part config file in system default editor for .cfg files.\nIf part is copy of another part, original part config will be opened
9898
#LOC_PartInfoInPAW_Settings_ShowPartMMPatchesHistory_ShowBtn = MM patches history
9999
#LOC_PartInfoInPAW_Settings_ShowPartMMPatchesHistory_ShowBtn_Tooltip = Button opens a window with a list of all MM patches applied to part,\nin the same order they were applied
100100
#LOC_PartInfoInPAW_Settings_EnginesInfo_Title = Information about engine
@@ -114,6 +114,7 @@ Localization
114114

115115
#LOC_PartInfoInPAW_Kg_Unit = kg
116116
#LOC_PartInfoInPAW_T_Unit = t
117+
#LOC_PartInfoInPAW_mN_Unit = mN
117118
#LOC_PartInfoInPAW_N_Unit = N
118119
#LOC_PartInfoInPAW_KN_Unit = kN
119120
#LOC_PartInfoInPAW_MN_Unit = MN

GameData/PartInfoInPAW/Localization/ru.cfg

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Localization
22
{
33
ru
44
{
5+
#LOC_PartInfoInPAW_PartModuleName = Part Info in PAW
56
#LOC_PartInfoInPAW_PartInfo_GroupTitle = Информация о детали
67
#LOC_PartInfoInPAW_Engine1Info_GroupTitle = Двигатель №1
78
#LOC_PartInfoInPAW_Engine2Info_GroupTitle = Двигатель №2
@@ -13,10 +14,10 @@ Localization
1314
#LOC_PartInfoInPAW_PartCost_Title = Стоимость
1415
#LOC_PartInfoInPAW_PartEmptyCostFullCost_Title = Стоим. / полная стоим.
1516
#LOC_PartInfoInPAW_PartEntryCost_Title = Стоим. выкупа
16-
#LOC_PartInfoInPAW_PartTemperature_Title = Температура (тек./макс.)
17-
#LOC_PartInfoInPAW_PartSkinTemperature_Title = Темп. обшивки (тек./макс.)
17+
#LOC_PartInfoInPAW_PartCrewInfo_Title = Экипаж / макс. экипаж
1818
#LOC_PartInfoInPAW_EnginePropellants_Title = Пропелленты
1919
#LOC_PartInfoInPAW_EnginePropellantFlow_Format = <<1>>: <<2>>/с
20+
#LOC_PartInfoInPAW_EnginePropellantFlowFull_Format = <<1>>: <<2>>/с\n(<<3>>)
2021
#LOC_PartInfoInPAW_EngineThrust_Title = Тяга
2122
#LOC_PartInfoInPAW_EngineThrust_Format = <<1>> <<3>> (вакуум) / <<2>> <<3>> (1 атм.)
2223
#LOC_PartInfoInPAW_EngineThrust_FormatAirBreathing = <<1>> <<3>> (Мах 0) / <<2>> <<3>> (Мах <<4>>)
@@ -59,7 +60,7 @@ Localization
5960
#LOC_PartInfoInPAW_CloseBtn = Закрыть
6061
#LOC_PartInfoInPAW_PartMMPatchesHistory_StatusLogParsed = История MM-патчей детали подготовлена
6162
#LOC_PartInfoInPAW_PartMMPatchesHistory_PartPatchesMsg = <b>Деталь <color=yellow><<1>></color> : всего <<2>> MM-патчей</b>
62-
#LOC_PartInfoInPAW_PartMMPatchesHistory_ExpandAllPatchesBtn = Раскрыть все
63+
#LOC_PartInfoInPAW_PartMMPatchesHistory_ExpandAllPatchesBtn = Развернуть все
6364
#LOC_PartInfoInPAW_PartMMPatchesHistory_CollapseAllPatchesBtn = Свернуть все
6465
#LOC_PartInfoInPAW_PartMMPatchesHistory_CopyPatchesWithPartCFG = Включать ориг. конфиг детали при копировании/открытии
6566
#LOC_PartInfoInPAW_PartMMPatchesHistory_CopyPatchesHistoryFileBtn = Скопировать патчи
@@ -93,7 +94,7 @@ Localization
9394
#LOC_PartInfoInPAW_Settings_OpenPartCFGInEditor_ShowBtn = Открыть конфиг в редакторе
9495
#LOC_PartInfoInPAW_Settings_OpenPartCFGInEditor_ShowBtn_Tooltip = Кнопка сохраняет во временный файл текстовое представление\nконфигурации детали после всех применённых MM-патчей (т.е. в том состоянии, в котором деталь присутствует в игре),\nи открывает файл в редакторе по умолчанию для .cfg-файлов
9596
#LOC_PartInfoInPAW_Settings_OpenOrigPartCFGInEditor_ShowBtn = Открыть ориг. конфиг в редакторе
96-
#LOC_PartInfoInPAW_Settings_OpenOrigPartCFGInEditor_ShowBtn_Tooltip = Кнопка сохраняет во временный файл содержимое текстового файла\nконфигурации детали (cfg-файл) в её оригинальном состоянии (до применения любых MM-патчей),\nи открывает файл в редакторе по умолчанию для .cfg-файлов.\nЕсли деталь является копией другой, будет открыта конфигурация изначальной детали
97+
#LOC_PartInfoInPAW_Settings_OpenOrigPartCFGInEditor_ShowBtn_Tooltip = Кнопка открывает файл конфигурации детали (cfg-файл) в её оригинальном состоянии\n(до применения любых MM-патчей) в редакторе по умолчанию для .cfg-файлов.\nЕсли деталь является копией другой, будет открыта конфигурация изначальной детали
9798
#LOC_PartInfoInPAW_Settings_ShowPartMMPatchesHistory_ShowBtn = История MM-патчей детали
9899
#LOC_PartInfoInPAW_Settings_ShowPartMMPatchesHistory_ShowBtn_Tooltip = Кнопка открывает окно с перечнем применённых к детали MM-патчей\n(в порядке их применения)
99100
#LOC_PartInfoInPAW_Settings_EnginesInfo_Title = Информация о двигателе
@@ -113,6 +114,7 @@ Localization
113114

114115
#LOC_PartInfoInPAW_Kg_Unit = кг
115116
#LOC_PartInfoInPAW_T_Unit = т
117+
#LOC_PartInfoInPAW_mN_Unit = мН
116118
#LOC_PartInfoInPAW_N_Unit = Н
117119
#LOC_PartInfoInPAW_KN_Unit = КН
118120
#LOC_PartInfoInPAW_MN_Unit = МН
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
PARTINFOINPAW
2+
{
3+
DebugLogInfo = false
4+
}

src/GUI/MMPatchesCollapseExpandGUIButton.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PartInfoInPAW
44
{
5-
public class MMPatchesCollapseExpandGUIButton: DialogGUIButton
5+
internal class MMPatchesCollapseExpandGUIButton: DialogGUIButton
66
{
77
private const string expandText = "+";
88
private const string collapseText = "-";
@@ -29,9 +29,7 @@ UIStyle style
2929

3030
private static string GetBtnText(List<MMPatchInfo> patchesList, int index)
3131
{
32-
if (patchesList[index].IsCollapsed())
33-
return expandText;
34-
return collapseText;
32+
return patchesList[index].IsCollapsed() ? expandText : collapseText;
3533
}
3634

3735
private static void Toggle(List<MMPatchInfo> patchesList, int index)

src/GUI/MMPatchesHistoryDialog.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace PartInfoInPAW
1111
{
12-
public static class MMPatchesHistoryDialog
12+
internal static class MMPatchesHistoryDialog
1313
{
1414
private static PopupDialog dialog;
1515
private static List<MMPatchInfo> patchesList;
@@ -121,7 +121,7 @@ public static async void ShowDialog(string partName, string partTitle, Part part
121121
new DialogGUIButton(
122122
Localizer.Format("#LOC_PartInfoInPAW_PartMMPatchesHistory_CopyPatchesHistoryFileBtn"),
123123
() => {
124-
string patchesHistory = Utils.GetPartMMPatchesHistory(part, patchesList, IncludePartCFGInPatchesCode);
124+
string patchesHistory = MMPatchesUtils.GetPartMMPatchesHistory(part, patchesList, IncludePartCFGInPatchesCode);
125125
if (!String.IsNullOrEmpty(patchesHistory))
126126
{
127127
try
@@ -143,7 +143,7 @@ public static async void ShowDialog(string partName, string partTitle, Part part
143143
new DialogGUIButton(
144144
Localizer.Format("#LOC_PartInfoInPAW_PartMMPatchesHistory_OpenPatchesHistoryBtn"),
145145
() => {
146-
string patchesHistory = Utils.GetPartMMPatchesHistory(part, patchesList, IncludePartCFGInPatchesCode);
146+
string patchesHistory = MMPatchesUtils.GetPartMMPatchesHistory(part, patchesList, IncludePartCFGInPatchesCode);
147147
if (!String.IsNullOrEmpty(patchesHistory))
148148
{
149149
string fileName = partName;
@@ -200,7 +200,8 @@ public static async void ShowDialog(string partName, string partTitle, Part part
200200
)
201201
),
202202
false,
203-
HighLogic.UISkin
203+
HighLogic.UISkin,
204+
false
204205
);
205206
}
206207
}

src/GUI/MMPatchesPatchGUILabel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PartInfoInPAW
44
{
5-
public class MMPatchesPatchGUILabel: DialogGUILabel
5+
internal class MMPatchesPatchGUILabel: DialogGUILabel
66
{
77
public MMPatchesPatchGUILabel(
88
List<MMPatchInfo> patchesList,

src/GameSettings.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace PartInfoInPAW
22
{
3-
public class PartInfoInPAWGameSettings_PartInfo : GameParameters.CustomParameterNode
3+
internal class PartInfoInPAWGameSettings_PartInfo : GameParameters.CustomParameterNode
44
{
55
public override string DisplaySection
66
{
@@ -58,7 +58,7 @@ public override bool Enabled(System.Reflection.MemberInfo member, GameParameters
5858
public override bool Interactible(System.Reflection.MemberInfo member, GameParameters parameters)
5959
{
6060
if (member.Name == "showCopyPartNodeBtn" || member.Name == "showOpenPartCFGInEditorBtn" || member.Name == "showPartMMPatchesHistoryBtn")
61-
return Utils.ModuleManagerInstalled;
61+
return PartInfoInPAW.IsModuleManagerPresent();
6262
return true;
6363
}
6464

@@ -105,7 +105,7 @@ public override bool Interactible(System.Reflection.MemberInfo member, GameParam
105105
public bool showPartMMPatchesHistoryBtn = true;
106106
}
107107

108-
public class PartInfoInPAWGameSettings_EngineInfo : GameParameters.CustomParameterNode
108+
internal class PartInfoInPAWGameSettings_EngineInfo : GameParameters.CustomParameterNode
109109
{
110110
public override string DisplaySection
111111
{
Lines changed: 10 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
namespace PartInfoInPAW
1111
{
12-
public delegate void PartPatchesHistoryCallback(List<MMPatchInfo> patchesList);
12+
internal delegate void PartPatchesHistoryCallback(List<MMPatchInfo> patchesList);
1313

14-
public static class MMLogParser
14+
internal static class MMLogParser
1515
{
1616
public enum ParserStatus
1717
{
@@ -112,8 +112,10 @@ public static async Task<List<MMPatchInfo>> ParseLogFile(string partName)
112112
if (LogFileLines.Length > 0)
113113
{
114114
string searchStr = "/PART[" + @partName + "]";
115-
foreach (string line in LogFileLines)
115+
int linesCount = LogFileLines.Length;
116+
for (int i = 0; i < linesCount; i++)
116117
{
118+
string line = LogFileLines[i];
117119
if (line.IndexOf(searchStr) != -1)
118120
{
119121
Match m = Regex.Match(line.Trim(), RegexPattern(partName));
@@ -156,9 +158,11 @@ public static async Task<List<MMPatchInfo>> ParseLogFile(string partName)
156158
int occurence = 0;
157159
int level = -1;
158160
bool found = false;
159-
foreach (string cfgLine in patchCFGFileLines)
161+
int cfgLinesCount = patchCFGFileLines.Length;
162+
string[] commentStart = { "//" };
163+
for (int j = 0; j < cfgLinesCount; j++)
160164
{
161-
string[] code = cfgLine.Split(new string[] { "//" }, 2, StringSplitOptions.None);
165+
string[] code = patchCFGFileLines[j].Split(commentStart, 2, StringSplitOptions.None);
162166
if (code[0].IndexOf(patchSelector) != -1)
163167
{
164168
if (patchNum == occurence)
@@ -207,109 +211,9 @@ public static async Task<List<MMPatchInfo>> ParseLogFile(string partName)
207211
return patches;
208212
}
209213

210-
public static string GetPatchesHistoryAsStr(string partName)
211-
{
212-
if (PatchesHistoryDict.ContainsKey(partName))
213-
{
214-
List<MMPatchInfo> patches = PatchesHistoryDict[partName];
215-
string result = $"// Patches for part {partName}: {patches.Count}" + Environment.NewLine + Environment.NewLine;
216-
foreach (MMPatchInfo m in patches)
217-
{
218-
result += m;
219-
}
220-
return result;
221-
}
222-
else
223-
{
224-
return $"// Patches count for part {partName}: 0" + Environment.NewLine;
225-
}
226-
}
227-
228214
private static string RegexPattern(string partName)
229215
{
230-
return @"^\[LOG \d{2}:\d{2}:\d{2}\.\d{3}\] Applying update (.+)/(@PART\[.+) to .+/PART\[" + Regex.Escape(partName) + @"\]$";
231-
}
232-
}
233-
234-
public class MMPatchInfo
235-
{
236-
public string PatchFilePath { get; protected set; }
237-
public string Patch { get; protected set; }
238-
public string PatchBody { get; protected set; }
239-
public bool PatchFullCollapsed { get; protected set; }
240-
241-
public MMPatchInfo(string patchFilePath, string patch, string patchBody)
242-
{
243-
PatchFilePath = patchFilePath;
244-
Patch = patch;
245-
PatchBody = patchBody;
246-
PatchFullCollapsed = true;
247-
}
248-
249-
public static string AddExtension(string patch)
250-
{
251-
string result = patch;
252-
if (result[0] == '/')
253-
{
254-
result = result.Substring(1);
255-
}
256-
result += "." + UrlDir.configExtension;
257-
return result;
258-
}
259-
260-
public void ToggleCollapsed()
261-
{
262-
PatchFullCollapsed = !PatchFullCollapsed;
263-
}
264-
265-
public void Collapse()
266-
{
267-
PatchFullCollapsed = true;
268-
}
269-
270-
public void Expand()
271-
{
272-
PatchFullCollapsed = false;
273-
}
274-
275-
public bool IsCollapsed()
276-
{
277-
return PatchFullCollapsed;
278-
}
279-
280-
public string GetPatchStr()
281-
{
282-
if (PatchBody == null)
283-
{
284-
return "// " + PatchFilePath + Environment.NewLine +
285-
Patch + Environment.NewLine +
286-
"{} // Could not parse patch CFG from " + PatchFilePath + Environment.NewLine + Environment.NewLine;
287-
}
288-
return "// " + PatchFilePath + Environment.NewLine +
289-
Patch + Environment.NewLine +
290-
PatchBody + Environment.NewLine + Environment.NewLine;
291-
}
292-
293-
public override string ToString()
294-
{
295-
if (PatchFullCollapsed)
296-
{
297-
return Localizer.Format("#LOC_PartInfoInPAW_PartMMPatchesHistory_PatchFileName", PatchFilePath);
298-
}
299-
else
300-
{
301-
if (PatchBody == null)
302-
{
303-
return Localizer.Format("#LOC_PartInfoInPAW_PartMMPatchesHistory_PatchFileName", PatchFilePath) +
304-
Environment.NewLine + Environment.NewLine +
305-
Patch + Environment.NewLine +
306-
Localizer.Format("#LOC_PartInfoInPAW_CantParsePatchCFG_ErrorMsg");
307-
}
308-
return Localizer.Format("#LOC_PartInfoInPAW_PartMMPatchesHistory_PatchFileName", PatchFilePath) +
309-
Environment.NewLine + Environment.NewLine +
310-
Patch + Environment.NewLine +
311-
PatchBody;
312-
}
216+
return @"^\[LOG \d{2}:\d{2}:\d{2}\.\d{3}\] Applying update (.+)/(@PART.+) to .+/PART\[" + Regex.Escape(partName) + @"\]$";
313217
}
314218
}
315219
}

0 commit comments

Comments
 (0)