Allow more than one title screen

This commit is contained in:
jsalmon3 2003-10-17 17:46:48 +00:00
parent be1d08770d
commit 9cf7caccd6
4 changed files with 84 additions and 65 deletions

View file

@ -450,7 +450,7 @@ extern int SlowFrameCounter;
*/ */
#define MyRand() rand() #define MyRand() rand()
extern char* TitleScreen; /// File for title screen extern char** TitleScreen; /// File for title screen
extern char* GameName; /// Name of the game (wc2,wc1) extern char* GameName; /// Name of the game (wc2,wc1)
extern char* MenuBackground; /// File for menu background extern char* MenuBackground; /// File for menu background
extern char* MenuBackgroundWithTitle; /// File for menu with title extern char* MenuBackgroundWithTitle; /// File for menu with title

View file

@ -234,7 +234,7 @@ extern SCM CclUnits(void);
-- Variables -- Variables
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
global char* TitleScreen; /// Titlescreen to show at startup global char** TitleScreen; /// Titlescreen to show at startup
global char* MenuBackground; /// File for menu background global char* MenuBackground; /// File for menu background
global char* MenuBackgroundWithTitle; /// File for menu with title global char* MenuBackgroundWithTitle; /// File for menu with title
global char* TitleMusic; /// File for title music global char* TitleMusic; /// File for title music
@ -451,7 +451,15 @@ local int WaitMouseY; /// Mouse Y position
local void WaitCallbackKey(unsigned dummy __attribute__((unused))) local void WaitCallbackKey(unsigned dummy __attribute__((unused)))
{ {
DebugLevel3Fn("Pressed %8x %8x\n" _C_ MouseButtons _C_ dummy); DebugLevel3Fn("Pressed %8x %8x\n" _C_ MouseButtons _C_ dummy);
WaitNoEvent=0; WaitNoEvent = 0;
}
/**
** Callback for input.
*/
local void WaitCallbackKey1(unsigned dummy __attribute__((unused)))
{
DebugLevel3Fn("Released %8x %8x\n" _C_ MouseButtons _C_ dummy);
} }
/** /**
@ -461,7 +469,7 @@ local void WaitCallbackKey2(unsigned dummy1 __attribute__((unused)),
unsigned dummy2 __attribute__((unused))) unsigned dummy2 __attribute__((unused)))
{ {
DebugLevel3Fn("Pressed %8x %8x %8x\n" _C_ MouseButtons _C_ dummy1 _C_ dummy2); DebugLevel3Fn("Pressed %8x %8x %8x\n" _C_ MouseButtons _C_ dummy1 _C_ dummy2);
WaitNoEvent=0; WaitNoEvent = 0;
} }
/** /**
@ -469,9 +477,18 @@ local void WaitCallbackKey2(unsigned dummy1 __attribute__((unused)),
*/ */
local void WaitCallbackKey3(unsigned dummy1 __attribute__((unused)), local void WaitCallbackKey3(unsigned dummy1 __attribute__((unused)),
unsigned dummy2 __attribute__((unused))) unsigned dummy2 __attribute__((unused)))
{
DebugLevel3Fn("Released %8x %8x %8x\n" _C_ MouseButtons _C_ dummy1 _C_ dummy2);
}
/**
** Callback for input.
*/
local void WaitCallbackKey4(unsigned dummy1 __attribute__((unused)),
unsigned dummy2 __attribute__((unused)))
{ {
DebugLevel3Fn("Repeated %8x %8x %8x\n" _C_ MouseButtons _C_ dummy1 _C_ dummy2); DebugLevel3Fn("Repeated %8x %8x %8x\n" _C_ MouseButtons _C_ dummy1 _C_ dummy2);
WaitNoEvent=0; WaitNoEvent = 0;
} }
/** /**
@ -856,7 +873,7 @@ local void VideoEffect0(int frame,
} }
#endif #endif
#ifdef DEBUG #ifdef DEBUG_DRAWFONTS
/** /**
** Draw the fonts, for screen shots. ** Draw the fonts, for screen shots.
*/ */
@ -911,65 +928,52 @@ local void DebugDrawFonts(void)
local void WaitForInput(int timeout) local void WaitForInput(int timeout)
{ {
EventCallback callbacks; EventCallback callbacks;
#if defined(linux) && !defined(DEBUG)
char* s;
char ddate[72 + 1];
FILE* ddfile;
#endif
SetVideoSync(); SetVideoSync();
callbacks.ButtonPressed = WaitCallbackKey; callbacks.ButtonPressed = WaitCallbackKey;
callbacks.ButtonReleased = WaitCallbackKey; callbacks.ButtonReleased = WaitCallbackKey1;
callbacks.MouseMoved = WaitCallbackMouse; callbacks.MouseMoved = WaitCallbackMouse;
callbacks.MouseExit = WaitCallbackExit; callbacks.MouseExit = WaitCallbackExit;
callbacks.KeyPressed = WaitCallbackKey2; callbacks.KeyPressed = WaitCallbackKey2;
callbacks.KeyReleased = WaitCallbackKey2; callbacks.KeyReleased = WaitCallbackKey3;
callbacks.KeyRepeated = WaitCallbackKey3; callbacks.KeyRepeated = WaitCallbackKey4;
callbacks.NetworkEvent = NetworkEvent; callbacks.NetworkEvent = NetworkEvent;
callbacks.SoundReady = WriteSound; callbacks.SoundReady = WriteSound;
// //
// FIXME: more work needed, scrolling credits, animations, ... // FIXME: more work needed, scrolling credits, animations, ...
#ifdef DEBUG
WaitNoEvent = 1; WaitNoEvent = 1;
#ifdef DEBUG_DRAWFONTS
while (WaitNoEvent) { while (WaitNoEvent) {
static int init = 0;
if (!init) {
SetDefaultTextColors(FontYellow, FontWhite);
LoadFonts();
init = 1;
}
DebugDrawFonts(); DebugDrawFonts();
WaitEventsOneFrame(&callbacks); WaitEventsOneFrame(&callbacks);
} }
#else #else
VideoLockScreen();
VideoDrawTextCentered(VideoWidth / 2, 5, LargeFont, "Press SPACE to continue.");
#ifdef linux
ddate[0] = '\0';
ddfile = popen("`which ddate`", "r");
fgets(ddate, 72, ddfile);
pclose(ddfile);
if ((s = strrchr(ddate, '\n'))) {
*s = '\0';
}
VideoDrawTextCentered(VideoWidth / 2, 20, LargeFont, ddate);
#endif
VideoUnlockScreen();
Invalidate();
RealizeVideoMemory();
WaitNoEvent = 1;
timeout *= CYCLES_PER_SECOND; timeout *= CYCLES_PER_SECOND;
while (timeout-- && WaitNoEvent) { while (timeout-- && WaitNoEvent) {
VideoEffect0(timeout, &callbacks); // FIXME: make this configurable
if (0) {
VideoEffect0(timeout, &callbacks);
}
WaitEventsOneFrame(&callbacks); WaitEventsOneFrame(&callbacks);
} }
VideoEffect0(-1, &callbacks); if (0) {
VideoEffect0(-1, &callbacks);
}
#endif #endif
VideoLockScreen(); VideoLockScreen();
VideoDrawTextCentered(VideoWidth / 2, 5, LargeFont, VideoClearScreen();
"----------------------------");
VideoUnlockScreen(); VideoUnlockScreen();
Invalidate(); Invalidate();
RealizeVideoMemory(); RealizeVideoMemory();
} }
/** /**
@ -1251,13 +1255,13 @@ Use it at your own risk.\n\n");
// //
InitVideo(); // setup video display InitVideo(); // setup video display
#ifdef WITH_SOUND #ifdef WITH_SOUND
if (!SoundOff && InitSound()) { // setup sound card if (!SoundOff && InitSound()) { // setup sound card
SoundOff = 1; SoundOff = 1;
SoundFildes = -1; SoundFildes = -1;
} }
#endif #endif
#ifndef DEBUG // For debug its better not to have: #ifndef DEBUG // For debug it's better not to have:
srand(time(NULL)); // Random counter = random each start srand(time(NULL)); // Random counter = random each start
#endif #endif
@ -1266,23 +1270,22 @@ Use it at your own risk.\n\n");
// //
// Show title screen. // Show title screen.
// //
i = 1;
SetClipping(0, 0, VideoWidth - 1, VideoHeight - 1); SetClipping(0, 0, VideoWidth - 1, VideoHeight - 1);
if (TitleScreen) { if (TitleScreen) {
if ((i = PlayMovie(TitleScreen, for (i = 0; TitleScreen[i]; ++i) {
PlayMovieZoomScreen | PlayMovieKeepAspect))) { if (PlayMovie(TitleScreen[i],
DisplayPicture(TitleScreen); PlayMovieZoomScreen | PlayMovieKeepAspect)) {
Invalidate(); DisplayPicture(TitleScreen[i]);
Invalidate();
// FIXME: make the time configurable
WaitForInput(20);
}
} }
} }
InitUnitsMemory(); // Units memory management InitUnitsMemory(); // Units memory management
PreMenuSetup(); // Load everything needed for menus PreMenuSetup(); // Load everything needed for menus
if (i) {
WaitForInput(20); // Show game intro
}
MenuLoop(MapName, &TheMap); // Enter the menu loop MenuLoop(MapName, &TheMap); // Enter the menu loop
return 0; return 0;

View file

@ -283,25 +283,26 @@ local SCM CclSetVideoFullscreen(SCM fullscreen)
** **
** @param title SCM title. (nil reports only) ** @param title SCM title. (nil reports only)
** **
** @return Old title screen. ** @return None
*/ */
local SCM CclSetTitleScreen(SCM title) local SCM CclSetTitleScreen(SCM list)
{ {
SCM old; int i;
old = NIL;
if (TitleScreen) { if (TitleScreen) {
old = gh_str02scm(TitleScreen); for (i = 0; TitleScreen[i]; ++i) {
} free(TitleScreen[i]);
if (!gh_null_p(title)) {
if (TitleScreen) {
free(TitleScreen);
TitleScreen = NULL;
} }
TitleScreen = gh_scm2newstr(title, NULL);
} }
return old; if (!gh_null_p(list)) {
i = 0;
TitleScreen = calloc(gh_length(list) + 1, sizeof(*TitleScreen));
while (!gh_null_p(list)) {
TitleScreen[i++] = gh_scm2newstr(gh_car(list), NULL);
list = gh_cdr(list);
}
}
return SCM_UNSPECIFIED;
} }
/** /**
@ -3240,7 +3241,7 @@ global void UserInterfaceCclRegister(void)
gh_new_procedure2_0("set-video-resolution!", CclSetVideoResolution); gh_new_procedure2_0("set-video-resolution!", CclSetVideoResolution);
gh_new_procedure1_0("set-video-fullscreen!", CclSetVideoFullscreen); gh_new_procedure1_0("set-video-fullscreen!", CclSetVideoFullscreen);
gh_new_procedure1_0("set-title-screen!", CclSetTitleScreen); gh_new_procedureN("set-title-screen!", CclSetTitleScreen);
gh_new_procedure1_0("set-menu-background!", CclSetMenuBackground); gh_new_procedure1_0("set-menu-background!", CclSetMenuBackground);
gh_new_procedure1_0("set-menu-background-with-title!", gh_new_procedure1_0("set-menu-background-with-title!",
CclSetMenuBackgroundWithTitle); CclSetMenuBackgroundWithTitle);

View file

@ -163,6 +163,13 @@ local void MovieCallbackKey(unsigned dummy __attribute__((unused)))
MovieKeyPressed = 0; MovieKeyPressed = 0;
} }
/**
** Callback for input.
*/
local void MovieCallbackKey1(unsigned dummy __attribute__((unused)))
{
}
/** /**
** Callback for input. ** Callback for input.
*/ */
@ -177,6 +184,14 @@ local void MovieCallbackKey2(unsigned dummy1 __attribute__((unused)),
*/ */
local void MovieCallbackKey3(unsigned dummy1 __attribute__((unused)), local void MovieCallbackKey3(unsigned dummy1 __attribute__((unused)),
unsigned dummy2 __attribute__((unused))) unsigned dummy2 __attribute__((unused)))
{
}
/**
** Callback for input.
*/
local void MovieCallbackKey4(unsigned dummy1 __attribute__((unused)),
unsigned dummy2 __attribute__((unused)))
{ {
MovieKeyPressed = 0; MovieKeyPressed = 0;
} }
@ -251,12 +266,12 @@ global int PlayMovie(const char* name, int flags)
#endif #endif
callbacks.ButtonPressed = MovieCallbackKey; callbacks.ButtonPressed = MovieCallbackKey;
callbacks.ButtonReleased = MovieCallbackKey; callbacks.ButtonReleased = MovieCallbackKey1;
callbacks.MouseMoved = MovieCallbackMouse; callbacks.MouseMoved = MovieCallbackMouse;
callbacks.MouseExit = MovieCallbackExit; callbacks.MouseExit = MovieCallbackExit;
callbacks.KeyPressed = MovieCallbackKey2; callbacks.KeyPressed = MovieCallbackKey2;
callbacks.KeyReleased = MovieCallbackKey2; callbacks.KeyReleased = MovieCallbackKey3;
callbacks.KeyRepeated = MovieCallbackKey3; callbacks.KeyRepeated = MovieCallbackKey4;
callbacks.NetworkEvent = NetworkEvent; callbacks.NetworkEvent = NetworkEvent;
callbacks.SoundReady = WriteSound; callbacks.SoundReady = WriteSound;