Пример #1
0
void GUIFontManager::LoadFonts(const std::string& fontSet)
{
  // Get the file to load fonts from:
  const std::string strPath = g_SkinInfo->GetSkinPath("Font.xml", &m_skinResolution);
  CLog::Log(LOGINFO, "Loading fonts from %s", strPath.c_str());

  CXBMCTinyXML xmlDoc;
  if (!xmlDoc.LoadFile(strPath))
  {
    CLog::Log(LOGERROR, "Couldn't load %s", strPath.c_str());
    return;
  }

  TiXmlElement* pRootElement = xmlDoc.RootElement();
  if (!pRootElement || pRootElement->ValueStr() != "fonts")
  {
    CLog::Log(LOGERROR, "file %s doesnt start with <fonts>", strPath.c_str());
    return;
  }

  // take note of the first font available in case we can't load the one specified
  std::string firstFont;

  const TiXmlElement *pChild = pRootElement->FirstChildElement("fontset");
  while (pChild)
  {
    const char* idAttr = pChild->Attribute("id");
    if (idAttr)
    {
      if (firstFont.empty())
        firstFont = idAttr;

      if (StringUtils::EqualsNoCase(fontSet, idAttr))
      {
        LoadFonts(pChild->FirstChild("font"));
        return;
      }
    }
    pChild = pChild->NextSiblingElement("fontset");
  }

  // no fontset was loaded, try the first
  if (!firstFont.empty())
  {
    CLog::Log(LOGWARNING, "file doesnt have <fontset> with name '%s', defaulting to first fontset", fontSet.c_str());
    LoadFonts(firstFont);
  }
  else
    CLog::Log(LOGERROR, "file '%s' doesnt have a valid <fontset>", strPath.c_str());
}
void RocketLayer::onEnter(){

	CCSprite::onEnter();
	RocketSingle::sharedRocket();

	p_context = Rocket::Core::CreateContext(name.c_str(), Rocket::Core::Vector2i(1024, 768));
	if (p_context == NULL)
	{
		Rocket::Core::Shutdown();

	}

	Rocket::Debugger::Initialise(p_context);

	LoadFonts("./data/");
	// Load and show the inventory document.
	inventory_1 = new Inventory("Inventory 1", Rocket::Core::Vector2f(50, 200), p_context);
	Inventory* inventory_2 = new Inventory("Inventory 2", Rocket::Core::Vector2f(540, 240), p_context);

	// Add items into the inventory.
	inventory_1->AddItem("Mk III L.A.S.E.R.");
	inventory_1->AddItem("Gravity Descender");
	inventory_1->AddItem("Closed-Loop Ion Beam");
	inventory_1->AddItem("5kT Mega-Bomb");
}
Пример #3
0
/**
**  Pre menu setup.
*/
void PreMenuSetup()
{
	//
	//  Initial menus require some gfx.
	//
	SetDefaultTextColors(FontYellow, FontWhite);

	LoadFonts();

	InitVideoCursors();

	if (MenuRace.empty()) {
		//Wyrmgus start
//		LoadCursors(PlayerRaces.Name[0]);
		LoadCursors();
		//Wyrmgus end
	} else {
		//Wyrmgus start
//		LoadCursors(MenuRace);
		LoadCursors();
		//Wyrmgus end
	}

	InitSettings();

	InitUserInterface();
	UI.Load();
}
Пример #4
0
/**
**  Load a game to file.
**
**  @param filename  File name to be loaded.
*/
void LoadGame(const std::string &filename)
{
	// log will be enabled if found in the save game
	CommandLogDisabled = true;
	SaveGameLoading = true;

	//Wyrmgus start
//	SetDefaultTextColors(FontYellow, FontWhite);
	SetDefaultTextColors(UI.NormalFontColor, UI.ReverseFontColor);
	//Wyrmgus end
	LoadFonts();

	LuaGarbageCollect();
	InitUnitTypes(1);
	LuaLoadFile(filename);
	LuaGarbageCollect();

	PlaceUnits();

	const unsigned long game_cycle = GameCycle;
	const unsigned syncrand = SyncRandSeed;
	const unsigned synchash = SyncHash;

	InitModules();
	LoadModules();

	GameCycle = game_cycle;
	SyncRandSeed = syncrand;
	SyncHash = synchash;
	SelectionChanged();
}
Пример #5
0
/**
**  Load all.
**
**  Call each module to load additional files (graphics,sounds).
*/
void LoadModules()
{
	LoadFonts();
	LoadIcons();
	LoadCursors(PlayerRaces.Name[ThisPlayer->Race]);
	UI.Load();
#ifndef DYNAMIC_LOAD
	LoadMissileSprites();
#endif
	LoadConstructions();
	LoadDecorations();
	LoadUnitTypes();

	InitPathfinder();

	LoadUnitSounds();
	MapUnitSounds();
	if (SoundEnabled()) {
		InitSoundClient();
	}

	SetPlayersPalette();
	UI.Minimap.Create();

	SetDefaultTextColors(UI.NormalFontColor, UI.ReverseFontColor);
}
Пример #6
0
/**
 *  \brief Loads the fonts in font files within the given directory structure
 *
 *   Recursively scans all directories under directory looking for TrueType
 *   (.ttf) and OpenType (.otf) font files or TrueType font collections (.ttc)
 *   and loads the fonts to make them available to the application.
 *
 *  \param directory      The directory to scan
 *  \param registeredFor  The user of the font. Used with releaseFonts() to
 *                        unload the font if no longer in use (by any users)
 *  \param maxDirs        The maximum number of subdirectories to scan
 */
