Exemple #1
0
// ////////////////////////////////////////////////////////////////////////////
bool startKeyMapEditor(bool first)
{
	addBackdrop();
	addSideText(FRONTEND_SIDETEXT, KM_SX, KM_Y, _("KEY MAPPING"));

	if (first)
	{
		loadKeyMap();									// get the current mappings.
	}

	WIDGET *parent = widgGetFromID(psWScreen, FRONTEND_BACKDROP);

	IntFormAnimated *kmForm = new IntFormAnimated(parent, false);
	kmForm->id = KM_FORM;
	kmForm->setGeometry(KM_X, KM_Y, KM_W, KM_H);

	addMultiBut(psWScreen, KM_FORM, KM_RETURN,			// return button.
	            8, 5,
	            iV_GetImageWidth(FrontImages, IMAGE_RETURN),
	            iV_GetImageHeight(FrontImages, IMAGE_RETURN),
	            _("Return To Previous Screen"), IMAGE_RETURN, IMAGE_RETURN_HI, IMAGE_RETURN_HI);

	addMultiBut(psWScreen, KM_FORM, KM_DEFAULT,
	            11, 45,
	            iV_GetImageWidth(FrontImages, IMAGE_KEYMAP_DEFAULT), iV_GetImageWidth(FrontImages, IMAGE_KEYMAP_DEFAULT),
	            _("Select Default"),
	            IMAGE_KEYMAP_DEFAULT, IMAGE_KEYMAP_DEFAULT_HI, IMAGE_KEYMAP_DEFAULT_HI);	// default.

	// add tab form..
	IntListTabWidget *kmList = new IntListTabWidget(kmForm);
	kmList->setChildSize(KM_ENTRYW, KM_ENTRYH);
	kmList->setChildSpacing(3, 3);
	kmList->setGeometry(52, 10, KM_ENTRYW, KM_H - 10 - 25);

	//Put the buttons on it
	std::vector<KEY_MAPPING *> mappings;
	for (KEY_MAPPING *m = keyMappings; m != nullptr; m = m->psNext)
	{
		if (m->status != KEYMAP__DEBUG && m->status != KEYMAP___HIDE)  // if it's not a debug mapping..
		{
			mappings.push_back(m);
		}
	}
	std::sort(mappings.begin(), mappings.end(), keyMappingSort);
	/* Add our first mapping to the form */
	/* Now add the others... */
	for (std::vector<KEY_MAPPING *>::const_iterator i = mappings.begin(); i != mappings.end(); ++i)
	{
		W_BUTTON *button = new W_BUTTON(kmList);
		button->id = KM_START + (i - mappings.begin());
		button->pUserData = *i;
		button->displayFunction = displayKeyMap;
		kmList->addWidgetToLayout(button);
	}

	/* Stop when the right number or when aphabetically last - not sure...! */
	/* Go home... */
	return true;
}
/* Add the Transporter Contents form */
bool intAddTransContentsForm(void)
{
	WIDGET *contForm = widgGetFromID(psWScreen, IDTRANS_CONTENTFORM);

	/* Add the contents form */
	IntListTabWidget *contList = new IntListTabWidget(contForm);
	contList->setChildSize(OBJ_BUTWIDTH, OBJ_BUTHEIGHT);
	contList->setChildSpacing(OBJ_GAP, OBJ_GAP);
	int contListWidth = OBJ_BUTWIDTH*2 + OBJ_GAP;
	contList->setGeometry((contForm->width() - contListWidth)/2, TRANSCONT_TABY, contListWidth, contForm->height() - TRANSCONT_TABY);

	/* Add the transporter contents buttons */
	int nextButtonId = IDTRANS_CONTSTART;

	//add each button
	if (psCurrTransporter == nullptr)
	{
		return true;
	}

	for (DROID *psDroid = psCurrTransporter->psGroup->psList; psDroid != nullptr && psDroid != psCurrTransporter; psDroid = psDroid->psGrpNext)
	{
		if (psDroid->selected)
		{
			continue;  // Droid is queued to be ejected from the transport, so don't display it.
		}

		/* Set the tip and add the button */
		IntTransportButton *button = new IntTransportButton(contList);
		button->id = nextButtonId;
		button->setTip(droidGetName(psDroid));
		button->setObject(psDroid);
		contList->addWidgetToLayout(button);

		/* Update the init struct for the next button */
		++nextButtonId;
		ASSERT(nextButtonId < IDTRANS_CONTEND, "Too many Transporter Droid buttons");
	}
	return true;
}
Exemple #3
0
// ////////////////////////////////////////////////////////////////////////////
bool startLimitScreen(void)
{
	addBackdrop();//background

	// load stats...
	if(!bLimiterLoaded)
	{
		initLoadingScreen(true);
		
		if (!resLoad("wrf/limiter_tex.wrf", 501))
		{
			return false;
		}

		if (!resLoad("wrf/piestats.wrf", 502))
		{
			return false;
		}

		if (!resLoad("wrf/limiter_data.wrf", 503))
		{
			return false;
		}

		bLimiterLoaded = true;

		closeLoadingScreen();		
	}

	if (challengeActive)
	{
		// reset the sliders..
		// it's a HACK since the actual limiter structure was cleared in the startMultiOptions function 
		for (unsigned i = 0; i < numStructureStats; ++i)
		{
			asStructLimits[0][i].limit = asStructLimits[0][i].globalLimit;
		}
		
		// turn off the sliders
		sliderEnableDrag(false);
	}
	else
	{
		//enable the sliders
		sliderEnableDrag(true);
	}

	addSideText(FRONTEND_SIDETEXT1,LIMITSX-2,LIMITSY,"LIMITS");	// draw sidetext...

	WIDGET *parent = widgGetFromID(psWScreen, FRONTEND_BACKDROP);

	IntFormAnimated *limitsForm = new IntFormAnimated(parent, false);
	limitsForm->id = IDLIMITS;
	limitsForm->setGeometry(LIMITSX, LIMITSY, LIMITSW, LIMITSH);

	// return button.
	addMultiBut(psWScreen,IDLIMITS,IDLIMITS_RETURN,
					LIMITS_OKX-40,LIMITS_OKY,
	            iV_GetImageWidth(FrontImages, IMAGE_NO),
	            iV_GetImageHeight(FrontImages, IMAGE_NO),
					_("Apply Defaults and Return To Previous Screen"),IMAGE_NO,IMAGE_NO,true);

	// ok button
	addMultiBut(psWScreen,IDLIMITS,IDLIMITS_OK,
					LIMITS_OKX,LIMITS_OKY,
					iV_GetImageWidth(FrontImages,IMAGE_OK),
					iV_GetImageHeight(FrontImages,IMAGE_OK),
					_("Accept Settings"),IMAGE_OK,IMAGE_OK,true);

	// add tab form..
	IntListTabWidget *limitsList = new IntListTabWidget(limitsForm);
	limitsList->setChildSize(BARWIDTH, BARHEIGHT);
	limitsList->setChildSpacing(5, 5);
	limitsList->setGeometry(50, 10, BARWIDTH, 370);

	//Put the buttons on it
	int limitsButtonId = IDLIMITS_ENTRIES_START;

	for (unsigned i = 0; i < numStructureStats; ++i)
	{
		if (asStructLimits[0][i].globalLimit != LOTS_OF)
		{
			W_FORM *button = new W_FORM(limitsList);
			button->id = limitsButtonId;
			button->displayFunction = displayStructureBar;
			button->UserData = i;
			limitsList->addWidgetToLayout(button);
			++limitsButtonId;

			addFESlider(limitsButtonId, limitsButtonId - 1, 290, 11,
						asStructLimits[0][i].globalLimit,
						asStructLimits[0][i].limit);
			++limitsButtonId;
		}
	}

	return true;
}
/* Add the Droids back at home form */
bool intAddDroidsAvailForm(void)
{
	// Is the form already up?
	bool Animate = true;
	if (widgGetFromID(psWScreen, IDTRANS_DROIDS) != NULL)
	{
		intRemoveTransDroidsAvailNoAnim();
		Animate = false;
	}

	if (intIsRefreshing())
	{
		Animate = false;
	}

	WIDGET *parent = psWScreen->psForm;

	/* Add the droids available form */
	IntFormAnimated *transDroids = new IntFormAnimated(parent, Animate);  // Do not animate the opening, if the window was already open.
	transDroids->id = IDTRANS_DROIDS;
	transDroids->setGeometry(TRANSDROID_X, TRANSDROID_Y, TRANSDROID_WIDTH, TRANSDROID_HEIGHT);

	/* Add the close button */
	W_BUTINIT sButInit;
	sButInit.formID = IDTRANS_DROIDS;
	sButInit.id = IDTRANS_DROIDCLOSE;
	sButInit.x = TRANSDROID_WIDTH - CLOSE_WIDTH;
	sButInit.y = 0;
	sButInit.width = CLOSE_WIDTH;
	sButInit.height = CLOSE_HEIGHT;
	sButInit.pTip = _("Close");
	sButInit.pDisplay = intDisplayImageHilight;
	sButInit.UserData = PACKDWORD_TRI(0, IMAGE_CLOSEHILIGHT , IMAGE_CLOSE);
	if (!widgAddButton(psWScreen, &sButInit))
	{
		return false;
	}

	//now add the tabbed droids available form
	IntListTabWidget *droidList = new IntListTabWidget(transDroids);
	droidList->id = IDTRANS_DROIDTAB;
	droidList->setChildSize(OBJ_BUTWIDTH, OBJ_BUTHEIGHT);
	droidList->setChildSpacing(OBJ_GAP, OBJ_GAP);
	int droidListWidth = OBJ_BUTWIDTH*2 + OBJ_GAP;
	droidList->setGeometry((TRANSDROID_WIDTH - droidListWidth)/2, AVAIL_STARTY + 15, droidListWidth, TRANSDROID_HEIGHT - (AVAIL_STARTY + 15));

	/* Add the droids available buttons */
	int nextButtonId = IDTRANS_DROIDSTART;

	/* Add the state of repair bar for each droid*/
	W_BARINIT sBarInit;
	sBarInit.id = IDTRANS_REPAIRBARSTART;
	sBarInit.x = STAT_TIMEBARX;
	sBarInit.y = STAT_TIMEBARY;
	sBarInit.width = STAT_PROGBARWIDTH;
	sBarInit.height = STAT_PROGBARHEIGHT;
	sBarInit.size = 50;
	sBarInit.sCol = WZCOL_ACTION_PROGRESS_BAR_MAJOR;
	sBarInit.sMinorCol = WZCOL_ACTION_PROGRESS_BAR_MINOR;

	//add droids built before the mission
	for (DROID *psDroid = mission.apsDroidLists[selectedPlayer]; psDroid != nullptr; psDroid = psDroid->psNext)
	{
		//stop adding the buttons once IDTRANS_DROIDEND has been reached
		if (nextButtonId == IDTRANS_DROIDEND)
		{
			break;
		}
		//don't add Transporter Droids!
		if ((psDroid->droidType != DROID_TRANSPORTER && psDroid->droidType != DROID_SUPERTRANSPORTER))
		{
			/* Set the tip and add the button */
			IntTransportButton *button = new IntTransportButton(droidList);
			button->id = nextButtonId;
			button->setTip(droidGetName(psDroid));
			button->setObject(psDroid);
			droidList->addWidgetToLayout(button);

			//add bar to indicate stare of repair
			sBarInit.size = (UWORD) PERCENT(psDroid->body, psDroid->originalBody);
			if (sBarInit.size > 100)
			{
				sBarInit.size = 100;
			}

			sBarInit.formID = nextButtonId;
			//sBarInit.iRange = TBAR_MAX_REPAIR;
			if (!widgAddBarGraph(psWScreen, &sBarInit))
			{
				return false;
			}

			/* Update the init struct for the next button */
			++nextButtonId;
			ASSERT(nextButtonId < IDTRANS_DROIDEND, "Too many Droids Built buttons");

			//and bar
			sBarInit.id += 1;
		}
	}

	//reset which tab we were on
	droidList->setCurrentPage(objMajor);

	return true;
}
/* Add the Transporter Button form */
bool intAddTransButtonForm(void)
{
	WIDGET *transForm = widgGetFromID(psWScreen, IDTRANS_FORM);

	/* Add the button form */
	IntListTabWidget *transList = new IntListTabWidget(transForm);
	transList->setChildSize(OBJ_BUTWIDTH, OBJ_BUTHEIGHT*2);
	transList->setChildSpacing(OBJ_GAP, OBJ_GAP);
	int objListWidth = OBJ_BUTWIDTH*5 + OBJ_GAP*4;
	transList->setGeometry((OBJ_BACKWIDTH - objListWidth)/2, TRANS_TABY, objListWidth, transForm->height() - TRANS_TABY);

	/* Add the transporter and status buttons */
	int nextObjButtonId = IDTRANS_START;
	int nextStatButtonId = IDTRANS_STATSTART;

	//add each button
	for (DROID *psDroid = transInterfaceDroidList(); psDroid; psDroid = psDroid->psNext)
	{
		if ((psDroid->droidType != DROID_TRANSPORTER && psDroid->droidType != DROID_SUPERTRANSPORTER) ||
		    psDroid->action == DACTION_TRANSPORTOUT || psDroid->action == DACTION_TRANSPORTIN)
		{
			continue;
		}

		WIDGET *buttonHolder = new WIDGET(transList);
		transList->addWidgetToLayout(buttonHolder);

		IntStatusButton *statButton = new IntStatusButton(buttonHolder);
		statButton->id = nextStatButtonId;
		statButton->setGeometry(0, 0, OBJ_BUTWIDTH, OBJ_BUTHEIGHT);

		IntObjectButton *objButton = new IntObjectButton(buttonHolder);
		objButton->id = nextObjButtonId;
		objButton->setGeometry(0, OBJ_STARTY, OBJ_BUTWIDTH, OBJ_BUTHEIGHT);

		/* Set the tip and add the button */
		objButton->setTip(droidGetName(psDroid));
		objButton->setObject(psDroid);

		//set the first Transporter to be the current one if not already set
		if (psCurrTransporter == nullptr)
		{
			psCurrTransporter = psDroid;
		}

		/* if the current droid matches psCurrTransporter lock the button */
		if (psDroid == psCurrTransporter)
		{
			objButton->setState(WBUT_LOCK);
			transList->setCurrentPage(transList->pages() - 1);
		}

		//now do status button
		statButton->setObject(nullptr);

		/* Update the init struct for the next buttons */
		++nextObjButtonId;
		ASSERT(nextObjButtonId < IDTRANS_END, "Too many Transporter buttons");

		++nextStatButtonId;
		ASSERT(nextStatButtonId < IDTRANS_STATEND, "Too many Transporter status buttons");
	}
	return true;
}
Exemple #6
0
/** Searches in the given search directory for files ending with the
 *  given extension. Then will create a window with buttons for each
 *  found file.
 *  \param searchDir the directory to search in
 *  \param fileExtension the extension files should end with, if the
 *         extension has a dot (.) then this dot _must_ be present as
 *         the first char in this parameter
 *  \param mode (purpose unknown)
 *  \param numPlayers (purpose unknown)
 */
