-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3DFXDisp.cpp
More file actions
160 lines (127 loc) · 3.42 KB
/
3DFXDisp.cpp
File metadata and controls
160 lines (127 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/* 3DFXDisp.cpp : implementation file
*
* Subtab of the Video tab, handles glide 3dfx mode selection.
* Does not initialise glide, options are avaliable purely on the basis of what
* 'should' be assuming system supports glide
*
* Very similar to the DX5 tab but kept seperate for easy of expansion
*/
#include "stdafx.h"
#include "launcher.h"
#include "3DFXDisp.h"
#include "win32func.h"
#include "launcher_settings.h"
typedef struct
{
int xres;
int yres;
char *text_desc;
} Mode3DFX;
// Glide only allows 16 bit so only two modes possible
const int NUM_3DFX_MODES = 2;
Mode3DFX glide_modes[NUM_3DFX_MODES] =
{
1024, 768, "3DFX Glide (1024x768)",
640, 480, "3DFX Glide (640x480)",
};
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// C3DFXDisp dialog
C3DFXDisp::C3DFXDisp(CWnd* pParent /*=NULL*/)
: CDialog(C3DFXDisp::IDD, pParent)
{
//{{AFX_DATA_INIT(C3DFXDisp)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void C3DFXDisp::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(C3DFXDisp)
DDX_Control(pDX, IDC_GLIDE_RES, m_res_list);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(C3DFXDisp, CDialog)
//{{AFX_MSG_MAP(C3DFXDisp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// C3DFXDisp message handlers
/**
* Initialise the dialog ready for viewing
*/
BOOL C3DFXDisp::OnInitDialog()
{
CDialog::OnInitDialog();
UpdateResList();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
/**
* Applies setting changes to registry
*/
void C3DFXDisp::SaveSettings()
{
// Now apply video mode
int index = m_res_list.GetCurSel();
if( index == CB_ERR)
{
MessageBox("Failed to set graphic mode", "Error", MB_ICONERROR);
return;
}
int current = m_res_list.GetItemData(index);
if(reg_set_sz(LauncherSettings::get_reg_path(), "Videocard", glide_modes[index].text_desc) == false)
{
MessageBox("Failed to set graphic mode", "Error", MB_ICONERROR);
}
if(reg_set_sz(LauncherSettings::get_reg_path(), "VideocardFs2open", glide_modes[index].text_desc) == false)
{
MessageBox("Failed to set graphic mode", "Error", MB_ICONERROR);
}
}
/**
* Determines the current settings in the registry and selects them in the list if avaliable
*/
void C3DFXDisp::LoadSettings()
{
char videocard_string[MAX_PATH];
// Lets get those video card settings
if(reg_get_sz(LauncherSettings::get_reg_path(), "VideocardFs2open", videocard_string, MAX_PATH) == false)
{
return;
}
int count = 0;
for(int i = 0; i < NUM_3DFX_MODES; i++)
{
if(strcmp(videocard_string, glide_modes[i].text_desc) == 0)
{
m_res_list.SetCurSel(count);
return;
}
count++;
}
m_res_list.SetCurSel(0);
}
/**
* Refreshes the list of modes avaliable, this depends on variables that have already
* been set using other functions of this class.
*/
void C3DFXDisp::UpdateResList()
{
int count = 0;
char res_text[20];
m_res_list.ResetContent();
for(int i = 0; i < NUM_3DFX_MODES; i++)
{
sprintf(res_text, "%d x %d", glide_modes[i].xres, glide_modes[i].yres);
// Store the index
int index = m_res_list.InsertString(count, res_text);
m_res_list.SetItemData(index, count);
count++;
}
m_res_list.SetCurSel(0);
}