Ejemplo n.º 1
0
void CSiteGroupsTree::Initialize(CSiteCheckDlg::Hook & checkHook, CSiteList & siteList)
{
    // Initialize settings

    XML::CXML params;
    WebWatch::Store::Instance().GetSiteGroupsTreeSettings(params);

    ASSERT(strcmp(params.GetTagName(), GetXMLName()) == 0);

    // Color initialization
    XML::CXML *colors = params.FindFirstChild(Colors::GetXMLName());
    if (colors)
        m_colors.reset(new Colors(*colors));
    else
        m_colors.reset(new Colors);

    // NOTE: SetTextColor() not really needed
    SetTextColor(m_colors->regular.color);

    // Rest of initialization...

    m_siteList = &siteList;
    m_siteListHook.reset(new SiteListHook(*this));
    m_siteList->AttachHook(*m_siteListHook);

    m_checkHook = &checkHook;

    WebWatch::SiteItemGroup & defaultGroup = BuildTree();
    SelectGroup(defaultGroup);

    InitializeMenus();
}
Ejemplo n.º 2
0
void __fastcall TObjFrm::AddCombo(int gr,int id,String Title,int vid,bool enable)
{
TGroupBox *g=SelectGroup(gr);
int h=g->Height;
TLabel *l=new TLabel(this);
l->Parent=g;
l->AutoSize=true;
l->Caption=Title;
l->Top=h+VCSP;
TComboBox *c=new TComboBox(this);
c->Parent=g;
c->Style=csDropDownList;
c->Top=h;
c->Tag=id;
Dict->TextPropByClasses(c->Items,id);
for (int i=0;i<c->Items->Count;i++)
    {
    TTextPropRec *rec=(TTextPropRec*)c->Items->Objects[i];
    if (rec->Id==vid)
        {
        c->ItemIndex=i;
        break;
        }
    }
c->Anchors=c->Anchors<<akRight;
c->OnChange=ElemChange;
c->Enabled=enable;
g->Height=h+c->Height+VERTSP;
AlignGroup(gr);
AddRef(c,id);
}
Ejemplo n.º 3
0
void Configuration::OnRenameGroup(wxCommandEvent& /*event*/)
{
  wxString GroupName = m_Groups->GetStringSelection();
  wxString OldName = GroupName;
  if ( GroupName.IsEmpty() )
    return;
  GroupName = ::wxGetTextFromUser(_("Enter new group name"),_("Change group name"),GroupName);
  if ( GroupName.IsEmpty() )
    return;
  int Index = m_Groups->FindString(GroupName);

  if ( Index != wxNOT_FOUND && Index != m_Groups->GetSelection() )
  {
    cbMessageBox(_("Group with this name already exists."),_T("Header Fixup"));
    return;
  }

  for ( size_t i=0; i<GroupName.Length(); i++ )
  {
    if ( wxString(g_alpha_numeric_chars).Find(GroupName.GetChar(i)) == wxNOT_FOUND )
    {
      cbMessageBox(_("Inalid group name, please use only alphanumeric characters or '_'."),_T("Header Fixup"));
      return;
    }
  }

  m_Groups->SetString(m_Groups->GetSelection(),GroupName);
  m_Bindings.m_Groups[GroupName] = m_Bindings.m_Groups[OldName];
  m_Bindings.m_Groups.erase(OldName);
  m_Groups->SetClientData(m_Groups->GetSelection(), (void*) &(m_Bindings.m_Groups[GroupName]) );
  SelectGroup(m_Groups->GetSelection());

  m_Dirty = true;
}// OnRenameGroup
Ejemplo n.º 4
0
void Configuration::OnBtnAddGroupClick(wxCommandEvent& /*event*/)
{
  wxString GroupName = ::wxGetTextFromUser(_("Enter name for new group"));
  if ( GroupName.IsEmpty() )
    return;

  if ( m_Groups->FindString(GroupName) != wxNOT_FOUND )
  {
    cbMessageBox(_("Group with this name already exists."),_T("Header Fixup"));
    return;
  }

  for ( size_t i=0; i<GroupName.Length(); i++ )
  {
    if ( wxString(g_alpha_numeric_chars).Find(GroupName.GetChar(i)) == wxNOT_FOUND )
    {
      cbMessageBox(_("Invalid group name, please use only alphanumeric characters or '_'."),_T("Header Fixup"));
      return;
    }
  }

  Bindings::MappingsT& Map = m_Bindings.m_Groups[GroupName];
  SelectGroup(m_Groups->Append(GroupName,(void*)&Map));

  m_Dirty = true;
}// OnBtnAddGroupClick
Ejemplo n.º 5
0
void Configuration::ShowGroups()
{
  m_Groups->Clear();
  for ( Bindings::GroupsT::iterator i = m_Bindings.m_Groups.begin(); i != m_Bindings.m_Groups.end(); ++i )
    m_Groups->Append(i->first, (void*) &(i->second) );

  SelectGroup(0);
}// ShowGroups
Ejemplo n.º 6
0
void CSiteGroupsTree::OnSiteGroupRemove()
{
    // Ask user whether to delete the selected group or not

    ASSERT(m_actionGroup);
    ASSERT(WebWatch::Store::Instance().IsRootGroup(*m_actionGroup) == false);

    CWnd *parent = GetParent();
    ASSERT(parent);

    std::string query("Are you sure you want to remove the group '");
    query += m_actionGroup->GetName();
    query += "' ?";

    UINT ret = parent->MessageBox(query.c_str(), "Remove group?", MB_YESNO | MB_ICONQUESTION);

    if (ret == IDNO)
        return;

    // Remove group
    
    // Gather all groups to remove from tree

    typedef std::vector<WebWatch::SiteItemGroup *> Groups;
    Groups groupsToRemove(1, m_actionGroup);
    groupsToRemove.reserve(m_actionGroup->GetGroupCount() + groupsToRemove.size());
    WebWatch::GatherChildGroups(*m_actionGroup, std::back_inserter(groupsToRemove));

    // Make sure site list is in stable state

    ASSERT(m_siteList);
    WebWatch::SiteItemGroup dummy("Dummy");
    m_siteList->SetSiteItemGroup(dummy);

    SetRedraw(FALSE);

    // Delete actual group and its sub-groups

    WebWatch::SiteItemGroup *parentGroup = m_actionGroup->GetParentGroup();
    ASSERT(parentGroup);

    parentGroup->DeleteGroup(*m_actionGroup);

    // Remove groups/items from tree and update tree

    std::for_each(groupsToRemove.begin(), groupsToRemove.end(), GroupRemover(*this));

    UpdateTree();

    SetRedraw();

    SelectGroup(*parentGroup, true);
}
Ejemplo n.º 7
0
void Configuration::OnBtnDeleteGroupClick(wxCommandEvent& /*event*/)
{
  if ( cbMessageBox(_("Are you sure?"),_("Deleting group"),wxYES|wxNO) != wxID_YES )
    return;
  wxString GroupName = m_Groups->GetStringSelection();
  if ( GroupName.IsEmpty() )
    return;
  m_Groups->Delete(m_Groups->GetSelection());
  m_Bindings.m_Groups.erase(GroupName);
  SelectGroup(m_Groups->GetSelection());

  m_Dirty = true;
}// OnBtnDeleteGroupClick
Ejemplo n.º 8
0
void UUnrealEdEngine::SelectGroup(AGroupActor* InGroupActor, bool bForceSelection/*=false*/, bool bInSelected/*=true*/, bool bNotify/*=true*/)
{
	USelection* SelectedActors = GetSelectedActors();
	SelectedActors->BeginBatchSelectOperation();
	SelectedActors->Modify();

	static bool bIteratingGroups = false;

	if( !bIteratingGroups )
	{
		bIteratingGroups = true;
		// Select all actors within the group (if locked or forced)
		if( bForceSelection || InGroupActor->IsLocked() )
		{	
			TArray<AActor*> GroupActors;
			InGroupActor->GetGroupActors(GroupActors);
			for( int32 ActorIndex=0; ActorIndex < GroupActors.Num(); ++ActorIndex )
			{                  
				SelectActor(GroupActors[ActorIndex], bInSelected, false );
			}
			bForceSelection = true;

			// Recursively select any subgroups
			TArray<AGroupActor*> SubGroups;
			InGroupActor->GetSubGroups(SubGroups);
			for( int32 GroupIndex=0; GroupIndex < SubGroups.Num(); ++GroupIndex )
			{
				SelectGroup(SubGroups[GroupIndex], bForceSelection, bInSelected, false);
			}
		}

		SelectedActors->EndBatchSelectOperation(bNotify);
		if (bNotify)
		{
			NoteSelectionChange();
		}

		//whenever selection changes, recompute whether the selection contains a locked actor
		bCheckForLockActors = true;

		//whenever selection changes, recompute whether the selection contains a world info actor
		bCheckForWorldSettingsActors = true;

		bIteratingGroups = false;
	}
}
Ejemplo n.º 9
0
void CSiteGroupsTree::OnSiteGroupMove()
{
    ASSERT(m_actionGroup);
    MoveChooseGroupHook hook(*m_actionGroup);
    CChooseGroupDlg dlg(WebWatch::Store::Instance().GetRootGroup(), &hook, GetParent());

    if (dlg.DoModal() != IDOK)
        return;

    WebWatch::SiteItemGroup *group = dlg.GetChosenGroup();
    if (group == 0)
        return;

    group->MoveGroup(*m_actionGroup);
    
    BuildTree();
    SelectGroup(*m_actionGroup, true);
}
Ejemplo n.º 10
0
void __fastcall TObjFrm::AddMask(int gr,int id,String Title,String Mask,String Val)
{
TGroupBox *g=SelectGroup(gr);
int h=g->Height;
TLabel *l=new TLabel(this);
l->Parent=g;
l->AutoSize=true;
l->Caption=Title;
l->Top=h+VCSP;
TMaskEdit *m=new TMaskEdit(this);
m->Parent=g;
m->Top=h;
m->EditMask=Mask;
m->Text=Val;
m->OnChange=ElemChange;
m->Anchors=m->Anchors<<akRight;
g->Height=h+m->Height+VERTSP;
AddRef(m,id);
}
Ejemplo n.º 11
0
void CSiteGroupsTree::OnSiteGroupMergeWithGroup()
{
    ASSERT(m_actionGroup);
    MergeChooseGroupHook hook(*m_actionGroup);
    CChooseGroupDlg dlg(WebWatch::Store::Instance().GetRootGroup(), &hook, GetParent());

    if (dlg.DoModal() != IDOK)
        return;

    WebWatch::SiteItemGroup *group = dlg.GetChosenGroup();
    if (group == 0)
        return;

    group->MergeGroup(*m_actionGroup);

    BuildTree();
    
    // The action group no longer exists, it was merged onto 'group'
    SelectGroup(*group, true); 
}
Ejemplo n.º 12
0
void CSiteGroupsTree::OnLButtonUp(UINT flags, CPoint point)
{
    CTreeCtrl::OnLButtonUp(flags, point);

    if (m_isDragging == false)
        return;

    // User is dropping an item

    m_isDragging = false;
    CImageList::DragLeave(this);
    CImageList::EndDrag();
    ReleaseCapture();
    m_dragImageList.reset(0);
    SelectDropTarget(0);

    // Determine whether dropping the item has an effect
    
    // Here we allow a group to be dropped on itself without any effect and without any
    // error message
    if ((m_draggedItem == m_droppedItem) || (m_droppedItem == 0))
        return;

    if (IsDroppableItem(m_draggedItem) == false)
        return;

    WebWatch::SiteItemGroup & draggedGroup = GetGroupFromItem(m_draggedItem);
    WebWatch::SiteItemGroup & droppedGroup = GetGroupFromItem(m_droppedItem);

    if (WebWatch::IsChildOf(draggedGroup, droppedGroup) == true) {
        GetParent()->MessageBox("Cannot move a group into one of its child groups", "Error", MB_OK | MB_ICONERROR);
        return;
    }

    // Do the actual moving
    
    droppedGroup.MoveGroup(draggedGroup);
    
    BuildTree();
    SelectGroup(draggedGroup, true);
}
Ejemplo n.º 13
0
void __fastcall TObjFrm::AddText(int gr,int id,String Title,String Val,bool enable)
{
TGroupBox *g=SelectGroup(gr);
int h=g->Height;
TLabel *l=new TLabel(this);
l->Parent=g;
l->AutoSize=true;
l->Caption=Title;
l->Top=h+VCSP;
TEdit *m=new TEdit(this);
m->Parent=g;
m->Top=h;
m->Text=Val;
m->Anchors=m->Anchors<<akRight;
m->OnChange=ElemChange;
m->Enabled=enable;

g->Height=h+m->Height+VERTSP;
AlignGroup(gr);
AddRef(m,id);
}
Ejemplo n.º 14
0
void __fastcall TObjFrm::AddCheckBox(int gr,int id,String Title,int Val,bool enable)
{
TGroupBox *g=SelectGroup(gr);
int h=g->Height;
TLabel *l=new TLabel(this);
l->Parent=g;
l->AutoSize=true;
l->Caption=Title;
l->Top=h+VCSP;
TCheckBox *c=new TCheckBox(this);
c->Parent=g;
c->Top=h;
c->Checked=Val;
c->Anchors=c->Anchors<<akRight;
c->OnClick=ElemChange;
c->Enabled=enable;

g->Height=h+c->Height+VERTSP;
AlignGroup(gr);
AddRef(c,id);
}
Ejemplo n.º 15
0
//-----------------------------------------------------------------------------
// Places Detail Objects on a face
//-----------------------------------------------------------------------------
static void EmitDetailObjectsOnDisplacementFace( dface_t* pFace, 
						DetailObject_t& detail, CCoreDispInfo& coreDispInfo )
{
	assert(pFace->numedges == 4);

	// We're going to pick a bunch of random points, and then probabilistically
	// decide whether or not to plant a detail object there.

	// Compute the area of the base face
	float area = ComputeDisplacementFaceArea( pFace );

	// Compute the number of samples to take
	int numSamples = area * detail.m_Density * 0.000001;

	// Now take a sample, and randomly place an object there
	for (int i = 0; i < numSamples; ++i )
	{
		// Create a random sample...
		float u = rand() / (float)RAND_MAX;
		float v = rand() / (float)RAND_MAX;

		// Compute alpha
		float alpha;
		Vector pt, normal;
		coreDispInfo.GetPositionOnSurface( u, v, pt, &normal, &alpha );
		alpha /= 255.0f;

		// Select a group based on the alpha value
		int group = SelectGroup( detail, alpha );

		// Now that we've got a group, choose a detail
		int model = SelectDetail( detail.m_Groups[group] );
		if (model < 0)
			continue;

		// Got a detail! Place it on the surface...
		PlaceDetail( detail.m_Groups[group].m_Models[model], pt, normal );
	}
}
Ejemplo n.º 16
0
void __fastcall TObjFrm::AlignGroup(int n)
{
Constraints->MinHeight=0;
Constraints->MaxHeight=0;
TGroupBox *g=SelectGroup(n);
int maxwid=0;
for (int i=0;i<g->ControlCount;i++)
    {
    TLabel *l=dynamic_cast<TLabel*>(g->Controls[i]);
    if (l)
        if (maxwid<l->Width)
            maxwid=l->Width;
    }
for (int i=0;i<g->ControlCount;i++)
    {
    TLabel *l=dynamic_cast<TLabel*>(g->Controls[i]);
    if (l)
        l->Left=LEFTSP+maxwid-l->Width;
    else
        {
        TControl *c=dynamic_cast<TControl*>(g->Controls[i]);
        if (c)
            {
            c->Left=LEFTSP+maxwid+TABSP;
            c->Width=g->Width-LEFTSP-maxwid-TABSP-RIGHTSP;
            }
        }
    }
Height=CGroup->Height+ChrGroup->Height+PlaceGroup->Height+70;
Button1->Top=TabSheet1->ClientHeight-5-Button1->Height;
Button2->Top=TabSheet1->ClientHeight-5-Button2->Height;
Button3->Top=TabSheet2->ClientHeight-5-Button3->Height;
Button4->Top=TabSheet2->ClientHeight-5-Button4->Height;
DocListBox->Width=TabSheet2->ClientWidth-2*DocListBox->Left;
DocListBox->Height=CGroup->Height;//+ChrGroup->Height+PlaceGroup->Height;
Constraints->MinHeight=Height;
Constraints->MaxHeight=Height;
}
Ejemplo n.º 17
0
void CSelectedUnits::GiveCommand(Command c, bool fromUser)
{
	GML_RECMUTEX_LOCK(sel); // GiveCommand
	GML_RECMUTEX_LOCK(group); // GiveCommand

//	logOutput.Print("Command given %i",c.id);
	if ((gu->spectating && !gs->godMode) || selectedUnits.empty()) {
		return;
	}

	if (fromUser) {		//add some statistics
		playerHandler->Player(gu->myPlayerNum)->currentStats.numCommands++;
		if (selectedGroup!=-1) {
			playerHandler->Player(gu->myPlayerNum)->currentStats.unitCommands+=grouphandlers[gu->myTeam]->groups[selectedGroup]->units.size();
		} else {
			playerHandler->Player(gu->myPlayerNum)->currentStats.unitCommands+=selectedUnits.size();
		}
	}

	if (c.id == CMD_GROUPCLEAR) {
		for(CUnitSet::iterator ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
			if((*ui)->group){
				(*ui)->SetGroup(0);
				possibleCommandsChanged=true;
			}
		}
		return;
	}
	else if (c.id == CMD_GROUPSELECT) {
		SelectGroup((*selectedUnits.begin())->group->id);
		return;
	}
	else if (c.id == CMD_GROUPADD) {
		CGroup* group=0;
		for(CUnitSet::iterator ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
			if((*ui)->group){
				group=(*ui)->group;
				possibleCommandsChanged=true;
				break;
			}
		}
		if(group){
			for(CUnitSet::iterator ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
				if(!(*ui)->group)
					(*ui)->SetGroup(group);
			}
			SelectGroup(group->id);
		}
		return;
	}
	else if (c.id == CMD_AISELECT) {
		if (gs->noHelperAIs) {
			logOutput.Print("LuaUI control is disabled");
			return;
		}
		if(c.params[0]!=0){
			CGroup* group=grouphandlers[gu->myTeam]->CreateNewGroup();

			for(CUnitSet::iterator ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
				(*ui)->SetGroup(group);
			}
			SelectGroup(group->id);
		}
		return;
	}
	else if (c.id == CMD_TIMEWAIT) {
		waitCommandsAI.AddTimeWait(c);
		return;
	}
	else if (c.id == CMD_DEATHWAIT) {
		if (teamHandler->ActiveAllyTeams() <= 2) {
			waitCommandsAI.AddDeathWait(c);
		} else {
			logOutput.Print("DeathWait can only be used when there are 2 Ally Teams");
		}
		return;
	}
	else if (c.id == CMD_SQUADWAIT) {
		waitCommandsAI.AddSquadWait(c);
		return;
	}
	else if (c.id == CMD_GATHERWAIT) {
		waitCommandsAI.AddGatherWait(c);
		return;
	}

	SendCommand(c);

	if (!selectedUnits.empty()) {
		CUnitSet::iterator ui = selectedUnits.begin();

		int soundIdx = (*ui)->unitDef->sounds.ok.getRandomIdx();
		if (soundIdx >= 0) {
			Channels::UnitReply.PlaySample(
				(*ui)->unitDef->sounds.ok.getID(soundIdx), (*ui),
				(*ui)->unitDef->sounds.ok.getVolume(soundIdx));
		}
	}
}
Ejemplo n.º 18
0
void CSelectedUnits::GiveCommand(Command c,bool fromUser)
{
//	info->AddLine("Command given %i",c.id);
	if(gu->spectating || selectedUnits.empty())
		return;

	if(fromUser){		//add some statistics
		gs->players[gu->myPlayerNum]->currentStats->numCommands++;
		if(selectedGroup!=-1){
			gs->players[gu->myPlayerNum]->currentStats->unitCommands+=grouphandler->groups[selectedGroup]->units.size();
		} else {
			gs->players[gu->myPlayerNum]->currentStats->unitCommands+=selectedUnits.size();
		}
	}

	if(c.id==CMD_GROUPCLEAR){
		for(set<CUnit*>::iterator ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
			if((*ui)->group)
				(*ui)->SetGroup(0);
		}
		return;
	}

	if(selectedGroup!=-1 && (grouphandler->groups[selectedGroup]->ai || c.id==CMD_AISELECT)){
		grouphandler->groups[selectedGroup]->GiveCommand(c);
		return;
	}

	if(c.id==CMD_GROUPSELECT){
		SelectGroup((*selectedUnits.begin())->group->id);
		return;
	}

	if(c.id==CMD_GROUPADD){
		CGroup* group=0;
		for(set<CUnit*>::iterator ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
			if((*ui)->group){
				group=(*ui)->group;
				break;
			}
		}
		if(group){
			for(set<CUnit*>::iterator ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
				if(!(*ui)->group)
					(*ui)->SetGroup(group);
			}	
			SelectGroup(group->id);
		}
		return;
	}

	if(c.id==CMD_AISELECT){
		if(c.params[0]!=0){
			map<string,string>::iterator aai;
			int a=0;
			for(aai=grouphandler->availableAI.begin();aai!=grouphandler->availableAI.end() && a<c.params[0]-1;++aai){
				a++;
			}
			CGroup* group=grouphandler->CreateNewGroup(aai->first);

			for(set<CUnit*>::iterator ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
				(*ui)->SetGroup(group);
			}
			SelectGroup(group->id);
		}
		return;
	}
//	selectedUnitsAI.GiveCommand(c);

	SendCommand(c);

	if(!selectedUnits.empty()){
		set<CUnit*>::iterator ui = selectedUnits.begin();
		if((*ui)->unitDef->sounds.ok.id)
			sound->PlayUnitReply((*ui)->unitDef->sounds.ok.id, (*ui), (*ui)->unitDef->sounds.ok.volume, true);
	}
}
Ejemplo n.º 19
0
/**
**  Select group.
**
**  @param group  Group number to select.
*/
static void UiSelectGroup(unsigned group, GroupSelectionMode mode = SELECTABLE_BY_RECTANGLE_ONLY)
{
	SelectGroup(group, mode);
	SelectionChanged();
}
Ejemplo n.º 20
0
void CSelectedUnits::GiveCommand(Command c, bool fromUser)
{
	GML_RECMUTEX_LOCK(grpsel); // GiveCommand

//	LOG_L(L_DEBUG, "Command given %i", c.id);
	if ((gu->spectating && !gs->godMode) || selectedUnits.empty()) {
		return;
	}

	const int& cmd_id = c.GetID();

	if (fromUser) { // add some statistics
		playerHandler->Player(gu->myPlayerNum)->currentStats.numCommands++;
		if (selectedGroup != -1) {
			playerHandler->Player(gu->myPlayerNum)->currentStats.unitCommands += grouphandlers[gu->myTeam]->groups[selectedGroup]->units.size();
		} else {
			playerHandler->Player(gu->myPlayerNum)->currentStats.unitCommands += selectedUnits.size();
		}
	}

	if (cmd_id == CMD_GROUPCLEAR) {
		for (CUnitSet::iterator ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) {
			if ((*ui)->group) {
				(*ui)->SetGroup(0);
				possibleCommandsChanged = true;
			}
		}
		return;
	}
	else if (cmd_id == CMD_GROUPSELECT) {
		SelectGroup((*selectedUnits.begin())->group->id);
		return;
	}
	else if (cmd_id == CMD_GROUPADD) {
		CGroup* group = NULL;
		for (CUnitSet::iterator ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) {
			if ((*ui)->group) {
				group = (*ui)->group;
				possibleCommandsChanged = true;
				break;
			}
		}
		if (group) {
			for (CUnitSet::iterator ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) {
				if (!(*ui)->group) {
					(*ui)->SetGroup(group);
				}
			}
			SelectGroup(group->id);
		}
		return;
	}
	else if (cmd_id == CMD_TIMEWAIT) {
		waitCommandsAI.AddTimeWait(c);
		return;
	}
	else if (cmd_id == CMD_DEATHWAIT) {
		waitCommandsAI.AddDeathWait(c);
		return;
	}
	else if (cmd_id == CMD_SQUADWAIT) {
		waitCommandsAI.AddSquadWait(c);
		return;
	}
	else if (cmd_id == CMD_GATHERWAIT) {
		waitCommandsAI.AddGatherWait(c);
		return;
	}

	SendCommand(c);

	#if (PLAY_SOUNDS == 1)
	if (!selectedUnits.empty()) {
		CUnitSet::const_iterator ui = selectedUnits.begin();

		const int soundIdx = (*ui)->unitDef->sounds.ok.getRandomIdx();
		if (soundIdx >= 0) {
			Channels::UnitReply.PlaySample(
				(*ui)->unitDef->sounds.ok.getID(soundIdx), (*ui),
				(*ui)->unitDef->sounds.ok.getVolume(soundIdx));
		}
	}
	#endif
}
Ejemplo n.º 21
0
int main (int argc, char *argv[]) {
  int st;
  SimParams params;
  int max_steps = std::numeric_limits<int>::max();

  std::string within_filename, output_filename;
  po::options_description desc("Options");
  desc.add_options()
    ("help,h",  "Print help messages")
    ("group,g", po::value<std::string>()->default_value("He"),
     "Group for temperature profiles")
    ("index,n", po::value<std::string>()->default_value("index.ndx"),
     ".ndx file containing atomic indices for groups")
    ("gro", po::value<std::string>()->default_value("conf.gro"),
     ".gro file containing list of atoms/molecules")
    ("top", po::value<std::string>()->default_value("topol.top"),
     ".top file containing atomic/molecular properties")
    ("within,w",
     po::value<std::string>(&within_filename)->default_value("within.dat"),
     ".dat file specifying solvating molecules")
    ("output,o",
     po::value<std::string>(&output_filename)->default_value("qDist.txt"),
     "Output filename");

  po::variables_map vm;
  po::store(po::parse_command_line(argc, argv, desc), vm);
  po::notify(vm);
  if (vm.count("help")) {
    std::cout << desc << "\n";
    exit(EXIT_SUCCESS);
  }

  std::map<std::string, std::vector<int> > groups;
  groups = ReadNdx(vm["index"].as<std::string>());

  std::vector<Molecule> molecules = GenMolecules(vm["top"].as<std::string>(),
                                                 params);
  AtomGroup all_atoms(vm["gro"].as<std::string>(), molecules);
  AtomGroup selected_group(vm["group"].as<std::string>(),
                           SelectGroup(groups, vm["group"].as<std::string>()),
                           all_atoms);

  std::fstream within_file(within_filename.c_str());
  assert(within_file.is_open());

  arma::irowvec within = arma::zeros<arma::irowvec>(selected_group.size());
  arma::irowvec nearest = arma::zeros<arma::irowvec>(4);
  Histogram q_hist(100, 0.01);

  rvec *x_in = NULL;
  matrix box_mat;
  arma::rowvec box = arma::zeros<arma::rowvec>(DIMS);
  std::string xtc_filename = "prod.xtc";
  XDRFILE *xtc_file;
  params.ExtractTrajMetadata(strdup(xtc_filename.c_str()), (&x_in), box);
  xtc_file = xdrfile_open(strdup(xtc_filename.c_str()), "r");
  params.set_max_time(vm["max_time"].as<double>());

  arma::rowvec dx;
  arma::mat dx_near = arma::zeros<arma::mat>(4,DIMS);
  arma::rowvec r2 = arma::zeros<arma::rowvec>(selected_group.size());
  float time,prec;
  for (int step=0; step<max_steps; step++) {
    if(read_xtc(xtc_file, params.num_atoms(), &st, &time, box_mat, x_in, &prec))
      break;
    params.set_box(box_mat);
    int i = 0;
    for (std::vector<int>::iterator i_atom = selected_group.begin();
         i_atom != selected_group.end(); i_atom++, i++) {
      selected_group.set_position(i, x_in[*i_atom]);
    }
    ReadInt(within, within_file);
    for (int i_atom = 0; i_atom < selected_group.size(); ++i_atom) {
      if (!within(i_atom)) continue;
      selected_group.FindNearestk(selected_group.position(i_atom), params.box(),
                                  selected_group.index_to_molecule(i_atom), 4,
                                  dx, r2, nearest);
      int q = 0;
      for (int i_near = 0; i_near < 4; ++i_near) {
        FindDxNoShift(dx, selected_group.position(i_atom),
                      selected_group.position(i_near), box);
        dx_near.row(i_near) = arma::normalise(dx);

        for (int i_near2 = 0; i_near2 < i_near; ++i_near2) {
          double sqrt_q =
              arma::dot(dx_near.row(i_near),dx_near.row(i_near2)) + 1.0/3.0;
          q += sqrt_q*sqrt_q;
        }
      }
      q_hist.Add(q);
    }
  }
  q_hist.Print(output_filename, true);
}
Ejemplo n.º 22
0
int main (int argc, char *argv[]) {
  int st;
  SimParams params;

  enum RdfWeighting { kNone, kTotalDipole, kPermanentDipole, kInducedDipole };

  po::options_description desc("Options");
  desc.add_options()
    ("help,h",  "Print help messages")
    ("group1", po::value<std::string>()->required(),
     "Group around which rdf is centered")
    ("group2", po::value<std::string>()->required(),
     "Group for which rdf will be calculated around the positions of group 1")
    ("index,n", po::value<std::string>()->default_value("index.ndx"),
     ".ndx file containing atomic indices for groups")
    ("gro", po::value<std::string>()->default_value("conf.gro"),
     ".gro file containing list of atoms/molecules")
    ("top", po::value<std::string>()->default_value("topol.top"),
     ".top file containing atomic/molecular properties")
    ("output,o", po::value<std::string>()->default_value("rdf.txt"),
     "Name for output file.")
    ("max_time,t",
     po::value<double>()->default_value(0.0),
     "Maximum simulation time to use in calculations")
    ("rdf_weighting,w", po::value<std::string>()->default_value("none"),
     "weighting factor for rdf. Choose from 'none', 'dipole', "
     "'permanent_dipole', and 'induced_dipole'");

  po::variables_map vm;
  po::store(po::parse_command_line(argc, argv, desc), vm);
  po::notify(vm);
  if (vm.count("help")) {
    std::cout << desc << "\n";
    exit(EXIT_SUCCESS);
  }

  RdfWeighting rdf_weighting;
  bool need_field = false;
  if (vm["rdf_weighting"].as<std::string>() == "none") {
    rdf_weighting = kNone;
  } else if (vm["rdf_weighting"].as<std::string>() == "dipole") {
    rdf_weighting = kTotalDipole;
    need_field = true;
  } else if (vm["rdf_weighting"].as<std::string>() == "permanent_dipole") {
    rdf_weighting = kPermanentDipole;
  } else if (vm["rdf_weighting"].as<std::string>() == "induced_dipole") {
    rdf_weighting = kInducedDipole;
    need_field = true;
  }

  std::map<std::string, std::vector<int> > groups;
  groups = ReadNdx(vm["index"].as<std::string>());
  std::vector<Molecule> molecules = GenMolecules(vm["top"].as<std::string>(),
                                                 params);

  SystemGroup all_atoms(vm["gro"].as<std::string>(), molecules);
  SubsystemGroup *first_group_pointer =
      SubsystemGroup::MakeSubsystemGroup(
          vm["group1"].as<std::string>(),
          SelectGroup(groups, vm["group1"].as<std::string>()), all_atoms);
  SubsystemGroup &first_group = *first_group_pointer;
  SubsystemGroup *second_group_pointer =
      SubsystemGroup::MakeSubsystemGroup(
          vm["group2"].as<std::string>(),
          SelectGroup(groups, vm["group2"].as<std::string>()), all_atoms);
  SubsystemGroup &second_group = *second_group_pointer;

  rvec *x_in = NULL;
  matrix box_mat;
  arma::rowvec box = arma::zeros<arma::rowvec>(DIMS);
  std::string xtc_filename = "prod.xtc";
  XDRFILE *xtc_file;
  params.ExtractTrajMetadata(strdup(xtc_filename.c_str()), (&x_in), box);
  xtc_file = xdrfile_open(strdup(xtc_filename.c_str()), "r");
  params.set_box(box);
  params.set_max_time(vm["max_time"].as<double>());

  if (need_field)
    second_group.OpenFieldFile();

  Histogram rdf_hist(params.box(0)/2.0/0.05, 0.05);

  arma::rowvec dx, dipole;
  float time, prec;
  int step = 0;
  double avg_volume;
  for (step = 0; step < params.max_steps(); ++step) {
    if(read_xtc(xtc_file, params.num_atoms(), &st, &time, box_mat, x_in, &prec))
      break;
    params.set_box(box_mat);
    avg_volume += params.volume();

    first_group.set_positions(x_in);
    second_group.set_positions(x_in);

    if (need_field) {
      second_group.SetElectricField(all_atoms, params.box());
      if (!second_group.field_check())
        second_group.WriteElectricField();
    }
    second_group.UpdateCom();
    for (int i_other = 0; i_other < second_group.num_molecules(); ++i_other) {
      switch(rdf_weighting) {
        case kPermanentDipole:
          second_group.PermanentDipole(i_other, params.box(), dipole, true);
          dipole *= ENM_TO_D;
          break;
        case kInducedDipole:
          second_group.InducedDipole(i_other, dipole, true);
          dipole *= ENM_TO_D;
          break;
        case kTotalDipole:
          second_group.PermanentDipole(i_other, params.box(), dipole, true);
          second_group.InducedDipole(i_other, dipole);
          dipole *= ENM_TO_D;
          break;
        default:
          break;
      }
      for (int i_atom = 0; i_atom < first_group.size(); ++i_atom) {
        FindDxNoShift(dx, first_group.position(i_atom),
                      second_group.com_position(i_other), params.box());
        double distance = arma::norm(dx);
        double weight;
        if (rdf_weighting == kTotalDipole || rdf_weighting == kInducedDipole ||
            rdf_weighting == kPermanentDipole) {
          dx = arma::normalise(dx);
          weight = arma::dot(dx,dipole);
        } else {
          weight = 1.0;
        }
        rdf_hist.Add(distance, weight);
      }
    }

  }
  xdrfile_close(xtc_file);

  avg_volume /= step;
  rdf_hist.Multiply(1.0/avg_volume/step/first_group.size()/
                    second_group.num_molecules());
  rdf_hist.WeightByShellVolume();

  rdf_hist.Print(vm["output"].as<std::string>(), true);
}
Ejemplo n.º 23
0
void Configuration::OnGroupsSelect(wxCommandEvent& /*event*/)
{
  SelectGroup(m_Groups->GetSelection());
}// OnGroupsSelect
Ejemplo n.º 24
0
void CSelectedUnits::GiveCommand(Command c, bool fromUser)
{
//	logOutput.Print("Command given %i",c.id);
	if ((gu->spectating && !gs->godMode) || selectedUnits.empty()) {
		return;
	}

	if (fromUser) {		//add some statistics
		gs->players[gu->myPlayerNum]->currentStats->numCommands++;
		if (selectedGroup!=-1) {
			gs->players[gu->myPlayerNum]->currentStats->unitCommands+=grouphandlers[gu->myTeam]->groups[selectedGroup]->units.size();
		} else {
			gs->players[gu->myPlayerNum]->currentStats->unitCommands+=selectedUnits.size();
		}
	}

	if (c.id == CMD_GROUPCLEAR) {
		for(CUnitSet::iterator ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
			if((*ui)->group){
				(*ui)->SetGroup(0);
				possibleCommandsChanged=true;
			}
		}
		return;
	}
	else if (c.id == CMD_GROUPSELECT) {
		SelectGroup((*selectedUnits.begin())->group->id);
		return;
	}
	else if (c.id == CMD_GROUPADD) {
		CGroup* group=0;
		for(CUnitSet::iterator ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
			if((*ui)->group){
				group=(*ui)->group;
				possibleCommandsChanged=true;
				break;
			}
		}
		if(group){
			for(CUnitSet::iterator ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
				if(!(*ui)->group)
					(*ui)->SetGroup(group);
			}
			SelectGroup(group->id);
		}
		return;
	}
	else if (c.id == CMD_AISELECT) {
		if (gs->noHelperAIs) {
			logOutput.Print("GroupAI and LuaUI control is disabled");
			return;
		}
		if(c.params[0]!=0){
			map<AIKey,string>::iterator aai;
			int a=0;
			for(aai=grouphandlers[gu->myTeam]->lastSuitedAis.begin();aai!=grouphandlers[gu->myTeam]->lastSuitedAis.end() && a<c.params[0]-1;++aai){
				a++;
			}
			CGroup* group=grouphandlers[gu->myTeam]->CreateNewGroup(aai->first);

			for(CUnitSet::iterator ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
				(*ui)->SetGroup(group);
			}
			SelectGroup(group->id);
		}
		return;
	}
	else if (c.id == CMD_TIMEWAIT) {
		waitCommandsAI.AddTimeWait(c);
		return;
	}
	else if (c.id == CMD_DEATHWAIT) {
		if (gs->activeAllyTeams <= 2) {
			waitCommandsAI.AddDeathWait(c);
		} else {
			logOutput.Print("DeathWait can only be used when there are 2 Ally Teams");
		}
		return;
	}
	else if (c.id == CMD_SQUADWAIT) {
		waitCommandsAI.AddSquadWait(c);
		return;
	}
	else if (c.id == CMD_GATHERWAIT) {
		waitCommandsAI.AddGatherWait(c);
		return;
	}

//	FIXME:  selectedUnitsAI.GiveCommand(c);

	if ((selectedGroup != -1) && grouphandlers[gu->myTeam]->groups[selectedGroup]->ai) {
		grouphandlers[gu->myTeam]->groups[selectedGroup]->GiveCommand(c);
		return;
	}

	SendCommand(c);

	if (!selectedUnits.empty()) {
		CUnitSet::iterator ui = selectedUnits.begin();

		int soundIdx = (*ui)->unitDef->sounds.ok.getRandomIdx();
		if (soundIdx >= 0) {
			sound->PlayUnitReply(
				(*ui)->unitDef->sounds.ok.getID(soundIdx), (*ui),
				(*ui)->unitDef->sounds.ok.getVolume(soundIdx), true);
		}
	}
}
void CSelectedUnitsHandler::GiveCommand(Command c, bool fromUser)
{
	if (gu->spectating && !gs->godMode)
		return;
	if (selectedUnits.empty())
		return;

	const int cmd_id = c.GetID();

	if (fromUser) { // add some statistics
		playerHandler->Player(gu->myPlayerNum)->currentStats.numCommands++;
		if (selectedGroup != -1) {
			playerHandler->Player(gu->myPlayerNum)->currentStats.unitCommands += grouphandlers[gu->myTeam]->groups[selectedGroup]->units.size();
		} else {
			playerHandler->Player(gu->myPlayerNum)->currentStats.unitCommands += selectedUnits.size();
		}
	}

	if (cmd_id == CMD_GROUPCLEAR) {
		for (CUnitSet::iterator ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) {
			if ((*ui)->group) {
				(*ui)->SetGroup(0);
				possibleCommandsChanged = true;
			}
		}
		return;
	}
	else if (cmd_id == CMD_GROUPSELECT) {
		SelectGroup((*selectedUnits.begin())->group->id);
		return;
	}
	else if (cmd_id == CMD_GROUPADD) {
		CGroup* group = NULL;
		for (CUnitSet::iterator ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) {
			if ((*ui)->group) {
				group = (*ui)->group;
				possibleCommandsChanged = true;
				break;
			}
		}
		if (group) {
			for (CUnitSet::iterator ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) {
				if (!(*ui)->group) {
					(*ui)->SetGroup(group);
				}
			}
			SelectGroup(group->id);
		}
		return;
	}
	else if (cmd_id == CMD_TIMEWAIT) {
		waitCommandsAI.AddTimeWait(c);
		return;
	}
	else if (cmd_id == CMD_DEATHWAIT) {
		waitCommandsAI.AddDeathWait(c);
		return;
	}
	else if (cmd_id == CMD_SQUADWAIT) {
		waitCommandsAI.AddSquadWait(c);
		return;
	}
	else if (cmd_id == CMD_GATHERWAIT) {
		waitCommandsAI.AddGatherWait(c);
		return;
	}

	SendCommand(c);

	if (!selectedUnits.empty()) {
		CUnitSet::const_iterator ui = selectedUnits.begin();
		Channels::UnitReply->PlayRandomSample((*ui)->unitDef->sounds.ok, *ui);
	}
}
Ejemplo n.º 26
0
void UUnrealEdEngine::SelectActor(AActor* Actor, bool bInSelected, bool bNotify, bool bSelectEvenIfHidden, bool bForceRefresh)
{
	const bool bWarnIfLevelLocked = true;
	if( !CanSelectActor( Actor, bInSelected, bSelectEvenIfHidden, bWarnIfLevelLocked ) )
	{
		return;
	}

	bool bSelectionHandled = false;

	TArray<FEdMode*> ActiveModes;
	GLevelEditorModeTools().GetActiveModes( ActiveModes );
	for( int32 ModeIndex = 0; ModeIndex < ActiveModes.Num(); ++ModeIndex )
	{
		bSelectionHandled |= ActiveModes[ModeIndex]->Select( Actor, bInSelected );
	}

	// Select the actor and update its internals.
	if( !bSelectionHandled )
	{
		if(bInSelected)
		{
			// If trying to select an Actor spawned by a ChildACtorComponent, instead select Actor that spawned us
			if(Actor->ParentComponentActor.IsValid())
			{
				Actor = Actor->ParentComponentActor.Get();
			}
		}

		if (GEditor->bGroupingActive)
		{
			// if this actor is a group, do a group select/deselect
			AGroupActor* SelectedGroupActor = Cast<AGroupActor>(Actor);
			if (SelectedGroupActor)
			{
				SelectGroup(SelectedGroupActor, true, bInSelected, bNotify);
			}
			else
			{
				// Select/Deselect this actor's entire group, starting from the top locked group.
				// If none is found, just use the actor.
				AGroupActor* ActorLockedRootGroup = AGroupActor::GetRootForActor(Actor, true);
				if (ActorLockedRootGroup)
				{
					SelectGroup(ActorLockedRootGroup, false, bInSelected, bNotify);
				}
			}
		}

		// Don't do any work if the actor's selection state is already the selected state.
		const bool bActorSelected = Actor->IsSelected();
		if ( (bActorSelected && !bInSelected) || (!bActorSelected && bInSelected) )
		{
			if(bInSelected)
			{
				UE_LOG(LogEditorSelectUtils, Verbose,  TEXT("Selected Actor: %s"), *Actor->GetClass()->GetName());
			}
			else
			{
				UE_LOG(LogEditorSelectUtils, Verbose,  TEXT("Deselected Actor: %s"), *Actor->GetClass()->GetName() );
			}

			GetSelectedActors()->Select( Actor, bInSelected );
			if (!bInSelected)
			{
				if (GetSelectedComponentCount() > 0)
				{
					GetSelectedComponents()->Modify();
				}

				for (UActorComponent* Component : Actor->GetComponents())
				{
					GetSelectedComponents()->Deselect( Component );

					// Remove the selection override delegates from the deselected components
					auto SceneComponent = Cast<USceneComponent>(Component);
					FComponentEditorUtils::BindComponentSelectionOverride(SceneComponent, false);
				}
			}
			else
			{
				// Bind the override delegates for the components in the selected actor
				for (UActorComponent* Component : Actor->GetComponents())
				{
					auto SceneComponent = Cast<USceneComponent>(Component);
					FComponentEditorUtils::BindComponentSelectionOverride(SceneComponent, true);
				}
			}

			//A fast path to mark selection rather than reconnecting ALL components for ALL actors that have changed state
			SetActorSelectionFlags (Actor);

			if( bNotify )
			{
				NoteSelectionChange();
			}

			//whenever selection changes, recompute whether the selection contains a locked actor
			bCheckForLockActors = true;

			//whenever selection changes, recompute whether the selection contains a world info actor
			bCheckForWorldSettingsActors = true;
		}
		else
		{
			if (bNotify || bForceRefresh)
			{
				//reset the property windows.  In case something has changed since previous selection
				UpdateFloatingPropertyWindows(bForceRefresh);
			}
		}
	}
}
Ejemplo n.º 27
0
//-----------------------------------------------------------------------------
// Places Detail Objects on a face
//-----------------------------------------------------------------------------
static void EmitDetailObjectsOnFace( dface_t* pFace, DetailObject_t& detail )
{
	if (pFace->numedges < 3)
		return;

	// We're going to pick a bunch of random points, and then probabilistically
	// decide whether or not to plant a detail object there.

	// Turn the face into a bunch of polygons, and compute the area of each
	int* pSurfEdges = &dsurfedges[pFace->firstedge];
	int vertexIdx = (pSurfEdges[0] < 0);
	int firstVertexIndex = dedges[abs(pSurfEdges[0])].v[vertexIdx];
	dvertex_t* pFirstVertex = &dvertexes[firstVertexIndex];
	for (int i = 1; i < pFace->numedges - 1; ++i )
	{
		int vertexIdx = (pSurfEdges[i] < 0);
		dedge_t* pEdge = &dedges[abs(pSurfEdges[i])];

		// Compute two triangle edges
		Vector e1, e2;
		VectorSubtract( dvertexes[pEdge->v[vertexIdx]].point, pFirstVertex->point, e1 );
		VectorSubtract( dvertexes[pEdge->v[1 - vertexIdx]].point, pFirstVertex->point, e2 );

		// Compute the triangle area
		Vector areaVec;
		CrossProduct( e1, e2, areaVec );
		float normalLength = areaVec.Length();
		float area = 0.5f * normalLength;

		// Compute the number of samples to take
		int numSamples = area * detail.m_Density * 0.000001;

		// Now take a sample, and randomly place an object there
		for (int i = 0; i < numSamples; ++i )
		{
			// Create a random sample...
			float u = rand() / (float)RAND_MAX;
			float v = rand() / (float)RAND_MAX;
			if (v > 1.0f - u)
			{
				u = 1.0f - u;
				v = 1.0f - v;
				assert( u + v <= 1.0f );
			}

			// Compute alpha
			float alpha = 1.0f;

			// Select a group based on the alpha value
			int group = SelectGroup( detail, alpha );

			// Now that we've got a group, choose a detail
			int model = SelectDetail( detail.m_Groups[group] );
			if (model < 0)
				continue;

			// Got a detail! Place it on the surface...
			Vector pt, normal;
			VectorMA( pFirstVertex->point, u, e1, pt );
			VectorMA( pt, v, e2, pt );
			VectorDivide( areaVec, -normalLength, normal );

			PlaceDetail( detail.m_Groups[group].m_Models[model], pt, normal );
		}
	}
}
Ejemplo n.º 28
0
/**
**	Handle keys in command mode.
**
**	@param key	Key scancode.
**	@return		True, if key is handles; otherwise false.
*/
local int CommandKey(int key)
{
    switch( key ) {
	case '\r':
	    KeyState=KeyStateInput;
	    Input[0]='\0';
	    InputIndex=0;
	    ShowInput();
	    return 1;
	case '^':
	    UnSelectAll();
            break;
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
            if( KeyModifiers&ModifierControl ) {
                //  dirty atoi version :)
                SetGroup(Selected,NumSelected,key-48);
            } else {
                SelectGroup(key-48);
            }
            UpdateBottomPanel();
            MustRedraw|=RedrawCursor|RedrawMap|RedrawPanels;
            break;
#if 0
    IfDebug(
	case '0':
	    ++ThisPlayer;
	    if( ThisPlayer==&Players[PlayerMax] ) {
		ThisPlayer=&Players[0];
	    }
	    MustRedraw=RedrawEverything;
	    break;

	case '1':
	    --ThisPlayer;
	    if( ThisPlayer<&Players[0] ) {
		ThisPlayer=&Players[PlayerMax-1];
	    }
	    MustRedraw=RedrawEverything;
	    break;
    );
#endif
        case KeyCodePause:
	case 'P':			// If pause-key didn't work
            if(GamePaused) {
                GamePaused=0;
                SetStatusLine("Game Resumed");
	    } else {
                GamePaused=1;
                SetStatusLine("Game Paused");
	    }
	    break;

	case KeyCodeF10:
	    InterfaceState=IfaceStateMenu;
	    GamePaused=1;
	    SetStatusLine("Game Paused");
	    ProcessMenu(MENU_GAME);
	    break;

	case '+':
	    VideoSyncSpeed+=10;
	    InitVideoSync();
	    SetStatusLine("Faster");
	    break;

	case '-':
	    VideoSyncSpeed-=10;
	    InitVideoSync();
	    SetStatusLine("Slower");
	    break;

	case 'S':			// SMALL s is needed for panel
	    SaveAll();
	    break;

	case 'c':
	    if(	NumSelected==1 ) {
		MapCenter(Selected[0]->X,Selected[0]->Y);
	    }
	    break;

//	TAB toggles minimap.
//	FIXME: more...
	case '\t':
	    DebugLevel1("TAB\n");
	    MinimapWithTerrain^=1;
	    MustRedraw|=RedrawMinimap;
	    break;
	    // FIXME: shift+TAB

	case 'q':
	    Exit(0);
	case KeyCodeUp:
	    if( MapY ) {
		if( KeyModifiers&ModifierControl ) {
		    if( MapY<MapHeight/2 ) {
			MapY=0;
		    } else {
			MapY-=MapHeight/2;
		    }
		} else {
		    --MapY;
		}
		MustRedraw|=RedrawMaps|RedrawMinimapCursor;
	    }
	    break;
	case KeyCodeDown:
	    if( MapY<TheMap.Height-MapHeight ) {
		if( KeyModifiers&ModifierControl ) {
		    if( MapY<TheMap.Height-MapHeight-MapHeight/2 ) {
			MapY+=MapHeight/2;
		    } else {
			MapY=TheMap.Height-MapHeight;
		    }
		} else {
		    ++MapY;
		}
		MustRedraw|=RedrawMaps|RedrawMinimapCursor;
	    }
	    break;
	case KeyCodeLeft:
	    if( MapX ) {
		if( KeyModifiers&ModifierControl ) {
		    if( MapX<MapWidth/2 ) {
			MapX=0;
		    } else {
			MapX-=MapWidth/2;
		    }
		} else {
		    --MapX;
		}
		MustRedraw|=RedrawMaps|RedrawMinimapCursor;
	    }
	    break;
	case KeyCodeRight:
	    if( MapX<TheMap.Width-MapWidth ) {
		if( KeyModifiers&ModifierControl ) {
		    if( MapX<TheMap.Width-MapWidth-MapWidth/2 ) {
			MapX+=MapWidth/2;
		    } else {
			MapX=TheMap.Width-MapWidth;
		    }
		} else {
		    ++MapX;
		}
		MustRedraw|=RedrawMaps|RedrawMinimapCursor;
	    }
	    break;

	default:
	    DebugLevel3("Key %d\n",key);
	    return 0;
    }