author | ecalot
<ecalot> 2003-10-11 10:13:15 UTC |
committer | ecalot
<ecalot> 2003-10-11 10:13:15 UTC |
parent | e28f31b9fa2f310d02e72efa4f5c2d6eef8ffc72 |
pv3/ChildFrm.cpp | +88 | -0 |
pv3/ChildFrm.h | +56 | -0 |
pv3/MainFrm.cpp | +109 | -0 |
pv3/MainFrm.h | +58 | -0 |
pv3/MyDialog.cpp | +244 | -0 |
pv3/MyDialog.h | +46 | -0 |
pv3/Princed V3.aps | +0 | -0 |
pv3/Princed V3.clw | +504 | -0 |
pv3/Princed V3.cpp | +207 | -0 |
pv3/Princed V3.dsp | +294 | -0 |
pv3/Princed V3.dsw | +29 | -0 |
pv3/Princed V3.h | +55 | -0 |
pv3/Princed V3.ncb | +1 | -0 |
pv3/Princed V3.opt | +0 | -0 |
pv3/Princed V3.rc | +885 | -0 |
pv3/Princed V3Doc.cpp | +236 | -0 |
pv3/Princed V3Doc.h | +141 | -0 |
pv3/Princed V3View.cpp | +697 | -0 |
pv3/Princed V3View.h | +111 | -0 |
pv3/RegisterWIN32.cpp | +973 | -0 |
pv3/RegisterWIN32.h | +132 | -0 |
pv3/StdAfx.cpp | +8 | -0 |
pv3/StdAfx.h | +28 | -0 |
pv3/cSelectLevelWindow.cpp | +52 | -0 |
pv3/cSelectLevelWindow.h | +46 | -0 |
pv3/conf.cpp | +60 | -0 |
pv3/maps.cpp | +841 | -0 |
pv3/maps.h | +216 | -0 |
pv3/process.cpp | +23 | -0 |
pv3/res/32x32.ped.ico | +0 | -0 |
pv3/res/Princed V3.rc2 | +13 | -0 |
pv3/res/Toolbar.bmp | +0 | -0 |
pv3/res/about.bmp | +0 | -0 |
pv3/res/about.jpg | +0 | -0 |
pv3/res/about_pi.bmp | +0 | -0 |
pv3/res/backmask.bmp | +0 | -0 |
pv3/res/backs.bmp | +0 | -0 |
pv3/res/dropper.cur | +0 | -0 |
pv3/res/elemmask.bmp | +0 | -0 |
pv3/res/elemp.bmp | +0 | -0 |
pv3/res/elempmask.bmp | +0 | -0 |
pv3/res/elems.bmp | +0 | -0 |
pv3/res/guard.bmp | +0 | -0 |
pv3/res/guardmask.bmp | +0 | -0 |
pv3/res/hand.cur | +0 | -0 |
pv3/res/icons & cursors.zip | +0 | -0 |
pv3/res/manifest.txt | +21 | -0 |
pv3/res/newer BMPs.zip | +0 | -0 |
pv3/res/palette.bmp | +0 | -0 |
pv3/res/princed.ico | +0 | -0 |
pv3/res/pspbrwse.jbf | +0 | -0 |
pv3/res/zoomer.cur | +0 | -0 |
pv3/resource.h | +126 | -0 |
pv3/stackqueue.cpp.cpp | +76 | -0 |
pv3/structures.h | +52 | -0 |
diff --git a/pv3/ChildFrm.cpp b/pv3/ChildFrm.cpp new file mode 100644 index 0000000..6346f18 --- /dev/null +++ b/pv3/ChildFrm.cpp @@ -0,0 +1,88 @@ +// ChildFrm.cpp : implementation of the CChildFrame class +// + +#include "stdafx.h" +#include "Princed V3.h" +#include "Princed V3Doc.h" +#include "Princed V3View.h" + +#include "ChildFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CChildFrame + +IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd) + +BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd) + //{{AFX_MSG_MAP(CChildFrame) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CChildFrame construction/destruction + +CChildFrame::CChildFrame() +{ + // TODO: add member initialization code here + +} + +CChildFrame::~CChildFrame() +{ +} + +BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + cs.style=WS_OVERLAPPED|WS_CAPTION|FWS_ADDTOTITLE|WS_THICKFRAME|WS_MAXIMIZE| + WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_CHILD|WS_VISIBLE; + return CMDIChildWnd::PreCreateWindow(cs); +} + + + +///////////////////////////////////////////////////////////////////////////// +// CChildFrame diagnostics + +#ifdef _DEBUG +void CChildFrame::AssertValid() const +{ + CMDIChildWnd::AssertValid(); +} + +void CChildFrame::Dump(CDumpContext& dc) const +{ + CMDIChildWnd::Dump(dc); +} + +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CChildFrame message handlers + +LRESULT CChildFrame::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + switch(message) { + case WM_SETTEXT: + { + CString t; TCHAR pt[10]; int x; + CPrincedV3Doc *pDoc=(DYNAMIC_DOWNCAST(CPrincedV3View, GetActiveView()))->GetDocument(); + x=pDoc->GetLevel(); + if(x!=-1) { + wsprintf(pt, _T(" #%d"), pDoc->GetLevel()); + t=reinterpret_cast<LPCTSTR>(lParam); t+=pt; + return CMDIChildWnd::DefWindowProc(message, wParam, + reinterpret_cast<LPARAM>((LPCTSTR)t)); + } + } + } + + return CMDIChildWnd::DefWindowProc(message, wParam, lParam); +} diff --git a/pv3/ChildFrm.h b/pv3/ChildFrm.h new file mode 100644 index 0000000..5167dce --- /dev/null +++ b/pv3/ChildFrm.h @@ -0,0 +1,56 @@ +// ChildFrm.h : interface of the CChildFrame class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_CHILDFRM_H__B98D158B_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_) +#define AFX_CHILDFRM_H__B98D158B_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +class CChildFrame : public CMDIChildWnd +{ + DECLARE_DYNCREATE(CChildFrame) +public: + CChildFrame(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CChildFrame) + public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + protected: + virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CChildFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +// Generated message map functions +protected: + //{{AFX_MSG(CChildFrame) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CHILDFRM_H__B98D158B_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_) diff --git a/pv3/MainFrm.cpp b/pv3/MainFrm.cpp new file mode 100644 index 0000000..7547f85 --- /dev/null +++ b/pv3/MainFrm.cpp @@ -0,0 +1,109 @@ +// MainFrm.cpp : implementation of the CMainFrame class +// + +#include "stdafx.h" +#include "Princed V3.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame + +IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) + +BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) + //{{AFX_MSG_MAP(CMainFrame) + ON_WM_CREATE() + ON_COMMAND(ID_WINDOW_CLOSEALL, OnWindowCloseall) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // status line indicator + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame construction/destruction + +CMainFrame::CMainFrame() +{ + // TODO: add member initialization code here + +} + +CMainFrame::~CMainFrame() +{ +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + if(!m_wndToolBar.Create(this) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { + TRACE0("Failed to create toolbar\n"); return -1; // fail to create + } + if (!m_wndStatusBar.Create(this) || + !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { + TRACE0("Failed to create status bar\n"); return -1; // fail to create + } + DragAcceptFiles(); + + // TODO: Delete these three lines if you don't want the toolbar to + // be dockable + EnableDocking(CBRS_ALIGN_ANY); + m_wndToolBar.SetBorders(1,3,3,3); + m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | + CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC| CBRS_GRIPPER); + m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT); + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + DockControlBar(&m_wndToolBar); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CMDIFrameWnd::PreCreateWindow(cs) ) + return FALSE; + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame diagnostics + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CMDIFrameWnd::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CMDIFrameWnd::Dump(dc); +} + +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame message handlers + +void CMainFrame::OnWindowCloseall() +{ + CWnd *pWnd=GetActiveFrame(), *tt; + if(pWnd==this) return; //there are no child windows + for(;pWnd;pWnd=tt) { tt=pWnd->GetNextWindow(); pWnd->SendMessage(WM_CLOSE); } +} diff --git a/pv3/MainFrm.h b/pv3/MainFrm.h new file mode 100644 index 0000000..ab95d13 --- /dev/null +++ b/pv3/MainFrm.h @@ -0,0 +1,58 @@ +// MainFrm.h : interface of the CMainFrame class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_MAINFRM_H__B98D1589_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_) +#define AFX_MAINFRM_H__B98D1589_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class CMainFrame : public CMDIFrameWnd +{ + DECLARE_DYNAMIC(CMainFrame) +public: + CMainFrame(); + +// Attributes +public: + void SetStatusText(LPCTSTR tex) { m_wndStatusBar.SetPaneText(0, tex); } + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMainFrame) + public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // control bar embedded members + CStatusBar m_wndStatusBar; + CToolBar m_wndToolBar; + +// Generated message map functions +protected: + //{{AFX_MSG(CMainFrame) + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnWindowCloseall(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MAINFRM_H__B98D1589_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_) diff --git a/pv3/MyDialog.cpp b/pv3/MyDialog.cpp new file mode 100644 index 0000000..45965fc --- /dev/null +++ b/pv3/MyDialog.cpp @@ -0,0 +1,244 @@ +// MyDialog.cpp : implementation file +// System font-censitive dialog class + +#include "stdafx.h" +#include "MyDialog.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CMyDialog dialog + + +///////////////////////////////////////////////////////////////////////////// +// CMyDialog message handlers + +#include <afxpriv.h> +#define DELETE_EXCEPTION(e) do { e->Delete(); } while (0) +int CMyDialog::DoModal() +{ + // can be constructed with a resource template or InitModalIndirect + ASSERT(m_lpszTemplateName != NULL || m_hDialogTemplate != NULL || + m_lpDialogTemplate != NULL); + + // load resource as necessary + LPCDLGTEMPLATE lpDialogTemplate = m_lpDialogTemplate; + HGLOBAL hDialogTemplate = m_hDialogTemplate; + HINSTANCE hInst = AfxGetResourceHandle(); + if (m_lpszTemplateName != NULL) + { + hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG); + HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG); + hDialogTemplate = LoadResource(hInst, hResource); + } + if (hDialogTemplate != NULL) + lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate); + + // return -1 in case of failure to load the dialog template resource + if (lpDialogTemplate == NULL) + return -1; + + // disable parent (before creating dialog) + HWND hWndParent = PreModal(); + AfxUnhookWindowCreate(); + BOOL bEnableParent = FALSE; + if (hWndParent != NULL && ::IsWindowEnabled(hWndParent)) + { + ::EnableWindow(hWndParent, FALSE); + bEnableParent = TRUE; + } + + TRY + { + // create modeless dialog + AfxHookWindowCreate(this); + if (MyCreateDlgIndirect(lpDialogTemplate, + CWnd::FromHandle(hWndParent), hInst)) + { + if (m_nFlags & WF_CONTINUEMODAL) + { + // enter modal loop + DWORD dwFlags = MLF_SHOWONIDLE; + if (GetStyle() & DS_NOIDLEMSG) + dwFlags |= MLF_NOIDLEMSG; + VERIFY(RunModalLoop(dwFlags) == m_nModalResult); + } + + // hide the window before enabling the parent, etc. + if (m_hWnd != NULL) + SetWindowPos(NULL, 0, 0, 0, 0, SWP_HIDEWINDOW| + SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER); + } + } + CATCH_ALL(e) + { + DELETE_EXCEPTION(e); + m_nModalResult = -1; + } + END_CATCH_ALL + + if (bEnableParent) + ::EnableWindow(hWndParent, TRUE); + if (hWndParent != NULL && ::GetActiveWindow() == m_hWnd) + ::SetActiveWindow(hWndParent); + + // destroy modal window + DestroyWindow(); + PostModal(); + + // unlock/free resources as necessary + if (m_lpszTemplateName != NULL || m_hDialogTemplate != NULL) + UnlockResource(hDialogTemplate); + if (m_lpszTemplateName != NULL) + FreeResource(hDialogTemplate); + + return m_nModalResult; +} + +#include <AFXIMPL.H> +#include <OCCIMPL.H> +BOOL CMyDialog::MyCreateDlgIndirect(LPCDLGTEMPLATE lpDialogTemplate, + CWnd* pParentWnd, HINSTANCE hInst) +{ + ASSERT(lpDialogTemplate != NULL); + if (pParentWnd != NULL) + ASSERT_VALID(pParentWnd); + + if (hInst == NULL) + hInst = AfxGetInstanceHandle(); + +#ifndef _AFX_NO_OCC_SUPPORT + _AFX_OCC_DIALOG_INFO occDialogInfo; + COccManager* pOccManager = afxOccManager; +#endif + + HGLOBAL hTemplate = NULL; + + HWND hWnd = NULL; +#ifdef _DEBUG + DWORD dwError = 0; +#endif + + TRY + { + VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTLS_REG)); + AfxDeferRegisterClass(AFX_WNDCOMMCTLSNEW_REG); + +#ifndef _AFX_NO_OCC_SUPPORT + // separately create OLE controls in the dialog template + if (pOccManager != NULL) + { + if (!SetOccDialogInfo(&occDialogInfo)) + return FALSE; + + lpDialogTemplate = pOccManager->PreCreateDialog(&occDialogInfo, + lpDialogTemplate); + } + + if (lpDialogTemplate == NULL) + return FALSE; +#endif //!_AFX_NO_OCC_SUPPORT + + // If no font specified, set the system font. + CString strFace; + WORD wSize = 0; + BOOL bSetSysFont = !CDialogTemplate::GetFont(lpDialogTemplate, strFace, + wSize); + + // On DBCS systems, also change "MS Sans Serif" or "Helv" to system font. + if ((!bSetSysFont) && GetSystemMetrics(SM_DBCSENABLED)) + { + bSetSysFont = (strFace == _T("MS Shell Dlg") || + strFace == _T("MS Sans Serif") || strFace == _T("Helv")); + if (bSetSysFont && (wSize == 8)) + wSize = 0; + } + + if (bSetSysFont) + { + LOGFONT lg; int x; HDC hDC=::GetDC(NULL); + //::GetObject(::GetStockObject(DEFAULT_GUI_FONT), sizeof(lg), &lg); + ::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lg), &lg, SPIF_UPDATEINIFILE); + CDialogTemplate dlgTemp(lpDialogTemplate); + x=MulDiv(abs(lg.lfHeight), 72, ::GetDeviceCaps(hDC, LOGPIXELSY)); + dlgTemp.SetFont(lg.lfFaceName, x); + hTemplate = dlgTemp.Detach(); ::ReleaseDC(NULL, hDC); + } + + if (hTemplate != NULL) + lpDialogTemplate = (DLGTEMPLATE*)GlobalLock(hTemplate); + + // setup for modal loop and creation + m_nModalResult = -1; + m_nFlags |= WF_CONTINUEMODAL; + + // create modeless dialog + AfxHookWindowCreate(this); + hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate, + pParentWnd->GetSafeHwnd(), AfxDlgProc); +#ifdef _DEBUG + dwError = ::GetLastError(); +#endif + } + CATCH_ALL(e) + { + DELETE_EXCEPTION(e); + m_nModalResult = -1; + } + END_CATCH_ALL + +#ifndef _AFX_NO_OCC_SUPPORT + if (pOccManager != NULL) + { + pOccManager->PostCreateDialog(&occDialogInfo); + if (hWnd != NULL) + SetOccDialogInfo(NULL); + } +#endif //!_AFX_NO_OCC_SUPPORT + + if (!AfxUnhookWindowCreate()) + PostNcDestroy(); // cleanup if Create fails too soon + + // handle EndDialog calls during OnInitDialog + if (hWnd != NULL && !(m_nFlags & WF_CONTINUEMODAL)) + { + ::DestroyWindow(hWnd); + hWnd = NULL; + } + + if (hTemplate != NULL) + { + GlobalUnlock(hTemplate); + GlobalFree(hTemplate); + } + + // help with error diagnosis (only if WM_INITDIALOG didn't EndDialog()) + if (hWnd == NULL) + { +#ifdef _DEBUG +#ifndef _AFX_NO_OCC_SUPPORT + if (m_nFlags & WF_CONTINUEMODAL) + { + if (afxOccManager == NULL) + { + TRACE0(">>> If this dialog has OLE controls:\n"); + TRACE0(">>> AfxEnableControlContainer has not been called yet.\n"); + TRACE0(">>> You should call it in your app's InitInstance function.\n"); + } + else if (dwError != 0) + { + TRACE1("Warning: Dialog creation failed! GetLastError returns 0x%8.8X\n", dwError); + } + } +#endif //!_AFX_NO_OCC_SUPPORT +#endif //_DEBUG + return FALSE; + } + + ASSERT(hWnd == m_hWnd); + return TRUE; +} diff --git a/pv3/MyDialog.h b/pv3/MyDialog.h new file mode 100644 index 0000000..1d72dac --- /dev/null +++ b/pv3/MyDialog.h @@ -0,0 +1,46 @@ +#if !defined(AFX_MYDIALOG_H__95397FE7_7038_4655_95B1_9BBAA2390A38__INCLUDED_) +#define AFX_MYDIALOG_H__95397FE7_7038_4655_95B1_9BBAA2390A38__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// MyDialog.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CMyDialog dialog + +class CMyDialog : public CDialog +{ +// Construction +public: + CMyDialog(LPCTSTR lpszTemp, CWnd* pParentWnd = NULL): CDialog(lpszTemp, pParentWnd) + { + } + CMyDialog(UINT nIDTemplate, CWnd* pParentWnd = NULL): CDialog(nIDTemplate, pParentWnd) + { + } + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMyDialog) + public: + virtual int DoModal(); + protected: + //}}AFX_VIRTUAL + +// Implementation +protected: + BOOL MyCreateDlgIndirect(LPCDLGTEMPLATE lpDialogTemplate, + CWnd* pParentWnd, HINSTANCE hInst); + + // Generated message map functions + //{{AFX_MSG(CMyDialog) + // NOTE: the ClassWizard will add member functions here + //}}AFX_MSG +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MYDIALOG_H__95397FE7_7038_4655_95B1_9BBAA2390A38__INCLUDED_) diff --git a/pv3/Princed V3.aps b/pv3/Princed V3.aps new file mode 100644 index 0000000..5eccb8c Binary files /dev/null and b/pv3/Princed V3.aps differ diff --git a/pv3/Princed V3.clw b/pv3/Princed V3.clw new file mode 100644 index 0000000..7dce712 --- /dev/null +++ b/pv3/Princed V3.clw @@ -0,0 +1,504 @@ +; CLW file contains information for the MFC ClassWizard + +[General Info] +Version=1 +LastClass=CAboutDlg +LastTemplate=CDialog +NewFileInclude1=#include "stdafx.h" +NewFileInclude2=#include "Princed V3.h" +LastPage=0 + +ClassCount=7 +Class1=CPrincedV3App +Class2=CPrincedV3Doc +Class3=CPrincedV3View +Class4=CMainFrame + +ResourceCount=11 +Resource1=IDD_ABOUTBOX +Resource2=IDR_MAINFRAME +Resource3=IDR_PRINCETYPE +Class5=CChildFrame +Class6=CAboutDlg +Resource4=IDR_TOOLPAL (English (U.S.)) +Resource5=IDD_EDIT_SAV +Resource6=IDD_DIALOG1 +Class7=cSelectLevelWindow +Resource7=IDD_DIALOG_SELECT_LEVEL (English (U.S.)) +Resource8=IDD_EDIT_SAV (English (U.S.)) +Resource9=IDD_ABOUTBOX (English (U.S.)) +Resource10=IDR_PRINCETYPE (English (U.S.)) +Resource11=IDR_MAINFRAME (English (U.S.)) + +[CLS:CPrincedV3App] +Type=0 +HeaderFile=Princed V3.h +ImplementationFile=Princed V3.cpp +Filter=N +LastObject=CPrincedV3App +BaseClass=CWinApp +VirtualFilter=AC + +[CLS:CPrincedV3Doc] +Type=0 +HeaderFile=Princed V3Doc.h +ImplementationFile=Princed V3Doc.cpp +Filter=N +LastObject=CPrincedV3Doc +BaseClass=CDocument +VirtualFilter=DC + +[CLS:CPrincedV3View] +Type=0 +HeaderFile=Princed V3View.h +ImplementationFile=Princed V3View.cpp +Filter=C +LastObject=CPrincedV3View +BaseClass=CScrollView +VirtualFilter=VWC + + +[CLS:CMainFrame] +Type=0 +HeaderFile=MainFrm.h +ImplementationFile=MainFrm.cpp +Filter=T +LastObject=CMainFrame +BaseClass=CMDIFrameWnd +VirtualFilter=fWC + + +[CLS:CChildFrame] +Type=0 +HeaderFile=ChildFrm.h +ImplementationFile=ChildFrm.cpp +Filter=M +LastObject=CChildFrame +BaseClass=CMDIChildWnd +VirtualFilter=mfWC + + +[CLS:CAboutDlg] +Type=0 +HeaderFile=Princed V3.cpp +ImplementationFile=Princed V3.cpp +Filter=D +LastObject=CAboutDlg +BaseClass=CMyDialog +VirtualFilter=dWC + +[DLG:IDD_ABOUTBOX] +Type=1 +ControlCount=4 +Control1=IDC_STATIC,static,1342177283 +Control2=IDC_STATIC,static,1342308352 +Control3=IDC_STATIC,static,1342308352 +Control4=IDOK,button,1342373889 +Class=CAboutDlg + +[MNU:IDR_MAINFRAME] +Type=1 +Class=CMainFrame +Command1=ID_FILE_NEW +Command2=ID_FILE_OPEN +Command3=ID_FILE_PRINT_SETUP +Command4=ID_FILE_MRU_FILE1 +Command5=ID_APP_EXIT +Command6=ID_VIEW_TOOLBAR +Command7=ID_VIEW_STATUS_BAR +CommandCount=8 +Command8=ID_APP_ABOUT + +[TB:IDR_MAINFRAME] +Type=1 +Class=CMainFrame +Command1=ID_FILE_NEW +Command2=ID_FILE_OPEN +Command3=ID_FILE_SAVE +Command4=ID_EDIT_CUT +Command5=ID_EDIT_COPY +Command6=ID_EDIT_PASTE +Command7=ID_FILE_PRINT +CommandCount=8 +Command8=ID_APP_ABOUT + +[MNU:IDR_PRINCETYPE] +Type=1 +Class=CPrincedV3View +Command1=ID_FILE_NEW +Command2=ID_FILE_OPEN +Command3=ID_FILE_CLOSE +Command4=ID_FILE_SAVE +Command5=ID_FILE_SAVE_AS +Command6=ID_FILE_PRINT +Command7=ID_FILE_PRINT_PREVIEW +Command8=ID_FILE_PRINT_SETUP +Command9=ID_FILE_MRU_FILE1 +Command10=ID_APP_EXIT +Command11=ID_EDIT_UNDO +Command12=ID_EDIT_CUT +Command13=ID_EDIT_COPY +Command14=ID_EDIT_PASTE +CommandCount=21 +Command15=ID_VIEW_TOOLBAR +Command16=ID_VIEW_STATUS_BAR +Command17=ID_WINDOW_NEW +Command18=ID_WINDOW_CASCADE +Command19=ID_WINDOW_TILE_HORZ +Command20=ID_WINDOW_ARRANGE +Command21=ID_APP_ABOUT + +[ACL:IDR_MAINFRAME] +Type=1 +Class=CMainFrame +Command1=ID_FILE_NEW +Command2=ID_FILE_OPEN +Command3=ID_FILE_SAVE +Command4=ID_FILE_PRINT +Command5=ID_EDIT_UNDO +Command6=ID_EDIT_CUT +Command7=ID_EDIT_COPY +Command8=ID_EDIT_PASTE +Command9=ID_EDIT_UNDO +Command10=ID_EDIT_CUT +Command11=ID_EDIT_COPY +Command12=ID_EDIT_PASTE +CommandCount=14 +Command13=ID_NEXT_PANE +Command14=ID_PREV_PANE + + +[MNU:IDR_MAINFRAME (English (U.S.))] +Type=1 +Class=? +Command1=ID_FILE_NEW +Command2=ID_FILE_OPEN +Command3=ID_FILE_CLOSE +Command4=ID_FILE_SAVE +Command5=ID_FILE_SAVE_AS +Command6=ID_FILE_SAVEALL +Command7=ID_FILE_COMPILEDAT +Command8=ID_FILE_UNCOMPILEDAT +Command9=ID_FILE_PUBLISHDAT +Command10=ID_FILE_EXPORTTOIMAGE +Command11=ID_FILE_EXPORTTOTEXT +Command12=ID_FILE_EXPORTTOHTML +Command13=ID_FILE_SEARCHFILES +Command14=ID_FILE_PREFERENCES +Command15=ID_FILE_MRU_FILE1 +Command16=ID_APP_EXIT +Command17=ID_VIEW_TOOLBAR +Command18=ID_VIEW_STATUS_BAR +Command19=ID_VIEW_MAPTOOLS +Command20=ID_VIEW_TOOLOPTIONSWINDOW +Command21=ID_VIEW_LEVELPROPERTRIES +Command22=ID_VIEW_OPENLEVELS +Command23=ID_VIEW_READERSCREENMENU +Command24=ID_VIEW_TOGGLEGRID +Command25=ID_VIEW_TOGGLERULERS +Command26=ID_VIEW_IN +Command27=ID_VIEW_ZOOM_OUT +Command28=ID_VIEW_ZOOM_FITSCREENTOWINDOW +Command29=ID_VIEW_ZOOM_200 +Command30=ID_VIEW_ZOOM_100 +Command31=ID_VIEW_ZOOM_50 +Command32=ID_VIEW_ZOOM_25 +Command33=ID_VIEW_ZOOM_FITLEVELTOWINDOW +Command34=ID_DEBUG_RUNLEVELFROMDEGUBPOSITION +Command35=ID_DEBUG_RUNLEVELFROMSTARTPOSITION +Command36=ID_DEBUG_REFRESHRUNNINGLEVE +Command37=ID_DEBUG_RUNDATFILE +Command38=ID_DEBUG_STOPRUNNING +Command39=ID_DEBUG_EXECUTEPRINCEOFPERSIA +Command40=ID_ADDONS_EDITHALLOFFAME +Command41=ID_ADDONS_EDITSAVEDGAME +Command42=ID_ADDONS_EDITGRAPHICS +Command43=ID_ADDONS_EDITPRINCEEXE +Command44=ID_HELP_HELPTOPICS +Command45=ID_HELP_INDEX +Command46=ID_HELP_LICENSE +Command47=ID_HELP_FREQUENTLYASKEDQUESTIONS +Command48=ID_HELP_PRINCEDHOMEPAGE +Command49=ID_APP_ABOUT +CommandCount=49 + +[MNU:IDR_PRINCETYPE (English (U.S.))] +Type=1 +Class=CPrincedV3View +Command1=ID_FILE_NEW +Command2=ID_FILE_OPEN +Command3=ID_FILE_CLOSE +Command4=ID_FILE_SAVE +Command5=ID_FILE_SAVE_AS +Command6=ID_FILE_SAVEALL +Command7=ID_FILE_COMPILEDAT +Command8=ID_FILE_UNCOMPILEDAT +Command9=ID_FILE_PUBLISHDAT +Command10=ID_FILE_EXPORTTOIMAGE +Command11=ID_FILE_EXPORTTOTEXT +Command12=ID_FILE_EXPORTTOHTML +Command13=ID_FILE_SEARCHFILES +Command14=ID_FILE_PREFERENCES +Command15=ID_FILE_MRU_FILE1 +Command16=ID_APP_EXIT +Command17=ID_EDIT_UNDO +Command18=ID_EDIT_REDO +Command19=ID_EDIT_CUT +Command20=ID_EDIT_COPY +Command21=ID_EDIT_PASTE +Command22=ID_EDIT_CLEARSELECTION +Command23=ID_VIEW_TOOLBAR +Command24=ID_VIEW_STATUS_BAR +Command25=ID_VIEW_MAPTOOLS +Command26=ID_VIEW_TOOLOPTIONSWINDOW +Command27=ID_VIEW_LEVELPROPERTRIES +Command28=ID_VIEW_OPENLEVELS +Command29=ID_VIEW_READERSCREENMENU +Command30=ID_VIEW_ASPALACE +Command31=ID_VIEW_ASDUNGEON +Command32=ID_VIEW_TOGGLEGRID +Command33=ID_VIEW_TOGGLERULERS +Command34=ID_VIEW_ZOOM_IN +Command35=ID_VIEW_ZOOM_OUT +Command36=ID_VIEW_ZOOM_FITSCREENTOWINDOW +Command37=ID_VIEW_ZOOM_200 +Command38=ID_VIEW_ZOOM_100 +Command39=ID_VIEW_ZOOM_50 +Command40=ID_VIEW_ZOOM_25 +Command41=ID_VIEW_ZOOM_FITLEVELTOWINDOW +Command42=ID_MAPTOOLS_WALL +Command43=ID_MAPTOOLS_CLEAR +Command44=ID_MAPTOOLS_OBJECTS_POSSION +Command45=ID_MAPTOOLS_WALKABLE_BALDOZACONESQUELETO +Command46=ID_MAPTOOLS_SWORD +Command47=ID_MAPTOOLS_OBJECTS_STARTPOSITION +Command48=ID_MAPTOOLS_OBJECTS_DEBUGPOSITION +Command49=ID_MAPTOOLS_OBJECTS_GUARDS +Command50=ID_MAPTOOLS_BACKGROUND_LIGHT +Command51=ID_MAPTOOLS_BACKGROUND_BRICKS +Command52=ID_MAPTOOLS_BACKGROUND_WINDOW +Command53=ID_MAPTOOLS_BACKGROUND_BIGWINDOW +Command54=ID_MAPTOOLS_BACKGROUND_COLUMN +Command55=ID_MAPTOOLS_BACKGROUND_BIGCOLUMN +Command56=ID_MAPTOOLS_BACKGROUND_RANDOM +Command57=ID_MAPTOOLS_WALKABLE_NORMAL +Command58=ID_MAPTOOLS_WALKABLE_BALDOZAROTA +Command59=ID_MAPTOOLS_WALKABLE_BALDOZAFLOJA +Command60=ID_MAPTOOLS_WALKABLE_BALDOZAAPRETABLE +Command61=ID_MAPTOOLS_WALKABLE_DOORCLOSER +Command62=ID_MAPTOOLS_WALKABLE_PINCHES +Command63=ID_MAPTOOLS_WALKABLE_RANDOM +Command64=ID_MAPTOOLS_GATES_DOOR +Command65=ID_MAPTOOLS_GATES_PUERTASIERRA +Command66=ID_MAPTOOLS_GATES_LEVELGATE +Command67=ID_MAPTOOLS_ARRASTRAR +Command68=ID_MAPTOOLS_SELECT +Command69=ID_MAPTOOLS_ZOOM +Command70=ID_MAPTOOLS_DROPPER +Command71=ID_DEBUG_RUNLEVELFROMDEGUBPOSITION +Command72=ID_DEBUG_RUNLEVELFROMSTARTPOSITION +Command73=ID_DEBUG_REFRESHRUNNINGLEVE +Command74=ID_DEBUG_RUNDATFILE +Command75=ID_DEBUG_STOPRUNNING +Command76=ID_DEBUG_EXECUTEPRINCEOFPERSIA +Command77=ID_ADDONS_EDITHALLOFFAME +Command78=ID_ADDONS_EDITSAVEDGAME +Command79=ID_ADDONS_EDITGRAPHICS +Command80=ID_ADDONS_EDITPRINCEEXE +Command81=ID_WINDOW_FITTOLEVEL +Command82=ID_WINDOW_TILE_HORZ +Command83=ID_WINDOW_TILE_VERT +Command84=ID_WINDOW_CASCADE +Command85=ID_WINDOW_ARRANGE +Command86=ID_WINDOW_CLOSEALL +Command87=ID_HELP_HELPTOPICS +Command88=ID_HELP_INDEX +Command89=ID_HELP_LICENSE +Command90=ID_HELP_FREQUENTLYASKEDQUESTIONS +Command91=ID_HELP_PRINCEDHOMEPAGE +Command92=ID_APP_ABOUT +CommandCount=92 + +[TB:IDR_MAINFRAME (English (U.S.))] +Type=1 +Class=? +Command1=ID_FILE_NEW +Command2=ID_FILE_OPEN +Command3=ID_FILE_SAVE +Command4=ID_EDIT_CUT +Command5=ID_EDIT_COPY +Command6=ID_EDIT_PASTE +Command7=ID_FILE_PRINT +Command8=ID_APP_ABOUT +CommandCount=8 + +[ACL:IDR_MAINFRAME (English (U.S.))] +Type=1 +Class=? +Command1=ID_ADDONS_EDITHALLOFFAME +Command2=ID_ADDONS_EDITSAVEDGAME +Command3=ID_ADDONS_EDITGRAPHICS +Command4=ID_ADDONS_EDITPRINCEEXE +Command5=ID_VIEW_STATUS_BAR +Command6=ID_DEBUG_REFRESHRUNNINGLEVE +Command7=ID_MAPTOOLS_WALKABLE_BALDOZAROTA +Command8=ID_MAPTOOLS_BACKGROUND_RANDOM +Command9=ID_MAPTOOLS_BACKGROUND_BRICKS +Command10=ID_MAPTOOLS_WALKABLE_DOORCLOSER +Command11=ID_EDIT_COPY +Command12=ID_MAPTOOLS_BACKGROUND_BIGCOLUMN +Command13=ID_MAPTOOLS_BACKGROUND_COLUMN +Command14=ID_MAPTOOLS_GATES_DOOR +Command15=ID_FILE_COMPILEDAT +Command16=ID_MAPTOOLS_DROPPER +Command17=ID_ADDONS_EDITPRINCEEXE +Command18=ID_MAPTOOLS_WALKABLE_NORMAL +Command19=ID_FILE_SEARCHFILES +Command20=ID_ADDONS_EDITHALLOFFAME +Command21=ID_MAPTOOLS_OBJECTS_GUARDS +Command22=ID_VIEW_TOGGLEGRID +Command23=ID_MAPTOOLS_GATES_PUERTASIERRA +Command24=ID_FILE_EXPORTTOHTML +Command25=ID_MAPTOOLS_ARRASTRAR +Command26=ID_MAPTOOLS_BACKGROUND_BIGWINDOW +Command27=ID_MAPTOOLS_OBJECTS_DEBUGPOSITION +Command28=ID_FILE_EXPORTTOIMAGE +Command29=ID_MAPTOOLS_BACKGROUND_WINDOW +Command30=ID_MAPTOOLS_WALKABLE_BALDOZACONESQUELETO +Command31=ID_ADDONS_EDITGRAPHICS +Command32=ID_MAPTOOLS_WALKABLE_BALDOZAFLOJA +Command33=ID_VIEW_OPENLEVELS +Command34=ID_VIEW_TOOLOPTIONSWINDOW +Command35=ID_MAPTOOLS_OBJECTS_STARTPOSITION +Command36=ID_FILE_NEW +Command37=ID_MAPTOOLS_WALKABLE_BALDOZAAPRETABLE +Command38=ID_FILE_OPEN +Command39=ID_MAPTOOLS_OBJECTS_POSSION +Command40=ID_FILE_PUBLISHDAT +Command41=ID_MAPTOOLS_WALKABLE_RANDOM +Command42=ID_APP_EXIT +Command43=ID_MAPTOOLS_SWORD +Command44=ID_VIEW_TOGGLERULERS +Command45=ID_MAPTOOLS_CLEAR +Command46=ID_FILE_SAVE +Command47=ID_MAPTOOLS_SELECT +Command48=ID_MAPTOOLS_WALKABLE_PINCHES +Command49=ID_MAPTOOLS_GATES_LEVELGATE +Command50=ID_FILE_EXPORTTOTEXT +Command51=ID_VIEW_TOOLBAR +Command52=ID_MAPTOOLS_BACKGROUND_LIGHT +Command53=ID_FILE_UNCOMPILEDAT +Command54=ID_EDIT_PASTE +Command55=ID_VIEW_ZOOM_IN +Command56=ID_EDIT_UNDO +Command57=ID_EDIT_CLEARSELECTION +Command58=ID_EDIT_CUT +Command59=ID_VIEW_ZOOM_FITSCREENTOWINDOW +Command60=ID_HELP_HELPTOPICS +Command61=ID_HELP_INDEX +Command62=ID_HELP_PRINCEDHOMEPAGE +Command63=ID_DEBUG_EXECUTEPRINCEOFPERSIA +Command64=ID_VIEW_LEVELPROPERTRIES +Command65=ID_WINDOW_CLOSEALL +Command66=ID_DEBUG_RUNLEVELFROMDEGUBPOSITION +Command67=ID_DEBUG_RUNLEVELFROMSTARTPOSITION +Command68=ID_NEXT_PANE +Command69=ID_WINDOW_FITTOLEVEL +Command70=ID_PREV_PANE +Command71=ID_FILE_PREFERENCES +Command72=ID_DEBUG_RUNDATFILE +Command73=ID_DEBUG_STOPRUNNING +Command74=ID_EDIT_COPY +Command75=ID_EDIT_PASTE +Command76=ID_VIEW_ZOOM_FITLEVELTOWINDOW +Command77=ID_VIEW_ZOOM_OUT +Command78=ID_MAPTOOLS_WALL +Command79=ID_EDIT_CUT +Command80=ID_EDIT_REDO +Command81=ID_EDIT_UNDO +Command82=ID_MAPTOOLS_ZOOM +CommandCount=82 + +[DLG:IDD_ABOUTBOX (English (U.S.))] +Type=1 +Class=CAboutDlg +ControlCount=7 +Control1=IDC_STATIC,static,1342177294 +Control2=IDC_STATIC,static,1342308480 +Control3=IDC_STATIC,static,1342308352 +Control4=IDOK,button,1342373889 +Control5=IDC_STATIC,static,1342308352 +Control6=IDC_STATIC,static,1342308352 +Control7=IDC_EDIT2,edit,1352730628 + +[DLG:IDD_DIALOG_SELECT_LEVEL (English (U.S.))] +Type=1 +Class=cSelectLevelWindow +ControlCount=4 +Control1=IDOK,button,1342242817 +Control2=IDCANCEL,button,1342242816 +Control3=IDC_COMBO1,combobox,1344340226 +Control4=IDC_STATIC,static,1342308352 + +[CLS:cSelectLevelWindow] +Type=0 +HeaderFile=cSelectLevelWindow.h +ImplementationFile=cSelectLevelWindow.cpp +BaseClass=CDialog +Filter=D +LastObject=cSelectLevelWindow +VirtualFilter=dWC + +[DLG:IDD_EDIT_SAV] +Type=1 +Class=? +ControlCount=10 +Control1=IDCANCEL,button,1342242816 +Control2=IDC_STATIC,static,1342308352 +Control3=IDC_EDIT1,edit,1350631552 +Control4=IDC_BROWSE,button,1342242816 +Control5=IDC_STATIC,static,1342177296 +Control6=IDC_OPEN,button,1342242816 +Control7=IDC_SAVE,button,1342242816 +Control8=IDC_STATIC,static,1342308352 +Control9=IDC_LEVEL,edit,1350631552 +Control10=IDC_SPIN1,msctls_updown32,1342177312 + +[TB:IDR_TOOLPAL (English (U.S.))] +Type=1 +Class=? +Command1=ID_TOOL_SELECTION +Command2=ID_BUTTON32903 +Command3=ID_BUTTON32904 +CommandCount=3 + +[DLG:IDD_EDIT_SAV (English (U.S.))] +Type=1 +Class=? +ControlCount=15 +Control1=IDCANCEL,button,1342242816 +Control2=IDC_STATIC,static,1342308352 +Control3=IDC_EDIT1,edit,1350631552 +Control4=IDC_BROWSE,button,1342242816 +Control5=IDC_STATIC,static,1342177296 +Control6=IDC_OPEN,button,1342242816 +Control7=IDC_SAVE,button,1342242816 +Control8=IDC_STATIC,static,1342308352 +Control9=IDC_COMBO1,combobox,1344340226 +Control10=IDC_STATIC,static,1342308352 +Control11=IDC_EDIT2,edit,1350631552 +Control12=IDC_SPIN1,msctls_updown32,1342177312 +Control13=IDC_STATIC,static,1342308352 +Control14=IDC_BUTTON1,button,1342242816 +Control15=IDC_EDIT3,edit,1350631552 + +[DLG:IDD_DIALOG1] +Type=1 +Class=? +ControlCount=5 +Control1=IDC_BUTTON1,button,1342177280 +Control2=IDC_BUTTON2,button,1342177280 +Control3=IDC_BUTTON3,button,1342177280 +Control4=IDC_STATIC,button,1342177287 +Control5=IDC_BUTTON4,button,1342177280 + diff --git a/pv3/Princed V3.cpp b/pv3/Princed V3.cpp new file mode 100644 index 0000000..b79a9e3 --- /dev/null +++ b/pv3/Princed V3.cpp @@ -0,0 +1,207 @@ +// Princed V3.cpp : Defines the class behaviors for the application. +// + +#include "stdafx.h" +#include "Princed V3.h" + +#include "MainFrm.h" +#include "ChildFrm.h" +#include "maps.h" +#include "Princed V3Doc.h" +#include "Princed V3View.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CPrincedV3App + +BEGIN_MESSAGE_MAP(CPrincedV3App, CWinApp) + //{{AFX_MSG_MAP(CPrincedV3App) + ON_COMMAND(ID_APP_ABOUT, OnAppAbout) + ON_COMMAND(ID_FILE_EXPORTTOIMAGE, OnFileExporttoimage) + ON_COMMAND(ID_HELP_PRINCEDHOMEPAGE, OnHelpPrincedhomepage) + ON_COMMAND(ID_ADDONS_EDITSAVEDGAME, OnAddonsEditsavedgame) + //}}AFX_MSG_MAP + // Standard file based document commands + ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) + // Standard print setup command + //ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CPrincedV3App construction + +CPrincedV3App::CPrincedV3App() +{ + // TODO: add construction code here, + // Place all significant initialization in InitInstance +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CPrincedV3App object + +CPrincedV3App theApp; + +///////////////////////////////////////////////////////////////////////////// +// CPrincedV3App initialization + +BOOL CPrincedV3App::InitInstance() +{ + if (!AfxSocketInit()) { + AfxMessageBox(IDP_SOCKETS_INIT_FAILED); + return FALSE; + } + AfxEnableControlContainer(); + + // Standard initialization + // If you are not using these features and wish to reduce the size + // of your final executable, you should remove from the following + // the specific initialization routines you do not need. + +#ifdef _AFXDLL + Enable3dControls(); // Call this when using MFC in a shared DLL +#else + Enable3dControlsStatic(); // Call this when linking to MFC statically +#endif + + // Change the registry key under which our settings are stored. + // TODO: You should modify this string to be something appropriate + // such as the name of your company or organization. + SetRegistryKey(_T("Princed Development Team-Princed V3")); + LoadStdProfileSettings(6); // Load standard INI file options (including MRU) + + // Register the application's document templates. Document templates + // serve as the connection between documents, frame windows and views. + + CMultiDocTemplate* pDocTemplate; + pDocTemplate = new CMultiDocTemplate( + IDR_PRINCETYPE, + RUNTIME_CLASS(CPrincedV3Doc), + RUNTIME_CLASS(CChildFrame), // custom MDI child frame + RUNTIME_CLASS(CPrincedV3View)); + AddDocTemplate(pDocTemplate); + + // create main MDI Frame window + CMainFrame* pMainFrame = new CMainFrame; + if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; + m_pMainWnd = pMainFrame; + + // Parse command line for standard shell commands, DDE, file open + CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); + + // Dispatch commands specified on the command line + if(!ProcessShellCommand(cmdInfo)) return FALSE; + + // The main window has been initialized, so show and update it. + pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); + + return TRUE; +} + + +///////////////////////////////////////////////////////////////////////////// +// CAboutDlg dialog used for App About + +#include "MyDialog.h" +class CAboutDlg : public CMyDialog +{ +public: + CAboutDlg(); + +// Dialog Data + //{{AFX_DATA(CAboutDlg) + enum { IDD = IDD_ABOUTBOX }; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CAboutDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + //{{AFX_MSG(CAboutDlg) + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CMyDialog(CAboutDlg::IDD) +{ + //{{AFX_DATA_INIT(CAboutDlg) + //}}AFX_DATA_INIT +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CMyDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CAboutDlg) + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CMyDialog) + //{{AFX_MSG_MAP(CAboutDlg) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// App command to run the dialog +void CPrincedV3App::OnAppAbout() +{ + CAboutDlg aboutDlg;aboutDlg.DoModal(); +} + +///////////////////////////////////////////////////////////////////////////// +// CPrincedV3App message handlers + + +void CPrincedV3App::OnFileExporttoimage() +{ + // TODO: Add your command handler code here + /* + cConfig c; + char* valor; + c.getSetting("pop1 path",valor); + msgBox(valor); + */ +} + +void msgBox(char *text) { + AfxMessageBox(_T(text),MB_OK,MB_ICONINFORMATION); +} + +//Open Princed's official homepage +void CPrincedV3App::OnHelpPrincedhomepage() +{ + CWaitCursor cur; CString hp; hp.LoadString(IDS_PRINCED_HOMEPAGE); + ::ShellExecute(*AfxGetMainWnd(), _T("open"), hp, NULL, NULL, SW_SHOW); +} + +BOOL CPrincedV3App::OnIdle(LONG lCount) +{ + CPrincedV3View *pView=DYNAMIC_DOWNCAST(CPrincedV3View, CWnd::GetFocus()); + if(pView) return pView->HandleKey(); else return CWinApp::OnIdle(lCount); +} + +void CPrincedV3App::OnAddonsEditsavedgame() +{ + CDialog dlg(IDD_EDIT_SAV); dlg.DoModal(); +} + +BOOL CAboutDlg::OnInitDialog() +{ + CMyDialog::OnInitDialog(); + + // TODO: Add extra initialization here + //void SetWindowText( LPCTSTR lpszString ); + + + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} diff --git a/pv3/Princed V3.dsp b/pv3/Princed V3.dsp new file mode 100644 index 0000000..9cdfd5f --- /dev/null +++ b/pv3/Princed V3.dsp @@ -0,0 +1,294 @@ +# Microsoft Developer Studio Project File - Name="Princed V3" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=Princed V3 - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Princed V3.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Princed V3.mak" CFG="Princed V3 - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Princed V3 - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "Princed V3 - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Princed V3 - Win32 Release" + +# PROP BASE Use_MFC 6 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 6 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x2c0a /d "NDEBUG" /d "_AFXDLL" +# ADD RSC /l 0x2c0a /d "NDEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 +# ADD LINK32 /nologo /subsystem:windows /machine:I386 + +!ELSEIF "$(CFG)" == "Princed V3 - Win32 Debug" + +# PROP BASE Use_MFC 6 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 6 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /Yu"stdafx.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x2c0a /d "_DEBUG" /d "_AFXDLL" +# ADD RSC /l 0x2c0a /d "_DEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "Princed V3 - Win32 Release" +# Name "Princed V3 - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\ChildFrm.cpp +# End Source File +# Begin Source File + +SOURCE=.\conf.cpp +# End Source File +# Begin Source File + +SOURCE=.\cSelectLevelWindow.cpp +# End Source File +# Begin Source File + +SOURCE=.\MainFrm.cpp +# End Source File +# Begin Source File + +SOURCE=.\maps.cpp +# End Source File +# Begin Source File + +SOURCE=.\MyDialog.cpp +# End Source File +# Begin Source File + +SOURCE=".\Princed V3.cpp" +# End Source File +# Begin Source File + +SOURCE=".\Princed V3.rc" +# End Source File +# Begin Source File + +SOURCE=".\Princed V3Doc.cpp" +# End Source File +# Begin Source File + +SOURCE=".\Princed V3View.cpp" +# End Source File +# Begin Source File + +SOURCE=.\process.cpp +# End Source File +# Begin Source File + +SOURCE=.\RegisterWIN32.cpp +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\ChildFrm.h +# End Source File +# Begin Source File + +SOURCE=.\cSelectLevelWindow.h +# End Source File +# Begin Source File + +SOURCE=.\MainFrm.h +# End Source File +# Begin Source File + +SOURCE=.\maps.h +# End Source File +# Begin Source File + +SOURCE=.\MyDialog.h +# End Source File +# Begin Source File + +SOURCE=".\Princed V3.h" +# End Source File +# Begin Source File + +SOURCE=".\Princed V3Doc.h" +# End Source File +# Begin Source File + +SOURCE=".\Princed V3View.h" +# End Source File +# Begin Source File + +SOURCE=.\RegisterWIN32.h +# End Source File +# Begin Source File + +SOURCE=.\Resource.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# Begin Source File + +SOURCE=.\structures.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\res\32x32.ped.ico +# End Source File +# Begin Source File + +SOURCE=.\res\about_pi.bmp +# End Source File +# Begin Source File + +SOURCE=.\res\backmask.bmp +# End Source File +# Begin Source File + +SOURCE=.\res\backs.bmp +# End Source File +# Begin Source File + +SOURCE=.\res\bitmap1.bmp +# End Source File +# Begin Source File + +SOURCE=.\res\dropper.cur +# End Source File +# Begin Source File + +SOURCE=.\res\elemmask.bmp +# End Source File +# Begin Source File + +SOURCE=.\res\elemp.bmp +# End Source File +# Begin Source File + +SOURCE=.\res\elempmask.bmp +# End Source File +# Begin Source File + +SOURCE=.\res\elems.bmp +# End Source File +# Begin Source File + +SOURCE=.\res\guard.bmp +# End Source File +# Begin Source File + +SOURCE=.\res\guardmask.bmp +# End Source File +# Begin Source File + +SOURCE=.\res\hand.cur +# End Source File +# Begin Source File + +SOURCE=.\res\palette.bmp +# End Source File +# Begin Source File + +SOURCE=".\res\Princed V3.ico" +# End Source File +# Begin Source File + +SOURCE=".\res\Princed V3.rc2" +# End Source File +# Begin Source File + +SOURCE=".\res\Princed V3Doc.ico" +# End Source File +# Begin Source File + +SOURCE="..\..\..\..\..\kkx\princed\menu\princed3\icons & cursors\princed.ico" +# End Source File +# Begin Source File + +SOURCE=.\res\princed.ico +# End Source File +# Begin Source File + +SOURCE=.\res\Toolbar.bmp +# End Source File +# Begin Source File + +SOURCE=.\res\zoomer.cur +# End Source File +# End Group +# Begin Source File + +SOURCE=.\res\manifest.txt +# End Source File +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project diff --git a/pv3/Princed V3.dsw b/pv3/Princed V3.dsw new file mode 100644 index 0000000..73f42ce --- /dev/null +++ b/pv3/Princed V3.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "Princed V3"=".\Princed V3.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/pv3/Princed V3.h b/pv3/Princed V3.h new file mode 100644 index 0000000..a65228a --- /dev/null +++ b/pv3/Princed V3.h @@ -0,0 +1,55 @@ +// Princed V3.h : main header file for the PRINCED V3 application +// + +#if !defined(AFX_PRINCEDV3_H__B98D1585_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_) +#define AFX_PRINCEDV3_H__B98D1585_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CPrincedV3App: +// See Princed V3.cpp for the implementation of this class +// + +class CPrincedV3App : public CWinApp +{ +public: + CPrincedV3App(); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CPrincedV3App) + public: + virtual BOOL InitInstance(); + virtual BOOL OnIdle(LONG lCount); + //}}AFX_VIRTUAL + +// Implementation + //{{AFX_MSG(CPrincedV3App) + afx_msg void OnAppAbout(); + afx_msg void OnFileExporttoimage(); + afx_msg void OnHelpPrincedhomepage(); + afx_msg void OnAddonsEditsavedgame(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +void msgBox(char *text); + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_PRINCEDV3_H__B98D1585_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_) + + + diff --git a/pv3/Princed V3.ncb b/pv3/Princed V3.ncb new file mode 100644 index 0000000..954d053 --- /dev/null +++ b/pv3/Princed V3.ncb @@ -0,0 +1 @@ +Microsoft C/C++ program database 2.00 diff --git a/pv3/Princed V3.opt b/pv3/Princed V3.opt new file mode 100644 index 0000000..8266bd9 Binary files /dev/null and b/pv3/Princed V3.opt differ diff --git a/pv3/Princed V3.rc b/pv3/Princed V3.rc new file mode 100644 index 0000000..8d916a6 --- /dev/null +++ b/pv3/Princed V3.rc @@ -0,0 +1,885 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDB_ELEMMASK BITMAP DISCARDABLE "res\\elemmask.bmp" +IDB_ELEMS BITMAP DISCARDABLE "res\\elems.bmp" +IDB_GUARD BITMAP DISCARDABLE "res\\guard.bmp" +IDB_GUARDMASK BITMAP DISCARDABLE "res\\guardmask.bmp" +IDB_BACKMASK BITMAP DISCARDABLE "res\\backmask.bmp" +IDB_BACKS BITMAP DISCARDABLE "res\\backs.bmp" +IDB_ELEMPMASK BITMAP DISCARDABLE "res\\elempmask.bmp" +IDB_ELEMP BITMAP DISCARDABLE "res\\elemp.bmp" +IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" +IDR_TOOLPAL BITMAP DISCARDABLE "res\\palette.bmp" +IDB_ABOUT_PIC BITMAP DISCARDABLE "res\\about_pi.bmp" + +///////////////////////////////////////////////////////////////////////////// +// +// 24 +// + +1 24 DISCARDABLE "res\\manifest.txt" + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_EDIT_SAV DIALOG DISCARDABLE 0, 0, 265, 127 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Edit Saved Game" +FONT 8, "MS Sans Serif" +BEGIN + PUSHBUTTON "Close",IDCANCEL,219,102,39,12 + LTEXT "&File Name:",IDC_STATIC,7,15,34,8 + EDITTEXT IDC_EDIT1,64,13,194,12,ES_AUTOHSCROLL + PUSHBUTTON "&Browse...",IDC_BROWSE,216,28,42,12 + CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,45,251,1 + PUSHBUTTON "&Open",IDC_OPEN,114,28,42,12 + PUSHBUTTON "&Save",IDC_SAVE,166,28,40,12 + LTEXT "&Level:",IDC_STATIC,7,60,20,8 + COMBOBOX IDC_COMBO1,64,58,108,14,CBS_DROPDOWN | CBS_SORT | + WS_VSCROLL | WS_TABSTOP + LTEXT "L&ives:",IDC_STATIC,7,80,21,8 + EDITTEXT IDC_EDIT2,64,78,96,13,ES_AUTOHSCROLL + CONTROL "Spin1",IDC_SPIN1,"msctls_updown32",UDS_ARROWKEYS,160,78, + 12,13 + LTEXT "&Remining time:",IDC_STATIC,7,102,50,8 + PUSHBUTTON "&New",IDC_BUTTON1,64,28,41,12 + EDITTEXT IDC_EDIT3,63,103,108,12,ES_AUTOHSCROLL +END + +IDD_ABOUTBOX DIALOGEX 0, 0, 262, 169 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "About Princed V3" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL 158,IDC_STATIC,"Static",SS_BITMAP,7,7,63,154, + WS_EX_CLIENTEDGE + LTEXT "Princed V3 Release 1",IDC_STATIC,75,7,119,8,SS_NOPREFIX + LTEXT "Copyright (C) 2003 - Princed V3 Development Team", + IDC_STATIC,75,17,180,8 + DEFPUSHBUTTON "OK",IDOK,205,147,50,14,WS_GROUP + LTEXT "Some enhaced GUI elements are Copyright \xa9 1998 Kirk Stowell. This program is freeware, you may share and distribute it. However you must read and respect the program license provided in the package where you have installed this program.", + IDC_STATIC,75,100,180,40 + LTEXT "Visit our homepage for newer versions:\r http://www.princed.com.ar", + IDC_STATIC,75,82,128,16 + EDITTEXT IDC_EDIT2,75,28,180,49,ES_MULTILINE | ES_READONLY | + WS_VSCROLL +END + +IDD_DIALOG_SELECT_LEVEL DIALOG DISCARDABLE 0, 0, 229, 57 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Select level" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,172,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,172,24,50,14 + COMBOBOX IDC_COMBO1,13,19,151,112,CBS_DROPDOWN | CBS_SORT | + WS_VSCROLL | WS_TABSTOP + LTEXT "Select the number of the level you want to edit", + IDC_STATIC,14,7,152,9 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_EDIT_SAV, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 258 + TOPMARGIN, 7 + BOTTOMMARGIN, 120 + END + + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 255 + TOPMARGIN, 7 + BOTTOMMARGIN, 161 + END + + IDD_DIALOG_SELECT_LEVEL, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 222 + TOPMARGIN, 7 + BOTTOMMARGIN, 50 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Cursor +// + +IDC_HANDPALM CURSOR DISCARDABLE "res\\hand.cur" +IDC_ZOOMTOOL CURSOR DISCARDABLE "res\\zoomer.cur" +IDC_DROPPER CURSOR DISCARDABLE "res\\dropper.cur" + +///////////////////////////////////////////////////////////////////////////// +// +// Toolbar +// + +IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15 +BEGIN + BUTTON ID_FILE_NEW + BUTTON ID_FILE_OPEN + BUTTON ID_FILE_SAVE + SEPARATOR + BUTTON ID_EDIT_CUT + BUTTON ID_EDIT_COPY + BUTTON ID_EDIT_PASTE + SEPARATOR + BUTTON ID_FILE_PRINT + SEPARATOR + BUTTON ID_APP_ABOUT +END + +IDR_TOOLPAL TOOLBAR DISCARDABLE 24, 24 +BEGIN + BUTTON ID_TOOL_SELECTION + SEPARATOR + BUTTON ID_BUTTON32903 + BUTTON ID_BUTTON32904 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MAINFRAME MENU PRELOAD DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&New...\tCtrl+N", ID_FILE_NEW + MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN + MENUITEM "&Close", ID_FILE_CLOSE + MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE + MENUITEM "Save &As...", ID_FILE_SAVE_AS + MENUITEM "Save All", ID_FILE_SAVEALL + MENUITEM SEPARATOR + MENUITEM "Compile DAT...", ID_FILE_COMPILEDAT + MENUITEM "Uncompile DAT...", ID_FILE_UNCOMPILEDAT + MENUITEM "Publish DAT...", ID_FILE_PUBLISHDAT + MENUITEM SEPARATOR + MENUITEM "Export to Image...", ID_FILE_EXPORTTOIMAGE + MENUITEM "Export to Text...", ID_FILE_EXPORTTOTEXT + MENUITEM "Export to HTML...", ID_FILE_EXPORTTOHTML + MENUITEM SEPARATOR + MENUITEM "Search Files...", ID_FILE_SEARCHFILES + MENUITEM "Preferences...", ID_FILE_PREFERENCES + MENUITEM SEPARATOR + MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED + MENUITEM SEPARATOR + MENUITEM "E&xit", ID_APP_EXIT + END + POPUP "&View" + BEGIN + MENUITEM "Main &Toolbar", ID_VIEW_TOOLBAR + MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR + MENUITEM "Map Tools", ID_VIEW_MAPTOOLS + MENUITEM "Tool Options Window", ID_VIEW_TOOLOPTIONSWINDOW + MENUITEM "Level Properties...", ID_VIEW_LEVELPROPERTRIES + MENUITEM "Open Levels", ID_VIEW_OPENLEVELS + MENUITEM "Screen reader menu", ID_VIEW_READERSCREENMENU + MENUITEM SEPARATOR + MENUITEM "Toggle Grid", ID_VIEW_TOGGLEGRID + MENUITEM "Toggle &Rulers", ID_VIEW_TOGGLERULERS + MENUITEM SEPARATOR + POPUP "Zoom" + BEGIN + MENUITEM "In\t+", ID_VIEW_IN + MENUITEM "Out\t-", ID_VIEW_ZOOM_OUT + MENUITEM SEPARATOR + MENUITEM "Fit screen to window", ID_VIEW_ZOOM_FITSCREENTOWINDOW + + MENUITEM "200%", ID_VIEW_ZOOM_200 + MENUITEM "100%", ID_VIEW_ZOOM_100 + MENUITEM "50%", ID_VIEW_ZOOM_50 + MENUITEM "25%", ID_VIEW_ZOOM_25 + MENUITEM "Fit level to window", ID_VIEW_ZOOM_FITLEVELTOWINDOW + + END + END + POPUP "Debug" + BEGIN + MENUITEM "Run level from °ub position", + ID_DEBUG_RUNLEVELFROMDEGUBPOSITION + + MENUITEM "Run level from &start position", + ID_DEBUG_RUNLEVELFROMSTARTPOSITION + + MENUITEM "&Refresh running level", ID_DEBUG_REFRESHRUNNINGLEVE + MENUITEM "Run DAT &file...", ID_DEBUG_RUNDATFILE + MENUITEM "S&top running", ID_DEBUG_STOPRUNNING + MENUITEM SEPARATOR + MENUITEM "Execute &Prince of Persia", ID_DEBUG_EXECUTEPRINCEOFPERSIA + + END + POPUP "Addons" + BEGIN + MENUITEM "Edit &Hall of Fame", ID_ADDONS_EDITHALLOFFAME + MENUITEM "Edit &saved game", ID_ADDONS_EDITSAVEDGAME + MENUITEM "Edit &graphics", ID_ADDONS_EDITGRAPHICS + , GRAYED + MENUITEM "Edit &Prince.exe", ID_ADDONS_EDITPRINCEEXE + END + POPUP "&Help" + BEGIN + MENUITEM "Help topics", ID_HELP_HELPTOPICS + MENUITEM SEPARATOR + MENUITEM "Index", ID_HELP_INDEX + MENUITEM "License", ID_HELP_LICENSE + MENUITEM "Frequently asked questions", ID_HELP_FREQUENTLYASKEDQUESTIONS + + MENUITEM SEPARATOR + MENUITEM "Princed Home Page", ID_HELP_PRINCEDHOMEPAGE + MENUITEM SEPARATOR + MENUITEM "&About Princed V3...", ID_APP_ABOUT + END +END + +IDR_PRINCETYPE MENU PRELOAD DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&New...\tCtrl+N", ID_FILE_NEW + MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN + MENUITEM "&Close", ID_FILE_CLOSE + MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE + MENUITEM "Save &As...\tF11", ID_FILE_SAVE_AS + MENUITEM "Save All\tCtrl+Alt+S", ID_FILE_SAVEALL + MENUITEM SEPARATOR + MENUITEM "Compile DAT...\tCtrl+D", ID_FILE_COMPILEDAT + MENUITEM "Uncompile DAT...\tCtrl+U", ID_FILE_UNCOMPILEDAT + MENUITEM "Publish DAT...\tCtrl+P", ID_FILE_PUBLISHDAT + MENUITEM SEPARATOR + MENUITEM "Export to Image...\tCtrl+I", ID_FILE_EXPORTTOIMAGE + MENUITEM "Export to Text...\tCtrl+T", ID_FILE_EXPORTTOTEXT + MENUITEM "Export to HTML...\tCtrl+H", ID_FILE_EXPORTTOHTML + MENUITEM SEPARATOR + MENUITEM "Search Files...\tCtrl+F", ID_FILE_SEARCHFILES + MENUITEM "Preferences...\tF8", ID_FILE_PREFERENCES + MENUITEM SEPARATOR + MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED + MENUITEM SEPARATOR + MENUITEM "E&xit\tCtrl+Q", ID_APP_EXIT + END + POPUP "&Edit" + BEGIN + MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO + MENUITEM "Redo\tCtrl+Y", ID_EDIT_REDO + MENUITEM SEPARATOR + MENUITEM "Cu&t Selection\tCtrl+X", ID_EDIT_CUT + MENUITEM "&Copy Selection\tCtrl+C", ID_EDIT_COPY + MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE + MENUITEM "Clear Selection\tDel", ID_EDIT_CLEARSELECTION + END + POPUP "&View" + BEGIN + MENUITEM "Main &Toolbar\tAlt+T", ID_VIEW_TOOLBAR + MENUITEM "&Status Bar\tAlt+1", ID_VIEW_STATUS_BAR + MENUITEM "Map Tools\tAlt+M", ID_VIEW_MAPTOOLS + MENUITEM "Tool Options Window\tAlt+O", ID_VIEW_TOOLOPTIONSWINDOW + MENUITEM "Level Properties...\tCtrl+F4", ID_VIEW_LEVELPROPERTRIES + MENUITEM "Open Levels\tAlt+L", ID_VIEW_OPENLEVELS + MENUITEM "Screen reader menu", ID_VIEW_READERSCREENMENU + MENUITEM SEPARATOR + MENUITEM "Palace", ID_VIEW_ASPALACE + MENUITEM "Dungeon", ID_VIEW_ASDUNGEON + MENUITEM SEPARATOR + MENUITEM "Toggle Grid\tAlt+G", ID_VIEW_TOGGLEGRID + MENUITEM "Toggle &Rulers\tAlt+R", ID_VIEW_TOGGLERULERS + MENUITEM SEPARATOR + POPUP "Zoom" + BEGIN + MENUITEM "In\t+", ID_VIEW_ZOOM_IN + MENUITEM "Out\t-", ID_VIEW_ZOOM_OUT + MENUITEM SEPARATOR + MENUITEM "Fit screen to window\t/", ID_VIEW_ZOOM_FITSCREENTOWINDOW + + MENUITEM "200%", ID_VIEW_ZOOM_200 + MENUITEM "100%", ID_VIEW_ZOOM_100 + MENUITEM "50%", ID_VIEW_ZOOM_50 + MENUITEM "25%", ID_VIEW_ZOOM_25 + MENUITEM "Fit level to window\t*", ID_VIEW_ZOOM_FITLEVELTOWINDOW + + END + END + POPUP "Map &tools" + BEGIN + MENUITEM "&Wall\tW", ID_MAPTOOLS_WALL + MENUITEM "&Space\tS", ID_MAPTOOLS_CLEAR + POPUP "&Objects" + BEGIN + MENUITEM "&Potion\tP", ID_MAPTOOLS_OBJECTS_POSSION + + MENUITEM "&Skeleton\tK", ID_MAPTOOLS_WALKABLE_BALDOZACONESQUELETO + + MENUITEM "S&word\tR", ID_MAPTOOLS_SWORD + MENUITEM "S&tart Position\tN", ID_MAPTOOLS_OBJECTS_STARTPOSITION + + MENUITEM "&Debug Position\tI", ID_MAPTOOLS_OBJECTS_DEBUGPOSITION + + MENUITEM "&Guard\tG", ID_MAPTOOLS_OBJECTS_GUARDS + + END + POPUP "&Background" + BEGIN + MENUITEM "&Torch\tCtrl+Shift+T", ID_MAPTOOLS_BACKGROUND_LIGHT + + MENUITEM "&Bricks\tCtrl+Shift+B", ID_MAPTOOLS_BACKGROUND_BRICKS + + MENUITEM "&Window\tCtrl+Alt+I", ID_MAPTOOLS_BACKGROUND_WINDOW + + MENUITEM "Big W&indow\tCtrl+Alt+H", ID_MAPTOOLS_BACKGROUND_BIGWINDOW + + MENUITEM "&Column\tCtrl+Shift+C", ID_MAPTOOLS_BACKGROUND_COLUMN + + MENUITEM "Big C&olumn\tCtrl+Alt+C", ID_MAPTOOLS_BACKGROUND_BIGCOLUMN + + MENUITEM SEPARATOR + MENUITEM "Random\tAlt+B", ID_MAPTOOLS_BACKGROUND_RANDOM + + END + POPUP "&Panel" + BEGIN + MENUITEM "Normal &Floor\tF", ID_MAPTOOLS_WALKABLE_NORMAL + + MENUITEM "&Broken Floor\tB", ID_MAPTOOLS_WALKABLE_BALDOZAROTA + + MENUITEM "&Loose Floor\tL", ID_MAPTOOLS_WALKABLE_BALDOZAFLOJA + + MENUITEM "&Door Opener\tO", ID_MAPTOOLS_WALKABLE_BALDOZAAPRETABLE + + MENUITEM "Door &Closer\tC", ID_MAPTOOLS_WALKABLE_DOORCLOSER + + MENUITEM "&Spikes\tCtrl+Shift+S", ID_MAPTOOLS_WALKABLE_PINCHES + + MENUITEM SEPARATOR + MENUITEM "Random\tAlt+P", ID_MAPTOOLS_WALKABLE_RANDOM + + END + POPUP "&Gates" + BEGIN + MENUITEM "Door\tD", ID_MAPTOOLS_GATES_DOOR + MENUITEM "Chopper\tH", ID_MAPTOOLS_GATES_PUERTASIERRA + + MENUITEM "Level Gate\tT", ID_MAPTOOLS_GATES_LEVELGATE + + END + MENUITEM SEPARATOR + MENUITEM "&Hand\tAlt+H", ID_MAPTOOLS_ARRASTRAR + MENUITEM "Sele&ct\tAlt+S", ID_MAPTOOLS_SELECT + MENUITEM "&Zoom\tAlt+Z", ID_MAPTOOLS_ZOOM + MENUITEM "&Dropper\tAlt+D", ID_MAPTOOLS_DROPPER + END + POPUP "Debug" + BEGIN + MENUITEM "Run level from &debug position\tF5", + ID_DEBUG_RUNLEVELFROMDEGUBPOSITION + + MENUITEM "Run level from &start position\tCtrl+F5", + ID_DEBUG_RUNLEVELFROMSTARTPOSITION + + MENUITEM "&Refresh running level\tCtrl+A", + ID_DEBUG_REFRESHRUNNINGLEVE + MENUITEM "Run DAT &file...\tF9", ID_DEBUG_RUNDATFILE + MENUITEM "S&top running\tCtrl+F9", ID_DEBUG_STOPRUNNING + MENUITEM SEPARATOR + MENUITEM "Execute &Prince of Persia\tF10", + ID_DEBUG_EXECUTEPRINCEOFPERSIA + + END + POPUP "Addons" + BEGIN + MENUITEM "Edit &Hall of Fame\tCtrl+1", ID_ADDONS_EDITHALLOFFAME + MENUITEM "Edit &saved game\tCtrl+2", ID_ADDONS_EDITSAVEDGAME + MENUITEM "Edit &graphics\tCtrl+3", ID_ADDONS_EDITGRAPHICS + , GRAYED + MENUITEM "Edit &Prince.exe\tCtrl+4", ID_ADDONS_EDITPRINCEEXE + END + POPUP "&Window" + BEGIN + MENUITEM "Fit to &level\tCtrl+F6", ID_WINDOW_FITTOLEVEL + MENUITEM "Tile &Horizontally", ID_WINDOW_TILE_HORZ + MENUITEM "Tile &Vertically", ID_WINDOW_TILE_VERT + MENUITEM "&Cascade", ID_WINDOW_CASCADE + MENUITEM "&Arrange Icons", ID_WINDOW_ARRANGE + MENUITEM "Close all\tCtrl+Shift+F4", ID_WINDOW_CLOSEALL + END + POPUP "&Help" + BEGIN + MENUITEM "Help topics\tF1", ID_HELP_HELPTOPICS + MENUITEM SEPARATOR + MENUITEM "Index\tCtrl+F1", ID_HELP_INDEX + MENUITEM "License", ID_HELP_LICENSE + MENUITEM "Frequently asked questions", ID_HELP_FREQUENTLYASKEDQUESTIONS + + MENUITEM SEPARATOR + MENUITEM "Princed Home Page\tCtrl+Alt+F1", ID_HELP_PRINCEDHOMEPAGE + MENUITEM SEPARATOR + MENUITEM "&About Princed V3...", ID_APP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE +BEGIN + "1", ID_ADDONS_EDITHALLOFFAME, VIRTKEY, CONTROL, NOINVERT + "2", ID_ADDONS_EDITSAVEDGAME, VIRTKEY, CONTROL, NOINVERT + "3", ID_ADDONS_EDITGRAPHICS, VIRTKEY, CONTROL, NOINVERT + "4", ID_ADDONS_EDITPRINCEEXE, VIRTKEY, CONTROL, NOINVERT + "5", ID_VIEW_STATUS_BAR, VIRTKEY, ALT, NOINVERT + "A", ID_DEBUG_REFRESHRUNNINGLEVE, VIRTKEY, CONTROL, NOINVERT + "B", ID_MAPTOOLS_WALKABLE_BALDOZAROTA, VIRTKEY, NOINVERT + "B", ID_MAPTOOLS_BACKGROUND_RANDOM, VIRTKEY, ALT, NOINVERT + "B", ID_MAPTOOLS_BACKGROUND_BRICKS, VIRTKEY, SHIFT, CONTROL, + NOINVERT + "C", ID_MAPTOOLS_WALKABLE_DOORCLOSER, VIRTKEY, NOINVERT + "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT + "C", ID_MAPTOOLS_BACKGROUND_BIGCOLUMN, VIRTKEY, CONTROL, ALT, + NOINVERT + "C", ID_MAPTOOLS_BACKGROUND_COLUMN, VIRTKEY, SHIFT, CONTROL, + NOINVERT + "D", ID_MAPTOOLS_GATES_DOOR, VIRTKEY, NOINVERT + "D", ID_FILE_COMPILEDAT, VIRTKEY, CONTROL, NOINVERT + "D", ID_MAPTOOLS_DROPPER, VIRTKEY, ALT, NOINVERT + "E", ID_ADDONS_EDITPRINCEEXE, VIRTKEY, ALT, NOINVERT + "F", ID_MAPTOOLS_WALKABLE_NORMAL, VIRTKEY, NOINVERT + "F", ID_FILE_SEARCHFILES, VIRTKEY, CONTROL, NOINVERT + "F", ID_ADDONS_EDITHALLOFFAME, VIRTKEY, ALT, NOINVERT + "G", ID_MAPTOOLS_OBJECTS_GUARDS, VIRTKEY, NOINVERT + "G", ID_VIEW_TOGGLEGRID, VIRTKEY, ALT, NOINVERT + "H", ID_MAPTOOLS_GATES_PUERTASIERRA, VIRTKEY, NOINVERT + "H", ID_FILE_EXPORTTOHTML, VIRTKEY, CONTROL, NOINVERT + "H", ID_MAPTOOLS_ARRASTRAR, VIRTKEY, ALT, NOINVERT + "H", ID_MAPTOOLS_BACKGROUND_BIGWINDOW, VIRTKEY, CONTROL, ALT, + NOINVERT + "I", ID_MAPTOOLS_OBJECTS_DEBUGPOSITION, VIRTKEY, NOINVERT + "I", ID_FILE_EXPORTTOIMAGE, VIRTKEY, CONTROL, NOINVERT + "I", ID_MAPTOOLS_BACKGROUND_WINDOW, VIRTKEY, CONTROL, ALT, + NOINVERT + "K", ID_MAPTOOLS_WALKABLE_BALDOZACONESQUELETO, VIRTKEY, + NOINVERT + "K", ID_ADDONS_EDITGRAPHICS, VIRTKEY, ALT, NOINVERT + "L", ID_MAPTOOLS_WALKABLE_BALDOZAFLOJA, VIRTKEY, NOINVERT + "L", ID_VIEW_OPENLEVELS, VIRTKEY, ALT, NOINVERT + "M", ID_VIEW_TOOLOPTIONSWINDOW, VIRTKEY, ALT, NOINVERT + "N", ID_MAPTOOLS_OBJECTS_STARTPOSITION, VIRTKEY, NOINVERT + "N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT + "O", ID_MAPTOOLS_WALKABLE_BALDOZAAPRETABLE, VIRTKEY, NOINVERT + "O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT + "P", ID_MAPTOOLS_OBJECTS_POSSION, VIRTKEY, NOINVERT + "P", ID_FILE_PUBLISHDAT, VIRTKEY, CONTROL, NOINVERT + "P", ID_MAPTOOLS_WALKABLE_RANDOM, VIRTKEY, ALT, NOINVERT + "Q", ID_APP_EXIT, VIRTKEY, CONTROL, NOINVERT + "R", ID_MAPTOOLS_SWORD, VIRTKEY, NOINVERT + "R", ID_VIEW_TOGGLERULERS, VIRTKEY, ALT, NOINVERT + "S", ID_MAPTOOLS_CLEAR, VIRTKEY, NOINVERT + "S", ID_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT + "S", ID_MAPTOOLS_SELECT, VIRTKEY, ALT, NOINVERT + "S", ID_MAPTOOLS_WALKABLE_PINCHES, VIRTKEY, SHIFT, CONTROL, + NOINVERT + "T", ID_MAPTOOLS_GATES_LEVELGATE, VIRTKEY, NOINVERT + "T", ID_FILE_EXPORTTOTEXT, VIRTKEY, CONTROL, NOINVERT + "T", ID_VIEW_TOOLBAR, VIRTKEY, ALT, NOINVERT + "T", ID_MAPTOOLS_BACKGROUND_LIGHT, VIRTKEY, SHIFT, CONTROL, + NOINVERT + "U", ID_FILE_UNCOMPILEDAT, VIRTKEY, CONTROL, NOINVERT + "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT + VK_ADD, ID_VIEW_ZOOM_IN, VIRTKEY, NOINVERT + VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT + VK_DELETE, ID_EDIT_CLEARSELECTION, VIRTKEY, NOINVERT + VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT + VK_DIVIDE, ID_VIEW_ZOOM_FITSCREENTOWINDOW, VIRTKEY, NOINVERT + VK_F1, ID_HELP_HELPTOPICS, VIRTKEY, NOINVERT + VK_F1, ID_HELP_INDEX, VIRTKEY, CONTROL, NOINVERT + VK_F1, ID_HELP_PRINCEDHOMEPAGE, VIRTKEY, CONTROL, ALT, NOINVERT + VK_F10, ID_DEBUG_EXECUTEPRINCEOFPERSIA, VIRTKEY, NOINVERT + VK_F4, ID_VIEW_LEVELPROPERTRIES, VIRTKEY, CONTROL, NOINVERT + VK_F4, ID_WINDOW_CLOSEALL, VIRTKEY, CONTROL, ALT, NOINVERT + VK_F5, ID_DEBUG_RUNLEVELFROMDEGUBPOSITION, VIRTKEY, NOINVERT + VK_F5, ID_DEBUG_RUNLEVELFROMSTARTPOSITION, VIRTKEY, CONTROL, + NOINVERT + VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT + VK_F6, ID_WINDOW_FITTOLEVEL, VIRTKEY, CONTROL, NOINVERT + VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT + VK_F8, ID_FILE_PREFERENCES, VIRTKEY, NOINVERT + VK_F9, ID_DEBUG_RUNDATFILE, VIRTKEY, NOINVERT + VK_F9, ID_DEBUG_STOPRUNNING, VIRTKEY, CONTROL, NOINVERT + VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT + VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT + VK_MULTIPLY, ID_VIEW_ZOOM_FITLEVELTOWINDOW, VIRTKEY, NOINVERT + VK_SUBTRACT, ID_VIEW_ZOOM_OUT, VIRTKEY, NOINVERT + "W", ID_MAPTOOLS_WALL, VIRTKEY, NOINVERT + "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT + "Y", ID_EDIT_REDO, VIRTKEY, CONTROL, NOINVERT + "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT + "Z", ID_MAPTOOLS_ZOOM, VIRTKEY, ALT, NOINVERT +END + + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 3,0,1,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "To get the latest version visit our homepage: http://www.princed.com.ar\0" + VALUE "CompanyName", "Princed Development Team\0" + VALUE "FileDescription", "Princed V3\0" + VALUE "FileVersion", "3, 0, 1\0" + VALUE "InternalName", "Princed V3\0" + VALUE "LegalCopyright", "Copyright (C) 2003 - Princed Development Team\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "Princed V3.EXE\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "Princed V3 Application\0" + VALUE "ProductVersion", "3, 0, 1\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog Info +// + +IDD_DIALOG_SELECT_LEVEL DLGINIT +BEGIN + IDC_COMBO1, 0x403, 5, 0 +0x6544, 0x6f6d, "\000" + IDC_COMBO1, 0x403, 8, 0 +0x654c, 0x6576, 0x206c, 0x0031, + IDC_COMBO1, 0x403, 8, 0 +0x654c, 0x6576, 0x206c, 0x0032, + IDC_COMBO1, 0x403, 8, 0 +0x654c, 0x6576, 0x206c, 0x0032, + IDC_COMBO1, 0x403, 8, 0 +0x654c, 0x6576, 0x206c, 0x0033, + IDC_COMBO1, 0x403, 9, 0 +0x654c, 0x6576, 0x206c, 0x3231, "\000" + IDC_COMBO1, 0x403, 10, 0 +0x654c, 0x6576, 0x206c, 0x3231, 0x0063, + IDC_COMBO1, 0x403, 18, 0 +0x654c, 0x6576, 0x206c, 0x3331, 0x5020, 0x6972, 0x636e, 0x7365, 0x0073, + + IDC_COMBO1, 0x403, 7, 0 +0x6f50, 0x6974, 0x6e6f, "\000" + 0 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDP_SOCKETS_INIT_FAILED "Windows sockets initialization failed." +END + +STRINGTABLE PRELOAD DISCARDABLE +BEGIN + IDR_MAINFRAME "Princed V3" + IDR_PRINCETYPE "\nPrince\nPrince\nPrince of Persia Map data (*.dat; *.ped)\nped\nPrincedV3.Document\nPrince Document" +END + +STRINGTABLE PRELOAD DISCARDABLE +BEGIN + AFX_IDS_APP_TITLE "Princed V3" + AFX_IDS_IDLEMESSAGE "Ready" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_INDICATOR_EXT "EXT" + ID_INDICATOR_CAPS "CAP" + ID_INDICATOR_NUM "NUM" + ID_INDICATOR_SCRL "SCRL" + ID_INDICATOR_OVR "OVR" + ID_INDICATOR_REC "REC" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_FILE_NEW "Create a new document\nNew" + ID_FILE_OPEN "Open an existing document\nOpen" + ID_FILE_CLOSE "Close the active document\nClose" + ID_FILE_SAVE "Save the active document\nSave" + ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" + ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" + ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" + ID_FILE_PRINT "Print the active document\nPrint" + ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_APP_ABOUT "Display program information, version number and copyright\nAbout" + ID_APP_EXIT "Quit the application; prompts to save documents\nExit" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_FILE_MRU_FILE1 "Open this document" + ID_FILE_MRU_FILE2 "Open this document" + ID_FILE_MRU_FILE3 "Open this document" + ID_FILE_MRU_FILE4 "Open this document" + ID_FILE_MRU_FILE5 "Open this document" + ID_FILE_MRU_FILE6 "Open this document" + ID_FILE_MRU_FILE7 "Open this document" + ID_FILE_MRU_FILE8 "Open this document" + ID_FILE_MRU_FILE9 "Open this document" + ID_FILE_MRU_FILE10 "Open this document" + ID_FILE_MRU_FILE11 "Open this document" + ID_FILE_MRU_FILE12 "Open this document" + ID_FILE_MRU_FILE13 "Open this document" + ID_FILE_MRU_FILE14 "Open this document" + ID_FILE_MRU_FILE15 "Open this document" + ID_FILE_MRU_FILE16 "Open this document" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_NEXT_PANE "Switch to the next window pane\nNext Pane" + ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_WINDOW_NEW "Open another window for the active document\nNew Window" + ID_WINDOW_ARRANGE "Arrange icons at the bottom of the window\nArrange Icons" + ID_WINDOW_CASCADE "Arrange windows so they overlap\nCascade Windows" + ID_WINDOW_TILE_HORZ "Arrange windows as non-overlapping tiles\nTile Windows" + ID_WINDOW_TILE_VERT "Arrange windows as non-overlapping tiles\nTile Windows" + ID_WINDOW_SPLIT "Split the active window into panes\nSplit" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_EDIT_CLEAR "Erase the selection\nErase" + ID_EDIT_CLEAR_ALL "Erase everything\nErase All" + ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" + ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" + ID_EDIT_FIND "Find the specified text\nFind" + ID_EDIT_PASTE "Insert Clipboard contents\nPaste" + ID_EDIT_REPEAT "Repeat the last action\nRepeat" + ID_EDIT_REPLACE "Replace specific text with different text\nReplace" + ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" + ID_EDIT_UNDO "Undo the last action\nUndo" + ID_EDIT_REDO "Redo the previously undone action\nRedo" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" + ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" +END + +STRINGTABLE DISCARDABLE +BEGIN + AFX_IDS_SCSIZE "Change the window size" + AFX_IDS_SCMOVE "Change the window position" + AFX_IDS_SCMINIMIZE "Reduce the window to an icon" + AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" + AFX_IDS_SCNEXTWINDOW "Switch to the next document window" + AFX_IDS_SCPREVWINDOW "Switch to the previous document window" + AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" +END + +STRINGTABLE DISCARDABLE +BEGIN + AFX_IDS_SCRESTORE "Restore the window to normal size" + AFX_IDS_SCTASKLIST "Activate Task List" + AFX_IDS_MDICHILD "Activate this window" +END + +STRINGTABLE DISCARDABLE +BEGIN + AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" + IDS_PRINCED_HOMEPAGE "http://www.princed.com.ar" + IDS_WALL_NAMES "Space\nFloor\nSpike\nColumn\nDoor\n0x05\nDoor Closer\nCarpet Wall\nBig Column Bottom\nBig Column Top\nPotion\nLoose Floor\nCarpet Wall Space\n0x0d\nBroken Floor\nDoor Opener\nExit Gate Left\nExit Gate Right\nChopper\nFloor with Torch\nWall\nSkeleton\nSword\nStar Window Left\nStar Window Right\nArch Column\nArch Down\nSmall Arch\nBig Arch Left\nBig Arch Right\nBroken Floor with Torch\n0x1f" + IDS_ABOUT_TEXT "testing" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_MAPTOOLS_CLEAR "Inserts a space" + ID_MAPTOOLS_OBJECTS_POSSION + "Places a floor with a potion (one of five types)" + ID_MAPTOOLS_WALL "Inserts a wall" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_MAPTOOLS_WALKABLE_BALDOZACONESQUELETO + "Places a floor with a skeleton: not available in palace mode" + ID_MAPTOOLS_SWORD "Places a floor with a sword" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_FILE_SAVEALL "Saves all document\nSave All" + ID_VIEW_MAPTOOLS "Show or hide the map tools bar\nMap Tools" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// Spanish (Castilian) (unknown sub-lang: 0xB) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ESS) +#ifdef _WIN32 +LANGUAGE LANG_SPANISH, 0xB +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" + "#ifdef _WIN32\r\n" + "LANGUAGE 9, 1\r\n" + "#pragma code_page(1252)\r\n" + "#endif //_WIN32\r\n" + "#include ""res\\Princed V3.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""afxres.rc"" // Standard components\r\n" + "#include ""afxprint.rc"" // printing/print preview resources\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON DISCARDABLE "res\\princed.ico" +IDR_PRINCETYPE ICON DISCARDABLE "res\\32x32.ped.ico" +#endif // Spanish (Castilian) (unknown sub-lang: 0xB) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE 9, 1 +#pragma code_page(1252) +#endif //_WIN32 +#include "res\Princed V3.rc2" // non-Microsoft Visual C++ edited resources +#include "afxres.rc" // Standard components +#include "afxprint.rc" // printing/print preview resources +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/pv3/Princed V3Doc.cpp b/pv3/Princed V3Doc.cpp new file mode 100644 index 0000000..7f69a42 --- /dev/null +++ b/pv3/Princed V3Doc.cpp @@ -0,0 +1,236 @@ +// Princed V3Doc.cpp : implementation of the CPrincedV3Doc class +// + +#include "stdafx.h" +#include "Princed V3.h" + +#include "maps.h" +#include "Princed V3Doc.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CPrincedV3Doc + +IMPLEMENT_DYNCREATE(CPrincedV3Doc, CDocument) + +BEGIN_MESSAGE_MAP(CPrincedV3Doc, CDocument) + //{{AFX_MSG_MAP(CPrincedV3Doc) + ON_COMMAND(ID_EDIT_UNDO, OnEditUndo) + ON_COMMAND(ID_EDIT_REDO, OnEditRedo) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CPrincedV3Doc construction/destruction + +//Width and height of POP1's screen +const int CPrincedV3Doc::SCRX=10, CPrincedV3Doc::SCRY=3; +const int CPrincedV3Doc::MAXSCRN=24; +CString CPrincedV3Doc::m_strWallName[32]; + +CPrincedV3Doc::CPrincedV3Doc(): m_Map("") +{ + m_Map.lev=(tLevel *)malloc(sizeof(tLevel)); + + if(m_strWallName[0].IsEmpty()) { //only once when necessary + int i; TCHAR buff[512]; + ::LoadString(AfxGetApp()->m_hInstance, IDS_WALL_NAMES, buff, 512); + for(i=0, m_strWallName[0]=_tcstok(buff, _T("\n")); i<31; + i++, m_strWallName[i]=_tcstok(NULL, _T("\n"))); + } +} + +CPrincedV3Doc::~CPrincedV3Doc() +{ +} + +BOOL CPrincedV3Doc::OnNewDocument() +{ + if(!CDocument::OnNewDocument()) return FALSE; + + // TODO: add reinitialization code here + // (SDI documents will reuse this document) + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////// +// CPrincedV3Doc diagnostics + +#ifdef _DEBUG +void CPrincedV3Doc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void CPrincedV3Doc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CPrincedV3Doc commands + +BOOL CPrincedV3Doc::OnOpenDocument(LPCTSTR lpszPathName) +{ + if(!CDocument::OnOpenDocument(lpszPathName)) return FALSE; + CFile f(lpszPathName, CFile::modeRead); DWORD dw=f.GetLength(); f.Close(); + + //according to the file size + switch(dw) { + case sizeof(tLevel): //if PED + m_nLevel=-1; m_Map.mLoadPED(lpszPathName, m_Map.lev); break; + case MAPS_BLOCK_SIZEOF_FILE: //if DAT, load whole level + m_nLevel=1; + m_Map.mLoadDAT(lpszPathName, m_Map.lev, m_nLevel); + break; + default: + return FALSE; //neither of the supported types + } + return TRUE; +} + +SCRNNUM CPrincedV3Doc::PositionFromScreen(int a, int b) const +{ + char c, x,y, err; x=(char)(a/SCRX)+1, y=(char)(b/SCRY)+1; + c=m_Map.mGetScreen(m_Map.lev, y, x, &err); return err || c<0 ? 0: c; +} + +CPrincedV3Doc::WALL CPrincedV3Doc::GetWallAt(int x, int y, SCRNNUM s) const +{ + switch(s) { + case -1: //x, y is the absolute position: screen number should be implied from it + s=PositionFromScreen(x, y); + if(s) return static_cast<WALL>(m_Map.mGetWall(m_Map.lev, (char)s, y%SCRY, x%SCRX)&(~0x20)); + else return wNull; + case 0: //invalid screen + return wNull; + default: //specified screen + ASSERT(x>=0 && x<SCRX && y>=0 && y<SCRY); + return static_cast<WALL>(m_Map.mGetWall(m_Map.lev, (char)s, y, x)&(~0x20)); + } +} + +CPrincedV3Doc::ATTRIB CPrincedV3Doc::GetBackAt(int x, int y, SCRNNUM s) const +{ + switch(s) { + case -1: //x, y is the absolute position: screen number should be implied from it + s=PositionFromScreen(x, y); + if(s) return static_cast<ATTRIB>(m_Map.mGetBack(m_Map.lev, (char)s, y%SCRY, x%SCRX)); + else return null; + case 0: //invalid screen + return null; + default: + ASSERT(x>=0 && x<SCRX && y>=0 && y<SCRY); + return static_cast<ATTRIB>(m_Map.mGetBack(m_Map.lev, (char)s, y, x)); + } +} + +void CPrincedV3Doc::LoadLevel(int n) +{ + //to go to another level, you must save the current document~ + if(m_nLevel!=-1 && SaveModified()) { + m_Map.mLoadDAT(GetPathName(), m_Map.lev, n); m_nLevel=n; SetModifiedFlag(FALSE); + } +} + +CString CPrincedV3Doc::GetWallName(CPrincedV3Doc::WALL nam, CPrincedV3Doc::ATTRIB at) const +{ + int wn=static_cast<int>(nam); + if(wn>=0 && wn<32) return m_strWallName[wn]; else return CString(""); +} + +BOOL CPrincedV3Doc::GetGuard(SCRNNUM s, GUARD *pInf) const +{ + char x, y, skill, color, dire, era; if(s<=0) return FALSE; + m_Map.mGetGuard(m_Map.lev, s, &y, &x, &skill, &color, &dire, &era); + if(pInf) { + pInf->color=static_cast<G_COLOR>(color); + pInf->skill=static_cast<G_SKILL>(skill); + pInf->org=static_cast<G_ORIENTATION>(dire); + pInf->x=x; pInf->y=y; + } + return era; +} + +//If there're any objects which belong to a palace (arch, carpet, for example) +BOOL CPrincedV3Doc::IsPalaceLevel() const +{ + int i,j,k; + for(k=1;k<=MAXSCRN;k++) + for(j=0;j<SCRY;j++) for(i=0;i<SCRX;i++) + switch(m_Map.mGetWall(m_Map.lev, k, j, i)) { + case wCarpetWall: + case wArchDown: case wArchUpSmall: case wArchUpBigLeft: + case wArchUpBigRight: case wArchColumn: + case wStarWindowLeft: case wStarWindowRight: + return TRUE; + case wSkeleton: + return FALSE; + case wCarpetWallSpace: //only if the adjacent cell is not the wall + if((m_Map.mGetWall(m_Map.lev, k, j, i+1)&(~0x20))!=wWallBlock) return TRUE; + } + return FALSE; +} + +void CPrincedV3Doc::PlaceObject(int x, int y, WALL wa, ATTRIB at, SCRNNUM s) +{ + switch(s) { + case -1: + s=PositionFromScreen(x, y); if(s) x%=SCRX, y%=SCRY; else return; + break; + case 0: return; //invalid screen + default: ASSERT(x>=0 && x<SCRX && y>=0 && y<SCRY); + } + m_Map.mSetWall(m_Map.lev, (char)s, (char)y, (char)x, wa); + m_Map.mSetBack(m_Map.lev, (char)s, (char)y, (char)x, at); +} + +CSize CPrincedV3Doc::GetMapSize() const +{ + char i,j; CSize pt; m_Map.mGetSize(m_Map.lev, &i, &j); pt.cx=j-1; pt.cy=i-1; + return pt; +} + +CPoint CPrincedV3Doc::GetStartScreen() const +{ + char i, j; m_Map.mGetMainScreen(m_Map.lev, &i, &j); return CPoint(j,i); +} + + +void CPrincedV3Doc::OnEditUndo() +{ + //will be implemented in the future. +} + +void CPrincedV3Doc::OnEditRedo() +{ + //will be implemented in the future. +} + +//lev \xb8\xe2\xb9\xf6\xc0\xc7 \xc7\xfc\xc5\xc2 \xb0\xedġ\xb1\xe2 +//\xb8\xca ũ\xb1⸦ \xb0\xe1\xc1\xa4\xc7\xd2 \xb6\xa7 GetSize\xb8\xa6 \xbb\xe7\xbf\xeb\xc7ϱ\xe2 +//\xc5\xf8\xb9ٿ\xa1 \xc4\xb8 \xb9ڽ\xba \xb1\xb8\xc7\xf6\xc7ϱ\xe2 + +BOOL CPrincedV3Doc::OnSaveDocument(LPCTSTR lpszPathName) +{ + if(m_nLevel==-1) { + if(CDocument::OnSaveDocument(lpszPathName)) { + m_Map.mSavePED(lpszPathName, m_Map.lev); return TRUE; + } + } + else { + //When saving DAT file, you mustn't call the base class, because it will completely + //overwrite the file, while we're going to modify only a part of the file. + + //TODO: then, what about when handling SAVE AS?? + m_Map.mSaveDAT(lpszPathName, m_Map.lev); + SetModifiedFlag(FALSE); + } + return FALSE; +} diff --git a/pv3/Princed V3Doc.h b/pv3/Princed V3Doc.h new file mode 100644 index 0000000..6c7c099 --- /dev/null +++ b/pv3/Princed V3Doc.h @@ -0,0 +1,141 @@ +// Princed V3Doc.h : interface of the CPrincedV3Doc class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_PRINCEDV3DOC_H__B98D158D_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_) +#define AFX_PRINCEDV3DOC_H__B98D158D_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "maps.h" + +typedef int SCRNNUM; + +class CPrincedV3Doc : public CDocument +{ +protected: // create from serialization only + CPrincedV3Doc(); + DECLARE_DYNCREATE(CPrincedV3Doc) + +// Attributes +public: + const static int SCRX, SCRY; //screen size 10x3 + const static int MAXSCRN; //max number of screens 24 + enum WALL { + wNull=0x00, + wFloor=0x01, + wLooseFloor=0x0b, + wOneColumn=0x03, + wBrokenFloor=0x0e, + wFloorTorch=0x13, + wBrokenFloorTorch=0x1e, + wBigColumnUp=0x09, + wBigColumnDown=0x08, + wPotion=0x0a, + wSkeleton=0x15, + wSword=0x16, + wSpike=0x02, + wChopper=0x12, + wDoorOpener=0x0f, + wDoorCloser=0x06, + wDoor=0x04, + wExitGateLeft=0x10, + wExitGateRight=0x11, + wWallBlock=0x14, + wCarpetWallSpace=0x0c, //it also exists in dungeon :) + + //Some out handling objects + wOutWallDown=0xFF1, + wOutWallRight=0xFF2, + wOutWallDownRight=0xFF3, + + //The following are palace-specific + wCarpetWall=0x07, + wArchDown=0x1a, + wArchUpSmall=0x1b, + wArchUpBigLeft=0x1c, + wArchUpBigRight=0x1d, + wArchColumn=0x19, + wStarWindowLeft=0x17, + wStarWindowRight=0x18 + }; + enum ATTRIB { + null=0x00, + wallBrick=1, wallBrick2=2, wallWindow=3, + potRedSmall=1, potRedBig=2, potGreenBigGravity=3, potGreenBigInverse=4, potBlueSmall=5, + spikState1=0, spikState2=1, spikState3=2, spikState4=3, + doorOpen=1, doorClosed=2 + }; + enum G_ORIENTATION { + gLeft=0, gRight=1 + }; + enum G_COLOR { + }; + enum G_SKILL { + }; + struct GUARD { + int x, y; //screen location + G_COLOR color; + G_SKILL skill; + G_ORIENTATION org; + }; + +// Operations +public: + void LoadLevel(int n); + int GetLevel() const { return m_nLevel; } + + //cMap helper functions + //x, y: block(wall)-unit coordinate + //a, b: screen-unit coordinate + //s: screen number + WALL GetWallAt(int x, int y, SCRNNUM s=-1) const; + ATTRIB GetBackAt(int x, int y, SCRNNUM s=-1) const; + SCRNNUM PositionFromScreen(int x, int y) const; + CString GetWallName(WALL nam, ATTRIB at=null) const; + BOOL GetGuard(SCRNNUM s, GUARD *pInf=NULL) const; + BOOL IsPalaceLevel() const; + CSize GetMapSize() const; + CPoint GetStartScreen() const; + void PlaceObject(int x, int y, WALL wa, ATTRIB at=null, SCRNNUM s=-1); + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CPrincedV3Doc) + public: + virtual BOOL OnNewDocument(); + virtual BOOL OnOpenDocument(LPCTSTR lpszPathName); + virtual BOOL OnSaveDocument(LPCTSTR lpszPathName); + //}}AFX_VIRTUAL + +// Implementation +public: + friend class CPrincedV3View; + virtual ~CPrincedV3Doc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + cMaps m_Map; CString m_strFile; + int m_nLevel; //-1 indicates it's PED file, not dat + static CString m_strWallName[]; + +// Generated message map functions +protected: + //{{AFX_MSG(CPrincedV3Doc) + afx_msg void OnEditUndo(); + afx_msg void OnEditRedo(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_PRINCEDV3DOC_H__B98D158D_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_) diff --git a/pv3/Princed V3View.cpp b/pv3/Princed V3View.cpp new file mode 100644 index 0000000..03ea67f --- /dev/null +++ b/pv3/Princed V3View.cpp @@ -0,0 +1,697 @@ +// Princed V3View.cpp : implementation of the CPrincedV3View class +// + +#include "stdafx.h" +#include "Princed V3.h" + +#include "MainFrm.h" +#include "Princed V3Doc.h" +#include "Princed V3View.h" +#include "conf.cpp" + +#include "process.cpp" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CPrincedV3View + +IMPLEMENT_DYNCREATE(CPrincedV3View, CScrollView) + +BEGIN_MESSAGE_MAP(CPrincedV3View, CScrollView) + //{{AFX_MSG_MAP(CPrincedV3View) + ON_COMMAND(ID_DEBUG_EXECUTEPRINCEOFPERSIA, OnDebugExecuteprinceofpersia) + ON_WM_KEYDOWN() + ON_WM_MOUSEMOVE() + ON_WM_DESTROY() + ON_WM_ERASEBKGND() + ON_WM_KEYUP() + ON_WM_LBUTTONDOWN() + ON_WM_SETCURSOR() + ON_WM_LBUTTONUP() + ON_WM_RBUTTONDOWN() + ON_WM_TIMER() + //}}AFX_MSG_MAP + // Standard printing commands + ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview) + ON_COMMAND_RANGE(ID_VIEW_ZOOM_200, ID_VIEW_ZOOM_25, OnZoomFactor) + ON_COMMAND_RANGE(ID_VIEW_ASDUNGEON, ID_VIEW_ASPALACE, OnViewMode) + ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_ASDUNGEON, ID_VIEW_ASPALACE, OnUpdateViewMode) + ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_ZOOM_200, ID_VIEW_ZOOM_25, OnUpdateZoomFactor) + + //the following number range is reserved for map tool command id. + ON_COMMAND_RANGE(32850, 32899, OnMapTool) + ON_UPDATE_COMMAND_UI_RANGE(32850, 32899, OnUpdateMapTool) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CPrincedV3View construction/destruction + +int CPrincedV3View::m_nKeys; BYTE CPrincedV3View::m_byKey[256]; +CPoint CPrincedV3View::m_ptPrev; +UINT CPrincedV3View::m_nCurTool=ID_MAPTOOLS_ARRASTRAR; //Hand tool is the default +const int CPrincedV3View::m_nZfact[]={ + 50, 75, 100, 150, 200, 300 +}; + +CPrincedV3View::CPrincedV3View(): m_bPalace(FALSE), m_pbmOld(NULL), m_nZoom(100), + m_bSmoothKey(TRUE), m_dwLastMomn(0) +{ + memset(m_byKey, 0, sizeof(m_byKey)); +} + +CPrincedV3View::~CPrincedV3View() +{ +} + +BOOL CPrincedV3View::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + return CScrollView::PreCreateWindow(cs); +} + +///////////////////////////////////////////////////////////////////////////// +// CPrincedV3View drawing + +void CPrincedV3View::PutSprite(CDC *pDC, int dstx, int dsty, CBitmap *pSrc, CBitmap *pMask, + int srcx, int cx, int cy) +{ + int cxp=cx>0 ? cx: -cx; //always positive. in case or mirrored bitblt + m_dcTemp.SelectObject(pMask); + pDC->StretchBlt(dstx, dsty, cxp*m_nZoom/100, cy*m_nZoom/100, &m_dcTemp, srcx, 0, cx, cy, + SRCAND); + m_dcTemp.SelectObject(pSrc); + pDC->StretchBlt(dstx, dsty, cxp*m_nZoom/100, cy*m_nZoom/100, &m_dcTemp, srcx, 0, cx, cy, + SRCPAINT); +} + +void CPrincedV3View::DrawObject(CDC *pDC, int x, int y, CPrincedV3Doc::WALL wa, CPrincedV3Doc::ATTRIB at) +{ + int ind=-1, atn; CBitmap *pbmBase, *pbmBaseMask; + pbmBase=m_bPalace ? &m_bmPala: &m_bmDung; atn=static_cast<int>(at); + pbmBaseMask=m_bPalace ? &m_bmPalaMask: &m_bmDungMask; + + //background processing + if(m_bPalace) { + switch(atn) { //only on a floor + case 0: + switch(wa) { + case CPrincedV3Doc::wNull: + break; + default: //only on a floor + ind=8; break; + } + break; + case 1: + switch(wa) { //only when blank space + case CPrincedV3Doc::wNull: + ind=8; break; + } + case 2: ind=9; break; case 3: ind=7; break; + } + } + else { + switch(wa) { + case CPrincedV3Doc::wNull: case CPrincedV3Doc::wFloor: + case CPrincedV3Doc::wLooseFloor: case CPrincedV3Doc::wBrokenFloor: + if(atn>0 && atn<=3) ind=atn-1; //dungeon + } + } + if(ind!=-1) + PutSprite(pDC, x+m_nBlockX, y+m_nFloorHeight, &m_bmBack, &m_bmBackMask, ind*32, + 32, 63); + + ind=-1; + switch(wa) { + //empty-background walls + case CPrincedV3Doc::wNull: break; + case CPrincedV3Doc::wFloor: ind=3; break; + case CPrincedV3Doc::wLooseFloor: ind=9; break; + case CPrincedV3Doc::wBrokenFloor: ind=5; break; + + case CPrincedV3Doc::wOneColumn: ind=6; break; + case CPrincedV3Doc::wFloorTorch: ind=4; break; + case CPrincedV3Doc::wBrokenFloorTorch: ind=25; break; + case CPrincedV3Doc::wBigColumnUp: ind=18; break; + case CPrincedV3Doc::wBigColumnDown: ind=19; break; + + case CPrincedV3Doc::wPotion: + switch(at) { + case CPrincedV3Doc::potRedSmall: ind=7; break; + case CPrincedV3Doc::potRedBig: ind=22; break; + case CPrincedV3Doc::potGreenBigGravity: + case CPrincedV3Doc::potGreenBigInverse: ind=21; break; + case CPrincedV3Doc::potBlueSmall: ind=20; break; + default: ind=3; break; //unknown potion + } + break; + + case CPrincedV3Doc::wSkeleton: ind=8; break; + case CPrincedV3Doc::wSword: ind=16; break; + case CPrincedV3Doc::wSpike: ind=12+atn; break; //12+(0~3) + case CPrincedV3Doc::wChopper: ind=17; break; + case CPrincedV3Doc::wDoorCloser: ind=10; break; + case CPrincedV3Doc::wDoorOpener: ind=11; break; + case CPrincedV3Doc::wDoor: ind=atn; break; //1,2 + + case CPrincedV3Doc::wExitGateLeft: + PutSprite(pDC, x, y-m_nFloorHeight-m_nFloorDep, pbmBase, pbmBaseMask, 23*58, 58, 76); + ind=3; break; + case CPrincedV3Doc::wExitGateRight: + PutSprite(pDC, x, y-m_nFloorHeight-m_nFloorDep, pbmBase, pbmBaseMask, 24*58, 58, 76); + ind=3; break; + case CPrincedV3Doc::wStarWindowLeft: + PutSprite(pDC, x, y-m_nFloorHeight-m_nFloorDep, pbmBase, pbmBaseMask, 30*58, 58, 76); + ind=3; break; + case CPrincedV3Doc::wStarWindowRight: + PutSprite(pDC, x, y-m_nFloorHeight-m_nFloorDep, pbmBase, pbmBaseMask, 31*58, 58, 76); + ind=3; break; + case CPrincedV3Doc::wArchColumn: ind= m_bPalace ? 27: 3; break; + case CPrincedV3Doc::wWallBlock: ind=0; break; + case CPrincedV3Doc::wOutWallDown: ind=32; break; + case CPrincedV3Doc::wOutWallRight: ind=33; break; + + case CPrincedV3Doc::wCarpetWall: + PutSprite(pDC, x, y, pbmBase, pbmBaseMask, 3*58, 58, 76); + case CPrincedV3Doc::wCarpetWallSpace: + //special exception case for 0x00 flag: carpet wall with arch!! + if(atn==0) PutSprite(pDC, x, y, pbmBase, pbmBaseMask, 29*58, 64, 76); + else ind=(atn==1 ? 26: atn==2 ? 28: 0); break; //26+(0~2) + } + + if(m_bPalace) { + //golden palace objects + switch(wa) { + case CPrincedV3Doc::wArchDown: + PutSprite(pDC, x, y+m_nFloorHeight, &m_bmBack, &m_bmBackMask, 3*32, 32, 63); + break; + case CPrincedV3Doc::wArchUpSmall: + PutSprite(pDC, x, y+m_nFloorHeight, &m_bmBack, &m_bmBackMask, 4*32, 32, 63); + break; + case CPrincedV3Doc::wArchUpBigLeft: + PutSprite(pDC, x, y+m_nFloorHeight, &m_bmBack, &m_bmBackMask, 5*32, 32, 63); + break; + case CPrincedV3Doc::wArchUpBigRight: + PutSprite(pDC, x, y+m_nFloorHeight, &m_bmBack, &m_bmBackMask, 6*32, 32, 63); + break; + } + } + + if(ind!=-1) PutSprite(pDC, x, y, pbmBase, pbmBaseMask, ind*58, 58, 76); +} + +//array allocation helper +static int *new_zero_int(int size) +{ + int *p; p=new int[size]; memset(p, 0, size*sizeof(int)); return p; +} + +template<typename T> +class CQueue { +protected: + struct NODE { + T data; NODE *extra; + }; + NODE *m_pHead, *m_pTail; int m_nElem; +public: + //Construction/destruction + CQueue(): m_pHead(NULL), m_nElem(0) {} + int GetCount() const { return m_nElem; } //number of elements + virtual ~CQueue(); + virtual void Add(const T& elem); + virtual bool Delete(T& elem); //returns the pointer to the element being deleted +}; + +template<typename T> +void CQueue<T>::Add(const T& elem) +{ + if(m_pHead) { m_pTail->extra=new NODE; m_pTail=m_pTail->extra; } + else { m_pTail=m_pHead=new NODE; } + m_pTail->extra=NULL; + m_pTail->data=elem; +} + +template<typename T> +bool CQueue<T>::Delete(T& elem) +{ + if(m_pHead) { //If there's anything to draw out + NODE *tmp=m_pHead; elem=m_pHead->data; m_pHead=m_pHead->extra; + delete tmp; return true; + } + else return false; //nothing +} + +template<typename T> +CQueue<T>::~CQueue() +{ + NODE *tmp, *tmp2; + for(tmp=m_pHead;tmp; tmp=tmp2) { tmp2=tmp->extra; delete tmp; } +} + +void CPrincedV3View::OnDraw(CDC* pDC) +{ + SCRNNUM s; CPrincedV3Doc* pDoc = GetDocument(); ASSERT_VALID(pDoc); + int i,j,k, x,y, it, jt; CRect rect; CPoint sp=GetScrollPosition(); + CPrincedV3Doc::GUARD guar; + + //guard settings + int *gu; CQueue<CPrincedV3Doc::GUARD> gq; gu=new_zero_int(CPrincedV3Doc::MAXSCRN+1); + + if(pDC->IsKindOf(RUNTIME_CLASS(CPaintDC))) //If by WM_PAINT, + //we can optimize the area to be drawn by accessing its member + rect=static_cast<CPaintDC *>(pDC)->m_ps.rcPaint; + else GetClientRect(rect); //draw the entire screen + + rect+=sp; //this is an invalid area + //to prevent garbages when scrolling to left/top, we must draw additional block (-1) + //but also check for negative values. + y=rect.bottom/m_nBlockY+1; x=rect.right/m_nBlockX+1; k=rect.top/m_nBlockY; k=max(k,0); + for(i=rect.left/m_nBlockX-1, i=max(i,0);i<x;i++) + for(j=y;j>=k;j--) { + s=pDoc->PositionFromScreen(i, j); + it=i%CPrincedV3Doc::SCRX; jt=j%CPrincedV3Doc::SCRY; + + //Virtual border objects + if (!s) { + SCRNNUM s2; + //If it is a floor + if ((jt==(CPrincedV3Doc::SCRY-1))&&(pDoc->PositionFromScreen(i, j+1))) + DrawObject(pDC, i*m_nBlockX, j*m_nBlockY-m_nFloorHeight, CPrincedV3Doc::wFloor, CPrincedV3Doc::null); + //If it is a wall + else if ((it==(CPrincedV3Doc::SCRX-1))&&(pDoc->PositionFromScreen(i+1, j))) + DrawObject(pDC, i*m_nBlockX, j*m_nBlockY-m_nFloorHeight, CPrincedV3Doc::wWallBlock, CPrincedV3Doc::null); + //If it is a lower nothing + else if ((jt==0)&&(s2=pDoc->PositionFromScreen(i, j-1))&&(pDoc->GetWallAt(it, CPrincedV3Doc::SCRY-1, s2)==CPrincedV3Doc::wNull)) + DrawObject(pDC, i*m_nBlockX, j*m_nBlockY-m_nFloorHeight, CPrincedV3Doc::wOutWallDown, CPrincedV3Doc::null); + //If it is a right nothing + else if ((it==0)&&(s2=pDoc->PositionFromScreen(i-1, j))&&(pDoc->GetWallAt(CPrincedV3Doc::SCRX-1, jt, s2)!=CPrincedV3Doc::wWallBlock)) + DrawObject(pDC, i*m_nBlockX, j*m_nBlockY-m_nFloorHeight, CPrincedV3Doc::wOutWallRight, CPrincedV3Doc::null); + //If it is a right-lower nothing + else if ((jt==0)&&(it==0)&&(s2=pDoc->PositionFromScreen(i-1, j-1))&&(pDoc->GetWallAt(CPrincedV3Doc::SCRX-1, CPrincedV3Doc::SCRY-1, s2)==CPrincedV3Doc::wNull)) + DrawObject(pDC, i*m_nBlockX, j*m_nBlockY-m_nFloorHeight, CPrincedV3Doc::wOutWallDownRight, CPrincedV3Doc::null); + else + DrawObject(pDC, i*m_nBlockX, j*m_nBlockY-m_nFloorHeight, CPrincedV3Doc::wWallBlock, CPrincedV3Doc::null); + } + + //Real objects + DrawObject(pDC, i*m_nBlockX, j*m_nBlockY-m_nFloorHeight, + pDoc->GetWallAt(it, jt, s), pDoc->GetBackAt(it, jt, s)); + + if(!gu[s]) { //Prepare for handling guard (only one guard per screen) + gu[s]=1; //only once + if(pDoc->GetGuard(s, &guar)) { //This screen has a guard + it=i-it; jt=j-jt; //12,13,14 -> 10, 3,4,5 -> 3 + guar.x+=it, guar.y+=jt; gq.Add(guar); //for convinience + } + } + } + + //Now, display guards at once //TODO: Redraw the front layer + while(gq.Delete(guar)) { + if(guar.color) k=guar.color; //normal guards + else k=8; //fat guy/Jaffar + + //according to his direction + switch(guar.org) { + case CPrincedV3Doc::gRight: + PutSprite(pDC, guar.x*m_nBlockX, guar.y*m_nBlockY-m_nFloorHeight, + &m_bmGuard, &m_bmGuardMask, k*58, 58, 76); + break; + case CPrincedV3Doc::gLeft: //m_nFloorDep is uncertain + PutSprite(pDC, guar.x*m_nBlockX+m_nFloorDep*2, guar.y*m_nBlockY- + m_nFloorHeight, &m_bmGuard, &m_bmGuardMask, (k+1)*58, -58, 76); + } + guar.x=(guar.x/10)*10; guar.y=(guar.y/3)*3; + } + + //at last, draw the border line + CPen rp, *op; rp.CreatePen(PS_SOLID, 1, m_bPalace ? RGB(0,255,255): RGB(255,0,0)); + op=pDC->SelectObject(&rp); + it=CPrincedV3Doc::SCRX*m_nBlockX; jt=CPrincedV3Doc::SCRY*m_nBlockY; + for(j=(rect.top/jt)*jt;j<rect.bottom;j+=jt) { + pDC->MoveTo(rect.left, j); pDC->LineTo(rect.right, j); + } + for(i=(rect.left/it)*it;i<rect.right;i+=it) { + pDC->MoveTo(i, rect.top); pDC->LineTo(i, rect.bottom); + } + + pDC->SelectObject(op); delete []gu; +#if 0 + CString st; + st.Format("Rendering level %d, pos %d %d, (screen %d) \n", m_nLev, i,j,c); + pDC->TextOut(0, rect.bottom-16, st); + + //locate the guard + { + //handle the front layer (when the guard overlaps the column and something) + for(err=b;err<b+2 && err<10;err++) { //have to consider the right side too :) + ind=-1; + switch(mpc.mGetWall(mpc.lev, c, a,err)&(~0x20)) { + case 0x03: ind=26; break; //floor with 1-story column + case 0x09: ind=27; break; //2-story floor (up part) + case 0x08: ind=28; break; //2-story floor (down part) + //TODO: more.. (spikes, choppers, doors ...) + } + if(ind!=-1) { + tempd.SelectObject(&bmMask); + pDC->BitBlt(err*32, a*63-13, 58, 76, &tempd, ind*58, 0, SRCAND); + tempd.SelectObject(&bmElem); + pDC->BitBlt(err*32, a*63-13, 58, 76, &tempd, ind*58, 0, SRCPAINT); + } + } + } + } + tempd.SelectObject(olb); +#endif +} + +///////////////////////////////////////////////////////////////////////////// +// CPrincedV3View printing + +BOOL CPrincedV3View::OnPreparePrinting(CPrintInfo* pInfo) +{ + // default preparation + return DoPreparePrinting(pInfo); +} + +void CPrincedV3View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: add extra initialization before printing +} + +void CPrincedV3View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: add cleanup after printing +} + +///////////////////////////////////////////////////////////////////////////// +// CPrincedV3View diagnostics + +#ifdef _DEBUG +void CPrincedV3View::AssertValid() const +{ + CScrollView::AssertValid(); +} + +void CPrincedV3View::Dump(CDumpContext& dc) const +{ + CScrollView::Dump(dc); +} + +CPrincedV3Doc* CPrincedV3View::GetDocument() // non-debug version is inline +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPrincedV3Doc))); + return (CPrincedV3Doc*)m_pDocument; +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CPrincedV3View message handlers + +void CPrincedV3View::OnDebugExecuteprinceofpersia() { +// SetRegKeyValue( + //cProcess normalExec("C:\\WINDOWS\\Escritorio\\kkx\\princed\\prince.exe"); + cConfig c; + c.setSetting("test","probando"); + c.setSetting("tama\xf1o",(char)43); + + Beep(2600,100); + +} + +void CPrincedV3View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + CPrincedV3Doc *pDoc=GetDocument(); + if(!m_byKey[nChar]) m_byKey[nChar]=1; m_nKeys++; + switch(nChar) { + case VK_PRIOR: + pDoc->LoadLevel(pDoc->GetLevel()-1); m_bPalace=pDoc->IsPalaceLevel(); CenterView(); + Invalidate(); break; + case VK_NEXT: + pDoc->LoadLevel(pDoc->GetLevel()+1); m_bPalace=pDoc->IsPalaceLevel(); CenterView(); + Invalidate(); break; + case VK_UP: + if(m_bSmoothKey) break; + ScrollToPosition(GetScrollPosition()+CPoint(0, -m_nBlockY)); break; + case VK_DOWN: + if(m_bSmoothKey) break; + ScrollToPosition(GetScrollPosition()+CPoint(0, m_nBlockY)); break; + case VK_LEFT: + if(m_bSmoothKey) break; + ScrollToPosition(GetScrollPosition()+CPoint(-m_nBlockX, 0)); break; + case VK_RIGHT: + if(m_bSmoothKey) break; + ScrollToPosition(GetScrollPosition()+CPoint(m_nBlockX, 0)); break; + case VK_SPACE: m_bPalace^=1; Invalidate(); break; + } + + CScrollView::OnKeyDown(nChar, nRepCnt, nFlags); +} + +void CPrincedV3View::OnMouseMove(UINT nFlags, CPoint point) +{ + if(GetCapture()==this) { //dragging + HandleEdit(point, nFlags); + switch(m_nCurTool) { + case ID_MAPTOOLS_ARRASTRAR: //Hand tool. drag the view. + ScrollToPosition(GetScrollPosition()+(m_ptPrev-point)); m_ptPrev=point; + break; + } + } + else { + //Hit-test the position + CMainFrame *pfr=DYNAMIC_DOWNCAST(CMainFrame, AfxGetMainWnd()); + CPrincedV3Doc* pDoc=GetDocument(); CPoint ps; CString t; + point+=GetScrollPosition(); ps.x=point.x/m_nBlockX, ps.y=point.y/m_nBlockY; + t.Format("(%d, %d) - %s 0x%x! ", ps.x, ps.y, + pDoc->GetWallName(pDoc->GetWallAt(ps.x, ps.y)), pDoc->GetBackAt(ps.x, ps.y)); + if(pfr) pfr->SetStatusText(t); + } +} + +void CPrincedV3View::OnInitialUpdate() +{ + SetZoom(m_nZoom); CScrollView::OnInitialUpdate(); + + m_bPalace=GetDocument()->IsPalaceLevel(); + if(m_bmBack.m_hObject==NULL) { //initialize graphic elements + m_bmBack.LoadBitmap(IDB_BACKS); m_bmBackMask.LoadBitmap(IDB_BACKMASK); + m_bmDung.LoadBitmap(IDB_ELEMS); m_bmDungMask.LoadBitmap(IDB_ELEMMASK); + m_bmPala.LoadBitmap(IDB_ELEMP); m_bmPalaMask.LoadBitmap(IDB_ELEMPMASK); + m_bmGuard.LoadBitmap(IDB_GUARD); m_bmGuardMask.LoadBitmap(IDB_GUARDMASK); + + CClientDC dc(this); + m_dcTemp.CreateCompatibleDC(&dc); m_pbmOld=m_dcTemp.GetCurrentBitmap(); + } +} + +void CPrincedV3View::OnDestroy() +{ + CScrollView::OnDestroy(); m_dcTemp.SelectObject(m_pbmOld); +} + +BOOL CPrincedV3View::OnEraseBkgnd(CDC* pDC) +{ + CRect rect; GetClientRect(rect); //fill black~ + pDC->FillRect(rect, CBrush::FromHandle((HBRUSH)::GetStockObject(BLACK_BRUSH))); + return TRUE; +} + +void CPrincedV3View::OnZoomFactor(UINT nID) +{ + switch(nID) { + case ID_VIEW_ZOOM_200: SetZoom(200); break; case ID_VIEW_ZOOM_100: SetZoom(100); break; + case ID_VIEW_ZOOM_50: SetZoom(50); break; case ID_VIEW_ZOOM_25: SetZoom(25); break; + } + Invalidate(); +} + +//Set the zoom factor, change related variables, and reset the view, placing the CPoint +//orientation to the center. +#define ZOOM(x) x=x*m_nZoom/100 +void CPrincedV3View::SetZoom(int fact, CPoint point) +{ + CSize sz; int nPrevz=m_nZoom; CRect rect; GetClientRect(rect); m_nZoom=fact; + m_nBlockX=32*m_nZoom/100; m_nBlockY=63*m_nZoom/100; m_nFloorHeight=13*m_nZoom/100; + m_nFloorDep=3*m_nZoom/100; + + sz=GetDocument()->GetMapSize(); + SetScrollSizes(MM_TEXT, CSize(m_nBlockX*CPrincedV3Doc::SCRX*15, + m_nBlockY*CPrincedV3Doc::SCRY*12), + CSize(CPrincedV3Doc::SCRX*m_nBlockX, m_nBlockY*CPrincedV3Doc::SCRY), + CSize(m_nBlockX, m_nBlockY)); + + point+=GetScrollPosition(); //now, center this point. + point.x=point.x*m_nZoom/nPrevz; point.y=point.y*m_nZoom/nPrevz; + ScrollToPosition(point+CPoint(-rect.Width()/2, -rect.Height()/2 )); + if(m_nZoom!=nPrevz) Invalidate(); //no optimized drawing +} +#undef ZOOM + +void CPrincedV3View::OnUpdateZoomFactor(CCmdUI *pCmdUI) +{ + switch(pCmdUI->m_nID) { + case ID_VIEW_ZOOM_200: pCmdUI->SetRadio(m_nZoom==200); break; + case ID_VIEW_ZOOM_100: pCmdUI->SetRadio(m_nZoom==100); break; + case ID_VIEW_ZOOM_50: pCmdUI->SetRadio(m_nZoom==50); break; + case ID_VIEW_ZOOM_25: pCmdUI->SetRadio(m_nZoom==25); break; + } +} + +void CPrincedV3View::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + if(m_byKey[nChar]) m_byKey[nChar]=0, m_nKeys--; +} + +BOOL CPrincedV3View::HandleKey() +{ + if(m_nKeys==0 || !m_bSmoothKey) { m_dwLastMomn=0; return FALSE; } + if(m_dwLastMomn==0) { m_dwLastMomn=::GetTickCount(); return TRUE; } + DWORD ex=::GetTickCount(); int delta; CPoint newp=GetScrollPosition(); + delta=(ex-m_dwLastMomn)*m_nZoom/200; //constant delta for both fast/slow computers + if(m_byKey[VK_LEFT]) newp+=CPoint(-delta,0); if(m_byKey[VK_RIGHT]) newp+=CPoint(delta,0); + if(m_byKey[VK_UP]) newp+=CPoint(0,-delta); if(m_byKey[VK_DOWN]) newp+=CPoint(0,delta); + if(newp!=GetScrollPosition()) { /*::Sleep(1);*/ ScrollToPosition(newp); } + m_dwLastMomn=ex; + return TRUE; +} + +void CPrincedV3View::CenterView() +{ + CRect rct; int srcsx, srcsy; CPoint pp=GetDocument()->GetStartScreen(); + GetClientRect(rct); srcsx=m_nBlockX*CPrincedV3Doc::SCRX; + srcsy=m_nBlockY*CPrincedV3Doc::SCRY; pp.x=(pp.x-1)*srcsx; pp.y=(pp.y-1)*srcsy; + pp.x-=(rct.Width()-srcsx)/2; pp.y-=(rct.Height()-srcsy)/2; + ScrollToPosition(pp); +} + +void CPrincedV3View::OnLButtonDown(UINT nFlags, CPoint point) +{ + int i; m_ptPrev=point; HandleEdit(point, nFlags); + switch(m_nCurTool) { + case ID_MAPTOOLS_ZOOM: //zoom in + for(i=0;i+1<sizeof(m_nZfact)/sizeof(m_nZfact[0]);i++) if(m_nZfact[i]>m_nZoom) break; + SetZoom(m_nZfact[i], point); break; + default: SetCapture(); + } +} + +void CPrincedV3View::OnMapTool(UINT nID) +{ + m_nCurTool=nID; +} + +void CPrincedV3View::OnUpdateMapTool(CCmdUI *pCmdUI) +{ + pCmdUI->Enable(!(pCmdUI->m_nID==ID_MAPTOOLS_WALKABLE_BALDOZACONESQUELETO && m_bPalace)); + pCmdUI->SetRadio(m_nCurTool==pCmdUI->m_nID); +} + +BOOL CPrincedV3View::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) +{ + UINT ind=0; + if(nHitTest==HTCLIENT) //not on a scroll bar or anything else! :-P + switch(m_nCurTool) { //different cursor for different map tools + case ID_MAPTOOLS_DROPPER: ind=IDC_DROPPER; break; + case ID_MAPTOOLS_ZOOM: ind=IDC_ZOOMTOOL; break; + case ID_MAPTOOLS_ARRASTRAR: ind=IDC_HANDPALM; break; + } + + if(ind!=0) { ::SetCursor(AfxGetApp()->LoadCursor(ind)); return FALSE; } + return CScrollView::OnSetCursor(pWnd, nHitTest, message); +} + +void CPrincedV3View::OnLButtonUp(UINT nFlags, CPoint point) +{ + ReleaseCapture(); +} + +void CPrincedV3View::OnRButtonDown(UINT nFlags, CPoint point) +{ + int i; + switch(m_nCurTool) { + case ID_MAPTOOLS_ZOOM: //zoom out + for(i=sizeof(m_nZfact)/sizeof(m_nZfact[0])-1;i>0;i--) if(m_nZfact[i]<m_nZoom) break; + SetZoom(m_nZfact[i], point); break; + } +} + +void CPrincedV3View::HandleEdit(CPoint point, UINT nFlags) +{ + BOOL b=TRUE; CPrincedV3Doc::WALL wa; CPrincedV3Doc::ATTRIB at=CPrincedV3Doc::null; + int sx,sy; CPoint pt=point; CPrincedV3Doc *pDoc=GetDocument(); + point+=GetScrollPosition(); sx=point.x/m_nBlockX, sy=point.y/m_nBlockY; + + switch(m_nCurTool) { + case ID_MAPTOOLS_CLEAR: wa=CPrincedV3Doc::wNull; break; //draw-something tool + case ID_MAPTOOLS_OBJECTS_POSSION: wa=CPrincedV3Doc::wPotion; at=CPrincedV3Doc::potRedSmall; break; + + case ID_MAPTOOLS_WALKABLE_NORMAL: wa=CPrincedV3Doc::wFloor; break; //normal floor + case ID_MAPTOOLS_WALKABLE_BALDOZAROTA: + switch(pDoc->GetWallAt(sx, sy)) { + case CPrincedV3Doc::wFloorTorch: case CPrincedV3Doc::wBrokenFloorTorch: + wa=CPrincedV3Doc::wBrokenFloorTorch; break; + default: wa=CPrincedV3Doc::wBrokenFloor; + } + break; //broken floor + case ID_MAPTOOLS_WALKABLE_BALDOZAFLOJA: wa=CPrincedV3Doc::wLooseFloor; break; //loose floor + case ID_MAPTOOLS_WALKABLE_BALDOZAAPRETABLE: wa=CPrincedV3Doc::wDoorOpener; break; //door opener + case ID_MAPTOOLS_WALKABLE_DOORCLOSER: wa=CPrincedV3Doc::wDoorCloser; break; //door closer + case ID_MAPTOOLS_WALKABLE_PINCHES: wa=CPrincedV3Doc::wSpike; break; //spikes + case ID_MAPTOOLS_WALKABLE_BALDOZACONESQUELETO: wa=CPrincedV3Doc::wSkeleton; break; //skeleton + + case ID_MAPTOOLS_GATES_DOOR: wa=CPrincedV3Doc::wDoor; at=CPrincedV3Doc::doorClosed; break; + case ID_MAPTOOLS_GATES_PUERTASIERRA: wa=CPrincedV3Doc::wChopper; break; //chopper + case ID_MAPTOOLS_SWORD: wa=CPrincedV3Doc::wSword;break; + //case ID_MAPTOOLS_GATES_LEVELGATE: wa=CPrincedV3Doc::; break; //level gate. (NOTE: 2 blocks) + case ID_MAPTOOLS_WALL: wa=CPrincedV3Doc::wWallBlock; break; + case ID_MAPTOOLS_BACKGROUND_COLUMN: wa=CPrincedV3Doc::wOneColumn; break; + //case ID_MAPTOOLS_BACKGROUND_BIGCOLUMN: wa=CPrincedV3Doc::wBigColumnUp; break; //(NOTE: 2 blocks) + case ID_MAPTOOLS_BACKGROUND_LIGHT: + switch(pDoc->GetWallAt(sx, sy)) { + case CPrincedV3Doc::wBrokenFloor: case CPrincedV3Doc::wBrokenFloorTorch: + wa=CPrincedV3Doc::wBrokenFloorTorch; break; + default: wa=CPrincedV3Doc::wFloorTorch; + } + break; + + //and many background objects + + default: b=FALSE; break; + } + if(b) { + CRect rct; + rct.left=pt.x-m_nBlockX; rct.right=pt.x+m_nBlockX*2; //with original mouse point + rct.top=pt.y-m_nBlockY; rct.bottom=pt.y+m_nBlockY*2; + if(pDoc->GetWallAt(sx, sy)!=wa || pDoc->GetBackAt(sx, sy)!=at) { + pDoc->PlaceObject(sx, sy, wa, at); InvalidateRect(rct); //invalidate only when necessary + } + pDoc->SetModifiedFlag(); + } +} + +//Setting the view mode -- either the palace or the dungeon +void CPrincedV3View::OnViewMode(UINT nID) +{ + m_bPalace= nID==ID_VIEW_ASPALACE; Invalidate(); +} + +void CPrincedV3View::OnUpdateViewMode(CCmdUI *pCmdUI) +{ + pCmdUI->SetRadio( (pCmdUI->m_nID==ID_VIEW_ASDUNGEON) ^ m_bPalace); +} + +void CPrincedV3View::OnTimer(UINT nIDEvent) +{ + //TODO: implement scroll when dragging mouse outside the view + + CScrollView::OnTimer(nIDEvent); +} diff --git a/pv3/Princed V3View.h b/pv3/Princed V3View.h new file mode 100644 index 0000000..1cc09b3 --- /dev/null +++ b/pv3/Princed V3View.h @@ -0,0 +1,111 @@ +// Princed V3View.h : interface of the CPrincedV3View class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_PRINCEDV3VIEW_H__B98D158F_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_) +#define AFX_PRINCEDV3VIEW_H__B98D158F_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +class CPrincedV3View : public CScrollView +{ +protected: // create from serialization only + CPrincedV3View(); + DECLARE_DYNCREATE(CPrincedV3View) + +// Attributes +public: + CPrincedV3Doc* GetDocument(); + +// Operations +public: + void DrawObject(CDC *pDC, int x, int y, CPrincedV3Doc::WALL wa, CPrincedV3Doc::ATTRIB at= + CPrincedV3Doc::null); + void CenterView(); + BOOL HandleKey(); //Idle-time processing for smooth key scroll + void HandleEdit(CPoint pt, UINT nFlags=0); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CPrincedV3View) + public: + virtual void OnDraw(CDC* pDC); // overridden to draw this view + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual void OnInitialUpdate(); + protected: + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); + virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CPrincedV3View(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + //Map tool + static UINT m_nCurTool; //currently selected tool + static CPoint m_ptPrev; //previous mouse cursor position (only one mouse, so static :-) + + //Graphic elements + CBitmap m_bmDung, m_bmDungMask, m_bmPala, m_bmPalaMask; + CBitmap m_bmGuard, m_bmGuardMask, m_bmBack, m_bmBackMask; + BOOL m_bPalace; //yellow palace mode? + + //Metric factor + int m_nBlockX, m_nBlockY, m_nFloorHeight, m_nFloorDep; //32, 63, 13, 3 + int m_nZoom; + void SetZoom(int fact, CPoint orig=CPoint(0,0)); + const static int m_nZfact[]; + + //Virtual DC + CDC m_dcTemp; CBitmap *m_pbmOld; + void PutSprite(CDC *pDC, int dstx, int dsty, CBitmap *pSrc, CBitmap *pMask, + int srcx, int cx, int cy); //helper function + + //Keyboard behavior + static BYTE m_byKey[256]; BOOL m_bSmoothKey; static int m_nKeys; DWORD m_dwLastMomn; + +// Generated message map functions +protected: + + afx_msg void OnZoomFactor(UINT nID); + afx_msg void OnUpdateZoomFactor(CCmdUI *pCmdUI); + afx_msg void OnMapTool(UINT nID); + afx_msg void OnUpdateMapTool(CCmdUI *pCmdUI); + afx_msg void OnViewMode(UINT nID); + afx_msg void OnUpdateViewMode(CCmdUI *pCmdUI); + //{{AFX_MSG(CPrincedV3View) + afx_msg void OnDebugExecuteprinceofpersia(); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnDestroy(); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); + afx_msg void OnTimer(UINT nIDEvent); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +#ifndef _DEBUG // debug version in Princed V3View.cpp +inline CPrincedV3Doc* CPrincedV3View::GetDocument() + { return (CPrincedV3Doc*)m_pDocument; } +#endif + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_PRINCEDV3VIEW_H__B98D158F_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_) diff --git a/pv3/RegisterWIN32.cpp b/pv3/RegisterWIN32.cpp new file mode 100644 index 0000000..b0badc7 --- /dev/null +++ b/pv3/RegisterWIN32.cpp @@ -0,0 +1,973 @@ +// RegisterWIN32.cpp: implementation of the CRegistreWIN32 class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "RegisterWIN32.h" + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CRegisterWIN32::CRegisterWIN32() +{ + //** Par defaut on utilise ce RootKey + m_RootKey = HKEY_LOCAL_MACHINE; + m_pszPath = new TCHAR[_MAX_PATH * sizeof(TCHAR)]; + m_hKey = NULL; + m_szTemp = new TCHAR[_MAX_PATH * sizeof(TCHAR)]; +} + +CRegisterWIN32::~CRegisterWIN32() +{ + //** Clean up memory and Close Session + delete []m_pszPath; + delete []m_szTemp; + if(m_hKey) RegCloseKey(m_hKey); +} + + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: Open +// +// Description....: Open a registry Session +// Example: CRegistreWIN32 MyReg; +// if( MyReg.Open(HKEY_CURRENT_USER, _T("Software\\SevySoft\\Admin")) ) +// //** Open the Key in Read Mode Only +// //** The Key is in the Registry +// else +// //** The Key is not founded +// +// Example: Open(HKEY_CURRENT_USER, _T("Software\\SevySoft\\Admin"), FALSE) +// //** This time if the Key do not exist then +// //** it will be created +// +// +// Author, date...: Yves Lessard , 24-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// hKeyRoot HKEY R Root Key +// szSubKey LPCTSTR R Sub Key +// bReadOnly BOOL R TRUE -> (Default) Read Only +// FALSE-> Read/Write +// If Subkey not found Create it +// Open BOOL W TRUE-> OK else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::Open(HKEY hKeyRoot, LPCTSTR szPath, BOOL bReadOnly) +{ + BOOL bResult = FALSE; + try + { + //** If a Session Key Opened then close it + if ( m_hKey ) + RegCloseKey(m_hKey); + + //** 5 Roots Key choice + if ( hKeyRoot == HKEY_CLASSES_ROOT || + hKeyRoot == HKEY_CURRENT_USER || + hKeyRoot == HKEY_LOCAL_MACHINE || + hKeyRoot == HKEY_USERS || + hKeyRoot == HKEY_CURRENT_CONFIG ) + { + //** Save RootKey for reference + m_RootKey = hKeyRoot; + if ( _tcslen(szPath)* sizeof(TCHAR) > 0 ) + { + //** We have a path so save it + _tcscpy(m_pszPath, szPath); + switch (bReadOnly) + { + case TRUE: + //** Read Mode Only + if ( VerifyKey() ) + bResult = TRUE; + break; + default: + //** Else Read/Write + if ( VerifyKey() == FALSE ) + { + //** Key not Found so create it + if( CreateKey() ) + bResult = TRUE; + } + } + } + } + } + catch(...) + { + bResult = FALSE; + } + return bResult; +} + + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: Close +// +// Description....: Close a Registry Session +// The destructor also Close the Key +// +// Author, date...: Yves Lessard , 24-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// Close BOOL W TRUE->OK else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::Close() +{ + BOOL bResult = FALSE; + try + { + if ( m_hKey ) + RegCloseKey(m_hKey); + m_hKey = NULL; + } + catch(...) + { + bResult = FALSE; + } + + return bResult; +} + + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: Open +// +// Description....: Open a Session with Path and Key +// The KeyRoot = HKEY_LOCAL_MACHINE as Default +// +// Author, date...: Yves Lessard , 24-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// szPath LPCTSTR R The Path +// bReadOnly BOOL R TRUE-> (Default) Read Only +// FALSE-> Read/Write +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::Open(LPCTSTR szPath, BOOL bReadOnly) +{ + BOOL bResult = FALSE; + try + { + //** If Session Key Opened then close it + if ( m_hKey ) + RegCloseKey(m_hKey); + //** Always use this one + m_RootKey = HKEY_LOCAL_MACHINE; + + if ( _tcslen(szPath)* sizeof(TCHAR) > 0 ) + { + _tcscpy(m_pszPath, szPath); + switch (bReadOnly) + { + case TRUE: + //** Read only mode + if ( VerifyKey() ) + //** The Path exist + bResult = TRUE; + break; + default: + //** Read Write Mode + if ( VerifyKey() == FALSE ) + { + //** If Path not Found Create it + if( CreateKey() ) + //** If success return TRUE + bResult = TRUE; + } + } + } + } + catch(...) + { + bResult = FALSE; + } + + return bResult; + +} + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: Write (int) +// +// Description....: Write Integer value +// +// +// Author, date...: Yves Lessard , 24-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// szKey LPCTSTR R The Key +// iVal int R The Value +// Write BOOL W TRUE->Succes Else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::Write(LPCTSTR szKey, int iVal) +{ + BOOL bResult = FALSE; + try + { + if ( SetValue(szKey, (DWORD)iVal) ) + bResult = TRUE; + } + catch(...) + { + bResult = FALSE; + } + return bResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: Write (string) +// +// Description....: Write a string into the Key value +// +// +// Author, date...: Yves Lessard , 24-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// szKey LPCTSTR R The Key +// szValue LPCTSTR R The String to Write +// Write BOOL W TRUE-> Ok Else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::Write(LPCTSTR szKey, LPCTSTR szValue) +{ + BOOL bResult = FALSE; + try + { + DWORD dLen = _tcslen(szValue) * sizeof(TCHAR); + if ( dLen > 0) + { + //** Not empty string so proceed + dLen++; + if( RegSetValueEx(m_hKey, szKey,0, + REG_SZ, (CONST BYTE*)szValue, + dLen ) == ERROR_SUCCESS ) + //** Success + bResult = TRUE; + } + } + catch(...) + { + bResult = FALSE; + } + return bResult; +} + + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: Write (DWORD) +// +// Description....: Write a DWORD to the Key +// +// +// Author, date...: Yves Lessard , 24-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// szKey LPCTSTR R The Key +// dwVal DWORD R The Value +// Write BOOL W TRUE->Succes Else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::Write(LPCTSTR szKey, DWORD dwVal) +{ + BOOL bResult = FALSE; + try + { + if ( SetValue(szKey, dwVal) ) + bResult = TRUE; + } + catch(...) + { + bResult = FALSE; + } + return bResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: Write (LPBYTE) +// +// Description....: Write a Binary value +// Example: BYTE MonByte[10]={1,2,3,4,5,6,7,8,9,10}; +// MyReg.Write("BinVal", MonByte, 10); +// We write the BYTE array with 10 values +// +// +// Author, date...: Yves Lessard , 24-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// szKey LPCTSTR R The Key +// dwVal LPBYTE R The BYTE Array +// nLen DWORD R Number of Elements to Write +// Write BOOL W TRUE->Succes Else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::Write(LPCTSTR szKey, LPBYTE pValue, DWORD nLen) +{ + BOOL bResult = FALSE; + try + { + if ( RegSetValueEx(m_hKey, szKey, 0, REG_BINARY, pValue, nLen) == ERROR_SUCCESS ) + bResult = TRUE; + } + catch(...) + { + bResult = FALSE; + } + return bResult; +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: Read +// +// Description....: Read a string Value into a char or TCHAR +// Example: TCHAR *szTemp=NULL; +// You don't need to allocate memory +// but you are responsable to free up memmory +// +// Author, date...: Yves Lessard , 25-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// szKey LPCTSTR R The key to read +// pszValue LPTSTR R Destination to store Data +// Read BOOL W TRUE-> OK Else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::Read(LPCTSTR szKey, LPTSTR &pszValue) +{ + BOOL bResult = FALSE; + try + { + if ( StringIN(szKey) ) + { + //** The Key exist so proceed + if( pszValue != NULL ) + delete pszValue; + //** We re-allocate memory on destination pointer + pszValue = new _TCHAR[_tcslen(m_szTemp) + 1 * sizeof(TCHAR)]; + //** Transfert the reading result + _tcscpy(pszValue, m_szTemp); + bResult = TRUE; + } + } + catch(...) + { + bResult = FALSE; + } + return bResult; +} + + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: Read (DWORD) +// +// Description....: We read a DWORD value +// Example: DWORD dVal; +// MyReg.Read("LTop", dVal); +// +// Author, date...: Yves Lessard , 25-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// szKey LPCTSTR R The Key +// pdwVal DWORD R Destination +// Read BOOL W TRUE->Succes else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::Read(LPCTSTR szKey, DWORD &pdwVal) +{ + BOOL bResult = FALSE; + try + { + if ( GetValue(szKey) ) + { + //** Save result into destination + pdwVal = m_dTemp; + bResult = TRUE; + } + } + catch(...) + { + bResult = FALSE; + } + return bResult; +} + + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: Read (int) +// +// Description....: Integer reading +// +// +// Author, date...: Yves Lessard , 24-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// szKey LPCTSTR R The Key +// *piVal int R Int result +// Read BOOL W TRUE->Succes Else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::Read(LPCTSTR szKey, int &piVal) +{ + BOOL bResult = FALSE; + try + { + if ( GetValue(szKey) ) + { + //** Store reulst into destination + piVal = (int)m_dTemp; + bResult = TRUE; + } + } + catch(...) + { + bResult = FALSE; + } + return bResult; +} + + +#ifdef USE_MFC +//** If we are using MFC CString + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: Read +// +// Description....: Read a String key & store it in CString (MFC) +// CString automaticaly deal with memory +// +// Author, date...: Yves Lessard , 24-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// szKey LPCTSTR R The Key +// szValue CString W The read result +// Read BOOL W TRUE->OK else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::Read(LPCTSTR szKey, CString &pszValue) +{ + BOOL bResult = FALSE; + try + { + if( StringIN(szKey) ) + { + //** Store result in CString destination + pszValue = m_szTemp; + bResult = TRUE; + } + } + catch(...) + { + bResult = FALSE; + } + return bResult; +} +#endif + + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: DeleteValue +// +// Description....: Delete a Key Value +// +// +// Author, date...: Yves Lessard , 25-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// szKey LPCTSTR R The Key Value +// DeleteValue BOOL W TRUE->Success else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::DeleteValue(LPCTSTR szKey) +{ + BOOL bResult = FALSE; + try + { + //** The Key Value to Delete + if ( RegDeleteValue(m_hKey, szKey) == ERROR_SUCCESS ) + bResult= TRUE; + } + catch(...) + { + bResult = FALSE; + } + return bResult; +} + + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: DeleteKey +// +// Description....: Delete Key and SubKey +// With WinNT we need a special Function +// You don't need to use Open for this Function +// Example: MyReg.DeleteKey(HKEY_CURRENT_USER, _T("Software\\SevySoft")); +// The Function will extract the Path = Software +// Then delete the Key SevySoft with all SubDir and Value Inside +// +// +// Author, date...: Yves Lessard , 07-Fev-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// hKeyRoot HKEY R The KeyRoot +// szPath LPCTSTR R Key or SubKey +// DeleteKey BOOL W TRUE->OK Else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::DeleteKey(HKEY hKeyRoot, LPCTSTR szPath) +{ + BOOL bResult = FALSE; + try + { + TCHAR *pszSubKey = new TCHAR[_MAX_PATH * sizeof(TCHAR)]; + TCHAR *pszPath = new TCHAR[_MAX_PATH * sizeof(TCHAR)]; + TCHAR *pDest=NULL; + //** If Path empty we get out + if( _tcslen(szPath) * sizeof(TCHAR) == 0) + goto Exit_Point; + + pDest= _tcsrchr(szPath, '\\'); + if (pDest != NULL) + { + //** Must extract the Last Key + pDest++; + //** Copy the Key or SubKey to delete + _tcscpy(pszSubKey, pDest); + //** We must now extract the Path + pDest--; + int iCount=0; + int Result=0; + Result = pDest - szPath ; + do + { + pszPath[iCount] = szPath[iCount]; + iCount++; + }while ( iCount < Result ); + //** Add end of string mark + pszPath[iCount]= '\0'; + } + else + { + //** We want to delete a path + _tcscpy(pszSubKey, szPath); + //** There is no path + _tcscpy(pszPath, _T("")); + } + HKEY hKey; + //** Check if Path exist ... + if ( RegOpenKeyEx(hKeyRoot, pszPath, 0L, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS ) + goto Exit_Point; + + //** Check NT or 2000 + if( GetOSversion() ) + if ( m_dTemp == 1 ) + { + //** NT system must use Recursive Delete + if( DeleteNTway(hKey, pszSubKey) ) + bResult = TRUE; + } + else + { + //** Windows 95 or 98 + if ( RegDeleteKey(hKey , pszSubKey) == ERROR_SUCCESS ) + bResult= TRUE; + } + + RegCloseKey(hKey); +Exit_Point: + delete pszSubKey, pszPath; + } + catch(...) + { + bResult = FALSE; + } + return bResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: Read LPBYTE +// +// Description....: Read a Byte array +// Most of the times we know how many Bytes we need +// Example: BYTE MyBytes[25]; +// DWORD dwByteRead; +// MyReg.Read("ArrayKey", MyBytes, dwByteRead); +// +// +// Author, date...: Yves Lessard , 24-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// szKey LPCTSTR R The Key +// pValue LPBYTE W The Byte Array +// pnLen DWORD W The number of Bytes readed +// Read BOOL W TRUE->Success else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::Read(LPCTSTR szKey, LPBYTE pValue, DWORD &pnLen) +{ + BOOL bResult = FALSE; + try + { + if ( VerifyKey() ) + { + if ( RegQueryValueEx(m_hKey, szKey, NULL, NULL, pValue, &pnLen) == ERROR_SUCCESS ) + bResult = TRUE; + } + } + catch(...) + { + bResult = FALSE; + } + + return bResult; +} + + +//********************* +// Private Functions +//********************* + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: VerifyKey +// +// Description....: Private function We check if a Key exist +// We already have the RootKey & Path +// +// +// Author, date...: Yves Lessard , 24-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// VerifyKey BOOL W TRUE-> OK else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::VerifyKey() +{ + BOOL bResult = FALSE; + try + { + if ( RegOpenKeyEx(m_RootKey, m_pszPath, 0L, KEY_ALL_ACCESS, &m_hKey) == ERROR_SUCCESS ) + //** Success the Key exist + bResult= TRUE; + } + catch(...) + { + bResult = FALSE; + } + + return bResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: StringIN +// +// Description....: Private function for String reading +// +// +// Author, date...: Yves Lessard , 24-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// szKey LPCTSTR R The Key to read +// StringIN BOOL W TRUE->OK Else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::StringIN(LPCTSTR szKey) +{ + BOOL bResult = FALSE; + try + { + if ( _tcsclen(szKey)* sizeof(TCHAR) > 0 ) + { + //** We can do the writing + DWORD dwType; + DWORD dwSize = MAX_PATH; + if( RegQueryValueEx(m_hKey, szKey, 0, &dwType, + (BYTE*)m_szTemp, &dwSize) == ERROR_SUCCESS) + //** No error + bResult = TRUE; + } + } + catch(...) + { + bResult = FALSE; + } + return bResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: SetValue +// +// Description....: Private function for DWORD & Int writing +// +// +// Author, date...: Yves Lessard , 24-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// SetValue BOOL W TRUE->OK Else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::SetValue(LPCTSTR szKey, DWORD dVal) +{ + BOOL bResult = FALSE; + try + { + //** Write the Value + if( RegSetValueEx(m_hKey, szKey,0, + REG_DWORD, (CONST BYTE*)&dVal, sizeof(DWORD)) == ERROR_SUCCESS ) + //** No error + bResult = TRUE; + } + catch(...) + { + bResult = FALSE; + } + return bResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: GetValue +// +// Description....: Private function to read a DWORD +// The value is store in m_dTemp +// +// Author, date...: Yves Lessard , 24-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// szKey LPCTSTR R The Key +// GetValue BOOL W TRUE->OK Else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::GetValue(LPCTSTR szKey) +{ + BOOL bResult = FALSE; + try + { + DWORD dwType; + DWORD dwSize = sizeof(DWORD); + if( RegQueryValueEx(m_hKey, szKey, 0, &dwType, + (BYTE*)&m_dTemp, &dwSize) == ERROR_SUCCESS ) + //** Success + bResult = TRUE; + } + catch(...) + { + bResult = FALSE; + } + return bResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: GetOSversion +// +// Description....: We want to know if NT4 ou Win2000 +// Private Fucntion +// +// Author, date...: Yves Lessard , 26-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// GetOSversion BOOL W TRUE->OK +// We should check m_dTemp after called +// m_dTemp = 1 NT4 ou Win2000 +// m_dTemp = 0 Win95, Win98 +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::GetOSversion() +{ + BOOL bResult = FALSE; + m_dTemp = 0; + try + { + OSVERSIONINFO osv; + osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + if (GetVersionEx(&osv)) + { + // note: szCSDVersion = service pack release + TCHAR *ServiceRelease = osv.szCSDVersion; + switch(osv.dwPlatformId) + { + case VER_PLATFORM_WIN32_NT: + m_dTemp=1; + bResult = TRUE; + break; + default: + m_dTemp=0; + bResult = TRUE; + break; + } + } + } + catch(...) + { + bResult = FALSE; + } + return bResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: CreateKey +// +// Description....: (Private Fucntion) From m_RootKey and m_pszPath and m_hKey +// We create the Key path +// +// +// Author, date...: Yves Lessard , 24-Avril-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// CreateKey BOOL W TRUE-> OK else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::CreateKey() +{ + BOOL bResult = FALSE; + try + { + if ( m_hKey ) + RegCloseKey(m_hKey); + LONG lresult=0; + lresult= RegCreateKeyEx(m_RootKey, m_pszPath, 0, 0, + REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, + 0, &m_hKey, 0); + if ( lresult == ERROR_SUCCESS ) + //** Creating the key was successfull + bResult= TRUE; + } + catch(...) + { + bResult = FALSE; + } + + return bResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// Function.......: DeleteNTway +// +// Description....: Delete each Subkey +// Thsi is a recursive Function +// +// Author, date...: Yves Lessard , 17-Apr-2001. +// +// Modifications..: +// +// Arguments +// Name Type Acces Description +// ------------------ ------- ------ ------------------------------------- +// hKey HKEY R The RootKey +// szSubKey LPCTSTR R The Subkey to Delete +// DeleteNTway BOOL W TRUE-> Success else FALSE +//////////////////////////////////////////////////////////////////////////////// +BOOL CRegisterWIN32::DeleteNTway(HKEY hKey, LPCTSTR szSubKey) +{ + BOOL bResult = FALSE; + try + { + HKEY lhKey; + FILETIME ft; + LONG lResult; + DWORD dwKeyLen; + TCHAR *pszTemp = new TCHAR[_MAX_PATH * sizeof(TCHAR)]; + + //** If Path empty we get out + if( _tcslen(szSubKey) * sizeof(TCHAR) == 0) + goto Exit_Point; + lResult =RegOpenKeyEx(hKey, szSubKey, 0L, KEY_ENUMERATE_SUB_KEYS, &lhKey); + if (lResult == ERROR_SUCCESS ) + { + //** So far the Key exist + do + { + dwKeyLen = _MAX_PATH * sizeof(TCHAR); + lResult = RegEnumKeyEx(lhKey, 0, pszTemp, &dwKeyLen, NULL, NULL, + NULL, &ft); + switch (lResult) + { + case ERROR_NO_MORE_ITEMS: + //** No more Subkey so delete the base + if ( RegDeleteKey(hKey , szSubKey) == ERROR_SUCCESS ) + { + bResult= TRUE; + goto Exit_Point; + } + break; + case ERROR_SUCCESS: + if( DeleteNTway(lhKey, pszTemp) ) + bResult = TRUE; + break; + } + }while( lResult == ERROR_SUCCESS); + RegCloseKey(lhKey); + } + +Exit_Point: + delete pszTemp; + } + catch(...) + { + bResult = FALSE; + } + return bResult; +} diff --git a/pv3/RegisterWIN32.h b/pv3/RegisterWIN32.h new file mode 100644 index 0000000..69506f3 --- /dev/null +++ b/pv3/RegisterWIN32.h @@ -0,0 +1,132 @@ +/****************************************************************************** +/** Class Name.....: CRegisterWIN32 (RegisterWIN32.h) +/** Description....: Some registry functions in WIN32 Environnment +/** If you want to use the Class in MFC (CString) +/** #define USE_MFC +/** +/** Author, date...: Yves Lessard , 27-Apr-2000. +/** +/** 1.0.0.0 30-Apr-2000 +/** +/** Modifications..: +/** +/** Method(Public) Description +/** +/** --> There are 2 ways to initialize a Session Key +/** +/** 1) Open(RootKey,SubKey,Mode) Open a Session and must pass the RootKey and Path +/** By default Mode is Read Only +/** 2) Open(Subkey, Mode) The Rootkey = HKEY_LOCAL_MACHINE as default +/** You specify the Path and The Key +/** Close Close a Session Key +/** +/** Write(szKey, LPCTSTR szValue) Write a String to the Key +/** Write(szKey, DWORD) Write a DWORD value +/** Write(szKey , Int) Write a Int value +/** Write(szKey, LPBYTE) Write Byte array +/** WriteStruct(szKey, T &obj) For all other kind of Data +/** Float, Double, CRect, etc +/** +/** Read(szKey, &pszDest) Read a string value +/** Read(szKey, CString) Read a String value Store in CString +/** Read(szKey, &DWORD) Read a Dword value +/** Read(szKey, Int) Read Integer value +/** Read(szKey, LPBYTE, &DWORD) Read a Byte array +/** ReadStruct(LPCTSTR szKey, T &obj) Read all other kind of Data +/** +/** DeleteValue(LPCTSTR szKey) Delete a Key Value +/** DeleteKey(HKEY, LPCTSTR szSubKey) Delete a Key or SubKey (Recursive) +/** +******************************************************************************/ + +//#if !defined(AFX_REGISTERWIN32_H__305C4B07_38D6_11D5_8068_0050BAB07D8B__INCLUDED_) +//#define AFX_REGISTERWIN32_H__305C4B07_38D6_11D5_8068_0050BAB07D8B__INCLUDED_ + +//#if _MSC_VER > 1000 +//#pragma once +//#endif // _MSC_VER > 1000 +#include <tchar.h> +#include <windows.h> +#include <stdlib.h> + +//** If use with MFC and you want CString remove rem on next line +//#define USE_MFC + +class CRegisterWIN32 +{ +public: + BOOL DeleteKey(HKEY hKeyRoot, LPCTSTR szPath); + BOOL DeleteValue(LPCTSTR szKey); +#ifdef USE_MFC + BOOL Read(LPCTSTR szKey, CString &pszValue); +#endif + BOOL Read(LPCTSTR szKey, int &piVal); + BOOL Read(LPCTSTR szKey, DWORD &pdwVal); + BOOL Read(LPCTSTR szKey, LPTSTR &pszValue); + BOOL Read(LPCTSTR szKey, LPBYTE pValue, DWORD &pnLen); + + BOOL Write(LPCTSTR szKey, int iVal); + BOOL Write(LPCTSTR szKey, DWORD dwVal); + BOOL Write(LPCTSTR szKey, LPCTSTR szValue); + BOOL Write(LPCTSTR szKey, LPBYTE pValue, DWORD nLen); + + BOOL Open(LPCTSTR szPath, BOOL bReadOnly = TRUE); + BOOL Close(); + BOOL Open(HKEY hKeyRoot, LPCTSTR szPath, BOOL bReadOnly = TRUE); + CRegisterWIN32(); + virtual ~CRegisterWIN32(); + //************** + // WriteStruct + //************** + template <class T>BOOL WriteStruct(LPCTSTR szKey, T &obj) + { + BOOL bResult = FALSE; + try + { + //** Translate data to Binary + if ( RegSetValueEx(m_hKey, szKey, 0, REG_BINARY,(LPBYTE)&obj, sizeof(T)) == ERROR_SUCCESS ) + bResult = TRUE; + } + catch(...) + { + bResult = FALSE; + } + return bResult; + } + //******************** + // ReadStruct + //******************** + template <class T>BOOL ReadStruct(LPCTSTR szKey, T &obj) + { + BOOL bResult = FALSE; + try + { + //** Read the data + DWORD dwLen = sizeof(T); + if ( ::RegQueryValueEx(m_hKey, szKey, NULL, NULL, (LPBYTE)&obj,&dwLen) == ERROR_SUCCESS ) + bResult = TRUE; + } + catch(...) + { + bResult = FALSE; + } + return bResult; + } + +private: + BOOL DeleteNTway(HKEY hKey, LPCTSTR szSubKey); + BOOL GetOSversion(); + _TCHAR * m_szTemp; + BOOL StringIN(LPCTSTR szKey); + BOOL GetValue(LPCTSTR szKey); + DWORD m_dTemp; + BOOL SetValue(LPCTSTR szKey, DWORD dVal); + HKEY m_hKey; + BOOL CreateKey(); + BOOL VerifyKey(); + _TCHAR *m_pszPath; + HKEY m_RootKey; + int iOSversion; +}; + +//#endif // !defined(AFX_REGISTERWIN32_H__305C4B07_38D6_11D5_8068_0050BAB07D8B__INCLUDED_) diff --git a/pv3/StdAfx.cpp b/pv3/StdAfx.cpp new file mode 100644 index 0000000..bc56938 --- /dev/null +++ b/pv3/StdAfx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// Princed V3.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + + diff --git a/pv3/StdAfx.h b/pv3/StdAfx.h new file mode 100644 index 0000000..391faef --- /dev/null +++ b/pv3/StdAfx.h @@ -0,0 +1,28 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__B98D1587_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_) +#define AFX_STDAFX_H__B98D1587_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include <afxwin.h> // MFC core and standard components +#include <afxext.h> // MFC extensions +#include <afxdisp.h> // MFC Automation classes +#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include <afxcmn.h> // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include <afxsock.h> // MFC socket extensions + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__B98D1587_6AA8_11D7_8A8E_00104B7CC0FF__INCLUDED_) diff --git a/pv3/cSelectLevelWindow.cpp b/pv3/cSelectLevelWindow.cpp new file mode 100644 index 0000000..84de5ee --- /dev/null +++ b/pv3/cSelectLevelWindow.cpp @@ -0,0 +1,52 @@ +// cSelectLevelWindow.cpp : implementation file +// + +#include "stdafx.h" +#include "Princed V3.h" +#include "cSelectLevelWindow.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// cSelectLevelWindow dialog + + +cSelectLevelWindow::cSelectLevelWindow(CWnd* pParent /*=NULL*/) + : CDialog(cSelectLevelWindow::IDD, pParent) +{ + //{{AFX_DATA_INIT(cSelectLevelWindow) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + + +void cSelectLevelWindow::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(cSelectLevelWindow) + // NOTE: the ClassWizard will add DDX and DDV calls here + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(cSelectLevelWindow, CDialog) + //{{AFX_MSG_MAP(cSelectLevelWindow) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// cSelectLevelWindow message handlers + +BOOL cSelectLevelWindow::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // TODO: Add extra initialization here + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} diff --git a/pv3/cSelectLevelWindow.h b/pv3/cSelectLevelWindow.h new file mode 100644 index 0000000..67e77a9 --- /dev/null +++ b/pv3/cSelectLevelWindow.h @@ -0,0 +1,46 @@ +#if !defined(AFX_CSELECTLEVELWINDOW_H__AF32C261_6F5D_11D7_8A8E_00104B7CC0FF__INCLUDED_) +#define AFX_CSELECTLEVELWINDOW_H__AF32C261_6F5D_11D7_8A8E_00104B7CC0FF__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// cSelectLevelWindow.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// cSelectLevelWindow dialog + +class cSelectLevelWindow : public CDialog +{ +// Construction +public: + cSelectLevelWindow(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(cSelectLevelWindow) + enum { IDD = IDD_DIALOG_SELECT_LEVEL }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(cSelectLevelWindow) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(cSelectLevelWindow) + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CSELECTLEVELWINDOW_H__AF32C261_6F5D_11D7_8A8E_00104B7CC0FF__INCLUDED_) diff --git a/pv3/conf.cpp b/pv3/conf.cpp new file mode 100644 index 0000000..2d94449 --- /dev/null +++ b/pv3/conf.cpp @@ -0,0 +1,60 @@ +// conf.cpp : implementation of the cMaps class +// + +#include "stdafx.h" +#include "Princed V3.h" +#include "string.h" +#include "RegisterWIN32.h" + +#define CONF_PROGRAM_NAME "Princed V3"; +#define CONF_PROGRAM_COMPANY "Princed Development Team"; + + +class cConfig { +private: + CRegisterWIN32 registro; + +public: + cConfig() { + registro.Open(HKEY_LOCAL_MACHINE, _T("Software\\Princed Development Team\\Princed V3\\settings"), FALSE); + checkConf(); + } + + ~cConfig() { + registro.Close(); + } + + void setSetting(char *setting,char *value) { + registro.Write(setting, value); + } + + void getSetting(char *setting,char *value) { + registro.Read(setting, value); + } + + void setSetting(char *setting,int value) { + registro.Write(setting, value); + } + + void getSetting(char *setting,int &value) { + registro.Read(setting, value); + } + + void setSetting(char *setting,char value) { + registro.Write(setting, value?"Yes":"No"); + } + + void getSetting(char *setting,char &value) { + char *sValue; + registro.Read(setting, sValue); + value=(strcmp(sValue,"Yes")); + } + +private: + void checkConf() { + //!ToDo!: buscar toda la configuracion y si no est\xe1 seteada, poner el default + + + } +} +; diff --git a/pv3/maps.cpp b/pv3/maps.cpp new file mode 100644 index 0000000..3e87f21 --- /dev/null +++ b/pv3/maps.cpp @@ -0,0 +1,841 @@ +// maps.cpp : implementation of the cMaps class +// + +#include "stdafx.h" +#include "Princed V3.h" +#include "cSelectLevelWindow.h" + +#include <sys/types.h> +#include <sys/stat.h> +#include "maps.h" + +cMaps::cMaps(char* fileName) { + struct _stat buf; + if (_stat( "stat.c", &buf )) { + return; + } + if (buf.st_size==MAPS_BLOCK_SIZEOF_FILE) { + char levelNumber=1; + //!ToDo!: que levelnumber se lea de un msgbox + cSelectLevelWindow levelWindow; + levelWindow.DoModal(); + mLoadDAT(fileName,lev,levelNumber); + } else { + mLoadPED(fileName,lev); + } +} + +bool cMaps::exists() { + return (lev!=NULL); +} + + +cMaps::~cMaps() { + free(lev); +} + +/***************************************************************\ +| I M P L E M E N T A T I O N | +\***************************************************************/ + +/* + Se utilizan partes del archivo como validadores, texto aparte, + etc. Aparentemente es texto desperdiciado, no se detectaron + cambios en el comportamiento de los niveles. +*/ + +/***************************************************************\ +| Private memory stream handling | +\***************************************************************/ + +void cMaps::mSetArray(tLevel* lev, const char *pos,int from,unsigned int length,int validator) { + char validate=0; + while (length--) { + validate+=((*lev).levelArray[from]-pos[length]); + (*lev).levelArray[from++]=pos[length]; + } + (*lev).levelArray[validator]+=validate; +} + +void cMaps::mGetArray(tLevel* lev, char* pos,int from,int length) { + while (length--) pos[length]=(*lev).levelArray[from++]; +} + +/***************************************************************\ +| Gate handling | +\***************************************************************/ + +//Privados +void cMaps::getRawEvent(tLevel* lev,char id,tGateEvent* event) { //private + (*event).pos[0] =(*lev).levelArray[MAPS_BLOCK_OFFSET_GATE_1+id]; + (*event).pos[1] =(*lev).levelArray[MAPS_BLOCK_OFFSET_GATE_2+id]; +} + +void cMaps::setRawEvent(tLevel* lev,char id,tGateEvent* event) { //private + unsigned char x1,x2,validate; + x1=(*event).pos[0]; + x2=(*event).pos[1]; + validate =((*lev).levelArray[MAPS_BLOCK_OFFSET_GATE_1+id]-x1)+((*lev).levelArray[MAPS_BLOCK_OFFSET_GATE_2+id]-x2); + + (*lev).levelArray[MAPS_BLOCK_OFFSET_GATE_1+id]=x1; + (*lev).levelArray[MAPS_BLOCK_OFFSET_GATE_2+id]=x2; + (*lev).levelArray[MAPS_BLOCK_OFFSET_VALIDATOR_WALL]+=validate; +} + +//Privado, pero publico dentro de maps.c +void cMaps::mLoadEventList(tLevel* lev) { + //Esta funcion carga el TDA con los datos que lee del rigido + char a=0; + char b=0; + + //Cargar gateList con las asociaciones del mapa + int j=0; + for (int i=0;i<MAPS_BLOCK_SIZEOF_WALL;i++) { + switch ((*lev).levelArray[MAPS_BLOCK_OFFSET_WALL+i]) { + case MAPS_OBJ_BAL_D: + case MAPS_OBJ_BAL_U: + (*lev).gateList.item[j].door=i; + (*lev).gateList.item[j++].id=(*lev).levelArray[MAPS_BLOCK_OFFSET_BACK+i]; + } + } + (*lev).gateList.size=j; + + //Cargar gateTDA con datos de la tabla + j=0; + for (tGateEvent evento;j<MAPS_BLOCK_SIZEOF_GATE;j++) { + getRawEvent(lev,j,&evento); + if (evento.pos[0]>=(0x80)) { + (*lev).gateTDA.row[a].size=b; + b=0; + a++; + } else { + b++; + } + (*lev).gateTDA.row[a].event[b]=evento; + } + (*lev).gateTDA.size=a; +} + +//mSevEventList private functions + +void cMaps::anularEvento(tGateEvent *e) { + (*e).pos[0]=0; + (*e).pos[1]=0; +} + +char cMaps::obtenerFila(tGateRow *fila,unsigned char c,int k,tLevel* lev) { + char aux=((*lev).gateTDA.row[k].size==c); + if (aux) { + *fila=(*lev).gateTDA.row[k]; + } + return aux; +} + +char cMaps::sameEvent(tGateEvent event1,tGateEvent event2) { + return ((event1.pos[1]==event2.pos[1]) && ((event1.pos[0]%0x80)==(event1.pos[0]%0x80))); +} + +tGateEvent cMaps::setFlag(tGateEvent evento,char flag) { + evento.pos[0]=(evento.pos[0]%0x80)+(0x80*flag); + return evento; +} + +#define MAPS_GATE_DIFFERS 0 +#define MAPS_GATE_EQUALS 1 +#define MAPS_GATE_BELONGS 2 + +char cMaps::belongsToDiskList(tLevel* lev, tGateRow *fila,int i) { + + char total=0; + char pertenece; + //recorrer la lista de eventos + for (int k=i;((*lev).gateEvents.event[k].pos[0]<(0x80));k++) { + total++; + pertenece=0; + for (char j=0;(j<(*fila).size) && (!pertenece);j++) { + pertenece=(sameEvent((*fila).event[j],(*lev).gateEvents.event[k])); + } + if (!pertenece) { + return MAPS_GATE_DIFFERS; + } + } + if (total==(*fila).size) { + return MAPS_GATE_EQUALS; + } else { + return MAPS_GATE_BELONGS; + } +} + +void cMaps::apuntar(tLevel* lev,unsigned char i) { + (*lev).gateList.item[(*lev).gateList.size].id=i; + (*lev).gateList.size++; +} + +#define MAPS_GATE_SINGLE_EVENT 0 +#define MAPS_GATE_MULTIPLE_EVENT 1 +char cMaps::intertLeft(tLevel* lev,tGateRow fila,int inicioFila,int numeroFila,char mode) { + //Esta funcion inserta en gateEvents el o los eventos de fila que no estan insertados + //Por cada insersion deben ser modificados los ids correspondientes en la gateList + //devuelve 1 si entro + //devuelve 0 en caso de superarse lso 256 bytes + + /* + 1) En caso de MULTIPLE EVENT los elementos de la fila + que ya estan enliastados en gateEvents deben ser + eliminados de la fila. Se coloca el evento nulo en + reemplazo de estos. + */ + + char j,pertenece; + if (mode==MAPS_GATE_MULTIPLE_EVENT) { + for (int k=inicioFila;((*lev).gateEvents.event[k].pos[0]<(0x80));k++) { + pertenece=0; + for (j=0;(j<fila.size) && (!pertenece);j++) { + pertenece=(sameEvent(fila.event[j],(*lev).gateEvents.event[k])); + } + if (pertenece) { + anularEvento(&(fila.event[j])); + } + } + } + + /* + 2) En caso de MAPS_GATE_SINGLE_EVENT el ultimo debe + marcar fin de la lista. A tal fin, cambiaremos ese + flag del evento. Como la inserion se hara de adelante + hacia atras, simplemente debemos setear el flag al + principio + */ + + int c=(mode==MAPS_GATE_SINGLE_EVENT); + + /* + 3) Se debera iterar para toda la fila e insertar + evento por evento en la gateEvents en la posicion inicioFila. + Cada insersion implica un corrimiento de ids en la gateList + */ + + for (j=0;(j<fila.size);j++) { + if (fila.event[j].pos[0]) { //Para cada evento nonulo de la fila + //Adelantar todos los eventos posteriores a inicioFila + for (int k=(*lev).gateEvents.size;k>inicioFila;k--) { + (*lev).gateEvents.event[k+1]=(*lev).gateEvents.event[k]; + } + + //Insertar (*fila).event[j] en la gateEvents en la posicion generada en inicioFila. + //Se tendra en cuenta el flag de de fin de lista + (*lev).gateEvents.event[inicioFila]=setFlag(fila.event[j],c); + + //El flag del fin de lista se cancela + c=0; + + //Incrementar la cantidad de eventos de la gateEvent, en caso de no poder abortar + if ((*lev).gateEvents.size==255) { + return 0; + } else { + (*lev).gateEvents.size++; + } + + //Finalmente se debe recorrer la gate list e incrementar el contenido que supere a inicioFila + for (int k2=0;k2<(*lev).gateList.size;k2++) { + if ((*lev).gateList.item[k2].id>=inicioFila) + ((*lev).gateList.item[k2].id)++; + } + } + } + return 1; +} + +//Main function +char cMaps::mSaveEventList(tLevel* lev) { + //Lee el TDA, optimiza el espacio que ocupan los datos y lo guardaen disco + //devuelve 1 en caso de que entre en disco + //devuelve 0 en caso de que no hayan entrado los datos en disco + + //Inicializar variables + unsigned char n=(*lev).gateTDA.size; + unsigned char c=1; + char x; + tGateRow fila; + (*lev).gateEvents.size=0; + (*lev).gateList.size=0; + + //Generar a partir de gateTDA la lista de eventos gateEventList y de asociaciones gateList + while (n) { //Para todos los elementos + for (int k=0;k<(*lev).gateTDA.size;k++) { //Recorrer filas de gateTDA + if (obtenerFila(&fila,c,k,lev)) { //mietras haya elementos con tamagno=c sin procesar fila=(*lev).gateTDA.row[n] where fila=(*lev).gateTDA.row[n].size=c; + //entra con fila seteada en la fila k con c elementos adentro. + n--; + x=0; + for (int i=0;((i<(*lev).gateEvents.size) && (!x));i++) { //recorrer lo ya creado de gateEvents + x=belongsToDiskList(lev,&fila,i); + switch (x) { + case MAPS_GATE_BELONGS: + /* + Pertenece, pero puede que este no sea el principio de la lista + en ese caso no puedo insertar porque corromperia la puerta + anterior, por eso voy a verificar que sea el primero de la lista + o bien que el anterior tenga el flag c. + */ + if ((i=0) || ((*lev).gateEvents.event[i-1].pos[0]>0x80)) { + if (!intertLeft(lev,fila,i,k,MAPS_GATE_MULTIPLE_EVENT)) { + return 0; + } + apuntar(lev,i); + } + break; + case MAPS_GATE_EQUALS: + apuntar(lev,i); + } + } + if (!x) { + if (!intertLeft(lev,fila,(*lev).gateEvents.size,k,MAPS_GATE_SINGLE_EVENT)) { + return 0; + } + } + } + } + c++; + } + + //Guardar gateEvents y gateList en el formato. + //gateList + for (int i=0;i<(*lev).gateEvents.size;i++) { + setRawEvent(lev,i,&((*lev).gateEvents.event[i])); + } + int location; + unsigned char validate=0; + for (int i2=0;i2<(*lev).gateList.size;i2++) { + location=MAPS_BLOCK_OFFSET_BACK+(*lev).gateList.item[i2].door; + validate+=(*lev).levelArray[location]-(*lev).gateList.item[i2].id; + (*lev).levelArray[location]=(*lev).gateList.item[i2].id; + } + (*lev).levelArray[MAPS_BLOCK_OFFSET_VALIDATOR_WALL]+=validate; + + return 1; +} + +void cMaps::getGateAsociation(tLevel* lev,char id,char* scr,char* p,char* b, char *termino) { + unsigned char x1,x2,valor; + x1 =(*lev).levelArray[MAPS_BLOCK_OFFSET_GATE_1+id]; + x2 =(*lev).levelArray[MAPS_BLOCK_OFFSET_GATE_2+id]; + + *scr =(x2/8)+(x1%(0x80))/(0x20); + valor =(x1%(0x20)); + *b =(valor%10); + *p =(valor/10); + *termino =(x1/(0x80)); //c=(Se pasa a la siguiente)?0:1 +} + +void cMaps::setGateAsociation(tLevel* lev,char id,char scr,char p,char b, char termino) { + unsigned char x1,x2,validate; + + x1 =((scr%4)*0x20)+(p*10+b)+(termino?0x80:0); + x2 =((scr/4)*0x20); + validate =((*lev).levelArray[MAPS_BLOCK_OFFSET_GATE_1+id]-x1)+((*lev).levelArray[MAPS_BLOCK_OFFSET_GATE_2+id]-x2); + + (*lev).levelArray[MAPS_BLOCK_OFFSET_GATE_1+id]=x1; + (*lev).levelArray[MAPS_BLOCK_OFFSET_GATE_2+id]=x2; + (*lev).levelArray[MAPS_BLOCK_OFFSET_VALIDATOR_WALL]+=validate; +} + +void cMaps::shiftEventId(tLevel* lev,char from,char delta) { //private + char validate=0; + for (int i=0;i<MAPS_BLOCK_SIZEOF_WALL;i++) { + switch ((*lev).levelArray[MAPS_BLOCK_OFFSET_WALL+i]) { + case MAPS_OBJ_BAL_D: + case MAPS_OBJ_BAL_U: + if ((*lev).levelArray[MAPS_BLOCK_OFFSET_BACK+i]>from) { + (*lev).levelArray[MAPS_BLOCK_OFFSET_BACK+i]+=delta; + validate-=delta; + } + } + } + (*lev).levelArray[MAPS_BLOCK_OFFSET_VALIDATOR_WALL]+=validate; +} + +void cMaps::insertEvent(tLevel* lev,char id,char scr,char p,char b) { + char x1,x2,x3,x4; + + shiftEventId(lev,id,+1); + for (int i=20;i>id;i--) { + getGateAsociation(lev,i-1,&x1,&x2,&x3,&x4); + setGateAsociation(lev,i,x1,x2,x3,x4); + } + setGateAsociation(lev,id,scr,p,b,0); +} + +/***************************************************************\ +| Text handling | +\***************************************************************/ + +#define MAPS_BLOCK_OFFSET_START_POSITION_SIZE3 3 +//Actualmente guarda 1+MAPS_BLOCK_SIZEOF_UNKNOWN_1+MAPS_BLOCK_SIZEOF_UNKNOWN_2+MAPS_BLOCK_SIZEOF_UNKNOWN_4+unk_5+unk_6+unk_7 = 564 caracteres. *text debe medir 565 incluyendo el caracter nulo. +void cMaps::mSetText (tLevel* lev,const char* text) { + mSetArray(lev,text,MAPS_BLOCK_OFFSET_START_POSITION+MAPS_BLOCK_OFFSET_START_POSITION_SIZE3,1,MAPS_BLOCK_OFFSET_VALIDATOR_LINK); + mSetArray(lev,&(text[1]),MAPS_BLOCK_OFFSET_UNKNOWN_1,MAPS_BLOCK_SIZEOF_UNKNOWN_1,MAPS_BLOCK_OFFSET_VALIDATOR_WALL); + mSetArray(lev,&(text[MAPS_BLOCK_SIZEOF_UNKNOWN_1+1]),MAPS_BLOCK_OFFSET_UNKNOWN_2,MAPS_BLOCK_SIZEOF_UNKNOWN_2,MAPS_BLOCK_OFFSET_VALIDATOR_WALL); + mSetArray(lev,&(text[MAPS_BLOCK_SIZEOF_UNKNOWN_2+MAPS_BLOCK_SIZEOF_UNKNOWN_1+1]),MAPS_BLOCK_OFFSET_UNKNOWN_4,MAPS_BLOCK_SIZEOF_UNKNOWN_4,MAPS_BLOCK_OFFSET_VALIDATOR_LINK); + mSetArray(lev,&(text[MAPS_BLOCK_SIZEOF_UNKNOWN_4+MAPS_BLOCK_SIZEOF_UNKNOWN_2+MAPS_BLOCK_SIZEOF_UNKNOWN_1+1]),MAPS_BLOCK_OFFSET_UNKNOWN_5,MAPS_BLOCK_SIZEOF_UNKNOWN_5,MAPS_BLOCK_OFFSET_VALIDATOR_LINK); + mSetArray(lev,&(text[MAPS_BLOCK_SIZEOF_UNKNOWN_5+MAPS_BLOCK_SIZEOF_UNKNOWN_4+MAPS_BLOCK_SIZEOF_UNKNOWN_2+MAPS_BLOCK_SIZEOF_UNKNOWN_1+1]),MAPS_BLOCK_OFFSET_UNKNOWN_6,MAPS_BLOCK_SIZEOF_UNKNOWN_6,MAPS_BLOCK_OFFSET_VALIDATOR_LINK); + mSetArray(lev,&(text[MAPS_BLOCK_SIZEOF_UNKNOWN_6+MAPS_BLOCK_SIZEOF_UNKNOWN_5+MAPS_BLOCK_SIZEOF_UNKNOWN_4+MAPS_BLOCK_SIZEOF_UNKNOWN_2+MAPS_BLOCK_SIZEOF_UNKNOWN_1+1]),MAPS_BLOCK_OFFSET_UNKNOWN_7,MAPS_BLOCK_SIZEOF_UNKNOWN_7,MAPS_BLOCK_OFFSET_VALIDATOR_LINK); +} + +void cMaps::mGetText (tLevel* lev,char* text) { + mGetArray(lev,text,MAPS_BLOCK_OFFSET_START_POSITION+MAPS_BLOCK_OFFSET_START_POSITION_SIZE3,1); + mGetArray(lev,&(text[1]),MAPS_BLOCK_OFFSET_UNKNOWN_1,MAPS_BLOCK_SIZEOF_UNKNOWN_1); + mGetArray(lev,&(text[MAPS_BLOCK_SIZEOF_UNKNOWN_1+1]),MAPS_BLOCK_OFFSET_UNKNOWN_2,MAPS_BLOCK_SIZEOF_UNKNOWN_2); + mGetArray(lev,&(text[MAPS_BLOCK_SIZEOF_UNKNOWN_2+MAPS_BLOCK_SIZEOF_UNKNOWN_1+1]),MAPS_BLOCK_OFFSET_UNKNOWN_4,MAPS_BLOCK_SIZEOF_UNKNOWN_4); + mGetArray(lev,&(text[MAPS_BLOCK_SIZEOF_UNKNOWN_4+MAPS_BLOCK_SIZEOF_UNKNOWN_2+MAPS_BLOCK_SIZEOF_UNKNOWN_1+1]),MAPS_BLOCK_OFFSET_UNKNOWN_5,MAPS_BLOCK_SIZEOF_UNKNOWN_5); + mGetArray(lev,&(text[MAPS_BLOCK_SIZEOF_UNKNOWN_5+MAPS_BLOCK_SIZEOF_UNKNOWN_4+MAPS_BLOCK_SIZEOF_UNKNOWN_2+MAPS_BLOCK_SIZEOF_UNKNOWN_1+1]),MAPS_BLOCK_OFFSET_UNKNOWN_6,MAPS_BLOCK_SIZEOF_UNKNOWN_6); + mGetArray(lev,&(text[MAPS_BLOCK_SIZEOF_UNKNOWN_6+MAPS_BLOCK_SIZEOF_UNKNOWN_5+MAPS_BLOCK_SIZEOF_UNKNOWN_4+MAPS_BLOCK_SIZEOF_UNKNOWN_2+MAPS_BLOCK_SIZEOF_UNKNOWN_1+1]),MAPS_BLOCK_OFFSET_UNKNOWN_7,MAPS_BLOCK_SIZEOF_UNKNOWN_7); + text[MAPS_BLOCK_SIZEOF_UNKNOWN_7+MAPS_BLOCK_SIZEOF_UNKNOWN_6+MAPS_BLOCK_SIZEOF_UNKNOWN_5+MAPS_BLOCK_SIZEOF_UNKNOWN_4+MAPS_BLOCK_SIZEOF_UNKNOWN_2+MAPS_BLOCK_SIZEOF_UNKNOWN_1+1]=0; +} + +/***************************************************************\ +| Start Position handling | +\***************************************************************/ + +void cMaps::mGetDebugPosition(tLevel* lev,char* pantalla, char* p, char *b,char *sentido) { + char dp[2]; + unsigned char valor; + mGetArray(lev,dp,MAPS_BLOCK_OFFSET_START_POSITION+4,2); + *pantalla =(dp[0]); + *sentido =(dp[1]%2); + valor =(dp[1]/2); + *b =(valor%10); + *p =(valor/10); +} + +void cMaps::mSetDebugPosition(tLevel* lev,char pantalla, char p, char b,char sentido) { + char dp[2]; + dp[0] =pantalla; + dp[1] =pantalla?(((p*10+b)*2)+(sentido?1:0)):0; + mSetArray(lev,dp,MAPS_BLOCK_OFFSET_START_POSITION+4,2,MAPS_BLOCK_OFFSET_VALIDATOR_LINK); +} + +void cMaps::mGetStartPosition(tLevel* lev,char* pantalla, char* p, char *b,char *sentido,char *sentido2) { + *pantalla =(*lev).levelArray[MAPS_BLOCK_OFFSET_START_POSITION]; + char valor=(*lev).levelArray[MAPS_BLOCK_OFFSET_START_POSITION+1]; + *b =(valor%10); + *p =(valor/10); + *sentido =((*lev).levelArray[MAPS_BLOCK_OFFSET_START_POSITION+2])?1:0; + *sentido2 =((*lev).levelArray[MAPS_BLOCK_OFFSET_START_POSITION+6])?1:0; +} + +void cMaps::mSetStartPosition(tLevel* lev,char pantalla, char p, char b,char sentido,char sentido2) { + unsigned char valor=pantalla; + int location=MAPS_BLOCK_OFFSET_START_POSITION; + unsigned char offsetval=0; + + //pantalla + offsetval+=(256-valor)+(*lev).levelArray[location]; + (*lev).levelArray[location++]=valor; + + //Posicion + valor =p*10+b; + offsetval+=(256-valor)+(*lev).levelArray[location]; + (*lev).levelArray[location++]=valor; + + //sentidos + valor =sentido?MAPS_DIRECTION_RIGHT:MAPS_DIRECTION_LEFT; + offsetval+=(256-valor)+(*lev).levelArray[location]; + (*lev).levelArray[location]=valor; + + location +=4; + valor =sentido2?MAPS_DIRECTION_RIGHT:MAPS_DIRECTION_LEFT; + offsetval+=(256-valor)+(*lev).levelArray[location]; + (*lev).levelArray[location]=valor; + + //Validacion + (*lev).levelArray[MAPS_BLOCK_OFFSET_VALIDATOR_LINK]+=offsetval; +} + +/***************************************************************\ +| S E T S & G E T S | +\***************************************************************/ + + +void cMaps::mSetWall (tLevel* lev,char pantalla,char p,char b,char valor) { + int location=MAPS_BLOCK_OFFSET_WALL+30*(pantalla-1)+10*p+b; + + (*lev).levelArray[MAPS_BLOCK_OFFSET_VALIDATOR_WALL]+=(*lev).levelArray[location]-valor; + (*lev).levelArray[location]=valor; +} + +char cMaps::mGetWall (tLevel* lev,char pantalla,char p,char b) const { + return (*lev).levelArray[MAPS_BLOCK_OFFSET_WALL+30*(pantalla-1)+10*p+b]; +} + +void cMaps::mSetBack (tLevel* lev,char pantalla,char p,char b,char valor) { + int location=MAPS_BLOCK_OFFSET_BACK+30*(pantalla-1)+10*p+b; + + (*lev).levelArray[MAPS_BLOCK_OFFSET_VALIDATOR_WALL]+=(*lev).levelArray[location]-valor; + (*lev).levelArray[location]=valor; +} + +char cMaps::mGetBack (tLevel* lev,char pantalla,char p,char b) const { + return (*lev).levelArray[MAPS_BLOCK_OFFSET_BACK+30*(pantalla-1)+10*p+b]; +} + +void cMaps::mSetLink (tLevel* lev,char pantalla,char tipo,char valor) { + if ((pantalla<25) && (pantalla) && (valor<25)) { + int location=(MAPS_BLOCK_OFFSET_LINK+((pantalla-1)*4)+tipo); + (*lev).levelArray[MAPS_BLOCK_OFFSET_VALIDATOR_LINK]+=(*lev).levelArray[location]-valor; + (*lev).levelArray[location]=valor; + } +} + +char cMaps::mGetLink (tLevel* lev,char pantalla,char tipo) { + return (*lev).levelArray[MAPS_BLOCK_OFFSET_LINK+((pantalla-1)*4)+tipo]; +} + +/***************************************************************\ +| Abstract Guard Handling | +\***************************************************************/ + +void cMaps::mSetGuard(tLevel* lev,char pantalla,char p,char b,char vidas,char color,char sentido,char erase) { + + //Posicion + unsigned char valor=erase?30:p*10+b; + int location=MAPS_BLOCK_OFFSET_GUARD_POSITION-1+pantalla; + unsigned char offsetval=((*lev).levelArray[MAPS_BLOCK_OFFSET_VALIDATOR_LINK]+(256-valor)+(*lev).levelArray[location]); + (*lev).levelArray[location]=valor; + //sentido + valor =sentido?MAPS_DIRECTION_RIGHT:MAPS_DIRECTION_LEFT; + location =MAPS_BLOCK_OFFSET_GUARD_DIRECTION-1+pantalla; + offsetval+=(256-valor)+(*lev).levelArray[location]; + (*lev).levelArray[location]=valor; + //skill + valor =erase?1:vidas; + location =MAPS_BLOCK_OFFSET_GUARD_SKILL-1+pantalla; + offsetval+=(256-valor)+(*lev).levelArray[location]; + (*lev).levelArray[location]=valor; + //Color + valor =erase?0:color; + location =MAPS_BLOCK_OFFSET_GUARD_COLOR-1+pantalla; + offsetval+=(256-valor)+(*lev).levelArray[location]; + (*lev).levelArray[location]=valor; + + //Validar + (*lev).levelArray[MAPS_BLOCK_OFFSET_VALIDATOR_LINK]=offsetval/*+(256-valor)+(*lev).levelArray[location]*/; +} + +void cMaps::mGetGuard(tLevel* lev,char pantalla,char* p,char* b,char* vidas,char* color,char* sentido,char* exists) const { + //Posicion + unsigned char valor=((*lev).levelArray[(MAPS_BLOCK_OFFSET_GUARD_POSITION-1+pantalla)]); + *exists = (valor<30); + *b = (valor%10); + *p = (valor/10); + //sentido + *sentido=!(*lev).levelArray[MAPS_BLOCK_OFFSET_GUARD_DIRECTION-1+pantalla]; + //skill + *vidas =(*lev).levelArray[MAPS_BLOCK_OFFSET_GUARD_SKILL-1+pantalla]; + //Color + *color =(*lev).levelArray[MAPS_BLOCK_OFFSET_GUARD_COLOR-1+pantalla]; +} + +/***************************************************************\ +| Screen Link Handling | +\***************************************************************/ + +//Recursive mapping sub procedures +void cMaps::mRecIndirect(char i, char j, tLevel* lev, char scr, char pos) { + char aux; + char auxb; + if ((*lev).handledLinks.linkMap[i][j]==255) { + aux=mGetLink (lev,scr,pos); + if (!(auxb=(!aux))) auxb=(!(*lev).handledLinks.linkList[aux]); + if (auxb) { + (*lev).handledLinks.linkMap[i][j]=aux; + if (aux) { + (*lev).handledLinks.linkList[aux]=1; + mRecLink(i,j,lev); + } + } else { + (*lev).handledLinks.linkMap[i][j]=0; + } + } +} + +void cMaps::mRecLink(char i, char j, tLevel* lev) { + char scr=(*lev).handledLinks.linkMap[i][j]; + + mRecIndirect(i,j-1,lev,scr,MAPS_sLeft); + mRecIndirect(i,j+1,lev,scr,MAPS_sRight); + mRecIndirect(i-1,j,lev,scr,MAPS_sUp); + mRecIndirect(i+1,j,lev,scr,MAPS_sDown); +} + +void cMaps::mCalcularLimUp (tLevel* lev) { + char i=0; + char j=0; + while (((*lev).handledLinks.linkMap[i][j]==255) && (j<MAPS_MAX_LENGTH)) { + if (++i==MAPS_MAX_LENGTH) { + j++; + i=0; + } + } + (*lev).handledLinks.limUp=j; +} + +void cMaps::mCalcularLimLeft (tLevel* lev) { + char i=0; + char j=0; + while (((*lev).handledLinks.linkMap[j][i]==255) && (j<MAPS_MAX_LENGTH)) { + if (++i==MAPS_MAX_LENGTH) { + j++; + i=0; + } + } + (*lev).handledLinks.limLeft=j; +} + +void cMaps::mCalcularLimDown (tLevel* lev) { + char i=0; + char j=MAPS_MAX_LENGTH-1; + while (((*lev).handledLinks.linkMap[i][j]==255) && j) { + if (++i==MAPS_MAX_LENGTH) { + j--; + i=0; + } + } + (*lev).handledLinks.limDown=j; +} + +void cMaps::mCalcularLimRight (tLevel* lev) { + char i=0; + char j=MAPS_MAX_LENGTH-1; + while (((*lev).handledLinks.linkMap[j][i]==255) && j) { + if (++i==MAPS_MAX_LENGTH) { + j--; + i=0; + } + } + (*lev).handledLinks.limRight=j; +} + + +// Main mCreateLinkMap +void cMaps::mCreateLinkMap(tLevel* lev) { //private + char i,j,start; + + //Initialize arrays + for (j=0;j<MAPS_MAX_LENGTH;j++) + for (i=0;i<MAPS_MAX_LENGTH;(*lev).handledLinks.linkMap[i++][j]=255); + for (j=1;j<=MAPS_MAX_SCREENS;(*lev).handledLinks.linkList[j++]=0); + + //Inicializar start en la pantalla de inicio + mGetStartPosition(lev,&start,&i,&i,&i,&i); + (*lev).handledLinks.linkMap[MAPS_LINKMAP_CENTER][MAPS_LINKMAP_CENTER]=start; + (*lev).handledLinks.linkList[start]=1; + + //Start Recursive Mapper + mRecLink(MAPS_LINKMAP_CENTER,MAPS_LINKMAP_CENTER,lev); + + //Buscar limites del nivel + mCalcularLimUp (lev); + mCalcularLimDown (lev); + mCalcularLimLeft (lev); + mCalcularLimRight(lev); + +} + +void cMaps::mGetSize (tLevel* lev, char* i,char* j) const { + *i=(*lev).handledLinks.limRight - (*lev).handledLinks.limLeft; + *j=(*lev).handledLinks.limDown - (*lev).handledLinks.limUp; +} + +char cMaps::mGetScrCount (tLevel* lev) { + char l,aux; + + aux=0; + for (l=1;l<=MAPS_MAX_SCREENS;aux+=((*lev).handledLinks.linkList[l++]?1:0)); + return aux; +} + +char cMaps::mGetScreen (tLevel* lev, char i,char j, char* error) const { + char aux; + + aux=(*lev).handledLinks.linkMap[(*lev).handledLinks.limLeft+i][(*lev).handledLinks.limUp+j]; + *error=(aux==255); + return aux; +} + +void cMaps::mGetMainScreen(tLevel* lev, char* i,char* j) const { + *i=(MAPS_LINKMAP_CENTER) - (*lev).handledLinks.limLeft; + *j=(MAPS_LINKMAP_CENTER) - (*lev).handledLinks.limUp; +} + +void cMaps::mAddScreen (tLevel* lev, char i,char j, char* error) { + char scr=mGetScreen(lev,i,j,error); + *error=(*error || scr); + if (!*error) { + int l=1; + while ((*lev).handledLinks.linkList[l] && (l++<MAPS_MAX_SCREENS)); + if ((*lev).handledLinks.linkList[l]) { + *error=1; + } else { + //Pedir pantalla + (*lev).handledLinks.linkList[l]=1; + + i+=(*lev).handledLinks.limLeft; + j+=(*lev).handledLinks.limUp; + + //En caso de agregar una pantalla en alguno de los bordes, estos se amplian + if ((*lev).handledLinks.limLeft=i) (*lev).handledLinks.limLeft--; + if ((*lev).handledLinks.limUp=j) (*lev).handledLinks.limUp--; + if ((*lev).handledLinks.limRight=i) (*lev).handledLinks.limRight++; + if ((*lev).handledLinks.limDown=j) (*lev).handledLinks.limDown++; + + + //Poner 0 alrededor de l + (*lev).handledLinks.linkMap[i][j-1]%=255; + (*lev).handledLinks.linkMap[i][j+1]%=255; + (*lev).handledLinks.linkMap[i+1][j]%=255; + (*lev).handledLinks.linkMap[i-1][j]%=255; + + //Poner l en l + (*lev).handledLinks.linkMap[i][j]=l; + + //Setear links desde l a las 4 pantallas adyacentes + mSetLink (lev,l,MAPS_sUp,(*lev).handledLinks.linkMap[i][j-1]); + mSetLink (lev,l,MAPS_sDown,(*lev).handledLinks.linkMap[i][j+1]); + mSetLink (lev,l,MAPS_sRight,(*lev).handledLinks.linkMap[i+1][j]); + mSetLink (lev,l,MAPS_sLeft,(*lev).handledLinks.linkMap[i-1][j]); + + //Setear links desde las 4 pantallas adyacentes a l + mSetLink (lev,(*lev).handledLinks.linkMap[i][j+1],MAPS_sUp,l); + mSetLink (lev,(*lev).handledLinks.linkMap[i][j-1],MAPS_sDown,l); + mSetLink (lev,(*lev).handledLinks.linkMap[i-1][j],MAPS_sRight,l); + mSetLink (lev,(*lev).handledLinks.linkMap[i+1][j],MAPS_sLeft,l); + + //Limpiar contenido de la pantalla l + for (i=0;i<3;i++) { + for (j=0;j<10;j++) { + mSetWall(lev,l,i,j,0); + mSetBack(lev,l,i,j,0); + } + } + mSetGuard(lev,l,1,1,1,1,1,1); + //Listo, ya cree la pantalla y la linkie + } + } +} + +void cMaps::mRemScreen (tLevel* lev, char i,char j, char* error) { + /*{Q&D: + 1) Si parten a la mitad un nivel se pierde una de las mitades + 2) no se refresca la LinkMap en ese caso + 3) tampoco une las pantallas que estaban a los costados}*/ + unsigned char l=mGetScreen(lev,i,j,error); + *error=*error || (!l); + if (!*error) { + //Liberar pantalla + (*lev).handledLinks.linkList[l]=0; + + //Seteo posiciones absolutas + i+=(*lev).handledLinks.limLeft; + j+=(*lev).handledLinks.limUp; + + //Poner 0 en l + (*lev).handledLinks.linkMap[i][j]=0; + + //En caso de remover una pantalla en alguno de los bordes, estos se recalculan + if ((*lev).handledLinks.limLeft=i) mCalcularLimLeft(lev); + if ((*lev).handledLinks.limUp=j) mCalcularLimUp(lev); + if ((*lev).handledLinks.limRight=i) mCalcularLimRight(lev); + if ((*lev).handledLinks.limDown=j) mCalcularLimDown(lev); + + //Borrar links desds las 4 pantallas adyacentes a l + mSetLink (lev,(*lev).handledLinks.linkMap[i][j+1],MAPS_sLeft,0); + mSetLink (lev,(*lev).handledLinks.linkMap[i][j-1],MAPS_sRight,0); + mSetLink (lev,(*lev).handledLinks.linkMap[i-1][j],MAPS_sDown,0); + mSetLink (lev,(*lev).handledLinks.linkMap[i+1][j],MAPS_sUp,0); + } +} + +void cMaps::mCpyScreen (tLevel* lev, char fromi,char fromj,char toi,char toj, char* error) { + char fromscr,toscr,i,j,k,l; + char sentido,existe; + + //Verificar que la pantalla source y la pantalla target existan + fromscr=mGetScreen(lev,fromi,fromj,error); //Verifico que existe la pantalla from + *error=(*error || fromscr); + if (!*error) { //Verifico que existe la pantalla to + toscr=mGetScreen(lev,toi,toj,error); + *error=(*error || toscr); + } + if (!*error) { //Si existen ambas pantallas + //Copiar contenido de la pantalla from a la pantalla to: + + //Copiar wall y back + char contenido[30]; + mGetArray(lev,contenido,MAPS_BLOCK_OFFSET_WALL-30+fromscr*30,30); + mSetArray(lev,contenido,MAPS_BLOCK_OFFSET_WALL-30+toscr*30,30,MAPS_BLOCK_OFFSET_VALIDATOR_WALL); + mGetArray(lev,contenido,MAPS_BLOCK_OFFSET_BACK-30+fromscr*30,30); + mSetArray(lev,contenido,MAPS_BLOCK_OFFSET_BACK-30+toscr*30,30,MAPS_BLOCK_OFFSET_VALIDATOR_WALL); + + //Copiar Guards + mGetGuard(lev,fromscr,&i,&j,&k,&l,&sentido,&existe); + mSetGuard(lev,toscr,i,j,k,l,sentido,existe); + //Listo, ya se copio el contenido y el guardia + } +} + +/***************************************************************\ +| File handling | +\***************************************************************/ + +char cMaps::mLoadPED(const char* vFile,tLevel* lev) { + FILE *fp; + char aux; + + if ((fp=fopen(vFile,"rb"))==NULL) { + return 0; + } else { + aux=fread (lev,sizeof(*lev),1,fp); + fclose(fp); + return aux; + } +} + +char cMaps::mLoadDAT(const char* vFile,tLevel* lev,char levelNumber) { + FILE *fp; + char aux; + + if ((fp=fopen(vFile,"rb"))==NULL) { + return 0; + } else { + (*lev).level=levelNumber; + fpos_t position=levelNumber*MAPS_BLOCK_SIZEOF_LEVEL+MAPS_BLOCK_OFFSET_LEVELS; + fsetpos (fp, &position); + aux=fread (&(*lev).levelArray,MAPS_BLOCK_SIZEOF_LEVEL,1,fp); + mCreateLinkMap(lev); + fclose(fp); + return aux; + } +} + +char cMaps::mSavePED(const char* vFile,tLevel* lev) { + FILE * pFile; + if ((pFile = fopen (vFile , "wb"))==NULL) { + return 0; + } + fwrite (lev, 1, sizeof(*lev), pFile); + fclose (pFile); + return 1; +} + +char cMaps::mSaveDAT(const char* vFile,tLevel* lev) { + FILE * pFile; + if ((pFile = fopen (vFile , "r+b"))==NULL) { + return 0; + } + fpos_t position=(*lev).level*MAPS_BLOCK_SIZEOF_LEVEL+MAPS_BLOCK_OFFSET_LEVELS; + fsetpos (pFile, &position); + fwrite ((*lev).levelArray, 1, MAPS_BLOCK_SIZEOF_LEVEL, pFile); + fclose (pFile); + return 1; +} +; \ No newline at end of file diff --git a/pv3/maps.h b/pv3/maps.h new file mode 100644 index 0000000..10a7f6e --- /dev/null +++ b/pv3/maps.h @@ -0,0 +1,216 @@ +/***************************************************************\ +| Format Block Specification | +\************************************************************** / + +Len Offs BlockName & Description +1 0 validador (0-1953) +720 1 wall +720 721 back +18 1441 doors1 +238 1459 unknown1 (22/215?) (por convencion: empty para guardar info) +18 1697 doors2 +238 1715 unknown2 (22/215?) (por convencion: empty para guardar info) +96 1953 links +64 2049 unknown3 (peligroso) +3 2113 startPosition (1: screen; 2: module; 3: direction) +3 2116 unknownSP (Dafault: triple 0) (por convencion: 1: comienzo de string info; 2 y 3: Debug Position) +1 2117 startPositionUnknown (direction?) +24 2120 guardPosition +24 2144 guardDirection (00: right; FF: left) +1 2168 unknown4/1 (por convencion: validator 1953-2306) +23 2169 unknown4/23 (por convencion: empty para guardar info) +24 2192 unknown5 (por convencion: empty para guardar info) +24 2216 guardSkill +24 2240 unknown6 (por convencion: empty para guardar info) +24 2264 guardColor +16 2288 unknown7 (por convencion: empty para guardar info) +2 2304 0F 09 + 2306 New Level + +/ **************************************************************\ +| Inclusiones | +\***************************************************************/ + +#ifndef INCLUDED_MAPS_H +#define INCLUDED_MAPS_H + +#include <stdio.h> + +/***************************************************************\ +| Definiciones del Precompilador | +\***************************************************************/ + +#define MAPS_MAX_SCREENS 24 +#define MAPS_MAX_LENGTH 49 +//MAPS_MAX_SCREENS*2+1 +#define MAPS_LINKMAP_CENTER 24 +//(char)(MAPS_MAX_SCREENS*2+1)/2 + +#define MAPS_DIRECTION_RIGHT 0x00 +#define MAPS_DIRECTION_LEFT 0xFF + +#define MAPS_BLOCK_SIZEOF_LEVEL 2306 +#define MAPS_BLOCK_OFFSET_LEVELS 6 + +#define MAPS_BLOCK_OFFSET_VALIDATOR_WALL 0 +#define MAPS_BLOCK_SIZEOF_VALIDATOR_WALL 1 +#define MAPS_BLOCK_OFFSET_WALL 1 +#define MAPS_BLOCK_SIZEOF_WALL 720 +#define MAPS_BLOCK_SIZEOF_BACK 720 +#define MAPS_BLOCK_OFFSET_BACK 721 +#define MAPS_BLOCK_OFFSET_LINK 1953 +#define MAPS_BLOCK_OFFSET_VALIDATOR_LINK 2168 +#define MAPS_BLOCK_OFFSET_GUARD_DIRECTION 2144 +#define MAPS_BLOCK_OFFSET_GUARD_POSITION 2120 +#define MAPS_BLOCK_OFFSET_START_POSITION 2113 +#define MAPS_BLOCK_OFFSET_GUARD_SKILL 2216 +#define MAPS_BLOCK_OFFSET_GUARD_COLOR 2264 +#define MAPS_BLOCK_OFFSET_UNKNOWN_1 1459 +#define MAPS_BLOCK_SIZEOF_UNKNOWN_1 238 +#define MAPS_BLOCK_OFFSET_UNKNOWN_2 1715 +#define MAPS_BLOCK_SIZEOF_UNKNOWN_2 238 +#define MAPS_BLOCK_OFFSET_UNKNOWN_4 2169 +#define MAPS_BLOCK_SIZEOF_UNKNOWN_4 23 +#define MAPS_BLOCK_SIZEOF_UNKNOWN_5 24 +#define MAPS_BLOCK_OFFSET_UNKNOWN_5 2192 +#define MAPS_BLOCK_SIZEOF_UNKNOWN_6 24 +#define MAPS_BLOCK_OFFSET_UNKNOWN_6 2240 +#define MAPS_BLOCK_SIZEOF_UNKNOWN_7 16 +#define MAPS_BLOCK_OFFSET_UNKNOWN_7 2288 +#define MAPS_BLOCK_SIZEOF_GATE_1 18 +#define MAPS_BLOCK_SIZEOF_GATE 18 +//256 +#define MAPS_BLOCK_OFFSET_GATE_1 1441 +#define MAPS_BLOCK_SIZEOF_GATE_2 18 +#define MAPS_BLOCK_OFFSET_GATE_2 1697 +#define MAPS_BLOCK_SIZEOF_FILE 37031 + +#define MAPS_OBJ_BAL_D 0x26 +#define MAPS_OBJ_BAL_U 0x2f + +//Constantes copadas +#define MAPS_sUp 2 +#define MAPS_sDown 3 +#define MAPS_sLeft 0 +#define MAPS_sRight 1 + + +#include "structures.h" + +/* +char pantalla --> the screen number +char p --> floor (0 to 2) +char b --> square (0 to 9) + +idem setWall but it sets the background property +char valor --> value (it has to be a MAP_BCK_* define) +vidas is something like lives but it depends on the level you are +sentido is where is the guard looking at +erase has to be 0, if you use a non 0 value you set no guard on this screen +*/ + +class cMaps { +public: + cMaps(char* fileName); + bool exists(); + ~cMaps(); + tLevel* lev; + +private: + + +/***************************************************************\ +| Prototipos | +\***************************************************************/ + +public: //prototipos publicos + + //File management procedures + char mLoadPED(const char* vFile,tLevel* lev); + char mLoadDAT(const char* vFile,tLevel* lev,char levelNumber); //Tested 5 + char mSavePED(const char* vFile,tLevel* lev); //Tested 8 + char mSaveDAT(const char* vFile,tLevel* lev); //Tested 3 + + //char mChangeLevel(tLevel* lev,char newLevel); //0 si no hay cambios; si hay cambios en paredes devuelve la camtidad de paredes cambiadas + //char mAllowedOn(char levelnumber,char wall); //1 si wall es permitido en levelnumber; 0 si no + + //Information methods + void mSetText (tLevel* lev,const char* text); + void mGetText (tLevel* lev,char* text); + + //tLevel Set methods + void mSetWall (tLevel* lev,char pantalla,char p,char b,char valor); + void mSetLink (tLevel* lev,char pantalla,char tipo,char valor); + void mSetGuard(tLevel* lev,char pantalla,char p,char b,char vidas,char color,char sentido,char erase); + void mSetBack (tLevel* lev,char pantalla,char p,char b,char valor); + //tLevel Get Methods + char mGetWall (tLevel* lev,char pantalla,char p,char b) const; + char mGetLink (tLevel* lev,char pantalla,char tipo); + void mGetGuard(tLevel* lev,char pantalla,char* p,char* b,char* vidas,char* color,char* sentido,char* erase) const; + char mGetBack (tLevel* lev,char pantalla,char p,char b) const; + + //Gate handling Methods + /* + Public: + mCreateEventList + mAddToEventList + mGetEventList + mRemFromEventList + mRemoveEventList + + Private: + + mSaveEventList + mLoadEventList + */ + + + //Screen Links Handling Methods + char mGetScreen (tLevel* lev, char i,char j, char* error) const; + void mGetMainScreen(tLevel* lev, char* i,char* j) const; + void mRemScreen (tLevel* lev, char i,char j, char* error); + void mAddScreen (tLevel* lev, char i,char j, char* error); + void mGetSize (tLevel* lev, char* i,char* j) const; + char mGetScrCount (tLevel* lev); + //Nota: si mGetScrCount(lev) es 24, entonces el nivel esta lleno + void mCpyScreen (tLevel* lev, char fromi,char fromj,char toi,char toj, char* error); + + //Start position handling + void mGetStartPosition(tLevel* lev,char* pantalla, char* p, char *b,char *sentido,char *sentido2); + void mSetStartPosition(tLevel* lev,char pantalla, char p, char b,char sentido,char sentido2); + void mGetDebugPosition(tLevel* lev,char* pantalla, char* p, char *b,char *sentido); + void mSetDebugPosition(tLevel* lev,char pantalla, char p, char b,char sentido); + //Nota: DebugPosition puede no existir en lev, en ese caso la convension es no existe si pantalla igual a 0, de lo contrario existe y la pantalla inicial es pantalla + +private: //Prototipos privados + void mSetArray(tLevel* lev, const char *pos,int from,unsigned int length,int validator); + void mGetArray(tLevel* lev, char* pos,int from,int length); + void getRawEvent(tLevel* lev,char id,tGateEvent* event); + void setRawEvent(tLevel* lev,char id,tGateEvent* event); + void mLoadEventList(tLevel* lev); + void anularEvento(tGateEvent *e); + char obtenerFila(tGateRow *fila,unsigned char c,int k,tLevel* lev); + char sameEvent(tGateEvent event1,tGateEvent event2); + tGateEvent setFlag(tGateEvent evento,char flag); + char belongsToDiskList(tLevel* lev, tGateRow *fila,int i); + void apuntar(tLevel* lev,unsigned char i); + char intertLeft(tLevel* lev,tGateRow fila,int inicioFila,int numeroFila,char mode); + char mSaveEventList(tLevel* lev); + void mRecLink(char i, char j, tLevel* lev); //recursive prototype + void mRecIndirect(char i, char j, tLevel* lev, char scr, char pos); + void mCalcularLimUp (tLevel* lev); + void mCalcularLimDown (tLevel* lev); + void mCalcularLimLeft (tLevel* lev); + void mCalcularLimRight (tLevel* lev); + void mCreateLinkMap(tLevel* lev); + void cMaps::getGateAsociation(tLevel* lev,char id,char* scr,char* p,char* b, char *termino); + void cMaps::setGateAsociation(tLevel* lev,char id,char scr,char p,char b, char termino); + void cMaps::shiftEventId(tLevel* lev,char from,char delta); + void cMaps::insertEvent(tLevel* lev,char id,char scr,char p,char b); + + + +} +; + +#endif diff --git a/pv3/process.cpp b/pv3/process.cpp new file mode 100644 index 0000000..01d3915 --- /dev/null +++ b/pv3/process.cpp @@ -0,0 +1,23 @@ +// process.cpp : implementation of the cProcess class +// + +#include "stdafx.h" +#include "Princed V3.h" +#include <process.h> +#include <signal.h> + +class cProcess { +private: + int handle; +public: + + cProcess(char *cmdname) { + handle=_spawnl(_P_NOWAIT, cmdname, "megahit","3", NULL); + + } + +//int raise( int sig ); + + +} +; \ No newline at end of file diff --git a/pv3/res/32x32.ped.ico b/pv3/res/32x32.ped.ico new file mode 100644 index 0000000..5680552 Binary files /dev/null and b/pv3/res/32x32.ped.ico differ diff --git a/pv3/res/Princed V3.rc2 b/pv3/res/Princed V3.rc2 new file mode 100644 index 0000000..104fc86 --- /dev/null +++ b/pv3/res/Princed V3.rc2 @@ -0,0 +1,13 @@ +// +// PRINCED V3.RC2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED + #error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/pv3/res/Toolbar.bmp b/pv3/res/Toolbar.bmp new file mode 100644 index 0000000..4900f03 Binary files /dev/null and b/pv3/res/Toolbar.bmp differ diff --git a/pv3/res/about.bmp b/pv3/res/about.bmp new file mode 100644 index 0000000..74c6d10 Binary files /dev/null and b/pv3/res/about.bmp differ diff --git a/pv3/res/about.jpg b/pv3/res/about.jpg new file mode 100644 index 0000000..2038850 Binary files /dev/null and b/pv3/res/about.jpg differ diff --git a/pv3/res/about_pi.bmp b/pv3/res/about_pi.bmp new file mode 100644 index 0000000..f96060b Binary files /dev/null and b/pv3/res/about_pi.bmp differ diff --git a/pv3/res/backmask.bmp b/pv3/res/backmask.bmp new file mode 100644 index 0000000..51182a6 Binary files /dev/null and b/pv3/res/backmask.bmp differ diff --git a/pv3/res/backs.bmp b/pv3/res/backs.bmp new file mode 100644 index 0000000..f96a4bb Binary files /dev/null and b/pv3/res/backs.bmp differ diff --git a/pv3/res/dropper.cur b/pv3/res/dropper.cur new file mode 100644 index 0000000..4ae0b0b Binary files /dev/null and b/pv3/res/dropper.cur differ diff --git a/pv3/res/elemmask.bmp b/pv3/res/elemmask.bmp new file mode 100644 index 0000000..64d8d79 Binary files /dev/null and b/pv3/res/elemmask.bmp differ diff --git a/pv3/res/elemp.bmp b/pv3/res/elemp.bmp new file mode 100644 index 0000000..1d84e57 Binary files /dev/null and b/pv3/res/elemp.bmp differ diff --git a/pv3/res/elempmask.bmp b/pv3/res/elempmask.bmp new file mode 100644 index 0000000..d35149a Binary files /dev/null and b/pv3/res/elempmask.bmp differ diff --git a/pv3/res/elems.bmp b/pv3/res/elems.bmp new file mode 100644 index 0000000..0426959 Binary files /dev/null and b/pv3/res/elems.bmp differ diff --git a/pv3/res/guard.bmp b/pv3/res/guard.bmp new file mode 100644 index 0000000..1fdd060 Binary files /dev/null and b/pv3/res/guard.bmp differ diff --git a/pv3/res/guardmask.bmp b/pv3/res/guardmask.bmp new file mode 100644 index 0000000..55e7119 Binary files /dev/null and b/pv3/res/guardmask.bmp differ diff --git a/pv3/res/hand.cur b/pv3/res/hand.cur new file mode 100644 index 0000000..38ec954 Binary files /dev/null and b/pv3/res/hand.cur differ diff --git a/pv3/res/icons & cursors.zip b/pv3/res/icons & cursors.zip new file mode 100644 index 0000000..0f2860a Binary files /dev/null and b/pv3/res/icons & cursors.zip differ diff --git a/pv3/res/manifest.txt b/pv3/res/manifest.txt new file mode 100644 index 0000000..70bcf93 --- /dev/null +++ b/pv3/res/manifest.txt @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> +<assemblyIdentity + name="Prince.editor" + processorArchitecture="x86" + version="1.0.0.0" + type="win32"/> +<description>Princed V3</description> +<dependency> + <dependentAssembly> + <assemblyIdentity + type="win32" + name="Microsoft.Windows.Common-Controls" + version="6.0.0.0" + processorArchitecture="x86" + publicKeyToken="6595b64144ccf1df" + language="*" + /> + </dependentAssembly> +</dependency> +</assembly> \ No newline at end of file diff --git a/pv3/res/newer BMPs.zip b/pv3/res/newer BMPs.zip new file mode 100644 index 0000000..cba4d97 Binary files /dev/null and b/pv3/res/newer BMPs.zip differ diff --git a/pv3/res/palette.bmp b/pv3/res/palette.bmp new file mode 100644 index 0000000..7b3489e Binary files /dev/null and b/pv3/res/palette.bmp differ diff --git a/pv3/res/princed.ico b/pv3/res/princed.ico new file mode 100644 index 0000000..10bfe8f Binary files /dev/null and b/pv3/res/princed.ico differ diff --git a/pv3/res/pspbrwse.jbf b/pv3/res/pspbrwse.jbf new file mode 100644 index 0000000..17185af Binary files /dev/null and b/pv3/res/pspbrwse.jbf differ diff --git a/pv3/res/zoomer.cur b/pv3/res/zoomer.cur new file mode 100644 index 0000000..c36918c Binary files /dev/null and b/pv3/res/zoomer.cur differ diff --git a/pv3/resource.h b/pv3/resource.h new file mode 100644 index 0000000..e61a635 --- /dev/null +++ b/pv3/resource.h @@ -0,0 +1,126 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by Princed V3.rc +// +#define IDD_ABOUTBOX 100 +#define IDP_SOCKETS_INIT_FAILED 104 +#define IDR_MAINFRAME 128 +#define IDR_PRINCETYPE 129 +#define IDD_DIALOG_SELECT_LEVEL 132 +#define IDB_ELEMMASK 136 +#define IDB_ELEMS 137 +#define IDB_GUARD 139 +#define IDB_GUARDMASK 140 +#define IDB_BACKMASK 141 +#define IDB_BACKS 142 +#define IDB_ELEMPMASK 143 +#define IDB_ELEMP 144 +#define IDD_EDIT_SAV 145 +#define IDC_HANDPALM 146 +#define IDC_ZOOMTOOL 147 +#define IDR_TOOLPAL 148 +#define IDC_DROPPER 150 +#define IDB_ABOUT_PIC 158 +#define IDC_COMBO1 1000 +#define IDC_EDIT1 1001 +#define IDC_BROWSE 1002 +#define IDC_OPEN 1003 +#define IDC_SAVE 1004 +#define IDC_LEVEL 1005 +#define IDC_SPIN1 1006 +#define IDC_EDIT2 1007 +#define IDC_BUTTON1 1009 +#define IDC_EDIT3 1010 +#define ID_FILE_SAVEALL 32771 +#define ID_FILE_COMPILEDAT 32772 +#define ID_FILE_UNCOMPILEDAT 32773 +#define ID_FILE_PUBLISHDAT 32774 +#define ID_FILE_EXPORTTOIMAGE 32775 +#define ID_FILE_EXPORTTOTEXT 32776 +#define ID_FILE_EXPORTTOHTML 32777 +#define ID_FILE_SEARCHFILES 32778 +#define ID_FILE_PREFERENCES 32779 +#define ID_EDIT_CLEARSELECTION 32780 +#define ID_VIEW_MAPTOOLS 32781 +#define ID_VIEW_TOOLOPTIONSWINDOW 32782 +#define ID_VIEW_LEVELPROPERTRIES 32783 +#define ID_VIEW_OPENLEVELS 32784 +#define ID_VIEW_READERSCREENMENU 32785 +#define ID_VIEW_TOGGLEGRID 32786 +#define ID_VIEW_TOGGLERULERS 32787 +#define ID_VIEW_IN 32788 +#define ID_VIEW_ZOOM_OUT 32789 +#define ID_VIEW_ZOOM_FITSCREENTOWINDOW 32790 +#define ID_VIEW_ZOOM_200 32791 +#define ID_VIEW_ZOOM_100 32792 +#define ID_VIEW_ZOOM_50 32793 +#define ID_VIEW_ZOOM_25 32794 +#define ID_VIEW_ZOOM_FITLEVELTOWINDOW 32795 +#define ID_ADDONS_EDITHALLOFFAME 32796 +#define ID_ADDONS_EDITSAVEDGAME 32797 +#define ID_ADDONS_EDITGRAPHICS 32798 +#define ID_ADDONS_EDITPRINCEEXE 32799 +#define ID_DEBUG_RUNLEVELFROMDEGUBPOSITION 32800 +#define ID_DEBUG_RUNLEVELFROMSTARTPOSITION 32801 +#define ID_DEBUG_REFRESHRUNNINGLEVE 32802 +#define ID_DEBUG_RUNDATFILE 32803 +#define ID_DEBUG_STOPRUNNING 32804 +#define ID_DEBUG_EXECUTEPRINCEOFPERSIA 32805 +#define ID_WINDOW_TILEHORIZONTALLY 32806 +#define ID_WINDOW_FITTOLEVEL 32807 +#define ID_WINDOW_CLOSEALL 32808 +#define ID_HELP_HELPTOPICS 32809 +#define ID_HELP_LICENSE 32810 +#define ID_HELP_FREQUENTLYASKEDQUESTIONS 32811 +#define ID_HELP_PRINCEDHOMEPAGE 32812 +#define ID_FILE_NEWX 32813 +#define ID_TOOL_SELECTION 32814 +#define ID_MAPTOOLS_CLEAR 32850 +#define ID_MAPTOOLS_OBJECTS_POSSION 32851 +#define ID_MAPTOOLS_OBJECTS_STARTPOSITION 32852 +#define ID_MAPTOOLS_OBJECTS_DEBUGPOSITION 32853 +#define ID_MAPTOOLS_OBJECTS_GUARDS 32854 +#define ID_MAPTOOLS_BACKGROUND_LIGHT 32855 +#define ID_MAPTOOLS_BACKGROUND_BRICKS 32856 +#define ID_MAPTOOLS_BACKGROUND_WINDOW 32857 +#define ID_MAPTOOLS_BACKGROUND_BIGWINDOW 32858 +#define ID_MAPTOOLS_BACKGROUND_COLUMN 32859 +#define ID_MAPTOOLS_BACKGROUND_BIGCOLUMN 32860 +#define ID_MAPTOOLS_BACKGROUND_RANDOM 32861 +#define ID_MAPTOOLS_WALL 32862 +#define ID_MAPTOOLS_WALKABLE_NORMAL 32863 +#define ID_MAPTOOLS_WALKABLE_BALDOZAROTA 32864 +#define ID_MAPTOOLS_WALKABLE_BALDOZAAPRETABLE 32865 +#define ID_MAPTOOLS_WALKABLE_BALDOZACONESQUELETO 32866 +#define ID_MAPTOOLS_WALKABLE_PINCHES 32867 +#define ID_MAPTOOLS_WALKABLE_BALDOZAFLOJA 32868 +#define ID_MAPTOOLS_WALKABLE_RANDOM 32869 +#define ID_MAPTOOLS_GATES_DOOR 32870 +#define ID_MAPTOOLS_GATES_PUERTASIERRA 32871 +#define ID_MAPTOOLS_GATES_LEVELGATE 32872 +#define ID_MAPTOOLS_DROPPER 32873 +#define ID_MAPTOOLS_SELECT 32874 +#define ID_MAPTOOLS_ZOOM 32875 +#define ID_MAPTOOLS_ARRASTRAR 32876 +#define ID_MAPTOOLS_WALKABLE_DOORCLOSER 32877 +#define ID_MAPTOOLS_SWORD 32878 +#define ID_VIEW_ASDUNGEON 32901 +#define ID_VIEW_ASPALACE 32902 +#define ID_BUTTON32903 32903 +#define ID_BUTTON32904 32904 +#define ID_VIEW_ZOOM_IN 32905 +#define IDS_PRINCED_HOMEPAGE 61446 +#define IDS_WALL_NAMES 61447 +#define IDS_ABOUT_TEXT 61448 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_3D_CONTROLS 1 +#define _APS_NEXT_RESOURCE_VALUE 159 +#define _APS_NEXT_COMMAND_VALUE 32907 +#define _APS_NEXT_CONTROL_VALUE 1011 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/pv3/stackqueue.cpp.cpp b/pv3/stackqueue.cpp.cpp new file mode 100644 index 0000000..5ce7914 --- /dev/null +++ b/pv3/stackqueue.cpp.cpp @@ -0,0 +1,76 @@ +#include <iostream.h> + +//ds \xbc\xf7\xc1\xa6 4: 20010078 \xb1\xe8\xbf빬 +//3\xb9\xf8 \xbc\xf7\xc1\xa6\xbf\xcd \xc0\xce\xc5\xcd\xc6\xe4\xc0̽\xba\xb4\xc2 \xbf\xcf\xc0\xfc\xc8\xf7 \xb0\xb0\xb5\xc7, \xb1\xb8\xc7\xf6 \xb9\xe6\xbdĸ\xb8 \xb8\xb5ũ\xb5\xe5 \xb8\xae\xbd\xbaƮ\xc0Դϴ\xd9. + +template<typename T> +class CStack { +protected: + struct NODE { + T data; NODE *extra; + }; + NODE *m_pHead; int m_nElem; +public: + //Construction/destruction + CStack(): m_pHead(NULL), m_nElem(0) {} + int GetCount() const { return m_nElem; } //number of elements + virtual ~CStack(); + virtual void Add(const T& elem); + virtual bool Delete(T& elem); //returns the pointer to the element being deleted +}; + +template<typename T> +class CQueue: public CStack<T> { +protected: + NODE *m_pTail; +public: + virtual void Add(const T& elem); +}; + +template<typename T> +void CStack<T>::Add(const T& elem) +{ + if(m_pHead==NULL) { m_pHead=new NODE; m_pHead->extra=NULL; } + else { NODE *tmp=m_pHead; m_pHead=new NODE; m_pHead->extra=tmp; } + m_pHead->data=elem; +} + +template<typename T> +void CQueue<T>::Add(const T& elem) +{ + if(m_pHead) { m_pTail->extra=new NODE; m_pTail=m_pTail->extra; } + else { m_pTail=m_pHead=new NODE; } + m_pTail->extra=NULL; m_pTail->data=elem; +} + +template<typename T> +bool CStack<T>::Delete(T& elem) +{ + if(m_pHead) { //If there's anything to draw out + NODE *tmp=m_pHead; elem=m_pHead->data; m_pHead=m_pHead->extra; delete tmp; + return true; + } + else return false; //nothing +} + +template<typename T> +CStack<T>::~CStack() +{ + NODE *tmp, *tmp2; //\xb3\xeb\xb5带 \xbc\xf8ȸ\xc7ϸ鼭 \xbf\xf8\xbcҵ\xe9\xc0\xbb \xb8\xf0\xb5\xce \xc1\xf6\xbf\xf2 + for(tmp=m_pHead;tmp; tmp=tmp2) { tmp2=tmp->extra; delete tmp; } +} + +int main() +{ + CStack<int> ap; CQueue<int> aq; int x; + cout<<"\xbd\xba\xc5ÿ\xa1\xb4\xd9 1 \xb3־\xfa\xb4\xd9 \xc1\xf6\xbf\xec\xb0\xed, 2 3 4 5\xb8\xa6 \xb3־\xfa\xb4ٰ\xa1 \xc2\xf7\xb7ʴ\xeb\xb7\xce \xbb\xa9\xb3\xbb\xb1\xe2\n"; + ap.Add(1); ap.Delete(x); ap.Add(2); ap.Add(3); ap.Add(4); ap.Add(5); + ap.Delete(x); cout<<x<<" "; ap.Delete(x); cout<<x<<" "; + ap.Delete(x); cout<<x<<" "; ap.Delete(x); cout<<x<<endl<<endl; + + cout<<"ť\xbf\xa1\xb4\xd9 1 \xb3־\xfa\xb4\xd9 \xc1\xf6\xbf\xec\xb0\xed, 2 3 4 5\xb8\xa6 \xb3־\xfa\xb4ٰ\xa1 \xc2\xf7\xb7ʴ\xeb\xb7\xce \xbb\xa9\xb3\xbb\xb1\xe2\n"; + aq.Add(1); aq.Delete(x); aq.Add(2); aq.Add(3); aq.Add(4); aq.Add(5); + aq.Delete(x); cout<<x<<" "; aq.Delete(x); cout<<x<<" "; + aq.Delete(x); cout<<x<<" "; aq.Delete(x); cout<<x<<endl; + return 0; +} diff --git a/pv3/structures.h b/pv3/structures.h new file mode 100644 index 0000000..43cd986 --- /dev/null +++ b/pv3/structures.h @@ -0,0 +1,52 @@ +/***************************************************************\ +| Estructuras de Datos | +\***************************************************************/ + +//Link Handler +typedef struct { + unsigned char linkMap[MAPS_MAX_LENGTH][MAPS_MAX_LENGTH]; + unsigned char linkList[MAPS_MAX_SCREENS]; + char limLeft,limRight,limUp,limDown; +}tLevelHandleLinks; + +//Gate Handler +typedef struct { + unsigned char pos[2]; +}tGateEvent; + +typedef struct { + tGateEvent event[256]; + unsigned char size; +}tGateEvents; + +typedef struct { + unsigned char size; + tGateEvent event[50]; +}tGateRow; + +typedef struct { + unsigned char size; + tGateRow row[50]; +}tGateTDA; + +typedef struct { + unsigned char id; + unsigned char door; +}tGateListItem; + +typedef struct { + int size; + tGateListItem item[720]; +}tGateList; + +//Main level structure +typedef struct { + char level; + tLevelHandleLinks handledLinks; + unsigned char levelArray[MAPS_BLOCK_SIZEOF_LEVEL]; + char desc[200]; + char name[50]; + tGateTDA gateTDA; + tGateList gateList; + tGateEvents gateEvents; +}tLevel;