diff --git a/GameData/SystemHeat/Localization/en-us.cfg b/GameData/SystemHeat/Localization/en-us.cfg index d92892b..8ea8d77 100644 --- a/GameData/SystemHeat/Localization/en-us.cfg +++ b/GameData/SystemHeat/Localization/en-us.cfg @@ -3,12 +3,52 @@ Localization en-us { #LOC_SystemHeat_Coolant_Default_title = Default Coolant Type - - // OVERLAY + // TOOLBAR + // ------------ + #LOC_SystemHeat_ToolbarPanel_Title = System Heat + #LOC_SystemHeat_ToolbarPanel_CraftStatsTitle = Craft Summary + + #LOC_SystemHeat_ToolbarPanel_OutgoingFluxTitle = Total Rejection + #LOC_SystemHeat_ToolbarPanel_IncomingFluxTile = Total Generation + #LOC_SystemHeat_ToolbarPanel_OutgoingFluxValue = <<1>> kW + #LOC_SystemHeat_ToolbarPanel_IncomingFluxValue = <<1>> kW + + #LOC_SystemHeat_ToolbarPanel_LoopCountTitle = Loop Count + #LOC_SystemHeat_ToolbarPanel_LoopCountValue = <<1>> + + + #LOC_SystemHeat_ToolbarPanel_SettingsTitle = Settings + + #LOC_SystemHeat_ToolbarPanel_SimulationRateTitle = Editor Simulation Rate + #LOC_SystemHeat_ToolbarPanel_OverlayToggle = Overlay + #LOC_SystemHeat_ToolbarPanel_SimulationRateValue = <<1>>x + + #LOC_SystemHeat_ToolbarPanel_LoopsTitle = Loops + #LOC_SystemHeat_ToolbarPanel_LoopTitle = Loop <<1>> + #LOC_SystemHeat_ToolbarPanel_LoopTemperatureTitle = • Temperature + #LOC_SystemHeat_ToolbarPanel_LoopTemperatureValue = <<1>>/<<2>> K + #LOC_SystemHeat_ToolbarPanel_LoopFluxTitle = • Net Flux + #LOC_SystemHeat_ToolbarPanel_LoopFluxValue = <<1>><<2>> kW + + // OVERLAY PANEL // ------------ #LOC_SystemHeat_OverlayPanel_UpperText = Temperature Output <<1>> K \nHeat Output <<2>> kW #LOC_SystemHeat_OverlayPanel_UpperTextNoTemp = Heat Output <<1>> kW #LOC_SystemHeat_OverlayPanel_LowerText = Loop Status\n Temperature <<1>>/<<2>> K \n Net Flux <<3>> kW \n Volume <<4>> m³ + // REACTOR TOOLBAR + // ------------ + #LOC_SystemHeat_ReactorPanel_Title = Installed Reactors + #LOC_SystemHeat_ReactorPanel_NoReactors = No reactors detected on vessel + #LOC_SystemHeat_ReactorPanel_ReactorOnToggleLabel = ON + #LOC_SystemHeat_ReactorPanel_Field_HeatGeneratedTitle = Heat Generated + #LOC_SystemHeat_ReactorPanel_Field_HeatGenerated = <<1>> kW + #LOC_SystemHeat_ReactorPanel_Field_PowerGeneratedTitle = Power Generated + #LOC_SystemHeat_ReactorPanel_Field_PowerGenerated = <<1>> kW + #LOC_SystemHeat_ReactorPanel_Field_CoreLifeTitle = Core Life + #LOC_SystemHeat_ReactorPanel_Field_CoreLife = <<1>> + #LOC_SystemHeat_ReactorPanel_Field_CoreTemperatureTitle = Core Temperature + #LOC_SystemHeat_ReactorPanel_Field_CoreTemperature = <<1>> K + #LOC_SystemHeat_ReactorPanel_Field_CoreTemperatureAlert = <<1>> K! // ENGINEER'S REPORT // ------------ @@ -102,6 +142,20 @@ Localization #LOC_SystemHeat_ModuleSystemHeatSink_ModuleName = Heat Sink #LOC_SystemHeat_ModuleSystemHeatSink_PartInfo = Stores or releases heat on demand. \n\nMaximum Heat Stored: <<1>> MJ \nHeat Storage Rate: <<2>> kW + #LOC_SystemHeat_ModuleSystemHeatSink_Field_HeatStorageDumpRate = Dump Rate + #LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemHeatGeneration = Storage Accepted + #LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemHeatGeneration_Dump = Storage Dumping + #LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemHeatGeneration_Storing = <<1>>/<<2>> kW + #LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemTemperature = Storage Temperature + #LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemTemperature_Running = <<1>> K + + #LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemHeatStored = Storage Capacity Used + #LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemHeatStored_Fraction = <<1>>% + + #LOC_SystemHeat_ModuleSystemHeatSink_Event_StoreHeat = Store Heat + #LOC_SystemHeat_ModuleSystemHeatSink_Event_DispenseHeat = Release Heat + + /// ModuleSystemHeatExchanger /// ================================= #LOC_SystemHeat_ModuleSystemHeatExchanger_ModuleName = Heat Exchanger diff --git a/GameData/SystemHeat/Localization/ru.cfg b/GameData/SystemHeat/Localization/ru.cfg new file mode 100644 index 0000000..d0375cb --- /dev/null +++ b/GameData/SystemHeat/Localization/ru.cfg @@ -0,0 +1,143 @@ +// Translated by ra4nd0m +Localization +{ + ru + { + #LOC_SystemHeat_Coolant_Default_title = Теплоноситель По Умолчанию + + // OVERLAY + // ------------ + #LOC_SystemHeat_OverlayPanel_UpperText = Выходная Температура <<1>> K \nВыходное Тепло <<2>> кВт + #LOC_SystemHeat_OverlayPanel_UpperTextNoTemp = Выходное Тепло <<1>> кВт + #LOC_SystemHeat_OverlayPanel_LowerText = Статус Петли\n Температура <<1>>/<<2>> K \n Чистый Поток <<3>> кВ \n Объём <<4>> м³ + + // ENGINEER'S REPORT + // ------------ + #LOC_SystemHeat_EngineerReport_LoopFluxTest_ConcernTitle = Петлям требуется дополнительная охлаждающая способность + #LOC_SystemHeat_EngineerReport_LoopFluxTest_ConcernDescription = Петля <<1>> обладает чистым тепловым потоком мощностью <<2>> кВт! <<3>> + + #LOC_SystemHeat_EngineerReport_LoopTemperatureTest_ConcernTitle = Температура Петли Слишком Высока + #LOC_SystemHeat_EngineerReport_LoopTemperatureTest_ConcernDescription = Температура одной, или нескольких петель слишком высока для их компонентов! + + #LOC_SystemHeat_Units_K = K + #LOC_SystemHeat_Units_кВт = кВт + + // PART MODULES + // ------------ + + // ModuleSystemHeat + /// ================================= + #LOC_SystemHeat_ModuleSystemHeat_DisplayName = Тепловая Система + #LOC_SystemHeat_ModuleSystemHeat_PartInfo = Эта запчасть - часть симуляции Тепловой Системы \n\nДобавляемый Объём Петли: <<1>> м³ + #LOC_SystemHeat_ModuleSystemHeat_GroupName = Тепловая Система + #LOC_SystemHeat_ModuleSystemHeat_Field_LoopID = ID Петли + #LOC_SystemHeat_ModuleSystemHeat_Field_SystemFlux = Системный Поток + #LOC_SystemHeat_ModuleSystemHeat_Field_SystemTemperature = Системная Температура + #LOC_SystemHeat_ModuleSystemHeat_Field_LoopID = + + // ModuleSystemHeatRadiator + /// ================================= + #LOC_SystemHeat_ModuleSystemHeatRadiator_DisplayName = Радиатор Охлаждения + #LOC_SystemHeat_ModuleSystemHeatRadiator_PartInfo = Охлаждает системы корабля прокачивая теплоноситель сквозь излучающие тепло поверхности.\n\nХарактеристики Рассеивания\n - <<1>> кВт при <<2>> K\n - <<3>> кВт при <<4>> K \n\nПараметры Классической Тепловой Системы + + #LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorStatus_Title = Статус Радиатора + #LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorEfficiency_Title = Эффективность Радиатора + #LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorEfficiency_Running = <<1>>% + #LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorEfficiency_Offline = Выключен + + // ModuleSystemHeatFissionReactor + /// ================================= + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_UIGroup_Title = Ядерный Реактор + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_ModuleName = Ядерный Реактор + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_PartInfo = Производит Электричества: <<1>> кВт\nСкорость Отклика: <<8>>%/s\nМинимальная Мощность: <<9>>%\nПриблизительный Срок Жизни Ядра: <<2>>\n\nПараметры Тепловой Системы:\n -Тепловая Мощность: <<3>> кВт\n -Отводимая В Систему Температура: <<4>> K\n\nТемпературные Параметры Реактора:\n -Оптимально: <<5>> K \n -Повреждение Ядра: <<6>> K\n -Расплав Ядра: <<7>> K + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Action_TogglePanelAction = Переключить Панель Реактора + + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Action_StartActionName = Запустить Реактор + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Action_ToggleActionName = Переключить Реактор + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Action_StopActionName = Остановить Реактор + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Event_Disable_Title = Выкл. Реактор + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Event_Enable_Title = Вкл. Реактор + + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Event_ShowReactorControl = Переключить Управление Реактором + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Event_RepairReactor = Починить Реактор + + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Message_Repair_RepairSuccess = Реактор отремонтирован на <<1>>%! + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Message_Repair_CoreTooDamaged = Ядро реактора слишком повреждено для ремонта + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Message_Repair_CoreAlreadyRepaired = Ядро реактора уже отремонтировано до предела, возможного в полевых условиях (<<1>>%) + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Message_Repair_EngineerLevelTooLow = Ремонт Ядра реактора требует Инженера <<1>> Уровня + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Message_Repair_NotWhileRunning = Нельзя начать ремонт пока реактор работает! + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Message_Repair_CoreTooHot = Реактор должен остыть ниже <<1>> K для начала ремонта! + + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_CurrentSafetyOverride = Температура Авто Отключения + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_CurrentPowerPercent = Настройка Мощнсоти + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_ReactorOutput = Мощность Реактора + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_ReactorOutput_Meltdown = Ядро Уничтожено + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_ReactorOutput_Offline = Реактор Выключен + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_ThermalTransfer = Доступная Мощность + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_CoreTemp = Температура Ядра + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_CoreStatus = Здоровье Ядра + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_CoreStatus_Meltdown = Полный Расплав Ядра + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_FuelStatus = Срок Жизни Ядра + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_FuelStatus_Meltdown = Ядро Уничтожено + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_FuelStatus_Offline = Реактор Выключен + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_FuelStatus_Exhausted = Топливо закончилось! + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_FuelStatus_VeryLong = Почти бесконечно + + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_GeneratorStatus = Генерация + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_GeneratorStatus_Normal = <<1>> ЭЭ/с + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_GeneratorStatus_Offline = Выключен + + /// ModuleSystemHeatFissionEngine + /// ================================= + #LOC_SystemHeat_ModuleSystemHeatFissionEngine_ModuleName = Ядерный Ракетный Двигатель + #LOC_SystemHeat_ModuleSystemHeatFissionEngine_UIGroup_Title = Ядерный Двигатель + #LOC_SystemHeat_ModuleSystemHeatFissionEngine_PartInfo = Создаёт тягу за счёт ядерного распада. \n\nПроизводит Электричества: <<1>> кВт\nСкорость Отклика: <<8>>%/s\nМинимальная Мощность: <<9>>%\nПриблизительный Срок Жизни Ядра: <<2>>\n\nПараметры Тепловой Системы:\n -Тепловая Мощность: <<3>> кВт\n -Отводимая В Систему Температура: <<4>> K\n\nТемпературные Параметры Реактора:\n -Оптимально: <<5>> K \n -Повреждение Ядра: <<6>> K\n -Расплав Ядра: <<7>> K + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Action_TogglePanelAction = Переключить Панель Реактора + + #LOC_SystemHeat_ModuleSystemHeatFissionEngine_PartInfo_NoPower = Создаёт тягу за счёт ядерного распада. \n\nСкорость Отклика: <<7>>%/s\nМинимальная Мощность: <<8>>%\nПриблизительный Срок Жизни Ядра: <<1>>\n\nПараметры Тепловой Системы:\n -Тепловая Мощность: <<2>> кВт\n -Отводимая В Систему Температура: <<3>> K\n\nТемпературные Параметры Реактора:\n -Оптимально: <<>> K \n -Повреждение Ядра: <<5>> K\n -Расплав Ядра: <<6>> K + #LOC_SystemHeat_ModuleSystemHeatFissionReactor_Action_TogglePanelAction = Переключить Панель Реактора + + /// ModuleSystemHeatSink + /// ================================= + #LOC_SystemHeat_ModuleSystemHeatSink_UIGroup_Title = Тепловой Аккумулятор + #LOC_SystemHeat_ModuleSystemHeatSink_ModuleName = Тепловой Аккумулятор + #LOC_SystemHeat_ModuleSystemHeatSink_PartInfo = По востребованности накапливает или выпускает тепло. \n\nМаксимальная Тепловая Вместимость: <<1>> MJ \nСкорость Накопления Тепла: <<2>> кВт + + /// ModuleSystemHeatExchanger + /// ================================= + #LOC_SystemHeat_ModuleSystemHeatExchanger_ModuleName = Теплообменник + #LOC_SystemHeat_ModuleSystemHeatExchanger_UIGroup_Title = Теплообменник + #LOC_SystemHeat_ModuleSystemHeatExchanger_PartInfo = Передаёт тепло из одной петли в другую. Может дополнительно менять температуру целевой петли. \n\nТребуется Электричества\n - При ΔT равном <<1>> K требуется <<2>> кВт\n - При ΔT равном <<3>> K требуется <<4>> кВт\n\nВыработка Побочного Тепла\n - При ΔT равном <<1>> K производится <<5>> кВт\n - При ΔT равном <<3>> K производится <<6>> кВт + + #LOC_SystemHeat_ModuleSystemHeatExchanger_Field_Direction = Направление + #LOC_SystemHeat_ModuleSystemHeatExchanger_Field_Direction_String = Петля <<1>> -> Петля <<2>> + #LOC_SystemHeat_ModuleSystemHeatExchanger_Field_Status = Статус + #LOC_SystemHeat_ModuleSystemHeatExchanger_Field_Status_Active = Выходная Температура: <<1>> K\nВыходной Поток: <<2>> кВт + #LOC_SystemHeat_ModuleSystemHeatExchanger_Field_Status_NoPower = Недостаточно Электричества! + #LOC_SystemHeat_ModuleSystemHeatExchanger_Field_Status_TooHot = Целевая Петля Перегрета! + #LOC_SystemHeat_ModuleSystemHeatExchanger_Field_Status_Disabled = Выключен + #LOC_SystemHeat_ModuleSystemHeatExchanger_Field_MaxHeatTransfer = Максимальная Передача Тепла + #LOC_SystemHeat_ModuleSystemHeatExchanger_Field_TemperatureAdjust = Регулировка Температуры + #LOC_SystemHeat_ModuleSystemHeatExchanger_Field_PowerCost = Потребление Электричества + #LOC_SystemHeat_ModuleSystemHeatExchanger_Field_PowerCost_Active = <<1>> кВт + + #LOC_SystemHeat_ModuleSystemHeatExchanger_Event_EnableExchanger = Вкл. Теплообменник + #LOC_SystemHeat_ModuleSystemHeatExchanger_Event_DisableExchanger = Выкл. Теплообменник + + // PARTS + // ------------ + #LOC_SystemHeat_manufacturer_pkmc_title = Внекербинская Добывающая Корпорация + + #LOC_SystemHeat_systemheat-exchanger-1_title = Теплообменник PX-1F + #LOC_SystemHeat_systemheat-exchanger-1_description = Передаёт тепло из одной петли в другую. Может дополнительно менять температуру целевой петли. Только для продвинутых Инженеров! + #LOC_SystemHeat_systemheat-exchanger-1_tags = + + #LOC_SystemHeat_systemheat-coolant-tank-radial-1_title = Бак С Теплоносителем PK-2.5 + #LOC_SystemHeat_systemheat-coolant-tank-radial-1_description = Хранит 2.5 кубометров плотного теплоносителя. Больший объём - более медленный нагрев. + #LOC_SystemHeat_systemheat-coolant-tank-radial-1_tags = + + #LOC_SystemHeat_systemheat-sink-1_title = Тепловой Аккумулятор PSK-200 + #LOC_SystemHeat_systemheat-sink-1_description = Этот большой и тяжёлый бак из какого-то продвинутого материала может накопить приличный объёем тепловой энергии. Полезен для хранения небольшого объёма тепла. + #LOC_SystemHeat_systemheat-sink-1_tags = + } +} \ No newline at end of file diff --git a/GameData/SystemHeat/Plugin/SystemHeat.dll b/GameData/SystemHeat/Plugin/SystemHeat.dll index 8f8ef1d..2ec15df 100644 Binary files a/GameData/SystemHeat/Plugin/SystemHeat.dll and b/GameData/SystemHeat/Plugin/SystemHeat.dll differ diff --git a/GameData/SystemHeat/UI/systemheatui.dat b/GameData/SystemHeat/UI/systemheatui.dat index 17f8126..fca5ca2 100644 Binary files a/GameData/SystemHeat/UI/systemheatui.dat and b/GameData/SystemHeat/UI/systemheatui.dat differ diff --git a/GameData/SystemHeat/UI/systemheatui.dato b/GameData/SystemHeat/UI/systemheatui.dato deleted file mode 100644 index ccee30e..0000000 Binary files a/GameData/SystemHeat/UI/systemheatui.dato and /dev/null differ diff --git a/GameData/SystemHeat/Versioning/SystemHeat.version b/GameData/SystemHeat/Versioning/SystemHeat.version index b607ff9..380c3b1 100644 --- a/GameData/SystemHeat/Versioning/SystemHeat.version +++ b/GameData/SystemHeat/Versioning/SystemHeat.version @@ -6,7 +6,7 @@ { "MAJOR":0, "MINOR":1, - "PATCH":2, + "PATCH":3, "BUILD":0 }, "KSP_VERSION": diff --git a/SystemHeat/SystemHeat/Modules/ModuleSystemHeatSink.cs b/SystemHeat/SystemHeat/Modules/ModuleSystemHeatSink.cs index be6f72a..986307e 100644 --- a/SystemHeat/SystemHeat/Modules/ModuleSystemHeatSink.cs +++ b/SystemHeat/SystemHeat/Modules/ModuleSystemHeatSink.cs @@ -48,20 +48,20 @@ public class ModuleSystemHeatSink : PartModule // Safety override - [KSPField(isPersistant = true, guiActive = false, guiName = "Dump rate", groupName = "heatsink", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatSink_UIGroup_Title"), UI_FloatRange(minValue = 0f, maxValue = 1500f, stepIncrement = 10f)] + [KSPField(isPersistant = true, guiActive = false, guiName = "#LOC_SystemHeat_ModuleSystemHeatSink_Field_HeatStorageDumpRate", groupName = "heatsink", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatSink_UIGroup_Title"), UI_FloatRange(minValue = 0f, maxValue = 1500f, stepIncrement = 10f)] public float heatStorageDumpRate = 500f; // UI Fields // UI field for showing heat - [KSPField(isPersistant = false, guiActive = true, guiActiveEditor = true, guiName = "Storage Accepted", groupName = "heatsink", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatSink_UIGroup_Title")] + [KSPField(isPersistant = false, guiActive = true, guiActiveEditor = true, guiName = "#LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemHeatGeneration", groupName = "heatsink", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatSink_UIGroup_Title")] public string systemHeatGeneration = ""; // UI field for showing heat - [KSPField(isPersistant = false, guiActive = true, guiActiveEditor = false, guiName = "Storage Temperature", groupName = "heatsink", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatSink_UIGroup_Title")] + [KSPField(isPersistant = false, guiActive = true, guiActiveEditor = false, guiName = "#LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemTemperature", groupName = "heatsink", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatSink_UIGroup_Title")] public string systemTemperature = ""; // UI field for showing heat - [KSPField(isPersistant = false, guiActive = true, guiActiveEditor = false, guiName = "Storage Capacity Used", groupName = "heatsink", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatSink_UIGroup_Title")] + [KSPField(isPersistant = false, guiActive = true, guiActiveEditor = false, guiName = "#LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemHeatStored", groupName = "heatsink", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatSink_UIGroup_Title")] public string systemHeatStored = ""; @@ -75,12 +75,12 @@ public class ModuleSystemHeatSink : PartModule /// KSPEVENTS /// ---------------------- - [KSPEvent(guiActive = true, guiActiveEditor = false, guiName = "Store Heat", active = true, groupName = "heatsink", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatSink_UIGroup_Title", groupStartCollapsed = false)] + [KSPEvent(guiActive = true, guiActiveEditor = false, guiName = "#LOC_SystemHeat_ModuleSystemHeatSink_Event_StoreHeat", active = true, groupName = "heatsink", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatSink_UIGroup_Title", groupStartCollapsed = false)] public void EnableStorage() { storageEnabled = true; } - [KSPEvent(guiActive = true, guiActiveEditor = false, guiName = "Dispense Heat", active = false, groupName = "heatsink", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatSink_UIGroup_Title", groupStartCollapsed = false)] + [KSPEvent(guiActive = true, guiActiveEditor = false, guiName = "#LOC_SystemHeat_ModuleSystemHeatSink_Event_DispenseHeat", active = false, groupName = "heatsink", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatSink_UIGroup_Title", groupStartCollapsed = false)] public void DisableStorage() { storageEnabled = false; @@ -191,17 +191,17 @@ public void FixedUpdate() if (HighLogic.LoadedSceneIsFlight) { GenerateHeatFlight(); - systemTemperature = String.Format("{0} K", storageTemperature.ToString("F0")); - systemHeatStored = String.Format("{0}%", (heatStored / heatStorageMaximum * 100f).ToString("F0")); - systemHeatGeneration = String.Format("{0}/{1} kW", (-heatModule.consumedSystemFlux).ToString("F0"), maxHeatRate.ToString("F0")); + systemTemperature = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemTemperature_Running", storageTemperature.ToString("F0")); + systemHeatStored = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemHeatStored_Fraction", (heatStored / heatStorageMaximum * 100f).ToString("F0")); + systemHeatGeneration = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemHeatGeneration_Storing", (-heatModule.consumedSystemFlux).ToString("F0"), maxHeatRate.ToString("F0")); } if (HighLogic.LoadedSceneIsEditor) { GenerateHeatEditor(); - systemTemperature = String.Format("{0} K", storageTemperature.ToString("F0")); - systemHeatStored = String.Format("{0}%", (heatStored / heatStorageMaximum * 100f).ToString("F0")); - systemHeatGeneration = String.Format("{0}/{1} kW", (-heatModule.consumedSystemFlux).ToString("F0"), maxHeatRate.ToString("F0")); + systemTemperature = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemTemperature_Running", storageTemperature.ToString("F0")); + systemHeatStored = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemHeatStored_Fraction", (heatStored / heatStorageMaximum * 100f).ToString("F0")); + systemHeatGeneration = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemHeatGeneration_Storing", (-heatModule.consumedSystemFlux).ToString("F0"), maxHeatRate.ToString("F0")); } } @@ -215,7 +215,7 @@ protected void GenerateHeatFlight() if (storageEnabled && heatStored < heatStorageMaximum) { heatModule.AddFlux(moduleID, 0f, -maxHeatRate); - Fields["systemHeatGeneration"].guiName = "Storage Accepted"; + Fields["systemHeatGeneration"].guiName = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemHeatGeneration"); if (heatModule.currentLoopTemperature >= heatModule.nominalLoopTemperature) { storageTemperature = Mathf.Clamp(storageTemperature + (-heatModule.consumedSystemFlux * TimeWarp.fixedDeltaTime) / (heatStorageSpecificHeat * heatStorageMass), 0f, 5000f); // Q = mcT @@ -224,7 +224,7 @@ protected void GenerateHeatFlight() } else if (!storageEnabled && heatStored > 0f) { - Fields["systemHeatGeneration"].guiName = "Storage Dumping"; + Fields["systemHeatGeneration"].guiName = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemHeatGeneration_Dump"); heatModule.AddFlux(moduleID, storageTemperature, heatStorageDumpRate); heatStored = Mathf.Clamp(heatStored - heatStorageDumpRate * TimeWarp.fixedDeltaTime, 0f, heatStorageMaximum); storageTemperature = storageTemperature - heatStorageDumpRate * TimeWarp.fixedDeltaTime / (heatStorageSpecificHeat * heatStorageMass); // Q = mcT diff --git a/SystemHeat/SystemHeat/UI/ReactorUI/ReactorPanel.cs b/SystemHeat/SystemHeat/UI/ReactorUI/ReactorPanel.cs index 72803c0..6dbfad7 100644 --- a/SystemHeat/SystemHeat/UI/ReactorUI/ReactorPanel.cs +++ b/SystemHeat/SystemHeat/UI/ReactorUI/ReactorPanel.cs @@ -8,7 +8,7 @@ namespace SystemHeat.UI { - public class ReactorPanel: MonoBehaviour + public class ReactorPanel : MonoBehaviour { public RectTransform rect; public Transform scrollRoot; @@ -32,6 +32,14 @@ private void FindComponents() scrollRoot = transform.FindDeepChild("PanelScroll"); windowTitle = transform.FindDeepChild("PanelTitleText").GetComponent(); noReactorsObject = transform.FindDeepChild("NoReactorsObject").GetComponent(); + + Localize(); + } + + void Localize() + { + windowTitle.text = Localizer.Format("#LOC_SystemHeat_ReactorPanel_Title"); + noReactorsObject.text = Localizer.Format("#LOC_SystemHeat_ReactorPanel_NoReactors"); } public void SetVisible(bool state) { @@ -42,24 +50,29 @@ public void ClearReactors() if (reactorModules != null) reactorModules.Clear(); if (reactorWidgets != null) - for (int i=reactorWidgets.Count -1; i>=0;i++) + for (int i = reactorWidgets.Count - 1; i >= 0; i--) { - Destroy(reactorWidgets[i].gameObject); + if (reactorWidgets[i] != null) + Destroy(reactorWidgets[i].gameObject); } } public void AddReactor(PartModule pm) { if (rect == null) FindComponents(); + noReactorsObject.gameObject.SetActive(false); - reactorModules.Add(pm); + if (!reactorModules.Contains(pm)) + { + reactorModules.Add(pm); - GameObject newWidget = (GameObject)Instantiate(SystemHeatUILoader.ReactorWidgetPrefab, Vector3.zero, Quaternion.identity); - newWidget.transform.SetParent(scrollRoot); - newWidget.transform.localPosition = Vector3.zero; - ReactorWidget w = newWidget.AddComponent(); - w.SetReactor(pm); - reactorWidgets.Add(w); + GameObject newWidget = (GameObject)Instantiate(SystemHeatUILoader.ReactorWidgetPrefab, Vector3.zero, Quaternion.identity); + newWidget.transform.SetParent(scrollRoot); + newWidget.transform.localPosition = Vector3.zero; + ReactorWidget w = newWidget.AddComponent(); + w.SetReactor(pm); + reactorWidgets.Add(w); + } } @@ -69,5 +82,5 @@ public void FixedUpdate() } } - + } diff --git a/SystemHeat/SystemHeat/UI/ReactorUI/ReactorToolbar.cs b/SystemHeat/SystemHeat/UI/ReactorUI/ReactorToolbar.cs index d807559..3320bb1 100644 --- a/SystemHeat/SystemHeat/UI/ReactorUI/ReactorToolbar.cs +++ b/SystemHeat/SystemHeat/UI/ReactorUI/ReactorToolbar.cs @@ -48,13 +48,17 @@ public void Start() } protected void CreateToolbarPanel() { - if (SystemHeatSettings.DebugUI) - Utils.Log("[ReactorToolbar]: Creating toolbar panel"); - GameObject newUIPanel = (GameObject)Instantiate(SystemHeatUILoader.ReactorToolbarPanelPrefab, Vector3.zero, Quaternion.identity); - newUIPanel.transform.SetParent(UIMasterController.Instance.appCanvas.transform); - newUIPanel.transform.localPosition = Vector3.zero; - reactorPanel = newUIPanel.AddComponent(); - reactorPanel.SetVisible(false); + if (reactorPanel == null) + + { + if (SystemHeatSettings.DebugUI) + Utils.Log("[ReactorToolbar]: Creating toolbar panel"); + GameObject newUIPanel = (GameObject)Instantiate(SystemHeatUILoader.ReactorToolbarPanelPrefab, Vector3.zero, Quaternion.identity); + newUIPanel.transform.SetParent(UIMasterController.Instance.appCanvas.transform); + newUIPanel.transform.localPosition = Vector3.zero; + reactorPanel = newUIPanel.AddComponent(); + reactorPanel.SetVisible(false); + } } protected void DestroyToolbarPanel() { @@ -79,8 +83,8 @@ void Update() if (HighLogic.LoadedSceneIsFlight) { - - reactorPanel.rect.position = stockToolbarButton.GetAnchorUL() - new Vector3(reactorPanel.rect.rect.width, reactorPanel.rect.rect.height, 0f); + if (reactorPanel && stockToolbarButton) + reactorPanel.rect.position = stockToolbarButton.GetAnchorUL() - new Vector3(reactorPanel.rect.rect.width, reactorPanel.rect.rect.height, 0f); } if (HighLogic.LoadedSceneIsEditor) { @@ -92,18 +96,57 @@ void Update() } public void OnVesselChanged(Vessel v) { - // Refresh reactors - ClearReactors(); - FindReactors(v); + Utils.Log($"[ReactorToolbar]: Changed to vessel {v}"); + ResetToolbarPanel(); } public void ClearReactors() { + if (reactorPanel != null) reactorPanel.ClearReactors(); } - public void FindReactors(Vessel ves) + + void ResetToolbarPanel() + { + // Refresh reactors + ClearReactors(); + if (FindAllReactors(FlightGlobals.ActiveVessel).Count > 0) + { + Utils.Log($"[ReactorToolbar]: Found reactors"); + if (stockToolbarButton == null) + { + Utils.Log($"[ReactorToolbar]: Creating toolbar for reactors"); + stockToolbarButton = ApplicationLauncher.Instance.AddModApplication( + OnToolbarButtonToggle, + OnToolbarButtonToggle, + DummyVoid, + DummyVoid, + DummyVoid, + DummyVoid, + ApplicationLauncher.AppScenes.FLIGHT, + (Texture)GameDatabase.Instance.GetTexture(toolbarUIIconURLOff, false)); + } + CreateToolbarPanel(); + FindReactors(FlightGlobals.ActiveVessel); + } + else + { + Utils.Log($"[ReactorToolbar]: No reactors"); + if (stockToolbarButton != null) + { + Utils.Log($"[ReactorToolbar]: Removing toolbar for reactors"); + ApplicationLauncher.Instance.RemoveModApplication(stockToolbarButton); + stockToolbarButton = null; + } + if (reactorPanel != null) + reactorPanel.SetVisible(false); + } + + } + + List FindAllReactors(Vessel ves) { if (SystemHeatSettings.DebugUI) Utils.Log($"[ReactorToolbar]: Detecting reactors on {ves}"); @@ -128,14 +171,24 @@ public void FindReactors(Vessel ves) } } } + return unsortedReactorList; + } + public void FindReactors(Vessel ves) + { + + List foundReactors = FindAllReactors(ves); if (SystemHeatSettings.DebugUI) - Utils.Log($"[ReactorToolbar]: found {unsortedReactorList.Count} reactors"); + Utils.Log($"[ReactorToolbar]: found {foundReactors.Count} reactors"); if (reactorPanel) - foreach (PartModule reactor in unsortedReactorList) + { + foreach (PartModule reactor in foundReactors) { reactorPanel.AddReactor(reactor); } + + } + } #region Stock Toolbar Methods @@ -166,8 +219,11 @@ protected void OnGUIAppLauncherReady() { showWindow = false; if (SystemHeatSettings.DebugUI) - Utils.Log("[UIReactorToolbar App Launcher Ready"); - if (ApplicationLauncher.Ready && stockToolbarButton == null) + Utils.Log("[ReactorToolbar]: App Launcher Ready"); + + + + if (ApplicationLauncher.Ready && FindAllReactors(FlightGlobals.ActiveVessel).Count > 0 && stockToolbarButton == null) { stockToolbarButton = ApplicationLauncher.Instance.AddModApplication( OnToolbarButtonToggle, diff --git a/SystemHeat/SystemHeat/UI/ReactorUI/ReactorWidget.cs b/SystemHeat/SystemHeat/UI/ReactorUI/ReactorWidget.cs index 1f9f7a1..584945c 100644 --- a/SystemHeat/SystemHeat/UI/ReactorUI/ReactorWidget.cs +++ b/SystemHeat/SystemHeat/UI/ReactorUI/ReactorWidget.cs @@ -14,6 +14,14 @@ public class ReactorWidget: MonoBehaviour public RectTransform rect; public Text reactorName; public Toggle onToggle; + public Text onToggleLabel; + public Toggle chargeToggle; + + public GameObject spacer; + + public GameObject chargeElement; + public Slider chargeSlider; + public Image sliderFill; public Image warningIcon; public RectTransform iconRoot; @@ -39,13 +47,28 @@ void FindComponents() iconRoot = transform.FindDeepChild("Icons") as RectTransform; dataRoot = transform.FindDeepChild("DataPanel") as RectTransform; infoRoot = transform.FindDeepChild("InfoPanel") as RectTransform; + onToggleLabel = transform.FindDeepChild("OnLabel").GetComponent(); + + spacer = transform.FindDeepChild("Space").gameObject; + chargeElement = transform.FindDeepChild("ChargeArea").gameObject; + chargeToggle = transform.FindDeepChild("ChargeArea").GetComponent(); + chargeSlider = transform.FindDeepChild("Slider").GetComponent(); + sliderFill = transform.FindDeepChild("Fill").GetComponent(); headerButton.onClick.RemoveAllListeners(); onToggle.onValueChanged.RemoveAllListeners(); + chargeToggle.onValueChanged.RemoveAllListeners(); headerButton.onClick.AddListener(delegate { ToggleData(); }); onToggle.onValueChanged.AddListener(delegate { ToggleReactor(); }); + chargeToggle.onValueChanged.AddListener(delegate { ToggleCharge(); }); + + Localize(); + } + void Localize() + { + onToggleLabel.text = Localizer.Format("#LOC_SystemHeat_ReactorPanel_ReactorOnToggleLabel"); } public void SetReactor(PartModule m) { @@ -66,51 +89,80 @@ public void SetReactor(PartModule m) { iconRoot.gameObject.SetActive(true); iconRoot.FindDeepChild("FissionReactorIcon").gameObject.SetActive(true); - AddDataWidget("heatGenerated", "Heat Generated"); - AddDataWidget("powerGenerated", "Power Generated"); - AddDataWidget("lifetime", "Core Life"); - AddDataWidget("temperature", "Core Temperature"); + AddDataWidget("heatGenerated", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_HeatGeneratedTitle")); + AddDataWidget("powerGenerated", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_PowerGeneratedTitle")); + AddDataWidget("lifetime", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreLifeTitle")); + AddDataWidget("temperature", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreTemperatureTitle")); bool isOn = false; bool.TryParse(module.Fields.GetValue("Enabled").ToString(), out isOn); onToggle.isOn = isOn; + + spacer.SetActive(false); + chargeElement.SetActive(false); + } if (m.moduleName == "ModuleSystemHeatFissionEngine") { iconRoot.gameObject.SetActive(true); iconRoot.FindDeepChild("FissionEngineIcon").gameObject.SetActive(true); - AddDataWidget("heatGenerated", "Heat Generated"); - AddDataWidget("powerGenerated", "Power Generated"); - AddDataWidget("lifetime", "Core Life"); - AddDataWidget("temperature", "Core Temperature"); + AddDataWidget("heatGenerated", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_HeatGeneratedTitle")); + AddDataWidget("powerGenerated", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_PowerGeneratedTitle")); + AddDataWidget("lifetime", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreLifeTitle")); + AddDataWidget("temperature", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreTemperatureTitle")); bool isOn = false; bool.TryParse(module.Fields.GetValue("Enabled").ToString(), out isOn); onToggle.isOn = isOn; + spacer.SetActive(false); + chargeElement.SetActive(false); + } if (m.moduleName == "ModuleFusionEngine") { iconRoot.gameObject.SetActive(true); iconRoot.FindDeepChild("FusionEngineIcon").gameObject.SetActive(true); - AddDataWidget("heatGenerated", "Heat Generated"); - AddDataWidget("powerGenerated", "Power Generated"); - AddDataWidget("lifetime", "Core Life"); - AddDataWidget("temperature", "Core Temperature"); + AddDataWidget("heatGenerated", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_HeatGeneratedTitle")); + AddDataWidget("powerGenerated", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_PowerGeneratedTitle")); + AddDataWidget("lifetime", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreLifeTitle")); + AddDataWidget("temperature", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreTemperatureTitle")); bool isOn = false; + bool.TryParse(module.Fields.GetValue("Enabled").ToString(), out isOn); onToggle.isOn = isOn; + + bool chargeOn = false; + bool.TryParse(module.Fields.GetValue("Charging").ToString(), out chargeOn); + + spacer.SetActive(true); + chargeElement.SetActive(true); + if (chargeOn) + { + chargeToggle.isOn = chargeOn; + } } if (m.moduleName == "FusionReactor") { iconRoot.gameObject.SetActive(true); iconRoot.FindDeepChild("FusionReactorIcon").gameObject.SetActive(true); - AddDataWidget("heatGenerated", "Heat Generated"); - AddDataWidget("powerGenerated", "Power Generated"); - AddDataWidget("lifetime", "Core Life"); - AddDataWidget("temperature", "Core Temperature"); - bool isOn = false; - bool.TryParse(module.Fields.GetValue("Enabled").ToString(), out isOn); + AddDataWidget("heatGenerated", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_HeatGeneratedTitle")); + AddDataWidget("powerGenerated", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_PowerGeneratedTitle")); + AddDataWidget("lifetime", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreLifeTitle")); + AddDataWidget("temperature", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreTemperatureTitle")); + Utils.Log($"x"); + Utils.Log($"{spacer}"); + bool.TryParse(module.Fields.GetValue("Enabled").ToString(), out bool isOn); onToggle.isOn = isOn; + + bool.TryParse(module.Fields.GetValue("Charging").ToString(), out bool chargeOn); + Utils.Log($"{chargeElement}"); + Utils.Log($"{chargeToggle}"); + spacer.SetActive(true); + chargeElement.SetActive(true); + if (chargeOn) + { + chargeToggle.isOn = chargeOn; + } } } @@ -148,6 +200,25 @@ public void ToggleReactor() } } + } + + public void ToggleCharge() + { + if (chargeToggle.isOn) + { + if (module.moduleName == "FusionReactor" || module.moduleName == "ModuleFusionEngine") + { + module.Invoke("EnableCharging", 0f); + } + } + else + { + if (module.moduleName == "FusionReactor" || module.moduleName == "ModuleFusionEngine") + { + module.Invoke("DisableCharging", 0f); + } + } + } protected void FixedUpdate() { @@ -155,33 +226,48 @@ protected void FixedUpdate() if (module.moduleName == "FusionReactor" || module.moduleName == "ModuleFusionEngine") { nominalTemp = float.Parse(module.Fields.GetValue("SystemOutletTemperature").ToString()); - datafields["heatGenerated"].SetValue(String.Format("{0:F0} kW", float.Parse(module.Fields.GetValue("SystemPower").ToString()))); - datafields["powerGenerated"].SetValue(String.Format("{0:F0} kW", float.Parse(module.Fields.GetValue("CurrentPowerProduced").ToString() ))); - datafields["lifetime"].SetValue(String.Format("{0}", module.Fields.GetValue("FuelInput"))); - datafields["temperature"].SetValue(String.Format("{0:F0} K", heatModule.LoopTemperature.ToString("F0"))); + datafields["heatGenerated"].SetValue(Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_HeatGenerated", float.Parse(module.Fields.GetValue("SystemPower").ToString()).ToString("F0") ) ); + datafields["powerGenerated"].SetValue(Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_PowerGenerated", float.Parse(module.Fields.GetValue("CurrentPowerProduced").ToString() ).ToString("F0"))); + datafields["lifetime"].SetValue(Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreLife", module.Fields.GetValue("FuelInput"))); + datafields["temperature"].SetValue(Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreTemperature", heatModule.LoopTemperature.ToString("F0"))); if (heatModule.LoopTemperature > nominalTemp) - datafields["temperature"].SetValue(String.Format("{0:F0} K!", heatModule.LoopTemperature.ToString("F0")), Color.red); + datafields["temperature"].SetValue(Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreTemperatureAlert", heatModule.LoopTemperature.ToString("F0")), Color.red); else - datafields["temperature"].SetValue(String.Format("{0:F0} K", heatModule.LoopTemperature.ToString("F0")), new Color(0.705f, 0.83f, 0.33f)); + datafields["temperature"].SetValue(Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreTemperature", heatModule.LoopTemperature.ToString("F0")), new Color(0.705f, 0.83f, 0.33f)); bool isOn = false; bool.TryParse(module.Fields.GetValue("Enabled").ToString(), out isOn); onToggle.isOn = isOn; + + + bool isCharge = false; + bool.TryParse(module.Fields.GetValue("Charging").ToString(), out isCharge); + chargeToggle.isOn = isCharge; + float chargeVal = (float)module.Fields.GetValue("CurrentCharge") / (float)module.Fields.GetValue("ChargeGoal"); + chargeSlider.value = chargeVal; + Color32 fillColor; + if (chargeVal < 1.0f) + HexColorField.HexToColor("#F67A28", out fillColor); + else + HexColorField.HexToColor("#B4D455", out fillColor); + + sliderFill.color = fillColor; + } if (module.moduleName == "ModuleSystemHeatFissionReactor" || module.moduleName == "ModuleSystemHeatFissionEngine") { nominalTemp = float.Parse(module.Fields.GetValue("NominalTemperature").ToString()); - datafields["heatGenerated"].SetValue(String.Format("{0:F0} kW", float.Parse(module.Fields.GetValue("CurrentHeatGeneration").ToString()))); - datafields["powerGenerated"].SetValue(String.Format("{0:F0} kW", float.Parse(module.Fields.GetValue("CurrentElectricalGeneration").ToString()))); - datafields["lifetime"].SetValue(String.Format("{0}", module.Fields.GetValue("FuelStatus"))); + datafields["heatGenerated"].SetValue(Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_HeatGenerated", float.Parse(module.Fields.GetValue("CurrentHeatGeneration").ToString()).ToString("F0") ) ); + datafields["powerGenerated"].SetValue(Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_PowerGenerated", float.Parse(module.Fields.GetValue("CurrentElectricalGeneration").ToString()).ToString("F0") )); + datafields["lifetime"].SetValue(Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreLife", module.Fields.GetValue("FuelStatus"))); if (heatModule.LoopTemperature > nominalTemp) - datafields["temperature"].SetValue(String.Format("{0:F0} K!", heatModule.LoopTemperature.ToString("F0")), Color.red); + datafields["temperature"].SetValue(Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreTemperatureAlert", heatModule.LoopTemperature.ToString("F0")), Color.red); else - datafields["temperature"].SetValue(String.Format("{0:F0} K", heatModule.LoopTemperature.ToString("F0")), new Color(0.705f, 0.83f, 0.33f)); + datafields["temperature"].SetValue(Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreTemperature", heatModule.LoopTemperature.ToString("F0")), new Color(0.705f, 0.83f, 0.33f)); bool isOn = false; bool.TryParse(module.Fields.GetValue("Enabled").ToString(), out isOn); @@ -199,7 +285,7 @@ protected void FixedUpdate() } public void ToggleData() { - Utils.Log($"{infoRoot.gameObject.activeSelf}"); + infoRoot.gameObject.SetActive(!infoRoot.gameObject.activeSelf); } public void SetVisible(bool state) { } diff --git a/SystemHeat/SystemHeat/UI/SystemHeatUI.cs b/SystemHeat/SystemHeat/UI/SystemHeatUI.cs index 49c4687..76a3502 100644 --- a/SystemHeat/SystemHeat/UI/SystemHeatUI.cs +++ b/SystemHeat/SystemHeat/UI/SystemHeatUI.cs @@ -104,6 +104,27 @@ protected void FindSimulator() Utils.Log($"[SystemHeatOverlay]: Located Flight data on vessel {FlightGlobals.ActiveVessel.vesselName}"); } } + protected bool HasHeatModules(Vessel ves) + { + + if (SystemHeatSettings.DebugUI) + Utils.Log($"[SystemHeatToolbar]: Detecting modules on {ves}"); + + + // Get all parts + List allParts = ves.parts; + for (int i = 0; i < allParts.Count; i++) + { + for (int j = 0; j < allParts[i].Modules.Count; j++) + { + if (allParts[i].Modules[j].moduleName == "ModuleSystemHeat") + { + return true; + } + } + } + return false; + } protected void FindSimulator(Vessel v) { if (HighLogic.LoadedSceneIsEditor) @@ -153,6 +174,7 @@ void Update() } if (toolbarPanel.loopPanel.activeSelf) toolbarPanel.rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 400f); + toolbarPanel.rect.position = stockToolbarButton.GetAnchorUL() - new Vector3(toolbarPanel.rect.rect.width, toolbarPanel.rect.rect.height, 0f); } if (HighLogic.LoadedSceneIsEditor) @@ -172,9 +194,50 @@ public void OnVesselChanged(Vessel v) SystemHeatOverlay.Instance.ClearPanels(); SystemHeatOverlay.Instance.AssignSimulator(simulator); + + if (toolbarPanel) toolbarPanel.AssignSimulator(simulator); - + + ResetToolbarPanel(); + } + + + void ResetToolbarPanel() + { + // Refresh reactors + + if (HasHeatModules(FlightGlobals.ActiveVessel)) + { + if (SystemHeatSettings.DebugUI) + Utils.Log($"[SystemHeatToolbar]: Found modules"); + if (stockToolbarButton == null) + { + Utils.Log($"[SystemHeatToolbar]: Creating toolbar button"); + stockToolbarButton = ApplicationLauncher.Instance.AddModApplication( + OnToolbarButtonToggle, + OnToolbarButtonToggle, + DummyVoid, + DummyVoid, + DummyVoid, + DummyVoid, + ApplicationLauncher.AppScenes.FLIGHT, + (Texture)GameDatabase.Instance.GetTexture(toolbarUIIconURLOff, false)); + } + } + else + { + Utils.Log($"[SystemHeatToolbar]: No modules"); + if (stockToolbarButton != null) + { + Utils.Log($"[SystemHeatToolbar]: Removing toolbar button"); + ApplicationLauncher.Instance.RemoveModApplication(stockToolbarButton); + stockToolbarButton = null; + } + if (toolbarPanel != null) + toolbarPanel.SetVisible(false); + } + } #region Stock Toolbar Methods public void OnDestroy() @@ -204,17 +267,18 @@ protected void OnGUIAppLauncherReady() showWindow = false; if (SystemHeatSettings.DebugUI) Utils.Log("[UI]: App Launcher Ready"); - if (ApplicationLauncher.Ready && stockToolbarButton == null) + if (ApplicationLauncher.Ready && stockToolbarButton == null) { - stockToolbarButton = ApplicationLauncher.Instance.AddModApplication( - OnToolbarButtonToggle, - OnToolbarButtonToggle, - DummyVoid, - DummyVoid, - DummyVoid, - DummyVoid, - ApplicationLauncher.AppScenes.VAB | ApplicationLauncher.AppScenes.SPH | ApplicationLauncher.AppScenes.FLIGHT, - (Texture)GameDatabase.Instance.GetTexture(toolbarUIIconURLOff, false)); + if (HighLogic.LoadedSceneIsFlight && HasHeatModules(FlightGlobals.ActiveVessel) || HighLogic.LoadedSceneIsEditor) + stockToolbarButton = ApplicationLauncher.Instance.AddModApplication( + OnToolbarButtonToggle, + OnToolbarButtonToggle, + DummyVoid, + DummyVoid, + DummyVoid, + DummyVoid, + ApplicationLauncher.AppScenes.VAB | ApplicationLauncher.AppScenes.SPH | ApplicationLauncher.AppScenes.FLIGHT, + (Texture)GameDatabase.Instance.GetTexture(toolbarUIIconURLOff, false)); } CreateToolbarPanel(); } diff --git a/SystemHeat/SystemHeat/UI/ToolbarPanel.cs b/SystemHeat/SystemHeat/UI/ToolbarPanel.cs index 65438aa..6b4a96b 100644 --- a/SystemHeat/SystemHeat/UI/ToolbarPanel.cs +++ b/SystemHeat/SystemHeat/UI/ToolbarPanel.cs @@ -6,6 +6,7 @@ using UnityEngine; using UnityEngine.UI; using KSP.UI; +using KSP.Localization; namespace SystemHeat.UI { @@ -26,6 +27,13 @@ public class ToolbarPanel: MonoBehaviour public GameObject simRateHeader; public GameObject simRateSliderObject; + protected Text simRateTitle; + protected Text overlayToggleTitle; + protected Text craftStatsTitle; + protected Text panelTitle; + protected Text loopsTitle; + protected Text settingsTitle; + protected Text totalIncomingFluxTitle; protected Text totalOutgoingFluxTitle; protected Text totalLoopsTitle; @@ -52,7 +60,14 @@ public void Awake() totalIncomingFluxTitle = transform.FindDeepChild("HeatGenerationTitle").GetComponent(); totalOutgoingFluxTitle = transform.FindDeepChild("HeatRejectionTitle").GetComponent(); + totalLoopsTitle = transform.FindDeepChild("LoopCountTitle").GetComponent(); + simRateTitle = transform.FindDeepChild("SimRateLabel").GetComponent(); + overlayToggleTitle = transform.FindDeepChild("OverlayLabel").GetComponent(); + craftStatsTitle = transform.FindDeepChild("StatsHeaderText").GetComponent(); + panelTitle = transform.FindDeepChild("PanelTitleText").GetComponent(); + loopsTitle = transform.FindDeepChild("LoopsHeaderText").GetComponent(); + settingsTitle = transform.FindDeepChild("SettingsHeaderText").GetComponent(); noLoopsText = transform.FindDeepChild("NoLoopText").GetComponent(); loopPanel = transform.FindDeepChild("PanelColumn2").gameObject; @@ -91,8 +106,25 @@ public void Awake() simRateSliderObject.gameObject.SetActive(false); } + Localize(); } + void Localize() + { + + totalIncomingFluxTitle.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_OutgoingFluxTitle"); + totalOutgoingFluxTitle.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_IncomingFluxTile"); + totalLoopsTitle.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_LoopCountTitle"); + loopsTitle.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_LoopsTitle"); + settingsTitle.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_SettingsTitle"); + craftStatsTitle.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_CraftStatsTitle"); + panelTitle.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_Title"); + + simRateTitle.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_SimulationRateTitle"); + overlayToggleTitle.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_OverlayToggle"); + + + } protected void Update() { if (simulator != null) @@ -127,8 +159,8 @@ protected void Update() } totalLoopsValue.text = simulator.HeatLoops.Count.ToString(); - totalOutgoingFluxValue.text = String.Format("{0:F0} kW", simulator.TotalHeatRejection); - totalIncomingFluxValue.text = String.Format("{0:F0} kW",simulator.TotalHeatGeneration); + totalOutgoingFluxValue.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_OutgoingFluxValue", simulator.TotalHeatRejection.ToString("F0")); + totalIncomingFluxValue.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_IncomingFluxValue", simulator.TotalHeatGeneration.ToString("F0")); } } void DestroyLoopWidgets() @@ -176,7 +208,7 @@ void PollLoopWidgets() public void OnSliderChange() { SystemHeatSettings.SimulationRateEditor = TimeWarp.fixedDeltaTime * rates[(int)simRateSlider.value]; - simRateLabel.text = String.Format("{0}x", rates[(int)simRateSlider.value]); + simRateLabel.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_SimulationRateValue", rates[(int)simRateSlider.value]); } public void SetVisible(bool state) { diff --git a/SystemHeat/SystemHeat/UI/ToolbarPanelLoopWidget.cs b/SystemHeat/SystemHeat/UI/ToolbarPanelLoopWidget.cs index a0d6d88..67cb05e 100644 --- a/SystemHeat/SystemHeat/UI/ToolbarPanelLoopWidget.cs +++ b/SystemHeat/SystemHeat/UI/ToolbarPanelLoopWidget.cs @@ -4,7 +4,7 @@ using System.Text; using UnityEngine.UI; using UnityEngine; -using JetBrains.Annotations; +using KSP.Localization; namespace SystemHeat.UI { @@ -43,8 +43,14 @@ void FindComponents() fluxTextValue = transform.FindDeepChild("FluxDataText").GetComponent(); overlayToggle.onValueChanged.AddListener(delegate { ToggleOverlay(); }); + + Localize(); + } + void Localize() + { + } - public void SetVisible(bool state) + public void SetVisible(bool state) { active = state; rect.gameObject.SetActive(state); @@ -57,10 +63,10 @@ public void SetLoop(int loopID) trackedLoopID = loopID; if (simulator != null) { - overlayToggleText.text = String.Format("Loop {0}", trackedLoopID.ToString()); + overlayToggleText.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_LoopTitle", trackedLoopID.ToString()); swatch.color = SystemHeatSettings.GetLoopColor(trackedLoopID); - fluxTextHeader.text = String.Format(" Net Flux"); - temperatureTextHeader.text = String.Format(" Temperature"); + fluxTextHeader.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_LoopFluxTitle"); + temperatureTextHeader.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_LoopTemperatureTitle"); } } public void AssignSimulator(SystemHeatSimulator sim) @@ -72,17 +78,28 @@ void Update() { if (trackedLoopID != -1 && simulator != null && simulator.HeatLoops.ContainsKey(trackedLoopID)) { - - temperatureTextValue.text = String.Format("{0}/{1} K", simulator.HeatLoops[trackedLoopID].Temperature.ToString("F0"), simulator.HeatLoops[trackedLoopID].NominalTemperature.ToString("F0")); - - fluxTextValue.text = String.Format("{0} kW", simulator.HeatLoops[trackedLoopID].NetFlux.ToString("F1")); + + temperatureTextValue.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_LoopTemperatureValue", + simulator.HeatLoops[trackedLoopID].Temperature.ToString("F0"), + simulator.HeatLoops[trackedLoopID].NominalTemperature.ToString("F0")); + + string prefix = ""; + if (simulator.HeatLoops[trackedLoopID].NetFlux == 0f) + prefix = ""; + if (simulator.HeatLoops[trackedLoopID].NetFlux > 0f) + prefix = "+"; + if (simulator.HeatLoops[trackedLoopID].NetFlux < 0f) + prefix = ""; + + fluxTextValue.text = Localizer.Format("#LOC_SystemHeat_ToolbarPanel_LoopFluxValue", prefix, + simulator.HeatLoops[trackedLoopID].NetFlux.ToString("F1")); if (simulator.HeatLoops[trackedLoopID].Temperature > simulator.HeatLoops[trackedLoopID].NominalTemperature) { Color32 c; HexColorField.HexToColor("fe8401", out c); temperatureTextValue.color = c; - } + } else { Color32 c; @@ -106,7 +123,7 @@ void Update() } public void ToggleOverlay() { - SystemHeatOverlay.Instance.SetVisible(overlayToggle.isOn, trackedLoopID); + SystemHeatOverlay.Instance.SetVisible(overlayToggle.isOn, trackedLoopID); } } } diff --git a/changelog.txt b/changelog.txt index 83696c9..7487b07 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,10 @@ +v0.1.3 +------ +- Worked on localization of things not previously localized (reactor panel, toolbar panel, ModuleHeatSink) +- Added a UI button to charge fusion reactors in the reactor panel +- Reactor/Heat toolbar buttons should now hide when looking at a vessel without reactors or heat modules +- More random bugfixes + v0.1.1 ------ - Fixed issue with map vector camera not being reset when entering map view (messing up orbit lines) diff --git a/readme.txt b/readme.txt index 3788f01..0347631 100644 --- a/readme.txt +++ b/readme.txt @@ -1,5 +1,5 @@ ================ -SystemHeat 0.1.2 +SystemHeat 0.1.3 ================ TBW