2006-02-24 04:48:15 +00:00
|
|
|
/*
|
|
|
|
** i_movie.cpp
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
2006-06-11 01:37:00 +00:00
|
|
|
** Copyright 1998-2006 Randy Heit
|
2006-02-24 04:48:15 +00:00
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
2006-09-14 00:02:31 +00:00
|
|
|
* If you do not have dshow.h, either download the latest DirectX SDK
|
2006-02-24 04:48:15 +00:00
|
|
|
* or #define I_DO_NOT_LIKE_BIG_DOWNLOADS
|
|
|
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
*/
|
|
|
|
|
- The sound code now handles restarting looping sounds itself. As far as
the rest of the game is concerned, these sounds will never stop once they
have been started until they are explicitly stopped. If they are evicted
from their channels, the sound code will restart them as soon as possible.
This means that instead of this:
if (!S_IsActorPlayingSomething(actor, CHAN_WEAPON, -1))
{
S_Sound(actor, CHAN_WEAPON|CHAN_LOOP, soundid, 1, ATTN_NORM);
}
The following is now just as effective:
S_Sound(actor, CHAN_WEAPON|CHAN_LOOP, soundid, 1, ATTN_NORM);
There are also a couple of other ramifications presented by this change:
* The full state of the sound system (sans music) is now stored in save
games. Any sounds that were playing when you saved will still be
playing when you load. (Try saving while Korax is making a speech in
Hexen to hear it.)
* Using snd_reset will also preserve any playing sounds.
* Movie playback is disabled, probably forever. I did not want to
update the MovieDisable/ResumeSound stuff for the new eviction
tracking code. A properly updated movie player will use the VMR,
which doesn't need these functions, since it would pipe the sound
straight through the sound system like everything else, so I decided
to dump them now, which leaves the movie player in a totally unworkable
state.
June 26, 2008
- Changed S_Sound() to take the same floating point attenuation that the
internal S_StartSound() uses. Now ambient sounds can use the public
S_Sound() interface.
- Fixed: S_RelinkSound() compared the points of the channels against the
from actor's point, rather than checking the channels' mover.
- Changed Strife's animated doors so that their sounds originate from the
interior of the sector making them and not from the entire vertical height
of the map.
SVN r1055 (trunk)
2008-06-29 04:19:38 +00:00
|
|
|
#ifndef I_DO_NOT_LIKE_BIG_DOWNLOADS
|
|
|
|
#define I_DO_NOT_LIKE_BIG_DOWNLOADS
|
|
|
|
#endif
|
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
|
|
|
#define USE_WINDOWS_DWORD
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "c_cvars.h"
|
|
|
|
|
|
|
|
CUSTOM_CVAR (Float, snd_movievolume, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|
|
|
{
|
|
|
|
if (self < 0.f)
|
|
|
|
self = 0.f;
|
|
|
|
else if (self > 1.f)
|
|
|
|
self = 1.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef I_DO_NOT_LIKE_BIG_DOWNLOADS
|
|
|
|
|
|
|
|
#include "i_movie.h"
|
|
|
|
|
|
|
|
int I_PlayMovie (const char *movie)
|
|
|
|
{
|
|
|
|
return MOVIE_Failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#include <dshow.h>
|
|
|
|
#include "i_movie.h"
|
|
|
|
#include "i_sound.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "c_console.h"
|
|
|
|
#include "win32iface.h"
|
|
|
|
#include "sbar.h"
|
|
|
|
|
|
|
|
EXTERN_CVAR (String, language)
|
|
|
|
|
|
|
|
#define WM_GRAPHNOTIFY (WM_APP+321)
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
#define INGAME_PRIORITY_CLASS NORMAL_PRIORITY_CLASS
|
|
|
|
#else
|
|
|
|
//#define INGAME_PRIORITY_CLASS HIGH_PRIORITY_CLASS
|
|
|
|
#define INGAME_PRIORITY_CLASS NORMAL_PRIORITY_CLASS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern HWND Window;
|
|
|
|
extern IVideo *Video;
|
|
|
|
extern LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
|
|
|
extern void I_CheckNativeMouse (bool preferNative);
|
|
|
|
|
|
|
|
static bool MovieNotDone;
|
|
|
|
static bool MovieInterrupted;
|
|
|
|
static bool MovieDestroyed;
|
|
|
|
static bool FullVideo;
|
|
|
|
static bool NoVideo;
|
|
|
|
static IVideoWindow *vidwin;
|
|
|
|
static IMediaEventEx *event;
|
|
|
|
static IGraphBuilder *graph;
|
|
|
|
static IMediaControl *control;
|
|
|
|
static IBasicAudio *audio;
|
|
|
|
static IBasicVideo *video;
|
|
|
|
|
|
|
|
static void CheckIfVideo ();
|
|
|
|
static void SetMovieSize ();
|
|
|
|
static void SetTheVolume ();
|
|
|
|
static void SizeWindowForVideo ();
|
|
|
|
|
|
|
|
LRESULT CALLBACK MovieWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_GRAPHNOTIFY:
|
|
|
|
{
|
2008-04-29 02:43:42 +00:00
|
|
|
long code;
|
|
|
|
LONG_PTR parm1, parm2;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
while (event->GetEvent (&code, &parm1, &parm2, 0) == S_OK)
|
|
|
|
{
|
|
|
|
if (code == EC_COMPLETE)
|
|
|
|
{
|
|
|
|
MovieNotDone = false;
|
|
|
|
}
|
|
|
|
event->FreeEventParams (code, parm1, parm2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SIZE:
|
|
|
|
if (vidwin == NULL)
|
|
|
|
{
|
|
|
|
InvalidateRect (Window, NULL, FALSE);
|
|
|
|
}
|
|
|
|
else if ((wParam == SIZE_MAXIMIZED || wParam == SIZE_RESTORED) && !FullVideo)
|
|
|
|
{
|
|
|
|
SetMovieSize ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_PAINT:
|
|
|
|
if (vidwin == NULL)
|
|
|
|
{
|
|
|
|
if (screen != NULL)
|
|
|
|
{
|
|
|
|
static_cast<BaseWinFB *> (screen)->PaintToWindow ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!FullVideo)
|
|
|
|
{
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
HBRUSH br;
|
|
|
|
HDC dc;
|
|
|
|
long left, top, width, height;
|
|
|
|
|
|
|
|
if (S_OK == vidwin->GetWindowPosition (&left, &top, &width, &height))
|
|
|
|
{
|
|
|
|
dc = BeginPaint (Window, &ps);
|
|
|
|
if (dc != NULL)
|
|
|
|
{
|
|
|
|
RECT rect = { left, top, left+width, top+height };
|
|
|
|
ScreenToClient (hWnd, (LPPOINT)&rect.left);
|
|
|
|
ScreenToClient (hWnd, (LPPOINT)&rect.right);
|
|
|
|
br = (HBRUSH)GetStockObject (BLACK_BRUSH);
|
|
|
|
switch (ExcludeClipRect (dc, rect.left, rect.top, rect.right, rect.bottom))
|
|
|
|
{
|
|
|
|
case SIMPLEREGION:
|
|
|
|
case COMPLEXREGION:
|
|
|
|
FillRect (dc, &ps.rcPaint, br);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
EndPaint (Window, &ps);
|
|
|
|
//return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
case WM_KEYDOWN:
|
|
|
|
case WM_SYSKEYDOWN:
|
|
|
|
/*
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
*/
|
|
|
|
if (MovieNotDone)
|
|
|
|
{
|
|
|
|
if (wParam == VK_ESCAPE || message == WM_CANCELMODE || message == WM_DESTROY)
|
|
|
|
{
|
|
|
|
control->Stop ();
|
|
|
|
MovieNotDone = false;
|
|
|
|
MovieInterrupted = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (message == WM_DESTROY)
|
|
|
|
{
|
|
|
|
MovieDestroyed = true;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WM_GETMINMAXINFO:
|
|
|
|
if (screen && !FullVideo)
|
|
|
|
{
|
|
|
|
LPMINMAXINFO mmi = (LPMINMAXINFO)lParam;
|
|
|
|
mmi->ptMinTrackSize.x = SCREENWIDTH + GetSystemMetrics (SM_CXSIZEFRAME) * 2;
|
|
|
|
mmi->ptMinTrackSize.y = SCREENHEIGHT + GetSystemMetrics (SM_CYSIZEFRAME) * 2 +
|
|
|
|
GetSystemMetrics (SM_CYCAPTION);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SETTINGCHANGE:
|
|
|
|
// In case regional settings were changed, reget preferred languages
|
|
|
|
language.Callback ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return DefWindowProc (hWnd, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
int I_PlayMovie (const char *name)
|
|
|
|
{
|
2007-02-13 00:10:16 +00:00
|
|
|
HRESULT hr;
|
2006-02-24 04:48:15 +00:00
|
|
|
int returnval = MOVIE_Failed;
|
|
|
|
size_t namelen = strlen (name) + 1;
|
|
|
|
wchar_t *uniname = new wchar_t[namelen];
|
|
|
|
bool returnSound = false;
|
|
|
|
bool runningFull = false;
|
|
|
|
bool hotkey = false;
|
|
|
|
size_t i;
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
MovieNotDone = true;
|
|
|
|
|
|
|
|
if (MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, name, -1, uniname, (int)namelen) == 0)
|
|
|
|
{ // Could not convert name to Unicode
|
|
|
|
goto bomb1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert slashes to backslashes because IGraphBuilder cannot deal with them
|
|
|
|
for (i = 0; i < namelen; ++i)
|
|
|
|
{
|
|
|
|
if (uniname[i] == L'/')
|
|
|
|
uniname[i] = L'\\';
|
|
|
|
}
|
|
|
|
|
2007-02-13 00:10:16 +00:00
|
|
|
if (FAILED(hr = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
|
2006-02-24 04:48:15 +00:00
|
|
|
IID_IGraphBuilder, (void **)&graph)))
|
|
|
|
{
|
|
|
|
goto bomb1;
|
|
|
|
}
|
|
|
|
|
|
|
|
control = NULL;
|
|
|
|
event = NULL;
|
|
|
|
vidwin = NULL;
|
|
|
|
audio = NULL;
|
|
|
|
video = NULL;
|
|
|
|
|
2007-02-13 00:10:16 +00:00
|
|
|
if (FAILED(hr = graph->RenderFile (uniname, NULL)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
goto bomb2;
|
|
|
|
}
|
|
|
|
|
|
|
|
graph->QueryInterface (IID_IMediaControl, (void **)&control);
|
|
|
|
graph->QueryInterface (IID_IMediaEventEx, (void **)&event);
|
|
|
|
graph->QueryInterface (IID_IVideoWindow, (void **)&vidwin);
|
|
|
|
graph->QueryInterface (IID_IBasicAudio, (void **)&audio);
|
|
|
|
graph->QueryInterface (IID_IBasicVideo, (void **)&video);
|
|
|
|
|
|
|
|
if (control == NULL || event == NULL)
|
|
|
|
{
|
|
|
|
goto bomb3;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GSnd != NULL)
|
|
|
|
{
|
|
|
|
GSnd->MovieDisableSound ();
|
|
|
|
}
|
|
|
|
returnSound = true;
|
|
|
|
|
|
|
|
CheckIfVideo ();
|
|
|
|
SetTheVolume ();
|
|
|
|
|
|
|
|
FullVideo = false;
|
|
|
|
|
|
|
|
if (vidwin != NULL)
|
|
|
|
{
|
|
|
|
FullVideo = runningFull = screen->IsFullscreen ();
|
|
|
|
|
|
|
|
// If the message drain cannot be set, then we simply won't be able
|
|
|
|
// to catch mouse button presses in the video window.
|
|
|
|
HRESULT drainhr = vidwin->put_MessageDrain ((OAHWND)Window);
|
|
|
|
|
|
|
|
if (FullVideo)
|
|
|
|
{
|
|
|
|
// Try to avoid nasty palette flashes by clearing the screen to black.
|
|
|
|
// Does not always work. :-(
|
|
|
|
static_cast<Win32Video *> (Video)->BlankForGDI ();
|
|
|
|
static_cast<Win32Video *> (Video)->GoFullscreen (false);
|
|
|
|
static_cast<BaseWinFB *> (screen)->ReleaseResources ();
|
2007-02-13 00:10:16 +00:00
|
|
|
if (FAILED (drainhr) || FAILED(hr = vidwin->put_FullScreenMode (OATRUE)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
SizeWindowForVideo ();
|
|
|
|
FullVideo = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!FullVideo)
|
|
|
|
{
|
|
|
|
vidwin->put_Owner ((OAHWND)Window);
|
|
|
|
vidwin->put_WindowStyle (WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
|
|
|
|
SetMovieSize ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RegisterHotKey (Window, 0, MOD_ALT, VK_TAB);
|
|
|
|
hotkey = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-13 00:10:16 +00:00
|
|
|
if (FAILED (hr = event->SetNotifyWindow ((OAHWND)Window, WM_GRAPHNOTIFY, 0)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
goto bomb3;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetPriorityClass (GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
|
|
|
|
|
|
|
|
I_CheckNativeMouse (true);
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
SetWindowLongPtr (Window, GWLP_WNDPROC, (LONG_PTR)MovieWndProc);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2007-02-13 00:10:16 +00:00
|
|
|
if (FAILED (hr = control->Run ()))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
goto bomb4;
|
|
|
|
}
|
|
|
|
|
|
|
|
MovieInterrupted = false;
|
|
|
|
MovieDestroyed = false;
|
|
|
|
|
|
|
|
while (MovieNotDone && GetMessage (&msg, NULL, 0, 0))
|
|
|
|
{
|
|
|
|
TranslateMessage (&msg);
|
|
|
|
DispatchMessage (&msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
returnval = MovieInterrupted ? MOVIE_Played_Aborted :
|
|
|
|
NoVideo ? MOVIE_Played_NoVideo :
|
|
|
|
MOVIE_Played;
|
|
|
|
|
|
|
|
bomb4:
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
SetWindowLongPtr (Window, GWLP_WNDPROC, (LONG_PTR)WndProc);
|
2006-02-24 04:48:15 +00:00
|
|
|
SetPriorityClass (GetCurrentProcess(), INGAME_PRIORITY_CLASS);
|
|
|
|
|
|
|
|
bomb3:
|
|
|
|
if (hotkey)
|
|
|
|
{
|
|
|
|
UnregisterHotKey (Window, 0);
|
|
|
|
}
|
|
|
|
if (vidwin != NULL)
|
|
|
|
{
|
|
|
|
if (!FullVideo)
|
|
|
|
{
|
|
|
|
vidwin->put_Visible (OAFALSE);
|
|
|
|
vidwin->put_Owner (NULL);
|
|
|
|
}
|
|
|
|
vidwin->Release ();
|
|
|
|
}
|
|
|
|
if (video != NULL)
|
|
|
|
{
|
|
|
|
video->Release ();
|
|
|
|
}
|
|
|
|
if (audio != NULL)
|
|
|
|
{
|
|
|
|
audio->Release ();
|
|
|
|
}
|
|
|
|
if (event != NULL)
|
|
|
|
{
|
|
|
|
event->Release ();
|
|
|
|
}
|
|
|
|
if (control != NULL)
|
|
|
|
{
|
|
|
|
control->Release ();
|
|
|
|
}
|
|
|
|
|
|
|
|
SetActiveWindow (Window);
|
|
|
|
|
|
|
|
bomb2:
|
|
|
|
graph->Release ();
|
|
|
|
|
|
|
|
if (returnSound)
|
|
|
|
{
|
|
|
|
if (GSnd != NULL)
|
|
|
|
{
|
|
|
|
GSnd->MovieResumeSound ();
|
|
|
|
}
|
|
|
|
C_FlushDisplay ();
|
|
|
|
}
|
|
|
|
if (runningFull)
|
|
|
|
{
|
|
|
|
static_cast<Win32Video *> (Video)->GoFullscreen (true);
|
|
|
|
static_cast<BaseWinFB *> (screen)->CreateResources ();
|
|
|
|
}
|
|
|
|
|
|
|
|
bomb1:
|
|
|
|
delete[] uniname;
|
|
|
|
|
|
|
|
if (MovieDestroyed)
|
|
|
|
{
|
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return returnval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CheckIfVideo ()
|
|
|
|
{
|
|
|
|
long visible;
|
|
|
|
|
|
|
|
if (vidwin == NULL || video == NULL)
|
|
|
|
{
|
|
|
|
NoVideo = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (vidwin->get_Visible (&visible) == E_NOINTERFACE)
|
|
|
|
{
|
|
|
|
NoVideo = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NoVideo = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NoVideo)
|
|
|
|
{
|
|
|
|
if (vidwin != NULL)
|
|
|
|
{
|
|
|
|
vidwin->Release ();
|
|
|
|
vidwin = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DHUDMessage *message = new DHUDMessage (
|
|
|
|
"This movie either does not contain a video stream "
|
|
|
|
"or no suitable decompressor could be found.",
|
|
|
|
1.5f, 0.375f, 0, 0, CR_RED, 1.f);
|
|
|
|
StatusBar->AttachMessage (message);
|
|
|
|
screen->Lock (false);
|
|
|
|
StatusBar->Draw (HUD_None);
|
|
|
|
StatusBar->DrawTopStuff (HUD_None);
|
|
|
|
screen->Update ();
|
|
|
|
StatusBar->DetachMessage (message);
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SetTheVolume ()
|
|
|
|
{
|
|
|
|
if (audio != NULL)
|
|
|
|
{
|
|
|
|
// Convert snd_movievolume from a linear range to 1/100th
|
|
|
|
// decibels and pass that to the IBasicAudio interface.
|
|
|
|
long volume;
|
|
|
|
|
|
|
|
if (snd_movievolume == 0.f)
|
|
|
|
{
|
|
|
|
volume = -10000;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
volume = (long)(log10 (snd_movievolume) * 10000.0);
|
|
|
|
}
|
|
|
|
audio->put_Volume (volume);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SizeWindowForVideo ()
|
|
|
|
{
|
|
|
|
LONG width, height;
|
|
|
|
|
|
|
|
if (video == NULL || FAILED (video->GetVideoSize (&width, &height)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
SetWindowPos (Window, NULL, 0, 0,
|
|
|
|
width + 2*GetSystemMetrics(SM_CXBORDER),
|
|
|
|
height + GetSystemMetrics(SM_CYCAPTION) + 2*GetSystemMetrics(SM_CYBORDER),
|
|
|
|
SWP_NOMOVE|SWP_NOOWNERZORDER);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SetMovieSize ()
|
|
|
|
{
|
|
|
|
LONG width, height, left, top;
|
|
|
|
RECT grc;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
GetClientRect (Window, &grc);
|
|
|
|
|
|
|
|
hr = video->GetVideoSize (&width, &height);
|
|
|
|
if (FAILED (hr))
|
|
|
|
{
|
|
|
|
vidwin->SetWindowPosition (0, 0, grc.right, grc.bottom);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
double aspect = (double)height / (double)width;
|
|
|
|
|
|
|
|
// Calculate size of video window that fits in our window
|
|
|
|
if (grc.right > grc.bottom)
|
|
|
|
{
|
|
|
|
height = grc.bottom;
|
|
|
|
width = (LONG)((double)height / aspect);
|
|
|
|
}
|
|
|
|
if (grc.right <= grc.bottom || width > grc.right)
|
|
|
|
{
|
|
|
|
width = grc.right;
|
|
|
|
height = (LONG)((double)width * aspect);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Then center it
|
|
|
|
left = (grc.right - width) / 2;
|
|
|
|
top = (grc.bottom - height) / 2;
|
|
|
|
|
|
|
|
// And use it
|
|
|
|
vidwin->SetWindowPosition (left, top, width, height);
|
|
|
|
|
|
|
|
InvalidateRect (Window, NULL, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // I_DO_NOT_LIKE_BIG_DOWNLOADS
|