Subject: [PATCH] Add an electricity tab to the factory window

Power stations show no electricity figures in their info window. The only place
the numbers exist at all is the "Power (MW)" curve on the chart tab, which gives
the monthly average and never what the plant is doing right now.

As requested in the thread, this does NOT grow the production section - the
factory window is already too big. The figures get a tab of their own, added
only when the factory is_electricity_producer(), reusing the conditional-tab
pattern the window already uses for its "Details" tab.

It adds NO new translation strings. The transformer window (pumpe_t::info())
already shows exactly these figures for exactly this factory, so the tab reuses
its keys verbatim:

  Net ID: %p            the powernet; absent when no transformer is connected
  Generation: %.0f MW   get_power_supply(), the capacity offered right now
  Power (MW): %.0f      get_power(), what the net actually draws
  Usage: %.0f %%        the net's normalised demand

"Power (MW)" is the chart's own label for FAB_POWER, and FAB_POWER is booked as
get_power(), so tab and curve name the same quantity. "Usage" is the net's
normal_demand, which is by definition get_power()/get_power_supply() - the same
ratio, already named by the engine. The generic "Status" key was not reused: it
translates in a stops-only context ("Stop status").

The text is built by a new fabrik_t::info_power(), mirroring the existing
info_prod()/info_conn(); the window refreshes it through its existing per-frame
update_components(). There is no division anywhere (only shifts and one
precomputed fixed-point value), and the net lines are skipped when no
transformer is connected.

Separately, a contrast tweak: the three electricity curves on the chart are all
green and are told apart by brightness alone. The two closest were the max-boost
reference (137) and the demand reference (COL_DARK_GREEN, 136); max-boost now
uses 140, the pure green of the 136..143 ramp, which is as far as the ramp
allows from both. This is a legibility improvement, not a bug fix - the old
colours were distinct, just close.

No change to the simulation, economy, power rules, savegames, serialisation,
network sync or paksets. info_power() is const and read-only; no new persistent
data, no new getters, no powernet_t changes.
---
diff --git a/src/simutrans/gui/fabrik_info.cc b/src/simutrans/gui/fabrik_info.cc
index 420aad2..67b6e5f 100644
--- a/src/simutrans/gui/fabrik_info.cc
+++ b/src/simutrans/gui/fabrik_info.cc
@@ -79,6 +79,7 @@ fabrik_info_t::fabrik_info_t(fabrik_t* fab_, const gebaeude_t* gb) :
 	view(scr_size( max(64, gfx->get_base_tile_raster_width()), max(56, (gfx->get_base_tile_raster_width() * 7) / 8))),
 	prod(&prod_buf),
 	txt(&info_buf),
