Example #1
0
void _ARMIA_RYSUJ_ROZKAZY(aint A) {
	aint AWT=0,WYS=0,TRYB=0,TEREN=0;
	TEREN=ARMIA[A][0][TNOGI];
	AWT=ARMIA[A][0][TWAGA];									//	   AWT=ARMIA(A,0,TWAGA)
	if( AWT==1 ) {													//	   If AWT=1
		WYS=135;															//	      WYS=135
	} else {																//	   Else
		WYS=150;															//	      WYS=150
	}																				//	   End If
	OKNO(110,70,80,WYS);										//	   OKNO[110,70,80,WYS]
	GADGET(OKX+4,OKY+4,72,15,GS("178"),8,2,6,31,1);		//	   GADGET[OKX+4,OKY+4,72,15,"Move",8,2,6,31,1]
	GADGET(OKX+4,OKY+40,72,15,GS("179"),8,2,6,31,3);	//	   GADGET[OKX+4,OKY+40,72,15,"Attack",8,2,6,31,3]
	GADGET(OKX+4,OKY+2+20,72,15,GS("180"),8,2,6,31,2);//	   GADGET[OKX+4,OKY+2+20,72,15,"Fast Move",8,2,6,31,2]
	if( TEREN<70 ) {												//	   If TEREN<70
		GADGET(OKX+4,OKY+58,72,15,GS("181"),8,2,6,31,4); //	      GADGET[OKX+4,OKY+58,72,15,"Hunt",8,2,6,31,4]
	} else {																//	   Else
		GADGET(OKX+4,OKY+58,72,15,GS("182"),8,2,6,31,4); //	      GADGET[OKX+4,OKY+58,72,15,"Recruit",8,2,6,31,4]
	}																				//	   End If
	GADGET(OKX+4,OKY+76,72,15,GS("183"),8,2,6,31,5);				//	   GADGET[OKX+4,OKY+76,72,15,"Camp",8,2,6,31,5]
	GADGET(OKX+4,OKY+94,72,15,GS("184"),8,2,6,31,6);	//	   GADGET[OKX+4,OKY+94,72,15,"Equipment",8,2,6,31,6]
	if( AWT==0 ) {													//	   If AWT=0
		GADGET(OKX+4,OKY+112,72,15,GS("185"),8,2,6,31,8);	//	      GADGET[OKX+4,OKY+112,72,15,"Action",8,2,6,31,8]
		GADGET(OKX+4,OKY+130,72,15,GS("186"),8,2,6,31,7);		//	      GADGET[OKX+4,OKY+130,72,15,"Exit",8,2,6,31,7]
	} else {																//	   Else
		GADGET(OKX+4,OKY+112,72,15,GS("186"),8,2,6,31,7);		//	      GADGET[OKX+4,OKY+112,72,15,"Exit",8,2,6,31,7]
	}																				//	   End If
	TRYB=ARMIA[A][0][TTRYB];								//	   TRYB=ARMIA(A,0,TTRYB)
	Gfx::Color(1.f,1.f,1.f);								//	   Ink 23,6
	if( TRYB>0 ) {													//	   If TRYB>0
		Text(OKX+65,OKY-4+18*TRYB,"@");				//	      Text OKX+65,OKY-4+18*TRYB,"@"
	}																				//	   End If
	if( TRYB==0 ) {													//	   If TRYB=0
		Text(OKX+65,OKY-4+18*5,"@");					//	      Text OKX+65,OKY-4+18*5,"@"
	}																				//	   End If
}
Example #2
0
void PRZYGODA_INFO(aint NR) {
																	//	Procedure PRZYGODA_INFO[NR]
	aint TYP=0, DL=0, ZN=0;
	astr A_S="", L_S="", R_S="";
	OKNO(70,100,180,23);						//	   OKNO[70,100,180,23]
	TYP=PRZYGODY[NR][P_TYP];				//	   TYP=PRZYGODY(NR,P_TYP)
	A_S=PRZYGODY_S[TYP][0];					//	   A$=PRZYGODY$(TYP,0)
	if( IM_PRZYGODY_S[NR] != "" ) {	//	   If IM_PRZYGODY$(NR)<>""
		DL=Len(A_S);									//	      DL=Len(A$)
		ZN=Instr(A_S,"$");						//	      ZN=Instr(A$,"$")
		if( ZN>0 ) {									//	      If ZN>0
			A_S=Minus_S(A_S,"$");				//	         A$=A$-"$"
			L_S=Left_S(A_S,ZN-1);				//	         L$=Left$(A$,ZN-1)
			R_S=Right_S(A_S,DL-ZN-1);		//	         R$=Right$(A$,DL-ZN-1)
			A_S=L_S+IM_PRZYGODY_S[NR]+R_S;//	         A$=L$+IM_PRZYGODY$(NR)+R$
		}															//	      End If
	}																//	   End If
	GADGET(OKX+4,OKY+4,172,15,A_S,31,2,30,1,-1);//	   GADGET[OKX+4,OKY+4,172,15,A$,31,2,30,1,-1]
	do {														//	   Repeat
		rysuj();
		GADGET(OKX+4,OKY+4,172,15,A_S,31,2,30,1,-1);//	   GADGET[OKX+4,OKY+4,172,15,A$,31,2,30,1,-1]
		WaitVbl();
	} while( MouseClick()!=1 );			//	   Until Mouse Click=1
	ZOKNO();												//	   ZOKNO
																	//	End Proc
}
// Start editing a line
void funced_start_edit(FuncEdData *data)
{
	// Set lister selection
	SetGadgetValue(
		data->objlist,
		GAD_FUNCED_LISTER,
		Att_NodeDataNumber(data->func_display_list,data->edit_node->data));

	// Copy string
	SetGadgetValue(
		data->objlist,
		GAD_FUNCED_EDIT,
		(ULONG)((FunctionEntry *)data->edit_node->data)->buffer);
	DisableObject(data->objlist,GAD_FUNCED_EDIT,FALSE);

	// Set function type
	SetGadgetValue(
		data->objlist,
		GAD_FUNCED_FUNCTION_TYPE,
		((FunctionEntry *)data->edit_node->data)->type);
	DisableObject(data->objlist,GAD_FUNCED_FUNCTION_TYPE,FALSE);

	// Enable some gadgets
	DisableObject(data->objlist,GAD_FUNCED_INSERT_ENTRY,FALSE);
	DisableObject(data->objlist,GAD_FUNCED_DELETE_ENTRY,FALSE);

	// Enable popup list if not a command, or if command & we have function list
	DisableObject(data->objlist,GAD_FUNCED_EDIT_GLASS,
		(((FunctionEntry *)data->edit_node->data)->type==INST_COMMAND && !data->startup->func_list));
	DisableObject(data->objlist,GAD_FUNCED_EDIT_ARGUMENT,
		(((FunctionEntry *)data->edit_node->data)->type==INST_COMMAND && !data->startup->func_list));

	// Activate gadget
	ActivateStrGad(GADGET(GetObject(data->objlist,GAD_FUNCED_EDIT)),data->window);
}
Example #4
0
void SDIR(astr A_S,aint K1,aint K2) {
																								//	Procedure SDIR[A$,K1,K2]
	aint I;
	astr PAT_S="", NAME_S="";
	OKNO(100,60,140,160);													//	   OKNO[100,60,140,160]
	GADGET(OKX+10,OKY+8,120,15,A_S,K1,0,K2,31,-1);//	   GADGET[OKX+10,OKY+8,120,15,A$,K1,0,K2,31,-1]
																								//	   If Exist(KAT$+"archiwum")
	PAT_S=KAT_S+"archiwum/";											//	      PAT$=KAT$+"archiwum/"
	if( ! DirExists(PAT_S) ) {
		PAT_S="./";
	}
																								//	   Else
																								//	      REQUEST["archiwum:","Archiwum"]
																								//	      PAT$="archiwum:"
																								//	   End If
																								//
	for( I=0; I<=4; ++I ) {												//	   For I=0 To 4
		NAME_S = _sdir_get_file_name(I);
		GADGET(OKX+10,OKY+28+(I*20),120,15,NAME_S,8,1,6,31,I+1);//	      GADGET[OKX+10,OKY+28+(I*20),120,15,NAME$,8,1,6,31,I+1]
	}																							//	   Next
	GADGET(OKX+10,OKY+128,120,15,GS("226"),8,1,6,31,6);//	   GADGET[OKX+10,OKY+128,120,15,"Exit",8,1,6,31,6]
	Param_S=PAT_S;																							//	End Proc[PAT$]
}
Example #5
0
void EKRAN1(void) {
	//	Procedure EKRAN1
	Screen(1);																//	   Screen 1
	Gfx::Cls(0,0,0);													//	   Cls 0 : Paste Bob 0,0,1
	PasteBob(0,0,1);
  GADGET(200,2,20,20,"bob3",2,0,19,5,1);		//	   GADGET[200,2,20,20,"bob3",2,0,19,5,1]
  GADGET(222,2,20,20,"bob4",2,0,19,5,2);		//	   GADGET[222,2,20,20,"bob4",2,0,19,5,2]
  GADGET(244,2,20,20,"bob5",2,0,19,5,3);		//	   GADGET[244,2,20,20,"bob5",2,0,19,5,3]
  GADGET(266,2,20,20,"bob6",2,0,19,5,4);		//	   GADGET[266,2,20,20,"bob6",2,0,19,5,4]
  GADGET(297,2,20,20,"bob7",2,0,19,5,10);		//	   GADGET[297,2,20,20,"bob7",2,0,19,5,10]
  GADGET(170,2,20,20,"bob2",2,0,19,5,5);		//	   GADGET[170,2,20,20,"bob2",2,0,19,5,5]
  GADGET(147,2,20,20,"bob8",2,0,19,5,9);		//	   GADGET[147,2,20,20,"bob8",2,0,19,5,9]
  GADGET(2,2,140,20,"",0,1,19,16,0);				//	   GADGET[2,2,140,20,"",0,1,19,16,0]

	_store_ekran1();
	//	End Proc
}
Example #6
0
void _M_RUCH_INFO(astr A_S) {
	aint KONIEC=0;
	rysuj(); MouseClick();
																					//	   INFO:
	OKNO(90,100,158,22);										//	   OKNO[90,100,158,22]
	GADGET(OKX+4,OKY+4,150,15,"",31,2,30,1,0);//	   GADGET[OKX+4,OKY+4,150,15,"",31,2,30,1,0]
	gad_text(1.0); Text(OKX+8,OKY+15,A_S);	//	   Ink 1,30 : Text OKX+8,OKY+15,A$
	void *sb=StoreBuffer(OKX-1,OKY-1,158+2,22+2);
	do {																		//	   Repeat
		rysuj();
		RestoreBuffer(sb);
		WaitVbl();
		if( MouseClick() ) {									//	      If Mouse Click=1
			KONIEC=-1;													//	         KONIEC=True
		}																			//	      End If
	} while( KONIEC==0 );										//	   Until KONIEC
	ZOKNO();																//	   ZOKNO
	FreeBuffer(sb);
	rysuj();
	WaitVbl();
}
Example #7
0
// Add an entry
void config_paths_add(config_path_data *data,BOOL activate)
{
	position_rec *pos;
	Att_Node *node;

	// Create a new entry
	if ((pos=(position_rec *)AllocMemH(data->memory,sizeof(position_rec)+256)))
	{
		// Initialise entry
		pos->node.ln_Type=PTYPE_POSITION;
		pos->node.ln_Name=pos->name;
		pos->flags|=POSITIONF_USER|POSITIONF_NEW;
		if (data->def_format)
			CopyMem((char *)data->def_format,(char *)&pos->format,sizeof(ListFormatStorage));

		// Initialise key
		pos->code=0xffff;

		// Add to list path list
		AddTail(data->paths,(struct Node *)pos);

		// Remove list from gadget
		SetGadgetChoices(data->objlist,GAD_PATHFORMAT_PATHS,(APTR)~0);

		// Add to lister
		node=Att_NewNode(data->path_list,0,(ULONG)pos,ADDNODE_SORT);

		// Attach list to gadget
		SetGadgetChoices(data->objlist,GAD_PATHFORMAT_PATHS,data->path_list);

		// Select the new node
		config_paths_select(data,node,TRUE);

		// Activate path field
		if (activate) ActivateStrGad(GADGET(GetObject(data->objlist,GAD_PATHFORMAT_PATH)),data->window);
	}
}
Example #8
0
// Change entry's path
void config_paths_change(config_path_data *data)
{
	char *str;
	BPTR lock;
	char path[256];
	position_rec *pos;
	Att_Node *node;
	struct List *search;

	// No path selected?
	if (!data->path_sel) return;

	// Get path string
	str=(char *)GetGadgetValue(data->objlist,GAD_PATHFORMAT_PATH);

	// Invalid?
	if (!str || !*str)
	{
		// Remove this path
		config_paths_remove(data,TRUE);
		return;
	}

	// Try to lock
	if ((lock=Lock(str,ACCESS_READ)))
	{
		// Get full pathname
		NameFromLock(lock,path,256);
		UnLock(lock);
	}

	// Otherwise, use entered path
	else strcpy(path,str);

	// Fix path with trailing /
	AddPart(path,"",256);

	// See if path is already in edit list
	if ((node=(Att_Node *)FindNameI((struct List *)data->path_list,path)))
	{
		// Not the currently selected node?
		if (node!=data->path_sel)
		{
			// Error
			DisplayBeep(data->window->WScreen);
			ActivateStrGad(GADGET(GetObject(data->objlist,GAD_PATHFORMAT_PATH)),data->window);
			return;
		}
	}

	// Is path already in snapshot list?
	search=data->paths;
	while ((pos=(position_rec *)FindNameI(search,path)))
	{
		// Position entry?
		if (pos->node.ln_Type==PTYPE_POSITION) break;
		search=(struct List *)pos;
	}

	// Found it?
	if (pos)
	{
		// Different entry?
		if (pos!=(position_rec *)data->path_sel->data)
		{
			// Remove current entry from list
			Remove((struct Node *)data->path_sel->data);

			// Free current data
			FreeMemH((void *)data->path_sel->data);
			data->path_sel->data=(ULONG)pos;
		}

		// If path exists, clear "new" flag
		if (lock) pos->flags&=~POSITIONF_NEW;
	}

	// It is now
	else pos=(position_rec *)data->path_sel->data;

	// Set its user flag
	pos->flags|=POSITIONF_USER;

	// Store new name
	strcpy(pos->name,path);

	// Remove list from gadget
	SetGadgetChoices(data->objlist,GAD_PATHFORMAT_PATHS,(APTR)~0);

	// Remove existing node and add new one
	Att_RemNode(data->path_sel);

	// Add to list
	data->path_sel=Att_NewNode(data->path_list,pos->node.ln_Name,(ULONG)pos,ADDNODE_SORT);

	// Attach list to gadget
	SetGadgetChoices(data->objlist,GAD_PATHFORMAT_PATHS,data->path_list);

	// Select the new node
	config_paths_select(data,data->path_sel,TRUE);
}
void FunctionEditor(void)
{
	struct IntuiMessage *gmsg,msg;
	int break_flag=0;
	UWORD gadgetid=0;
	ULONG waitbits;
	FuncEdData *data;
	IPCData *ipc;
	NewConfigWindow newwin;
	FunctionStartup *startup=0;
	IPCMessage *submsg;
	int success=0;
	BOOL open_window=1;
	BPTR lock;
	ConfigWindow windims;

	// Do startup
	if (!(ipc=Local_IPC_ProcStartup((ULONG *)&startup, (APTR)&funced_init)))
	{
		funced_cleanup(startup->data);
		return;
	}

	// Get data pointer
	data=startup->data;

	// Lock RAM: and CD to it
	if ((lock=Lock("ram:",ACCESS_READ)))
		lock=CurrentDir(lock);

	// Copy dimensions
	if (startup->flags&FUNCEDF_CENTER)
		windims=_function_editor_window_center;
	else
	if (startup->flags&FUNCEDF_LABEL)
		windims=_function_editor_label_window;
	else
		windims=_function_editor_window;

	// Fill in new window
	newwin.parent=startup->window;
	newwin.dims=&windims;
	newwin.title=(startup->title[0])?startup->title:(char *)GetString(startup->locale,MSG_FUNCED_TITLE);
	newwin.locale=startup->locale;
	newwin.port=0;
	newwin.flags=WINDOW_VISITOR|WINDOW_AUTO_KEYS|WINDOW_REQ_FILL;//|WINDOW_SIZE_BOTTOM;
	newwin.font=0;

	// Build flag list
	funced_build_flaglist(data);
	waitbits=1<<ipc->command_port->mp_SigBit|1<<data->drag.timer->port->mp_SigBit;

	// Event loop
	FOREVER
	{
		// Check drag
		if (config_drag_check(&data->drag))
		{
			// End drag
			functioned_end_drag(data,0);
		}

		// Task message?
		while ((submsg=(IPCMessage *)GetMsg(ipc->command_port)))
		{
			// Close message?
			if (submsg->command==IPC_QUIT)
			{
				// Keep changes?
				success=submsg->flags;

				// Set break flag
				break_flag=1;
			}

			// Activate
			else
			if (submsg->command==IPC_ACTIVATE && data->window)
			{
				WindowToFront(data->window);
				ActivateWindow(data->window);
			}

			// Hide
			else
			if (submsg->command==IPC_HIDE && data->window)
			{
				// Store changes in function
				funced_store_edits(data);

				// End any drag in progress
				functioned_end_drag(data,0);

				// Remove AppWindow
				RemoveAppWindow(data->appwindow);
				data->appwindow=0;

				// Close window
				CloseConfigWindow(data->window);

				// Zero stuff
				data->window=0;
				data->objlist=0;
				waitbits=1<<ipc->command_port->mp_SigBit;
			}

			// Show
			else
			if (submsg->command==IPC_SHOW && !data->window)
			{
				// Set flag to open window
				open_window=1;
				newwin.parent=(struct Window *)submsg->data;
			}

			// Passed-along app message
			else
			if (submsg->command==CFG_APPMESSAGE_PASS)
			{
				funced_appmsg(data,submsg->data);
				ReplyMsg((struct Message *)submsg->data);
			}

			// Update our identity
			else
			if (submsg->command==CFG_NEW_ID)
			{
				data->function->function.func_type=submsg->flags;
				startup->object_flags=(ULONG)submsg->data;
			}

			// Copy a function
			else
			if (submsg->command==FUNCTIONEDIT_COPY_LINE)
			{
				FunctionEntry *entry,*next;

				// Copy function
				functioned_copy_line(
					data,
					(FunctionEntry *)submsg->data,
					0,
					(Point *)submsg->data_free);

				// Free function
				entry=(FunctionEntry *)submsg->data;
				while (entry)
				{
					// Get next
					next=(FunctionEntry *)entry->node;

					// Free entry
					FreeVec(entry);
					entry=next;
				}
			}

			// Clip button
			else
			if (submsg->command==BUTTONEDIT_CLIP_BUTTON)
			{
				Cfg_ButtonFunction *func;

				// Show busy pointer
				SetWindowBusy(data->window);

				// Stop editing
				funced_end_edit(data,data->edit_node,0,0);
				data->edit_node=0;

				// Get first function
				if ((func=(Cfg_ButtonFunction *)
					FindFunctionType(
						(struct List *)&((Cfg_Button *)submsg->data)->function_list,
						FTYPE_LEFT_BUTTON)))
				{
					FunctionEntry dummy;
					Cfg_Instruction *ins;

					// Go through instructions
					for (ins=(Cfg_Instruction *)func->instructions.mlh_Head;
						ins->node.mln_Succ;
						ins=(Cfg_Instruction *)ins->node.mln_Succ)
					{
						// Fill out dummy entry
						dummy.type=ins->type;
						if (ins->string) strcpy(dummy.buffer,ins->string);
						else dummy.buffer[0]=0;

						// Copy function line
						data->edit_node=funced_new_entry(data,0,&dummy);
					}

					// Start editing last line
					funced_start_edit(data);

					// Get flags
					data->function->function.flags=func->function.flags;
					data->function->function.code=func->function.code;
					data->function->function.qual=func->function.qual;
					data->function->function.qual_mask=func->function.qual_mask;
					data->function->function.qual_same=func->function.qual_same;

					// Update flag list
					funced_update_flaglist(data);

					// Update key
					funced_show_key(data);
				}

				// Free button
				FreeButton((Cfg_Button *)submsg->data);

				// Clear busy pointer
				ClearWindowBusy(data->window);
			}

			// Reply the message
			IPC_Reply(submsg);
		}

		// Open window?
		if (open_window)
		{
			// Open window
			if (!(data->window=OpenConfigWindow(&newwin)) ||
				!(data->p_objlist=AddObjectList(
					data->window,
					(startup->flags&FUNCEDF_IMAGE)?_function_editor_image_objects:
						((startup->flags&FUNCEDF_LABEL)?_function_editor_label_objects:
														_function_editor_normal_objects))) ||
				!(data->objlist=AddObjectList(data->window,_function_editor_objects)))
				break;

			// Add use or save button
			AddObjectList(data->window,(startup->flags&FUNCEDF_SAVE)?_function_editor_objects_save:_function_editor_objects_use);

			// Store window for drag
			data->drag.window=data->window;

			// Set window ID
			SetWindowID(data->window,0,WINDOW_FUNCTION_EDITOR,(struct MsgPort *)ipc);

			// Add menus
			AddWindowMenus(data->window,_funced_menus);

			// Make this an AppWindow
			data->appwindow=AddAppWindowA(0,0,data->window,data->appport,0);

			// Get waitbits
			waitbits|=1<<data->window->UserPort->mp_SigBit;
			if (data->appwindow) waitbits|=1<<data->appport->mp_SigBit;

			// Disable key?
			if (startup->flags&FUNCEDF_NO_KEY)
			{
				DisableObject(data->objlist,GAD_FUNCED_KEY,TRUE);
			}

			// Initialise gadgets with function data.
			funced_init_gads(data);
			open_window=0;
		}

		// Intuimessage
		if (data->window)
		{
			while ((gmsg=GetWindowMsg(data->window->UserPort)))
			{
				Att_Node *node;

				// Copy message and reply (unless IDCMPUPDATE)
				msg=*gmsg;
				if (gmsg->Class!=IDCMP_IDCMPUPDATE)
				{
					ReplyWindowMsg(gmsg);
					gmsg=0;
				}

				// Get GadgetID
				if (msg.Class==IDCMP_GADGETDOWN ||
					msg.Class==IDCMP_GADGETUP)
					gadgetid=((struct Gadget *)msg.IAddress)->GadgetID;

				// Look at message
				switch (msg.Class)
				{
					// Key press
					case IDCMP_VANILLAKEY:

						// If editing something, activate string gadget
						if (data->edit_node)
							ActivateStrGad(GADGET(GetObject(data->objlist,GAD_FUNCED_EDIT)),data->window);
						break;


					// Close window
					case IDCMP_CLOSEWINDOW:

						// Set break flag
						break_flag=1;
						break;


					// Mouse move
					case IDCMP_MOUSEMOVE:

						// Handle drag move
						config_drag_move(&data->drag);
						break;


					// Inactive window does menu down
					case IDCMP_INACTIVEWINDOW:
						msg.Code=MENUDOWN;

					// Mouse buttons
					case IDCMP_MOUSEBUTTONS:

						// Valid drag info?
						if (data->drag.drag)
						{
							short ok=-1;

							// Dropped ok?
							if (msg.Code==SELECTUP)
							{
								// Is shift down?
								if (msg.Qualifier&(IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT))
									data->drag_shift=1;
								else data->drag_shift=0;

								// Remember last position
								data->drag.drag_x=data->window->WScreen->MouseX;
								data->drag.drag_y=data->window->WScreen->MouseY;
								ok=1;
							}

							// Aborted
							else
							if (msg.Code==MENUDOWN)
							{
								// Set abort
								ok=0;
							}

							// End drag?
							if (ok!=-1) functioned_end_drag(data,ok);
						}
						break;


					// Menu
					case IDCMP_MENUPICK:

						{
							struct MenuItem *item;

							// Get item
							if (!(item=ItemAddress(data->window->MenuStrip,msg.Code)))
								break;

							// Treat as gadget
							gadgetid=MENUID(item);
						}

					// Gadget
					case IDCMP_GADGETUP:
					case IDCMP_GADGETDOWN:

						// Look at gadget ID
						switch (gadgetid)
						{
							// Hotkey
							case GAD_FUNCED_KEY:
								{
									IX ix;
									char *ptr;

									// Get key, see if it's invalid
									if ((ptr=(char *)GetGadgetValue(data->objlist,GAD_FUNCED_KEY)) && *ptr)
									{
										// Try to parse
										if (ParseIX(ptr,&ix))
										{
											// Flash screen
											DisplayBeep(data->window->WScreen);

											// Activate key field again
											ActivateStrGad(GADGET(GetObject(data->objlist,GAD_FUNCED_KEY)),data->window);
										}
										else
										{
											data->function->function.code=ix.ix_Code;
											data->function->function.qual=QualValid(ix.ix_Qualifier);
											data->function->function.qual_mask=ix.ix_QualMask;
											data->function->function.qual_same=ix.ix_QualSame;
										}
									}
								}
								break;


							// Flag selected
							case GAD_FUNCED_FLAGS:

								// Get selected node
								node=Att_FindNode(data->flag_list,msg.Code);

								// Set flag
								data->function->function.flags^=node->data;

								// Check change
								funced_check_flag(&data->function->function.flags,node->data);

								// Update flag list
								funced_update_flaglist(data);
								break;


							// Edit a line
							case GAD_FUNCED_LISTER:

								// Get selected node
								node=Att_FindNode(data->func_display_list,msg.Code);

								// Is this the node we're already editing?
								if (node==data->edit_node) break;

								// If we're editing another one, store its contents
								if (data->edit_node)
									funced_end_edit(data,data->edit_node,0,0);

								// Start editing this entry
								data->edit_node=node;
								funced_start_edit(data);
								break;


							// Return pressed in edit line
							case GAD_FUNCED_EDIT:

								// See if we were editing something
								if (data->edit_node)
								{
									// Stop editing
									funced_end_edit(data,data->edit_node,END_DISABLE,msg.Qualifier);
									data->edit_node=0;
								}
								break;


							// New entry
							case GAD_FUNCED_NEW_ENTRY:
							case GAD_FUNCED_INSERT_ENTRY:

								// Create new entry
								functioned_copy_line(data,0,gadgetid,0);
								break;


							// Delete entry
							case GAD_FUNCED_DELETE_ENTRY:
								// Check we were editing something
								if (!data->edit_node) break;

								// Stop editing (signal delete)
								funced_end_edit(data,data->edit_node,END_DISABLE|END_DELETE,0);
								data->edit_node=0;
								break;


							// Function type
							case GAD_FUNCED_FUNCTION_TYPE:
								// Check we were editing something
								if (!data->edit_node) break;

								// Store type
								((FunctionEntry *)data->edit_node->data)->type=msg.Code;

								// Disable popup button if no functions
								DisableObject(
									data->objlist,
									GAD_FUNCED_EDIT_GLASS,
									(msg.Code==INST_COMMAND && !data->startup->func_list));
								break;


							// Glass gadget
							case GAD_FUNCED_EDIT_GLASS:

								// Check we were editing something
								if (data->edit_node)
								{
									char buffer[256];

									// Put up requester
									if (!(funced_command_req(
										data,
										buffer,
										((FunctionEntry *)data->edit_node->data)->type)))
										break;

									// Insert string in edit line
									funced_edit_insertstring(
										data->objlist,
										GAD_FUNCED_EDIT,
										buffer,
										DOpusBase,(struct Library *)IntuitionBase);
								}
								break;


							// Argument list
							case GAD_FUNCED_EDIT_ARGUMENT:

								// Check we were editing something
								if (data->edit_node)
								{
									char buffer[80];

									// Put up requester
									if (!(funced_command_req(
										data,
										buffer,
										-1))) break;

									// Insert string in edit line
									funced_edit_insertstring(
										data->objlist,
										GAD_FUNCED_EDIT,
										buffer,
										DOpusBase,(struct Library *)IntuitionBase);
								}
								break;


							// Export
							case MENU_FUNCED_EXPORT_ASCII:
							case MENU_FUNCED_EXPORT_CMD:

								// Got file requester?
								if (WINREQUESTER(data->window))
								{
									struct TagItem tags[6];
									struct FileRequester *req=WINREQUESTER(data->window);

									// Show busy pointer
									SetWindowBusy(data->window);

									// File requester tags
									tags[0].ti_Tag=ASLFR_Window;
									tags[0].ti_Data=(ULONG)data->window;
									tags[1].ti_Tag=ASLFR_TitleText;
									tags[1].ti_Data=(ULONG)GetString(startup->locale,MSG_FUNCED_SELECT_FILE);
									tags[2].ti_Tag=ASLFR_Flags1;
									tags[2].ti_Data=FRF_DOSAVEMODE|FRF_PRIVATEIDCMP;
									tags[3].ti_Tag=ASLFR_Flags2;
									tags[3].ti_Data=FRF_REJECTICONS;
									tags[4].ti_Tag=(gadgetid==MENU_FUNCED_EXPORT_CMD)?ASLFR_InitialDrawer:TAG_DONE;
									tags[4].ti_Data=(ULONG)"DOpus5:Commands";
									tags[5].ti_Tag=TAG_DONE;

									// Show filerequester
									if (AslRequest(req,tags))
									{
										// Build filename
										strcpy(data->buffer,req->fr_Drawer);
										AddPart(data->buffer,req->fr_File,256);

										// Store changes in function
										funced_store_edits(data);

										// Do export
										if (gadgetid==MENU_FUNCED_EXPORT_CMD)
											function_export_cmd(data->buffer,0,data->function);
										else
											L_FunctionExportASCII(data->buffer,0,data->function,startup->a4);
									}

									// Remove busy pointer
									ClearWindowBusy(data->window);
								}
								break;


							// Cut/Copy
							case MENU_FUNCED_CUT:
							case MENU_FUNCED_COPY:
								{
									APTR iff;

									// Set busy pointer
									SetWindowBusy(data->window);

									// Open clipboard
									if ((iff=IFFOpen((char *)0,IFF_CLIP_WRITE,ID_OPUS)))
									{
										// Stop editing
										funced_end_edit(data,data->edit_node,END_DISABLE,0);
										data->edit_node=0;

										// Store changes in function
										funced_store_edits(data);

										// Save function
										SaveFunction(iff,data->function);

										// Close clipboard
										IFFClose(iff);
									}

									// Just copy, not cut?
									if (gadgetid==MENU_FUNCED_COPY)
									{
										// Clear busy pointer
										ClearWindowBusy(data->window);
										break;
									}

									// Fall through, paste null function
								}

							// Paste
							case MENU_FUNCED_PASTE:
								{
									Cfg_Function *func=0;

									// Set busy pointer
									SetWindowBusy(data->window);

									// End any edit
									funced_end_edit(data,data->edit_node,END_DISABLE,0);
									data->edit_node=0;

									// Paste?
									if (gadgetid==MENU_FUNCED_PASTE)
									{
										APTR iff;

										// Open clipboard
										if ((iff=IFFOpen((char *)0,IFF_CLIP_READ,ID_OPUS)))
										{
											// Find function
											if (IFFNextChunk(iff,ID_FUNC))
											{
												// Read function
												func=ReadFunction(iff,0,0,0);
											}

											// Close clipboard
											IFFClose(iff);
										}

										// No valid function?
										if (!func)
										{
											// Flash error
											DisplayBeep(data->window->WScreen);
											ClearWindowBusy(data->window);
											break;
										}
									}

									// Detach existing list
									SetGadgetChoices(data->objlist,GAD_FUNCED_FLAGS,(APTR)~0);

									// Clear function list
									Att_RemList(data->function_list,REMLIST_SAVELIST|REMLIST_FREEDATA);

									// Free existing instructions
									FreeInstructionList(data->function);

									// Rebuild display list
									funced_build_display(data);

									// Clear flags
									data->function->function.flags=0;
									funced_update_flaglist(data);

									// Clear key
									data->function->function.code=0xffff;
									SetGadgetValue(data->objlist,GAD_FUNCED_KEY,0);

									// Clear label
									if (startup->flags&FUNCEDF_LABEL)
									{
										data->label[0]=0;
										SetGadgetValue(data->p_objlist,GAD_FUNCED_LABEL,0);
									}

									// Paste function in?
									if (func)
									{
										short type;

										// Save type
										type=data->function->function.func_type;

										// Copy function in
										CopyFunction(func,0,data->function);
										data->function->function.func_type=type;

										// Free copied function
										FreeFunction(func);

										// Initialise gadgets
										funced_init_gads(data);
									}
	
									// Clear busy pointer
									ClearWindowBusy(data->window);
								}
								break;


							// Use
							case GAD_FUNCED_USE:
								success=1;

							// Cancel
							case GAD_FUNCED_CANCEL:
								break_flag=1;
								break;
						}
						break;


					// Key press
					case IDCMP_RAWKEY:

						// Help?
						if (msg.Code==0x5f &&
							!(msg.Qualifier&VALID_QUALIFIERS))	
						{
							// Set busy pointer
							SetWindowBusy(data->window);

							// Send help command
							IPC_Command(startup->main_owner,IPC_HELP,(1<<31),"Function Editor",0,REPLY_NO_PORT);

							// Clear busy pointer
							ClearWindowBusy(data->window);
						}
						break;


					// BOOPSI message
					case IDCMP_IDCMPUPDATE:
						{
							struct TagItem *tags=(struct TagItem *)msg.IAddress;
							short item;

							// Check ID
							if (GetTagData(GA_ID,0,tags)!=GAD_FUNCED_LISTER)
								break;

							// Get item
							if ((item=GetTagData(DLV_DragNotify,-1,tags))!=-1)
							{
								// Start the drag
								config_drag_start(&data->drag,data->func_display_list,item,tags,TRUE);
							}
						}
						break;


					// Ticks
					case IDCMP_INTUITICKS:
						++data->drag.tick_count;
						break;
				}

				// Reply to any outstanding message
				if (gmsg) ReplyWindowMsg(gmsg);
			}
		}

		// AppMessage
		if (data->appwindow)
		{
			struct AppMessage *msg;

			while ((msg=(struct AppMessage *)GetMsg(data->appport)))
			{
				// Make sure window is active
				ActivateWindow(data->window);

				// Handle message
				funced_appmsg(data,msg);
				ReplyMsg((struct Message *)msg);
			}
		}

		// Check break flag
		if (break_flag) break;

		// Wait for message
		Wait(waitbits);
	}

	// Restore CD
	if (lock) UnLock(CurrentDir(lock));

	// Edit successful?
	if (success)
	{
		FunctionReturn ret;

		// Store changes in function
		funced_store_edits(data);

		// Fill out return data
		ret.object=startup->object;
		ret.object_flags=startup->object_flags;
		ret.function=data->function;

		// Send new function back
		IPC_Command(startup->owner_ipc,FUNCTIONEDIT_RETURN,0,&ret,0,REPLY_NO_PORT);
	}

	// End any drag in progress
	functioned_end_drag(data,0);

	// Free edit function
	FreeFunction(data->function);

	// Close window
	RemoveAppWindow(data->appwindow);
	CloseConfigWindow(data->window);

	// Close application port
	if (data->appport)
	{
		struct Message *msg;
		while ((msg=GetMsg(data->appport)))
			ReplyMsg(msg);
		DeleteMsgPort(data->appport);
	}

	// Say goodbye
	IPC_Goodbye(ipc,startup->owner_ipc,startup->object_flags);

	// Delete IPC data
	Forbid();
	IPC_Free(ipc);

	// Free data
	funced_cleanup(data);
	FreeVec(startup);
}
Example #10
0
short LIBFUNC L_DoSimpleRequest(
	REG(a0, struct Window *parent),
	REG(a1, struct DOpusSimpleRequest *simple),
	REG(a6, struct Library *libbase))
{
	APTR memory;
	simplereq_data *data;
	UWORD gadgetid=0;

	#ifdef __amigaos4__
	libbase = (struct Library *)dopuslibbase_global;
	#endif

	// Allocate memory handle
	if (!(memory=L_NewMemHandle(0,0,MEMF_CLEAR)))
		return 1;

	// Allocate data
	if (!(data=(simplereq_data *)L_AllocMemH(memory,sizeof(simplereq_data))))
	{
		L_FreeMemHandle(memory);
		return 1;
	}

	// Initialise
	data->simple=simple;
	data->parent=parent;
	data->string_buffer=simple->string_buffer;
	data->gadgets=simple->gadgets;
	data->libbase=(struct MyLibrary *)libbase;
	data->signal=-1;
	data->memory=memory;

	// Center window; over mouse?
	if (simple->flags&SRF_MOUSE_POS)
	{
		data->req_dims.char_dim.Left=POS_MOUSE_CENTER;
		data->req_dims.char_dim.Top=POS_MOUSE_CENTER;
	}

	// Over parent
	else
	{
		data->req_dims.char_dim.Left=POS_CENTER;
		data->req_dims.char_dim.Top=POS_CENTER;
	}

	// Construct requester
	if (!(simple_build(data)))
	{
		// Failed
		L_FreeMemHandle(memory);
		return 1;
	}

	// IPC port supplied?
	if (simple->flags&SRF_IPC && simple->ipc)
	{
		data->ipc=simple->ipc;
		data->waitbits=1<<data->ipc->command_port->mp_SigBit;
	}

	// Signal supplied?
	else
	if (simple->flags&SRF_SIGNAL)
	{
		data->signal=(short)simple->ipc;
		data->waitbits=1<<data->signal;
	}

	// Otherwise
	else
	{
		data->waitbits=IPCSIG_QUIT;
		SetSignal(0,IPCSIG_QUIT);
	}

	// Open requester
	if (_simplereq_open(data,parent))
	{
		// Wait on requester
		FOREVER
		{
			struct IntuiMessage *msg;
			IPCMessage *imsg;
			short break_flag=0;
			ULONG waitres;

			// IPC message?
			if (data->ipc)
			{
				while ((imsg=(IPCMessage *)GetMsg(data->ipc->command_port)))
				{
					if (imsg->command==IPC_HIDE)
						_simplereq_close(data);
					else
					if (imsg->command==IPC_SHOW)
					{
						if (!(_simplereq_open(data,imsg->data)))
							break_flag=1;
					}
					else
					if (imsg->command==IPC_ACTIVATE)
					{
						if (data->window)
						{
							WindowToFront(data->window);
							ActivateWindow(data->window);
						}
					}
					else
					if (imsg->command==IPC_QUIT || imsg->command==IPC_ABORT)
					{
						break_flag=1;
						gadgetid=(UWORD)-1;
					}
					L_IPC_Reply(imsg);
				}
			}

			// Intuition message?
			if (data->window)
			{
				while ((msg=L_GetWindowMsg(data->window->UserPort, (APTR)libbase)))
				{
					struct IntuiMessage copy_msg;

					// Copy message and reply
					copy_msg=*msg;
					L_ReplyWindowMsg(msg);

					// Check message type
					if (copy_msg.Class==IDCMP_GADGETUP)
					{
						// Get gadget ID
						gadgetid=((struct Gadget *)copy_msg.IAddress)->GadgetID;

						// Checkbox?
						if (gadgetid==GAD_CHECK_ID)
						{
							// Store value
							if (simple->check_ptr) *simple->check_ptr=copy_msg.Code;
						}

						// Tab on a string gadget?
						else
						if (gadgetid==GAD_STRING2_ID ||
							(gadgetid==GAD_STRING_ID &&
								(copy_msg.Code==0x9 ||
								copy_msg.Code==0x45 ||
								copy_msg.Qualifier&(IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT))))
							continue;

						// Popup gadget?
						else
						if (gadgetid==GAD_POPUP_ID)
						{
							char buf[400],file[40],*ptr;
							struct TagItem tags[4];

							// Get initial path and file
							strcpy(buf,(char *)L_GetGadgetValue(data->objlist,GAD_STRING_ID,data->libbase));
							if ((ptr=FilePart(buf)))
							{
								stccpy(file,ptr,40);
								*ptr=0;
							}
							else file[0]=0;

							// Initialise tags
							tags[0].ti_Tag=ASLFR_Window;
							tags[0].ti_Data=(ULONG)data->window;
							tags[1].ti_Tag=ASLFR_InitialFile;
							tags[1].ti_Data=(ULONG)file;
							tags[2].ti_Tag=ASLFR_InitialDrawer;
							tags[2].ti_Data=(ULONG)buf;
							tags[3].ti_Tag=TAG_END;

							// Show requester
							if (simple->filereq &&
								AslRequest(simple->filereq,tags))
							{
								// Build new path
								strcpy(buf,((struct FileRequester *)simple->filereq)->fr_Drawer);
								AddPart(buf,((struct FileRequester *)simple->filereq)->fr_File,400);

								// Show in string gadget
								L_SetGadgetValue(data->objlist,GAD_STRING_ID,(long)buf);
								L_ActivateStrGad(GADGET(L_GetObject(data->objlist,GAD_STRING_ID)),data->window);
							}
							continue;
						}

						// Set break flag
						else break_flag=1;
					}

					// Key press
					else
					if (copy_msg.Class==IDCMP_VANILLAKEY)
					{
						// Y = yes
						if (copy_msg.Code=='y' || copy_msg.Code=='Y')
						{
							gadgetid=1;
							break_flag=1;
						}

						// N = no
						else
						if (copy_msg.Code=='n' || copy_msg.Code=='N')
						{
							gadgetid=0;
							break_flag=1;
						}
					}
				}
			}

			// Check break flag
			if (break_flag) break;

			// Wait for a message
			waitres=Wait(data->waitbits|
						((data->window)?(1<<data->window->UserPort->mp_SigBit):0));

			// Quit?
			if (waitres&IPCSIG_QUIT)
			{
				gadgetid=0;
				break;
			}

			// Signal?
			else
			if (data->signal!=-1 && (waitres&(1<<data->signal)))
			{
				gadgetid=(UWORD)-5;
				break;
			}
		}
	}

	// Close requester
	_simplereq_close(data);

	// Free memory
	L_FreeMemHandle(memory);

	// Return gadget code
	return gadgetid;
}
Example #11
0
BOOL _simplereq_open(simplereq_data *data,void *parent)
{
	// Not already open?
	if (!data->window)
	{
		short x,space,gad,object,gadsize=0;

		// Set parent
		data->new_win.parent=parent;

		// Open window
		if (!(data->window=L_OpenConfigWindow(&data->new_win,data->libbase)))
			return 0;

		// Are gadgets smaller than text?
		if (data->max_gadget_width<data->max_text_width-4)
		{
			short max;

			// Go through gadgets, get widest one
			for (gad=0,max=0;data->gadgets[gad];gad++)
			{
				short width;

				// Get gadget width
				width=TextLength(data->window->RPort,data->gadgets[gad],strlen(data->gadgets[gad]));

				// Widest so far?
				if (width>max) max=width;
			}

			// Is there room for all gadgets to be the same size?
			if ((((max+GAD_X_EXTRA+GAD_X_SPACE)*data->gadget_count)-GAD_X_SPACE)<=data->max_text_width)
			{
				// Use standard size
				gadsize=max;
				data->max_gadget_width=(gadsize+GAD_X_EXTRA)*data->gadget_count;
			}
		}

		// Initialise x coordinate
		x=3;

		// Less than 3 gadgets?
		if (data->gadget_count<3) space=0;

		// Gadgets are smaller than text?
		else
		if (data->max_gadget_width<data->max_text_width-4)
			space=(data->max_text_width-data->max_gadget_width+4)/(data->gadget_count-1);

		// Fixed spacing
		else space=GAD_X_SPACE;

		// Go through gadgets
		for (gad=0,object=data->first_object;data->gadgets[gad];gad++,object++)
		{
			short width;

			// Get gadget width
			if (gadsize>0) width=gadsize;
			else width=TextLength(data->window->RPort,data->gadgets[gad],strlen(data->gadgets[gad]));

			// Fill out gadget position
			data->objects[object].char_dims.Top=POS_RIGHT_JUSTIFY;
			data->objects[object].char_dims.Height=1;
			data->objects[object].fine_dims.Top=-3;
			data->objects[object].fine_dims.Width=width+GAD_X_EXTRA;
			data->objects[object].fine_dims.Height=6;

			// Special positioning?
			if (data->gadget_count<3)
			{
				// Center?
				if (data->gadget_count==1)
					data->objects[object].char_dims.Left=POS_CENTER;

				// Left?
				else
				if (gad==0)
					data->objects[object].fine_dims.Left=x;

				// Right
				else
				{
					data->objects[object].char_dims.Left=POS_RIGHT_JUSTIFY;
					data->objects[object].fine_dims.Left=-3;
				}
			}

			// Final gadget?
			else
			if (gad==data->gadget_count-1)
			{
				// Right-justify
				data->objects[object].char_dims.Left=POS_RIGHT_JUSTIFY;
				data->objects[object].fine_dims.Left=-3;
			}

			// Normal positioning
			else data->objects[object].fine_dims.Left=x;

			// Increment position
			x+=width+GAD_X_EXTRA+space;
		}

		// Add objects
		if (!(data->objlist=L_AddObjectList(data->window,data->objects,data->libbase)))
		{
			L_CloseConfigWindow(data->window,data->libbase);
			data->window=0;
			return 0;
		}

		// String gadget? Initialise and activate it
		if (data->string_buffer)
		{
			// Initialise (if a string)
			if (!(data->simple->flags&SRF_LONGINT))
			{
				// Initialise first gadget
				L_SetGadgetValue(data->objlist,GAD_STRING_ID,(long)data->simple->string_buffer);

				// Initialise second string gadget
				if (data->string_buffer_2)
					L_SetGadgetValue(data->objlist,GAD_STRING2_ID,(long)data->string_buffer_2);
			}

			// Activate it
			L_ActivateStrGad(GADGET(L_GetObject(data->objlist,GAD_STRING_ID)),data->window);
		}

		// Initialise checkbox
		if (data->simple->flags&SRF_CHECKMARK &&
			data->simple->check_ptr)
			L_SetGadgetValue(data->objlist,GAD_CHECK_ID,(ULONG)*data->simple->check_ptr);
	}

	return 1;
}
// Get search data
static int search_get_data(
	FunctionHandle *handle,
	SearchData *data)
{
	NewConfigWindow new_win;
	struct Window *window;
	ObjectList *objlist;
	Lister *lister;
	short cancel=1;

	// Fill out new window
	if ((lister=function_lister_current(&handle->source_paths)))
	{
		new_win.parent=lister->window;
		new_win.flags=0;
	}
	else
	{
		new_win.parent=GUI->screen_pointer;
		new_win.flags=WINDOW_SCREEN_PARENT;
	}
	new_win.dims=&search_window;
	new_win.title=GetString(&locale,MSG_ENTER_SEARCH_STRING);
	new_win.locale=&locale;
	new_win.port=0;
	new_win.flags|=WINDOW_NO_CLOSE|WINDOW_VISITOR|WINDOW_AUTO_KEYS|WINDOW_REQ_FILL;
	new_win.font=0;

	// Open window
	if (!(window=OpenConfigWindow(&new_win)) ||
		!(objlist=AddObjectList(window,search_objects)))
	{
		CloseConfigWindow(window);
		return 0;
	}

	// Initial settings
	SetGadgetValue(objlist,GAD_SEARCH_TEXT,(ULONG)data->search_text);
	SetGadgetValue(objlist,GAD_SEARCH_CASE,data->search_flags&SEARCH_NOCASE);
	SetGadgetValue(objlist,GAD_SEARCH_WILD,data->search_flags&SEARCH_WILDCARD);
	SetGadgetValue(objlist,GAD_SEARCH_ONLYWORD,data->search_flags&SEARCH_ONLYWORDS);
	SetGadgetValue(objlist,GAD_SEARCH_RESULT,data->search_result);

	// Activate text field
	ActivateStrGad(GADGET(GetObject(objlist,GAD_SEARCH_TEXT)),window);

	// Event loop
	FOREVER
	{
		struct IntuiMessage *msg;
		BOOL break_flag=0;

		// Check for abort
		if (function_check_abort(handle))
			break;

		// Activate?
		if (handle->flags2&FUNCF_ACTIVATE_ME)
		{
			ActivateWindow(window);
			WindowToFront(window);
			handle->flags2&=~FUNCF_ACTIVATE_ME;
		}

		// Any Intuition messages?
		while ((msg=GetWindowMsg(window->UserPort)))
		{
			struct IntuiMessage copy_msg;

			// Copy message and reply
			copy_msg=*msg;
			ReplyWindowMsg(msg);

			// Gadget?
			if (copy_msg.Class==IDCMP_GADGETUP)
			{
				UWORD gadgetid;

				// Get gadget id
				gadgetid=((struct Gadget *)copy_msg.IAddress)->GadgetID;

				// Look at gadget ID
				switch (gadgetid)
				{
					// Okay
					case GAD_SEARCH_TEXT:
					case GAD_SEARCH_OKAY:

						// Store flags
						data->search_flags=0;
						if (GetGadgetValue(objlist,GAD_SEARCH_CASE))
							data->search_flags|=SEARCH_NOCASE;
						if (GetGadgetValue(objlist,GAD_SEARCH_WILD))
							data->search_flags|=SEARCH_WILDCARD;
						if (GetGadgetValue(objlist,GAD_SEARCH_ONLYWORD))
							data->search_flags|=SEARCH_ONLYWORDS;
						data->search_result=GetGadgetValue(objlist,GAD_SEARCH_RESULT);

						// Get search text
						strcpy(data->search_text,(char *)GetGadgetValue(objlist,GAD_SEARCH_TEXT));
						cancel=0;

					// Cancel
					case GAD_SEARCH_CANCEL:
						break_flag=1;
						break;
				}
			}
		}

		// Check break flag
		if (break_flag) break;

		// Wait for an event
		Wait(1<<window->UserPort->mp_SigBit|1<<handle->ipc->command_port->mp_SigBit);
	}

	// Close window
	CloseConfigWindow(window);

	// Return
	return !cancel;
}
Example #13
0
void _ARMIA_RYSUJ_INFO(aint A) {
	aint AX=0,AY=0,PL=0,I=0;
	aint GD=0,DANE=0;//,KONIEC=0;
	aint WOJ=0,SILA=0,SPEED=0,TRYB=0,CELX=0,CELY=0,ROZ=0;
	aint TEREN=0,ZARCIE=0;
	astr RO_S="",D_S="",DNI_S="",WOJ_S="",R2_S="";

	AX=ARMIA[A][0][TX];											//	   AX=ARMIA(A,0,TX)
	AY=ARMIA[A][0][TY];											//	   AY=ARMIA(A,0,TY)
	PL=ARMIA[A][0][TMAG];										//	   PL=ARMIA(A,0,TMAG)

	OKNO(80,80,150,100);										//	   OKNO[80,80,150,100]
	GD=50;																	//	   GD=50
	if( A<20 ) {														//	   If A<20
		RO_S=GS("187");												//	      RO$="Commands"
		DANE=-1;															//	      DANE=True
	} else {																//	   Else
		RO_S=GS("188");												//	      RO$="Inquiry"
		if( ARMIA[A][0][TMAGMA]>28 && ARMIA[A][0][TMAGMA]<100 ) {	//	      If ARMIA(A,0,TMAGMA)>28 and ARMIA(A,0,TMAGMA)<100
			DANE=0; D_S=GS("189");							//	         DANE=False : D$="No informations."
		} else {															//	      Else
			if( ARMIA[A][0][TMAGMA]>1 ) {				//	         If ARMIA(A,0,TMAGMA)>1
				DNI_S=GS("190");									//	            DNI$=" days."
			} else {														//	         Else
				DNI_S=GS("191");									//	            DNI$=" day."
			}																		//	         End If
			DANE=0;															//	         DANE=False : D$="Informations during "+Str$(ARMIA(A,0,TMAGMA))+DNI$
			D_S=GS("192")+Str_S(ARMIA[A][0][TMAGMA])+DNI_S;
		}																			//	      End If
		if( ARMIA[A][0][TMAGMA]==0 || ARMIA[A][0][TMAGMA]==100 ) {//	      If ARMIA(A,0,TMAGMA)=0 or ARMIA(A,0,TMAGMA)=100
			RO_S=GS("193");											//	         RO$="Trace "
			GD=52;															//	         GD=52
			DANE=-1;														//	         DANE=True
		}																			//	      End If
	}																				//	   End If
	GADGET(OKX+4,OKY+4,142,74,"",31,2,30,1,-1);//	   GADGET[OKX+4,OKY+4,142,74,"",31,2,30,1,-1]
	GADGET(OKX+4,OKY+80,GD,15,RO_S,8,2,6,31,10);//	   GADGET[OKX+4,OKY+80,GD,15,RO$,8,2,6,31,10]
	GADGET(OKX+106,OKY+80,40,15,GS("194"),8,2,6,31,1);//	   GADGET[OKX+106,OKY+80,40,15,"   Ok  ",8,2,6,31,1]
	if( ARMIA[A][0][TMAGMA]==100 ) {				//	   If ARMIA(A,0,TMAGMA)=100 : Ink 31,6 : Text OKX+48,OKY+89,"@" : End If
		gad_text(1.0);
		Text(OKX+48,OKY+89,"@");
	}
	//!!!nieco inaczej											//	   No Mask 23+PL : Paste Bob OKX+8,OKY+8,23+PL
	Gfx::Color(0,0,0); _Bar(OKX+8,OKY+8,OKX+40,OKY+40);
	PasteBob(OKX+8,OKY+8,23+PL);
	SetZone(11,OKX+50,OKY+5,OKX+120,OKY+15);//	   Set Zone 11,OKX+50,OKY+5 To OKX+120,OKY+15
	gad_text(1.0);													//	   Ink 1,30 : Text OKX+50,OKY+15,ARMIA$(A,0)
	Text(OKX+50,OKY+15,ARMIA_S[A][0]);
	if( DANE !=0 ) {												//	   If DANE
		for(I=1;I<=10;++I) {									//	      For I=1 To 10
			if( ARMIA[A][I][TE]>0 ) {						//	         If ARMIA(A,I,TE)>0
				WOJ+=1;														//	            Add WOJ,1
				SILA+=ARMIA[A][I][TSI];						//	            Add SILA,ARMIA(A,I,TSI)
				SILA+=ARMIA[A][I][TE];						//	            Add SILA,ARMIA(A,I,TE)
				SPEED+=ARMIA[A][I][TSZ];					//	            Add SPEED,ARMIA(A,I,TSZ)
			}																		//	         End If
		}																			//	      Next I
		ARMIA[A][0][TE]=WOJ;									//	      ARMIA(A,0,TE)=WOJ
		SPEED=((SPEED/WOJ)/5);								//	      SPEED=((SPEED/WOJ)/5)
		ARMIA[A][0][TSZ]=SPEED;								//	      ARMIA(A,0,TSZ)=SPEED
		ARMIA[A][0][TSI]=SILA;								//	      ARMIA(A,0,TSI)=SILA
		AX=ARMIA[A][0][TX];										//	      AX=ARMIA(A,0,TX)
		AY=ARMIA[A][0][TY];										//	      AY=ARMIA(A,0,TY)
		TRYB=ARMIA[A][0][TTRYB];							//	      TRYB=ARMIA(A,0,TTRYB)
		CELX=ARMIA[A][0][TCELX];							//	      CELX=ARMIA(A,0,TCELX)
		CELY=ARMIA[A][0][TCELY];							//	      CELY=ARMIA(A,0,TCELY)
		ROZ=ARMIA[A][0][TTRYB];								//	      ROZ=ARMIA(A,0,TTRYB)
		TEREN=ARMIA[A][0][TNOGI];							//	      TEREN=ARMIA(A,0,TNOGI)
		WOJ_S=GS("195");											//	      WOJ$=" worriors"
		if( WOJ==1 ) WOJ_S=GS("196");					//	      If WOJ=1 : WOJ$=" worrior" : End If
		if(	ROZ==0 ) {												//	      If ROZ=0
			RO_S=GS("197");											//	         RO$="Unit is tenting"
			if( TEREN>69 ) {										//	         If TEREN>69
				RO_S+=GS("198")+MIASTA_S[TEREN-70];	//	            RO$=RO$+" in "+MIASTA$(TEREN-70)
			}																		//	         End If
		}																			//	      End If
		if( ROZ==1 || ROZ==2 ) {							//	      If ROZ=1 or ROZ=2 : RO$="Unit is moving." : End If
			RO_S=GS("199");
		}
		if( ROZ==3 ) {												//	      If ROZ=3
			if( CELY==0 ) {											//	         If CELY=0
				R2_S=ARMIA_S[CELX][0];						//	            R2$=ARMIA$(CELX,0)
			} else {														//	         Else
				R2_S=MIASTA_S[CELX];							//	            R2$=MIASTA$(CELX)
			}																		//	         End If
			RO_S=GS("200")+R2_S;				//	         RO$="We're attacking "+R2$
		}																			//	      End If
		if( ROZ==4 ) {												//	      If ROZ=4 : RO$="We're hunting" : End If
			RO_S=GS("201");
		}
		ZARCIE=ARMIA[A][0][TAMO]/WOJ;					//	      ZARCIE=ARMIA(A,0,TAMO)/WOJ
		DNI_S=GS("202")+Str_S(ZARCIE)+GS("203");//	      DNI$="Food for "+Str$(ZARCIE)+" days"
		if( ZARCIE==1 ) {											//	      If ZARCIE=1 : DNI$="Food for only 1 day" : End If
			DNI_S=GS("204");
		}
		if( ZARCIE<=0 ) {											//	      If ZARCIE<=0 : DNI$="We have no food !" : End If
			DNI_S=GS("205");
		}
		gad_text(1.0);																	//	      Ink 1,30
		Text(OKX+50,OKY+35,GS("206")+Str_S(SILA));	//	      Text OKX+50,OKY+35,"Strength  :"+Str$(SILA)
		Text(OKX+50,OKY+25,Str_S(WOJ)+WOJ_S);						//	      Text OKX+50,OKY+25,Str$(WOJ)+WOJ$
		Text(OKX+50,OKY+45,DNI_S);											//	      Text OKX+50,OKY+45,DNI$
		Text(OKX+50,OKY+55,GS("207")+Str_S(SPEED));	//	      Text OKX+50,OKY+55,"Speed     :"+Str$(SPEED)
		Text(OKX+12,OKY+65,RO_S);												//	      Text OKX+12,OKY+65,RO$
	} else {																//	   Else
		gad_text(1.0);
		Text(OKX+12,OKY+60,D_S);							//	      Text OKX+12,OKY+60,D$
	}																				//	   End If
}