Allow more than one title screen
This commit is contained in:
parent
be1d08770d
commit
9cf7caccd6
4 changed files with 84 additions and 65 deletions
|
@ -450,7 +450,7 @@ extern int SlowFrameCounter;
|
|||
*/
|
||||
#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* MenuBackground; /// File for menu background
|
||||
extern char* MenuBackgroundWithTitle; /// File for menu with title
|
||||
|
|
|
@ -234,7 +234,7 @@ extern SCM CclUnits(void);
|
|||
-- 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* MenuBackgroundWithTitle; /// File for menu with title
|
||||
global char* TitleMusic; /// File for title music
|
||||
|
@ -454,6 +454,14 @@ local void WaitCallbackKey(unsigned dummy __attribute__((unused)))
|
|||
WaitNoEvent = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
** Callback for input.
|
||||
*/
|
||||
local void WaitCallbackKey1(unsigned dummy __attribute__((unused)))
|
||||
{
|
||||
DebugLevel3Fn("Released %8x %8x\n" _C_ MouseButtons _C_ dummy);
|
||||
}
|
||||
|
||||
/**
|
||||
** Callback for input.
|
||||
*/
|
||||
|
@ -469,6 +477,15 @@ local void WaitCallbackKey2(unsigned dummy1 __attribute__((unused)),
|
|||
*/
|
||||
local void WaitCallbackKey3(unsigned dummy1 __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);
|
||||
WaitNoEvent = 0;
|
||||
|
@ -856,7 +873,7 @@ local void VideoEffect0(int frame,
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef DEBUG_DRAWFONTS
|
||||
/**
|
||||
** Draw the fonts, for screen shots.
|
||||
*/
|
||||
|
@ -911,65 +928,52 @@ local void DebugDrawFonts(void)
|
|||
local void WaitForInput(int timeout)
|
||||
{
|
||||
EventCallback callbacks;
|
||||
#if defined(linux) && !defined(DEBUG)
|
||||
char* s;
|
||||
char ddate[72 + 1];
|
||||
FILE* ddfile;
|
||||
#endif
|
||||
|
||||
SetVideoSync();
|
||||
|
||||
callbacks.ButtonPressed = WaitCallbackKey;
|
||||
callbacks.ButtonReleased = WaitCallbackKey;
|
||||
callbacks.ButtonReleased = WaitCallbackKey1;
|
||||
callbacks.MouseMoved = WaitCallbackMouse;
|
||||
callbacks.MouseExit = WaitCallbackExit;
|
||||
callbacks.KeyPressed = WaitCallbackKey2;
|
||||
callbacks.KeyReleased = WaitCallbackKey2;
|
||||
callbacks.KeyRepeated = WaitCallbackKey3;
|
||||
callbacks.KeyReleased = WaitCallbackKey3;
|
||||
callbacks.KeyRepeated = WaitCallbackKey4;
|
||||
callbacks.NetworkEvent = NetworkEvent;
|
||||
callbacks.SoundReady = WriteSound;
|
||||
|
||||
//
|
||||
// FIXME: more work needed, scrolling credits, animations, ...
|
||||
#ifdef DEBUG
|
||||
WaitNoEvent = 1;
|
||||
#ifdef DEBUG_DRAWFONTS
|
||||
while (WaitNoEvent) {
|
||||
static int init = 0;
|
||||
if (!init) {
|
||||
SetDefaultTextColors(FontYellow, FontWhite);
|
||||
LoadFonts();
|
||||
init = 1;
|
||||
}
|
||||
DebugDrawFonts();
|
||||
WaitEventsOneFrame(&callbacks);
|
||||
}
|
||||
#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;
|
||||
while (timeout-- && WaitNoEvent) {
|
||||
// FIXME: make this configurable
|
||||
if (0) {
|
||||
VideoEffect0(timeout, &callbacks);
|
||||
}
|
||||
WaitEventsOneFrame(&callbacks);
|
||||
}
|
||||
if (0) {
|
||||
VideoEffect0(-1, &callbacks);
|
||||
}
|
||||
#endif
|
||||
|
||||
VideoLockScreen();
|
||||
VideoDrawTextCentered(VideoWidth / 2, 5, LargeFont,
|
||||
"----------------------------");
|
||||
VideoClearScreen();
|
||||
VideoUnlockScreen();
|
||||
Invalidate();
|
||||
RealizeVideoMemory();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1257,7 +1261,7 @@ Use it at your own risk.\n\n");
|
|||
}
|
||||
#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
|
||||
#endif
|
||||
|
||||
|
@ -1266,23 +1270,22 @@ Use it at your own risk.\n\n");
|
|||
//
|
||||
// Show title screen.
|
||||
//
|
||||
i = 1;
|
||||
SetClipping(0, 0, VideoWidth - 1, VideoHeight - 1);
|
||||
if (TitleScreen) {
|
||||
if ((i = PlayMovie(TitleScreen,
|
||||
PlayMovieZoomScreen | PlayMovieKeepAspect))) {
|
||||
DisplayPicture(TitleScreen);
|
||||
for (i = 0; TitleScreen[i]; ++i) {
|
||||
if (PlayMovie(TitleScreen[i],
|
||||
PlayMovieZoomScreen | PlayMovieKeepAspect)) {
|
||||
DisplayPicture(TitleScreen[i]);
|
||||
Invalidate();
|
||||
// FIXME: make the time configurable
|
||||
WaitForInput(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InitUnitsMemory(); // Units memory management
|
||||
PreMenuSetup(); // Load everything needed for menus
|
||||
|
||||
if (i) {
|
||||
WaitForInput(20); // Show game intro
|
||||
}
|
||||
|
||||
MenuLoop(MapName, &TheMap); // Enter the menu loop
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -283,25 +283,26 @@ local SCM CclSetVideoFullscreen(SCM fullscreen)
|
|||
**
|
||||
** @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) {
|
||||
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);
|
||||
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 old;
|
||||
}
|
||||
return SCM_UNSPECIFIED;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3240,7 +3241,7 @@ global void UserInterfaceCclRegister(void)
|
|||
gh_new_procedure2_0("set-video-resolution!", CclSetVideoResolution);
|
||||
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-with-title!",
|
||||
CclSetMenuBackgroundWithTitle);
|
||||
|
|
|
@ -163,6 +163,13 @@ local void MovieCallbackKey(unsigned dummy __attribute__((unused)))
|
|||
MovieKeyPressed = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
** Callback for input.
|
||||
*/
|
||||
local void MovieCallbackKey1(unsigned dummy __attribute__((unused)))
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
** Callback for input.
|
||||
*/
|
||||
|
@ -177,6 +184,14 @@ local void MovieCallbackKey2(unsigned dummy1 __attribute__((unused)),
|
|||
*/
|
||||
local void MovieCallbackKey3(unsigned dummy1 __attribute__((unused)),
|
||||
unsigned dummy2 __attribute__((unused)))
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
** Callback for input.
|
||||
*/
|
||||
local void MovieCallbackKey4(unsigned dummy1 __attribute__((unused)),
|
||||
unsigned dummy2 __attribute__((unused)))
|
||||
{
|
||||
MovieKeyPressed = 0;
|
||||
}
|
||||
|
@ -251,12 +266,12 @@ global int PlayMovie(const char* name, int flags)
|
|||
#endif
|
||||
|
||||
callbacks.ButtonPressed = MovieCallbackKey;
|
||||
callbacks.ButtonReleased = MovieCallbackKey;
|
||||
callbacks.ButtonReleased = MovieCallbackKey1;
|
||||
callbacks.MouseMoved = MovieCallbackMouse;
|
||||
callbacks.MouseExit = MovieCallbackExit;
|
||||
callbacks.KeyPressed = MovieCallbackKey2;
|
||||
callbacks.KeyReleased = MovieCallbackKey2;
|
||||
callbacks.KeyRepeated = MovieCallbackKey3;
|
||||
callbacks.KeyReleased = MovieCallbackKey3;
|
||||
callbacks.KeyRepeated = MovieCallbackKey4;
|
||||
callbacks.NetworkEvent = NetworkEvent;
|
||||
callbacks.SoundReady = WriteSound;
|
||||
|
||||
|
|
Loading…
Reference in a new issue