+	power(&power_buf),
 	scroll_info(&container_info)
 {
 	if (fab) {
@@ -171,6 +172,16 @@ void fabrik_info_t::init(fabrik_t* fab_, const gebaeude_t* gb)
 	chart.set_factory(fab);
 	switch_mode.take_tabs(chart.get_tab_panel());
 
+	// electricity figures in a tab of their own: only a power station has any,
+	// and the window is crowded enough without them
+	if(  fab->get_desc()->is_electricity_producer()  ) {
+		switch_mode.add_tab(&container_power, translator::translate("Electricity"));
+		container_power.set_table_layout(1,0);
+		container_power.add_component(&power);
+		fab->info_power(power_buf);
+		power.recalc_size();
+	}
+
 	// factory description in tab
 	{
 		bool add_tab = false;
@@ -311,6 +322,9 @@ void fabrik_info_t::update_components()
 	// update texts
 	fab->info_prod( prod_buf );
 	fab->info_conn( info_buf );
+	if(  fab->get_desc()->is_electricity_producer()  ) {
+		fab->info_power( power_buf );
+	}
 
 	// consumers
 	if(  fab->get_consumer().get_count() != old_consumers_count ) {
diff --git a/src/simutrans/gui/fabrik_info.h b/src/simutrans/gui/fabrik_info.h
index b503d10..86e8acd 100644
--- a/src/simutrans/gui/fabrik_info.h
+++ b/src/simutrans/gui/fabrik_info.h
@@ -37,7 +37,7 @@ class fabrik_info_t : public gui_frame_t, public action_listener_t
 private:
 	fabrik_t *fab;
 
-	cbuffer_t info_buf, prod_buf, details_buf;
+	cbuffer_t info_buf, prod_buf, details_buf, power_buf;
 
 	factory_chart_t chart;
 
@@ -46,7 +46,7 @@ private:
 	char fabname[256];
 	gui_textinput_t input;
 
-	gui_textarea_t prod, txt;
+	gui_textarea_t prod, txt, power;
 	gui_colorbox_t indicator_color;
 
 	gui_tab_panel_t switch_mode;
@@ -54,7 +54,7 @@ private:
 	gui_image_t boost_electric, boost_passenger, boost_mail;
 
 
-	gui_aligned_container_t container_info, container_details;
+	gui_aligned_container_t container_info, container_details, container_power;
 
 	gui_aligned_container_t all_suppliers, all_consumers, all_stops, all_cities;
 	uint32 old_suppliers_count, old_consumers_count, old_stops_count, old_cities_count;
diff --git a/src/simutrans/gui/factory_chart.cc b/src/simutrans/gui/factory_chart.cc
index e2baee4..b4156ff 100644
--- a/src/simutrans/gui/factory_chart.cc
+++ b/src/simutrans/gui/factory_chart.cc
@@ -89,7 +89,11 @@ static const gui_chart_t::convert_proc ref_convert[MAX_FAB_REF_LINE] =
 
 static const uint8 ref_color[MAX_FAB_REF_LINE] =
 {
-	137, COL_LIGHT_BLUE, COL_LIGHT_RED,
+	// max boost electric: 140 is the pure green of the 136..143 ramp, as far as the
+	// ramp allows from both the demand line (COL_DARK_GREEN) and the boost curve
+	// (COL_LIGHT_GREEN) - all three are electricity, so all three are green, and
+	// only the brightness tells them apart.
+	140, COL_LIGHT_BLUE, COL_LIGHT_RED,
 	COL_DARK_GREEN, COL_SOFT_BLUE, COL_OPERATION
 };
 
diff --git a/src/simutrans/simfab.cc b/src/simutrans/simfab.cc
index f479f02..4b5f369 100644
--- a/src/simutrans/simfab.cc
+++ b/src/simutrans/simfab.cc
@@ -37,6 +37,7 @@
 #include "dataobj/translator.h"
 #include "dataobj/loadsave.h"
 #include "dataobj/pakset_manager.h"
+#include "dataobj/powernet.h"
 
 #include "descriptor/factory_desc.h"
 #include "builder/hausbauer.h"
@@ -3063,6 +3064,33 @@ void fabrik_t::info_prod(cbuffer_t& buf) const
 }
 
 
+void fabrik_t::info_power(cbuffer_t& buf) const
+{
+	buf.clear();
+
+	// The supply is fed into the net by this factory's own transformer (a pumpe_t);
+	// same lookup as get_power_supply(). Without one the plant feeds no net at all,
+	// and get_power_supply() is 0, so only the net lines have to be left out.
+	pumpe_t *const trans = transformers.empty() ? NULL : dynamic_cast<pumpe_t *>(transformers.front());
+	powernet_t *const net = trans ? trans->get_net() : NULL;
+
+	if(  net  ) {
+		buf.printf(translator::translate("Net ID: %p"), net);
+		buf.append("\n");
+	}
+	// capacity offered to the net now, already scaled by production level and boost
+	buf.printf(translator::translate("Generation: %.0f MW"), (double)(get_power_supply() >> POWER_TO_MW));
+	buf.append("\n");
+	// what the net actually draws from this plant: supply * normalised demand,
+	// the same figure the "Power (MW)" curve records every month
+	buf.printf("%s: %.0f", translator::translate("Power (MW)"), (double)convert_power(get_power()));
+	if(  net  ) {
+		buf.append("\n");
+		buf.printf(translator::translate("Usage: %.0f %%"), (double)((100 * net->get_normal_demand()) >> powernet_t::FRACTION_PRECISION));
+	}
+}
+
+
 void fabrik_t::info_conn(cbuffer_t& buf) const
 {
 	buf.clear();
diff --git a/src/simutrans/simfab.h b/src/simutrans/simfab.h
index d248feb..023936a 100644
--- a/src/simutrans/simfab.h
+++ b/src/simutrans/simfab.h
@@ -616,6 +616,9 @@ public:
 	// infostring on targets/sources
 	void info_conn(cbuffer_t& buf) const;
 
+	// infostring on electricity output; only meaningful for is_electricity_producer()
+	void info_power(cbuffer_t& buf) const;
+
 	void rdwr(loadsave_t *file);
 
 	/*
