Esempio n. 1
0
static void
BindSelectedColor(AG_Event *event)
{
	AG_HSVPal *hsv = AG_PTR(1);
	AG_TlistItem *it = AG_PTR(2);
	AG_Color *c = it->p1;

	AG_BindUint8(hsv, "RGBAv", (Uint8 *)c);
}
Esempio n. 2
0
static void
StartBrowser(AG_Event *event)
{
	MyTestInstance *ti = AG_PTR(1);
	AG_Window *winParent = AG_PTR(2), *win;

	if ((win = DEV_Browser(&ti->vfsRoot)) != NULL)
		AG_WindowAttach(winParent, win);
}
Esempio n. 3
0
static void
SelectedSize(AG_Event *event)
{
	AG_FontSelector *fs = AG_PTR(1);
	AG_TlistItem *it = AG_PTR(2);

	fs->curSize = atoi(it->text);
	UpdateFontSelection(fs);
	UpdatePreview(fs);
}
Esempio n. 4
0
static void
SelectedFace(AG_Event *event)
{
	AG_FontSelector *fs = AG_PTR(1);
	AG_TlistItem *it = AG_PTR(2);

	Strlcpy(fs->curFace, it->text, sizeof(fs->curFace));
	UpdateFontSelection(fs);
	UpdatePreview(fs);
}
Esempio n. 5
0
    void apply_options(AG_Event *event)
    {
        int opengl = *static_cast<int*>(AG_PTR(1));
        int fs = *static_cast<int*>(AG_PTR(2));
        int lang = *static_cast<int*>(AG_PTR(3));

        std::stringstream str;
        str << "Fullscreen: " << fs;
        logger->logDebug(str.str());

        if (lang == -1)
            return;

        switch (lang)
        {
            case 0:
                game->setLanguage("en");
                break;

            case 1:
                game->setLanguage("pt");
                break;

            case 2:
                game->setLanguage("es");
                break;
        }

        interfaceManager->removeAllWindows();
        game->restart(opengl, fs, width, height);

        XMLFile file;
        if (file.load(resourceManager->getDataPath("townslife.cfg")))
        {
            file.setElement("graphics");

            file.changeInt("graphics", "opengl", opengl);
            if (fs)
                file.changeString("graphics", "fullscreen", "true");
            else
                file.changeString("graphics", "fullscreen", "false");
            file.changeInt("graphics", "width", width);
            file.changeInt("graphics", "height", height);

            file.setElement("language");
            file.changeString("language", "value", game->getLanguage());

            file.save();
        }

        GameState *state = new LoginState;
        game->changeState(state);
    }
