void
CmdIntelDlg::OnPlay(AWEvent* e)
{
	CombatEvent* event = 0;
	int          index = lst_news->GetSelection();

	if (index >= 0) {
		event = (CombatEvent*) lst_news->GetItemData(index, 0);
	}

	if (mov_news && cam_view && event && event->SceneFile() && *event->SceneFile()) {
		event_scene = event->SceneFile();
		start_scene = 2;
		ShowMovie();
	}
}
Exemplo n.º 2
0
/******************************Public*Routine******************************\
* CloseMovie
*
\**************************************************************************/
DWORD//
CMpegMovie::CloseMovie(
    )
{
	m_Mode = MOVIE_NOTOPENED;

	if ( m_bWin9xCompatible ) {

		ShowMovie( FALSE );


		if(m_Mc)
		{
			if(m_Me)
			{
				m_Me->SetNotifyWindow(NULL, 0, 0);
            m_Me->Release();
            m_Me = NULL;
			}

			if(m_Ms)
			{
            m_Ms->Release();
            m_Ms = NULL;
			}


			if (m_Bv)
			{
				m_Bv->Release();
				m_Bv = NULL;
			}

			if (m_Vw)
			{
				m_Vw->put_Owner(NULL);
				m_Vw->put_MessageDrain(NULL);
				m_Vw->Release();
				m_Vw = NULL;
			}

			if (m_Ba)
			{
				m_Ba->Release();
				m_Ba = NULL;
			}


			m_Mc->Release();
			m_Mc = NULL;

			if(m_Gb)
			{
				m_Gb->Release();
            m_Gb = NULL;
			}

		}

		QzUninitialize();
		return 0L;

	}	else {

		if ( m_pDdcc ) m_pDdcc->Release();

		if(m_Mc)
		{
			if(m_Me)
			{
				m_Me->SetNotifyWindow(NULL, 0, 0);
            m_Me->Release();
            m_Me = NULL;
			}

        if(m_Ms)
        {
            m_Ms->Release();
            m_Ms = NULL;
        }

        if(m_Wc)
        {
            m_Wc->Release();
            m_Wc = NULL;
        }

 			if (m_Ba)
			{
				m_Ba->Release();
				m_Ba = NULL;
			}


        m_Mc->Release();
        m_Mc = NULL;

        if(m_Gb)
        {
            m_Gb->Release();
            m_Gb = NULL;
        }

        if(m_Fg)
        {
            m_Fg->Release();
            m_Fg = NULL;
        }
    }

    QzUninitialize();
    return 0L;

	}
}
Exemplo n.º 3
0
bool Application::Birth()
{
	CoInitializeEx(NULL,NULL);
	Globals.Exiting	=	false;
	srand(GetTickCount());
	Input::I = new Input::Input_t;
	//===[ КОНФИГУРАЦИЯ ]===========================================================================
		ReadConfig();
	//===[ КОНФИГУРАЦИЯ ]===========================================================================	
	CCons.INIT();
#ifdef WIN32
	WNDCLASSEX wc;
	DWORD dwExStyle;
	DWORD dwStyle;
	RECT WindowRect;

	WindowRect.left = 0L;
	WindowRect.top	= 0L;
	WindowRect.right = Globals.VP.Width;
	WindowRect.bottom = Globals.VP.Height;

	Application::Vars.App.HInstance = GetModuleHandle(NULL);
	memset(&wc,0,sizeof(WNDCLASSEX));
	wc.cbSize = sizeof(WNDCLASSEX);
	wc.style = CS_HREDRAW|CS_VREDRAW|CS_OWNDC;
	wc.lpfnWndProc = (WNDPROC) WndProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = Application::Vars.App.HInstance;
	wc.hIcon = LoadIcon(Application::Vars.App.HInstance,MAKEINTRESOURCE(IDI_ICON1));
	wc.hIconSm = LoadIcon(Application::Vars.App.HInstance,MAKEINTRESOURCE(IDI_ICON1));
	wc.hCursor = LoadCursor(0, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+2);//NULL;
	wc.lpszMenuName  = NULL;
	wc.lpszClassName = MY_WINDOW_CLASS_NAME;

	FASSERT(RegisterClassEx(&wc));
	if(IsFullScreen)
	{
		EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&Application::Vars.win.PrevDS);
		memset(&Application::Vars.win.CurrDS, 0, sizeof(Application::Vars.win.CurrDS));
		Application::Vars.win.CurrDS.dmSize = sizeof(Application::Vars.win.CurrDS);
		Application::Vars.win.CurrDS.dmPelsWidth = Globals.VP.Width;
		Application::Vars.win.CurrDS.dmPelsHeight = Globals.VP.Height;
		Application::Vars.win.CurrDS.dmBitsPerPel = Globals.VP.Bits;
		Application::Vars.win.CurrDS.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT|DM_DISPLAYFREQUENCY;
		Application::Vars.win.CurrDS.dmDisplayFrequency=Globals.VP.Hzs;

		if(ChangeDisplaySettings(&Application::Vars.win.CurrDS,CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
		{
			if(MessageBox(0, "Cannot run in fullscreen mode!\nRun in window?",
				"Hardware trouble!", MB_YESNO|MB_ICONEXCLAMATION) == IDYES)
			{
				IsFullScreen = false;
			}
			else 
			{
				MessageBox(0, "OK!!! I'm quit...", "!!!", MB_OK | MB_ICONQUESTION);
				PostQuitMessage(1);
				return NO_ERROR;
			};
		};
	};

	if(IsFullScreen)
	{
			dwExStyle	= WS_EX_APPWINDOW/* | WS_EX_TOPMOST*/; // WS_EX_TOPMOST - Поверх всех окон
			dwStyle		= WS_POPUP;
	}
	else
	{
// ВНИМАНИЕ Здесь обнаружены глюки при использовании nView от nVidia!
			dwExStyle	= WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
			dwStyle		= WS_OVERLAPPEDWINDOW;
	};
	ShowCursor(false);
	AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);
	if (WindowRect.left < 0)
		WindowRect.right -= WindowRect.left,WindowRect.left = 0;
	if (WindowRect.top < 0)
		WindowRect.bottom -= WindowRect.top,WindowRect.top = 0;
	Application::Vars.win.MHWnd =
			CreateWindowEx(		dwExStyle, 
								MY_WINDOW_CLASS_NAME,
								MY_WINDOW_NAME,
								dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
								WindowRect.left,
								WindowRect.top,
								WindowRect.right - WindowRect.left,
								WindowRect.bottom - WindowRect.top,
								NULL,
								NULL,
								GetModuleHandle(0),
								NULL
								);
	FASSERT(Application::Vars.win.MHWnd);
	ShowWindow(Application::Vars.win.MHWnd, SW_SHOW);
	SetForegroundWindow(Application::Vars.win.MHWnd);
	SetFocus(Application::Vars.win.MHWnd);

	// Получаем контекст устройства
	Application::Vars.win.DC = GetDC(Application::Vars.win.MHWnd);
		FASSERT(Application::Vars.win.DC);
	// Установка формата пикселей
		PIXELFORMATDESCRIPTOR mainPFD;
		memset(&mainPFD,0,sizeof(PIXELFORMATDESCRIPTOR));
		mainPFD.nSize			= sizeof(PIXELFORMATDESCRIPTOR);
		mainPFD.nVersion		= 1;
		mainPFD.iPixelType		= PFD_TYPE_RGBA;
		mainPFD.dwFlags			= PFD_DRAW_TO_WINDOW |PFD_DOUBLEBUFFER |PFD_SUPPORT_OPENGL;
		mainPFD.iLayerType		= PFD_MAIN_PLANE;
		mainPFD.cDepthBits		=	16;
		int PF;
		PF = ChoosePixelFormat(Application::Vars.win.DC,&mainPFD);
		FASSERT(PF);	// Выбрали!
		FASSERT(SetPixelFormat(Application::Vars.win.DC,PF,&mainPFD));			// Поставили!
	// Создание контекста рендера
		Application::Vars.win.RC = wglCreateContext (Application::Vars.win.DC);
		FASSERT(Application::Vars.win.RC);
	// Установка полученого контекста главным
		FASSERT(wglMakeCurrent (Application::Vars.win.DC, Application::Vars.win.RC));
#else
		dpy = XOpenDisplay(0);						// Открываем дисплей по-умолчанию (может быть сетевой)
		vi = glXChooseVisual(	dpy,				// Получаем подходящий визуал
								DefaultScreen(dpy),
								attributeList);
		cx = glXCreateContext(dpy, vi, 0, GL_TRUE);	// Создание контекста
		// create	a color	map
		cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen),
				 vi->visual, AllocNone);
		// Создаём окно
		swa.colormap = cmap;
		swa.border_pixel = 0;
		swa.event_mask = StructureNotifyMask;
		win = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 100, 100,
			  0, vi->depth,	InputOutput, vi->visual,
			  CWBorderPixel|CWColormap|CWEventMask,	&swa);
		XMapWindow(dpy, win);
		XIfEvent(dpy, &event, WaitForNotify, (char*)win);

		
		glXMakeCurrent(dpy, win, cx);				// Привязка контекста к окну