void MythFontManager::LoadFonts(const QString &directory,
                                const QString &registeredFor, int *maxDirs)
{
    if (directory.isEmpty() || directory == "/" || registeredFor.isEmpty())
        return;
    (*maxDirs)--;
    if (*maxDirs < 1)
    {
        LOG(VB_GENERAL, LOG_WARNING, LOC +
            "Reached the maximum directory depth "
            "for a font directory structure. Terminating font scan.");
        return;
    }

    // Load the font files from this directory
    LoadFontsFromDirectory(directory, registeredFor);
    // Recurse through subdirectories
    QDir dir(directory);
    QFileInfoList files = dir.entryInfoList();
    QFileInfo info;
    for (QFileInfoList::const_iterator it = files.begin();
         ((it != files.end()) && (*maxDirs > 0)); ++it)
    {
        info = *it;
        // Skip '.' and '..' and other files starting with "." by checking
        // baseName()
        if (!info.baseName().isEmpty() && info.isDir())
            LoadFonts(info.absoluteFilePath(), registeredFor, maxDirs);
    }
}
Пример #7
0
bool cgGdiplusRender::Initialize( cgHwnd hWnd, int w, int h )
{
	if (!cgUIRender::Initialize(hWnd, w, h))
		return false;

	Gdiplus::GdiplusStartupInput gdiplusStartupInput;
	Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);

	m_kBlend.BlendOp=AC_SRC_OVER; //theonlyBlendOpdefinedinWindows2000
	m_kBlend.BlendFlags=0; //nothingelseisspecial...
	m_kBlend.AlphaFormat=AC_SRC_ALPHA; //...
	m_kBlend.SourceConstantAlpha=255;//AC_SRC_ALPHA 

	m_pkBkSurface = CreateUISurface(w, h);

	if (!m_pkBkSurface)
		return false;

	m_pkGraphics = new Gdiplus::Graphics((HDC)m_pkBkSurface->GetContent());

	if (!LoadFonts())
		return false;

	return true;
}
Пример #8
0
CGeneral::CGeneral()
{
   m_fSndLoaded = false;
   LoadFonts();
   InitCursor();
   LoadImages();
   LoadSound();
}
Пример #9
0
// Инициализация библиотеки эмулятора
void InitEGraph()
{
char pcCaption[80];
if (strlen(szVideoDriver)!=0)
  {
  strcpy(pcCaption, "SDL_VIDEODRIVER=");
  strcat(pcCaption,szVideoDriver);
  putenv(pcCaption);
  }
if (strlen(szAudioDriver)!=0)
  {
  strcpy(pcCaption, "SDL_AUDIODRIVER=");
  strcat(pcCaption,szAudioDriver);
  putenv(pcCaption);
  }
//putenv("SDL_VIDEODRIVER=windib");
//putenv("SDL_AUDIODRIVER=waveout");
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
if (!bMute)
  bMute=SDL_InitSubSystem(SDL_INIT_AUDIO);

char pcDrvName[20];
strcpy(pcCaption, "Emu80/SDL v. 3.14 development (video: ");
SDL_VideoDriverName(pcDrvName, 20);
strcat(pcCaption,pcDrvName);
if (!bMute)
  {
  strcat(pcCaption,", audio: ");
  SDL_AudioDriverName(pcDrvName, 20);
  strcat(pcCaption,pcDrvName);
  }
strcat(pcCaption,"), F10 - menu");

//SDL_WM_SetCaption("Emu80 / SDL", 0);
SDL_WM_SetCaption(pcCaption, 0);

atexit(SDL_Quit);

//semDraw=SDL_CreateSemaphore(1);

/*sfScreen = SDL_SetVideoMode(640, 480, 8,
                            SDL_HWSURFACE |
                            SDL_HWPALETTE);*/
pcScreenBuf=new char[160*64];
ClearScreen();
LoadFonts();

SetVideoMode(vmText30);
//ChangeResolution();

//SDL_ShowCursor(SDL_DISABLE);
ClearScreen();

InitAudio();
}
Пример #10
0
CGeneral::CGeneral():
m_iPrevGirl(0),
m_iPrevGirlColor(0),
m_iCurMusic(-1)
{
   LoadImages();
   LoadFonts();
   LoadMusic();
   LoadSound();
   InitCursor();
}
Пример #11
0
	void Chart::DrawToScreen(sf::RenderWindow* window)
	{
		LogFnStart();

		CreateTexture();
		LoadFonts();
		Render();
		DrawTextElements();
		CopyToScreen(window);

		LogFnEnd();
	}