Esempio n. 6
0
static void
SelectPathOK(AG_Event *event)
{
	char *key = AG_STRING(1);
	AG_Textbox *tbox = AG_PTR(2);
	AG_Window *win = AG_PTR(3);
	char *path = AG_STRING(4);
	
	AG_SetString(agConfig, key, path);
	AG_TextboxSetString(tbox, path);
	AG_ObjectDetach(win);
}
Esempio n. 7
0
static void
SelectFont(AG_Event *event)
{
	VG_Text *vt = AG_PTR(1);
	AG_Window *win = AG_PTR(2);
	AG_FontSelector *fs = AG_PTR(3);

	Strlcpy(vt->fontFace, fs->curFace, sizeof(vt->fontFace));
	vt->fontSize = fs->curSize;
	vt->fontFlags = 0;
	if (fs->curStyle & AG_FONT_BOLD) { vt->fontFlags |= VG_TEXT_BOLD; }
	if (fs->curStyle & AG_FONT_ITALIC) { vt->fontFlags |= VG_TEXT_ITALIC; }

	AG_ObjectDetach(win);
}
Esempio n. 8
0
File: fill.c Progetto: adsr/agar
static void
InvertColors(AG_Event *event)
{
	struct rg_fill_feature *fi = AG_PTR(1);
	AG_Color c;

	switch (fi->type) {
	case FILL_SOLID:
		c = fi->f_solid.c;
		c.r = 255 - c.r;
		c.g = 255 - c.g;
		c.b = 255 - c.b;
		break;
	case FILL_HGRADIENT:
	case FILL_VGRADIENT:
	case FILL_CGRADIENT:
		c = fi->f_gradient.c1;
		c.r = 255 - c.r;
		c.g = 255 - c.g;
		c.b = 255 - c.b;
		fi->f_gradient.c1 = c;

		c = fi->f_gradient.c2;
		c.r = 255 - c.r;
		c.g = 255 - c.g;
		c.b = 255 - c.b;
		fi->f_gradient.c2 = c;
		break;
	default:
		break;
	}
}
Esempio n. 9
0
static void
Changed(AG_Event *event)
{
	AG_Window *win = AG_PTR(1);

	AG_WindowSetOpacity(win, opval);
}
Esempio n. 10
0
static void
MinimizeWindow(AG_Event *event)
{
	AG_Titlebar *tbar = AG_PTR(1);

	AG_WindowMinimize(tbar->win);
}
Esempio n. 11
0
File: textbox.c Progetto: adsr/agar
static void
EndScrollbarDrag(AG_Event *event)
{
	AG_Textbox *tb = AG_PTR(1);

	tb->ed->flags &= ~(AG_EDITABLE_NOSCROLL);
}
Esempio n. 12
0
static void
CloseWindow(AG_Event *event)
{
	AG_Titlebar *tbar = AG_PTR(1);

	AG_PostEvent(NULL, tbar->win, "window-close", NULL);
}
Esempio n. 13
0
void EventReceiver(AG_Event *event)
{
	EventHandler *handler = static_cast<EventHandler*>(AG_PTR(1));

	if(handler)
		handler->Trigger(event);
}
Esempio n. 14
0
static void
Bound(AG_Event *event)
{
	AG_HSVPal *hsv = AG_SELF();
	AG_Variable *V = AG_PTR(1);

	if (AG_VARIABLE_TYPE(V) == AG_VARIABLE_UINT32 &&
	    strcmp(V->name, "pixel") == 0) {
#if 0
		hsv->flags |= AG_HSVPAL_PIXEL;
#endif
		UpdateHSVFromPixel(hsv, *(Uint32 *)V->data.p);
	} else if (strcmp(V->name, "RGBAv") == 0) {
		UpdateHSVFromRGBAv(hsv);
	} else if (strcmp(V->name, "RGBv") == 0) {
		UpdateHSVFromRGBv(hsv);
	} else if (strcmp(V->name, "pixel-format") == 0) {
		if (!(hsv->flags & AG_HSVPAL_FORCE_NOALPHA)) {
			AG_PixelFormat **pFormat = (AG_PixelFormat **)V->data.p;
			if ((*pFormat)->Amask != 0) {
				hsv->flags &= ~(AG_HSVPAL_NOALPHA);
			} else {
				hsv->flags |= AG_HSVPAL_NOALPHA;
			}
		}
	}
	AG_Redraw(hsv);
}
Esempio n. 15
0
File: combo.c Progetto: adsr/agar
static void
Return(AG_Event *event)
{
	char text[AG_TEXTBOX_STRING_MAX];
	AG_Textbox *tbox = AG_SELF();
	AG_Combo *com = AG_PTR(1);
	
	AG_ObjectLock(com->list);

	AG_TextboxCopyString(tbox, text, sizeof(text));

	if ((com->flags & AG_COMBO_ANY_TEXT) == 0) {
		AG_TlistItem *it;
	
		if (text[0] != '\0' &&
		    (it = AG_TlistSelectText(com->list, text)) != NULL) {
			AG_TextboxSetString(com->tbox, it->text);
			AG_PostEvent(NULL, com, "combo-selected", "%p", it);
		} else {
			AG_TlistDeselectAll(com->list);
			AG_TextboxSetString(com->tbox, "");
			AG_PostEvent(NULL, com, "combo-text-unknown", "%s",
			    text);
		}
	} else {
		AG_TlistDeselectAll(com->list);
		AG_PostEvent(NULL, com, "combo-text-entry", "%s", text);
	}

	AG_ObjectUnlock(com->list);
}
Esempio n. 16
0
static void OnChangeTotalVolume(AG_Event *event)
{
	AG_Slider *self = (AG_Slider *)AG_SELF();
	struct gui_sound *cfg = AG_PTR(1);
	if(cfg == NULL) return;
	SetTotalVolume(cfg->iTotalVolume);
}
Esempio n. 17
0
File: ucombo.c Progetto: adsr/agar
static void
Expand(AG_Event *event)
{
	AG_UCombo *com = AG_PTR(1);
	AG_Driver *drv = WIDGET(com)->drv;
	int expand = AG_INT(2);
	AG_SizeReq rList;
	int x, y, w, h;
	Uint wView, hView;

	AG_ObjectLock(com);
	if (expand) {
		com->panel = AG_WindowNew(AG_WINDOW_POPUP|AG_WINDOW_MODAL|
		                          AG_WINDOW_NOTITLE);
		AG_ObjectSetName(com->panel, "_UComboPopup");
		AG_WindowSetPadding(com->panel, 0,0,0,0);
		AG_ObjectAttach(com->panel, com->list);
		if (WIDGET(com)->window != NULL)
			AG_WindowAttach(WIDGET(com)->window, com->panel);
	
		if (com->wSaved > 0) {
			w = com->wSaved;
			h = com->hSaved;
		} else {
			if (com->wPreList != -1 && com->hPreList != -1) {
				AG_TlistSizeHintPixels(com->list,
				    com->wPreList, com->hPreList);
			}
			AG_WidgetSizeReq(com->list, &rList);
			w = rList.w + com->panel->wBorderSide*2;
			h = rList.h + com->panel->wBorderBot;
		}
		x = WIDGET(com)->rView.x2 - w;
		y = WIDGET(com)->rView.y1;
		
		AG_GetDisplaySize(WIDGET(com)->drv, &wView, &hView);
		if (x+w > wView) { w = wView - x; }
		if (y+h > hView) { h = hView - y; }
		
		if (AGDRIVER_CLASS(drv)->wm == AG_WM_MULTIPLE &&
		    WIDGET(com)->window != NULL) {
			x += WIDGET(WIDGET(com)->window)->x;
			y += WIDGET(WIDGET(com)->window)->y;
		}
		if (x < 0) { x = 0; }
		if (y < 0) { y = 0; }
		if (w < 4 || h < 4) {
			Collapse(com);
			return;
		}
		AG_SetEvent(com->panel, "window-modal-close",
		    ModalClose, "%p", com);
		AG_WindowSetGeometry(com->panel, x,y, w,h);
		AG_WindowShow(com->panel);
	} else {
		Collapse(com);
	}
	AG_ObjectUnlock(com);
}
Esempio n. 18
0
File: textbox.c Progetto: adsr/agar
static void
BeginScrollbarDrag(AG_Event *event)
{
	AG_Textbox *tb = AG_PTR(1);
	
	AG_WidgetFocus(tb->ed);
	tb->ed->flags |= AG_EDITABLE_NOSCROLL;
}
Esempio n. 19
0
File: fill.c Progetto: adsr/agar
static void
set_type(AG_Event *event)
{
	struct rg_fill_feature *fi = AG_PTR(1);
	int type = AG_INT(2);

	fi->type = type;
}
Esempio n. 20
0
static void
SetAlign(AG_Event *event)
{
	VG_Text *vt = AG_PTR(1);
	enum vg_alignment align = (enum vg_alignment)AG_INT(2);

	vt->align = align;
}
Esempio n. 21
0
File: ucombo.c Progetto: adsr/agar
static void
ModalClose(AG_Event *event)
{
	AG_UCombo *com = AG_PTR(1);

	if (com->panel != NULL)
		Collapse(com);
}
Esempio n. 22
0
static void
ModalClose(AG_Event *event)
{
    AG_FileSelector *fs = AG_PTR(1);

    if (fs->panel != NULL)
        Collapse(fs);
}
Esempio n. 23
0
File: uniconv.c Progetto: adsr/agar
static void
SelectUnicodeRange(AG_Event *event)
{
	char text[4][128];
	AG_Treetbl *tt = AG_PTR(1);
	AG_TlistItem *it = AG_PTR(2);
	struct unicode_range *range = it->p1;
	const struct unicode_range *next_range = NULL;
	Uint32 i, end;
	char *c;

	for (i = 0; i < unicodeRangeCount; i++) {
		if ((&unicodeRanges[i] == range) &&
		    (i+1 < unicodeRangeCount)) {
			next_range = &unicodeRanges[i+1];
			break;
		}
	}
	end = (next_range != NULL) ? next_range->start-1 : 0xffff;

	AG_TreetblClearRows(tt);
	
	for (i = range->start; i < end; i++) {
		if (i == 10)
			continue;
        
		/* prep column 0 */
		unitext[0] = i;
		AG_ExportUnicode(AG_UNICODE_TO_UTF8, utf8text, unitext,
		    sizeof(unitext));
		Snprintf(text[0], sizeof(text[0]), "%s", utf8text);
        
		/* prep column 1 */
		utf8seq[0] = '\0';
		for (c = &utf8text[0]; *c != '\0'; c++) {
			char s[4];
            
			Snprintf(s, sizeof(s), "%x", (unsigned char)*c);
			Strlcat(utf8seq, s, sizeof(utf8seq));
		}
		Snprintf(text[1], sizeof(text[1]), "%s", utf8seq);
        
		AG_TreetblAddRow(tt, NULL, i, "%s,%s", text[0], text[1]);
	}
}
Esempio n. 24
0
static void
SelectedStyle(AG_Event *event)
{
	AG_FontSelector *fs = AG_PTR(1);
	AG_TlistItem *it = AG_PTR(2);
	Uint flags = 0;

	if (!strcmp(it->text, _("Italic")))
		flags |= AG_FONT_ITALIC;
	if (!strcmp(it->text, _("Bold")))
		flags |= AG_FONT_BOLD;
	if (!strcmp(it->text, _("Bold Italic")))
		flags |= (AG_FONT_BOLD|AG_FONT_ITALIC);

	fs->curStyle = flags;
	UpdateFontSelection(fs);
	UpdatePreview(fs);
}
Esempio n. 25
0
File: dev.c Progetto: varialus/agar
static void
SelectTool(AG_Event *event)
{
	const struct dev_tool_ent *ent = AG_PTR(1);
	AG_Window *win;

	if ((win = (ent->fn)()) != NULL)
		AG_WindowShow(win);
}
Esempio n. 26
0
static void XM7_DbgMMRDrawFn(AG_Event *event)
{
   XM7_SDLView *view = (XM7_SDLView *)AG_SELF();
    struct XM7_DbgMMRDump *p = (struct XM7_DbgMMRDump *)AG_PTR(1);
    BOOL forceredraw = AG_INT(2);

    if(p == NULL) return;
    XM7_ConsoleUpdate(view, p->cons, forceredraw);
}
Esempio n. 27
0
static void RenderMethodSelected(AG_Event *event)
{
   AG_Combo *self = (AG_Combo *)AG_SELF();
   AG_TlistItem *list = (AG_TlistItem *)AG_PTR(2);
   struct gui_disp *cfg = (struct gui_disp *)AG_PTR(1);
   int method = -1;
   
   if(list == NULL) return;
   if(cfg == NULL) return;

   if(list->p1 != NULL) {
     method = *(int *)(list->p1);
   }
   if(method < RENDERING_FULL) return;
   if(method >= RENDERING_END) return;
   cfg->nRenderMethod = method;
   return;
}
Esempio n. 28
0
static void
FileChosen(AG_Event *event)
{
    AG_FileSelector *fs = AG_PTR(1);
    char *path = AG_STRING(2);

    AG_TextboxSetString(fs->tbox, path);
    AG_PostEvent(NULL, fs, "file-chosen", "%s", path);
    Collapse(fs);
}
Esempio n. 29
0
static void OnChangeSampleRate(AG_Event *event)
{
	struct gui_sound *cfg = AG_PTR(1);
	int num = AG_INT(2);
	if(cfg == NULL) return;
	if(num > 6 ){
		num = 6;
	}
	cfg->nSampleRate = SampleRates[num];
}
Esempio n. 30
0
static void OnChangeVolume(AG_Event *event)
{
	AG_Slider *self = (AG_Slider *)AG_SELF();
	struct gui_sound *cfg = AG_PTR(1);
	
	if(cfg == NULL) return;
	SetSoundVolume2(cfg->uChSeparation, cfg->nFMVolume,
			cfg->nPSGVolume, cfg->nBeepVolume,
			cfg->nCMTVolume, cfg->nWaveVolume);
}