Esempio n. 1
0
// Create a frame for each player to display their current fleet in,
// to be used when selecting the next ship to fight with.
void
BuildPickMeleeFrame (void)
{
	STAMP s;
	CONTEXT	OldContext = SetContext (OffScreenContext);

	if (PickMeleeFrame)
		DestroyDrawable (ReleaseDrawable (PickMeleeFrame));

	PickMeleeFrame = CaptureDrawable (CreateDrawable (
			WANT_PIXMAP, MELEE_WIDTH, MELEE_HEIGHT, 2));
	s.origin.x = 0;
	s.origin.y = 0;

	s.frame = CaptureDrawable (LoadGraphic (MELEE_PICK_MASK_PMAP_ANIM));
	SetContextFGFrame (PickMeleeFrame);
	DrawStamp (&s);

	s.frame = IncFrameIndex (s.frame);
	SetContextFGFrame (IncFrameIndex (PickMeleeFrame));
	DrawStamp (&s);

	DestroyDrawable (ReleaseDrawable (s.frame));

	SetContext (OldContext);
}
Esempio n. 2
0
void
free_ship (RACE_DESC *raceDescPtr, BOOLEAN FreeIconData,
           BOOLEAN FreeBattleData)
{
    if (raceDescPtr->uninit_func != NULL)
        (*raceDescPtr->uninit_func) (raceDescPtr);

    if (FreeBattleData)
    {
        DATA_STUFF *shipData = &raceDescPtr->ship_data;

        free_image (shipData->special);
        free_image (shipData->weapon);
        free_image (shipData->ship);

        DestroyDrawable (
            ReleaseDrawable (shipData->captain_control.background));
        DestroyMusic (shipData->victory_ditty);
        DestroySound (ReleaseSound (shipData->ship_sounds));
    }

    if (FreeIconData)
    {
        SHIP_INFO *shipInfo = &raceDescPtr->ship_info;

        DestroyDrawable (ReleaseDrawable (shipInfo->melee_icon));
        DestroyDrawable (ReleaseDrawable (shipInfo->icons));
        DestroyStringTable (ReleaseStringTable (shipInfo->race_strings));
    }

    DestroyCodeRes (ReleaseCodeRes (raceDescPtr->CodeRef));
}
Esempio n. 3
0
PUBLIC void
glXDestroyWindow(Display * dpy, GLXWindow win)
{
   WARN_ONCE_GLX_1_3(dpy, __func__);

   DestroyDrawable(dpy, (GLXDrawable) win, X_GLXDestroyWindow);
}
Esempio n. 4
0
File: init.c Progetto: intgr/sc2-uqm
/* Warning: Some ships (such as the Umgah) will alias their pixarrays,
   so we need to track to make sure that we do not double-free. */