#endif
		GetSysInfo();
#ifndef	_DEBUG
		if (AVIp.Open("data/VIDEO/logo.avi") == FJC_NO_ERROR)
		{
			AVIp.Caching();
			GT.Start();
			ShowMovie(true);
			AVIp.CloseAVI();
		}
		else
		{
			LF.Logf("Birth","Невозможно загрузить и проиграть заставку");
		}
#endif
	// Инициализация библиотек и глобальных объектов
		InitOpenGL();						// Графика - OpenGL
		LF.Log("BIRTH","Init OpenGL complete");
		InitOpenIL();						// Поддержка изображений - OpenIL(DevIL)
		LF.Log("BIRTH","Init OpenIL complete");
// инициализация менеджера ресурсов		
		rm.INIT("Consolas.LFont","default.png","cube.lwo");
		CCons.SetFont(rm.SELECT_Font("Console"));

		SimpleLogo.init(&SwapBuffersEXT,IL_PNG,"data/textures/Logos/NewLOGO.PNG");
		SimpleLogo.render_logo(FJC_STARTUP_LOGO_MODE_BEGIN);
		rm.SELECT_Font("Courier")->SetColor(1,0,0);
		SimpleLogo.render_logo(	FJC_STARTUP_LOGO_MODE_PROCEED_WITH_TEXT,1,
								TextBlock(rm.SELECT_Font("Consolas"),"Now loading, please wait",250.0f,300.0f));
		Sound.Init();
		TestBuf.Init();
		TestBuf.LoadWav("data/sounds/KDE_Startup_new2.wav");
		TestSource.Init();
		TestSource.LinkWithBufer(&TestBuf);
		LF.Log("BIRTH","Init OpenAL complete");
		InitMATH();							// Математическая библиотека
		LF.Log("BIRTH","InitMATH");
		LF.Msg("Init complete");
		LoadResources();
		PS.INIT();
	return NO_ERROR;
};
void
CmdIntelDlg::ExecFrame()
{
	CmdDlg::ExecFrame();

	if (campaign != Campaign::GetCampaign() || campaign->GetUpdateTime() != update_time) {
		campaign    = Campaign::GetCampaign();
		update_time = campaign->GetUpdateTime();

		lst_news->ClearItems();
		txt_news->SetText("");

		if (img_news)
		img_news->SetPicture(bmp_default);
	}

	if (campaign) {
		List<CombatEvent>& events      = campaign->GetEvents();
		bool               auto_scroll = false;

		if (events.size() > lst_news->NumItems()) {
			while (events.size() > lst_news->NumItems()) {
				CombatEvent* info = events[lst_news->NumItems()];

				const char* unread = info->Visited() ? " " : "*";
				int i = lst_news->AddItemWithData(unread, (DWORD) info) - 1;

				char dateline[32];
				FormatDayTime(dateline, info->Time());
				lst_news->SetItemText(i, 1, dateline);
				lst_news->SetItemText(i, 2, info->Title());
				lst_news->SetItemText(i, 3, info->Region());
				lst_news->SetItemText(i, 4, Game::GetText(info->SourceName()));

				if (!info->Visited())
				auto_scroll = true;
			}

			if (lst_news->GetSortColumn() > 0)
			lst_news->SortItems();
		}

		else if (events.size() < lst_news->NumItems()) {
			lst_news->ClearItems();

			for (int i = 0; i < events.size(); i++) {
				CombatEvent* info = events[i];

				const char* unread = info->Visited() ? " " : "*";
				int j = lst_news->AddItemWithData(unread, (DWORD) info) - 1;

				char dateline[32];
				FormatDayTime(dateline, info->Time());
				lst_news->SetItemText(j, 1, dateline);
				lst_news->SetItemText(j, 2, info->Title());
				lst_news->SetItemText(j, 3, info->Region());
				lst_news->SetItemText(j, 4, Game::GetText(info->SourceName()));

				if (!info->Visited())
				auto_scroll = true;
			}

			if (lst_news->GetSortColumn() > 0)
			lst_news->SortItems();

			txt_news->SetText("");

			if (img_news)
			img_news->SetPicture(bmp_default);
		}

		if (auto_scroll) {
			int first_unread = -1;

			for (int i = 0; i < lst_news->NumItems(); i++) {
				if (lst_news->GetItemText(i, 0) == "*") {
					first_unread = i;
					break;
				}
			}

			if (first_unread >= 0)
			lst_news->ScrollTo(first_unread);
		}
	}

	Starshatter* stars = Starshatter::GetInstance();

	if (start_scene > 0) {
		ShowMovie();

		start_scene--;

		if (start_scene == 0) {
			if (stars && campaign) {
				stars->ExecCutscene(event_scene, campaign->Path());

				if (stars->InCutscene()) {
					Sim* sim = Sim::GetSim();

					if (sim) {
						cam_view->UseCamera(CameraDirector::GetInstance()->GetCamera());
						cam_view->UseScene(sim->GetScene());
					}
				}
			}

			event_scene = "";
		}
	}
	else {
		if (dsp_view)
		dsp_view->ExecFrame();

		if (stars->InCutscene())
		ShowMovie();
		else
		HideMovie();
	}
}
int main(int argc, char* args[])
{
		//Please Read Note above at top.
		char line, ch;
		char **CurrentWorld;
		int position;
		int maxTicks, rows, columns, i, j;
        int SCREEN_WIDTH, SCREEN_HEIGHT, rectH, rectW, noRect;
        		
        //Read textfile
		CurrentWorld = readWorld(&rows, &columns, &maxTicks);
        
		//SCREEN_WIDTH = 600;
        //SCREEN_HEIGHT = 600;
        //the window must be calculated by the number of rows and columns
        //whilst having some spcae as a buffer 
        ///It must also be divisible  by 10 ie be a whole number
        
        //buffer of 5 will be filled by a border set of squares
        SCREEN_WIDTH = (columns + (columns%10)+1)*10;
        SCREEN_HEIGHT = (rows + (rows%10)+1)*10;
        
        //work our rectangle dimensions
        //noRect = columns*rows;
        rectW = columns;
        rectH = rows;
        
		//SDL World Primitives
        SDL_Rect Rect;
		SDL_Surface* screen;
		SDL_Event event;
		Uint32 flags = SDL_SWSURFACE|SDL_FULLSCREEN;
        
		//Start SDL 
		SDL_Init( SDL_INIT_EVERYTHING ); 
		screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_SWSURFACE );
		//This will not draw directly to the sceen. You must call flip to actually see the results of the drawing
		SDL_FillRect(screen,&Rect,SDL_MapRGB(screen->format,255,255,255));
		//Call this to write a caption to screen
		SDL_WM_SetCaption ("Stable world!", NULL);
		
		//You must have this or SDL will crash whenever user input is detected
		SDL_PollEvent (&event);
		//To ensure that the quit box at the top of your window works
		switch (event.type)
		{
			case SDL_QUIT:
				exit(0);
			//case 
		}
        
		//3d array to hold all worlds
		char ***CompleteWorld = (char***)malloc(maxTicks*sizeof(char(**)));; 
		//initialise and allocate the second part of the array ie number of columns per row
		for(i = 1; i < maxTicks; i++)
		{
			CompleteWorld[i] = (char**) malloc(rows*sizeof(char*));
			for(j=0; j<rows; j++)
			{
				CompleteWorld[i][j] = (char*) malloc(columns*sizeof(char));
			}
		}
    	
    	//add to first entry of CompleteWorld
    	CompleteWorld[0] = CurrentWorld;
	    
        //display the movie
        ShowMovie(CompleteWorld, maxTicks, rows, columns, screen, &Rect, rectH, rectW);
        //free memory
        for(i = 0; i < maxTicks; i++)
		{
			free(CompleteWorld[i]);
			for(j=0; j<rows; j++)
			{
				free(CompleteWorld[i][j]);
			}
		}
		SDL_Quit(); 
		
		return 0;
        
}