Planeshift

pslaunch.h

Go to the documentation of this file.
00001 /*
00002 * pslaunch.h - Author: Mike Gist
00003 *
00004 * Copyright (C) 2007 Atomic Blue ([email protected], http://www.atomicblue.org)
00005 *
00006 *
00007 * This program is free software; you can redistribute it and/or
00008 * modify it under the terms of the GNU General Public License
00009 * as published by the Free Software Foundation (version 2 of the License)
00010 * This program is distributed in the hope that it will be useful,
00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 * GNU General Public License for more details.
00014 * You should have received a copy of the GNU General Public License
00015 * along with this program; if not, write to the Free Software
00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 *
00018 */
00019 
00020 #ifndef __PSLAUNCH_H__
00021 #define __PSLAUNCH_H__
00022 
00023 #include <csutil/threading/thread.h>
00024 
00025 #include "updaterconfig.h"
00026 #include "updaterengine.h"
00027 
00028 #include "util/genericevent.h"
00029 
00030 class pawsMessageTextBox;
00031 
00032 #define APPNAME "PlaneShift Launcher"
00033 
00034 #define LAUNCHER_CONFIG_FILENAME "/this/pslaunch.cfg"
00035 
00036 class pawsLauncherWindowFactory;
00037 class pawsMainWidget;
00038 class PawsManager;
00039 struct iSoundManager;
00040 struct iObjectRegistry;
00041 
00042 class psLauncherGUI
00043 {
00044 private:
00045 
00046     iObjectRegistry* object_reg;
00047     csRef<iVFS> vfs;
00048     csRef<iConfigManager> configManager;
00049     csRef<iGraphics3D>      g3d;
00050     csRef<iGraphics2D>      g2d;
00051     csRef<iEventQueue>      queue;
00052     csRef<iSoundManager>    soundManager;
00053     DeclareGenericEventHandler(EventHandler, psLauncherGUI, "planeshift.launcher");
00054     csRef<EventHandler> event_handler;
00055 
00056     // PAWS
00057     PawsManager*    paws;
00058     pawsMainWidget* mainWidget;
00059     pawsLauncherWindowFactory* launcherWidget;
00060 
00061     /* Info shared with other threads. */
00062     InfoShare *infoShare;
00063 
00064     /* Set to true to launch the client. */
00065     bool *execPSClient;
00066     
00067     /* keeps track of whether the window is visible or not. */
00068     bool drawScreen;
00069 
00070     /* Limits the frame rate either by sleeping. */
00071     void FrameLimit();
00072 
00073     /* Time when the last frame was drawn. */
00074     csTicks elapsed;
00075 
00076     /* Load the app */
00077     bool InitApp();
00078 
00079     /* Handles an event from the event handler */
00080     bool HandleEvent (iEvent &ev);
00081 
00082     /* Downloads server news */
00083     Downloader* downloader;
00084 
00085     /* File utilities */
00086     FileUtil* fileUtil;
00087 
00088     /* True if we've already been told there's an update available. */
00089     bool updateTold;
00090 
00091 public:
00092     /* Quit the application */
00093     void Quit();
00094 
00095     void ExecClient(bool value) { *execPSClient = value; }
00096 
00097     psLauncherGUI(iObjectRegistry* _object_reg, InfoShare *_infoShare, bool *_execPSClient);
00098 
00099     Downloader* GetDownloader() { return downloader; }
00100 
00101     iVFS* GetVFS() { return vfs; }
00102 
00103     FileUtil* GetFileUtil() { return fileUtil; }
00104 
00105     void PerformUpdate(bool update, bool integrity);
00106 
00107     void PerformRepair();
00108 
00109     void CancelUpdater() { infoShare->SetCancelUpdater(true); }
00110 
00111     bool UpdateChecked() { return infoShare->GetUpdateChecked(); }
00112 
00113     csString GetCurrentClientVersion() { return infoShare->GetCurrentClientVersion(); }
00114 
00115     // Run.
00116     void Run();
00117 };
00118 
00119 #endif // __PSLAUNCH_H__