BOOLEAN
free_image (FRAME *pixarray)
{
	BOOLEAN retval;
	COUNT i, j;
	void *already_freed[NUM_VIEWS];

	retval = TRUE;
	for (i = 0; i < NUM_VIEWS; ++i)
	{
		if (pixarray[i] != NULL)
		{
			BOOLEAN ok = TRUE;
			for (j = 0; j < i; j++)
			{
				if (already_freed[j] == pixarray[i])
				{
					ok = FALSE;
					break;
				}
			}
			if (ok)
			{
				if (!DestroyDrawable (ReleaseDrawable (pixarray[i])))
					retval = FALSE;
			}
			already_freed[i] = pixarray[i];
			pixarray[i] = NULL;
		}
	}

	return (retval);
}
Esempio n. 5
0
PUBLIC void
glXDestroyPixmap(Display * dpy, GLXPixmap pixmap)
{
   WARN_ONCE_GLX_1_3(dpy, __func__);

   DestroyDrawable(dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap);
}
void
UninitOscilloscope (void)
{
	// XXX: Is never called (BUG?)
	DestroyDrawable (ReleaseDrawable (scopeWork));
	scopeWork = NULL;
	scope_init = 0;
}
Esempio n. 7
0
PUBLIC void
glXDestroyWindow(Display * dpy, GLXWindow win)
{
   WARN_ONCE_GLX_1_3(dpy, __func__);
#ifndef GLX_USE_APPLEGL
   DestroyDrawable(dpy, (GLXDrawable) win, X_GLXDestroyWindow);
#endif
}
Esempio n. 8
0
void
FreeLanderFont (PLANET_INFO *info)
{
	DestroyFont (info->LanderFont);
	info->LanderFont = NULL;
	DestroyDrawable (ReleaseDrawable (info->LanderFontEff));
	info->LanderFontEff = NULL;
}
Esempio n. 9
0
static void
DrawOrbitalDisplay (DRAW_ORBITAL_MODE Mode)
{
	RECT r;

	SetContext (SpaceContext);
	GetContextClipRect (&r);

	BatchGraphics ();
	
	if (Mode != DRAW_ORBITAL_UPDATE)
	{
		SetTransitionSource (NULL);

		DrawSISFrame ();
		DrawSISMessage (NULL);
		DrawSISTitle (GLOBAL_SIS (PlanetName));
		DrawStarBackGround ();
		DrawPlanetSurfaceBorder ();
	}

	if (Mode == DRAW_ORBITAL_WAIT)
	{
		STAMP s;

		SetContext (GetScanContext (NULL));
		s.frame = CaptureDrawable (LoadGraphic (ORBENTER_PMAP_ANIM));
		s.origin.x = -SAFE_X;
		s.origin.y = 0;
		DrawStamp (&s);
		DestroyDrawable (ReleaseDrawable (s.frame));
	}
	else if (Mode == DRAW_ORBITAL_FULL)
	{
		DrawDefaultPlanetSphere ();
	}

	if (Mode != DRAW_ORBITAL_WAIT)
	{
		SetContext (GetScanContext (NULL));
		DrawPlanet (0, BLACK_COLOR);
	}

	if (Mode != DRAW_ORBITAL_UPDATE)
	{
		ScreenTransition (3, &r);
	}

	UnbatchGraphics ();

	// for later RepairBackRect()
	// JMS_GFX
	if (RESOLUTION_FACTOR == 0)
		LoadIntoExtraScreen (&r);
	else
		LoadIntoExtraScreen_Fs (&r);
}
Esempio n. 10
0
void
SplashScreen (void (* DoProcessing)(DWORD TimeOut))
{
	BYTE xform_buf[1];
	STAMP s;
	DWORD TimeOut;
	BOOLEAN InputState;

	xform_buf[0] = FadeAllToBlack;
	SleepThreadUntil (XFormColorMap (
			(COLORMAPPTR) xform_buf, ONE_SECOND / 120));
	LockMutex (GraphicsLock);
	SetContext (ScreenContext);
	s.origin.x = s.origin.y = 0;
	s.frame = CaptureDrawable (LoadGraphic (TITLE_ANIM));
	DrawStamp (&s);
	DestroyDrawable (ReleaseDrawable (s.frame));
	UnlockMutex (GraphicsLock);

	xform_buf[0] = FadeAllToColor;
	TimeOut = XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2);

	if (DoProcessing)
		DoProcessing (TimeOut);
	if (GLOBAL (CurrentActivity) & CHECK_ABORT)
	{
		return;
	}
	
	/* There was a forcible setting of CHECK_ABORT here.  I cannot
	 * find any purpose for this that DoRestart doesn't handle
	 * better (forcing all other threads but this one to quit out,
	 * I believe), and have thus removed it.  It was interfering
	 * with the proper operation of the quit operation.
	 * --Michael */

	TimeOut += ONE_SECOND * 3;
	while (!(InputState = AnyButtonPress (FALSE)) &&
	       (GetTimeCounter () <= TimeOut) &&
	       !(GLOBAL (CurrentActivity) & CHECK_ABORT))
	{
		TaskSwitch ();
	}
	if (GLOBAL (CurrentActivity) & CHECK_ABORT)
	{
		return;
	}
	GLOBAL (CurrentActivity) &= ~CHECK_ABORT;

	/* You can't try to quit during a fade to black, because if
	 * you try, the confirmation window will fade to black too.
	 * Fixing this will require a rewrite of our whole rendering
	 * engine. -- Michael */
	xform_buf[0] = FadeAllToBlack;
	SleepThreadUntil (XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2));
}
Esempio n. 11
0
void
free_gravity_well (void)
{
	COUNT i;

	for (i = 0; i < NUM_VIEWS; ++i)
	{
		DestroyDrawable (ReleaseDrawable (planet[i]));
		planet[i] = 0;
	}
}
Esempio n. 12
0
PUBLIC void
glXDestroyPixmap(Display * dpy, GLXPixmap pixmap)
{
   WARN_ONCE_GLX_1_3(dpy, __func__);
#ifdef GLX_USE_APPLEGL
   if (apple_glx_pixmap_destroy(dpy, pixmap))
      __glXSendError(dpy, GLXBadPixmap, pixmap, X_GLXDestroyPixmap, false);
#else
   DestroyDrawable(dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap);
#endif
}
Esempio n. 13
0
static void
UninitKernel (BOOLEAN ships)
{
	UninitSpace ();

	DestroySound (ReleaseSound (MenuSounds));
	DestroyFont (MicroFont);
	DestroyStringTable (ReleaseStringTable (GameStrings));
	DestroyDrawable (ReleaseDrawable (StatusFrame));
	DestroyDrawable (ReleaseDrawable (ActivityFrame));
	DestroyFont (TinyFont);
	DestroyFont (StarConFont);

	UninitQueue (&race_q[0]);
	UninitQueue (&race_q[1]);

	if (ships)
		FreeMasterShipList ();
	
	ActivityFrame = 0;
}
Esempio n. 14
0
File: init.c Progetto: intgr/sc2-uqm
void
UninitSpace (void)
{
	if (space_ini_cnt && --space_ini_cnt == 0)
	{
		free_image (blast);
		free_image (explosion);
		free_image (asteroid);

		DestroyDrawable (ReleaseDrawable (stars_in_space));
		stars_in_space = 0;
	}
}
Esempio n. 15
0
static void
DrawOrbitalDisplay (DRAW_ORBITAL_MODE Mode)
{
    RECT r = { { SIS_ORG_X, SIS_ORG_Y },
        { SIS_SCREEN_WIDTH, SIS_SCREEN_HEIGHT }
    };

    BatchGraphics ();

    if (Mode != DRAW_ORBITAL_UPDATE)
    {
        SetTransitionSource (NULL);

        DrawSISFrame ();
        DrawSISMessage (NULL_PTR);
        DrawSISTitle (GLOBAL_SIS (PlanetName));
        DrawStarBackGround (TRUE);
    }

    SetContext (SpaceContext);

    if (Mode == DRAW_ORBITAL_WAIT)
    {
        STAMP s;

        s.frame = CaptureDrawable (
                      LoadGraphic (ORBENTER_PMAP_ANIM));
        s.origin.x = -SAFE_X;
        s.origin.y = SIS_SCREEN_HEIGHT - MAP_HEIGHT;
        DrawStamp (&s);
        DestroyDrawable (ReleaseDrawable (s.frame));
    }
    else
    {
        DrawPlanet (SIS_SCREEN_WIDTH - MAP_WIDTH,
                    SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, 0);
    }

    if (Mode != DRAW_ORBITAL_UPDATE)
    {
        ScreenTransition (3, &r);
    }

    UnbatchGraphics ();

    if (Mode != DRAW_ORBITAL_WAIT)
    {
        LoadIntoExtraScreen (&r);
    }
}
Esempio n. 16
0
BOOLEAN
DoSaveTeam (MELEE_STATE *pMS)
{
	STAMP MsgStamp;
	char file[NAME_MAX];
	uio_Stream *stream;
	CONTEXT OldContext;
	bool saveOk = false;

	snprintf (file, sizeof file, "%s.mle",
			MeleeSetup_getTeamName (pMS->meleeSetup, pMS->side));

	LockMutex (GraphicsLock);
	OldContext = SetContext (ScreenContext);
	ConfirmSaveLoad (&MsgStamp);
			// Show the "Saving . . ." message.
	UnlockMutex (GraphicsLock);

	stream = uio_fopen (meleeDir, file, "wb");
	if (stream != NULL)
	{
		saveOk = (MeleeTeam_serialize (&pMS->meleeSetup->teams[pMS->side],
				stream) == 0);
		uio_fclose (stream);

		if (!saveOk)
			uio_unlink (meleeDir, file);
	}

	pMS->load.top = 0;
	pMS->load.cur = 0;

	// Undo the screen damage done by the "Saving . . ." message.
	LockMutex (GraphicsLock);
	DrawStamp (&MsgStamp);
	DestroyDrawable (ReleaseDrawable (MsgStamp.frame));
	SetContext (OldContext);
	UnlockMutex (GraphicsLock);

	if (!saveOk)
		SaveProblem ();

	// Update the team list; a previously existing team may have been
	// deleted when save failed.
	LoadTeamList (pMS);
	SelectTeamByFileName (pMS, file);
	
	return (stream != 0);
}
Esempio n. 17
0
void
FreeKernel (void)
{
	UninitKernel (TRUE);
	UninitContexts ();

	UninitResourceSystem ();

	UninitPlayerInput ();

	DestroyDrawable (ReleaseDrawable (Screen));
	DestroyContext (ScreenContext);

	UninitVideoPlayer ();
	UninitSound ();
	UninitGraphics ();
}
Esempio n. 18
0
BOOLEAN
free_image (PFRAME pixarray)
{
	BOOLEAN retval;
	COUNT i;

	retval = TRUE;
	for (i = 0; i < NUM_VIEWS; ++i)
	{
		if (pixarray[i] != (FRAME)NULL_PTR)
		{
			if (!DestroyDrawable (ReleaseDrawable (pixarray[i])))
				retval = FALSE;
			pixarray[i] = (FRAME)NULL_PTR;
		}
	}

	return (retval);
}
Esempio n. 19
0
// stretch_frame
// create a new frame of size neww x newh, and blit a scaled version FramePtr
// into it.
// destroy the old frame if 'destroy' is 1
FRAME stretch_frame (FRAME FramePtr, int neww, int newh, int destroy)
{
	FRAME NewFrame;
	CREATE_FLAGS flags;
	TFB_Image *tfbImg;
	TFB_Canvas src, dst;

	flags = GetFrameParentDrawable (FramePtr)->Flags;
	NewFrame = CaptureDrawable (
				CreateDrawable (flags, (SIZE)neww, (SIZE)newh, 1));
	tfbImg = FramePtr->image;
	LockMutex (tfbImg->mutex);
	src = tfbImg->NormalImg;
	dst = NewFrame->image->NormalImg;
	TFB_DrawCanvas_Rescale_Nearest (src, dst, -1, NULL, NULL, NULL);
	UnlockMutex (tfbImg->mutex);
	if (destroy)
		DestroyDrawable (ReleaseDrawable (FramePtr));
	return (NewFrame);
}
Esempio n. 20
0
static BOOLEAN
RestartMenu (PMENU_STATE pMS)
{
	DWORD TimeOut;
	BYTE black_buf[1];

	ReinitQueue (&race_q[0]);
	ReinitQueue (&race_q[1]);

	black_buf[0] = FadeAllToBlack;

	SetContext (ScreenContext);

	GLOBAL (CurrentActivity) |= CHECK_ABORT;
	if (GLOBAL_SIS (CrewEnlisted) == (COUNT)~0
			&& GET_GAME_STATE (UTWIG_BOMB_ON_SHIP)
			&& !GET_GAME_STATE (UTWIG_BOMB))
	{	// player blew himself up with Utwig bomb
		BYTE white_buf[] = {FadeAllToWhite};

		SET_GAME_STATE (UTWIG_BOMB_ON_SHIP, 0);

		SleepThreadUntil (XFormColorMap ((COLORMAPPTR)white_buf,
				ONE_SECOND / 8) + ONE_SECOND / 60);
		SetContextBackGroundColor (BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F));
		ClearDrawable ();
		FlushColorXForms ();

		TimeOut = ONE_SECOND / 8;
	}
	else
	{
		TimeOut = ONE_SECOND / 2;

		if (LOBYTE (LastActivity) == WON_LAST_BATTLE)
		{
			GLOBAL (CurrentActivity) = WON_LAST_BATTLE;
			Victory ();
			Credits (TRUE);

			FreeGameData ();
			
			TimeOut = ONE_SECOND / 2;
			GLOBAL (CurrentActivity) = CHECK_ABORT;
		}
	}

	LastActivity = NextActivity = 0;

	SleepThreadUntil (XFormColorMap ((COLORMAPPTR)black_buf, TimeOut));
	if (TimeOut == ONE_SECOND / 8)
		SleepThread (ONE_SECOND * 3);
	DrawRestartMenuGraphic (pMS);
	FlushInput ();
	GLOBAL (CurrentActivity) &= ~CHECK_ABORT;
	SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT);
	DoInput (pMS, TRUE);
	
	StopMusic ();
	if (pMS->hMusic)
	{
		DestroyMusic (pMS->hMusic);
		pMS->hMusic = 0;
	}

	LockMutex (GraphicsLock);
	SetFlashRect (NULL_PTR, (FRAME)0);
	UnlockMutex (GraphicsLock);
	DestroyDrawable (ReleaseDrawable (pMS->CurFrame));

	if (GLOBAL (CurrentActivity) == (ACTIVITY)~0)
		return (FALSE); // timed out

	if (GLOBAL (CurrentActivity) & CHECK_ABORT)
		return (FALSE); // quit

	TimeOut = XFormColorMap ((COLORMAPPTR)black_buf, ONE_SECOND / 2);
	
	SleepThreadUntil (TimeOut);
	FlushColorXForms ();

	SeedRandomNumbers ();

	return (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE);
}
Esempio n. 21
0
PUBLIC void
glXDestroyPixmap(Display *dpy, GLXPixmap pixmap)
{
   DestroyDrawable( dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap );
}
Esempio n. 22
0
void
DoPopupWindow (const char *msg)
{
	stringbank *bank = StringBank_Create ();
	const char *lines[30];
	WIDGET_LABEL label;
	STAMP s;
	CONTEXT oldContext;
	RECT oldRect;
	RECT windowRect;
	POPUP_STATE state;
	MENU_SOUND_FLAGS s0, s1;
	InputFrameCallback *oldCallback;

	if (!bank)
	{
		log_add (log_Fatal, "FATAL: Memory exhaustion when preparing popup window");
		exit (EXIT_FAILURE);
	}

	label.tag = WIDGET_TYPE_LABEL;
	label.parent = NULL;
 	label.handleEvent = Widget_HandleEventIgnoreAll;
	label.receiveFocus = Widget_ReceiveFocusRefuseFocus;
	label.draw = Widget_DrawLabel;
	label.height = Widget_HeightLabel;
	label.width = Widget_WidthFullScreen;
	label.line_count = SplitString (msg, '\n', 30, lines, bank);
	label.lines = lines;

	LockMutex (GraphicsLock);

	oldContext = SetContext (ScreenContext);
	GetContextClipRect (&oldRect);
	SetContextClipRect (NULL);

	// TODO: Maybe DrawLabelAsWindow() should return a saved STAMP?
	//   We do not know the dimensions here, and so save the whole context
	s = SaveContextFrame (NULL);

	Widget_SetFont (StarConFont);
	Widget_SetWindowColors (SHADOWBOX_BACKGROUND_COLOR, SHADOWBOX_DARK_COLOR,
			SHADOWBOX_MEDIUM_COLOR);
	DrawLabelAsWindow (&label, &windowRect);
	SetSystemRect (&windowRect);

	GetMenuSounds (&s0, &s1);
	SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE);
	oldCallback = SetInputCallback (NULL);

	state.InputFunc = DoPopup;
	DoInput (&state, TRUE);

	SetInputCallback (oldCallback);
	ClearSystemRect ();
	DrawStamp (&s);
	DestroyDrawable (ReleaseDrawable (s.frame));
	SetContextClipRect (&oldRect);
	SetContext (oldContext);
	UnlockMutex (GraphicsLock);
	SetMenuSounds (s0, s1);
	StringBank_Free (bank);
}
Esempio n. 23
0
static BOOLEAN
RestartMenu (MENU_STATE *pMS)
{
	TimeCount TimeOut;

	ReinitQueue (&race_q[0]);
	ReinitQueue (&race_q[1]);

	SetContext (ScreenContext);

	GLOBAL (CurrentActivity) |= CHECK_ABORT;
	if (GLOBAL_SIS (CrewEnlisted) == (COUNT)~0
			&& GET_GAME_STATE (UTWIG_BOMB_ON_SHIP)
			&& !GET_GAME_STATE (UTWIG_BOMB))
	{	// player blew himself up with Utwig bomb
		SET_GAME_STATE (UTWIG_BOMB_ON_SHIP, 0);

		SleepThreadUntil (FadeScreen (FadeAllToWhite, ONE_SECOND / 8)
				+ ONE_SECOND / 60);
		SetContextBackGroundColor (
				BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F));
		ClearDrawable ();
		FlushColorXForms ();

		TimeOut = ONE_SECOND / 8;
	}
	else
	{
		TimeOut = ONE_SECOND / 2;

		if (LOBYTE (LastActivity) == WON_LAST_BATTLE)
		{
			GLOBAL (CurrentActivity) = WON_LAST_BATTLE;
			Victory ();
			Credits (TRUE);

			FreeGameData ();
			
			GLOBAL (CurrentActivity) = CHECK_ABORT;
		}
	}

	LastActivity = 0;
	NextActivity = 0;

	// TODO: This fade is not always necessary, especially after a splash
	//   screen. It only makes a user wait.
	SleepThreadUntil (FadeScreen (FadeAllToBlack, TimeOut));
	if (TimeOut == ONE_SECOND / 8)
		SleepThread (ONE_SECOND * 3);

	pMS->CurFrame = CaptureDrawable (LoadGraphic (RESTART_PMAP_ANIM));

	DrawRestartMenuGraphic (pMS);
	GLOBAL (CurrentActivity) &= ~CHECK_ABORT;
	SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT);
	SetDefaultMenuRepeatDelay ();
	DoInput (pMS, TRUE);
	
	StopMusic ();
	if (pMS->hMusic)
	{
		DestroyMusic (pMS->hMusic);
		pMS->hMusic = 0;
	}

	Flash_terminate (pMS->flashContext);
	pMS->flashContext = 0;
	DestroyDrawable (ReleaseDrawable (pMS->CurFrame));
	pMS->CurFrame = 0;

	if (GLOBAL (CurrentActivity) == (ACTIVITY)~0)
		return (FALSE); // timed out

	if (GLOBAL (CurrentActivity) & CHECK_ABORT)
		return (FALSE); // quit

	TimeOut = FadeScreen (FadeAllToBlack, ONE_SECOND / 2);
	
	SleepThreadUntil (TimeOut);
	FlushColorXForms ();

	SeedRandomNumbers ();

	return (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE);
}
Esempio n. 24
0
BOOLEAN
DoConfirmExit (void)
{
	BOOLEAN result;

	if (PlayingTrack ())
		PauseTrack ();

	LockMutex (GraphicsLock);
	{
		RECT r;
		STAMP s;
		RECT ctxRect;
		CONTEXT oldContext;
		RECT oldRect;
		BOOLEAN response = FALSE, done;

		oldContext = SetContext (ScreenContext);
		GetContextClipRect (&oldRect);
		SetContextClipRect (NULL);

		GetContextClipRect (&ctxRect);
		r.extent.width = CONFIRM_WIN_WIDTH + 4;
		r.extent.height = CONFIRM_WIN_HEIGHT + 4;
		r.corner.x = (ctxRect.extent.width - r.extent.width) >> 1;
		r.corner.y = (ctxRect.extent.height - r.extent.height) >> 1;
		s = SaveContextFrame (&r);
		SetSystemRect (&r);

		DrawConfirmationWindow (response);
		FlushGraphics ();

		FlushInput ();
		done = FALSE;
		
		do {
			// Forbid recursive calls or pausing here!
			ExitRequested = FALSE;
			GamePaused = FALSE;
			UpdateInputState ();
			if (GLOBAL (CurrentActivity) & CHECK_ABORT)
			{	// something else triggered an exit
				done = TRUE;
				response = TRUE;
			}
			else if (PulsedInputState.menu[KEY_MENU_SELECT])
			{
				done = TRUE;
				PlayMenuSound (MENU_SOUND_SUCCESS);
			}
			else if (PulsedInputState.menu[KEY_MENU_CANCEL])
			{
				done = TRUE;
				response = FALSE;
			}
			else if (PulsedInputState.menu[KEY_MENU_LEFT] || PulsedInputState.menu[KEY_MENU_RIGHT])
			{
				response = !response;
				DrawConfirmationWindow (response);
				PlayMenuSound (MENU_SOUND_MOVE);
			}
			SleepThread (ONE_SECOND / 30);
		} while (!done);

		// Restore the screen under the confirmation window
		DrawStamp (&s);
		DestroyDrawable (ReleaseDrawable (s.frame));
		ClearSystemRect ();
		if (response || (GLOBAL (CurrentActivity) & CHECK_ABORT))
		{
			result = TRUE;
			GLOBAL (CurrentActivity) |= CHECK_ABORT;
		}		
		else
		{
			result = FALSE;
		}
		ExitRequested = FALSE;
		GamePaused = FALSE;
		FlushInput ();
		SetContextClipRect (&oldRect);
		SetContext (oldContext);
	}
	UnlockMutex (GraphicsLock);

	if (PlayingTrack ())
		ResumeTrack ();

	return (result);
}
Esempio n. 25
0
void
FreePlanet (void)
{
	COUNT i, j;
	PLANET_ORBIT *Orbit = &pSolarSysState->Orbit;

	UninitSphereRotation ();

	StopMusic ();
	LockMutex (GraphicsLock);

	for (i = 0; i < sizeof (pSolarSysState->PlanetSideFrame)
			/ sizeof (pSolarSysState->PlanetSideFrame[0]); ++i)
	{
		DestroyDrawable (ReleaseDrawable (pSolarSysState->PlanetSideFrame[i]));
		pSolarSysState->PlanetSideFrame[i] = 0;
	}

//    FreeLanderData ();

	DestroyStringTable (ReleaseStringTable (pSolarSysState->XlatRef));
	pSolarSysState->XlatRef = 0;
	DestroyDrawable (ReleaseDrawable (pSolarSysState->TopoFrame));
	pSolarSysState->TopoFrame = 0;
	DestroyColorMap (ReleaseColorMap (pSolarSysState->OrbitalCMap));
	pSolarSysState->OrbitalCMap = 0;

	HFree (Orbit->lpTopoData);
	Orbit->lpTopoData = 0;
	DestroyDrawable (ReleaseDrawable (Orbit->TopoZoomFrame));
	Orbit->TopoZoomFrame = 0;
	DestroyDrawable (ReleaseDrawable (Orbit->SphereFrame));
	Orbit->SphereFrame = NULL;

	DestroyDrawable (ReleaseDrawable (Orbit->TintFrame));
	Orbit->TintFrame = 0;
	Orbit->TintColor = BLACK_COLOR;

	DestroyDrawable (ReleaseDrawable (Orbit->ObjectFrame));
	Orbit->ObjectFrame = 0;
	DestroyDrawable (ReleaseDrawable (Orbit->WorkFrame));
	Orbit->WorkFrame = 0;

	HFree (Orbit->TopoColors);
	Orbit->TopoColors = NULL;
	HFree (Orbit->ScratchArray);
	Orbit->ScratchArray = NULL;
	if (Orbit->map_rotate && Orbit->light_diff)
	{
		for (j=0 ; j < MAP_HEIGHT+1 ; j++)
		{
			HFree (Orbit->map_rotate[j]);
			HFree (Orbit->light_diff[j]);
		}
	}

	HFree (Orbit->map_rotate);
	Orbit->map_rotate = NULL;
	HFree (Orbit->light_diff);
	Orbit->light_diff = NULL;

	DestroyStringTable (ReleaseStringTable (
			pSolarSysState->SysInfo.PlanetInfo.DiscoveryString
			));
	pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = 0;
	FreeLanderFont (&pSolarSysState->SysInfo.PlanetInfo);

	// Need to make sure our own CONTEXTs are not active because
	// we will destroy them now
	SetContext (SpaceContext);
	DestroyPlanetContext ();
	DestroyScanContext ();

	UnlockMutex (GraphicsLock);
}
Esempio n. 26
0
// Show the contexts on the screen.
// Must be called from the main thread.
void
debugContexts (void)
{
	static volatile bool inDebugContexts = false;
			// Prevent this function from being called from within itself.
	
	CONTEXT orgContext;
	CONTEXT debugDrawContext;
			// We're going to use this context to draw in.
	FRAME debugDrawFrame;
	double hueIncrement;
	size_t visibleContextI;
	CONTEXT context;
	size_t contextCount;
	FRAME savedScreen;

	// Prevent this function from being called from within itself.
	if (inDebugContexts)
		return;
	inDebugContexts = true;

	contextCount = countVisibleContexts ();
	if (contextCount == 0)
	{
		goto out;
	}
	
	savedScreen = getScreen ();
	FlushGraphics ();
			// Make sure that the screen has actually been captured,
			// before we use the frame.

	// Create a new frame to draw on.
	debugDrawContext = CreateContext ("debugDrawContext");
	// New work frame is a copy of the original.
	debugDrawFrame = CaptureDrawable (CloneFrame (savedScreen));
	orgContext = SetContext (debugDrawContext);
	SetContextFGFrame (debugDrawFrame);

	hueIncrement = 360.0 / contextCount;

	visibleContextI = 0;
	for (context = GetFirstContext (); context != NULL;
			context = GetNextContext (context))
	{
		if (context == debugDrawContext) {
			// Skip our own context.
			continue;
		}
	
		if (isContextVisible (context))
		{
			// Only draw the visible contexts.
			drawContext (context, visibleContextI * hueIncrement);
			visibleContextI++;
		}

		describeContext (stderr, context);
	}

	// Blit the final debugging frame to the screen.
	putScreen (debugDrawFrame);

	// Wait for a key:
	{
		WAIT_STATE state;
		state.InputFunc = waitForKey;
		DoInput(&state, TRUE);
	}

	SetContext (orgContext);

	// Destroy the debugging frame and context.
	DestroyContext (debugDrawContext);
			// This does nothing with the drawable set with
			// SetContextFGFrame().
	DestroyDrawable (ReleaseDrawable (debugDrawFrame));
	
	putScreen (savedScreen);

	DestroyDrawable (ReleaseDrawable (savedScreen));

out:
	inDebugContexts = false;
}
Esempio n. 27
0
/* This code assumes that you aren't in Character Mode.  This is
 * currently safe because VControl doesn't see keystrokes when you
 * are, and thus cannot conclude that an exit is necessary. */
