コード例 #1
0
ファイル: ctriggerlist.cpp プロジェクト: FractalBobz/kmuddy
cTriggerList::cTriggerList ()
  : cList ("triggers")
{
  // create properties
  // basic ones
  addStringProperty ("pattern", "Matching pattern");
  addIntProperty ("newtext-count", "Replacement line count", 0);
  // then we have a "newtext-"+i string for each
  addIntProperty ("matching", "Comparison type", int(cPattern::substring));
  addStringProperty ("condition", "Matching condition");

  // script
  addStringProperty ("script", "Script to execute");

  // options
  addBoolProperty ("cs", "Case sensitive", true);
  addBoolProperty ("dont-send", "Don't send", false);
  addBoolProperty ("whole-words", "Whole words", true);
  addBoolProperty ("global", "Global matching", false);
  addIntProperty ("action-matched", "Action if matched", (int) cList::Stop);
  addIntProperty ("action-not-matched", "Action if not matched", (int) cList::Continue);

  // colorizations
  addBoolProperty ("colorize", "Color trigger", false);
  addIntProperty ("colorize-count", "Colorization count", 0);
  // then we have a "colorize-variable-"+i - which variable is affected
  // "colorize-fg-"+i - foreground color
  // "colorize-bg-"+i - background color
  // the FG and BG numbers: positive means a RGB value (subtract 1 to get real value), negative means a color from the ANSI set (add 16 to get the real color), 0 means no change

  // special triggers
  addBoolProperty ("rewrite", "Rewrite trigger", false);
  addStringProperty ("rewrite-var", "Rewrite variable");
  addStringProperty ("rewrite-text", "Rewrite new text");

  addBoolProperty ("gag", "Gag trigger", false);
  addBoolProperty ("notify", "Notify trigger", false);
  addBoolProperty ("prompt", "Prompt detection trigger", false);
  addBoolProperty ("sound", "Sound trigger", false);
  addStringProperty ("sound-file", "Sound file name");

  addBoolProperty ("output-window", "Send output to separate window", false);
  addBoolProperty ("output-gag-in-main", "Gag main window in favour of output", false);
  addStringProperty ("output-window-name", "Output window name");
  
  d = new Private;

  d->detectingPrompt = false;
  d->curline = 0;
}
コード例 #2
0
ファイル: cgenericlist.cpp プロジェクト: FractalBobz/kmuddy
void cGenericList::stringProperty (const QString &name, QString defaultValue)
{
  addStringProperty (name, QString(), defaultValue);
}
コード例 #3
0
/* MapObjectPropsPanel::addUDMFProperty
 * Adds the UDMF property [prop] to the grid, under [basegroup]. Will
 * add the correct property cell type for the UDMF property
 *******************************************************************/