Пример #12
0
void FontSelectManager::Set(DropList& _face, DropList& _height,
                            Option& _bold, Option& _italic, Option& _naa) {
	face = &_face;
	face->WhenAction = THISBACK(FaceSelect);
	height = &_height;
	height->WhenAction = THISBACK(Select);
	bold = &_bold;
	bold->WhenAction = THISBACK(Select);
	italic = &_italic;
	italic->WhenAction = THISBACK(Select);
	naa = &_naa;
	naa->WhenAction = THISBACK(Select);
	face->Clear();
	Index<String> fni;
	LoadFonts(face, fni, true);
	face->AddSeparator();
	LoadFonts(face, fni, false);
	face->SetIndex(0);
	height->ClearList();
	for(int i = 6; i < 64; i++)
		height->Add(i);
	FaceSelect();
}
Пример #13
0
void Drawer::Init (SDL_Surface* aSource)
{
    /* mCairoSurface = cairo_image_surface_create_for_data ( (unsigned char *)aSource->pixels,
                                                                           CAIRO_FORMAT_RGB24,
                                                                           aSource->w,
                                                                           aSource->h,
                                                                           aSource->pitch);*/

    mCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, aSource->w, aSource->h);

    mCairoDC = cairo_create (mCairoSurface);

    LoadFonts();
}
Пример #14
0
void Init_All()
{
  Init_Graphics();
  InitSpriteList();
  Init_Audio();
  InitSoundList();
  atexit(CleanUpAll);
  LoadFonts();
  InitMessages();
  LoadMouse(Cyan,Gold,DarkViolet);
  InitEntityList();
  ResetAllParticles();
  DrawSplashScreen();
  LoadContent();
  NewMap(32, 48,0,15);
  DrawMap();
}
Пример #15
0
/**
**  Load a game to file.
**
**  @param filename  File name to be loaded.
*/
void LoadGame(const std::string &filename)
{
	//Wyrmgus start
	CleanPlayers(); //clean players, as they may not have been cleansed after a scenario
	CurrentCustomHero = nullptr; //otherwise the loaded game will have an extra hero for the current custom hero
	//Wyrmgus end
	
	// log will be enabled if found in the save game
	CommandLogDisabled = true;
	SaveGameLoading = true;

	//Wyrmgus start
//	SetDefaultTextColors(FontYellow, FontWhite);
	SetDefaultTextColors(UI.NormalFontColor, UI.ReverseFontColor);
	//Wyrmgus end
	LoadFonts();
	
	//Wyrmgus start
	InitPlayers();
	//Wyrmgus end

	LuaGarbageCollect();
	InitUnitTypes(1);
	//Wyrmgus start
	CalculateItemsToLoad();
	//Wyrmgus end
	LuaLoadFile(filename);
	LuaGarbageCollect();

	PlaceUnits();

	const unsigned long game_cycle = GameCycle;
	const unsigned long long current_total_hours = CDate::CurrentTotalHours;
	const unsigned syncrand = SyncRandSeed;
	const unsigned synchash = SyncHash;

	InitModules();
	LoadModules();

	GameCycle = game_cycle;
	CDate::CurrentTotalHours = current_total_hours;
	SyncRandSeed = syncrand;
	SyncHash = synchash;
	SelectionChanged();
}
Пример #16
0
void CGraphics::Initialise(IDirect3DDevice9 * pDevice)
{
	// Is the d3d9 device valid?
	if(pDevice)
	{
		// Store the d3d9 device pointer
		m_pDevice = pDevice;

		// Load the fonts
		if(!LoadFonts())
		{
			CLogFile::Printf("Failed to load the fonts!");

			// Terminate process
			TerminateProcess(GetCurrentProcess(), 0);
		}
	}
}
Пример #17
0
int main(int argc, char**argv) {
    Q_INIT_RESOURCE(xsys);
    Q_INIT_RESOURCE(dwidget);
    QApplication app(argc, argv);

    ImmDisableIME(GetCurrentThreadId());
    InstallLogHandler();
    LoadFonts();
    LoadTranslate(app);

    MainWindow w;
    w.setWindowTitle (DeepinInstaller::AppTitle());
    w.setWindowIcon(QIcon(":/data/deepin-system-installer.png"));
    w.show();

    int ret = app.exec();
    qDebug()<<"app.exec() return with"<<ret;
    return 0;
}
Пример #18
0
void CGraphics::Initialise(IDirect3DDevice9 * pDevice)
{
	// Is the d3d9 device valid?
	if(pDevice)
	{
		// Store the d3d9 device pointer
		m_pDevice = pDevice;

		// Load the fonts
		if(!LoadFonts())
		{
			CLogFile::Printf("Failed to load the fonts!");

			// Terminate process
			TerminateProcess(GetCurrentProcess(), 0);
		}

		/*// Basic initialize
		D3DXCreateLine ( pDevice, &m_pLineInterface );
		D3DXCreateTextureFromFileInMemory ( pDevice, g_szPixel, sizeof ( g_szPixel ), &m_pDXPixelTexture );

		D3DDEVICE_CREATION_PARAMETERS cparams;
		RECT rect;

		m_pDevice->GetCreationParameters(&cparams);
		GetWindowRect(cparams.hFocusWindow, &rect);
		
		int width=rect.bottom-rect.top;
		int height=rect.right-rect.left;

		D3DXCreateTextureFromFile( pDevice, "multiplayer/logo.png", &pLoadingScreenTexture);
		m_pDevice->SetTexture(0, pLoadingScreenTexture);

		// Reset our device
		g_pCore->OnDeviceReset(m_pDevice);*/
	}
}
Пример #19
0
UINT32 FontServStart( EVENT_STACK_T *ev_st,  REG_ID_T reg_id,  UINT32 param2 )
{
    APP_FONTSERV_T     *app = NULL;
    UINT32 status = RESULT_OK;

    app = (APP_FONTSERV_T*)APP_InitAppData( (void *)APP_HandleEvent,
                                              sizeof(APP_FONTSERV_T),
                                              reg_id,
                                              0, 1,
                                              1,
                                              1, 1, 0 );

    status = APP_Start( ev_st,
                        &app->apt,
                        HW_STATE_INIT,
                        state_handling_table,
                        FontServExit,
                        app_name,
                        0 );

    LoadFonts( );

    return RESULT_OK;
}
Пример #20
0
/**
 *  \brief Loads the fonts in font files within the given directory structure
 *
 *   Scans directory and its subdirectories, up to MAX_DIRS total, looking for
 *   TrueType (.ttf) and OpenType (.otf) font files or TrueType font
 *   collections (.ttc) and loads the fonts to make them available to the
 *   application.
 *
 *  \param directory      The directory to scan
 *  \param registeredFor  The user of the font. Used with releaseFonts() to
 *                        unload the font if no longer in use (by any users)
 *  \sa LoadFonts(const QString &, const QString &, int *)
 */
void MythFontManager::LoadFonts(const QString &directory,
                                const QString &registeredFor)
{
    int maxDirs = MAX_DIRS;
    LoadFonts(directory, registeredFor, &maxDirs);

    QFontDatabase database;
    foreach (const QString & family, database.families())
    {
        QString result = QString("Font Family '%1': ").arg(family);
        foreach (const QString &style, database.styles(family))
        {
            result += QString("%1(").arg(style);

            QString sizes;
            foreach (int points, database.smoothSizes(family, style))
                sizes += QString::number(points) + ' ';

            result += QString("%1) ").arg(sizes.trimmed());
        }

        LOG(VB_GUI, LOG_DEBUG, LOC + result.trimmed());
    }
}
Пример #21
0
void Game::Start()
{
	if (_gameState != Uninitialized)
		return;

	_mainWindow.create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32), "Map Maker");
	_mainWindow.setFramerateLimit(60);

	int level[] =
    {
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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1, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    };

	const int MAPWIDTH = 20;
	const int MAPHEIGHT = 20;
	const std::string tileset = "images/tileset2.png";

	Map* board = new Map(tileset, sf::Vector2i(16, 16), "maps/4.txt", MAPWIDTH, MAPHEIGHT);
	TextureBar* bar = new TextureBar("images/texturebar.png", tileset, MAPWIDTH, MAPHEIGHT);

	Initialize("Map", board, 0, 0);
	Initialize("Texture Bar", bar, 0, 800);

	LoadFonts();

	_gameState = Playing;

	while (!IsExiting())
	{
		GameLoop();
	}

	_mainWindow.close();
}
Пример #22
0
/**
**  The main program: initialise, parse options and arguments.
**
**  @param argc  Number of arguments.
**  @param argv  Vector of arguments.
*/
int stratagusMain(int argc, char **argv)
{
#ifdef USE_BEOS
	//  Parse arguments for BeOS
	beos_init(argc, argv);
#endif
#ifdef USE_WIN32
	SetUnhandledExceptionFilter(CreateDumpFile);
#endif
#if defined(USE_WIN32) && ! defined(REDIRECT_OUTPUT)
	SetupConsole();
#endif
	//  Setup some defaults.
#ifndef MAC_BUNDLE
	StratagusLibPath = ".";
#else
	freopen("/tmp/stdout.txt", "w", stdout);
	freopen("/tmp/stderr.txt", "w", stderr);
	// Look for the specified data set inside the application bundle
	// This should be a subdir of the Resources directory
	CFURLRef pluginRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(),
												 CFSTR(MAC_BUNDLE_DATADIR), NULL, NULL);
	CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef,  kCFURLPOSIXPathStyle);
	const char *pathPtr = CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding());
	Assert(pathPtr);
	StratagusLibPath = pathPtr;
