| 1 | /***
 | 
|---|
| 2 |  This file belongs to the Gotcha! distribution.
 | 
|---|
| 3 |  Copyright (C) 1998-2002 Thorsten Thielen <thth@c2226.de>
 | 
|---|
| 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 2 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, write to the Free Software
 | 
|---|
| 17 |  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
|---|
| 18 |  ***/
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #ifndef _Settings_H_
 | 
|---|
| 21 | #define _Settings_H_
 | 
|---|
| 22 | 
 | 
|---|
| 23 | // ** defines & stuff ***************************************************** /*FOLD00*/
 | 
|---|
| 24 | 
 | 
|---|
| 25 | #include "gotcha.h"
 | 
|---|
| 26 | #include "mmio.h"
 | 
|---|
| 27 | #include "./settings/thth_settings.h"
 | 
|---|
| 28 | 
 | 
|---|
| 29 | #define PSZ_PROFILENAME           "gotcha.ini"
 | 
|---|
| 30 | 
 | 
|---|
| 31 | // this should be increased every time the format of the proFile changes
 | 
|---|
| 32 | #define L_PROFILEVERSION          2
 | 
|---|
| 33 | 
 | 
|---|
| 34 | #define COUNT_PAGES               4
 | 
|---|
| 35 | 
 | 
|---|
| 36 | enum { SAVESTYLE_CLIPBOARD, SAVESTYLE_FILE, };
 | 
|---|
| 37 | #if 0
 | 
|---|
| 38 | enum {
 | 
|---|
| 39 |     BMF_12, BMF_16, BMF_20, BMF_OS13, BMF_OS20, BMF_TIF, BMF_TIFU,
 | 
|---|
| 40 |     BMF_TGA, BMF_PCX, BMF_GIF, BMF_JPG, BMF_DIB,
 | 
|---|
| 41 |     BMF_INVALID
 | 
|---|
| 42 | };
 | 
|---|
| 43 | #else
 | 
|---|
| 44 | enum {
 | 
|---|
| 45 |     BMF_JPG, BMF_PNG, BMF_OS20, BMF_TIF, BMF_TGA, BMF_PCX, BMF_GIF,
 | 
|---|
| 46 |     BMF_PBM, BMF_JP2, BMF_JBG, BMF_RAW, BMF_DIB,
 | 
|---|
| 47 |     BMF_INVALID
 | 
|---|
| 48 | };
 | 
|---|
| 49 | #endif
 | 
|---|
| 50 | enum { FSS_PROMPT, FSS_NUMFILES, FSS_FORCEFILE, };
 | 
|---|
| 51 | 
 | 
|---|
| 52 | class ImageFormatInfo
 | 
|---|
| 53 | {
 | 
|---|
| 54 | public:
 | 
|---|
| 55 |     BOOL     available;
 | 
|---|
| 56 |     USHORT   type;
 | 
|---|
| 57 |     FOURCC   fourcc;
 | 
|---|
| 58 |     PSZ      label;
 | 
|---|
| 59 |     PSZ      extension;
 | 
|---|
| 60 |     PSZ      eaType;
 | 
|---|
| 61 | };
 | 
|---|
| 62 | 
 | 
|---|
| 63 | // ** classdef ************************************************************ /*FOLD00*/
 | 
|---|
| 64 | 
 | 
|---|
| 65 | class Settings : public ththSettings
 | 
