Permalink
Browse files

pump: add interaction menu entries for air pipes

  • Loading branch information...
MDT-Maikel committed Jan 13, 2018
1 parent dc54162 commit eb24079b2fbbd2bb1389c0ca61661b252c575e38
@@ -121,7 +121,7 @@ public func GetPipeControlMenuEntries(object clonk)
PushBack(menu_entries, GetTankMenuEntry(neutral_pipe, "$MsgConnectNeutral$", 3, LIBRARY_TANK_Menu_Action_Add_Neutral, RGB(80, 80, 120)));
if (IsAllowedSwapSourceDrain())
- PushBack(menu_entries, GetTankMenuEntry(Icon_Swap, "$MsgSwapSourceDrain$", 4, LIBRARY_TANK_Menu_Action_Swap_SourceDrain, nil));
+ PushBack(menu_entries, GetTankMenuEntry(Icon_Swap, "$MsgSwapSourceDrain$", 10, LIBRARY_TANK_Menu_Action_Swap_SourceDrain, nil));
return menu_entries;
}
@@ -179,6 +179,70 @@ private func SetInfoMessage(string msg)
UpdateInteractionMenus(this.GetPumpControlMenuEntries);
}
+static const LIBRARY_TANK_Menu_Action_Cut_AirPipe = "cutairpipe";
+static const LIBRARY_TANK_Menu_Action_Add_AirPipe = "addairpipe";
+
+// Extend liquid tank connection interface to air pipes.
+public func GetPipeControlMenuEntries(object clonk)
+{
+ var menu_entries = inherited(clonk, ...);
+
+ var drain_pipe = GetDrainPipe();
+ // Modify cut drain pipe menu entry for air pipe.
+ if (drain_pipe && !drain_pipe->QueryCutLineConnection(this) && drain_pipe->IsAirPipe())
+ {
+ for (var entry in menu_entries)
+ {
+ if (entry.extra_data == LIBRARY_TANK_Menu_Action_Cut_Drain)
+ {
+ entry.extra_data = LIBRARY_TANK_Menu_Action_Cut_AirPipe;
+ entry.Priority = 4;
+ entry.custom.image.BackgroundColor = RGB(0, 153, 255);
+ entry.custom.text.Text = "$MsgCutAirPipe$";
+ break;
+ }
+ }
+ }
+
+ // Add attach air pipe menu entry.
+ var air_pipe = FindAvailablePipe(clonk, Find_Func("IsAirPipe"));
+ if (!drain_pipe && air_pipe)
+ PushBack(menu_entries, GetTankMenuEntry(air_pipe, "$MsgConnectAirPipe$", 4, LIBRARY_TANK_Menu_Action_Add_AirPipe, RGB(0, 153, 255)));
+ return menu_entries;
+}
+
+public func OnPipeControlHover(id symbol, string action, desc_menu_target, menu_id)
+{
+ if (action == LIBRARY_TANK_Menu_Action_Cut_AirPipe)
+ {
+ GuiUpdateText("$DescCutAirPipe$", menu_id, 1, desc_menu_target);
+ return;
+ }
+ if (action == LIBRARY_TANK_Menu_Action_Add_AirPipe)
+ {
+ GuiUpdateText("$DescConnectAirPipe$", menu_id, 1, desc_menu_target);
+ return;
+ }
+ return inherited(symbol, action, desc_menu_target, menu_id, ...);
+}
+
+public func OnPipeControl(symbol_or_object, string action, bool alt)
+{
+ if (action == LIBRARY_TANK_Menu_Action_Cut_AirPipe)
+ {
+ this->DoCutPipe(GetDrainPipe());
+ UpdateInteractionMenus(this.GetPipeControlMenuEntries);
+ return;
+ }
+ if (action == LIBRARY_TANK_Menu_Action_Add_AirPipe)
+ {
+ this->DoConnectPipe(symbol_or_object, PIPE_STATE_Air);
+ UpdateInteractionMenus(this.GetPipeControlMenuEntries);
+ return;
+ }
+ return inherited(symbol_or_object, action, alt, ...);
+}
+
/*-- Pipe control --*/
@@ -33,4 +33,9 @@ MsgHasPipes=Die Pumpe hat schon ein Zu- und Abflussrohr.
PumpMaterials=Pumpe Materialien
MsgEnableMaterial=Schalte das Pumpen von Material %s ein.
-MsgDisableMaterial=Schalte das Pumpen von Material %s aus.
+MsgDisableMaterial=Schalte das Pumpen von Material %s aus.
+
+MsgCutAirPipe=Luftrohr trennen
+MsgConnectAirPipe=Luftrohr anschließen
+DescCutAirPipe=Entfernt das Luftrohr.
+DescConnectAirPipe=Schließt ein Luftrohr an.
@@ -33,4 +33,9 @@ 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.
+MsgDisableMaterial=Disable the pumping of material %s.
+
+MsgCutAirPipe=Cut off air pipe
+MsgConnectAirPipe=Connect air pipe
+DescCutAirPipe=Removes the air pipe.
+DescConnectAirPipe=Connects an air pipe.

0 comments on commit eb24079

Please sign in to comment.