#endif

#ifdef USE_PHYSFS
	if (PHYSFS_init(argv[0])) {
		PHYSFS_mount(PHYSFS_DATAFILE, "/", 0);
	}
#endif

#ifdef USE_STACKTRACE
	try {
#endif
	Parameters &parameters = Parameters::Instance;
	parameters.SetDefaultValues();
	parameters.SetLocalPlayerNameFromEnv();

#ifdef REDIRECT_OUTPUT
	RedirectOutput();
#endif

	if (argc > 0) {
		parameters.applicationName = argv[0];
	}

	// FIXME: Parse options before or after scripts?
	ParseCommandLine(argc, argv, parameters);
	// Init the random number generator.
	InitSyncRand();

	makedir(parameters.GetUserDirectory().c_str(), 0777);

	// Init Lua and register lua functions!
	InitLua();
	LuaRegisterModules();

	// Initialise AI module
	InitAiModule();

	LoadCcl(parameters.luaStartFilename, parameters.luaScriptArguments);

	PrintHeader();
	PrintLicense();

	// Setup video display
	InitVideo();

	// Setup sound card
	if (!InitSound()) {
		InitMusic();
	}

#ifndef DEBUG			// For debug it's better not to have:
	srand(time(NULL));	// Random counter = random each start
#endif

	//  Show title screens.
	SetDefaultTextColors(FontYellow, FontWhite);
	LoadFonts();
	SetClipping(0, 0, Video.Width - 1, Video.Height - 1);
	Video.ClearScreen();
	ShowTitleScreens();

	// Init player data
	ThisPlayer = NULL;
	//Don't clear the Players structure as it would erase the allowed units.
	// memset(Players, 0, sizeof(Players));
	NumPlayers = 0;

	UnitManager.Init();	// Units memory management
	PreMenuSetup();		// Load everything needed for menus

	MenuLoop();

	Exit(0);
#ifdef USE_STACKTRACE
	} catch (const std::exception &e) {
		fprintf(stderr, "Stratagus crashed!\n");
		//Wyrmgus start
//		fprintf(stderr, "Please send this call stack to our bug tracker: https://github.com/Wargus/stratagus/issues\n");
		fprintf(stderr, "Please send this call stack to our bug tracker: https://github.com/Andrettin/Wyrmgus/issues\n");
		//Wyrmgus end
		fprintf(stderr, "and tell us what caused this bug to occur.\n");
		fprintf(stderr, " === exception state traceback === \n");
		fprintf(stderr, "%s", e.what());
		exit(1);
	}
#endif
	return 0;
}
Пример #23
0
/**
 * @brief Initializes the SpringApp instance
 * @return whether initialization was successful
 */
