/* Decode and execute the corresponding command */
tResult StateControlManagementSlim::ExecRequest(tUInt32 scmStep_command){
	// execute the request command by changing the state of the StateController corresponding to scmStep_command
	/* decode the commands and react accordingly -> change tInt16 i16CurrentScmManeuverID and tInt16 i16CurrentScmStepID */
	/* Begin and End of defined intervals for commands specified in 'ScmCommunication.h' */
	tUInt32 stepPlusCommandOffset = C_STEP_PLUS_COMMAND_BEGIN;
	tUInt32 stepJumpCommandOffset = C_STEP_JUMP_COMMAND_BEGIN;
	tUInt32 maneuverCommandOffset = C_MAN_JUMP_COMMAND_BEGIN;
	tUInt32 maneuverCommandEnd = C_MAN_JUMP_COMMAND_END;

	if(scmStep_command >= stepPlusCommandOffset && scmStep_command < stepJumpCommandOffset){
		/* Increase step by certain number , starting from 0 to 99*/
		RETURN_IF_FAILED(ChangeStep(scmStep_command - stepPlusCommandOffset));
	}else if(scmStep_command >= stepJumpCommandOffset && scmStep_command < maneuverCommandOffset){
		/* Jump to certain step , starting from 100 */
		RETURN_IF_FAILED(JumpToStep(scmStep_command- stepJumpCommandOffset));
	}else if(scmStep_command >= maneuverCommandOffset && scmStep_command < maneuverCommandEnd){
		/* Jump to certain maneuver, starting from 200 */
		RETURN_IF_FAILED(JumpToManeuver(scmStep_command - maneuverCommandOffset));
	}else{
		#ifdef WRITE_DEBUG_OUTPUT_TO_FILE
		scm_logfile << std::endl << "### --- " << std::endl << "SCM ERROR: ERROR in ExecRequest(). Undefined Command. Check ENUM-file" << std::endl;
		#endif
		RETURN_AND_LOG_ERROR_STR(ERR_INVALID_STATE, cString::Format("SCM: ERROR in ExecRequest(). Undefined Command. Check ENUM-file"));
	}

	RETURN_NOERROR;
}
예제 #2
0
void CExportWizardDlg::OnBnClickedBack()
{
	Invalidate();

	if (m_iStep == 2)
		ChangeStep(1);
}
예제 #3
0
void CEventWizardDlg::OnSwitchTab()
{
	if (m_bOK) return;

	if(m_locked)
		return;
	PreChangeStep();
	ChangeStep();
}
예제 #4
0
void CExportWizardDlg::OnBnClickedNext()
{
	Invalidate();

	if (m_iStep == 2)
	{
		// Save variables and finish up
		m_Output.GetWindowText(m_OutputPath);

		if (m_OutputPath == "")
		{
			CErrorDlg Dlg;
			Dlg.Error("Error exporting", "You must enter a legitimate path to export to.");
			return;
		}

		// Installer
		if (m_Installer.GetCheck() == BST_CHECKED) m_bInstaller = true;
		else m_bInstaller = false;

		// Enable python
		if (m_EnablePython.GetCheck() == BST_CHECKED) application->game_information.use_python = true;
		else application->game_information.use_python = false;

		// Screensaver
		if (m_Screensaver.GetCheck() == BST_CHECKED) m_bScreensaver = true;
		else m_bScreensaver = false;

		// Save python modules
		application->m_PythonDistrib.clear();

		for(int i = 0; i < m_Modules.GetCount(); i++)
		{
			CString File;
			m_Modules.GetText(i, File);

			if(m_Modules.GetCheck(i))
				application->m_PythonDistrib[File] = 0;
		}

		OnOK();
	}

	if (m_iStep == 1)
		ChangeStep(2);
}
예제 #5
0
// Initialise the dialog
//
BOOL CEventWizardDlg::OnInitDialog() 
{
	// Startup
	CDialog::OnInitDialog();

	int currentPosition = 1;

	// Create an m_ObjectImages
	m_ObjectImages.DeleteImageList();

	bool bSmallImages = false;

	// Check what size images we'll need
	// 32x32 without families or 16x16 with
	if (application->families.size() == 0)
	{
		m_ObjectImages.Create(32, 32, ILC_COLOR24, 3, 3);
		m_List.SetImageList(&m_ObjectImages, LVSIL_NORMAL);

		HBITMAP SystemBitmap = LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_SYSTEM));
		ImageList_Add(m_ObjectImages, SystemBitmap, SystemBitmap);
		DeleteObject(SystemBitmap);
	}

	else
	{
		// If it's small, also set the view to small images
		m_List.SetView(LV_VIEW_SMALLICON);

		m_ObjectImages.Create(16, 16, ILC_COLOR24, 3, 3);
		m_List.SetImageList(&m_ObjectImages, LVSIL_SMALL);

		HBITMAP SystemBitmap = LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_SYSTEMC));
		ImageList_Add(m_ObjectImages, SystemBitmap, SystemBitmap);	
		DeleteObject(SystemBitmap);

		bSmallImages = true;
	}

	// Prepare to iterate all objects to add icons
	POSITION pos = objMap->GetStartPosition();
	long mapKey;
	CObjType* ObjectType;

	// Add '(System)' because system uses it
	object_folders["(System)"] = 0;

	// Loop through and add all objects to the otList
	while (pos != NULL) 
	{
		objMap->GetNextAssoc(pos, mapKey, ObjectType);

		if(!ObjectType->m_bIsGroupType)
		{
			CObj *o;
			bool bAdd = false;

			// If global, its okay to add...if its not global..and we have a layout...we need to check
			if (ObjectType->m_bGlobal) 
			{
				bAdd = true;
			}
			else if(layout)
			{
				POSITION pos = layout->objects.GetStartPosition();

				for (int i = 0; i < layout->objects.GetCount(); i++) 
				{
					long ID;
					layout->objects.GetNextAssoc(pos, ID, o);
						
					if (o->GetGlobalID() == ObjectType->ObjectIdentifier)
					{
						bAdd = true;	
					}
				}
			}
			else // we have no layout to this event sheet
			{
				bAdd = true;
			}

			// Dont add if it doesn't have conditions/actions
			bool hasAces = false;
			for (int i = 0; i < ObjectType->GetTableCount(m_aceType); i++)
			{
				if (ObjectType->GetACESEntry(m_aceType, i)->aceListName == "")
				{
					hasAces = true;
					break;
				}
				if (hasAces)
					break;
			}
			if(!hasAces)
				bAdd = false;

			// Okay cool...look like its okay to add...just check if is showabout in the event sheet editor
			if(bAdd && ObjectType->m_bShowInEventSheetEditor)
			{
				// Possibly add a new category
				if(object_folders.find(ObjectType->GetFolder()) == object_folders.end())
				{
					object_folders[ObjectType->GetFolder()] = object_folders.size();
				}
				m_otList.push_back(ObjectType);
			}
		}
	}

	// Sort
	sort(m_otList.begin(), m_otList.end(), ObjTypeSortFunction);

	// Now loop the otList backwards to display each object icon
	for(vector<CObjType*>::iterator i = m_otList.begin(); i != m_otList.end(); i++)
	{	
		HBITMAP Bitmap;

		if (bSmallImages)
			Bitmap = (*i)->small_image.MakeBitmap();
		else
			Bitmap = (*i)->m_Image.MakeBitmap();

		ImageList_Add(m_ObjectImages, Bitmap, Bitmap);

		DeleteObject(Bitmap);
	}	

	pos = objMap->GetStartPosition();

	// Family icons
	list<Family>::iterator f = application->families.begin();

	for ( ; f != application->families.end(); f++)
	{
		if(f->is_in_use)
		{
			HBITMAP Bitmap = f->small_image.MakeBitmap();
			ImageList_Add(m_ObjectImages, Bitmap, Bitmap);
			
			DeleteObject(Bitmap);
		}
	}
	
	// Title
	CString Title;

	if (m_aceType == CONDITION)
		Title.Format("Construct : New condition");
	else if (m_aceType == ACTION)
		Title.Format("Construct : New action");
	else if (m_aceType == EXPRESSION)
		Title.Format("Construct : New expression");

	SetWindowText(Title);

	CRect Rect;
	m_ACEList.GetWindowRect(&Rect);
	ScreenToClient(&Rect);
	Rect.top = Rect.bottom - 1;
	Rect.bottom = Rect.top + 18;
	m_CategoryTabs.Create(this, Rect, 1001, WS_CHILD | WS_VISIBLE, __ETWS_ORIENT_BOTTOM);

	m_ACEList.GetWindowRect(&Rect);
	ScreenToClient(&Rect);
	Rect.top -= 17;
	Rect.bottom = Rect.top + 18;
	m_Tabs.Create(this, Rect, 1002, WS_CHILD | WS_VISIBLE, __ETWS_ORIENT_TOP);

	GetClientRect(&Rect);

	Rect.bottom = Rect.top + 22;
	Rect.right += 48;

	// Resizing anchors
	BOOL First = dlgMan.Load(this->m_hWnd, "Software\\Construct\\EventWizardDialogs");
	if (!First)
	{
		first_run.Attach(this);
		first_run.SetHighlightOnMouseOver();
		first_run.SetResize();
		first_run.SetWrapText();

		if (m_aceType == ACTION)
			first_run.SetText("Events are created via this wizard.  Choose an object from the list below.  A list of actions will then appear, some of which require parameters: for example 'Create object' under System.  Once all parameters are filled out, click Finish to insert your action.");
		if (m_aceType == CONDITION)
			first_run.SetText("Events are created via this wizard.  Choose an object from the list below.  A list of conditions will then appear, some of which require parameters: for example 'Compare' under System.  Once all parameters are filled out, click Finish to insert your condition.");

	}

    dlgAnchor.Init(this->m_hWnd);

	dlgAnchor.Add(IDC_OBJECTLIST, ANCHOR_TOPLEFT | ANCHOR_BOTTOMRIGHT);
	dlgAnchor.Add(IDC_ACELIST, ANCHOR_TOPLEFT | ANCHOR_BOTTOMRIGHT);
	dlgAnchor.Add(IDC_FIND, ANCHOR_TOP | ANCHOR_RIGHT);

	dlgAnchor.Add(1001, ANCHOR_LEFT | ANCHOR_BOTTOMRIGHT);
	dlgAnchor.Add(1002, ANCHOR_TOPLEFT | ANCHOR_RIGHT);
	dlgAnchor.Add(1003, ANCHOR_TOPLEFT | ANCHOR_RIGHT);
	
	dlgAnchor.Add(IDC_BACK, ANCHOR_BOTTOM | ANCHOR_RIGHT);
	dlgAnchor.Add(IDC_CANCEL, ANCHOR_BOTTOM | ANCHOR_LEFT);
	dlgAnchor.Add(IDC_NEXT, ANCHOR_BOTTOM | ANCHOR_RIGHT);
	
	m_Cancel.SetWindowText(CANCEL);

	// Set ACE margins
	CRect ListRect;
	m_ACEList.GetClientRect(&ListRect);
	ListRect.left += 5;
	ListRect.top += 5;
	m_ACEList.SetWorkAreas(1, &ListRect);
	m_ACEList.SetColumnWidth(0, 200);		// Spaces everything out nicely for step 2.

	int initStep = m_iStep;

	if (m_InitialStage == 0)
	{
		m_iStep = 1;
		ChangeStep();
	}

	else
	{
		// New to 0.96.3
		m_pSelectedObject = m_InitialSelect;
		initStep = 2;
	}

	// The below is used so we set the default selected items (eg. if we are editing)
	if(m_pSelectedObject != -2)
	{
		// Have an object already selected
		for(int i = 0; i < m_List.GetItemCount(); i++)
			if(m_List.GetItemData(i) == m_pSelectedObject)
				m_List.SetItemState(i,LVIS_SELECTED, LVIS_SELECTED);
	}

	if(m_aceIndex != -1)
	{
		PreChangeStep();
		m_iStep = 2;
		int aceIndex = m_aceIndex;

		ChangeStep();
		if(m_childid != 0)
		{
			CObjType* pType = application->FindObjTypeFromNumber(m_pSelectedObject);
			if(pType)
			{
				int index = 1;
				list<CBehavior>::iterator i = pType->behaviors.begin();
				list<CBehavior>::iterator end = pType->behaviors.end();

				for(; i!= end; i++)
				{
					if(i->id == m_childid)
					{
						m_Tabs.SelectionSet(index);
						break;
					}

					index ++;
				}

				list<CEffect>::iterator e = pType->effects.begin();
				for(;e!= pType->effects.end(); e++)
				{
					if(e->m_effectID == -m_childid)				
						m_Tabs.SelectionSet(index);

					index ++;
				}
			}

			ChangeStep();
		}

		m_aceIndex = aceIndex;

		for(int i = 0; i < m_ACEList.GetItemCount(); i++)
		{
			if(m_ACEList.GetItemData(i) == m_aceIndex)
				m_ACEList.SetItemState(i,LVIS_SELECTED, LVIS_SELECTED);
		}		
	}

	if(initStep != m_iStep)
	{
		PreChangeStep();
		m_iStep = initStep;
		ChangeStep();
	}

	UpdateButtons();

	// Expression dialogs will move slightly to make it clear it's on top of the existing parameters dialog.
	if (m_aceType == EXPRESSION) {
		RECT rc;
		this->GetWindowRect(&rc);
		rc.left += 50;
		rc.top += 50;
		this->SetWindowPos(NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE);
	}

	// New drawing code
	LOGFONT* m_pLF;
	m_pLF=(LOGFONT*)calloc(1,sizeof(LOGFONT));
	strncpy(m_pLF->lfFaceName,"Segoe UI",9);
	m_pLF->lfHeight=14;
	m_pLF->lfWeight=600;
	m_pLF->lfItalic=0;
	m_pLF->lfUnderline=0;
	m_FontBold.CreateFontIndirect(m_pLF);

	m_pLF->lfWeight = 0;
	m_Font.CreateFontIndirect(m_pLF);

	m_Find.SetIcon(IDI_SEARCH);

	return FALSE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}