|---|
| 66 | {
 | 
|---|
| 67 | public:
 | 
|---|
| 68 |     Settings (VOID);
 | 
|---|
| 69 | 
 | 
|---|
| 70 |     BOOL   Dialog (BOOL f = FALSE);
 | 
|---|
| 71 | 
 | 
|---|
| 72 |     PSZ    QuerySaveFile (VOID) { return QueryString (SEI_SAVEFILE); }
 | 
|---|
| 73 |     VOID   SetSaveFile (PSZ psz) { SetString (SEI_SAVEFILE, psz); }
 | 
|---|
| 74 | 
 | 
|---|
| 75 |     VOID   SetWindowData (SWP *pswp, BOOL f = TRUE);
 | 
|---|
| 76 |     VOID   QueryWindowData (SWP *pswp, USHORT us[7], BOOL f = TRUE);
 | 
|---|
| 77 | 
 | 
|---|
| 78 |     BOOL   HideWindow (VOID) { return QueryFlag (SEI_HIDEWINDOW); }
 | 
|---|
| 79 |     VOID   HideWindow (BOOL f) { SetFlag (SEI_HIDEWINDOW, f); }
 | 
|---|
| 80 | 
 | 
|---|
| 81 |     BOOL   DelayedCapture (VOID) { return QueryFlag (SEI_DELAYEDCAPTURE); }
 | 
|---|
| 82 |     VOID   DelayedCapture (BOOL f) { SetFlag (SEI_DELAYEDCAPTURE, f); }
 | 
|---|
| 83 | 
 | 
|---|
| 84 |     BYTE   QuerySaveStyle (VOID) { return QueryLong (SEI_SAVESTYLE); }
 | 
|---|
| 85 |     VOID   SetSaveStyle (BYTE b) { SetLong (SEI_SAVESTYLE, b); }
 | 
|---|
| 86 | 
 | 
|---|
| 87 |     BOOL   AutoaddExtension (VOID) { return QueryFlag (SEI_AUTOADDEXTENSION); }
 | 
|---|
| 88 |     VOID   AutoaddExtension (BOOL f) { SetFlag (SEI_AUTOADDEXTENSION, f); }
 | 
|---|
| 89 | 
 | 
|---|
| 90 |     BOOL   ConfirmOverwrite (VOID) { return QueryFlag (SEI_CONFIRMOVERWRITE); }
 | 
|---|
| 91 |     VOID   ConfirmOverwrite (BOOL f) { SetFlag (SEI_CONFIRMOVERWRITE, f); }
 | 
|---|
| 92 | 
 | 
|---|
| 93 |     PSZ    QueryForceSaveFile (VOID) { return QueryString (SEI_FORCESAVEFILE); }
 | 
|---|
| 94 |     VOID   SetForceSaveFile (PSZ psz) { SetString (SEI_FORCESAVEFILE, psz); }
 | 
|---|
| 95 | 
 | 
|---|
| 96 |     BOOL   DelayCountdown (VOID) { return QueryFlag (SEI_DELAYCOUNTDOWN); }
 | 
|---|
| 97 |     VOID   DelayCountdown (BOOL f) { SetFlag (SEI_DELAYCOUNTDOWN, f); }
 | 
|---|
| 98 | 
 | 
|---|
| 99 |     USHORT QueryDelayTime (VOID) { return QueryLong (SEI_DELAYTIME); }
 | 
|---|
| 100 |     VOID   SetDelayTime (USHORT us) { SetLong (SEI_DELAYTIME, us); }
 | 
|---|
| 101 | 
 | 
|---|
| 102 |     BOOL   SnapshotWindow (VOID) { return QueryFlag (SEI_SNAPSHOTWINDOW); }
 | 
|---|
| 103 |     VOID   SnapshotWindow (BOOL f) { SetFlag (SEI_SNAPSHOTWINDOW, f); }
 | 
|---|
| 104 | 
 | 
|---|
| 105 |     BOOL   SSWHide (VOID) { return QueryFlag (SEI_SSWHIDE); }
 | 
|---|
| 106 |     VOID   SSWHide (BOOL f) { SetFlag (SEI_SSWHIDE, f); }
 | 
|---|
| 107 | 
 | 
|---|
| 108 |     BOOL   SSWAlwaysOnTop (VOID) { return QueryFlag (SEI_SSWALWAYSONTOP); }
 | 
|---|
| 109 |     VOID   SSWAlwaysOnTop (BOOL f) { SetFlag  (SEI_SSWALWAYSONTOP, f); }
 | 
|---|
| 110 | 
 | 
|---|
| 111 |     BYTE   QuerySSWCaptureType (VOID) { return QueryLong (SEI_SSWCAPTURETYPE); }
 | 
|---|
| 112 |     VOID   SetSSWCaptureType (BYTE b) { SetLong (SEI_SSWCAPTURETYPE, b); }
 | 
|---|
| 113 | 
 | 
|---|
| 114 |     BOOL   SerialCapture (VOID) { return QueryFlag (SEI_SERIALCAPTURE); }
 | 
|---|
| 115 |     VOID   SerialCapture (BOOL f) { SetFlag (SEI_SERIALCAPTURE, f); }
 | 
|---|
| 116 | 
 | 
|---|
| 117 |     USHORT QuerySerialTime (VOID) { return QueryLong (SEI_SERIALTIME); }
 | 
|---|
| 118 |     VOID   SetSerialTime (USHORT us) { SetLong (SEI_SERIALTIME, us); }
 | 
|---|
| 119 | 
 | 
|---|
| 120 |     BOOL   DoSound (VOID) { return QueryFlag (SEI_DOSOUND); }
 | 
|---|
| 121 |     VOID   DoSound (BOOL f) { SetFlag (SEI_DOSOUND, f); }
 | 
|---|
| 122 | 
 | 
|---|
| 123 |     BYTE   QueryFileFormat (VOID) { return QueryLong (SEI_FILEFORMAT); }
 | 
|---|
| 124 |     VOID   SetFileFormat (BYTE b) { SetLong (SEI_FILEFORMAT, b); }
 | 
|---|
| 125 | 
 | 
|---|
| 126 |     BYTE   QueryFileSaveStyle (VOID) { return QueryLong (SEI_FILESAVESTYLE); }
 | 
|---|
| 127 |     VOID   SetFileSaveStyle (BYTE b) { SetLong (SEI_FILESAVESTYLE, b); }
 | 
|---|
| 128 | 
 | 
|---|
| 129 |     PSZ    QueryNumSaveDir (VOID);
 | 
|---|
| 130 |     VOID   SetNumSaveDir (PSZ psz)
 | 
|---|
| 131 |     {
 | 
|---|
| 132 |         if ((psz[strlen (psz)-1] == '\\') || (psz[strlen (psz)-1] == '/'))
 | 
|---|
| 133 |             psz[strlen (psz)-1] = '\0';
 | 
|---|
| 134 |         SetString (SEI_NUMSAVEDIR, psz);
 | 
|---|
| 135 |     }
 | 
|---|
| 136 | 
 | 
|---|
| 137 |     VOID   SelectLanguage (VOID);
 | 
|---|
| 138 | 
 | 
|---|
| 139 |     PSZ    GetFileExtension( SHORT type = BMF_INVALID );
 | 
|---|
| 140 |     FOURCC GetFOURCC( SHORT type = BMF_INVALID );
 | 
|---|
| 141 |     PSZ    GetFileEAType( SHORT type = BMF_INVALID );
 | 
|---|
| 142 | 
 | 
|---|
| 143 |     BOOL           IsMMIOAvailable( VOID );
 | 
|---|
| 144 |     class thth_MMIO      *GetMMIO( VOID );
 | 
|---|
| 145 | 
 | 
|---|
| 146 | protected:
 | 
|---|
| 147 |     USHORT   FileNotOpenError (VOID);
 | 
|---|
| 148 |     USHORT   VersionError (VOID);
 | 
|---|
| 149 | 
 | 
|---|
| 150 |     BOOL     ReloadResources (PSZ psz);
 | 
|---|
| 151 | 
 | 
|---|
| 152 |     USHORT   GetLanguages (HWND hwnd);
 | 
|---|
| 153 | 
 | 
|---|
| 154 | private:
 | 
|---|
| 155 |     static MRESULT EXPENTRY
 | 
|---|
| 156 |         DialogProcedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
 | 
|---|
| 157 |     static MRESULT EXPENTRY
 | 
|---|
| 158 |         Page1Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
 | 
|---|
| 159 |     static MRESULT EXPENTRY
 | 
|---|
| 160 |         Page2Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
 | 
|---|
| 161 |     static MRESULT EXPENTRY
 | 
|---|
| 162 |         Page3Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
 | 
|---|
| 163 |     static MRESULT EXPENTRY
 | 
|---|
| 164 |         Page4Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
 | 
|---|
| 165 | 
 | 
|---|
| 166 |     VOID AdjustButton (HWND hwnd, USHORT id, BOOL f)
 | 
|---|
| 167 |     {
 | 
|---|
| 168 |         WinSendDlgItemMsg (hwnd, id, BM_SETCHECK,
 | 
|---|
| 169 |                            MPFROMLONG (f), MPFROMLONG (0));
 | 
|---|
| 170 |     }
 | 
|---|
| 171 | 
 | 
|---|
| 172 |     VOID AdjustFlag (HWND hwnd, USHORT id, BOOL &f)
 | 
|---|
| 173 |     {
 | 
|---|
| 174 |         f = BOOL (WinSendDlgItemMsg (hwnd, id, BM_QUERYCHECK, 0, 0));
 | 
|---|
| 175 |     }
 | 
|---|
| 176 | 
 | 
|---|
| 177 |     HWND         hwndPage[COUNT_PAGES];
 | 
|---|
| 178 |     static PSZ   pszPageTab[COUNT_PAGES];
 | 
|---|
| 179 |     BOOL   fAutoLanguage;
 | 
|---|
| 180 | 
 | 
|---|
| 181 |     thth_MMIO    *mmio;
 | 
|---|
| 182 | 
 | 
|---|
| 183 |     HWND   hwndDlg;
 | 
|---|
| 184 | 
 | 
|---|
| 185 |     static ImageFormatInfo ifi[];
 | 
|---|
| 186 | };
 | 