bool SpringApp::Initialize()
{
#if !(defined(WIN32) || defined(__APPLE__) || defined(HEADLESS))
	//! this MUST run before any other X11 call (esp. those by SDL!)
	//! we need it to make calls to X11 threadsafe
	if (!XInitThreads()) {
		LOG_L(L_FATAL, "Xlib is not thread safe");
		return false;
	}
#endif

#if defined(_WIN32) && defined(__GNUC__)
	// load QTCreator's gdb helper dll; a variant of this should also work on other OSes
	{
		// don't display a dialog box if gdb helpers aren't found
		UINT olderrors = SetErrorMode(SEM_FAILCRITICALERRORS);
		if (LoadLibrary("gdbmacros.dll")) {
			LOG("QT Creator's gdbmacros.dll loaded");
		}
		SetErrorMode(olderrors);
	}
#endif

	// Initialize class system
	creg::System::InitializeClasses();

	// Initialize crash reporting
	CrashHandler::Install();

	globalRendering = new CGlobalRendering();

	ParseCmdLine();
	CMyMath::Init();
	good_fpu_control_registers("::Run");

	// log OS version
	LOG("OS: %s", Platform::GetOS().c_str());
	if (Platform::Is64Bit())
		LOG("OS: 64bit native mode");
	else if (Platform::Is32BitEmulation())
		LOG("OS: emulated 32bit mode");
	else
		LOG("OS: 32bit native mode");

	// Rename Threads
	// We give the process itself the name `unknown`, htop & co. will still show the binary's name.
	// But all child threads copy by default the name of their parent, so all threads that don't set
	// their name themselves will show up as 'unknown'.
	Threading::SetThreadName("unknown");
#ifdef _OPENMP
	#pragma omp parallel
	{
		int i = omp_get_thread_num();
		if (i != 0) { // 0 is the source thread
			std::ostringstream buf;
			buf << "omp" << i;
			Threading::SetThreadName(buf.str().c_str());
		}
	}
#endif

	// Install Watchdog
	Watchdog::Install();
	Watchdog::RegisterThread(WDT_MAIN, true);

	FileSystemInitializer::Initialize();

	// Create Window
	if (!InitWindow(("Spring " + SpringVersion::GetSync()).c_str())) {
		SDL_Quit();
		return false;
	}

	mouseInput = IMouseInput::GetInstance();
	keyInput = KeyInput::GetInstance();
	input.AddHandler(boost::bind(&SpringApp::MainEventHandler, this, _1));

	// Global structures
	gs = new CGlobalSynced();
	gu = new CGlobalUnsynced();

	// Initialize GLEW
	LoadExtensions();

	//! check if FSAA init worked fine
	if (globalRendering->FSAA && !MultisampleVerify())
		globalRendering->FSAA = 0;

	InitOpenGL();
	agui::InitGui();
	LoadFonts();

	globalRendering->PostInit();

	// Initialize named texture handler
	CNamedTextures::Init();

	// Initialize Lua GL
	LuaOpenGL::Init();

	// Sound & Input
	ISound::Initialize();
	InitJoystick();

	// Multithreading & Affinity
	LOG("CPU Cores: %d", Threading::GetAvailableCores());
	const uint32_t affinity = configHandler->GetUnsigned("SetCoreAffinity");
	const uint32_t cpuMask  = Threading::SetAffinity(affinity);
	if (cpuMask == 0xFFFFFF) {
		LOG("CPU affinity not set");
	}
	else if (cpuMask != affinity) {
		LOG("CPU affinity mask set: %d (config is %d)", cpuMask, affinity);
	}
	else if (cpuMask == 0) {
		LOG_L(L_ERROR, "Failed to CPU affinity mask <%d>", affinity);
	}
	else {
		LOG("CPU affinity mask set: %d", cpuMask);
	}

	// Create CGameSetup and CPreGame objects
	Startup();

	return true;
}
Пример #24
0
int ModeHandler(int mode, char *textIn, int argc, char **argv)
{
	LcdSpi *lcd;
	Spi *spiBus0;
	ScreenData *screenBg;
	int result = 0;
	Fonts font;
	iconv_t ic;
	size_t res;
	char text[MAX_ISO8859_LEN] = "";
	
	memset(&font, 0, sizeof(Fonts));
	spiBus0 = SpiCreate(0);
	if (spiBus0 == NULL) {
		printf("SPI-Error\n");
		exit(EXITCODE_ERROR);
	}
	lcd = LcdOpen(spiBus0);
	if (!lcd) {
		printf("LCD-Error\n");
		exit(EXITCODE_ERROR);
	}
	if (gConfig.mIsInit == 1) {
		LcdInit(lcd);
	} else if (gConfig.mIsInit == 2) {
		LcdUninit(lcd);
		exit(EXITCODE_OK);
	}
	if (gConfig.mIsBgLight) {
		LcdSetBgLight(lcd, gConfig.mBgLight & 1, gConfig.mBgLight & 2, gConfig.mBgLight & 4);
	}
	screenBg = ScreenInit(LCD_X, LCD_Y);
	if (!screenBg) {
		printf("Screen-Error\n");
		exit(EXITCODE_ERROR);
	}
	ScreenClear(screenBg);
	if (gConfig.mBgFilename) {
		if (ScreenLoadImage(screenBg, gConfig.mBgFilename, gConfig.mBgOffX, gConfig.mBgOffY) != 0) {
			ScreenClear(screenBg);
		}
	}
	
	if (textIn) {
		int testInLen = strlen(textIn);
		char **inPtr = &textIn;
		char *outPtr = &text[0];
		
		ic = iconv_open("ISO-8859-1", "UTF-8");
		if (ic != (iconv_t)(-1)) {
			size_t inBytesLeft = testInLen;
			size_t outBytesLeft = sizeof(text) - 1;
		   
			res = iconv(ic, inPtr, &inBytesLeft, &outPtr, &outBytesLeft);
			if ((int)res != -1 && outBytesLeft) {
				outPtr[0] = 0;
			} else {
				strncpy(text, textIn, sizeof(text) - 1);
				text[sizeof(text) - 1] = 0;
			}
			iconv_close(ic);
		}
	}
	
	//printf("Mode: %i\n", mode);
	switch (mode) {
	case OPT_YESNO:
		LoadFonts(&font);
		result = YesNo(lcd, &font, text, screenBg);
		break;
	case OPT_OK:
		LoadFonts(&font);
		result = Ok(lcd, &font, text, screenBg);
		break;
	case OPT_MENU:
		LoadFonts(&font);
		result = Menu(lcd, &font, screenBg, optind, argc, argv);
		break;
	case OPT_IPV4:
		LoadFonts(&font);
		result = Ipv4(lcd, &font, text, screenBg, optind, argc, argv);
		break;
	case OPT_SUBNETMASK:
		LoadFonts(&font);
		result = Subnetmask(lcd, &font, text, screenBg, optind, argc, argv);
		break;
	case OPT_INFO:
		LoadFonts(&font);
		result = Info(lcd, &font, text, screenBg);
		break;
	case OPT_BUTTONWAIT:
		result = ButtonWait();
		break;
	case OPT_INTINPUT:
		LoadFonts(&font);
		result = IntInput(lcd, &font, text, screenBg, optind, argc, argv);
		break;
	case OPT_PROGRESS:
		LoadFonts(&font);
		result = Progress(lcd, &font, text, screenBg, optind, argc, argv);
		break;
	case OPT_PERCENT:
		LoadFonts(&font);
		result = Percent(lcd, &font, text, screenBg, optind, argc, argv);
		break;
	default:
		break;
	}
	
	if (font.mSystem) {
		//FontDestroy(font.mSystem);
	}
	if (font.mInternal) {
		//FontDestroy(font.mInternal);
	}

	if (gConfig.mIsClear) {
		LcdCls(lcd);
	}
	ScreenDestroy(screenBg);
	LcdCleanup(lcd);
	SpiDestroy(spiBus0);
	
	return result;
}
Пример #25
0
/**
 * @brief Initializes the SpringApp instance
 * @return whether initialization was successful
 */
