From f21117a1ebb837fec02b42a3808896d6edb4ccf6 Mon Sep 17 00:00:00 2001
From: Treeki <treeki@gmail.com>
Date: Thu, 20 Sep 2012 17:29:47 +0200
Subject: beginnings of the new HUD

---
 src/koopatlas/hud.cpp | 48 +++++++++++++++++++++++++++++++++++++++++-------
 src/koopatlas/hud.h   |  7 +++++++
 2 files changed, 48 insertions(+), 7 deletions(-)

(limited to 'src/koopatlas')

diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp
index bdd51b0..b7e40d2 100644
--- a/src/koopatlas/hud.cpp
+++ b/src/koopatlas/hud.cpp
@@ -16,17 +16,19 @@ dWMHud_c::dWMHud_c() {
 	layoutLoaded = false;
 }
 
+enum WMHudAnimation {
+	SHOW_LIVES = 0,
+	SHOW_HEADER,
+	SHOW_FOOTER
+};
+
 
 int dWMHud_c::onCreate() {
 	if (!layoutLoaded) {
-		bool gotFile = layout.loadArc("maphud.arc", false);
+		bool gotFile = layout.loadArc("MapHUD.arc", false);
 		if (!gotFile)
 			return false;
 
-		//static const char *brlanNames[3] = {"maphud_hitbutton.brlan", "maphud_in.brlan", "maphud_out.brlan"};
-		static const char *brlanNames[5] = {"maphud_hitbutton.brlan", "bottom_in.brlan", "bottom_out.brlan", "top_in.brlan", "top_out.brlan"};
-		static const char *groupNames[6] = {"B01_Button", "B02_Button", "A00_Window", "A00_Window", "A01_Window", "A01_Window"};
-
 		bool output = layout.build("maphud.brlyt");
 
 		if (!IsWideScreen()) {
@@ -39,10 +41,19 @@ int dWMHud_c::onCreate() {
 			layout.layout.rootPane->scale.y = 0.7711f;
 		}
 
-		layout.loadAnimations(brlanNames, 5);
-		layout.loadGroups(groupNames, (int[6]){0, 0, 1, 2, 3, 4}, 6);
+		static const char *brlanNames[2] = {"MapHUD_ShowMain.brlan", "MapHUD_ShowHeader.brlan"};
+		static const char *groupNames[3] = {"G_Lives", "G_Header", "G_Footer"};
+
+		layout.loadAnimations(brlanNames, 2);
+		layout.loadGroups(groupNames, (int[3]){0, 1, 0}, 3);
 		layout.disableAllAnimations();
 
+		layout.enableNonLoopAnim(SHOW_LIVES);
+		layout.enableNonLoopAnim(SHOW_FOOTER);
+
+		static const char *tbNames[2] = {"MenuButtonInfo", "ItemsButtonInfo"};
+		layout.setLangStrings(tbNames, (int[2]){12, 15}, 4, 2);
+
 		layoutLoaded = true;
 	}
 
@@ -51,11 +62,17 @@ int dWMHud_c::onCreate() {
 
 
 int dWMHud_c::onDelete() {
+	if (!layoutLoaded)
+		return true;
+
 	return layout.free();
 }
 
 
 int dWMHud_c::onExecute() {
+	if (!layoutLoaded)
+		return true;
+
 	layout.execAnimations();
 	layout.update();
 
@@ -64,8 +81,25 @@ int dWMHud_c::onExecute() {
 
 
 int dWMHud_c::onDraw() {
+	if (!layoutLoaded)
+		return true;
+
 	layout.scheduleForDrawing();
 
 	return true;
 }
 
+
+
+
+void dWMHud_c::playShowHeaderAnim() {
+	layout.enableNonLoopAnim(SHOW_HEADER);
+}
+
+void dWMHud_c::playHideHeaderAnim() {
+	if (layout.isAnimOn(SHOW_HEADER)) {
+		layout.enableNonLoopAnim(SHOW_HEADER, true);
+	}
+	layout.grpHandlers[SHOW_HEADER].frameCtrl.flags = 2; // NO_LOOP | REVERSE
+}
+
diff --git a/src/koopatlas/hud.h b/src/koopatlas/hud.h
index ac7b81e..87f731b 100644
--- a/src/koopatlas/hud.h
+++ b/src/koopatlas/hud.h
@@ -17,6 +17,13 @@ class dWMHud_c : public dBase_c {
 
 		static dWMHud_c *build();
 		static dWMHud_c *instance;
+
+
+		bool showingHeader;
+
+
+		void playShowHeaderAnim();
+		void playHideHeaderAnim();
 };
 
 #endif
-- 
cgit v1.2.3