|---|
| 187 | 
 | 
|---|
| 188 | // ** inline funcs ******************************************************** /*FOLD00*/
 | 
|---|
| 189 | 
 | 
|---|
| 190 | inline VOID Settings :: SetWindowData (SWP *pswp, BOOL f)
 | 
|---|
| 191 | {
 | 
|---|
| 192 |     // FIXME puke, yukk, choke! get this flag thing away! do it better!
 | 
|---|
| 193 |     // FIXME what is with US?
 | 
|---|
| 194 |     if (f)
 | 
|---|
| 195 |         SetBinary(SEI_SWPSSW, PVOID(pswp), sizeof(SWP));
 | 
|---|
| 196 |     else
 | 
|---|
| 197 |         SetBinary(SEI_SWP, PVOID(pswp), sizeof(SWP));
 | 
|---|
| 198 | }
 | 
|---|
| 199 | 
 | 
|---|
| 200 | inline BOOL Settings :: IsMMIOAvailable( VOID )
 | 
|---|
| 201 | {
 | 
|---|
| 202 |     if( mmio ) return TRUE;
 | 
|---|
| 203 |     return FALSE;
 | 
|---|
| 204 | }
 | 
|---|
| 205 | 
 | 
|---|
| 206 | thth_MMIO *Settings :: GetMMIO( VOID ) { return mmio; }
 | 
|---|
| 207 | 
 | 
|---|
| 208 | // ************************************************************************
 | 
|---|
| 209 | #endif
 | 
|---|