bool SpringApp::Initialize()
{
#if !(defined(WIN32) || defined(__APPLE__) || defined(HEADLESS))
	//! this MUST run before any other X11 call (esp. those by SDL!)
	//! we need it to make calls to X11 threadsafe
	if (!XInitThreads()) {
		LOG_L(L_FATAL, "Xlib is not thread safe");
		return false;
	}
#endif

#if defined(_WIN32) && defined(__GNUC__)
	// load QTCreator's gdb helper dll; a variant of this should also work on other OSes
	{
		// don't display a dialog box if gdb helpers aren't found
		UINT olderrors = SetErrorMode(SEM_FAILCRITICALERRORS);
		if (LoadLibrary("gdbmacros.dll")) {
			LOG("QT Creator's gdbmacros.dll loaded");
		}
		SetErrorMode(olderrors);
	}
#endif

	// Initialize class system
	creg::System::InitializeClasses();

	// Initialize crash reporting
	CrashHandler::Install();

	globalRendering = new CGlobalRendering();

	ParseCmdLine();
	CMyMath::Init();
	good_fpu_control_registers("::Run");

	Watchdog::Install();
	//! register (this) mainthread
	Watchdog::RegisterThread(WDT_MAIN, true);

	// log OS version
	LOG("OS: %s", Platform::GetOS().c_str());
	if (Platform::Is64Bit())
		LOG("OS: 64bit native mode");
	else if (Platform::Is32BitEmulation())
		LOG("OS: emulated 32bit mode");
	else
		LOG("OS: 32bit native mode");

	FileSystemInitializer::Initialize();

	UpdateOldConfigs();

	if (!InitWindow(("Spring " + SpringVersion::GetSync()).c_str())) {
		SDL_Quit();
		return false;
	}

	mouseInput = IMouseInput::GetInstance();
	keyInput = KeyInput::GetInstance();
	input.AddHandler(boost::bind(&SpringApp::MainEventHandler, this, _1));

	// Global structures
	gs = new CGlobalSynced();
	gu = new CGlobalUnsynced();

	// Initialize GLEW
	LoadExtensions();

	//! check if FSAA init worked fine
	if (globalRendering->FSAA && !MultisampleVerify())
		globalRendering->FSAA = 0;

	InitOpenGL();
	agui::InitGui();
	LoadFonts();

	globalRendering->PostInit();

	// Initialize named texture handler
	CNamedTextures::Init();

	// Initialize Lua GL
	LuaOpenGL::Init();

	// Sound
	ISound::Initialize();
	InitJoystick();

	SetProcessAffinity(configHandler->GetInt("SetCoreAffinity"));

	// Create CGameSetup and CPreGame objects
	Startup();

	return true;
}
Пример #26
0
/**
 * @brief Initializes the SpringApp instance
 * @return whether initialization was successful
 */
