Ejemplo n.º 1
0
	void TestState::enter()
	{
	    int screenWidth = graphicsEngine->getScreenWidth();
		int screenHeight = graphicsEngine->getScreenHeight();

		AG_Window *chatWindow = AG_WindowNewNamed(AG_WINDOW_NOBUTTONS, "ChatWindow");
		AG_WindowSetCaption(chatWindow, "Chat");
		AG_WindowSetSpacing(chatWindow, 5);
		AG_WindowSetGeometry(chatWindow, 10, screenHeight - 185, 400, 175);
		AG_WindowShow(chatWindow);

        AG_Notebook *book = AG_NotebookNew(chatWindow, AG_NOTEBOOK_EXPAND);
        AG_ObjectSetName(book, "ChannelsFolder");
        AG_NotebookTab *nbTab = AG_NotebookAddTab(book, "Global Chat", AG_BOX_VERT);
        AG_ObjectSetName(nbTab, "GlobalChat");

        AG_Console *console = AG_ConsoleNew(nbTab, AG_CONSOLE_EXPAND|AG_CONSOLE_AUTOSCROLL);
        AG_ObjectSetName(console, "Chat");

		AG_Textbox *chatInput = AG_TextboxNewS(chatWindow, AG_TEXTBOX_CATCH_TAB, "");
		AG_TextboxSizeHint(chatInput, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
		AG_SetEvent(chatInput, "textbox-return", submit_chat, "%p%p%p", chatServer, chatInput, console);

		// add elements to interface manager
		interfaceManager->addWindow(chatWindow);

		popUp = AG_WindowNew(AG_WINDOW_NOBUTTONS);
		AG_WindowSetCaption(popUp, "Exit Game");
		AG_WindowSetGeometry(popUp, screenWidth / 2 - 75, screenHeight / 2 - 40, 150, 80);
		AG_WindowHide(popUp);

		AG_Button *logOut = AG_ButtonNewFn(popUp, 0, "Log Out", handle_logout, 0);
		AG_ButtonJustify(logOut, AG_TEXT_CENTER);

		AG_Button *exitGame = AG_ButtonNewFn(popUp, 0, "Exit to Desktop", handle_exit, 0);
		AG_ButtonJustify(exitGame, AG_TEXT_CENTER);

		interfaceManager->addWindow(popUp);

		std::string nick = player->getSelectedCharacter()->getName();
		std::string host = "neo.us.whatnet.org";
		chatServer->setNick(nick);

#ifndef WITHOUT_CHAT
        chatServer->connect(host);
#endif

        // add listener
        interfaceManager->addMouseListener(&handle_mouse);
	}
Ejemplo n.º 2
0
static void
EditNumValues(AG_Event *event)
{
	AG_HSVPal *pal = AG_PTR(1);
	AG_Window *pwin;
	AG_Window *win;
	AG_Numerical *num;
	AG_Variable *b1, *b2;
	float v;

	if ((pwin = AG_ParentWindow(pal)) == NULL)
		return;

	if ((win = AG_WindowNewNamed(AG_WINDOW_NOMAXIMIZE, "hsvpal-%p-numedit",
	    pal)) == NULL) {
		return;
	}
	AG_WindowSetCaption(win, _("Color values"));
	AG_WindowSetPosition(win, AG_WINDOW_LOWER_LEFT, 0);
	AG_WindowSetCloseAction(win, AG_WINDOW_DETACH);
	{
		AG_Variable *bAlpha;
		void *pAlpha;

		num = AG_NumericalNew(win, 0, NULL, _("Hue: "));
		AG_NumericalSizeHint(num, "000");
		AG_WidgetCopyBinding(num, "value", pal, "hue");
		AG_NumericalSetRange(num, 0.0, 359.0);
		AG_NumericalSetIncrement(num, 1);
		AG_NumericalSetPrecision(num, "f", 0);
		
		num = AG_NumericalNew(win, 0, NULL, _("Saturation: "));
		AG_NumericalSizeHint(num, "00.00");
		AG_WidgetCopyBinding(num, "value", pal, "saturation");
		AG_NumericalSetRange(num, 0.0, 1.0);
		AG_NumericalSetIncrement(num, 0.01);
		AG_NumericalSetPrecision(num, "f", 2);

		num = AG_NumericalNew(win, 0, NULL, _("Value: "));
		AG_NumericalSizeHint(num, "00.00");
		AG_WidgetCopyBinding(num, "value", pal, "value");
		AG_NumericalSetRange(num, 0.0, 1.0);
		AG_NumericalSetIncrement(num, 0.01);
		AG_NumericalSetPrecision(num, "f", 2);

		num = AG_NumericalNew(win, 0, NULL, _("Alpha: "));
		AG_NumericalSizeHint(num, "0.000");
		AG_WidgetCopyBinding(num, "value", pal, "alpha");
		bAlpha = AG_GetVariable(pal, "alpha", &pAlpha);
		switch (AG_VARIABLE_TYPE(bAlpha)) {
		case AG_VARIABLE_FLOAT:
		case AG_VARIABLE_DOUBLE:
			AG_NumericalSetRange(num, 0.0, 1.0);
			AG_NumericalSetIncrement(num, 0.005);
			AG_NumericalSetPrecision(num, "f", 3);
			break;
		case AG_VARIABLE_INT:
		case AG_VARIABLE_UINT:
		case AG_VARIABLE_UINT8:
			AG_NumericalSetRange(num, 0.0, 255.0);
			AG_NumericalSetIncrement(num, 1.0);
			AG_NumericalSetPrecision(num, "f", 0);
			break;
		default:
			break;
		}
		AG_UnlockVariable(bAlpha);
	}

	AG_WindowAttach(pwin, win);
	AG_WindowShow(win);
}
Ejemplo n.º 3
0
    void OptionsState::enter()
    {
        int screenWidth = graphicsEngine->getScreenWidth();
		int screenHeight = graphicsEngine->getScreenHeight();
		int halfScreenWidth = screenWidth / 2;
		int halfScreenHeight = screenHeight / 2;

        AG_Window *win = AG_WindowNew(AG_WINDOW_PLAIN|AG_WINDOW_DENYFOCUS);
		AG_WindowShow(win);
		AG_WindowMaximize(win);

		interfaceManager->addWindow(win);

		// create options window
		AG_Window *optionWindow = AG_WindowNewNamed(AG_WINDOW_NOBUTTONS, "OptionWindow");
		AG_WindowSetCaption(optionWindow, "Options");
		AG_WindowSetGeometry(optionWindow, halfScreenWidth - 85, halfScreenHeight - 85, 170, 170);

		// alignment
		AG_VBox *box = AG_VBoxNew(optionWindow, 0);

		// create list of resolutions
		Point pt;
		pt.x = 1024;
		pt.y = 768;
		mRes.push_back(pt);
		pt.x = 800;
		pt.y = 600;
		mRes.push_back(pt);
		pt.x = 1280;
		pt.y = 1024;
		mRes.push_back(pt);
		pt.x = 1440;
		pt.y = 900;
		mRes.push_back(pt);

		// add selection box for resolution
        selectionBox = AG_UComboNew(box, 0);
        AG_ExpandHoriz(selectionBox);
        AG_UComboSizeHint(selectionBox, "Resolution", mRes.size());

        // loop through all the resolutions
        for (unsigned int i = 0; i < mRes.size(); ++i)
        {
            std::stringstream str;
            str << mRes[i].x << " x " << mRes[i].y;
            AG_TlistAddPtr(selectionBox->list, NULL, str.str().c_str(), &mRes[i]);
        }

        AG_TlistSelect(selectionBox->list, AG_TlistFirstItem(selectionBox->list));
        AG_SetEvent(selectionBox, "ucombo-selected", selected_resolution, NULL);

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

		// add checkbox for fullscreen
        AG_CheckboxNewInt(box, 0, "Fullscreen", &mFullscreen);

        // add checkbox for hardware acceleration
        AG_CheckboxNewInt(box, 0, "OpenGL", &mOpenGL);

        // add radio for languages
        const char *languages[] = { "English", "Portugues", "Espa\xc3\xb1ol", NULL};
        AG_RadioNewInt(box, 0, languages, &mLangs);

        AG_HBox *hbox = AG_HBoxNew(box, 0);
		// add button to apply
		AG_ButtonNewFn(hbox, 0, "Apply", apply_options, "%p%p%p", &mOpenGL, &mFullscreen, &mLangs);

		// add button to cancel
        AG_ButtonNewFn(hbox, 0, "Cancel", cancel_options, 0);

        AG_WindowShow(optionWindow);
        interfaceManager->addWindow(optionWindow);
    }