rlm@1
|
1 // GSACodeSelect.cpp : implementation file
|
rlm@1
|
2 //
|
rlm@1
|
3
|
rlm@1
|
4 #include "stdafx.h"
|
rlm@1
|
5 #include "resource.h"
|
rlm@1
|
6 #include "GSACodeSelect.h"
|
rlm@1
|
7
|
rlm@1
|
8 /////////////////////////////////////////////////////////////////////////////
|
rlm@1
|
9 // GSACodeSelect dialog
|
rlm@1
|
10
|
rlm@1
|
11 GSACodeSelect::GSACodeSelect(FILE *file, CWnd*pParent /*=NULL*/)
|
rlm@1
|
12 : CDialog(GSACodeSelect::IDD, pParent)
|
rlm@1
|
13 {
|
rlm@1
|
14 //{{AFX_DATA_INIT(GSACodeSelect)
|
rlm@1
|
15 // NOTE: the ClassWizard will add member initialization here
|
rlm@1
|
16 //}}AFX_DATA_INIT
|
rlm@1
|
17 m_file = file;
|
rlm@1
|
18 }
|
rlm@1
|
19
|
rlm@1
|
20 void GSACodeSelect::DoDataExchange(CDataExchange*pDX)
|
rlm@1
|
21 {
|
rlm@1
|
22 CDialog::DoDataExchange(pDX);
|
rlm@1
|
23 //{{AFX_DATA_MAP(GSACodeSelect)
|
rlm@1
|
24 DDX_Control(pDX, IDC_GAME_LIST, m_games);
|
rlm@1
|
25 //}}AFX_DATA_MAP
|
rlm@1
|
26 }
|
rlm@1
|
27
|
rlm@1
|
28 BEGIN_MESSAGE_MAP(GSACodeSelect, CDialog)
|
rlm@1
|
29 //{{AFX_MSG_MAP(GSACodeSelect)
|
rlm@1
|
30 ON_BN_CLICKED(ID_OK, OnOk)
|
rlm@1
|
31 ON_LBN_SELCHANGE(IDC_GAME_LIST, OnSelchangeGameList)
|
rlm@1
|
32 ON_BN_CLICKED(ID_CANCEL, OnCancel)
|
rlm@1
|
33 //}}AFX_MSG_MAP
|
rlm@1
|
34 END_MESSAGE_MAP()
|
rlm@1
|
35
|
rlm@1
|
36 /////////////////////////////////////////////////////////////////////////////
|
rlm@1
|
37 // GSACodeSelect message handlers
|
rlm@1
|
38
|
rlm@1
|
39 void GSACodeSelect::OnCancel()
|
rlm@1
|
40 {
|
rlm@1
|
41 EndDialog(-1);
|
rlm@1
|
42 }
|
rlm@1
|
43
|
rlm@1
|
44 void GSACodeSelect::OnOk()
|
rlm@1
|
45 {
|
rlm@1
|
46 EndDialog(m_games.GetCurSel());
|
rlm@1
|
47 }
|
rlm@1
|
48
|
rlm@1
|
49 void GSACodeSelect::OnSelchangeGameList()
|
rlm@1
|
50 {
|
rlm@1
|
51 int item = m_games.GetCurSel();
|
rlm@1
|
52 CWnd *ok = GetDlgItem(ID_OK);
|
rlm@1
|
53
|
rlm@1
|
54 ok->EnableWindow(item != -1);
|
rlm@1
|
55 }
|
rlm@1
|
56
|
rlm@1
|
57 BOOL GSACodeSelect::OnInitDialog()
|
rlm@1
|
58 {
|
rlm@1
|
59 CDialog::OnInitDialog();
|
rlm@1
|
60
|
rlm@1
|
61 char buffer[1024];
|
rlm@1
|
62
|
rlm@1
|
63 FILE *f = m_file;
|
rlm@1
|
64 int games = 0;
|
rlm@1
|
65 int len = 0;
|
rlm@1
|
66 fseek(f, -4, SEEK_CUR);
|
rlm@1
|
67 fread(&games, 1, 4, f);
|
rlm@1
|
68 while (games > 0)
|
rlm@1
|
69 {
|
rlm@1
|
70 fread(&len, 1, 4, f);
|
rlm@1
|
71 fread(buffer, 1, len, f);
|
rlm@1
|
72 buffer[len] = 0;
|
rlm@1
|
73 m_games.AddString(buffer);
|
rlm@1
|
74 int codes = 0;
|
rlm@1
|
75 fread(&codes, 1, 4, f);
|
rlm@1
|
76
|
rlm@1
|
77 while (codes > 0)
|
rlm@1
|
78 {
|
rlm@1
|
79 fread(&len, 1, 4, f);
|
rlm@1
|
80 fseek(f, len, SEEK_CUR);
|
rlm@1
|
81 fread(&len, 1, 4, f);
|
rlm@1
|
82 fseek(f, len, SEEK_CUR);
|
rlm@1
|
83 fseek(f, 4, SEEK_CUR);
|
rlm@1
|
84 fread(&len, 1, 4, f);
|
rlm@1
|
85 fseek(f, len*12, SEEK_CUR);
|
rlm@1
|
86 codes--;
|
rlm@1
|
87 }
|
rlm@1
|
88 games--;
|
rlm@1
|
89 }
|
rlm@1
|
90 GetDlgItem(ID_OK)->EnableWindow(FALSE);
|
rlm@1
|
91 CenterWindow();
|
rlm@1
|
92
|
rlm@1
|
93 return TRUE; // return TRUE unless you set the focus to a control
|
rlm@1
|
94 // EXCEPTION: OCX Property Pages should return FALSE
|
rlm@1
|
95 }
|
rlm@1
|
96
|