bool SpringApp::Initialize()
{
	assert(cmdline != NULL);
	assert(configHandler != NULL);

	// list user's config
	LOG("============== <User Config> ==============");
	const std::map<std::string, std::string> settings = configHandler->GetDataWithoutDefaults();
	for (auto& it: settings) {
		// exclude non-engine configtags
		if (ConfigVariable::GetMetaData(it.first) == nullptr)
			continue;

		LOG("%s = %s", it.first.c_str(), it.second.c_str());
	}
	LOG("============== </User Config> ==============");

	FileSystemInitializer::InitializeLogOutput();
	CLogOutput::LogSystemInfo();
	LOG("         CPU Clock: %s", spring_clock::GetName());
	LOG("Physical CPU Cores: %d", Threading::GetPhysicalCpuCores());
	LOG(" Logical CPU Cores: %d", Threading::GetLogicalCpuCores());
	CMyMath::Init();

	globalRendering = new CGlobalRendering();
	globalRendering->SetFullScreen(configHandler->GetBool("Fullscreen"), cmdline->IsSet("window"), cmdline->IsSet("fullscreen"));

#if !(defined(WIN32) || defined(__APPLE__) || defined(HEADLESS))
	// this MUST run before any other X11 call (esp. those by SDL!)
	// we need it to make calls to X11 threadsafe
	if (!XInitThreads()) {
		LOG_L(L_FATAL, "Xlib is not thread safe");
		return false;
	}
#endif

#if defined(WIN32) && defined(__GNUC__)
	// load QTCreator's gdb helper dll; a variant of this should also work on other OSes
	{
		// don't display a dialog box if gdb helpers aren't found
		UINT olderrors = SetErrorMode(SEM_FAILCRITICALERRORS);
		if (LoadLibrary("gdbmacros.dll")) {
			LOG_L(L_DEBUG, "QT Creator's gdbmacros.dll loaded");
		}
		SetErrorMode(olderrors);
	}
#endif
	// Initialize crash reporting
	CrashHandler::Install();
	good_fpu_control_registers(__FUNCTION__);

	// CREG & GlobalConfig
	creg::System::InitializeClasses();
	GlobalConfig::Instantiate();

	// Create Window
	if (!InitWindow(("Spring " + SpringVersion::GetSync()).c_str())) {
		SDL_Quit();
		return false;
	}

	// Init OpenGL
	LoadExtensions(); // Initialize GLEW
	globalRendering->PostInit();
	InitOpenGL();

	// Install Watchdog (must happen after time epoch is set)
	Watchdog::Install();
	Watchdog::RegisterThread(WDT_MAIN, true);

	// ArchiveScanner uses for_mt --> needs thread-count set
	// (use all threads available, later switch to less)
	ThreadPool::SetThreadCount(ThreadPool::GetMaxThreads());
	FileSystemInitializer::Initialize();

	mouseInput = IMouseInput::GetInstance();
	input.AddHandler(boost::bind(&SpringApp::MainEventHandler, this, _1));

	// Global structures
	gs = new CGlobalSynced();
	gu = new CGlobalUnsynced();

	// GUIs
	agui::InitGui();
	LoadFonts();
	CNamedTextures::Init();
	LuaOpenGL::Init();
	ISound::Initialize();
	InitJoystick();

	// Lua socket restrictions
	luaSocketRestrictions = new CLuaSocketRestrictions();

	// Multithreading & Affinity
	Threading::SetThreadName("unknown"); // set default threadname
	Threading::InitThreadPool();
	Threading::SetThreadScheduler();
	battery = new CBattery();

	// Create CGameSetup and CPreGame objects
	Startup();

	return true;
}
Пример #27
0
void StateControl::Initialize()
{
	cout << endl;
	cout << "* * * * * * * * * * * * *" << endl;
	cout << "*                       *" << endl;
	cout << "*    STARTING RADIO     *" << endl;	
	cout << "*                       *" << endl;
	cout << "* * * * * * * * * * * * *" << endl;
	cout << endl;
	cout << "-------------" << endl;
	cout << "Activity Log:" << endl;
	cout << "-------------" << endl;

	cout << "Getting time seed for random numbers..." << endl;
	srand ((unsigned int) time(NULL));

	cout << "Starting Allegro 5..." << endl;
	if (!al_init())
	{
		al_show_native_message_box(NULL, NULL, "Could not initialize Allegro 5", NULL, NULL, NULL);
	}

	cout << "Initializing addons..." << endl;
	al_init_image_addon();
	al_init_primitives_addon();
	al_init_acodec_addon();
	al_init_font_addon();
	al_init_ttf_addon();
	cout << "Installing devices..." << endl;
	al_install_mouse();
	al_install_keyboard();
	al_install_audio();

	cout << "Creating display..." << endl;
	CreateAllegroDisplay();	
	cout << "Loading fonts..." << endl;
	LoadFonts();

	cout << "Creating timers..." << endl;
	timer = al_create_timer(1.0 / FPS);

	cout << "Creating event queues..." << endl;
	event_queue = al_create_event_queue();

	cout << "Registring event sources..." << endl;
	al_register_event_source(event_queue, al_get_display_event_source(display));
	al_register_event_source(event_queue, al_get_timer_event_source(timer));
	al_register_event_source(event_queue, al_get_mouse_event_source());
	al_register_event_source(event_queue, al_get_keyboard_event_source());	

	cout << "Initializing variables..." << endl;
	left_mouse_button_pressed = false;
	left_mouse_button_released = false;
	right_mouse_button_pressed = false;
	right_mouse_button_released = false;

	playing_music = false;

	possible_double_press = false;
	double_press_counter = 0;

	player_interface_y_coord = 380;
	music_time_counter = 0;

	cout << "Starting timers..." << endl;
	al_start_timer(timer);
}
Пример #28
0
HGameInitError InitGameState(const LoadedGameEntities &ents, GameDataVersion data_ver)
{
    const ScriptAPIVersion base_api = (ScriptAPIVersion)game.options[OPT_BASESCRIPTAPI];
    const ScriptAPIVersion compat_api = (ScriptAPIVersion)game.options[OPT_SCRIPTCOMPATLEV];
    if (data_ver >= kGameVersion_341)
    {
        const char * const scapi_names[] = {"v3.2.1", "v3.3.0", "v3.3.4", "v3.3.5", "v3.4.0", "v3.4.1", "v3.5.0"};
        Debug::Printf(kDbgMsg_Init, "Requested script API: %s (%d), compat level: %s (%d)",
                    base_api >= 0 && base_api <= kScriptAPI_Current ? scapi_names[base_api] : "unknown", base_api,
                    compat_api >= 0 && compat_api <= kScriptAPI_Current ? scapi_names[compat_api] : "unknown", compat_api);
    }
    // If the game was compiled using unsupported version of the script API,
    // we warn about potential incompatibilities but proceed further.
    if (game.options[OPT_BASESCRIPTAPI] > kScriptAPI_Current)
        platform->DisplayAlert("Warning: this game requests a higher version of AGS script API, it may not run correctly or run at all.");

    //
    // 1. Check that the loaded data is valid and compatible with the current
    // engine capabilities.
    //
    if (game.numfonts == 0)
        return new GameInitError(kGameInitErr_NoFonts);
    if (game.audioClipTypeCount > MAX_AUDIO_TYPES)
        return new GameInitError(kGameInitErr_TooManyAudioTypes, String::FromFormat("Required: %d, max: %d", game.audioClipTypeCount, MAX_AUDIO_TYPES));

    //
    // 2. Apply overriding config settings
    //
    // The earlier versions of AGS provided support for "upscaling" low-res
    // games (320x200 and 320x240) to hi-res (640x400 and 640x480
    // respectively). The script API has means for detecting if the game is
    // running upscaled, and game developer could use this opportunity to setup
    // game accordingly (e.g. assign hi-res fonts, etc).
    // This feature is officially deprecated since 3.1.0, however the engine
    // itself still supports it, technically.
    // This overriding option re-enables "upscaling". It works ONLY for low-res
    // resolutions, such as 320x200 and 320x240.
    if (usetup.override_upscale)
    {
        if (game.GetDefaultResolution() == kGameResolution_320x200)
            game.SetDefaultResolution(kGameResolution_640x400);
        else if (game.GetDefaultResolution() == kGameResolution_320x240)
            game.SetDefaultResolution(kGameResolution_640x480);
    }

    //
    // 3. Allocate and init game objects
    //
    charextra = (CharacterExtras*)calloc(game.numcharacters, sizeof(CharacterExtras));
    charcache = (CharacterCache*)calloc(1,sizeof(CharacterCache)*game.numcharacters+5);
    mls = (MoveList*)calloc(game.numcharacters + MAX_ROOM_OBJECTS + 1, sizeof(MoveList));
    actSpsCount = game.numcharacters + MAX_ROOM_OBJECTS + 2;
    actsps = (Bitmap **)calloc(actSpsCount, sizeof(Bitmap *));
    actspsbmp = (IDriverDependantBitmap**)calloc(actSpsCount, sizeof(IDriverDependantBitmap*));
    actspswb = (Bitmap **)calloc(actSpsCount, sizeof(Bitmap *));
    actspswbbmp = (IDriverDependantBitmap**)calloc(actSpsCount, sizeof(IDriverDependantBitmap*));
    actspswbcache = (CachedActSpsData*)calloc(actSpsCount, sizeof(CachedActSpsData));
    play.charProps.resize(game.numcharacters);
    HError err = InitAndRegisterGameEntities();
    if (!err)
        return new GameInitError(kGameInitErr_EntityInitFail, err);
    LoadFonts();

    //
    // 4. Initialize certain runtime variables
    //
    game_paused = 0;  // reset the game paused flag
    ifacepopped = -1;

    if (game.saveGameFileExtension[0] != 0)
        saveGameSuffix.Format(".%s", game.saveGameFileExtension);
    else
        saveGameSuffix = "";

    play.score_sound = game.scoreClipID;
    play.fade_effect = game.options[OPT_FADETYPE];

    //
    // 5. Initialize runtime state of certain game objects
    //
    for (int i = 0; i < numguilabels; ++i)
    {
        // labels are not clickable by default
        guilabels[i].SetClickable(false);
    }
    play.gui_draw_order = (int*)calloc(game.numgui * sizeof(int), 1);
    update_gui_zorder();
    calculate_reserved_channel_count();

    //
    // 6. Register engine API exports
    // NOTE: we must do this before plugin start, because some plugins may
    // require access to script API at initialization time.
    //
    ccSetScriptAliveTimer(150000);
    ccSetStringClassImpl(&myScriptStringImpl);
    setup_script_exports(base_api, compat_api);

    //
    // 7. Start up plugins
    //
    pl_register_plugins(ents.PluginInfos);
    pl_startup_plugins();

    //
    // 8. Create script modules
    // NOTE: we must do this after plugins, because some plugins may export
    // script symbols too.
    //
    gamescript = ents.GlobalScript;
    dialogScriptsScript = ents.DialogScript;
    numScriptModules = ents.ScriptModules.size();
    scriptModules = ents.ScriptModules;
    AllocScriptModules();
    if (create_global_script())
        return new GameInitError(kGameInitErr_ScriptLinkFailed, ccErrorString);

    return HGameInitError::None();
}
Пример #29
0
/**
**  The main program: initialise, parse options and arguments.
**
**  @param argc  Number of arguments.
**  @param argv  Vector of arguments.
*/
int main(int argc, char **argv)
{
#ifdef REDIRECT_OUTPUT
	RedirectOutput();
#endif

#ifdef USE_BEOS
	//  Parse arguments for BeOS
	beos_init(argc, argv);
#endif

	//  Setup some defaults.
#ifndef MAC_BUNDLE
	StratagusLibPath = ".";
#else
	freopen("/tmp/stdout.txt", "w", stdout);
	freopen("/tmp/stderr.txt", "w", stderr);
	// Look for the specified data set inside the application bundle
	// This should be a subdir of the Resources directory
	CFURLRef pluginRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(),
												 CFSTR(MAC_BUNDLE_DATADIR), NULL, NULL);
	CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef,  kCFURLPOSIXPathStyle);
	const char *pathPtr = CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding());
	Assert(pathPtr);
	StratagusLibPath = pathPtr;