void addMultiRequest(const char* searchDir, const char* fileExtension, UDWORD mode, UBYTE mapCam, UBYTE numPlayers)
{
	const unsigned int extensionLength = strlen(fileExtension);
	const unsigned int buttonsX = (mode == MULTIOP_MAP) ? 22 : 17;

	context = mode;
	if(mode == MULTIOP_MAP)
	{	// only save these when they select MAP button
		current_tech = mapCam;
		current_numplayers = numPlayers;
	}
	char **fileList = PHYSFS_enumerateFiles(searchDir);

	psRScreen = new W_SCREEN; ///< move this to intinit or somewhere like that.. (close too.)

	WIDGET *parent = psRScreen->psForm;

	/* add a form to place the tabbed form on */
	IntFormAnimated *requestForm = new IntFormAnimated(parent);
	requestForm->id = M_REQUEST;
	requestForm->setGeometry(M_REQUEST_X + D_W, M_REQUEST_Y + D_H, M_REQUEST_W, M_REQUEST_H);

	// Add the button list.
	IntListTabWidget *requestList = new IntListTabWidget(requestForm);
	requestList->setChildSize(R_BUT_W, R_BUT_H);
	requestList->setChildSpacing(4, 4);
	requestList->setGeometry(2 + buttonsX, 2, M_REQUEST_W - buttonsX, M_REQUEST_H - 4);

	// Add the close button.
	W_BUTINIT sButInit;
	sButInit.formID = M_REQUEST;
	sButInit.id = M_REQUEST_CLOSE;
	sButInit.x = M_REQUEST_W - CLOSE_WIDTH - 3;
	sButInit.y = 0;
	sButInit.width = CLOSE_WIDTH;
	sButInit.height = CLOSE_HEIGHT;
	sButInit.pTip = _("Close");
	sButInit.pDisplay = intDisplayImageHilight;
	sButInit.UserData = PACKDWORD_TRI(0,IMAGE_CLOSEHILIGHT , IMAGE_CLOSE);
	widgAddButton(psRScreen, &sButInit);

	// Put the buttons on it.
	int nextButtonId = M_REQUEST_BUT;
	for (char **currFile = fileList; *currFile != NULL; ++currFile)
	{
		const unsigned int fileNameLength = strlen(*currFile);

		// Check to see if this file matches the given extension
		if (fileNameLength <= extensionLength
		 || strcmp(&(*currFile)[fileNameLength - extensionLength], fileExtension) != 0)
			continue;

		char *withoutExtension = strdup(*currFile);
		withoutExtension[fileNameLength - extensionLength] = '\0';

		// Set the tip and add the button
		W_BUTTON *button = new W_BUTTON(requestList);
		button->id = nextButtonId;
		button->setTip(withoutExtension);
		button->setString(withoutExtension);
		button->displayFunction = displayRequestOption;
		requestList->addWidgetToLayout(button);

		free(withoutExtension);

		/* Update the init struct for the next button */
		++nextButtonId;
	}

	// Make sure to return memory back to PhyscisFS
	PHYSFS_freeList(fileList);

	multiRequestUp = true;
	hoverPreviewId = 0;

	if(mode == MULTIOP_MAP)
	{
		LEVEL_DATASET *mapData;
		bool first = true;
		while ((mapData = enumerateMultiMaps(first, mapCam, numPlayers)) != NULL)
		{
			first = false;

			// add number of players to string.
			W_BUTTON *button = new W_BUTTON(requestList);
			button->id = nextButtonId;
			button->setTip(mapData->pName);
			button->setString(mapData->pName);
			button->pUserData = mapData;
			button->displayFunction = displayRequestOption;
			requestList->addWidgetToLayout(button);

			++nextButtonId;
		}

		// if it's map select then add the cam style buttons.
		sButInit = W_BUTINIT();
		sButInit.formID		= M_REQUEST;
		sButInit.id		= M_REQUEST_C1;
		sButInit.x              = 3;
		sButInit.y              = 254;
		sButInit.width		= 17;
		sButInit.height		= 17;
		sButInit.UserData	= 1;
		sButInit.pTip		= _("Technology level 1");
		sButInit.pDisplay	= displayCamTypeBut;

		widgAddButton(psRScreen, &sButInit);

		sButInit.id		= M_REQUEST_C2;
		sButInit.y		+= 22;
		sButInit.UserData	= 2;
		sButInit.pTip		= _("Technology level 2");
		widgAddButton(psRScreen, &sButInit);

		sButInit.id		= M_REQUEST_C3;
		sButInit.y		+= 22;
		sButInit.UserData	= 3;
		sButInit.pTip		= _("Technology level 3");
		widgAddButton(psRScreen, &sButInit);

		sButInit.id		= M_REQUEST_AP;
		sButInit.y		= 17;
		sButInit.UserData	= 0;
		sButInit.pTip		= _("Any number of players");
		sButInit.pDisplay	= displayNumPlayersBut;
		widgAddButton(psRScreen, &sButInit);

		STATIC_ASSERT(MAX_PLAYERS_IN_GUI <= ARRAY_SIZE(M_REQUEST_NP) + 1);
		for (unsigned numPlayers = 2; numPlayers <= MAX_PLAYERS_IN_GUI; ++numPlayers)
		{
			static char ttip[MAX_PLAYERS_IN_GUI + 1][20];
			sButInit.id             = M_REQUEST_NP[numPlayers - 2];
			sButInit.y		+= 22;
			sButInit.UserData	= numPlayers;
			ssprintf(ttip[numPlayers], ngettext("%d player", "%d players", numPlayers), numPlayers);
			sButInit.pTip		= ttip[numPlayers];
			widgAddButton(psRScreen, &sButInit);
		}
	}
}