| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | // LightingStatus.cpp : implementation file |
| 20 | // |
| 21 | |
| 22 | #include "mfc_compatibility.h" |
| 23 | #include "editor.h" |
| 24 | #include "LightingStatus.h" |
| 25 | #include "radiosity.h" |
| 26 | |
| 27 | #ifdef _DEBUG |
| 28 | #define new DEBUG_NEW |
| 29 | #undef THIS_FILE |
| 30 | static char THIS_FILE[] = __FILE__; |
| 31 | #endif |
| 32 | |
| 33 | ///////////////////////////////////////////////////////////////////////////// |
| 34 | // CLightingStatus dialog |
| 35 | |
| 36 | CLightingStatus::CLightingStatus(CWnd *pParent /*=NULL*/) : CDialog(CLightingStatus::IDD, pParent) { |
| 37 | //{{AFX_DATA_INIT(CLightingStatus) |
| 38 | // NOTE: the ClassWizard will add member initialization here |
| 39 | //}}AFX_DATA_INIT |
| 40 | } |
| 41 | |
| 42 | void CLightingStatus::DoDataExchange(CDataExchange *pDX) { |
| 43 | CDialog::DoDataExchange(pDX); |
| 44 | //{{AFX_DATA_MAP(CLightingStatus) |
| 45 | // NOTE: the ClassWizard will add DDX and DDV calls here |
| 46 | //}}AFX_DATA_MAP |
| 47 | } |
| 48 | |
| 49 | BEGIN_MESSAGE_MAP(CLightingStatus, CDialog) |
| 50 | //{{AFX_MSG_MAP(CLightingStatus) |
| 51 | ON_BN_CLICKED(IDC_STOP_LIGHTING, OnStopLighting) |
| 52 | ON_WM_TIMER() |
| 53 | //}}AFX_MSG_MAP |
| 54 | END_MESSAGE_MAP() |
| 55 | |
| 56 | ///////////////////////////////////////////////////////////////////////////// |
| 57 | // CLightingStatus message handlers |
| 58 | |
| 59 | void CLightingStatus::OnStopLighting() { |
| 60 | int answer = MessageBox("Are you sure you wish to stop lighting?", "Light Question", MB_YESNO); |
| 61 | if (answer == IDNO) |
| 62 | return; |
| 63 | |
| 64 | OutrageMessageBox("Lighting will stop at the next iteration, this might take a minute..."); |
| 65 | |
| 66 | rad_DoneCalculating = 1; |
| 67 | } |
| 68 | |
| 69 | BOOL CLightingStatus::OnInitDialog() { |
| 70 | CDialog::OnInitDialog(); |
| 71 | CWnd::SetTimer(1, 500, NULL); // twice per second |
| 72 | |
| 73 | return TRUE; // return TRUE unless you set the focus to a control |
| 74 | // EXCEPTION: OCX Property Pages should return FALSE |
| 75 | } |
| 76 | |
| 77 | void CLightingStatus::OnTimer(UINT nIDEvent) { |
| 78 | char str[100]; |
| 79 | |
| 80 | sprintf(str, "Percentage complete: %.2f %%", (1.0 - rad_Convergence) * 100.0); |
| 81 | CEdit *ebox; |
| 82 | ebox = (CEdit *)GetDlgItem(IDC_LIGHTING_COMPLETE); |
| 83 | ebox->SetWindowText(str); |
| 84 | |
| 85 | CDialog::OnTimer(nIDEvent); |
| 86 | } |
| 87 | |
| 88 | BOOL CLightingStatus::DestroyWindow() { |
| 89 | // TODO: Add your specialized code here and/or call the base class |
| 90 | |
| 91 | CWnd::KillTimer(1); |
| 92 | return CDialog::DestroyWindow(); |
| 93 | } |