Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

AutoSelect.c File Reference

#include <stdlib.h>
#include <assert.h>
#include <Windows.h>
#include "AutoSelect.h"
#include "ErrorLog.h"
#include "Ram.h"

Go to the source code of this file.

Defines

#define A1_BETTER   (-1)
#define A2_BETTER   ( 1)
#define TIE   ( 0)

Functions

int AutoSelect_Compare (const void *arg1, const void *arg2)
void AutoSelect_SortDriverList (ModeList *DriverList, int ListLength)
void GameMgr_ResetMainWindow (HWND hWnd, int32 Width, int32 Height)
geBoolean AutoSelect_PickDriver (HWND hWnd, geEngine *Engine, ModeList *DriverList, int ListLength, int *Selection)


Define Documentation

#define A1_BETTER   (-1)
 

#define A2_BETTER   ( 1)
 

#define TIE   ( 0)
 


Function Documentation

int AutoSelect_Compare const void *  arg1,
const void *  arg2
[static]
 

Definition at line 28 of file AutoSelect.c.

References ModeList::DriverType, ModeList::Height, ModeList::InAWindow, and ModeList::Width.

Referenced by AutoSelect_SortDriverList().

00029 {
00030         /* used for quicksort comparison.  
00031                 returns <0 if arg1 is 'smaller than' arg2
00032                 returns >0 if arg1 is 'greater than' arg2
00033                 returns =0 if arg1 is 'the same as'  arg2
00034                    since the list is sorted by most desirable mode/resolution first, the better mode is 'smaller than'
00035         */
00036         #define A1_BETTER  (-1)
00037         #define A2_BETTER  ( 1)
00038         #define TIE        ( 0)
00039 
00040         int Compare = 0;
00041         ModeList *A1,*A2;
00042         assert(arg1);
00043         assert(arg2);
00044         A1 = (ModeList *)arg1;
00045         A2 = (ModeList *)arg2;
00046 
00047         // sort by DriverType            (smaller enum value first)
00048         // then by windowed
00049         // then by Width             (larger width first)
00050         // then by Height            (larger height first) 
00051         
00052         if      ( A1->DriverType < A2->DriverType )
00053                 return A1_BETTER;
00054         else if ( A2->DriverType < A1->DriverType )
00055                 return A2_BETTER;
00056 
00057         if              ( !A1->InAWindow && A2->InAWindow )
00058                 return A1_BETTER;
00059         if              ( A1->InAWindow && !A2->InAWindow )
00060                 return A2_BETTER;
00061 
00062         if      ( A1->Width > A2->Width )
00063                 return A1_BETTER;
00064         else if ( A2->Width > A1->Width )
00065                 return A2_BETTER;
00066 
00067         if      ( A1->Height > A2->Height )
00068                 return A1_BETTER;
00069         else if ( A2->Height > A1->Height )
00070                 return A2_BETTER;
00071 
00072         return TIE;
00073 }

geBoolean AutoSelect_PickDriver HWND  hWnd,
geEngine Engine,
ModeList DriverList,
int  ListLength,
int *  Selection
 

Definition at line 83 of file AutoSelect.c.

References Engine, ModeList::Evaluation, GameMgr_ResetMainWindow(), GE_FALSE, GE_TRUE, geBoolean, geEngine_SetDriverAndMode(), geErrorLog_AddString, ModeList::InAWindow, MODELIST_EVALUATED_OK, and NULL.

Referenced by PickMode().

00084 {
00085         int i;
00086 
00087         assert( Engine      != NULL );
00088         assert( DriverList  != NULL );
00089         assert( Selection   != NULL );
00090 
00091         for (i=0; i<ListLength; i++)
00092                 {
00093                         if (DriverList[i].Evaluation == MODELIST_EVALUATED_OK)
00094                                 {
00095                                         if (DriverList[i].InAWindow)
00096                                                 {
00097                                                         GameMgr_ResetMainWindow(hWnd, DriverList[i].Width, DriverList[i].Height);
00098                                                 }
00099 
00100                                         if (!geEngine_SetDriverAndMode(Engine, DriverList[i].Driver, DriverList[i].Mode))
00101                                                 {
00102                                                         geErrorLog_AddString(-1, "AutoSelect_ModeAndDriver:  driver mode set failed.  continuing.  Driver:", DriverList[i].DriverNamePtr);
00103                                                         geErrorLog_AddString(-1, "AutoSelect_ModeAndDriver:  driver mode set failed.  continuing.    Mode:", DriverList[i].ModeNamePtr);
00104                                                 }
00105                                         else 
00106                                                 {
00107                                                         *Selection = i;
00108                                                         return GE_TRUE;
00109                                                 }
00110                                 }
00111                 }
00112 
00113         return GE_FALSE;
00114 }

void AutoSelect_SortDriverList ModeList DriverList,
int  ListLength
 

Definition at line 75 of file AutoSelect.c.

References AutoSelect_Compare().

Referenced by WinMain().

00076 {
00077         qsort( DriverList, ListLength, sizeof( DriverList[0] ), AutoSelect_Compare );
00078 }

void GameMgr_ResetMainWindow HWND  hWnd,
int32  Width,
int32  Height
 

Definition at line 1285 of file GameMgr.c.

01286 {
01287         RECT ScreenRect;
01288 
01289         GetWindowRect(GetDesktopWindow(),&ScreenRect);
01290 
01291         SetWindowLong(hWnd, 
01292                  GWL_STYLE, 
01293                  GetWindowLong(hWnd, GWL_STYLE) & ~WS_POPUP);
01294 
01295         SetWindowLong(hWnd, 
01296                  GWL_STYLE, 
01297                  GetWindowLong(hWnd, GWL_STYLE) | (WS_OVERLAPPED  | 
01298                                                    WS_CAPTION     | 
01299                                                    WS_SYSMENU     | 
01300                                                    WS_MINIMIZEBOX));
01301 
01302         SetWindowLong(hWnd, 
01303                   GWL_STYLE, 
01304                   GetWindowLong(hWnd, GWL_STYLE) | WS_THICKFRAME |
01305                                                      WS_MAXIMIZEBOX);
01306 
01307         //SetWindowLong(hWnd, 
01308     //              GWL_EXSTYLE, 
01309     //              GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_TOPMOST);
01310 
01311         {
01312                 RECT ClientRect;
01313                 int Style = GetWindowLong (hWnd, GWL_STYLE);
01314                 
01315                 ClientRect.left = 0;
01316                 ClientRect.top = 0;
01317                 ClientRect.right = Width - 1;
01318                 ClientRect.bottom = Height - 1;
01319                 AdjustWindowRect (&ClientRect, Style, FALSE);   // FALSE == No menu     
01320                 
01321                 {
01322                         int WindowWidth = ClientRect.right - ClientRect.left + 1;
01323                         int WindowHeight = ClientRect.bottom - ClientRect.top + 1;
01324                         SetWindowPos 
01325                         (
01326                                 hWnd, HWND_TOP,
01327                                 (ScreenRect.right+ScreenRect.left)/2 - WindowWidth/2,
01328                                 (ScreenRect.bottom+ScreenRect.top)/2 - WindowHeight/2, 
01329                                 WindowWidth, WindowHeight,
01330                                 SWP_NOCOPYBITS | SWP_NOZORDER
01331                         );
01332                 }
01333         }
01334 
01335         ShowWindow(hWnd, SW_SHOWNORMAL);
01336         UpdateWindow(hWnd);
01337         SetFocus(hWnd);
01338 }


Generated on Tue Sep 30 12:36:59 2003 for GTestAndEngine by doxygen 1.3.2