From 6fde56332f5d1ce172b7526f06ad524549f45752 Mon Sep 17 00:00:00 2001
From: johns <>
Date: Sun, 11 Jun 2000 21:56:23 +0000
Subject: [PATCH] Showing only enery bars for selected units (configurable)
 from Iuri Fiedoruk

---
 doc/ChangeLog.html       |  5 ++++-
 src/include/unit.h       |  5 +++--
 src/stratagus/script.cpp | 12 ++++++++++++
 src/unit/unit_draw.cpp   | 10 ++++++++++
 4 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/doc/ChangeLog.html b/doc/ChangeLog.html
index fc0fb8744..4f797aef5 100644
--- a/doc/ChangeLog.html
+++ b/doc/ChangeLog.html
@@ -504,8 +504,11 @@
     <LI>Fixed bug: Repairing buildings already at max HP from David Slimp.
     <LI>Command...Fast=1 removed, use now ResetPath.
     <LI>Prepared all calls for handling the new return codes of the pathfinder.
-    <LI>Implemented first part of Select Scenario requesters.
+    <LI>Implemented first part of Select Scenario requesters from ari.
     <LI>Enabled real 24bpp mode.
+    <LI>New horizontal energy bars from Iuri Fiedoruk.
+    <LI>Removed old code for unit management and network.
+    <LI>New code for automatic target choose.
     <LI>+++
     </UL>
 
diff --git a/src/include/unit.h b/src/include/unit.h
index bf924b822..429f7dd71 100644
--- a/src/include/unit.h
+++ b/src/include/unit.h
@@ -333,9 +333,10 @@ extern int ShowHealthBar;		/// Flag: show health bar
 extern int ShowHealthDot;		/// Flag: show health dot
 extern int ShowManaBar;			/// Flag: show mana bar
 extern int ShowManaDot;			/// Flag: show mana dot
-extern int ShowHealthHorizontal;       /// Flag: show health bar horizontal
-extern int ShowManaHorizontal;         /// Flag: show mana bar horizontal
+extern int ShowHealthHorizontal;	/// Flag: show health bar horizontal
+extern int ShowManaHorizontal;		/// Flag: show mana bar horizontal
 extern int ShowNoFull;			/// Flag: show no full health or mana
+extern int ShowEnergySelectedOnly;	/// Flag: show energy only for selected
 extern int DecorationOnTop;		/// Flag: show health and mana on top
 extern int ShowSightRange;		/// Flag: show right range
 extern int ShowReactRange;		/// Flag: show react range
diff --git a/src/stratagus/script.cpp b/src/stratagus/script.cpp
index 888315a78..49c0b066f 100644
--- a/src/stratagus/script.cpp
+++ b/src/stratagus/script.cpp
@@ -229,6 +229,17 @@ local SCM CclShowManaDot(void)
     return SCM_UNSPECIFIED;
 }
 
+/**
+**	Enable energy bars and dots only for selected units
+*/
+local SCM CclShowEnergySelected(void)
+{
+    ShowEnergySelectedOnly=1;
+
+    return SCM_UNSPECIFIED;
+}
+
+
 /**
 **	Enable display of full bars/dots.
 */
@@ -906,6 +917,7 @@ global void CclInit(void)
 
     init_subr_0("show-mana-bar",CclShowManaBar);
     init_subr_0("show-mana-dot",CclShowManaDot);
+    init_subr_0("show-energy-selected-only",CclShowEnergySelected);
     init_subr_0("show-full",CclShowFull);
     init_subr_0("show-no-full",CclShowNoFull);
     init_subr_0("decoration-on-top",CclDecorationOnTop);
diff --git a/src/unit/unit_draw.cpp b/src/unit/unit_draw.cpp
index e8136524e..4b8ac195e 100644
--- a/src/unit/unit_draw.cpp
+++ b/src/unit/unit_draw.cpp
@@ -58,6 +58,8 @@ global int ShowOrders;			/// Flag: show orders of unit on map
 global int ShowHealthHorizontal=1;
     /// Flag: health horizontal instead of vertical
 global int ShowManaHorizontal=1;
+    /// Flag: show bars and dot energy only for selected
+global int ShowEnergySelectedOnly; 
 
 // FIXME: not all variables of this file are here
 // FIXME: perhaps split this file into two?
@@ -344,6 +346,14 @@ local void DrawDecoration(Unit* unit,const UnitType* type,int x,int y)
     int color;
     UnitStats* stats;
 
+
+    //
+    //	Only for selected units?
+    //
+    if( ShowEnergySelectedOnly && !unit->Selected ) {
+	return;
+    }
+
     //
     //	Health bar on left side of unit.
     //