Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
GridProps.cpp
Go to the documentation of this file.
1 /* Project Magic 2.0
2  Destroyer Studios LLC
3  Copyright © 1997-2004. All Rights Reserved.
4 
5  SUBSYSTEM: Magic.exe
6  FILE: GridProps.cpp
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Grid Properties Dialog implementation file
13 */
14 
15 
16 #include "stdafx.h"
17 #include "Magic.h"
18 #include "GridProps.h"
19 #include "Grid.h"
20 
21 #ifdef _DEBUG
22 #define new DEBUG_NEW
23 #undef THIS_FILE
24 static char THIS_FILE[] = __FILE__;
25 #endif
26 
27 // +--------------------------------------------------------------------+
28 // GridProps dialog
29 // +--------------------------------------------------------------------+
30 
31 GridProps::GridProps(Grid* g, CWnd* pParent /*=NULL*/)
32  : CDialog(GridProps::IDD, pParent), grid(g)
33 {
34  //{{AFX_DATA_INIT(GridProps)
35  mGridShow = grid->IsShow();
36  mGridSnap = grid->IsSnap();
40  mGridSize = grid->GetSize();
41  //}}AFX_DATA_INIT
42 }
43 
44 static const char* C(CString& str)
45 {
46  static char buf[512];
47  int i;
48  for (i = 0; i < str.GetLength(); i++)
49  buf[i] = (char) str.GetAt(i);
50  buf[i] = 0;
51 
52  return buf;
53 }
54 
55 void GridProps::DoDataExchange(CDataExchange* pDX)
56 {
58  //{{AFX_DATA_MAP(GridProps)
59  DDX_Check(pDX, IDC_GRID_SHOW, mGridShow);
60  DDX_Check(pDX, IDC_GRID_SNAP, mGridSnap);
61  DDX_Text(pDX, IDC_REFERENCE_PLAN, mReferencePlan);
62  DDX_Text(pDX, IDC_REFERENCE_FRONT, mReferenceFront);
63  DDX_Text(pDX, IDC_REFERENCE_SIDE, mReferenceSide);
64  DDX_Text(pDX, IDC_GRID_SIZE, mGridSize);
65  DDV_MinMaxInt(pDX, mGridSize, 1, 64);
66  //}}AFX_DATA_MAP
67 
68  // if saving, write the values back to the grid
69  if (pDX->m_bSaveAndValidate) {
70  grid->SetSnap(mGridSnap ? true : false);
71  grid->SetShow(mGridShow ? true : false);
73 
77  }
78 }
79 
80 
81 BEGIN_MESSAGE_MAP(GridProps, CDialog)
82  //{{AFX_MSG_MAP(GridProps)
83  ON_BN_CLICKED(IDC_FILE_PLAN, OnFilePlan)
84  ON_BN_CLICKED(IDC_FILE_FRONT, OnFileFront)
85  ON_BN_CLICKED(IDC_FILE_SIDE, OnFileSide)
86  //}}AFX_MSG_MAP
87 END_MESSAGE_MAP()
88 
89 // +--------------------------------------------------------------------+
90 
91 static void OnImageFile(CString& strImageFile)
92 {
93  char filename[512];
94  filename[0] = '\0';
95  CFileDialog ofd(TRUE, "pcx");
96 
97  ofd.m_ofn.lpstrFilter = "PCX Files\0*.pcx\0All Files\0*.*\0\0";
98  ofd.m_ofn.lpstrFile = filename;
99  ofd.m_ofn.nMaxFile = sizeof(filename);
100 
101  if (ofd.DoModal() != IDOK)
102  return;
103 
104  char tex_name[512];
105  sprintf(tex_name, "%s", ofd.GetFileName().GetBuffer(0));
106 
107  strImageFile = tex_name;
108 }
109 
111 {
112  OnImageFile(mReferencePlan);
113  UpdateData(FALSE);
114 }
115 
117 {
118  OnImageFile(mReferenceFront);
119  UpdateData(FALSE);
120 }
121 
123 {
124  OnImageFile(mReferenceSide);
125  UpdateData(FALSE);
126 }