BOOLEAN
DoConfirmExit (void)
{
	BOOLEAN result;
	static BOOLEAN in_confirm = FALSE;
	if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE &&
			LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE &&
			!(LastActivity & CHECK_RESTART))
		SuspendGameClock ();
	if (CommData.ConversationPhrases && PlayingTrack ())
		PauseTrack ();

	LockMutex (GraphicsLock);
	if (in_confirm)
	{
		result = FALSE;
		ExitRequested = FALSE;
	}
	else
	{
		RECT r;
		STAMP s;
		FRAME F;
		CONTEXT oldContext;
		RECT oldRect;
		BOOLEAN response = FALSE, done;

		in_confirm = TRUE;
		oldContext = SetContext (ScreenContext);
		GetContextClipRect (&oldRect);
		SetContextClipRect (NULL_PTR);

		r.extent.width = CONFIRM_WIN_WIDTH + 4;
		r.extent.height = CONFIRM_WIN_HEIGHT + 4;
		r.corner.x = (SCREEN_WIDTH - r.extent.width) >> 1;
		r.corner.y = (SCREEN_HEIGHT - r.extent.height) >> 1;
		s.origin = r.corner;
		F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0));

		SetSystemRect (&r);

		DrawConfirmationWindow (response);

		// Releasing the lock lets the rotate_planet_task
		// draw a frame.  PauseRotate can still allow one more frame
		// to be drawn, so it is safer to just not release the lock
		//UnlockMutex (GraphicsLock);
		FlushGraphics ();
		//LockMutex (GraphicsLock);

		GLOBAL (CurrentActivity) |= CHECK_ABORT;
		FlushInput ();
		done = FALSE;

		do {
			// Forbid recursive calls or pausing here!
			ExitRequested = FALSE;
			GamePaused = FALSE;
			UpdateInputState ();
			if (PulsedInputState.menu[KEY_MENU_SELECT])
			{
				done = TRUE;
				PlayMenuSound (MENU_SOUND_SUCCESS);
			}
			else if (PulsedInputState.menu[KEY_MENU_CANCEL])
			{
				done = TRUE;
				response = FALSE;
			}
			else if (PulsedInputState.menu[KEY_MENU_LEFT] || PulsedInputState.menu[KEY_MENU_RIGHT])
			{
				response = !response;
				DrawConfirmationWindow (response);
				PlayMenuSound (MENU_SOUND_MOVE);
			}
			TaskSwitch ();
		} while (!done);

		s.frame = F;
		DrawStamp (&s);
		DestroyDrawable (ReleaseDrawable (s.frame));
		ClearSystemRect ();
		if (response)
		{
			result = TRUE;
		}		
		else
		{
			result = FALSE;
			GLOBAL (CurrentActivity) &= ~CHECK_ABORT;
		}
		ExitRequested = FALSE;
		GamePaused = FALSE;
		FlushInput ();
		SetContextClipRect (&oldRect);
		SetContext (oldContext);
	}
	UnlockMutex (GraphicsLock);

	if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE &&
			LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE &&
			!(LastActivity & CHECK_RESTART))
		ResumeGameClock ();
	if (CommData.ConversationPhrases && PlayingTrack ())
	{
		ResumeTrack ();
		if (CommData.AlienTransitionDesc.AnimFlags & TALK_DONE)
			do_subtitles ((void *)~0);
	}

	in_confirm = FALSE;
	return (result);
}
Esempio n. 28
0
PUBLIC void
GLX_PREFIX(glXDestroyWindow)(Display *dpy, GLXWindow win)
{
   DestroyDrawable( dpy, (GLXDrawable) win, X_GLXDestroyWindow );
}
Esempio n. 29
0
PUBLIC void
GLX_PREFIX(glXDestroyPixmap)(Display *dpy, GLXPixmap pixmap)
{
   DestroyDrawable( dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap );
}
Esempio n. 30
0
void
DoPopupWindow(const char *msg)
{
	stringbank *bank = StringBank_Create ();
	const char *lines[30];
	WIDGET_LABEL label;
	RECT r;
	STAMP s;
	FRAME F;
	CONTEXT oldContext;
	RECT oldRect;
	POPUP_STATE state;
	MENU_SOUND_FLAGS s0, s1;
	

	if (!bank)
	{
		log_add (log_Fatal, "FATAL: Memory exhaustion when preparing popup window");
		exit (EXIT_FAILURE);
	}

	label.tag = WIDGET_TYPE_LABEL;
	label.parent = NULL;
 	label.handleEvent = Widget_HandleEventIgnoreAll;
	label.receiveFocus = Widget_ReceiveFocusRefuseFocus;
	label.draw = Widget_DrawLabel;
	label.height = Widget_HeightLabel;
	label.width = Widget_WidthFullScreen;
	label.line_count = SplitString (msg, '\n', 30, lines, bank);
	label.lines = lines;

	LockMutex (GraphicsLock);

	oldContext = SetContext (ScreenContext);
	GetContextClipRect (&oldRect);
	SetContextClipRect (NULL_PTR);

	/* TODO: Better measure of dimensions than this */
	r.extent.width = SCREEN_WIDTH;
	r.extent.height = SCREEN_HEIGHT;
	r.corner.x = (SCREEN_WIDTH - r.extent.width) >> 1;
	r.corner.y = (SCREEN_HEIGHT - r.extent.height) >> 1;
	F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0));

	s.origin = r.corner;
	s.frame = F;

	DrawLabelAsWindow (&label);

	GetMenuSounds (&s0, &s1);
	SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE);

	state.InputFunc = DoPopup;
	DoInput (&state, TRUE);

	DrawStamp (&s);
	DestroyDrawable (ReleaseDrawable (s.frame));
	FlushInput ();
	SetContextClipRect (&oldRect);
	SetContext (oldContext);
	UnlockMutex (GraphicsLock);
	SetMenuSounds (s0, s1);
	StringBank_Free (bank);
}