Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Atlas.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2009 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "precompiled.h"
19 
20 #include "Atlas.h"
21 
23 #include "ps/DllLoader.h"
24 
25 //----------------------------------------------------------------------------
26 // Atlas (map editor) integration
27 //----------------------------------------------------------------------------
28 
29 DllLoader atlas_dll("AtlasUI");
30 
32 {
33  // used by ATLAS_RunIfOnCmdLine; makes any error output go through
34  // DEBUG_DISPLAY_ERROR rather than a GUI dialog box (because GUI init was
35  // skipped to reduce load time).
37 };
38 
39 // starts the Atlas UI.
40 static void ATLAS_Run(const CmdLineArgs& args, int flags = 0)
41 {
42  // first check if we can run at all
43  if(!atlas_dll.LoadDLL())
44  {
45  if(flags & ATLAS_NO_GUI)
46  DEBUG_DISPLAY_ERROR(L"The Atlas UI was not successfully loaded and therefore cannot be started as requested.");
47  else
48  DEBUG_DISPLAY_ERROR(L"The Atlas UI was not successfully loaded and therefore cannot be started as requested.");// TODO: implement GUI error message
49  return;
50  }
51 
52  // TODO (make nicer)
53  extern bool BeginAtlas(const CmdLineArgs& args, const DllLoader& dll);
54  if (!BeginAtlas(args, atlas_dll))
55  {
56  debug_warn(L"Atlas loading failed");
57  return;
58  }
59 }
60 
62 {
63  return atlas_dll.LoadDLL();
64 }
65 
66 // starts the Atlas UI if an "-editor" switch is found on the command line.
67 // this is the alternative to starting the main menu and clicking on
68 // the editor button; it is much faster because it's called during early
69 // init and therefore skips GUI setup.
70 // notes:
71 // - GUI init still runs, but some GUI setup will be skipped since
72 // ATLAS_IsRunning() will return true.
73 bool ATLAS_RunIfOnCmdLine(const CmdLineArgs& args, bool force)
74 {
75  if (force || args.Has("editor"))
76  {
77  ATLAS_Run(args, ATLAS_NO_GUI);
78  return true;
79  }
80 
81  return false;
82 }
static void ATLAS_Run(const CmdLineArgs &args, int flags=0)
Definition: Atlas.cpp:40
bool ATLAS_IsAvailable()
Definition: Atlas.cpp:61
AtlasRunFlags
Definition: Atlas.cpp:31
bool ATLAS_RunIfOnCmdLine(const CmdLineArgs &args, bool force)
Definition: Atlas.cpp:73
bool Has(const char *name) const
Test whether the given name was specified, as either -name or -name=value
Definition: CmdLineArgs.cpp:66
DllLoader atlas_dll("AtlasUI")
bool LoadDLL()
Attempt to load and initialise the library, if not already.
Definition: DllLoader.cpp:152
#define DEBUG_DISPLAY_ERROR(description)
Definition: debug.h:197
#define debug_warn(expr)
display the error dialog with the given text.
Definition: debug.h:324