From 26a005e788c351b8716c0750e797f0621b939b90 Mon Sep 17 00:00:00 2001
From: jsalmon3 <>
Date: Tue, 18 Jun 2002 18:55:39 +0000
Subject: [PATCH] Added TheUI.Offset640X and TheUI.Offset480Y

---
 src/game/intro.cpp   | 18 +++++++++---------
 src/include/ui.h     |  4 ++++
 src/ui/script_ui.cpp |  7 +++++--
 3 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/src/game/intro.cpp b/src/game/intro.cpp
index 1f80ae43d..217db6146 100644
--- a/src/game/intro.cpp
+++ b/src/game/intro.cpp
@@ -347,7 +347,7 @@ global void ShowIntro(const Intro *intro)
     int OldVideoSyncSpeed;
 
     UseContinueButton=1;
-    InitContinueButton((VideoWidth-640)/2+455,(VideoHeight-480)/2+440);
+    InitContinueButton(TheUI.Offset640X+455,TheUI.Offset480Y+440);
     GameCursor=TheUI.Point.Cursor;
     DestroyCursorBackground();
 
@@ -405,13 +405,13 @@ global void ShowIntro(const Intro *intro)
 	}
     }
 
-    x=(VideoWidth-640)/2;
+    x=TheUI.Offset640X;
     line=0;
     stage=1;
     IntroNoEvent=1;
     c=0;
     while( 1 ) {
-	y=(VideoHeight-480)/2;
+	y=TheUI.Offset480Y;
 	if( !PlayingMusic && stage<MAX_BRIEFING_VOICES &&
 		intro->VoiceFile[stage] ) {
 	    PlayFile(intro->VoiceFile[stage]);
@@ -543,12 +543,12 @@ global void ShowCredits(Credits *credits)
     }
 
     UseContinueButton=1;
-    InitContinueButton((VideoWidth-640)/2+455,(VideoHeight-480)/2+440);
+    InitContinueButton(TheUI.Offset640X+455,TheUI.Offset480Y+440);
     GameCursor=TheUI.Point.Cursor;
     DestroyCursorBackground();
 
-    x=(VideoWidth-640)/2;
-    y=(VideoHeight-480)/2;
+    x=TheUI.Offset640X;
+    y=TheUI.Offset480Y;
     IntroNoEvent=1;
     line=0;
     scrolling=1;
@@ -800,8 +800,8 @@ local int GameStatsDrawFunc(int frame)
     if( (frame%StatsPause)!=0 )
 	return done;
 
-    x=(VideoWidth-640)/2;
-    y=(VideoHeight-480)/2;
+    x=TheUI.Offset640X;
+    y=TheUI.Offset480Y;
     dodraw=frame/StatsPause;
 
     for( i=0,c=0; i<PlayerMax; i++) {
@@ -1147,7 +1147,7 @@ global void ShowStats(void)
     VideoUnlockScreen();
 
     UseContinueButton=1;
-    InitContinueButton((VideoWidth-640)/2+455,(VideoHeight-480)/2+440);
+    InitContinueButton(TheUI.Offset640X+455,TheUI.Offset480Y+440);
     GameCursor=TheUI.Point.Cursor;
     DestroyCursorBackground();
 
diff --git a/src/include/ui.h b/src/include/ui.h
index bdc1616f2..506a6452a 100644
--- a/src/include/ui.h
+++ b/src/include/ui.h
@@ -256,6 +256,10 @@ typedef struct _ui_ {
 	/// used for displaying unit training queues
     Button	Buttons2[6];
 
+    // Offsets for 640x480 center used by menus
+    int		Offset640X;		/// Offset for 640x480 X position
+    int		Offset480Y;		/// Offset for 640x480 Y position
+
     //
     //	Cursors used.
     //
diff --git a/src/ui/script_ui.cpp b/src/ui/script_ui.cpp
index 895aac301..bf2575f52 100644
--- a/src/ui/script_ui.cpp
+++ b/src/ui/script_ui.cpp
@@ -1385,6 +1385,9 @@ local SCM CclDefineMenu(SCM list)
 
     DebugLevel3Fn("Define menu\n");
 
+    TheUI.Offset640X = (VideoWidth - 640) / 2;
+    TheUI.Offset480Y = (VideoHeight - 480) / 2;
+
     //
     //	Parse the arguments, already the new tagged format.
     //
@@ -1472,8 +1475,8 @@ local SCM CclDefineMenu(SCM list)
 		}
 	    } else {
 		//printf("VideoWidth = %d\n", VideoWidth);
-		menu->x += (VideoWidth - 640) / 2;
-		menu->y += (VideoHeight - 480) / 2;
+		menu->x += TheUI.Offset640X;
+		menu->y += TheUI.Offset480Y;
 	    }
 	}
 	//printf("Me:%s\n", name);