#endif

	Parameters &parameters = Parameters::Instance;
	parameters.SetDefaultValues();
	parameters.LocalPlayerName = GetLocalPlayerNameFromEnv();

	if (argc > 0) {
		parameters.applicationName = argv[0];
	}

	// FIXME: Parse options before or after scripts?
	ParseCommandLine(argc, argv, parameters);
	// Init the random number generator.
	InitSyncRand();

	makedir(parameters.GetUserDirectory().c_str(), 0777);

	// Init Lua and register lua functions!
	InitLua();
	LuaRegisterModules();

	// Initialise AI module
	InitAiModule();

	LoadCcl(parameters.luaStartFilename);

	PrintHeader();
	PrintLicense();

	// Setup video display
	InitVideo();

	// Setup sound card
	if (!InitSound()) {
		InitMusic();
	}

#ifndef DEBUG           // For debug it's better not to have:
	srand(time(NULL));  // Random counter = random each start
#endif

	//  Show title screens.
	SetDefaultTextColors(FontYellow, FontWhite);
	LoadFonts();
	SetClipping(0, 0, Video.Width - 1, Video.Height - 1);
	Video.ClearScreen();
	ShowTitleScreens();

	// Init player data
	ThisPlayer = NULL;
	//Don't clear the Players strucure as it would erase the allowed units.
	// memset(Players, 0, sizeof(Players));
	NumPlayers = 0;

	UnitManager.Init(); // Units memory management
	PreMenuSetup();     // Load everything needed for menus

	MenuLoop();

	Exit(0);
	return 0;
}
Пример #30
0
//------------------------------------------------------------------------
// InitGame()
//------------------------------------------------------------------------
void InitGame (void)
{
	Sint16                     i,x,y;
	Uint16        *blockstart;
//long mmsize;

	MM_Startup ();                  // so the signon screen can be freed
#if IN_DEVELOPMENT || GEORGE_CHEAT || SHOW_CHECKSUM
	if (MS_CheckParm("checksum"))
	{
		ShowChecksums();
		MM_Shutdown();
		exit(0);
	}
#endif
	CA_Startup ();

// Any problems with this version of the game?
//
#if IN_DEVELOPMENT || TECH_SUPPORT_VERSION
	if (!MS_CheckParm("nochex"))
#endif

#if !SKIP_CHECKSUMS
		CheckValidity("MAPTEMP.",MAPTEMP_CHECKSUM);

#if GAME_VERSION != SHAREWARE_VERSION
	if (ChecksumFile("FILE_ID.DIZ",0) != DIZFILE_CHECKSUM)
		gamestate.flags |= GS_BAD_DIZ_FILE;
#endif
#endif

	VL_SetVGAPlaneMode ();
	VL_SetPalette (0,256,vgapal);

	VW_Startup ();
	IN_Startup ();
	PM_Startup ();
	SD_Startup ();
	US_Startup ();

	if (CheckForSpecialCode(POWERBALLTEXT))
#if IN_DEVELOPMENT
		DebugOk = true;
#else
		PowerBall = true;
#endif

	if (CheckForSpecialCode(TICSTEXT))
		gamestate.flags |= GS_TICS_FOR_SCORE;

	if (CheckForSpecialCode(MUSICTEXT))
		gamestate.flags |= GS_MUSIC_TEST;

	if (CheckForSpecialCode(RADARTEXT))
		gamestate.flags |= GS_SHOW_OVERHEAD;

#if IN_DEVELOPMENT
	//
	// Clear Monocrome
	//
	_fmemset(MK_FP(0xb000,0x0000),0,4000);
#endif

//
// build some tables
//
	InitDigiMap ();

	for (i=0;i<MAPSIZE;i++)
	{
		nearmapylookup[i] = &tilemap[0][0]+MAPSIZE*i;
		farmapylookup[i] = i*64;
	}

	for (i=0;i<PORTTILESHIGH;i++)
		uwidthtable[i] = UPDATEWIDE*i;

	blockstart = &blockstarts[0];
	for (y=0;y<UPDATEHIGH;y++)
		for (x=0;x<UPDATEWIDE;x++)
			*blockstart++ = SCREENWIDTH*16*y+x*TILEWIDTH;

	updateptr = &update[0];

	bufferofs = 0;
	displayofs = 0;
	ReadConfig ();

//
// draw intro screen stuff
//
//	if (!(gamestate.flags & GS_QUICKRUN))
//		IntroScreen ();

//
// load in and lock down some basic chunks
//

	LoadFonts();

	LoadLatchMem ();
	BuildTables ();          // trig tables
	SetupWalls ();
	NewViewSize ();

//
// initialize variables
//
	InitRedShifts ();
}