Subversion Repositories AndroidProjects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
244 chris 1
#ifndef __SEXYAPPBASE_H__
2
#define __SEXYAPPBASE_H__
3
 
4
#include "Common.h"
5
#include "Rect.h"
6
#include "Color.h"
7
#include "ButtonListener.h"
8
#include "DialogListener.h"
9
#include "Buffer.h"
10
#include "CritSect.h"
11
#include "SharedImage.h"
12
#include "Ratio.h"
13
 
14
namespace ImageLib
15
{
16
        class Image;
17
};
18
 
19
namespace Sexy
20
{
21
 
22
class WidgetManager;
23
class DDInterface;
24
class Image;
25
class DDImage;
26
class Widget;
27
class SoundManager;
28
class MusicInterface;
29
class MemoryImage;
30
class HTTPTransfer;
31
class Dialog;
32
 
33
class ResourceManager;
34
 
35
class WidgetSafeDeleteInfo
36
{
37
public:
38
        int                                             mUpdateAppDepth;
39
        Widget*                                 mWidget;
40
};
41
 
42
 
43
typedef std::list<WidgetSafeDeleteInfo> WidgetSafeDeleteList;
44
typedef std::set<MemoryImage*> MemoryImageSet;
45
typedef std::map<int, Dialog*> DialogMap;
46
typedef std::list<Dialog*> DialogList;
47
typedef std::list<MSG> WindowsMessageList;
48
typedef std::vector<std::string> StringVector;
49
//typedef std::basic_string<TCHAR> tstring; // string of TCHARs
50
 
51
typedef std::map<std::string, SexyString> StringSexyStringMap;
52
typedef std::map<std::string, std::string> StringStringMap;
53
typedef std::map<std::string, std::wstring> StringWStringMap;
54
typedef std::map<std::string, bool> StringBoolMap;
55
typedef std::map<std::string, int> StringIntMap;
56
typedef std::map<std::string, double> StringDoubleMap;
57
typedef std::map<std::string, StringVector> StringStringVectorMap;
58
 
59
enum
60
{
61
        CURSOR_POINTER,
62
        CURSOR_HAND,
63
        CURSOR_DRAGGING,
64
        CURSOR_TEXT,
65
        CURSOR_CIRCLE_SLASH,
66
        CURSOR_SIZEALL,
67
        CURSOR_SIZENESW,
68
        CURSOR_SIZENS,
69
        CURSOR_SIZENWSE,
70
        CURSOR_SIZEWE, 
71
        CURSOR_WAIT,
72
        CURSOR_NONE,
73
        CURSOR_CUSTOM,
74
        NUM_CURSORS
75
};
76
 
77
enum
78
{
79
        DEMO_MOUSE_POSITION,   
80
        DEMO_ACTIVATE_APP,
81
        DEMO_SIZE,
82
        DEMO_KEY_DOWN,
83
        DEMO_KEY_UP,
84
        DEMO_KEY_CHAR,
85
        DEMO_CLOSE,
86
        DEMO_MOUSE_ENTER,
87
        DEMO_MOUSE_EXIT,
88
        DEMO_LOADING_COMPLETE,
89
        DEMO_REGISTRY_GETSUBKEYS,
90
        DEMO_REGISTRY_READ,
91
        DEMO_REGISTRY_WRITE,
92
        DEMO_REGISTRY_ERASE,   
93
        DEMO_FILE_EXISTS,
94
        DEMO_FILE_READ,
95
        DEMO_FILE_WRITE,
96
        DEMO_HTTP_RESULT,
97
        DEMO_SYNC,
98
        DEMO_ASSERT_STRING_EQUAL,
99
        DEMO_ASSERT_INT_EQUAL,
100
        DEMO_MOUSE_WHEEL,
101
        DEMO_HANDLE_COMPLETE,
102
        DEMO_VIDEO_DATA,
103
        DEMO_IDLE = 31
104
};
105
 
106
enum {
107
        FPS_ShowFPS,
108
        FPS_ShowCoords,
109
        Num_FPS_Types
110
};
111
 
112
enum
113
{
114
        UPDATESTATE_MESSAGES,
115
        UPDATESTATE_PROCESS_1,
116
        UPDATESTATE_PROCESS_2,
117
        UPDATESTATE_PROCESS_DONE
118
};
119
 
120
typedef std::map<HANDLE, int> HandleToIntMap;
121
 
122
class SexyAppBase : public ButtonListener, public DialogListener
123
{
124
public:
125
 
126
        ulong                                   mRandSeed;
127
 
128
        std::string                             mCompanyName;
129
        std::string                             mFullCompanyName;
130
        std::string                             mProdName;     
131
        SexyString                              mTitle;
132
        std::string                             mRegKey;
133
        std::string                             mChangeDirTo;
134
 
135
        int                                             mRelaxUpdateBacklogCount; // app doesn't try to catch up for this many frames
136
        int                                             mPreferredX;
137
        int                                             mPreferredY;
138
        int                                             mWidth;
139
        int                                             mHeight;
140
        int                                             mFullscreenBits;
141
        double                                  mMusicVolume;
142
        double                                  mSfxVolume;
143
        double                                  mDemoMusicVolume;
144
        double                                  mDemoSfxVolume;
145
        bool                                    mNoSoundNeeded;
146
        bool                                    mWantFMod;
147
        bool                                    mCmdLineParsed;
148
        bool                                    mSkipSignatureChecks;
149
        bool                                    mStandardWordWrap;
150
        bool                                    mbAllowExtendedChars;
151
 
152
        HANDLE                                  mMutex;
153
        bool                                    mOnlyAllowOneCopyToRun;
154
        UINT                                    mNotifyGameMessage;
155
        CritSect                                mCritSect;     
156
        bool                                    mBetaValidate;
157
        uchar                                   mAdd8BitMaxTable[512];
158
        WidgetManager*                  mWidgetManager;
159
        DialogMap                               mDialogMap;
160
        DialogList                              mDialogList;
161
        DWORD                                   mPrimaryThreadId;
162
        bool                                    mSEHOccured;
163
        bool                                    mShutdown;
164
        bool                                    mExitToTop;
165
        bool                                    mIsWindowed;
166
        bool                                    mIsPhysWindowed;
167
        bool                                    mFullScreenWindow; // uses ChangeDisplaySettings to run fullscreen with mIsWindowed true
168
        bool                                    mForceFullscreen;
169
        bool                                    mForceWindowed;
170
        bool                                    mInitialized;  
171
        bool                                    mProcessInTimer;
172
        DWORD                                   mTimeLoaded;
173
        HWND                                    mHWnd;
174
        HWND                                    mInvisHWnd;
175
        bool                                    mIsScreenSaver;
176
        bool                                    mAllowMonitorPowersave;
177
        WindowsMessageList              mDeferredMessages;
178
        bool                                    mNoDefer;      
179
        bool                                    mFullScreenPageFlip;   
180
        bool                                    mTabletPC;
181
        DDInterface*                    mDDInterface;
182
        bool                                    mAlphaDisabled;
183
        MusicInterface*                 mMusicInterface;       
184
        bool                                    mReadFromRegistry;
185
        std::string                             mRegisterLink;
186
        std::string                             mProductVersion;       
187
        Image*                                  mCursorImages[NUM_CURSORS];
188
        HCURSOR                                 mOverrideCursor;
189
        bool                                    mIsOpeningURL;
190
        bool                                    mShutdownOnURLOpen;
191
        std::string                             mOpeningURL;
192
        DWORD                                   mOpeningURLTime;
193
        DWORD                                   mLastTimerTime;
194
        DWORD                                   mLastBigDelayTime;     
195
        double                                  mUnmutedMusicVolume;
196
        double                                  mUnmutedSfxVolume;     
197
        int                                             mMuteCount;
198
        int                                             mAutoMuteCount;
199
        bool                                    mDemoMute;
200
        bool                                    mMuteOnLostFocus;
201
        MemoryImageSet                  mMemoryImageSet;
202
        SharedImageMap                  mSharedImageMap;
203
        bool                                    mCleanupSharedImages;
204
 
205
        int                                             mNonDrawCount;
206
        int                                             mFrameTime;
207
 
208
        bool                                    mIsDrawing;
209
        bool                                    mLastDrawWasEmpty;
210
        bool                                    mHasPendingDraw;
211
        double                                  mPendingUpdatesAcc;
212
        double                                  mUpdateFTimeAcc;
213
        DWORD                                   mLastTimeCheck;
214
        DWORD                                   mLastTime;
215
        DWORD                                   mLastUserInputTick;
216
 
217
        int                                             mSleepCount;
218
        int                                             mDrawCount;
219
        int                                             mUpdateCount;
220
        int                                             mUpdateAppState;
221
        int                                             mUpdateAppDepth;
222
        double                                  mUpdateMultiplier;             
223
        bool                                    mPaused;
224
        int                                             mFastForwardToUpdateNum;
225
        bool                                    mFastForwardToMarker;
226
        bool                                    mFastForwardStep;
227
        DWORD                                   mLastDrawTick;
228
        DWORD                                   mNextDrawTick;
229
        int                                             mStepMode;  // 0 = off, 1 = step, 2 = waiting for step
230
 
231
        int                                             mCursorNum;
232
        SoundManager*                   mSoundManager;
233
        HCURSOR                                 mHandCursor;
234
        HCURSOR                                 mDraggingCursor;
235
        WidgetSafeDeleteList    mSafeDeleteList;
236
        bool                                    mMouseIn;      
237
        bool                                    mRunning;
238
        bool                                    mActive;
239
        bool                                    mMinimized;
240
        bool                                    mPhysMinimized;
241
        bool                                    mIsDisabled;
242
        bool                                    mHasFocus;
243
        int                                             mDrawTime;
244
        ulong                                   mFPSStartTick;
245
        int                                             mFPSFlipCount;
246
        int                                             mFPSDirtyCount;
247
        int                                             mFPSTime;
248
        int                                             mFPSCount;
249
        bool                                    mShowFPS;
250
        int                                             mShowFPSMode;
251
        int                                             mScreenBltTime;
252
        bool                                    mAutoStartLoadingThread;
253
        bool                                    mLoadingThreadStarted;
254
        bool                                    mLoadingThreadCompleted;
255
        bool                                    mLoaded;
256
        bool                                    mYieldMainThread;
257
        bool                                    mLoadingFailed;
258
        bool                                    mCursorThreadRunning;
259
        bool                                    mSysCursor;    
260
        bool                                    mCustomCursorsEnabled;
261
        bool                                    mCustomCursorDirty;    
262
        bool                                    mLastShutdownWasGraceful;
263
        bool                                    mIsWideWindow;
264
 
265
        int                                             mNumLoadingThreadTasks;
266
        int                                             mCompletedLoadingThreadTasks;
267
 
268
        // For recording/playback of program control
269
        bool                                    mRecordingDemoBuffer;
270
        bool                                    mPlayingDemoBuffer;
271
        bool                                    mManualShutdown;
272
        std::string                     mDemoPrefix;
273
        std::string                     mDemoFileName;
274
        Buffer                                  mDemoBuffer;
275
        int                                             mDemoLength;
276
        int                                             mLastDemoMouseX;
277
        int                                             mLastDemoMouseY;
278
        int                                             mLastDemoUpdateCnt;
279
        bool                                    mDemoNeedsCommand;
280
        bool                                    mDemoIsShortCmd;
281
        int                                             mDemoCmdNum;
282
        int                                             mDemoCmdOrder;
283
        int                                             mDemoCmdBitPos;
284
        bool                                    mDemoLoadingComplete;
285
        HandleToIntMap                  mHandleToIntMap; // For waiting on handles
286
        int                                             mCurHandleNum;
287
 
288
        typedef std::pair<std::string, int> DemoMarker;
289
        typedef std::list<DemoMarker> DemoMarkerList;
290
        DemoMarkerList                  mDemoMarkerList;
291
 
292
        bool                                    mDebugKeysEnabled;
293
        bool                                    mEnableMaximizeButton;
294
        bool                                    mCtrlDown;
295
        bool                                    mAltDown;
296
 
297
        int                                             mSyncRefreshRate;
298
        bool                                    mVSyncUpdates;
299
        bool                                    mVSyncBroken;
300
        int                                             mVSyncBrokenCount;
301
        DWORD                                   mVSyncBrokenTestStartTick;
302
        DWORD                                   mVSyncBrokenTestUpdates;
303
        bool                                    mWaitForVSync;
304
        bool                                    mSoftVSyncWait;
305
        bool                                    mUserChanged3DSetting;
306
        bool                                    mAutoEnable3D;
307
        bool                                    mTest3D;
308
        DWORD                                   mMinVidMemory3D;
309
        DWORD                                   mRecommendedVidMemory3D;
310
 
311
        bool                                    mWidescreenAware;
312
        Rect                                    mScreenBounds;
313
        bool                                    mEnableWindowAspect;
314
        Ratio                                   mWindowAspect;
315
 
316
        StringWStringMap                mStringProperties;
317
        StringBoolMap                   mBoolProperties;
318
        StringIntMap                    mIntProperties;
319
        StringDoubleMap                 mDoubleProperties;
320
        StringStringVectorMap   mStringVectorProperties;
321
        ResourceManager*                mResourceManager;
322
 
323
#ifdef ZYLOM
324
        uint                                    mZylomGameId;
325
#endif
326
 
327
        LONG                                    mOldWndProc;
328
 
329
protected:     
330
        void                                    RehupFocus();
331
        void                                    ClearKeysDown();
332
        bool                                    ProcessDeferredMessages(bool singleMessage);
333
        void                                    UpdateFTimeAcc();
334
        virtual bool                    Process(bool allowSleep = true);               
335
        virtual void                    UpdateFrames();
336
        virtual bool                    DoUpdateFrames();
337
        virtual void                    DoUpdateFramesF(float theFrac);
338
        virtual void                    MakeWindow();
339
        virtual void                    EnforceCursor();
340
        virtual void                    ReInitImages();
341
        virtual void                    DeleteNativeImageData();       
342
        virtual void                    DeleteExtraImageData();
343
 
344
        // Loading thread methods       
345
        virtual void                    LoadingThreadCompleted();
346
        static void                             LoadingThreadProcStub(void *theArg);   
347
 
348
        // Cursor thread methods
349
        void                                    CursorThreadProc();
350
        static void                             CursorThreadProcStub(void *theArg);
351
        void                                    StartCursorThread();
352
 
353
        void                                    WaitForLoadingThread();                        
354
        void                                    ProcessSafeDeleteList();       
355
        void                                    RestoreScreenResolution();
356
        void                                    DoExit(int theCode);
357
 
358
        void                                    TakeScreenshot();
359
        void                                    DumpProgramInfo();     
360
        void                                    ShowMemoryUsage();                     
361
 
362
        // Registry helpers
363
        bool                                    RegistryRead(const std::string& theValueName, ulong* theType, uchar* theValue, ulong* theLength);
364
        bool                                    RegistryReadKey(const std::string& theValueName, ulong* theType, uchar* theValue, ulong* theLength, HKEY theMainKey = HKEY_CURRENT_USER);
365
        bool                                    RegistryWrite(const std::string& theValueName, ulong theType, const uchar* theValue, ulong theLength);
366
 
367
        // Demo recording helpers       
368
        void                                    ProcessDemo();
369
 
370
public:
371
        SexyAppBase();
372
        virtual ~SexyAppBase();
373
 
374
        // Common overrides:
375
        virtual MusicInterface* CreateMusicInterface(HWND theHWnd);
376
        virtual void                    InitHook();
377
        virtual void                    ShutdownHook();
378
        virtual void                    PreTerminate();
379
        virtual void                    LoadingThreadProc();
380
        virtual void                    WriteToRegistry();
381
        virtual void                    ReadFromRegistry();
382
        virtual Dialog*                 NewDialog(int theDialogId, bool isModal, const SexyString& theDialogHeader, const SexyString& theDialogLines, const SexyString& theDialogFooter, int theButtonMode);           
383
        virtual void                    PreDisplayHook();
384
 
385
        // Public methods
386
        virtual void                    BeginPopup();
387
        virtual void                    EndPopup();
388
        virtual int                             MsgBox(const std::string &theText, const std::string &theTitle = "Message", int theFlags = MB_OK);
389
        virtual int                             MsgBox(const std::wstring &theText, const std::wstring &theTitle = L"Message", int theFlags = MB_OK);
390
        virtual void                    Popup(const std::string& theString);
391
        virtual void                    Popup(const std::wstring& theString);
392
        virtual void                    LogScreenSaverError(const std::string &theError);
393
        virtual void                    SafeDeleteWidget(Widget* theWidget);   
394
 
395
        virtual void                    URLOpenFailed(const std::string& theURL);
396
        virtual void                    URLOpenSucceeded(const std::string& theURL);
397
        virtual bool                    OpenURL(const std::string& theURL, bool shutdownOnOpen = false);       
398
        virtual std::string             GetProductVersion(const std::string& thePath); 
399
 
400
        virtual void                    SEHOccured();
401
        virtual std::string             GetGameSEHInfo();
402
        virtual void                    GetSEHWebParams(DefinesMap* theDefinesMap);
403
        virtual void                    Shutdown();    
404
 
405
        virtual void                    DoParseCmdLine();
406
        virtual void                    ParseCmdLine(const std::string& theCmdLine);
407
        virtual void                    HandleCmdLineParam(const std::string& theParamName, const std::string& theParamValue);
408
        virtual void                    HandleNotifyGameMessage(int theType, int theParam); // for HWND_BROADCAST of mNotifyGameMessage (0-1000 are reserved for SexyAppBase for theType)
409
        virtual void                    HandleGameAlreadyRunning();
410
 
411
        virtual void                    Start();       
412
        virtual void                    Init();
413
        virtual void                    PreDDInterfaceInitHook();
414
        virtual void                    PostDDInterfaceInitHook();
415
        virtual bool                    ChangeDirHook(const char *theIntendedPath);
416
        virtual void                    PlaySample(int theSoundNum);
417
        virtual void                    PlaySample(int theSoundNum, int thePan);
418
 
419
        virtual double                  GetMasterVolume();
420
        virtual double                  GetMusicVolume();
421
        virtual double                  GetSfxVolume();
422
        virtual bool                    IsMuted();
423
 
424
        virtual void                    SetMasterVolume(double theVolume);
425
        virtual void                    SetMusicVolume(double theVolume);
426
        virtual void                    SetSfxVolume(double theVolume);
427
        virtual void                    Mute(bool autoMute = false);
428
        virtual void                    Unmute(bool autoMute = false);
429
 
430
        void                                    StartLoadingThread();
431
        virtual double                  GetLoadingThreadProgress();    
432
 
433
        void                                    CopyToClipboard(const std::string& theString);
434
        std::string                             GetClipboard();
435
 
436
        void                                    SetCursor(int theCursorNum);
437
        int                                             GetCursor();
438
        void                                    EnableCustomCursors(bool enabled);     
439
        virtual DDImage*                GetImage(const std::string& theFileName, bool commitBits = true);      
440
        virtual SharedImageRef  GetSharedImage(const std::string& theFileName, const std::string& theVariant = "", bool* isNew = NULL);
441
 
442
        void                                    CleanSharedImages();
443
        void                                    PrecacheAdditive(MemoryImage* theImage);
444
        void                                    PrecacheAlpha(MemoryImage* theImage);
445
        void                                    PrecacheNative(MemoryImage* theImage);
446
        void                                    SetCursorImage(int theCursorNum, Image* theImage);
447
 
448
        DDImage*                                CreateCrossfadeImage(Image* theImage1, const Rect& theRect1, Image* theImage2, const Rect& theRect2, double theFadeFactor);
449
        void                                    ColorizeImage(Image* theImage, const Color& theColor);
450
        DDImage*                                CreateColorizedImage(Image* theImage, const Color& theColor);
451
        DDImage*                                CopyImage(Image* theImage, const Rect& theRect);
452
        DDImage*                                CopyImage(Image* theImage);
453
        void                                    MirrorImage(Image* theImage);
454
        void                                    FlipImage(Image* theImage);
455
        void                                    RotateImageHue(Sexy::MemoryImage *theImage, int theDelta);
456
        ulong                                   HSLToRGB(int h, int s, int l);
457
        ulong                                   RGBToHSL(int r, int g, int b);
458
        void                                    HSLToRGB(const ulong* theSource, ulong* theDest, int theSize);
459
        void                                    RGBToHSL(const ulong* theSource, ulong* theDest, int theSize);
460
 
461
        void                                    AddMemoryImage(MemoryImage* theMemoryImage);
462
        void                                    RemoveMemoryImage(MemoryImage* theMemoryImage);
463
        void                                    Remove3DData(MemoryImage* theMemoryImage);
464
        virtual void                    SwitchScreenMode();
465
        virtual void                    SwitchScreenMode(bool wantWindowed);
466
        virtual void                    SwitchScreenMode(bool wantWindowed, bool is3d, bool force = false);
467
        virtual void                    SetAlphaDisabled(bool isDisabled);
468
 
469
        virtual Dialog*                 DoDialog(int theDialogId, bool isModal, const SexyString& theDialogHeader, const SexyString& theDialogLines, const SexyString& theDialogFooter, int theButtonMode);
470
        virtual Dialog*                 GetDialog(int theDialogId);
471
        virtual void                    AddDialog(int theDialogId, Dialog* theDialog);
472
        virtual void                    AddDialog(Dialog* theDialog);
473
        virtual bool                    KillDialog(int theDialogId, bool removeWidget, bool deleteWidget);
474
        virtual bool                    KillDialog(int theDialogId);
475
        virtual bool                    KillDialog(Dialog* theDialog);
476
        virtual int                             GetDialogCount();
477
        virtual void                    ModalOpen();
478
        virtual void                    ModalClose();  
479
        virtual void                    DialogButtonPress(int theDialogId, int theButtonId);
480
        virtual void                    DialogButtonDepress(int theDialogId, int theButtonId);
481
 
482
        virtual void                    GotFocus();
483
        virtual void                    LostFocus();   
484
        virtual bool                    IsAltKeyUsed(WPARAM wParam);
485
        virtual bool                    DebugKeyDown(int theKey);      
486
        virtual bool                    DebugKeyDownAsync(int theKey, bool ctrlDown, bool altDown);
487
        virtual void                    CloseRequestAsync();
488
        bool                                    Is3DAccelerated();
489
        bool                                    Is3DAccelerationSupported();
490
        bool                                    Is3DAccelerationRecommended();
491
        void                                    DemoSyncRefreshRate();
492
        void                                    Set3DAcclerated(bool is3D, bool reinit = true);
493
        virtual void                    Done3dTesting();
494
        virtual std::string             NotifyCrashHook(); // return file name that you want to upload
495
 
496
        virtual bool                    CheckSignature(const Buffer& theBuffer, const std::string& theFileName);
497
        virtual bool                    DrawDirtyStuff();
498
        virtual void                    Redraw(Rect* theClipRect);
499
 
500
        // Properties access methods
501
        bool                                    LoadProperties(const std::string& theFileName, bool required, bool checkSig);
502
        bool                                    LoadProperties();
503
        virtual void                    InitPropertiesHook();
504
 
505
        // Resource access methods
506
        void                                    LoadResourceManifest();
507
        void                                    ShowResourceError(bool doExit = false);
508
 
509
        bool                                    GetBoolean(const std::string& theId);
510
        bool                                    GetBoolean(const std::string& theId, bool theDefault); 
511
        int                                             GetInteger(const std::string& theId);
512
        int                                             GetInteger(const std::string& theId, int theDefault);
513
        double                                  GetDouble(const std::string& theId);
514
        double                                  GetDouble(const std::string& theId, double theDefault);
515
        SexyString                              GetString(const std::string& theId);
516
        SexyString                              GetString(const std::string& theId, const SexyString& theDefault);
517
 
518
        StringVector                    GetStringVector(const std::string& theId);
519
 
520
        void                                    SetBoolean(const std::string& theId, bool theValue);
521
        void                                    SetInteger(const std::string& theId, int theValue);
522
        void                                    SetDouble(const std::string& theId, double theValue);
523
        void                                    SetString(const std::string& theId, const std::wstring& theValue);
524
 
525
        // Demo access methods
526
        bool                                    PrepareDemoCommand(bool required);
527
        void                                    WriteDemoTimingBlock();
528
        void                                    WriteDemoBuffer();
529
        bool                                    ReadDemoBuffer(std::string &theError);//UNICODE
530
        void                                    DemoSyncBuffer(Buffer* theBuffer);
531
        void                                    DemoSyncString(std::string* theString);
532
        void                                    DemoSyncInt(int* theInt);
533
        void                                    DemoSyncBool(bool* theBool);
534
        void                                    DemoAssertStringEqual(const std::string& theString);
535
        void                                    DemoAssertIntEqual(int theInt);
536
        void                                    DemoAddMarker(const std::string& theString);
537
        void                                    DemoRegisterHandle(HANDLE theHandle);
538
        void                                    DemoWaitForHandle(HANDLE theHandle);
539
        bool                                    DemoCheckHandle(HANDLE theHandle);
540
 
541
 
542
        // Registry access methods
543
        bool                                    RegistryGetSubKeys(const std::string& theKeyName, StringVector* theSubKeys);
544
        bool                                    RegistryReadString(const std::string& theValueName, std::string* theString);
545
        bool                                    RegistryReadInteger(const std::string& theValueName, int* theValue);
546
        bool                                    RegistryReadBoolean(const std::string& theValueName, bool* theValue);
547
        bool                                    RegistryReadData(const std::string& theValueName, uchar* theValue, ulong* theLength);
548
        bool                                    RegistryWriteString(const std::string& theValueName, const std::string& theString);
549
        bool                                    RegistryWriteInteger(const std::string& theValueName, int theValue);
550
        bool                                    RegistryWriteBoolean(const std::string& theValueName, bool theValue);
551
        bool                                    RegistryWriteData(const std::string& theValueName, const uchar* theValue, ulong theLength);    
552
        bool                                    RegistryEraseKey(const SexyString& theKeyName);
553
        void                                    RegistryEraseValue(const SexyString& theValueName);
554
 
555
        // File access methods
556
        bool                                    WriteBufferToFile(const std::string& theFileName, const Buffer* theBuffer);
557
        bool                                    ReadBufferFromFile(const std::string& theFileName, Buffer* theBuffer, bool dontWriteToDemo = false);//UNICODE
558
        bool                                    WriteBytesToFile(const std::string& theFileName, const void *theData, unsigned long theDataLen);
559
        bool                                    FileExists(const std::string& theFileName);
560
        bool                                    EraseFile(const std::string& theFileName);
561
 
562
        // Misc methods
563
        virtual void                    DoMainLoop();
564
        virtual bool                    UpdateAppStep(bool* updated);
565
        virtual bool                    UpdateApp();
566
        int                                             InitDDInterface();
567
        void                                    ClearUpdateBacklog(bool relaxForASecond = false);
568
        bool                                    IsScreenSaver();
569
        virtual bool                    AppCanRestore();
570
        static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);        
571
};
572
 
573
extern SexyAppBase* gSexyAppBase;
574
 
575
};
576
 
577
#endif //__SEXYAPPBASE_H__