2009-04-18 19:00:33 +02:00
|
|
|
/* Copyright (C) 2009 Wildfire Games.
|
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2006-04-24 01:14:18 +02:00
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
#include "Atlas.h"
|
|
|
|
|
2006-12-20 04:09:21 +01:00
|
|
|
#include "ps/GameSetup/CmdLineArgs.h"
|
|
|
|
#include "ps/DllLoader.h"
|
|
|
|
|
2006-04-24 01:14:18 +02:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Atlas (map editor) integration
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2006-12-20 04:09:21 +01:00
|
|
|
DllLoader atlas_dll("AtlasUI");
|
2006-04-24 01:14:18 +02:00
|
|
|
|
|
|
|
enum AtlasRunFlags
|
|
|
|
{
|
|
|
|
// used by ATLAS_RunIfOnCmdLine; makes any error output go through
|
2008-01-19 12:33:11 +01:00
|
|
|
// DEBUG_DISPLAY_ERROR rather than a GUI dialog box (because GUI init was
|
2006-04-24 01:14:18 +02:00
|
|
|
// skipped to reduce load time).
|
|
|
|
ATLAS_NO_GUI = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
// starts the Atlas UI.
|
2006-12-09 15:39:52 +01:00
|
|
|
static void ATLAS_Run(const CmdLineArgs& args, int flags = 0)
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
|
|
|
// first check if we can run at all
|
2006-12-20 04:09:21 +01:00
|
|
|
if(!atlas_dll.LoadDLL())
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
|
|
|
if(flags & ATLAS_NO_GUI)
|
2008-01-19 12:33:11 +01:00
|
|
|
DEBUG_DISPLAY_ERROR(L"The Atlas UI was not successfully loaded and therefore cannot be started as requested.");
|
2006-04-24 01:14:18 +02:00
|
|
|
else
|
2008-01-19 12:33:11 +01:00
|
|
|
DEBUG_DISPLAY_ERROR(L"The Atlas UI was not successfully loaded and therefore cannot be started as requested.");// TODO: implement GUI error message
|
2006-04-24 01:14:18 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO (make nicer)
|
2006-12-20 04:09:21 +01:00
|
|
|
extern bool BeginAtlas(const CmdLineArgs& args, const DllLoader& dll);
|
|
|
|
if (!BeginAtlas(args, atlas_dll))
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
2009-11-03 22:46:35 +01:00
|
|
|
debug_warn(L"Atlas loading failed");
|
2006-04-24 01:14:18 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// starts the Atlas UI if an "-editor" switch is found on the command line.
|
|
|
|
// this is the alternative to starting the main menu and clicking on
|
|
|
|
// the editor button; it is much faster because it's called during early
|
|
|
|
// init and therefore skips GUI setup.
|
|
|
|
// notes:
|
|
|
|
// - GUI init still runs, but some GUI setup will be skipped since
|
|
|
|
// ATLAS_IsRunning() will return true.
|
2006-12-09 15:39:52 +01:00
|
|
|
bool ATLAS_RunIfOnCmdLine(const CmdLineArgs& args)
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
2006-12-09 15:39:52 +01:00
|
|
|
if (args.Has("editor"))
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
2006-12-09 15:39:52 +01:00
|
|
|
ATLAS_Run(args, ATLAS_NO_GUI);
|
|
|
|
return true;
|
2006-04-24 01:14:18 +02:00
|
|
|
}
|
2006-12-09 15:39:52 +01:00
|
|
|
|
|
|
|
return false;
|
2006-04-24 01:14:18 +02:00
|
|
|
}
|