void MapObjectPropsPanel::addUDMFProperty(UDMFProperty* prop, int objtype, string basegroup, wxPropertyGrid* grid)
{
	// Check property was given
	if (!prop)
		return;

	// Set grid to add to (main one if grid is NULL)
	if (!grid)
		grid = pg_properties;

	// Determine group name
	string groupname;
	if (!basegroup.IsEmpty())
		groupname = basegroup + ".";
	groupname += prop->getGroup();

	// Get group to add
	wxPGProperty* group = grid->GetProperty(groupname);
	if (!group)
		group = grid->Append(new wxPropertyCategory(prop->getGroup(), groupname));

	// Determine property name
	string propname;
	if (!basegroup.IsEmpty())
		propname = basegroup + ".";
	propname += prop->getProperty();

	// Add property depending on type
	//MOPGProperty* mopg_prop = NULL;
	if (prop->getType() == UDMFProperty::TYPE_BOOL)
		addBoolProperty(group, prop->getName(), propname, false, grid, prop);
	else if (prop->getType() == UDMFProperty::TYPE_INT)
		addIntProperty(group, prop->getName(), propname, false, grid, prop);
	else if (prop->getType() == UDMFProperty::TYPE_FLOAT)
		addFloatProperty(group, prop->getName(), propname, false, grid, prop);
	else if (prop->getType() == UDMFProperty::TYPE_STRING)
		addStringProperty(group, prop->getName(), propname, false, grid, prop);
	else if (prop->getType() == UDMFProperty::TYPE_COLOUR)
	{
		MOPGColourProperty* prop_col = new MOPGColourProperty(prop->getName(), propname);
		prop_col->setParent(this);
		prop_col->setUDMFProp(prop);
		properties.push_back(prop_col);
		grid->AppendIn(group, prop_col);
	}
	else if (prop->getType() == UDMFProperty::TYPE_ASPECIAL)
	{
		MOPGActionSpecialProperty* prop_as = new MOPGActionSpecialProperty(prop->getName(), propname);
		prop_as->setParent(this);
		prop_as->setUDMFProp(prop);
		properties.push_back(prop_as);
		grid->AppendIn(group, prop_as);
	}
	else if (prop->getType() == UDMFProperty::TYPE_SSPECIAL)
	{
		MOPGSectorSpecialProperty* prop_ss = new MOPGSectorSpecialProperty(prop->getName(), propname);
		prop_ss->setParent(this);
		prop_ss->setUDMFProp(prop);
		properties.push_back(prop_ss);
		grid->AppendIn(group, prop_ss);
	}
	else if (prop->getType() == UDMFProperty::TYPE_TTYPE)
	{
		MOPGThingTypeProperty* prop_tt = new MOPGThingTypeProperty(prop->getName(), propname);
		prop_tt->setParent(this);
		prop_tt->setUDMFProp(prop);
		properties.push_back(prop_tt);
		grid->AppendIn(group, prop_tt);
	}
	else if (prop->getType() == UDMFProperty::TYPE_ANGLE)
	{
		MOPGAngleProperty* prop_angle = new MOPGAngleProperty(prop->getName(), propname);
		prop_angle->setParent(this);
		prop_angle->setUDMFProp(prop);
		properties.push_back(prop_angle);
		grid->AppendIn(group, prop_angle);
	}
	else if (prop->getType() == UDMFProperty::TYPE_TEX_WALL)
		addTextureProperty(group, prop->getName(), propname, 0, false, grid, prop);
	else if (prop->getType() == UDMFProperty::TYPE_TEX_FLAT)
		addTextureProperty(group, prop->getName(), propname, 1, false, grid, prop);
	else if (prop->getType() == UDMFProperty::TYPE_ID)
	{
		int tagtype;
		if (objtype == MOBJ_LINE)
			tagtype = MOPGTagProperty::TT_LINEID;
		else if (objtype == MOBJ_THING)
			tagtype = MOPGTagProperty::TT_THINGID;
		else
			tagtype = MOPGTagProperty::TT_SECTORTAG;

		MOPGTagProperty* prop_id = new MOPGTagProperty(tagtype, prop->getName(), propname);
		prop_id->setParent(this);
		prop_id->setUDMFProp(prop);
		properties.push_back(prop_id);
		grid->AppendIn(group, prop_id);
	}

	/*if (mopg_prop) {
		mopg_prop->setParent(this);
		mopg_prop->setUDMFProp(prop);
		properties.push_back(mopg_prop);
		grid->AppendIn(group, (wxPGProperty*)mopg_prop);
	}*/
}
コード例 #4
0
/* MapObjectPropsPanel::openObject
 * Populates the grid with properties for all MapObjects in [objects]
 *******************************************************************/
