diff --git a/planet/Objects.ocd/Structures.ocd/Pump.ocd/Script.c b/planet/Objects.ocd/Structures.ocd/Pump.ocd/Script.c index 060810de6..6897bf2d8 100644 --- a/planet/Objects.ocd/Structures.ocd/Pump.ocd/Script.c +++ b/planet/Objects.ocd/Structures.ocd/Pump.ocd/Script.c @@ -17,6 +17,8 @@ static const PUMP_Menu_Action_Switch_On = "on"; static const PUMP_Menu_Action_Switch_Off = "off"; static const PUMP_Menu_Action_Description = "description"; +static const PUMP_Menu_Action_Material_Enable = "material_on"; +static const PUMP_Menu_Action_Material_Disable = "material_off"; local animation; // animation handle @@ -127,7 +129,7 @@ func GetPumpMenuEntry(proplist custom_entry, symbol, string text, int priority, public func GetInteractionMenus(object clonk) { var menus = _inherited(clonk, ...) ?? []; - var prod_menu = + var control_menu = { title = "$Control$", entries_callback = this.GetPumpControlMenuEntries, @@ -137,7 +139,18 @@ public func GetInteractionMenus(object clonk) BackgroundColor = RGB(0, 50, 50), Priority = 20 }; - PushBack(menus, prod_menu); + PushBack(menus, control_menu); + var materials_menu = + { + title = "$PumpMaterials$", + entries_callback = this.GetPumpMaterialsMenuEntries, + callback = "OnPumpMaterials", + callback_hover = "OnPumpMaterialsHover", + callback_target = this, + BackgroundColor = RGB(0, 50, 50), + Priority = 25 + }; + PushBack(menus, materials_menu); return menus; } @@ -732,7 +745,7 @@ public func SetMaterialSelection(array mats) return; } -private func RemoveFromMaterialSeleciton(id mat) +private func RemoveFromMaterialSelection(id mat) { return RemoveArrayValue(pump_materials, mat); } @@ -754,6 +767,57 @@ private func IsInMaterialSelection(/* any */ mat) return false; } +public func GetPumpMaterialsMenuEntries(object clonk) +{ + var menu_entries = []; + // Add materials to the selection. + var index = 0, def; + while (def = GetDefinition(index++)) + { + if (def->~IsLiquid() && def != Library_Liquid) + { + var act = PUMP_Menu_Action_Material_Disable; + var status = Icon_Ok; + var enabled = IsInMaterialSelection(def); + if (!enabled) + { + act = PUMP_Menu_Action_Material_Enable; + status = Icon_Cancel; + } + PushBack(menu_entries, + {symbol = def, extra_data = act, + custom = + { + Right = "2em", Bottom = "2em", + BackgroundColor = {Std = 0, OnHover = 0x50ff0000}, + Priority = index, + status = {Right = "1em", Top = "1em", Symbol = status}, + image = {Symbol = def} + }} + ); + } + } + return menu_entries; +} + +public func OnPumpMaterialsHover(id symbol, string action, desc_menu_target, menu_id) +{ + var text = ""; + if (action == PUMP_Menu_Action_Material_Enable) text = Format("$MsgEnableMaterial$", symbol->GetLiquidType()); + else if (action == PUMP_Menu_Action_Material_Disable) text = Format("$MsgDisableMaterial$", symbol->GetLiquidType()); + else if (action == PUMP_Menu_Action_Description) text = this.Description; + GuiUpdateText(text, menu_id, 1, desc_menu_target); +} + +public func OnPumpMaterials(symbol_or_object, string action, bool alt) +{ + if (action == PUMP_Menu_Action_Material_Enable) + AddToMaterialSelection(symbol_or_object); + else if (action == PUMP_Menu_Action_Material_Disable) + RemoveFromMaterialSelection(symbol_or_object); + UpdateInteractionMenus(this.GetPumpMaterialsMenuEntries); +} + /*-- Properties --*/ diff --git a/planet/Objects.ocd/Structures.ocd/Pump.ocd/StringTblDE.txt b/planet/Objects.ocd/Structures.ocd/Pump.ocd/StringTblDE.txt index 365b1c873..79fb932bc 100644 --- a/planet/Objects.ocd/Structures.ocd/Pump.ocd/StringTblDE.txt +++ b/planet/Objects.ocd/Structures.ocd/Pump.ocd/StringTblDE.txt @@ -28,4 +28,8 @@ MsgAirPipeProhibited=Die Pumpe hat bereits ein Abflussrohr, es ist kein Platz f MsgCreatedSource=Zuflussrohr angeschlossen. MsgCreatedDrain=Abflussrohr angeschlossen. MsgCreatedAirDrain=Luftrohr angeschlossen. -MsgHasPipes=Die Pumpe hat schon ein Zu- und Abflussrohr. \ No newline at end of file +MsgHasPipes=Die Pumpe hat schon ein Zu- und Abflussrohr. + +PumpMaterials=Pumpe Materialien +MsgEnableMaterial=Schalte das Pumpen von Materiale %s ein. +MsgDisableMaterial=Schalte das Pumpen von Materiale %s aus. \ No newline at end of file diff --git a/planet/Objects.ocd/Structures.ocd/Pump.ocd/StringTblUS.txt b/planet/Objects.ocd/Structures.ocd/Pump.ocd/StringTblUS.txt index 364e6a502..b6d157f5d 100644 --- a/planet/Objects.ocd/Structures.ocd/Pump.ocd/StringTblUS.txt +++ b/planet/Objects.ocd/Structures.ocd/Pump.ocd/StringTblUS.txt @@ -28,4 +28,8 @@ MsgAirPipeProhibited=Pump already has a drain pipe and cannot take an air pipe. MsgCreatedSource=Connected source pipe. MsgCreatedDrain=Connected drain pipe. MsgCreatedAirDrain=Connected air pipe. -MsgHasPipes=Pump already has a source and a drain pipe. \ No newline at end of file +MsgHasPipes=Pump already has a source and a drain pipe. + +PumpMaterials=Pump Materials +MsgEnableMaterial=Enable the pumping of material %s. +MsgDisableMaterial=Disable the pumping of material %s. \ No newline at end of file diff --git a/planet/Tests.ocf/LiquidSystem.ocs/Script.c b/planet/Tests.ocf/LiquidSystem.ocs/Script.c index 5013c683e..91408eaf1 100644 --- a/planet/Tests.ocf/LiquidSystem.ocs/Script.c +++ b/planet/Tests.ocf/LiquidSystem.ocs/Script.c @@ -58,7 +58,7 @@ protected func InitializePlayer(int plr) // Add test control effect. var effect = AddEffect("IntTestControl", nil, 100, 2); - effect.testnr = 2; + effect.testnr = 1; effect.launched = false; effect.plr = plr; return; @@ -193,6 +193,7 @@ global func Test1_Completed() global func Test1_OnFinished() { RemoveAll(Find_Or(Find_ID(Foundry), Find_ID(Pump), Find_ID(Loam))); + RestoreWaterLevels(); return; } @@ -232,7 +233,8 @@ global func Test2_Completed() global func Test2_OnFinished() { - RemoveAll(Find_Or(Find_ID(Foundry), Find_ID(Pump))); + RemoveAll(Find_Or(Find_ID(Foundry), Find_ID(Pump), Find_ID(Pipe))); + RestoreWaterLevels(); return; } @@ -275,6 +277,7 @@ global func Test3_Completed() global func Test3_OnFinished() { RemoveAll(Find_Or(Find_ID(SteamEngine), Find_ID(Pump), Find_ID(Pipe))); + RestoreWaterLevels(); return; } @@ -287,7 +290,7 @@ global func RestoreWaterLevels() DrawMaterialQuad("Water", 144, 168, 208 + 1, 168, 208 + 1, 304, 144, 304, true); for (var x = 216; x <= 280; x++) for (var y = 24; y <= 120; y++) - if (GetMaterial(x, y) == Material("Water")) + if (GetMaterial(x, y) != Material("BrickSoft")) ClearFreeRect(x, y, 1, 1); return; } @@ -296,7 +299,7 @@ global func RemoveWater() { for (var x = 144; x <= 208 + 1; x++) for (var y = 168; y <= 304; y++) - if (GetMaterial(x, y) == Material("Water")) + if (GetMaterial(x, y) != Material("BrickSoft")) ClearFreeRect(x, y, 1, 1); return; }