LCOV - code coverage report
Current view: top level - source/ps/GameSetup - Atlas.cpp (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 2 18 11.1 %
Date: 2023-01-19 00:18:29 Functions: 2 5 40.0 %

          Line data    Source code
       1             : /* Copyright (C) 2014 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             : 
      22             : #include "ps/GameSetup/CmdLineArgs.h"
      23             : #include "ps/DllLoader.h"
      24             : 
      25             : //----------------------------------------------------------------------------
      26             : // Atlas (map editor) integration
      27             : //----------------------------------------------------------------------------
      28             : 
      29           1 : DllLoader atlas_dll("AtlasUI", CLogger::Normal);
      30             : 
      31             : enum AtlasRunFlags
      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).
      36             :     ATLAS_NO_GUI = 1
      37             : };
      38             : 
      39             : // starts the Atlas UI.
      40           0 : static void ATLAS_Run(const CmdLineArgs& args, int flags = 0)
      41             : {
      42             :     // first check if we can run at all
      43           0 :     if(!atlas_dll.LoadDLL())
      44             :     {
      45           0 :         if(flags & ATLAS_NO_GUI)
      46           0 :             DEBUG_DISPLAY_ERROR(L"The Atlas UI was not successfully loaded and therefore cannot be started as requested.");
      47             :         else
      48           0 :             DEBUG_DISPLAY_ERROR(L"The Atlas UI was not successfully loaded and therefore cannot be started as requested.");// TODO: implement GUI error message
      49           0 :         return;
      50             :     }
      51             : 
      52             :     // TODO (make nicer)
      53             :     extern bool BeginAtlas(const CmdLineArgs& args, const DllLoader& dll);
      54           0 :     if (!BeginAtlas(args, atlas_dll))
      55             :     {
      56           0 :         debug_warn(L"Atlas loading failed");
      57           0 :         return;
      58             :     }
      59             : }
      60             : 
      61           0 : bool ATLAS_IsAvailable()
      62             : {
      63           0 :     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           0 : bool ATLAS_RunIfOnCmdLine(const CmdLineArgs& args, bool force)
      74             : {
      75           0 :     if (force || args.Has("editor"))
      76             :     {
      77           0 :         ATLAS_Run(args, ATLAS_NO_GUI);
      78           0 :         return true;
      79             :     }
      80             : 
      81           0 :     return false;
      82           3 : }

Generated by: LCOV version 1.13