void MapObjectPropsPanel::openObjects(vector<MapObject*>& objects)
{
	// Check any objects were given
	if (objects.size() == 0 || objects[0] == NULL)
	{
		this->objects.clear();
		pg_properties->DisableProperty(pg_properties->GetGrid()->GetRoot());
		pg_properties->SetPropertyValueUnspecified(pg_properties->GetGrid()->GetRoot());
		pg_properties->Refresh();
		pg_props_side1->DisableProperty(pg_props_side1->GetGrid()->GetRoot());
		pg_props_side1->SetPropertyValueUnspecified(pg_props_side1->GetGrid()->GetRoot());
		pg_props_side1->Refresh();
		pg_props_side2->DisableProperty(pg_props_side2->GetGrid()->GetRoot());
		pg_props_side2->SetPropertyValueUnspecified(pg_props_side2->GetGrid()->GetRoot());
		pg_props_side2->Refresh();

		return;
	}
	else
		pg_properties->EnableProperty(pg_properties->GetGrid()->GetRoot());

	// Setup property grid for the object type
	if (theMapEditor->currentMapDesc().format == MAP_UDMF)
		setupTypeUDMF(objects[0]->getObjType());
	else
		setupType(objects[0]->getObjType());

	// Find any custom properties (UDMF only)
	if (theMapEditor->currentMapDesc().format == MAP_UDMF)
	{
		for (unsigned a = 0; a < objects.size(); a++)
		{
			// Go through object properties
			vector<MobjPropertyList::prop_t> objprops = objects[a]->props().allProperties();
			for (unsigned b = 0; b < objprops.size(); b++)
			{
				// Ignore side property
				if (objprops[b].name.StartsWith("side1.") || objprops[b].name.StartsWith("side2."))
					continue;

				// Check if hidden
				if (VECTOR_EXISTS(hide_props, objprops[b].name))
					continue;

				// Check if property is already on the list
				bool exists = false;
				for (unsigned c = 0; c < properties.size(); c++)
				{
					if (properties[c]->getPropName() == objprops[b].name)
					{
						exists = true;
						break;
					}
				}

				if (!exists)
				{
					// Create custom group if needed
					if (!group_custom)
						group_custom = pg_properties->Append(new wxPropertyCategory("Custom"));

					//LOG_MESSAGE(2, "Add custom property \"%s\"", objprops[b].name);

					// Add property
					switch (objprops[b].value.getType())
					{
					case PROP_BOOL:
						addBoolProperty(group_custom, objprops[b].name, objprops[b].name); break;
					case PROP_INT:
						addIntProperty(group_custom, objprops[b].name, objprops[b].name); break;
					case PROP_FLOAT:
						addFloatProperty(group_custom, objprops[b].name, objprops[b].name); break;
					default:
						addStringProperty(group_custom, objprops[b].name, objprops[b].name); break;
					}
				}
			}
		}
	}

	// Generic properties
	for (unsigned a = 0; a < properties.size(); a++)
		properties[a]->openObjects(objects);

	// Handle line sides
	if (objects[0]->getObjType() == MOBJ_LINE)
	{
		// Enable/disable side properties
		wxPGProperty* prop = pg_properties->GetProperty("sidefront");
		if (prop && (prop->IsValueUnspecified() || prop->GetValue().GetInteger() >= 0))
			pg_props_side1->EnableProperty(pg_props_side1->GetGrid()->GetRoot());
		else
		{
			pg_props_side1->DisableProperty(pg_props_side1->GetGrid()->GetRoot());
			pg_props_side1->SetPropertyValueUnspecified(pg_props_side1->GetGrid()->GetRoot());
		}
		prop = pg_properties->GetProperty("sideback");
		if (prop && (prop->IsValueUnspecified() || prop->GetValue().GetInteger() >= 0))
			pg_props_side2->EnableProperty(pg_props_side2->GetGrid()->GetRoot());
		else
		{
			pg_props_side2->DisableProperty(pg_props_side2->GetGrid()->GetRoot());
			pg_props_side2->SetPropertyValueUnspecified(pg_props_side2->GetGrid()->GetRoot());
		}
	}

	// Update internal objects list
	if (&objects != &this->objects)
	{
		this->objects.clear();
		for (unsigned a = 0; a < objects.size(); a++)
			this->objects.push_back(objects[a]);
	}

	// Possibly update the argument names and visibility
	updateArgs(NULL);

	pg_properties->Refresh();
	pg_props_side1->Refresh();
	pg_props_side2->Refresh();
}
コード例 #5
0
/* MapObjectPropsPanel::onBtnAdd
 * Called when the add property button is clicked
 *******************************************************************/
