Example #1
0
static void
SDLGL_Close(void *obj)
{
	AG_Driver *drv = obj;
	AG_DriverSDLGL *sgl = obj;

#ifdef AG_DEBUG
	if (nDrivers != 1) { AG_FatalError("Driver close without open"); }
#endif
	AG_FreeCursors(AGDRIVER(sgl));

	if (AG_CfgBool("view.full-screen")) {
		SDL_WM_ToggleFullScreen(sgl->s);
	}
	if (initedSDLVideo) {
		SDL_QuitSubSystem(SDL_INIT_VIDEO);
		initedSDLVideo = 0;
	}
	AG_ObjectDetach(drv->mouse);
	AG_ObjectDestroy(drv->mouse);
	AG_ObjectDetach(drv->kbd);
	AG_ObjectDestroy(drv->kbd);
	drv->mouse = NULL;
	drv->kbd = NULL;

	if (sgl->outMode != AG_SDLGL_OUT_NONE) {
		Free(sgl->outBuf);
		sgl->outBuf = NULL;
		sgl->outMode = AG_SDLGL_OUT_NONE;
	}

	nDrivers = 0;
}
Example #2
0
File: ucombo.c Project: adsr/agar
static void
Destroy(void *p)
{
	AG_UCombo *com = p;

	AG_ObjectDestroy(com->list);
}
Example #3
0
File: drv.c Project: varialus/agar
/* Close and destroy a driver. */
void
AG_DriverClose(AG_Driver *drv)
{
	AG_ObjectDetach(drv);
	AGDRIVER_CLASS(drv)->close(drv);
	AG_ObjectDestroy(drv);
}
Example #4
0
static void
CloseMenu(AG_HSVPal *pal)
{
	AG_MenuCollapse(pal->menu_item);
	AG_ObjectDestroy(pal->menu);

	pal->menu = NULL;
	pal->menu_item = NULL;
	pal->menu_win = NULL;
}
Example #5
0
static void
Destroy(void *p)
{
    AG_FileSelector *fs = p;

    if (fs ->panel != NULL) {
        AG_WindowHide(fs->panel);
        AG_ObjectDetach(fs->filedlg);
        AG_ObjectDetach(fs->panel);
    }
    AG_ObjectDestroy(fs->filedlg);
}
Example #6
0
static void
Destroy(void *obj)
{
	MyTestInstance *ti = obj;

	/* Destroy our test VFS. */
	AG_ObjectDestroy(&ti->vfsRoot);

	if (--inited == 0) {
		/* Unregister our classes for a complete cleanup. */
		AG_UnregisterClass(&AnimalClass);
		AG_UnregisterClass(&MammalClass);

		DEV_DestroySubsystem();
	}
}
Example #7
0
void
AG_ButtonSurfaceNODUP(AG_Button *bu, AG_Surface *su)
{
	AG_ObjectLock(bu);
	if (bu->lbl != NULL) {
		AG_ObjectDetach(bu->lbl);
		AG_ObjectDestroy(bu->lbl);
		bu->lbl = NULL;
	}
	if (bu->surface != -1) {
		AG_WidgetReplaceSurfaceNODUP(bu, bu->surface, su);
	} else {
		bu->surface = AG_WidgetMapSurfaceNODUP(bu, su);
	}
	AG_ObjectUnlock(bu);
	AG_Redraw(bu);
}
Example #8
0
/* Set the label text (format string). */
void
AG_BoxSetLabelS(AG_Box *box, const char *s)
{
	AG_ObjectLock(box);
	if (s != NULL) {
		if (box->lbl == NULL) {
			box->lbl = AG_LabelNewS(box, 0, s);
			AG_SetStyle(box->lbl, "font-size", "80%");
		} else {
			AG_LabelTextS(box->lbl, s);
		}
	} else {
		AG_ObjectDetach(box->lbl);
		AG_ObjectDestroy(box->lbl);
		box->lbl = NULL;
	}
	AG_Redraw(box);
	AG_ObjectUnlock(box);
}
Example #9
0
File: drv.c Project: varialus/agar
/* Create a new driver instance. */
AG_Driver *
AG_DriverOpen(AG_DriverClass *dc)
{
	AG_Driver *drv;

	if ((drv = AG_ObjectNew(NULL, dc->name, AGCLASS(dc))) == NULL) {
		return (NULL);
	}
	if (dc->open(drv, NULL) == -1) {
		AG_ObjectDestroy(drv);
		return (NULL);
	}
	for (drv->id = 1; ; drv->id++) {
		if (AG_GetDriverByID(drv->id) == NULL)
			break;
	}
	AG_ObjectSetName(drv, "%s%u", dc->name, drv->id);
	AG_ObjectAttach(&agDrivers, drv);
	return (drv);
}
Example #10
0
File: textbox.c Project: adsr/agar
/* Toggle word wrapping */
void
AG_TextboxSetWordWrap(AG_Textbox *tb, int flag)
{
	AG_EditableSetWordWrap(tb->ed, flag);

	if (tb->ed->flags & AG_EDITABLE_MULTILINE) {
		if (tb->hBar != NULL) {
			AG_ObjectDetach(tb->hBar);
			AG_ObjectDestroy(tb->hBar);
			tb->hBar = NULL;
		}
		if (!flag) {
			tb->hBar = AG_ScrollbarNew(tb, AG_SCROLLBAR_HORIZ,
			    AG_SCROLLBAR_AUTOHIDE);
			AG_BindInt(tb->hBar, "value", &tb->ed->x);
			AG_BindInt(tb->hBar, "max", &tb->ed->xMax);
			AG_BindInt(tb->hBar, "visible", &WIDTH(tb->ed));
			AG_SetEvent(tb->hBar, "scrollbar-drag-begin", BeginScrollbarDrag, "%p", tb);
			AG_SetEvent(tb->hBar, "scrollbar-drag-end", EndScrollbarDrag, "%p", tb);
			AG_TextboxSizeHintLines(tb, 4);
		}
	}
}
Example #11
0
static int
SDLGL_Open(void *obj, const char *spec)
{
	extern const AG_TimeOps agTimeOps_SDL;
	AG_Driver *drv = obj;
	AG_DriverSDLGL *sgl = obj;
	
	if (nDrivers != 0) {
		AG_SetError("Multiple SDL displays are not supported");
		return (-1);
	}

	/* Initialize SDL's video subsystem. */
	if (!initedSDL) {
		if (SDL_Init(0) == -1) {
			AG_SetError("SDL_Init() failed: %s", SDL_GetError());
			return (-1);
		}
		initedSDL = 1;
	}
	if (!SDL_WasInit(SDL_INIT_VIDEO)) {
		if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
			AG_SetError("SDL_INIT_VIDEO failed: %s", SDL_GetError());
			return (-1);
		}
		initedSDLVideo = 1;
	}

	/* We can use SDL's time interface. */
	if (agTimeOps == &agTimeOps_dummy)
		AG_SetTimeOps(&agTimeOps_SDL);

	/* Initialize this driver instance. */
	if ((drv->mouse = AG_MouseNew(sgl, "SDL mouse")) == NULL ||
	    (drv->kbd = AG_KeyboardNew(sgl, "SDL keyboard")) == NULL) {
		goto fail;
	}
	sgl->outMode = AG_SDLGL_OUT_NONE;
	sgl->outPath = NULL;
	sgl->outFrame = 0;
	sgl->outLast = 0;
	sgl->outBuf = NULL;

	/* Configure the window caption */
	SDL_WM_SetCaption(agProgName, agProgName);

	nDrivers = 1;
	return (0);
fail:
	if (drv->kbd != NULL) {
		AG_ObjectDetach(drv->kbd);
		AG_ObjectDestroy(drv->kbd);
		drv->kbd = NULL;
	}
	if (drv->mouse != NULL) {
		AG_ObjectDetach(drv->mouse);
		AG_ObjectDestroy(drv->mouse);
		drv->mouse = NULL;
	}
	return (-1);
}