void JKG_Slice_Script_OnEsc(char **args) {

	menuDef_t *menu;

	menu = Menus_FindByName("jkg_slice");

	if (!menu) {
		// wtf?
		return;
	}

	// The escape button was pressed, see if we're currently displaying a dialog
	if (sliceData.dlgActive) {
		// Yes we are, check the type and process it
		if (sliceData.dlgType != DLGTYPE_BLANK) {
			if (sliceData.dlgid == DLGID_SERVER) {
				cgImports->SendClientCommand("~slc dlgresp 0");
			}
			JKG_Slice_Dialog_Close();
		}
	} else {
		// No dialogs are up, see if we're trying to run a program
		if (sliceData.inputState != INPUTSTATE_NORMAL) {
			// Abort the program
			sliceData.inputState = INPUTSTATE_NORMAL;
			Menu_ItemDisable(menu, "btn_stopslicing", 0);
			Menu_SetItemText(menu, "btn_runprogram", "Run program");
			Menu_ItemDisable(menu, "proglist", 0);
			Menu_SetItemText(menu, "progdesc", sliceData.programs[sliceData.selectedProgram].desc);
		} else {
			// Bring up the stop slicing dialog
			JKG_Slice_Dialog_Show("Are you sure you wish to stop slicing?", NULL, NULL, DLGTYPE_YESNO, DLGID_STOPSLICING);
		}
	}
}
static void JKG_Slice_Dialog_Show(const char *line1, const char *line2, const char *line3, int type, int dlgid) {
	menuDef_t *menu;
	
	sliceData.dlgActive = qtrue;

	if (line1) {
		Q_strncpyz(&sliceData.dlgText1[0], line1, 255);
	} else {
		sliceData.dlgText1[0] = 0;
	}

	if (line2) {
		Q_strncpyz(&sliceData.dlgText2[0], line2, 255);
	} else {
		sliceData.dlgText2[0] = 0;
	}

	if (line3) {
		Q_strncpyz(&sliceData.dlgText3[0], line3, 255);
	} else {
		sliceData.dlgText3[0] = 0;
	}

	sliceData.dlgType = type;
	sliceData.dlgid = dlgid;

	
	menu = Menus_FindByName("jkg_slice");

	if (!menu) {
		return;
	}

	// First, disable all controls on the interface
	Menu_ItemDisable(menu, "grid", 1);
	Menu_ItemDisable(menu, "prog", 1);
	Menu_ItemDisable(menu, "btns", 1);
	
	Menu_ClearFocus(menu);

	Menu_ShowItemByName(menu, "dialog", qtrue);
	if (type == DLGTYPE_OK) {
		Menu_ShowItemByName(menu, "btn_dialogok", qtrue);
	} else if (type == DLGTYPE_YESNO) {
		Menu_ShowItemByName(menu, "btn_dialogyesno", qtrue);
	}
}
void JKG_Slice_Script_RunProgram(char **args) {
	menuDef_t *menu;

	menu = Menus_FindByName("jkg_slice");

	if (!menu) {
		// wtf?
		return;
	}
	
	if (sliceData.selectedProgram == -1) {
		return;
	}

	if (sliceData.inputState != INPUTSTATE_NORMAL) {
		// Abort program
		sliceData.inputState = INPUTSTATE_NORMAL;
		Menu_ItemDisable(menu, "btn_stopslicing", 0);
		Menu_SetItemText(menu, "btn_runprogram", "Run program");
		Menu_ItemDisable(menu, "proglist", 0);
		Menu_SetItemText(menu, "progdesc", sliceData.programs[sliceData.selectedProgram].desc);
		return;
	}

	switch (sliceData.programs[sliceData.selectedProgram].type)
	{
	case PROGTYPE_NORMAL:
		cgImports->SendClientCommand(va("~slc runprog %s", sliceData.programs[sliceData.selectedProgram].ID));
		break;
	case PROGTYPE_NODE:
		sliceData.inputState = INPUTSTATE_AWAITINGNODE;
		Menu_ItemDisable(menu, "btn_stopslicing", 1);
		Menu_SetItemText(menu, "btn_runprogram", "Abort program");
		Menu_ItemDisable(menu, "proglist", 1);
		Menu_SetItemText(menu, "progdesc", "Please choose a node to run this program on");
		break;
	case PROGTYPE_INACTIVENODE:
		sliceData.inputState = INPUTSTATE_AWAITINGINACTIVENODE;
		Menu_ItemDisable(menu, "btn_stopslicing", 1);
		Menu_SetItemText(menu, "btn_runprogram", "Abort program");
		Menu_ItemDisable(menu, "proglist", 1);
		Menu_SetItemText(menu, "progdesc", "Please choose an inactive node to run this program on");
		break;
	case PROGTYPE_LINE:
		sliceData.inputState = INPUTSTATE_AWAITINGLINE;
		Menu_ItemDisable(menu, "btn_stopslicing", 1);
		Menu_SetItemText(menu, "btn_runprogram", "Abort program");
		Menu_ItemDisable(menu, "proglist", 1);
		Menu_SetItemText(menu, "progdesc", "Please choose a row or column to run this program on");
		break;
	}
}
static void JKG_Slice_Dialog_Close() {
	menuDef_t *menu;

	sliceData.dlgActive = 0;
	
	menu = Menus_FindByName("jkg_slice");

	if (!menu) {
		return;
	}
	Menu_ShowItemByName(menu, "dialog", qfalse);
	Menu_ShowItemByName(menu, "btn_dialogok", qfalse);
	Menu_ShowItemByName(menu, "btn_dialogyesno", qfalse);
	
	Menu_ItemDisable(menu, "grid", 0);
	Menu_ItemDisable(menu, "prog", 0);
	Menu_ItemDisable(menu, "btns", 0);

	Menu_ClearFocus(menu);
}
예제 #5
0
static void PartyMngt_Dialog_Close() {
	menuDef_t *menu;

	PDlgData.InUse = 0;
	
	menu = Menus_FindByName("jkg_partymanagement");

	if (!menu) {
		return;
	}
	Menu_ShowItemByName(menu, "dialog", qfalse);
	Menu_ShowItemByName(menu, "btn_dialogok", qfalse);
	Menu_ShowItemByName(menu, "btn_dialogyesno", qfalse);
	Menu_ShowItemByName(menu, "btn_dialogtext", qfalse);
	
	Menu_ItemDisable(menu, "list", 0);
	Menu_ItemDisable(menu, "btn_noparty", 0);
	Menu_ItemDisable(menu, "btn_inparty", 0);
	Menu_ItemDisable(menu, "btn_inpartylead", 0);
	Menu_ItemDisable(menu, "btn_bottom", 0);

	Menu_ClearFocus(menu);
}
예제 #6
0
static void PartyMngt_Dialog_Show(const char *line1, const char *line2, const char *line3, int type, PDlgCallback callback) {
	menuDef_t *menu;
	itemDef_t *item;
	if (!callback) {
		return;
	}
	
	PDlgData.InUse = 1;

	if (line1) {
		Q_strncpyz(&PDlgData.line1[0], line1, 255);
	} else {
		PDlgData.line1[0] = 0;
	}

	if (line2) {
		Q_strncpyz(&PDlgData.line2[0], line2, 255);
	} else {
		PDlgData.line2[0] = 0;
	}

	if (line3) {
		Q_strncpyz(&PDlgData.line3[0], line3, 255);
	} else {
		PDlgData.line3[0] = 0;
	}

	PDlgData.type = type;
	PDlgData.callback = callback;

	
	menu = Menus_FindByName("jkg_partymanagement");

	if (!menu) {
		return;
	}

	// First, disable all controls on the interface
	Menu_ItemDisable(menu, "list", 1);
	Menu_ItemDisable(menu, "btn_noparty", 1);
	Menu_ItemDisable(menu, "btn_inparty", 1);
	Menu_ItemDisable(menu, "btn_inpartylead", 1);
	Menu_ItemDisable(menu, "btn_bottom", 1);
	
	Menu_ClearFocus(menu);

	Menu_ShowItemByName(menu, "dialog", qtrue);
	if (type == PDLG_OK) {
		Menu_ShowItemByName(menu, "btn_dialogok", qtrue);
	} else if (type == PDLG_YESNO) {
		Menu_ShowItemByName(menu, "btn_dialogyesno", qtrue);
	} else if (type == PDLG_TEXT) {
		Menu_ShowItemByName(menu, "btn_dialogtext", qtrue);
		// Clear the text
		item = Menu_FindItemByName(menu, "dlg_textentry");
		if (item) {
			item->typeData.edit->buffer[0] = 0;
			item->cursorPos = 0;
			Menu_SetTextFieldFocus(item);
		}
	} else {
		// Invalid dialog type!
		assert(0);
	}
}