void MapObjectPropsPanel::onBtnAdd(wxCommandEvent& e)
{
	wxDialog dlg(this, -1, "Add UDMF Property");

	// Setup dialog sizer
	wxBoxSizer* msizer = new wxBoxSizer(wxVERTICAL);
	dlg.SetSizer(msizer);
	wxGridBagSizer* sizer = new wxGridBagSizer(10, 10);
	msizer->Add(sizer, 1, wxEXPAND|wxALL, 10);

	// Name
	wxTextCtrl* text_name = new wxTextCtrl(&dlg, -1, "");
	sizer->Add(new wxStaticText(&dlg, -1, "Name:"), wxGBPosition(0, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
	sizer->Add(text_name, wxGBPosition(0, 1), wxDefaultSpan, wxEXPAND);

	// Type
	string types[] ={ "Boolean", "String", "Integer", "Float", "Angle", "Texture (Wall)", "Texture (Flat)", "Colour" };
	wxChoice* choice_type = new wxChoice(&dlg, -1, wxDefaultPosition, wxDefaultSize, 7, types);
	choice_type->SetSelection(0);
	sizer->Add(new wxStaticText(&dlg, -1, "Type:"), wxGBPosition(1, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
	sizer->Add(choice_type, wxGBPosition(1, 1), wxDefaultSpan, wxEXPAND);

	// Buttons
	sizer->Add(dlg.CreateButtonSizer(wxOK|wxCANCEL), wxGBPosition(2, 0), wxGBSpan(1, 2), wxEXPAND);

	// Show dialog
	dlg.Layout();
	dlg.Fit();
	dlg.CenterOnParent();
	if (dlg.ShowModal() == wxID_OK)
	{
		// Create custom group if needed
		if (!group_custom)
			group_custom = pg_properties->Append(new wxPropertyCategory("Custom"));

		// Get name entered
		string propname = text_name->GetValue().Lower();
		if (propname == "" || propname.Contains(" "))	// TODO: Proper regex check
		{
			wxMessageBox("Invalid property name", "Error");
			return;
		}

		// Check if existing
		for (unsigned a = 0; a < properties.size(); a++)
		{
			if (properties[a]->getPropName() == propname)
			{
				wxMessageBox(S_FMT("Property \"%s\" already exists", propname), "Error");
				return;
			}
		}

		// Add property
		if (choice_type->GetSelection() == 0)
			addBoolProperty(group_custom, propname, propname);
		else if (choice_type->GetSelection() == 1)
			addStringProperty(group_custom, propname, propname);
		else if (choice_type->GetSelection() == 2)
			addIntProperty(group_custom, propname, propname);
		else if (choice_type->GetSelection() == 3)
			addFloatProperty(group_custom, propname, propname);
		else if (choice_type->GetSelection() == 4)
		{
			MOPGAngleProperty* prop_angle = new MOPGAngleProperty(propname, propname);
			prop_angle->setParent(this);
			properties.push_back(prop_angle);
			pg_properties->AppendIn(group_custom, prop_angle);
		}
		else if (choice_type->GetSelection() == 5)
			addTextureProperty(group_custom, propname, propname, 0);
		else if (choice_type->GetSelection() == 6)
			addTextureProperty(group_custom, propname, propname, 1);
		else if (choice_type->GetSelection() == 7)
		{
			MOPGColourProperty* prop_col = new MOPGColourProperty(propname, propname);
			prop_col->setParent(this);
			properties.push_back(prop_col);
			pg_properties->AppendIn(group_custom, prop_col);
		}
	}
}